Skip to content

Commit 2532390

Browse files
committed
Merge branch 'enic-use-all-the-resources-configured-on-vic'
Nelson Escobar says: ==================== 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. v3: https://lore.kernel.org/20241108-remove_vic_resource_limits-v3-0-3ba8123bcffc@cisco.com v2: https://lore.kernel.org/20241024-remove_vic_resource_limits-v2-0-039b8cae5fdd@cisco.com v1: https://lore.kernel.org/20241022041707.27402-2-neescoba@cisco.com ==================== Link: https://patch.msgid.link/20241113-remove_vic_resource_limits-v4-0-a34cf8570c67@cisco.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents 025b2bb + a28ccf1 commit 2532390

4 files changed

Lines changed: 299 additions & 199 deletions

File tree

drivers/net/ethernet/cisco/enic/enic.h

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@
2323

2424
#define ENIC_BARS_MAX 6
2525

26-
#define ENIC_WQ_MAX 8
27-
#define ENIC_RQ_MAX 8
28-
#define ENIC_CQ_MAX (ENIC_WQ_MAX + ENIC_RQ_MAX)
29-
#define ENIC_INTR_MAX (ENIC_CQ_MAX + 2)
26+
#define ENIC_WQ_MAX 256
27+
#define ENIC_RQ_MAX 256
3028

3129
#define ENIC_WQ_NAPI_BUDGET 256
3230

@@ -162,6 +160,17 @@ struct enic_rq_stats {
162160
u64 desc_skip; /* Rx pkt went into later buffer */
163161
};
164162

163+
struct enic_wq {
164+
spinlock_t lock; /* spinlock for wq */
165+
struct vnic_wq vwq;
166+
struct enic_wq_stats stats;
167+
} ____cacheline_aligned;
168+
169+
struct enic_rq {
170+
struct vnic_rq vrq;
171+
struct enic_rq_stats stats;
172+
} ____cacheline_aligned;
173+
165174
/* Per-instance private data structure */
166175
struct enic {
167176
struct net_device *netdev;
@@ -173,8 +182,8 @@ struct enic {
173182
struct work_struct reset;
174183
struct work_struct tx_hang_reset;
175184
struct work_struct change_mtu_work;
176-
struct msix_entry msix_entry[ENIC_INTR_MAX];
177-
struct enic_msix_entry msix[ENIC_INTR_MAX];
185+
struct msix_entry *msix_entry;
186+
struct enic_msix_entry *msix;
178187
u32 msg_enable;
179188
spinlock_t devcmd_lock;
180189
u8 mac_addr[ETH_ALEN];
@@ -193,28 +202,25 @@ struct enic {
193202
bool enic_api_busy;
194203
struct enic_port_profile *pp;
195204

196-
/* work queue cache line section */
197-
____cacheline_aligned struct vnic_wq wq[ENIC_WQ_MAX];
198-
spinlock_t wq_lock[ENIC_WQ_MAX];
199-
struct enic_wq_stats wq_stats[ENIC_WQ_MAX];
205+
struct enic_wq *wq;
206+
unsigned int wq_avail;
200207
unsigned int wq_count;
201208
u16 loop_enable;
202209
u16 loop_tag;
203210

204-
/* receive queue cache line section */
205-
____cacheline_aligned struct vnic_rq rq[ENIC_RQ_MAX];
206-
struct enic_rq_stats rq_stats[ENIC_RQ_MAX];
211+
struct enic_rq *rq;
212+
unsigned int rq_avail;
207213
unsigned int rq_count;
208214
struct vxlan_offload vxlan;
209-
struct napi_struct napi[ENIC_RQ_MAX + ENIC_WQ_MAX];
215+
struct napi_struct *napi;
210216

211-
/* interrupt resource cache line section */
212-
____cacheline_aligned struct vnic_intr intr[ENIC_INTR_MAX];
217+
struct vnic_intr *intr;
218+
unsigned int intr_avail;
213219
unsigned int intr_count;
214220
u32 __iomem *legacy_pba; /* memory-mapped */
215221

216-
/* completion queue cache line section */
217-
____cacheline_aligned struct vnic_cq cq[ENIC_CQ_MAX];
222+
struct vnic_cq *cq;
223+
unsigned int cq_avail;
218224
unsigned int cq_count;
219225
struct enic_rfs_flw_tbl rfs_h;
220226
u32 rx_copybreak;
@@ -272,18 +278,28 @@ static inline unsigned int enic_msix_wq_intr(struct enic *enic,
272278
return enic->cq[enic_cq_wq(enic, wq)].interrupt_offset;
273279
}
274280

275-
static inline unsigned int enic_msix_err_intr(struct enic *enic)
276-
{
277-
return enic->rq_count + enic->wq_count;
278-
}
281+
/* MSIX interrupts are organized as the error interrupt, then the notify
282+
* interrupt followed by all the I/O interrupts. The error interrupt needs
283+
* to fit in 7 bits due to hardware constraints
284+
*/
285+
#define ENIC_MSIX_RESERVED_INTR 2
286+
#define ENIC_MSIX_ERR_INTR 0
287+
#define ENIC_MSIX_NOTIFY_INTR 1
288+
#define ENIC_MSIX_IO_INTR_BASE ENIC_MSIX_RESERVED_INTR
289+
#define ENIC_MSIX_MIN_INTR (ENIC_MSIX_RESERVED_INTR + 2)
279290

280291
#define ENIC_LEGACY_IO_INTR 0
281292
#define ENIC_LEGACY_ERR_INTR 1
282293
#define ENIC_LEGACY_NOTIFY_INTR 2
283294

295+
static inline unsigned int enic_msix_err_intr(struct enic *enic)
296+
{
297+
return ENIC_MSIX_ERR_INTR;
298+
}
299+
284300
static inline unsigned int enic_msix_notify_intr(struct enic *enic)
285301
{
286-
return enic->rq_count + enic->wq_count + 1;
302+
return ENIC_MSIX_NOTIFY_INTR;
287303
}
288304

289305
static inline bool enic_is_err_intr(struct enic *enic, int intr)

drivers/net/ethernet/cisco/enic/enic_ethtool.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ static void enic_get_ethtool_stats(struct net_device *netdev,
337337
for (i = 0; i < NUM_ENIC_GEN_STATS; i++)
338338
*(data++) = ((u64 *)&enic->gen_stats)[enic_gen_stats[i].index];
339339
for (i = 0; i < enic->rq_count; i++) {
340-
struct enic_rq_stats *rqstats = &enic->rq_stats[i];
340+
struct enic_rq_stats *rqstats = &enic->rq[i].stats;
341341
int index;
342342

343343
for (j = 0; j < NUM_ENIC_PER_RQ_STATS; j++) {
@@ -346,7 +346,7 @@ static void enic_get_ethtool_stats(struct net_device *netdev,
346346
}
347347
}
348348
for (i = 0; i < enic->wq_count; i++) {
349-
struct enic_wq_stats *wqstats = &enic->wq_stats[i];
349+
struct enic_wq_stats *wqstats = &enic->wq[i].stats;
350350
int index;
351351

352352
for (j = 0; j < NUM_ENIC_PER_WQ_STATS; j++) {
@@ -695,8 +695,8 @@ static void enic_get_channels(struct net_device *netdev,
695695

696696
switch (vnic_dev_get_intr_mode(enic->vdev)) {
697697
case VNIC_DEV_INTR_MODE_MSIX:
698-
channels->max_rx = ENIC_RQ_MAX;
699-
channels->max_tx = ENIC_WQ_MAX;
698+
channels->max_rx = min(enic->rq_avail, ENIC_RQ_MAX);
699+
channels->max_tx = min(enic->wq_avail, ENIC_WQ_MAX);
700700
channels->rx_count = enic->rq_count;
701701
channels->tx_count = enic->wq_count;
702702
break;

0 commit comments

Comments
 (0)