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