Skip to content

Commit 2444f45

Browse files
author
CKI KWF Bot
committed
Merge: rhel-10.1 enic driver update
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/828 JIRA: https://issues.redhat.com/browse/RHEL-84863 Signed-off-by: Nelson Escobar <nescobar@redhat.com> Update enic with upstream changes up to 6.15-rc1 Approved-by: Michal Schmidt <mschmidt@redhat.com> Approved-by: John Meneghini <jmeneghi@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: CKI GitLab Kmaint Pipeline Bot <26919896-cki-kmaint-pipeline-bot@users.noreply.gitlab.com>
2 parents fbc5505 + 422a956 commit 2444f45

File tree

18 files changed

+1129
-735
lines changed

18 files changed

+1129
-735
lines changed

drivers/net/ethernet/cisco/enic/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
config ENIC
77
tristate "Cisco VIC Ethernet NIC Support"
88
depends on PCI
9+
select PAGE_POOL
910
help
1011
This enables the support for the Cisco VIC Ethernet card.

drivers/net/ethernet/cisco/enic/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ obj-$(CONFIG_ENIC) := enic.o
33

44
enic-y := enic_main.o vnic_cq.o vnic_intr.o vnic_wq.o \
55
enic_res.o enic_dev.o enic_pp.o vnic_dev.o vnic_rq.o vnic_vic.o \
6-
enic_ethtool.o enic_api.o enic_clsf.o
6+
enic_ethtool.o enic_api.o enic_clsf.o enic_rq.o enic_wq.o
77

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

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,28 +40,7 @@ struct cq_desc {
4040
#define CQ_DESC_COMP_NDX_BITS 12
4141
#define CQ_DESC_COMP_NDX_MASK ((1 << CQ_DESC_COMP_NDX_BITS) - 1)
4242

43-
static inline void cq_desc_dec(const struct cq_desc *desc_arg,
44-
u8 *type, u8 *color, u16 *q_number, u16 *completed_index)
45-
{
46-
const struct cq_desc *desc = desc_arg;
47-
const u8 type_color = desc->type_color;
48-
49-
*color = (type_color >> CQ_DESC_COLOR_SHIFT) & CQ_DESC_COLOR_MASK;
50-
51-
/*
52-
* Make sure color bit is read from desc *before* other fields
53-
* are read from desc. Hardware guarantees color bit is last
54-
* bit (byte) written. Adding the rmb() prevents the compiler
55-
* and/or CPU from reordering the reads which would potentially
56-
* result in reading stale values.
57-
*/
58-
59-
rmb();
60-
61-
*type = type_color & CQ_DESC_TYPE_MASK;
62-
*q_number = le16_to_cpu(desc->q_number) & CQ_DESC_Q_NUM_MASK;
63-
*completed_index = le16_to_cpu(desc->completed_index) &
64-
CQ_DESC_COMP_NDX_MASK;
65-
}
43+
#define CQ_DESC_32_FI_MASK (BIT(0) | BIT(1))
44+
#define CQ_DESC_64_FI_MASK (BIT(0) | BIT(1))
6645

6746
#endif /* _CQ_DESC_H_ */

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

Lines changed: 55 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,22 @@ struct cq_enet_wq_desc {
1717
u8 type_color;
1818
};
1919

20-
static inline void cq_enet_wq_desc_dec(struct cq_enet_wq_desc *desc,
21-
u8 *type, u8 *color, u16 *q_number, u16 *completed_index)
22-
{
23-
cq_desc_dec((struct cq_desc *)desc, type,
24-
color, q_number, completed_index);
25-
}
20+
/*
21+
* Defines and Capabilities for CMD_CQ_ENTRY_SIZE_SET
22+
*/
23+
#define VNIC_RQ_ALL (~0ULL)
24+
25+
#define VNIC_RQ_CQ_ENTRY_SIZE_16 0
26+
#define VNIC_RQ_CQ_ENTRY_SIZE_32 1
27+
#define VNIC_RQ_CQ_ENTRY_SIZE_64 2
28+
29+
#define VNIC_RQ_CQ_ENTRY_SIZE_16_CAPABLE BIT(VNIC_RQ_CQ_ENTRY_SIZE_16)
30+
#define VNIC_RQ_CQ_ENTRY_SIZE_32_CAPABLE BIT(VNIC_RQ_CQ_ENTRY_SIZE_32)
31+
#define VNIC_RQ_CQ_ENTRY_SIZE_64_CAPABLE BIT(VNIC_RQ_CQ_ENTRY_SIZE_64)
32+
33+
#define VNIC_RQ_CQ_ENTRY_SIZE_ALL_BIT (VNIC_RQ_CQ_ENTRY_SIZE_16_CAPABLE | \
34+
VNIC_RQ_CQ_ENTRY_SIZE_32_CAPABLE | \
35+
VNIC_RQ_CQ_ENTRY_SIZE_64_CAPABLE)
2636

2737
/* Completion queue descriptor: Ethernet receive queue, 16B */
2838
struct cq_enet_rq_desc {
@@ -36,6 +46,45 @@ struct cq_enet_rq_desc {
3646
u8 type_color;
3747
};
3848

49+
/* Completion queue descriptor: Ethernet receive queue, 32B */
50+
struct cq_enet_rq_desc_32 {
51+
__le16 completed_index_flags;
52+
__le16 q_number_rss_type_flags;
53+
__le32 rss_hash;
54+
__le16 bytes_written_flags;
55+
__le16 vlan;
56+
__le16 checksum_fcoe;
57+
u8 flags;
58+
u8 fetch_index_flags;
59+
__le32 time_stamp;
60+
__le16 time_stamp2;
61+
__le16 pie_info;
62+
__le32 pie_info2;
63+
__le16 pie_info3;
64+
u8 pie_info4;
65+
u8 type_color;
66+
};
67+
68+
/* Completion queue descriptor: Ethernet receive queue, 64B */
69+
struct cq_enet_rq_desc_64 {
70+
__le16 completed_index_flags;
71+
__le16 q_number_rss_type_flags;
72+
__le32 rss_hash;
73+
__le16 bytes_written_flags;
74+
__le16 vlan;
75+
__le16 checksum_fcoe;
76+
u8 flags;
77+
u8 fetch_index_flags;
78+
__le32 time_stamp;
79+
__le16 time_stamp2;
80+
__le16 pie_info;
81+
__le32 pie_info2;
82+
__le16 pie_info3;
83+
u8 pie_info4;
84+
u8 reserved[32];
85+
u8 type_color;
86+
};
87+
3988
#define CQ_ENET_RQ_DESC_FLAGS_INGRESS_PORT (0x1 << 12)
4089
#define CQ_ENET_RQ_DESC_FLAGS_FCOE (0x1 << 13)
4190
#define CQ_ENET_RQ_DESC_FLAGS_EOP (0x1 << 14)
@@ -88,85 +137,4 @@ struct cq_enet_rq_desc {
88137
#define CQ_ENET_RQ_DESC_FLAGS_IPV4_FRAGMENT (0x1 << 6)
89138
#define CQ_ENET_RQ_DESC_FLAGS_FCS_OK (0x1 << 7)
90139

91-
static inline void cq_enet_rq_desc_dec(struct cq_enet_rq_desc *desc,
92-
u8 *type, u8 *color, u16 *q_number, u16 *completed_index,
93-
u8 *ingress_port, u8 *fcoe, u8 *eop, u8 *sop, u8 *rss_type,
94-
u8 *csum_not_calc, u32 *rss_hash, u16 *bytes_written, u8 *packet_error,
95-
u8 *vlan_stripped, u16 *vlan_tci, u16 *checksum, u8 *fcoe_sof,
96-
u8 *fcoe_fc_crc_ok, u8 *fcoe_enc_error, u8 *fcoe_eof,
97-
u8 *tcp_udp_csum_ok, u8 *udp, u8 *tcp, u8 *ipv4_csum_ok,
98-
u8 *ipv6, u8 *ipv4, u8 *ipv4_fragment, u8 *fcs_ok)
99-
{
100-
u16 completed_index_flags;
101-
u16 q_number_rss_type_flags;
102-
u16 bytes_written_flags;
103-
104-
cq_desc_dec((struct cq_desc *)desc, type,
105-
color, q_number, completed_index);
106-
107-
completed_index_flags = le16_to_cpu(desc->completed_index_flags);
108-
q_number_rss_type_flags =
109-
le16_to_cpu(desc->q_number_rss_type_flags);
110-
bytes_written_flags = le16_to_cpu(desc->bytes_written_flags);
111-
112-
*ingress_port = (completed_index_flags &
113-
CQ_ENET_RQ_DESC_FLAGS_INGRESS_PORT) ? 1 : 0;
114-
*fcoe = (completed_index_flags & CQ_ENET_RQ_DESC_FLAGS_FCOE) ?
115-
1 : 0;
116-
*eop = (completed_index_flags & CQ_ENET_RQ_DESC_FLAGS_EOP) ?
117-
1 : 0;
118-
*sop = (completed_index_flags & CQ_ENET_RQ_DESC_FLAGS_SOP) ?
119-
1 : 0;
120-
121-
*rss_type = (u8)((q_number_rss_type_flags >> CQ_DESC_Q_NUM_BITS) &
122-
CQ_ENET_RQ_DESC_RSS_TYPE_MASK);
123-
*csum_not_calc = (q_number_rss_type_flags &
124-
CQ_ENET_RQ_DESC_FLAGS_CSUM_NOT_CALC) ? 1 : 0;
125-
126-
*rss_hash = le32_to_cpu(desc->rss_hash);
127-
128-
*bytes_written = bytes_written_flags &
129-
CQ_ENET_RQ_DESC_BYTES_WRITTEN_MASK;
130-
*packet_error = (bytes_written_flags &
131-
CQ_ENET_RQ_DESC_FLAGS_TRUNCATED) ? 1 : 0;
132-
*vlan_stripped = (bytes_written_flags &
133-
CQ_ENET_RQ_DESC_FLAGS_VLAN_STRIPPED) ? 1 : 0;
134-
135-
/*
136-
* Tag Control Information(16) = user_priority(3) + cfi(1) + vlan(12)
137-
*/
138-
*vlan_tci = le16_to_cpu(desc->vlan);
139-
140-
if (*fcoe) {
141-
*fcoe_sof = (u8)(le16_to_cpu(desc->checksum_fcoe) &
142-
CQ_ENET_RQ_DESC_FCOE_SOF_MASK);
143-
*fcoe_fc_crc_ok = (desc->flags &
144-
CQ_ENET_RQ_DESC_FCOE_FC_CRC_OK) ? 1 : 0;
145-
*fcoe_enc_error = (desc->flags &
146-
CQ_ENET_RQ_DESC_FCOE_ENC_ERROR) ? 1 : 0;
147-
*fcoe_eof = (u8)((le16_to_cpu(desc->checksum_fcoe) >>
148-
CQ_ENET_RQ_DESC_FCOE_EOF_SHIFT) &
149-
CQ_ENET_RQ_DESC_FCOE_EOF_MASK);
150-
*checksum = 0;
151-
} else {
152-
*fcoe_sof = 0;
153-
*fcoe_fc_crc_ok = 0;
154-
*fcoe_enc_error = 0;
155-
*fcoe_eof = 0;
156-
*checksum = le16_to_cpu(desc->checksum_fcoe);
157-
}
158-
159-
*tcp_udp_csum_ok =
160-
(desc->flags & CQ_ENET_RQ_DESC_FLAGS_TCP_UDP_CSUM_OK) ? 1 : 0;
161-
*udp = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_UDP) ? 1 : 0;
162-
*tcp = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_TCP) ? 1 : 0;
163-
*ipv4_csum_ok =
164-
(desc->flags & CQ_ENET_RQ_DESC_FLAGS_IPV4_CSUM_OK) ? 1 : 0;
165-
*ipv6 = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_IPV6) ? 1 : 0;
166-
*ipv4 = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_IPV4) ? 1 : 0;
167-
*ipv4_fragment =
168-
(desc->flags & CQ_ENET_RQ_DESC_FLAGS_IPV4_FRAGMENT) ? 1 : 0;
169-
*fcs_ok = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_FCS_OK) ? 1 : 0;
170-
}
171-
172140
#endif /* _CQ_ENET_DESC_H_ */

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

Lines changed: 55 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,27 @@
1717
#include "vnic_nic.h"
1818
#include "vnic_rss.h"
1919
#include <linux/irq.h>
20+
#include <net/page_pool/helpers.h>
2021

2122
#define DRV_NAME "enic"
2223
#define DRV_DESCRIPTION "Cisco VIC Ethernet NIC Driver"
2324

2425
#define ENIC_BARS_MAX 6
2526

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)
27+
#define ENIC_WQ_MAX 256
28+
#define ENIC_RQ_MAX 256
3029

3130
#define ENIC_WQ_NAPI_BUDGET 256
3231

3332
#define ENIC_AIC_LARGE_PKT_DIFF 3
3433

34+
enum ext_cq {
35+
ENIC_RQ_CQ_ENTRY_SIZE_16,
36+
ENIC_RQ_CQ_ENTRY_SIZE_32,
37+
ENIC_RQ_CQ_ENTRY_SIZE_64,
38+
ENIC_RQ_CQ_ENTRY_SIZE_MAX,
39+
};
40+
3541
struct enic_msix_entry {
3642
int requested;
3743
char devname[IFNAMSIZ + 8];
@@ -77,6 +83,10 @@ struct enic_rx_coal {
7783
#define ENIC_SET_INSTANCE (1 << 3)
7884
#define ENIC_SET_HOST (1 << 4)
7985

86+
#define MAX_TSO BIT(16)
87+
#define WQ_ENET_MAX_DESC_LEN BIT(WQ_ENET_LEN_BITS)
88+
#define ENIC_DESC_MAX_SPLITS (MAX_TSO / WQ_ENET_MAX_DESC_LEN + 1)
89+
8090
struct enic_port_profile {
8191
u32 set;
8292
u8 request;
@@ -160,8 +170,21 @@ struct enic_rq_stats {
160170
u64 pkt_truncated; /* truncated pkts */
161171
u64 no_skb; /* out of skbs */
162172
u64 desc_skip; /* Rx pkt went into later buffer */
173+
u64 pp_alloc_fail; /* page pool alloc failure */
163174
};
164175

176+
struct enic_wq {
177+
spinlock_t lock; /* spinlock for wq */
178+
struct vnic_wq vwq;
179+
struct enic_wq_stats stats;
180+
} ____cacheline_aligned;
181+
182+
struct enic_rq {
183+
struct vnic_rq vrq;
184+
struct enic_rq_stats stats;
185+
struct page_pool *pool;
186+
} ____cacheline_aligned;
187+
165188
/* Per-instance private data structure */
166189
struct enic {
167190
struct net_device *netdev;
@@ -173,8 +196,8 @@ struct enic {
173196
struct work_struct reset;
174197
struct work_struct tx_hang_reset;
175198
struct work_struct change_mtu_work;
176-
struct msix_entry msix_entry[ENIC_INTR_MAX];
177-
struct enic_msix_entry msix[ENIC_INTR_MAX];
199+
struct msix_entry *msix_entry;
200+
struct enic_msix_entry *msix;
178201
u32 msg_enable;
179202
spinlock_t devcmd_lock;
180203
u8 mac_addr[ETH_ALEN];
@@ -193,33 +216,30 @@ struct enic {
193216
bool enic_api_busy;
194217
struct enic_port_profile *pp;
195218

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];
219+
struct enic_wq *wq;
220+
unsigned int wq_avail;
200221
unsigned int wq_count;
201222
u16 loop_enable;
202223
u16 loop_tag;
203224

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];
225+
struct enic_rq *rq;
226+
unsigned int rq_avail;
207227
unsigned int rq_count;
208228
struct vxlan_offload vxlan;
209-
struct napi_struct napi[ENIC_RQ_MAX + ENIC_WQ_MAX];
229+
struct napi_struct *napi;
210230

211-
/* interrupt resource cache line section */
212-
____cacheline_aligned struct vnic_intr intr[ENIC_INTR_MAX];
231+
struct vnic_intr *intr;
232+
unsigned int intr_avail;
213233
unsigned int intr_count;
214234
u32 __iomem *legacy_pba; /* memory-mapped */
215235

216-
/* completion queue cache line section */
217-
____cacheline_aligned struct vnic_cq cq[ENIC_CQ_MAX];
236+
struct vnic_cq *cq;
237+
unsigned int cq_avail;
218238
unsigned int cq_count;
219239
struct enic_rfs_flw_tbl rfs_h;
220-
u32 rx_copybreak;
221240
u8 rss_key[ENIC_RSS_LEN];
222241
struct vnic_gen_stats gen_stats;
242+
enum ext_cq ext_cq;
223243
};
224244

225245
static inline struct net_device *vnic_get_netdev(struct vnic_dev *vdev)
@@ -272,18 +292,28 @@ static inline unsigned int enic_msix_wq_intr(struct enic *enic,
272292
return enic->cq[enic_cq_wq(enic, wq)].interrupt_offset;
273293
}
274294

275-
static inline unsigned int enic_msix_err_intr(struct enic *enic)
276-
{
277-
return enic->rq_count + enic->wq_count;
278-
}
295+
/* MSIX interrupts are organized as the error interrupt, then the notify
296+
* interrupt followed by all the I/O interrupts. The error interrupt needs
297+
* to fit in 7 bits due to hardware constraints
298+
*/
299+
#define ENIC_MSIX_RESERVED_INTR 2
300+
#define ENIC_MSIX_ERR_INTR 0
301+
#define ENIC_MSIX_NOTIFY_INTR 1
302+
#define ENIC_MSIX_IO_INTR_BASE ENIC_MSIX_RESERVED_INTR
303+
#define ENIC_MSIX_MIN_INTR (ENIC_MSIX_RESERVED_INTR + 2)
279304

280305
#define ENIC_LEGACY_IO_INTR 0
281306
#define ENIC_LEGACY_ERR_INTR 1
282307
#define ENIC_LEGACY_NOTIFY_INTR 2
283308

309+
static inline unsigned int enic_msix_err_intr(struct enic *enic)
310+
{
311+
return ENIC_MSIX_ERR_INTR;
312+
}
313+
284314
static inline unsigned int enic_msix_notify_intr(struct enic *enic)
285315
{
286-
return enic->rq_count + enic->wq_count + 1;
316+
return ENIC_MSIX_NOTIFY_INTR;
287317
}
288318

289319
static inline bool enic_is_err_intr(struct enic *enic, int intr)
@@ -331,5 +361,6 @@ int enic_is_valid_vf(struct enic *enic, int vf);
331361
int enic_is_dynamic(struct enic *enic);
332362
void enic_set_ethtool_ops(struct net_device *netdev);
333363
int __enic_set_rsskey(struct enic *enic);
364+
void enic_ext_cq(struct enic *enic);
334365

335366
#endif /* _ENIC_H_ */

0 commit comments

Comments
 (0)