Commit 0a312cf8 authored by Alexei Starovoitov's avatar Alexei Starovoitov
Browse files

Merge branch 'xdp: introduce xdp-feature support'



Lorenzo Bianconi says:

====================

Introduce the capability to export the XDP features supported by the NIC.
Introduce a XDP compliance test tool (xdp_features) to check the features
exported by the NIC match the real features supported by the driver.
Allow XDP_REDIRECT of non-linear XDP frames into a devmap.
Export XDP features for each XDP capable driver.
Extend libbpf netlink implementation in order to support netlink_generic
protocol.
Introduce a simple generic netlink family for netdev data.

Changes since v4:
- rebase on top of bpf-next
- get rid of XDP_FEATURE_* enum in XDP compliance test tool
- rely on AF_INET6 address family and on IPv6-mapped-IPv6 addresses for IPv4
  in XDP compliance test tool
- add tsnep driver support

Changes since v3:
- add IPv6 support to XDP compliance test tool
- rely on network_helpers in XDP compliance test tool
- cosmetics changes

Changes since v2:
- rebase on top of bpf-next
- fix compilation error

Changes since v1:
- add Documentation to netdev.yaml
- use flags instead of enum as type for netdev.yaml definitions
- squash XDP_PASS, XDP_DROP, XDP_TX and XDP_ABORTED into XDP_BASIC since they
  are supported by all drivers.
- add notifier event to xdp_features_set_redirect_target() and
  xdp_features_clear_redirect_target()
- add selftest for xdp-features support in bpf_xdp_detach()
- add IPv6 preliminary support to XDP compliance test tool

Changes since RFCv2:
- do not assume fixed layout for genl kernel messages
- fix warnings in netdev_nl_dev_fill
- fix capabilities for nfp driver
- add supported_sg parameter to xdp_features_set_redirect_target and drop
  __xdp_features_set_redirect_target routine

Changes since RFCv1:
- Introduce netdev-genl implementation and get rid of rtnl one.
- Introduce netlink_generic support in libbpf netlink implementation
- Rename XDP_FEATURE_* in NETDEV_XDP_ACT_*
- Rename XDP_FEATURE_REDIRECT_TARGET in NETDEV_XDP_ACT_NDO_XMIT
- Rename XDP_FEATURE_FRAG_RX in NETDEV_XDP_ACT_RX_SG
- Rename XDP_FEATURE_FRAG_TARFET in NETDEV_XDP_ACT_NDO_XMIT
- Get rid of XDP_LOCK feature.
- Move xdp_feature field in a netdevice struct hole in the 4th cacheline.

Jakub Kicinski (1):
  netdev-genl: create a simple family for netdev stuff

Lorenzo Bianconi (5):
  libbpf: add the capability to specify netlink proto in
    libbpf_netlink_send_recv
  libbpf: add API to get XDP/XSK supported features
  bpf: devmap: check XDP features in __xdp_enqueue routine
  selftests/bpf: add test for bpf_xdp_query xdp-features support
  selftests/bpf: introduce XDP compliance test tool
====================

Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parents 15080908 4dba3e78
Loading
Loading
Loading
Loading
+100 −0
Original line number Diff line number Diff line
name: netdev

doc:
  netdev configuration over generic netlink.

definitions:
  -
    type: flags
    name: xdp-act
    entries:
      -
        name: basic
        doc:
          XDP feautues set supported by all drivers
          (XDP_ABORTED, XDP_DROP, XDP_PASS, XDP_TX)
      -
        name: redirect
        doc:
          The netdev supports XDP_REDIRECT
      -
        name: ndo-xmit
        doc:
          This feature informs if netdev implements ndo_xdp_xmit callback.
      -
        name: xsk-zerocopy
        doc:
          This feature informs if netdev supports AF_XDP in zero copy mode.
      -
        name: hw-offload
        doc:
         This feature informs if netdev supports XDP hw oflloading.
      -
        name: rx-sg
        doc:
          This feature informs if netdev implements non-linear XDP buffer
          support in the driver napi callback.
      -
        name: ndo-xmit-sg
        doc:
          This feature informs if netdev implements non-linear XDP buffer
          support in ndo_xdp_xmit callback.

attribute-sets:
  -
    name: dev
    attributes:
      -
        name: ifindex
        doc: netdev ifindex
        type: u32
        value: 1
        checks:
          min: 1
      -
        name: pad
        type: pad
      -
        name: xdp-features
        doc: Bitmask of enabled xdp-features.
        type: u64
        enum: xdp-act
        enum-as-flags: true

operations:
  list:
    -
      name: dev-get
      doc: Get / dump information about a netdev.
      value: 1
      attribute-set: dev
      do:
        request:
          attributes:
            - ifindex
        reply: &dev-all
          attributes:
            - ifindex
            - xdp-features
      dump:
        reply: *dev-all
    -
      name: dev-add-ntf
      doc: Notification about device appearing.
      notify: dev-get
      mcgrp: mgmt
    -
      name: dev-del-ntf
      doc: Notification about device disappearing.
      notify: dev-get
      mcgrp: mgmt
    -
      name: dev-change-ntf
      doc: Notification about device configuration being changed.
      notify: dev-get
      mcgrp: mgmt

mcast-groups:
  list:
    -
      name: mgmt
+4 −0
Original line number Diff line number Diff line
@@ -597,7 +597,9 @@ static int ena_xdp_set(struct net_device *netdev, struct netdev_bpf *bpf)
				if (rc)
					return rc;
			}
			xdp_features_set_redirect_target(netdev, false);
		} else if (old_bpf_prog) {
			xdp_features_clear_redirect_target(netdev);
			rc = ena_destroy_and_free_all_xdp_queues(adapter);
			if (rc)
				return rc;
@@ -4103,6 +4105,8 @@ static void ena_set_conf_feat_params(struct ena_adapter *adapter,
	/* Set offload features */
	ena_set_dev_offloads(feat, netdev);

	netdev->xdp_features = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT;

	adapter->max_mtu = feat->dev_attr.max_mtu;
	netdev->max_mtu = adapter->max_mtu;
	netdev->min_mtu = ENA_MIN_MTU;
+5 −0
Original line number Diff line number Diff line
@@ -384,6 +384,11 @@ void aq_nic_ndev_init(struct aq_nic_s *self)
	self->ndev->mtu = aq_nic_cfg->mtu - ETH_HLEN;
	self->ndev->max_mtu = aq_hw_caps->mtu - ETH_FCS_LEN - ETH_HLEN;

	self->ndev->xdp_features = NETDEV_XDP_ACT_BASIC |
				   NETDEV_XDP_ACT_REDIRECT |
				   NETDEV_XDP_ACT_NDO_XMIT |
				   NETDEV_XDP_ACT_RX_SG |
				   NETDEV_XDP_ACT_NDO_XMIT_SG;
}

void aq_nic_set_tx_ring(struct aq_nic_s *self, unsigned int idx,
+3 −0
Original line number Diff line number Diff line
@@ -13686,6 +13686,9 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)

	netif_set_tso_max_size(dev, GSO_MAX_SIZE);

	dev->xdp_features = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT |
			    NETDEV_XDP_ACT_RX_SG;

#ifdef CONFIG_BNXT_SRIOV
	init_waitqueue_head(&bp->sriov_cfg_wait);
#endif
+2 −0
Original line number Diff line number Diff line
@@ -422,9 +422,11 @@ static int bnxt_xdp_set(struct bnxt *bp, struct bpf_prog *prog)

	if (prog) {
		bnxt_set_rx_skb_mode(bp, true);
		xdp_features_set_redirect_target(dev, true);
	} else {
		int rx, tx;

		xdp_features_clear_redirect_target(dev);
		bnxt_set_rx_skb_mode(bp, false);
		bnxt_get_max_rings(bp, &rx, &tx, true);
		if (rx > 1) {
Loading