From: Ioana Ciornei <ioana.ciornei@nxp.com>
To: gregkh@linuxfoundation.org
Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
Ioana Ciornei <ioana.ciornei@nxp.com>
Subject: [PATCH 6/6] staging: dpaa2-ethsw: check if there is space for a new VLAN
Date: Tue, 21 Jul 2020 12:19:19 +0300 [thread overview]
Message-ID: <20200721091919.20394-7-ioana.ciornei@nxp.com> (raw)
In-Reply-To: <20200721091919.20394-1-ioana.ciornei@nxp.com>
Avoid getting into a WARNING as below by checking, while in the prepare
state of the transactional operation, if there is space for a new VLAN.
If we reached the maximum number, return an appropriate error.
[ 6503.657564] eth3: Commit of object (id=1) failed.
[ 6503.657588] WARNING: CPU: 2 PID: 17144 at net/switchdev/switchdev.c:277 switchdev_port_obj_add_now+0xcc/0x110
...
[ 6503.657628] x1 : 70887ce26695c500 x0 : 0000000000000000
[ 6503.657630] Call trace:
[ 6503.657633] switchdev_port_obj_add_now+0xcc/0x110
[ 6503.657635] switchdev_port_obj_add+0x40/0xc0
[ 6503.657638] br_switchdev_port_vlan_add+0x50/0x78
[ 6503.657640] __vlan_add+0x2dc/0x758
[ 6503.657642] nbp_vlan_add+0xc0/0x180
[ 6503.657644] br_vlan_info.isra.0+0x68/0x128
[ 6503.657646] br_process_vlan_info+0x224/0x2f8
[ 6503.657647] br_afspec+0x158/0x188
[ 6503.657649] br_setlink+0x1a4/0x290
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
index c6885912c60b..19fc0401e261 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
@@ -979,10 +979,27 @@ static int port_vlans_add(struct net_device *netdev,
struct switchdev_trans *trans)
{
struct ethsw_port_priv *port_priv = netdev_priv(netdev);
- int vid, err = 0;
+ struct ethsw_core *ethsw = port_priv->ethsw_data;
+ struct dpsw_attr *attr = ðsw->sw_attr;
+ int vid, err = 0, new_vlans = 0;
+
+ if (switchdev_trans_ph_prepare(trans)) {
+ for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++)
+ if (!port_priv->ethsw_data->vlans[vid])
+ new_vlans++;
+
+ /* Check if there is space for a new VLAN */
+ err = dpsw_get_attributes(ethsw->mc_io, 0, ethsw->dpsw_handle,
+ ðsw->sw_attr);
+ if (err) {
+ netdev_err(netdev, "dpsw_get_attributes err %d\n", err);
+ return err;
+ }
+ if (attr->max_vlans - attr->num_vlans < new_vlans)
+ return -ENOSPC;
- if (switchdev_trans_ph_prepare(trans))
return 0;
+ }
for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) {
if (!port_priv->ethsw_data->vlans[vid]) {
--
2.25.1
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
prev parent reply other threads:[~2020-07-21 9:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-21 9:19 [PATCH 0/6] staging: dpaa2-ethsw: various fixes Ioana Ciornei
2020-07-21 9:19 ` [PATCH 1/6] staging: dpaa2-ethsw: verify the nofifier block Ioana Ciornei
2020-07-21 9:19 ` [PATCH 2/6] staging: dpaa2-ethsw: don't allow interfaces from different DPSWs to be bridged Ioana Ciornei
2020-07-21 9:19 ` [PATCH 3/6] staging: dpaa2-ethsw: setup the STP state for all installed VLANs Ioana Ciornei
2020-07-21 9:19 ` [PATCH 4/6] staging: dpaa2-ethsw: destroy workqueue after deregistering the notifiers Ioana Ciornei
2020-07-21 9:19 ` [PATCH 5/6] staging: dpaa2-ethsw: read the port state from firmware Ioana Ciornei
2020-07-21 9:19 ` Ioana Ciornei [this message]
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=20200721091919.20394-7-ioana.ciornei@nxp.com \
--to=ioana.ciornei@nxp.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).