mbox series

[net-next,v5,0/3] Add minimal XDP support to TI AM65 CPSW Ethernet driver

Message ID 20240223-am65-cpsw-xdp-basic-v5-0-bc1739170bc6@baylibre.com
Headers show
Series Add minimal XDP support to TI AM65 CPSW Ethernet driver | expand

Message

Julien Panis March 28, 2024, 9:26 a.m. UTC
This patch adds XDP support to TI AM65 CPSW Ethernet driver.

The following features are implemented: NETDEV_XDP_ACT_BASIC,
NETDEV_XDP_ACT_REDIRECT, and NETDEV_XDP_ACT_NDO_XMIT.

Zero-copy and non-linear XDP buffer supports are NOT implemented.

Besides, the page pool memory model is used to get better performance.

Signed-off-by: Julien Panis <jpanis@baylibre.com>
---
Changes in v5:
- In k3_cppi_desc_pool_destroy(), free memory allocated for desc_infos.
- Link to v4: https://lore.kernel.org/r/20240223-am65-cpsw-xdp-basic-v4-0-2e45e5dec048@baylibre.com

Changes in v4:
- Add skb_mark_for_recycle() in am65_cpsw_nuss_rx_packets() function.
- Specify napi page pool parameter in am65_cpsw_create_xdp_rxqs() function.
- Add benchmark numbers (with VS without page pool) in the commit description.
- Add xdp_do_flush() in am65_cpsw_run_xdp() function for XDP_REDIRECT case.
- Link to v3: https://lore.kernel.org/r/20240223-am65-cpsw-xdp-basic-v3-0-5d944a9d84a0@baylibre.com

Changes in v3:
- Fix a potential issue with TX buffer type, which is now set for each buffer.
- Link to v2: https://lore.kernel.org/r/20240223-am65-cpsw-xdp-basic-v2-0-01c6caacabb6@baylibre.com

Changes in v2:
- Use page pool memory model instead of MEM_TYPE_PAGE_ORDER0.
- In am65_cpsw_alloc_skb(), release reference on the page pool page
in case of error returned by build_skb().
- [nit] Cleanup am65_cpsw_nuss_common_open/stop() functions.
- [nit] Arrange local variables in reverse xmas tree order.
- Link to v1: https://lore.kernel.org/r/20240223-am65-cpsw-xdp-basic-v1-1-9f0b6cbda310@baylibre.com

---
Julien Panis (3):
      net: ethernet: ti: Add accessors for struct k3_cppi_desc_pool members
      net: ethernet: ti: Add desc_infos member to struct k3_cppi_desc_pool
      net: ethernet: ti: am65-cpsw: Add minimal XDP support

 drivers/net/ethernet/ti/am65-cpsw-nuss.c    | 536 +++++++++++++++++++++++++---
 drivers/net/ethernet/ti/am65-cpsw-nuss.h    |  13 +
 drivers/net/ethernet/ti/k3-cppi-desc-pool.c |  37 ++
 drivers/net/ethernet/ti/k3-cppi-desc-pool.h |   4 +
 4 files changed, 540 insertions(+), 50 deletions(-)
---
base-commit: 6613476e225e090cc9aad49be7fa504e290dd33d
change-id: 20240223-am65-cpsw-xdp-basic-4db828508b48

Best regards,

Comments

Julien Panis March 28, 2024, 12:25 p.m. UTC | #1
On 3/28/24 13:06, Naveen Mamindlapalli wrote:
>> -----Original Message-----
>> From: Julien Panis <jpanis@baylibre.com>
>> Sent: Thursday, March 28, 2024 2:57 PM
>> To: David S. Miller <davem@davemloft.net>; Eric Dumazet
>> <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>; Paolo Abeni
>> <pabeni@redhat.com>; Russell King <linux@armlinux.org.uk>; Alexei Starovoitov
>> <ast@kernel.org>; Daniel Borkmann <daniel@iogearbox.net>; Jesper Dangaard
>> Brouer <hawk@kernel.org>; John Fastabend <john.fastabend@gmail.com>;
>> Sumit Semwal <sumit.semwal@linaro.org>; Christian König
>> <christian.koenig@amd.com>; Simon Horman <horms@kernel.org>; Andrew
>> Lunn <andrew@lunn.ch>; Ratheesh Kannoth <rkannoth@marvell.com>
>> Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org; bpf@vger.kernel.org;
>> linux-media@vger.kernel.org; dri-devel@lists.freedesktop.org; linaro-mm-
>> sig@lists.linaro.org; Julien Panis <jpanis@baylibre.com>
>> Subject: [PATCH net-next v5 1/3] net: ethernet: ti: Add accessors
>> for struct k3_cppi_desc_pool members
>>
>> This patch adds accessors for desc_size and cpumem members. They may be
>> used, for instance, to compute a descriptor index.
>>
>> Signed-off-by: Julien Panis <jpanis@baylibre.com>
>> ---
>>   drivers/net/ethernet/ti/k3-cppi-desc-pool.c | 12 ++++++++++++
>> drivers/net/ethernet/ti/k3-cppi-desc-pool.h |  2 ++
>>   2 files changed, 14 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/ti/k3-cppi-desc-pool.c b/drivers/net/ethernet/ti/k3-
>> cppi-desc-pool.c
>> index 05cc7aab1ec8..fe8203c05731 100644
>> --- a/drivers/net/ethernet/ti/k3-cppi-desc-pool.c
>> +++ b/drivers/net/ethernet/ti/k3-cppi-desc-pool.c
>> @@ -132,5 +132,17 @@ size_t k3_cppi_desc_pool_avail(struct
>> k3_cppi_desc_pool *pool)  }  EXPORT_SYMBOL_GPL(k3_cppi_desc_pool_avail);
>>
>> +size_t k3_cppi_desc_pool_desc_size(struct k3_cppi_desc_pool *pool) {
>> +	return pool->desc_size;
> Don't you need to add NULL check on pool ptr since this function is exported?

Thanks for the review.
Absolutely, you're right.

>
>> +}
>> +EXPORT_SYMBOL_GPL(k3_cppi_desc_pool_desc_size);
>> +
>> +void *k3_cppi_desc_pool_cpuaddr(struct k3_cppi_desc_pool *pool) {
>> +	return pool->cpumem;
> Same here.
>
>> +}
>> +EXPORT_SYMBOL_GPL(k3_cppi_desc_pool_cpuaddr);
>> +
>>   MODULE_LICENSE("GPL");
>>   MODULE_DESCRIPTION("TI K3 CPPI5 descriptors pool API"); diff --git
>> a/drivers/net/ethernet/ti/k3-cppi-desc-pool.h b/drivers/net/ethernet/ti/k3-cppi-desc-
>> pool.h
>> index a7e3fa5e7b62..149d5579a5e2 100644
>> --- a/drivers/net/ethernet/ti/k3-cppi-desc-pool.h
>> +++ b/drivers/net/ethernet/ti/k3-cppi-desc-pool.h
>> @@ -26,5 +26,7 @@ k3_cppi_desc_pool_dma2virt(struct k3_cppi_desc_pool
>> *pool, dma_addr_t dma);  void *k3_cppi_desc_pool_alloc(struct
>> k3_cppi_desc_pool *pool);  void k3_cppi_desc_pool_free(struct
>> k3_cppi_desc_pool *pool, void *addr);  size_t k3_cppi_desc_pool_avail(struct
>> k3_cppi_desc_pool *pool);
>> +size_t k3_cppi_desc_pool_desc_size(struct k3_cppi_desc_pool *pool);
>> +void *k3_cppi_desc_pool_cpuaddr(struct k3_cppi_desc_pool *pool);
>>
>>   #endif /* K3_CPPI_DESC_POOL_H_ */
>>
>> --
>> 2.37.3
>>