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