From patchwork Tue Jan 6 17:43:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 425758 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 625F3140082 for ; Wed, 7 Jan 2015 04:44:27 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755979AbbAFRoM (ORCPT ); Tue, 6 Jan 2015 12:44:12 -0500 Received: from devils.ext.ti.com ([198.47.26.153]:34510 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755801AbbAFRoK (ORCPT ); Tue, 6 Jan 2015 12:44:10 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id t06Hi8Go011709; Tue, 6 Jan 2015 11:44:08 -0600 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id t06Hi8Y5022622; Tue, 6 Jan 2015 11:44:08 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.174.1; Tue, 6 Jan 2015 11:44:08 -0600 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id t06Hi75t000526; Tue, 6 Jan 2015 11:44:08 -0600 From: Felipe Balbi To: David Miller CC: , Linux OMAP Mailing List , Felipe Balbi , , Mugunthan V N Subject: [PATCH] net: ethernet: cpsw: ignore VLAN ID 1 Date: Tue, 6 Jan 2015 11:43:32 -0600 Message-ID: <1420566212-30081-1-git-send-email-balbi@ti.com> X-Mailer: git-send-email 2.2.0 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org CPSW completely hangs if we add, and later remove, VLAN ID #1. What happens is that after removing VLAN ID #1, no packets will be received by CPSW rendering network unusable. In order to "fix" the issue, we're returning -EINVAL if anybody tries to add VLAN ID #1. While at that, also filter out any ID > 4095 because we only have 12 bits for VLAN IDs. Fixes: 3b72c2f (drivers: net:ethernet: cpsw: add support for VLAN) Cc: # v3.9+ Cc: Mugunthan V N Tested-by: Schuyler Patton Signed-off-by: Felipe Balbi --- drivers/net/ethernet/ti/cpsw.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index e61ee8351272..028bb7f3de65 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -1669,6 +1669,13 @@ static int cpsw_ndo_vlan_rx_add_vid(struct net_device *ndev, if (vid == priv->data.default_vlan) return 0; + /* NOTICE: CPSW does not support VID 1. We should + * also filter out VID > 4095 as we only have 12 + * bits for VID entries + */ + if (vid == 1 || vid >= VLAN_N_VID) + return -EINVAL; + dev_info(priv->dev, "Adding vlanid %d to vlan filter\n", vid); return cpsw_add_vlan_ale_entry(priv, vid); } @@ -1682,6 +1689,13 @@ static int cpsw_ndo_vlan_rx_kill_vid(struct net_device *ndev, if (vid == priv->data.default_vlan) return 0; + /* NOTICE: CPSW does not support VID 1. We should + * also filter out VID > 4095 as we only have 12 + * bits for VID entries + */ + if (vid == 1 || vid >= VLAN_N_VID) + 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)