ionic txrx updates
Subsystems (3)
cover ionic txrx updates
These are a few patches to do some cleanup in the packet handling and give us more flexibility in tuning performance by allowing us to put Tx handling on separate interrupts when it makes sense for particular traffic loads.
Shannon Nelson (4):
ionic: use fewer firmware doorbells on rx fill
ionic: recover from ringsize change failure
ionic: tx separate servicing
ionic: separate interrupt for Tx and Rx
.../ethernet/pensando/ionic/ionic_ethtool.c | 118 +++++++++-- .../net/ethernet/pensando/ionic/ionic_lif.c | 42 +++- .../net/ethernet/pensando/ionic/ionic_lif.h | 5 + .../net/ethernet/pensando/ionic/ionic_txrx.c | 188 ++++++++++++------ .../net/ethernet/pensando/ionic/ionic_txrx.h | 2 + 5 files changed, 267 insertions(+), 88 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/4 ionic: use fewer firmware doorbells on rx fill
We really don't need to hit the Rx queue doorbell so many times, we can wait to the end and cause a little less thrash.
--- drivers/net/ethernet/pensando/ionic/ionic_txrx.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_txrx.c +5 -10
@@ -337,9 +337,6 @@ static void ionic_rx_page_free(struct ionic_queue *q, struct page *page,__free_page (page); } -#define IONIC_RX_RING_DOORBELL_STRIDE ((1 << 5) - 1) -#define IONIC_RX_RING_HEAD_BUF_SZ 2048 -void ionic_rx_fill (struct ionic_queue *q) {struct net_device *netdev = q->lif->netdev;
@@ -351,7 +348,6 @@ void ionic_rx_fill(struct ionic_queue *q)unsigned int remain_len;unsigned int seg_len;unsigned int nfrags; -bool ring_doorbell;unsigned int i, j;unsigned int len;
@@ -366,9 +362,7 @@ void ionic_rx_fill(struct ionic_queue *q) page_info = &desc_info->pages[0 ];if (page_info->page) {/* recycle the buffer */ - ring_doorbell = ((q->head->index +1 ) & -IONIC_RX_RING_DOORBELL_STRIDE ) ==0 ; -ionic_rxq_post (q, ring_doorbell, ionic_rx_clean,NULL ); +ionic_rxq_post (q, false, ionic_rx_clean,NULL );continue ; }
@@ -407,10 +401,11 @@ void ionic_rx_fill(struct ionic_queue *q) page_info++; } - ring_doorbell = ((q->head->index +1 ) & -IONIC_RX_RING_DOORBELL_STRIDE ) ==0 ; -ionic_rxq_post (q, ring_doorbell, ionic_rx_clean,NULL ); +ionic_rxq_post (q, false, ionic_rx_clean,NULL ); } + +ionic_dbell_ring (q->lif->kern_dbpage, q->hw_type, + q->dbval | q->head->index); }static void ionic_rx_fill_cb (void *arg)
Signature · 1 line
2.17.1
PATCH 2/4 ionic: recover from ringsize change failure
In reply to Shannon NelsonIf the ringsize change fails, try restoring the previous setting.
--- .../ethernet/pensando/ionic/ionic_ethtool.c | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +22 -1
@@ -480,6 +480,8 @@ static int ionic_set_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring) {struct ionic_lif *lif =netdev_priv (netdev); +int tx_start, rx_start; +int err;if (ring->rx_mini_pending || ring->rx_jumbo_pending) {netdev_info (netdev,"Changing jumbo or mini descriptors not supported\n" );
@@ -497,7 +499,26 @@ static int ionic_set_ringparam(struct net_device *netdev, ring->rx_pending == lif->nrxq_descs)return 0 ; -return ionic_reset_queues (lif, ionic_set_ringsize, ring); + tx_start = lif->ntxq_descs; + rx_start = lif->nrxq_descs; + + err =ionic_reset_queues (lif, ionic_set_ringsize, ring); + +if (err) { +int my_err; + +netdev_warn (netdev,"Ringsize change failed, restoring ring sizes\n" ); + ring->tx_pending = tx_start; + ring->rx_pending = rx_start; + my_err =ionic_reset_queues (lif, ionic_set_ringsize, ring); + +if (my_err) { +netdev_err (netdev,"Ringsize restore failed\n" ); + err = my_err; + } + } + +return err; } static void ionic_get_channels(struct net_device *netdev,
Signature · 1 line
2.17.1
PATCH 4/4 ionic: separate interrupt for Tx and Rx
In reply to Shannon NelsonAdd the capability to split the Tx queues onto their own interrupts with their own napi contexts. This gives the opportunity for more direct control of Tx interrupt handling, such as CPU affinity and interrupt coalescing, useful for some traffic loads.
To enable, use the ethtool private flag:
ethtool --set-priv-flag enp20s0 split-q-intr on To restore defaults ethtool --set-priv-flag enp20s0 split-q-intr off
When enabled, the number of queues is cut in half in order to reuse the interrupts that have already been allocated to the device. When disabled, the queue count is restored.
--- .../ethernet/pensando/ionic/ionic_ethtool.c | 95 ++++++++++++++++--- .../net/ethernet/pensando/ionic/ionic_lif.c | 41 ++++++-- .../net/ethernet/pensando/ionic/ionic_lif.h | 3 + .../net/ethernet/pensando/ionic/ionic_txrx.c | 67 +++++++++++++ .../net/ethernet/pensando/ionic/ionic_txrx.h | 2 + 5 files changed, 187 insertions(+), 21 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +81 -14
@@ -14,6 +14,8 @@static const char ionic_priv_flags_strings[][ETH_GSTRING_LEN ] = { #define IONIC_PRIV_F_SW_DBG_STATS BIT(0)"sw-dbg-stats" , +#define IONIC_PRIV_F_SPLIT_INTR BIT(1) +"split-q-intr" , };#define IONIC_PRIV_FLAGS_COUNT ARRAY_SIZE(ionic_priv_flags_strings)
@@ -400,8 +402,7 @@ static int ionic_get_coalesce(struct net_device *netdev, {struct ionic_lif *lif =netdev_priv (netdev); -/* Tx uses Rx interrupt */ - coalesce->tx_coalesce_usecs = lif->rx_coalesce_usecs; + coalesce->tx_coalesce_usecs = lif->tx_coalesce_usecs; coalesce->rx_coalesce_usecs = lif->rx_coalesce_usecs;return 0 ;
@@ -414,7 +415,8 @@ static int ionic_set_coalesce(struct net_device *netdev,struct ionic_identity *ident;struct ionic_qcq *qcq;unsigned int i; -u32 coal; +u32 rx_coal; +u32 tx_coal; ident = &lif->ionic->ident;if (ident->dev.intr_coal_div ==0 ) {
@@ -423,26 +425,31 @@ static int ionic_set_coalesce(struct net_device *netdev,return -EIO ; } -/* Tx uses Rx interrupt, so only change Rx */ -if (coalesce->tx_coalesce_usecs != lif->rx_coalesce_usecs) { +/* Tx normally shares Rx interrupt, so only change Rx */ +if (!test_bit (IONIC_LIF_F_SPLIT_INTR , lif->state) && + coalesce->tx_coalesce_usecs != lif->rx_coalesce_usecs) {netdev_warn (netdev,"only the rx-usecs can be changed\n" );return -EINVAL ; } -/* Convert the usec request to a HW useable value. If they asked +/* Convert the usec request to a HW usable value. If they asked * for non-zero and it resolved to zero, bump it up */ - coal =ionic_coal_usec_to_hw (lif->ionic, coalesce->rx_coalesce_usecs); -if (!coal && coalesce->rx_coalesce_usecs) - coal =1 ; - -if (coal >IONIC_INTR_CTRL_COAL_MAX ) + rx_coal =ionic_coal_usec_to_hw (lif->ionic, coalesce->rx_coalesce_usecs); +if (!rx_coal && coalesce->rx_coalesce_usecs) + rx_coal =1 ; + tx_coal =ionic_coal_usec_to_hw (lif->ionic, coalesce->tx_coalesce_usecs); +if (!tx_coal && coalesce->tx_coalesce_usecs) + tx_coal =1 ; + +if (rx_coal >IONIC_INTR_CTRL_COAL_MAX || + tx_coal >IONIC_INTR_CTRL_COAL_MAX )return -ERANGE ; -/* Save the new value */ +/* Save the new values */ lif->rx_coalesce_usecs = coalesce->rx_coalesce_usecs; -if (coal != lif->rx_coalesce_hw) { - lif->rx_coalesce_hw = coal; +if (rx_coal != lif->rx_coalesce_hw) { + lif->rx_coalesce_hw = rx_coal;if (test_bit (IONIC_LIF_F_UP , lif->state)) {for (i =0 ; i < lif->nxqs; i++) {
@@ -454,6 +461,23 @@ static int ionic_set_coalesce(struct net_device *netdev, } } +if (test_bit (IONIC_LIF_F_SPLIT_INTR , lif->state)) + lif->tx_coalesce_usecs = coalesce->tx_coalesce_usecs; +else + lif->tx_coalesce_usecs = coalesce->rx_coalesce_usecs; +if (tx_coal != lif->tx_coalesce_hw) { + lif->tx_coalesce_hw = tx_coal; + +if (test_bit (IONIC_LIF_F_UP , lif->state)) { +for (i =0 ; i < lif->nxqs; i++) { + qcq = lif->txqcqs[i].qcq; +ionic_intr_coal_init (lif->ionic->idev.intr_ctrl, + qcq->intr.index, + lif->tx_coalesce_hw); + } + } + } +return 0 ; }
@@ -544,11 +568,19 @@ static int ionic_set_channels(struct net_device *netdev, struct ethtool_channels *ch) {struct ionic_lif *lif =netdev_priv (netdev); +int max_cnt;if (!ch->combined_count || ch->other_count || ch->rx_count || ch->tx_count)return -EINVAL ; + max_cnt = lif->ionic->ntxqs_per_lif; +if (test_bit (IONIC_LIF_F_SPLIT_INTR , lif->state)) + max_cnt /=2 ; + +if (ch->combined_count > max_cnt) +return -EINVAL ; +if (ch->combined_count == lif->nxqs)return 0 ;
@@ -563,17 +595,52 @@ static u32 ionic_get_priv_flags(struct net_device *netdev)if (test_bit (IONIC_LIF_F_SW_DEBUG_STATS , lif->state)) priv_flags |=IONIC_PRIV_F_SW_DBG_STATS ; +if (test_bit (IONIC_LIF_F_SPLIT_INTR , lif->state)) + priv_flags |=IONIC_PRIV_F_SPLIT_INTR ; +return priv_flags; } +static void ionic_set_split_intr (struct ionic_lif *lif,void *arg) +{ +int old_nxqs = lif->nxqs; +int new_sqintr = !!arg; + +if (new_sqintr) { +/* split the queues across the interrupts */ + lif->nxqs /=2 ; +set_bit (IONIC_LIF_F_SPLIT_INTR , lif->state); + }else { +/* combine Tx and Rx queues on the interrupts */ + lif->nxqs *=2 ; +clear_bit (IONIC_LIF_F_SPLIT_INTR , lif->state); + lif->tx_coalesce_usecs = lif->rx_coalesce_usecs; + lif->tx_coalesce_hw = lif->rx_coalesce_hw; + } + +netdev_info (lif->netdev,"%s queue interrupts and changing queue count from %d to %d\n" , + new_sqintr ?"Splitting" :"Sharing" , old_nxqs, lif->nxqs); +} +static int ionic_set_priv_flags (struct net_device *netdev,u32 priv_flags) {struct ionic_lif *lif =netdev_priv (netdev); +int sqintr, new_sqintr;clear_bit (IONIC_LIF_F_SW_DEBUG_STATS , lif->state);if (priv_flags &IONIC_PRIV_F_SW_DBG_STATS )set_bit (IONIC_LIF_F_SW_DEBUG_STATS , lif->state); + sqintr =test_bit (IONIC_LIF_F_SPLIT_INTR , lif->state); + new_sqintr = !!(priv_flags &IONIC_PRIV_F_SPLIT_INTR ); +if (sqintr != new_sqintr) { +void *arg =0 ; + +if (new_sqintr) + arg = (void *)1 ; +ionic_reset_queues (lif, ionic_set_split_intr, arg); + } +return 0 ; }
drivers/net/ethernet/pensando/ionic/ionic_lif.c +34 -7
106 lines not on this page · raw message
drivers/net/ethernet/pensando/ionic/ionic_lif.h +3 -0
@@ -138,6 +138,7 @@ enum ionic_lif_state_flags {IONIC_LIF_F_LINK_CHECK_REQUESTED ,IONIC_LIF_F_QUEUE_RESET ,IONIC_LIF_F_FW_RESET , +IONIC_LIF_F_SPLIT_INTR ,/* leave this as last */ IONIC_LIF_F_STATE_SIZE
@@ -205,6 +206,8 @@ struct ionic_lif {struct dentry *dentry;u32 rx_coalesce_usecs;/* what the user asked for */ u32 rx_coalesce_hw;/* what the hw is using */ +u32 tx_coalesce_usecs;/* what the user asked for */ +u32 tx_coalesce_hw;/* what the hw is using */ struct work_struct tx_timeout_work; };
drivers/net/ethernet/pensando/ionic/ionic_txrx.c +67 -0
74 lines not on this page · raw message
drivers/net/ethernet/pensando/ionic/ionic_txrx.h +2 -0
@@ -11,6 +11,8 @@ void ionic_rx_fill(struct ionic_queue *q);void ionic_rx_empty (struct ionic_queue *q);void ionic_tx_empty (struct ionic_queue *q);int ionic_rx_napi (struct napi_struct *napi,int budget); +int ionic_tx_napi (struct napi_struct *napi,int budget); +int ionic_txrx_napi (struct napi_struct *napi,int budget);netdev_tx_t ionic_start_xmit (struct sk_buff *skb,struct net_device *netdev);#endif /* _IONIC_TXRX_H_ */
Signature · 1 line
2.17.1
PATCH 3/4 ionic: tx separate servicing
In reply to Shannon NelsonWe give the tx clean path its own budget and service routine in order to give a little more leeway to be more aggressive, and in preparation for coming changes. We've found this gives us a little better performance in some packet processing scenarios without hurting other scenarios.
--- .../net/ethernet/pensando/ionic/ionic_lif.c | 1 + .../net/ethernet/pensando/ionic/ionic_lif.h | 2 + .../net/ethernet/pensando/ionic/ionic_txrx.c | 106 +++++++++--------- 3 files changed, 53 insertions(+), 56 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_lif.c +1 -0
@@ -2065,6 +2065,7 @@ static struct ionic_lif *ionic_lif_alloc(struct ionic *ionic, unsigned int index lif->index = index; lif->ntxq_descs =IONIC_DEF_TXRX_DESC ; lif->nrxq_descs =IONIC_DEF_TXRX_DESC ; + lif->tx_budget =IONIC_TX_BUDGET_DEFAULT ;/* Convert the default coalesce value to actual hw resolution */ lif->rx_coalesce_usecs =IONIC_ITR_COAL_USEC_DEFAULT ;
drivers/net/ethernet/pensando/ionic/ionic_lif.h +2 -0
@@ -13,6 +13,7 @@#define IONIC_MAX_NUM_NAPI_CNTR (NAPI_POLL_WEIGHT + 1)#define IONIC_MAX_NUM_SG_CNTR (IONIC_TX_MAX_SG_ELEMS + 1)#define IONIC_RX_COPYBREAK_DEFAULT 256 +#define IONIC_TX_BUDGET_DEFAULT 256struct ionic_tx_stats {u64 dma_map_err;
@@ -176,6 +177,7 @@ struct ionic_lif {unsigned int ntxq_descs;unsigned int nrxq_descs;u32 rx_copybreak; +u32 tx_budget;unsigned int rx_mode;u64 hw_features;bool mc_overflow;
drivers/net/ethernet/pensando/ionic/ionic_txrx.c +50 -56
160 lines not on this page · raw message
Signature · 1 line
2.17.1
Jakub Kicinski
maintainerRe: [PATCH net-next 4/4] ionic: separate interrupt for Tx and Rx
In reply to Shannon NelsonQuoted 11 lines · On Fri, 24 Jul 2020 17:23:26 -0700 Shannon Nelson wrote:
Add the capability to split the Tx queues onto their own interrupts with their own napi contexts. This gives the opportunity for more direct control of Tx interrupt handling, such as CPU affinity and interrupt coalescing, useful for some traffic loads.
To enable, use the ethtool private flag:
ethtool --set-priv-flag enp20s0 split-q-intr on To restore defaults ethtool --set-priv-flag enp20s0 split-q-intr off
Quoted 5 lines
When enabled, the number of queues is cut in half in order to reuse the interrupts that have already been allocated to the device. When disabled, the queue count is restored.
Signed-off-by Shannon Nelson <[email protected]>
Splitting queues into tx-only and rx-only is done like this:
ethtool -L enp20s0 rx N tx N combined 0
And then back to combined:
ethtool -L enp20s0 rx 0 tx 0 combined N
No need for a private flag here.
David Miller
maintainerRe: [PATCH net-next 2/4] ionic: recover from ringsize change failure
In reply to Shannon NelsonFrom: Shannon Nelson <[email protected]>
Date: Fri, 24 Jul 2020 17:23:24 -0700
Quoted 3 lines
If the ringsize change fails, try restoring the previous setting.
Signed-off-by Shannon Nelson <[email protected]>
You really can't recover properly, or reliably, with the way all of this is structured in the ionic driver. This is at best a half attempt at error recovery.
Doing a full ionic_open() call abstracts things too heavily.
What you need to do is save away the current queue memory and object, without freeing them, and only release them when you can successfully setup the new queues.
This is the only way you can properly recover from errors in this operation, with a proper check/commit sequence.
I'd rather not merge half solutions to this problem, sorry.
Re: [PATCH net-next 4/4] ionic: separate interrupt for Tx and Rx
In reply to Jakub KicinskiQuoted 19 lines · Jakub Kicinski
Quoted 11 lines · On Fri, 24 Jul 2020 17:23:26 -0700 Shannon Nelson wrote:
Add the capability to split the Tx queues onto their own interrupts with their own napi contexts. This gives the opportunity for more direct control of Tx interrupt handling, such as CPU affinity and interrupt coalescing, useful for some traffic loads.
To enable, use the ethtool private flag:
ethtool --set-priv-flag enp20s0 split-q-intr on To restore defaults ethtool --set-priv-flag enp20s0 split-q-intr offQuoted 5 lines
When enabled, the number of queues is cut in half in order to reuse the interrupts that have already been allocated to the device. When disabled, the queue count is restored.
Signed-off-by Shannon Nelson <[email protected]>Splitting queues into tx-only and rx-only is done like this:
Quoted 7 lines
ethtool -L enp20s0 rx N tx N combined 0
And then back to combined:
ethtool -L enp20s0 rx 0 tx 0 combined N
No need for a private flag here.
Sure, we can do it that way.
Thanks,
sln
Re: [PATCH net-next 2/4] ionic: recover from ringsize change failure
In reply to David MillerQuoted 12 lines · David Miller
From: Shannon Nelson <[email protected]>
Date: Fri, 24 Jul 2020 17:23:24 -0700Quoted 3 lines
If the ringsize change fails, try restoring the previous setting.
Signed-off-by Shannon Nelson <[email protected]>You really can't recover properly, or reliably, with the way all of this is structured in the ionic driver. This is at best a half attempt at error recovery.
Doing a full
ionic_open()call abstracts things too heavily.
Quoted 8 lines
What you need to do is save away the current queue memory and object, without freeing them, and only release them when you can successfully setup the new queues.
This is the only way you can properly recover from errors in this operation, with a proper check/commit sequence.
I'd rather not merge half solutions to this problem, sorry.
Sure, thanks anyway.
sln