From: Michael Dege <michael.dege@renesas.com>
To: "Yoshihiro Shimoda" <yoshihiro.shimoda.uh@renesas.com>,
"Andrew Lunn" <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Niklas Söderlund" <niklas.soderlund@ragnatech.se>,
"Paul Barker" <paul@pbarker.dev>
Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
linux-kernel@vger.kernel.org,
Michael Dege <michael.dege@renesas.com>
Subject: [PATCH net-next v4 02/13] net: renesas: rswitch: use device instead of net_device
Date: Mon, 11 May 2026 10:52:05 +0200 [thread overview]
Message-ID: <20260511-rswitch_add_vlans-v4-2-a5a225f8faae@renesas.com> (raw)
In-Reply-To: <20260511-rswitch_add_vlans-v4-0-a5a225f8faae@renesas.com>
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 <michael.dege@renesas.com>
---
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/ethernet/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 rswitch_gwca_queue *gq,
return -ENOMEM;
}
-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;
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 = NULL;
@@ -320,7 +320,7 @@ static void rswitch_gwca_queue_free(struct net_device *ndev,
kfree(gq->rx_bufs);
gq->rx_bufs = 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 = 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;
- gq->rx_ring = dma_alloc_coherent(ndev->dev.parent,
+ gq->rx_ring = 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 = kzalloc_objs(*gq->unmap_addrs, gq->ring_size);
if (!gq->unmap_addrs)
goto out;
- gq->tx_ring = dma_alloc_coherent(ndev->dev.parent,
+ gq->tx_ring = 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;
out:
- rswitch_gwca_queue_free(ndev, gq);
+ rswitch_gwca_queue_free(&priv->pdev->dev, gq);
return -ENOMEM;
}
@@ -469,12 +469,11 @@ static void rswitch_gwca_ts_queue_fill(struct rswitch_private *priv,
}
}
-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 = 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 = (i + start_index) % gq->ring_size;
desc = &gq->rx_ring[index];
if (!gq->dir_tx) {
- dma_addr = dma_map_single(ndev->dev.parent,
+ dma_addr = 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;
desc->desc.info_ds = cpu_to_le16(RSWITCH_DESC_BUF_SIZE);
rswitch_desc_set_dptr(&desc->desc, dma_addr);
dma_wmb();
desc->desc.die_dt = DT_FEMPTY | DIE;
- desc->info1 = cpu_to_le64(INFO1_SPN(rdev->etha->index));
} else {
desc->desc.die_dt = DT_EEMPTY | DIE;
}
@@ -508,7 +506,7 @@ static int rswitch_gwca_queue_ext_ts_fill(struct net_device *ndev,
index = (i + start_index) % gq->ring_size;
desc = &gq->rx_ring[index];
dma_addr = 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_device *ndev,
return -ENOMEM;
}
-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;
memset(gq->rx_ring, 0, ring_size);
- err = rswitch_gwca_queue_ext_ts_fill(ndev, gq, 0, gq->ring_size);
+ err = rswitch_gwca_queue_ext_ts_fill(dev, gq, 0, gq->ring_size);
if (err < 0)
return err;
@@ -638,7 +636,7 @@ static void rswitch_txdmac_free(struct net_device *ndev)
{
struct rswitch_device *rdev = netdev_priv(ndev);
- 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);
}
@@ -672,7 +670,7 @@ static void rswitch_rxdmac_free(struct net_device *ndev)
{
struct rswitch_device *rdev = netdev_priv(ndev);
- 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);
}
@@ -681,7 +679,7 @@ static int rswitch_rxdmac_init(struct rswitch_private *priv, unsigned int index)
struct rswitch_device *rdev = priv->rdev[index];
struct net_device *ndev = rdev->ndev;
- 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);
}
static int rswitch_gwca_hw_init(struct rswitch_private *priv)
@@ -872,7 +870,7 @@ static bool rswitch_rx(struct net_device *ndev, int *quota)
ret = rswitch_gwca_queue_alloc_rx_buf(gq, gq->dirty, num);
if (ret < 0)
goto err;
- ret = rswitch_gwca_queue_ext_ts_fill(ndev, gq, gq->dirty, num);
+ ret = rswitch_gwca_queue_ext_ts_fill(ndev->dev.parent, gq, gq->dirty, num);
if (ret < 0)
goto err;
gq->dirty = rswitch_next_queue_index(gq, false, num);
--
2.43.0
next prev parent reply other threads:[~2026-05-11 8:57 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-11 8:52 [net-next PATCH v4 00/13] net: renesas: rswitch: R-Car S4 add VLAN aware switching Michael Dege
2026-05-11 8:52 ` [PATCH net-next v4 01/13] net: renesas: rswitch: improve port change mode functions Michael Dege
2026-05-11 8:52 ` Michael Dege [this message]
2026-05-11 8:52 ` [PATCH net-next v4 03/13] net: renesas: rswitch: fix FWPC2 register access macros Michael Dege
2026-05-11 8:52 ` [PATCH net-next v4 04/13] net: renesas: rswitch: add register definitions for vlan support Michael Dege
2026-05-11 8:52 ` [PATCH net-next v4 05/13] net: renesas: rswitch: add exception path for packets with unknown dst MAC Michael Dege
2026-05-11 8:52 ` [PATCH net-next v4 06/13] net: renesas: rswitch: add forwarding rules for gwca Michael Dege
2026-05-11 8:52 ` [PATCH net-next v4 07/13] net: renesas: rswitch: make helper functions available to whole driver Michael Dege
2026-05-11 8:52 ` [PATCH net-next v4 08/13] net: renesas: rswitch: add basic vlan init to rswitch_fwd_init Michael Dege
2026-05-11 8:52 ` [PATCH net-next v4 09/13] net: renesas: rswitch: update port HW init Michael Dege
2026-05-11 8:52 ` [PATCH net-next v4 10/13] net: renesas: rswitch: clean up is_rdev rswitch_device checking Michael Dege
2026-05-11 8:52 ` [PATCH net-next v4 11/13] net: renesas: rswitch: add passing of rswitch_private into notifiers Michael Dege
2026-05-11 8:52 ` [PATCH net-next v4 12/13] net: renesas: rswitch: add handler for FDB notification Michael Dege
2026-05-11 8:52 ` [PATCH net-next v4 13/13] net: renesas: rswitch: add vlan aware switching Michael Dege
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260511-rswitch_add_vlans-v4-2-a5a225f8faae@renesas.com \
--to=michael.dege@renesas.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=niklas.soderlund@ragnatech.se \
--cc=pabeni@redhat.com \
--cc=paul@pbarker.dev \
--cc=yoshihiro.shimoda.uh@renesas.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox