ionic: refactor use of ionic_rx_fill()
authorNeel Patel <neel@pensando.io>
Wed, 26 Oct 2022 14:37:44 +0000 (07:37 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Feb 2023 18:11:44 +0000 (19:11 +0100)
[ Upstream commit e55f0f5befc26e2ba6bb8c1f945ea8e37ee0e334 ]

The same pre-work code is used before each call to
ionic_rx_fill(), so bring it in and make it a part of
the routine.

Signed-off-by: Neel Patel <neel@pensando.io>
Signed-off-by: Shannon Nelson <snelson@pensando.io>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Stable-dep-of: b69585bfcece ("ionic: missed doorbell workaround")
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/pensando/ionic/ionic_txrx.c

index c03986bf262890deaf3c99f48f78aade2d7b68ba..7977de4d67b76179b050da21db6d3eae1ff8d40c 100644 (file)
@@ -348,16 +348,25 @@ void ionic_rx_fill(struct ionic_queue *q)
        struct ionic_rxq_sg_desc *sg_desc;
        struct ionic_rxq_sg_elem *sg_elem;
        struct ionic_buf_info *buf_info;
+       unsigned int fill_threshold;
        struct ionic_rxq_desc *desc;
        unsigned int remain_len;
        unsigned int frag_len;
        unsigned int nfrags;
+       unsigned int n_fill;
        unsigned int i, j;
        unsigned int len;
 
+       n_fill = ionic_q_space_avail(q);
+
+       fill_threshold = min_t(unsigned int, IONIC_RX_FILL_THRESHOLD,
+                              q->num_descs / IONIC_RX_FILL_DIV);
+       if (n_fill < fill_threshold)
+               return;
+
        len = netdev->mtu + ETH_HLEN + VLAN_HLEN;
 
-       for (i = ionic_q_space_avail(q); i; i--) {
+       for (i = n_fill; i; i--) {
                nfrags = 0;
                remain_len = len;
                desc_info = &q->info[q->head_idx];
@@ -511,7 +520,6 @@ int ionic_rx_napi(struct napi_struct *napi, int budget)
        struct ionic_cq *cq = napi_to_cq(napi);
        struct ionic_dev *idev;
        struct ionic_lif *lif;
-       u16 rx_fill_threshold;
        u32 work_done = 0;
        u32 flags = 0;
 
@@ -521,10 +529,7 @@ int ionic_rx_napi(struct napi_struct *napi, int budget)
        work_done = ionic_cq_service(cq, budget,
                                     ionic_rx_service, NULL, NULL);
 
-       rx_fill_threshold = min_t(u16, IONIC_RX_FILL_THRESHOLD,
-                                 cq->num_descs / IONIC_RX_FILL_DIV);
-       if (work_done && ionic_q_space_avail(cq->bound_q) >= rx_fill_threshold)
-               ionic_rx_fill(cq->bound_q);
+       ionic_rx_fill(cq->bound_q);
 
        if (work_done < budget && napi_complete_done(napi, work_done)) {
                ionic_dim_update(qcq, IONIC_LIF_F_RX_DIM_INTR);
@@ -550,7 +555,6 @@ int ionic_txrx_napi(struct napi_struct *napi, int budget)
        struct ionic_dev *idev;
        struct ionic_lif *lif;
        struct ionic_cq *txcq;
-       u16 rx_fill_threshold;
        u32 rx_work_done = 0;
        u32 tx_work_done = 0;
        u32 flags = 0;
@@ -565,10 +569,7 @@ int ionic_txrx_napi(struct napi_struct *napi, int budget)
        rx_work_done = ionic_cq_service(rxcq, budget,
                                        ionic_rx_service, NULL, NULL);
 
-       rx_fill_threshold = min_t(u16, IONIC_RX_FILL_THRESHOLD,
-                                 rxcq->num_descs / IONIC_RX_FILL_DIV);
-       if (rx_work_done && ionic_q_space_avail(rxcq->bound_q) >= rx_fill_threshold)
-               ionic_rx_fill(rxcq->bound_q);
+       ionic_rx_fill(rxcq->bound_q);
 
        if (rx_work_done < budget && napi_complete_done(napi, rx_work_done)) {
                ionic_dim_update(qcq, 0);