]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
octeon_ep_vf: introduce octep_vf_oq_next_idx() helper
authorDavid Carlier <devnexen@gmail.com>
Thu, 9 Apr 2026 18:40:08 +0000 (19:40 +0100)
committerJakub Kicinski <kuba@kernel.org>
Mon, 13 Apr 2026 22:40:49 +0000 (15:40 -0700)
Introduce octep_vf_oq_next_idx() to consolidate the repeated
ring index advance and wraparound pattern in __octep_vf_oq_process_rx().

No functional change intended.

Signed-off-by: David Carlier <devnexen@gmail.com>
Link: https://patch.msgid.link/20260409184009.930359-2-devnexen@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_rx.c

index b579d5b545c46d4d82456e8df36ccbfc118d212d..7bd1b9b8d7f5a1662124a87f05f3f8af41dac44b 100644 (file)
@@ -352,6 +352,11 @@ static int octep_vf_oq_check_hw_for_pkts(struct octep_vf_device *oct,
        return new_pkts;
 }
 
+static inline u32 octep_vf_oq_next_idx(struct octep_vf_oq *oq, u32 idx)
+{
+       return (idx + 1 == oq->max_count) ? 0 : idx + 1;
+}
+
 /**
  * __octep_vf_oq_process_rx() - Process hardware Rx queue and push to stack.
  *
@@ -415,10 +420,8 @@ static int __octep_vf_oq_process_rx(struct octep_vf_device *oct,
                        skb = napi_build_skb((void *)resp_hw, PAGE_SIZE);
                        skb_reserve(skb, data_offset);
                        skb_put(skb, buff_info->len);
-                       read_idx++;
                        desc_used++;
-                       if (read_idx == oq->max_count)
-                               read_idx = 0;
+                       read_idx = octep_vf_oq_next_idx(oq, read_idx);
                } else {
                        struct skb_shared_info *shinfo;
                        u16 data_len;
@@ -429,10 +432,8 @@ static int __octep_vf_oq_process_rx(struct octep_vf_device *oct,
                         * subsequent fragments contains only data.
                         */
                        skb_put(skb, oq->max_single_buffer_size);
-                       read_idx++;
                        desc_used++;
-                       if (read_idx == oq->max_count)
-                               read_idx = 0;
+                       read_idx = octep_vf_oq_next_idx(oq, read_idx);
 
                        shinfo = skb_shinfo(skb);
                        data_len = buff_info->len - oq->max_single_buffer_size;
@@ -454,10 +455,8 @@ static int __octep_vf_oq_process_rx(struct octep_vf_device *oct,
                                                buff_info->len,
                                                buff_info->len);
                                buff_info->page = NULL;
-                               read_idx++;
                                desc_used++;
-                               if (read_idx == oq->max_count)
-                                       read_idx = 0;
+                               read_idx = octep_vf_oq_next_idx(oq, read_idx);
                        }
                }