mirror of https://github.com/hak5/openwrt.git
generic: rtl8366: add cpu_port, num_ports and num_vlan_mc to struct rtl8366_smi
SVN-Revision: 21978lede-17.01
parent
08942e9a98
commit
81e9e7916f
|
@ -25,6 +25,10 @@ struct rtl8366_smi {
|
||||||
struct mii_bus *mii_bus;
|
struct mii_bus *mii_bus;
|
||||||
int mii_irq[PHY_MAX_ADDR];
|
int mii_irq[PHY_MAX_ADDR];
|
||||||
|
|
||||||
|
unsigned int cpu_port;
|
||||||
|
unsigned int num_ports;
|
||||||
|
unsigned int num_vlan_mc;
|
||||||
|
|
||||||
struct rtl8366_smi_ops *ops;
|
struct rtl8366_smi_ops *ops;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -691,7 +691,7 @@ static int rtl8366rb_set_vlan(struct rtl8366_smi *smi, int vid, u32 member,
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
/* Try to find an existing MC entry for this VID */
|
/* Try to find an existing MC entry for this VID */
|
||||||
for (i = 0; i < RTL8366RB_NUM_VLANS; i++) {
|
for (i = 0; i < smi->num_vlan_mc; i++) {
|
||||||
struct rtl8366_vlan_mc vlanmc;
|
struct rtl8366_vlan_mc vlanmc;
|
||||||
|
|
||||||
err = smi->ops->get_vlan_mc(smi, i, &vlanmc);
|
err = smi->ops->get_vlan_mc(smi, i, &vlanmc);
|
||||||
|
@ -737,7 +737,7 @@ static int rtl8366rb_mc_is_used(struct rtl8366_smi *smi, int mc_index,
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
*used = 0;
|
*used = 0;
|
||||||
for (i = 0; i < RTL8366RB_NUM_PORTS; i++) {
|
for (i = 0; i < smi->num_ports; i++) {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
err = smi->ops->get_mc_index(smi, i, &index);
|
err = smi->ops->get_mc_index(smi, i, &index);
|
||||||
|
@ -762,7 +762,7 @@ static int rtl8366rb_set_pvid(struct rtl8366_smi *smi, unsigned port,
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Try to find an existing MC entry for this VID */
|
/* Try to find an existing MC entry for this VID */
|
||||||
for (i = 0; i < RTL8366RB_NUM_VLANS; i++) {
|
for (i = 0; i < smi->num_vlan_mc; i++) {
|
||||||
err = smi->ops->get_vlan_mc(smi, i, &vlanmc);
|
err = smi->ops->get_vlan_mc(smi, i, &vlanmc);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
@ -778,7 +778,7 @@ static int rtl8366rb_set_pvid(struct rtl8366_smi *smi, unsigned port,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We have no MC entry for this VID, try to find an empty one */
|
/* We have no MC entry for this VID, try to find an empty one */
|
||||||
for (i = 0; i < RTL8366RB_NUM_VLANS; i++) {
|
for (i = 0; i < smi->num_vlan_mc; i++) {
|
||||||
err = smi->ops->get_vlan_mc(smi, i, &vlanmc);
|
err = smi->ops->get_vlan_mc(smi, i, &vlanmc);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
@ -803,7 +803,7 @@ static int rtl8366rb_set_pvid(struct rtl8366_smi *smi, unsigned port,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* MC table is full, try to find an unused entry and replace it */
|
/* MC table is full, try to find an unused entry and replace it */
|
||||||
for (i = 0; i < RTL8366RB_NUM_VLANS; i++) {
|
for (i = 0; i < smi->num_vlan_mc; i++) {
|
||||||
int used;
|
int used;
|
||||||
|
|
||||||
err = rtl8366rb_mc_is_used(smi, i, &used);
|
err = rtl8366rb_mc_is_used(smi, i, &used);
|
||||||
|
@ -861,19 +861,19 @@ static int rtl8366rb_reset_vlan(struct rtl8366_smi *smi)
|
||||||
vlanmc.member = 0;
|
vlanmc.member = 0;
|
||||||
vlanmc.untag = 0;
|
vlanmc.untag = 0;
|
||||||
vlanmc.fid = 0;
|
vlanmc.fid = 0;
|
||||||
for (i = 0; i < RTL8366RB_NUM_VLANS; i++) {
|
for (i = 0; i < smi->num_vlan_mc; i++) {
|
||||||
err = smi->ops->set_vlan_mc(smi, i, &vlanmc);
|
err = smi->ops->set_vlan_mc(smi, i, &vlanmc);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < RTL8366RB_NUM_PORTS; i++) {
|
for (i = 0; i < smi->num_ports; i++) {
|
||||||
if (i == RTL8366RB_PORT_CPU)
|
if (i == smi->cpu_port)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
err = rtl8366rb_set_vlan(smi, (i + 1),
|
err = rtl8366rb_set_vlan(smi, (i + 1),
|
||||||
(1 << i) | RTL8366RB_PORT_CPU,
|
(1 << i) | (1 << smi->cpu_port),
|
||||||
(1 << i) | RTL8366RB_PORT_CPU,
|
(1 << i) | (1 << smi->cpu_port),
|
||||||
0);
|
0);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
@ -1692,6 +1692,9 @@ static int __init rtl8366rb_probe(struct platform_device *pdev)
|
||||||
smi->gpio_sda = pdata->gpio_sda;
|
smi->gpio_sda = pdata->gpio_sda;
|
||||||
smi->gpio_sck = pdata->gpio_sck;
|
smi->gpio_sck = pdata->gpio_sck;
|
||||||
smi->ops = &rtl8366rb_smi_ops;
|
smi->ops = &rtl8366rb_smi_ops;
|
||||||
|
smi->cpu_port = RTL8366RB_PORT_NUM_CPU;
|
||||||
|
smi->num_ports = RTL8366RB_NUM_PORTS;
|
||||||
|
smi->num_vlan_mc = RTL8366RB_NUM_VLANS;
|
||||||
|
|
||||||
err = rtl8366_smi_init(smi);
|
err = rtl8366_smi_init(smi);
|
||||||
if (err)
|
if (err)
|
||||||
|
|
|
@ -681,7 +681,7 @@ static int rtl8366s_set_vlan(struct rtl8366_smi *smi, int vid, u32 member,
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
/* Try to find an existing MC entry for this VID */
|
/* Try to find an existing MC entry for this VID */
|
||||||
for (i = 0; i < RTL8366S_NUM_VLANS; i++) {
|
for (i = 0; i < smi->num_vlan_mc; i++) {
|
||||||
struct rtl8366_vlan_mc vlanmc;
|
struct rtl8366_vlan_mc vlanmc;
|
||||||
|
|
||||||
err = smi->ops->get_vlan_mc(smi, i, &vlanmc);
|
err = smi->ops->get_vlan_mc(smi, i, &vlanmc);
|
||||||
|
@ -727,7 +727,7 @@ static int rtl8366s_mc_is_used(struct rtl8366_smi *smi, int mc_index,
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
*used = 0;
|
*used = 0;
|
||||||
for (i = 0; i < RTL8366S_NUM_PORTS; i++) {
|
for (i = 0; i < smi->num_ports; i++) {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
err = smi->ops->get_mc_index(smi, i, &index);
|
err = smi->ops->get_mc_index(smi, i, &index);
|
||||||
|
@ -752,7 +752,7 @@ static int rtl8366s_set_pvid(struct rtl8366_smi *smi, unsigned port,
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Try to find an existing MC entry for this VID */
|
/* Try to find an existing MC entry for this VID */
|
||||||
for (i = 0; i < RTL8366S_NUM_VLANS; i++) {
|
for (i = 0; i < smi->num_vlan_mc; i++) {
|
||||||
err = smi->ops->get_vlan_mc(smi, i, &vlanmc);
|
err = smi->ops->get_vlan_mc(smi, i, &vlanmc);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
@ -768,7 +768,7 @@ static int rtl8366s_set_pvid(struct rtl8366_smi *smi, unsigned port,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We have no MC entry for this VID, try to find an empty one */
|
/* We have no MC entry for this VID, try to find an empty one */
|
||||||
for (i = 0; i < RTL8366S_NUM_VLANS; i++) {
|
for (i = 0; i < smi->num_vlan_mc; i++) {
|
||||||
err = smi->ops->get_vlan_mc(smi, i, &vlanmc);
|
err = smi->ops->get_vlan_mc(smi, i, &vlanmc);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
@ -793,7 +793,7 @@ static int rtl8366s_set_pvid(struct rtl8366_smi *smi, unsigned port,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* MC table is full, try to find an unused entry and replace it */
|
/* MC table is full, try to find an unused entry and replace it */
|
||||||
for (i = 0; i < RTL8366S_NUM_VLANS; i++) {
|
for (i = 0; i < smi->num_vlan_mc; i++) {
|
||||||
int used;
|
int used;
|
||||||
|
|
||||||
err = rtl8366s_mc_is_used(smi, i, &used);
|
err = rtl8366s_mc_is_used(smi, i, &used);
|
||||||
|
@ -850,19 +850,19 @@ static int rtl8366s_reset_vlan(struct rtl8366_smi *smi)
|
||||||
vlanmc.member = 0;
|
vlanmc.member = 0;
|
||||||
vlanmc.untag = 0;
|
vlanmc.untag = 0;
|
||||||
vlanmc.fid = 0;
|
vlanmc.fid = 0;
|
||||||
for (i = 0; i < RTL8366S_NUM_VLANS; i++) {
|
for (i = 0; i < smi->num_vlan_mc; i++) {
|
||||||
err = smi->ops->set_vlan_mc(smi, i, &vlanmc);
|
err = smi->ops->set_vlan_mc(smi, i, &vlanmc);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < RTL8366S_NUM_PORTS; i++) {
|
for (i = 0; i < smi->num_ports; i++) {
|
||||||
if (i == RTL8366S_PORT_CPU)
|
if (i == smi->cpu_port)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
err = rtl8366s_set_vlan(smi, (i + 1),
|
err = rtl8366s_set_vlan(smi, (i + 1),
|
||||||
(1 << i) | RTL8366S_PORT_CPU,
|
(1 << i) | (1 << smi->cpu_port),
|
||||||
(1 << i) | RTL8366S_PORT_CPU,
|
(1 << i) | (1 << smi->cpu_port),
|
||||||
0);
|
0);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
@ -1682,6 +1682,9 @@ static int __init rtl8366s_probe(struct platform_device *pdev)
|
||||||
smi->gpio_sda = pdata->gpio_sda;
|
smi->gpio_sda = pdata->gpio_sda;
|
||||||
smi->gpio_sck = pdata->gpio_sck;
|
smi->gpio_sck = pdata->gpio_sck;
|
||||||
smi->ops = &rtl8366s_smi_ops;
|
smi->ops = &rtl8366s_smi_ops;
|
||||||
|
smi->cpu_port = RTL8366S_PORT_NUM_CPU;
|
||||||
|
smi->num_ports = RTL8366S_NUM_PORTS;
|
||||||
|
smi->num_vlan_mc = RTL8366S_NUM_VLANS;
|
||||||
|
|
||||||
err = rtl8366_smi_init(smi);
|
err = rtl8366_smi_init(smi);
|
||||||
if (err)
|
if (err)
|
||||||
|
|
Loading…
Reference in New Issue