mirror of https://gitee.com/openkylin/linux.git
xsk: expose xdp_umem_get_{data,dma} to drivers
Move the xdp_umem_get_{data,dma} functions to include/net/xdp_sock.h, so that the upcoming zero-copy implementation in the Ethernet drivers can utilize them. Also, supply some dummy function implementations for CONFIG_XDP_SOCKETS=n configs. Signed-off-by: Björn Töpel <bjorn.topel@intel.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
parent
dce5bd6140
commit
9025403420
|
@ -79,6 +79,16 @@ void xsk_umem_discard_addr(struct xdp_umem *umem);
|
|||
void xsk_umem_complete_tx(struct xdp_umem *umem, u32 nb_entries);
|
||||
bool xsk_umem_consume_tx(struct xdp_umem *umem, dma_addr_t *dma, u32 *len);
|
||||
void xsk_umem_consume_tx_done(struct xdp_umem *umem);
|
||||
|
||||
static inline char *xdp_umem_get_data(struct xdp_umem *umem, u64 addr)
|
||||
{
|
||||
return umem->pages[addr >> PAGE_SHIFT].addr + (addr & (PAGE_SIZE - 1));
|
||||
}
|
||||
|
||||
static inline dma_addr_t xdp_umem_get_dma(struct xdp_umem *umem, u64 addr)
|
||||
{
|
||||
return umem->pages[addr >> PAGE_SHIFT].dma + (addr & (PAGE_SIZE - 1));
|
||||
}
|
||||
#else
|
||||
static inline int xsk_generic_rcv(struct xdp_sock *xs, struct xdp_buff *xdp)
|
||||
{
|
||||
|
@ -98,6 +108,39 @@ static inline bool xsk_is_setup_for_bpf_map(struct xdp_sock *xs)
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline u64 *xsk_umem_peek_addr(struct xdp_umem *umem, u64 *addr)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline void xsk_umem_discard_addr(struct xdp_umem *umem)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void xsk_umem_complete_tx(struct xdp_umem *umem, u32 nb_entries)
|
||||
{
|
||||
}
|
||||
|
||||
static inline bool xsk_umem_consume_tx(struct xdp_umem *umem, dma_addr_t *dma,
|
||||
u32 *len)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline void xsk_umem_consume_tx_done(struct xdp_umem *umem)
|
||||
{
|
||||
}
|
||||
|
||||
static inline char *xdp_umem_get_data(struct xdp_umem *umem, u64 addr)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline dma_addr_t xdp_umem_get_dma(struct xdp_umem *umem, u64 addr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_XDP_SOCKETS */
|
||||
|
||||
#endif /* _LINUX_XDP_SOCK_H */
|
||||
|
|
|
@ -8,16 +8,6 @@
|
|||
|
||||
#include <net/xdp_sock.h>
|
||||
|
||||
static inline char *xdp_umem_get_data(struct xdp_umem *umem, u64 addr)
|
||||
{
|
||||
return umem->pages[addr >> PAGE_SHIFT].addr + (addr & (PAGE_SIZE - 1));
|
||||
}
|
||||
|
||||
static inline dma_addr_t xdp_umem_get_dma(struct xdp_umem *umem, u64 addr)
|
||||
{
|
||||
return umem->pages[addr >> PAGE_SHIFT].dma + (addr & (PAGE_SIZE - 1));
|
||||
}
|
||||
|
||||
int xdp_umem_assign_dev(struct xdp_umem *umem, struct net_device *dev,
|
||||
u32 queue_id, u16 flags);
|
||||
bool xdp_umem_validate_queues(struct xdp_umem *umem);
|
||||
|
|
Loading…
Reference in New Issue