mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-06 13:55:08 +08:00
2d4238f556
Add zero copy AF_XDP support. This patch adds zero copy support for Tx and Rx; code for zero copy is added to ice_xsk.h and ice_xsk.c. For Tx, implement ndo_xsk_wakeup. As with other drivers, reuse existing XDP Tx queues for this task, since XDP_REDIRECT guarantees mutual exclusion between different NAPI contexts based on CPU ID. In turn, a netdev can XDP_REDIRECT to another netdev with a different NAPI context, since the operation is bound to a specific core and each core has its own hardware ring. For Rx, allocate frames as MEM_TYPE_ZERO_COPY on queues that AF_XDP is enabled. Signed-off-by: Krzysztof Kazimierczak <krzysztof.kazimierczak@intel.com> Co-developed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com> Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
73 lines
1.9 KiB
C
73 lines
1.9 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/* Copyright (c) 2019, Intel Corporation. */
|
|
|
|
#ifndef _ICE_XSK_H_
|
|
#define _ICE_XSK_H_
|
|
#include "ice_txrx.h"
|
|
#include "ice.h"
|
|
|
|
struct ice_vsi;
|
|
|
|
#ifdef CONFIG_XDP_SOCKETS
|
|
int ice_xsk_umem_setup(struct ice_vsi *vsi, struct xdp_umem *umem, u16 qid);
|
|
void ice_zca_free(struct zero_copy_allocator *zca, unsigned long handle);
|
|
int ice_clean_rx_irq_zc(struct ice_ring *rx_ring, int budget);
|
|
bool ice_clean_tx_irq_zc(struct ice_ring *xdp_ring, int budget);
|
|
int ice_xsk_wakeup(struct net_device *netdev, u32 queue_id, u32 flags);
|
|
bool ice_alloc_rx_bufs_slow_zc(struct ice_ring *rx_ring, u16 count);
|
|
bool ice_xsk_any_rx_ring_ena(struct ice_vsi *vsi);
|
|
void ice_xsk_clean_rx_ring(struct ice_ring *rx_ring);
|
|
void ice_xsk_clean_xdp_ring(struct ice_ring *xdp_ring);
|
|
#else
|
|
static inline int
|
|
ice_xsk_umem_setup(struct ice_vsi __always_unused *vsi,
|
|
struct xdp_umem __always_unused *umem,
|
|
u16 __always_unused qid)
|
|
{
|
|
return -ENOTSUPP;
|
|
}
|
|
|
|
static inline void
|
|
ice_zca_free(struct zero_copy_allocator __always_unused *zca,
|
|
unsigned long __always_unused handle)
|
|
{
|
|
}
|
|
|
|
static inline int
|
|
ice_clean_rx_irq_zc(struct ice_ring __always_unused *rx_ring,
|
|
int __always_unused budget)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline bool
|
|
ice_clean_tx_irq_zc(struct ice_ring __always_unused *xdp_ring,
|
|
int __always_unused budget)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
static inline bool
|
|
ice_alloc_rx_bufs_slow_zc(struct ice_ring __always_unused *rx_ring,
|
|
u16 __always_unused count)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
static inline bool ice_xsk_any_rx_ring_ena(struct ice_vsi __always_unused *vsi)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
static inline int
|
|
ice_xsk_wakeup(struct net_device __always_unused *netdev,
|
|
u32 __always_unused queue_id, u32 __always_unused flags)
|
|
{
|
|
return -ENOTSUPP;
|
|
}
|
|
|
|
#define ice_xsk_clean_rx_ring(rx_ring) do {} while (0)
|
|
#define ice_xsk_clean_xdp_ring(xdp_ring) do {} while (0)
|
|
#endif /* CONFIG_XDP_SOCKETS */
|
|
#endif /* !_ICE_XSK_H_ */
|