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