Skip to content

Commit

Permalink
net: renesas: rswitch: Rename rings in struct rswitch_gwca_queue
Browse files Browse the repository at this point in the history
[ Upstream commit 251eadc ]

To add a new ring which is really related to timestamp (ts_ring)
in the future, rename the following members to improve readability:

    ring --> tx_ring
    ts_ring --> rx_ring

Signed-off-by: Yoshihiro Shimoda <[email protected]>
Reviewed-by: Alexander Duyck <[email protected]>
Signed-off-by: Jakub Kicinski <[email protected]>
Stable-dep-of: e05bb97 ("net: renesas: rswitch: Fix the output value of quote from rswitch_rx()")
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
shimoday authored and gregkh committed Mar 22, 2023
1 parent d963ab4 commit 79a971e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 34 deletions.
64 changes: 32 additions & 32 deletions drivers/net/ethernet/renesas/rswitch.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ static int rswitch_get_num_cur_queues(struct rswitch_gwca_queue *gq)

static bool rswitch_is_queue_rxed(struct rswitch_gwca_queue *gq)
{
struct rswitch_ext_ts_desc *desc = &gq->ts_ring[gq->dirty];
struct rswitch_ext_ts_desc *desc = &gq->rx_ring[gq->dirty];

if ((desc->desc.die_dt & DT_MASK) != DT_FEMPTY)
return true;
Expand Down Expand Up @@ -284,13 +284,13 @@ static void rswitch_gwca_queue_free(struct net_device *ndev,
if (gq->gptp) {
dma_free_coherent(ndev->dev.parent,
sizeof(struct rswitch_ext_ts_desc) *
(gq->ring_size + 1), gq->ts_ring, gq->ring_dma);
gq->ts_ring = NULL;
(gq->ring_size + 1), gq->rx_ring, gq->ring_dma);
gq->rx_ring = NULL;
} else {
dma_free_coherent(ndev->dev.parent,
sizeof(struct rswitch_ext_desc) *
(gq->ring_size + 1), gq->ring, gq->ring_dma);
gq->ring = NULL;
(gq->ring_size + 1), gq->tx_ring, gq->ring_dma);
gq->tx_ring = NULL;
}

if (!gq->dir_tx) {
Expand Down Expand Up @@ -322,14 +322,14 @@ static int rswitch_gwca_queue_alloc(struct net_device *ndev,
rswitch_gwca_queue_alloc_skb(gq, 0, gq->ring_size);

if (gptp)
gq->ts_ring = dma_alloc_coherent(ndev->dev.parent,
gq->rx_ring = dma_alloc_coherent(ndev->dev.parent,
sizeof(struct rswitch_ext_ts_desc) *
(gq->ring_size + 1), &gq->ring_dma, GFP_KERNEL);
else
gq->ring = dma_alloc_coherent(ndev->dev.parent,
sizeof(struct rswitch_ext_desc) *
(gq->ring_size + 1), &gq->ring_dma, GFP_KERNEL);
if (!gq->ts_ring && !gq->ring)
gq->tx_ring = dma_alloc_coherent(ndev->dev.parent,
sizeof(struct rswitch_ext_desc) *
(gq->ring_size + 1), &gq->ring_dma, GFP_KERNEL);
if (!gq->rx_ring && !gq->tx_ring)
goto out;

i = gq->index / 32;
Expand Down Expand Up @@ -362,14 +362,14 @@ static int rswitch_gwca_queue_format(struct net_device *ndev,
struct rswitch_private *priv,
struct rswitch_gwca_queue *gq)
{
int tx_ring_size = sizeof(struct rswitch_ext_desc) * gq->ring_size;
int ring_size = sizeof(struct rswitch_ext_desc) * gq->ring_size;
struct rswitch_ext_desc *desc;
struct rswitch_desc *linkfix;
dma_addr_t dma_addr;
int i;

memset(gq->ring, 0, tx_ring_size);
for (i = 0, desc = gq->ring; i < gq->ring_size; i++, desc++) {
memset(gq->tx_ring, 0, ring_size);
for (i = 0, desc = gq->tx_ring; i < gq->ring_size; i++, desc++) {
if (!gq->dir_tx) {
dma_addr = dma_map_single(ndev->dev.parent,
gq->skbs[i]->data, PKT_BUF_SZ,
Expand Down Expand Up @@ -398,7 +398,7 @@ static int rswitch_gwca_queue_format(struct net_device *ndev,

err:
if (!gq->dir_tx) {
for (i--, desc = gq->ring; i >= 0; i--, desc++) {
for (i--, desc = gq->tx_ring; i >= 0; i--, desc++) {
dma_addr = rswitch_desc_get_dptr(&desc->desc);
dma_unmap_single(ndev->dev.parent, dma_addr, PKT_BUF_SZ,
DMA_FROM_DEVICE);
Expand All @@ -408,9 +408,9 @@ static int rswitch_gwca_queue_format(struct net_device *ndev,
return -ENOMEM;
}

static int rswitch_gwca_queue_ts_fill(struct net_device *ndev,
struct rswitch_gwca_queue *gq,
int start_index, int num)
static int rswitch_gwca_queue_ext_ts_fill(struct net_device *ndev,
struct rswitch_gwca_queue *gq,
int start_index, int num)
{
struct rswitch_device *rdev = netdev_priv(ndev);
struct rswitch_ext_ts_desc *desc;
Expand All @@ -419,7 +419,7 @@ static int rswitch_gwca_queue_ts_fill(struct net_device *ndev,

for (i = 0; i < num; i++) {
index = (i + start_index) % gq->ring_size;
desc = &gq->ts_ring[index];
desc = &gq->rx_ring[index];
if (!gq->dir_tx) {
dma_addr = dma_map_single(ndev->dev.parent,
gq->skbs[index]->data, PKT_BUF_SZ,
Expand All @@ -443,7 +443,7 @@ static int rswitch_gwca_queue_ts_fill(struct net_device *ndev,
if (!gq->dir_tx) {
for (i--; i >= 0; i--) {
index = (i + start_index) % gq->ring_size;
desc = &gq->ts_ring[index];
desc = &gq->rx_ring[index];
dma_addr = rswitch_desc_get_dptr(&desc->desc);
dma_unmap_single(ndev->dev.parent, dma_addr, PKT_BUF_SZ,
DMA_FROM_DEVICE);
Expand All @@ -453,21 +453,21 @@ static int rswitch_gwca_queue_ts_fill(struct net_device *ndev,
return -ENOMEM;
}

static int rswitch_gwca_queue_ts_format(struct net_device *ndev,
struct rswitch_private *priv,
struct rswitch_gwca_queue *gq)
static int rswitch_gwca_queue_ext_ts_format(struct net_device *ndev,
struct rswitch_private *priv,
struct rswitch_gwca_queue *gq)
{
int tx_ts_ring_size = sizeof(struct rswitch_ext_ts_desc) * gq->ring_size;
int ring_size = sizeof(struct rswitch_ext_ts_desc) * gq->ring_size;
struct rswitch_ext_ts_desc *desc;
struct rswitch_desc *linkfix;
int err;

memset(gq->ts_ring, 0, tx_ts_ring_size);
err = rswitch_gwca_queue_ts_fill(ndev, gq, 0, gq->ring_size);
memset(gq->rx_ring, 0, ring_size);
err = rswitch_gwca_queue_ext_ts_fill(ndev, gq, 0, gq->ring_size);
if (err < 0)
return err;

desc = &gq->ts_ring[gq->ring_size]; /* Last */
desc = &gq->rx_ring[gq->ring_size]; /* Last */
rswitch_desc_set_dptr(&desc->desc, gq->ring_dma);
desc->desc.die_dt = DT_LINKFIX;

Expand Down Expand Up @@ -595,7 +595,7 @@ static int rswitch_rxdmac_init(struct rswitch_private *priv, int index)
struct rswitch_device *rdev = priv->rdev[index];
struct net_device *ndev = rdev->ndev;

return rswitch_gwca_queue_ts_format(ndev, priv, rdev->rx_queue);
return rswitch_gwca_queue_ext_ts_format(ndev, priv, rdev->rx_queue);
}

static int rswitch_gwca_hw_init(struct rswitch_private *priv)
Expand Down Expand Up @@ -676,7 +676,7 @@ static bool rswitch_rx(struct net_device *ndev, int *quota)
boguscnt = min_t(int, gq->ring_size, *quota);
limit = boguscnt;

desc = &gq->ts_ring[gq->cur];
desc = &gq->rx_ring[gq->cur];
while ((desc->desc.die_dt & DT_MASK) != DT_FEMPTY) {
if (--boguscnt < 0)
break;
Expand Down Expand Up @@ -704,14 +704,14 @@ static bool rswitch_rx(struct net_device *ndev, int *quota)
rdev->ndev->stats.rx_bytes += pkt_len;

gq->cur = rswitch_next_queue_index(gq, true, 1);
desc = &gq->ts_ring[gq->cur];
desc = &gq->rx_ring[gq->cur];
}

num = rswitch_get_num_cur_queues(gq);
ret = rswitch_gwca_queue_alloc_skb(gq, gq->dirty, num);
if (ret < 0)
goto err;
ret = rswitch_gwca_queue_ts_fill(ndev, gq, gq->dirty, num);
ret = rswitch_gwca_queue_ext_ts_fill(ndev, gq, gq->dirty, num);
if (ret < 0)
goto err;
gq->dirty = rswitch_next_queue_index(gq, false, num);
Expand All @@ -738,7 +738,7 @@ static int rswitch_tx_free(struct net_device *ndev, bool free_txed_only)

for (; rswitch_get_num_cur_queues(gq) > 0;
gq->dirty = rswitch_next_queue_index(gq, false, 1)) {
desc = &gq->ring[gq->dirty];
desc = &gq->tx_ring[gq->dirty];
if (free_txed_only && (desc->desc.die_dt & DT_MASK) != DT_FEMPTY)
break;

Expand Down Expand Up @@ -1416,7 +1416,7 @@ static netdev_tx_t rswitch_start_xmit(struct sk_buff *skb, struct net_device *nd
}

gq->skbs[gq->cur] = skb;
desc = &gq->ring[gq->cur];
desc = &gq->tx_ring[gq->cur];
rswitch_desc_set_dptr(&desc->desc, dma_addr);
desc->desc.info_ds = cpu_to_le16(skb->len);

Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/renesas/rswitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -915,8 +915,8 @@ struct rswitch_gwca_queue {
bool dir_tx;
bool gptp;
union {
struct rswitch_ext_desc *ring;
struct rswitch_ext_ts_desc *ts_ring;
struct rswitch_ext_desc *tx_ring;
struct rswitch_ext_ts_desc *rx_ring;
};
dma_addr_t ring_dma;
int ring_size;
Expand Down

0 comments on commit 79a971e

Please sign in to comment.