Commit 68e331c7 authored by Roopa Prabhu's avatar Roopa Prabhu Committed by David S. Miller

bridge: offload bridge port attributes to switch asic if feature flag set

This patch adds support to set/del bridge port attributes in hardware from
the bridge driver.

With this, when the user sends a bridge setlink message with no flags or
master flags set,
   - the bridge driver ndo_bridge_setlink handler sets settings in the kernel
   - calls the swicthdev api to propagate the attrs to the switchdev
	hardware

   You can still use the self flag to go to the switch hw or switch port
   driver directly.

With this, it also makes sure a notification goes out only after the
attributes are set both in the kernel and hw.

The patch calls switchdev api only if BRIDGE_FLAGS_SELF is not set.
This is because the offload cases with BRIDGE_FLAGS_SELF are handled in
the caller (in rtnetlink.c).
Signed-off-by: default avatarRoopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8a44dbb2
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <net/rtnetlink.h> #include <net/rtnetlink.h>
#include <net/net_namespace.h> #include <net/net_namespace.h>
#include <net/sock.h> #include <net/sock.h>
#include <net/switchdev.h>
#include <uapi/linux/if_bridge.h> #include <uapi/linux/if_bridge.h>
#include "br_private.h" #include "br_private.h"
...@@ -500,7 +501,7 @@ int br_setlink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags) ...@@ -500,7 +501,7 @@ int br_setlink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags)
struct nlattr *afspec; struct nlattr *afspec;
struct net_bridge_port *p; struct net_bridge_port *p;
struct nlattr *tb[IFLA_BRPORT_MAX + 1]; struct nlattr *tb[IFLA_BRPORT_MAX + 1];
int err = 0; int err = 0, ret_offload = 0;
protinfo = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), IFLA_PROTINFO); protinfo = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), IFLA_PROTINFO);
afspec = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), IFLA_AF_SPEC); afspec = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), IFLA_AF_SPEC);
...@@ -542,9 +543,18 @@ int br_setlink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags) ...@@ -542,9 +543,18 @@ int br_setlink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags)
afspec, RTM_SETLINK); afspec, RTM_SETLINK);
} }
if (!(flags & BRIDGE_FLAGS_SELF)) {
/* set bridge attributes in hardware if supported
*/
ret_offload = netdev_switch_port_bridge_setlink(dev, nlh,
flags);
if (ret_offload && ret_offload != -EOPNOTSUPP)
br_warn(p->br, "error setting attrs on port %u(%s)\n",
(unsigned int)p->port_no, p->dev->name);
}
if (err == 0) if (err == 0)
br_ifinfo_notify(RTM_NEWLINK, p); br_ifinfo_notify(RTM_NEWLINK, p);
out: out:
return err; return err;
} }
...@@ -554,7 +564,7 @@ int br_dellink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags) ...@@ -554,7 +564,7 @@ int br_dellink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags)
{ {
struct nlattr *afspec; struct nlattr *afspec;
struct net_bridge_port *p; struct net_bridge_port *p;
int err; int err = 0, ret_offload = 0;
afspec = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), IFLA_AF_SPEC); afspec = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), IFLA_AF_SPEC);
if (!afspec) if (!afspec)
...@@ -573,6 +583,16 @@ int br_dellink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags) ...@@ -573,6 +583,16 @@ int br_dellink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags)
*/ */
br_ifinfo_notify(RTM_NEWLINK, p); br_ifinfo_notify(RTM_NEWLINK, p);
if (!(flags & BRIDGE_FLAGS_SELF)) {
/* del bridge attributes in hardware
*/
ret_offload = netdev_switch_port_bridge_dellink(dev, nlh,
flags);
if (ret_offload && ret_offload != -EOPNOTSUPP)
br_warn(p->br, "error deleting attrs on port %u (%s)\n",
(unsigned int)p->port_no, p->dev->name);
}
return err; return err;
} }
static int br_validate(struct nlattr *tb[], struct nlattr *data[]) static int br_validate(struct nlattr *tb[], struct nlattr *data[])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment