Skip to content

Commit

Permalink
net: renesas: rswitch: Remove gptp flag from rswitch_gwca_queue
Browse files Browse the repository at this point in the history
In the previous code, the gptp flag was completely related to
the !dir_tx in struct rswitch_gwca_queue because
rswitch_gwca_queue_alloc() was called below:

< In rswitch_txdmac_alloc() >
err = rswitch_gwca_queue_alloc(ndev, priv, rdev->tx_queue, true, false,
			      TX_RING_SIZE);
So, dir_tx = true, and gptp = false.

< In rswitch_rxdmac_alloc() >
err = rswitch_gwca_queue_alloc(ndev, priv, rdev->rx_queue, false, true,
			      RX_RING_SIZE);
So, dir_tx = false, and gptp = true.

In the future, a new queue handling for timestamp will be implemented
and this gptp flag is confusable. So, remove the gptp flag.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Yoshihiro Shimoda authored and Jakub Kicinski committed Feb 11, 2023
1 parent e3f3803 commit 48cf0a2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
26 changes: 11 additions & 15 deletions drivers/net/ethernet/renesas/rswitch.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,54 +280,52 @@ static void rswitch_gwca_queue_free(struct net_device *ndev,
{
int i;

if (gq->gptp) {
if (!gq->dir_tx) {
dma_free_coherent(ndev->dev.parent,
sizeof(struct rswitch_ext_ts_desc) *
(gq->ring_size + 1), gq->rx_ring, gq->ring_dma);
gq->rx_ring = NULL;

for (i = 0; i < gq->ring_size; i++)
dev_kfree_skb(gq->skbs[i]);
} else {
dma_free_coherent(ndev->dev.parent,
sizeof(struct rswitch_ext_desc) *
(gq->ring_size + 1), gq->tx_ring, gq->ring_dma);
gq->tx_ring = NULL;
}

if (!gq->dir_tx) {
for (i = 0; i < gq->ring_size; i++)
dev_kfree_skb(gq->skbs[i]);
}

kfree(gq->skbs);
gq->skbs = NULL;
}

static int rswitch_gwca_queue_alloc(struct net_device *ndev,
struct rswitch_private *priv,
struct rswitch_gwca_queue *gq,
bool dir_tx, bool gptp, int ring_size)
bool dir_tx, int ring_size)
{
int i, bit;

gq->dir_tx = dir_tx;
gq->gptp = gptp;
gq->ring_size = ring_size;
gq->ndev = ndev;

gq->skbs = kcalloc(gq->ring_size, sizeof(*gq->skbs), GFP_KERNEL);
if (!gq->skbs)
return -ENOMEM;

if (!dir_tx)
if (!dir_tx) {
rswitch_gwca_queue_alloc_skb(gq, 0, gq->ring_size);

if (gptp)
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
} else {
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;

Expand Down Expand Up @@ -539,8 +537,7 @@ static int rswitch_txdmac_alloc(struct net_device *ndev)
if (!rdev->tx_queue)
return -EBUSY;

err = rswitch_gwca_queue_alloc(ndev, priv, rdev->tx_queue, true, false,
TX_RING_SIZE);
err = rswitch_gwca_queue_alloc(ndev, priv, rdev->tx_queue, true, TX_RING_SIZE);
if (err < 0) {
rswitch_gwca_put(priv, rdev->tx_queue);
return err;
Expand Down Expand Up @@ -574,8 +571,7 @@ static int rswitch_rxdmac_alloc(struct net_device *ndev)
if (!rdev->rx_queue)
return -EBUSY;

err = rswitch_gwca_queue_alloc(ndev, priv, rdev->rx_queue, false, true,
RX_RING_SIZE);
err = rswitch_gwca_queue_alloc(ndev, priv, rdev->rx_queue, false, RX_RING_SIZE);
if (err < 0) {
rswitch_gwca_put(priv, rdev->rx_queue);
return err;
Expand Down
1 change: 0 additions & 1 deletion drivers/net/ethernet/renesas/rswitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,6 @@ struct rswitch_etha {
struct rswitch_gwca_queue {
int index;
bool dir_tx;
bool gptp;
union {
struct rswitch_ext_desc *tx_ring;
struct rswitch_ext_ts_desc *rx_ring;
Expand Down

0 comments on commit 48cf0a2

Please sign in to comment.