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 __checkReturn efx_rc_t
37 __inout efx_nic_t *enp)
39 const efx_rx_ops_t *erxop;
42 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
43 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NIC);
45 if (!(enp->en_mod_flags & EFX_MOD_EV)) {
50 if (enp->en_mod_flags & EFX_MOD_RX) {
55 switch (enp->en_family) {
63 if ((rc = erxop->erxo_init(enp)) != 0)
66 enp->en_erxop = erxop;
67 enp->en_mod_flags |= EFX_MOD_RX;
77 EFSYS_PROBE1(fail1, efx_rc_t, rc);
80 enp->en_mod_flags &= ~EFX_MOD_RX;
88 const efx_rx_ops_t *erxop = enp->en_erxop;
90 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
91 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NIC);
92 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_RX);
93 EFSYS_ASSERT3U(enp->en_rx_qcount, ==, 0);
95 erxop->erxo_fini(enp);
98 enp->en_mod_flags &= ~EFX_MOD_RX;
104 __in_ecount(n) efsys_dma_addr_t *addrp,
107 __in unsigned int completed,
108 __in unsigned int added)
110 efx_nic_t *enp = erp->er_enp;
111 const efx_rx_ops_t *erxop = enp->en_erxop;
113 EFSYS_ASSERT3U(erp->er_magic, ==, EFX_RXQ_MAGIC);
115 erxop->erxo_qpost(erp, addrp, size, n, completed, added);
121 __in unsigned int added,
122 __inout unsigned int *pushedp)
124 efx_nic_t *enp = erp->er_enp;
125 const efx_rx_ops_t *erxop = enp->en_erxop;
127 EFSYS_ASSERT3U(erp->er_magic, ==, EFX_RXQ_MAGIC);
129 erxop->erxo_qpush(erp, added, pushedp);
132 __checkReturn efx_rc_t
136 efx_nic_t *enp = erp->er_enp;
137 const efx_rx_ops_t *erxop = enp->en_erxop;
140 EFSYS_ASSERT3U(erp->er_magic, ==, EFX_RXQ_MAGIC);
142 if ((rc = erxop->erxo_qflush(erp)) != 0)
148 EFSYS_PROBE1(fail1, efx_rc_t, rc);
157 efx_nic_t *enp = erp->er_enp;
158 const efx_rx_ops_t *erxop = enp->en_erxop;
160 EFSYS_ASSERT3U(erp->er_magic, ==, EFX_RXQ_MAGIC);
162 erxop->erxo_qenable(erp);
165 __checkReturn efx_rc_t
168 __in unsigned int index,
169 __in unsigned int label,
170 __in efx_rxq_type_t type,
171 __in efsys_mem_t *esmp,
175 __deref_out efx_rxq_t **erpp)
177 const efx_rx_ops_t *erxop = enp->en_erxop;
181 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
182 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_RX);
184 /* Allocate an RXQ object */
185 EFSYS_KMEM_ALLOC(enp->en_esip, sizeof (efx_rxq_t), erp);
192 erp->er_magic = EFX_RXQ_MAGIC;
194 erp->er_index = index;
195 erp->er_mask = n - 1;
198 if ((rc = erxop->erxo_qcreate(enp, index, label, type, esmp, n, id,
210 EFSYS_KMEM_FREE(enp->en_esip, sizeof (efx_rxq_t), erp);
212 EFSYS_PROBE1(fail1, efx_rc_t, rc);
221 efx_nic_t *enp = erp->er_enp;
222 const efx_rx_ops_t *erxop = enp->en_erxop;
224 EFSYS_ASSERT3U(erp->er_magic, ==, EFX_RXQ_MAGIC);
226 erxop->erxo_qdestroy(erp);
229 __checkReturn efx_rc_t
230 efx_pseudo_hdr_pkt_length_get(
232 __in uint8_t *buffer,
233 __out uint16_t *lengthp)
235 efx_nic_t *enp = erp->er_enp;
236 const efx_rx_ops_t *erxop = enp->en_erxop;
238 EFSYS_ASSERT3U(erp->er_magic, ==, EFX_RXQ_MAGIC);
240 return (erxop->erxo_prefix_pktlen(enp, buffer, lengthp));