提交 d390238c 编写于 作者: V Vivien Didelot 提交者: David S. Miller

net: dsa: initialize the routing table

The routing table of every switch in a tree is currently initialized to
all zeros. This is an issue since 0 is a valid port number.

Add a DSA_RTABLE_NONE=-1 constant to initialize the signed values of the
routing table pointing to other switches.

This fixes the device mapping of the mv88e6xxx driver where the port
pointing to the switch itself and to non-existent switches was wrongly
configured to be 0. It is now set to the expected 0xf value.
Signed-off-by: NVivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: NAndrew Lunn <andrew@lunn.ch>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 86dfb4ac
...@@ -32,6 +32,8 @@ enum dsa_tag_protocol { ...@@ -32,6 +32,8 @@ enum dsa_tag_protocol {
#define DSA_MAX_SWITCHES 4 #define DSA_MAX_SWITCHES 4
#define DSA_MAX_PORTS 12 #define DSA_MAX_PORTS 12
#define DSA_RTABLE_NONE -1
struct dsa_chip_data { struct dsa_chip_data {
/* /*
* How to access the switch configuration registers. * How to access the switch configuration registers.
......
...@@ -774,11 +774,17 @@ static int dsa_of_probe(struct device *dev) ...@@ -774,11 +774,17 @@ static int dsa_of_probe(struct device *dev)
chip_index = -1; chip_index = -1;
for_each_available_child_of_node(np, child) { for_each_available_child_of_node(np, child) {
int i;
chip_index++; chip_index++;
cd = &pd->chip[chip_index]; cd = &pd->chip[chip_index];
cd->of_node = child; cd->of_node = child;
/* Initialize the routing table */
for (i = 0; i < DSA_MAX_SWITCHES; ++i)
cd->rtable[i] = DSA_RTABLE_NONE;
/* When assigning the host device, increment its refcount */ /* When assigning the host device, increment its refcount */
cd->host_dev = get_device(&mdio_bus->dev); cd->host_dev = get_device(&mdio_bus->dev);
......
...@@ -595,7 +595,7 @@ static int _dsa_register_switch(struct dsa_switch *ds, struct device_node *np) ...@@ -595,7 +595,7 @@ static int _dsa_register_switch(struct dsa_switch *ds, struct device_node *np)
struct device_node *ports = dsa_get_ports(ds, np); struct device_node *ports = dsa_get_ports(ds, np);
struct dsa_switch_tree *dst; struct dsa_switch_tree *dst;
u32 tree, index; u32 tree, index;
int err; int i, err;
err = dsa_parse_member(np, &tree, &index); err = dsa_parse_member(np, &tree, &index);
if (err) if (err)
...@@ -622,6 +622,11 @@ static int _dsa_register_switch(struct dsa_switch *ds, struct device_node *np) ...@@ -622,6 +622,11 @@ static int _dsa_register_switch(struct dsa_switch *ds, struct device_node *np)
ds->dst = dst; ds->dst = dst;
ds->index = index; ds->index = index;
/* Initialize the routing table */
for (i = 0; i < DSA_MAX_SWITCHES; ++i)
ds->rtable[i] = DSA_RTABLE_NONE;
dsa_dst_add_ds(dst, ds, index); dsa_dst_add_ds(dst, ds, index);
err = dsa_dst_complete(dst); err = dsa_dst_complete(dst);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册