From: Pavel Nakonechny <pavel.nakonechny@skitlab.ru>
To: netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
Grant Likely <grant.likely@linaro.org>,
Rob Herring <robh+dt@kernel.org>,
Florian Fainelli <f.fainelli@gmail.com>,
Fabian Frederick <fabf@skynet.be>,
Alexander Duyck <alexander.h.duyck@intel.com>,
Joe Perches <joe@perches.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH] net: dsa: fix filling rtable from OF description
Date: Sat, 04 Apr 2015 16:48:48 +0300 [thread overview]
Message-ID: <1941340.ZSOIoOXLWB@pavel.skitlab.int> (raw)
According to description in 'include/net/dsa.h', in cascade switches
configurations where there are more than one interconnected devices,
'rtable' array in 'dsa_chip_data' structure is used to indicate which
port on this switch should be used to send packets to that are destined
for corresponding switch.
However, dsa_of_setup_routing_table() fills 'rtable' with port numbers
of the _target_ switch, but not current one.
This commit removes redundant devicetree parsing and adds needed port
number as a function argument. So dsa_of_setup_routing_table() now just
looks for target switch number by parsing parent of 'link' device node.
This was tested on custom board with two Marvell 88E6095 switches with
following corresponding rtables: { -1, 10 } and { 8, -1 }.
Signed-off-by: Pavel Nakonechny <pavel.nakonechny@skitlab.ru>
---
net/dsa/dsa.c | 19 +++----------------
1 file changed, 3 insertions(+), 16 deletions(-)
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 947f550..5593a0d 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -375,12 +375,10 @@ static struct net_device *dev_to_net_device(struct device *dev)
#ifdef CONFIG_OF
static int dsa_of_setup_routing_table(struct dsa_platform_data *pd,
struct dsa_chip_data *cd,
- int chip_index,
+ int chip_index, int port_index,
struct device_node *link)
{
- int ret;
const __be32 *reg;
- int link_port_addr;
int link_sw_addr;
struct device_node *parent_sw;
int len;
@@ -409,20 +407,9 @@ static int dsa_of_setup_routing_table(struct dsa_platform_data *pd,
memset(cd->rtable, -1, pd->nr_chips * sizeof(s8));
}
- reg = of_get_property(link, "reg", NULL);
- if (!reg) {
- ret = -EINVAL;
- goto out;
- }
-
- link_port_addr = be32_to_cpup(reg);
-
- cd->rtable[link_sw_addr] = link_port_addr;
+ cd->rtable[link_sw_addr] = port_index;
return 0;
-out:
- kfree(cd->rtable);
- return ret;
}
static void dsa_of_free_platform_data(struct dsa_platform_data *pd)
@@ -528,7 +515,7 @@ static int dsa_of_probe(struct platform_device *pdev)
if (!strcmp(port_name, "dsa") && link &&
pd->nr_chips > 1) {
ret = dsa_of_setup_routing_table(pd, cd,
- chip_index, link);
+ chip_index, port_index, link);
if (ret)
goto out_free_chip;
}
--
next reply other threads:[~2015-04-04 13:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-04 13:48 Pavel Nakonechny [this message]
2015-04-04 16:38 ` [PATCH] net: dsa: fix filling rtable from OF description Andrew Lunn
2015-04-04 17:10 ` Pavel Nakonechny
2015-04-04 21:00 ` Andrew Lunn
2015-04-04 21:02 ` Andrew Lunn
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=1941340.ZSOIoOXLWB@pavel.skitlab.int \
--to=pavel.nakonechny@skitlab.ru \
--cc=alexander.h.duyck@intel.com \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=fabf@skynet.be \
--cc=grant.likely@linaro.org \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=robh+dt@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