From: Tobias Waldekranz <tobias@waldekranz.com>
To: Vladimir Oltean <olteanv@gmail.com>
Cc: davem@davemloft.net, kuba@kernel.org, andrew@lunn.ch,
vivien.didelot@gmail.com, f.fainelli@gmail.com,
j.vosburgh@gmail.com, vfalico@gmail.com, andy@greyhouse.net,
netdev@vger.kernel.org
Subject: Re: [PATCH v4 net-next 3/5] net: dsa: Link aggregation support
Date: Wed, 16 Dec 2020 21:09:58 +0100 [thread overview]
Message-ID: <87k0thbjhl.fsf@waldekranz.com> (raw)
In-Reply-To: <20201216184427.amplixitum6x2zui@skbuf>
On Wed, Dec 16, 2020 at 20:44, Vladimir Oltean <olteanv@gmail.com> wrote:
> On Wed, Dec 16, 2020 at 05:00:54PM +0100, Tobias Waldekranz wrote:
>> diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
>> index 183003e45762..deee4c0ecb31 100644
>> --- a/net/dsa/dsa2.c
>> +++ b/net/dsa/dsa2.c
>> @@ -21,6 +21,46 @@
>> static DEFINE_MUTEX(dsa2_mutex);
>> LIST_HEAD(dsa_tree_list);
>>
>> +void dsa_lag_map(struct dsa_switch_tree *dst, struct net_device *lag)
>
> Maybe a small comment here and in dsa_lag_unmap, describing what they're
> for? They look a bit bland. Just a few words about the linear array will
> suffice.
Not sure I understand why these two are "bland" whereas dsa_switch_find
just below it is not. But sure, I will add a comment. You want a block
comment before each function?
>> +{
>> + unsigned int id;
>> +
>> + if (dsa_lag_id(dst, lag) >= 0)
>> + /* Already mapped */
>> + return;
>> +
>> + for (id = 0; id < dst->lags_len; id++) {
>> + if (!dsa_lag_dev(dst, id)) {
>> + dst->lags[id] = lag;
>> + return;
>> + }
>> + }
>> +
>> + /* No IDs left, which is OK. Some drivers do not need it. The
>> + * ones that do, e.g. mv88e6xxx, will discover that
>> + * dsa_tree_lag_id returns an error for this device when
>> + * joining the LAG. The driver can then return -EOPNOTSUPP
>> + * back to DSA, which will fall back to a software LAG.
>> + */
>> +}
>> +
>> +void dsa_lag_unmap(struct dsa_switch_tree *dst, struct net_device *lag)
>> +{
>> + struct dsa_port *dp;
>> + unsigned int id;
>> +
>> + dsa_lag_foreach_port(dp, dst, lag)
>> + /* There are remaining users of this mapping */
>> + return;
>> +
>> + dsa_lags_foreach_id(id, dst) {
>> + if (dsa_lag_dev(dst, id) == lag) {
>> + dst->lags[id] = NULL;
>> + break;
>> + }
>> + }
>> +}
>> diff --git a/net/dsa/port.c b/net/dsa/port.c
>> index 73569c9af3cc..121e5044dbe7 100644
>> --- a/net/dsa/port.c
>> +++ b/net/dsa/port.c
>> @@ -193,6 +193,85 @@ void dsa_port_bridge_leave(struct dsa_port *dp, struct net_device *br)
>> dsa_port_set_state_now(dp, BR_STATE_FORWARDING);
>> }
>>
>> +int dsa_port_lag_change(struct dsa_port *dp,
>> + struct netdev_lag_lower_state_info *linfo)
>> +{
>> + struct dsa_notifier_lag_info info = {
>> + .sw_index = dp->ds->index,
>> + .port = dp->index,
>> + };
>> + bool tx_enabled;
>> +
>> + if (!dp->lag_dev)
>> + return 0;
>> +
>> + /* On statically configured aggregates (e.g. loadbalance
>> + * without LACP) ports will always be tx_enabled, even if the
>> + * link is down. Thus we require both link_up and tx_enabled
>> + * in order to include it in the tx set.
>> + */
>> + tx_enabled = linfo->link_up && linfo->tx_enabled;
>> +
>> + if (tx_enabled == dp->lag_tx_enabled)
>> + return 0;
>
> Why would we get a NETDEV_CHANGELOWERSTATE notification if tx_enabled ==
> dp->lag_tx_enabled? What is it that changed?
A typical scenario would be:
1. Link goes down: linfo->link_up=false linfo->tx_enabled=false
=> tx_enabled=false
2. Link comes up: linfo->link_up=true linfo->tx_enabled=false
=> tx_enabled=false
3. LACP peers: linfo->link_up=true linfo->tx_enabled=true
=> tx_enabled=true
We get three events, but we only go to the hardware for (1) and (3).
>> +
>> + dp->lag_tx_enabled = tx_enabled;
>> +
>> + return dsa_port_notify(dp, DSA_NOTIFIER_LAG_CHANGE, &info);
>> +}
>
> I am very happy with how simple this turned out. Thanks for the patience.
> You can add these tags when you resend once net-next opens.
>
> Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
> Tested-by: Vladimir Oltean <olteanv@gmail.com>
Thank you. Yeah I also like the way it ended up.
next prev parent reply other threads:[~2020-12-16 20:10 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-16 16:00 [PATCH v4 net-next 0/5] net: dsa: Link aggregation support Tobias Waldekranz
2020-12-16 16:00 ` [PATCH v4 net-next 1/5] net: bonding: Notify ports about their initial state Tobias Waldekranz
2020-12-16 16:28 ` Vladimir Oltean
2020-12-16 16:00 ` [PATCH v4 net-next 2/5] net: dsa: Don't offload port attributes on standalone ports Tobias Waldekranz
2020-12-16 16:27 ` Vladimir Oltean
2020-12-16 19:32 ` Tobias Waldekranz
2020-12-16 16:00 ` [PATCH v4 net-next 3/5] net: dsa: Link aggregation support Tobias Waldekranz
2020-12-16 16:22 ` Vladimir Oltean
2020-12-16 19:47 ` Tobias Waldekranz
2020-12-16 18:02 ` Vladimir Oltean
2020-12-16 19:49 ` Tobias Waldekranz
2020-12-16 18:44 ` Vladimir Oltean
2020-12-16 20:09 ` Tobias Waldekranz [this message]
2020-12-17 18:31 ` Vladimir Oltean
2020-12-16 16:00 ` [PATCH v4 net-next 4/5] net: dsa: mv88e6xxx: " Tobias Waldekranz
2020-12-16 19:04 ` Vladimir Oltean
2020-12-16 20:21 ` Tobias Waldekranz
2020-12-16 16:00 ` [PATCH v4 net-next 5/5] net: dsa: tag_dsa: Support reception of packets from LAG devices Tobias Waldekranz
2020-12-16 19:14 ` Vladimir Oltean
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87k0thbjhl.fsf@waldekranz.com \
--to=tobias@waldekranz.com \
--cc=andrew@lunn.ch \
--cc=andy@greyhouse.net \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=j.vosburgh@gmail.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=vfalico@gmail.com \
--cc=vivien.didelot@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.