diff mbox series

[net-next] enic: Replace hardcoded values for vnic descriptor by defines

Message ID 20240423035305.6858-1-satishkh@cisco.com (mailing list archive)
State Accepted
Commit 369dac68d22ef6052160b3cd383f2d04b1810f84
Delegated to: Netdev Maintainers
Headers show
Series [net-next] enic: Replace hardcoded values for vnic descriptor by defines | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
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: 941 this patch: 941
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 4 maintainers not CCed: pabeni@redhat.com kuba@kernel.org edumazet@google.com benve@cisco.com
netdev/build_clang success Errors and warnings before: 937 this patch: 937
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: 954 this patch: 954
netdev/checkpatch warning WARNING: line length of 85 exceeds 80 columns
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
netdev/contest success net-next-2024-04-24--15-00 (tests: 995)

Commit Message

Satish Kharat April 23, 2024, 3:53 a.m. UTC
Replace the hardcoded values used in the calculations for
vnic descriptors and rings with defines. Minor code cleanup.

Signed-off-by: Satish Kharat <satishkh@cisco.com>
---
 drivers/net/ethernet/cisco/enic/vnic_dev.c | 20 ++++++++------------
 drivers/net/ethernet/cisco/enic/vnic_dev.h |  5 +++++
 2 files changed, 13 insertions(+), 12 deletions(-)

Comments

Simon Horman April 24, 2024, 6:09 p.m. UTC | #1
+ Christian, Satish, Dave, Eric, Jakub & Paolo

On Mon, Apr 22, 2024 at 08:53:05PM -0700, Satish Kharat wrote:
> Replace the hardcoded values used in the calculations for
> vnic descriptors and rings with defines. Minor code cleanup.
> 
> Signed-off-by: Satish Kharat <satishkh@cisco.com>

Hi Satish,

it is probably not necessary to repost because of this,
but please use get_maintainers.pl my.patch to seed
the CC list when posting Networking patches.

That notwithstanding, this patch looks good to me.

Reviewed-by: Simon Horman <horms@kernel.org>

> ---
>  drivers/net/ethernet/cisco/enic/vnic_dev.c | 20 ++++++++------------
>  drivers/net/ethernet/cisco/enic/vnic_dev.h |  5 +++++
>  2 files changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/net/ethernet/cisco/enic/vnic_dev.c b/drivers/net/ethernet/cisco/enic/vnic_dev.c
> index 12a83fa1302d..9f6089e81608 100644
> --- a/drivers/net/ethernet/cisco/enic/vnic_dev.c
> +++ b/drivers/net/ethernet/cisco/enic/vnic_dev.c
> @@ -146,23 +146,19 @@ EXPORT_SYMBOL(vnic_dev_get_res);
>  static unsigned int vnic_dev_desc_ring_size(struct vnic_dev_ring *ring,
>  	unsigned int desc_count, unsigned int desc_size)
>  {
> -	/* The base address of the desc rings must be 512 byte aligned.
> -	 * Descriptor count is aligned to groups of 32 descriptors.  A
> -	 * count of 0 means the maximum 4096 descriptors.  Descriptor
> -	 * size is aligned to 16 bytes.
> -	 */
> -
> -	unsigned int count_align = 32;
> -	unsigned int desc_align = 16;
>  
> -	ring->base_align = 512;
> +	/* Descriptor ring base address alignment in bytes*/
> +	ring->base_align = VNIC_DESC_BASE_ALIGN;
>  
> +	/* A count of 0 means the maximum descriptors */
>  	if (desc_count == 0)
> -		desc_count = 4096;
> +		desc_count = VNIC_DESC_MAX_COUNT;
>  
> -	ring->desc_count = ALIGN(desc_count, count_align);
> +	/* Descriptor count aligned in groups of VNIC_DESC_COUNT_ALIGN descriptors */
> +	ring->desc_count = ALIGN(desc_count, VNIC_DESC_COUNT_ALIGN);
>  
> -	ring->desc_size = ALIGN(desc_size, desc_align);
> +	/* Descriptor size alignment in bytes */
> +	ring->desc_size = ALIGN(desc_size, VNIC_DESC_SIZE_ALIGN);
>  
>  	ring->size = ring->desc_count * ring->desc_size;
>  	ring->size_unaligned = ring->size + ring->base_align;
> diff --git a/drivers/net/ethernet/cisco/enic/vnic_dev.h b/drivers/net/ethernet/cisco/enic/vnic_dev.h
> index 6273794b923b..7fdd8c661c99 100644
> --- a/drivers/net/ethernet/cisco/enic/vnic_dev.h
> +++ b/drivers/net/ethernet/cisco/enic/vnic_dev.h
> @@ -31,6 +31,11 @@ static inline void writeq(u64 val, void __iomem *reg)
>  #undef pr_fmt
>  #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>  
> +#define VNIC_DESC_SIZE_ALIGN	16
> +#define VNIC_DESC_COUNT_ALIGN	32
> +#define VNIC_DESC_BASE_ALIGN	512
> +#define VNIC_DESC_MAX_COUNT	4096
> +
>  enum vnic_dev_intr_mode {
>  	VNIC_DEV_INTR_MODE_UNKNOWN,
>  	VNIC_DEV_INTR_MODE_INTX,
> -- 
> 2.44.0
> 
>
patchwork-bot+netdevbpf@kernel.org April 25, 2024, 9:40 a.m. UTC | #2
Hello:

This patch was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:

On Mon, 22 Apr 2024 20:53:05 -0700 you wrote:
> Replace the hardcoded values used in the calculations for
> vnic descriptors and rings with defines. Minor code cleanup.
> 
> Signed-off-by: Satish Kharat <satishkh@cisco.com>
> ---
>  drivers/net/ethernet/cisco/enic/vnic_dev.c | 20 ++++++++------------
>  drivers/net/ethernet/cisco/enic/vnic_dev.h |  5 +++++
>  2 files changed, 13 insertions(+), 12 deletions(-)

Here is the summary with links:
  - [net-next] enic: Replace hardcoded values for vnic descriptor by defines
    https://git.kernel.org/netdev/net-next/c/369dac68d22e

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/cisco/enic/vnic_dev.c b/drivers/net/ethernet/cisco/enic/vnic_dev.c
index 12a83fa1302d..9f6089e81608 100644
--- a/drivers/net/ethernet/cisco/enic/vnic_dev.c
+++ b/drivers/net/ethernet/cisco/enic/vnic_dev.c
@@ -146,23 +146,19 @@  EXPORT_SYMBOL(vnic_dev_get_res);
 static unsigned int vnic_dev_desc_ring_size(struct vnic_dev_ring *ring,
 	unsigned int desc_count, unsigned int desc_size)
 {
-	/* The base address of the desc rings must be 512 byte aligned.
-	 * Descriptor count is aligned to groups of 32 descriptors.  A
-	 * count of 0 means the maximum 4096 descriptors.  Descriptor
-	 * size is aligned to 16 bytes.
-	 */
-
-	unsigned int count_align = 32;
-	unsigned int desc_align = 16;
 
-	ring->base_align = 512;
+	/* Descriptor ring base address alignment in bytes*/
+	ring->base_align = VNIC_DESC_BASE_ALIGN;
 
+	/* A count of 0 means the maximum descriptors */
 	if (desc_count == 0)
-		desc_count = 4096;
+		desc_count = VNIC_DESC_MAX_COUNT;
 
-	ring->desc_count = ALIGN(desc_count, count_align);
+	/* Descriptor count aligned in groups of VNIC_DESC_COUNT_ALIGN descriptors */
+	ring->desc_count = ALIGN(desc_count, VNIC_DESC_COUNT_ALIGN);
 
-	ring->desc_size = ALIGN(desc_size, desc_align);
+	/* Descriptor size alignment in bytes */
+	ring->desc_size = ALIGN(desc_size, VNIC_DESC_SIZE_ALIGN);
 
 	ring->size = ring->desc_count * ring->desc_size;
 	ring->size_unaligned = ring->size + ring->base_align;
diff --git a/drivers/net/ethernet/cisco/enic/vnic_dev.h b/drivers/net/ethernet/cisco/enic/vnic_dev.h
index 6273794b923b..7fdd8c661c99 100644
--- a/drivers/net/ethernet/cisco/enic/vnic_dev.h
+++ b/drivers/net/ethernet/cisco/enic/vnic_dev.h
@@ -31,6 +31,11 @@  static inline void writeq(u64 val, void __iomem *reg)
 #undef pr_fmt
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
+#define VNIC_DESC_SIZE_ALIGN	16
+#define VNIC_DESC_COUNT_ALIGN	32
+#define VNIC_DESC_BASE_ALIGN	512
+#define VNIC_DESC_MAX_COUNT	4096
+
 enum vnic_dev_intr_mode {
 	VNIC_DEV_INTR_MODE_UNKNOWN,
 	VNIC_DEV_INTR_MODE_INTX,