ionic: refactor use of ionic_rx_fill()
authorNeel Patel <neel@pensando.io>
Wed, 26 Oct 2022 14:37:44 +0000 (07:37 -0700)
committerJakub Kicinski <kuba@kernel.org>
Fri, 28 Oct 2022 03:34:14 +0000 (20:34 -0700)
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>
drivers/net/ethernet/pensando/ionic/ionic_txrx.c

index 190681aa7187315aea1184daa3f8bd00deaaf493..0c3977416cd1c319e8bfda66de76e902dc39b633 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);