realtek: Cleanup setting inner/outer PVID and Ingress/Egres VLAN filtering
Use setting functions instead of register numbers in order to clean up the code. Also use enums to define inner/outer VLAN types and the filter type. Signed-off-by: Sebastian Gottschall <s.gottschall@dd-wrt.com> Signed-off-by: Birger Koblitz <git@birger-koblitz.de>
This commit is contained in:
committed by
Daniel Golle
parent
5b8b382df9
commit
77f3e2ea17
@@ -1705,6 +1705,35 @@ int rtl839x_l3_setup(struct rtl838x_switch_priv *priv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtl839x_vlan_port_pvidmode_set(int port, enum pbvlan_type type, enum pbvlan_mode mode)
|
||||
{
|
||||
if (type == PBVLAN_TYPE_INNER)
|
||||
sw_w32_mask(0x3, mode, RTL839X_VLAN_PORT_PB_VLAN + (port << 2));
|
||||
else
|
||||
sw_w32_mask(0x3 << 14, mode << 14, RTL839X_VLAN_PORT_PB_VLAN + (port << 2));
|
||||
}
|
||||
|
||||
void rtl839x_vlan_port_pvid_set(int port, enum pbvlan_type type, int pvid)
|
||||
{
|
||||
if (type == PBVLAN_TYPE_INNER)
|
||||
sw_w32_mask(0xfff << 2, pvid << 2, RTL839X_VLAN_PORT_PB_VLAN + (port << 2));
|
||||
else
|
||||
sw_w32_mask(0xfff << 16, pvid << 16, RTL839X_VLAN_PORT_PB_VLAN + (port << 2));
|
||||
}
|
||||
|
||||
static void rtl839x_set_igr_filter(int port, enum igr_filter state)
|
||||
{
|
||||
sw_w32_mask(0x3 << ((port & 0xf)<<1), state << ((port & 0xf)<<1),
|
||||
RTL839X_VLAN_PORT_IGR_FLTR + (((port >> 4) << 2)));
|
||||
}
|
||||
|
||||
static void rtl839x_set_egr_filter(int port, enum egr_filter state)
|
||||
{
|
||||
sw_w32_mask(0x1 << (port % 0x20), state << (port % 0x20),
|
||||
RTL839X_VLAN_PORT_EGR_FLTR + (((port >> 5) << 2)));
|
||||
}
|
||||
|
||||
|
||||
const struct rtl838x_reg rtl839x_reg = {
|
||||
.mask_port_reg_be = rtl839x_mask_port_reg_be,
|
||||
.set_port_reg_be = rtl839x_set_port_reg_be,
|
||||
@@ -1738,6 +1767,10 @@ const struct rtl838x_reg rtl839x_reg = {
|
||||
.vlan_profile_dump = rtl839x_vlan_profile_dump,
|
||||
.vlan_profile_setup = rtl839x_vlan_profile_setup,
|
||||
.vlan_fwd_on_inner = rtl839x_vlan_fwd_on_inner,
|
||||
.vlan_port_pvidmode_set = rtl839x_vlan_port_pvidmode_set,
|
||||
.vlan_port_pvid_set = rtl839x_vlan_port_pvid_set,
|
||||
.set_vlan_igr_filter = rtl839x_set_igr_filter,
|
||||
.set_vlan_egr_filter = rtl839x_set_egr_filter,
|
||||
.stp_get = rtl839x_stp_get,
|
||||
.stp_set = rtl839x_stp_set,
|
||||
.mac_force_mode_ctrl = rtl839x_mac_force_mode_ctrl,
|
||||
@@ -1756,9 +1789,6 @@ const struct rtl838x_reg rtl839x_reg = {
|
||||
.write_l2_entry_using_hash = rtl839x_write_l2_entry_using_hash,
|
||||
.read_cam = rtl839x_read_cam,
|
||||
.write_cam = rtl839x_write_cam,
|
||||
.vlan_port_egr_filter = RTL839X_VLAN_PORT_EGR_FLTR,
|
||||
.vlan_port_igr_filter = RTL839X_VLAN_PORT_IGR_FLTR,
|
||||
.vlan_port_pb = RTL839X_VLAN_PORT_PB_VLAN,
|
||||
.vlan_port_tag_sts_ctrl = RTL839X_VLAN_PORT_TAG_STS_CTRL,
|
||||
.trk_mbr_ctr = rtl839x_trk_mbr_ctr,
|
||||
.rma_bpdu_fld_pmask = RTL839X_RMA_BPDU_FLD_PMSK,
|
||||
|
||||
Reference in New Issue
Block a user