Skip to content

Commit 48cf0a2

Browse files
shimodaykuba-moo
authored andcommitted
net: renesas: rswitch: Remove gptp flag from rswitch_gwca_queue
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>
1 parent e3f3803 commit 48cf0a2

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

drivers/net/ethernet/renesas/rswitch.c

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -280,54 +280,52 @@ static void rswitch_gwca_queue_free(struct net_device *ndev,
280280
{
281281
int i;
282282

283-
if (gq->gptp) {
283+
if (!gq->dir_tx) {
284284
dma_free_coherent(ndev->dev.parent,
285285
sizeof(struct rswitch_ext_ts_desc) *
286286
(gq->ring_size + 1), gq->rx_ring, gq->ring_dma);
287287
gq->rx_ring = NULL;
288+
289+
for (i = 0; i < gq->ring_size; i++)
290+
dev_kfree_skb(gq->skbs[i]);
288291
} else {
289292
dma_free_coherent(ndev->dev.parent,
290293
sizeof(struct rswitch_ext_desc) *
291294
(gq->ring_size + 1), gq->tx_ring, gq->ring_dma);
292295
gq->tx_ring = NULL;
293296
}
294297

295-
if (!gq->dir_tx) {
296-
for (i = 0; i < gq->ring_size; i++)
297-
dev_kfree_skb(gq->skbs[i]);
298-
}
299-
300298
kfree(gq->skbs);
301299
gq->skbs = NULL;
302300
}
303301

304302
static int rswitch_gwca_queue_alloc(struct net_device *ndev,
305303
struct rswitch_private *priv,
306304
struct rswitch_gwca_queue *gq,
307-
bool dir_tx, bool gptp, int ring_size)
305+
bool dir_tx, int ring_size)
308306
{
309307
int i, bit;
310308

311309
gq->dir_tx = dir_tx;
312-
gq->gptp = gptp;
313310
gq->ring_size = ring_size;
314311
gq->ndev = ndev;
315312

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

320-
if (!dir_tx)
317+
if (!dir_tx) {
321318
rswitch_gwca_queue_alloc_skb(gq, 0, gq->ring_size);
322319

323-
if (gptp)
324320
gq->rx_ring = dma_alloc_coherent(ndev->dev.parent,
325321
sizeof(struct rswitch_ext_ts_desc) *
326322
(gq->ring_size + 1), &gq->ring_dma, GFP_KERNEL);
327-
else
323+
} else {
328324
gq->tx_ring = dma_alloc_coherent(ndev->dev.parent,
329325
sizeof(struct rswitch_ext_desc) *
330326
(gq->ring_size + 1), &gq->ring_dma, GFP_KERNEL);
327+
}
328+
331329
if (!gq->rx_ring && !gq->tx_ring)
332330
goto out;
333331

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

542-
err = rswitch_gwca_queue_alloc(ndev, priv, rdev->tx_queue, true, false,
543-
TX_RING_SIZE);
540+
err = rswitch_gwca_queue_alloc(ndev, priv, rdev->tx_queue, true, TX_RING_SIZE);
544541
if (err < 0) {
545542
rswitch_gwca_put(priv, rdev->tx_queue);
546543
return err;
@@ -574,8 +571,7 @@ static int rswitch_rxdmac_alloc(struct net_device *ndev)
574571
if (!rdev->rx_queue)
575572
return -EBUSY;
576573

577-
err = rswitch_gwca_queue_alloc(ndev, priv, rdev->rx_queue, false, true,
578-
RX_RING_SIZE);
574+
err = rswitch_gwca_queue_alloc(ndev, priv, rdev->rx_queue, false, RX_RING_SIZE);
579575
if (err < 0) {
580576
rswitch_gwca_put(priv, rdev->rx_queue);
581577
return err;

drivers/net/ethernet/renesas/rswitch.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,6 @@ struct rswitch_etha {
913913
struct rswitch_gwca_queue {
914914
int index;
915915
bool dir_tx;
916-
bool gptp;
917916
union {
918917
struct rswitch_ext_desc *tx_ring;
919918
struct rswitch_ext_ts_desc *rx_ring;

0 commit comments

Comments
 (0)