Subject: Re: [PATCH 2/3] bridge: offload bridge port attributes to switch asic if feature flag set

From: Roopa Prabhu <[email-masked]>
Date: Fri, 05 Dec 2014 06:37:45 -0800

On 12/4/14, 11:38 PM, Jiri Pirko wrote:
> Fri, Dec 05, 2014 at 03:26:40AM CET, [email-masked] wrote:
>> From: Roopa Prabhu <[email-masked]>
>>
>> This allows offloading to switch asic without having the user to set
>> any flag. And this is done in the bridge driver to rollback kernel settings
>> on hw offload failure if required in the future.
>>
>> With this, it also makes sure a notification goes out only after the
>> attributes are set both in the kernel and hw.
>> ---
>> net/bridge/br_netlink.c |   27 ++++++++++++++++++++++++++-
>> 1 file changed, 26 insertions(+), 1 deletion(-)
>>
>> diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
>> index 9f5eb55..ce173f0 100644
>> --- a/net/bridge/br_netlink.c
>> +++ b/net/bridge/br_netlink.c
>> @@ -407,9 +407,21 @@ int br_setlink(struct net_device *dev, struct nlmsghdr *nlh)
>> 				afspec, RTM_SETLINK);
>> 	}
>>
>> +	if ((dev->features & NETIF_F_HW_SWITCH_OFFLOAD) &&
>> +			dev->netdev_ops->ndo_bridge_setlink) {
>> +		int ret = dev->netdev_ops->ndo_bridge_setlink(dev, nlh);
> 	This (and I suspect other patches as well) has many issues which
> 	are pointed out by scripts/checkpatch.pl sctipts. For example
> 	here, there should be an empty line. Please run your patches by
> 	this script before you send them.
>
>> +		if (ret && ret != -EOPNOTSUPP) {
>> +			/* XXX Fix this in the future to rollback
>> +			 * kernel settings and return error
>> +			 */
>> +			br_warn(p->br, "error offloading bridge attributes "
>> +					"on port %u(%s)\n", (unsigned int) p->port_no,
>> +					p->dev->name);
>> +		}
>> +	}
>> +
>> 	if (err == 0)
>> 		br_ifinfo_notify(RTM_NEWLINK, p);
>> -
>> out:
>> 	return err;
>> }
>> @@ -433,6 +445,19 @@ int br_dellink(struct net_device *dev, struct nlmsghdr *nlh)
>> 	err = br_afspec((struct net_bridge *)netdev_priv(dev), p,
>> 			afspec, RTM_DELLINK);
>>
>> +	if (dev->features & NETIF_F_HW_SWITCH_OFFLOAD
>> +			&& dev->netdev_ops->ndo_bridge_setlink) {
>> +		int ret = dev->netdev_ops->ndo_bridge_dellink(dev, nlh);
> 	c&p issue, there should be check for dellink here.
>
>> +		if (ret && ret != -EOPNOTSUPP) {
>> +			/* XXX Fix this in the future to rollback
>> +			 * kernel settings and return error
>> +			 */
>> +			br_warn(p->br, "error offloading bridge attributes "
>> +					"on port %u(%s)\n", (unsigned int) p->port_no,
>> +					p->dev->name);
>> +		}
>> +	}
>> +
>
> 	I agree with Scott that this code should be moved to rtnetlink.c

I moved it here to make rollback easier. Plus i don't want software 
notification to go out before hardware is programmed.
And the software notification goes out from here.

I don't intend to implement rollback in v2 (that will be a separate series).
  But, i do want to take care of the notification problem.