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.
34 __checkReturn efx_rc_t
38 __in efsys_mem_t *esmp,
43 uint32_t stop = start + n;
44 efsys_dma_addr_t addr;
49 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
50 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NIC);
52 #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
53 if (enp->en_family == EFX_FAMILY_HUNTINGTON ||
54 enp->en_family == EFX_FAMILY_MEDFORD) {
56 * FIXME: the efx_sram_buf_tbl_*() functionality needs to be
57 * pulled inside the Falcon/Siena queue create/destroy code,
58 * and then the original functions can be removed (see bug30834
59 * comment #1). But, for now, we just ensure that they are
60 * no-ops for EF10, to allow bringing up existing drivers
61 * without modification.
66 #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
68 if (stop >= EFX_BUF_TBL_SIZE) {
73 /* Add the entries into the buffer table */
74 addr = EFSYS_MEM_ADDR(esmp);
75 for (id = start; id != stop; id++) {
76 EFX_POPULATE_QWORD_5(qword,
77 FRF_AZ_IP_DAT_BUF_SIZE, 0, FRF_AZ_BUF_ADR_REGION, 0,
78 FRF_AZ_BUF_ADR_FBUF_DW0,
79 (uint32_t)((addr >> 12) & 0xffffffff),
80 FRF_AZ_BUF_ADR_FBUF_DW1,
81 (uint32_t)((addr >> 12) >> 32),
82 FRF_AZ_BUF_OWNER_ID_FBUF, 0);
84 EFX_BAR_TBL_WRITEQ(enp, FR_AZ_BUF_FULL_TBL,
90 EFSYS_PROBE2(buf, uint32_t, start, uint32_t, stop - 1);
92 /* Flush the write buffer */
93 EFX_POPULATE_OWORD_2(oword, FRF_AZ_BUF_UPD_CMD, 1,
94 FRF_AZ_BUF_CLR_CMD, 0);
95 EFX_BAR_WRITEO(enp, FR_AZ_BUF_TBL_UPD_REG, &oword);
97 /* Poll for the last entry being written to the buffer table */
98 EFSYS_ASSERT3U(id, ==, stop);
103 EFSYS_PROBE1(wait, unsigned int, count);
108 EFX_BAR_TBL_READQ(enp, FR_AZ_BUF_FULL_TBL,
111 if (EFX_QWORD_FIELD(qword, FRF_AZ_BUF_ADR_FBUF_DW0) ==
112 (uint32_t)((addr >> 12) & 0xffffffff) &&
113 EFX_QWORD_FIELD(qword, FRF_AZ_BUF_ADR_FBUF_DW1) ==
114 (uint32_t)((addr >> 12) >> 32))
117 } while (++count < 100);
123 /* Verify the rest of the entries in the buffer table */
124 while (--id != start) {
125 addr -= EFX_BUF_SIZE;
127 /* Read the buffer table entry */
128 EFX_BAR_TBL_READQ(enp, FR_AZ_BUF_FULL_TBL,
131 if (EFX_QWORD_FIELD(qword, FRF_AZ_BUF_ADR_FBUF_DW0) !=
132 (uint32_t)((addr >> 12) & 0xffffffff) ||
133 EFX_QWORD_FIELD(qword, FRF_AZ_BUF_ADR_FBUF_DW1) !=
134 (uint32_t)((addr >> 12) >> 32)) {
150 EFX_POPULATE_OWORD_4(oword, FRF_AZ_BUF_UPD_CMD, 0,
151 FRF_AZ_BUF_CLR_CMD, 1, FRF_AZ_BUF_CLR_END_ID, id - 1,
152 FRF_AZ_BUF_CLR_START_ID, start);
153 EFX_BAR_WRITEO(enp, FR_AZ_BUF_TBL_UPD_REG, &oword);
156 EFSYS_PROBE1(fail1, efx_rc_t, rc);
162 efx_sram_buf_tbl_clear(
169 uint32_t stop = start + n;
171 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
172 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NIC);
174 #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
175 if (enp->en_family == EFX_FAMILY_HUNTINGTON ||
176 enp->en_family == EFX_FAMILY_MEDFORD) {
178 * FIXME: the efx_sram_buf_tbl_*() functionality needs to be
179 * pulled inside the Falcon/Siena queue create/destroy code,
180 * and then the original functions can be removed (see bug30834
181 * comment #1). But, for now, we just ensure that they are
182 * no-ops for EF10, to allow bringing up existing drivers
183 * without modification.
188 #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
190 EFSYS_ASSERT3U(stop, <, EFX_BUF_TBL_SIZE);
192 EFSYS_PROBE2(buf, uint32_t, start, uint32_t, stop - 1);
194 EFX_POPULATE_OWORD_4(oword, FRF_AZ_BUF_UPD_CMD, 0,
195 FRF_AZ_BUF_CLR_CMD, 1, FRF_AZ_BUF_CLR_END_ID, stop - 1,
196 FRF_AZ_BUF_CLR_START_ID, start);
197 EFX_BAR_WRITEO(enp, FR_AZ_BUF_TBL_UPD_REG, &oword);