Skip to content

Commit 0acab8b

Browse files
Doug AmbriskoDoug Ambrisko
Doug Ambrisko
authored and
Doug Ambrisko
committed
enic(4): fix down/up, MTU changes and more
ifconfig down/up cycles was not working. Fix that which is required to support MTU changes. Now doing ifconfig enic0 mtu 3000 for example works. If the MTU is changes in the VIC HW configuration, that is not reflected in and the OS reports the default 1500. I need to look at that but changing it via ifconfig works. So this is different then what Linux does. Change TX interrupt allocation to be in this driver. Change the admin interrupt count to 2. This make multiple queues work but need to be done as pairs so if the VIC has more TX or RX queues setup in the VIC configuration it will use the lesser value. While updating the TX interrupt also add support for devcmd2. Enable checksum offloading. PR: 282095
1 parent fb98fc4 commit 0acab8b

17 files changed

+559
-136
lines changed

sys/dev/enic/cq_desc.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,6 @@ struct cq_desc {
4444
#define CQ_DESC_COMP_NDX_BITS 12
4545
#define CQ_DESC_COMP_NDX_MASK ((1 << CQ_DESC_COMP_NDX_BITS) - 1)
4646

47-
static inline void cq_color_enc(struct cq_desc *desc, const u8 color)
48-
{
49-
if (color)
50-
desc->type_color |= (1 << CQ_DESC_COLOR_SHIFT);
51-
else
52-
desc->type_color &= ~(1 << CQ_DESC_COLOR_SHIFT);
53-
}
54-
5547
static inline void cq_desc_enc(struct cq_desc *desc,
5648
const u8 type, const u8 color, const u16 q_number,
5749
const u16 completed_index)
@@ -87,11 +79,4 @@ static inline void cq_desc_dec(const struct cq_desc *desc_arg,
8779
CQ_DESC_COMP_NDX_MASK;
8880
}
8981

90-
static inline void cq_color_dec(const struct cq_desc *desc_arg, u8 *color)
91-
{
92-
volatile const struct cq_desc *desc = desc_arg;
93-
94-
*color = (desc->type_color >> CQ_DESC_COLOR_SHIFT) & CQ_DESC_COLOR_MASK;
95-
}
96-
9782
#endif /* _CQ_DESC_H_ */

sys/dev/enic/enic.h

Lines changed: 32 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,13 @@ struct vnic_res {
108108
#define ENIC_DEFAULT_VXLAN_PORT 4789
109109

110110
/*
111-
* Interrupt 0: LSC and errors
112111
* Interrupt 1: rx queue 0
113112
* Interrupt 2: rx queue 1
114113
* ...
114+
* Interrupt x: LSC and errors
115115
*/
116116
#define ENICPMD_LSC_INTR_OFFSET 0
117-
#define ENICPMD_RXQ_INTR_OFFSET 1
117+
#define ENICPMD_RXQ_INTR_OFFSET 0
118118

119119
#include "vnic_devcmd.h"
120120

@@ -152,6 +152,9 @@ struct vnic_dev {
152152
u64 args[VNIC_DEVCMD_NARGS];
153153
int in_reset;
154154
struct vnic_intr_coal_timer_info intr_coal_timer_info;
155+
struct devcmd2_controller *devcmd2;
156+
int (*devcmd_rtn)(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd,
157+
int wait);
155158
void *(*alloc_consistent)(void *priv, size_t size,
156159
bus_addr_t *dma_handle, struct iflib_dma_info *res, u8 *name);
157160
void (*free_consistent)(void *priv, size_t size, void *vaddr,
@@ -175,6 +178,28 @@ struct intr_queue {
175178
struct enic_softc *softc;
176179
};
177180

181+
#define ENIC_MAX_LINK_SPEEDS 3
182+
#define ENIC_LINK_SPEED_10G 10000
183+
#define ENIC_LINK_SPEED_4G 4000
184+
#define ENIC_LINK_40G_INDEX 2
185+
#define ENIC_LINK_10G_INDEX 1
186+
#define ENIC_LINK_4G_INDEX 0
187+
#define ENIC_RX_COALESCE_RANGE_END 125
188+
#define ENIC_AIC_TS_BREAK 100
189+
190+
struct enic_rx_coal {
191+
u32 small_pkt_range_start;
192+
u32 large_pkt_range_start;
193+
u32 range_end;
194+
u32 use_adaptive_rx_coalesce;
195+
};
196+
197+
/* Store only the lower range. Higher range is given by fw. */
198+
struct enic_intr_mod_range {
199+
u32 small_pkt_range_start;
200+
u32 large_pkt_range_start;
201+
};
202+
178203
struct enic {
179204
struct enic *next;
180205
struct rte_pci_device *pdev;
@@ -267,6 +292,9 @@ struct enic {
267292
uint64_t tx_offload_mask; /* PKT_TX flags accepted */
268293
struct enic_softc *softc;
269294
int port_mtu;
295+
struct enic_rx_coal rx_coalesce_setting;
296+
u32 rx_coalesce_usecs;
297+
u32 tx_coalesce_usecs;
270298
};
271299

272300
struct enic_softc {
@@ -307,11 +335,6 @@ struct enic_softc {
307335

308336
/* Per-instance private data structure */
309337

310-
static inline unsigned int enic_vnic_rq_count(struct enic *enic)
311-
{
312-
return enic->rq_count;
313-
}
314-
315338
static inline unsigned int enic_cq_rq(struct enic *enic, unsigned int rq)
316339
{
317340
return rq;
@@ -322,21 +345,6 @@ static inline unsigned int enic_cq_wq(struct enic *enic, unsigned int wq)
322345
return enic->rq_count + wq;
323346
}
324347

325-
static inline uint32_t
326-
enic_ring_add(uint32_t n_descriptors, uint32_t i0, uint32_t i1)
327-
{
328-
uint32_t d = i0 + i1;
329-
d -= (d >= n_descriptors) ? n_descriptors : 0;
330-
return d;
331-
}
332-
333-
static inline uint32_t
334-
enic_ring_sub(uint32_t n_descriptors, uint32_t i0, uint32_t i1)
335-
{
336-
int32_t d = i1 - i0;
337-
return (uint32_t)((d < 0) ? ((int32_t)n_descriptors + d) : d);
338-
}
339-
340348
static inline uint32_t
341349
enic_ring_incr(uint32_t n_descriptors, uint32_t idx)
342350
{
@@ -346,34 +354,14 @@ enic_ring_incr(uint32_t n_descriptors, uint32_t idx)
346354
return idx;
347355
}
348356

349-
void enic_free_wq(void *txq);
350-
int enic_alloc_intr_resources(struct enic *enic);
351357
int enic_setup_finish(struct enic *enic);
352-
int enic_alloc_wq(struct enic *enic, uint16_t queue_idx,
353-
unsigned int socket_id, uint16_t nb_desc);
354358
void enic_start_wq(struct enic *enic, uint16_t queue_idx);
355359
int enic_stop_wq(struct enic *enic, uint16_t queue_idx);
356360
void enic_start_rq(struct enic *enic, uint16_t queue_idx);
357-
void enic_free_rq(void *rxq);
358-
int enic_set_vnic_res(struct enic *enic);
359-
int enic_init_rss_nic_cfg(struct enic *enic);
360-
int enic_set_rss_reta(struct enic *enic, union vnic_rss_cpu *rss_cpu);
361-
int enic_set_vlan_strip(struct enic *enic);
361+
int enic_stop_rq(struct enic *enic, uint16_t queue_idx);
362+
void enic_dev_disable(struct enic *enic);
362363
int enic_enable(struct enic *enic);
363364
int enic_disable(struct enic *enic);
364-
void enic_remove(struct enic *enic);
365-
int enic_get_link_status(struct enic *enic);
366-
void enic_dev_stats_clear(struct enic *enic);
367-
void enic_add_packet_filter(struct enic *enic);
368-
int enic_set_mac_address(struct enic *enic, uint8_t *mac_addr);
369-
int enic_del_mac_address(struct enic *enic, int mac_index);
370-
unsigned int enic_cleanup_wq(struct enic *enic, struct vnic_wq *wq);
371-
372-
void enic_post_wq_index(struct vnic_wq *wq);
373-
int enic_probe(struct enic *enic);
374-
int enic_clsf_init(struct enic *enic);
375-
void enic_clsf_destroy(struct enic *enic);
376-
int enic_set_mtu(struct enic *enic, uint16_t new_mtu);
377365
int enic_link_update(struct enic *enic);
378366
bool enic_use_vector_rx_handler(struct enic *enic);
379367
void enic_fdir_info(struct enic *enic);

sys/dev/enic/enic_res.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ int enic_get_vnic_config(struct enic *enic)
9595

9696
dev_info(enic_get_dev(enic),
9797
"vNIC MAC addr %02x:%02x:%02x:%02x:%02x:%02x "
98-
"wq/rq %d/%d mtu d, max mtu:%d\n",
98+
"wq/rq %d/%d mtu %d, max mtu:%d\n",
9999
enic->mac_addr[0], enic->mac_addr[1], enic->mac_addr[2],
100100
enic->mac_addr[3], enic->mac_addr[4], enic->mac_addr[5],
101101
c->wq_desc_count, c->rq_desc_count,
102-
/* enic->rte_dev->data->mtu, */ enic->max_mtu);
102+
c->mtu, enic->max_mtu);
103103
dev_info(enic_get_dev(enic), "vNIC csum tx/rx %s/%s "
104104
"rss %s intr mode %s type %s timer %d usec "
105105
"loopback tag 0x%04x\n",

sys/dev/enic/enic_res.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,5 @@ int enic_set_nic_cfg(struct enic *enic, u8 rss_default_cpu, u8 rss_hash_type,
6767
u8 ig_vlan_strip_en);
6868
void enic_get_res_counts(struct enic *enic);
6969
void enic_init_vnic_resources(struct enic *enic);
70-
int enic_alloc_vnic_resources(struct enic *);
71-
void enic_free_vnic_resources(struct enic *);
7270

7371
#endif /* _ENIC_RES_H_ */

sys/dev/enic/enic_txrx.c

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ enic_isc_txd_encap(void *vsc, if_pkt_info_t pi)
103103

104104
softc = vsc;
105105
enic = &softc->enic;
106+
if_softc_ctx_t scctx = softc->scctx;
106107

107108
wq = &enic->wq[pi->ipi_qsidx];
108109
nsegs = pi->ipi_nsegs;
@@ -112,6 +113,9 @@ enic_isc_txd_encap(void *vsc, if_pkt_info_t pi)
112113
head_idx = wq->head_idx;
113114
desc_count = wq->ring.desc_count;
114115

116+
if ((scctx->isc_capenable & IFCAP_RXCSUM) != 0)
117+
offload_mode |= WQ_ENET_OFFLOAD_MODE_CSUM;
118+
115119
for (i = 0; i < nsegs; i++) {
116120
eop = 0;
117121
cq = 0;
@@ -320,7 +324,7 @@ enic_isc_rxd_flush(void *vsc, uint16_t rxqid, uint8_t flid, qidx_t pidx)
320324
static int
321325
enic_legacy_intr(void *xsc)
322326
{
323-
return -1;
327+
return (1);
324328
}
325329

326330
static inline void
@@ -375,7 +379,7 @@ enic_wq_service(struct vnic_dev *vdev, struct cq_desc *cq_desc, u8 type,
375379

376380
vnic_wq_service(&enic->wq[q_number], cq_desc,
377381
completed_index, NULL, opaque);
378-
return 0;
382+
return (0);
379383
}
380384

381385
static void
@@ -384,7 +388,7 @@ vnic_rq_service(struct vnic_rq *rq, struct cq_desc *cq_desc,
384388
void(*buf_service)(struct vnic_rq *rq, struct cq_desc *cq_desc,
385389
/* struct vnic_rq_buf * *buf, */ int skipped, void *opaque), void *opaque)
386390
{
387-
391+
if_softc_ctx_t scctx;
388392
if_rxd_info_t ri = (if_rxd_info_t) opaque;
389393
u8 type, color, eop, sop, ingress_port, vlan_stripped;
390394
u8 fcoe, fcoe_sof, fcoe_fc_crc_ok, fcoe_enc_error, fcoe_eof;
@@ -396,6 +400,8 @@ vnic_rq_service(struct vnic_rq *rq, struct cq_desc *cq_desc,
396400
int cqidx;
397401
if_rxd_frag_t frag;
398402

403+
scctx = rq->vdev->softc->scctx;
404+
399405
cq_enet_rq_desc_dec((struct cq_enet_rq_desc *)cq_desc,
400406
&type, &color, &q_number, &completed_index,
401407
&ingress_port, &fcoe, &eop, &sop, &rss_type,
@@ -419,6 +425,11 @@ vnic_rq_service(struct vnic_rq *rq, struct cq_desc *cq_desc,
419425
ri->iri_cidx = cqidx;
420426
ri->iri_nfrags = 1;
421427
ri->iri_len = bytes_written;
428+
429+
if ((scctx->isc_capenable & IFCAP_RXCSUM) != 0)
430+
if (!csum_not_calc && (tcp_udp_csum_ok || ipv4_csum_ok)) {
431+
ri->iri_csum_flags = (CSUM_IP_CHECKED | CSUM_IP_VALID);
432+
}
422433
}
423434

424435
static int
@@ -431,7 +442,7 @@ enic_rq_service(struct vnic_dev *vdev, struct cq_desc *cq_desc,
431442
vnic_rq_service(&enic->rq[ri->iri_qsidx], cq_desc, completed_index,
432443
VNIC_RQ_RETURN_DESC, NULL, /* enic_rq_indicate_buf, */ opaque);
433444

434-
return 0;
445+
return (0);
435446
}
436447

437448
void
@@ -468,10 +479,8 @@ enic_stop_wq(struct enic *enic, uint16_t queue_idx)
468479
int ret;
469480

470481
ret = vnic_wq_disable(&enic->wq[queue_idx]);
471-
if (ret)
472-
return ret;
473482

474-
return 0;
483+
return (ret);
475484
}
476485

477486
void
@@ -483,3 +492,19 @@ enic_start_rq(struct enic *enic, uint16_t queue_idx)
483492
vnic_rq_enable(rq);
484493
enic_initial_post_rx(enic, rq);
485494
}
495+
496+
int
497+
enic_stop_rq(struct enic *enic, uint16_t queue_idx)
498+
{
499+
int ret;
500+
501+
ret = vnic_rq_disable(&enic->rq[queue_idx]);
502+
503+
return (ret);
504+
}
505+
506+
507+
void
508+
enic_dev_disable(struct enic *enic) {
509+
vnic_dev_disable(enic->vdev);
510+
}

0 commit comments

Comments
 (0)