From nobody Sat Jun 13 03:33:03 2026 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 061E63C3C0B; Mon, 11 May 2026 08:57:40 +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=1778489862; cv=none; b=mETPf9t54Ui6MbOYphi6z1lyn6eny7lb74DJ4pzMfxk4a9zexnDPSqM59Fy+UTv6z51IwoHwGSen58MmbkHhGmfunkKgG0rpAiEW5O7vtcyBLMtI2f1e2n4KL0lNvgqsvuIwjIGIYfukV7H0sxZmzEBCwnIriMXoZxFKr+T/oMA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778489862; c=relaxed/simple; bh=3lkr+RE11y4eF24FLC88bvRLrDKItySrEf6pwuvS2n8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YOczF4JzUc/bLSqCW7XvOMTXPmBraMlcMN6fcNr9BUoFj0/MJ1Im4HeG9/pXXyBvaJbYEGPpu6nRMILTzLbZc0tAxvQDxUIXaISxHhBm+vURLMlVWDB62wdSZz0zFl4NTp2UHs/395NRRX+TDl95BTLpL8mv8huyAgpq+vx/6C8= 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: MF6PMOYrRAOmIzw67suatg== X-CSE-MsgGUID: LkMrMzCLQzyqFxj/zmNqFg== Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 11 May 2026 17:52:31 +0900 Received: from [127.0.1.1] (unknown [10.226.78.135]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 9AA1C4009A31; Mon, 11 May 2026 17:52:28 +0900 (JST) From: Michael Dege Date: Mon, 11 May 2026 10:52:04 +0200 Subject: [PATCH net-next v4 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: <20260511-rswitch_add_vlans-v4-1-a5a225f8faae@renesas.com> References: <20260511-rswitch_add_vlans-v4-0-a5a225f8faae@renesas.com> In-Reply-To: <20260511-rswitch_add_vlans-v4-0-a5a225f8faae@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=1778489544; l=3593; i=michael.dege@renesas.com; s=20251023; h=from:subject:message-id; bh=3lkr+RE11y4eF24FLC88bvRLrDKItySrEf6pwuvS2n8=; b=vsTl+CtPIXCaSOxiE8LfnywK/aJMXln7+/W4itStZchqG/ihgu2vdMlzOd0WbO/HC2vJC5wlZ mRZ/nSaM/BgBszhLJtTx9mpLxGMFkqCZmXNpUg9b+snyyMYJXr8kSHW 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 | 43 +++++++++++++++----------= ---- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/drivers/net/ethernet/renesas/rswitch_main.c b/drivers/net/ethe= rnet/renesas/rswitch_main.c index 6fe964816322..9b739594cc02 100644 --- a/drivers/net/ethernet/renesas/rswitch_main.c +++ b/drivers/net/ethernet/renesas/rswitch_main.c @@ -176,14 +176,21 @@ 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); + if (ret < 0) + return ret; =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 +689,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 +721,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 +728,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 +1114,20 @@ 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); + if (ret < 0) + return ret; =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 +1207,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 Sat Jun 13 03:33:03 2026 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F35583C552D; Mon, 11 May 2026 08:57:42 +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=1778489864; cv=none; b=ST/SqJLnkvzs5k/8xQToc/5PCA3hI2TQJxwwI4iyZqNCB1vsIAG2qWV+odKkcqWimUcz21oXiu+Mn8XqthegxCyETI24KfrPMjuKPixZbW/EE3Mr5yiBDhx66JLLBuSwzSOxlz/5eNADYML2vec6G68RtyMt9qZLajxYo8t+BDE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778489864; c=relaxed/simple; bh=NqiXDt44KexY4kBU8hsHB66tQB6ItpiVhLKQdkRX0/A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DIf+Qmd/aJiJvX54d+h5DF4YqxLIGoKagWR0i2YaGYBGBwrxAe1Uwptk3MkEoZsSotSECH43otlTOc5rA1SYWSJHuwxO72QKaKf+GceaAz2Lmxa0BKzGLnsKu220druOgL4frG+rU2iAPMPU512nr90D4dO8ikH3ptVfzGiaBoQ= 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: YM0Qp+gSTciBQmAqAsA0yw== X-CSE-MsgGUID: ZcJ0yWRCThulOt2opA0GDg== Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 11 May 2026 17:52:35 +0900 Received: from [127.0.1.1] (unknown [10.226.78.135]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 2DAB14009A31; Mon, 11 May 2026 17:52:31 +0900 (JST) From: Michael Dege Date: Mon, 11 May 2026 10:52:05 +0200 Subject: [PATCH net-next v4 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: <20260511-rswitch_add_vlans-v4-2-a5a225f8faae@renesas.com> References: <20260511-rswitch_add_vlans-v4-0-a5a225f8faae@renesas.com> In-Reply-To: <20260511-rswitch_add_vlans-v4-0-a5a225f8faae@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=1778489544; l=6218; i=michael.dege@renesas.com; s=20251023; h=from:subject:message-id; bh=NqiXDt44KexY4kBU8hsHB66tQB6ItpiVhLKQdkRX0/A=; b=I54C62NeldiXEn+yeMBBqwPXz1NU2L4dzfv3EeLfzBR4HxCU6aLHgRhQYYyre+so+QuJMP/Au Wgy5uKbfYqkDzmtMrGEdzqzMBmMDzJPmVM33KMBkNxFjaeBv2P4pJDC 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 9b739594cc02..3a2bc14e5bd7 100644 --- a/drivers/net/ethernet/renesas/rswitch_main.c +++ b/drivers/net/ethernet/renesas/rswitch_main.c @@ -304,13 +304,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; @@ -320,7 +320,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; @@ -359,7 +359,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 { @@ -369,7 +369,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); } @@ -387,7 +387,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; } @@ -469,12 +469,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; @@ -483,18 +482,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; } @@ -508,7 +506,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); } } @@ -516,7 +514,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) { @@ -526,7 +524,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 @@ -638,7 +636,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 @@ -672,7 +670,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 @@ -681,7 +679,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) @@ -872,7 +870,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 Sat Jun 13 03:33:03 2026 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 148543C3C12; Mon, 11 May 2026 08:57:40 +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=1778489862; cv=none; b=mlbjZsN8GAyVQjAggTZIOQwM30Hj4dqbkaWMB1YrQzRAMX8NAbggpNRZvNlkT6QzNHa0TmY8oiXSzQnVL2cs6SKBbcHbhTFu2I/8QUPBSm5M6TEEbp1+ubo7gQiwaO7MiZ4XkbwPSV97WPzKTYHOkUR0pVXAXD44fRWKqiM8mSE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778489862; c=relaxed/simple; bh=KjtGe1BQGxipfuBuOYFRkxY7t6hscTJYReI9p1EyeTo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=I4UXNYRTp2jR14Ehe29WJ0aX5IrzC8GhlSSaqo+mmS/XgH6ZchgbU9qiY5igkHGU9o6WgCUZ5l7U2ctDVkxjsvF5ZVl4/jawww9o5inaqwNkNgKWeSMlso8disLatH+2u0LvdRoxrTfmfpxuvaco7tkYk5G6In3BGilCMQE2G/I= 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: Gzr1SZuHQwCFh2L9ldp1Ug== X-CSE-MsgGUID: goS03OfaQiygx023Yb7gCA== Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 11 May 2026 17:52:38 +0900 Received: from [127.0.1.1] (unknown [10.226.78.135]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id B56734010DEB; Mon, 11 May 2026 17:52:35 +0900 (JST) From: Michael Dege Date: Mon, 11 May 2026 10:52:06 +0200 Subject: [PATCH net-next v4 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: <20260511-rswitch_add_vlans-v4-3-a5a225f8faae@renesas.com> References: <20260511-rswitch_add_vlans-v4-0-a5a225f8faae@renesas.com> In-Reply-To: <20260511-rswitch_add_vlans-v4-0-a5a225f8faae@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=1778489544; l=2272; i=michael.dege@renesas.com; s=20251023; h=from:subject:message-id; bh=KjtGe1BQGxipfuBuOYFRkxY7t6hscTJYReI9p1EyeTo=; b=oUxrm9hLrj2ijwUf308C2le5VQzOE/42ZTzau/IdEfTkoNz2BZGwofYTkg/z/GHm3YrGsoOIk Fbbip/jmT82A9nwi04BZDe8O89UJYXio0VClixA/U6vp95qQ5F7Ob0Y 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 3a2bc14e5bd7..e05c42db5f4c 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 Sat Jun 13 03:33:03 2026 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 235873CAE75; Mon, 11 May 2026 08:57:44 +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=1778489865; cv=none; b=n8YPYv4CtcF5feFKfrOISG38r/N2Hq4PiOeEXMGFFiE4LM+8Qh6ZxRWKHhYmr+DNMMu1J0yRoIbl7xCIUvl/Zik9+Eko/WNnhWgm6ZzHWfJLdLl4rtGvozPDT5IJP+UA5MzO268sr1pRIwyHP8ndLTp5d2AlqEcm+XYkN+AO+OM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778489865; c=relaxed/simple; bh=jxtflo7pqLz5vv2Og2F+NhedUGaL5nZobcZN5x5IYz4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ULil7zae/adwFxbANfKHY5K1J1uIT18SB4JAwa/YlQr3cnRRpxgBW24Gbh22aL1ZxCnWx3hYbkFdYupDxP8rk4wPQAuBdSEGkrePZe+GATMkjNuuFIjOL8akUbw4GdkyR8jg2erUFkJeSoSshBzcfRN8FuJcLFmG6gyooevQ1so= 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: XdOujXfpRpGzBYn0DGcwjw== X-CSE-MsgGUID: smNM0BcQRkur7ixIzSNV8w== Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 11 May 2026 17:52:42 +0900 Received: from [127.0.1.1] (unknown [10.226.78.135]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 487664010E3A; Mon, 11 May 2026 17:52:39 +0900 (JST) From: Michael Dege Date: Mon, 11 May 2026 10:52:07 +0200 Subject: [PATCH net-next v4 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: <20260511-rswitch_add_vlans-v4-4-a5a225f8faae@renesas.com> References: <20260511-rswitch_add_vlans-v4-0-a5a225f8faae@renesas.com> In-Reply-To: <20260511-rswitch_add_vlans-v4-0-a5a225f8faae@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=1778489544; l=6223; i=michael.dege@renesas.com; s=20251023; h=from:subject:message-id; bh=jxtflo7pqLz5vv2Og2F+NhedUGaL5nZobcZN5x5IYz4=; b=uBmKWw8wsb7W89oUUlX/upYSiE5oO11K1AAqKfJSDIw4RzgKSrsixrMrljoE1AZzzT+xS2sXv OHc1zHmGffhB5NPTVTPVzn4T5zWDWjKO+u9Ka8hpgJXVdmJlK1s83Ui 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..e56c15dd4ecd 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 GENMASK(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 Sat Jun 13 03:33:03 2026 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 232753CF674; Mon, 11 May 2026 08:57:48 +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=1778489870; cv=none; b=WOp6OcYJAbhm7gY5HvA7vuagsvu9eYdrZTE34h37hekwQjMGLFwac9jP8TvT7uNL3LWbEf0+PdwbvxTI1X1zRyp/PEof8etAGHfaDW3jc3HK4fu7+kMENwlCve/Ov0Xr9QCTnOPbM2KPLXAy45Pk2lzMdg935gLuryAEe0B+oeU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778489870; c=relaxed/simple; bh=BK4EhySTkA3ZOziO+g6xAlQYH+gxhg9yeiDTQtpN6IE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nBRMAzg9FIa0Bt76Tkiu+KIoeZXU4yhrx5FHpc8RtpsZaK8/+QFRuEC2xrFeghisEcOSm+NMrIwIEKcejQc47zUwr7RI8MCSydl+8orL2v+T74tobs/c2BksIw0fBWZUvpxuEJH7ngSI8P8Ch2Ucq+wuW04U6BW2hYuQ0GNvfig= 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: 6Ck5V8yqT8WvcbqrBUeWCA== X-CSE-MsgGUID: l+UWU5y1R9GxX3gtFeLoxQ== Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 11 May 2026 17:52:45 +0900 Received: from [127.0.1.1] (unknown [10.226.78.135]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id CFC114009A31; Mon, 11 May 2026 17:52:42 +0900 (JST) From: Michael Dege Date: Mon, 11 May 2026 10:52:08 +0200 Subject: [PATCH net-next v4 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: <20260511-rswitch_add_vlans-v4-5-a5a225f8faae@renesas.com> References: <20260511-rswitch_add_vlans-v4-0-a5a225f8faae@renesas.com> In-Reply-To: <20260511-rswitch_add_vlans-v4-0-a5a225f8faae@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=1778489544; l=8735; i=michael.dege@renesas.com; s=20251023; h=from:subject:message-id; bh=BK4EhySTkA3ZOziO+g6xAlQYH+gxhg9yeiDTQtpN6IE=; b=NeQ1zwXSjSn7k/H8SqaRzia+VMx1B8sBbbH+KOPhXJ6P1lQwPsuIZE2J06A2ydzwU15nqiu3W 1Kms3vabOX9CadlidIe2uGCEJo8EJTsLA5Wp7xrAqMZhWOd5Wzi47a2 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 | 2 + drivers/net/ethernet/renesas/rswitch_main.c | 94 +++++++++++++++++++++++++= +--- 2 files changed, 89 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/renesas/rswitch.h b/drivers/net/ethernet/= renesas/rswitch.h index e56c15dd4ecd..8415f52a239e 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]; @@ -1162,6 +1163,7 @@ struct rswitch_device { void __iomem *addr; struct rswitch_gwca_queue *tx_queue; struct rswitch_gwca_queue *rx_queue; + struct rswitch_gwca_queue *rx_old_queue; struct sk_buff *ts_skb[TS_TAGS_PER_PORT]; DECLARE_BITMAP(ts_skb_used, TS_TAGS_PER_PORT); bool disabled; diff --git a/drivers/net/ethernet/renesas/rswitch_main.c b/drivers/net/ethe= rnet/renesas/rswitch_main.c index e05c42db5f4c..bf26c1a3384a 100644 --- a/drivers/net/ethernet/renesas/rswitch_main.c +++ b/drivers/net/ethernet/renesas/rswitch_main.c @@ -682,6 +682,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; @@ -719,6 +747,10 @@ static int rswitch_gwca_hw_init(struct rswitch_private= *priv) return err; } =20 + err =3D rswitch_shared_rx_queue_alloc(priv); + if (err < 0) + return err; + return rswitch_gwca_change_mode(priv, GWMC_OPC_OPERATION); } =20 @@ -730,6 +762,8 @@ static int rswitch_gwca_hw_deinit(struct rswitch_privat= e *priv) if (err < 0) return err; =20 + rswitch_shared_rx_queue_free(priv); + return rswitch_gwca_change_mode(priv, GWMC_OPC_DISABLE); } =20 @@ -938,10 +972,15 @@ static int rswitch_poll(struct napi_struct *napi, int= budget) =20 if (napi_complete_done(napi, budget - quota)) { spin_lock_irqsave(&priv->lock, flags); + if (rdev->rx_old_queue) { + rdev->rx_queue =3D rdev->rx_old_queue; + rdev->rx_old_queue =3D NULL; + } if (test_bit(rdev->port, priv->opened_ports)) { 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 @@ -954,15 +993,40 @@ 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; + unsigned int rx_q_index; + u32 spn; + + rdev =3D netdev_priv(gq->ndev); + rx_q_index =3D rdev->rx_queue->index; + +/* If we receive a shared queue through the exception path, it will be mis= sing the ndev + * pointer. This needs to be added to be able to determine from which port= the packet was + * received. Then we temporarily exchange the rx_queue pointer in rdev. Th= is will be + * restored after the packet has been processed. + */ + + 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; + /* store original rx_queue */ + rdev->rx_old_queue =3D rdev->rx_queue; + rdev->rx_queue =3D gq; + } =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, rx_q_index, false); + rswitch_enadis_data_irq(priv, priv->gwca.l2_shared_rx_queue->index, fals= e); + spin_unlock(&priv->lock); __napi_schedule(&rdev->napi); } } @@ -980,7 +1044,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; @@ -1517,6 +1581,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; @@ -1570,6 +1642,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) @@ -1620,6 +1694,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); @@ -1646,6 +1721,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 @@ -1953,6 +2029,7 @@ static int rswitch_device_alloc(struct rswitch_privat= e *priv, unsigned int index rdev->port =3D index; rdev->etha =3D &priv->etha[index]; rdev->addr =3D priv->addr; + rdev->rx_old_queue =3D NULL; =20 ndev->base_addr =3D (unsigned long)rdev->addr; snprintf(ndev->name, IFNAMSIZ, "tsn%d", index); @@ -2170,6 +2247,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 Sat Jun 13 03:33:03 2026 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AE51A2DF719; Mon, 11 May 2026 08:52:50 +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=1778489572; cv=none; b=Hst5JoDVm4KvXivlX2Lji2PAksVT0Q2jIifRbCGAs0+TQ5mK45V5nkefh4odKYysshVCj33mTvMmeiLcYRj8RG5RlI953PC5Ohdn/3Ub/JJOMkqFdmRsaZm0yjx1QUjFBoKckXSnAYclnHnU9H8msZHQEJoNJCAeJjYkL/o8m1k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778489572; c=relaxed/simple; bh=JGGhbyQumfo3wcFix6PAjLF371iAqBT/aYF9KzKp2j0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TP5VLoM1lSn9Ccznm3nLO7O5HQKscULa6AJkE2+XM8LHhOgrPvCDP/eM8zyHNrjEc14/p5GLwUiJmQbeBK1jtWEfFFhk1DKlM4Ys+SiY1lxeyZ5vwqADmD9259g/WUoq63bBvhy9vaUY5N5HORxZ9wbyQz7cKpKhpsuVHZZnhOc= 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: 6Y0GVprmRP6GR5Y34Z0ckQ== X-CSE-MsgGUID: 3Q8s+sSFS/CDIRXHLgYV8g== Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 11 May 2026 17:52:49 +0900 Received: from [127.0.1.1] (unknown [10.226.78.135]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 628764010E3A; Mon, 11 May 2026 17:52:46 +0900 (JST) From: Michael Dege Date: Mon, 11 May 2026 10:52:09 +0200 Subject: [PATCH net-next v4 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: <20260511-rswitch_add_vlans-v4-6-a5a225f8faae@renesas.com> References: <20260511-rswitch_add_vlans-v4-0-a5a225f8faae@renesas.com> In-Reply-To: <20260511-rswitch_add_vlans-v4-0-a5a225f8faae@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=1778489544; l=1614; i=michael.dege@renesas.com; s=20251023; h=from:subject:message-id; bh=JGGhbyQumfo3wcFix6PAjLF371iAqBT/aYF9KzKp2j0=; b=zd8gZHvEnZ+as+0jFP5rCe67MXdKRbRlv9++VcKUhzrxSrd2FO6wqa18Ufpsq+18jDLFYkRE2 SP0rQLqM8+uBzQxdpehfT5Ubydp/3/CvXc1KZZAUQqB5pluTUcR+M2q 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..3cc0ce8762f3 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_clr =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 Sat Jun 13 03:33:03 2026 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4B18C3BB9FC; Mon, 11 May 2026 08:52:53 +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=1778489574; cv=none; b=m2lw3zfpGoEg46VeDcDJCxd0xsWOGY7wEmB8w2l31i+/cj0CDtObDWjAEj88aiMS3PsTuxEvRLRkQnmC8uNCB+ej0EQpVO3xMTe2bcbXrWvYSyXYDaJpWC1eeP2G6kHyXcsHcdGSqtvTmdKeaCTSqvRGbD5M3WcgEAld6mwM+/U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778489574; c=relaxed/simple; bh=l6Or7TtGjPAtyZp/mjgkAkaX0FlXmpjsymwHngG/R/Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eu/LB9Y0d4li7VEYcImPfbPeFIR/wygKkfXYibX84TgN+YpYodrFLxCm77ELJUw+vdqordF0oQV+EdCYUeEBmDbO5nu8sZBt4TYZbz02Mlge1CN0+IrlxSCjkLmW+Sb7lBHgy6nyIczWhWqiWk+1kk9JFsDKDTyLbA75bOWX0Ss= 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: jyYYp573RhyBRk28yrmfKw== X-CSE-MsgGUID: 6f1T1Po4Thy7YFzBfsV6JA== Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 11 May 2026 17:52:53 +0900 Received: from [127.0.1.1] (unknown [10.226.78.135]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id EC6964010DEB; Mon, 11 May 2026 17:52:49 +0900 (JST) From: Michael Dege Date: Mon, 11 May 2026 10:52:10 +0200 Subject: [PATCH net-next v4 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: <20260511-rswitch_add_vlans-v4-7-a5a225f8faae@renesas.com> References: <20260511-rswitch_add_vlans-v4-0-a5a225f8faae@renesas.com> In-Reply-To: <20260511-rswitch_add_vlans-v4-0-a5a225f8faae@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=1778489544; l=2846; i=michael.dege@renesas.com; s=20251023; h=from:subject:message-id; bh=l6Or7TtGjPAtyZp/mjgkAkaX0FlXmpjsymwHngG/R/Y=; b=TrYarLSWFRLZgEGVj+JFcuouNsuH+IJfJHocXw1N8cMjQaNOmWXNauJXOjSjA/A8zRGEw96Sy 09rXNRK6tWUBcOOl9izHc2N56bgMDjDiG66w++PZk9n2jGM+HtoDz8W 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 8415f52a239e..d7a8866a3993 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__ @@ -1219,5 +1219,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 bf26c1a3384a..7d85905f2be2 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 @@ -1168,8 +1168,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 Sat Jun 13 03:33:03 2026 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D26D63BAD99; Mon, 11 May 2026 08:52:57 +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=1778489579; cv=none; b=jus1H1biXYgpLPDTkQNuCmDTnbTP7uCiQukL6SNVqR82P0RJ64z26WVZrprOdo2MLHRp1Tj2r+Hcvi4DezDXYW4WR9A0sm/txe1Dl3534J8J8yeHkWG307Q6+yOKkoHEQnaG5lOaA2qOsEc4m1NGWgfB1tB0W+x65jJX7yP9JbU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778489579; c=relaxed/simple; bh=2lvWdFNnegbVPck1/sYsq0efWTSUMEV3loHEE41KwMY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=n8nrsUAhaxDyr76kkkof4BM6mqYiZ1h2nzIiDTai5LXk0BYlIk/9Q0PiICpYoCP3LUNTAU9LgX2B76lK3NID0o70/5oSZ3l1YdJ+2+qUl81hgl7Xt/kTIo72BcIGg2doH6M2yalHyL6VWdeB9he0OCuOUaaDyvB4X4ERP39+FrA= 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: ydzwYBMkQcqd0pPl7OgGBA== X-CSE-MsgGUID: u2j4W/5ISeO4MUsXNxC8/Q== Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 11 May 2026 17:52:56 +0900 Received: from [127.0.1.1] (unknown [10.226.78.135]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 801074009A31; Mon, 11 May 2026 17:52:53 +0900 (JST) From: Michael Dege Date: Mon, 11 May 2026 10:52:11 +0200 Subject: [PATCH net-next v4 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: <20260511-rswitch_add_vlans-v4-8-a5a225f8faae@renesas.com> References: <20260511-rswitch_add_vlans-v4-0-a5a225f8faae@renesas.com> In-Reply-To: <20260511-rswitch_add_vlans-v4-0-a5a225f8faae@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=1778489544; l=1893; i=michael.dege@renesas.com; s=20251023; h=from:subject:message-id; bh=2lvWdFNnegbVPck1/sYsq0efWTSUMEV3loHEE41KwMY=; b=veLY/dY+7oy4k80oO60nxxhWGSTVlRiFj1gxjhA1Pp9UlHkGZTePSZz7kK2+WPxmeGm90VdKP rI0Sz2PcM3xCD7+9r9bhaiwxC1Xok6j3pnt6tkBenZiXs7kfYHChFha 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 7d85905f2be2..90c44dcfd169 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 Sat Jun 13 03:33:03 2026 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6818E3BED31; Mon, 11 May 2026 08:53:00 +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=1778489582; cv=none; b=OxodooPS9ehBVfKUprwEaCBvLRGmg2wq2SjMcv84vBZ9YlacF+0W69EBzjVOolfPHlczmeXUkOfoIu5kskutZe0qmEhqCGZ12Pzuix03kC1MJH/43drYDi4uYzRReh7TEJKfNetp/q0dBJ3K5Kumh93nhuWdzr4iM+12kNAo8HY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778489582; c=relaxed/simple; bh=hkjuP3fD8RUOCXLPGqZ55U5OK8Y8iNWY4aoCgxW6cmI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qzLWCGsCvTt2nmPblHxFTx+TGddHs7eYX7qy/FCf6+o/mR5qnIfqC3GlG9YDAvFSZ3c94bflCIaOFK4NfFYAllSem52XXf7pvP2BqJmZk7Gg3c6JAwt8u2xHqKT12S1jLwJhexaaq5bPP5G9ZkZC9LW385frLO0MYXxt4g7ZARM= 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: 1PvqY/fjT12nf5lFqjiJxw== X-CSE-MsgGUID: rE+AugzlR1CkOWRNhhV5FA== Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 11 May 2026 17:53:00 +0900 Received: from [127.0.1.1] (unknown [10.226.78.135]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 12B324010DEB; Mon, 11 May 2026 17:52:56 +0900 (JST) From: Michael Dege Date: Mon, 11 May 2026 10:52:12 +0200 Subject: [PATCH net-next v4 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: <20260511-rswitch_add_vlans-v4-9-a5a225f8faae@renesas.com> References: <20260511-rswitch_add_vlans-v4-0-a5a225f8faae@renesas.com> In-Reply-To: <20260511-rswitch_add_vlans-v4-0-a5a225f8faae@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=1778489544; l=2575; i=michael.dege@renesas.com; s=20251023; h=from:subject:message-id; bh=hkjuP3fD8RUOCXLPGqZ55U5OK8Y8iNWY4aoCgxW6cmI=; b=OKYuXT0pJNhF9q2X7lg7IAdGMPEFrNRFmXXOFM2bKmI3qVQ+/Yw7l73v9m5inRcOTj6jRFPX7 4dWwasvULNlB05Ou5SltFxreGxT10Mwkk/yoieYWoV4OWecU1P4J0ab 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 d7a8866a3993..89315b6cde0f 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 90c44dcfd169..d00af333fcce 100644 --- a/drivers/net/ethernet/renesas/rswitch_main.c +++ b/drivers/net/ethernet/renesas/rswitch_main.c @@ -737,8 +737,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); @@ -880,6 +883,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); @@ -1284,7 +1288,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 Sat Jun 13 03:33:03 2026 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 01CE23BD63D; Mon, 11 May 2026 08:53:03 +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=1778489585; cv=none; b=dnSKPH50Z58NGbKcEagBjmRoMwB+tNt9YDBZGWtQusYTlbU3JoChIntecKxy1mg6SMLMwUxva2d9ugl+c/X4kl0i//LgvzWG6vi5DEotowe0HG5eVFi+c/GCBbP/ekh11ZPXo5/8KV6r5u+NSd5k+gFZyYbiiUYD3jiJZiw/8rM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778489585; c=relaxed/simple; bh=ZVwEfbWxL/kjFIOQzU+C2EPYG5AfUI1qggMxCbUnbtw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ARtngG1QjDe+i3ADURtMwq/W/pt4wHkab0sdM52jroopE/pqc26U2Usxhb1nQ9bR+PSdgHZh0xEpdu+eiUpX7zyGRoA/Ky+LQaFLw+PUGKLVvOig/k8n52W1umAqj7nO6s9JuVkiMXuqG/32OqN2wAr/Hmy/h/6OFkwlo7Qi1MA= 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: Qy5sxOumRaqsfdIMwbMEVg== X-CSE-MsgGUID: KZRVB/AbQvKlRcm+2j3E6g== Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 11 May 2026 17:53:03 +0900 Received: from [127.0.1.1] (unknown [10.226.78.135]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 9F6C34009A31; Mon, 11 May 2026 17:53:00 +0900 (JST) From: Michael Dege Date: Mon, 11 May 2026 10:52:13 +0200 Subject: [PATCH net-next v4 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: <20260511-rswitch_add_vlans-v4-10-a5a225f8faae@renesas.com> References: <20260511-rswitch_add_vlans-v4-0-a5a225f8faae@renesas.com> In-Reply-To: <20260511-rswitch_add_vlans-v4-0-a5a225f8faae@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=1778489544; l=2714; i=michael.dege@renesas.com; s=20251023; h=from:subject:message-id; bh=ZVwEfbWxL/kjFIOQzU+C2EPYG5AfUI1qggMxCbUnbtw=; b=IWY6tGnfQogjhe+WHBXrqEMkFExEvnqPK9nohaMr6bPVqpFHyvrQS9LTlIvNFv8G5aD4knPbS uhsu0FAggm/C98qjV/kNb7M8fARTWfds3M7CTf7uHKovAzt0icT3DKY 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 3cc0ce8762f3..dd8aecbcb2a8 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 d00af333fcce..bb9ead193cd6 100644 --- a/drivers/net/ethernet/renesas/rswitch_main.c +++ b/drivers/net/ethernet/renesas/rswitch_main.c @@ -1979,7 +1979,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 Sat Jun 13 03:33:03 2026 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8F73E3BAD92; Mon, 11 May 2026 08:53:07 +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=1778489589; cv=none; b=cuftcDeU9jBTZN9N9Vdhtf0G1AtA1A0rdWShkBlUjeMy9nJV+SJ1YtN76E/E63vniLu1YWmvaW8/YNgRwTGwriYkGjCYT8x8SxOS1jj3whNm5W3cvSWSitCuUSx6a5VQvjTaZWfOTXZf9BP11YhXu+OnqcpqHxOOgf1r+IFOfDo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778489589; c=relaxed/simple; bh=8qZcwzyFkTWzWUYTrSt2/n8qMoLPtqhgJVcFV06qqhY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QdbobSD2IBMCBZnxfZMMg6MedyGbO5/tpGvaJQTRmM23nm5ePwQ+NWBR8btbnCt1ykPQy8juhWfUKf2jxiS1gpSQExCHjjFAZRuetkbqKPqTGDJFICcMDmiqPUkpCMD2dAVeg0vKDjneCyQUQr39CofUKA5Kuc5c+XMMT578od8= 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: /IXS3/wlS0GpgZ4HpYGF8Q== X-CSE-MsgGUID: cDLc0rYaTsGCcOwIbCbJNA== Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 11 May 2026 17:53:07 +0900 Received: from [127.0.1.1] (unknown [10.226.78.135]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 38E444009A31; Mon, 11 May 2026 17:53:03 +0900 (JST) From: Michael Dege Date: Mon, 11 May 2026 10:52:14 +0200 Subject: [PATCH net-next v4 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: <20260511-rswitch_add_vlans-v4-11-a5a225f8faae@renesas.com> References: <20260511-rswitch_add_vlans-v4-0-a5a225f8faae@renesas.com> In-Reply-To: <20260511-rswitch_add_vlans-v4-0-a5a225f8faae@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=1778489544; l=5516; i=michael.dege@renesas.com; s=20251023; h=from:subject:message-id; bh=8qZcwzyFkTWzWUYTrSt2/n8qMoLPtqhgJVcFV06qqhY=; b=Pk/1tUX3aLMuYPlE3iJ93wXD3bhDmXknVypc4oeTT8QmJKuJd00z10r4YFZkS11z0DKC3SIHi d/ZfN9Yqob7CM0UVFZ/faj2L2vUPtmUDT76R1Z7C9CDvg4gSgj8Jgjk 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 89315b6cde0f..949f0cb3c64e 100644 --- a/drivers/net/ethernet/renesas/rswitch.h +++ b/drivers/net/ethernet/renesas/rswitch.h @@ -1200,6 +1200,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 dd8aecbcb2a8..06c61c54db72 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 bb9ead193cd6..7ea3f4cc8f17 100644 --- a/drivers/net/ethernet/renesas/rswitch_main.c +++ b/drivers/net/ethernet/renesas/rswitch_main.c @@ -2290,7 +2290,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; @@ -2329,7 +2329,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 Sat Jun 13 03:33:03 2026 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 333093C279D; Mon, 11 May 2026 08:53:11 +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=1778489593; cv=none; b=D+shgMfIUVdz1d1VWiyp6dj1fO1fbYXD0jN8Ul01F37rc8P0/+8CFIW1Zqe0bRyo2WTZH7wogDpgTXF9mfSm9SSLk7gr56oemmrI3Bqo5kExSC/3iKRDeDBqZkfXUjH9aP96bAWbtGOMTVQOWIVgcydZbSZ+uNsa1PafBiToNVw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778489593; c=relaxed/simple; bh=08tPQ2SlXpT/44pKgI7sMtclAsc/NvTJBw8wqh+v9xs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mWEuVGrDJrleG5nUOJtyksXn0s/lmAv++q1VO1elm7GpZekp8HFrovDhtpKYqFz2ZYsouXNGsYsZk/2vghP/vlQEfFQBHyD4s7kvXUXL/8my/FxNSlpmjeV6MEO6nVRC8q9rxkyNsi8QjJRi92Sq3mPmiL8U33F5in6xcaYkrLs= 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: 4DwZo0Q/SYiVPE5W+1omwg== X-CSE-MsgGUID: iwUK2FoqT8SRP/yqX9dKmg== Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 11 May 2026 17:53:11 +0900 Received: from [127.0.1.1] (unknown [10.226.78.135]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id C644C4010DEB; Mon, 11 May 2026 17:53:07 +0900 (JST) From: Michael Dege Date: Mon, 11 May 2026 10:52:15 +0200 Subject: [PATCH net-next v4 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: <20260511-rswitch_add_vlans-v4-12-a5a225f8faae@renesas.com> References: <20260511-rswitch_add_vlans-v4-0-a5a225f8faae@renesas.com> In-Reply-To: <20260511-rswitch_add_vlans-v4-0-a5a225f8faae@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=1778489544; l=8906; i=michael.dege@renesas.com; s=20251023; h=from:subject:message-id; bh=08tPQ2SlXpT/44pKgI7sMtclAsc/NvTJBw8wqh+v9xs=; b=1OJi3o2s2+M7fwDfqUMdNjsteDzFg7qDx+wMZOETHCS4QZ2N0P27une68Pt2uFn7nVW/3z/fs yIqifQMCGl+AfBm4gce8FSItD0Jzdai59tm+rXTphg68hyAssNbY9F+ 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 | 9 ++ drivers/net/ethernet/renesas/rswitch_l2.c | 196 ++++++++++++++++++++++++++= ---- 2 files changed, 182 insertions(+), 23 deletions(-) diff --git a/drivers/net/ethernet/renesas/rswitch.h b/drivers/net/ethernet/= renesas/rswitch.h index 949f0cb3c64e..3689463ddb1d 100644 --- a/drivers/net/ethernet/renesas/rswitch.h +++ b/drivers/net/ethernet/renesas/rswitch.h @@ -1213,11 +1213,20 @@ struct rswitch_private { bool etha_no_runtime_change; bool gwca_halt; struct net_device *offload_brdev; + netdevice_tracker dev_tracker; =20 enum hwtstamp_tx_types tstamp_tx_ctrl; 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 06c61c54db72..24d659576f62 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,172 @@ 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; + const unsigned char addr[] =3D {0, 0, 0, 0, 0, 0}; + 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); + rswitch_gwca_write_mac_address(switchdev_work->priv, addr); + break; + default: + break; + } + +out: + rtnl_unlock(); + + kfree(switchdev_work->fdb_info.addr); + netdev_put(ndev, &switchdev_work->priv->dev_tracker); + kfree(switchdev_work); +} + +/* 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; + + 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); + netdev_hold(ndev, &priv->dev_tracker, GFP_ATOMIC); + queue_work(system_long_wq, &switchdev_work->work); + + break; + } + + 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 Sat Jun 13 03:33:03 2026 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4D0233C3BFD; Mon, 11 May 2026 08:53:14 +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=1778489597; cv=none; b=krbBI6pLdI93zcG7dPltuUkMz97+LLr8ulovEq1xS0TKGB9BcqpVUNTEbI3wK0CU95cZ7cw/trT7Z9/i/SPMmZf/WGRt4fVgSrd82SKXkoWZ+JiGc8o1V73CSXqQAq+zSoA8cINna+bBIhmaj8TstK5L10gBf2KUUm9wEXv25MU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778489597; c=relaxed/simple; bh=TAmFOBdr1Rt5ExUPKR62ytPWrMHoG+d/2Rm6lG2Yd8s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LaG9KOw2WLRq/wV1X2/ljAzmfgEq25gW03pMrASq1zPoffgt5CIZBwa7fBimlnNkyxmgJpXdfU7G9SI8I0T7VPPd/M7+m+h4trm7rWZqHmSxWxusbCoSLhTsC6Af1upvE/cVX/LXqDLrztDg98H3kJD5AYFZnGkukPLQdk0NKgI= 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: LHvZVxjgQuKGRe5iM1c+Ag== X-CSE-MsgGUID: xk4J3WRfT+Km/L4EqHHBbA== Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 11 May 2026 17:53:14 +0900 Received: from [127.0.1.1] (unknown [10.226.78.135]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 5982A4009A31; Mon, 11 May 2026 17:53:11 +0900 (JST) From: Michael Dege Date: Mon, 11 May 2026 10:52:16 +0200 Subject: [PATCH net-next v4 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: <20260511-rswitch_add_vlans-v4-13-a5a225f8faae@renesas.com> References: <20260511-rswitch_add_vlans-v4-0-a5a225f8faae@renesas.com> In-Reply-To: <20260511-rswitch_add_vlans-v4-0-a5a225f8faae@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=1778489544; l=14831; i=michael.dege@renesas.com; s=20251023; h=from:subject:message-id; bh=TAmFOBdr1Rt5ExUPKR62ytPWrMHoG+d/2Rm6lG2Yd8s=; b=MXlQtajnTlgzLz/UiyR+To7yBsB7KEPr7Q0vg8U7Mo5PYyUfiypPnFXYVQwZAI88RIAXVNJ6M IaCs7HaCLCYDUwvaOkd1qlSFe7wQHyo3x+OvicSUqvZ0JAxe9ULsnia 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 | 401 ++++++++++++++++++++++++++= +--- 2 files changed, 364 insertions(+), 38 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 24d659576f62..5c16e204de45 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,401 @@ 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; + struct rswitch_private *priv; + int err; + + switch (info->obj->id) { + case SWITCHDEV_OBJ_ID_PORT_VLAN: + p_vlan =3D SWITCHDEV_OBJ_PORT_VLAN(info->obj); + 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; + + priv =3D container_of(nb, struct rswitch_private, + rswitch_switchdev_blocking_nb); + + 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; + struct rswitch_private *priv; + int err; + + switch (info->obj->id) { + case SWITCHDEV_OBJ_ID_PORT_VLAN: + p_vlan =3D SWITCHDEV_OBJ_PORT_VLAN(info->obj); + 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; + + priv =3D container_of(nb, struct rswitch_private, + rswitch_switchdev_blocking_nb); + + 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) --=20 2.43.0