diff mbox

[net,1/1] drivers: net: cpsw: discard dual emac default vlan configuration

Message ID 1421756740-32180-1-git-send-email-mugunthanvnm@ti.com
State Superseded, archived
Delegated to: David Miller
Headers show

Commit Message

Mugunthan V N Jan. 20, 2015, 12:25 p.m. UTC
In Dual EMAC, the default vlans are used to segregate rx packets between
the ports, so adding the same default vlan to the switch will affect the
normal packet transfers. So returning error on addition of dual emac
default vlans.

Even if emac 0 default port vlan is added to emac 1, it will lead to
break dual EMAC port seperations.

Fixes: d9ba8f9 (driver: net: ethernet: cpsw: dual emac interface implementation)
Cc: <stable@vger.kernel.org> # v3.9+
Reported-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
---
 drivers/net/ethernet/ti/cpsw.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

Comments

Sergei Shtylyov Jan. 20, 2015, 2:25 p.m. UTC | #1
Hello.

On 1/20/2015 3:25 PM, Mugunthan V N wrote:

> In Dual EMAC, the default vlans are used to segregate rx packets between

    VLANs. And RX.

> the ports, so adding the same default vlan to the switch will affect the

    VLAN.

> normal packet transfers. So returning error on addition of dual emac

    EMAC.

> default vlans.

    VLANs.

> Even if emac 0 default port vlan is added to emac 1, it will lead to

    EMAC. And VLAN

> break

    Breaking.

> dual EMAC port seperations.

    Separations.

> Fixes: d9ba8f9 (driver: net: ethernet: cpsw: dual emac interface implementation)

    12 hex digits, please.

> Cc: <stable@vger.kernel.org> # v3.9+
> Reported-by: Felipe Balbi <balbi@ti.com>
> Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
> ---
>   drivers/net/ethernet/ti/cpsw.c | 22 ++++++++++++++++++++++
>   1 file changed, 22 insertions(+)

> diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
> index e068d48..7c32815 100644
> --- a/drivers/net/ethernet/ti/cpsw.c
> +++ b/drivers/net/ethernet/ti/cpsw.c
> @@ -1683,6 +1683,19 @@ static int cpsw_ndo_vlan_rx_add_vid(struct net_device *ndev,
>   	if (vid == priv->data.default_vlan)
>   		return 0;
>
> +	if (priv->data.dual_emac) {
> +		/* In dual EMAC, reserved VLAN id should not be used of

    s/of/for/, perhaps?

> +		 * creating vlan interfaces as this can break the dual

    s/vlan/VLAN/. Be consistent, please.

> +		 * EMAC port seperation

    Separation.

[...]

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mugunthan V N Jan. 22, 2015, 8:20 a.m. UTC | #2
On Tuesday 20 January 2015 07:55 PM, Sergei Shtylyov wrote:
> Hello.
> 
> On 1/20/2015 3:25 PM, Mugunthan V N wrote:
> 
>> In Dual EMAC, the default vlans are used to segregate rx packets between
> 
>    VLANs. And RX.
> 
>> the ports, so adding the same default vlan to the switch will affect the
> 
>    VLAN.
> 
>> normal packet transfers. So returning error on addition of dual emac
> 
>    EMAC.
> 
>> default vlans.
> 
>    VLANs.
> 
>> Even if emac 0 default port vlan is added to emac 1, it will lead to
> 
>    EMAC. And VLAN
> 
>> break
> 
>    Breaking.
> 
>> dual EMAC port seperations.
> 
>    Separations.
> 
>> Fixes: d9ba8f9 (driver: net: ethernet: cpsw: dual emac interface
>> implementation)
> 
>    12 hex digits, please.
> 
>> Cc: <stable@vger.kernel.org> # v3.9+
>> Reported-by: Felipe Balbi <balbi@ti.com>
>> Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
>> ---
>>   drivers/net/ethernet/ti/cpsw.c | 22 ++++++++++++++++++++++
>>   1 file changed, 22 insertions(+)
> 
>> diff --git a/drivers/net/ethernet/ti/cpsw.c
>> b/drivers/net/ethernet/ti/cpsw.c
>> index e068d48..7c32815 100644
>> --- a/drivers/net/ethernet/ti/cpsw.c
>> +++ b/drivers/net/ethernet/ti/cpsw.c
>> @@ -1683,6 +1683,19 @@ static int cpsw_ndo_vlan_rx_add_vid(struct
>> net_device *ndev,
>>       if (vid == priv->data.default_vlan)
>>           return 0;
>>
>> +    if (priv->data.dual_emac) {
>> +        /* In dual EMAC, reserved VLAN id should not be used of
> 
>    s/of/for/, perhaps?
> 
>> +         * creating vlan interfaces as this can break the dual
> 
>    s/vlan/VLAN/. Be consistent, please.
> 
>> +         * EMAC port seperation
> 
>    Separation.
> 
> [...]

Will fix this and resubmit next version.

Regards
Mugunthan V N

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index e068d48..7c32815 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -1683,6 +1683,19 @@  static int cpsw_ndo_vlan_rx_add_vid(struct net_device *ndev,
 	if (vid == priv->data.default_vlan)
 		return 0;
 
+	if (priv->data.dual_emac) {
+		/* In dual EMAC, reserved VLAN id should not be used of
+		 * creating vlan interfaces as this can break the dual
+		 * EMAC port seperation
+		 */
+		int i;
+
+		for (i = 0; i < priv->data.slaves; i++) {
+			if (vid == priv->slaves[i].port_vlan)
+				return -EINVAL;
+		}
+	}
+
 	dev_info(priv->dev, "Adding vlanid %d to vlan filter\n", vid);
 	return cpsw_add_vlan_ale_entry(priv, vid);
 }
@@ -1696,6 +1709,15 @@  static int cpsw_ndo_vlan_rx_kill_vid(struct net_device *ndev,
 	if (vid == priv->data.default_vlan)
 		return 0;
 
+	if (priv->data.dual_emac) {
+		int i;
+
+		for (i = 0; i < priv->data.slaves; i++) {
+			if (vid == priv->slaves[i].port_vlan)
+				return -EINVAL;
+		}
+	}
+
 	dev_info(priv->dev, "removing vlanid %d from vlan filter\n", vid);
 	ret = cpsw_ale_del_vlan(priv->ale, vid, 0);
 	if (ret != 0)