Re: [patch net-next 6/7] net: dsa: don't do devlink port setup early

Jiri Pirko
2022-08-26T08:38:36Z

Fri, Aug 26, 2022 at 12:47:24AM CEST, olteanv@gmail.com wrote:
>On Thu, Aug 25, 2022 at 12:33:59PM +0200, Jiri Pirko wrote:
>> Note there is no longer needed to reinit port as unused if
>> dsa_port_setup() fails, as it unregisters the devlink port instance on
>> the error path.
>> @@ -957,8 +941,6 @@ static void dsa_switch_teardown(struct dsa_switch *ds)
>> dsa_switch_unregister_notifier(ds);
>>
>> if (ds->devlink) {
>> - dsa_switch_for_each_port(dp, ds)
>> - dsa_port_devlink_teardown(dp);
>> devlink_free(ds->devlink);
>> ds->devlink = NULL;
>> }
>> @@ -1010,11 +992,8 @@ static int dsa_tree_setup_ports(struct dsa_switch_tree *dst)
>> list_for_each_entry(dp, &dst->ports, list) {
>> if (dsa_port_is_user(dp) || dsa_port_is_unused(dp)) {
>> err = dsa_port_setup(dp);
>> - if (err) {
>> - err = dsa_port_reinit_as_unused(dp);
>> - if (err)
>> - goto teardown;
>> - }
>> + if (err)
>> + goto teardown;
>> }
>> }
>
>Please don't delete this, there is still a need.
>
>First of all, dsa_port_setup() for user ports must not fail the probing
>of the switch - see commit 86f8b1c01a0a ("net: dsa: Do not make user
>port errors fatal").

Got it, will leave the unused port here. I will just use
dsa_port_setup() to init it. Something like:

list_for_each_entry(dp, &dst->ports, list) {
if (dsa_port_is_user(dp) || dsa_port_is_unused(dp)) {
err = dsa_port_setup(dp);
if (err) {
dp->type = DSA_PORT_TYPE_UNUSED;
err = dsa_port_setup(dp);
if (err)
goto teardown;
}
}

>
>Also, DSA exposes devlink regions for unused ports too - those have the
>{DSA_PORT_TYPE,DEVLINK_PORT_FLAVOUR}_UNUSED flavor.

Yep.

>
>I also see some weird behavior when I intentionally break the probing of
>some ports, but I haven't debugged to see exactly why, and it's likely
>I won't have time to debug this week.

Nevermind. Will wait until you have time to test it. Thanks!