Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
sudo: required
language: bash
dist: bionic
services:
- docker

env:
global:
- PROJECT_NAME='libbpf'
- AUTHOR_EMAIL="$(git log -1 --pretty=\"%aE\")"
- REPO_ROOT="$TRAVIS_BUILD_DIR"
- CI_ROOT="$REPO_ROOT/travis-ci"
- VMTEST_ROOT="$CI_ROOT/vmtest"

addons:
apt:
packages:
- qemu-kvm
- zstd
- binutils-dev
- elfutils
- libcap-dev
- libelf-dev
- libdw-dev
- python3-docutils

jobs:
include:
- stage: Builds & Tests
name: Kernel LATEST + selftests
language: bash
env: KERNEL=LATEST
script: $CI_ROOT/vmtest/run_vmtest.sh || travis_terminate 1
1 change: 1 addition & 0 deletions drivers/net/ethernet/broadcom/bnxt/bnxt.c
Original file line number Diff line number Diff line change
Expand Up @@ -12604,6 +12604,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
dev->features |= dev->hw_features | NETIF_F_HIGHDMA;
if (dev->features & NETIF_F_GRO_HW)
dev->features &= ~NETIF_F_LRO;
xdp_set_feature_flag(&dev->features);
dev->priv_flags |= IFF_UNICAST_FLT;

#ifdef CONFIG_BNXT_SRIOV
Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -4014,6 +4014,7 @@ static int dpaa2_eth_netdev_init(struct net_device *net_dev)
NETIF_F_SG | NETIF_F_HIGHDMA |
NETIF_F_LLTX | NETIF_F_HW_TC;
net_dev->hw_features = net_dev->features;
xdp_set_feature_flag(&net_dev->features);

return 0;
}
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/ethernet/intel/i40e/i40e_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -12873,6 +12873,8 @@ static int i40e_config_netdev(struct i40e_vsi *vsi)
netdev->hw_features |= hw_features;

netdev->features |= hw_features | NETIF_F_HW_VLAN_CTAG_FILTER;
xdp_set_feature_flag(&netdev->features);
xsk_set_feature_flag(&netdev->features);
netdev->hw_enc_features |= NETIF_F_TSO_MANGLEID;

if (vsi->type == I40E_VSI_MAIN) {
Expand Down
4 changes: 4 additions & 0 deletions drivers/net/ethernet/intel/ice/ice_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "ice_dcb_lib.h"
#include "ice_dcb_nl.h"
#include "ice_devlink.h"
#include <net/xdp_sock_drv.h>

#define DRV_SUMMARY "Intel(R) Ethernet Connection E800 Series Linux Driver"
static const char ice_driver_string[] = DRV_SUMMARY;
Expand Down Expand Up @@ -2941,6 +2942,9 @@ static void ice_set_netdev_features(struct net_device *netdev)

/* enable features */
netdev->features |= netdev->hw_features;
xdp_set_feature_flag(&netdev->features);
xsk_set_feature_flag(&netdev->features);

/* encap and VLAN devices inherit default, csumo and tso features */
netdev->hw_enc_features |= dflt_features | csumo_features |
tso_features;
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/ethernet/intel/igb/igb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3293,6 +3293,8 @@ static int igb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
NETIF_F_HW_VLAN_CTAG_RX |
NETIF_F_HW_VLAN_CTAG_TX;

xdp_set_feature_flag(&netdev->features);

netdev->priv_flags |= IFF_SUPP_NOFCS;

netdev->priv_flags |= IFF_UNICAST_FLT;
Expand Down
3 changes: 3 additions & 0 deletions drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -10880,6 +10880,9 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED)
netdev->features |= NETIF_F_LRO;

xdp_set_feature_flag(&netdev->features);
xsk_set_feature_flag(&netdev->features);

if (ixgbe_check_fw_error(adapter)) {
err = -EIO;
goto err_sw_init;
Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/marvell/mvneta.c
Original file line number Diff line number Diff line change
Expand Up @@ -5262,6 +5262,7 @@ static int mvneta_probe(struct platform_device *pdev)
NETIF_F_TSO | NETIF_F_RXCSUM;
dev->hw_features |= dev->features;
dev->vlan_features |= dev->features;
xdp_set_feature_flag(&dev->features);
dev->priv_flags |= IFF_LIVE_ADDR_CHANGE;
dev->gso_max_segs = MVNETA_MAX_TSO_SEGS;

Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6475,6 +6475,7 @@ static int mvpp2_port_probe(struct platform_device *pdev,
mvpp2_set_hw_csum(port, port->pool_long->id);

dev->vlan_features |= features;
xdp_set_feature_flag(&dev->features);
dev->gso_max_segs = MVPP2_MAX_TSO_SEGS;
dev->priv_flags |= IFF_UNICAST_FLT;

Expand Down
2 changes: 2 additions & 0 deletions drivers/net/ethernet/mellanox/mlx5/core/en_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4980,6 +4980,8 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev)

netdev->features |= NETIF_F_HIGHDMA;
netdev->features |= NETIF_F_HW_VLAN_STAG_FILTER;
xdp_set_feature_flag(&netdev->features);
xsk_set_feature_flag(&netdev->features);

netdev->priv_flags |= IFF_UNICAST_FLT;

Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/qlogic/qede/qede_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,7 @@ static void qede_init_ndev(struct qede_dev *edev)
ndev->features = hw_features | NETIF_F_RXHASH | NETIF_F_RXCSUM |
NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HIGHDMA |
NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_HW_VLAN_CTAG_TX;
xdp_set_feature_flag(&ndev->features);

ndev->hw_features = hw_features;

Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/sfc/efx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,7 @@ static int efx_pci_probe(struct pci_dev *pci_dev,
efx = netdev_priv(net_dev);
efx->type = (const struct efx_nic_type *) entry->driver_data;
efx->fixed_features |= NETIF_F_HIGHDMA;
xdp_set_feature_flag(&efx->fixed_features);

pci_set_drvdata(pci_dev, efx);
SET_NETDEV_DEV(net_dev, &pci_dev->dev);
Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/socionext/netsec.c
Original file line number Diff line number Diff line change
Expand Up @@ -2099,6 +2099,7 @@ static int netsec_probe(struct platform_device *pdev)
ndev->features |= NETIF_F_HIGHDMA | NETIF_F_RXCSUM | NETIF_F_GSO |
NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
ndev->hw_features = ndev->features;
xdp_set_feature_flag(&ndev->features);

priv->rx_cksum_offload_flag = true;

Expand Down
2 changes: 2 additions & 0 deletions drivers/net/ethernet/ti/cpsw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1475,6 +1475,7 @@ static int cpsw_probe_dual_emac(struct cpsw_priv *priv)
priv_sl2->emac_port = 1;
cpsw->slaves[1].ndev = ndev;
ndev->features |= NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_HW_VLAN_CTAG_RX;
xdp_set_feature_flag(&ndev->features);

ndev->netdev_ops = &cpsw_netdev_ops;
ndev->ethtool_ops = &cpsw_ethtool_ops;
Expand Down Expand Up @@ -1654,6 +1655,7 @@ static int cpsw_probe(struct platform_device *pdev)
cpsw->slaves[0].ndev = ndev;

ndev->features |= NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_HW_VLAN_CTAG_RX;
xdp_set_feature_flag(&ndev->features);

ndev->netdev_ops = &cpsw_netdev_ops;
ndev->ethtool_ops = &cpsw_ethtool_ops;
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/ethernet/ti/cpsw_new.c
Original file line number Diff line number Diff line change
Expand Up @@ -1416,6 +1416,8 @@ static int cpsw_create_ports(struct cpsw_common *cpsw)
ndev->features |= NETIF_F_HW_VLAN_CTAG_FILTER |
NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_NETNS_LOCAL;

xdp_set_feature_flag(&ndev->features);

ndev->netdev_ops = &cpsw_netdev_ops;
ndev->ethtool_ops = &cpsw_ethtool_ops;
SET_NETDEV_DEV(ndev, dev);
Expand Down
4 changes: 4 additions & 0 deletions drivers/net/tun.c
Original file line number Diff line number Diff line change
Expand Up @@ -2721,6 +2721,10 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
~(NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_STAG_TX);

/* Currently tap does not support XDP, only tun does. */
if (tun->flags == IFF_TUN)
xdp_set_feature_flag(&dev->features);

tun->flags = (tun->flags & ~TUN_FEATURES) |
(ifr->ifr_flags & TUN_FEATURES);

Expand Down
1 change: 1 addition & 0 deletions drivers/net/veth.c
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,7 @@ static void veth_setup(struct net_device *dev)
dev->hw_features = VETH_FEATURES;
dev->hw_enc_features = VETH_FEATURES;
dev->mpls_features = NETIF_F_HW_CSUM | NETIF_F_GSO_SOFTWARE;
xdp_set_feature_flag(&dev->features);
}

/*
Expand Down
1 change: 1 addition & 0 deletions drivers/net/virtio_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -3017,6 +3017,7 @@ static int virtnet_probe(struct virtio_device *vdev)
dev->hw_features |= NETIF_F_LRO;

dev->vlan_features = dev->features;
xdp_set_feature_flag(&dev->features);

/* MTU range: 68 - 65535 */
dev->min_mtu = MIN_MTU;
Expand Down
1 change: 1 addition & 0 deletions drivers/net/xen-netfront.c
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,7 @@ static struct net_device *xennet_create_dev(struct xenbus_device *dev)
* negotiate with the backend regarding supported features.
*/
netdev->features |= netdev->hw_features;
xdp_set_feature_flag(&netdev->features);

netdev->ethtool_ops = &xennet_ethtool_ops;
netdev->min_mtu = ETH_MIN_MTU;
Expand Down
6 changes: 6 additions & 0 deletions include/linux/netdev_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ enum {

NETIF_F_HW_MACSEC_BIT, /* Offload MACsec operations */

NETIF_F_XDP_BIT, /* XDP support */
NETIF_F_AF_XDP_ZC_BIT, /* AF_XDP zero-copy support */
/*
* Add your fresh new feature above and remember to update
* netdev_features_strings[] in net/core/ethtool.c and maybe
Expand Down Expand Up @@ -157,6 +159,9 @@ enum {
#define NETIF_F_GRO_FRAGLIST __NETIF_F(GRO_FRAGLIST)
#define NETIF_F_GSO_FRAGLIST __NETIF_F(GSO_FRAGLIST)
#define NETIF_F_HW_MACSEC __NETIF_F(HW_MACSEC)
#define NETIF_F_XDP __NETIF_F(XDP)
#define NETIF_F_AF_XDP_ZC __NETIF_F(AF_XDP_ZC)


/* Finds the next feature with the highest number of the range of start till 0.
*/
Expand All @@ -182,6 +187,7 @@ static inline int find_next_netdev_feature(u64 feature, unsigned long start)
/* Features valid for ethtool to change */
/* = all defined minus driver/device-class-related */
#define NETIF_F_NEVER_CHANGE (NETIF_F_VLAN_CHALLENGED | \
NETIF_F_XDP | NETIF_F_AF_XDP_ZC | \
NETIF_F_LLTX | NETIF_F_NETNS_LOCAL)

/* remember that ((t)1 << t_BITS) is undefined in C99 */
Expand Down
13 changes: 13 additions & 0 deletions include/net/xdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,19 @@ struct xdp_attachment_info {
u32 flags;
};

#if defined(CONFIG_NET) && defined(CONFIG_BPF_SYSCALL)
static __always_inline void
xdp_set_feature_flag(netdev_features_t *features)
{
*features |= NETIF_F_XDP;
}
#else
static __always_inline void
xdp_set_feature_flag(netdev_features_t *features)
{
}
#endif

struct netdev_bpf;
bool xdp_attachment_flags_ok(struct xdp_attachment_info *info,
struct netdev_bpf *bpf);
Expand Down
11 changes: 11 additions & 0 deletions include/net/xdp_sock_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ void xsk_clear_rx_need_wakeup(struct xsk_buff_pool *pool);
void xsk_clear_tx_need_wakeup(struct xsk_buff_pool *pool);
bool xsk_uses_need_wakeup(struct xsk_buff_pool *pool);

static __always_inline void
xsk_set_feature_flag(netdev_features_t *features)
{
*features |= NETIF_F_AF_XDP_ZC;
}

static inline u32 xsk_pool_get_headroom(struct xsk_buff_pool *pool)
{
return XDP_PACKET_HEADROOM + pool->headroom;
Expand Down Expand Up @@ -235,6 +241,11 @@ static inline void xsk_buff_raw_dma_sync_for_device(struct xsk_buff_pool *pool,
{
}

static __always_inline void
xsk_set_feature_flag(netdev_features_t *features)
{
}

#endif /* CONFIG_XDP_SOCKETS */

#endif /* _LINUX_XDP_SOCK_DRV_H */
1 change: 1 addition & 0 deletions include/uapi/linux/if_xdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* application.
*/
#define XDP_USE_NEED_WAKEUP (1 << 3)
#define XDP_CHECK_NATIVE_MODE (1 << 4)

/* Flags for xsk_umem_config flags */
#define XDP_UMEM_UNALIGNED_CHUNK_FLAG (1 << 0)
Expand Down
2 changes: 2 additions & 0 deletions net/ethtool/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ const char netdev_features_strings[NETDEV_FEATURE_COUNT][ETH_GSTRING_LEN] = {
[NETIF_F_HW_TLS_RX_BIT] = "tls-hw-rx-offload",
[NETIF_F_GRO_FRAGLIST_BIT] = "rx-gro-list",
[NETIF_F_HW_MACSEC_BIT] = "macsec-hw-offload",
[NETIF_F_XDP_BIT] = "xdp",
[NETIF_F_AF_XDP_ZC_BIT] = "af-xdp-zc",
};

const char
Expand Down
4 changes: 2 additions & 2 deletions net/xdp/xsk.c
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len)

flags = sxdp->sxdp_flags;
if (flags & ~(XDP_SHARED_UMEM | XDP_COPY | XDP_ZEROCOPY |
XDP_USE_NEED_WAKEUP))
XDP_USE_NEED_WAKEUP | XDP_CHECK_NATIVE_MODE))
return -EINVAL;

rtnl_lock();
Expand Down Expand Up @@ -686,7 +686,7 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len)
struct socket *sock;

if ((flags & XDP_COPY) || (flags & XDP_ZEROCOPY) ||
(flags & XDP_USE_NEED_WAKEUP)) {
(flags & XDP_USE_NEED_WAKEUP) || (flags & XDP_CHECK_NATIVE_MODE)) {
/* Cannot specify flags for shared sockets. */
err = -EINVAL;
goto out_unlock;
Expand Down
21 changes: 18 additions & 3 deletions net/xdp/xsk_buff_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,32 @@ static void xp_disable_drv_zc(struct xsk_buff_pool *pool)
static int __xp_assign_dev(struct xsk_buff_pool *pool,
struct net_device *netdev, u16 queue_id, u16 flags)
{
bool force_zc, force_copy;
bool force_zc, force_copy, force_check;
struct netdev_bpf bpf;
int err = 0;

ASSERT_RTNL();

force_zc = flags & XDP_ZEROCOPY;
force_copy = flags & XDP_COPY;
force_check = flags & XDP_CHECK_NATIVE_MODE;


if (force_zc && force_copy)
return -EINVAL;

if (!(flags & XDP_SHARED_UMEM)) {
if (force_check) {
/* forbid driver mode without full XDP support */
if (!(NETIF_F_XDP & netdev->features))
return -EOPNOTSUPP;
} else {
/* forbid skb mode and zero copy */
if (force_zc)
return -EINVAL;
}
}

if (xsk_get_pool_from_qid(netdev, queue_id))
return -EBUSY;

Expand All @@ -159,8 +173,8 @@ static int __xp_assign_dev(struct xsk_buff_pool *pool,
/* For copy-mode, we are done. */
return 0;

if (!netdev->netdev_ops->ndo_bpf ||
!netdev->netdev_ops->ndo_xsk_wakeup) {
if (!(NETIF_F_XDP & netdev->features &&
NETIF_F_AF_XDP_ZC & netdev->features)) {
err = -EOPNOTSUPP;
goto err_unreg_pool;
}
Expand Down Expand Up @@ -206,6 +220,7 @@ int xp_assign_dev_shared(struct xsk_buff_pool *pool, struct xdp_umem *umem,
return -EINVAL;

flags = umem->zc ? XDP_ZEROCOPY : XDP_COPY;
flags |= XDP_SHARED_UMEM;
if (pool->uses_need_wakeup)
flags |= XDP_USE_NEED_WAKEUP;

Expand Down
Loading