ice: Support XDP hints in AF_XDP ZC mode
authorLarysa Zaremba <larysa.zaremba@intel.com>
Tue, 5 Dec 2023 21:08:37 +0000 (22:08 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 14 Dec 2023 00:16:40 +0000 (16:16 -0800)
In AF_XDP ZC, xdp_buff is not stored on ring,
instead it is provided by xsk_buff_pool.
Space for metadata sources right after such buffers was already reserved
in commit 94ecc5ca4dbf ("xsk: Add cb area to struct xdp_buff_xsk").

Some things (such as pointer to packet context) do not change on a
per-packet basis, so they can be set at the same time as RX queue info.
On the other hand, RX descriptor is unique for each packet, but is already
known when setting DMA addresses. This minimizes performance impact of
hints on regular packet processing.

Update AF_XDP ZC packet processing to support XDP hints.

Co-developed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com>
Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Link: https://lore.kernel.org/r/20231205210847.28460-9-larysa.zaremba@intel.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
drivers/net/ethernet/intel/ice/ice_base.c
drivers/net/ethernet/intel/ice/ice_xsk.c

index 2d83f3c029e7bec85ffae2e1447bec2537888cbf..a040f02a342e7b3e34a19bfcc399a2dbbcddc03a 100644 (file)
@@ -519,6 +519,19 @@ static int ice_setup_rx_ctx(struct ice_rx_ring *ring)
        return 0;
 }
 
+static void ice_xsk_pool_fill_cb(struct ice_rx_ring *ring)
+{
+       void *ctx_ptr = &ring->pkt_ctx;
+       struct xsk_cb_desc desc = {};
+
+       XSK_CHECK_PRIV_TYPE(struct ice_xdp_buff);
+       desc.src = &ctx_ptr;
+       desc.off = offsetof(struct ice_xdp_buff, pkt_ctx) -
+                  sizeof(struct xdp_buff);
+       desc.bytes = sizeof(ctx_ptr);
+       xsk_pool_fill_cb(ring->xsk_pool, &desc);
+}
+
 /**
  * ice_vsi_cfg_rxq - Configure an Rx queue
  * @ring: the ring being configured
@@ -553,6 +566,7 @@ int ice_vsi_cfg_rxq(struct ice_rx_ring *ring)
                        if (err)
                                return err;
                        xsk_pool_set_rxq_info(ring->xsk_pool, &ring->xdp_rxq);
+                       ice_xsk_pool_fill_cb(ring);
 
                        dev_info(dev, "Registered XDP mem model MEM_TYPE_XSK_BUFF_POOL on Rx ring %d\n",
                                 ring->q_index);
index 906e383e864a06d1cee08fe07a19c5e045409fb7..11b6114ab83d1b2bad885973dc28eb09690fe7c5 100644 (file)
@@ -458,6 +458,11 @@ static u16 ice_fill_rx_descs(struct xsk_buff_pool *pool, struct xdp_buff **xdp,
                rx_desc->read.pkt_addr = cpu_to_le64(dma);
                rx_desc->wb.status_error0 = 0;
 
+               /* Put private info that changes on a per-packet basis
+                * into xdp_buff_xsk->cb.
+                */
+               ice_xdp_meta_set_desc(*xdp, rx_desc);
+
                rx_desc++;
                xdp++;
        }