mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2024-11-27 21:44:04 +02:00
generic: rtl8366: add common vlan_4k structure
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@21915 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
53bb5d147a
commit
22e4a8566f
@ -42,6 +42,13 @@ struct rtl8366_vlan_mc {
|
|||||||
u8 fid;
|
u8 fid;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct rtl8366_vlan_4k {
|
||||||
|
u16 vid;
|
||||||
|
u8 untag;
|
||||||
|
u8 member;
|
||||||
|
u8 fid;
|
||||||
|
};
|
||||||
|
|
||||||
int rtl8366_smi_init(struct rtl8366_smi *smi);
|
int rtl8366_smi_init(struct rtl8366_smi *smi);
|
||||||
void rtl8366_smi_cleanup(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 rtl8366_smi_write_reg(struct rtl8366_smi *smi, u32 addr, u32 data);
|
||||||
|
@ -372,20 +372,21 @@ static int rtl8366_get_mib_counter(struct rtl8366rb *rtl, int counter,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int rtl8366rb_get_vlan_4k(struct rtl8366rb *rtl, u32 vid,
|
static int rtl8366rb_get_vlan_4k(struct rtl8366rb *rtl, u32 vid,
|
||||||
struct rtl8366rb_vlan_4k *vlan4k)
|
struct rtl8366_vlan_4k *vlan4k)
|
||||||
{
|
{
|
||||||
struct rtl8366_smi *smi = &rtl->smi;
|
struct rtl8366_smi *smi = &rtl->smi;
|
||||||
|
struct rtl8366rb_vlan_4k vlan4k_priv;
|
||||||
int err;
|
int err;
|
||||||
u32 data;
|
u32 data;
|
||||||
u16 *tableaddr;
|
u16 *tableaddr;
|
||||||
|
|
||||||
memset(vlan4k, '\0', sizeof(struct rtl8366rb_vlan_4k));
|
memset(vlan4k, '\0', sizeof(struct rtl8366_vlan_4k));
|
||||||
vlan4k->vid = vid;
|
vlan4k_priv.vid = vid;
|
||||||
|
|
||||||
if (vid >= RTL8366_NUM_VIDS)
|
if (vid >= RTL8366_NUM_VIDS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
tableaddr = (u16 *)vlan4k;
|
tableaddr = (u16 *)&vlan4k_priv;
|
||||||
|
|
||||||
/* write VID */
|
/* write VID */
|
||||||
data = *tableaddr;
|
data = *tableaddr;
|
||||||
@ -419,15 +420,20 @@ static int rtl8366rb_get_vlan_4k(struct rtl8366rb *rtl, u32 vid,
|
|||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
*tableaddr = data;
|
*tableaddr = data;
|
||||||
|
|
||||||
vlan4k->vid = vid;
|
vlan4k->vid = vid;
|
||||||
|
vlan4k->untag = vlan4k_priv.untag;
|
||||||
|
vlan4k->member = vlan4k_priv.member;
|
||||||
|
vlan4k->fid = vlan4k_priv.fid;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rtl8366rb_set_vlan_4k(struct rtl8366rb *rtl,
|
static int rtl8366rb_set_vlan_4k(struct rtl8366rb *rtl,
|
||||||
const struct rtl8366rb_vlan_4k *vlan4k)
|
const struct rtl8366_vlan_4k *vlan4k)
|
||||||
{
|
{
|
||||||
struct rtl8366_smi *smi = &rtl->smi;
|
struct rtl8366_smi *smi = &rtl->smi;
|
||||||
|
struct rtl8366rb_vlan_4k vlan4k_priv;
|
||||||
int err;
|
int err;
|
||||||
u32 data;
|
u32 data;
|
||||||
u16 *tableaddr;
|
u16 *tableaddr;
|
||||||
@ -438,7 +444,12 @@ static int rtl8366rb_set_vlan_4k(struct rtl8366rb *rtl,
|
|||||||
vlan4k->fid > RTL8366S_FIDMAX)
|
vlan4k->fid > RTL8366S_FIDMAX)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
tableaddr = (u16 *)vlan4k;
|
vlan4k_priv.vid = vlan4k->vid;
|
||||||
|
vlan4k_priv.untag = vlan4k->untag;
|
||||||
|
vlan4k_priv.member = vlan4k->member;
|
||||||
|
vlan4k_priv.fid = vlan4k->fid;
|
||||||
|
|
||||||
|
tableaddr = (u16 *)&vlan4k_priv;
|
||||||
|
|
||||||
data = *tableaddr;
|
data = *tableaddr;
|
||||||
|
|
||||||
@ -645,7 +656,7 @@ static int rtl8366rb_set_vlan_port_pvid(struct rtl8366rb *rtl, int port, int val
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct rtl8366_vlan_mc vlanmc;
|
struct rtl8366_vlan_mc vlanmc;
|
||||||
struct rtl8366rb_vlan_4k vlan4k;
|
struct rtl8366_vlan_4k vlan4k;
|
||||||
|
|
||||||
if (port >= RTL8366_NUM_PORTS || val >= RTL8366_NUM_VIDS)
|
if (port >= RTL8366_NUM_PORTS || val >= RTL8366_NUM_VIDS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@ -741,7 +752,7 @@ static int rtl8366rb_vlan_set_4ktable(struct rtl8366rb *rtl, int enable)
|
|||||||
|
|
||||||
static int rtl8366rb_reset_vlan(struct rtl8366rb *rtl)
|
static int rtl8366rb_reset_vlan(struct rtl8366rb *rtl)
|
||||||
{
|
{
|
||||||
struct rtl8366rb_vlan_4k vlan4k;
|
struct rtl8366_vlan_4k vlan4k;
|
||||||
struct rtl8366_vlan_mc vlanmc;
|
struct rtl8366_vlan_mc vlanmc;
|
||||||
int err;
|
int err;
|
||||||
int i;
|
int i;
|
||||||
@ -1167,7 +1178,7 @@ static int rtl8366rb_sw_get_vlan_info(struct switch_dev *dev,
|
|||||||
int i;
|
int i;
|
||||||
u32 len = 0;
|
u32 len = 0;
|
||||||
struct rtl8366_vlan_mc vlanmc;
|
struct rtl8366_vlan_mc vlanmc;
|
||||||
struct rtl8366rb_vlan_4k vlan4k;
|
struct rtl8366_vlan_4k vlan4k;
|
||||||
struct rtl8366rb *rtl = sw_to_rtl8366rb(dev);
|
struct rtl8366rb *rtl = sw_to_rtl8366rb(dev);
|
||||||
char *buf = rtl->buf;
|
char *buf = rtl->buf;
|
||||||
|
|
||||||
@ -1333,7 +1344,7 @@ static int rtl8366rb_sw_set_vlan_ports(struct switch_dev *dev,
|
|||||||
struct switch_val *val)
|
struct switch_val *val)
|
||||||
{
|
{
|
||||||
struct rtl8366_vlan_mc vlanmc;
|
struct rtl8366_vlan_mc vlanmc;
|
||||||
struct rtl8366rb_vlan_4k vlan4k;
|
struct rtl8366_vlan_4k vlan4k;
|
||||||
struct rtl8366rb *rtl = sw_to_rtl8366rb(dev);
|
struct rtl8366rb *rtl = sw_to_rtl8366rb(dev);
|
||||||
struct switch_port *port;
|
struct switch_port *port;
|
||||||
int i;
|
int i;
|
||||||
|
@ -373,20 +373,21 @@ static int rtl8366_get_mib_counter(struct rtl8366s *rtl, int counter,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int rtl8366s_get_vlan_4k(struct rtl8366s *rtl, u32 vid,
|
static int rtl8366s_get_vlan_4k(struct rtl8366s *rtl, u32 vid,
|
||||||
struct rtl8366s_vlan_4k *vlan4k)
|
struct rtl8366_vlan_4k *vlan4k)
|
||||||
{
|
{
|
||||||
struct rtl8366_smi *smi = &rtl->smi;
|
struct rtl8366_smi *smi = &rtl->smi;
|
||||||
|
struct rtl8366s_vlan_4k vlan4k_priv;
|
||||||
int err;
|
int err;
|
||||||
u32 data;
|
u32 data;
|
||||||
u16 *tableaddr;
|
u16 *tableaddr;
|
||||||
|
|
||||||
memset(vlan4k, '\0', sizeof(struct rtl8366s_vlan_4k));
|
memset(vlan4k, '\0', sizeof(struct rtl8366_vlan_4k));
|
||||||
vlan4k->vid = vid;
|
vlan4k_priv.vid = vid;
|
||||||
|
|
||||||
if (vid >= RTL8366_NUM_VIDS)
|
if (vid >= RTL8366_NUM_VIDS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
tableaddr = (u16 *)vlan4k;
|
tableaddr = (u16 *)&vlan4k_priv;
|
||||||
|
|
||||||
/* write VID */
|
/* write VID */
|
||||||
data = *tableaddr;
|
data = *tableaddr;
|
||||||
@ -413,15 +414,20 @@ static int rtl8366s_get_vlan_4k(struct rtl8366s *rtl, u32 vid,
|
|||||||
return err;
|
return err;
|
||||||
|
|
||||||
*tableaddr = data;
|
*tableaddr = data;
|
||||||
|
|
||||||
vlan4k->vid = vid;
|
vlan4k->vid = vid;
|
||||||
|
vlan4k->untag = vlan4k_priv.untag;
|
||||||
|
vlan4k->member = vlan4k_priv.member;
|
||||||
|
vlan4k->fid = vlan4k_priv.fid;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rtl8366s_set_vlan_4k(struct rtl8366s *rtl,
|
static int rtl8366s_set_vlan_4k(struct rtl8366s *rtl,
|
||||||
const struct rtl8366s_vlan_4k *vlan4k)
|
const struct rtl8366_vlan_4k *vlan4k)
|
||||||
{
|
{
|
||||||
struct rtl8366_smi *smi = &rtl->smi;
|
struct rtl8366_smi *smi = &rtl->smi;
|
||||||
|
struct rtl8366s_vlan_4k vlan4k_priv;
|
||||||
int err;
|
int err;
|
||||||
u32 data;
|
u32 data;
|
||||||
u16 *tableaddr;
|
u16 *tableaddr;
|
||||||
@ -432,7 +438,12 @@ static int rtl8366s_set_vlan_4k(struct rtl8366s *rtl,
|
|||||||
vlan4k->fid > RTL8366S_FIDMAX)
|
vlan4k->fid > RTL8366S_FIDMAX)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
tableaddr = (u16 *)vlan4k;
|
vlan4k_priv.vid = vlan4k->vid;
|
||||||
|
vlan4k_priv.untag = vlan4k->untag;
|
||||||
|
vlan4k_priv.member = vlan4k->member;
|
||||||
|
vlan4k_priv.fid = vlan4k->fid;
|
||||||
|
|
||||||
|
tableaddr = (u16 *)&vlan4k_priv;
|
||||||
|
|
||||||
data = *tableaddr;
|
data = *tableaddr;
|
||||||
|
|
||||||
@ -612,7 +623,7 @@ static int rtl8366s_set_vlan_port_pvid(struct rtl8366s *rtl, int port, int val)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct rtl8366_vlan_mc vlanmc;
|
struct rtl8366_vlan_mc vlanmc;
|
||||||
struct rtl8366s_vlan_4k vlan4k;
|
struct rtl8366_vlan_4k vlan4k;
|
||||||
|
|
||||||
if (port >= RTL8366_NUM_PORTS || val >= RTL8366_NUM_VIDS)
|
if (port >= RTL8366_NUM_PORTS || val >= RTL8366_NUM_VIDS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@ -708,7 +719,7 @@ static int rtl8366s_vlan_set_4ktable(struct rtl8366s *rtl, int enable)
|
|||||||
|
|
||||||
static int rtl8366s_reset_vlan(struct rtl8366s *rtl)
|
static int rtl8366s_reset_vlan(struct rtl8366s *rtl)
|
||||||
{
|
{
|
||||||
struct rtl8366s_vlan_4k vlan4k;
|
struct rtl8366_vlan_4k vlan4k;
|
||||||
struct rtl8366_vlan_mc vlanmc;
|
struct rtl8366_vlan_mc vlanmc;
|
||||||
int err;
|
int err;
|
||||||
int i;
|
int i;
|
||||||
@ -1134,7 +1145,7 @@ static int rtl8366s_sw_get_vlan_info(struct switch_dev *dev,
|
|||||||
int i;
|
int i;
|
||||||
u32 len = 0;
|
u32 len = 0;
|
||||||
struct rtl8366_vlan_mc vlanmc;
|
struct rtl8366_vlan_mc vlanmc;
|
||||||
struct rtl8366s_vlan_4k vlan4k;
|
struct rtl8366_vlan_4k vlan4k;
|
||||||
struct rtl8366s *rtl = sw_to_rtl8366s(dev);
|
struct rtl8366s *rtl = sw_to_rtl8366s(dev);
|
||||||
char *buf = rtl->buf;
|
char *buf = rtl->buf;
|
||||||
|
|
||||||
@ -1301,7 +1312,7 @@ static int rtl8366s_sw_set_vlan_ports(struct switch_dev *dev,
|
|||||||
struct switch_val *val)
|
struct switch_val *val)
|
||||||
{
|
{
|
||||||
struct rtl8366_vlan_mc vlanmc;
|
struct rtl8366_vlan_mc vlanmc;
|
||||||
struct rtl8366s_vlan_4k vlan4k;
|
struct rtl8366_vlan_4k vlan4k;
|
||||||
struct rtl8366s *rtl = sw_to_rtl8366s(dev);
|
struct rtl8366s *rtl = sw_to_rtl8366s(dev);
|
||||||
struct switch_port *port;
|
struct switch_port *port;
|
||||||
int i;
|
int i;
|
||||||
|
Loading…
Reference in New Issue
Block a user