From patchwork Thu Oct 24 10:30:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: MD Danish Anwar X-Patchwork-Id: 13848728 Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (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 C654518B46A; Thu, 24 Oct 2024 10:31:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729765892; cv=none; b=pk5Bh4RVehY1dhXRvjeg6dlkuHncSJ8G1aJFt6YCid07x0b71SJ0CKnnH0gn84hrfuCKg/IeuuHp11TOb54sPJCMo0dW22/dLqPuLsN9sZN091CEwei4yMueODup6kYGc2NLZ4ebAH5N2p05qH/D6By3CpxGQbGZ0UDIGeVj3ys= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729765892; c=relaxed/simple; bh=dIAxm1szg0eXxoUrHaRJyEkFiqNB1EbdiqdWK0Q3L7Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=q6FC/TPQ1xkWhm5z3VDFpnyFOGbUpJl9WF2tfNJMNWQtLYvwcL0gdacK5ULIfCEJfNSekKxkWSrG1/aX5S1vjTgJ1sP6yfkeGV0h1CxLiHpInSI1XeLqhZNO5ZkjqkQGiwcWK9se6iR3R9HsGXE5y3rVfwm136Rh8tr66I2SeYY= 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=meUcuEIU; arc=none smtp.client-ip=198.47.19.141 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="meUcuEIU" Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 49OAV0AH105566; Thu, 24 Oct 2024 05:31:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1729765860; bh=7pYI8kQhzLjk8qhIVY25r6ky5/FBxidxa1N2CUq2AxI=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=meUcuEIUCGevKlh1I5NWc5PRPQTLTOTK4YmrI1wNzb5KaJTIzU78AYCe50port1j+ xcAgZNKpRdhHstjQDVV5IILKC1rpVO9GO9G/r1zbhK83kRP9U9nRIbpyJle6pgwfRX mVFCgFgjEgocNz10kfLTDynGWlVtipqxVz4tu6fQ= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 49OAV0DB022888 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 24 Oct 2024 05:31:00 -0500 Received: from DFLE101.ent.ti.com (10.64.6.22) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Thu, 24 Oct 2024 05:30:59 -0500 Received: from fllvsmtp8.itg.ti.com (10.64.41.158) by DFLE101.ent.ti.com (10.64.6.22) 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; Thu, 24 Oct 2024 05:30:59 -0500 Received: from lelv0854.itg.ti.com (lelv0854.itg.ti.com [10.181.64.140]) by fllvsmtp8.itg.ti.com (8.15.2/8.15.2) with ESMTP id 49OAUxwd082187; Thu, 24 Oct 2024 05:30:59 -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 49OAUxfs024592; Thu, 24 Oct 2024 05:30:59 -0500 From: MD Danish Anwar To: , , , , , , , , , , , , , , , CC: , , , , , Vignesh Raghavendra , Roger Quadros , , Subject: [PATCH net-next v2 1/4] net: hsr: Add VLAN support Date: Thu, 24 Oct 2024 16:00:53 +0530 Message-ID: <20241024103056.3201071-2-danishanwar@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241024103056.3201071-1-danishanwar@ti.com> References: <20241024103056.3201071-1-danishanwar@ti.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea From: WingMan Kwok Add support for creating VLAN interfaces over HSR/PRP interface. Signed-off-by: WingMan Kwok Signed-off-by: Murali Karicheri Signed-off-by: MD Danish Anwar --- net/hsr/hsr_device.c | 5 ----- net/hsr/hsr_forward.c | 19 ++++++++++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c index ebdfd5b64e17..0ca47ebb01d3 100644 --- a/net/hsr/hsr_device.c +++ b/net/hsr/hsr_device.c @@ -572,11 +572,6 @@ void hsr_dev_setup(struct net_device *dev) NETIF_F_HW_VLAN_CTAG_TX; dev->features = dev->hw_features; - - /* VLAN on top of HSR needs testing and probably some work on - * hsr_header_create() etc. - */ - dev->features |= NETIF_F_VLAN_CHALLENGED; } /* Return true if dev is a HSR master; return false otherwise. diff --git a/net/hsr/hsr_forward.c b/net/hsr/hsr_forward.c index b38060246e62..aa6acebc7c1e 100644 --- a/net/hsr/hsr_forward.c +++ b/net/hsr/hsr_forward.c @@ -280,6 +280,7 @@ static struct sk_buff *hsr_fill_tag(struct sk_buff *skb, struct hsr_port *port, u8 proto_version) { struct hsr_ethhdr *hsr_ethhdr; + unsigned char *pc; int lsdu_size; /* pad to minimum packet size which is 60 + 6 (HSR tag) */ @@ -290,7 +291,18 @@ static struct sk_buff *hsr_fill_tag(struct sk_buff *skb, if (frame->is_vlan) lsdu_size -= 4; - hsr_ethhdr = (struct hsr_ethhdr *)skb_mac_header(skb); + pc = skb_mac_header(skb); + if (frame->is_vlan) + /* This 4-byte shift (size of a vlan tag) does not + * mean that the ethhdr starts there. But rather it + * provides the proper environment for accessing + * the fields, such as hsr_tag etc., just like + * when the vlan tag is not there. This is because + * the hsr tag is after the vlan tag. + */ + hsr_ethhdr = (struct hsr_ethhdr *)(pc + VLAN_HLEN); + else + hsr_ethhdr = (struct hsr_ethhdr *)pc; hsr_set_path_id(hsr_ethhdr, port); set_hsr_tag_LSDU_size(&hsr_ethhdr->hsr_tag, lsdu_size); @@ -368,7 +380,7 @@ struct sk_buff *prp_create_tagged_frame(struct hsr_frame_info *frame, return skb_clone(frame->skb_std, GFP_ATOMIC); } - skb = skb_copy_expand(frame->skb_std, 0, + skb = skb_copy_expand(frame->skb_std, skb_headroom(frame->skb_std), skb_tailroom(frame->skb_std) + HSR_HLEN, GFP_ATOMIC); return prp_fill_rct(skb, frame, port); @@ -690,9 +702,6 @@ static int fill_frame_info(struct hsr_frame_info *frame, if (frame->is_vlan) { vlan_hdr = (struct hsr_vlan_ethhdr *)ethhdr; proto = vlan_hdr->vlanhdr.h_vlan_encapsulated_proto; - /* FIXME: */ - netdev_warn_once(skb->dev, "VLAN not yet supported"); - return -EINVAL; } frame->is_from_san = false; From patchwork Thu Oct 24 10:30:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: MD Danish Anwar X-Patchwork-Id: 13848727 Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (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 C65A31AC42B; Thu, 24 Oct 2024 10:31:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729765892; cv=none; b=cWaMqlFNNla0MiDPIhKSMxRzhSUk6/BsYgSIR0CnWPLzzgH+7urmZQTHftGvoGC8B1D/nFMDWEhCvybY+asPwQkzmSKEbCRq3Rqk28Zm4lO3/pc8Dy29U2Isq62tAZi6WQm2aA0E7zysqEHyQooCum+Uom66dEYcEP2Ev2ok1hM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729765892; c=relaxed/simple; bh=1e9EMzbOkCe8QeLgo321fC6JIOrshzvFhDmjxlTYQHU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Gi+gbUbf1cZT46SqWp8EI1f93GSGeoav0P3qf5LHsx9amVNwXDeU+GtGrxcvugZYng3Sf/xSJSRguido2Xu9eJBNF+/1Bih3vIepKqVf6bJ0O1K90neKy3z/5ieoVYECe9Lk4rJZj5H8m5L6jnUad52y/+AAhWP8eIBfOMK0RK8= 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=eohmtpwF; arc=none smtp.client-ip=198.47.19.141 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="eohmtpwF" Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 49OAV2Dv105576; Thu, 24 Oct 2024 05:31:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1729765862; bh=F0r9YfXt8Uj1SHwj4YtWmhPuFbfRsQj+MfokUz9rqAs=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=eohmtpwFdE849Xn6RLdgdudJNx9EGCo0TfRQGu5ufN6XRRyqd3Ic41OplhGmMjsyy uDF+9HOZpBtuwpp6CYRk4Tv2LwmS3NuGBptE5uthBP01+1h33GLQpieeeUJtk5079h 45aLLRZ8DLYy/NhvHY1MKHtaQn140R21ANnTJuFY= Received: from DLEE108.ent.ti.com (dlee108.ent.ti.com [157.170.170.38]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 49OAV2a9002479 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 24 Oct 2024 05:31:02 -0500 Received: from DLEE100.ent.ti.com (157.170.170.30) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Thu, 24 Oct 2024 05:31:01 -0500 Received: from fllvsmtp7.itg.ti.com (10.64.40.31) by DLEE100.ent.ti.com (157.170.170.30) 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; Thu, 24 Oct 2024 05:31:01 -0500 Received: from lelv0854.itg.ti.com (lelv0854.itg.ti.com [10.181.64.140]) by fllvsmtp7.itg.ti.com (8.15.2/8.15.2) with ESMTP id 49OAV1vA000544; Thu, 24 Oct 2024 05:31:01 -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 49OAV1G5024597; Thu, 24 Oct 2024 05:31:01 -0500 From: MD Danish Anwar To: , , , , , , , , , , , , , , , CC: , , , , , Vignesh Raghavendra , Roger Quadros , , Subject: [PATCH net-next v2 2/4] net: hsr: Add VLAN CTAG filter support Date: Thu, 24 Oct 2024 16:00:54 +0530 Message-ID: <20241024103056.3201071-3-danishanwar@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241024103056.3201071-1-danishanwar@ti.com> References: <20241024103056.3201071-1-danishanwar@ti.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea 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) } } +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 = 0; + + hsr = netdev_priv(dev); + + hsr_for_each_port(hsr, port) { + if (port->type == HSR_PT_MASTER) + continue; + + ret = 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 = netdev_priv(dev); + + hsr_for_each_port(hsr, port) { + if (port->type == 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 = { .ndo_change_mtu = hsr_dev_change_mtu, .ndo_open = hsr_dev_open, @@ -523,6 +585,8 @@ static const struct net_device_ops hsr_device_ops = { .ndo_change_rx_flags = hsr_change_rx_flags, .ndo_fix_features = hsr_fix_features, .ndo_set_rx_mode = hsr_set_rx_mode, + .ndo_vlan_rx_add_vid = hsr_ndo_vlan_rx_add_vid, + .ndo_vlan_rx_kill_vid = hsr_ndo_vlan_rx_kill_vid, }; static const struct device_type hsr_type = { @@ -569,7 +633,8 @@ void hsr_dev_setup(struct net_device *dev) dev->hw_features = 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; dev->features = dev->hw_features; } @@ -647,6 +712,10 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2], (slave[1]->features & NETIF_F_HW_HSR_FWD)) hsr->fwd_offloaded = true; + if ((slave[0]->features & NETIF_F_HW_VLAN_CTAG_FILTER) && + (slave[1]->features & NETIF_F_HW_VLAN_CTAG_FILTER)) + hsr_dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER; + res = register_netdevice(hsr_dev); if (res) goto err_unregister; From patchwork Thu Oct 24 10:30:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: MD Danish Anwar X-Patchwork-Id: 13848730 Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) (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 892451C8FB5; Thu, 24 Oct 2024 10:31:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.142 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729765896; cv=none; b=Z+VCHvLuuxNnUKl7HrVmSmRIP4fdsI6/zByjYld5JFppJHVfk6UE87O+Vhyj+cxcBZ5FVE2vEQwQiXn1/ym+Aa44vRX5Ot+Y0s9e3tIMO+EILG7ZKRWtikTIfkZAtE7WE1N5EWbrcrK8/lqEHClfdszyH/p7QR9cz2e3q3hQUNE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729765896; c=relaxed/simple; bh=Gmz9Xqx0ZtU8zOpInCLRKD7Z2S5uEH9cxuDripCqFqg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=c17WJKLiLAYyMhlBfFJvQkPyd8iTZX3zuGdmJXztZIqO5Fz8XUF4R7u4Iap9MOFYFDbpubWJBWrZWMcVN0D2bQW/FmJm3vVqvcfUOrSwt9pO4Jnj9hzTuBt9cCKEgZOwpeAraOUAWccVb/8XqYKnObpyBXSVny+nHkNjaiMK7Ig= 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=I8u0GvhH; arc=none smtp.client-ip=198.47.19.142 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="I8u0GvhH" Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 49OAV4Rn053993; Thu, 24 Oct 2024 05:31:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1729765864; bh=n964dTNex7tpk0he9DOLYs/250I2jZHfL5mWxJ2ZSgM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=I8u0GvhH6hH46g0figOoGcDm9W0dv/yg0KhLFHzlmXVTlyP/gI07AE+mF8N7xe5+l KiU1yTUjwZ01XXY1l5Xe2sP3DrINvImcKeNVpg7EBhJ5ZRXFI2Qc+sfdi1di6T0Qw3 UxQiaK6A5tOYS/VLR6Evx2JottONV+lLZwatA3iU= Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 49OAV4Qc023029 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 24 Oct 2024 05:31:04 -0500 Received: from DFLE106.ent.ti.com (10.64.6.27) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Thu, 24 Oct 2024 05:31:03 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE106.ent.ti.com (10.64.6.27) 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; Thu, 24 Oct 2024 05:31:03 -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 49OAV3PM081880; Thu, 24 Oct 2024 05:31:03 -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 49OAV2lp024601; Thu, 24 Oct 2024 05:31:03 -0500 From: MD Danish Anwar To: , , , , , , , , , , , , , , , CC: , , , , , Vignesh Raghavendra , Roger Quadros , , Subject: [PATCH net-next v2 3/4] net: ti: icssg-prueth: Add VLAN support for HSR mode Date: Thu, 24 Oct 2024 16:00:55 +0530 Message-ID: <20241024103056.3201071-4-danishanwar@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241024103056.3201071-1-danishanwar@ti.com> References: <20241024103056.3201071-1-danishanwar@ti.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea From: Ravi Gunasekaran Add support for VLAN addition/deletion in HSR mode. In HSR mode, even if the host port is not a member of the VLAN domain, the slave ports should simply forward the frames. So allow forwarding of all VLAN frames in HSR mode. Signed-off-by: Ravi Gunasekaran Signed-off-by: MD Danish Anwar --- drivers/net/ethernet/ti/icssg/icssg_prueth.c | 45 +++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/ethernet/ti/icssg/icssg_prueth.c index 0556910938fa..b4d70c6e0cff 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c @@ -808,6 +808,47 @@ static netdev_features_t emac_ndo_fix_features(struct net_device *ndev, return features; } +static int emac_ndo_vlan_rx_add_vid(struct net_device *ndev, + __be16 proto, u16 vid) +{ + struct prueth_emac *emac = netdev_priv(ndev); + struct prueth *prueth = emac->prueth; + int untag_mask = 0; + int port_mask; + + if (prueth->is_hsr_offload_mode) { + port_mask = BIT(PRUETH_PORT_HOST) | BIT(emac->port_id); + untag_mask = 0; + + netdev_dbg(emac->ndev, "VID add vid:%u port_mask:%X untag_mask %X\n", + vid, port_mask, untag_mask); + + icssg_vtbl_modify(emac, vid, port_mask, untag_mask, true); + icssg_set_pvid(emac->prueth, vid, emac->port_id); + } + return 0; +} + +static int emac_ndo_vlan_rx_del_vid(struct net_device *ndev, + __be16 proto, u16 vid) +{ + struct prueth_emac *emac = netdev_priv(ndev); + struct prueth *prueth = emac->prueth; + int untag_mask = 0; + int port_mask; + + if (prueth->is_hsr_offload_mode) { + port_mask = BIT(PRUETH_PORT_HOST); + untag_mask = 0; + + netdev_dbg(emac->ndev, "VID del vid:%u port_mask:%X untag_mask %X\n", + vid, port_mask, untag_mask); + + icssg_vtbl_modify(emac, vid, port_mask, untag_mask, false); + } + return 0; +} + static const struct net_device_ops emac_netdev_ops = { .ndo_open = emac_ndo_open, .ndo_stop = emac_ndo_stop, @@ -820,6 +861,8 @@ static const struct net_device_ops emac_netdev_ops = { .ndo_get_stats64 = icssg_ndo_get_stats64, .ndo_get_phys_port_name = icssg_ndo_get_phys_port_name, .ndo_fix_features = emac_ndo_fix_features, + .ndo_vlan_rx_add_vid = emac_ndo_vlan_rx_add_vid, + .ndo_vlan_rx_kill_vid = emac_ndo_vlan_rx_del_vid, }; static int prueth_netdev_init(struct prueth *prueth, @@ -947,7 +990,7 @@ static int prueth_netdev_init(struct prueth *prueth, ndev->netdev_ops = &emac_netdev_ops; ndev->ethtool_ops = &icssg_ethtool_ops; ndev->hw_features = NETIF_F_SG; - ndev->features = ndev->hw_features; + ndev->features = ndev->hw_features | NETIF_F_HW_VLAN_CTAG_FILTER; ndev->hw_features |= NETIF_PRUETH_HSR_OFFLOAD_FEATURES; netif_napi_add(ndev, &emac->napi_rx, icssg_napi_rx_poll); From patchwork Thu Oct 24 10:30:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: MD Danish Anwar X-Patchwork-Id: 13848731 Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) (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 892971C8FC6; Thu, 24 Oct 2024 10:31:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.142 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729765897; cv=none; b=HKdDNsvtCJcBoBNbyXU3ZnunIGdX88vnTBACIxLMzMRylgnviz2I3BfUcRXw2Fjt+aqB2Yw+eVPgjrij6LgvUoLe/BUNCEHutYzNL/zHd3GfUOJnzr6DuGaRwTFKjH5o1xD+eK1QdAGQvvC/665cDNDmhgmwCX2hEfXHVL6NsBM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729765897; c=relaxed/simple; bh=gbDuprkSDRO1ZVxjUu34hDqDYjqd4wbx47kCz6jjL28=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=elIjZFNPZ7HoUVpW/mxELR8kO93CAdsdif+bxBvQjiMGosBt9gXobfsC3VbSw2pUrA3Op6ibFDkELmSrwb0l4Qd4J2w5SIQx4VfFZxOGD/7uR8AO27AsmNgoT9XD+3+Wmv0haQ58wxCLe1AjwuuGWWhY25Qf5xDtfHN7ifTPUkg= 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=y3fMsBd6; arc=none smtp.client-ip=198.47.19.142 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="y3fMsBd6" Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 49OAV6i9054005; Thu, 24 Oct 2024 05:31:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1729765866; bh=NR17OZSW7xbWDhOwoXB2afulJaLK/GIoceGzWejwggk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=y3fMsBd6DPWrecQ6AqVWprha/GtdeiWLSxY2tL9oOUwiUKgPo1YLc64iZznxpvBW/ rxo00XozE3k1yP7gtHRuyg3tRu9ec+d8eEQjM4PJJSr2Exdnjlbfy4w9HtsyAdfeVK 9SB0PTbd41hNUkmCYLOavOsNaHVRnuUUTfOfwWTo= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 49OAV6HQ023086 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 24 Oct 2024 05:31:06 -0500 Received: from DFLE113.ent.ti.com (10.64.6.34) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Thu, 24 Oct 2024 05:31:05 -0500 Received: from fllvsmtp7.itg.ti.com (10.64.40.31) by DFLE113.ent.ti.com (10.64.6.34) 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; Thu, 24 Oct 2024 05:31:05 -0500 Received: from lelv0854.itg.ti.com (lelv0854.itg.ti.com [10.181.64.140]) by fllvsmtp7.itg.ti.com (8.15.2/8.15.2) with ESMTP id 49OAV5BS000717; Thu, 24 Oct 2024 05:31:05 -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 49OAV4g6024608; Thu, 24 Oct 2024 05:31:05 -0500 From: MD Danish Anwar To: , , , , , , , , , , , , , , , CC: , , , , , Vignesh Raghavendra , Roger Quadros , , Subject: [PATCH net-next v2 4/4] selftests: hsr: Add test for VLAN Date: Thu, 24 Oct 2024 16:00:56 +0530 Message-ID: <20241024103056.3201071-5-danishanwar@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241024103056.3201071-1-danishanwar@ti.com> References: <20241024103056.3201071-1-danishanwar@ti.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea Add test for VLAN ping for HSR. The test adds vlan interfaces to the hsr interface and then verifies if ping to them works. Signed-off-by: MD Danish Anwar --- tools/testing/selftests/net/hsr/config | 1 + tools/testing/selftests/net/hsr/hsr_ping.sh | 63 ++++++++++++++++++++- 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/hsr/config b/tools/testing/selftests/net/hsr/config index 241542441c51..555a868743f0 100644 --- a/tools/testing/selftests/net/hsr/config +++ b/tools/testing/selftests/net/hsr/config @@ -3,3 +3,4 @@ CONFIG_NET_SCH_NETEM=m CONFIG_HSR=y CONFIG_VETH=y CONFIG_BRIDGE=y +CONFIG_VLAN_8021Q=m diff --git a/tools/testing/selftests/net/hsr/hsr_ping.sh b/tools/testing/selftests/net/hsr/hsr_ping.sh index f5d207fc770a..fb7c7d3fb6c7 100755 --- a/tools/testing/selftests/net/hsr/hsr_ping.sh +++ b/tools/testing/selftests/net/hsr/hsr_ping.sh @@ -2,13 +2,15 @@ # SPDX-License-Identifier: GPL-2.0 ipv6=true +vlan=false source ./hsr_common.sh -optstring="h4" +optstring="h4v" usage() { echo "Usage: $0 [OPTION]" echo -e "\t-4: IPv4 only: disable IPv6 tests (default: test both IPv4 and IPv6)" + echo -e "\t-v: Enable VLAN tests" } while getopts "$optstring" option;do @@ -20,6 +22,9 @@ while getopts "$optstring" option;do "4") ipv6=false ;; + "v") + vlan=true + ;; "?") usage $0 exit 1 @@ -175,6 +180,50 @@ setup_hsr_interfaces() ip -net "$ns3" link set hsr3 up } +setup_vlan_interfaces() { + ip link add link hsr1 name hsr1.2 type vlan id 2 + ip link add link hsr1 name hsr1.3 type vlan id 3 + ip link add link hsr1 name hsr1.4 type vlan id 4 + ip link add link hsr1 name hsr1.5 type vlan id 5 + + ip link add link hsr2 name hsr2.2 type vlan id 2 + ip link add link hsr2 name hsr2.3 type vlan id 3 + ip link add link hsr2 name hsr2.4 type vlan id 4 + ip link add link hsr2 name hsr2.5 type vlan id 5 + + ip link add link hsr3 name hsr3.2 type vlan id 2 + ip link add link hsr3 name hsr3.3 type vlan id 3 + ip link add link hsr3 name hsr3.4 type vlan id 4 + ip link add link hsr3 name hsr3.5 type vlan id 5 + + ip -net "$ns1" addr add 100.64.2.1/24 dev hsr1.2 + ip -net "$ns1" addr add 100.64.3.1/24 dev hsr1.3 + ip -net "$ns1" addr add 100.64.4.1/24 dev hsr1.4 + ip -net "$ns1" addr add 100.64.5.1/24 dev hsr1.5 + + ip -net "$ns2" addr add 100.64.2.2/24 dev hsr2.2 + ip -net "$ns2" addr add 100.64.3.2/24 dev hsr2.3 + ip -net "$ns2" addr add 100.64.4.2/24 dev hsr2.4 + ip -net "$ns2" addr add 100.64.5.2/24 dev hsr2.5 + + ip -net "$ns3" addr add 100.64.2.3/24 dev hsr3.2 + ip -net "$ns3" addr add 100.64.3.3/24 dev hsr3.3 + ip -net "$ns3" addr add 100.64.4.3/24 dev hsr3.4 + ip -net "$ns3" addr add 100.64.5.3/24 dev hsr3.5 +} + +hsr_vlan_ping() { + do_ping "$ns2" 100.64.2.1 + do_ping "$ns2" 100.64.3.1 + do_ping "$ns2" 100.64.4.1 + do_ping "$ns2" 100.64.5.1 + + do_ping "$ns2" 100.64.2.3 + do_ping "$ns2" 100.64.3.3 + do_ping "$ns2" 100.64.4.3 + do_ping "$ns2" 100.64.5.3 +} + check_prerequisites setup_ns ns1 ns2 ns3 @@ -183,9 +232,21 @@ trap cleanup_all_ns EXIT setup_hsr_interfaces 0 do_complete_ping_test +# Run VLAN Test +if $vlan; then + setup_vlan_interfaces + hsr_vlan_ping +fi + setup_ns ns1 ns2 ns3 setup_hsr_interfaces 1 do_complete_ping_test +# Run VLAN Test +if $vlan; then + setup_vlan_interfaces + hsr_vlan_ping +fi + exit $ret