enic: Use all the resources configured on VIC
Subsystems (3)
v4 cover enic: Use all the resources configured on VIC
Allow users to configure and use more than 8 rx queues and 8 tx queues on the Cisco VIC.
This series changes the maximum number of tx and rx queues supported from 8 to the hardware limit of 256, and allocates memory based on the number of resources configured on the VIC.
---
Changes in v4:
- Followed Vadim Fedorenko's suggestions for re-arranging enic_wq and
adding ____cacheline_aligned to the new structs.
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- Per Jakub's suggestions, split commit 5 into smaller commits and use net_get_num_default_rss_queues() to set the number of RQs used.
- Fixed an issue with commit 2 caught during testing with a missing
changed needed in enic_init_vnic_resources().
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Followed Kalesh's suggestions: removed redundant NULL assigments, returning -ENOMEM directly
- Reviewed-by tag for Simon Horman <[email protected]>
- Marked Satish Kharat and John Daley as co-developers to better reflect their role in this patch set
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Nelson Escobar (7):
enic: Create enic_wq/rq structures to bundle per wq/rq data
enic: Make MSI-X I/O interrupts come after the other required ones
enic: Save resource counts we read from HW
enic: Allocate arrays in enic struct based on VIC config
enic: Adjust used MSI-X wq/rq/cq/interrupt resources in a more robust way
enic: Move enic resource adjustments to separate function
enic: Move kdump check into enic_adjust_resources()
drivers/net/ethernet/cisco/enic/enic.h | 62 ++-- drivers/net/ethernet/cisco/enic/enic_ethtool.c | 8 +- drivers/net/ethernet/cisco/enic/enic_main.c | 386 +++++++++++++++---------- drivers/net/ethernet/cisco/enic/enic_res.c | 42 +-- 4 files changed, 299 insertions(+), 199 deletions(-)
---
base-commit: 6f07cd8301706b661776074ddc97c991d107cc91
change-id: 20241023-remove_vic_resource_limits-eaa64f9e65fb
Best regards,
Signature · 1 line
Nelson Escobar <[email protected]>
PATCH v4 1/7 enic: Create enic_wq/rq structures to bundle per wq/rq data
Bundling the wq/rq specific data into dedicated enic_wq/rq structures cleans up the enic structure and simplifies future changes related to wq/rq.
--- drivers/net/ethernet/cisco/enic/enic.h | 18 ++-- drivers/net/ethernet/cisco/enic/enic_ethtool.c | 4 +- drivers/net/ethernet/cisco/enic/enic_main.c | 120 ++++++++++++------------- drivers/net/ethernet/cisco/enic/enic_res.c | 12 +-- 4 files changed, 81 insertions(+), 73 deletions(-)
drivers/net/ethernet/cisco/enic/enic.h +13 -5
@@ -162,6 +162,17 @@ struct enic_rq_stats {u64 desc_skip;/* Rx pkt went into later buffer */ }; +struct enic_wq { +spinlock_t lock;/* spinlock for wq */ +struct vnic_wq vwq; +struct enic_wq_stats stats; +}____cacheline_aligned ; + +struct enic_rq { +struct vnic_rq vrq; +struct enic_rq_stats stats; +}____cacheline_aligned ; +/* Per-instance private data structure */ struct enic {struct net_device *netdev;
@@ -194,16 +205,13 @@ struct enic {struct enic_port_profile *pp;/* work queue cache line section */ -____cacheline_aligned struct vnic_wq wq[ENIC_WQ_MAX ]; -spinlock_t wq_lock[ENIC_WQ_MAX ]; -struct enic_wq_stats wq_stats[ENIC_WQ_MAX ]; +____cacheline_aligned struct enic_wq wq[ENIC_WQ_MAX ];unsigned int wq_count;u16 loop_enable;u16 loop_tag;/* receive queue cache line section */ -____cacheline_aligned struct vnic_rq rq[ENIC_RQ_MAX ]; -struct enic_rq_stats rq_stats[ENIC_RQ_MAX ]; +____cacheline_aligned struct enic_rq rq[ENIC_RQ_MAX ];unsigned int rq_count;struct vxlan_offload vxlan;struct napi_struct napi[ENIC_RQ_MAX +ENIC_WQ_MAX ];
drivers/net/ethernet/cisco/enic/enic_ethtool.c +2 -2
@@ -337,7 +337,7 @@ static void enic_get_ethtool_stats(struct net_device *netdev,for (i =0 ; i <NUM_ENIC_GEN_STATS ; i++) *(data++) = ((u64 *)&enic->gen_stats)[enic_gen_stats[i].index];for (i =0 ; i < enic->rq_count; i++) { -struct enic_rq_stats *rqstats = &enic->rq_stats[i]; +struct enic_rq_stats *rqstats = &enic->rq[i].stats;int index;for (j =0 ; j <NUM_ENIC_PER_RQ_STATS ; j++) {
@@ -346,7 +346,7 @@ static void enic_get_ethtool_stats(struct net_device *netdev, } }for (i =0 ; i < enic->wq_count; i++) { -struct enic_wq_stats *wqstats = &enic->wq_stats[i]; +struct enic_wq_stats *wqstats = &enic->wq[i].stats;int index;for (j =0 ; j <NUM_ENIC_PER_WQ_STATS ; j++) {
drivers/net/ethernet/cisco/enic/enic_main.c +60 -60
354 lines not on this page · raw message
drivers/net/ethernet/cisco/enic/enic_res.c +6 -6
@@ -176,9 +176,9 @@ void enic_free_vnic_resources(struct enic *enic)unsigned int i;for (i =0 ; i < enic->wq_count; i++) -vnic_wq_free (&enic->wq[i]); +vnic_wq_free (&enic->wq[i].vwq);for (i =0 ; i < enic->rq_count; i++) -vnic_rq_free (&enic->rq[i]); +vnic_rq_free (&enic->rq[i].vrq);for (i =0 ; i < enic->cq_count; i++)vnic_cq_free (&enic->cq[i]);for (i =0 ; i < enic->intr_count; i++)
@@ -233,7 +233,7 @@ void enic_init_vnic_resources(struct enic *enic)for (i =0 ; i < enic->rq_count; i++) { cq_index = i; -vnic_rq_init (&enic->rq[i], +vnic_rq_init (&enic->rq[i].vrq, cq_index, error_interrupt_enable, error_interrupt_offset);
@@ -241,7 +241,7 @@ void enic_init_vnic_resources(struct enic *enic)for (i =0 ; i < enic->wq_count; i++) { cq_index = enic->rq_count + i; -vnic_wq_init (&enic->wq[i], +vnic_wq_init (&enic->wq[i].vwq, cq_index, error_interrupt_enable, error_interrupt_offset);
@@ -322,7 +322,7 @@ int enic_alloc_vnic_resources(struct enic *enic)*/ for (i =0 ; i < enic->wq_count; i++) { - err =vnic_wq_alloc (enic->vdev, &enic->wq[i], i, + err =vnic_wq_alloc (enic->vdev, &enic->wq[i].vwq, i, enic->config.wq_desc_count,sizeof (struct wq_enet_desc ));if (err)
@@ -330,7 +330,7 @@ int enic_alloc_vnic_resources(struct enic *enic) }for (i =0 ; i < enic->rq_count; i++) { - err =vnic_rq_alloc (enic->vdev, &enic->rq[i], i, + err =vnic_rq_alloc (enic->vdev, &enic->rq[i].vrq, i, enic->config.rq_desc_count,sizeof (struct rq_enet_desc ));if (err)
Signature · 1 line
2.35.6
Re: [PATCH net-next v4 1/7] enic: Create enic_wq/rq structures to bundle per wq/rq data
Quoted 10 lines · Nelson Escobar
Bundling the wq/rq specific data into dedicated enic_wq/rq structures cleans up the enic structure and simplifies future changes related to wq/rq.
Co-developed-by John Daley <[email protected]>Signed-off-by John Daley <[email protected]>Co-developed-by Satish Kharat <[email protected]>Signed-off-by Satish Kharat <[email protected]>Signed-off-by Nelson Escobar <[email protected]>Reviewed-by Simon Horman <[email protected]>
Re: [PATCH net-next v4 1/7] enic: Create enic_wq/rq structures to bundle per wq/rq data
Quoted 15 lines · Vadim Fedorenko
Quoted 9 lines · Nelson Escobar
Bundling the wq/rq specific data into dedicated enic_wq/rq structures cleans up the enic structure and simplifies future changes related to wq/rq.
Co-developed-by John Daley <[email protected]>Signed-off-by John Daley <[email protected]>Co-developed-by Satish Kharat <[email protected]>Signed-off-by Satish Kharat <[email protected]>Signed-off-by Nelson Escobar <[email protected]>Reviewed-by Simon Horman <[email protected]>
Quoted 2 lines
Reviewed-by Vadim Fedorenko <[email protected]>
Thanks for your review and your previous feedback.
Nelson.
PATCH v4 2/7 enic: Make MSI-X I/O interrupts come after the other required ones
In reply to Nelson EscobarThe VIC hardware has a constraint that the MSIX interrupt used for errors be specified as a 7 bit number. Before this patch, it was allocated after the I/O interrupts, which would cause a problem if 128 or more I/O interrupts are in use.
So make the required interrupts come before the I/O interrupts to guarantee the error interrupt offset never exceeds 7 bits.
--- drivers/net/ethernet/cisco/enic/enic.h | 20 +++++++++++++++----- drivers/net/ethernet/cisco/enic/enic_res.c | 11 +++++++---- 2 files changed, 22 insertions(+), 9 deletions(-)
drivers/net/ethernet/cisco/enic/enic.h +15 -5
@@ -280,18 +280,28 @@ static inline unsigned int enic_msix_wq_intr(struct enic *enic,return enic->cq[enic_cq_wq (enic, wq)].interrupt_offset; } -static inline unsigned int enic_msix_err_intr (struct enic *enic) -{ -return enic->rq_count + enic->wq_count; -} +/* MSIX interrupts are organized as the error interrupt, then the notify +* interrupt followed by all the I/O interrupts. The error interrupt needs +* to fit in 7 bits due to hardware constraints +*/ +#define ENIC_MSIX_RESERVED_INTR 2 +#define ENIC_MSIX_ERR_INTR 0 +#define ENIC_MSIX_NOTIFY_INTR 1 +#define ENIC_MSIX_IO_INTR_BASE ENIC_MSIX_RESERVED_INTR +#define ENIC_MSIX_MIN_INTR (ENIC_MSIX_RESERVED_INTR + 2)#define ENIC_LEGACY_IO_INTR 0#define ENIC_LEGACY_ERR_INTR 1#define ENIC_LEGACY_NOTIFY_INTR 2 +static inline unsigned int enic_msix_err_intr (struct enic *enic) +{ +return ENIC_MSIX_ERR_INTR ; +} +static inline unsigned int enic_msix_notify_intr (struct enic *enic) { -return enic->rq_count + enic->wq_count +1 ; +return ENIC_MSIX_NOTIFY_INTR ; }static inline bool enic_is_err_intr (struct enic *enic,int intr)
drivers/net/ethernet/cisco/enic/enic_res.c +7 -4
@@ -221,9 +221,12 @@ void enic_init_vnic_resources(struct enic *enic)switch (intr_mode) {case VNIC_DEV_INTR_MODE_INTX : + error_interrupt_enable =1 ; + error_interrupt_offset =ENIC_LEGACY_ERR_INTR ; +break ;case VNIC_DEV_INTR_MODE_MSIX : error_interrupt_enable =1 ; - error_interrupt_offset = enic->intr_count -2 ; + error_interrupt_offset =enic_msix_err_intr (enic);break ;default : error_interrupt_enable =0 ;
@@ -249,15 +252,15 @@ void enic_init_vnic_resources(struct enic *enic)/* Init CQ resources * -* CQ[0 - n+m-1] point to INTR[0] for INTx, MSI -* CQ[0 - n+m-1] point to INTR[0 - n+m-1] for MSI-X +* All CQs point to INTR[0] for INTx, MSI +* CQ[i] point to INTR[ENIC_MSIX_IO_INTR_BASE + i] for MSI-X */ for (i =0 ; i < enic->cq_count; i++) {switch (intr_mode) {case VNIC_DEV_INTR_MODE_MSIX : - interrupt_offset = i; + interrupt_offset =ENIC_MSIX_IO_INTR_BASE + i;break ;default : interrupt_offset =0 ;
Signature · 1 line
2.35.6
Re: [PATCH net-next v4 2/7] enic: Make MSI-X I/O interrupts come after the other required ones
Quoted 8 lines · Nelson Escobar
The VIC hardware has a constraint that the MSIX interrupt used for errors be specified as a 7 bit number. Before this patch, it was allocated after the I/O interrupts, which would cause a problem if 128 or more I/O interrupts are in use.
So make the required interrupts come before the I/O interrupts to guarantee the error interrupt offset never exceeds 7 bits.
Quoted 6 lines
Co-developed-by John Daley <[email protected]>Signed-off-by John Daley <[email protected]>Co-developed-by Satish Kharat <[email protected]>Signed-off-by Satish Kharat <[email protected]>Reviewed-by Simon Horman <[email protected]>Signed-off-by Nelson Escobar <[email protected]>
PATCH v4 3/7 enic: Save resource counts we read from HW
In reply to Nelson EscobarSave the resources counts for wq,rq,cq, and interrupts in *_avail variables so that we don't lose the information when adjusting the counts we are actually using.
Report the wq_avail and rq_avail as the channel maximums in 'ethtool -l' output.
--- drivers/net/ethernet/cisco/enic/enic.h | 4 ++++ drivers/net/ethernet/cisco/enic/enic_ethtool.c | 4 ++-- drivers/net/ethernet/cisco/enic/enic_res.c | 19 ++++++++++++------- 3 files changed, 18 insertions(+), 9 deletions(-)
drivers/net/ethernet/cisco/enic/enic.h +4 -0
@@ -206,23 +206,27 @@ struct enic {/* work queue cache line section */ ____cacheline_aligned struct enic_wq wq[ENIC_WQ_MAX ]; +unsigned int wq_avail;unsigned int wq_count;u16 loop_enable;u16 loop_tag;/* receive queue cache line section */ ____cacheline_aligned struct enic_rq rq[ENIC_RQ_MAX ]; +unsigned int rq_avail;unsigned int rq_count;struct vxlan_offload vxlan;struct napi_struct napi[ENIC_RQ_MAX +ENIC_WQ_MAX ];/* interrupt resource cache line section */ ____cacheline_aligned struct vnic_intr intr[ENIC_INTR_MAX ]; +unsigned int intr_avail;unsigned int intr_count;u32 __iomem *legacy_pba;/* memory-mapped */ /* completion queue cache line section */ ____cacheline_aligned struct vnic_cq cq[ENIC_CQ_MAX ]; +unsigned int cq_avail;unsigned int cq_count;struct enic_rfs_flw_tbl rfs_h;u32 rx_copybreak;
drivers/net/ethernet/cisco/enic/enic_ethtool.c +2 -2
@@ -695,8 +695,8 @@ static void enic_get_channels(struct net_device *netdev,switch (vnic_dev_get_intr_mode (enic->vdev)) {case VNIC_DEV_INTR_MODE_MSIX : - channels->max_rx =ENIC_RQ_MAX ; - channels->max_tx =ENIC_WQ_MAX ; + channels->max_rx =min (enic->rq_avail,ENIC_RQ_MAX ); + channels->max_tx =min (enic->wq_avail,ENIC_WQ_MAX ); channels->rx_count = enic->rq_count; channels->tx_count = enic->wq_count;break ;
drivers/net/ethernet/cisco/enic/enic_res.c +12 -7
@@ -187,16 +187,21 @@ void enic_free_vnic_resources(struct enic *enic)void enic_get_res_counts (struct enic *enic) { - enic->wq_count =vnic_dev_get_res_count (enic->vdev,RES_TYPE_WQ ); - enic->rq_count =vnic_dev_get_res_count (enic->vdev,RES_TYPE_RQ ); - enic->cq_count =vnic_dev_get_res_count (enic->vdev,RES_TYPE_CQ ); - enic->intr_count =vnic_dev_get_res_count (enic->vdev, -RES_TYPE_INTR_CTRL ); + enic->wq_avail =vnic_dev_get_res_count (enic->vdev,RES_TYPE_WQ ); + enic->rq_avail =vnic_dev_get_res_count (enic->vdev,RES_TYPE_RQ ); + enic->cq_avail =vnic_dev_get_res_count (enic->vdev,RES_TYPE_CQ ); + enic->intr_avail =vnic_dev_get_res_count (enic->vdev, +RES_TYPE_INTR_CTRL ); + + enic->wq_count = enic->wq_avail; + enic->rq_count = enic->rq_avail; + enic->cq_count = enic->cq_avail; + enic->intr_count = enic->intr_avail;dev_info (enic_get_dev (enic),"vNIC resources avail: wq %d rq %d cq %d intr %d\n" , - enic->wq_count, enic->rq_count, - enic->cq_count, enic->intr_count); + enic->wq_avail, enic->rq_avail, + enic->cq_avail, enic->intr_avail); }void enic_init_vnic_resources (struct enic *enic)
Signature · 1 line
2.35.6
Re: [PATCH net-next v4 3/7] enic: Save resource counts we read from HW
Quoted 7 lines · Nelson Escobar
Save the resources counts for wq,rq,cq, and interrupts in
*_availvariables so that we don't lose the information when adjusting the counts we are actually using.Report the
wq_availandrq_availas the channel maximums in 'ethtool -l' output.
Quoted 6 lines
Co-developed-by John Daley <[email protected]>Signed-off-by John Daley <[email protected]>Co-developed-by Satish Kharat <[email protected]>Signed-off-by Satish Kharat <[email protected]>Signed-off-by Nelson Escobar <[email protected]>Reviewed-by Simon Horman <[email protected]>
PATCH v4 4/7 enic: Allocate arrays in enic struct based on VIC config
In reply to Nelson EscobarAllocate wq, rq, cq, intr, and napi arrays based on the number of resources configured in the VIC.
--- drivers/net/ethernet/cisco/enic/enic.h | 24 ++++----- drivers/net/ethernet/cisco/enic/enic_main.c | 84 ++++++++++++++++++++++++++--- 2 files changed, 87 insertions(+), 21 deletions(-)
drivers/net/ethernet/cisco/enic/enic.h +9 -15
@@ -23,10 +23,8 @@#define ENIC_BARS_MAX 6 -#define ENIC_WQ_MAX 8 -#define ENIC_RQ_MAX 8 -#define ENIC_CQ_MAX (ENIC_WQ_MAX + ENIC_RQ_MAX) -#define ENIC_INTR_MAX (ENIC_CQ_MAX + 2) +#define ENIC_WQ_MAX 256 +#define ENIC_RQ_MAX 256#define ENIC_WQ_NAPI_BUDGET 256
@@ -184,8 +182,8 @@ struct enic {struct work_struct reset;struct work_struct tx_hang_reset;struct work_struct change_mtu_work; -struct msix_entry msix_entry[ENIC_INTR_MAX ]; -struct enic_msix_entry msix[ENIC_INTR_MAX ]; +struct msix_entry *msix_entry; +struct enic_msix_entry *msix;u32 msg_enable;spinlock_t devcmd_lock;u8 mac_addr[ETH_ALEN ];
@@ -204,28 +202,24 @@ struct enic {bool enic_api_busy;struct enic_port_profile *pp; -/* work queue cache line section */ -____cacheline_aligned struct enic_wq wq[ENIC_WQ_MAX ]; +struct enic_wq *wq;unsigned int wq_avail;unsigned int wq_count;u16 loop_enable;u16 loop_tag; -/* receive queue cache line section */ -____cacheline_aligned struct enic_rq rq[ENIC_RQ_MAX ]; +struct enic_rq *rq;unsigned int rq_avail;unsigned int rq_count;struct vxlan_offload vxlan; -struct napi_struct napi[ENIC_RQ_MAX +ENIC_WQ_MAX ]; +struct napi_struct *napi; -/* interrupt resource cache line section */ -____cacheline_aligned struct vnic_intr intr[ENIC_INTR_MAX ]; +struct vnic_intr *intr;unsigned int intr_avail;unsigned int intr_count;u32 __iomem *legacy_pba;/* memory-mapped */ -/* completion queue cache line section */ -____cacheline_aligned struct vnic_cq cq[ENIC_CQ_MAX ]; +struct vnic_cq *cq;unsigned int cq_avail;unsigned int cq_count;struct enic_rfs_flw_tbl rfs_h;
drivers/net/ethernet/cisco/enic/enic_main.c +78 -6
138 lines not on this page · raw message
Signature · 1 line
2.35.6
Re: [PATCH net-next v4 4/7] enic: Allocate arrays in enic struct based on VIC config
Quoted 9 lines · Nelson Escobar
Allocate wq, rq, cq, intr, and napi arrays based on the number of resources configured in the VIC.
Co-developed-by John Daley <[email protected]>Signed-off-by John Daley <[email protected]>Co-developed-by Satish Kharat <[email protected]>Signed-off-by Satish Kharat <[email protected]>Signed-off-by Nelson Escobar <[email protected]>Reviewed-by Simon Horman <[email protected]>
PATCH v4 5/7 enic: Adjust used MSI-X wq/rq/cq/interrupt resources in a more robust way
In reply to Nelson EscobarInstead of failing to use MSI-X if resources aren't configured exactly right, use the resources we do have. Since we could start using large numbers of rq resources, we do limit the rq count to what netif_get_num_default_rss_queues() recommends.
--- drivers/net/ethernet/cisco/enic/enic_main.c | 116 ++++++++++++++-------------- 1 file changed, 57 insertions(+), 59 deletions(-)
drivers/net/ethernet/cisco/enic/enic_main.c +57 -59
@@ -2442,85 +2442,86 @@ static void enic_tx_hang_reset(struct work_struct *work)static int enic_set_intr_mode (struct enic *enic) { - unsigned int n = min_t(unsigned int, enic->rq_count, ENIC_RQ_MAX); - unsigned int m = min_t(unsigned int, enic->wq_count, ENIC_WQ_MAX);unsigned int i; +int num_intr;/* Set interrupt mode (INTx, MSI, MSI-X) depending * on system capabilities. * -* Try MSI-X first +* We need a minimum of 1 RQ, 1 WQ, and 2 CQs * -* We need n RQs, m WQs, n+m CQs, and n+m+2 INTRs -* (the second to last INTR is used for WQ/RQ errors) -* (the last INTR is used for notifications) */ -for (i =0 ; i < enic->intr_avail; i++) - enic->msix_entry[i].entry = i; - -/* Use multiple RQs if RSS is enabled -*/ - -if (ENIC_SETTING (enic,RSS ) && - enic->config.intr_mode <1 && - enic->rq_count >= n && - enic->wq_count >= m && - enic->cq_count >= n + m && - enic->intr_count >= n + m +2 ) { - -if (pci_enable_msix_range (enic->pdev, enic->msix_entry, - n + m +2 , n + m +2 ) >0 ) { - - enic->rq_count = n; - enic->wq_count = m; - enic->cq_count = n + m; - enic->intr_count = n + m +2 ; - -vnic_dev_set_intr_mode (enic->vdev, -VNIC_DEV_INTR_MODE_MSIX ); - -return 0 ; - } +if (enic->rq_avail <1 || enic->wq_avail <1 || enic->cq_avail <2 ) { +dev_err (enic_get_dev (enic), +"Not enough resources available rq: %d wq: %d cq: %d\n" , + enic->rq_avail, enic->wq_avail, + enic->cq_avail); +return -ENOSPC ; } +/* if RSS isn't set, then we can only use one RQ */ +if (!ENIC_SETTING (enic,RSS )) + enic->rq_avail =1 ; + +/* Try MSI-X first */ if (enic->config.intr_mode <1 && - enic->rq_count >=1 && - enic->wq_count >= m && - enic->cq_count >=1 + m && - enic->intr_count >=1 + m +2 ) { -if (pci_enable_msix_range (enic->pdev, enic->msix_entry, -1 + m +2 ,1 + m +2 ) >0 ) { - - enic->rq_count =1 ; - enic->wq_count = m; - enic->cq_count =1 + m; - enic->intr_count =1 + m +2 ; + enic->intr_avail >=ENIC_MSIX_MIN_INTR ) { +unsigned int max_queues; +unsigned int rq_default; +unsigned int rq_avail; +unsigned int wq_avail; + +for (i =0 ; i < enic->intr_avail; i++) + enic->msix_entry[i].entry = i; + + num_intr =pci_enable_msix_range (enic->pdev, enic->msix_entry, +ENIC_MSIX_MIN_INTR , + enic->intr_avail); +if (num_intr >0 ) { + wq_avail =min (enic->wq_avail,ENIC_WQ_MAX ); + rq_default =netif_get_num_default_rss_queues (); + rq_avail =min3 (enic->rq_avail,ENIC_RQ_MAX , rq_default); + max_queues =min (enic->cq_avail, + enic->intr_avail -ENIC_MSIX_RESERVED_INTR ); + +if (wq_avail + rq_avail <= max_queues) { + enic->rq_count = rq_avail; + enic->wq_count = wq_avail; + }else { +/* recalculate wq/rq count */ +if (rq_avail < wq_avail) { + enic->rq_count =min (rq_avail, max_queues /2 ); + enic->wq_count = max_queues - enic->rq_count; + }else { + enic->wq_count =min (wq_avail, max_queues /2 ); + enic->rq_count = max_queues - enic->wq_count; + } + } + enic->cq_count = enic->rq_count + enic->wq_count; + enic->intr_count = enic->cq_count +ENIC_MSIX_RESERVED_INTR ;vnic_dev_set_intr_mode (enic->vdev, -VNIC_DEV_INTR_MODE_MSIX ); - +VNIC_DEV_INTR_MODE_MSIX ); + enic->intr_avail = num_intr;return 0 ; } }/* Next try MSI * -* We need 1 RQ, 1 WQ, 2 CQs, and 1 INTR +* We need 1 INTR */ if (enic->config.intr_mode <2 && - enic->rq_count >=1 && - enic->wq_count >=1 && - enic->cq_count >=2 && - enic->intr_count >=1 && + enic->intr_avail >=1 && !pci_enable_msi (enic->pdev)) { enic->rq_count =1 ; enic->wq_count =1 ; enic->cq_count =2 ; enic->intr_count =1 ; - + enic->intr_avail =1 ;vnic_dev_set_intr_mode (enic->vdev,VNIC_DEV_INTR_MODE_MSI );return 0 ;
@@ -2528,23 +2529,20 @@ static int enic_set_intr_mode(struct enic *enic)/* Next try INTx * -* We need 1 RQ, 1 WQ, 2 CQs, and 3 INTRs +* We need 3 INTRs * (the first INTR is used for WQ/RQ) * (the second INTR is used for WQ/RQ errors) * (the last INTR is used for notifications) */ if (enic->config.intr_mode <3 && - enic->rq_count >=1 && - enic->wq_count >=1 && - enic->cq_count >=2 && - enic->intr_count >=3 ) { + enic->intr_avail >=3 ) { enic->rq_count =1 ; enic->wq_count =1 ; enic->cq_count =2 ; enic->intr_count =3 ; - + enic->intr_avail =3 ;vnic_dev_set_intr_mode (enic->vdev,VNIC_DEV_INTR_MODE_INTX );return 0 ;
@@ -2762,8 +2760,8 @@ static void enic_kdump_kernel_config(struct enic *enic) {if (is_kdump_kernel ()) {dev_info (enic_get_dev (enic),"Running from within kdump kernel. Using minimal resources\n" ); - enic->rq_count =1 ; - enic->wq_count =1 ; + enic->rq_avail =1 ; + enic->wq_avail =1 ; enic->config.rq_desc_count =ENIC_MIN_RQ_DESCS ; enic->config.wq_desc_count =ENIC_MIN_WQ_DESCS ; enic->config.mtu =min_t (u16,1500 , enic->config.mtu);
Signature · 1 line
2.35.6
Re: [PATCH net-next v4 5/7] enic: Adjust used MSI-X wq/rq/cq/interrupt resources in a more robust way
Quoted 11 lines · Nelson Escobar
Instead of failing to use MSI-X if resources aren't configured exactly right, use the resources we do have. Since we could start using large numbers of rq resources, we do limit the rq count to what
netif_get_num_default_rss_queues()recommends.Co-developed-by John Daley <[email protected]>Signed-off-by John Daley <[email protected]>Co-developed-by Satish Kharat <[email protected]>Signed-off-by Satish Kharat <[email protected]>Reviewed-by Simon Horman <[email protected]>Signed-off-by Nelson Escobar <[email protected]>
PATCH v4 6/7 enic: Move enic resource adjustments to separate function
In reply to Nelson EscobarMove the enic resource adjustments out of enic_set_intr_mode() and into its own function, enic_adjust_resources().
--- drivers/net/ethernet/cisco/enic/enic_main.c | 127 +++++++++++++++------------- 1 file changed, 70 insertions(+), 57 deletions(-)
drivers/net/ethernet/cisco/enic/enic_main.c +70 -57
@@ -2448,30 +2448,11 @@ static int enic_set_intr_mode(struct enic *enic)/* Set interrupt mode (INTx, MSI, MSI-X) depending * on system capabilities. * -* We need a minimum of 1 RQ, 1 WQ, and 2 CQs -* +* Try MSI-X first */ -if (enic->rq_avail <1 || enic->wq_avail <1 || enic->cq_avail <2 ) { -dev_err (enic_get_dev (enic), -"Not enough resources available rq: %d wq: %d cq: %d\n" , - enic->rq_avail, enic->wq_avail, - enic->cq_avail); -return -ENOSPC ; - } - -/* if RSS isn't set, then we can only use one RQ */ -if (!ENIC_SETTING (enic,RSS )) - enic->rq_avail =1 ; - -/* Try MSI-X first */ if (enic->config.intr_mode <1 && enic->intr_avail >=ENIC_MSIX_MIN_INTR ) { -unsigned int max_queues; -unsigned int rq_default; -unsigned int rq_avail; -unsigned int wq_avail; -for (i =0 ; i < enic->intr_avail; i++) enic->msix_entry[i].entry = i;
@@ -2479,28 +2460,6 @@ static int enic_set_intr_mode(struct enic *enic)ENIC_MSIX_MIN_INTR , enic->intr_avail);if (num_intr >0 ) { - wq_avail =min (enic->wq_avail,ENIC_WQ_MAX ); - rq_default =netif_get_num_default_rss_queues (); - rq_avail =min3 (enic->rq_avail,ENIC_RQ_MAX , rq_default); - max_queues =min (enic->cq_avail, - enic->intr_avail -ENIC_MSIX_RESERVED_INTR ); - -if (wq_avail + rq_avail <= max_queues) { - enic->rq_count = rq_avail; - enic->wq_count = wq_avail; - }else { -/* recalculate wq/rq count */ -if (rq_avail < wq_avail) { - enic->rq_count =min (rq_avail, max_queues /2 ); - enic->wq_count = max_queues - enic->rq_count; - }else { - enic->wq_count =min (wq_avail, max_queues /2 ); - enic->rq_count = max_queues - enic->wq_count; - } - } - enic->cq_count = enic->rq_count + enic->wq_count; - enic->intr_count = enic->cq_count +ENIC_MSIX_RESERVED_INTR ; -vnic_dev_set_intr_mode (enic->vdev,VNIC_DEV_INTR_MODE_MSIX ); enic->intr_avail = num_intr;
@@ -2516,14 +2475,8 @@ static int enic_set_intr_mode(struct enic *enic)if (enic->config.intr_mode <2 && enic->intr_avail >=1 && !pci_enable_msi (enic->pdev)) { - - enic->rq_count =1 ; - enic->wq_count =1 ; - enic->cq_count =2 ; - enic->intr_count =1 ; enic->intr_avail =1 ;vnic_dev_set_intr_mode (enic->vdev,VNIC_DEV_INTR_MODE_MSI ); -return 0 ; }
@@ -2537,14 +2490,8 @@ static int enic_set_intr_mode(struct enic *enic)if (enic->config.intr_mode <3 && enic->intr_avail >=3 ) { - - enic->rq_count =1 ; - enic->wq_count =1 ; - enic->cq_count =2 ; - enic->intr_count =3 ; enic->intr_avail =3 ;vnic_dev_set_intr_mode (enic->vdev,VNIC_DEV_INTR_MODE_INTX ); -return 0 ; }
@@ -2569,6 +2516,67 @@ static void enic_clear_intr_mode(struct enic *enic)vnic_dev_set_intr_mode (enic->vdev,VNIC_DEV_INTR_MODE_UNKNOWN ); } +static int enic_adjust_resources (struct enic *enic) +{ +unsigned int max_queues; +unsigned int rq_default; +unsigned int rq_avail; +unsigned int wq_avail; + +if (enic->rq_avail <1 || enic->wq_avail <1 || enic->cq_avail <2 ) { +dev_err (enic_get_dev (enic), +"Not enough resources available rq: %d wq: %d cq: %d\n" , + enic->rq_avail, enic->wq_avail, + enic->cq_avail); +return -ENOSPC ; + } + +/* if RSS isn't set, then we can only use one RQ */ +if (!ENIC_SETTING (enic,RSS )) + enic->rq_avail =1 ; + +switch (vnic_dev_get_intr_mode (enic->vdev)) { +case VNIC_DEV_INTR_MODE_INTX : +case VNIC_DEV_INTR_MODE_MSI : + enic->rq_count =1 ; + enic->wq_count =1 ; + enic->cq_count =2 ; + enic->intr_count = enic->intr_avail; +break ; +case VNIC_DEV_INTR_MODE_MSIX : +/* Adjust the number of wqs/rqs/cqs/interrupts that will be +* used based on which resource is the most constrained +*/ + wq_avail =min (enic->wq_avail,ENIC_WQ_MAX ); + rq_default =netif_get_num_default_rss_queues (); + rq_avail =min3 (enic->rq_avail,ENIC_RQ_MAX , rq_default); + max_queues =min (enic->cq_avail, + enic->intr_avail -ENIC_MSIX_RESERVED_INTR ); +if (wq_avail + rq_avail <= max_queues) { + enic->rq_count = rq_avail; + enic->wq_count = wq_avail; + }else { +/* recalculate wq/rq count */ +if (rq_avail < wq_avail) { + enic->rq_count =min (rq_avail, max_queues /2 ); + enic->wq_count = max_queues - enic->rq_count; + }else { + enic->wq_count =min (wq_avail, max_queues /2 ); + enic->rq_count = max_queues - enic->wq_count; + } + } + enic->cq_count = enic->rq_count + enic->wq_count; + enic->intr_count = enic->cq_count +ENIC_MSIX_RESERVED_INTR ; + +break ; +default : +dev_err (enic_get_dev (enic),"Unknown interrupt mode\n" ); +return -EINVAL ; + } + +return 0 ; +} +static void enic_get_queue_stats_rx (struct net_device *dev,int idx,struct netdev_queue_stats_rx *rxs) {
@@ -2807,9 +2815,7 @@ static int enic_dev_init(struct enic *enic)*/ enic_kdump_kernel_config (enic); -/* Set interrupt mode based on resource counts and system -* capabilities -*/ +/* Set interrupt mode based on system capabilities */ err =enic_set_intr_mode (enic);if (err) {
@@ -2818,6 +2824,13 @@ static int enic_dev_init(struct enic *enic) goto err_out_free_vnic_resources; } +/* Adjust resource counts based on most constrained resources */ + err =enic_adjust_resources (enic); +if (err) { +dev_err (dev,"Failed to adjust resources\n" ); + goto err_out_free_vnic_resources; + } +/* Allocate and configure vNIC resources */
Signature · 1 line
2.35.6
Re: [PATCH net-next v4 6/7] enic: Move enic resource adjustments to separate function
Quoted 9 lines · Nelson Escobar
Move the enic resource adjustments out of
enic_set_intr_mode()and into its own function,enic_adjust_resources().Co-developed-by John Daley <[email protected]>Signed-off-by John Daley <[email protected]>Co-developed-by Satish Kharat <[email protected]>Signed-off-by Satish Kharat <[email protected]>Reviewed-by Simon Horman <[email protected]>Signed-off-by Nelson Escobar <[email protected]>
Oh, that's nice clean up of resource management code, thanks!
PATCH v4 7/7 enic: Move kdump check into enic_adjust_resources()
In reply to Nelson EscobarMove the kdump check into enic_adjust_resources() so that everything that modifies resources is in the same function.
--- drivers/net/ethernet/cisco/enic/enic_main.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-)
drivers/net/ethernet/cisco/enic/enic_main.c +9 -16
@@ -2531,6 +2531,15 @@ static int enic_adjust_resources(struct enic *enic)return -ENOSPC ; } +if (is_kdump_kernel ()) { +dev_info (enic_get_dev (enic),"Running from within kdump kernel. Using minimal resources\n" ); + enic->rq_avail =1 ; + enic->wq_avail =1 ; + enic->config.rq_desc_count =ENIC_MIN_RQ_DESCS ; + enic->config.wq_desc_count =ENIC_MIN_WQ_DESCS ; + enic->config.mtu =min_t (u16,1500 , enic->config.mtu); + } +/* if RSS isn't set, then we can only use one RQ */ if (!ENIC_SETTING (enic,RSS )) enic->rq_avail =1 ;
@@ -2764,18 +2773,6 @@ static void enic_dev_deinit(struct enic *enic)enic_free_enic_resources (enic); } -static void enic_kdump_kernel_config (struct enic *enic) -{ -if (is_kdump_kernel ()) { -dev_info (enic_get_dev (enic),"Running from within kdump kernel. Using minimal resources\n" ); - enic->rq_avail =1 ; - enic->wq_avail =1 ; - enic->config.rq_desc_count =ENIC_MIN_RQ_DESCS ; - enic->config.wq_desc_count =ENIC_MIN_WQ_DESCS ; - enic->config.mtu =min_t (u16,1500 , enic->config.mtu); - } -} -static int enic_dev_init (struct enic *enic) {struct device *dev =enic_get_dev (enic);
@@ -2811,10 +2808,6 @@ static int enic_dev_init(struct enic *enic)return err; } -/* modify resource count if we are in kdump_kernel -*/ -enic_kdump_kernel_config (enic); -/* Set interrupt mode based on system capabilities */ err =enic_set_intr_mode (enic);
Signature · 1 line
2.35.6
Re: [PATCH net-next v4 7/7] enic: Move kdump check into enic_adjust_resources()
Quoted 9 lines · Nelson Escobar
Move the kdump check into
enic_adjust_resources()so that everything that modifies resources is in the same function.Co-developed-by John Daley <[email protected]>Signed-off-by John Daley <[email protected]>Co-developed-by Satish Kharat <[email protected]>Signed-off-by Satish Kharat <[email protected]>Reviewed-by Simon Horman <[email protected]>Signed-off-by Nelson Escobar <[email protected]>
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Wed, 13 Nov 2024 23:56:32 +0000 you wrote:
Allow users to configure and use more than 8 rx queues and 8 tx queues on the Cisco VIC.
This series changes the maximum number of tx and rx queues supported from 8 to the hardware limit of 256, and allocates memory based on the number of resources configured on the VIC.
[...]
Here is the summary with links:
- [net-next,v4,1/7] enic: Create enic_wq/rq structures to bundle per wq/rq data
https://git.kernel.org/netdev/net-next/c/b67609c93153 - [net-next,v4,2/7] enic: Make MSI-X I/O interrupts come after the other required ones https://git.kernel.org/netdev/net-next/c/231646cb6a8c - [net-next,v4,3/7] enic: Save resource counts we read from HW https://git.kernel.org/netdev/net-next/c/5aee3324724a - [net-next,v4,4/7] enic: Allocate arrays in enic struct based on VIC config https://git.kernel.org/netdev/net-next/c/a64e5492ca90 - [net-next,v4,5/7] enic: Adjust used MSI-X wq/rq/cq/interrupt resources in a more robust way https://git.kernel.org/netdev/net-next/c/cc94d6c4d40c - [net-next,v4,6/7] enic: Move enic resource adjustments to separate function https://git.kernel.org/netdev/net-next/c/374f6c04df8e - [net-next,v4,7/7] enic: Move kdump check into enic_adjust_resources() https://git.kernel.org/netdev/net-next/c/a28ccf1d6c10
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html