ixgbevf: Add XDP frame size to VF driver
authorJesper Dangaard Brouer <brouer@redhat.com>
Thu, 14 May 2020 10:50:59 +0000 (12:50 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 15 May 2020 04:21:56 +0000 (21:21 -0700)
This patch mirrors the changes to ixgbe in previous patch.

This VF driver doesn't support XDP_REDIRECT, but correct tailroom is
still necessary for BPF-helper xdp_adjust_tail.  In legacy-mode +
larger PAGE_SIZE, due to lacking tailroom, we accept that
xdp_adjust_tail shrink doesn't work.

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Cc: intel-wired-lan@lists.osuosl.org
Cc: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Cc: Alexander Duyck <alexander.duyck@gmail.com>
Link: https://lore.kernel.org/bpf/158945345984.97035.13518286183248025173.stgit@firesoul
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c

index 4622c4e..a39e2cb 100644 (file)
@@ -1095,19 +1095,31 @@ xdp_out:
        return ERR_PTR(-result);
 }
 
+static unsigned int ixgbevf_rx_frame_truesize(struct ixgbevf_ring *rx_ring,
+                                             unsigned int size)
+{
+       unsigned int truesize;
+
+#if (PAGE_SIZE < 8192)
+       truesize = ixgbevf_rx_pg_size(rx_ring) / 2; /* Must be power-of-2 */
+#else
+       truesize = ring_uses_build_skb(rx_ring) ?
+               SKB_DATA_ALIGN(IXGBEVF_SKB_PAD + size) +
+               SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) :
+               SKB_DATA_ALIGN(size);
+#endif
+       return truesize;
+}
+
 static void ixgbevf_rx_buffer_flip(struct ixgbevf_ring *rx_ring,
                                   struct ixgbevf_rx_buffer *rx_buffer,
                                   unsigned int size)
 {
-#if (PAGE_SIZE < 8192)
-       unsigned int truesize = ixgbevf_rx_pg_size(rx_ring) / 2;
+       unsigned int truesize = ixgbevf_rx_frame_truesize(rx_ring, size);
 
+#if (PAGE_SIZE < 8192)
        rx_buffer->page_offset ^= truesize;
 #else
-       unsigned int truesize = ring_uses_build_skb(rx_ring) ?
-                               SKB_DATA_ALIGN(IXGBEVF_SKB_PAD + size) :
-                               SKB_DATA_ALIGN(size);
-
        rx_buffer->page_offset += truesize;
 #endif
 }
@@ -1125,6 +1137,11 @@ static int ixgbevf_clean_rx_irq(struct ixgbevf_q_vector *q_vector,
 
        xdp.rxq = &rx_ring->xdp_rxq;
 
+       /* Frame size depend on rx_ring setup when PAGE_SIZE=4K */
+#if (PAGE_SIZE < 8192)
+       xdp.frame_sz = ixgbevf_rx_frame_truesize(rx_ring, 0);
+#endif
+
        while (likely(total_rx_packets < budget)) {
                struct ixgbevf_rx_buffer *rx_buffer;
                union ixgbe_adv_rx_desc *rx_desc;
@@ -1157,7 +1174,10 @@ static int ixgbevf_clean_rx_irq(struct ixgbevf_q_vector *q_vector,
                        xdp.data_hard_start = xdp.data -
                                              ixgbevf_rx_offset(rx_ring);
                        xdp.data_end = xdp.data + size;
-
+#if (PAGE_SIZE > 4096)
+                       /* At larger PAGE_SIZE, frame_sz depend on len size */
+                       xdp.frame_sz = ixgbevf_rx_frame_truesize(rx_ring, size);
+#endif
                        skb = ixgbevf_run_xdp(adapter, rx_ring, &xdp);
                }