diff mbox

[net-next,4/9] net: dsa: mv88e6xxx: allocate the number of ports

Message ID 20170329203020.27042-5-vivien.didelot@savoirfairelinux.com
State Superseded, archived
Delegated to: David Miller
Headers show

Commit Message

Vivien Didelot March 29, 2017, 8:30 p.m. UTC
The current code allocates DSA_MAX_PORTS ports for a Marvell dsa_switch
structure. Provide the exact number of ports so the corresponding
ds->num_ports is accurate.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
 drivers/net/dsa/mv88e6xxx/chip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andrew Lunn March 30, 2017, 1:50 p.m. UTC | #1
On Wed, Mar 29, 2017 at 04:30:15PM -0400, Vivien Didelot wrote:
> The current code allocates DSA_MAX_PORTS ports for a Marvell dsa_switch
> structure. Provide the exact number of ports so the corresponding
> ds->num_ports is accurate.

Hi Vivien

Is net/dsa/dsa.c: dsa_switch_setup() still used?  If it is, won't that
invalidate your assumption about ds->num_ports.

   Andrew
Vivien Didelot March 30, 2017, 2:06 p.m. UTC | #2
Hi Andrew,

Andrew Lunn <andrew@lunn.ch> writes:

> On Wed, Mar 29, 2017 at 04:30:15PM -0400, Vivien Didelot wrote:
>> The current code allocates DSA_MAX_PORTS ports for a Marvell dsa_switch
>> structure. Provide the exact number of ports so the corresponding
>> ds->num_ports is accurate.
>
> Is net/dsa/dsa.c: dsa_switch_setup() still used?  If it is, won't that
> invalidate your assumption about ds->num_ports.

I think dsa_switch_setup is part of the legacy code and is likely to be
removed soon.

But this is not an issue per-se. What happens if the switch is allocated
with DSA_MAX_PORTS ports instead of the correct number, is that the PVT
will be programmed to allow the non-existent port IDs to egress frames
on the CPU port and DSA links only.

Thanks,

        Vivien
diff mbox

Patch

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 955c7e672423..b114bf8e6a11 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -4286,7 +4286,7 @@  static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
 	struct device *dev = chip->dev;
 	struct dsa_switch *ds;
 
-	ds = dsa_switch_alloc(dev, DSA_MAX_PORTS);
+	ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
 	if (!ds)
 		return -ENOMEM;