162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later
262306a36Sopenharmony_ci *
362306a36Sopenharmony_ci * Linux driver for VMware's vmxnet3 ethernet NIC.
462306a36Sopenharmony_ci * Copyright (C) 2008-2023, VMware, Inc. All Rights Reserved.
562306a36Sopenharmony_ci * Maintained by: pv-drivers@vmware.com
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci */
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#ifndef _VMXNET3_XDP_H
1062306a36Sopenharmony_ci#define _VMXNET3_XDP_H
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci#include <linux/filter.h>
1362306a36Sopenharmony_ci#include <linux/bpf_trace.h>
1462306a36Sopenharmony_ci#include <linux/netlink.h>
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci#include "vmxnet3_int.h"
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci#define VMXNET3_XDP_HEADROOM	(XDP_PACKET_HEADROOM + NET_IP_ALIGN)
1962306a36Sopenharmony_ci#define VMXNET3_XDP_RX_TAILROOM	SKB_DATA_ALIGN(sizeof(struct skb_shared_info))
2062306a36Sopenharmony_ci#define VMXNET3_XDP_RX_OFFSET	VMXNET3_XDP_HEADROOM
2162306a36Sopenharmony_ci#define VMXNET3_XDP_MAX_FRSIZE	(PAGE_SIZE - VMXNET3_XDP_HEADROOM - \
2262306a36Sopenharmony_ci				 VMXNET3_XDP_RX_TAILROOM)
2362306a36Sopenharmony_ci#define VMXNET3_XDP_MAX_MTU	(VMXNET3_XDP_MAX_FRSIZE - ETH_HLEN - \
2462306a36Sopenharmony_ci				 2 * VLAN_HLEN - ETH_FCS_LEN)
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ciint vmxnet3_xdp(struct net_device *netdev, struct netdev_bpf *bpf);
2762306a36Sopenharmony_ciint vmxnet3_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames,
2862306a36Sopenharmony_ci		     u32 flags);
2962306a36Sopenharmony_ciint vmxnet3_process_xdp(struct vmxnet3_adapter *adapter,
3062306a36Sopenharmony_ci			struct vmxnet3_rx_queue *rq,
3162306a36Sopenharmony_ci			struct Vmxnet3_RxCompDesc *rcd,
3262306a36Sopenharmony_ci			struct vmxnet3_rx_buf_info *rbi,
3362306a36Sopenharmony_ci			struct Vmxnet3_RxDesc *rxd,
3462306a36Sopenharmony_ci			struct sk_buff **skb_xdp_pass);
3562306a36Sopenharmony_ciint vmxnet3_process_xdp_small(struct vmxnet3_adapter *adapter,
3662306a36Sopenharmony_ci			      struct vmxnet3_rx_queue *rq,
3762306a36Sopenharmony_ci			      void *data, int len,
3862306a36Sopenharmony_ci			      struct sk_buff **skb_xdp_pass);
3962306a36Sopenharmony_civoid *vmxnet3_pp_get_buff(struct page_pool *pp, dma_addr_t *dma_addr,
4062306a36Sopenharmony_ci			  gfp_t gfp_mask);
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_cistatic inline bool vmxnet3_xdp_enabled(struct vmxnet3_adapter *adapter)
4362306a36Sopenharmony_ci{
4462306a36Sopenharmony_ci	return !!rcu_access_pointer(adapter->xdp_bpf_prog);
4562306a36Sopenharmony_ci}
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ci#endif
48