Skip to content

Commit 87388cb

Browse files
shimodaygregkh
authored andcommitted
net: rswitch: Add a setting ext descriptor function
[ Upstream commit fcff581 ] If the driver would like to transmit a jumbo frame like 2KiB or more, it should be split into multiple queues. In the near future, to support this, add a setting ext descriptor function to improve code readability. Signed-off-by: Yoshihiro Shimoda <[email protected]> Signed-off-by: David S. Miller <[email protected]> Stable-dep-of: 0c9547e ("net: renesas: rswitch: fix race window between tx start and complete") Signed-off-by: Sasha Levin <[email protected]>
1 parent 0aeec4b commit 87388cb

File tree

1 file changed

+47
-26
lines changed

1 file changed

+47
-26
lines changed

drivers/net/ethernet/renesas/rswitch.c

Lines changed: 47 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,6 +1516,51 @@ static int rswitch_stop(struct net_device *ndev)
15161516
return 0;
15171517
};
15181518

1519+
static bool rswitch_ext_desc_set_info1(struct rswitch_device *rdev,
1520+
struct sk_buff *skb,
1521+
struct rswitch_ext_desc *desc)
1522+
{
1523+
desc->info1 = cpu_to_le64(INFO1_DV(BIT(rdev->etha->index)) |
1524+
INFO1_IPV(GWCA_IPV_NUM) | INFO1_FMT);
1525+
if (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) {
1526+
struct rswitch_gwca_ts_info *ts_info;
1527+
1528+
ts_info = kzalloc(sizeof(*ts_info), GFP_ATOMIC);
1529+
if (!ts_info)
1530+
return false;
1531+
1532+
skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
1533+
rdev->ts_tag++;
1534+
desc->info1 |= cpu_to_le64(INFO1_TSUN(rdev->ts_tag) | INFO1_TXC);
1535+
1536+
ts_info->skb = skb_get(skb);
1537+
ts_info->port = rdev->port;
1538+
ts_info->tag = rdev->ts_tag;
1539+
list_add_tail(&ts_info->list, &rdev->priv->gwca.ts_info_list);
1540+
1541+
skb_tx_timestamp(skb);
1542+
}
1543+
1544+
return true;
1545+
}
1546+
1547+
static bool rswitch_ext_desc_set(struct rswitch_device *rdev,
1548+
struct sk_buff *skb,
1549+
struct rswitch_ext_desc *desc,
1550+
dma_addr_t dma_addr, u16 len, u8 die_dt)
1551+
{
1552+
rswitch_desc_set_dptr(&desc->desc, dma_addr);
1553+
desc->desc.info_ds = cpu_to_le16(len);
1554+
if (!rswitch_ext_desc_set_info1(rdev, skb, desc))
1555+
return false;
1556+
1557+
dma_wmb();
1558+
1559+
desc->desc.die_dt = die_dt;
1560+
1561+
return true;
1562+
}
1563+
15191564
static netdev_tx_t rswitch_start_xmit(struct sk_buff *skb, struct net_device *ndev)
15201565
{
15211566
struct rswitch_device *rdev = netdev_priv(ndev);
@@ -1539,33 +1584,9 @@ static netdev_tx_t rswitch_start_xmit(struct sk_buff *skb, struct net_device *nd
15391584
gq->skbs[gq->cur] = skb;
15401585
gq->unmap_addrs[gq->cur] = dma_addr;
15411586
desc = &gq->tx_ring[gq->cur];
1542-
rswitch_desc_set_dptr(&desc->desc, dma_addr);
1543-
desc->desc.info_ds = cpu_to_le16(skb->len);
1544-
1545-
desc->info1 = cpu_to_le64(INFO1_DV(BIT(rdev->etha->index)) |
1546-
INFO1_IPV(GWCA_IPV_NUM) | INFO1_FMT);
1547-
if (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) {
1548-
struct rswitch_gwca_ts_info *ts_info;
1549-
1550-
ts_info = kzalloc(sizeof(*ts_info), GFP_ATOMIC);
1551-
if (!ts_info)
1552-
goto err_unmap;
1553-
1554-
skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
1555-
rdev->ts_tag++;
1556-
desc->info1 |= cpu_to_le64(INFO1_TSUN(rdev->ts_tag) | INFO1_TXC);
1557-
1558-
ts_info->skb = skb_get(skb);
1559-
ts_info->port = rdev->port;
1560-
ts_info->tag = rdev->ts_tag;
1561-
list_add_tail(&ts_info->list, &rdev->priv->gwca.ts_info_list);
1562-
1563-
skb_tx_timestamp(skb);
1564-
}
1565-
1566-
dma_wmb();
1587+
if (!rswitch_ext_desc_set(rdev, skb, desc, dma_addr, skb->len, DT_FSINGLE | DIE))
1588+
goto err_unmap;
15671589

1568-
desc->desc.die_dt = DT_FSINGLE | DIE;
15691590
wmb(); /* gq->cur must be incremented after die_dt was set */
15701591

15711592
gq->cur = rswitch_next_queue_index(gq, true, 1);

0 commit comments

Comments
 (0)