octeon_ep: fix tx dma unmap len values in SG
Subsystems (3)
PATCH 1/1 octeon_ep: fix tx dma unmap len values in SG
Lengths of SG pointers are in big-endian
--- drivers/net/ethernet/marvell/octeon_ep/octep_tx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/octeon_ep/octep_tx.c +2 -2
@@ -69,12 +69,12 @@ int octep_iq_process_completions(struct octep_iq *iq, u16 budget) compl_sg++;dma_unmap_single (iq->dev, tx_buffer->sglist[0 ].dma_ptr[0 ], - tx_buffer->sglist[0 ].len[0 ],DMA_TO_DEVICE ); + tx_buffer->sglist[0 ].len[3 ],DMA_TO_DEVICE ); i =1 ;/* entry 0 is main skb, unmapped above */ while (frags--) {dma_unmap_page (iq->dev, tx_buffer->sglist[i >>2 ].dma_ptr[i &3 ], - tx_buffer->sglist[i >>2 ].len[i &3 ],DMA_TO_DEVICE ); + tx_buffer->sglist[i >>2 ].len[3 - (i &3 )],DMA_TO_DEVICE ); i++; }
Signature · 1 line
2.25.1
Simon Horman
reviewerQuoted 16 lines · Shinas Rasheed
Lengths of SG pointers are in big-endian
Fixes 37d79d059606 ("octeon_ep: add Tx/Rx processing and interrupt support")Signed-off-by Shinas Rasheed <[email protected]>--- drivers/net/ethernet/marvell/octeon_ep/octep_tx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/net/ethernet/marvell/octeon_ep/octep_tx.c +0
-0@@ -69,12 +69,12 @@ int octep_iq_process_completions(struct octep_iq *iq, u16 budget) compl_sg++; dma_unmap_single(iq->dev, tx_buffer->sglist[0].dma_ptr[0],
drivers/net/ethernet/marvell/octeon_ep/octep_tx.c int octep_iq_process_completions(struct octep_iq *iq, u16 budget) · line 79
Quoted 10 lines
drivers/net/ethernet/marvell/octeon_ep/octep_tx.c +2
-2- tx_buffer->sglist[0].len[0], DMA_TO_DEVICE); + tx_buffer->sglist[0].len[3], DMA_TO_DEVICE); i =1 ;/* entry 0 is main skb, unmapped above */ while (frags--) {dma_unmap_page (iq->dev, tx_buffer->sglist[i >>2 ].dma_ptr[i &3 ], - tx_buffer->sglist[i >>2 ].len[i &3 ],DMA_TO_DEVICE ); + tx_buffer->sglist[i >>2 ].len[3 - (i &3 )],DMA_TO_DEVICE ); i++; }
Hi Shinas,
is this change also needed in octep_iq_process_completions() ? The code there looks rather similar.
Hi Simon,
This change is required in octep_iq_process_completions, as given in the patch, since the scatter gather pointer lengths arrive as big-endian in hardware.
Paolo Abeni
maintainerQuoted 2 lines · Shinas Rasheed
This change is required in
octep_iq_process_completions, as given in the patch, since the scatter gather pointer lengths arrive as big-endian in hardware.
I guess Simon intended asking about octep_iq_free_pending(), and AFAICT your reply confirm that the change is required there, too.
Additionally the changelog really need to be expanded. I don't understand how this change relates to endianess: if the ring format is big endian I expect some be16_to_cpu(len) instead of complement-to-4 of indexes.
Please clarify and expand the changelog, thanks!
Paolo
Hi Paolo, Hi Simon,
From: Paolo Abeni <[email protected]>
Sent: Tuesday, September 12, 2023 2:15 PM
To: Shinas Rasheed <[email protected]>; [email protected] <[email protected]>
Cc: Abhijit Ayarekar <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; Haseeb Gani <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; Satananda Burla <[email protected]>; Sathesh B Edara <[email protected]>; Veerasenareddy Burru <[email protected]>; Vimlesh Kumar <[email protected]>
Subject: [EXT] Re: [net PATCH] octeon_ep: fix tx dma unmap len values in SG
External Email
----------------------------------------------------------------------
Quoted 1 line
I guess Simon intended asking about
octep_iq_free_pending(), and AFAICT
your reply confirm that the change is required there, too.
You are correct in that the change is also required in octep_iq_free_pending as well. Thanks for pointing that out! I will submit another version of this patchset including that.
Quoted 1 line
Additionally the changelog really need to be expanded. I don't
understand how this change relates to endianess: if the ring format is big endian I expect some be16_to_cpu(len) instead of complement-to-4 of indexes.
The bytes are in itself not big endian, but rather the each of the 16 bytes are kept in memory in a kind of big-endian order. Apologizing for the confusion.
63 48 47 32 31 16 15 0
| Len0 | Len1 | Len2 | Len3 |
I shall provide an ascii figure like above in the code to explain and also update the changelog accordingly. Thanks for your time!
PATCH v2 1/1 octeon_ep: fix tx dma unmap len values in SG
Lengths of SG pointers are kept in the following order in the SG entries in hardware.
63 48|47 32|31 16|15 0
-----------------------------------------
| Len 0 | Len 1 | Len 2 | Len 3 |
-----------------------------------------
| Ptr 0 |
-----------------------------------------
| Ptr 1 |
-----------------------------------------
| Ptr 2 |
-----------------------------------------
| Ptr 3 |
-----------------------------------------
Dma pointers have to be unmapped based on their respective lengths given in this format.
--- .../net/ethernet/marvell/octeon_ep/octep_main.c | 8 ++++---- .../net/ethernet/marvell/octeon_ep/octep_tx.c | 8 ++++---- .../net/ethernet/marvell/octeon_ep/octep_tx.h | 16 +++++++++++++++- 3 files changed, 23 insertions(+), 9 deletions(-)
drivers/net/ethernet/marvell/octeon_ep/octep_main.c +4 -4
@@ -734,13 +734,13 @@ static netdev_tx_t octep_start_xmit(struct sk_buff *skb, dma_map_sg_err:if (si >0 ) {dma_unmap_single (iq->dev, sglist[0 ].dma_ptr[0 ], - sglist[0 ].len[0 ],DMA_TO_DEVICE ); - sglist[0 ].len[0 ] =0 ; + sglist[0 ].len[3 ],DMA_TO_DEVICE ); + sglist[0 ].len[3 ] =0 ; }while (si >1 ) {dma_unmap_page (iq->dev, sglist[si >>2 ].dma_ptr[si &3 ], - sglist[si >>2 ].len[si &3 ],DMA_TO_DEVICE ); - sglist[si >>2 ].len[si &3 ] =0 ; + sglist[si >>2 ].len[3 - (si &3 )],DMA_TO_DEVICE ); + sglist[si >>2 ].len[3 - (si &3 )] =0 ; si--; } tx_buffer->gather =0 ;
drivers/net/ethernet/marvell/octeon_ep/octep_tx.c +4 -4
@@ -69,12 +69,12 @@ int octep_iq_process_completions(struct octep_iq *iq, u16 budget) compl_sg++;dma_unmap_single (iq->dev, tx_buffer->sglist[0 ].dma_ptr[0 ], - tx_buffer->sglist[0 ].len[0 ],DMA_TO_DEVICE ); + tx_buffer->sglist[0 ].len[3 ],DMA_TO_DEVICE ); i =1 ;/* entry 0 is main skb, unmapped above */ while (frags--) {dma_unmap_page (iq->dev, tx_buffer->sglist[i >>2 ].dma_ptr[i &3 ], - tx_buffer->sglist[i >>2 ].len[i &3 ],DMA_TO_DEVICE ); + tx_buffer->sglist[i >>2 ].len[3 - (i &3 )],DMA_TO_DEVICE ); i++; }
@@ -131,13 +131,13 @@ static void octep_iq_free_pending(struct octep_iq *iq)dma_unmap_single (iq->dev, tx_buffer->sglist[0 ].dma_ptr[0 ], - tx_buffer->sglist[0 ].len[0 ], + tx_buffer->sglist[0 ].len[3 ],DMA_TO_DEVICE ); i =1 ;/* entry 0 is main skb, unmapped above */ while (frags--) {dma_unmap_page (iq->dev, tx_buffer->sglist[i >>2 ].dma_ptr[i &3 ], - tx_buffer->sglist[i >>2 ].len[i &3 ],DMA_TO_DEVICE ); + tx_buffer->sglist[i >>2 ].len[3 - (i &3 )],DMA_TO_DEVICE ); i++; }
drivers/net/ethernet/marvell/octeon_ep/octep_tx.h +15 -1
@@ -17,7 +17,21 @@#define TX_BUFTYPE_NET_SG 2#define NUM_TX_BUFTYPES 3 -/* Hardware format for Scatter/Gather list */ +/* Hardware format for Scatter/Gather list +* +* 63 48|47 32|31 16|15 0 +* ----------------------------------------- +* | Len 0 | Len 1 | Len 2 | Len 3 | +* ----------------------------------------- +* | Ptr 0 | +* ----------------------------------------- +* | Ptr 1 | +* ----------------------------------------- +* | Ptr 2 | +* ----------------------------------------- +* | Ptr 3 | +* ----------------------------------------- +*/ struct octep_tx_sglist_desc {u16 len[4 ];dma_addr_t dma_ptr[4 ];
Signature · 1 line
2.25.1
Quoted 17 lines · Shinas Rasheed
Lengths of SG pointers are kept in the following order in the SG entries in hardware.
63 48|47 32|31 16|15 0
-----------------------------------------
| Len 0 | Len 1 | Len 2 | Len 3 |
-----------------------------------------
| Ptr 0 |
-----------------------------------------
| Ptr 1 |
-----------------------------------------
| Ptr 2 |
-----------------------------------------
| Ptr 3 |
-----------------------------------------
Dma pointers have to be unmapped based on their respective lengths given in this format.
Quoted 2 lines
Fixes 37d79d059606 ("octeon_ep: add Tx/Rx processing and interrupt support")Signed-off-by Shinas Rasheed <[email protected]>
This patch was applied to netdev/net.git (main) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:
Quoted 9 lines · On Wed, 13 Sep 2023 01:41:56 -0700 you wrote:
Lengths of SG pointers are kept in the following order in the SG entries in hardware.
63 48|47 32|31 16|15 0
-----------------------------------------
| Len 0 | Len 1 | Len 2 | Len 3 |
-----------------------------------------
| Ptr 0 |[...]
Here is the summary with links:
- [net,v2] octeon_ep: fix tx dma unmap len values in SG
https://git.kernel.org/netdev/net/c/350db8a59eb3
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
A message that is not in the archive (sent off-list or not yet received): PH0PR18MB473404EA35ADAC222C9EB68FC7F1A@PH0PR18MB4734.namprd18.prod.outlook.com
Simon Horman
reviewerQuoted 3 lines · Shinas Rasheed
Hi Simon,
This change is required in
octep_iq_process_completions, as given in the patch, since the scatter gather pointer lengths arrive as big-endian in hardware.
Hi,
yes, I see that. And sorry for asking such a silly question. But what I meant to ask is, if the change is also needed in octep_iq_free_pending()?