Эх сурвалжийг харах

HACK: drivers: net: cpsw: switch-config: unknown vlan handling

Currently only known VLAN id packets are handled inside the switch,
when an unknown VLAN is received, the switch will drop the packets.
This ioctl allows user to subscribe the ports for unknown VLAN id
packet forwarding with combinations like packet with multicst destination
address present which is present in ALE table with unknown VLAN id and
packet with multicast destination address which is not present in ALE
table with unknown VLAN id, then switch will start forwarding these
packets as per configured by the user. Additional features of the
unknown vlan handling of the switch other than port forwarding is to
untag on egress for external ports.

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Mugunthan V N 7 жил өмнө
parent
commit
5ee9a1e835

+ 22 - 0
drivers/net/ethernet/ti/cpsw.c

@@ -2313,6 +2313,28 @@ static int cpsw_switch_config_ioctl(struct net_device *ndev,
 		ret = copy_to_user(ifrq->ifr_data, &config, sizeof(config));
 		break;
 	}
+	case CONFIG_SWITCH_ADD_UNKNOWN_VLAN_INFO:
+		if ((config.unknown_vlan_member <= 7) &&
+		    (config.unknown_vlan_untag <= 7) &&
+		    (config.unknown_vlan_unreg_multi <= 7) &&
+		    (config.unknown_vlan_reg_multi <= 7)) {
+			cpsw_ale_control_set(cpsw->ale, 0,
+					     ALE_PORT_UNTAGGED_EGRESS,
+					     config.unknown_vlan_untag);
+			cpsw_ale_control_set(cpsw->ale, 0,
+					     ALE_PORT_UNKNOWN_REG_MCAST_FLOOD,
+					     config.unknown_vlan_reg_multi);
+			cpsw_ale_control_set(cpsw->ale, 0,
+					     ALE_PORT_UNKNOWN_MCAST_FLOOD,
+					     config.unknown_vlan_unreg_multi);
+			cpsw_ale_control_set(cpsw->ale, 0,
+					     ALE_PORT_UNKNOWN_VLAN_MEMBER,
+					     config.unknown_vlan_member);
+			ret = 0;
+		} else {
+			dev_err(priv->dev, "Invalid Unknown VLAN Arguments\n");
+		}
+		break;
 
 	default:
 		ret = -EOPNOTSUPP;

+ 5 - 0
include/uapi/linux/net_switch_config.h

@@ -18,6 +18,7 @@ enum {
 	CONFIG_SWITCH_DEL_VLAN,
 	CONFIG_SWITCH_SET_PORT_CONFIG,
 	CONFIG_SWITCH_GET_PORT_CONFIG,
+	CONFIG_SWITCH_ADD_UNKNOWN_VLAN_INFO,
 };
 
 /*
@@ -34,6 +35,10 @@ struct net_switch_config {
 	unsigned char	addr[6];
 	unsigned int	super;
 	struct ethtool_cmd ecmd;
+	unsigned char	unknown_vlan_member;
+	unsigned char	unknown_vlan_untag;
+	unsigned int	unknown_vlan_unreg_multi;
+	unsigned int	unknown_vlan_reg_multi;
 
 	unsigned int ret_type;   /* Return  Success/Failure */
 };