From nobody Thu Nov 28 07:51:45 2024 Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B62F13BAC3; Fri, 4 Oct 2024 07:47:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.249 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728028061; cv=none; b=tTlH6dVuZUz5zpCEQjWY9MUWgLpQj+FMnazHLXvPMMe5QzMeNiU+2AKlkwx6c5HoL/CGJkgYj0C2HoEePFzMhNXHfmIffV9MCAIhiDVn+WZs7zjzIhT5K3OUu6RGaiITgdR5xfTKlXteXgC351fC+nZEp18sn7Shd6veKfkHWEA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728028061; c=relaxed/simple; bh=1e9EMzbOkCe8QeLgo321fC6JIOrshzvFhDmjxlTYQHU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JwbiMjDg8fTDbMGtu/zIx5+y2eUTPLaE/asq+187VGAlElVydpA9s2kvpD3/qGelZdHSbpS00DQlu8pl4+2hPC0Auwujm3riRmzUTHBtvHRI4PcZBDBta0YeQ2FPe0t4w7Cxk2CfXOe+NMpreYdVEpCm1y03AeTdp+1RVDy+Bo4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=mHxfTecu; arc=none smtp.client-ip=198.47.23.249 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="mHxfTecu" Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 4947lLAC029262; Fri, 4 Oct 2024 02:47:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1728028041; bh=F0r9YfXt8Uj1SHwj4YtWmhPuFbfRsQj+MfokUz9rqAs=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=mHxfTecuZKLg9yI7YutXqdjxwCwToPVeUOOS1sViuPHtmk9wi900F5fWPniHxYki0 4yaPSB1mJjI0bIYwzNo2jke7cd/7Daj9zYCDdtD36agU/FpNoXfGYcjaP46GASligO MVTZJPV9FtJFxTndGQChbSCdvPe+Qrjoe1+LxD0I= Received: from DFLE111.ent.ti.com (dfle111.ent.ti.com [10.64.6.32]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 4947lLha035331 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 4 Oct 2024 02:47:21 -0500 Received: from DFLE110.ent.ti.com (10.64.6.31) by DFLE111.ent.ti.com (10.64.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 4 Oct 2024 02:47:21 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE110.ent.ti.com (10.64.6.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 4 Oct 2024 02:47:21 -0500 Received: from lelv0854.itg.ti.com (lelv0854.itg.ti.com [10.181.64.140]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 4947lLI8071986; Fri, 4 Oct 2024 02:47:21 -0500 Received: from localhost (danish-tpc.dhcp.ti.com [10.24.69.25]) by lelv0854.itg.ti.com (8.14.7/8.14.7) with ESMTP id 4947lKxV025142; Fri, 4 Oct 2024 02:47:21 -0500 From: MD Danish Anwar To: , , , , , , , , , , , CC: , , , , Vignesh Raghavendra , Roger Quadros , Subject: [PATCH net-next 2/3] net: hsr: Add VLAN CTAG filter support Date: Fri, 4 Oct 2024 13:17:14 +0530 Message-ID: <20241004074715.791191-3-danishanwar@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241004074715.791191-1-danishanwar@ti.com> References: <20241004074715.791191-1-danishanwar@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea Content-Type: text/plain; charset="utf-8" From: Murali Karicheri This patch adds support for VLAN ctag based filtering at slave devices. The slave ethernet device may be capable of filtering ethernet packets based on VLAN ID. This requires that when the VLAN interface is created over an HSR/PRP interface, it passes the VID information to the associated slave ethernet devices so that it updates the hardware filters to filter ethernet frames based on VID. This patch adds the required functions to propagate the vid information to the slave devices. Signed-off-by: Murali Karicheri Signed-off-by: MD Danish Anwar --- net/hsr/hsr_device.c | 71 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c index 0ca47ebb01d3..ff586bdc2bde 100644 --- a/net/hsr/hsr_device.c +++ b/net/hsr/hsr_device.c @@ -515,6 +515,68 @@ static void hsr_change_rx_flags(struct net_device *dev= , int change) } } =20 +static int hsr_ndo_vlan_rx_add_vid(struct net_device *dev, + __be16 proto, u16 vid) +{ + struct hsr_port *port; + struct hsr_priv *hsr; + int ret =3D 0; + + hsr =3D netdev_priv(dev); + + hsr_for_each_port(hsr, port) { + if (port->type =3D=3D HSR_PT_MASTER) + continue; + + ret =3D vlan_vid_add(port->dev, proto, vid); + switch (port->type) { + case HSR_PT_SLAVE_A: + if (ret) { + netdev_err(dev, "add vid failed for Slave-A\n"); + return ret; + } + break; + + case HSR_PT_SLAVE_B: + if (ret) { + /* clean up Slave-A */ + netdev_err(dev, "add vid failed for Slave-B\n"); + vlan_vid_del(port->dev, proto, vid); + return ret; + } + break; + default: + break; + } + } + + return 0; +} + +static int hsr_ndo_vlan_rx_kill_vid(struct net_device *dev, + __be16 proto, u16 vid) +{ + struct hsr_port *port; + struct hsr_priv *hsr; + + hsr =3D netdev_priv(dev); + + hsr_for_each_port(hsr, port) { + if (port->type =3D=3D HSR_PT_MASTER) + continue; + switch (port->type) { + case HSR_PT_SLAVE_A: + case HSR_PT_SLAVE_B: + vlan_vid_del(port->dev, proto, vid); + break; + default: + break; + } + } + + return 0; +} + static const struct net_device_ops hsr_device_ops =3D { .ndo_change_mtu =3D hsr_dev_change_mtu, .ndo_open =3D hsr_dev_open, @@ -523,6 +585,8 @@ static const struct net_device_ops hsr_device_ops =3D { .ndo_change_rx_flags =3D hsr_change_rx_flags, .ndo_fix_features =3D hsr_fix_features, .ndo_set_rx_mode =3D hsr_set_rx_mode, + .ndo_vlan_rx_add_vid =3D hsr_ndo_vlan_rx_add_vid, + .ndo_vlan_rx_kill_vid =3D hsr_ndo_vlan_rx_kill_vid, }; =20 static const struct device_type hsr_type =3D { @@ -569,7 +633,8 @@ void hsr_dev_setup(struct net_device *dev) =20 dev->hw_features =3D NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HIGHDMA | NETIF_F_GSO_MASK | NETIF_F_HW_CSUM | - NETIF_F_HW_VLAN_CTAG_TX; + NETIF_F_HW_VLAN_CTAG_TX | + NETIF_F_HW_VLAN_CTAG_FILTER; =20 dev->features =3D dev->hw_features; } @@ -647,6 +712,10 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struc= t net_device *slave[2], (slave[1]->features & NETIF_F_HW_HSR_FWD)) hsr->fwd_offloaded =3D true; =20 + if ((slave[0]->features & NETIF_F_HW_VLAN_CTAG_FILTER) && + (slave[1]->features & NETIF_F_HW_VLAN_CTAG_FILTER)) + hsr_dev->features |=3D NETIF_F_HW_VLAN_CTAG_FILTER; + res =3D register_netdevice(hsr_dev); if (res) goto err_unregister; --=20 2.34.1