From nobody Wed Apr 1 12:39:40 2026 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 410E83A544E; Tue, 31 Mar 2026 10:04:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774951459; cv=none; b=AZnnxFKYtWwEM5YP0Y6qfeyp40rS5RpaHOxcUIzPSnGV9TCG5u5v6X1XWCzTci+/AgZNKngzm7vjFd+FlXqr/QE8V08puMrMN5KptMhFEzKgaUjCpLYU6r+LyDAOi6GQoSOZpr6YO19QqAXaWU+0rNi0PcFulVtIGigrAYQy+Jg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774951459; c=relaxed/simple; bh=aqwo6YDRLA2mVz94WYaEU1NWDqPecZfQ0fOXF3ovnY0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pi9h+L3Q3PSWeuWR43oVZ9Nqb3MSao86Pea+2977agJFwU7bA3DaRb5rmi7LMbe/ZDK760Y68Z6Ko+KYtxJ2Deyy5Dkf2bAPw3zp6ZJyqnj21o7Xmz6ZICKIE3fYCI9ygW71sy0sUM0aq8Y7JPHHUKx+87IgSAPEAFibQ4flkKM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com; spf=pass smtp.mailfrom=renesas.com; arc=none smtp.client-ip=210.160.252.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=renesas.com X-CSE-ConnectionGUID: Uh497dTgTGiqcxqODgNM9A== X-CSE-MsgGUID: /XF8lVXlTt6CWlTLQcrKaQ== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 31 Mar 2026 19:04:10 +0900 Received: from [127.0.1.1] (unknown [10.226.78.135]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id F15B2416C823; Tue, 31 Mar 2026 19:04:06 +0900 (JST) From: Michael Dege Date: Tue, 31 Mar 2026 12:03:55 +0200 Subject: [PATCH net-next v3 01/13] net: renesas: rswitch: improve port change mode functions Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260331-rswitch_add_vlans-v3-1-c37f41b1c556@renesas.com> References: <20260331-rswitch_add_vlans-v3-0-c37f41b1c556@renesas.com> In-Reply-To: <20260331-rswitch_add_vlans-v3-0-c37f41b1c556@renesas.com> To: Yoshihiro Shimoda , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?q?Niklas_S=C3=B6derlund?= , Paul Barker Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Dege X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774951442; l=3529; i=michael.dege@renesas.com; s=20251023; h=from:subject:message-id; bh=aqwo6YDRLA2mVz94WYaEU1NWDqPecZfQ0fOXF3ovnY0=; b=lOC13aZSa196mt5Ii+fYj+aWJwzBUrL/t0pHWT8YuMExIKqjRSLg+EKYDBT/w6m7lMMheQ4B6 +Y+KKmtXZqrD0zFKPwmWOYhWJUBN1Wru76OpmTOs+5uugTBGMyoDGvi X-Developer-Key: i=michael.dege@renesas.com; a=ed25519; pk=gu1rwIcCrAxNMv2I8fIfiQvt51xzZwnQy4Ua/DscQt8= For ETHA and GWCA ports every mode change from operational to configuration and vice-versa requires to change the mode to "disable" first. This was done by calling the function twice. Let the change_mode functione take care of this requiered step in a single call. Signed-off-by: Michael Dege --- drivers/net/ethernet/renesas/rswitch_main.c | 39 +++++++++++++------------= ---- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/drivers/net/ethernet/renesas/rswitch_main.c b/drivers/net/ethe= rnet/renesas/rswitch_main.c index 6fe964816322..f6d1e610e7fa 100644 --- a/drivers/net/ethernet/renesas/rswitch_main.c +++ b/drivers/net/ethernet/renesas/rswitch_main.c @@ -176,14 +176,19 @@ static int rswitch_gwca_change_mode(struct rswitch_pr= ivate *priv, if (!rswitch_agent_clock_is_enabled(priv->addr, priv->gwca.index)) rswitch_agent_clock_ctrl(priv->addr, priv->gwca.index, 1); =20 - iowrite32(mode, priv->addr + GWMC); + iowrite32(GWMC_OPC_DISABLE, priv->addr + GWMC); =20 - ret =3D rswitch_reg_wait(priv->addr, GWMS, GWMS_OPS_MASK, mode); + ret =3D rswitch_reg_wait(priv->addr, GWMS, GWMS_OPS_MASK, GWMC_OPC_DISABL= E); =20 - if (mode =3D=3D GWMC_OPC_DISABLE) + if (mode =3D=3D GWMC_OPC_DISABLE) { rswitch_agent_clock_ctrl(priv->addr, priv->gwca.index, 0); =20 - return ret; + return ret; + } + + iowrite32(mode, priv->addr + GWMC); + + return rswitch_reg_wait(priv->addr, GWMS, GWMS_OPS_MASK, mode); } =20 static int rswitch_gwca_mcast_table_reset(struct rswitch_private *priv) @@ -682,9 +687,6 @@ static int rswitch_gwca_hw_init(struct rswitch_private = *priv) unsigned int i; int err; =20 - err =3D rswitch_gwca_change_mode(priv, GWMC_OPC_DISABLE); - if (err < 0) - return err; err =3D rswitch_gwca_change_mode(priv, GWMC_OPC_CONFIG); if (err < 0) return err; @@ -717,9 +719,6 @@ static int rswitch_gwca_hw_init(struct rswitch_private = *priv) return err; } =20 - err =3D rswitch_gwca_change_mode(priv, GWMC_OPC_DISABLE); - if (err < 0) - return err; return rswitch_gwca_change_mode(priv, GWMC_OPC_OPERATION); } =20 @@ -727,9 +726,6 @@ static int rswitch_gwca_hw_deinit(struct rswitch_privat= e *priv) { int err; =20 - err =3D rswitch_gwca_change_mode(priv, GWMC_OPC_DISABLE); - if (err < 0) - return err; err =3D rswitch_gwca_change_mode(priv, GWMC_OPC_RESET); if (err < 0) return err; @@ -1116,14 +1112,18 @@ static int rswitch_etha_change_mode(struct rswitch_= etha *etha, if (!rswitch_agent_clock_is_enabled(etha->coma_addr, etha->index)) rswitch_agent_clock_ctrl(etha->coma_addr, etha->index, 1); =20 - iowrite32(mode, etha->addr + EAMC); - - ret =3D rswitch_reg_wait(etha->addr, EAMS, EAMS_OPS_MASK, mode); + iowrite32(EAMC_OPC_DISABLE, etha->addr + EAMC); + ret =3D rswitch_reg_wait(etha->addr, EAMS, EAMS_OPS_MASK, EAMC_OPC_DISABL= E); =20 - if (mode =3D=3D EAMC_OPC_DISABLE) + if (mode =3D=3D EAMC_OPC_DISABLE) { rswitch_agent_clock_ctrl(etha->coma_addr, etha->index, 0); =20 - return ret; + return ret; + } + + iowrite32(mode, etha->addr + EAMC); + + return rswitch_reg_wait(etha->addr, EAMS, EAMS_OPS_MASK, mode); } =20 static void rswitch_etha_read_mac_address(struct rswitch_etha *etha) @@ -1203,9 +1203,6 @@ static int rswitch_etha_hw_init(struct rswitch_etha *= etha, const u8 *mac) { int err; =20 - err =3D rswitch_etha_change_mode(etha, EAMC_OPC_DISABLE); - if (err < 0) - return err; err =3D rswitch_etha_change_mode(etha, EAMC_OPC_CONFIG); if (err < 0) return err; --=20 2.43.0 From nobody Wed Apr 1 12:39:40 2026 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1388C3ED5B9; Tue, 31 Mar 2026 10:04:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774951459; cv=none; b=oxZ/tLtzPf06enIquMdJPTJH3+y+k1UnQnbBKM2NNYFk0L0lfL+C2cpg7rKZ8lR68cLsRmZqsYIoYqcjx0rcnIcoLNgm6sY0a4xkuilDZRSFxF0iVCL7auB0AuySnN/13wD43cw/wYo+/QsXLQtYKQnN4FkFpmKrnZLmSSEYQwo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774951459; c=relaxed/simple; bh=AHTbZ5ZMDiHqSa7GUptX2ISx1icHznDQhy/RCqMiIuo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EaNQOj1TSzEYrIrE5nKhwe1m3F5oLwObNyuDwrML/VYU1OkH9/jy1TRwV1BRmKAzhBvTKECynolXg+HpoMYdvfwGQWcm5l/rC2L8GPrQyYQqCzFhX7w3FwBzQ7v5rYiOS0phxK2A0eBXMYOsATVTxfRVtBFR5Ze8QWjKs61Fr+E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com; spf=pass smtp.mailfrom=renesas.com; arc=none smtp.client-ip=210.160.252.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=renesas.com X-CSE-ConnectionGUID: T3rErIdoTl2cLYU8MPmm3g== X-CSE-MsgGUID: F7UAlxxoQ3eoq1y0hh1U8g== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 31 Mar 2026 19:04:13 +0900 Received: from [127.0.1.1] (unknown [10.226.78.135]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 84F35416C823; Tue, 31 Mar 2026 19:04:10 +0900 (JST) From: Michael Dege Date: Tue, 31 Mar 2026 12:03:56 +0200 Subject: [PATCH net-next v3 02/13] net: renesas: rswitch: use device instead of net_device Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260331-rswitch_add_vlans-v3-2-c37f41b1c556@renesas.com> References: <20260331-rswitch_add_vlans-v3-0-c37f41b1c556@renesas.com> In-Reply-To: <20260331-rswitch_add_vlans-v3-0-c37f41b1c556@renesas.com> To: Yoshihiro Shimoda , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?q?Niklas_S=C3=B6derlund?= , Paul Barker Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Dege X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774951442; l=6218; i=michael.dege@renesas.com; s=20251023; h=from:subject:message-id; bh=AHTbZ5ZMDiHqSa7GUptX2ISx1icHznDQhy/RCqMiIuo=; b=HxfJoejGz8IDYXrr34UdVPlM4ngJ3CikbWTj/HHkA5k2VGSWHPvspD6+aA/BIZY5+/HpaoKGF fiFJ8YuQB7RBSXh1edjKQ+34t34gt3lVFmXnjvR0JYlN3VmL8Ldb2F3 X-Developer-Key: i=michael.dege@renesas.com; a=ed25519; pk=gu1rwIcCrAxNMv2I8fIfiQvt51xzZwnQy4Ua/DscQt8= In upcomming changes for adding vlan support struct net_device will not be available in all cases, therefore use struct device instead. Signed-off-by: Michael Dege --- drivers/net/ethernet/renesas/rswitch_main.c | 34 ++++++++++++++-----------= ---- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/renesas/rswitch_main.c b/drivers/net/ethe= rnet/renesas/rswitch_main.c index f6d1e610e7fa..f10e188bc0bd 100644 --- a/drivers/net/ethernet/renesas/rswitch_main.c +++ b/drivers/net/ethernet/renesas/rswitch_main.c @@ -302,13 +302,13 @@ static int rswitch_gwca_queue_alloc_rx_buf(struct rsw= itch_gwca_queue *gq, return -ENOMEM; } =20 -static void rswitch_gwca_queue_free(struct net_device *ndev, +static void rswitch_gwca_queue_free(struct device *dev, struct rswitch_gwca_queue *gq) { unsigned int i; =20 if (!gq->dir_tx) { - dma_free_coherent(ndev->dev.parent, + dma_free_coherent(dev, sizeof(struct rswitch_ext_ts_desc) * (gq->ring_size + 1), gq->rx_ring, gq->ring_dma); gq->rx_ring =3D NULL; @@ -318,7 +318,7 @@ static void rswitch_gwca_queue_free(struct net_device *= ndev, kfree(gq->rx_bufs); gq->rx_bufs =3D NULL; } else { - dma_free_coherent(ndev->dev.parent, + dma_free_coherent(dev, sizeof(struct rswitch_ext_desc) * (gq->ring_size + 1), gq->tx_ring, gq->ring_dma); gq->tx_ring =3D NULL; @@ -357,7 +357,7 @@ static int rswitch_gwca_queue_alloc(struct net_device *= ndev, if (rswitch_gwca_queue_alloc_rx_buf(gq, 0, gq->ring_size) < 0) goto out; =20 - gq->rx_ring =3D dma_alloc_coherent(ndev->dev.parent, + gq->rx_ring =3D dma_alloc_coherent(&priv->pdev->dev, sizeof(struct rswitch_ext_ts_desc) * (gq->ring_size + 1), &gq->ring_dma, GFP_KERNEL); } else { @@ -367,7 +367,7 @@ static int rswitch_gwca_queue_alloc(struct net_device *= ndev, gq->unmap_addrs =3D kzalloc_objs(*gq->unmap_addrs, gq->ring_size); if (!gq->unmap_addrs) goto out; - gq->tx_ring =3D dma_alloc_coherent(ndev->dev.parent, + gq->tx_ring =3D dma_alloc_coherent(&priv->pdev->dev, sizeof(struct rswitch_ext_desc) * (gq->ring_size + 1), &gq->ring_dma, GFP_KERNEL); } @@ -385,7 +385,7 @@ static int rswitch_gwca_queue_alloc(struct net_device *= ndev, return 0; =20 out: - rswitch_gwca_queue_free(ndev, gq); + rswitch_gwca_queue_free(&priv->pdev->dev, gq); =20 return -ENOMEM; } @@ -467,12 +467,11 @@ static void rswitch_gwca_ts_queue_fill(struct rswitch= _private *priv, } } =20 -static int rswitch_gwca_queue_ext_ts_fill(struct net_device *ndev, +static int rswitch_gwca_queue_ext_ts_fill(struct device *dev, struct rswitch_gwca_queue *gq, unsigned int start_index, unsigned int num) { - struct rswitch_device *rdev =3D netdev_priv(ndev); struct rswitch_ext_ts_desc *desc; unsigned int i, index; dma_addr_t dma_addr; @@ -481,18 +480,17 @@ static int rswitch_gwca_queue_ext_ts_fill(struct net_= device *ndev, index =3D (i + start_index) % gq->ring_size; desc =3D &gq->rx_ring[index]; if (!gq->dir_tx) { - dma_addr =3D dma_map_single(ndev->dev.parent, + dma_addr =3D dma_map_single(dev, gq->rx_bufs[index] + RSWITCH_HEADROOM, RSWITCH_MAP_BUF_SIZE, DMA_FROM_DEVICE); - if (dma_mapping_error(ndev->dev.parent, dma_addr)) + if (dma_mapping_error(dev, dma_addr)) goto err; =20 desc->desc.info_ds =3D cpu_to_le16(RSWITCH_DESC_BUF_SIZE); rswitch_desc_set_dptr(&desc->desc, dma_addr); dma_wmb(); desc->desc.die_dt =3D DT_FEMPTY | DIE; - desc->info1 =3D cpu_to_le64(INFO1_SPN(rdev->etha->index)); } else { desc->desc.die_dt =3D DT_EEMPTY | DIE; } @@ -506,7 +504,7 @@ static int rswitch_gwca_queue_ext_ts_fill(struct net_de= vice *ndev, index =3D (i + start_index) % gq->ring_size; desc =3D &gq->rx_ring[index]; dma_addr =3D rswitch_desc_get_dptr(&desc->desc); - dma_unmap_single(ndev->dev.parent, dma_addr, + dma_unmap_single(dev, dma_addr, RSWITCH_MAP_BUF_SIZE, DMA_FROM_DEVICE); } } @@ -514,7 +512,7 @@ static int rswitch_gwca_queue_ext_ts_fill(struct net_de= vice *ndev, return -ENOMEM; } =20 -static int rswitch_gwca_queue_ext_ts_format(struct net_device *ndev, +static int rswitch_gwca_queue_ext_ts_format(struct device *dev, struct rswitch_private *priv, struct rswitch_gwca_queue *gq) { @@ -524,7 +522,7 @@ static int rswitch_gwca_queue_ext_ts_format(struct net_= device *ndev, int err; =20 memset(gq->rx_ring, 0, ring_size); - err =3D rswitch_gwca_queue_ext_ts_fill(ndev, gq, 0, gq->ring_size); + err =3D rswitch_gwca_queue_ext_ts_fill(dev, gq, 0, gq->ring_size); if (err < 0) return err; =20 @@ -636,7 +634,7 @@ static void rswitch_txdmac_free(struct net_device *ndev) { struct rswitch_device *rdev =3D netdev_priv(ndev); =20 - rswitch_gwca_queue_free(ndev, rdev->tx_queue); + rswitch_gwca_queue_free(ndev->dev.parent, rdev->tx_queue); rswitch_gwca_put(rdev->priv, rdev->tx_queue); } =20 @@ -670,7 +668,7 @@ static void rswitch_rxdmac_free(struct net_device *ndev) { struct rswitch_device *rdev =3D netdev_priv(ndev); =20 - rswitch_gwca_queue_free(ndev, rdev->rx_queue); + rswitch_gwca_queue_free(ndev->dev.parent, rdev->rx_queue); rswitch_gwca_put(rdev->priv, rdev->rx_queue); } =20 @@ -679,7 +677,7 @@ static int rswitch_rxdmac_init(struct rswitch_private *= priv, unsigned int index) struct rswitch_device *rdev =3D priv->rdev[index]; struct net_device *ndev =3D rdev->ndev; =20 - return rswitch_gwca_queue_ext_ts_format(ndev, priv, rdev->rx_queue); + return rswitch_gwca_queue_ext_ts_format(ndev->dev.parent, priv, rdev->rx_= queue); } =20 static int rswitch_gwca_hw_init(struct rswitch_private *priv) @@ -870,7 +868,7 @@ static bool rswitch_rx(struct net_device *ndev, int *qu= ota) ret =3D rswitch_gwca_queue_alloc_rx_buf(gq, gq->dirty, num); if (ret < 0) goto err; - ret =3D rswitch_gwca_queue_ext_ts_fill(ndev, gq, gq->dirty, num); + ret =3D rswitch_gwca_queue_ext_ts_fill(ndev->dev.parent, gq, gq->dirty, n= um); if (ret < 0) goto err; gq->dirty =3D rswitch_next_queue_index(gq, false, num); --=20 2.43.0 From nobody Wed Apr 1 12:39:40 2026 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5F25D3A7590; Tue, 31 Mar 2026 10:04:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774951461; cv=none; b=NWNG3g/IazGiX4s+uRjNjptX+JWRoFBU3TpBnGLLlJa8lfHkkqlgklLv8HT/dG8kZOzmd7s4fov1Nlh6aPWgQRvwUNQjV4sTAF2+A5eZyzcwBeKgTXojp3dj6xXyfGV8T+BrBERENU2l2ZeZI4ppES/EUF2cmcm/n/Ww6j1ofr8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774951461; c=relaxed/simple; bh=qOJp9NLB9+UtI5DU5azk15Hf+Q/qHTqK5aYPyRrfBfY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=W7/8mTz4nl/zbECSr/hV3hjySbo+itFKZLY0Nf2FiQGQJRG81LhwFSh5NXVwV02osQ3EfZlQZZWEIeEGNUNbkBho5PvcJy4IHQUq9tPJmY4S2uFzWQZFLQr7rK3cvzM19E/ZQGESGuBHkS6R826UEkqpT/WzgBgsFMPQLnAgLP8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com; spf=pass smtp.mailfrom=renesas.com; arc=none smtp.client-ip=210.160.252.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=renesas.com X-CSE-ConnectionGUID: gWMv3/ZVSoiTOsw96S4sXQ== X-CSE-MsgGUID: 09rdp35hSnmgIrRZNS3Wxw== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 31 Mar 2026 19:04:17 +0900 Received: from [127.0.1.1] (unknown [10.226.78.135]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 16633416C39F; Tue, 31 Mar 2026 19:04:13 +0900 (JST) From: Michael Dege Date: Tue, 31 Mar 2026 12:03:57 +0200 Subject: [PATCH net-next v3 03/13] net: renesas: rswitch: fix FWPC2 register access macros Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260331-rswitch_add_vlans-v3-3-c37f41b1c556@renesas.com> References: <20260331-rswitch_add_vlans-v3-0-c37f41b1c556@renesas.com> In-Reply-To: <20260331-rswitch_add_vlans-v3-0-c37f41b1c556@renesas.com> To: Yoshihiro Shimoda , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?q?Niklas_S=C3=B6derlund?= , Paul Barker Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Dege X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774951442; l=2272; i=michael.dege@renesas.com; s=20251023; h=from:subject:message-id; bh=qOJp9NLB9+UtI5DU5azk15Hf+Q/qHTqK5aYPyRrfBfY=; b=43aorNHPETIGQ1SJqrGP8ARa9vXlCmA076Cz+95UEQht/ls4QTj+coKHpgFna9ImeMTh755Fl 9c/wB4fInhxDYv/w7JAStXzJpcvIYAUoodAIMtl7fJVKxi1WMPP50ZD X-Developer-Key: i=michael.dege@renesas.com; a=ed25519; pk=gu1rwIcCrAxNMv2I8fIfiQvt51xzZwnQy4Ua/DscQt8= Fix typo in macro name and remove duplicate macro definition. Signed-off-by: Michael Dege --- drivers/net/ethernet/renesas/rswitch.h | 3 +-- drivers/net/ethernet/renesas/rswitch_l2.c | 2 +- drivers/net/ethernet/renesas/rswitch_main.c | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/renesas/rswitch.h b/drivers/net/ethernet/= renesas/rswitch.h index aa605304fed0..340524d995ac 100644 --- a/drivers/net/ethernet/renesas/rswitch.h +++ b/drivers/net/ethernet/renesas/rswitch.h @@ -826,8 +826,7 @@ enum rswitch_gwca_mode { #define FWPC1_DDE BIT(0) =20 #define FWPC2(i) (FWPC20 + (i) * 0x10) -#define FWCP2_LTWFW GENMASK(16 + (RSWITCH_NUM_AGENTS - 1), 16) -#define FWCP2_LTWFW_MASK GENMASK(16 + (RSWITCH_NUM_AGENTS - 1), 16) +#define FWPC2_LTWFW GENMASK(16 + (RSWITCH_NUM_AGENTS - 1), 16) =20 #define FWPBFC(i) (FWPBFC0 + (i) * 0x10) #define FWPBFC_PBDV GENMASK(RSWITCH_NUM_AGENTS - 1, 0) diff --git a/drivers/net/ethernet/renesas/rswitch_l2.c b/drivers/net/ethern= et/renesas/rswitch_l2.c index 9433cd8adced..709524c8a5c4 100644 --- a/drivers/net/ethernet/renesas/rswitch_l2.c +++ b/drivers/net/ethernet/renesas/rswitch_l2.c @@ -82,7 +82,7 @@ static void rswitch_update_l2_hw_forwarding(struct rswitc= h_private *priv) * * Do not allow L2 forwarding to self for hw port. */ - iowrite32(FIELD_PREP(FWCP2_LTWFW_MASK, fwd_mask | BIT(rdev->port)), + iowrite32(FIELD_PREP(FWPC2_LTWFW, fwd_mask | BIT(rdev->port)), priv->addr + FWPC2(rdev->port)); } =20 diff --git a/drivers/net/ethernet/renesas/rswitch_main.c b/drivers/net/ethe= rnet/renesas/rswitch_main.c index f10e188bc0bd..d404bc41bd1e 100644 --- a/drivers/net/ethernet/renesas/rswitch_main.c +++ b/drivers/net/ethernet/renesas/rswitch_main.c @@ -129,7 +129,7 @@ static int rswitch_fwd_init(struct rswitch_private *pri= v) iowrite32(FIELD_PREP(FWCP1_LTHFW, all_ports_mask), priv->addr + FWPC1(i)); /* Disallow L2 forwarding */ - iowrite32(FIELD_PREP(FWCP2_LTWFW, all_ports_mask), + iowrite32(FIELD_PREP(FWPC2_LTWFW, all_ports_mask), priv->addr + FWPC2(i)); /* Disallow port based forwarding */ iowrite32(0, priv->addr + FWPBFC(i)); --=20 2.43.0 From nobody Wed Apr 1 12:39:40 2026 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E53853EF0D2; Tue, 31 Mar 2026 10:04:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774951462; cv=none; b=LXysFIR8iaJPXk5NLCh6qpf0AhAWDR/lf2qUV+JaxCBDprym3itC6B9CWvenoZiWA/6HNS2D8c360YSScaJLpLRqayTjVdLFLcHjNmwkAtnVLGKsjQjCC92In6mbyxTlCF6Wv7NSISDmVxnr5QUTzeeB+vrAmRqbukbnxw50VaM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774951462; c=relaxed/simple; bh=rcTOSka6tP/lYSG7IJtOBUcaxYoJK+gaZ9DeXg39u/s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uHYH0EjRaqiWhGaakb+1UPLKhS74EEYNIR5MmkRdXoKMU5xmqDpkngd0uOpB8NWjoZKV+S09MmBh+p5bweSBbJ8tvtMDDtVm6pqNP03lwGr4Xp5fQkbl4lobZnH9gH2jvL0/Iiu7HwgJZi5gLIfYYeAROUoljjBHQZMi95fP1SY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com; spf=pass smtp.mailfrom=renesas.com; arc=none smtp.client-ip=210.160.252.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=renesas.com X-CSE-ConnectionGUID: MM/aGryuROivuLqyOLbxTQ== X-CSE-MsgGUID: qDwNr2DxRLSlDiv7xF0+Ew== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 31 Mar 2026 19:04:20 +0900 Received: from [127.0.1.1] (unknown [10.226.78.135]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id A0C89416C39F; Tue, 31 Mar 2026 19:04:17 +0900 (JST) From: Michael Dege Date: Tue, 31 Mar 2026 12:03:58 +0200 Subject: [PATCH net-next v3 04/13] net: renesas: rswitch: add register definitions for vlan support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260331-rswitch_add_vlans-v3-4-c37f41b1c556@renesas.com> References: <20260331-rswitch_add_vlans-v3-0-c37f41b1c556@renesas.com> In-Reply-To: <20260331-rswitch_add_vlans-v3-0-c37f41b1c556@renesas.com> To: Yoshihiro Shimoda , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?q?Niklas_S=C3=B6derlund?= , Paul Barker Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Dege X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774951442; l=6161; i=michael.dege@renesas.com; s=20251023; h=from:subject:message-id; bh=rcTOSka6tP/lYSG7IJtOBUcaxYoJK+gaZ9DeXg39u/s=; b=F7QTPdSdGBxLE4K013S3LqK92HyVMFTutHWbIByLL8oHsEjvYQQRKAKubSlTC/L37f2qtDfsH ptaqDCDPlThD4tcxDK6UJNIzq6mSg2JVHXQLnW20BLHoE8fwt+g2OH5 X-Developer-Key: i=michael.dege@renesas.com; a=ed25519; pk=gu1rwIcCrAxNMv2I8fIfiQvt51xzZwnQy4Ua/DscQt8= Add missing register and bit definitions for vlan support. Signed-off-by: Michael Dege --- drivers/net/ethernet/renesas/rswitch.h | 156 +++++++++++++++++++++++++++++= +++- 1 file changed, 152 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/renesas/rswitch.h b/drivers/net/ethernet/= renesas/rswitch.h index 340524d995ac..15d3fa48b0e3 100644 --- a/drivers/net/ethernet/renesas/rswitch.h +++ b/drivers/net/ethernet/renesas/rswitch.h @@ -7,8 +7,10 @@ #ifndef __RSWITCH_H__ #define __RSWITCH_H__ =20 +#include #include #include +#include =20 #include "rcar_gen4_ptp.h" =20 @@ -221,7 +223,7 @@ enum rswitch_reg { FWMACTL1 =3D FWRO + 0x4634, FWMACTL2 =3D FWRO + 0x4638, FWMACTL3 =3D FWRO + 0x463c, - FWMACTL4 =3D FWRO + 0x4640, + FWMACTL40 =3D FWRO + 0x4640, FWMACTL5 =3D FWRO + 0x4650, FWMACTLR =3D FWRO + 0x4654, FWMACTIM =3D FWRO + 0x4660, @@ -249,7 +251,7 @@ enum rswitch_reg { FWVLANTL0 =3D FWRO + 0x4910, FWVLANTL1 =3D FWRO + 0x4914, FWVLANTL2 =3D FWRO + 0x4918, - FWVLANTL3 =3D FWRO + 0x4920, + FWVLANTL30 =3D FWRO + 0x4920, FWVLANTL4 =3D FWRO + 0x4930, FWVLANTLR =3D FWRO + 0x4934, FWVLANTIM =3D FWRO + 0x4940, @@ -508,7 +510,7 @@ enum rswitch_reg { EACTDQMLM =3D TARO + 0x010c, EAVCC =3D TARO + 0x0130, EAVTC =3D TARO + 0x0134, - EATTFC =3D TARO + 0x0138, + EARTFC =3D TARO + 0x0138, EACAEC =3D TARO + 0x0200, EACC =3D TARO + 0x0204, EACAIVC0 =3D TARO + 0x0220, @@ -729,6 +731,41 @@ enum rswitch_etha_mode { =20 #define EAMS_OPS_MASK EAMC_OPC_OPERATION =20 +/* bit field definitions for EAVCC and GWVCC */ +#define VEM GENMASK(18, 16) +#define VIM BIT(0) + +/* bit field definitions for EAVTC and GWVTC */ +#define STD BIT(31) +#define STP GENMASK(30, 28) +#define STV GENMASK(27, 16) +#define CTD BIT(15) +#define CTP GENMASK(14, 12) +#define CTV GENMASK(11, 0) + +/* bit field definitions for EARTFC and GWTTCF */ +#define UT BIT(8) +#define SCRT BIT(7) +#define SCT BIT(6) +#define CRT BIT(5) +#define CT BIT(4) +#define CSRT BIT(3) +#define CST BIT(2) +#define RT BIT(1) +#define NT BIT(0) + +/* bit field definitions for EARDQDC and GWRDQDC */ +#define DQD GENMASK(10, 0) +#define DES_RAM_DP 0x400 + +enum vlan_egress_mode { + NO_VLAN, + C_TAG_VLAN, + HW_C_TAG_VLAN, + SC_TAG_VLAN, + HW_SC_TAG_VLAN, +}; + #define EAVCC_VEM_SC_TAG (0x3 << 16) =20 #define MPIC_PIS GENMASK(2, 0) @@ -806,6 +843,22 @@ enum rswitch_gwca_mode { #define CABPPFLC_INIT_VALUE 0x00800080 =20 /* MFWD */ +#define FWGC_SVM GENMASK(1, 0) + +enum switch_vlan_mode { + NO_VLAN_MODE, + C_TAG, + SC_TAG, +}; + +/* FWCEPRC2 */ +#define FDMACSLFEF BIT(19) +#define FDMACUFEF BIT(3) + +/* FWCEPTC */ +#define EPCS GENMASK(17, 16) +#define EPCSD GENMASK(6, 0) + #define FWPC0(i) (FWPC00 + (i) * 0x10) #define FWPC0_LTHTA BIT(0) #define FWPC0_IP4UE BIT(3) @@ -816,10 +869,13 @@ enum rswitch_gwca_mode { #define FWPC0_IPDSA BIT(12) #define FWPC0_IPHLA BIT(18) #define FWPC0_MACDSA BIT(20) +#define FWPC0_MACRUDA BIT(21) #define FWPC0_MACSSA BIT(23) #define FWPC0_MACHLA BIT(26) #define FWPC0_MACHMA BIT(27) #define FWPC0_VLANSA BIT(28) +#define FWPC0_VLANRU BIT(29) +#define FWPC0_VLANRUS BIT(30) =20 #define FWPC1(i) (FWPC10 + (i) * 0x10) #define FWCP1_LTHFW GENMASK(16 + (RSWITCH_NUM_AGENTS - 1), 16) @@ -847,6 +903,98 @@ enum rswitch_gwca_mode { #define FWMACAGC_MACAGOG BIT(28) #define FWMACAGC_MACDESOG BIT(29) =20 +//FWMACTL0 +#define FWMACTL0_ED BIT(16) +#define FWMACTL0_HLD BIT(10) +#define FWMACTL0_DE BIT(9) +#define FWMACTL0_SL BIT(8) + +//FWMACTL3 +#define FWMACTL3_DSLV GENMASK(16 + RSWITCH_NUM_AGENTS - 1, 16) +#define FWMACTL3_SSLV GENMASK(RSWITCH_NUM_AGENTS - 1, 0) + +//FWMACTL4 +#define FWMACTL4(i) (FWMACTL40 + (i) * 4) +#define FWMACTL4_CSDL GENMASK(6, 0) + +//FWMACTL5 +#define FWMACTL5_CME BIT(21) +#define FWMACTL5_EME BIT(20) +#define FWMACTL5_IPU BIT(19) +#define FWMACTL5_IPV GENMASK(18, 16) +#define FWMACTL5_DV GENMASK(6, 0) + +//FWMACTLR +#define FWMACTLR_L BIT(31) +#define FWMACTLR_LCN GENMASK(25, 16) +#define FWMACTLR_LO BIT(3) +#define FWMACTLR_LEF BIT(2) +#define FWMACTLR_LSF BIT(1) +#define FWMACTLR_LF BIT(0) + +// FWVLANTEC +#define VLANTMUE GENMASK(28, 16) + +// FWVLANTL0 +#define VLANED BIT(16) +#define VLANHLDL BIT(10) +#define VLANSLL BIT(8) + +// FWVLANTL1 +#define VLANVIDL GENMASK(11, 0) + +// FWVLANTL2 +#define VLANSLVL GENMASK(6, 0) + +// FWVLANTL3 +#define FWVLANTL3(i) (FWVLANTL30 + (i) * 4) +#define VLANCSDL GENMASK(6, 0) + +// FWVLANTL4 +#define VLANCMEL BIT(21) +#define VLANEMEL BIT(20) +#define VLANIPUL BIT(19) +#define VLANIPVL GENMASK(18, 16) +#define VLANDVL GENMASK(6, 0) + +// FWVLANTLR +#define VLANTL BIT(31) +#define VLANLO BIT(3) +#define VLANLEF BIT(2) +#define VLANLSF BIT(1) +#define VLANLF BIT(0) + +// FWVLANTIM +#define VLANTR BIT(1) +#define VLANTIOG BIT(0) + +// FWVLANTEM +#define VLANTUEN GENMASK(28, 16) +#define VLANTEN GENAMSK(12, 0) + +// FWVLANTS +#define VLANVIDS GENMASK(11, 0) + +// FWVLANTSR0 +#define VLANTS BIT(31) +#define VLANHLDS BIT(10) +#define VLANSLS BIT(8) +#define VLANSNF BIT(1) +#define VLANSEF BIT(0) + +// FWVLANTSR1 +#define VLANSLVS GENMASK(6, 0) + +// FWVLANTSR2 +#define FWVLANTSR2(i) (FWVLANTSR20 + (i) * 4) + +// FWVLANTSR3 +#define VLANCMES BIT(21) +#define VLANEMES BIT(20) +#define VLANIPUS BIT(19) +#define VLANIPVS GENMASK(18, 16) +#define VLANDVS GENMASK(6, 0) + #define RSW_AGEING_CLK_PER_US 0x140 #define RSW_AGEING_TIME 300 =20 @@ -904,7 +1052,7 @@ enum DIE_DT { #define INFO1_DV(port_vector) ((u64)(port_vector) << 48ULL) =20 /* For reception */ -#define INFO1_SPN(port) ((u64)(port) << 36ULL) +#define SPN GENMASK_U64(38, 36) =20 /* For timestamp descriptor in dptrl (Byte 4 to 7) */ #define TS_DESC_TSUN(dptrl) ((dptrl) & GENMASK(7, 0)) --=20 2.43.0 From nobody Wed Apr 1 12:39:40 2026 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0F7323F0A9E; Tue, 31 Mar 2026 10:04:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774951466; cv=none; b=CqiZ81ilkyNoSr7NCeup9Jc+4FcPhIpLDrq3G2w6rDUmdDA1WwCzeTrk9zq4NR1RDLxoFsjFlQVeLTdtthPB+9R+v3AgsYV7I7yJz+sMwTJFWSzy19Y9GUz+X5Tvy+3EYrCa+IXXEUJIHi6NzfMvFUZ278hzfyeZ7Pq/SXum65s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774951466; c=relaxed/simple; bh=NIXrzKvYkeIbWECbz0RwNchfNNumhL29gSB9oSILpRY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=h80FZjMV0QjGcLIhFYjaHfm6wD3/6kWpWztTvDfy/AFjko3S+hP/AviywkUyyE78SM8/mMUt5cSYxKj8VA2qW3p+j1IY/ua3s3Id3VdvvIPfLgTal9Ri0Q8X6alY9S2+niJZxTFHOj6pwv/XjHFyFKOQ7rMimq3NQLsZBPOsxQs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com; spf=pass smtp.mailfrom=renesas.com; arc=none smtp.client-ip=210.160.252.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=renesas.com X-CSE-ConnectionGUID: UEdiFsCTTJGhfZC38w4Ohw== X-CSE-MsgGUID: lPw4jlY0QrOs8B/YPx00hg== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 31 Mar 2026 19:04:24 +0900 Received: from [127.0.1.1] (unknown [10.226.78.135]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 31ACF416C39F; Tue, 31 Mar 2026 19:04:20 +0900 (JST) From: Michael Dege Date: Tue, 31 Mar 2026 12:03:59 +0200 Subject: [PATCH net-next v3 05/13] net: renesas: rswitch: add exception path for packets with unknown dst MAC Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260331-rswitch_add_vlans-v3-5-c37f41b1c556@renesas.com> References: <20260331-rswitch_add_vlans-v3-0-c37f41b1c556@renesas.com> In-Reply-To: <20260331-rswitch_add_vlans-v3-0-c37f41b1c556@renesas.com> To: Yoshihiro Shimoda , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?q?Niklas_S=C3=B6derlund?= , Paul Barker Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Dege X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774951442; l=7215; i=michael.dege@renesas.com; s=20251023; h=from:subject:message-id; bh=NIXrzKvYkeIbWECbz0RwNchfNNumhL29gSB9oSILpRY=; b=VqQsy+7k4S1GCoWVm73R6cv9uQsvoDr3DLkm0R4i+V5opvkCiDeJYsn2YeFvVS0/K2dFViVLY WTY97fONsKaBD8z4zhbwIH1/rNvSQfiQkprnOZz+XO+SJWXUQZwQ31j X-Developer-Key: i=michael.dege@renesas.com; a=ed25519; pk=gu1rwIcCrAxNMv2I8fIfiQvt51xzZwnQy4Ua/DscQt8= Packets with unknown MAC address cannot be handled by the HW forwarding. These need to be forwarded, via an exception path, to the network driver. Creates a queue for the exeption path. Packets received with unknown src/dst address need to be passed to the CPU. The received packet does not have the correct source port information, this is derived from the descriptor and added to the new queue. The received packet is added to the new queue and sent to the CPU for MAC learning. The CPU will broadcast the received packet, to all ports. This is how the HW learns the new MAC address. Signed-off-by: Michael Dege --- drivers/net/ethernet/renesas/rswitch.h | 1 + drivers/net/ethernet/renesas/rswitch_main.c | 80 +++++++++++++++++++++++++= +--- 2 files changed, 74 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/renesas/rswitch.h b/drivers/net/ethernet/= renesas/rswitch.h index 15d3fa48b0e3..bf123b564ed1 100644 --- a/drivers/net/ethernet/renesas/rswitch.h +++ b/drivers/net/ethernet/renesas/rswitch.h @@ -1148,6 +1148,7 @@ struct rswitch_gwca { struct rswitch_gwca_queue *queues; int num_queues; struct rswitch_gwca_queue ts_queue; + struct rswitch_gwca_queue *l2_shared_rx_queue; DECLARE_BITMAP(used, RSWITCH_MAX_NUM_QUEUES); u32 tx_irq_bits[RSWITCH_NUM_IRQ_REGS]; u32 rx_irq_bits[RSWITCH_NUM_IRQ_REGS]; diff --git a/drivers/net/ethernet/renesas/rswitch_main.c b/drivers/net/ethe= rnet/renesas/rswitch_main.c index d404bc41bd1e..3c142fa3c810 100644 --- a/drivers/net/ethernet/renesas/rswitch_main.c +++ b/drivers/net/ethernet/renesas/rswitch_main.c @@ -680,6 +680,34 @@ static int rswitch_rxdmac_init(struct rswitch_private = *priv, unsigned int index) return rswitch_gwca_queue_ext_ts_format(ndev->dev.parent, priv, rdev->rx_= queue); } =20 +static int rswitch_shared_rx_queue_alloc(struct rswitch_private *priv) +{ + struct rswitch_gwca *gwca =3D &priv->gwca; + struct device *dev =3D &priv->pdev->dev; + + int err; + + gwca->l2_shared_rx_queue =3D rswitch_gwca_get(priv); + if (!gwca->l2_shared_rx_queue) + return -EBUSY; + + err =3D rswitch_gwca_queue_alloc(NULL, priv, gwca->l2_shared_rx_queue, fa= lse, RX_RING_SIZE); + if (err < 0) { + rswitch_gwca_put(priv, gwca->l2_shared_rx_queue); + return err; + } + + return rswitch_gwca_queue_ext_ts_format(dev, priv, gwca->l2_shared_rx_que= ue); +} + +static void rswitch_shared_rx_queue_free(struct rswitch_private *priv) +{ + struct rswitch_gwca *gwca =3D &priv->gwca; + + rswitch_gwca_queue_free(&priv->pdev->dev, gwca->l2_shared_rx_queue); + rswitch_gwca_put(priv, gwca->l2_shared_rx_queue); +} + static int rswitch_gwca_hw_init(struct rswitch_private *priv) { unsigned int i; @@ -717,6 +745,12 @@ static int rswitch_gwca_hw_init(struct rswitch_private= *priv) return err; } =20 + err =3D rswitch_shared_rx_queue_alloc(priv); + if (err < 0) { + rswitch_shared_rx_queue_free(priv); + return err; + } + return rswitch_gwca_change_mode(priv, GWMC_OPC_OPERATION); } =20 @@ -940,6 +974,7 @@ static int rswitch_poll(struct napi_struct *napi, int b= udget) rswitch_enadis_data_irq(priv, rdev->tx_queue->index, true); rswitch_enadis_data_irq(priv, rdev->rx_queue->index, true); } + rswitch_enadis_data_irq(priv, priv->gwca.l2_shared_rx_queue->index, true= ); spin_unlock_irqrestore(&priv->lock, flags); } =20 @@ -952,15 +987,31 @@ static int rswitch_poll(struct napi_struct *napi, int= budget) return 0; } =20 -static void rswitch_queue_interrupt(struct net_device *ndev) +static void rswitch_queue_interrupt(struct rswitch_private *priv, struct r= switch_gwca_queue *gq) { - struct rswitch_device *rdev =3D netdev_priv(ndev); + struct rswitch_ext_ts_desc *desc; + struct rswitch_device *rdev; + struct net_device *ndev; + u32 spn; + + if (gq->index =3D=3D priv->gwca.l2_shared_rx_queue->index) { + desc =3D &gq->rx_ring[gq->cur]; + spn =3D FIELD_GET(SPN, desc->info1); + ndev =3D priv->rdev[spn]->ndev; + rdev =3D netdev_priv(ndev); + gq->ndev =3D ndev; + rdev->rx_queue =3D gq; + } else { + rdev =3D netdev_priv(gq->ndev); + } + =20 if (napi_schedule_prep(&rdev->napi)) { - spin_lock(&rdev->priv->lock); - rswitch_enadis_data_irq(rdev->priv, rdev->tx_queue->index, false); - rswitch_enadis_data_irq(rdev->priv, rdev->rx_queue->index, false); - spin_unlock(&rdev->priv->lock); + spin_lock(&priv->lock); + rswitch_enadis_data_irq(priv, rdev->tx_queue->index, false); + rswitch_enadis_data_irq(priv, rdev->rx_queue->index, false); + rswitch_enadis_data_irq(priv, priv->gwca.l2_shared_rx_queue->index, fals= e); + spin_unlock(&priv->lock); __napi_schedule(&rdev->napi); } } @@ -978,7 +1029,7 @@ static irqreturn_t rswitch_data_irq(struct rswitch_pri= vate *priv, u32 *dis) continue; =20 rswitch_ack_data_irq(priv, gq->index); - rswitch_queue_interrupt(gq->ndev); + rswitch_queue_interrupt(priv, gq); } =20 return IRQ_HANDLED; @@ -1513,6 +1564,14 @@ static int rswitch_serdes_set_params(struct rswitch_= device *rdev) return phy_set_speed(rdev->serdes, rdev->etha->speed); } =20 +static void rswitch_etha_set_exception_path(struct rswitch_private *priv) +{ + iowrite32(FDMACUFEF, priv->addr + FWCEPRC2); + iowrite32(FIELD_PREP(EPCS, GWCA_INDEX) | + FIELD_PREP(EPCSD, priv->gwca.l2_shared_rx_queue->index), + priv->addr + FWCEPTC); +} + static int rswitch_ether_port_init_one(struct rswitch_device *rdev) { int err; @@ -1566,6 +1625,8 @@ static int rswitch_ether_port_init_all(struct rswitch= _private *priv) unsigned int i; int err; =20 + rswitch_etha_set_exception_path(priv); + rswitch_for_each_enabled_port(priv, i) { err =3D rswitch_ether_port_init_one(priv->rdev[i]); if (err) @@ -1616,6 +1677,7 @@ static int rswitch_open(struct net_device *ndev) bitmap_set(rdev->priv->opened_ports, rdev->port, 1); rswitch_enadis_data_irq(rdev->priv, rdev->tx_queue->index, true); rswitch_enadis_data_irq(rdev->priv, rdev->rx_queue->index, true); + rswitch_enadis_data_irq(rdev->priv, rdev->priv->gwca.l2_shared_rx_queue->= index, true); spin_unlock_irqrestore(&rdev->priv->lock, flags); =20 phy_start(ndev->phydev); @@ -1642,6 +1704,7 @@ static int rswitch_stop(struct net_device *ndev) spin_lock_irqsave(&rdev->priv->lock, flags); rswitch_enadis_data_irq(rdev->priv, rdev->tx_queue->index, false); rswitch_enadis_data_irq(rdev->priv, rdev->rx_queue->index, false); + rswitch_enadis_data_irq(rdev->priv, rdev->priv->gwca.l2_shared_rx_queue->= index, false); bitmap_clear(rdev->priv->opened_ports, rdev->port, 1); spin_unlock_irqrestore(&rdev->priv->lock, flags); =20 @@ -2166,6 +2229,9 @@ static int renesas_eth_sw_probe(struct platform_devic= e *pdev) priv->gwca.index =3D AGENT_INDEX_GWCA; priv->gwca.num_queues =3D min(RSWITCH_NUM_PORTS * NUM_QUEUES_PER_NDEV, RSWITCH_MAX_NUM_QUEUES); + /* One extra queue for L2 switch reception */ + priv->gwca.num_queues =3D min(priv->gwca.num_queues + 1, + RSWITCH_MAX_NUM_QUEUES); priv->gwca.queues =3D devm_kcalloc(&pdev->dev, priv->gwca.num_queues, sizeof(*priv->gwca.queues), GFP_KERNEL); if (!priv->gwca.queues) --=20 2.43.0 From nobody Wed Apr 1 12:39:40 2026 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DDBF03F1662; Tue, 31 Mar 2026 10:04:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774951470; cv=none; b=eAXea/yjUVBPauhO6/3ll80xdvdLyfPzpyw2PBY945GVPesXncY5wuutj9Fa5KRd3WTLu89wmava2UwdEG596i0QdSho3sEwqh37w778wd/tOSodhR7voaOgFd12Phi06AZDV2tTcVLD8uKVB5ShM4bOsCvWEIn1ABi1GvYPGoE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774951470; c=relaxed/simple; bh=iNxe+78/8LfJp0QgyF9JQQuVKOLxeDUsKgyPSJLqbQ0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CBZlutz5LUS7ALLj4J7qFAYGM8ytLHHAdkRNcHMxRJS/csQ6A5dQCqN3S/T2MVLujCF5Nl8N2yDkVzBDrF1XlE+txezfrZqFqrz+oEVsRFl02i949Qj7+RMZ5ThXqpVQ5fZidofFX6fxTKu2AQzsXbU9RS3gRhi8XhTtODd5Wsk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com; spf=pass smtp.mailfrom=renesas.com; arc=none smtp.client-ip=210.160.252.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=renesas.com X-CSE-ConnectionGUID: Do6nEv58T+W3Y6r9x4SA1g== X-CSE-MsgGUID: 3U9RsP6pT4+jIyxhm2dm6w== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 31 Mar 2026 19:04:27 +0900 Received: from [127.0.1.1] (unknown [10.226.78.135]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id BAFD4416C39F; Tue, 31 Mar 2026 19:04:24 +0900 (JST) From: Michael Dege Date: Tue, 31 Mar 2026 12:04:00 +0200 Subject: [PATCH net-next v3 06/13] net: renesas: rswitch: add forwarding rules for gwca Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260331-rswitch_add_vlans-v3-6-c37f41b1c556@renesas.com> References: <20260331-rswitch_add_vlans-v3-0-c37f41b1c556@renesas.com> In-Reply-To: <20260331-rswitch_add_vlans-v3-0-c37f41b1c556@renesas.com> To: Yoshihiro Shimoda , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?q?Niklas_S=C3=B6derlund?= , Paul Barker Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Dege X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774951442; l=1614; i=michael.dege@renesas.com; s=20251023; h=from:subject:message-id; bh=iNxe+78/8LfJp0QgyF9JQQuVKOLxeDUsKgyPSJLqbQ0=; b=Cy0fN8GLSdKuAI8N3y0cz88KRZaFVlthY+KiH4LruqgwEE/aGeMO4dvM+PakWe41UpGd0Xjua wKXW+t3xYkkC0N1+TCihUXz+2TwMHYEpFeaGvqxpoYVAgm2uBFmPWd6 X-Developer-Key: i=michael.dege@renesas.com; a=ed25519; pk=gu1rwIcCrAxNMv2I8fIfiQvt51xzZwnQy4Ua/DscQt8= Add rules to forward packets from the Ethernet ports to the CPU port (GWCA) using L2 forwarding instead of port forwarding. Signed-off-by: Michael Dege --- drivers/net/ethernet/renesas/rswitch_l2.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/net/ethernet/renesas/rswitch_l2.c b/drivers/net/ethern= et/renesas/rswitch_l2.c index 709524c8a5c4..cabf1f92ad0c 100644 --- a/drivers/net/ethernet/renesas/rswitch_l2.c +++ b/drivers/net/ethernet/renesas/rswitch_l2.c @@ -93,10 +93,32 @@ static void rswitch_update_l2_hw_forwarding(struct rswi= tch_private *priv) } } =20 +static void rswitch_update_l2_hw_forwarding_gwca(struct rswitch_private *p= riv) +{ + struct rswitch_device *rdev; + u32 fwpc0_set, fwpc0_clr, fwpc2_set, fwpc2_clr; + + fwpc0_clr =3D FWPC0_MACSSA | FWPC0_MACDSA | FWPC0_MACRUDA; + fwpc0_set =3D fwpc0_clr; + fwpc2_clr =3D FIELD_PREP(FWPC2_LTWFW, BIT(AGENT_INDEX_GWCA)); + fwpc2_set =3D fwpc2_clr; + + (priv->offload_brdev) ? (fwpc0_clr =3D 0, fwpc2_set =3D 0) + : (fwpc0_set =3D 0, fwpc2_set =3D 0); + + rswitch_modify(priv->addr, FWPC0(AGENT_INDEX_GWCA), fwpc0_clr, fwpc0_set); + + rswitch_for_all_ports(priv, rdev) { + rswitch_modify(priv->addr, FWPC2(rdev->etha->index), + fwpc2_clr, fwpc2_set); + } +} + void rswitch_update_l2_offload(struct rswitch_private *priv) { rswitch_update_l2_hw_learning(priv); rswitch_update_l2_hw_forwarding(priv); + rswitch_update_l2_hw_forwarding_gwca(priv); } =20 static void rswitch_update_offload_brdev(struct rswitch_private *priv) --=20 2.43.0 From nobody Wed Apr 1 12:39:40 2026 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 88CE43F20F1; Tue, 31 Mar 2026 10:04:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774951473; cv=none; b=sgEXKKoTqhQPk0YWsvQ7AB5PjeOniO1LPAhO5V/6iImjDO3C9N3s2IwU4Xjwe2RlrrAF+YPlikdcfkm07h6oGSaIIqla7HWb86RayV826DqdZ75gLsN3p6jFq7jVZXrUnoHhzgHg3N4705JV0SXDLaI6n9ljTY2A8gjiMZgsytM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774951473; c=relaxed/simple; bh=6edi9epqRQK97jgNLWH1B49uvX0IGGcIOTispn58OuI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kMRbj1ZWwzJpdk/09sjOq0ivg8e9Ub+g74aQwgs81ahEuKCw1SDqsTqS+V8nzczce2hlI34udwZNJM2PEh/Q9/n6rzaIUgkfYMoacJPbtbZX7J8v+lMnUlFVXL+3Uoo6cQ9wPUiBsS1V7FVY1S3U12PUn7F1+S71oKNmPEYBfPg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com; spf=pass smtp.mailfrom=renesas.com; arc=none smtp.client-ip=210.160.252.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=renesas.com X-CSE-ConnectionGUID: ZxFHVT1hREm57JX7WeXrxA== X-CSE-MsgGUID: 0Lq8zLQ3T02I44GWcV0niA== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 31 Mar 2026 19:04:31 +0900 Received: from [127.0.1.1] (unknown [10.226.78.135]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 4D539416C823; Tue, 31 Mar 2026 19:04:28 +0900 (JST) From: Michael Dege Date: Tue, 31 Mar 2026 12:04:01 +0200 Subject: [PATCH net-next v3 07/13] net: renesas: rswitch: make helper functions available to whole driver Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260331-rswitch_add_vlans-v3-7-c37f41b1c556@renesas.com> References: <20260331-rswitch_add_vlans-v3-0-c37f41b1c556@renesas.com> In-Reply-To: <20260331-rswitch_add_vlans-v3-0-c37f41b1c556@renesas.com> To: Yoshihiro Shimoda , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?q?Niklas_S=C3=B6derlund?= , Paul Barker Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Dege X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774951442; l=2846; i=michael.dege@renesas.com; s=20251023; h=from:subject:message-id; bh=6edi9epqRQK97jgNLWH1B49uvX0IGGcIOTispn58OuI=; b=5l8pTq8YmPCr3gt96lfagR107qh+ZkUZ0reP/e3etQ5UNKjWJ9dE/LKVftQ7o4qjJtGX4+rn1 G9E6amMKh6bD10J9yMTd2DPPOIBPzaC69GqKXgt7Rtprl/530Gyq10e X-Developer-Key: i=michael.dege@renesas.com; a=ed25519; pk=gu1rwIcCrAxNMv2I8fIfiQvt51xzZwnQy4Ua/DscQt8= These functions will be needed in L2 and vlan handling. Remove static declaration and add function prototype to rswitch.h. Signed-off-by: Michael Dege --- drivers/net/ethernet/renesas/rswitch.h | 6 ++++-- drivers/net/ethernet/renesas/rswitch_main.c | 12 ++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/renesas/rswitch.h b/drivers/net/ethernet/= renesas/rswitch.h index bf123b564ed1..ff2a84057f01 100644 --- a/drivers/net/ethernet/renesas/rswitch.h +++ b/drivers/net/ethernet/renesas/rswitch.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* Renesas Ethernet Switch device driver * - * Copyright (C) 2022-2025 Renesas Electronics Corporation + * Copyright (C) 2022-2026 Renesas Electronics Corporation */ =20 #ifndef __RSWITCH_H__ @@ -1218,5 +1218,7 @@ struct rswitch_private { =20 bool is_rdev(const struct net_device *ndev); void rswitch_modify(void __iomem *addr, enum rswitch_reg reg, u32 clear, u= 32 set); - +int rswitch_reg_wait(void __iomem *addr, u32 offs, u32 mask, u32 expected); +int rswitch_gwca_change_mode(struct rswitch_private *priv, enum rswitch_gw= ca_mode mode); +int rswitch_etha_change_mode(struct rswitch_etha *etha, enum rswitch_etha_= mode mode); #endif /* #ifndef __RSWITCH_H__ */ diff --git a/drivers/net/ethernet/renesas/rswitch_main.c b/drivers/net/ethe= rnet/renesas/rswitch_main.c index 3c142fa3c810..99c9bef14ca5 100644 --- a/drivers/net/ethernet/renesas/rswitch_main.c +++ b/drivers/net/ethernet/renesas/rswitch_main.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* Renesas Ethernet Switch device driver * - * Copyright (C) 2022-2025 Renesas Electronics Corporation + * Copyright (C) 2022-2026 Renesas Electronics Corporation */ =20 #include @@ -32,7 +32,7 @@ =20 #define RSWITCH_GPTP_OFFSET_S4 0x00018000 =20 -static int rswitch_reg_wait(void __iomem *addr, u32 offs, u32 mask, u32 ex= pected) +int rswitch_reg_wait(void __iomem *addr, u32 offs, u32 mask, u32 expected) { u32 val; =20 @@ -168,8 +168,8 @@ static int rswitch_fwd_init(struct rswitch_private *pri= v) } =20 /* Gateway CPU agent block (GWCA) */ -static int rswitch_gwca_change_mode(struct rswitch_private *priv, - enum rswitch_gwca_mode mode) +int rswitch_gwca_change_mode(struct rswitch_private *priv, + enum rswitch_gwca_mode mode) { int ret; =20 @@ -1153,8 +1153,8 @@ static int rswitch_gwca_ts_request_irqs(struct rswitc= h_private *priv) } =20 /* Ethernet TSN Agent block (ETHA) and Ethernet MAC IP block (RMAC) */ -static int rswitch_etha_change_mode(struct rswitch_etha *etha, - enum rswitch_etha_mode mode) +int rswitch_etha_change_mode(struct rswitch_etha *etha, + enum rswitch_etha_mode mode) { int ret; =20 --=20 2.43.0 From nobody Wed Apr 1 12:39:40 2026 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1903A3E8C78; Tue, 31 Mar 2026 10:04:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774951476; cv=none; b=RiYr6H/CYCeIEa+97Ar83x74OANUbQi8UaxOJL1KuNtCmRv3DEzBciQLq59o+M0kB4wnn2nMT66xsGKqep+n/32qp5ijVMDvF+2Rq1ZIMWtukfBPjF5XKK5pDRMJ99elok9Ef/EmkRb7bSKT40WUA97FpbdDPwfhtonwM8oQrVk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774951476; c=relaxed/simple; bh=td1I14EXlazWrIEBK/atTJgs/cbblMkCLk3f/CFOynk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hHVqrQo++UI7Rc5NtjLgHcnu6t/ULe0pPTZfgSE5EnxPdDu7o62S2SLjH6bkQDSS9GnFRq/1R+lfdTYfr57lgmduW46oCIksh1hSCuJkgU3V+Kl2Mjh90RSTsABOTrM8BjS32/YDIjbDYVECWGZx24430Ny+MuYjEjQRe34mmB4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com; spf=pass smtp.mailfrom=renesas.com; arc=none smtp.client-ip=210.160.252.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=renesas.com X-CSE-ConnectionGUID: e/4C8ROoRoi0I6n0PX1TcA== X-CSE-MsgGUID: 1Tc/wNM8Tj25pqqiKLwLkA== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 31 Mar 2026 19:04:34 +0900 Received: from [127.0.1.1] (unknown [10.226.78.135]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id D2D98416C823; Tue, 31 Mar 2026 19:04:31 +0900 (JST) From: Michael Dege Date: Tue, 31 Mar 2026 12:04:02 +0200 Subject: [PATCH net-next v3 08/13] net: renesas: rswitch: add basic vlan init to rswitch_fwd_init Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260331-rswitch_add_vlans-v3-8-c37f41b1c556@renesas.com> References: <20260331-rswitch_add_vlans-v3-0-c37f41b1c556@renesas.com> In-Reply-To: <20260331-rswitch_add_vlans-v3-0-c37f41b1c556@renesas.com> To: Yoshihiro Shimoda , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?q?Niklas_S=C3=B6derlund?= , Paul Barker Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Dege X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774951442; l=1893; i=michael.dege@renesas.com; s=20251023; h=from:subject:message-id; bh=td1I14EXlazWrIEBK/atTJgs/cbblMkCLk3f/CFOynk=; b=nh4FdZ9jgMtwPt+TAvBS6IVHnwktccVQazoJlBjnw9+3Mo8KaUjM+TRxBoEcVm1XfVJEdcxL6 dqxdB+URCDLALNecvl7aEptNyHK+2dCS8kZJDM4kK3j8Fmw6AXVWx9W X-Developer-Key: i=michael.dege@renesas.com; a=ed25519; pk=gu1rwIcCrAxNMv2I8fIfiQvt51xzZwnQy4Ua/DscQt8= Add basic vlan related register initialization. Signed-off-by: Michael Dege --- drivers/net/ethernet/renesas/rswitch_main.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/renesas/rswitch_main.c b/drivers/net/ethe= rnet/renesas/rswitch_main.c index 99c9bef14ca5..160b70997924 100644 --- a/drivers/net/ethernet/renesas/rswitch_main.c +++ b/drivers/net/ethernet/renesas/rswitch_main.c @@ -120,6 +120,7 @@ static int rswitch_fwd_init(struct rswitch_private *pri= v) u32 all_ports_mask =3D GENMASK(RSWITCH_NUM_AGENTS - 1, 0); unsigned int i; u32 reg_val; + int ret; =20 /* Start with empty configuration */ for (i =3D 0; i < RSWITCH_NUM_AGENTS; i++) { @@ -154,17 +155,27 @@ static int rswitch_fwd_init(struct rswitch_private *p= riv) } =20 /* For GWCA port, allow direct descriptor forwarding */ - rswitch_modify(priv->addr, FWPC1(priv->gwca.index), FWPC1_DDE, FWPC1_DDE); + rswitch_modify(priv->addr, FWPC1(priv->gwca.index), 0, FWPC1_DDE); =20 /* Initialize hardware L2 forwarding table */ =20 - /* Allow entire table to be used for "unsecure" entries */ + /* Allow entire table to be used for "un-secure" entries */ rswitch_modify(priv->addr, FWMACHEC, 0, FWMACHEC_MACHMUE_MASK); =20 /* Initialize MAC hash table */ iowrite32(FWMACTIM_MACTIOG, priv->addr + FWMACTIM); =20 - return rswitch_reg_wait(priv->addr, FWMACTIM, FWMACTIM_MACTIOG, 0); + ret =3D rswitch_reg_wait(priv->addr, FWMACTIM, FWMACTIM_MACTIOG, 0); + if (ret) + return ret; + + /* Allow entire VLAN table to be used for "un-secure" entries */ + iowrite32(VLANTMUE, priv->addr + FWVLANTEC); + + /* Initialize VLAN table */ + iowrite32(VLANTIOG, priv->addr + FWVLANTIM); + + return rswitch_reg_wait(priv->addr, FWVLANTIM, VLANTIOG, 0); } =20 /* Gateway CPU agent block (GWCA) */ --=20 2.43.0 From nobody Wed Apr 1 12:39:40 2026 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9D30C3E8C78; Tue, 31 Mar 2026 10:04:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774951480; cv=none; b=RQYm0aYpDh1YUc4n1+X1gaqTYM7nJZVPXcFEjWSYj+gvLLxOgNYNKiJLxu/FbcKjSZSgtiLcNlsC4u0h0NE7R++mZNQGS45YIWemRvU6BDOwS+hRK/3NCwWC0Iod+RHBw9FdSVJJrT+tiw54nQP94k4IRp1WKRJYIR5GtObeXrM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774951480; c=relaxed/simple; bh=tC+SG52R0mtloz5r9G0Wu1IxFfsNRk0HFBPss2jLDUc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LVWUKH7MWXGSNiO7MFO6diEaZWwyoCjcgTV/nCZALA8k3Q3LpQ6lcqMqqvqH4/FVN0Fd6jKmuBYhxHCQgBXojS6UEFF4aQaNQvcQU0vuCKBqEce633oZ5WzZC9tHCM/Cj0PwSLYc2ANUCskCuotNJHzS/KxhmI5bsqdm5PhBFys= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com; spf=pass smtp.mailfrom=renesas.com; arc=none smtp.client-ip=210.160.252.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=renesas.com X-CSE-ConnectionGUID: zXVdgTNZQEWw95OKvmQeuA== X-CSE-MsgGUID: RpL6pmDHTWC6T3jnDLW+tQ== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 31 Mar 2026 19:04:38 +0900 Received: from [127.0.1.1] (unknown [10.226.78.135]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 645CF416C823; Tue, 31 Mar 2026 19:04:35 +0900 (JST) From: Michael Dege Date: Tue, 31 Mar 2026 12:04:03 +0200 Subject: [PATCH net-next v3 09/13] net: renesas: rswitch: update port HW init Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260331-rswitch_add_vlans-v3-9-c37f41b1c556@renesas.com> References: <20260331-rswitch_add_vlans-v3-0-c37f41b1c556@renesas.com> In-Reply-To: <20260331-rswitch_add_vlans-v3-0-c37f41b1c556@renesas.com> To: Yoshihiro Shimoda , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?q?Niklas_S=C3=B6derlund?= , Paul Barker Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Dege X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774951442; l=2575; i=michael.dege@renesas.com; s=20251023; h=from:subject:message-id; bh=tC+SG52R0mtloz5r9G0Wu1IxFfsNRk0HFBPss2jLDUc=; b=KVAbd+7HxIeN1nS95czmWaNclhzgBWdbKOIC1OG2ZW0TZc8nHBEpFibJc6wfgMvuH4fF9vUU1 jdAUxtc3qYeBBit8cvazatbgeR7s/7+Cg7ac/K5UIxRI57IvXCrH6Hs X-Developer-Key: i=michael.dege@renesas.com; a=ed25519; pk=gu1rwIcCrAxNMv2I8fIfiQvt51xzZwnQy4Ua/DscQt8= Certain Ethernet and cpu port settings need to be updated for vlan support. Signed-off-by: Michael Dege --- drivers/net/ethernet/renesas/rswitch.h | 4 ---- drivers/net/ethernet/renesas/rswitch_main.c | 15 ++++++++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/renesas/rswitch.h b/drivers/net/ethernet/= renesas/rswitch.h index ff2a84057f01..42c8bbafa27d 100644 --- a/drivers/net/ethernet/renesas/rswitch.h +++ b/drivers/net/ethernet/renesas/rswitch.h @@ -766,8 +766,6 @@ enum vlan_egress_mode { HW_SC_TAG_VLAN, }; =20 -#define EAVCC_VEM_SC_TAG (0x3 << 16) - #define MPIC_PIS GENMASK(2, 0) #define MPIC_PIS_GMII 2 #define MPIC_PIS_XGMII 4 @@ -806,8 +804,6 @@ enum rswitch_gwca_mode { #define GWMTIRM_MTIOG BIT(0) #define GWMTIRM_MTR BIT(1) =20 -#define GWVCC_VEM_SC_TAG (0x3 << 16) - #define GWARIRM_ARIOG BIT(0) #define GWARIRM_ARR BIT(1) =20 diff --git a/drivers/net/ethernet/renesas/rswitch_main.c b/drivers/net/ethe= rnet/renesas/rswitch_main.c index 160b70997924..60bfa22cc412 100644 --- a/drivers/net/ethernet/renesas/rswitch_main.c +++ b/drivers/net/ethernet/renesas/rswitch_main.c @@ -735,8 +735,11 @@ static int rswitch_gwca_hw_init(struct rswitch_private= *priv) if (err < 0) return err; =20 - iowrite32(GWVCC_VEM_SC_TAG, priv->addr + GWVCC); - iowrite32(0, priv->addr + GWTTFC); + iowrite32(0, priv->addr + GWIRC); + iowrite32(FIELD_PREP(DQD, DES_RAM_DP), priv->addr + GWRDQDC0); + /* Drop frames with unknown tags */ + iowrite32(UT, priv->addr + GWTTFC); + iowrite32(lower_32_bits(priv->gwca.linkfix_table_dma), priv->addr + GWDCB= AC1); iowrite32(upper_32_bits(priv->gwca.linkfix_table_dma), priv->addr + GWDCB= AC0); iowrite32(lower_32_bits(priv->gwca.ts_queue.ring_dma), priv->addr + GWTDC= AC10); @@ -878,6 +881,7 @@ static bool rswitch_rx(struct net_device *ndev, int *qu= ota) limit =3D boguscnt; =20 desc =3D &gq->rx_ring[gq->cur]; + while ((desc->desc.die_dt & DT_MASK) !=3D DT_FEMPTY) { dma_rmb(); skb =3D rswitch_rx_handle_desc(ndev, gq, desc); @@ -1267,7 +1271,12 @@ static int rswitch_etha_hw_init(struct rswitch_etha = *etha, const u8 *mac) if (err < 0) return err; =20 - iowrite32(EAVCC_VEM_SC_TAG, etha->addr + EAVCC); + iowrite32(0, etha->addr + EAIRC); + iowrite32(FIELD_PREP(DQD, DES_RAM_DP), etha->addr + EATDQDC0); + + /* Drop frames with unknown tags */ + iowrite32(UT, etha->addr + EARTFC); + rswitch_rmac_setting(etha, mac); rswitch_etha_enable_mii(etha); =20 --=20 2.43.0 From nobody Wed Apr 1 12:39:40 2026 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BAC993EF0DC; Tue, 31 Mar 2026 10:04:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774951484; cv=none; b=uUzv53zChvHXn6a5pCY+GV1k/E6W/ORmsYtF13Wq10lOvwjniApoIQo2GieKTX0GWKHpULwkxnRP60PimDgDRRVEqAsmM2RLwKwr2cmHPON0RBAmcdv2sbSJAAFvXgQPKhs0nOpglEE7sOPUVQ76V5lUk7A/yFwRlMf1jABDLEw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774951484; c=relaxed/simple; bh=sQSaxlM7a5nZ2wZ0RK4jADV0oM5+2mN19pMlCn7V02g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pwmMQpmXsTWRVkyeCOqyoDX73sr86dZVxFUkUKiFoYOACCq7pItut7OnCeRkh+9Nmqqau4/6fj0TZCwZbAWcJR+2OzEn6zgvaSaWLIoUQHkh83EI8nhTlYs3Bf1c1j+lL7BgQ1JS0YtgcTojqZh9dBZWz1/WpXKNDNdjI34Nlhk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com; spf=pass smtp.mailfrom=renesas.com; arc=none smtp.client-ip=210.160.252.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=renesas.com X-CSE-ConnectionGUID: 1tg9J7aPQ3i3TGskGu2++w== X-CSE-MsgGUID: DzDCbSuYSpGqZVNtnqjv1w== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 31 Mar 2026 19:04:42 +0900 Received: from [127.0.1.1] (unknown [10.226.78.135]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id E89DA416C823; Tue, 31 Mar 2026 19:04:38 +0900 (JST) From: Michael Dege Date: Tue, 31 Mar 2026 12:04:04 +0200 Subject: [PATCH net-next v3 10/13] net: renesas: rswitch: clean up is_rdev rswitch_device checking Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260331-rswitch_add_vlans-v3-10-c37f41b1c556@renesas.com> References: <20260331-rswitch_add_vlans-v3-0-c37f41b1c556@renesas.com> In-Reply-To: <20260331-rswitch_add_vlans-v3-0-c37f41b1c556@renesas.com> To: Yoshihiro Shimoda , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?q?Niklas_S=C3=B6derlund?= , Paul Barker Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Dege X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774951442; l=2714; i=michael.dege@renesas.com; s=20251023; h=from:subject:message-id; bh=sQSaxlM7a5nZ2wZ0RK4jADV0oM5+2mN19pMlCn7V02g=; b=+ydQjzN8MJSEL4ZYiybVg8H5An+TYbfSxHKTpPkLS2OxjXmhSiLU/FpIxK0XiaFxW2cnefCH4 As/nZlTjxruCvTcvleiNaOkgk4zDfuKlW2HKvP6add5eJXIEcTpoevp X-Developer-Key: i=michael.dege@renesas.com; a=ed25519; pk=gu1rwIcCrAxNMv2I8fIfiQvt51xzZwnQy4Ua/DscQt8= Add null pointer checking for ndev and remove unnecessay rswitch_port_check() wrapper function. Signed-off-by: Michael Dege --- drivers/net/ethernet/renesas/rswitch_l2.c | 15 +++++---------- drivers/net/ethernet/renesas/rswitch_main.c | 2 +- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/renesas/rswitch_l2.c b/drivers/net/ethern= et/renesas/rswitch_l2.c index cabf1f92ad0c..ae3857ef9af6 100644 --- a/drivers/net/ethernet/renesas/rswitch_l2.c +++ b/drivers/net/ethernet/renesas/rswitch_l2.c @@ -158,11 +158,6 @@ static void rswitch_update_offload_brdev(struct rswitc= h_private *priv) rswitch_update_l2_offload(priv); } =20 -static bool rswitch_port_check(const struct net_device *ndev) -{ - return is_rdev(ndev); -} - static void rswitch_port_update_brdev(struct net_device *ndev, struct net_device *brdev) { @@ -199,7 +194,7 @@ static int rswitch_netdevice_event(struct notifier_bloc= k *nb, struct netdev_notifier_changeupper_info *info; struct net_device *brdev; =20 - if (!rswitch_port_check(ndev)) + if (!is_rdev(ndev)) return NOTIFY_DONE; if (event !=3D NETDEV_CHANGEUPPER) return NOTIFY_DONE; @@ -254,12 +249,12 @@ static int rswitch_switchdev_event(struct notifier_bl= ock *nb, =20 if (event =3D=3D SWITCHDEV_PORT_ATTR_SET) { ret =3D switchdev_handle_port_attr_set(ndev, ptr, - rswitch_port_check, + is_rdev, rswitch_port_attr_set); return notifier_from_errno(ret); } =20 - if (!rswitch_port_check(ndev)) + if (!is_rdev(ndev)) return NOTIFY_DONE; =20 return notifier_from_errno(-EOPNOTSUPP); @@ -278,11 +273,11 @@ static int rswitch_switchdev_blocking_event(struct no= tifier_block *nb, return -EOPNOTSUPP; case SWITCHDEV_PORT_ATTR_SET: ret =3D switchdev_handle_port_attr_set(ndev, ptr, - rswitch_port_check, + is_rdev, rswitch_port_attr_set); break; default: - if (!rswitch_port_check(ndev)) + if (!is_rdev(ndev)) return NOTIFY_DONE; ret =3D -EOPNOTSUPP; } diff --git a/drivers/net/ethernet/renesas/rswitch_main.c b/drivers/net/ethe= rnet/renesas/rswitch_main.c index 60bfa22cc412..fc2c9892aea0 100644 --- a/drivers/net/ethernet/renesas/rswitch_main.c +++ b/drivers/net/ethernet/renesas/rswitch_main.c @@ -1962,7 +1962,7 @@ static const struct net_device_ops rswitch_netdev_ops= =3D { =20 bool is_rdev(const struct net_device *ndev) { - return (ndev->netdev_ops =3D=3D &rswitch_netdev_ops); + return ndev && (ndev->netdev_ops =3D=3D &rswitch_netdev_ops); } =20 static int rswitch_get_ts_info(struct net_device *ndev, struct kernel_etht= ool_ts_info *info) --=20 2.43.0 From nobody Wed Apr 1 12:39:40 2026 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5255F3B6BEB; Tue, 31 Mar 2026 10:04:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774951487; cv=none; b=f3vW10SdK/SLQkNfizMx+yMZzuqYbVMeGLmPFMC48nQ2WRa8LGHFOkKg0VzVTxbcaVqWisOMC0vbm0Dy/+y8rYAKt2E61Now2PfwStn2w2xyRMF/QjZ1rIFSBCeurAd2V/cfHvQVs/oe/9HBs1kDaxkqoWbZmjGC43QXcA5uar4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774951487; c=relaxed/simple; bh=WAfBjqa3OGSnnHpoYPepB93JQeuYuGFIGvox+ouDe8I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=h/5Q8RBmDlVBgj6wvw7Rd+e5br7vO1ZyuqwG0KbJJQ3sySLtGRmuilLK6MY966fbrosVaBj8XB58tQN2ASPRK3mooUOtWv3UIipPq0+e06dRxohGmJ5vbZHI+CZEvPu2rODn5fF7FT5FVH+FU4WWlAje2WNJs7s9wayVV4Wvnis= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com; spf=pass smtp.mailfrom=renesas.com; arc=none smtp.client-ip=210.160.252.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=renesas.com X-CSE-ConnectionGUID: C3AB0Z6JQoGjIGppZ9sK5w== X-CSE-MsgGUID: n7ZO3+ebRjaGX03x/Vn3ww== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 31 Mar 2026 19:04:45 +0900 Received: from [127.0.1.1] (unknown [10.226.78.135]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 7F56D416C825; Tue, 31 Mar 2026 19:04:42 +0900 (JST) From: Michael Dege Date: Tue, 31 Mar 2026 12:04:05 +0200 Subject: [PATCH net-next v3 11/13] net: renesas: rswitch: add passing of rswitch_private into notifiers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260331-rswitch_add_vlans-v3-11-c37f41b1c556@renesas.com> References: <20260331-rswitch_add_vlans-v3-0-c37f41b1c556@renesas.com> In-Reply-To: <20260331-rswitch_add_vlans-v3-0-c37f41b1c556@renesas.com> To: Yoshihiro Shimoda , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?q?Niklas_S=C3=B6derlund?= , Paul Barker Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Dege X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774951442; l=5516; i=michael.dege@renesas.com; s=20251023; h=from:subject:message-id; bh=WAfBjqa3OGSnnHpoYPepB93JQeuYuGFIGvox+ouDe8I=; b=qYRpGJb7ED1mSnLQIoMxQUQv26gLEZK3aCG/cZaftfbYvaXxbE72nUWdnpZKiQtyzLex5w5k2 srSDq2Sro7XCabUYJA2Z5DuEfZX+vkiwvlqe/5CT7SsvTUz9hj0cdZJ X-Developer-Key: i=michael.dege@renesas.com; a=ed25519; pk=gu1rwIcCrAxNMv2I8fIfiQvt51xzZwnQy4Ua/DscQt8= Provide struct rswitch_private to notifiers. This will be needed to access the HW in the notification handlers. Signed-off-by: Michael Dege --- drivers/net/ethernet/renesas/rswitch.h | 5 ++++ drivers/net/ethernet/renesas/rswitch_l2.c | 45 ++++++++++++-------------= ---- drivers/net/ethernet/renesas/rswitch_l2.h | 6 ++-- drivers/net/ethernet/renesas/rswitch_main.c | 4 +-- 4 files changed, 28 insertions(+), 32 deletions(-) diff --git a/drivers/net/ethernet/renesas/rswitch.h b/drivers/net/ethernet/= renesas/rswitch.h index 42c8bbafa27d..6dfc53c6b985 100644 --- a/drivers/net/ethernet/renesas/rswitch.h +++ b/drivers/net/ethernet/renesas/rswitch.h @@ -1199,6 +1199,11 @@ struct rswitch_private { struct rswitch_etha etha[RSWITCH_NUM_PORTS]; struct rswitch_mfwd mfwd; =20 + /* Notifiers */ + struct notifier_block rswitch_netdevice_nb; + struct notifier_block rswitch_switchdev_nb; + struct notifier_block rswitch_switchdev_blocking_nb; + struct list_head port_list; =20 spinlock_t lock; /* lock interrupt registers' control */ diff --git a/drivers/net/ethernet/renesas/rswitch_l2.c b/drivers/net/ethern= et/renesas/rswitch_l2.c index ae3857ef9af6..f1c5c96027ba 100644 --- a/drivers/net/ethernet/renesas/rswitch_l2.c +++ b/drivers/net/ethernet/renesas/rswitch_l2.c @@ -285,48 +285,39 @@ static int rswitch_switchdev_blocking_event(struct no= tifier_block *nb, return notifier_from_errno(ret); } =20 -static struct notifier_block rswitch_netdevice_nb =3D { - .notifier_call =3D rswitch_netdevice_event, -}; - -static struct notifier_block rswitch_switchdev_nb =3D { - .notifier_call =3D rswitch_switchdev_event, -}; - -static struct notifier_block rswitch_switchdev_blocking_nb =3D { - .notifier_call =3D rswitch_switchdev_blocking_event, -}; - -int rswitch_register_notifiers(void) +int rswitch_register_notifiers(struct rswitch_private *priv) { - int ret; + int err; =20 - ret =3D register_netdevice_notifier(&rswitch_netdevice_nb); - if (ret) + priv->rswitch_netdevice_nb.notifier_call =3D rswitch_netdevice_event; + err =3D register_netdevice_notifier(&priv->rswitch_netdevice_nb); + if (err) goto register_netdevice_notifier_failed; =20 - ret =3D register_switchdev_notifier(&rswitch_switchdev_nb); - if (ret) + priv->rswitch_switchdev_nb.notifier_call =3D rswitch_switchdev_event; + err =3D register_switchdev_notifier(&priv->rswitch_switchdev_nb); + if (err) goto register_switchdev_notifier_failed; =20 - ret =3D register_switchdev_blocking_notifier(&rswitch_switchdev_blocking_= nb); - if (ret) + priv->rswitch_switchdev_blocking_nb.notifier_call =3D rswitch_switchdev_b= locking_event; + err =3D register_switchdev_blocking_notifier(&priv->rswitch_switchdev_blo= cking_nb); + if (err) goto register_switchdev_blocking_notifier_failed; =20 return 0; =20 register_switchdev_blocking_notifier_failed: - unregister_switchdev_notifier(&rswitch_switchdev_nb); + unregister_switchdev_notifier(&priv->rswitch_switchdev_nb); register_switchdev_notifier_failed: - unregister_netdevice_notifier(&rswitch_netdevice_nb); + unregister_netdevice_notifier(&priv->rswitch_netdevice_nb); register_netdevice_notifier_failed: =20 - return ret; + return err; } =20 -void rswitch_unregister_notifiers(void) +void rswitch_unregister_notifiers(struct rswitch_private *priv) { - unregister_switchdev_blocking_notifier(&rswitch_switchdev_blocking_nb); - unregister_switchdev_notifier(&rswitch_switchdev_nb); - unregister_netdevice_notifier(&rswitch_netdevice_nb); + unregister_switchdev_blocking_notifier(&priv->rswitch_switchdev_blocking_= nb); + unregister_switchdev_notifier(&priv->rswitch_switchdev_nb); + unregister_netdevice_notifier(&priv->rswitch_netdevice_nb); } diff --git a/drivers/net/ethernet/renesas/rswitch_l2.h b/drivers/net/ethern= et/renesas/rswitch_l2.h index 57050ede8f31..af9780c63c9a 100644 --- a/drivers/net/ethernet/renesas/rswitch_l2.h +++ b/drivers/net/ethernet/renesas/rswitch_l2.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* Renesas Ethernet Switch device driver * - * Copyright (C) 2025 Renesas Electronics Corporation + * Copyright (C) 2025 - 2026 Renesas Electronics Corporation */ =20 #ifndef __RSWITCH_L2_H__ @@ -9,7 +9,7 @@ =20 void rswitch_update_l2_offload(struct rswitch_private *priv); =20 -int rswitch_register_notifiers(void); -void rswitch_unregister_notifiers(void); +int rswitch_register_notifiers(struct rswitch_private *priv); +void rswitch_unregister_notifiers(struct rswitch_private *priv); =20 #endif /* #ifndef __RSWITCH_L2_H__ */ diff --git a/drivers/net/ethernet/renesas/rswitch_main.c b/drivers/net/ethe= rnet/renesas/rswitch_main.c index fc2c9892aea0..92dd372aaa20 100644 --- a/drivers/net/ethernet/renesas/rswitch_main.c +++ b/drivers/net/ethernet/renesas/rswitch_main.c @@ -2272,7 +2272,7 @@ static int renesas_eth_sw_probe(struct platform_devic= e *pdev) if (list_empty(&priv->port_list)) dev_warn(&pdev->dev, "could not initialize any ports\n"); =20 - ret =3D rswitch_register_notifiers(); + ret =3D rswitch_register_notifiers(priv); if (ret) { dev_err(&pdev->dev, "could not register notifiers\n"); return ret; @@ -2311,7 +2311,7 @@ static void renesas_eth_sw_remove(struct platform_dev= ice *pdev) { struct rswitch_private *priv =3D platform_get_drvdata(pdev); =20 - rswitch_unregister_notifiers(); + rswitch_unregister_notifiers(priv); rswitch_deinit(priv); =20 pm_runtime_put(&pdev->dev); --=20 2.43.0 From nobody Wed Apr 1 12:39:40 2026 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4C5923BED16; Tue, 31 Mar 2026 10:04:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774951491; cv=none; b=HpvFmJJnmbDsJWwPjwkmIU9ubzoqHRS5zEpagOsmw5w7Goe5PR0dB2bqw8S0ut7eMfvtlKEvveBldMrkeUTagqhkueH6ZuBkpQ4dtQShx2PEkYLyVQHcBLD4zhKHMuR0XFRBcVu3JDansIcEKWAFY9f9wrZ/A55/zLNYxkJo4FI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774951491; c=relaxed/simple; bh=3Lv1xwr4+L63Jy7K7ory2uKzTRGIdthOPGp5pOxxqZU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RmmagZvcQyb5kjYrWn0dSI/0VfIDhJwOndrN86CzSP/DTkWLCz8UDqr0G62ge2dLJC+2aU7GX1WaLtzX9XQhpfFQHORvjcsSW0eYQ+2sjarur0SV9bgD7Lof3Ce4UtwQdzAl/qtjHnQaSM0QngyGkEyo7HM8HrawVkQdCEIT+P0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com; spf=pass smtp.mailfrom=renesas.com; arc=none smtp.client-ip=210.160.252.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=renesas.com X-CSE-ConnectionGUID: hQ3ZbRB6S5u+CTRikRtlpA== X-CSE-MsgGUID: polP+duBRLikVxq9ZoLEpw== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 31 Mar 2026 19:04:49 +0900 Received: from [127.0.1.1] (unknown [10.226.78.135]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 102E4416C827; Tue, 31 Mar 2026 19:04:45 +0900 (JST) From: Michael Dege Date: Tue, 31 Mar 2026 12:04:06 +0200 Subject: [PATCH net-next v3 12/13] net: renesas: rswitch: add handler for FDB notification Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260331-rswitch_add_vlans-v3-12-c37f41b1c556@renesas.com> References: <20260331-rswitch_add_vlans-v3-0-c37f41b1c556@renesas.com> In-Reply-To: <20260331-rswitch_add_vlans-v3-0-c37f41b1c556@renesas.com> To: Yoshihiro Shimoda , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?q?Niklas_S=C3=B6derlund?= , Paul Barker Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Dege X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774951442; l=8841; i=michael.dege@renesas.com; s=20251023; h=from:subject:message-id; bh=3Lv1xwr4+L63Jy7K7ory2uKzTRGIdthOPGp5pOxxqZU=; b=L87QcBzIJbegNtxA/aWCh9BqTO73w9d5wdHQH6S52xUEAcWUy+huEeCXQ1AJuzDn0WXFY0na4 8egi1LyOmRNAfGNba3/jA2nKERaiz+Z38KojKfMitm7l6nZZwlaaITS X-Developer-Key: i=michael.dege@renesas.com; a=ed25519; pk=gu1rwIcCrAxNMv2I8fIfiQvt51xzZwnQy4Ua/DscQt8= The SWITCHDEV_FDB_ADD_TO_DEVICE notification writes the bridge MAC address to the GWCA and adds a static rule to the MAC table. The SWITCHDEV_FDB_DEL_TO_DEVICE removes the static rule from the MAC table. Signed-off-by: Michael Dege --- drivers/net/ethernet/renesas/rswitch.h | 8 ++ drivers/net/ethernet/renesas/rswitch_l2.c | 205 ++++++++++++++++++++++++++= ---- 2 files changed, 190 insertions(+), 23 deletions(-) diff --git a/drivers/net/ethernet/renesas/rswitch.h b/drivers/net/ethernet/= renesas/rswitch.h index 6dfc53c6b985..443fc4e49602 100644 --- a/drivers/net/ethernet/renesas/rswitch.h +++ b/drivers/net/ethernet/renesas/rswitch.h @@ -1217,6 +1217,14 @@ struct rswitch_private { enum hwtstamp_rx_filters tstamp_rx_ctrl; }; =20 +struct rswitch_switchdev_event_work { + struct work_struct work; + struct switchdev_notifier_fdb_info fdb_info; + struct net_device *ndev; + struct rswitch_private *priv; + unsigned long event; +}; + bool is_rdev(const struct net_device *ndev); void rswitch_modify(void __iomem *addr, enum rswitch_reg reg, u32 clear, u= 32 set); int rswitch_reg_wait(void __iomem *addr, u32 offs, u32 mask, u32 expected); diff --git a/drivers/net/ethernet/renesas/rswitch_l2.c b/drivers/net/ethern= et/renesas/rswitch_l2.c index f1c5c96027ba..ea95a87ed234 100644 --- a/drivers/net/ethernet/renesas/rswitch_l2.c +++ b/drivers/net/ethernet/renesas/rswitch_l2.c @@ -23,7 +23,8 @@ static bool rdev_for_l2_offload(struct rswitch_device *rd= ev) static void rswitch_change_l2_hw_offloading(struct rswitch_device *rdev, bool start, bool learning) { - u32 bits =3D learning ? FWPC0_MACSSA | FWPC0_MACHLA | FWPC0_MACHMA : FWPC= 0_MACDSA; + u32 bits =3D learning ? FWPC0_MACSSA | FWPC0_MACHLA | FWPC0_MACHMA | FWPC= 0_MACRUDA : + FWPC0_MACDSA; u32 clear =3D start ? 0 : bits; u32 set =3D start ? bits : 0; =20 @@ -82,8 +83,9 @@ static void rswitch_update_l2_hw_forwarding(struct rswitc= h_private *priv) * * Do not allow L2 forwarding to self for hw port. */ - iowrite32(FIELD_PREP(FWPC2_LTWFW, fwd_mask | BIT(rdev->port)), - priv->addr + FWPC2(rdev->port)); + rswitch_modify(priv->addr, FWPC2(rdev->port), + FIELD_PREP(FWPC2_LTWFW, ~(fwd_mask | BIT(rdev->port))), + 0); } =20 if (new_forwarding_offload && !rdev->forwarding_offloaded) @@ -188,7 +190,8 @@ static int rswitch_port_update_stp_state(struct net_dev= ice *ndev, u8 stp_state) } =20 static int rswitch_netdevice_event(struct notifier_block *nb, - unsigned long event, void *ptr) + unsigned long event, + void *ptr) { struct net_device *ndev =3D netdev_notifier_info_to_dev(ptr); struct netdev_notifier_changeupper_info *info; @@ -241,25 +244,6 @@ static int rswitch_port_attr_set(struct net_device *nd= ev, const void *ctx, } } =20 -static int rswitch_switchdev_event(struct notifier_block *nb, - unsigned long event, void *ptr) -{ - struct net_device *ndev =3D switchdev_notifier_info_to_dev(ptr); - int ret; - - if (event =3D=3D SWITCHDEV_PORT_ATTR_SET) { - ret =3D switchdev_handle_port_attr_set(ndev, ptr, - is_rdev, - rswitch_port_attr_set); - return notifier_from_errno(ret); - } - - if (!is_rdev(ndev)) - return NOTIFY_DONE; - - return notifier_from_errno(-EOPNOTSUPP); -} - static int rswitch_switchdev_blocking_event(struct notifier_block *nb, unsigned long event, void *ptr) { @@ -285,6 +269,181 @@ static int rswitch_switchdev_blocking_event(struct no= tifier_block *nb, return notifier_from_errno(ret); } =20 +static int rswitch_gwca_write_mac_address(struct rswitch_private *priv, co= nst u8 *mac) +{ + int err; + + err =3D rswitch_gwca_change_mode(priv, GWMC_OPC_CONFIG); + if (err < 0) + return err; + + iowrite32((mac[0] << 8) | mac[1], priv->addr + GWMAC0); + iowrite32((mac[2] << 24) | (mac[3] << 16) | (mac[4] << 8) | mac[5], + priv->addr + GWMAC1); + + return rswitch_gwca_change_mode(priv, GWMC_OPC_OPERATION); +} + +static int rswitch_add_addr_to_mactable(struct rswitch_private *priv, cons= t u8 *mac) +{ + u32 index =3D priv->gwca.l2_shared_rx_queue->index; + int err; + + rswitch_modify(priv->addr, FWMACTL0, FWMACTL0_ED, 0); + iowrite32((mac[0] << 8) | mac[1], priv->addr + FWMACTL1); + iowrite32((mac[2] << 24) | (mac[3] << 16) | (mac[4] << 8) | mac[5], + priv->addr + FWMACTL2); + iowrite32(FWMACTL3_DSLV | FWMACTL3_SSLV, + priv->addr + FWMACTL3); + iowrite32(FIELD_PREP(FWMACTL4_CSDL, index), + priv->addr + FWMACTL4(GWCA_INDEX)); + iowrite32(FIELD_PREP(FWMACTL5_DV, BIT(AGENT_INDEX_GWCA)), + priv->addr + FWMACTL5); + + err =3D rswitch_reg_wait(priv->addr, FWMACTLR, FWMACTLR_L, 0); + if (err < 0) + return err; + + if (ioread32(priv->addr + FWMACTLR)) + return NOTIFY_BAD; + + return NOTIFY_DONE; +} + +static int rswitch_del_addr_from_mactable(struct rswitch_private *priv, co= nst u8 *mac) +{ + int err; + + rswitch_modify(priv->addr, FWMACTL0, 0, FWMACTL0_ED); + iowrite32((mac[0] << 8) | mac[1], priv->addr + FWMACTL1); + iowrite32((mac[2] << 24) | (mac[3] << 16) | (mac[4] << 8) | mac[5], + priv->addr + FWMACTL2); + iowrite32(FWMACTL3_DSLV | FWMACTL3_SSLV, + priv->addr + FWMACTL3); + iowrite32(FIELD_PREP(FWMACTL4_CSDL, BIT(0)), + priv->addr + FWMACTL4(GWCA_INDEX)); + iowrite32(FIELD_PREP(FWMACTL5_DV, BIT(AGENT_INDEX_GWCA)), + priv->addr + FWMACTL5); + + err =3D rswitch_reg_wait(priv->addr, FWMACTLR, FWMACTLR_L, 0); + if (err < 0) + return err; + + err =3D ioread32(priv->addr + FWMACTLR); + if (err) + return NOTIFY_BAD; + + return NOTIFY_DONE; +} + +static void rswitch_switchdev_bridge_fdb_event_work(struct work_struct *wo= rk) +{ + struct rswitch_switchdev_event_work *switchdev_work; + struct rswitch_device *rdev; + struct net_device *ndev; + + switchdev_work =3D container_of(work, struct rswitch_switchdev_event_work= , work); + ndev =3D switchdev_work->ndev; + + rtnl_lock(); + + /* Unfortunately all net_device members point to br0, there is no simple = way to check + * if the event was triggered by a port device setting. + */ + rswitch_for_all_ports(switchdev_work->priv, rdev) { + if (ether_addr_equal(rdev->ndev->dev_addr, switchdev_work->fdb_info.addr= )) + goto out; + } + + /* Handle only bridge device */ + if (is_rdev(ndev)) + goto out; + + switch (switchdev_work->event) { + case SWITCHDEV_FDB_ADD_TO_DEVICE: + rswitch_gwca_write_mac_address(switchdev_work->priv, switchdev_work->fdb= _info.addr); + rswitch_add_addr_to_mactable(switchdev_work->priv, switchdev_work->fdb_i= nfo.addr); + break; + case SWITCHDEV_FDB_DEL_TO_DEVICE: + rswitch_del_addr_from_mactable(switchdev_work->priv, switchdev_work->fdb= _info.addr); + break; + default: + break; + } + +out: + rtnl_unlock(); + + kfree(switchdev_work->fdb_info.addr); + kfree(switchdev_work); + dev_put(ndev); +} + +/* called under rcu_read_lock() */ +static int rswitch_switchdev_event(struct notifier_block *nb, + unsigned long event, + void *ptr) +{ + struct net_device *ndev =3D switchdev_notifier_info_to_dev(ptr); + struct rswitch_switchdev_event_work *switchdev_work; + struct switchdev_notifier_fdb_info *fdb_info; + struct switchdev_notifier_info *info =3D ptr; + struct rswitch_private *priv; + int err; + + priv =3D container_of(nb, struct rswitch_private, rswitch_switchdev_nb); + + switch (event) { + case SWITCHDEV_FDB_ADD_TO_DEVICE: + fallthrough; + case SWITCHDEV_FDB_DEL_TO_DEVICE: + switchdev_work =3D kzalloc(sizeof(*switchdev_work), GFP_ATOMIC); + + if (!switchdev_work) + return NOTIFY_BAD; + + switchdev_work->ndev =3D info->dev; + switchdev_work->priv =3D priv; + switchdev_work->event =3D event; + + fdb_info =3D container_of(info, + struct switchdev_notifier_fdb_info, + info); + + INIT_WORK(&switchdev_work->work, rswitch_switchdev_bridge_fdb_event_work= ); + + memcpy(&switchdev_work->fdb_info, ptr, sizeof(switchdev_work->fdb_info)); + + switchdev_work->fdb_info.addr =3D kzalloc(ETH_ALEN, GFP_ATOMIC); + if (!switchdev_work->fdb_info.addr) + goto err_addr_alloc; + + ether_addr_copy((u8 *)switchdev_work->fdb_info.addr, + fdb_info->addr); + dev_hold(ndev); + queue_work(system_long_wq, &switchdev_work->work); + + break; + case SWITCHDEV_PORT_ATTR_SET: + err =3D switchdev_handle_port_attr_set(ndev, ptr, + is_rdev, + rswitch_port_attr_set); + return notifier_from_errno(err); + + if (!is_rdev(ndev)) + return NOTIFY_DONE; + + return notifier_from_errno(-EOPNOTSUPP); + } + + return NOTIFY_DONE; + +err_addr_alloc: + kfree(switchdev_work); + + return NOTIFY_BAD; +} + int rswitch_register_notifiers(struct rswitch_private *priv) { int err; --=20 2.43.0 From nobody Wed Apr 1 12:39:40 2026 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D2B1A3CCA16; Tue, 31 Mar 2026 10:04:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774951495; cv=none; b=CWbYega3lhuhCeV1AF9mg7/i5KMzSls8Mk3DhZm6Owny2ECF1DgfmOMr3L1sL5Q3OcldFb2K4lJOY7tFIr1F24cmUh8dOJWRwSJrgAV3MfGKOKM3oNz43J5war79JrkUdg9OhKUCUBzAhKsXorT8CurzCSkyq7Sg/73Wb4+OtCs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774951495; c=relaxed/simple; bh=VYRRItLBgOCi0ClLnqF5xeQ8XlkkFxVvkBLa4dcF7ZQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YQj+08ZSZ8YIzVzqgNWe5tj0vjyGH98uAg5Wn6RusV2STSBfqBLZViuT/QRHTp1Y/zTIX9HKnepkteGqopwYpx5Gfy1EDp6+j6AmRxJNh81NqxMivrLwwnU//CMRT0x5L7AXpCrtPP/Mp2BTIR1mPvJmYM0dAGB6OYLmz2tvI6U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com; spf=pass smtp.mailfrom=renesas.com; arc=none smtp.client-ip=210.160.252.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=renesas.com X-CSE-ConnectionGUID: gD5FOTcFS6a+mVutX1zB8A== X-CSE-MsgGUID: IXD9uUsQTziKM8hCWxwiUQ== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 31 Mar 2026 19:04:52 +0900 Received: from [127.0.1.1] (unknown [10.226.78.135]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 97544416C823; Tue, 31 Mar 2026 19:04:49 +0900 (JST) From: Michael Dege Date: Tue, 31 Mar 2026 12:04:07 +0200 Subject: [PATCH net-next v3 13/13] net: renesas: rswitch: add vlan aware switching Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260331-rswitch_add_vlans-v3-13-c37f41b1c556@renesas.com> References: <20260331-rswitch_add_vlans-v3-0-c37f41b1c556@renesas.com> In-Reply-To: <20260331-rswitch_add_vlans-v3-0-c37f41b1c556@renesas.com> To: Yoshihiro Shimoda , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?q?Niklas_S=C3=B6derlund?= , Paul Barker Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Dege X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774951442; l=15544; i=michael.dege@renesas.com; s=20251023; h=from:subject:message-id; bh=VYRRItLBgOCi0ClLnqF5xeQ8XlkkFxVvkBLa4dcF7ZQ=; b=bZuu+1ACxF4jbuuBw7SViXDjz9/Pf5FFjAnYkxEBHIPd8EAQA/kGupzbOGpqSrL/kpxo4YWgn WoGmtQDe/sODtHmpunKCZ/dT5xsmB24XRZF27ymtoaPCt1lWI5yjD1C X-Developer-Key: i=michael.dege@renesas.com; a=ed25519; pk=gu1rwIcCrAxNMv2I8fIfiQvt51xzZwnQy4Ua/DscQt8= Add vlan support to L2 HW bridge. On R-Car S4 there is limited vlan support, which is not fully 802.1Q compliant. The aim of this driver addition is to get as close as possible to the correct behavior. Limitations are: - all ports should be in the same default vlan - default vlans are not stripped on egress. Signed-off-by: Michael Dege --- drivers/net/ethernet/renesas/Kconfig | 1 + drivers/net/ethernet/renesas/rswitch_l2.c | 408 ++++++++++++++++++++++++++= ---- 2 files changed, 360 insertions(+), 49 deletions(-) diff --git a/drivers/net/ethernet/renesas/Kconfig b/drivers/net/ethernet/re= nesas/Kconfig index 9b7559c88bee..2494ff60e8c2 100644 --- a/drivers/net/ethernet/renesas/Kconfig +++ b/drivers/net/ethernet/renesas/Kconfig @@ -43,6 +43,7 @@ config RENESAS_ETHER_SWITCH tristate "Renesas Ethernet Switch support" depends on ARCH_RENESAS || COMPILE_TEST depends on PTP_1588_CLOCK + depends on BRIDGE || BRIDGE=3Dn select CRC32 select MII select PHYLINK diff --git a/drivers/net/ethernet/renesas/rswitch_l2.c b/drivers/net/ethern= et/renesas/rswitch_l2.c index ea95a87ed234..b7d0e7f94ecd 100644 --- a/drivers/net/ethernet/renesas/rswitch_l2.c +++ b/drivers/net/ethernet/renesas/rswitch_l2.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include =20 @@ -173,22 +174,6 @@ static void rswitch_port_update_brdev(struct net_devic= e *ndev, rswitch_update_offload_brdev(rdev->priv); } =20 -static int rswitch_port_update_stp_state(struct net_device *ndev, u8 stp_s= tate) -{ - struct rswitch_device *rdev; - - if (!is_rdev(ndev)) - return -ENODEV; - - rdev =3D netdev_priv(ndev); - rdev->learning_requested =3D (stp_state =3D=3D BR_STATE_LEARNING || - stp_state =3D=3D BR_STATE_FORWARDING); - rdev->forwarding_requested =3D (stp_state =3D=3D BR_STATE_FORWARDING); - rswitch_update_l2_offload(rdev->priv); - - return 0; -} - static int rswitch_netdevice_event(struct notifier_block *nb, unsigned long event, void *ptr) @@ -212,61 +197,397 @@ static int rswitch_netdevice_event(struct notifier_b= lock *nb, return NOTIFY_OK; } =20 -static int rswitch_update_ageing_time(struct net_device *ndev, clock_t tim= e) +static int rswitch_port_update_stp_state(struct net_device *ndev, u8 stp_s= tate) { - struct rswitch_device *rdev =3D netdev_priv(ndev); - u32 reg_val; + struct rswitch_device *rdev; =20 if (!is_rdev(ndev)) return -ENODEV; =20 + rdev =3D netdev_priv(ndev); + rdev->learning_requested =3D (stp_state =3D=3D BR_STATE_LEARNING || + stp_state =3D=3D BR_STATE_FORWARDING); + rdev->forwarding_requested =3D (stp_state =3D=3D BR_STATE_FORWARDING); + rswitch_update_l2_offload(rdev->priv); + + return 0; +} + +static int rswitch_update_ageing_time(struct rswitch_private *priv, clock_= t time) +{ + u32 reg_val; + if (!FIELD_FIT(FWMACAGC_MACAGT, time)) return -EINVAL; =20 reg_val =3D FIELD_PREP(FWMACAGC_MACAGT, time); reg_val |=3D FWMACAGC_MACAGE | FWMACAGC_MACAGSL; - iowrite32(reg_val, rdev->priv->addr + FWMACAGC); + iowrite32(reg_val, priv->addr + FWMACAGC); =20 return 0; } =20 -static int rswitch_port_attr_set(struct net_device *ndev, const void *ctx, - const struct switchdev_attr *attr, - struct netlink_ext_ack *extack) +static void rswitch_update_vlan_filtering(struct rswitch_private *priv, + bool vlan_filtering) +{ + if (vlan_filtering) + rswitch_modify(priv->addr, FWPC0(AGENT_INDEX_GWCA), + 0, FWPC0_VLANSA | FWPC0_VLANRU); + else + rswitch_modify(priv->addr, FWPC0(AGENT_INDEX_GWCA), + FWPC0_VLANSA | FWPC0_VLANRU, 0); +} + +static int rswitch_handle_port_attr_set(struct net_device *ndev, + struct notifier_block *nb, + struct switchdev_notifier_port_attr_info *info) { + const struct switchdev_attr *attr =3D info->attr; + struct rswitch_private *priv; + int err =3D 0; + + priv =3D container_of(nb, struct rswitch_private, rswitch_switchdev_block= ing_nb); + switch (attr->id) { case SWITCHDEV_ATTR_ID_PORT_STP_STATE: - return rswitch_port_update_stp_state(ndev, attr->u.stp_state); + err =3D rswitch_port_update_stp_state(ndev, attr->u.stp_state); + + break; case SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME: - return rswitch_update_ageing_time(ndev, attr->u.ageing_time); + err =3D rswitch_update_ageing_time(priv, attr->u.ageing_time); + + break; + case SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING: + rswitch_update_vlan_filtering(priv, attr->u.vlan_filtering); + + break; + case SWITCHDEV_ATTR_ID_BRIDGE_MC_DISABLED: + + break; + default: + return -EOPNOTSUPP; + } + + if (err < 0) + return err; + + info->handled =3D true; + + return NOTIFY_DONE; +} + +static int rswitch_read_vlan_table(struct rswitch_private *priv, u16 vid, + u32 *vlanslvs, u32 *vlandvs) +{ + int err; + + iowrite32(FIELD_PREP(VLANVIDS, vid), priv->addr + FWVLANTS); + err =3D rswitch_reg_wait(priv->addr, FWVLANTSR0, VLANTS, 0); + if (err < 0) + return err; + + /* check if vlans are present in table */ + if (!(ioread32(priv->addr + FWVLANTSR0) & VLANSNF)) { + *vlanslvs =3D (ioread32(priv->addr + FWVLANTSR1) & VLANSLVS); + *vlandvs =3D (ioread32(priv->addr + FWVLANTSR3) & VLANDVS); + } + + return 0; +} + +static int rswitch_write_vlan_table(struct rswitch_private *priv, u16 vid,= u32 index) +{ + u32 vlancsdl =3D priv->gwca.l2_shared_rx_queue->index; + u32 vlanslvs =3D 0, vlandvs =3D 0; + int err; + + err =3D rswitch_read_vlan_table(priv, vid, &vlanslvs, &vlandvs); + if (err < 0) + return err; + + rswitch_modify(priv->addr, FWVLANTL0, VLANED, 0); + iowrite32(FIELD_PREP(VLANVIDL, vid), priv->addr + FWVLANTL1); + + vlanslvs |=3D BIT(index); + vlandvs |=3D BIT(index); + iowrite32(FIELD_PREP(VLANSLVL, vlanslvs), priv->addr + FWVLANTL2); + iowrite32(FIELD_PREP(VLANCSDL, vlancsdl), priv->addr + FWVLANTL3(GWCA_IND= EX)); + iowrite32(FIELD_PREP(VLANDVL, vlandvs), priv->addr + FWVLANTL4); + + return rswitch_reg_wait(priv->addr, FWVLANTLR, VLANTL, 0); +} + +static int rswitch_erase_vlan_table(struct rswitch_private *priv, u16 vid,= u32 index) +{ + u32 vlanslvs =3D 0, vlandvs =3D 0; + int err; + + err =3D rswitch_read_vlan_table(priv, vid, &vlanslvs, &vlandvs); + if (err < 0) + return err; + + vlanslvs &=3D ~BIT(index); + vlandvs &=3D ~BIT(index); + + /* only erase empty vlan table entries */ + if (vlanslvs =3D=3D 0) + rswitch_modify(priv->addr, FWVLANTL0, 0, VLANED); + + iowrite32(FIELD_PREP(VLANVIDL, vid), priv->addr + FWVLANTL1); + iowrite32(FIELD_PREP(VLANSLVL, vlanslvs), priv->addr + FWVLANTL2); + iowrite32(FIELD_PREP(VLANDVL, vlandvs), priv->addr + FWVLANTL4); + + return rswitch_reg_wait(priv->addr, FWVLANTLR, VLANTL, 0); +} + +static int rswitch_port_set_vlan_tag(struct rswitch_etha *etha, + struct switchdev_obj_port_vlan *p_vlan, + bool delete) +{ + u32 vem_val; + int err; + + err =3D rswitch_etha_change_mode(etha, EAMC_OPC_CONFIG); + if (err < 0) + return err; + + rswitch_modify(etha->addr, EAVCC, VIM, 0); + + if (((ioread32(etha->addr + EAVTC) & CTV) =3D=3D p_vlan->vid) && delete) { + rswitch_modify(etha->addr, EAVTC, CTV, 0); + rswitch_modify(etha->addr, EAVCC, VEM, 0); + } else if (!delete) { + if ((p_vlan->flags & BRIDGE_VLAN_INFO_PVID) && + (p_vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED)) + vem_val =3D FIELD_PREP(VEM, C_TAG_VLAN); + else if (p_vlan->flags & BRIDGE_VLAN_INFO_PVID) + vem_val =3D FIELD_PREP(VEM, HW_C_TAG_VLAN); + else + vem_val =3D 0; + rswitch_modify(etha->addr, EAVCC, VEM, vem_val); + rswitch_modify(etha->addr, EAVTC, CTV, FIELD_PREP(CTV, p_vlan->vid)); + } + + return rswitch_etha_change_mode(etha, EAMC_OPC_OPERATION); +} + +static int rswitch_gwca_set_vlan_tag(struct rswitch_private *priv, + struct switchdev_obj_port_vlan *p_vlan, + bool delete) +{ + u32 vem_val; + int err; + + err =3D rswitch_gwca_change_mode(priv, GWMC_OPC_CONFIG); + if (err < 0) + return err; + + rswitch_modify(priv->addr, GWVCC, VIM, 0); + + if (((ioread32(priv->addr + GWVTC) & CTV) =3D=3D p_vlan->vid) && delete) { + rswitch_modify(priv->addr, GWVTC, CTV, 0); + rswitch_modify(priv->addr, GWVCC, VEM, 0); + } else if (!delete) { + if ((p_vlan->flags & BRIDGE_VLAN_INFO_PVID) && + (p_vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED)) + vem_val =3D FIELD_PREP(VEM, C_TAG_VLAN); + else if (p_vlan->flags & BRIDGE_VLAN_INFO_PVID) + vem_val =3D FIELD_PREP(VEM, HW_C_TAG_VLAN); + else + vem_val =3D 0; + rswitch_modify(priv->addr, GWVCC, VEM, vem_val); + rswitch_modify(priv->addr, GWVTC, CTV, FIELD_PREP(CTV, p_vlan->vid)); + } + + return rswitch_gwca_change_mode(priv, GWMC_OPC_OPERATION); +} + +static int rswitch_port_obj_do_add(struct net_device *ndev, + struct switchdev_obj_port_vlan *p_vlan) +{ + struct rswitch_device *rdev =3D netdev_priv(ndev); + struct rswitch_private *priv =3D rdev->priv; + struct rswitch_etha *etha =3D rdev->etha; + int err; + + /* Set Rswitch VLAN mode */ + iowrite32(br_vlan_enabled(rdev->brdev) ? FIELD_PREP(FWGC_SVM, C_TAG) : 0, + priv->addr + FWGC); + + err =3D rswitch_write_vlan_table(priv, p_vlan->vid, etha->index); + if (err < 0) + return err; + + /* If the default vlan for this port has been set, don't overwrite it. */ + if (ioread32(etha->addr + EAVCC)) + return NOTIFY_DONE; + + if (br_vlan_enabled(rdev->brdev)) + rswitch_modify(priv->addr, FWPC0(etha->index), 0, FWPC0_VLANSA | FWPC0_V= LANRU); + + rswitch_modify(priv->addr, FWPC2(AGENT_INDEX_GWCA), + FIELD_PREP(FWPC2_LTWFW, BIT(etha->index)), + 0); + + return rswitch_port_set_vlan_tag(etha, p_vlan, false); +} + +static int rswitch_port_obj_do_add_gwca(struct net_device *ndev, + struct rswitch_private *priv, + struct switchdev_obj_port_vlan *p_vlan) +{ + int err; + + if (!(p_vlan->flags & BRIDGE_VLAN_INFO_BRENTRY)) + return NOTIFY_DONE; + + /* Set Rswitch VLAN mode */ + iowrite32(br_vlan_enabled(ndev) ? FIELD_PREP(FWGC_SVM, C_TAG) : 0, priv->= addr + FWGC); + + err =3D rswitch_write_vlan_table(priv, p_vlan->vid, AGENT_INDEX_GWCA); + if (err < 0) + return err; + + /* If the default vlan for this port has been set, don't overwrite it. */ + if (ioread32(priv->addr + GWVCC)) + return NOTIFY_DONE; + + return rswitch_gwca_set_vlan_tag(priv, p_vlan, false); +} + +static int rswitch_port_obj_do_del(struct net_device *ndev, + struct switchdev_obj_port_vlan *p_vlan) +{ + struct rswitch_device *rdev =3D netdev_priv(ndev); + struct rswitch_private *priv =3D rdev->priv; + struct rswitch_etha *etha =3D rdev->etha; + int err; + + err =3D rswitch_port_set_vlan_tag(etha, p_vlan, true); + if (err < 0) + return err; + + rswitch_modify(priv->addr, FWPC0(etha->index), FWPC0_VLANSA | FWPC0_VLANR= U, 0); + rswitch_modify(priv->addr, FWPC2(AGENT_INDEX_GWCA), 0, + FIELD_PREP(FWPC2_LTWFW, BIT(etha->index))); + rswitch_modify(priv->addr, FWPC2(rdev->port), + 0, FIELD_PREP(FWPC2_LTWFW, GENMASK(RSWITCH_NUM_AGENTS - 1, 0))); + + return rswitch_erase_vlan_table(priv, p_vlan->vid, etha->index); +} + +static int rswitch_port_obj_do_del_gwca(struct net_device *ndev, + struct rswitch_private *priv, + struct switchdev_obj_port_vlan *p_vlan) +{ + int err; + + err =3D rswitch_gwca_set_vlan_tag(priv, p_vlan, true); + if (err < 0) + return err; + + rswitch_modify(priv->addr, FWPC0(AGENT_INDEX_GWCA), + FWPC0_VLANSA | FWPC0_VLANRU, + 0); + + return rswitch_erase_vlan_table(priv, p_vlan->vid, AGENT_INDEX_GWCA); +} + +static int rswitch_handle_port_obj_add(struct net_device *ndev, + struct notifier_block *nb, + struct switchdev_notifier_port_obj_info *info) +{ + struct switchdev_obj_port_vlan *p_vlan =3D SWITCHDEV_OBJ_PORT_VLAN(info->= obj); + struct rswitch_private *priv; + int err; + + priv =3D container_of(nb, struct rswitch_private, rswitch_switchdev_block= ing_nb); + + if ((p_vlan->flags & BRIDGE_VLAN_INFO_MASTER) || + (p_vlan->flags & BRIDGE_VLAN_INFO_RANGE_BEGIN) || + (p_vlan->flags & BRIDGE_VLAN_INFO_RANGE_END) || + (p_vlan->flags & BRIDGE_VLAN_INFO_ONLY_OPTS)) + return NOTIFY_DONE; + + switch (info->obj->id) { + case SWITCHDEV_OBJ_ID_PORT_VLAN: + if (!is_rdev(ndev)) + err =3D rswitch_port_obj_do_add_gwca(ndev, priv, p_vlan); + else + err =3D rswitch_port_obj_do_add(ndev, p_vlan); + + if (err < 0) + return err; + + break; default: return -EOPNOTSUPP; } + + info->handled =3D true; + + return NOTIFY_DONE; +} + +static int rswitch_handle_port_obj_del(struct net_device *ndev, + struct notifier_block *nb, + struct switchdev_notifier_port_obj_info *info) +{ + struct switchdev_obj_port_vlan *p_vlan =3D SWITCHDEV_OBJ_PORT_VLAN(info->= obj); + struct rswitch_private *priv; + int err; + + priv =3D container_of(nb, struct rswitch_private, rswitch_switchdev_block= ing_nb); + + if ((p_vlan->flags & BRIDGE_VLAN_INFO_MASTER) || + (p_vlan->flags & BRIDGE_VLAN_INFO_RANGE_BEGIN) || + (p_vlan->flags & BRIDGE_VLAN_INFO_RANGE_END) || + (p_vlan->flags & BRIDGE_VLAN_INFO_ONLY_OPTS)) + return NOTIFY_DONE; + + switch (info->obj->id) { + case SWITCHDEV_OBJ_ID_PORT_VLAN: + if (!is_rdev(ndev)) + err =3D rswitch_port_obj_do_del_gwca(ndev, priv, p_vlan); + else + err =3D rswitch_port_obj_do_del(ndev, p_vlan); + + if (err < 0) + return err; + + break; + default: + return -EOPNOTSUPP; + } + + info->handled =3D true; + + return NOTIFY_DONE; } =20 static int rswitch_switchdev_blocking_event(struct notifier_block *nb, - unsigned long event, void *ptr) + unsigned long event, + void *ptr) { struct net_device *ndev =3D switchdev_notifier_info_to_dev(ptr); - int ret; + int err; =20 switch (event) { case SWITCHDEV_PORT_OBJ_ADD: - return -EOPNOTSUPP; + err =3D rswitch_handle_port_obj_add(ndev, nb, ptr); + + return notifier_from_errno(err); case SWITCHDEV_PORT_OBJ_DEL: - return -EOPNOTSUPP; + err =3D rswitch_handle_port_obj_del(ndev, nb, ptr); + + return notifier_from_errno(err); case SWITCHDEV_PORT_ATTR_SET: - ret =3D switchdev_handle_port_attr_set(ndev, ptr, - is_rdev, - rswitch_port_attr_set); - break; - default: - if (!is_rdev(ndev)) - return NOTIFY_DONE; - ret =3D -EOPNOTSUPP; + err =3D rswitch_handle_port_attr_set(ndev, nb, ptr); + + return notifier_from_errno(err); } =20 - return notifier_from_errno(ret); + return NOTIFY_DONE; } =20 static int rswitch_gwca_write_mac_address(struct rswitch_private *priv, co= nst u8 *mac) @@ -389,7 +710,6 @@ static int rswitch_switchdev_event(struct notifier_bloc= k *nb, struct switchdev_notifier_fdb_info *fdb_info; struct switchdev_notifier_info *info =3D ptr; struct rswitch_private *priv; - int err; =20 priv =3D container_of(nb, struct rswitch_private, rswitch_switchdev_nb); =20 @@ -424,16 +744,6 @@ static int rswitch_switchdev_event(struct notifier_blo= ck *nb, queue_work(system_long_wq, &switchdev_work->work); =20 break; - case SWITCHDEV_PORT_ATTR_SET: - err =3D switchdev_handle_port_attr_set(ndev, ptr, - is_rdev, - rswitch_port_attr_set); - return notifier_from_errno(err); - - if (!is_rdev(ndev)) - return NOTIFY_DONE; - - return notifier_from_errno(-EOPNOTSUPP); } =20 return NOTIFY_DONE; --=20 2.43.0