Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1438597
| From | Vivien Didelot <vivien.didelot@savoirfairelinux.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH net-next 3/9] net: dsa: mv88e6xxx: extract device mapping |
| Date | 2016-07-07 15:00 +0200 |
| Message-ID | <rSh4m-71b-41@gated-at.bofh.it> (permalink) |
| References | <rSh4l-71b-11@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
The Device Mapping register is an indirect table access.
Provide helpers to access this table and explicit the checking of the
new DSA_RTABLE_NONE routing table value.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
drivers/net/dsa/mv88e6xxx/chip.c | 49 ++++++++++++++++++++++++++++------------
1 file changed, 34 insertions(+), 15 deletions(-)
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 1e39fa6..9b37310 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -3094,9 +3094,39 @@ static int mv88e6xxx_g1_setup(struct mv88e6xxx_chip *chip)
return 0;
}
+static int mv88e6xxx_g2_device_mapping_write(struct mv88e6xxx_chip *chip,
+ int target, int port)
+{
+ u16 val = GLOBAL2_DEVICE_MAPPING_UPDATE | (target << 8) | (port & 0xf);
+
+ return mv88e6xxx_write(chip, REG_GLOBAL2, GLOBAL2_DEVICE_MAPPING, val);
+}
+
+static int mv88e6xxx_g2_set_device_mapping(struct mv88e6xxx_chip *chip)
+{
+ int target, port;
+ int err;
+
+ /* Initialize the routing port to the 32 possible target devices */
+ for (target = 0; target < 32; ++target) {
+ port = 0xf;
+
+ if (target < DSA_MAX_SWITCHES) {
+ port = chip->ds->rtable[target];
+ if (port == DSA_RTABLE_NONE)
+ port = 0xf;
+ }
+
+ err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
+ if (err)
+ break;
+ }
+
+ return err;
+}
+
static int mv88e6xxx_g2_setup(struct mv88e6xxx_chip *chip)
{
- struct dsa_switch *ds = chip->ds;
int err;
int i;
@@ -3120,20 +3150,9 @@ static int mv88e6xxx_g2_setup(struct mv88e6xxx_chip *chip)
return err;
/* Program the DSA routing table. */
- for (i = 0; i < 32; i++) {
- int nexthop = 0x1f;
-
- if (i != ds->index && i < DSA_MAX_SWITCHES)
- nexthop = ds->rtable[i] & 0x1f;
-
- err = _mv88e6xxx_reg_write(
- chip, REG_GLOBAL2,
- GLOBAL2_DEVICE_MAPPING,
- GLOBAL2_DEVICE_MAPPING_UPDATE |
- (i << GLOBAL2_DEVICE_MAPPING_TARGET_SHIFT) | nexthop);
- if (err)
- return err;
- }
+ err = mv88e6xxx_g2_set_device_mapping(chip);
+ if (err)
+ return err;
/* Clear all trunk masks. */
for (i = 0; i < 8; i++) {
--
2.9.0
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH net-next 0/9] net: dsa: mv88e6xxx: STP and Global 2 cleanup Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-07-07 15:00 +0200
[PATCH net-next 3/9] net: dsa: mv88e6xxx: extract device mapping Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-07-07 15:00 +0200
[PATCH net-next 4/9] net: dsa: mv88e6xxx: extract trunk mapping Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-07-07 15:00 +0200
[PATCH net-next 5/9] net: dsa: mv88e6xxx: add cap for MGMT Enables bits Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-07-07 15:10 +0200
[PATCH net-next 2/9] net: dsa: mv88e6xxx: split setup of Global 1 and 2 Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-07-07 15:10 +0200
[PATCH net-next 9/9] net: dsa: mv88e6xxx: add cap for IRL Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-07-07 15:10 +0200
[PATCH net-next 8/9] net: dsa: mv88e6xxx: add cap for Priority Override Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-07-07 15:10 +0200
[PATCH net-next 6/9] net: dsa: mv88e6xxx: rework Switch MAC setter Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-07-07 15:10 +0200
Re: [PATCH net-next 6/9] net: dsa: mv88e6xxx: rework Switch MAC setter Andrew Lunn <andrew@lunn.ch> - 2016-07-07 16:00 +0200
Re: [PATCH net-next 6/9] net: dsa: mv88e6xxx: rework Switch MAC setter Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-07-09 02:10 +0200
csiph-web