ionic: rework fix for doorbell miss
Subsystems (3)
v2 cover ionic: rework fix for doorbell miss
A latency test in a scaled out setting (many VMs with many queues) has uncovered an issue with our missed doorbell fix from commit b69585bfcece ("ionic: missed doorbell workaround")
As a refresher, the Elba ASIC has an issue where once in a blue moon it might miss/drop a queue doorbell notification from the driver. This can result in Tx timeouts and potential Rx buffer misses.
The basic problem with the original solution is that we're delaying things with a timer for every single queue, periodically using mod_timer() to reset to reset the alarm, and mod_timer() becomes a more and more expensive thing as there are more and more VFs and queues each with their own timer. A ping-pong latency test tends to exacerbate the effect such that every napi is doing a mod_timer() in every cycle.
An alternative has been worked out to replace this using periodic workqueue items outside the napi cycle to request a napi_schedule driven by a single delayed-workqueue per device rather than a timer for every queue. Also, now that newer firmware is actually reporting its ASIC type, we can restrict this to the appropriate chip.
The testing scenario used 128 VFs in UP state, 16 queues per VF, and latency tests were done using TCP_RR with adaptive interrupt coalescing enabled, running on 1 VF. We would see 99th percentile latencies of up to 900us range, with some max fliers as much as 4ms.
With these fixes the 99th percentile latencies are typically well under 50us with the occasional max under 500us.
v2:
- 3/8: add commentary for why have a private work queue (Jakub)
- 4/8: no open-code of napi_schedule() (Jakub)
- 4/8: watch for deadlock with cancel_delayed_work_sync() (Jakub)
- 7/8: better ionic_lif field order after reducing rx_copybreak size (David)
- 7/8: include some pahole diff info (Andrew)
- 8/8: use bool not bitflag for doorbell_wa (David)
v1:
https://lore.kernel.org/netdev/[email protected]/
Brett Creeley (3):
ionic: Keep interrupt affinity up to date
ionic: Use an u16 for rx_copybreak
ionic: Only run the doorbell workaround for certain asic_type
Shannon Nelson (5):
ionic: remove missed doorbell per-queue timer
ionic: add private workqueue per-device
ionic: add work item for missed-doorbell check
ionic: add per-queue napi_schedule for doorbell check
ionic: check for queue deadline in doorbell_napi_work
drivers/net/ethernet/pensando/ionic/ionic.h | 7 + .../ethernet/pensando/ionic/ionic_bus_pci.c | 3 + .../net/ethernet/pensando/ionic/ionic_dev.c | 129 +++++++++++++++- .../net/ethernet/pensando/ionic/ionic_dev.h | 8 +- .../ethernet/pensando/ionic/ionic_ethtool.c | 11 +- .../net/ethernet/pensando/ionic/ionic_lif.c | 144 ++++++++++++------ .../net/ethernet/pensando/ionic/ionic_lif.h | 12 +- .../net/ethernet/pensando/ionic/ionic_main.c | 2 +- .../net/ethernet/pensando/ionic/ionic_txrx.c | 24 ++- 9 files changed, 264 insertions(+), 76 deletions(-)
Signature · 1 line
2.17.1
PATCH v2 1/8 ionic: remove missed doorbell per-queue timer
Remove the timer-per-queue mechanics from the missed doorbell check in preparation for the new missed doorbell fix.
--- .../net/ethernet/pensando/ionic/ionic_dev.c | 4 --- .../net/ethernet/pensando/ionic/ionic_lif.c | 36 ++++--------------- .../net/ethernet/pensando/ionic/ionic_lif.h | 2 -- .../net/ethernet/pensando/ionic/ionic_txrx.c | 22 +++++------- 4 files changed, 15 insertions(+), 49 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_dev.c +0 -4
@@ -703,10 +703,6 @@ void ionic_q_post(struct ionic_queue *q, bool ring_doorbell) q->dbval | q->head_idx); q->dbell_jiffies = jiffies; - -if (q_to_qcq (q)->napi_qcq) -mod_timer (&q_to_qcq (q)->napi_qcq->napi_deadline, - jiffies +IONIC_NAPI_DEADLINE ); } }
drivers/net/ethernet/pensando/ionic/ionic_lif.c +7 -29
@@ -213,13 +213,6 @@ void ionic_link_status_check_request(struct ionic_lif *lif, bool can_sleep) } } -static void ionic_napi_deadline (struct timer_list *timer) -{ - struct ionic_qcq *qcq = container_of(timer, struct ionic_qcq, napi_deadline); - -napi_schedule (&qcq->napi); -} -static irqreturn_t ionic_isr (int irq,void *data) {struct napi_struct *napi = data;
@@ -343,7 +336,6 @@ static int ionic_qcq_disable(struct ionic_lif *lif, struct ionic_qcq *qcq, int fsynchronize_irq (qcq->intr.vector);irq_set_affinity_hint (qcq->intr.vector,NULL );napi_disable (&qcq->napi); -del_timer_sync (&qcq->napi_deadline); }/* If there was a previous fw communcation error, don't bother with
@@ -478,7 +470,6 @@ static void ionic_link_qcq_interrupts(struct ionic_qcq *src_qcq, { n_qcq->intr.vector = src_qcq->intr.vector; n_qcq->intr.index = src_qcq->intr.index; - n_qcq->napi_qcq = src_qcq->napi_qcq; }static int ionic_alloc_qcq_interrupt (struct ionic_lif *lif,struct ionic_qcq *qcq)
@@ -832,11 +823,8 @@ static int ionic_lif_txq_init(struct ionic_lif *lif, struct ionic_qcq *qcq) q->dbell_deadline =IONIC_TX_DOORBELL_DEADLINE ; q->dbell_jiffies = jiffies; -if (test_bit (IONIC_LIF_F_SPLIT_INTR , lif->state)) { +if (test_bit (IONIC_LIF_F_SPLIT_INTR , lif->state))netif_napi_add (lif->netdev, &qcq->napi, ionic_tx_napi); - qcq->napi_qcq = qcq; -timer_setup (&qcq->napi_deadline, ionic_napi_deadline,0 ); - } qcq->flags |=IONIC_QCQ_F_INITED ;
@@ -909,9 +897,6 @@ static int ionic_lif_rxq_init(struct ionic_lif *lif, struct ionic_qcq *qcq)else netif_napi_add (lif->netdev, &qcq->napi, ionic_txrx_napi); - qcq->napi_qcq = qcq; -timer_setup (&qcq->napi_deadline, ionic_napi_deadline,0 ); - qcq->flags |=IONIC_QCQ_F_INITED ;return 0 ;
@@ -1166,7 +1151,6 @@ static int ionic_adminq_napi(struct napi_struct *napi, int budget)struct ionic_dev *idev = &lif->ionic->idev;unsigned long irqflags;unsigned int flags =0 ; -bool resched = false;int rx_work =0 ;int tx_work =0 ;int n_work =0 ;
@@ -1203,15 +1187,12 @@ static int ionic_adminq_napi(struct napi_struct *napi, int budget)ionic_intr_credits (idev->intr_ctrl, intr->index, credits, flags); } -if (!a_work &&ionic_adminq_poke_doorbell (&lif->adminqcq->q)) - resched = true; -if (lif->hwstamp_rxq && !rx_work &&ionic_rxq_poke_doorbell (&lif->hwstamp_rxq->q)) - resched = true; -if (lif->hwstamp_txq && !tx_work &&ionic_txq_poke_doorbell (&lif->hwstamp_txq->q)) - resched = true; -if (resched) -mod_timer (&lif->adminqcq->napi_deadline, - jiffies +IONIC_NAPI_DEADLINE ); +if (!a_work) +ionic_adminq_poke_doorbell (&lif->adminqcq->q); +if (lif->hwstamp_rxq && !rx_work) +ionic_rxq_poke_doorbell (&lif->hwstamp_rxq->q); +if (lif->hwstamp_txq && !tx_work) +ionic_txq_poke_doorbell (&lif->hwstamp_txq->q);return work_done; }
@@ -3502,9 +3483,6 @@ static int ionic_lif_adminq_init(struct ionic_lif *lif)netif_napi_add (lif->netdev, &qcq->napi, ionic_adminq_napi); - qcq->napi_qcq = qcq; -timer_setup (&qcq->napi_deadline, ionic_napi_deadline,0 ); -napi_enable (&qcq->napi);if (qcq->flags &IONIC_QCQ_F_INTR ) {
drivers/net/ethernet/pensando/ionic/ionic_lif.h +0 -2
@@ -84,11 +84,9 @@ struct ionic_qcq {u32 cmb_pgid;u32 cmb_order;struct dim dim; -struct timer_list napi_deadline;struct ionic_queue q;struct ionic_cq cq;struct napi_struct napi; -struct ionic_qcq *napi_qcq;struct ionic_intr_info intr;struct dentry *dentry; };
drivers/net/ethernet/pensando/ionic/ionic_txrx.c +8 -14
@@ -868,9 +868,6 @@ void ionic_rx_fill(struct ionic_queue *q) q->dbell_deadline =IONIC_RX_MIN_DOORBELL_DEADLINE ; q->dbell_jiffies = jiffies; - -mod_timer (&q_to_qcq (q)->napi_qcq->napi_deadline, - jiffies +IONIC_NAPI_DEADLINE ); }void ionic_rx_empty (struct ionic_queue *q)
@@ -953,8 +950,8 @@ int ionic_tx_napi(struct napi_struct *napi, int budget) work_done, flags); } -if (!work_done &&ionic_txq_poke_doorbell (&qcq->q)) -mod_timer (&qcq->napi_deadline, jiffies +IONIC_NAPI_DEADLINE ); +if (!work_done) +ionic_txq_poke_doorbell (&qcq->q);return work_done; }
@@ -996,8 +993,8 @@ int ionic_rx_napi(struct napi_struct *napi, int budget) work_done, flags); } -if (!work_done &&ionic_rxq_poke_doorbell (&qcq->q)) -mod_timer (&qcq->napi_deadline, jiffies +IONIC_NAPI_DEADLINE ); +if (!work_done) +ionic_rxq_poke_doorbell (&qcq->q);return work_done; }
@@ -1010,7 +1007,6 @@ int ionic_txrx_napi(struct napi_struct *napi, int budget)struct ionic_qcq *txqcq;struct ionic_lif *lif;struct ionic_cq *txcq; -bool resched = false;u32 rx_work_done =0 ;u32 tx_work_done =0 ;u32 flags =0 ;
@@ -1042,12 +1038,10 @@ int ionic_txrx_napi(struct napi_struct *napi, int budget) tx_work_done + rx_work_done, flags); } -if (!rx_work_done &&ionic_rxq_poke_doorbell (&rxqcq->q)) - resched = true; -if (!tx_work_done &&ionic_txq_poke_doorbell (&txqcq->q)) - resched = true; -if (resched) -mod_timer (&rxqcq->napi_deadline, jiffies +IONIC_NAPI_DEADLINE ); +if (!rx_work_done) +ionic_rxq_poke_doorbell (&rxqcq->q); +if (!tx_work_done) +ionic_txq_poke_doorbell (&txqcq->q);return rx_work_done; }
Signature · 1 line
2.17.1
PATCH v2 2/8 ionic: Keep interrupt affinity up to date
In reply to Shannon NelsonFrom: Brett Creeley <[email protected]>
Currently the driver either sets the initial interrupt affinity for its adminq and tx/rx queues on probe or resets it on various down/up/reconfigure flows. If any user and/or user process (i.e. irqbalance) changes IRQ affinity for any of the driver's interrupts that will be reset to driver defaults whenever any down/up/reconfigure operation happens. This is incorrect and is fixed by making 2 changes:
1. Allocate an array of cpumasks that's only allocated on probe and destroyed on remove.
2. Update the cpumask(s) for interrupts that are in use by registering for affinity notifiers.
--- drivers/net/ethernet/pensando/ionic/ionic.h | 1 + .../net/ethernet/pensando/ionic/ionic_dev.h | 4 +- .../net/ethernet/pensando/ionic/ionic_lif.c | 85 +++++++++++++++++-- 3 files changed, 81 insertions(+), 9 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic.h +1 -0
@@ -54,6 +54,7 @@ struct ionic {unsigned int nrxqs_per_lif;unsigned int nintrs;DECLARE_BITMAP (intrs,IONIC_INTR_CTRL_REGS_MAX ); +cpumask_var_t *affinity_masks;struct work_struct nb_work;struct notifier_block nb;struct rw_semaphore vf_op_lock;/* lock for VF operations */
drivers/net/ethernet/pensando/ionic/ionic_dev.h +2 -2
@@ -280,9 +280,9 @@ struct ionic_intr_info {u64 rearm_count;unsigned int index;unsigned int vector; -unsigned int cpu;u32 dim_coal_hw; -cpumask_t affinity_mask; +cpumask_var_t *affinity_mask; +struct irq_affinity_notify aff_notify; };struct ionic_cq {
drivers/net/ethernet/pensando/ionic/ionic_lif.c +78 -7
150 lines not on this page · raw message
Signature · 1 line
2.17.1
Jakub Kicinski
maintainerRe: [PATCH v2 net-next 2/8] ionic: Keep interrupt affinity up to date
Review
Quoted 2 lines · On Tue, 18 Jun 2024 17:32:51 -0700 Shannon Nelson wrote:
(quoted diff) +2
-0+ if (!affinity_masks) + return -ENOMEM;
There's a tab here instead of a space
Jakub Kicinski
maintainerRe: [PATCH v2 net-next 2/8] ionic: Keep interrupt affinity up to date
Quoted 5 lines · On Wed, 19 Jun 2024 17:43:17 -0700 Jakub Kicinski wrote:
Review
Quoted 2 lines · On Tue, 18 Jun 2024 17:32:51 -0700 Shannon Nelson wrote:
(quoted diff) +2
-0+ if (!affinity_masks) + return -ENOMEM;There's a tab here instead of a space
The rest looks good, I'll fix when applying.
Re: [PATCH v2 net-next 2/8] ionic: Keep interrupt affinity up to date
Quoted 9 lines · Jakub Kicinski
Quoted 5 lines · On Wed, 19 Jun 2024 17:43:17 -0700 Jakub Kicinski wrote:
Review
Quoted 2 lines · On Tue, 18 Jun 2024 17:32:51 -0700 Shannon Nelson wrote:
(quoted diff) +2
-0+ if (!affinity_masks) + return -ENOMEM;There's a tab here instead of a space
The rest looks good, I'll fix when applying.
Huh... that slipped through our standard checks. Thanks for the help. sln
PATCH v2 3/8 ionic: add private workqueue per-device
In reply to Shannon NelsonInstead of using the system's default workqueue, add a private workqueue for the device to use for its little jobs. This is to better support the new work items we will be adding in the next patches for PF and VF specific jobs, without inundating the system workqueue in a couple of customer cases where our devices get scaled out to 100-200 VFs.
--- drivers/net/ethernet/pensando/ionic/ionic.h | 1 + .../net/ethernet/pensando/ionic/ionic_dev.c | 21 +++++++++++++++---- .../net/ethernet/pensando/ionic/ionic_lif.c | 14 ++++++------- .../net/ethernet/pensando/ionic/ionic_lif.h | 2 +- .../net/ethernet/pensando/ionic/ionic_main.c | 2 +- 5 files changed, 27 insertions(+), 13 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic.h +1 -0
@@ -47,6 +47,7 @@ struct ionic {struct ionic_dev_bar bars[IONIC_BARS_MAX ];unsigned int num_bars;struct ionic_identity ident; +struct workqueue_struct *wq;struct ionic_lif *lif;unsigned int nnqs_per_lif;unsigned int neqs_per_lif;
drivers/net/ethernet/pensando/ionic/ionic_dev.c +17 -4
@@ -43,11 +43,11 @@ static void ionic_watchdog_cb(struct timer_list *t) work->type =IONIC_DW_TYPE_RX_MODE ;netdev_dbg (lif->netdev,"deferred: rx_mode\n" ); -ionic_lif_deferred_enqueue (&lif->deferred, work); +ionic_lif_deferred_enqueue (lif, work); } } -static void ionic_watchdog_init (struct ionic *ionic) +static int ionic_watchdog_init (struct ionic *ionic) {struct ionic_dev *idev = &ionic->idev;
@@ -63,6 +63,15 @@ static void ionic_watchdog_init(struct ionic *ionic) idev->fw_status_ready = true; idev->fw_generation =IONIC_FW_STS_F_GENERATION &ioread8 (&idev->dev_info_regs->fw_status); + + ionic->wq =alloc_workqueue ("%s-wq" ,WQ_UNBOUND ,0 , +dev_name (ionic->dev)); +if (!ionic->wq) { +dev_err (ionic->dev,"alloc_workqueue failed" ); +return -ENOMEM ; + } + +return 0 ; }void ionic_init_devinfo (struct ionic *ionic)
@@ -94,6 +103,7 @@ int ionic_dev_setup(struct ionic *ionic)struct device *dev = ionic->dev;int size;u32 sig; +int err;/* BAR0: dev_cmd and interrupts */ if (num_bars <1 ) {
@@ -129,7 +139,9 @@ int ionic_dev_setup(struct ionic *ionic)return -EFAULT ; } -ionic_watchdog_init (ionic); + err =ionic_watchdog_init (ionic); +if (err) +return err; idev->db_pages = bar->vaddr; idev->phy_db_pages = bar->bus_addr;
@@ -161,6 +173,7 @@ void ionic_dev_teardown(struct ionic *ionic) idev->phy_cmb_pages =0 ; idev->cmb_npages =0 ; +destroy_workqueue (ionic->wq);mutex_destroy (&idev->cmb_inuse_lock); }
@@ -273,7 +286,7 @@ int ionic_heartbeat_check(struct ionic *ionic)if (work) { work->type =IONIC_DW_TYPE_LIF_RESET ; work->fw_status = fw_status_ready; -ionic_lif_deferred_enqueue (&lif->deferred, work); +ionic_lif_deferred_enqueue (lif, work); } } }
drivers/net/ethernet/pensando/ionic/ionic_lif.c +7 -7
@@ -126,13 +126,13 @@ static void ionic_lif_deferred_work(struct work_struct *work) }while (true); } -void ionic_lif_deferred_enqueue (struct ionic_deferred *def, +void ionic_lif_deferred_enqueue (struct ionic_lif *lif,struct ionic_deferred_work *work) { -spin_lock_bh (&def->lock); -list_add_tail (&work->list, &def->list); -spin_unlock_bh (&def->lock); -schedule_work (&def->work); +spin_lock_bh (&lif->deferred.lock); +list_add_tail (&work->list, &lif->deferred.list); +spin_unlock_bh (&lif->deferred.lock); +queue_work (lif->ionic->wq, &lif->deferred.work); }static void ionic_link_status_check (struct ionic_lif *lif)
@@ -207,7 +207,7 @@ void ionic_link_status_check_request(struct ionic_lif *lif, bool can_sleep) } work->type =IONIC_DW_TYPE_LINK_STATUS ; -ionic_lif_deferred_enqueue (&lif->deferred, work); +ionic_lif_deferred_enqueue (lif, work); }else {ionic_link_status_check (lif); }
@@ -1389,7 +1389,7 @@ static void ionic_ndo_set_rx_mode(struct net_device *netdev) } work->type =IONIC_DW_TYPE_RX_MODE ;netdev_dbg (lif->netdev,"deferred: rx_mode\n" ); -ionic_lif_deferred_enqueue (&lif->deferred, work); +ionic_lif_deferred_enqueue (lif, work); }static __le64 ionic_netdev_features_to_nic (netdev_features_t features)
drivers/net/ethernet/pensando/ionic/ionic_lif.h +1 -1
@@ -331,7 +331,7 @@ static inline bool ionic_txq_hwstamp_enabled(struct ionic_queue *q)void ionic_link_status_check_request (struct ionic_lif *lif,bool can_sleep);void ionic_get_stats64 (struct net_device *netdev,struct rtnl_link_stats64 *ns); -void ionic_lif_deferred_enqueue (struct ionic_deferred *def, +void ionic_lif_deferred_enqueue (struct ionic_lif *lif,struct ionic_deferred_work *work);int ionic_lif_alloc (struct ionic *ionic);int ionic_lif_init (struct ionic_lif *lif);
drivers/net/ethernet/pensando/ionic/ionic_main.c +1 -1
@@ -287,7 +287,7 @@ bool ionic_notifyq_service(struct ionic_cq *cq)clear_bit (IONIC_LIF_F_FW_STOPPING , lif->state); }else { work->type =IONIC_DW_TYPE_LIF_RESET ; -ionic_lif_deferred_enqueue (&lif->deferred, work); +ionic_lif_deferred_enqueue (lif, work); } }break ;
Signature · 1 line
2.17.1
PATCH v2 4/8 ionic: add work item for missed-doorbell check
In reply to Shannon NelsonAdd the first queued work for checking on the missed doorbell. This is a delayed work item that reschedules itself every cycle starting at probe.
--- drivers/net/ethernet/pensando/ionic/ionic.h | 1 + .../ethernet/pensando/ionic/ionic_bus_pci.c | 2 + .../net/ethernet/pensando/ionic/ionic_dev.c | 66 +++++++++++++++++++ .../net/ethernet/pensando/ionic/ionic_dev.h | 3 +- .../net/ethernet/pensando/ionic/ionic_lif.c | 2 + 5 files changed, 73 insertions(+), 1 deletion(-)
drivers/net/ethernet/pensando/ionic/ionic.h +1 -0
@@ -56,6 +56,7 @@ struct ionic {unsigned int nintrs;DECLARE_BITMAP (intrs,IONIC_INTR_CTRL_REGS_MAX );cpumask_var_t *affinity_masks; +struct delayed_work doorbell_check_dwork;struct work_struct nb_work;struct notifier_block nb;struct rw_semaphore vf_op_lock;/* lock for VF operations */
drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c +2 -0
@@ -377,6 +377,7 @@ static int ionic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)mod_timer (&ionic->watchdog_timer,round_jiffies (jiffies + ionic->watchdog_period)); +ionic_queue_doorbell_check (ionic,IONIC_NAPI_DEADLINE );return 0 ;
@@ -411,6 +412,7 @@ static void ionic_remove(struct pci_dev *pdev)if (test_and_clear_bit (IONIC_LIF_F_FW_RESET , ionic->lif->state))set_bit (IONIC_LIF_F_FW_STOPPING , ionic->lif->state); +cancel_delayed_work_sync (&ionic->doorbell_check_dwork);ionic_lif_unregister (ionic->lif);ionic_devlink_unregister (ionic);ionic_lif_deinit (ionic->lif);
drivers/net/ethernet/pensando/ionic/ionic_dev.c +66 -0
82 lines not on this page · raw message
drivers/net/ethernet/pensando/ionic/ionic_dev.h +2 -1
@@ -28,7 +28,7 @@#define IONIC_DEV_INFO_REG_COUNT 32#define IONIC_DEV_CMD_REG_COUNT 32 -#define IONIC_NAPI_DEADLINE (HZ / 200)/* 5ms */ +#define IONIC_NAPI_DEADLINE (HZ)/* 1 sec */ #define IONIC_ADMIN_DOORBELL_DEADLINE (HZ / 2)/* 500ms */ #define IONIC_TX_DOORBELL_DEADLINE (HZ / 100)/* 10ms */ #define IONIC_RX_MIN_DOORBELL_DEADLINE (HZ / 100)/* 10ms */
@@ -386,6 +386,7 @@ bool ionic_q_is_posted(struct ionic_queue *q, unsigned int pos);int ionic_heartbeat_check (struct ionic *ionic);bool ionic_is_fw_running (struct ionic_dev *idev); +void ionic_queue_doorbell_check (struct ionic *ionic,int delay);bool ionic_adminq_poke_doorbell (struct ionic_queue *q);bool ionic_txq_poke_doorbell (struct ionic_queue *q);
drivers/net/ethernet/pensando/ionic/ionic_lif.c +2 -0
@@ -1191,6 +1191,7 @@ static int ionic_adminq_napi(struct napi_struct *napi, int budget)if (lif->adminqcq && lif->adminqcq->flags &IONIC_QCQ_F_INITED ) a_work =ionic_cq_service (&lif->adminqcq->cq, budget, ionic_adminq_service,NULL ,NULL ); +spin_unlock_irqrestore (&lif->adminq_lock, irqflags);if (lif->hwstamp_rxq)
@@ -3406,6 +3407,7 @@ int ionic_restart_lif(struct ionic_lif *lif)clear_bit (IONIC_LIF_F_FW_RESET , lif->state);ionic_link_status_check_request (lif,CAN_SLEEP );netif_device_attach (lif->netdev); +ionic_queue_doorbell_check (ionic,IONIC_NAPI_DEADLINE );return 0 ;
Signature · 1 line
2.17.1
PATCH v2 5/8 ionic: add per-queue napi_schedule for doorbell check
In reply to Shannon NelsonAdd a work item for each queue that will be run on the queue's preferred cpu and will schedule another napi. This napi is run in case the device missed a doorbell and didn't process a packet. This is a problem for the Elba asic that happens very rarely.
--- .../net/ethernet/pensando/ionic/ionic_dev.c | 23 +++++++++++++++++-- .../net/ethernet/pensando/ionic/ionic_dev.h | 1 + .../net/ethernet/pensando/ionic/ionic_lif.c | 2 ++ .../net/ethernet/pensando/ionic/ionic_lif.h | 1 + 4 files changed, 25 insertions(+), 2 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_dev.c +21 -2
@@ -54,6 +54,13 @@ static void ionic_napi_schedule_do_softirq(struct napi_struct *napi)local_bh_enable (); } +void ionic_doorbell_napi_work (struct work_struct *work) +{ + struct ionic_qcq *qcq = container_of(work, struct ionic_qcq, + doorbell_napi_work); +ionic_napi_schedule_do_softirq (&qcq->napi); +} +static int ionic_get_preferred_cpu (struct ionic *ionic,struct ionic_intr_info *intr) {
@@ -66,6 +73,18 @@ static int ionic_get_preferred_cpu(struct ionic *ionic,return cpu; } +static void ionic_queue_dbell_napi_work (struct ionic *ionic, +struct ionic_qcq *qcq) +{ +int cpu; + +if (!(qcq->flags &IONIC_QCQ_F_INTR )) +return ; + + cpu =ionic_get_preferred_cpu (ionic, &qcq->intr); +queue_work_on (cpu, ionic->wq, &qcq->doorbell_napi_work); +} +static void ionic_doorbell_check_dwork (struct work_struct *work) { struct ionic *ionic = container_of(work, struct ionic,
@@ -86,8 +105,8 @@ static void ionic_doorbell_check_dwork(struct work_struct *work)int i;for (i =0 ; i < lif->nxqs; i++) { -ionic_napi_schedule_do_softirq (&lif->txqcqs[i]->napi); -ionic_napi_schedule_do_softirq (&lif->rxqcqs[i]->napi); +ionic_queue_dbell_napi_work (ionic, lif->txqcqs[i]); +ionic_queue_dbell_napi_work (ionic, lif->rxqcqs[i]); } if (lif->hwstamp_txq &&
drivers/net/ethernet/pensando/ionic/ionic_dev.h +1 -0
@@ -386,6 +386,7 @@ bool ionic_q_is_posted(struct ionic_queue *q, unsigned int pos);int ionic_heartbeat_check (struct ionic *ionic);bool ionic_is_fw_running (struct ionic_dev *idev); +void ionic_doorbell_napi_work (struct work_struct *work);void ionic_queue_doorbell_check (struct ionic *ionic,int delay);bool ionic_adminq_poke_doorbell (struct ionic_queue *q);
drivers/net/ethernet/pensando/ionic/ionic_lif.c +2 -0
@@ -344,6 +344,7 @@ static int ionic_qcq_disable(struct ionic_lif *lif, struct ionic_qcq *qcq, int fif (qcq->flags &IONIC_QCQ_F_INTR ) {struct ionic_dev *idev = &lif->ionic->idev; +cancel_work_sync (&qcq->doorbell_napi_work);cancel_work_sync (&qcq->dim.work);ionic_intr_mask (idev->intr_ctrl, qcq->intr.index,IONIC_INTR_MASK_SET );
@@ -690,6 +691,7 @@ static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type,INIT_WORK (&new->dim.work, ionic_dim_work); new->dim.mode =DIM_CQ_PERIOD_MODE_START_FROM_CQE ; +INIT_WORK (&new->doorbell_napi_work, ionic_doorbell_napi_work); *qcq = new;
drivers/net/ethernet/pensando/ionic/ionic_lif.h +1 -0
@@ -88,6 +88,7 @@ struct ionic_qcq {struct ionic_cq cq;struct napi_struct napi;struct ionic_intr_info intr; +struct work_struct doorbell_napi_work;struct dentry *dentry; };
Signature · 1 line
2.17.1
PATCH v2 6/8 ionic: check for queue deadline in doorbell_napi_work
In reply to Shannon NelsonCheck the deadline against the last time run and only schedule a new napi if we haven't been run recently.
--- drivers/net/ethernet/pensando/ionic/ionic_dev.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/net/ethernet/pensando/ionic/ionic_dev.c +8 -1
@@ -58,7 +58,14 @@ void ionic_doorbell_napi_work(struct work_struct *work) { struct ionic_qcq *qcq = container_of(work, struct ionic_qcq, doorbell_napi_work); -ionic_napi_schedule_do_softirq (&qcq->napi); +unsigned long now, then, dif; + + now =READ_ONCE (jiffies); + then = qcq->q.dbell_jiffies; + dif = now - then; + +if (dif > qcq->q.dbell_deadline) +ionic_napi_schedule_do_softirq (&qcq->napi); } static int ionic_get_preferred_cpu(struct ionic *ionic,
Signature · 1 line
2.17.1
PATCH v2 7/8 ionic: Use an u16 for rx_copybreak
In reply to Shannon NelsonFrom: Brett Creeley <[email protected]>
We only support (u16)-1 size for rx_copybreak, so we can reduce the field size and move a couple other fields around to save a little space in the ionic_lif struct.
Before:
/* size: 17440, cachelines: 273, members: 56 */ /* sum members: 17403, holes: 9, sum holes: 37 */ /* last cacheline: 32 bytes */
After:
/* size: 17424, cachelines: 273, members: 56 */ /* sum members: 17401, holes: 7, sum holes: 23 */ /* last cacheline: 16 bytes */
--- drivers/net/ethernet/pensando/ionic/ionic_ethtool.c | 11 ++++++++++- drivers/net/ethernet/pensando/ionic/ionic_lif.h | 6 +++--- 2 files changed, 13 insertions(+), 4 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +10 -1
@@ -11,6 +11,8 @@#include "ionic_ethtool.h" #include "ionic_stats.h" +#define IONIC_MAX_RX_COPYBREAK min(U16_MAX, IONIC_MAX_BUF_LEN) +static void ionic_get_stats_strings (struct ionic_lif *lif,u8 *buf) {u32 i;
@@ -872,10 +874,17 @@ static int ionic_set_tunable(struct net_device *dev, const void *data) {struct ionic_lif *lif =netdev_priv (dev); +u32 rx_copybreak;switch (tuna->id) {case ETHTOOL_RX_COPYBREAK : - lif->rx_copybreak = *(u32 *)data; + rx_copybreak = *(u32 *)data; +if (rx_copybreak >IONIC_MAX_RX_COPYBREAK ) { +netdev_err (dev,"Max supported rx_copybreak size: %u\n" , +IONIC_MAX_RX_COPYBREAK ); +return -EINVAL ; + } + lif->rx_copybreak = (u16 )rx_copybreak;break ;default :return -EOPNOTSUPP ;
drivers/net/ethernet/pensando/ionic/ionic_lif.h +3 -3
@@ -206,10 +206,10 @@ struct ionic_lif {unsigned int nxqs;unsigned int ntxq_descs;unsigned int nrxq_descs; -u32 rx_copybreak;u64 rxq_features; -u16 rx_mode;u64 hw_features; +u16 rx_copybreak; +u16 rx_mode;bool registered;u16 lif_type;unsigned int link_down_count;
@@ -225,11 +225,11 @@ struct ionic_lif {u32 info_sz;struct ionic_qtype_info qtype_info[IONIC_QTYPE_MAX ]; -u16 rss_types;u8 rss_hash_key[IONIC_RSS_HASH_KEY_SIZE ];u8 *rss_ind_tbl;dma_addr_t rss_ind_tbl_pa;u32 rss_ind_tbl_sz; +u16 rss_types;struct ionic_rx_filters rx_filters;u32 rx_coalesce_usecs;/* what the user asked for */
Signature · 1 line
2.17.1
PATCH v2 8/8 ionic: Only run the doorbell workaround for certain asic_type
In reply to Shannon NelsonFrom: Brett Creeley <[email protected]>
If the doorbell workaround isn't required for a certain asic_type then there is no need to run the associated code. Since newer FW versions are finally reporting their asic_type we can use a flag to determine whether or not to do the workaround.
--- drivers/net/ethernet/pensando/ionic/ionic.h | 4 ++++ .../ethernet/pensando/ionic/ionic_bus_pci.c | 3 ++- .../net/ethernet/pensando/ionic/ionic_dev.c | 16 ++++++++++++-- .../net/ethernet/pensando/ionic/ionic_lif.c | 21 ++++++++++++------- .../net/ethernet/pensando/ionic/ionic_lif.h | 1 + .../net/ethernet/pensando/ionic/ionic_txrx.c | 14 +++++++------ 6 files changed, 42 insertions(+), 17 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic.h +4 -0
@@ -18,6 +18,8 @@ struct ionic_lif;#define PCI_DEVICE_ID_PENSANDO_IONIC_ETH_PF 0x1002#define PCI_DEVICE_ID_PENSANDO_IONIC_ETH_VF 0x1003 +#define IONIC_ASIC_TYPE_ELBA 2 +#define DEVCMD_TIMEOUT 5#define IONIC_ADMINQ_TIME_SLICE msecs_to_jiffies(100)
@@ -96,4 +98,6 @@ int ionic_port_identify(struct ionic *ionic);int ionic_port_init (struct ionic *ionic);int ionic_port_reset (struct ionic *ionic); +bool ionic_doorbell_wa (struct ionic *ionic); +#endif /* _IONIC_H_ */
drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c +2 -1
@@ -412,7 +412,8 @@ static void ionic_remove(struct pci_dev *pdev)if (test_and_clear_bit (IONIC_LIF_F_FW_RESET , ionic->lif->state))set_bit (IONIC_LIF_F_FW_STOPPING , ionic->lif->state); -cancel_delayed_work_sync (&ionic->doorbell_check_dwork); +if (ionic->lif->doorbell_wa) +cancel_delayed_work_sync (&ionic->doorbell_check_dwork);ionic_lif_unregister (ionic->lif);ionic_devlink_unregister (ionic);ionic_lif_deinit (ionic->lif);
drivers/net/ethernet/pensando/ionic/ionic_dev.c +14 -2
@@ -128,6 +128,13 @@ static void ionic_doorbell_check_dwork(struct work_struct *work)ionic_queue_doorbell_check (ionic,IONIC_NAPI_DEADLINE ); } +bool ionic_doorbell_wa (struct ionic *ionic) +{ +u8 asic_type = ionic->idev.dev_info.asic_type; + +return !asic_type || asic_type ==IONIC_ASIC_TYPE_ELBA ; +} +static int ionic_watchdog_init (struct ionic *ionic) {struct ionic_dev *idev = &ionic->idev;
@@ -151,8 +158,10 @@ static int ionic_watchdog_init(struct ionic *ionic)dev_err (ionic->dev,"alloc_workqueue failed" );return -ENOMEM ; } -INIT_DELAYED_WORK (&ionic->doorbell_check_dwork, - ionic_doorbell_check_dwork); + +if (ionic_doorbell_wa (ionic)) +INIT_DELAYED_WORK (&ionic->doorbell_check_dwork, + ionic_doorbell_check_dwork);return 0 ; }
@@ -161,6 +170,9 @@ void ionic_queue_doorbell_check(struct ionic *ionic, int delay) {int cpu; +if (!ionic->lif->doorbell_wa) +return ; + cpu =ionic_get_preferred_cpu (ionic, &ionic->lif->adminqcq->intr);queue_delayed_work_on (cpu, ionic->wq, &ionic->doorbell_check_dwork, delay);
drivers/net/ethernet/pensando/ionic/ionic_lif.c +13 -8
@@ -344,7 +344,8 @@ static int ionic_qcq_disable(struct ionic_lif *lif, struct ionic_qcq *qcq, int fif (qcq->flags &IONIC_QCQ_F_INTR ) {struct ionic_dev *idev = &lif->ionic->idev; -cancel_work_sync (&qcq->doorbell_napi_work); +if (lif->doorbell_wa) +cancel_work_sync (&qcq->doorbell_napi_work);cancel_work_sync (&qcq->dim.work);ionic_intr_mask (idev->intr_ctrl, qcq->intr.index,IONIC_INTR_MASK_SET );
@@ -691,7 +692,8 @@ static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type,INIT_WORK (&new->dim.work, ionic_dim_work); new->dim.mode =DIM_CQ_PERIOD_MODE_START_FROM_CQE ; -INIT_WORK (&new->doorbell_napi_work, ionic_doorbell_napi_work); +if (lif->doorbell_wa) +INIT_WORK (&new->doorbell_napi_work, ionic_doorbell_napi_work); *qcq = new;
@@ -1215,12 +1217,14 @@ static int ionic_adminq_napi(struct napi_struct *napi, int budget)ionic_intr_credits (idev->intr_ctrl, intr->index, credits, flags); } -if (!a_work) -ionic_adminq_poke_doorbell (&lif->adminqcq->q); -if (lif->hwstamp_rxq && !rx_work) -ionic_rxq_poke_doorbell (&lif->hwstamp_rxq->q); -if (lif->hwstamp_txq && !tx_work) -ionic_txq_poke_doorbell (&lif->hwstamp_txq->q); +if (lif->doorbell_wa) { +if (!a_work) +ionic_adminq_poke_doorbell (&lif->adminqcq->q); +if (lif->hwstamp_rxq && !rx_work) +ionic_rxq_poke_doorbell (&lif->hwstamp_rxq->q); +if (lif->hwstamp_txq && !tx_work) +ionic_txq_poke_doorbell (&lif->hwstamp_txq->q); + }return work_done; }
@@ -3749,6 +3753,7 @@ int ionic_lif_init(struct ionic_lif *lif) goto err_out_notifyq_deinit; lif->rx_copybreak =IONIC_RX_COPYBREAK_DEFAULT ; + lif->doorbell_wa =ionic_doorbell_wa (lif->ionic);set_bit (IONIC_LIF_F_INITED , lif->state);
drivers/net/ethernet/pensando/ionic/ionic_lif.h +1 -0
@@ -211,6 +211,7 @@ struct ionic_lif {u16 rx_copybreak;u16 rx_mode;bool registered; +bool doorbell_wa;u16 lif_type;unsigned int link_down_count;unsigned int nmcast;
drivers/net/ethernet/pensando/ionic/ionic_txrx.c +8 -6
@@ -950,7 +950,7 @@ int ionic_tx_napi(struct napi_struct *napi, int budget) work_done, flags); } -if (!work_done) +if (!work_done && cq->bound_q->lif->doorbell_wa)ionic_txq_poke_doorbell (&qcq->q);return work_done;
@@ -993,7 +993,7 @@ int ionic_rx_napi(struct napi_struct *napi, int budget) work_done, flags); } -if (!work_done) +if (!work_done && cq->bound_q->lif->doorbell_wa)ionic_rxq_poke_doorbell (&qcq->q);return work_done;
@@ -1038,10 +1038,12 @@ int ionic_txrx_napi(struct napi_struct *napi, int budget) tx_work_done + rx_work_done, flags); } -if (!rx_work_done) -ionic_rxq_poke_doorbell (&rxqcq->q); -if (!tx_work_done) -ionic_txq_poke_doorbell (&txqcq->q); +if (lif->doorbell_wa) { +if (!rx_work_done) +ionic_rxq_poke_doorbell (&rxqcq->q); +if (!tx_work_done) +ionic_txq_poke_doorbell (&txqcq->q); + }return rx_work_done; }
Signature · 1 line
2.17.1
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Tue, 18 Jun 2024 17:32:49 -0700 you wrote:
A latency test in a scaled out setting (many VMs with many queues) has uncovered an issue with our missed doorbell fix from commit
b69585bfcece("ionic: missed doorbell workaround")As a refresher, the Elba ASIC has an issue where once in a blue moon it might miss/drop a queue doorbell notification from the driver. This can result in Tx timeouts and potential Rx buffer misses.
[...]
Here is the summary with links:
- [v2,net-next,1/8] ionic: remove missed doorbell per-queue timer
https://git.kernel.org/netdev/net-next/c/4aaa49a282ad - [v2,net-next,2/8] ionic: Keep interrupt affinity up to date https://git.kernel.org/netdev/net-next/c/d458d4b4fd43 - [v2,net-next,3/8] ionic: add private workqueue per-device https://git.kernel.org/netdev/net-next/c/9e25450da700 - [v2,net-next,4/8] ionic: add work item for missed-doorbell check https://git.kernel.org/netdev/net-next/c/4ded136c78f8 - [v2,net-next,5/8] ionic: add per-queue napi_schedule for doorbell check https://git.kernel.org/netdev/net-next/c/d7f9bc685918 - [v2,net-next,6/8] ionic: check for queue deadline in doorbell_napi_work https://git.kernel.org/netdev/net-next/c/55a3982ec721 - [v2,net-next,7/8] ionic: Use an u16 for rx_copybreak https://git.kernel.org/netdev/net-next/c/f703d56c0305 - [v2,net-next,8/8] ionic: Only run the doorbell workaround for certain asic_type https://git.kernel.org/netdev/net-next/c/da0262c2c931
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html