diff mbox series

[net-next,v5,1/3] net: ethernet: ti: Add accessors for struct k3_cppi_desc_pool members

Message ID 20240223-am65-cpsw-xdp-basic-v5-1-bc1739170bc6@baylibre.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series Add minimal XDP support to TI AM65 CPSW Ethernet driver | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 1 maintainers not CCed: danishanwar@ti.com
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 24 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Julien Panis March 28, 2024, 9:26 a.m. UTC
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(+)

Comments

Naveen Mamindlapalli March 28, 2024, 12:06 p.m. UTC | #1
> -----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?

> +}
> +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
>
Julien Panis March 28, 2024, 12:25 p.m. UTC | #2
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
>>
Russell King (Oracle) March 30, 2024, 6:28 p.m. UTC | #3
On Thu, Mar 28, 2024 at 12:06:56PM +0000, Naveen Mamindlapalli wrote:
> > 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?

What bearing does exporting a function have on whether it should check
for NULL?

Given that this function returns size_t, it can't return an error
number. So what value would it return if "pool" were NULL? It can
only return a positive integer or zero.

Also, the argument should be const as the function doesn't modify the
contents of "pool".
diff mbox series

Patch

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;
+}
+EXPORT_SYMBOL_GPL(k3_cppi_desc_pool_desc_size);
+
+void *k3_cppi_desc_pool_cpuaddr(struct k3_cppi_desc_pool *pool)
+{
+	return pool->cpumem;
+}
+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_ */