From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: "netdev@vger.kernel.org" <netdev@vger.kernel.org>
Cc: "Florian Fainelli" <f.fainelli@gmail.com>,
"Andrew Lunn" <andrew@lunn.ch>,
"Vivien Didelot" <vivien.didelot@gmail.com>,
"Tobias Waldekranz" <tobias@waldekranz.com>,
"DENG Qingfang" <dqfext@gmail.com>,
"Alvin Šipraga" <alsi@bang-olufsen.dk>,
"Kurt Kanzenbach" <kurt@linutronix.de>,
"Hauke Mehrtens" <hauke@hauke-m.de>,
"Woojung Huh" <woojung.huh@microchip.com>,
"UNGLinuxDriver@microchip.com" <UNGLinuxDriver@microchip.com>,
"Sean Wang" <sean.wang@mediatek.com>,
"Landen Chao" <Landen.Chao@mediatek.com>,
"Matthias Brugger" <matthias.bgg@gmail.com>,
"Claudiu Manoil" <claudiu.manoil@nxp.com>,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
"Linus Walleij" <linus.walleij@linaro.org>,
"George McCollister" <george.mccollister@gmail.com>
Subject: Re: [PATCH v2 net-next 5/7] net: dsa: keep the bridge_dev and bridge_num as part of the same structure
Date: Sat, 4 Dec 2021 23:18:54 +0000 [thread overview]
Message-ID: <20211204231853.a4z2p3vv5jor4nxx@skbuf> (raw)
In-Reply-To: <20211204201146.4088103-6-vladimir.oltean@nxp.com>
On Sat, Dec 04, 2021 at 10:11:44PM +0200, Vladimir Oltean wrote:
> @@ -310,21 +306,31 @@ static int dsa_port_bridge_create(struct dsa_port *dp,
> struct netlink_ext_ack *extack)
> {
> struct dsa_switch *ds = dp->ds;
> - unsigned int bridge_num;
> + struct dsa_bridge *bridge;
>
> - dp->bridge_dev = br;
> -
> - if (!ds->max_num_bridges)
> + bridge = dsa_tree_bridge_find(ds->dst, br);
> + if (bridge) {
> + refcount_inc(&bridge->refcount);
> + dp->bridge = bridge;
> return 0;
> + }
> +
> + bridge = kzalloc(sizeof(*bridge), GFP_KERNEL);
> + if (!bridge)
> + return -ENOMEM;
> +
> + refcount_set(&bridge->refcount, 1);
> +
> + bridge->dev = br;
>
> - bridge_num = dsa_bridge_num_get(br, ds->max_num_bridges);
> - if (!bridge_num) {
> + bridge->num = dsa_bridge_num_get(br, ds->max_num_bridges);
> + if (ds->max_num_bridges && !bridge->num) {
> NL_SET_ERR_MSG_MOD(extack,
> "Range of offloadable bridges exceeded");
There should be a kfree(bridge) here before returning -EOPNOTSUPP.
I'll wait for further feedback before reposting.
> return -EOPNOTSUPP;
> }
>
> - dp->bridge_num = bridge_num;
> + dp->bridge = bridge;
>
> return 0;
> }
next prev parent reply other threads:[~2021-12-04 23:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-04 20:11 [PATCH v2 net-next 0/7] Rework DSA bridge TX forwarding offload API Vladimir Oltean
2021-12-04 20:11 ` [PATCH v2 net-next 1/7] net: dsa: make dp->bridge_num one-based Vladimir Oltean
2021-12-04 20:11 ` [PATCH v2 net-next 2/7] net: dsa: assign a bridge number even without TX forwarding offload Vladimir Oltean
2021-12-04 20:11 ` [PATCH v2 net-next 3/7] net: dsa: hide dp->bridge_dev and dp->bridge_num behind helpers Vladimir Oltean
2021-12-04 23:27 ` Vladimir Oltean
2021-12-04 20:11 ` [PATCH v2 net-next 4/7] net: dsa: rename dsa_port_offloads_bridge to dsa_port_offloads_bridge_dev Vladimir Oltean
2021-12-04 20:11 ` [PATCH v2 net-next 5/7] net: dsa: keep the bridge_dev and bridge_num as part of the same structure Vladimir Oltean
2021-12-04 23:18 ` Vladimir Oltean [this message]
2021-12-04 20:11 ` [PATCH v2 net-next 6/7] net: dsa: add a "tx_fwd_offload" argument to ->port_bridge_join Vladimir Oltean
2021-12-06 11:01 ` Alvin Šipraga
2021-12-04 20:11 ` [PATCH v2 net-next 7/7] net: dsa: eliminate dsa_switch_ops :: port_bridge_tx_fwd_{,un}offload Vladimir Oltean
2021-12-06 11:01 ` Alvin Šipraga
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=20211204231853.a4z2p3vv5jor4nxx@skbuf \
--to=vladimir.oltean@nxp.com \
--cc=Landen.Chao@mediatek.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=alexandre.belloni@bootlin.com \
--cc=alsi@bang-olufsen.dk \
--cc=andrew@lunn.ch \
--cc=claudiu.manoil@nxp.com \
--cc=dqfext@gmail.com \
--cc=f.fainelli@gmail.com \
--cc=george.mccollister@gmail.com \
--cc=hauke@hauke-m.de \
--cc=kurt@linutronix.de \
--cc=linus.walleij@linaro.org \
--cc=matthias.bgg@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=sean.wang@mediatek.com \
--cc=tobias@waldekranz.com \
--cc=vivien.didelot@gmail.com \
--cc=woojung.huh@microchip.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox