Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fe3ef616 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'switchdev_offload_flags'

Roopa Prabhu says:

====================
switchdev offload flags

This patch series introduces new offload flags for switchdev.
Kernel network subsystems can use this flag to accelerate
network functions by offloading to hw.

I expect that there will be need for subsystem specific feature
flag in the future.

This patch series currently only addresses bridge driver link
attribute offloads to hardware.

Looking at the current state of bridge l2 offload in the kernel,
    - flag 'self' is the way to directly manage the bridge device in hw via
      the ndo_bridge_setlink/ndo_bridge_getlink calls

    - flag 'master' is always used to manage the in kernel bridge devices
      via the same ndo_bridge_setlink/ndo_bridge_getlink calls

Today these are used separately. The nic offloads use hwmode "vepa/veb" to go
directly to hw with the "self" flag.

At this point i am trying not to introduce any new user facing flags/attributes.
In the model where we want the kernel bridging to be accelerated with
hardware, we very much want the bridge driver to be involved.

In this proposal,
- The offload flag/bit helps switch asic drivers to indicate that they
  accelerate the kernel networking objects/functions
- The user does not have to specify a new flag to do so. A bridge created with
  switch asic ports will be accelerated if the switch driver supports it.
- The user can continue to directly manage l2 in nics (ixgbe) using the
  existing hwmode/self flags
- It also does not stop users from using the 'self' flag to talk to the
  switch asic driver directly
- Involving the bridge driver makes sure the add/del notifications to user
  space go out after both kernel and hardware are programmed

(To selectively offload bridge port attributes,
example learning in hw only etc, we can introduce offload bits for
per bridge port flag attribute as in my previous patch
https://patchwork.ozlabs.org/patch/413211/

. I have not included that in this
series)

v2
   - try a different name for the offload flag/bit
   - tries to solve the stacked netdev case by traversing the lowerdev
     list to reach the switch port

v3 -
    - Tested with bond as bridge port for the stacked device case.
      Includes a bond_fix_features change to not ignore the
      NETIF_F_HW_NETFUNC_OFFLOAD flag
    - Some checkpatch fixes

v4 -
    - rename flag to NETIF_F_HW_SWITCH_OFFLOAD
    - add ndo_bridge_setlink/dellink handlers in bond and team drivers as
      suggested by jiri.
    - introduce default ndo_dflt_netdev_switch_port_bridge_setlink/dellink
    handlers that masters can use to call offload api on lowerdevs.
====================

Signed-off-by: default avatarRoopa Prabhu <roopa@cumulusnetworks.com>
parents b2dec116 a16a8ee7
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@
#include <net/pkt_sched.h>
#include <linux/rculist.h>
#include <net/flow_keys.h>
#include <net/switchdev.h>
#include <net/bonding.h>
#include <net/bond_3ad.h>
#include <net/bond_alb.h>
@@ -979,7 +980,11 @@ static netdev_features_t bond_fix_features(struct net_device *dev,
	netdev_features_t mask;
	struct slave *slave;

	mask = features;
	/* If any slave has the offload feature flag set,
	 * set the offload flag on the bond.
	 */
	mask = features | NETIF_F_HW_SWITCH_OFFLOAD;

	features &= ~NETIF_F_ONE_FOR_ALL;
	features |= NETIF_F_ALL_FOR_ALL;

@@ -3952,6 +3957,8 @@ static const struct net_device_ops bond_netdev_ops = {
	.ndo_add_slave		= bond_enslave,
	.ndo_del_slave		= bond_release,
	.ndo_fix_features	= bond_fix_features,
	.ndo_bridge_setlink	= ndo_dflt_netdev_switch_port_bridge_setlink,
	.ndo_bridge_dellink	= ndo_dflt_netdev_switch_port_bridge_dellink,
};

static const struct device_type bond_type = {
+2 −1
Original line number Diff line number Diff line
@@ -4327,7 +4327,8 @@ int be_load_fw(struct be_adapter *adapter, u8 *fw_file)
	return status;
}

static int be_ndo_bridge_setlink(struct net_device *dev, struct nlmsghdr *nlh)
static int be_ndo_bridge_setlink(struct net_device *dev, struct nlmsghdr *nlh,
				 u16 flags)
{
	struct be_adapter *adapter = netdev_priv(dev);
	struct nlattr *attr, *br_spec;
+1 −1
Original line number Diff line number Diff line
@@ -7786,7 +7786,7 @@ static int ixgbe_ndo_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
}

static int ixgbe_ndo_bridge_setlink(struct net_device *dev,
				    struct nlmsghdr *nlh)
				    struct nlmsghdr *nlh, u16 flags)
{
	struct ixgbe_adapter *adapter = netdev_priv(dev);
	struct nlattr *attr, *br_spec;
+3 −2
Original line number Diff line number Diff line
@@ -3722,7 +3722,7 @@ static int rocker_port_fdb_dump(struct sk_buff *skb,
}

static int rocker_port_bridge_setlink(struct net_device *dev,
				      struct nlmsghdr *nlh)
				      struct nlmsghdr *nlh, u16 flags)
{
	struct rocker_port *rocker_port = netdev_priv(dev);
	struct nlattr *protinfo;
@@ -4030,7 +4030,8 @@ static int rocker_probe_port(struct rocker *rocker, unsigned int port_number)
		       NAPI_POLL_WEIGHT);
	rocker_carrier_init(rocker_port);

	dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
	dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER |
				NETIF_F_HW_SWITCH_OFFLOAD;

	err = register_netdev(dev);
	if (err) {
+4 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
#include <net/genetlink.h>
#include <net/netlink.h>
#include <net/sch_generic.h>
#include <net/switchdev.h>
#include <generated/utsrelease.h>
#include <linux/if_team.h>

@@ -1925,7 +1926,7 @@ static netdev_features_t team_fix_features(struct net_device *dev,
	struct team *team = netdev_priv(dev);
	netdev_features_t mask;

	mask = features;
	mask = features | NETIF_F_HW_SWITCH_OFFLOAD;
	features &= ~NETIF_F_ONE_FOR_ALL;
	features |= NETIF_F_ALL_FOR_ALL;

@@ -1975,6 +1976,8 @@ static const struct net_device_ops team_netdev_ops = {
	.ndo_del_slave		= team_del_slave,
	.ndo_fix_features	= team_fix_features,
	.ndo_change_carrier     = team_change_carrier,
	.ndo_bridge_setlink     = ndo_dflt_netdev_switch_port_bridge_setlink,
	.ndo_bridge_dellink     = ndo_dflt_netdev_switch_port_bridge_dellink,
};

/***********************
Loading