Skip to contentSkip to conversation

net: ethernet: ti: cpsw/emac: switch to use skb_put_padto()

PATCH Applied Grygorii Strashko 3 participants 8 messages Aug 5, 2021 – Aug 6, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover net: ethernet: ti: cpsw/emac: switch to use skb_put_padto()

hi

Now frame padding in TI TI CPSW/EMAC is implemented in a bit of entangled way as frame SKB padded in drivers (without skb->len) while frame length fixed in CPDMA. Things became even more confusing hence CPSW switcdev driver need to perform min TX frame length correction in switch mode [1].

To avoid further confusion, make xmit path more clear and linear, and avoid updating CPDMA configuration interface for min TX frame length correction (which is not CPDMA job in general) this series switches TI CPSW/EMAC drivers to skb_put_padto() instead of skb_padto() in their xmit path, so skb->len also got updated properly and then removes TX frame length fixup from CPDMA code.

[1] https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/

Grygorii Strashko (3):
net: ethernet: ti: cpsw: switch to use skb_put_padto()
net: ethernet: ti: davinci_emac: switch to use skb_put_padto()
net: ethernet: ti: davinci_cpdma: drop frame padding

 drivers/net/ethernet/ti/cpsw.c          | 2 +-
 drivers/net/ethernet/ti/cpsw_priv.c     | 1 -
 drivers/net/ethernet/ti/davinci_cpdma.c | 5 -----
 drivers/net/ethernet/ti/davinci_cpdma.h | 1 -
 drivers/net/ethernet/ti/davinci_emac.c  | 3 +--
 5 files changed, 2 insertions(+), 10 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/3 net: ethernet: ti: cpsw: switch to use skb_put_padto()

Use skb_put_padto() instead of skb_padto() so skb->len also got updated, as preparation for further removing frame padding from cpdma.
It also makes xmit path more clear and linear.

---
 drivers/net/ethernet/ti/cpsw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/ti/cpsw.c +1 -1
index abf9a2a6f7eb..8e1e582a10c8 100644
@@ -905,7 +905,7 @@ static netdev_tx_t cpsw_ndo_start_xmit(struct sk_buff *skb,
 	struct cpdma_chan *txch;
 	int ret, q_idx;
 
-	if (skb_padto(skb, CPSW_MIN_PACKET_SIZE)) {
+	if (skb_put_padto(skb, CPSW_MIN_PACKET_SIZE)) {
 		cpsw_err(priv, tx_err, "packet pad failed\n");
 		ndev->stats.tx_dropped++;
 		return NET_XMIT_DROP;
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/3 net: ethernet: ti: davinci_emac: switch to use skb_put_padto()

In reply to Grygorii Strashko

Use skb_put_padto() instead of skb_padto() so skb->len also got updated, as preparation for further removing frame padding from cpdma.
It also makes xmit path more clear and linear.

---
 drivers/net/ethernet/ti/davinci_emac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/ti/davinci_emac.c +1 -1
index 637796670746..b1c5cbe7478b 100644
@@ -943,7 +943,7 @@ static int emac_dev_xmit(struct sk_buff *skb, struct net_device *ndev)
 		goto fail_tx;
 	}
 
-	ret_code = skb_padto(skb, EMAC_DEF_MIN_ETHPKTSIZE);
+	ret_code = skb_put_padto(skb, EMAC_DEF_MIN_ETHPKTSIZE);
 	if (unlikely(ret_code < 0)) {
 		if (netif_msg_tx_err(priv) && net_ratelimit())
 			dev_err(emac_dev, "DaVinci EMAC: packet pad failed");
Signature · 1 line
2.17.1
#3 lore raw

PATCH 3/3 net: ethernet: ti: davinci_cpdma: drop frame padding

In reply to Grygorii Strashko

Hence all users of davinci_cpdma switched to skb_put_padto() the frame padding can be removed from it.

---
 drivers/net/ethernet/ti/cpsw_priv.c     | 1 -
 drivers/net/ethernet/ti/davinci_cpdma.c | 5 -----
 drivers/net/ethernet/ti/davinci_cpdma.h | 1 -
 drivers/net/ethernet/ti/davinci_emac.c  | 1 -
 4 files changed, 8 deletions(-)
drivers/net/ethernet/ti/cpsw_priv.c +0 -1
index ecc2a6b7e28f..d97a72c9ec53 100644
@@ -518,7 +518,6 @@ int cpsw_init_common(struct cpsw_common *cpsw, void __iomem *ss_regs,
 
 	dma_params.num_chan		= data->channels;
 	dma_params.has_soft_reset	= true;
-	dma_params.min_packet_size	= CPSW_MIN_PACKET_SIZE;
 	dma_params.desc_mem_size	= data->bd_ram_size;
 	dma_params.desc_align		= 16;
 	dma_params.has_ext_regs		= true;
drivers/net/ethernet/ti/davinci_cpdma.c +0 -5
index d2eab5cd1e0c..753d94c9915a 100644
@@ -1034,11 +1034,6 @@ static int cpdma_chan_submit_si(struct submit_info *si)
 		return -ENOMEM;
 	}
 
-	if (len < ctlr->params.min_packet_size) {
-		len = ctlr->params.min_packet_size;
-		chan->stats.runt_transmit_buff++;
-	}
-
 	mode = CPDMA_DESC_OWNER | CPDMA_DESC_SOP | CPDMA_DESC_EOP;
 	cpdma_desc_to_port(chan, mode, si->directed);
 
drivers/net/ethernet/ti/davinci_cpdma.h +0 -1
index d3cfe234d16a..62151f13c7ce 100644
@@ -26,7 +26,6 @@ struct cpdma_params {
 	void __iomem		*rxthresh, *rxfree;
 	int			num_chan;
 	bool			has_soft_reset;
-	int			min_packet_size;
 	dma_addr_t		desc_mem_phys;
 	dma_addr_t		desc_hw_addr;
 	int			desc_mem_size;
drivers/net/ethernet/ti/davinci_emac.c +0 -1
index b1c5cbe7478b..cd2ef0282f38 100644
@@ -1850,7 +1850,6 @@ static int davinci_emac_probe(struct platform_device *pdev)
 	dma_params.txcp			= priv->emac_base + 0x640;
 	dma_params.rxcp			= priv->emac_base + 0x660;
 	dma_params.num_chan		= EMAC_MAX_TXRX_CHANNELS;
-	dma_params.min_packet_size	= EMAC_DEF_MIN_ETHPKTSIZE;
 	dma_params.desc_hw_addr		= hw_ram_addr;
 	dma_params.desc_mem_size	= pdata->ctrl_ram_size;
 	dma_params.desc_align		= 16;
Signature · 1 line
2.17.1
#4 lore raw
In reply to Grygorii Strashko
This series was applied to netdev/net-next.git (refs/heads/master):

Hello:

This series was applied to netdev/net-next.git (refs/heads/master):

Quoted 8 lines · On Thu, 5 Aug 2021 17:55:52 +0300 you wrote:

hi

Now frame padding in TI TI CPSW/EMAC is implemented in a bit of entangled way as frame SKB padded in drivers (without skb->len) while frame length fixed in CPDMA. Things became even more confusing hence CPSW switcdev driver need to perform min TX frame length correction in switch mode [1].

[...]

Here is the summary with links:
- [net-next,1/3] net: ethernet: ti: cpsw: switch to use skb_put_padto()

    https://git.kernel.org/netdev/net-next/c/1f88d5d566b8
  - [net-next,2/3] net: ethernet: ti: davinci_emac: switch to use skb_put_padto()
    https://git.kernel.org/netdev/net-next/c/61e7a22da75b
  - [net-next,3/3] net: ethernet: ti: davinci_cpdma: drop frame padding
    https://git.kernel.org/netdev/net-next/c/9ffc513f95ee

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html

#5 lore raw

hi Jakub, David,

Quoted 14 lines · On 06/08/2021 12:30, [email protected] wrote:

Hello:

This series was applied to netdev/net-next.git (refs/heads/master):

Quoted 8 lines · On Thu, 5 Aug 2021 17:55:52 +0300 you wrote:

hi

Now frame padding in TI TI CPSW/EMAC is implemented in a bit of entangled way as frame SKB padded in drivers (without skb->len) while frame length fixed in CPDMA. Things became even more confusing hence CPSW switcdev driver need to perform min TX frame length correction in switch mode [1].

[...]

Quoted 7 lines

Here is the summary with links:
- [net-next,1/3] net: ethernet: ti: cpsw: switch to use skb_put_padto()

     https://git.kernel.org/netdev/net-next/c/1f88d5d566b8
   - [net-next,2/3] net: ethernet: ti: davinci_emac: switch to use skb_put_padto()
     https://git.kernel.org/netdev/net-next/c/61e7a22da75b
   - [net-next,3/3] net: ethernet: ti: davinci_cpdma: drop frame padding
     https://git.kernel.org/netdev/net-next/c/9ffc513f95ee

I'm terribly sorry for the mess here - this series depends from patch "net: ethernet: ti: cpsw: fix min eth packet size for non-switch use-cases" [1]

Not sure what I've being thinking about I've had to note it or include in this series :(

I'm very sorry again - can it be dropped?

[1] https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/

Signature · 2 lines
Best regards,
grygorii
maintainer
#6 lore raw

From: Grygorii Strashko <[email protected]>
Date: Fri, 6 Aug 2021 13:00:30 +0300

Quoted 2 lines

I'm very sorry again - can it be dropped?

Easiest is for you to send a fixup or a revert to the list, thanks.

#7 lore raw
Quoted 9 lines · David Miller

From: Grygorii Strashko <[email protected]>
Date: Fri, 6 Aug 2021 13:00:30 +0300

Quoted 2 lines

I'm very sorry again - can it be dropped?

Easiest is for you to send a fixup or a revert to the list, thanks.

Only Patch 3 need to be reverted - i'll send revert. Thank you.

Signature · 2 lines
Best regards,
grygorii