Message ID | 20201202150724.31439-4-magnus.karlsson@gmail.com |
---|---|
State | New |
Headers | show |
Series | i40e, ice, ixgbe: optimize for XDP_REDIRECT in xsk path | expand |
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of Magnus > Karlsson > Sent: Wednesday, December 2, 2020 8:37 PM > To: Karlsson, Magnus <magnus.karlsson@intel.com>; Topel, Bjorn > <bjorn.topel@intel.com>; intel-wired-lan@lists.osuosl.org; Nguyen, Anthony L > <anthony.l.nguyen@intel.com> > Cc: netdev@vger.kernel.org; maciejromanfijalkowski@gmail.com > Subject: [Intel-wired-lan] [PATCH net-next 3/3] ice: optimize for XDP_REDIRECT in > xsk path > > From: Magnus Karlsson <magnus.karlsson@intel.com> > > Optimize ice_run_xdp_zc() for the XDP program verdict being XDP_REDIRECT in > the zsk zero-copy path. This path is only used when having AF_XDP zero-copy on > and in that case most packets will be directed to user space. This provides a little > over 100k extra packets in throughput on my server when running l2fwd in > xdpsock. > > Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com> > --- > drivers/net/ethernet/intel/ice/ice_xsk.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > Tested-by: George Kuruvinakunnel <george.kuruvinakunnel@intel.com>
diff --git a/drivers/net/ethernet/intel/ice/ice_xsk.c b/drivers/net/ethernet/intel/ice/ice_xsk.c index 797886524054..3b180e52112f 100644 --- a/drivers/net/ethernet/intel/ice/ice_xsk.c +++ b/drivers/net/ethernet/intel/ice/ice_xsk.c @@ -521,6 +521,14 @@ ice_run_xdp_zc(struct ice_ring *rx_ring, struct xdp_buff *xdp) } act = bpf_prog_run_xdp(xdp_prog, xdp); + + if (likely(act == XDP_REDIRECT)) { + err = xdp_do_redirect(rx_ring->netdev, xdp, xdp_prog); + result = !err ? ICE_XDP_REDIR : ICE_XDP_CONSUMED; + rcu_read_unlock(); + return result; + } + switch (act) { case XDP_PASS: break; @@ -528,10 +536,6 @@ ice_run_xdp_zc(struct ice_ring *rx_ring, struct xdp_buff *xdp) xdp_ring = rx_ring->vsi->xdp_rings[rx_ring->q_index]; result = ice_xmit_xdp_buff(xdp, xdp_ring); break; - case XDP_REDIRECT: - err = xdp_do_redirect(rx_ring->netdev, xdp, xdp_prog); - result = !err ? ICE_XDP_REDIR : ICE_XDP_CONSUMED; - break; default: bpf_warn_invalid_xdp_action(act); fallthrough;