@@ -22,6 +22,67 @@ static inline void ionic_rxq_post(struct ionic_queue *q, bool ring_dbell,
2222 ionic_q_post (q , ring_dbell , cb_func , cb_arg );
2323}
2424
25+ bool ionic_txq_poke_doorbell (struct ionic_queue * q )
26+ {
27+ unsigned long now , then , dif ;
28+ struct netdev_queue * netdev_txq ;
29+ struct net_device * netdev ;
30+
31+ netdev = q -> lif -> netdev ;
32+ netdev_txq = netdev_get_tx_queue (netdev , q -> index );
33+
34+ HARD_TX_LOCK (netdev , netdev_txq , smp_processor_id ());
35+
36+ if (q -> tail_idx == q -> head_idx ) {
37+ HARD_TX_UNLOCK (netdev , netdev_txq );
38+ return false;
39+ }
40+
41+ now = READ_ONCE (jiffies );
42+ then = q -> dbell_jiffies ;
43+ dif = now - then ;
44+
45+ if (dif > q -> dbell_deadline ) {
46+ ionic_dbell_ring (q -> lif -> kern_dbpage , q -> hw_type ,
47+ q -> dbval | q -> head_idx );
48+
49+ q -> dbell_jiffies = now ;
50+ }
51+
52+ HARD_TX_UNLOCK (netdev , netdev_txq );
53+
54+ return true;
55+ }
56+
57+ bool ionic_rxq_poke_doorbell (struct ionic_queue * q )
58+ {
59+ unsigned long now , then , dif ;
60+
61+ /* no lock, called from rx napi or txrx napi, nothing else can fill */
62+
63+ if (q -> tail_idx == q -> head_idx )
64+ return false;
65+
66+ now = READ_ONCE (jiffies );
67+ then = q -> dbell_jiffies ;
68+ dif = now - then ;
69+
70+ if (dif > q -> dbell_deadline ) {
71+ ionic_dbell_ring (q -> lif -> kern_dbpage , q -> hw_type ,
72+ q -> dbval | q -> head_idx );
73+
74+ q -> dbell_jiffies = now ;
75+
76+ dif = 2 * q -> dbell_deadline ;
77+ if (dif > IONIC_RX_MAX_DOORBELL_DEADLINE )
78+ dif = IONIC_RX_MAX_DOORBELL_DEADLINE ;
79+
80+ q -> dbell_deadline = dif ;
81+ }
82+
83+ return true;
84+ }
85+
2586static inline struct netdev_queue * q_to_ndq (struct ionic_queue * q )
2687{
2788 return netdev_get_tx_queue (q -> lif -> netdev , q -> index );
@@ -424,6 +485,12 @@ void ionic_rx_fill(struct ionic_queue *q)
424485
425486 ionic_dbell_ring (q -> lif -> kern_dbpage , q -> hw_type ,
426487 q -> dbval | q -> head_idx );
488+
489+ q -> dbell_deadline = IONIC_RX_MIN_DOORBELL_DEADLINE ;
490+ q -> dbell_jiffies = jiffies ;
491+
492+ mod_timer (& q_to_qcq (q )-> napi_qcq -> napi_deadline ,
493+ jiffies + IONIC_NAPI_DEADLINE );
427494}
428495
429496void ionic_rx_empty (struct ionic_queue * q )
@@ -511,6 +578,9 @@ int ionic_tx_napi(struct napi_struct *napi, int budget)
511578 work_done , flags );
512579 }
513580
581+ if (!work_done && ionic_txq_poke_doorbell (& qcq -> q ))
582+ mod_timer (& qcq -> napi_deadline , jiffies + IONIC_NAPI_DEADLINE );
583+
514584 return work_done ;
515585}
516586
@@ -544,23 +614,29 @@ int ionic_rx_napi(struct napi_struct *napi, int budget)
544614 work_done , flags );
545615 }
546616
617+ if (!work_done && ionic_rxq_poke_doorbell (& qcq -> q ))
618+ mod_timer (& qcq -> napi_deadline , jiffies + IONIC_NAPI_DEADLINE );
619+
547620 return work_done ;
548621}
549622
550623int ionic_txrx_napi (struct napi_struct * napi , int budget )
551624{
552- struct ionic_qcq * qcq = napi_to_qcq (napi );
625+ struct ionic_qcq * rxqcq = napi_to_qcq (napi );
553626 struct ionic_cq * rxcq = napi_to_cq (napi );
554627 unsigned int qi = rxcq -> bound_q -> index ;
628+ struct ionic_qcq * txqcq ;
555629 struct ionic_dev * idev ;
556630 struct ionic_lif * lif ;
557631 struct ionic_cq * txcq ;
632+ bool resched = false;
558633 u32 rx_work_done = 0 ;
559634 u32 tx_work_done = 0 ;
560635 u32 flags = 0 ;
561636
562637 lif = rxcq -> bound_q -> lif ;
563638 idev = & lif -> ionic -> idev ;
639+ txqcq = lif -> txqcqs [qi ];
564640 txcq = & lif -> txqcqs [qi ]-> cq ;
565641
566642 tx_work_done = ionic_cq_service (txcq , IONIC_TX_BUDGET_DEFAULT ,
@@ -572,7 +648,7 @@ int ionic_txrx_napi(struct napi_struct *napi, int budget)
572648 ionic_rx_fill (rxcq -> bound_q );
573649
574650 if (rx_work_done < budget && napi_complete_done (napi , rx_work_done )) {
575- ionic_dim_update (qcq , 0 );
651+ ionic_dim_update (rxqcq , 0 );
576652 flags |= IONIC_INTR_CRED_UNMASK ;
577653 rxcq -> bound_intr -> rearm_count ++ ;
578654 }
@@ -583,6 +659,13 @@ int ionic_txrx_napi(struct napi_struct *napi, int budget)
583659 tx_work_done + rx_work_done , flags );
584660 }
585661
662+ if (!rx_work_done && ionic_rxq_poke_doorbell (& rxqcq -> q ))
663+ resched = true;
664+ if (!tx_work_done && ionic_txq_poke_doorbell (& txqcq -> q ))
665+ resched = true;
666+ if (resched )
667+ mod_timer (& rxqcq -> napi_deadline , jiffies + IONIC_NAPI_DEADLINE );
668+
586669 return rx_work_done ;
587670}
588671
0 commit comments