linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2] net: ethernet: ti: am65-cpsw-nuss: Fix skb size by accounting for skb_shared_info
@ 2025-06-26  5:12 Chintan Vankar
  2025-06-26  6:07 ` Siddharth Vadapalli
  2025-06-28  0:08 ` Jakub Kicinski
  0 siblings, 2 replies; 4+ messages in thread
From: Chintan Vankar @ 2025-06-26  5:12 UTC (permalink / raw)
  To: andrew+netdev, davem, edumazet, kuba, pabeni, rogerq, horms,
	mwalle, jacob.e.keller, jpanis
  Cc: s-vadapalli, danishanwar, netdev, linux-kernel, Chintan Vankar

While transitioning from netdev_alloc_ip_align() to build_skb(), memory
for the "skb_shared_info" member of an "skb" was not allocated. Fix this
by including sizeof(skb_shared_info) in the packet length during
allocation.

Fixes: 8acacc40f733 ("net: ethernet: ti: am65-cpsw: Add minimal XDP support")
Signed-off-by: Chintan Vankar <c-vankar@ti.com>
---

This patch is based on the commit '9caca6ac0e26' of origin/main branch of
Linux-net repository.

Link to v1:
https://lore.kernel.org/r/598f9e77-8212-426b-97ab-427cb8bd4910@ti.com/

Changes from v1 to v2:
- Updated commit message and code change as suggested by Siddharth
  Vadapalli.

 drivers/net/ethernet/ti/am65-cpsw-nuss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index f20d1ff192ef..67fef2ea4900 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -856,7 +856,7 @@ static struct sk_buff *am65_cpsw_build_skb(void *page_addr,
 {
 	struct sk_buff *skb;
 
-	len += AM65_CPSW_HEADROOM;
+	len += AM65_CPSW_HEADROOM + SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
 
 	skb = build_skb(page_addr, len);
 	if (unlikely(!skb))
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net v2] net: ethernet: ti: am65-cpsw-nuss: Fix skb size by accounting for skb_shared_info
  2025-06-26  5:12 [PATCH net v2] net: ethernet: ti: am65-cpsw-nuss: Fix skb size by accounting for skb_shared_info Chintan Vankar
@ 2025-06-26  6:07 ` Siddharth Vadapalli
  2025-06-28  0:08 ` Jakub Kicinski
  1 sibling, 0 replies; 4+ messages in thread
From: Siddharth Vadapalli @ 2025-06-26  6:07 UTC (permalink / raw)
  To: Chintan Vankar
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, rogerq, horms,
	mwalle, jacob.e.keller, jpanis, s-vadapalli, danishanwar, netdev,
	linux-kernel

On Thu, Jun 26, 2025 at 10:42:26AM +0530, Chintan Vankar wrote:
> While transitioning from netdev_alloc_ip_align() to build_skb(), memory
> for the "skb_shared_info" member of an "skb" was not allocated. Fix this
> by including sizeof(skb_shared_info) in the packet length during
> allocation.
> 
> Fixes: 8acacc40f733 ("net: ethernet: ti: am65-cpsw: Add minimal XDP support")
> Signed-off-by: Chintan Vankar <c-vankar@ti.com>
> ---
> 
> This patch is based on the commit '9caca6ac0e26' of origin/main branch of
> Linux-net repository.
> 
> Link to v1:
> https://lore.kernel.org/r/598f9e77-8212-426b-97ab-427cb8bd4910@ti.com/
> 
> Changes from v1 to v2:
> - Updated commit message and code change as suggested by Siddharth
>   Vadapalli.

Thank you for addressing the feedback on the v1 patch.

Reviewed-by: Siddharth Vadapalli <s-vadapalli@ti.com>

Regards,
Siddharth.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net v2] net: ethernet: ti: am65-cpsw-nuss: Fix skb size by accounting for skb_shared_info
  2025-06-26  5:12 [PATCH net v2] net: ethernet: ti: am65-cpsw-nuss: Fix skb size by accounting for skb_shared_info Chintan Vankar
  2025-06-26  6:07 ` Siddharth Vadapalli
@ 2025-06-28  0:08 ` Jakub Kicinski
  2025-07-03  5:23   ` Chintan Vankar
  1 sibling, 1 reply; 4+ messages in thread
From: Jakub Kicinski @ 2025-06-28  0:08 UTC (permalink / raw)
  To: Chintan Vankar
  Cc: andrew+netdev, davem, edumazet, pabeni, rogerq, horms, mwalle,
	jacob.e.keller, jpanis, s-vadapalli, danishanwar, netdev,
	linux-kernel

On Thu, 26 Jun 2025 10:42:26 +0530 Chintan Vankar wrote:
> While transitioning from netdev_alloc_ip_align() to build_skb(), memory
> for the "skb_shared_info" member of an "skb" was not allocated. Fix this
> by including sizeof(skb_shared_info) in the packet length during
> allocation.
> 
> Fixes: 8acacc40f733 ("net: ethernet: ti: am65-cpsw: Add minimal XDP support")
> Signed-off-by: Chintan Vankar <c-vankar@ti.com>
> ---
> 
> This patch is based on the commit '9caca6ac0e26' of origin/main branch of
> Linux-net repository.
> 
> Link to v1:
> https://lore.kernel.org/r/598f9e77-8212-426b-97ab-427cb8bd4910@ti.com/
> 
> Changes from v1 to v2:
> - Updated commit message and code change as suggested by Siddharth
>   Vadapalli.
> 
>  drivers/net/ethernet/ti/am65-cpsw-nuss.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> index f20d1ff192ef..67fef2ea4900 100644
> --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> @@ -856,7 +856,7 @@ static struct sk_buff *am65_cpsw_build_skb(void *page_addr,
>  {
>  	struct sk_buff *skb;
>  
> -	len += AM65_CPSW_HEADROOM;
> +	len += AM65_CPSW_HEADROOM + SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
>  
>  	skb = build_skb(page_addr, len);

Looks to me like each packet is placed in a full page, isn't it?
If that's the case the correct value for "buffer size" is PAGE_SIZE
-- 
pw-bot: cr

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net v2] net: ethernet: ti: am65-cpsw-nuss: Fix skb size by accounting for skb_shared_info
  2025-06-28  0:08 ` Jakub Kicinski
@ 2025-07-03  5:23   ` Chintan Vankar
  0 siblings, 0 replies; 4+ messages in thread
From: Chintan Vankar @ 2025-07-03  5:23 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: andrew+netdev, davem, edumazet, pabeni, rogerq, horms, mwalle,
	jacob.e.keller, jpanis, s-vadapalli, danishanwar, netdev,
	linux-kernel

Hello Jakub,

On 28/06/25 05:38, Jakub Kicinski wrote:
> On Thu, 26 Jun 2025 10:42:26 +0530 Chintan Vankar wrote:
>> While transitioning from netdev_alloc_ip_align() to build_skb(), memory
>> for the "skb_shared_info" member of an "skb" was not allocated. Fix this
>> by including sizeof(skb_shared_info) in the packet length during
>> allocation.
>>
>> Fixes: 8acacc40f733 ("net: ethernet: ti: am65-cpsw: Add minimal XDP support")
>> Signed-off-by: Chintan Vankar <c-vankar@ti.com>
>> ---
>>
>> This patch is based on the commit '9caca6ac0e26' of origin/main branch of
>> Linux-net repository.
>>
>> Link to v1:
>> https://lore.kernel.org/r/598f9e77-8212-426b-97ab-427cb8bd4910@ti.com/
>>
>> Changes from v1 to v2:
>> - Updated commit message and code change as suggested by Siddharth
>>    Vadapalli.
>>
>>   drivers/net/ethernet/ti/am65-cpsw-nuss.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
>> index f20d1ff192ef..67fef2ea4900 100644
>> --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
>> +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
>> @@ -856,7 +856,7 @@ static struct sk_buff *am65_cpsw_build_skb(void *page_addr,
>>   {
>>   	struct sk_buff *skb;
>>   
>> -	len += AM65_CPSW_HEADROOM;
>> +	len += AM65_CPSW_HEADROOM + SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
>>   
>>   	skb = build_skb(page_addr, len);
> 
> Looks to me like each packet is placed in a full page, isn't it?
> If that's the case the correct value for "buffer size" is PAGE_SIZE


Thanks for reviewing the patch and pointing this out. Since the maximum
packet size received from the wire is AM65_CPSW_MAX_PACKET_SIZE that is
2024 Bytes, after adding headroom and tailroom, the total Bytes will
remain below the minimum page size available that is 4096, it is better
to use PAGE_SIZE.

Regards,
Chintan.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-07-03  5:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-26  5:12 [PATCH net v2] net: ethernet: ti: am65-cpsw-nuss: Fix skb size by accounting for skb_shared_info Chintan Vankar
2025-06-26  6:07 ` Siddharth Vadapalli
2025-06-28  0:08 ` Jakub Kicinski
2025-07-03  5:23   ` Chintan Vankar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).