Skip to content

Commit

Permalink
enic: Replace hardcoded values for vnic descriptor by defines
Browse files Browse the repository at this point in the history
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>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Satish Kharat authored and David S. Miller committed Apr 25, 2024
1 parent caf9388 commit 369dac6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
20 changes: 8 additions & 12 deletions drivers/net/ethernet/cisco/enic/vnic_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions drivers/net/ethernet/cisco/enic/vnic_dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 369dac6

Please sign in to comment.