Skip to content

Commit 40587f7

Browse files
author
Paolo Abeni
committed
Merge branch 'enic-enable-32-64-byte-cqes-and-get-max-rx-tx-ring-size-from-hw'
Satish Kharat via says: ==================== enic: enable 32, 64 byte cqes and get max rx/tx ring size from hw This series enables using the max rx and tx ring sizes read from hw. For newer hw that can be up to 16k entries. This requires bigger completion entries for rx queues. This series enables the use of the 32 and 64 byte completion queues entries for enic rx queues on supported hw versions. This is in addition to the exiting (default) 16 byte rx cqes. Signed-off-by: Satish Kharat <[email protected]> ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents 71ca356 + df9fd2a commit 40587f7

File tree

17 files changed

+545
-259
lines changed

17 files changed

+545
-259
lines changed

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 enic_rq.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: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@
3131

3232
#define ENIC_AIC_LARGE_PKT_DIFF 3
3333

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+
3441
struct enic_msix_entry {
3542
int requested;
3643
char devname[IFNAMSIZ + 8];
@@ -76,6 +83,10 @@ struct enic_rx_coal {
7683
#define ENIC_SET_INSTANCE (1 << 3)
7784
#define ENIC_SET_HOST (1 << 4)
7885

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+
7990
struct enic_port_profile {
8091
u32 set;
8192
u8 request;
@@ -228,6 +239,7 @@ struct enic {
228239
struct enic_rfs_flw_tbl rfs_h;
229240
u8 rss_key[ENIC_RSS_LEN];
230241
struct vnic_gen_stats gen_stats;
242+
enum ext_cq ext_cq;
231243
};
232244

233245
static inline struct net_device *vnic_get_netdev(struct vnic_dev *vdev)
@@ -349,5 +361,6 @@ int enic_is_valid_vf(struct enic *enic, int vf);
349361
int enic_is_dynamic(struct enic *enic);
350362
void enic_set_ethtool_ops(struct net_device *netdev);
351363
int __enic_set_rsskey(struct enic *enic);
364+
void enic_ext_cq(struct enic *enic);
352365

353366
#endif /* _ENIC_H_ */

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,9 @@ static void enic_get_ringparam(struct net_device *netdev,
222222
struct enic *enic = netdev_priv(netdev);
223223
struct vnic_enet_config *c = &enic->config;
224224

225-
ring->rx_max_pending = ENIC_MAX_RQ_DESCS;
225+
ring->rx_max_pending = c->max_rq_ring;
226226
ring->rx_pending = c->rq_desc_count;
227-
ring->tx_max_pending = ENIC_MAX_WQ_DESCS;
227+
ring->tx_max_pending = c->max_wq_ring;
228228
ring->tx_pending = c->wq_desc_count;
229229
}
230230

@@ -252,18 +252,18 @@ static int enic_set_ringparam(struct net_device *netdev,
252252
}
253253
rx_pending = c->rq_desc_count;
254254
tx_pending = c->wq_desc_count;
255-
if (ring->rx_pending > ENIC_MAX_RQ_DESCS ||
255+
if (ring->rx_pending > c->max_rq_ring ||
256256
ring->rx_pending < ENIC_MIN_RQ_DESCS) {
257257
netdev_info(netdev, "rx pending (%u) not in range [%u,%u]",
258258
ring->rx_pending, ENIC_MIN_RQ_DESCS,
259-
ENIC_MAX_RQ_DESCS);
259+
c->max_rq_ring);
260260
return -EINVAL;
261261
}
262-
if (ring->tx_pending > ENIC_MAX_WQ_DESCS ||
262+
if (ring->tx_pending > c->max_wq_ring ||
263263
ring->tx_pending < ENIC_MIN_WQ_DESCS) {
264264
netdev_info(netdev, "tx pending (%u) not in range [%u,%u]",
265265
ring->tx_pending, ENIC_MIN_WQ_DESCS,
266-
ENIC_MAX_WQ_DESCS);
266+
c->max_wq_ring);
267267
return -EINVAL;
268268
}
269269
if (running)

0 commit comments

Comments
 (0)