From nobody Thu Apr 9 05:25:47 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EAF3DC05027 for ; Thu, 2 Feb 2023 12:58:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231994AbjBBM6t (ORCPT ); Thu, 2 Feb 2023 07:58:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230375AbjBBM6q (ORCPT ); Thu, 2 Feb 2023 07:58:46 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 391E9193; Thu, 2 Feb 2023 04:58:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1675342725; x=1706878725; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ogFJQVXNUNjBJFqygmk4PZfTb+58Qo0jzOmynUcXT5E=; b=b7sk/bTFs4uWkfgljUvjTTDCvgkijFrsOuWdvDuQc4vlLozMiq0sIqC4 5lODoQ9YD3JYaV2a4SdangD706lTYBID1m4fOP1dliB1e30UEgGDUrG8j jUiy4m/pfIdpl+lgRYTCInY3oHrs4vLcAO2a3KoKanO2ouQ6qE2NcVc2l nmCCDCwRutYQyTMj/XnQF0fd61PpiBwkCuTYT1n96Hmvr29lifz0bj0PU V/8krhKX8nMRNN2uoiiTWzlq8l919S3rdLds8DNgTA2WCZ8LMbNF2mybL gbF/yN2r0c6DlpDqMu6+ESK5RXlgBZ6zQfVcRnCheZTARQWtBkweIl6hN g==; X-IronPort-AV: E=Sophos;i="5.97,267,1669100400"; d="scan'208";a="198620504" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 02 Feb 2023 05:58:44 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Thu, 2 Feb 2023 05:58:32 -0700 Received: from che-lt-i67786lx.microchip.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Thu, 2 Feb 2023 05:58:28 -0700 From: Rakesh Sankaranarayanan To: , CC: , , , , , , , , , Subject: [RFC PATCH net-next 01/11] net: dsa: microchip: lan937x: add cascade tailtag Date: Thu, 2 Feb 2023 18:29:20 +0530 Message-ID: <20230202125930.271740-2-rakesh.sankaranarayanan@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202125930.271740-1-rakesh.sankaranarayanan@microchip.com> References: <20230202125930.271740-1-rakesh.sankaranarayanan@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" cascade tailtag contains 3 bytes of information, it includes additional bytes for accomodating port number in second switch. Destination port bitmap on first switch is at bit position 7:0 and of second switch is at bit position 15:8, add new tailtag xmit and rcv functions for cascade with proper formatting. Add new tag protocol for cascading and link with new xmit and rcv functions. Signed-off-by: Rakesh Sankaranarayanan --- include/net/dsa.h | 2 ++ net/dsa/tag_ksz.c | 80 ++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 77 insertions(+), 5 deletions(-) diff --git a/include/net/dsa.h b/include/net/dsa.h index a15f17a38eca..55651ad29193 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -56,6 +56,7 @@ struct phylink_link_state; #define DSA_TAG_PROTO_RTL8_4T_VALUE 25 #define DSA_TAG_PROTO_RZN1_A5PSW_VALUE 26 #define DSA_TAG_PROTO_LAN937X_VALUE 27 +#define DSA_TAG_PROTO_LAN937X_CASCADE_VALUE 28 =20 enum dsa_tag_protocol { DSA_TAG_PROTO_NONE =3D DSA_TAG_PROTO_NONE_VALUE, @@ -86,6 +87,7 @@ enum dsa_tag_protocol { DSA_TAG_PROTO_RTL8_4T =3D DSA_TAG_PROTO_RTL8_4T_VALUE, DSA_TAG_PROTO_RZN1_A5PSW =3D DSA_TAG_PROTO_RZN1_A5PSW_VALUE, DSA_TAG_PROTO_LAN937X =3D DSA_TAG_PROTO_LAN937X_VALUE, + DSA_TAG_PROTO_LAN937X_CASCADE =3D DSA_TAG_PROTO_LAN937X_CASCADE_VALUE, }; =20 struct dsa_switch; diff --git a/net/dsa/tag_ksz.c b/net/dsa/tag_ksz.c index 0eb1c7784c3d..7ab2c7eaa4ca 100644 --- a/net/dsa/tag_ksz.c +++ b/net/dsa/tag_ksz.c @@ -16,6 +16,7 @@ #define KSZ9477_NAME "ksz9477" #define KSZ9893_NAME "ksz9893" #define LAN937X_NAME "lan937x" +#define LAN937X_CASCADE_NAME "lan937x_cascade" =20 /* Typically only one byte is used for tail tag. */ #define KSZ_PTP_TAG_LEN 4 @@ -24,6 +25,9 @@ =20 #define KSZ_HWTS_EN 0 =20 +#define SWITCH_0 0 +#define SWITCH_1 1 + struct ksz_tagger_private { struct ksz_tagger_data data; /* Must be first */ unsigned long state; @@ -84,10 +88,10 @@ static int ksz_connect(struct dsa_switch *ds) } =20 static struct sk_buff *ksz_common_rcv(struct sk_buff *skb, - struct net_device *dev, - unsigned int port, unsigned int len) + struct net_device *dev, unsigned int port, + unsigned int len, u8 device) { - skb->dev =3D dsa_master_find_slave(dev, 0, port); + skb->dev =3D dsa_master_find_slave(dev, device, port); if (!skb->dev) return NULL; =20 @@ -141,7 +145,7 @@ static struct sk_buff *ksz8795_rcv(struct sk_buff *skb,= struct net_device *dev) { u8 *tag =3D skb_tail_pointer(skb) - KSZ_EGRESS_TAG_LEN; =20 - return ksz_common_rcv(skb, dev, tag[0] & 7, KSZ_EGRESS_TAG_LEN); + return ksz_common_rcv(skb, dev, tag[0] & 7, KSZ_EGRESS_TAG_LEN, SWITCH_0); } =20 static const struct dsa_device_ops ksz8795_netdev_ops =3D { @@ -177,6 +181,7 @@ MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_KSZ8795, KSZ8= 795_NAME); #define KSZ9477_INGRESS_TAG_LEN 2 #define KSZ9477_PTP_TAG_LEN 4 #define KSZ9477_PTP_TAG_INDICATION 0x80 +#define LAN937X_CASCADE_CHIP 0x40 =20 #define KSZ9477_TAIL_TAG_PRIO GENMASK(8, 7) #define KSZ9477_TAIL_TAG_OVERRIDE BIT(9) @@ -304,6 +309,7 @@ static struct sk_buff *ksz9477_rcv(struct sk_buff *skb,= struct net_device *dev) u8 *tag =3D skb_tail_pointer(skb) - KSZ_EGRESS_TAG_LEN; unsigned int port =3D tag[0] & 7; unsigned int len =3D KSZ_EGRESS_TAG_LEN; + u8 device =3D SWITCH_0; =20 /* Extra 4-bytes PTP timestamp */ if (tag[0] & KSZ9477_PTP_TAG_INDICATION) { @@ -311,7 +317,10 @@ static struct sk_buff *ksz9477_rcv(struct sk_buff *skb= , struct net_device *dev) len +=3D KSZ_PTP_TAG_LEN; } =20 - return ksz_common_rcv(skb, dev, port, len); + if (tag[0] & LAN937X_CASCADE_CHIP) + device =3D SWITCH_1; + + return ksz_common_rcv(skb, dev, port, len, device); } =20 static const struct dsa_device_ops ksz9477_netdev_ops =3D { @@ -390,6 +399,7 @@ MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_KSZ9893, KSZ9= 893_NAME); * (eg, 0x00=3Dport1, 0x02=3Dport3, 0x07=3Dport8) */ #define LAN937X_EGRESS_TAG_LEN 2 +#define LAN937X_CASCADE_TAG_LEN 3 =20 #define LAN937X_TAIL_TAG_BLOCKING_OVERRIDE BIT(11) #define LAN937X_TAIL_TAG_LOOKUP BIT(12) @@ -442,11 +452,71 @@ static const struct dsa_device_ops lan937x_netdev_ops= =3D { DSA_TAG_DRIVER(lan937x_netdev_ops); MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_LAN937X, LAN937X_NAME); =20 +/* For xmit, 3/7 bytes are added before FCS. + * -----------------------------------------------------------------------= ---- + * DA(6bytes)|SA(6bytes)|....|Data(nbytes)|ts(4bytes)|tag0(1byte)|tag1(1by= te)| + * tag2(1byte)|FCS(4bytes) + * -----------------------------------------------------------------------= ---- + * ts : time stamp (Present only if PTP is enabled in the Hardware) + * tag0 : represents tag override, lookup and valid + * tag1 : each bit represents destination port map through switch 2 + * (eg, 0x01=3Dport1, 0x02=3Dport2, 0x80=3Dport8) + * tag2 : each bit represents destination port map through switch 1 + * (eg, 0x01=3Dport1, 0x02=3Dport2, 0x80=3Dport8) + * + * For rcv, 1/5 bytes is added before FCS. + * -----------------------------------------------------------------------= ---- + * DA(6bytes)|SA(6bytes)|....|Data(nbytes)|ts(4bytes)|tag0(1byte)|FCS(4byt= es) + * -----------------------------------------------------------------------= ---- + * ts : time stamp (Present only if bit 7 of tag0 is set) + * tag0 : zero-based value represents port + * (eg, 0x00=3Dport1, 0x02=3Dport3, 0x07=3Dport8) + */ +static struct sk_buff *lan937x_cascade_xmit(struct sk_buff *skb, + struct net_device *dev) +{ + struct dsa_port *dp =3D dsa_slave_to_port(dev); + const struct ethhdr *hdr =3D eth_hdr(skb); + __be32 *tag; + u32 val; + + if (skb->ip_summed =3D=3D CHECKSUM_PARTIAL && skb_checksum_help(skb)) + return NULL; + + tag =3D skb_put(skb, LAN937X_CASCADE_TAG_LEN); + + val |=3D BIT((dp->index + (8 * dp->ds->index))); + + if (is_link_local_ether_addr(hdr->h_dest)) + val |=3D (LAN937X_TAIL_TAG_BLOCKING_OVERRIDE << 8); + + val |=3D (LAN937X_TAIL_TAG_VALID << 8); + + put_unaligned_be24(val, tag); + + return skb; +} + +static const struct dsa_device_ops lan937x_cascade_netdev_ops =3D { + .name =3D LAN937X_CASCADE_NAME, + .proto =3D DSA_TAG_PROTO_LAN937X_CASCADE, + .xmit =3D lan937x_cascade_xmit, + .rcv =3D ksz9477_rcv, + .connect =3D ksz_connect, + .disconnect =3D ksz_disconnect, + .needed_tailroom =3D LAN937X_CASCADE_TAG_LEN, +}; + +DSA_TAG_DRIVER(lan937x_cascade_netdev_ops); +MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_LAN937x_CASCADE, + LAN937X_CASCADE_NAME); + static struct dsa_tag_driver *dsa_tag_driver_array[] =3D { &DSA_TAG_DRIVER_NAME(ksz8795_netdev_ops), &DSA_TAG_DRIVER_NAME(ksz9477_netdev_ops), &DSA_TAG_DRIVER_NAME(ksz9893_netdev_ops), &DSA_TAG_DRIVER_NAME(lan937x_netdev_ops), + &DSA_TAG_DRIVER_NAME(lan937x_cascade_netdev_ops), }; =20 module_dsa_tag_drivers(dsa_tag_driver_array); --=20 2.34.1 From nobody Thu Apr 9 05:25:47 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45C5AC636D4 for ; Thu, 2 Feb 2023 12:58:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232234AbjBBM66 (ORCPT ); Thu, 2 Feb 2023 07:58:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232119AbjBBM6u (ORCPT ); Thu, 2 Feb 2023 07:58:50 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FD8F59249; Thu, 2 Feb 2023 04:58:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1675342729; x=1706878729; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1djmTQ6/cbT1raftQ9vms3W0+SE59JVgpFBKfe2ifxw=; b=pJbzyPe0Ya98QA+mWbkyrswAoFl2lWZIABcC44XkfYVzEh0Hyd/edAka MAGkBh37c2Naw7VLaPpxrvpWvde1PTndjSgWCuISH29LltqSKlo3KIbBx HgYiXnXxJkT1nzETBA9QoQHVMvnz/nNLnG+zsKGvGN9nSrEJJT/U22SBe LEYda//vmFBU1mTm4i8hUa9/56A4MXyM5nDAeTxUJctod0Rb5Sw/tQOBa laP1GKEAePY1cl9xr8C+dBT/RvClNoa4NO7eEWe0HH4mHJ7iTVUs8e38f EeYoP22tEMWcx9ceOMQn23RMZOCOwPoGZHN/nmqprrvR0hHvgdn4PX2cg w==; X-IronPort-AV: E=Sophos;i="5.97,267,1669100400"; d="scan'208";a="135251584" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 02 Feb 2023 05:58:39 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Thu, 2 Feb 2023 05:58:38 -0700 Received: from che-lt-i67786lx.microchip.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Thu, 2 Feb 2023 05:58:34 -0700 From: Rakesh Sankaranarayanan To: , CC: , , , , , , , , , Subject: [RFC PATCH net-next 02/11] net: dsa: microchip: lan937x: update SMI index Date: Thu, 2 Feb 2023 18:29:21 +0530 Message-ID: <20230202125930.271740-3-rakesh.sankaranarayanan@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202125930.271740-1-rakesh.sankaranarayanan@microchip.com> References: <20230202125930.271740-1-rakesh.sankaranarayanan@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Current DSA driver register mdio interface for a port in the format of SMI-switch_index:port_number, switch_index is derived using variable ds->index. For a single switch ds->index will be always zero, and for cascaded switch, ds->index should be one. But it is found that ds->index is getting updated only after mdio_register stage. Update mdio_register to use variable directly from device tree using "dsa,member" identifier. Signed-off-by: Rakesh Sankaranarayanan --- drivers/net/dsa/microchip/ksz_common.c | 6 +++++- drivers/net/dsa/microchip/ksz_common.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/micro= chip/ksz_common.c index 46becc0382d6..d2ec5acd7b17 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -1882,7 +1882,7 @@ static int ksz_mdio_register(struct ksz_device *dev) bus->read =3D ksz_sw_mdio_read; bus->write =3D ksz_sw_mdio_write; bus->name =3D "ksz slave smi"; - snprintf(bus->id, MII_BUS_ID_SIZE, "SMI-%d", ds->index); + snprintf(bus->id, MII_BUS_ID_SIZE, "SMI-%d", dev->smi_index); bus->parent =3D ds->dev; bus->phy_mask =3D ~ds->phys_mii_mask; =20 @@ -3136,6 +3136,7 @@ struct ksz_device *ksz_switch_alloc(struct device *ba= se, void *priv) { struct dsa_switch *ds; struct ksz_device *swdev; + u32 sw_idx[2]; =20 ds =3D devm_kzalloc(base, sizeof(*ds), GFP_KERNEL); if (!ds) @@ -3155,6 +3156,9 @@ struct ksz_device *ksz_switch_alloc(struct device *ba= se, void *priv) swdev->ds =3D ds; swdev->priv =3D priv; =20 + of_property_read_variable_u32_array(base->of_node, "dsa,member", sw_idx, = 2, 2); + swdev->smi_index =3D sw_idx[1]; + return swdev; } EXPORT_SYMBOL(ksz_switch_alloc); diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/micro= chip/ksz_common.h index d2d5761d58e9..aab60f2587bf 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -147,6 +147,7 @@ struct ksz_device { u32 chip_id; u8 chip_rev; int cpu_port; /* port connected to CPU */ + u32 smi_index; int phy_port_cnt; phy_interface_t compat_interface; bool synclko_125; --=20 2.34.1 From nobody Thu Apr 9 05:25:47 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 425F5C05027 for ; Thu, 2 Feb 2023 12:58:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229935AbjBBM6w (ORCPT ); Thu, 2 Feb 2023 07:58:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229666AbjBBM6s (ORCPT ); Thu, 2 Feb 2023 07:58:48 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB254EF82; Thu, 2 Feb 2023 04:58:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1675342726; x=1706878726; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bxVhL1m9KqOfZ9Y/N1jqZpYPk1To2xrlI3Xdh5PfAks=; b=EiVff7QfUvQrneIJCVgjDlXUuhtQ4/cOcZXp9T5WL/QQIJuTZKWTfG5g MroN2ACLf9AAfo/nN/u7nNDNhaY25W2pZ8gn9Ofnm5j0oJLkTkpWfAzUl ApsH+60Qu0ulWZTBeZcpb6QE9kFlGuIZgXmF0FYg7h4Ey5PtWZ+aVfpqz jak+nhkj8MVKmSVKk+YE4Vvh9pn5//OHXmfpsAkP0zeI8zvPDCrYl4CLY faR+UH3CTpExA5IChn0Wrjn6e/XKHgw5XbA2bo/D89nPGwJ6SAvJFnbIE 7DwjxKlPge88oSpUU2mqWFaWi2lrBdqQiBRBsKDO2rVGJhvj58WuyeVNh Q==; X-IronPort-AV: E=Sophos;i="5.97,267,1669100400"; d="scan'208";a="198620506" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 02 Feb 2023 05:58:44 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Thu, 2 Feb 2023 05:58:44 -0700 Received: from che-lt-i67786lx.microchip.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Thu, 2 Feb 2023 05:58:39 -0700 From: Rakesh Sankaranarayanan To: , CC: , , , , , , , , , Subject: [RFC PATCH net-next 03/11] net: dsa: microchip: lan937x: enable cascade port Date: Thu, 2 Feb 2023 18:29:22 +0530 Message-ID: <20230202125930.271740-4-rakesh.sankaranarayanan@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202125930.271740-1-rakesh.sankaranarayanan@microchip.com> References: <20230202125930.271740-1-rakesh.sankaranarayanan@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Get index of cascaded port (if any) from device tree and enable the feature. These ports referenced as dev->dsa_port and will be used for processing further based on cascaded connection. For the second switch in cascaded connection, no dev->cpu_port will be assigned, and same happens for dev->dsa_port variable for switches without cascading. For the single switch design, there is no way dev->cpu_port will be unassigned. But coming to cascaded connection, it can be unassigned, and they will be having value zero. Keeping the initial value as zero will create error in other features like port forwarding since DSA will misunderstood these as port index zero. So keep the default values as 0xFF which is of invalid value so that if nothing assigned, taking bitmap of the cpu_port or dsa_port will not cause any harm. Signed-off-by: Rakesh Sankaranarayanan --- drivers/net/dsa/microchip/ksz_common.c | 4 +++ drivers/net/dsa/microchip/ksz_common.h | 2 ++ drivers/net/dsa/microchip/lan937x.h | 1 + drivers/net/dsa/microchip/lan937x_main.c | 31 ++++++++++++++++++++++++ drivers/net/dsa/microchip/lan937x_reg.h | 3 +++ 5 files changed, 41 insertions(+) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/micro= chip/ksz_common.c index d2ec5acd7b17..ada673b6efc6 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -292,6 +292,7 @@ static const struct ksz_dev_ops lan937x_dev_ops =3D { .change_mtu =3D lan937x_change_mtu, .phylink_mac_link_up =3D ksz9477_phylink_mac_link_up, .config_cpu_port =3D lan937x_config_cpu_port, + .config_dsa_port =3D lan937x_config_dsa_port, .tc_cbs_set_cinc =3D lan937x_tc_cbs_set_cinc, .enable_stp_addr =3D ksz9477_enable_stp_addr, .reset =3D lan937x_reset_switch, @@ -2095,6 +2096,9 @@ static int ksz_setup(struct dsa_switch *ds) =20 dev->dev_ops->config_cpu_port(ds); =20 + if (dev->dev_ops->config_dsa_port) + dev->dev_ops->config_dsa_port(ds); + dev->dev_ops->enable_stp_addr(dev); =20 ds->num_tx_queues =3D dev->info->num_tx_queues; diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/micro= chip/ksz_common.h index aab60f2587bf..c3c3eee178f4 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -147,6 +147,7 @@ struct ksz_device { u32 chip_id; u8 chip_rev; int cpu_port; /* port connected to CPU */ + int dsa_port; /* Port used as cascaded port */ u32 smi_index; int phy_port_cnt; phy_interface_t compat_interface; @@ -358,6 +359,7 @@ struct ksz_dev_ops { void (*setup_rgmii_delay)(struct ksz_device *dev, int port); int (*tc_cbs_set_cinc)(struct ksz_device *dev, int port, u32 val); void (*config_cpu_port)(struct dsa_switch *ds); + void (*config_dsa_port)(struct dsa_switch *ds); int (*enable_stp_addr)(struct ksz_device *dev); int (*reset)(struct ksz_device *dev); int (*init)(struct ksz_device *dev); diff --git a/drivers/net/dsa/microchip/lan937x.h b/drivers/net/dsa/microchi= p/lan937x.h index 3388d91dbc44..ef84abc31556 100644 --- a/drivers/net/dsa/microchip/lan937x.h +++ b/drivers/net/dsa/microchip/lan937x.h @@ -11,6 +11,7 @@ int lan937x_setup(struct dsa_switch *ds); void lan937x_teardown(struct dsa_switch *ds); void lan937x_port_setup(struct ksz_device *dev, int port, bool cpu_port); void lan937x_config_cpu_port(struct dsa_switch *ds); +void lan937x_config_dsa_port(struct dsa_switch *ds); int lan937x_switch_init(struct ksz_device *dev); void lan937x_switch_exit(struct ksz_device *dev); int lan937x_r_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 *data); diff --git a/drivers/net/dsa/microchip/lan937x_main.c b/drivers/net/dsa/mic= rochip/lan937x_main.c index 399a3905e6ca..5108a3f4bf76 100644 --- a/drivers/net/dsa/microchip/lan937x_main.c +++ b/drivers/net/dsa/microchip/lan937x_main.c @@ -205,11 +205,42 @@ void lan937x_port_setup(struct ksz_device *dev, int p= ort, bool cpu_port) dev->dev_ops->cfg_port_member(dev, port, member); } =20 +void lan937x_config_dsa_port(struct dsa_switch *ds) +{ + struct ksz_device *dev =3D ds->priv; + struct dsa_port *dp; + + dev->dsa_port =3D 0xFF; + + dsa_switch_for_each_port(dp, ds) { + if (dsa_is_dsa_port(ds, dp->index)) { + ksz_rmw32(dev, REG_SW_CASCADE_MODE_CTL, + CASCADE_PORT_SEL, dp->index); + dev->dsa_port =3D dp->index; + + /* Tail tag should be enabled for switch 0 + * in cascaded connection. + */ + if (dev->smi_index =3D=3D 0) { + lan937x_port_cfg(dev, dp->index, REG_PORT_CTRL_0, + PORT_TAIL_TAG_ENABLE, true); + } + + /* Frame check length should be disabled for cascaded ports */ + lan937x_port_cfg(dev, dp->index, REG_PORT_MAC_CTRL_0, + PORT_CHECK_LENGTH, false); + } + } +} + void lan937x_config_cpu_port(struct dsa_switch *ds) { struct ksz_device *dev =3D ds->priv; struct dsa_port *dp; =20 + /* Initializing cpu_port parameter into invalid value */ + dev->cpu_port =3D 0xFF; + dsa_switch_for_each_cpu_port(dp, ds) { if (dev->info->cpu_ports & (1 << dp->index)) { dev->cpu_port =3D dp->index; diff --git a/drivers/net/dsa/microchip/lan937x_reg.h b/drivers/net/dsa/micr= ochip/lan937x_reg.h index 45b606b6429f..4f30bc12f7a9 100644 --- a/drivers/net/dsa/microchip/lan937x_reg.h +++ b/drivers/net/dsa/microchip/lan937x_reg.h @@ -32,6 +32,9 @@ #define REG_SW_PORT_INT_STATUS__4 0x0018 #define REG_SW_PORT_INT_MASK__4 0x001C =20 +#define REG_SW_CASCADE_MODE_CTL 0x0030 +#define CASCADE_PORT_SEL 7 + /* 1 - Global */ #define REG_SW_GLOBAL_OUTPUT_CTRL__1 0x0103 #define SW_CLK125_ENB BIT(1) --=20 2.34.1 From nobody Thu Apr 9 05:25:47 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7894AC61DA4 for ; Thu, 2 Feb 2023 12:59:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232358AbjBBM7A (ORCPT ); Thu, 2 Feb 2023 07:59:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232145AbjBBM6v (ORCPT ); Thu, 2 Feb 2023 07:58:51 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C55C6EAFB; Thu, 2 Feb 2023 04:58:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1675342730; x=1706878730; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=a227EjQrvydGYIKcbwgGhKJ7ZtgW5ewg9wl5/GCvx7U=; b=NbX8cCPd1fLE7N2TwNJ5L7aHc3Cl1NxvtJI2JcyIhH3iItretLIpfvFe 1qYqTbFf+JvhcLNWX1lBexVnD+xK2aRK9q5IqdOkOC+EKj57kY9qY29DK vjQke1fK+ndYIF9/6qK1cr3h7sLNvohaC+hfJf7cf5Yoxh/gbj+aV8sIf JZffQhuX6lUkMtr1VsgYkaP7r2iGmURS4vRZ/yfFNWkV9vUfSBIoePkPG 9xbTymhzik/txlnPW5oUroCYNxDGmoP/FTkAr2xHUPiFIph5zJRH+BJlP a5eoTMpyhSnLTnNABcH3xYL07JuIwV3xEqWAqxSqg/tj7wM18mua2TlOV Q==; X-IronPort-AV: E=Sophos;i="5.97,267,1669100400"; d="scan'208";a="210318418" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 02 Feb 2023 05:58:49 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Thu, 2 Feb 2023 05:58:49 -0700 Received: from che-lt-i67786lx.microchip.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Thu, 2 Feb 2023 05:58:45 -0700 From: Rakesh Sankaranarayanan To: , CC: , , , , , , , , , Subject: [RFC PATCH net-next 04/11] net: dsa: microchip: lan937x: update port number for LAN9373 Date: Thu, 2 Feb 2023 18:29:23 +0530 Message-ID: <20230202125930.271740-5-rakesh.sankaranarayanan@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202125930.271740-1-rakesh.sankaranarayanan@microchip.com> References: <20230202125930.271740-1-rakesh.sankaranarayanan@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" LAN9373 have total 8 physical ports. Update port_cnt member in ksz_chip_data structure. Signed-off-by: Rakesh Sankaranarayanan --- drivers/net/dsa/microchip/ksz_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/micro= chip/ksz_common.c index ada673b6efc6..7062ce1749fb 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -1490,7 +1490,7 @@ const struct ksz_chip_data ksz_switch_chips[] =3D { .num_alus =3D 1024, .num_statics =3D 256, .cpu_ports =3D 0x38, /* can be configured as cpu port */ - .port_cnt =3D 5, /* total physical port count */ + .port_cnt =3D 8, /* total physical port count */ .port_nirqs =3D 6, .num_tx_queues =3D 8, .tc_cbs_supported =3D true, --=20 2.34.1 From nobody Thu Apr 9 05:25:47 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66330C05027 for ; Thu, 2 Feb 2023 12:59:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232401AbjBBM7T (ORCPT ); Thu, 2 Feb 2023 07:59:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232371AbjBBM7D (ORCPT ); Thu, 2 Feb 2023 07:59:03 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F67B8E484; Thu, 2 Feb 2023 04:59:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1675342740; x=1706878740; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=09IBqS4LmrOKoAcjHwQjILLjOKkVRx2085Me/Fn628s=; b=xh/ILQrOOKZfZ737sSsXrL3SRW5et8xnY4qKGt1D3mVWqBeId3Hj8o2J RuukaqzZZWW9Nm3izAuI4DpUtgmfQdkmKEpKk0QWgZNBln1z5mMEfvFlh kvg5/x8j/djBZs1H0QrkWZeUnLUDXHvScHAY81Y4a35uv+90PFCsKN3pZ vJr/3bl6zsKdH4QdFD54GsVBesoK8lbtA0B3KTJsuC2FFMkvP7WgwKquB RRi5zLGyP2wpNGgrOe/DFWj6tanIB2gcmVJsbhUAeONpZW0eq7TmvfGEM tH6GIv1hU0yvn1+qcjtIG/KZNGnzONNUhvWGD7uRzaAFAX9y5mhqjloV7 Q==; X-IronPort-AV: E=Sophos;i="5.97,267,1669100400"; d="scan'208";a="198620642" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 02 Feb 2023 05:58:59 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Thu, 2 Feb 2023 05:58:54 -0700 Received: from che-lt-i67786lx.microchip.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Thu, 2 Feb 2023 05:58:50 -0700 From: Rakesh Sankaranarayanan To: , CC: , , , , , , , , , Subject: [RFC PATCH net-next 05/11] net: dsa: microchip: lan937x: add shared global interrupt Date: Thu, 2 Feb 2023 18:29:24 +0530 Message-ID: <20230202125930.271740-6-rakesh.sankaranarayanan@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202125930.271740-1-rakesh.sankaranarayanan@microchip.com> References: <20230202125930.271740-1-rakesh.sankaranarayanan@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In cascade mode interrupt line is shared among both switches. Update global interrupt flag for shared interrupt, otherwise second switch probe will fail with busy status. Signed-off-by: Rakesh Sankaranarayanan --- drivers/net/dsa/microchip/ksz_common.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/micro= chip/ksz_common.c index 7062ce1749fb..adf8391dd29f 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -2009,7 +2009,8 @@ static irqreturn_t ksz_irq_thread_fn(int irq, void *d= ev_id) return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE); } =20 -static int ksz_irq_common_setup(struct ksz_device *dev, struct ksz_irq *ki= rq) +static int ksz_irq_common_setup(struct ksz_device *dev, struct ksz_irq *ki= rq, + unsigned long flag) { int ret, n; =20 @@ -2025,7 +2026,7 @@ static int ksz_irq_common_setup(struct ksz_device *de= v, struct ksz_irq *kirq) irq_create_mapping(kirq->domain, n); =20 ret =3D request_threaded_irq(kirq->irq_num, NULL, ksz_irq_thread_fn, - IRQF_ONESHOT, kirq->name, kirq); + flag, kirq->name, kirq); if (ret) goto out; =20 @@ -2048,7 +2049,7 @@ static int ksz_girq_setup(struct ksz_device *dev) =20 girq->irq_num =3D dev->irq; =20 - return ksz_irq_common_setup(dev, girq); + return ksz_irq_common_setup(dev, girq, (IRQF_ONESHOT | IRQF_SHARED)); } =20 static int ksz_pirq_setup(struct ksz_device *dev, u8 p) @@ -2064,7 +2065,7 @@ static int ksz_pirq_setup(struct ksz_device *dev, u8 = p) if (pirq->irq_num < 0) return pirq->irq_num; =20 - return ksz_irq_common_setup(dev, pirq); + return ksz_irq_common_setup(dev, pirq, IRQF_ONESHOT); } =20 static int ksz_setup(struct dsa_switch *ds) --=20 2.34.1 From nobody Thu Apr 9 05:25:47 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6926DC05027 for ; Thu, 2 Feb 2023 12:59:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232512AbjBBM7V (ORCPT ); Thu, 2 Feb 2023 07:59:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232372AbjBBM7D (ORCPT ); Thu, 2 Feb 2023 07:59:03 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FCD689FAC; Thu, 2 Feb 2023 04:59:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1675342741; x=1706878741; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=32H2oJWTk/bY+4r4IuXy3k5EXeQhNmioppl2l7N7A2E=; b=St3z3Em+sFB1Naes9cIk9mdM0mhZF1hfBRVP3q/xy+VbJ+VddBeYDacW PQibYf/GYKF2iAeXDuPaFac3Vs495+kyLmh2wy3U+wX4yxoqxHd6bDkU1 ujWQuIMZoGoMStOiNhAlllhz/IcQbRd5KzHCK39TR7z0Z7W9tu9X4MG2L mBlVN51k5TfT/ctOGKCv4V8rjUdI4Cq7IWFkbWhh1myzMN6OH6+qgnUts a4fXeJXdOeIRWNKH2V2ptQokPEfhcDoh6XZgM5opXGFU3zZOPhw086a3n sA5QO8aO0hGmOwIVbTQEvZcUbJx5Pm0qMmp1x++/Y7UCJWcfoJd3FpVIO g==; X-IronPort-AV: E=Sophos;i="5.97,267,1669100400"; d="scan'208";a="135251838" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 02 Feb 2023 05:59:00 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Thu, 2 Feb 2023 05:59:00 -0700 Received: from che-lt-i67786lx.microchip.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Thu, 2 Feb 2023 05:58:55 -0700 From: Rakesh Sankaranarayanan To: , CC: , , , , , , , , , Subject: [RFC PATCH net-next 06/11] net: dsa: microchip: lan937x: get cascade tag protocol Date: Thu, 2 Feb 2023 18:29:25 +0530 Message-ID: <20230202125930.271740-7-rakesh.sankaranarayanan@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202125930.271740-1-rakesh.sankaranarayanan@microchip.com> References: <20230202125930.271740-1-rakesh.sankaranarayanan@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Update ksz_get_tag_protocol to return separate tag protocol if switch is connected in cascade mode. Variable ds->dst->last_switch will contain total number of switches registered. For cascaded connection alone, this will be more than zero. Signed-off-by: Rakesh Sankaranarayanan --- drivers/net/dsa/microchip/ksz_common.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/micro= chip/ksz_common.c index adf8391dd29f..2160a3e61a5a 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -2567,9 +2567,13 @@ static enum dsa_tag_protocol ksz_get_tag_protocol(st= ruct dsa_switch *ds, dev->chip_id =3D=3D KSZ9567_CHIP_ID) proto =3D DSA_TAG_PROTO_KSZ9477; =20 - if (is_lan937x(dev)) + if (is_lan937x(dev)) { proto =3D DSA_TAG_PROTO_LAN937X_VALUE; =20 + if (ds->dst->last_switch) + proto =3D DSA_TAG_PROTO_LAN937X_CASCADE_VALUE; + } + return proto; } =20 --=20 2.34.1 From nobody Thu Apr 9 05:25:47 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05BEBC61DA4 for ; Thu, 2 Feb 2023 12:59:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232490AbjBBM7k (ORCPT ); Thu, 2 Feb 2023 07:59:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232375AbjBBM7R (ORCPT ); Thu, 2 Feb 2023 07:59:17 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 477418F241; Thu, 2 Feb 2023 04:59:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1675342749; x=1706878749; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gOPgGw0RohtMRFMCFrPybEvNkhUd8DRkAKdQTixdWLk=; b=wN/tie7PXKsvgyYPNfmOkfUVkYMGFhEVyLZK00FvOasaK7psHFcP1jOG 54bL5xl+kyEU/2UXRqycUh9pn00FcsjuzZ+aq07tzXPLBp1BxS1p/Y+J0 3UY5zfA0gERa6Iz005fxWOIGgb03JHt5EP2tPVFh6e/nGUCLUBxH3SKyU 9OECkTzbXzLpsB1BFr0ToLg981AJGmxlEA0l6NVQ1zrv7Xsoh2Y8rFXFm bBlp+ugzlhI8kRv1lvJ711piq+7XdOXOOA0GJsYD0whSWK8gecg+B8EPi f+02oK+rD3Ek7vot+EfFeWmGQSY+B9wMJn94Wd6FvnEbaLIOUBhx9GYV9 g==; X-IronPort-AV: E=Sophos;i="5.97,267,1669100400"; d="scan'208";a="135251855" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 02 Feb 2023 05:59:08 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Thu, 2 Feb 2023 05:59:05 -0700 Received: from che-lt-i67786lx.microchip.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Thu, 2 Feb 2023 05:59:01 -0700 From: Rakesh Sankaranarayanan To: , CC: , , , , , , , , , Subject: [RFC PATCH net-next 07/11] net: dsa: microchip: lan937x: update switch register Date: Thu, 2 Feb 2023 18:29:26 +0530 Message-ID: <20230202125930.271740-8-rakesh.sankaranarayanan@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202125930.271740-1-rakesh.sankaranarayanan@microchip.com> References: <20230202125930.271740-1-rakesh.sankaranarayanan@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Second switch in cascaded connection doesn't have port with macb interface. dsa_switch_register returns error if macb interface is not up. Due to this reason, second switch in cascaded connection will not report error during dsa_switch_register and mib thread work will be invoked even if actual switch register is not done. This will lead to kernel warning and it can be avoided by checking device tree setup status. This will return true only after actual switch register is done. Signed-off-by: Rakesh Sankaranarayanan --- drivers/net/dsa/microchip/ksz_common.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/micro= chip/ksz_common.c index 2160a3e61a5a..0df71156a540 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -3213,6 +3213,7 @@ int ksz_switch_register(struct ksz_device *dev) { const struct ksz_chip_data *info; struct device_node *port, *ports; + struct dsa_switch_tree *dst; phy_interface_t interface; unsigned int port_num; int ret; @@ -3330,6 +3331,15 @@ int ksz_switch_register(struct ksz_device *dev) return ret; } =20 + /* Do not proceed further if device tree setup is not done. + * dsa_register_switch() will not report error in case of + * cascaded switch. This will lead to scheduling mib read + * work and kernel warning. + */ + dst =3D dev->ds->dst; + if (!dst->setup) + return 0; + /* Read MIB counters every 30 seconds to avoid overflow. */ dev->mib_read_interval =3D msecs_to_jiffies(5000); =20 --=20 2.34.1 From nobody Thu Apr 9 05:25:47 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29C00C636D4 for ; Thu, 2 Feb 2023 12:59:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232555AbjBBM7p (ORCPT ); Thu, 2 Feb 2023 07:59:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232300AbjBBM7U (ORCPT ); Thu, 2 Feb 2023 07:59:20 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72B118F25B; Thu, 2 Feb 2023 04:59:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1675342752; x=1706878752; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IPrDFvqI3OZVkXu9LgANLuFGMbNRDf2adVIuQuhodQ4=; b=ruAuCAvm3vIujiNwqYsYVNOBzTXBCBYVAniNwYzHhie02EPuwuY+0sKX wLMni1nTN8t9u3AoLvlirZM1+v3ETOmr+eXf/qsDZt55MWuWN52TkwCNf BqndCA4Fw+zv1Am5jj29rYxZrdzyUk5w8IRi7gAkHesfSwPHXT3dZ6igG wYeQJOw/KMi+S8uT1jQ9UsMXHvrh8Hq1xsFQK7rzqZIQ2iIyHfAAkUcrg mH6PHPvWiWbg0/Pw5ljy48xA3bZF+W2Ey2+eYCrtZ7OTCmIicKW1uhF6S oBTdJvE6pq7ZV/94SJ+PJrmqoIsX9I3L/YCkPCll52K5RCqHoCHFSRWRX Q==; X-IronPort-AV: E=Sophos;i="5.97,267,1669100400"; d="scan'208";a="135251882" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 02 Feb 2023 05:59:11 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Thu, 2 Feb 2023 05:59:10 -0700 Received: from che-lt-i67786lx.microchip.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Thu, 2 Feb 2023 05:59:06 -0700 From: Rakesh Sankaranarayanan To: , CC: , , , , , , , , , Subject: [RFC PATCH net-next 08/11] net: dsa: microchip: lan937x: avoid mib read for cascaded port Date: Thu, 2 Feb 2023 18:29:27 +0530 Message-ID: <20230202125930.271740-9-rakesh.sankaranarayanan@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202125930.271740-1-rakesh.sankaranarayanan@microchip.com> References: <20230202125930.271740-1-rakesh.sankaranarayanan@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Cascaded port need not be involved in mib read process. Unlike cpu port, mib read function will be called for all other ports. Add check to skip function if port is of type DSA_PORT_TYPE_DSA. Signed-off-by: Rakesh Sankaranarayanan --- drivers/net/dsa/microchip/ksz_common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/micro= chip/ksz_common.c index 0df71156a540..913296c5dd50 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -2230,7 +2230,8 @@ static void ksz_mib_read_work(struct work_struct *wor= k) int i; =20 for (i =3D 0; i < dev->info->port_cnt; i++) { - if (dsa_is_unused_port(dev->ds, i)) + if (dsa_is_unused_port(dev->ds, i) || + dsa_is_dsa_port(dev->ds, i)) continue; =20 p =3D &dev->ports[i]; --=20 2.34.1 From nobody Thu Apr 9 05:25:47 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0A92C636D4 for ; Thu, 2 Feb 2023 13:00:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232524AbjBBNAE (ORCPT ); Thu, 2 Feb 2023 08:00:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232453AbjBBM7h (ORCPT ); Thu, 2 Feb 2023 07:59:37 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37ED68E49E; Thu, 2 Feb 2023 04:59:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1675342758; x=1706878758; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OJg0llhgyQd77eI4/rlRjP9TKpD1ddTPYFukai6jCVo=; b=xLZmsHz84cowWyVJQWW4+YybwYQpbdvMkzFa0kw5ALpVBLJ6+I7oDU+p REACz9KM8HrG4ltsJxge3ir95wXiJ67FJhjY9xmf1tqCa5iknmsjeTclq 0bfLiWfxaGGQsQkyeZ5IB6ABFz5Dza9d5bndEJPGIy9zZrBhYEU6D3EQY ChK2WJeLazomN0J2oi0DOEMv2pwFCrd3CBRu0/qDwGwp7iSJDljBcQkwc TzK03W5kYWRcealhC5rc23OA6aa/+705qJfbVG7pFpePcDVpqyvULSGEF sJ09S3fX7jmWqVXqkEJ1knp8Y6p6UmSF4pJqRbHzlFLIjLtjvuoZ16kjN A==; X-IronPort-AV: E=Sophos;i="5.97,267,1669100400"; d="scan'208";a="135252001" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 02 Feb 2023 05:59:17 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Thu, 2 Feb 2023 05:59:15 -0700 Received: from che-lt-i67786lx.microchip.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Thu, 2 Feb 2023 05:59:11 -0700 From: Rakesh Sankaranarayanan To: , CC: , , , , , , , , , Subject: [RFC PATCH net-next 09/11] net: dsa: microchip: lan937x: update port membership with dsa port Date: Thu, 2 Feb 2023 18:29:28 +0530 Message-ID: <20230202125930.271740-10-rakesh.sankaranarayanan@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202125930.271740-1-rakesh.sankaranarayanan@microchip.com> References: <20230202125930.271740-1-rakesh.sankaranarayanan@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Like cpu port, cascaded port will act as host port in second switch. And all ports from both switches should be able to forward packets to cascaded ports. Add cascaded port (dev->dsa_port) to each port membership. Current design add bit map of user ports as cpu port membership. Include cascaded port index as well to this group. Signed-off-by: Rakesh Sankaranarayanan --- drivers/net/dsa/microchip/ksz_common.c | 7 ++++--- drivers/net/dsa/microchip/lan937x_main.c | 2 +- include/net/dsa.h | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/micro= chip/ksz_common.c index 913296c5dd50..b8b7b5b7b52d 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -1748,9 +1748,9 @@ static void ksz_get_strings(struct dsa_switch *ds, in= t port, =20 static void ksz_update_port_member(struct ksz_device *dev, int port) { + u8 port_member =3D 0, cpu_port, dsa_port; struct ksz_port *p =3D &dev->ports[port]; struct dsa_switch *ds =3D dev->ds; - u8 port_member =3D 0, cpu_port; const struct dsa_port *dp; int i, j; =20 @@ -1759,6 +1759,7 @@ static void ksz_update_port_member(struct ksz_device = *dev, int port) =20 dp =3D dsa_to_port(ds, port); cpu_port =3D BIT(dsa_upstream_port(ds, port)); + dsa_port =3D BIT(dev->dsa_port); =20 for (i =3D 0; i < ds->num_ports; i++) { const struct dsa_port *other_dp =3D dsa_to_port(ds, i); @@ -1798,10 +1799,10 @@ static void ksz_update_port_member(struct ksz_devic= e *dev, int port) val |=3D BIT(j); } =20 - dev->dev_ops->cfg_port_member(dev, i, val | cpu_port); + dev->dev_ops->cfg_port_member(dev, i, val | cpu_port | dsa_port); } =20 - dev->dev_ops->cfg_port_member(dev, port, port_member | cpu_port); + dev->dev_ops->cfg_port_member(dev, port, port_member | cpu_port | dsa_por= t); } =20 static int ksz_sw_mdio_read(struct mii_bus *bus, int addr, int regnum) diff --git a/drivers/net/dsa/microchip/lan937x_main.c b/drivers/net/dsa/mic= rochip/lan937x_main.c index 5108a3f4bf76..b17bb1ea2a4a 100644 --- a/drivers/net/dsa/microchip/lan937x_main.c +++ b/drivers/net/dsa/microchip/lan937x_main.c @@ -198,7 +198,7 @@ void lan937x_port_setup(struct ksz_device *dev, int por= t, bool cpu_port) true); =20 if (cpu_port) - member =3D dsa_user_ports(ds); + member =3D dsa_user_ports(ds) | dsa_dsa_ports(ds); else member =3D BIT(dsa_upstream_port(ds, port)); =20 diff --git a/include/net/dsa.h b/include/net/dsa.h index 55651ad29193..939aa6ff1a38 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -591,6 +591,10 @@ static inline bool dsa_is_user_port(struct dsa_switch = *ds, int p) dsa_switch_for_each_port((_dp), (_ds)) \ if (dsa_port_is_cpu((_dp))) =20 +#define dsa_switch_for_each_dsa_port(_dp, _ds) \ + dsa_switch_for_each_port((_dp), (_ds)) \ + if (dsa_port_is_dsa((_dp))) + #define dsa_switch_for_each_cpu_port_continue_reverse(_dp, _ds) \ dsa_switch_for_each_port_continue_reverse((_dp), (_ds)) \ if (dsa_port_is_cpu((_dp))) @@ -617,6 +621,17 @@ static inline u32 dsa_cpu_ports(struct dsa_switch *ds) return mask; } =20 +static inline u32 dsa_dsa_ports(struct dsa_switch *ds) +{ + struct dsa_port *dsa_dp; + u32 mask =3D 0; + + dsa_switch_for_each_dsa_port(dsa_dp, ds) + mask |=3D BIT(dsa_dp->index); + + return mask; +} + /* Return the local port used to reach an arbitrary switch device */ static inline unsigned int dsa_routing_port(struct dsa_switch *ds, int dev= ice) { --=20 2.34.1 From nobody Thu Apr 9 05:25:47 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2069AC61DA4 for ; Thu, 2 Feb 2023 13:00:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232636AbjBBNAQ (ORCPT ); Thu, 2 Feb 2023 08:00:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232591AbjBBM7t (ORCPT ); Thu, 2 Feb 2023 07:59:49 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37BC68C405; Thu, 2 Feb 2023 04:59:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1675342762; x=1706878762; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ouumZ6vbUvawBmcL9NxoUu7tYtFUqagkN0ir03uG0JE=; b=jblrvlrd04/sJWl2s+iqEKMS0szsyJcqY2/Jv55Ru1z9VoM/2k7kLdtd ENq7di3NJLKt3AuSZg8QSM2RzgtoMSbNLf5CrDdJIgtCIhxXyLW2ouXAm wEcU3yG1SikMA8MFXa6aT22GVF78fAcNmszb1TliXdRFzQwD/EjcrUUhI UJ+ChakIXLnUz0XIh5Vd925PvXIVAl94CQbKN+zZ6/CItynADBAwdIl0C jpYUD6uZttHPFLtSlK94NSDkNTY0DycABzxK8cSlVJDFjVZ4Lk6H5EusR k+7hruLPc2gpg11IlAQ9lATIh/Ne3SYihktinr9CgPRHjSOBwnm1k9Pif g==; X-IronPort-AV: E=Sophos;i="5.97,267,1669100400"; d="scan'208";a="135252070" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 02 Feb 2023 05:59:21 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Thu, 2 Feb 2023 05:59:21 -0700 Received: from che-lt-i67786lx.microchip.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Thu, 2 Feb 2023 05:59:16 -0700 From: Rakesh Sankaranarayanan To: , CC: , , , , , , , , , Subject: [RFC PATCH net-next 10/11] net: dsa: microchip: lan937x: update vlan untag membership Date: Thu, 2 Feb 2023 18:29:29 +0530 Message-ID: <20230202125930.271740-11-rakesh.sankaranarayanan@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202125930.271740-1-rakesh.sankaranarayanan@microchip.com> References: <20230202125930.271740-1-rakesh.sankaranarayanan@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Exclude cascaded port from vlan untag membership table since it will be the host port for second switch. Here setting 1 means, port will be capable of receiving tagged frames and 0 means, port can not receive tagged frames. Signed-off-by: Rakesh Sankaranarayanan --- drivers/net/dsa/microchip/ksz9477.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchi= p/ksz9477.c index bf13d47c26cf..4c12131098b1 100644 --- a/drivers/net/dsa/microchip/ksz9477.c +++ b/drivers/net/dsa/microchip/ksz9477.c @@ -399,7 +399,7 @@ int ksz9477_port_vlan_add(struct ksz_device *dev, int p= ort, vlan_table[1] |=3D BIT(port); else vlan_table[1] &=3D ~BIT(port); - vlan_table[1] &=3D ~(BIT(dev->cpu_port)); + vlan_table[1] &=3D ~(BIT(dev->cpu_port) | BIT(dev->dsa_port)); =20 vlan_table[2] |=3D BIT(port) | BIT(dev->cpu_port); =20 --=20 2.34.1 From nobody Thu Apr 9 05:25:47 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69C75C61DA4 for ; Thu, 2 Feb 2023 13:00:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232520AbjBBNAf (ORCPT ); Thu, 2 Feb 2023 08:00:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232527AbjBBNAK (ORCPT ); Thu, 2 Feb 2023 08:00:10 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 656668E4AC; Thu, 2 Feb 2023 04:59:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1675342774; x=1706878774; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=l+6j3bIkI3D5xNchH0czU8eucYVEM7sYgP+6GkMs3tk=; b=OxSsIfqyLrh9uu+vES8XplLrbxqwa2M+Acz4JZ4joo9SQrBdzQsQ1D6i 5Gx9IA8kpPmU9sf2KGdvfNBTEwfiZSCSXqCzYv5dQdeiK2io9V3EWh4wB OkOFCLg4B0r7cXVdtkVVlz1qXDxe56Z9CHP5XUUTiREzsGLrUi+Ha0u2h NAXEp5b+YzsnG71yLXBFUDaW6+MJNjNf/FTFTlZ0rVDFEPZY7Tdn0v2jz nwNB/KjivT8Ylftq/W4N5u3ivqZMeYk2Kqkjxw+sX0lPqyL6uR7SOw6V6 DlZiGrXoEqVXB8JnVilHXcjUZFdFgZN5fYMKPu8L3Qu6eeqNtphZuPjN+ Q==; X-IronPort-AV: E=Sophos;i="5.97,267,1669100400"; d="scan'208";a="135252111" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 02 Feb 2023 05:59:27 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Thu, 2 Feb 2023 05:59:26 -0700 Received: from che-lt-i67786lx.microchip.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Thu, 2 Feb 2023 05:59:22 -0700 From: Rakesh Sankaranarayanan To: , CC: , , , , , , , , , Subject: [RFC PATCH net-next 11/11] net: dsa: microchip: lan937x: update multicast table Date: Thu, 2 Feb 2023 18:29:30 +0530 Message-ID: <20230202125930.271740-12-rakesh.sankaranarayanan@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202125930.271740-1-rakesh.sankaranarayanan@microchip.com> References: <20230202125930.271740-1-rakesh.sankaranarayanan@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Program multicast table for cascaded port in second switch with default port forward value since it is the host port for second switch. Current driver program the same for cpu port in first switch. Signed-off-by: Rakesh Sankaranarayanan --- drivers/net/dsa/microchip/ksz9477.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchi= p/ksz9477.c index 4c12131098b1..521d8c2e1540 100644 --- a/drivers/net/dsa/microchip/ksz9477.c +++ b/drivers/net/dsa/microchip/ksz9477.c @@ -1116,18 +1116,22 @@ void ksz9477_config_cpu_port(struct dsa_switch *ds) =20 int ksz9477_enable_stp_addr(struct ksz_device *dev) { + u32 fwd_port =3D BIT(dev->cpu_port); const u32 *masks; u32 data; int ret; =20 masks =3D dev->info->masks; =20 + if (dev->ds->index =3D=3D 1) + fwd_port =3D BIT(dev->dsa_port); + /* Enable Reserved multicast table */ ksz_cfg(dev, REG_SW_LUE_CTRL_0, SW_RESV_MCAST_ENABLE, true); =20 /* Set the Override bit for forwarding BPDU packet to CPU */ ret =3D ksz_write32(dev, REG_SW_ALU_VAL_B, - ALU_V_OVERRIDE | BIT(dev->cpu_port)); + ALU_V_OVERRIDE | fwd_port); if (ret < 0) return ret; =20 --=20 2.34.1