2 * Copyright (c) 2007-2016 Solarflare Communications Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
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.
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.
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.
35 #define EFX_TX_QSTAT_INCR(_etp, _stat) \
37 (_etp)->et_stat[_stat]++; \
38 _NOTE(CONSTANTCONDITION) \
41 #define EFX_TX_QSTAT_INCR(_etp, _stat)
46 static __checkReturn efx_rc_t
54 static __checkReturn efx_rc_t
57 __in unsigned int index,
58 __in unsigned int label,
59 __in efsys_mem_t *esmp,
65 __out unsigned int *addedp);
71 static __checkReturn efx_rc_t
74 __in_ecount(n) efx_buffer_t *eb,
76 __in unsigned int completed,
77 __inout unsigned int *addedp);
82 __in unsigned int added,
83 __in unsigned int pushed);
85 static __checkReturn efx_rc_t
88 __in unsigned int ns);
90 static __checkReturn efx_rc_t
98 __checkReturn efx_rc_t
101 __in_ecount(n) efx_desc_t *ed,
103 __in unsigned int completed,
104 __inout unsigned int *addedp);
107 siena_tx_qdesc_dma_create(
109 __in efsys_dma_addr_t addr,
112 __out efx_desc_t *edp);
116 siena_tx_qstats_update(
118 __inout_ecount(TX_NQSTATS) efsys_stat_t *stat);
121 #endif /* EFSYS_OPT_SIENA */
125 static const efx_tx_ops_t __efx_tx_siena_ops = {
126 siena_tx_init, /* etxo_init */
127 siena_tx_fini, /* etxo_fini */
128 siena_tx_qcreate, /* etxo_qcreate */
129 siena_tx_qdestroy, /* etxo_qdestroy */
130 siena_tx_qpost, /* etxo_qpost */
131 siena_tx_qpush, /* etxo_qpush */
132 siena_tx_qpace, /* etxo_qpace */
133 siena_tx_qflush, /* etxo_qflush */
134 siena_tx_qenable, /* etxo_qenable */
135 NULL, /* etxo_qpio_enable */
136 NULL, /* etxo_qpio_disable */
137 NULL, /* etxo_qpio_write */
138 NULL, /* etxo_qpio_post */
139 siena_tx_qdesc_post, /* etxo_qdesc_post */
140 siena_tx_qdesc_dma_create, /* etxo_qdesc_dma_create */
141 NULL, /* etxo_qdesc_tso_create */
142 NULL, /* etxo_qdesc_tso2_create */
143 NULL, /* etxo_qdesc_vlantci_create */
145 siena_tx_qstats_update, /* etxo_qstats_update */
148 #endif /* EFSYS_OPT_SIENA */
150 #if EFSYS_OPT_HUNTINGTON
151 static const efx_tx_ops_t __efx_tx_hunt_ops = {
152 ef10_tx_init, /* etxo_init */
153 ef10_tx_fini, /* etxo_fini */
154 ef10_tx_qcreate, /* etxo_qcreate */
155 ef10_tx_qdestroy, /* etxo_qdestroy */
156 ef10_tx_qpost, /* etxo_qpost */
157 ef10_tx_qpush, /* etxo_qpush */
158 ef10_tx_qpace, /* etxo_qpace */
159 ef10_tx_qflush, /* etxo_qflush */
160 ef10_tx_qenable, /* etxo_qenable */
161 ef10_tx_qpio_enable, /* etxo_qpio_enable */
162 ef10_tx_qpio_disable, /* etxo_qpio_disable */
163 ef10_tx_qpio_write, /* etxo_qpio_write */
164 ef10_tx_qpio_post, /* etxo_qpio_post */
165 ef10_tx_qdesc_post, /* etxo_qdesc_post */
166 ef10_tx_qdesc_dma_create, /* etxo_qdesc_dma_create */
167 ef10_tx_qdesc_tso_create, /* etxo_qdesc_tso_create */
168 ef10_tx_qdesc_tso2_create, /* etxo_qdesc_tso2_create */
169 ef10_tx_qdesc_vlantci_create, /* etxo_qdesc_vlantci_create */
171 ef10_tx_qstats_update, /* etxo_qstats_update */
174 #endif /* EFSYS_OPT_HUNTINGTON */
176 #if EFSYS_OPT_MEDFORD
177 static const efx_tx_ops_t __efx_tx_medford_ops = {
178 ef10_tx_init, /* etxo_init */
179 ef10_tx_fini, /* etxo_fini */
180 ef10_tx_qcreate, /* etxo_qcreate */
181 ef10_tx_qdestroy, /* etxo_qdestroy */
182 ef10_tx_qpost, /* etxo_qpost */
183 ef10_tx_qpush, /* etxo_qpush */
184 ef10_tx_qpace, /* etxo_qpace */
185 ef10_tx_qflush, /* etxo_qflush */
186 ef10_tx_qenable, /* etxo_qenable */
187 ef10_tx_qpio_enable, /* etxo_qpio_enable */
188 ef10_tx_qpio_disable, /* etxo_qpio_disable */
189 ef10_tx_qpio_write, /* etxo_qpio_write */
190 ef10_tx_qpio_post, /* etxo_qpio_post */
191 ef10_tx_qdesc_post, /* etxo_qdesc_post */
192 ef10_tx_qdesc_dma_create, /* etxo_qdesc_dma_create */
193 NULL, /* etxo_qdesc_tso_create */
194 ef10_tx_qdesc_tso2_create, /* etxo_qdesc_tso2_create */
195 ef10_tx_qdesc_vlantci_create, /* etxo_qdesc_vlantci_create */
197 ef10_tx_qstats_update, /* etxo_qstats_update */
200 #endif /* EFSYS_OPT_MEDFORD */
202 __checkReturn efx_rc_t
206 const efx_tx_ops_t *etxop;
209 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
210 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NIC);
212 if (!(enp->en_mod_flags & EFX_MOD_EV)) {
217 if (enp->en_mod_flags & EFX_MOD_TX) {
222 switch (enp->en_family) {
224 case EFX_FAMILY_SIENA:
225 etxop = &__efx_tx_siena_ops;
227 #endif /* EFSYS_OPT_SIENA */
229 #if EFSYS_OPT_HUNTINGTON
230 case EFX_FAMILY_HUNTINGTON:
231 etxop = &__efx_tx_hunt_ops;
233 #endif /* EFSYS_OPT_HUNTINGTON */
235 #if EFSYS_OPT_MEDFORD
236 case EFX_FAMILY_MEDFORD:
237 etxop = &__efx_tx_medford_ops;
239 #endif /* EFSYS_OPT_MEDFORD */
247 EFSYS_ASSERT3U(enp->en_tx_qcount, ==, 0);
249 if ((rc = etxop->etxo_init(enp)) != 0)
252 enp->en_etxop = etxop;
253 enp->en_mod_flags |= EFX_MOD_TX;
263 EFSYS_PROBE1(fail1, efx_rc_t, rc);
265 enp->en_etxop = NULL;
266 enp->en_mod_flags &= ~EFX_MOD_TX;
274 const efx_tx_ops_t *etxop = enp->en_etxop;
276 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
277 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NIC);
278 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_TX);
279 EFSYS_ASSERT3U(enp->en_tx_qcount, ==, 0);
281 etxop->etxo_fini(enp);
283 enp->en_etxop = NULL;
284 enp->en_mod_flags &= ~EFX_MOD_TX;
287 __checkReturn efx_rc_t
290 __in unsigned int index,
291 __in unsigned int label,
292 __in efsys_mem_t *esmp,
297 __deref_out efx_txq_t **etpp,
298 __out unsigned int *addedp)
300 const efx_tx_ops_t *etxop = enp->en_etxop;
301 efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
305 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
306 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_TX);
308 EFSYS_ASSERT3U(enp->en_tx_qcount + 1, <, encp->enc_txq_limit);
310 /* Allocate an TXQ object */
311 EFSYS_KMEM_ALLOC(enp->en_esip, sizeof (efx_txq_t), etp);
318 etp->et_magic = EFX_TXQ_MAGIC;
320 etp->et_index = index;
321 etp->et_mask = n - 1;
324 /* Initial descriptor index may be modified by etxo_qcreate */
327 if ((rc = etxop->etxo_qcreate(enp, index, label, esmp,
328 n, id, flags, eep, etp, addedp)) != 0)
338 EFSYS_KMEM_FREE(enp->en_esip, sizeof (efx_txq_t), etp);
340 EFSYS_PROBE1(fail1, efx_rc_t, rc);
348 efx_nic_t *enp = etp->et_enp;
349 const efx_tx_ops_t *etxop = enp->en_etxop;
351 EFSYS_ASSERT3U(etp->et_magic, ==, EFX_TXQ_MAGIC);
353 EFSYS_ASSERT(enp->en_tx_qcount != 0);
356 etxop->etxo_qdestroy(etp);
358 /* Free the TXQ object */
359 EFSYS_KMEM_FREE(enp->en_esip, sizeof (efx_txq_t), etp);
362 __checkReturn efx_rc_t
365 __in_ecount(n) efx_buffer_t *eb,
367 __in unsigned int completed,
368 __inout unsigned int *addedp)
370 efx_nic_t *enp = etp->et_enp;
371 const efx_tx_ops_t *etxop = enp->en_etxop;
374 EFSYS_ASSERT3U(etp->et_magic, ==, EFX_TXQ_MAGIC);
376 if ((rc = etxop->etxo_qpost(etp, eb,
377 n, completed, addedp)) != 0)
383 EFSYS_PROBE1(fail1, efx_rc_t, rc);
390 __in unsigned int added,
391 __in unsigned int pushed)
393 efx_nic_t *enp = etp->et_enp;
394 const efx_tx_ops_t *etxop = enp->en_etxop;
396 EFSYS_ASSERT3U(etp->et_magic, ==, EFX_TXQ_MAGIC);
398 etxop->etxo_qpush(etp, added, pushed);
401 __checkReturn efx_rc_t
404 __in unsigned int ns)
406 efx_nic_t *enp = etp->et_enp;
407 const efx_tx_ops_t *etxop = enp->en_etxop;
410 EFSYS_ASSERT3U(etp->et_magic, ==, EFX_TXQ_MAGIC);
412 if ((rc = etxop->etxo_qpace(etp, ns)) != 0)
418 EFSYS_PROBE1(fail1, efx_rc_t, rc);
422 __checkReturn efx_rc_t
426 efx_nic_t *enp = etp->et_enp;
427 const efx_tx_ops_t *etxop = enp->en_etxop;
430 EFSYS_ASSERT3U(etp->et_magic, ==, EFX_TXQ_MAGIC);
432 if ((rc = etxop->etxo_qflush(etp)) != 0)
438 EFSYS_PROBE1(fail1, efx_rc_t, rc);
446 efx_nic_t *enp = etp->et_enp;
447 const efx_tx_ops_t *etxop = enp->en_etxop;
449 EFSYS_ASSERT3U(etp->et_magic, ==, EFX_TXQ_MAGIC);
451 etxop->etxo_qenable(etp);
454 __checkReturn efx_rc_t
458 efx_nic_t *enp = etp->et_enp;
459 const efx_tx_ops_t *etxop = enp->en_etxop;
462 EFSYS_ASSERT3U(etp->et_magic, ==, EFX_TXQ_MAGIC);
464 if (~enp->en_features & EFX_FEATURE_PIO_BUFFERS) {
468 if (etxop->etxo_qpio_enable == NULL) {
472 if ((rc = etxop->etxo_qpio_enable(etp)) != 0)
482 EFSYS_PROBE1(fail1, efx_rc_t, rc);
490 efx_nic_t *enp = etp->et_enp;
491 const efx_tx_ops_t *etxop = enp->en_etxop;
493 EFSYS_ASSERT3U(etp->et_magic, ==, EFX_TXQ_MAGIC);
495 if (etxop->etxo_qpio_disable != NULL)
496 etxop->etxo_qpio_disable(etp);
499 __checkReturn efx_rc_t
502 __in_ecount(buf_length) uint8_t *buffer,
503 __in size_t buf_length,
504 __in size_t pio_buf_offset)
506 efx_nic_t *enp = etp->et_enp;
507 const efx_tx_ops_t *etxop = enp->en_etxop;
510 EFSYS_ASSERT3U(etp->et_magic, ==, EFX_TXQ_MAGIC);
512 if (etxop->etxo_qpio_write != NULL) {
513 if ((rc = etxop->etxo_qpio_write(etp, buffer, buf_length,
514 pio_buf_offset)) != 0)
522 EFSYS_PROBE1(fail1, efx_rc_t, rc);
526 __checkReturn efx_rc_t
529 __in size_t pkt_length,
530 __in unsigned int completed,
531 __inout unsigned int *addedp)
533 efx_nic_t *enp = etp->et_enp;
534 const efx_tx_ops_t *etxop = enp->en_etxop;
537 EFSYS_ASSERT3U(etp->et_magic, ==, EFX_TXQ_MAGIC);
539 if (etxop->etxo_qpio_post != NULL) {
540 if ((rc = etxop->etxo_qpio_post(etp, pkt_length, completed,
549 EFSYS_PROBE1(fail1, efx_rc_t, rc);
553 __checkReturn efx_rc_t
556 __in_ecount(n) efx_desc_t *ed,
558 __in unsigned int completed,
559 __inout unsigned int *addedp)
561 efx_nic_t *enp = etp->et_enp;
562 const efx_tx_ops_t *etxop = enp->en_etxop;
565 EFSYS_ASSERT3U(etp->et_magic, ==, EFX_TXQ_MAGIC);
567 if ((rc = etxop->etxo_qdesc_post(etp, ed,
568 n, completed, addedp)) != 0)
574 EFSYS_PROBE1(fail1, efx_rc_t, rc);
579 efx_tx_qdesc_dma_create(
581 __in efsys_dma_addr_t addr,
584 __out efx_desc_t *edp)
586 efx_nic_t *enp = etp->et_enp;
587 const efx_tx_ops_t *etxop = enp->en_etxop;
589 EFSYS_ASSERT3U(etp->et_magic, ==, EFX_TXQ_MAGIC);
590 EFSYS_ASSERT(etxop->etxo_qdesc_dma_create != NULL);
592 etxop->etxo_qdesc_dma_create(etp, addr, size, eop, edp);
596 efx_tx_qdesc_tso_create(
598 __in uint16_t ipv4_id,
599 __in uint32_t tcp_seq,
600 __in uint8_t tcp_flags,
601 __out efx_desc_t *edp)
603 efx_nic_t *enp = etp->et_enp;
604 const efx_tx_ops_t *etxop = enp->en_etxop;
606 EFSYS_ASSERT3U(etp->et_magic, ==, EFX_TXQ_MAGIC);
607 EFSYS_ASSERT(etxop->etxo_qdesc_tso_create != NULL);
609 etxop->etxo_qdesc_tso_create(etp, ipv4_id, tcp_seq, tcp_flags, edp);
613 efx_tx_qdesc_tso2_create(
615 __in uint16_t ipv4_id,
616 __in uint32_t tcp_seq,
618 __out_ecount(count) efx_desc_t *edp,
621 efx_nic_t *enp = etp->et_enp;
622 const efx_tx_ops_t *etxop = enp->en_etxop;
624 EFSYS_ASSERT3U(etp->et_magic, ==, EFX_TXQ_MAGIC);
625 EFSYS_ASSERT(etxop->etxo_qdesc_tso2_create != NULL);
627 etxop->etxo_qdesc_tso2_create(etp, ipv4_id, tcp_seq, mss, edp, count);
631 efx_tx_qdesc_vlantci_create(
634 __out efx_desc_t *edp)
636 efx_nic_t *enp = etp->et_enp;
637 const efx_tx_ops_t *etxop = enp->en_etxop;
639 EFSYS_ASSERT3U(etp->et_magic, ==, EFX_TXQ_MAGIC);
640 EFSYS_ASSERT(etxop->etxo_qdesc_vlantci_create != NULL);
642 etxop->etxo_qdesc_vlantci_create(etp, tci, edp);
648 efx_tx_qstats_update(
650 __inout_ecount(TX_NQSTATS) efsys_stat_t *stat)
652 efx_nic_t *enp = etp->et_enp;
653 const efx_tx_ops_t *etxop = enp->en_etxop;
655 EFSYS_ASSERT3U(etp->et_magic, ==, EFX_TXQ_MAGIC);
657 etxop->etxo_qstats_update(etp, stat);
664 static __checkReturn efx_rc_t
671 * Disable the timer-based TX DMA backoff and allow TX DMA to be
672 * controlled by the RX FIFO fill level (although always allow a
675 EFX_BAR_READO(enp, FR_AZ_TX_RESERVED_REG, &oword);
676 EFX_SET_OWORD_FIELD(oword, FRF_AZ_TX_RX_SPACER, 0xfe);
677 EFX_SET_OWORD_FIELD(oword, FRF_AZ_TX_RX_SPACER_EN, 1);
678 EFX_SET_OWORD_FIELD(oword, FRF_AZ_TX_ONE_PKT_PER_Q, 1);
679 EFX_SET_OWORD_FIELD(oword, FRF_AZ_TX_PUSH_EN, 0);
680 EFX_SET_OWORD_FIELD(oword, FRF_AZ_TX_DIS_NON_IP_EV, 1);
681 EFX_SET_OWORD_FIELD(oword, FRF_AZ_TX_PREF_THRESHOLD, 2);
682 EFX_SET_OWORD_FIELD(oword, FRF_AZ_TX_PREF_WD_TMR, 0x3fffff);
685 * Filter all packets less than 14 bytes to avoid parsing
688 EFX_SET_OWORD_FIELD(oword, FRF_BZ_TX_FLUSH_MIN_LEN_EN, 1);
689 EFX_BAR_WRITEO(enp, FR_AZ_TX_RESERVED_REG, &oword);
692 * Do not set TX_NO_EOP_DISC_EN, since it limits packets to 16
693 * descriptors (which is bad).
695 EFX_BAR_READO(enp, FR_AZ_TX_CFG_REG, &oword);
696 EFX_SET_OWORD_FIELD(oword, FRF_AZ_TX_NO_EOP_DISC_EN, 0);
697 EFX_BAR_WRITEO(enp, FR_AZ_TX_CFG_REG, &oword);
702 #define EFX_TX_DESC(_etp, _addr, _size, _eop, _added) \
708 id = (_added)++ & (_etp)->et_mask; \
709 offset = id * sizeof (efx_qword_t); \
711 EFSYS_PROBE5(tx_post, unsigned int, (_etp)->et_index, \
712 unsigned int, id, efsys_dma_addr_t, (_addr), \
713 size_t, (_size), boolean_t, (_eop)); \
715 EFX_POPULATE_QWORD_4(qword, \
716 FSF_AZ_TX_KER_CONT, (_eop) ? 0 : 1, \
717 FSF_AZ_TX_KER_BYTE_COUNT, (uint32_t)(_size), \
718 FSF_AZ_TX_KER_BUF_ADDR_DW0, \
719 (uint32_t)((_addr) & 0xffffffff), \
720 FSF_AZ_TX_KER_BUF_ADDR_DW1, \
721 (uint32_t)((_addr) >> 32)); \
722 EFSYS_MEM_WRITEQ((_etp)->et_esmp, offset, &qword); \
724 _NOTE(CONSTANTCONDITION) \
727 static __checkReturn efx_rc_t
730 __in_ecount(n) efx_buffer_t *eb,
732 __in unsigned int completed,
733 __inout unsigned int *addedp)
735 unsigned int added = *addedp;
739 if (added - completed + n > EFX_TXQ_LIMIT(etp->et_mask + 1))
742 for (i = 0; i < n; i++) {
743 efx_buffer_t *ebp = &eb[i];
744 efsys_dma_addr_t start = ebp->eb_addr;
745 size_t size = ebp->eb_size;
746 efsys_dma_addr_t end = start + size;
749 * Fragments must not span 4k boundaries.
750 * Here it is a stricter requirement than the maximum length.
752 EFSYS_ASSERT(P2ROUNDUP(start + 1,
753 etp->et_enp->en_nic_cfg.enc_tx_dma_desc_boundary) >= end);
755 EFX_TX_DESC(etp, start, size, ebp->eb_eop, added);
758 EFX_TX_QSTAT_INCR(etp, TX_POST);
764 EFSYS_PROBE1(fail1, efx_rc_t, rc);
772 __in unsigned int added,
773 __in unsigned int pushed)
775 efx_nic_t *enp = etp->et_enp;
780 /* Push the populated descriptors out */
781 wptr = added & etp->et_mask;
783 EFX_POPULATE_OWORD_1(oword, FRF_AZ_TX_DESC_WPTR, wptr);
785 /* Only write the third DWORD */
786 EFX_POPULATE_DWORD_1(dword,
787 EFX_DWORD_0, EFX_OWORD_FIELD(oword, EFX_DWORD_3));
789 /* Guarantee ordering of memory (descriptors) and PIO (doorbell) */
790 EFX_DMA_SYNC_QUEUE_FOR_DEVICE(etp->et_esmp, etp->et_mask + 1,
791 wptr, pushed & etp->et_mask);
792 EFSYS_PIO_WRITE_BARRIER();
793 EFX_BAR_TBL_WRITED3(enp, FR_BZ_TX_DESC_UPD_REGP0,
794 etp->et_index, &dword, B_FALSE);
797 #define EFX_MAX_PACE_VALUE 20
799 static __checkReturn efx_rc_t
802 __in unsigned int ns)
804 efx_nic_t *enp = etp->et_enp;
805 efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
807 unsigned int pace_val;
808 unsigned int timer_period;
815 * The pace_val to write into the table is s.t
816 * ns <= timer_period * (2 ^ pace_val)
818 timer_period = 104 / encp->enc_clk_mult;
819 for (pace_val = 1; pace_val <= EFX_MAX_PACE_VALUE; pace_val++) {
820 if ((timer_period << pace_val) >= ns)
824 if (pace_val > EFX_MAX_PACE_VALUE) {
829 /* Update the pacing table */
830 EFX_POPULATE_OWORD_1(oword, FRF_AZ_TX_PACE, pace_val);
831 EFX_BAR_TBL_WRITEO(enp, FR_AZ_TX_PACE_TBL, etp->et_index,
837 EFSYS_PROBE1(fail1, efx_rc_t, rc);
842 static __checkReturn efx_rc_t
846 efx_nic_t *enp = etp->et_enp;
850 efx_tx_qpace(etp, 0);
852 label = etp->et_index;
854 /* Flush the queue */
855 EFX_POPULATE_OWORD_2(oword, FRF_AZ_TX_FLUSH_DESCQ_CMD, 1,
856 FRF_AZ_TX_FLUSH_DESCQ, label);
857 EFX_BAR_WRITEO(enp, FR_AZ_TX_FLUSH_DESCQ_REG, &oword);
866 efx_nic_t *enp = etp->et_enp;
869 EFX_BAR_TBL_READO(enp, FR_AZ_TX_DESC_PTR_TBL,
870 etp->et_index, &oword, B_TRUE);
872 EFSYS_PROBE5(tx_descq_ptr, unsigned int, etp->et_index,
873 uint32_t, EFX_OWORD_FIELD(oword, EFX_DWORD_3),
874 uint32_t, EFX_OWORD_FIELD(oword, EFX_DWORD_2),
875 uint32_t, EFX_OWORD_FIELD(oword, EFX_DWORD_1),
876 uint32_t, EFX_OWORD_FIELD(oword, EFX_DWORD_0));
878 EFX_SET_OWORD_FIELD(oword, FRF_AZ_TX_DC_HW_RPTR, 0);
879 EFX_SET_OWORD_FIELD(oword, FRF_AZ_TX_DESCQ_HW_RPTR, 0);
880 EFX_SET_OWORD_FIELD(oword, FRF_AZ_TX_DESCQ_EN, 1);
882 EFX_BAR_TBL_WRITEO(enp, FR_AZ_TX_DESC_PTR_TBL,
883 etp->et_index, &oword, B_TRUE);
886 static __checkReturn efx_rc_t
889 __in unsigned int index,
890 __in unsigned int label,
891 __in efsys_mem_t *esmp,
897 __out unsigned int *addedp)
899 efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
904 _NOTE(ARGUNUSED(esmp))
906 EFX_STATIC_ASSERT(EFX_EV_TX_NLABELS ==
907 (1 << FRF_AZ_TX_DESCQ_LABEL_WIDTH));
908 EFSYS_ASSERT3U(label, <, EFX_EV_TX_NLABELS);
910 EFSYS_ASSERT(ISP2(encp->enc_txq_max_ndescs));
911 EFX_STATIC_ASSERT(ISP2(EFX_TXQ_MINNDESCS));
913 if (!ISP2(n) || (n < EFX_TXQ_MINNDESCS) || (n > EFX_EVQ_MAXNEVS)) {
917 if (index >= encp->enc_txq_limit) {
922 (1 << size) <= (int)(encp->enc_txq_max_ndescs / EFX_TXQ_MINNDESCS);
924 if ((1 << size) == (int)(n / EFX_TXQ_MINNDESCS))
926 if (id + (1 << size) >= encp->enc_buftbl_limit) {
931 /* Set up the new descriptor queue */
934 EFX_POPULATE_OWORD_6(oword,
935 FRF_AZ_TX_DESCQ_BUF_BASE_ID, id,
936 FRF_AZ_TX_DESCQ_EVQ_ID, eep->ee_index,
937 FRF_AZ_TX_DESCQ_OWNER_ID, 0,
938 FRF_AZ_TX_DESCQ_LABEL, label,
939 FRF_AZ_TX_DESCQ_SIZE, size,
940 FRF_AZ_TX_DESCQ_TYPE, 0);
942 EFX_SET_OWORD_FIELD(oword, FRF_BZ_TX_NON_IP_DROP_DIS, 1);
943 EFX_SET_OWORD_FIELD(oword, FRF_BZ_TX_IP_CHKSM_DIS,
944 (flags & EFX_TXQ_CKSUM_IPV4) ? 0 : 1);
945 EFX_SET_OWORD_FIELD(oword, FRF_BZ_TX_TCP_CHKSM_DIS,
946 (flags & EFX_TXQ_CKSUM_TCPUDP) ? 0 : 1);
948 EFX_BAR_TBL_WRITEO(enp, FR_AZ_TX_DESC_PTR_TBL,
949 etp->et_index, &oword, B_TRUE);
958 EFSYS_PROBE1(fail1, efx_rc_t, rc);
963 __checkReturn efx_rc_t
966 __in_ecount(n) efx_desc_t *ed,
968 __in unsigned int completed,
969 __inout unsigned int *addedp)
971 unsigned int added = *addedp;
975 if (added - completed + n > EFX_TXQ_LIMIT(etp->et_mask + 1)) {
980 for (i = 0; i < n; i++) {
981 efx_desc_t *edp = &ed[i];
985 id = added++ & etp->et_mask;
986 offset = id * sizeof (efx_desc_t);
988 EFSYS_MEM_WRITEQ(etp->et_esmp, offset, &edp->ed_eq);
991 EFSYS_PROBE3(tx_desc_post, unsigned int, etp->et_index,
992 unsigned int, added, unsigned int, n);
994 EFX_TX_QSTAT_INCR(etp, TX_POST);
1000 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1005 siena_tx_qdesc_dma_create(
1006 __in efx_txq_t *etp,
1007 __in efsys_dma_addr_t addr,
1010 __out efx_desc_t *edp)
1013 * Fragments must not span 4k boundaries.
1014 * Here it is a stricter requirement than the maximum length.
1016 EFSYS_ASSERT(P2ROUNDUP(addr + 1,
1017 etp->et_enp->en_nic_cfg.enc_tx_dma_desc_boundary) >= addr + size);
1019 EFSYS_PROBE4(tx_desc_dma_create, unsigned int, etp->et_index,
1020 efsys_dma_addr_t, addr,
1021 size_t, size, boolean_t, eop);
1023 EFX_POPULATE_QWORD_4(edp->ed_eq,
1024 FSF_AZ_TX_KER_CONT, eop ? 0 : 1,
1025 FSF_AZ_TX_KER_BYTE_COUNT, (uint32_t)size,
1026 FSF_AZ_TX_KER_BUF_ADDR_DW0,
1027 (uint32_t)(addr & 0xffffffff),
1028 FSF_AZ_TX_KER_BUF_ADDR_DW1,
1029 (uint32_t)(addr >> 32));
1032 #endif /* EFSYS_OPT_SIENA */
1034 #if EFSYS_OPT_QSTATS
1036 /* START MKCONFIG GENERATED EfxTransmitQueueStatNamesBlock 2866874ecd7a363b */
1037 static const char * const __efx_tx_qstat_name[] = {
1041 /* END MKCONFIG GENERATED EfxTransmitQueueStatNamesBlock */
1045 __in efx_nic_t *enp,
1046 __in unsigned int id)
1048 _NOTE(ARGUNUSED(enp))
1049 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
1050 EFSYS_ASSERT3U(id, <, TX_NQSTATS);
1052 return (__efx_tx_qstat_name[id]);
1054 #endif /* EFSYS_OPT_NAMES */
1055 #endif /* EFSYS_OPT_QSTATS */
1059 #if EFSYS_OPT_QSTATS
1061 siena_tx_qstats_update(
1062 __in efx_txq_t *etp,
1063 __inout_ecount(TX_NQSTATS) efsys_stat_t *stat)
1067 for (id = 0; id < TX_NQSTATS; id++) {
1068 efsys_stat_t *essp = &stat[id];
1070 EFSYS_STAT_INCR(essp, etp->et_stat[id]);
1071 etp->et_stat[id] = 0;
1074 #endif /* EFSYS_OPT_QSTATS */
1078 __in efx_txq_t *etp)
1080 efx_nic_t *enp = etp->et_enp;
1083 /* Purge descriptor queue */
1084 EFX_ZERO_OWORD(oword);
1086 EFX_BAR_TBL_WRITEO(enp, FR_AZ_TX_DESC_PTR_TBL,
1087 etp->et_index, &oword, B_TRUE);
1092 __in efx_nic_t *enp)
1094 _NOTE(ARGUNUSED(enp))
1097 #endif /* EFSYS_OPT_SIENA */