New upstream version 18.02
[deb_dpdk.git] / drivers / net / sfc / base / ef10_tx.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  * Copyright (c) 2012-2018 Solarflare Communications Inc.
4  * All rights reserved.
5  */
6
7 #include "efx.h"
8 #include "efx_impl.h"
9
10
11 #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
12
13 #if EFSYS_OPT_QSTATS
14 #define EFX_TX_QSTAT_INCR(_etp, _stat)                                  \
15         do {                                                            \
16                 (_etp)->et_stat[_stat]++;                               \
17         _NOTE(CONSTANTCONDITION)                                        \
18         } while (B_FALSE)
19 #else
20 #define EFX_TX_QSTAT_INCR(_etp, _stat)
21 #endif
22
23 static  __checkReturn   efx_rc_t
24 efx_mcdi_init_txq(
25         __in            efx_nic_t *enp,
26         __in            uint32_t ndescs,
27         __in            uint32_t target_evq,
28         __in            uint32_t label,
29         __in            uint32_t instance,
30         __in            uint16_t flags,
31         __in            efsys_mem_t *esmp)
32 {
33         efx_mcdi_req_t req;
34         uint8_t payload[MAX(MC_CMD_INIT_TXQ_IN_LEN(EFX_TXQ_MAX_BUFS),
35                             MC_CMD_INIT_TXQ_OUT_LEN)];
36         efx_qword_t *dma_addr;
37         uint64_t addr;
38         int npages;
39         int i;
40         efx_rc_t rc;
41
42         EFSYS_ASSERT(EFX_TXQ_MAX_BUFS >=
43             EFX_TXQ_NBUFS(enp->en_nic_cfg.enc_txq_max_ndescs));
44
45         npages = EFX_TXQ_NBUFS(ndescs);
46         if (MC_CMD_INIT_TXQ_IN_LEN(npages) > sizeof (payload)) {
47                 rc = EINVAL;
48                 goto fail1;
49         }
50
51         (void) memset(payload, 0, sizeof (payload));
52         req.emr_cmd = MC_CMD_INIT_TXQ;
53         req.emr_in_buf = payload;
54         req.emr_in_length = MC_CMD_INIT_TXQ_IN_LEN(npages);
55         req.emr_out_buf = payload;
56         req.emr_out_length = MC_CMD_INIT_TXQ_OUT_LEN;
57
58         MCDI_IN_SET_DWORD(req, INIT_TXQ_IN_SIZE, ndescs);
59         MCDI_IN_SET_DWORD(req, INIT_TXQ_IN_TARGET_EVQ, target_evq);
60         MCDI_IN_SET_DWORD(req, INIT_TXQ_IN_LABEL, label);
61         MCDI_IN_SET_DWORD(req, INIT_TXQ_IN_INSTANCE, instance);
62
63         MCDI_IN_POPULATE_DWORD_9(req, INIT_TXQ_IN_FLAGS,
64             INIT_TXQ_IN_FLAG_BUFF_MODE, 0,
65             INIT_TXQ_IN_FLAG_IP_CSUM_DIS,
66             (flags & EFX_TXQ_CKSUM_IPV4) ? 0 : 1,
67             INIT_TXQ_IN_FLAG_TCP_CSUM_DIS,
68             (flags & EFX_TXQ_CKSUM_TCPUDP) ? 0 : 1,
69             INIT_TXQ_EXT_IN_FLAG_INNER_IP_CSUM_EN,
70             (flags & EFX_TXQ_CKSUM_INNER_IPV4) ? 1 : 0,
71             INIT_TXQ_EXT_IN_FLAG_INNER_TCP_CSUM_EN,
72             (flags & EFX_TXQ_CKSUM_INNER_TCPUDP) ? 1 : 0,
73             INIT_TXQ_EXT_IN_FLAG_TSOV2_EN, (flags & EFX_TXQ_FATSOV2) ? 1 : 0,
74             INIT_TXQ_IN_FLAG_TCP_UDP_ONLY, 0,
75             INIT_TXQ_IN_CRC_MODE, 0,
76             INIT_TXQ_IN_FLAG_TIMESTAMP, 0);
77
78         MCDI_IN_SET_DWORD(req, INIT_TXQ_IN_OWNER_ID, 0);
79         MCDI_IN_SET_DWORD(req, INIT_TXQ_IN_PORT_ID, EVB_PORT_ID_ASSIGNED);
80
81         dma_addr = MCDI_IN2(req, efx_qword_t, INIT_TXQ_IN_DMA_ADDR);
82         addr = EFSYS_MEM_ADDR(esmp);
83
84         for (i = 0; i < npages; i++) {
85                 EFX_POPULATE_QWORD_2(*dma_addr,
86                     EFX_DWORD_1, (uint32_t)(addr >> 32),
87                     EFX_DWORD_0, (uint32_t)(addr & 0xffffffff));
88
89                 dma_addr++;
90                 addr += EFX_BUF_SIZE;
91         }
92
93         efx_mcdi_execute(enp, &req);
94
95         if (req.emr_rc != 0) {
96                 rc = req.emr_rc;
97                 goto fail2;
98         }
99
100         return (0);
101
102 fail2:
103         EFSYS_PROBE(fail2);
104 fail1:
105         EFSYS_PROBE1(fail1, efx_rc_t, rc);
106
107         return (rc);
108 }
109
110 static  __checkReturn   efx_rc_t
111 efx_mcdi_fini_txq(
112         __in            efx_nic_t *enp,
113         __in            uint32_t instance)
114 {
115         efx_mcdi_req_t req;
116         uint8_t payload[MAX(MC_CMD_FINI_TXQ_IN_LEN,
117                             MC_CMD_FINI_TXQ_OUT_LEN)];
118         efx_rc_t rc;
119
120         (void) memset(payload, 0, sizeof (payload));
121         req.emr_cmd = MC_CMD_FINI_TXQ;
122         req.emr_in_buf = payload;
123         req.emr_in_length = MC_CMD_FINI_TXQ_IN_LEN;
124         req.emr_out_buf = payload;
125         req.emr_out_length = MC_CMD_FINI_TXQ_OUT_LEN;
126
127         MCDI_IN_SET_DWORD(req, FINI_TXQ_IN_INSTANCE, instance);
128
129         efx_mcdi_execute_quiet(enp, &req);
130
131         if (req.emr_rc != 0) {
132                 rc = req.emr_rc;
133                 goto fail1;
134         }
135
136         return (0);
137
138 fail1:
139         /*
140          * EALREADY is not an error, but indicates that the MC has rebooted and
141          * that the TXQ has already been destroyed.
142          */
143         if (rc != EALREADY)
144                 EFSYS_PROBE1(fail1, efx_rc_t, rc);
145
146         return (rc);
147 }
148
149         __checkReturn   efx_rc_t
150 ef10_tx_init(
151         __in            efx_nic_t *enp)
152 {
153         _NOTE(ARGUNUSED(enp))
154         return (0);
155 }
156
157                         void
158 ef10_tx_fini(
159         __in            efx_nic_t *enp)
160 {
161         _NOTE(ARGUNUSED(enp))
162 }
163
164         __checkReturn   efx_rc_t
165 ef10_tx_qcreate(
166         __in            efx_nic_t *enp,
167         __in            unsigned int index,
168         __in            unsigned int label,
169         __in            efsys_mem_t *esmp,
170         __in            size_t ndescs,
171         __in            uint32_t id,
172         __in            uint16_t flags,
173         __in            efx_evq_t *eep,
174         __in            efx_txq_t *etp,
175         __out           unsigned int *addedp)
176 {
177         efx_nic_cfg_t *encp = &enp->en_nic_cfg;
178         uint16_t inner_csum;
179         efx_qword_t desc;
180         efx_rc_t rc;
181
182         _NOTE(ARGUNUSED(id))
183
184         inner_csum = EFX_TXQ_CKSUM_INNER_IPV4 | EFX_TXQ_CKSUM_INNER_TCPUDP;
185         if (((flags & inner_csum) != 0) &&
186             (encp->enc_tunnel_encapsulations_supported == 0)) {
187                 rc = EINVAL;
188                 goto fail1;
189         }
190
191         if ((rc = efx_mcdi_init_txq(enp, ndescs, eep->ee_index, label, index,
192             flags, esmp)) != 0)
193                 goto fail2;
194
195         /*
196          * A previous user of this TX queue may have written a descriptor to the
197          * TX push collector, but not pushed the doorbell (e.g. after a crash).
198          * The next doorbell write would then push the stale descriptor.
199          *
200          * Ensure the (per network port) TX push collector is cleared by writing
201          * a no-op TX option descriptor. See bug29981 for details.
202          */
203         *addedp = 1;
204         EFX_POPULATE_QWORD_6(desc,
205             ESF_DZ_TX_DESC_IS_OPT, 1,
206             ESF_DZ_TX_OPTION_TYPE, ESE_DZ_TX_OPTION_DESC_CRC_CSUM,
207             ESF_DZ_TX_OPTION_UDP_TCP_CSUM,
208             (flags & EFX_TXQ_CKSUM_TCPUDP) ? 1 : 0,
209             ESF_DZ_TX_OPTION_IP_CSUM,
210             (flags & EFX_TXQ_CKSUM_IPV4) ? 1 : 0,
211             ESF_DZ_TX_OPTION_INNER_UDP_TCP_CSUM,
212             (flags & EFX_TXQ_CKSUM_INNER_TCPUDP) ? 1 : 0,
213             ESF_DZ_TX_OPTION_INNER_IP_CSUM,
214             (flags & EFX_TXQ_CKSUM_INNER_IPV4) ? 1 : 0);
215
216         EFSYS_MEM_WRITEQ(etp->et_esmp, 0, &desc);
217         ef10_tx_qpush(etp, *addedp, 0);
218
219         return (0);
220
221 fail2:
222         EFSYS_PROBE(fail2);
223 fail1:
224         EFSYS_PROBE1(fail1, efx_rc_t, rc);
225
226         return (rc);
227 }
228
229                 void
230 ef10_tx_qdestroy(
231         __in    efx_txq_t *etp)
232 {
233         /* FIXME */
234         _NOTE(ARGUNUSED(etp))
235         /* FIXME */
236 }
237
238         __checkReturn   efx_rc_t
239 ef10_tx_qpio_enable(
240         __in            efx_txq_t *etp)
241 {
242         efx_nic_t *enp = etp->et_enp;
243         efx_piobuf_handle_t handle;
244         efx_rc_t rc;
245
246         if (etp->et_pio_size != 0) {
247                 rc = EALREADY;
248                 goto fail1;
249         }
250
251         /* Sub-allocate a PIO block from a piobuf */
252         if ((rc = ef10_nic_pio_alloc(enp,
253                     &etp->et_pio_bufnum,
254                     &handle,
255                     &etp->et_pio_blknum,
256                     &etp->et_pio_offset,
257                     &etp->et_pio_size)) != 0) {
258                 goto fail2;
259         }
260         EFSYS_ASSERT3U(etp->et_pio_size, !=, 0);
261
262         /* Link the piobuf to this TXQ */
263         if ((rc = ef10_nic_pio_link(enp, etp->et_index, handle)) != 0) {
264                 goto fail3;
265         }
266
267         /*
268          * et_pio_offset is the offset of the sub-allocated block within the
269          * hardware PIO buffer. It is used as the buffer address in the PIO
270          * option descriptor.
271          *
272          * et_pio_write_offset is the offset of the sub-allocated block from the
273          * start of the write-combined memory mapping, and is used for writing
274          * data into the PIO buffer.
275          */
276         etp->et_pio_write_offset =
277             (etp->et_pio_bufnum * ER_DZ_TX_PIOBUF_STEP) +
278             ER_DZ_TX_PIOBUF_OFST + etp->et_pio_offset;
279
280         return (0);
281
282 fail3:
283         EFSYS_PROBE(fail3);
284         ef10_nic_pio_free(enp, etp->et_pio_bufnum, etp->et_pio_blknum);
285 fail2:
286         EFSYS_PROBE(fail2);
287         etp->et_pio_size = 0;
288 fail1:
289         EFSYS_PROBE1(fail1, efx_rc_t, rc);
290
291         return (rc);
292 }
293
294                         void
295 ef10_tx_qpio_disable(
296         __in            efx_txq_t *etp)
297 {
298         efx_nic_t *enp = etp->et_enp;
299
300         if (etp->et_pio_size != 0) {
301                 /* Unlink the piobuf from this TXQ */
302                 ef10_nic_pio_unlink(enp, etp->et_index);
303
304                 /* Free the sub-allocated PIO block */
305                 ef10_nic_pio_free(enp, etp->et_pio_bufnum, etp->et_pio_blknum);
306                 etp->et_pio_size = 0;
307                 etp->et_pio_write_offset = 0;
308         }
309 }
310
311         __checkReturn   efx_rc_t
312 ef10_tx_qpio_write(
313         __in                    efx_txq_t *etp,
314         __in_ecount(length)     uint8_t *buffer,
315         __in                    size_t length,
316         __in                    size_t offset)
317 {
318         efx_nic_t *enp = etp->et_enp;
319         efsys_bar_t *esbp = enp->en_esbp;
320         uint32_t write_offset;
321         uint32_t write_offset_limit;
322         efx_qword_t *eqp;
323         efx_rc_t rc;
324
325         EFSYS_ASSERT(length % sizeof (efx_qword_t) == 0);
326
327         if (etp->et_pio_size == 0) {
328                 rc = ENOENT;
329                 goto fail1;
330         }
331         if (offset + length > etp->et_pio_size) {
332                 rc = ENOSPC;
333                 goto fail2;
334         }
335
336         /*
337          * Writes to PIO buffers must be 64 bit aligned, and multiples of
338          * 64 bits.
339          */
340         write_offset = etp->et_pio_write_offset + offset;
341         write_offset_limit = write_offset + length;
342         eqp = (efx_qword_t *)buffer;
343         while (write_offset < write_offset_limit) {
344                 EFSYS_BAR_WC_WRITEQ(esbp, write_offset, eqp);
345                 eqp++;
346                 write_offset += sizeof (efx_qword_t);
347         }
348
349         return (0);
350
351 fail2:
352         EFSYS_PROBE(fail2);
353 fail1:
354         EFSYS_PROBE1(fail1, efx_rc_t, rc);
355
356         return (rc);
357 }
358
359         __checkReturn   efx_rc_t
360 ef10_tx_qpio_post(
361         __in                    efx_txq_t *etp,
362         __in                    size_t pkt_length,
363         __in                    unsigned int completed,
364         __inout                 unsigned int *addedp)
365 {
366         efx_qword_t pio_desc;
367         unsigned int id;
368         size_t offset;
369         unsigned int added = *addedp;
370         efx_rc_t rc;
371
372
373         if (added - completed + 1 > EFX_TXQ_LIMIT(etp->et_mask + 1)) {
374                 rc = ENOSPC;
375                 goto fail1;
376         }
377
378         if (etp->et_pio_size == 0) {
379                 rc = ENOENT;
380                 goto fail2;
381         }
382
383         id = added++ & etp->et_mask;
384         offset = id * sizeof (efx_qword_t);
385
386         EFSYS_PROBE4(tx_pio_post, unsigned int, etp->et_index,
387                     unsigned int, id, uint32_t, etp->et_pio_offset,
388                     size_t, pkt_length);
389
390         EFX_POPULATE_QWORD_5(pio_desc,
391                         ESF_DZ_TX_DESC_IS_OPT, 1,
392                         ESF_DZ_TX_OPTION_TYPE, 1,
393                         ESF_DZ_TX_PIO_CONT, 0,
394                         ESF_DZ_TX_PIO_BYTE_CNT, pkt_length,
395                         ESF_DZ_TX_PIO_BUF_ADDR, etp->et_pio_offset);
396
397         EFSYS_MEM_WRITEQ(etp->et_esmp, offset, &pio_desc);
398
399         EFX_TX_QSTAT_INCR(etp, TX_POST_PIO);
400
401         *addedp = added;
402         return (0);
403
404 fail2:
405         EFSYS_PROBE(fail2);
406 fail1:
407         EFSYS_PROBE1(fail1, efx_rc_t, rc);
408
409         return (rc);
410 }
411
412         __checkReturn           efx_rc_t
413 ef10_tx_qpost(
414         __in                    efx_txq_t *etp,
415         __in_ecount(ndescs)     efx_buffer_t *eb,
416         __in                    unsigned int ndescs,
417         __in                    unsigned int completed,
418         __inout                 unsigned int *addedp)
419 {
420         unsigned int added = *addedp;
421         unsigned int i;
422         efx_rc_t rc;
423
424         if (added - completed + ndescs > EFX_TXQ_LIMIT(etp->et_mask + 1)) {
425                 rc = ENOSPC;
426                 goto fail1;
427         }
428
429         for (i = 0; i < ndescs; i++) {
430                 efx_buffer_t *ebp = &eb[i];
431                 efsys_dma_addr_t addr = ebp->eb_addr;
432                 size_t size = ebp->eb_size;
433                 boolean_t eop = ebp->eb_eop;
434                 unsigned int id;
435                 size_t offset;
436                 efx_qword_t qword;
437
438                 /* No limitations on boundary crossing */
439                 EFSYS_ASSERT(size <=
440                     etp->et_enp->en_nic_cfg.enc_tx_dma_desc_size_max);
441
442                 id = added++ & etp->et_mask;
443                 offset = id * sizeof (efx_qword_t);
444
445                 EFSYS_PROBE5(tx_post, unsigned int, etp->et_index,
446                     unsigned int, id, efsys_dma_addr_t, addr,
447                     size_t, size, boolean_t, eop);
448
449                 EFX_POPULATE_QWORD_5(qword,
450                     ESF_DZ_TX_KER_TYPE, 0,
451                     ESF_DZ_TX_KER_CONT, (eop) ? 0 : 1,
452                     ESF_DZ_TX_KER_BYTE_CNT, (uint32_t)(size),
453                     ESF_DZ_TX_KER_BUF_ADDR_DW0, (uint32_t)(addr & 0xffffffff),
454                     ESF_DZ_TX_KER_BUF_ADDR_DW1, (uint32_t)(addr >> 32));
455
456                 EFSYS_MEM_WRITEQ(etp->et_esmp, offset, &qword);
457         }
458
459         EFX_TX_QSTAT_INCR(etp, TX_POST);
460
461         *addedp = added;
462         return (0);
463
464 fail1:
465         EFSYS_PROBE1(fail1, efx_rc_t, rc);
466
467         return (rc);
468 }
469
470 /*
471  * This improves performance by, when possible, pushing a TX descriptor at the
472  * same time as the doorbell. The descriptor must be added to the TXQ, so that
473  * can be used if the hardware decides not to use the pushed descriptor.
474  */
475                         void
476 ef10_tx_qpush(
477         __in            efx_txq_t *etp,
478         __in            unsigned int added,
479         __in            unsigned int pushed)
480 {
481         efx_nic_t *enp = etp->et_enp;
482         unsigned int wptr;
483         unsigned int id;
484         size_t offset;
485         efx_qword_t desc;
486         efx_oword_t oword;
487
488         wptr = added & etp->et_mask;
489         id = pushed & etp->et_mask;
490         offset = id * sizeof (efx_qword_t);
491
492         EFSYS_MEM_READQ(etp->et_esmp, offset, &desc);
493
494         /*
495          * Bug 65776: TSO option descriptors cannot be pushed if pacer bypass is
496          * enabled on the event queue this transmit queue is attached to.
497          *
498          * To ensure the code is safe, it is easiest to simply test the type of
499          * the descriptor to push, and only push it is if it not a TSO option
500          * descriptor.
501          */
502         if ((EFX_QWORD_FIELD(desc, ESF_DZ_TX_DESC_IS_OPT) != 1) ||
503             (EFX_QWORD_FIELD(desc, ESF_DZ_TX_OPTION_TYPE) !=
504             ESE_DZ_TX_OPTION_DESC_TSO)) {
505                 /* Push the descriptor and update the wptr. */
506                 EFX_POPULATE_OWORD_3(oword, ERF_DZ_TX_DESC_WPTR, wptr,
507                     ERF_DZ_TX_DESC_HWORD, EFX_QWORD_FIELD(desc, EFX_DWORD_1),
508                     ERF_DZ_TX_DESC_LWORD, EFX_QWORD_FIELD(desc, EFX_DWORD_0));
509
510                 /* Ensure ordering of memory (descriptors) and PIO (doorbell) */
511                 EFX_DMA_SYNC_QUEUE_FOR_DEVICE(etp->et_esmp, etp->et_mask + 1,
512                                             wptr, id);
513                 EFSYS_PIO_WRITE_BARRIER();
514                 EFX_BAR_TBL_DOORBELL_WRITEO(enp, ER_DZ_TX_DESC_UPD_REG,
515                                             etp->et_index, &oword);
516         } else {
517                 efx_dword_t dword;
518
519                 /*
520                  * Only update the wptr. This is signalled to the hardware by
521                  * only writing one DWORD of the doorbell register.
522                  */
523                 EFX_POPULATE_OWORD_1(oword, ERF_DZ_TX_DESC_WPTR, wptr);
524                 dword = oword.eo_dword[2];
525
526                 /* Ensure ordering of memory (descriptors) and PIO (doorbell) */
527                 EFX_DMA_SYNC_QUEUE_FOR_DEVICE(etp->et_esmp, etp->et_mask + 1,
528                                             wptr, id);
529                 EFSYS_PIO_WRITE_BARRIER();
530                 EFX_BAR_TBL_WRITED2(enp, ER_DZ_TX_DESC_UPD_REG,
531                                     etp->et_index, &dword, B_FALSE);
532         }
533 }
534
535         __checkReturn           efx_rc_t
536 ef10_tx_qdesc_post(
537         __in                    efx_txq_t *etp,
538         __in_ecount(ndescs)     efx_desc_t *ed,
539         __in                    unsigned int ndescs,
540         __in                    unsigned int completed,
541         __inout                 unsigned int *addedp)
542 {
543         unsigned int added = *addedp;
544         unsigned int i;
545         efx_rc_t rc;
546
547         if (added - completed + ndescs > EFX_TXQ_LIMIT(etp->et_mask + 1)) {
548                 rc = ENOSPC;
549                 goto fail1;
550         }
551
552         for (i = 0; i < ndescs; i++) {
553                 efx_desc_t *edp = &ed[i];
554                 unsigned int id;
555                 size_t offset;
556
557                 id = added++ & etp->et_mask;
558                 offset = id * sizeof (efx_desc_t);
559
560                 EFSYS_MEM_WRITEQ(etp->et_esmp, offset, &edp->ed_eq);
561         }
562
563         EFSYS_PROBE3(tx_desc_post, unsigned int, etp->et_index,
564                     unsigned int, added, unsigned int, ndescs);
565
566         EFX_TX_QSTAT_INCR(etp, TX_POST);
567
568         *addedp = added;
569         return (0);
570
571 fail1:
572         EFSYS_PROBE1(fail1, efx_rc_t, rc);
573
574         return (rc);
575 }
576
577         void
578 ef10_tx_qdesc_dma_create(
579         __in    efx_txq_t *etp,
580         __in    efsys_dma_addr_t addr,
581         __in    size_t size,
582         __in    boolean_t eop,
583         __out   efx_desc_t *edp)
584 {
585         _NOTE(ARGUNUSED(etp))
586
587         /* No limitations on boundary crossing */
588         EFSYS_ASSERT(size <= etp->et_enp->en_nic_cfg.enc_tx_dma_desc_size_max);
589
590         EFSYS_PROBE4(tx_desc_dma_create, unsigned int, etp->et_index,
591                     efsys_dma_addr_t, addr,
592                     size_t, size, boolean_t, eop);
593
594         EFX_POPULATE_QWORD_5(edp->ed_eq,
595                     ESF_DZ_TX_KER_TYPE, 0,
596                     ESF_DZ_TX_KER_CONT, (eop) ? 0 : 1,
597                     ESF_DZ_TX_KER_BYTE_CNT, (uint32_t)(size),
598                     ESF_DZ_TX_KER_BUF_ADDR_DW0, (uint32_t)(addr & 0xffffffff),
599                     ESF_DZ_TX_KER_BUF_ADDR_DW1, (uint32_t)(addr >> 32));
600 }
601
602         void
603 ef10_tx_qdesc_tso_create(
604         __in    efx_txq_t *etp,
605         __in    uint16_t ipv4_id,
606         __in    uint32_t tcp_seq,
607         __in    uint8_t  tcp_flags,
608         __out   efx_desc_t *edp)
609 {
610         _NOTE(ARGUNUSED(etp))
611
612         EFSYS_PROBE4(tx_desc_tso_create, unsigned int, etp->et_index,
613                     uint16_t, ipv4_id, uint32_t, tcp_seq,
614                     uint8_t, tcp_flags);
615
616         EFX_POPULATE_QWORD_5(edp->ed_eq,
617                             ESF_DZ_TX_DESC_IS_OPT, 1,
618                             ESF_DZ_TX_OPTION_TYPE,
619                             ESE_DZ_TX_OPTION_DESC_TSO,
620                             ESF_DZ_TX_TSO_TCP_FLAGS, tcp_flags,
621                             ESF_DZ_TX_TSO_IP_ID, ipv4_id,
622                             ESF_DZ_TX_TSO_TCP_SEQNO, tcp_seq);
623 }
624
625         void
626 ef10_tx_qdesc_tso2_create(
627         __in                    efx_txq_t *etp,
628         __in                    uint16_t ipv4_id,
629         __in                    uint32_t tcp_seq,
630         __in                    uint16_t tcp_mss,
631         __out_ecount(count)     efx_desc_t *edp,
632         __in                    int count)
633 {
634         _NOTE(ARGUNUSED(etp, count))
635
636         EFSYS_PROBE4(tx_desc_tso2_create, unsigned int, etp->et_index,
637                     uint16_t, ipv4_id, uint32_t, tcp_seq,
638                     uint16_t, tcp_mss);
639
640         EFSYS_ASSERT(count >= EFX_TX_FATSOV2_OPT_NDESCS);
641
642         EFX_POPULATE_QWORD_5(edp[0].ed_eq,
643                             ESF_DZ_TX_DESC_IS_OPT, 1,
644                             ESF_DZ_TX_OPTION_TYPE,
645                             ESE_DZ_TX_OPTION_DESC_TSO,
646                             ESF_DZ_TX_TSO_OPTION_TYPE,
647                             ESE_DZ_TX_TSO_OPTION_DESC_FATSO2A,
648                             ESF_DZ_TX_TSO_IP_ID, ipv4_id,
649                             ESF_DZ_TX_TSO_TCP_SEQNO, tcp_seq);
650         EFX_POPULATE_QWORD_4(edp[1].ed_eq,
651                             ESF_DZ_TX_DESC_IS_OPT, 1,
652                             ESF_DZ_TX_OPTION_TYPE,
653                             ESE_DZ_TX_OPTION_DESC_TSO,
654                             ESF_DZ_TX_TSO_OPTION_TYPE,
655                             ESE_DZ_TX_TSO_OPTION_DESC_FATSO2B,
656                             ESF_DZ_TX_TSO_TCP_MSS, tcp_mss);
657 }
658
659         void
660 ef10_tx_qdesc_vlantci_create(
661         __in    efx_txq_t *etp,
662         __in    uint16_t  tci,
663         __out   efx_desc_t *edp)
664 {
665         _NOTE(ARGUNUSED(etp))
666
667         EFSYS_PROBE2(tx_desc_vlantci_create, unsigned int, etp->et_index,
668                     uint16_t, tci);
669
670         EFX_POPULATE_QWORD_4(edp->ed_eq,
671                             ESF_DZ_TX_DESC_IS_OPT, 1,
672                             ESF_DZ_TX_OPTION_TYPE,
673                             ESE_DZ_TX_OPTION_DESC_VLAN,
674                             ESF_DZ_TX_VLAN_OP, tci ? 1 : 0,
675                             ESF_DZ_TX_VLAN_TAG1, tci);
676 }
677
678
679         __checkReturn   efx_rc_t
680 ef10_tx_qpace(
681         __in            efx_txq_t *etp,
682         __in            unsigned int ns)
683 {
684         efx_rc_t rc;
685
686         /* FIXME */
687         _NOTE(ARGUNUSED(etp, ns))
688         _NOTE(CONSTANTCONDITION)
689         if (B_FALSE) {
690                 rc = ENOTSUP;
691                 goto fail1;
692         }
693         /* FIXME */
694
695         return (0);
696
697 fail1:
698         EFSYS_PROBE1(fail1, efx_rc_t, rc);
699
700         return (rc);
701 }
702
703         __checkReturn   efx_rc_t
704 ef10_tx_qflush(
705         __in            efx_txq_t *etp)
706 {
707         efx_nic_t *enp = etp->et_enp;
708         efx_rc_t rc;
709
710         if ((rc = efx_mcdi_fini_txq(enp, etp->et_index)) != 0)
711                 goto fail1;
712
713         return (0);
714
715 fail1:
716         /*
717          * EALREADY is not an error, but indicates that the MC has rebooted and
718          * that the TXQ has already been destroyed. Callers need to know that
719          * the TXQ flush has completed to avoid waiting until timeout for a
720          * flush done event that will not be delivered.
721          */
722         if (rc != EALREADY)
723                 EFSYS_PROBE1(fail1, efx_rc_t, rc);
724
725         return (rc);
726 }
727
728                         void
729 ef10_tx_qenable(
730         __in            efx_txq_t *etp)
731 {
732         /* FIXME */
733         _NOTE(ARGUNUSED(etp))
734         /* FIXME */
735 }
736
737 #if EFSYS_OPT_QSTATS
738                         void
739 ef10_tx_qstats_update(
740         __in                            efx_txq_t *etp,
741         __inout_ecount(TX_NQSTATS)      efsys_stat_t *stat)
742 {
743         unsigned int id;
744
745         for (id = 0; id < TX_NQSTATS; id++) {
746                 efsys_stat_t *essp = &stat[id];
747
748                 EFSYS_STAT_INCR(essp, etp->et_stat[id]);
749                 etp->et_stat[id] = 0;
750         }
751 }
752
753 #endif /* EFSYS_OPT_QSTATS */
754
755 #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */