From: Andrew Lunn <andrew@lunn.ch>
To: David Miller <davem@davemloft.net>,
Vivien Didelot <vivien.didelot@savoirfairelinux.com>,
Florian Fainelli <f.fainelli@gmail.com>
Cc: netdev <netdev@vger.kernel.org>, Shawn Guo <shawnguo@kernel.org>,
Andrew Lunn <andrew@lunn.ch>
Subject: [PATCHv2 net-next 08/17] net: dsa: Copy the routing table into the switch structure
Date: Sat, 4 Jun 2016 21:17:00 +0200 [thread overview]
Message-ID: <1465067829-1875-11-git-send-email-andrew@lunn.ch> (raw)
In-Reply-To: <1465067829-1875-1-git-send-email-andrew@lunn.ch>
The new binding will not have a chip data structure, it will place the
routing directly into the switch structure. To enable backwards
compatibility, copy the routing from the chip data into the switch
structure.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
v2 - Reformat rtable comment.
---
drivers/net/dsa/mv88e6xxx.c | 4 ++--
include/net/dsa.h | 9 ++++++++-
net/dsa/dsa.c | 2 ++
3 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index d622c0fb76cc..492801a6398c 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -3024,8 +3024,8 @@ static int mv88e6xxx_setup_global(struct mv88e6xxx_priv_state *ps)
for (i = 0; i < 32; i++) {
int nexthop = 0x1f;
- if (i != ps->ds->index && i < ps->ds->dst->pd->nr_chips)
- nexthop = ps->ds->cd->rtable[i] & 0x1f;
+ if (i != ds->index && i < DSA_MAX_SWITCHES)
+ nexthop = ds->rtable[i] & 0x1f;
err = _mv88e6xxx_reg_write(
ps, REG_GLOBAL2,
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 4e3afa9648ca..b666f27b3daa 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -148,6 +148,13 @@ struct dsa_switch {
*/
struct dsa_switch_driver *drv;
+ /*
+ * An array of which element [a] indicates which port on this
+ * switch should be used to send packets to that are destined
+ * for switch a. Can be NULL if there is only one switch chip.
+ */
+ s8 rtable[DSA_MAX_SWITCHES];
+
#ifdef CONFIG_NET_DSA_HWMON
/*
* Hardware monitoring information
@@ -194,7 +201,7 @@ static inline u8 dsa_upstream_port(struct dsa_switch *ds)
if (dst->cpu_switch == ds->index)
return dst->cpu_port;
else
- return ds->cd->rtable[dst->cpu_switch];
+ return ds->rtable[dst->cpu_switch];
}
struct switchdev_trans;
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 6177dd750847..bfe1d03d4730 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -297,6 +297,8 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
dst->tag_protocol = drv->tag_protocol;
}
+ memcpy(ds->rtable, cd->rtable, sizeof(ds->rtable));
+
/*
* Do basic register setup.
*/
--
2.8.1
next prev parent reply other threads:[~2016-06-04 19:18 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-04 19:16 [PATCHv2 net-next 00/17] New DSA bind, switches as devices Andrew Lunn
2016-06-04 19:16 ` [PATCH] dma: Add a benchmark for using SRAM memory as receiver buffers Andrew Lunn
2016-06-04 19:16 ` [PATCHv2 net-next 01/17] net: dsa: slave: chip data is optional, don't dereference NULL Andrew Lunn
2016-06-04 19:16 ` [PATCHv2 net-next] net: igb: Only dma sync frame length Andrew Lunn
2016-06-04 19:16 ` [PATCHv2 net-next 02/17] net: dsa: mv88e6xxx: fix circular lock in PPU work Andrew Lunn
2016-06-04 19:16 ` [PATCHv2 net-next 03/17] net: dsa: slave: Remove MDIO address from switch MDIO bus name Andrew Lunn
2016-06-04 19:16 ` [PATCHv2 net-next 04/17] net: dsa: tag_{e}dsa.c: Remove dependency on platform data Andrew Lunn
2016-06-04 19:16 ` [PATCHv2 net-next 05/17] net: dsa: Add a ports structure and use it in the switch structure Andrew Lunn
2016-06-04 19:16 ` [PATCHv2 net-next 06/17] net: dsa: Move port device node into port structure Andrew Lunn
2016-06-04 19:16 ` [PATCHv2 net-next 07/17] net: dsa: Remove dynamic allocate of routing table Andrew Lunn
2016-06-04 19:17 ` Andrew Lunn [this message]
2016-06-04 19:17 ` [PATCHv2 net-next 09/17] net: dsa: Split up creating/destroying of DSA and CPU ports Andrew Lunn
2016-06-04 19:17 ` [PATCHv2 net-next 10/17] net: dsa: mv88e6xxx: Only support EDSA tagging Andrew Lunn
2016-06-04 19:17 ` [PATCHv2 net-next 11/17] net: dsa: Refactor selection of tag ops into a function Andrew Lunn
2016-06-04 19:17 ` [PATCHv2 net-next 12/17] net: dsa: Make mdio bus optional Andrew Lunn
2016-06-04 19:17 ` [PATCHv2 net-next 13/17] net: dsa: mv88e6xxx: Rename _phy_ to _mdio_ Andrew Lunn
2016-06-04 19:17 ` [PATCHv2 net-next 14/17] net: dsa: mv88e6xxx: Refactor MDIO so driver registers mdio bus Andrew Lunn
2016-06-04 19:17 ` [PATCHv2 net-next 15/17] net: dsa: Add new binding implementation Andrew Lunn
2016-06-04 19:17 ` [PATCHv2 net-next 16/17] arm: dt: vf610-zii-devel-b: Make use of new DSA binding Andrew Lunn
2016-06-04 19:17 ` [PATCHv2 net-next 17/17] net: dsa: Document new binding Andrew Lunn
2016-06-04 19:28 ` [PATCHv2 net-next 00/17] New DSA bind, switches as devices Andrew Lunn
2016-06-04 21:30 ` David Miller
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=1465067829-1875-11-git-send-email-andrew@lunn.ch \
--to=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=shawnguo@kernel.org \
--cc=vivien.didelot@savoirfairelinux.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;
as well as URLs for NNTP newsgroup(s).