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