aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2015-02-02 02:16:40 -0500
committerDavid S. Miller <davem@davemloft.net>2015-02-02 02:16:40 -0500
commitfe3ef6165388f28e2b26d55a19721bf12cb9de2f (patch)
tree8d3ada6f1604dff4639c41c87f11513b4df2f224
parentb2dec116fb9f3d8c7dd2e878fa1b9b88262985f7 (diff)
parenta16a8ee7f60327086a35b688c78b555a8b4ac363 (diff)
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: Roopa Prabhu <roopa@cumulusnetworks.com>
-rw-r--r--drivers/net/bonding/bond_main.c9
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c3
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_main.c2
-rw-r--r--drivers/net/ethernet/rocker/rocker.c5
-rw-r--r--drivers/net/team/team.c5
-rw-r--r--include/linux/netdev_features.h6
-rw-r--r--include/linux/netdevice.h6
-rw-r--r--include/net/switchdev.h37
-rw-r--r--net/bridge/br_netlink.c30
-rw-r--r--net/bridge/br_private.h4
-rw-r--r--net/core/rtnetlink.c10
-rw-r--r--net/switchdev/switchdev.c110
12 files changed, 206 insertions, 21 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index e229a8657de8..c9e519cb9214 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -77,6 +77,7 @@
77#include <net/pkt_sched.h> 77#include <net/pkt_sched.h>
78#include <linux/rculist.h> 78#include <linux/rculist.h>
79#include <net/flow_keys.h> 79#include <net/flow_keys.h>
80#include <net/switchdev.h>
80#include <net/bonding.h> 81#include <net/bonding.h>
81#include <net/bond_3ad.h> 82#include <net/bond_3ad.h>
82#include <net/bond_alb.h> 83#include <net/bond_alb.h>
@@ -979,7 +980,11 @@ static netdev_features_t bond_fix_features(struct net_device *dev,
979 netdev_features_t mask; 980 netdev_features_t mask;
980 struct slave *slave; 981 struct slave *slave;
981 982
982 mask = features; 983 /* If any slave has the offload feature flag set,
984 * set the offload flag on the bond.
985 */
986 mask = features | NETIF_F_HW_SWITCH_OFFLOAD;
987
983 features &= ~NETIF_F_ONE_FOR_ALL; 988 features &= ~NETIF_F_ONE_FOR_ALL;
984 features |= NETIF_F_ALL_FOR_ALL; 989 features |= NETIF_F_ALL_FOR_ALL;
985 990
@@ -3952,6 +3957,8 @@ static const struct net_device_ops bond_netdev_ops = {
3952 .ndo_add_slave = bond_enslave, 3957 .ndo_add_slave = bond_enslave,
3953 .ndo_del_slave = bond_release, 3958 .ndo_del_slave = bond_release,
3954 .ndo_fix_features = bond_fix_features, 3959 .ndo_fix_features = bond_fix_features,
3960 .ndo_bridge_setlink = ndo_dflt_netdev_switch_port_bridge_setlink,
3961 .ndo_bridge_dellink = ndo_dflt_netdev_switch_port_bridge_dellink,
3955}; 3962};
3956 3963
3957static const struct device_type bond_type = { 3964static const struct device_type bond_type = {
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 598c5070c629..efed92c7b731 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -4327,7 +4327,8 @@ fw_exit:
4327 return status; 4327 return status;
4328} 4328}
4329 4329
4330static int be_ndo_bridge_setlink(struct net_device *dev, struct nlmsghdr *nlh) 4330static int be_ndo_bridge_setlink(struct net_device *dev, struct nlmsghdr *nlh,
4331 u16 flags)
4331{ 4332{
4332 struct be_adapter *adapter = netdev_priv(dev); 4333 struct be_adapter *adapter = netdev_priv(dev);
4333 struct nlattr *attr, *br_spec; 4334 struct nlattr *attr, *br_spec;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 7bb421bfd84e..e4086fea4be2 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -7786,7 +7786,7 @@ static int ixgbe_ndo_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
7786} 7786}
7787 7787
7788static int ixgbe_ndo_bridge_setlink(struct net_device *dev, 7788static int ixgbe_ndo_bridge_setlink(struct net_device *dev,
7789 struct nlmsghdr *nlh) 7789 struct nlmsghdr *nlh, u16 flags)
7790{ 7790{
7791 struct ixgbe_adapter *adapter = netdev_priv(dev); 7791 struct ixgbe_adapter *adapter = netdev_priv(dev);
7792 struct nlattr *attr, *br_spec; 7792 struct nlattr *attr, *br_spec;
diff --git a/drivers/net/ethernet/rocker/rocker.c b/drivers/net/ethernet/rocker/rocker.c
index 11f4ffcc113d..3c17ef2e3ff3 100644
--- a/drivers/net/ethernet/rocker/rocker.c
+++ b/drivers/net/ethernet/rocker/rocker.c
@@ -3722,7 +3722,7 @@ skip:
3722} 3722}
3723 3723
3724static int rocker_port_bridge_setlink(struct net_device *dev, 3724static int rocker_port_bridge_setlink(struct net_device *dev,
3725 struct nlmsghdr *nlh) 3725 struct nlmsghdr *nlh, u16 flags)
3726{ 3726{
3727 struct rocker_port *rocker_port = netdev_priv(dev); 3727 struct rocker_port *rocker_port = netdev_priv(dev);
3728 struct nlattr *protinfo; 3728 struct nlattr *protinfo;
@@ -4030,7 +4030,8 @@ static int rocker_probe_port(struct rocker *rocker, unsigned int port_number)
4030 NAPI_POLL_WEIGHT); 4030 NAPI_POLL_WEIGHT);
4031 rocker_carrier_init(rocker_port); 4031 rocker_carrier_init(rocker_port);
4032 4032
4033 dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER; 4033 dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER |
4034 NETIF_F_HW_SWITCH_OFFLOAD;
4034 4035
4035 err = register_netdev(dev); 4036 err = register_netdev(dev);
4036 if (err) { 4037 if (err) {
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index 4b2bfc52c52f..0e62274e884a 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -28,6 +28,7 @@
28#include <net/genetlink.h> 28#include <net/genetlink.h>
29#include <net/netlink.h> 29#include <net/netlink.h>
30#include <net/sch_generic.h> 30#include <net/sch_generic.h>
31#include <net/switchdev.h>
31#include <generated/utsrelease.h> 32#include <generated/utsrelease.h>
32#include <linux/if_team.h> 33#include <linux/if_team.h>
33 34
@@ -1925,7 +1926,7 @@ static netdev_features_t team_fix_features(struct net_device *dev,
1925 struct team *team = netdev_priv(dev); 1926 struct team *team = netdev_priv(dev);
1926 netdev_features_t mask; 1927 netdev_features_t mask;
1927 1928
1928 mask = features; 1929 mask = features | NETIF_F_HW_SWITCH_OFFLOAD;
1929 features &= ~NETIF_F_ONE_FOR_ALL; 1930 features &= ~NETIF_F_ONE_FOR_ALL;
1930 features |= NETIF_F_ALL_FOR_ALL; 1931 features |= NETIF_F_ALL_FOR_ALL;
1931 1932
@@ -1975,6 +1976,8 @@ static const struct net_device_ops team_netdev_ops = {
1975 .ndo_del_slave = team_del_slave, 1976 .ndo_del_slave = team_del_slave,
1976 .ndo_fix_features = team_fix_features, 1977 .ndo_fix_features = team_fix_features,
1977 .ndo_change_carrier = team_change_carrier, 1978 .ndo_change_carrier = team_change_carrier,
1979 .ndo_bridge_setlink = ndo_dflt_netdev_switch_port_bridge_setlink,
1980 .ndo_bridge_dellink = ndo_dflt_netdev_switch_port_bridge_dellink,
1978}; 1981};
1979 1982
1980/*********************** 1983/***********************
diff --git a/include/linux/netdev_features.h b/include/linux/netdev_features.h
index 8e30685affeb..7d59dc6ab789 100644
--- a/include/linux/netdev_features.h
+++ b/include/linux/netdev_features.h
@@ -66,6 +66,7 @@ enum {
66 NETIF_F_HW_VLAN_STAG_FILTER_BIT,/* Receive filtering on VLAN STAGs */ 66 NETIF_F_HW_VLAN_STAG_FILTER_BIT,/* Receive filtering on VLAN STAGs */
67 NETIF_F_HW_L2FW_DOFFLOAD_BIT, /* Allow L2 Forwarding in Hardware */ 67 NETIF_F_HW_L2FW_DOFFLOAD_BIT, /* Allow L2 Forwarding in Hardware */
68 NETIF_F_BUSY_POLL_BIT, /* Busy poll */ 68 NETIF_F_BUSY_POLL_BIT, /* Busy poll */
69 NETIF_F_HW_SWITCH_OFFLOAD_BIT, /* HW switch offload */
69 70
70 /* 71 /*
71 * Add your fresh new feature above and remember to update 72 * Add your fresh new feature above and remember to update
@@ -124,6 +125,7 @@ enum {
124#define NETIF_F_HW_VLAN_STAG_TX __NETIF_F(HW_VLAN_STAG_TX) 125#define NETIF_F_HW_VLAN_STAG_TX __NETIF_F(HW_VLAN_STAG_TX)
125#define NETIF_F_HW_L2FW_DOFFLOAD __NETIF_F(HW_L2FW_DOFFLOAD) 126#define NETIF_F_HW_L2FW_DOFFLOAD __NETIF_F(HW_L2FW_DOFFLOAD)
126#define NETIF_F_BUSY_POLL __NETIF_F(BUSY_POLL) 127#define NETIF_F_BUSY_POLL __NETIF_F(BUSY_POLL)
128#define NETIF_F_HW_SWITCH_OFFLOAD __NETIF_F(HW_SWITCH_OFFLOAD)
127 129
128/* Features valid for ethtool to change */ 130/* Features valid for ethtool to change */
129/* = all defined minus driver/device-class-related */ 131/* = all defined minus driver/device-class-related */
@@ -159,7 +161,9 @@ enum {
159 */ 161 */
160#define NETIF_F_ONE_FOR_ALL (NETIF_F_GSO_SOFTWARE | NETIF_F_GSO_ROBUST | \ 162#define NETIF_F_ONE_FOR_ALL (NETIF_F_GSO_SOFTWARE | NETIF_F_GSO_ROBUST | \
161 NETIF_F_SG | NETIF_F_HIGHDMA | \ 163 NETIF_F_SG | NETIF_F_HIGHDMA | \
162 NETIF_F_FRAGLIST | NETIF_F_VLAN_CHALLENGED) 164 NETIF_F_FRAGLIST | NETIF_F_VLAN_CHALLENGED | \
165 NETIF_F_HW_SWITCH_OFFLOAD)
166