#include <linux/phy.h>
struct rtl8366_smi_ops;
+struct rtl8366_vlan_ops;
struct mii_bus;
struct rtl8366_smi {
struct rtl8366_smi_ops *ops;
};
-struct rtl8366_smi_ops {
- int (*detect)(struct rtl8366_smi *smi);
-
- int (*mii_read)(struct mii_bus *bus, int addr, int reg);
- int (*mii_write)(struct mii_bus *bus, int addr, int reg, u16 val);
-};
-
struct rtl8366_vlan_mc {
u16 vid;
u8 priority;
u8 fid;
};
+struct rtl8366_smi_ops {
+ int (*detect)(struct rtl8366_smi *smi);
+
+ int (*mii_read)(struct mii_bus *bus, int addr, int reg);
+ int (*mii_write)(struct mii_bus *bus, int addr, int reg, u16 val);
+
+ int (*get_vlan_mc)(struct rtl8366_smi *smi, u32 index,
+ struct rtl8366_vlan_mc *vlanmc);
+ int (*set_vlan_mc)(struct rtl8366_smi *smi, u32 index,
+ const struct rtl8366_vlan_mc *vlanmc);
+ int (*get_vlan_4k)(struct rtl8366_smi *smi, u32 vid,
+ struct rtl8366_vlan_4k *vlan4k);
+ int (*set_vlan_4k)(struct rtl8366_smi *smi,
+ const struct rtl8366_vlan_4k *vlan4k);
+ int (*get_mc_index)(struct rtl8366_smi *smi, int port, int *val);
+ int (*set_mc_index)(struct rtl8366_smi *smi, int port, int index);
+};
+
int rtl8366_smi_init(struct rtl8366_smi *smi);
void rtl8366_smi_cleanup(struct rtl8366_smi *smi);
int rtl8366_smi_write_reg(struct rtl8366_smi *smi, u32 addr, u32 data);
int i;
/* Update the 4K table */
- err = rtl8366rb_get_vlan_4k(smi, vid, &vlan4k);
+ err = smi->ops->get_vlan_4k(smi, vid, &vlan4k);
if (err)
return err;
vlan4k.member = member;
vlan4k.untag = untag;
vlan4k.fid = fid;
- err = rtl8366rb_set_vlan_4k(smi, &vlan4k);
+ err = smi->ops->set_vlan_4k(smi, &vlan4k);
if (err)
return err;
for (i = 0; i < RTL8366RB_NUM_VLANS; i++) {
struct rtl8366_vlan_mc vlanmc;
- err = rtl8366rb_get_vlan_mc(smi, i, &vlanmc);
+ err = smi->ops->get_vlan_mc(smi, i, &vlanmc);
if (err)
return err;
vlanmc.untag = untag;
vlanmc.fid = fid;
- err = rtl8366rb_set_vlan_mc(smi, i, &vlanmc);
+ err = smi->ops->set_vlan_mc(smi, i, &vlanmc);
break;
}
}
int err;
int index;
- err = rtl8366rb_get_mc_index(smi, port, &index);
+ err = smi->ops->get_mc_index(smi, port, &index);
if (err)
return err;
- err = rtl8366rb_get_vlan_mc(smi, index, &vlanmc);
+ err = smi->ops->get_vlan_mc(smi, index, &vlanmc);
if (err)
return err;
for (i = 0; i < RTL8366RB_NUM_PORTS; i++) {
int index = 0;
- err = rtl8366rb_get_mc_index(smi, i, &index);
+ err = smi->ops->get_mc_index(smi, i, &index);
if (err)
return err;
/* Try to find an existing MC entry for this VID */
for (i = 0; i < RTL8366RB_NUM_VLANS; i++) {
- err = rtl8366rb_get_vlan_mc(smi, i, &vlanmc);
+ err = smi->ops->get_vlan_mc(smi, i, &vlanmc);
if (err)
return err;
if (vid == vlanmc.vid) {
- err = rtl8366rb_set_vlan_mc(smi, i, &vlanmc);
+ err = smi->ops->set_vlan_mc(smi, i, &vlanmc);
if (err)
return err;
- err = rtl8366rb_set_mc_index(smi, port, i);
+ err = smi->ops->set_mc_index(smi, port, i);
return err;
}
}
/* We have no MC entry for this VID, try to find an empty one */
for (i = 0; i < RTL8366RB_NUM_VLANS; i++) {
- err = rtl8366rb_get_vlan_mc(smi, i, &vlanmc);
+ err = smi->ops->get_vlan_mc(smi, i, &vlanmc);
if (err)
return err;
if (vlanmc.vid == 0 && vlanmc.member == 0) {
/* Update the entry from the 4K table */
- err = rtl8366rb_get_vlan_4k(smi, vid, &vlan4k);
+ err = smi->ops->get_vlan_4k(smi, vid, &vlan4k);
if (err)
return err;
vlanmc.member = vlan4k.member;
vlanmc.untag = vlan4k.untag;
vlanmc.fid = vlan4k.fid;
- err = rtl8366rb_set_vlan_mc(smi, i, &vlanmc);
+ err = smi->ops->set_vlan_mc(smi, i, &vlanmc);
if (err)
return err;
- err = rtl8366rb_set_mc_index(smi, port, i);
+ err = smi->ops->set_mc_index(smi, port, i);
return err;
}
}
if (!used) {
/* Update the entry from the 4K table */
- err = rtl8366rb_get_vlan_4k(smi, vid, &vlan4k);
+ err = smi->ops->get_vlan_4k(smi, vid, &vlan4k);
if (err)
return err;
vlanmc.member = vlan4k.member;
vlanmc.untag = vlan4k.untag;
vlanmc.fid = vlan4k.fid;
- err = rtl8366rb_set_vlan_mc(smi, i, &vlanmc);
+ err = smi->ops->set_vlan_mc(smi, i, &vlanmc);
if (err)
return err;
- err = rtl8366rb_set_mc_index(smi, port, i);
+ err = smi->ops->set_mc_index(smi, port, i);
return err;
}
}
vlanmc.untag = 0;
vlanmc.fid = 0;
for (i = 0; i < RTL8366RB_NUM_VLANS; i++) {
- err = rtl8366rb_set_vlan_mc(smi, i, &vlanmc);
+ err = smi->ops->set_vlan_mc(smi, i, &vlanmc);
if (err)
return err;
}
.detect = rtl8366rb_detect,
.mii_read = rtl8366rb_mii_read,
.mii_write = rtl8366rb_mii_write,
+
+ .get_vlan_mc = rtl8366rb_get_vlan_mc,
+ .set_vlan_mc = rtl8366rb_set_vlan_mc,
+ .get_vlan_4k = rtl8366rb_get_vlan_4k,
+ .set_vlan_4k = rtl8366rb_set_vlan_4k,
+ .get_mc_index = rtl8366rb_get_mc_index,
+ .set_mc_index = rtl8366rb_set_mc_index,
};
static int __init rtl8366rb_probe(struct platform_device *pdev)
int i;
/* Update the 4K table */
- err = rtl8366s_get_vlan_4k(smi, vid, &vlan4k);
+ err = smi->ops->get_vlan_4k(smi, vid, &vlan4k);
if (err)
return err;
vlan4k.member = member;
vlan4k.untag = untag;
vlan4k.fid = fid;
- err = rtl8366s_set_vlan_4k(smi, &vlan4k);
+ err = smi->ops->set_vlan_4k(smi, &vlan4k);
if (err)
return err;
for (i = 0; i < RTL8366S_NUM_VLANS; i++) {
struct rtl8366_vlan_mc vlanmc;
- err = rtl8366s_get_vlan_mc(smi, i, &vlanmc);
+ err = smi->ops->get_vlan_mc(smi, i, &vlanmc);
if (err)
return err;
vlanmc.untag = untag;
vlanmc.fid = fid;
- err = rtl8366s_set_vlan_mc(smi, i, &vlanmc);
+ err = smi->ops->set_vlan_mc(smi, i, &vlanmc);
break;
}
}
int err;
int index;
- err = rtl8366s_get_mc_index(smi, port, &index);
+ err = smi->ops->get_mc_index(smi, port, &index);
if (err)
return err;
- err = rtl8366s_get_vlan_mc(smi, index, &vlanmc);
+ err = smi->ops->get_vlan_mc(smi, index, &vlanmc);
if (err)
return err;
for (i = 0; i < RTL8366S_NUM_PORTS; i++) {
int index = 0;
- err = rtl8366s_get_mc_index(smi, i, &index);
+ err = smi->ops->get_mc_index(smi, i, &index);
if (err)
return err;
/* Try to find an existing MC entry for this VID */
for (i = 0; i < RTL8366S_NUM_VLANS; i++) {
- err = rtl8366s_get_vlan_mc(smi, i, &vlanmc);
+ err = smi->ops->get_vlan_mc(smi, i, &vlanmc);
if (err)
return err;
if (vid == vlanmc.vid) {
- err = rtl8366s_set_vlan_mc(smi, i, &vlanmc);
+ err = smi->ops->set_vlan_mc(smi, i, &vlanmc);
if (err)
return err;
- err = rtl8366s_set_mc_index(smi, port, i);
+ err = smi->ops->set_mc_index(smi, port, i);
return err;
}
}
/* We have no MC entry for this VID, try to find an empty one */
for (i = 0; i < RTL8366S_NUM_VLANS; i++) {
- err = rtl8366s_get_vlan_mc(smi, i, &vlanmc);
+ err = smi->ops->get_vlan_mc(smi, i, &vlanmc);
if (err)
return err;
if (vlanmc.vid == 0 && vlanmc.member == 0) {
/* Update the entry from the 4K table */
- err = rtl8366s_get_vlan_4k(smi, vid, &vlan4k);
+ err = smi->ops->get_vlan_4k(smi, vid, &vlan4k);
if (err)
return err;
vlanmc.member = vlan4k.member;
vlanmc.untag = vlan4k.untag;
vlanmc.fid = vlan4k.fid;
- err = rtl8366s_set_vlan_mc(smi, i, &vlanmc);
+ err = smi->ops->set_vlan_mc(smi, i, &vlanmc);
if (err)
return err;
- err = rtl8366s_set_mc_index(smi, port, i);
+ err = smi->ops->set_mc_index(smi, port, i);
return err;
}
}
if (!used) {
/* Update the entry from the 4K table */
- err = rtl8366s_get_vlan_4k(smi, vid, &vlan4k);
+ err = smi->ops->get_vlan_4k(smi, vid, &vlan4k);
if (err)
return err;
vlanmc.member = vlan4k.member;
vlanmc.untag = vlan4k.untag;
vlanmc.fid = vlan4k.fid;
- err = rtl8366s_set_vlan_mc(smi, i, &vlanmc);
+ err = smi->ops->set_vlan_mc(smi, i, &vlanmc);
if (err)
return err;
- err = rtl8366s_set_mc_index(smi, port, i);
+ err = smi->ops->set_mc_index(smi, port, i);
return err;
}
}
vlanmc.untag = 0;
vlanmc.fid = 0;
for (i = 0; i < RTL8366S_NUM_VLANS; i++) {
- err = rtl8366s_set_vlan_mc(smi, i, &vlanmc);
+ err = smi->ops->set_vlan_mc(smi, i, &vlanmc);
if (err)
return err;
}
.detect = rtl8366s_detect,
.mii_read = rtl8366s_mii_read,
.mii_write = rtl8366s_mii_write,
+
+ .get_vlan_mc = rtl8366s_get_vlan_mc,
+ .set_vlan_mc = rtl8366s_set_vlan_mc,
+ .get_vlan_4k = rtl8366s_get_vlan_4k,
+ .set_vlan_4k = rtl8366s_set_vlan_4k,
+ .get_mc_index = rtl8366s_get_mc_index,
+ .set_mc_index = rtl8366s_set_mc_index,
};
static int __init rtl8366s_probe(struct platform_device *pdev)