Skip to content

Commit 68e331c

Browse files
roopa-prabhudavem330
authored andcommitted
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: Roopa Prabhu <roopa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 8a44dbb commit 68e331c

1 file changed

Lines changed: 23 additions & 3 deletions

File tree

‎net/bridge/br_netlink.c‎

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <net/rtnetlink.h>
1717
#include <net/net_namespace.h>
1818
#include <net/sock.h>
19+
#include <net/switchdev.h>
1920
#include <uapi/linux/if_bridge.h>
2021

2122
#include "br_private.h"
@@ -500,7 +501,7 @@ int br_setlink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags)
500501
struct nlattr *afspec;
501502
struct net_bridge_port *p;
502503
struct nlattr *tb[IFLA_BRPORT_MAX + 1];
503-
int err = 0;
504+
int err = 0, ret_offload = 0;
504505

505506
protinfo = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), IFLA_PROTINFO);
506507
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)
542543
afspec, RTM_SETLINK);
543544
}
544545

546+
if (!(flags & BRIDGE_FLAGS_SELF)) {
547+
/* set bridge attributes in hardware if supported
548+
*/
549+
ret_offload = netdev_switch_port_bridge_setlink(dev, nlh,
550+
flags);
551+
if (ret_offload && ret_offload != -EOPNOTSUPP)
552+
br_warn(p->br, "error setting attrs on port %u(%s)\n",
553+
(unsigned int)p->port_no, p->dev->name);
554+
}
555+
545556
if (err == 0)
546557
br_ifinfo_notify(RTM_NEWLINK, p);
547-
548558
out:
549559
return err;
550560
}
@@ -554,7 +564,7 @@ int br_dellink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags)
554564
{
555565
struct nlattr *afspec;
556566
struct net_bridge_port *p;
557-
int err;
567+
int err = 0, ret_offload = 0;
558568

559569
afspec = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), IFLA_AF_SPEC);
560570
if (!afspec)
@@ -573,6 +583,16 @@ int br_dellink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags)
573583
*/
574584
br_ifinfo_notify(RTM_NEWLINK, p);
575585

586+
if (!(flags & BRIDGE_FLAGS_SELF)) {
587+
/* del bridge attributes in hardware
588+
*/
589+
ret_offload = netdev_switch_port_bridge_dellink(dev, nlh,
590+
flags);
591+
if (ret_offload && ret_offload != -EOPNOTSUPP)
592+
br_warn(p->br, "error deleting attrs on port %u (%s)\n",
593+
(unsigned int)p->port_no, p->dev->name);
594+
}
595+
576596
return err;
577597
}
578598
static int br_validate(struct nlattr *tb[], struct nlattr *data[])

0 commit comments

Comments
 (0)