mirror of https://gitee.com/openkylin/linux.git
net: dsa: define port types
Introduce an enumerated type for ports, which will be way more explicit to identify a port type instead of digging into switch port masks. A port can be of type CPU, DSA, user, or unused by default. This is a static parsed information that cannot be changed at runtime. Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
02bc6e546e
commit
057cad2c59
|
@ -180,6 +180,13 @@ struct dsa_port {
|
||||||
struct sk_buff *(*rcv)(struct sk_buff *skb, struct net_device *dev,
|
struct sk_buff *(*rcv)(struct sk_buff *skb, struct net_device *dev,
|
||||||
struct packet_type *pt);
|
struct packet_type *pt);
|
||||||
|
|
||||||
|
enum {
|
||||||
|
DSA_PORT_TYPE_UNUSED = 0,
|
||||||
|
DSA_PORT_TYPE_CPU,
|
||||||
|
DSA_PORT_TYPE_DSA,
|
||||||
|
DSA_PORT_TYPE_USER,
|
||||||
|
} type;
|
||||||
|
|
||||||
struct dsa_switch *ds;
|
struct dsa_switch *ds;
|
||||||
unsigned int index;
|
unsigned int index;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
|
|
@ -185,6 +185,7 @@ static int dsa_ds_complete(struct dsa_switch_tree *dst, struct dsa_switch *ds)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
ds->dsa_port_mask |= BIT(index);
|
ds->dsa_port_mask |= BIT(index);
|
||||||
|
port->type = DSA_PORT_TYPE_DSA;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -504,6 +505,7 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index,
|
||||||
* net/dsa/dsa.c::dsa_switch_setup_one does.
|
* net/dsa/dsa.c::dsa_switch_setup_one does.
|
||||||
*/
|
*/
|
||||||
ds->cpu_port_mask |= BIT(index);
|
ds->cpu_port_mask |= BIT(index);
|
||||||
|
port->type = DSA_PORT_TYPE_CPU;
|
||||||
|
|
||||||
tag_protocol = ds->ops->get_tag_protocol(ds);
|
tag_protocol = ds->ops->get_tag_protocol(ds);
|
||||||
tag_ops = dsa_resolve_tag_protocol(tag_protocol);
|
tag_ops = dsa_resolve_tag_protocol(tag_protocol);
|
||||||
|
@ -543,6 +545,7 @@ static int dsa_ds_parse(struct dsa_switch_tree *dst, struct dsa_switch *ds)
|
||||||
* net/dsa/dsa.c::dsa_switch_setup_one does.
|
* net/dsa/dsa.c::dsa_switch_setup_one does.
|
||||||
*/
|
*/
|
||||||
ds->enabled_port_mask |= BIT(index);
|
ds->enabled_port_mask |= BIT(index);
|
||||||
|
port->type = DSA_PORT_TYPE_USER;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,6 +101,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds,
|
||||||
struct dsa_chip_data *cd = ds->cd;
|
struct dsa_chip_data *cd = ds->cd;
|
||||||
bool valid_name_found = false;
|
bool valid_name_found = false;
|
||||||
int index = ds->index;
|
int index = ds->index;
|
||||||
|
struct dsa_port *dp;
|
||||||
int i, ret;
|
int i, ret;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -109,6 +110,8 @@ static int dsa_switch_setup_one(struct dsa_switch *ds,
|
||||||
for (i = 0; i < ds->num_ports; i++) {
|
for (i = 0; i < ds->num_ports; i++) {
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
|
dp = &ds->ports[i];
|
||||||
|
|
||||||
name = cd->port_names[i];
|
name = cd->port_names[i];
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
@ -122,10 +125,13 @@ static int dsa_switch_setup_one(struct dsa_switch *ds,
|
||||||
dst->cpu_dp = &ds->ports[i];
|
dst->cpu_dp = &ds->ports[i];
|
||||||
dst->cpu_dp->master = master;
|
dst->cpu_dp->master = master;
|
||||||
ds->cpu_port_mask |= 1 << i;
|
ds->cpu_port_mask |= 1 << i;
|
||||||
|
dp->type = DSA_PORT_TYPE_CPU;
|
||||||
} else if (!strcmp(name, "dsa")) {
|
} else if (!strcmp(name, "dsa")) {
|
||||||
ds->dsa_port_mask |= 1 << i;
|
ds->dsa_port_mask |= 1 << i;
|
||||||
|
dp->type = DSA_PORT_TYPE_DSA;
|
||||||
} else {
|
} else {
|
||||||
ds->enabled_port_mask |= 1 << i;
|
ds->enabled_port_mask |= 1 << i;
|
||||||
|
dp->type = DSA_PORT_TYPE_USER;
|
||||||
}
|
}
|
||||||
valid_name_found = true;
|
valid_name_found = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue