1 /* SPDX-License-Identifier: BSD-3-Clause
3 * Copyright (c) 2007-2018 Solarflare Communications Inc.
10 __checkReturn efx_rc_t
14 __in efsys_mem_t *esmp,
19 uint32_t stop = start + n;
20 efsys_dma_addr_t addr;
25 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
26 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NIC);
28 #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
29 if (enp->en_family == EFX_FAMILY_HUNTINGTON ||
30 enp->en_family == EFX_FAMILY_MEDFORD ||
31 enp->en_family == EFX_FAMILY_MEDFORD2) {
33 * FIXME: the efx_sram_buf_tbl_*() functionality needs to be
34 * pulled inside the Falcon/Siena queue create/destroy code,
35 * and then the original functions can be removed (see bug30834
36 * comment #1). But, for now, we just ensure that they are
37 * no-ops for EF10, to allow bringing up existing drivers
38 * without modification.
43 #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
45 if (stop >= EFX_BUF_TBL_SIZE) {
50 /* Add the entries into the buffer table */
51 addr = EFSYS_MEM_ADDR(esmp);
52 for (id = start; id != stop; id++) {
53 EFX_POPULATE_QWORD_5(qword,
54 FRF_AZ_IP_DAT_BUF_SIZE, 0, FRF_AZ_BUF_ADR_REGION, 0,
55 FRF_AZ_BUF_ADR_FBUF_DW0,
56 (uint32_t)((addr >> 12) & 0xffffffff),
57 FRF_AZ_BUF_ADR_FBUF_DW1,
58 (uint32_t)((addr >> 12) >> 32),
59 FRF_AZ_BUF_OWNER_ID_FBUF, 0);
61 EFX_BAR_TBL_WRITEQ(enp, FR_AZ_BUF_FULL_TBL,
67 EFSYS_PROBE2(buf, uint32_t, start, uint32_t, stop - 1);
69 /* Flush the write buffer */
70 EFX_POPULATE_OWORD_2(oword, FRF_AZ_BUF_UPD_CMD, 1,
71 FRF_AZ_BUF_CLR_CMD, 0);
72 EFX_BAR_WRITEO(enp, FR_AZ_BUF_TBL_UPD_REG, &oword);
74 /* Poll for the last entry being written to the buffer table */
75 EFSYS_ASSERT3U(id, ==, stop);
80 EFSYS_PROBE1(wait, unsigned int, count);
85 EFX_BAR_TBL_READQ(enp, FR_AZ_BUF_FULL_TBL,
88 if (EFX_QWORD_FIELD(qword, FRF_AZ_BUF_ADR_FBUF_DW0) ==
89 (uint32_t)((addr >> 12) & 0xffffffff) &&
90 EFX_QWORD_FIELD(qword, FRF_AZ_BUF_ADR_FBUF_DW1) ==
91 (uint32_t)((addr >> 12) >> 32))
94 } while (++count < 100);
100 /* Verify the rest of the entries in the buffer table */
101 while (--id != start) {
102 addr -= EFX_BUF_SIZE;
104 /* Read the buffer table entry */
105 EFX_BAR_TBL_READQ(enp, FR_AZ_BUF_FULL_TBL,
108 if (EFX_QWORD_FIELD(qword, FRF_AZ_BUF_ADR_FBUF_DW0) !=
109 (uint32_t)((addr >> 12) & 0xffffffff) ||
110 EFX_QWORD_FIELD(qword, FRF_AZ_BUF_ADR_FBUF_DW1) !=
111 (uint32_t)((addr >> 12) >> 32)) {
127 EFX_POPULATE_OWORD_4(oword, FRF_AZ_BUF_UPD_CMD, 0,
128 FRF_AZ_BUF_CLR_CMD, 1, FRF_AZ_BUF_CLR_END_ID, id - 1,
129 FRF_AZ_BUF_CLR_START_ID, start);
130 EFX_BAR_WRITEO(enp, FR_AZ_BUF_TBL_UPD_REG, &oword);
133 EFSYS_PROBE1(fail1, efx_rc_t, rc);
139 efx_sram_buf_tbl_clear(
146 uint32_t stop = start + n;
148 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
149 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NIC);
151 #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
152 if (enp->en_family == EFX_FAMILY_HUNTINGTON ||
153 enp->en_family == EFX_FAMILY_MEDFORD ||
154 enp->en_family == EFX_FAMILY_MEDFORD2) {
156 * FIXME: the efx_sram_buf_tbl_*() functionality needs to be
157 * pulled inside the Falcon/Siena queue create/destroy code,
158 * and then the original functions can be removed (see bug30834
159 * comment #1). But, for now, we just ensure that they are
160 * no-ops for EF10, to allow bringing up existing drivers
161 * without modification.
166 #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
168 EFSYS_ASSERT3U(stop, <, EFX_BUF_TBL_SIZE);
170 EFSYS_PROBE2(buf, uint32_t, start, uint32_t, stop - 1);
172 EFX_POPULATE_OWORD_4(oword, FRF_AZ_BUF_UPD_CMD, 0,
173 FRF_AZ_BUF_CLR_CMD, 1, FRF_AZ_BUF_CLR_END_ID, stop - 1,
174 FRF_AZ_BUF_CLR_START_ID, start);
175 EFX_BAR_WRITEO(enp, FR_AZ_BUF_TBL_UPD_REG, &oword);
182 efx_sram_byte_increment_set(
184 __in boolean_t negate,
185 __out efx_qword_t *eqp)
187 size_t offset = row * FR_AZ_SRM_DBG_REG_STEP;
190 _NOTE(ARGUNUSED(negate))
192 for (index = 0; index < sizeof (efx_qword_t); index++)
193 eqp->eq_u8[index] = offset + index;
197 efx_sram_all_the_same_set(
199 __in boolean_t negate,
200 __out efx_qword_t *eqp)
202 _NOTE(ARGUNUSED(row))
207 EFX_ZERO_QWORD(*eqp);
211 efx_sram_bit_alternate_set(
213 __in boolean_t negate,
214 __out efx_qword_t *eqp)
216 _NOTE(ARGUNUSED(row))
218 EFX_POPULATE_QWORD_2(*eqp,
219 EFX_DWORD_0, (negate) ? 0x55555555 : 0xaaaaaaaa,
220 EFX_DWORD_1, (negate) ? 0x55555555 : 0xaaaaaaaa);
224 efx_sram_byte_alternate_set(
226 __in boolean_t negate,
227 __out efx_qword_t *eqp)
229 _NOTE(ARGUNUSED(row))
231 EFX_POPULATE_QWORD_2(*eqp,
232 EFX_DWORD_0, (negate) ? 0x00ff00ff : 0xff00ff00,
233 EFX_DWORD_1, (negate) ? 0x00ff00ff : 0xff00ff00);
237 efx_sram_byte_changing_set(
239 __in boolean_t negate,
240 __out efx_qword_t *eqp)
242 size_t offset = row * FR_AZ_SRM_DBG_REG_STEP;
245 for (index = 0; index < sizeof (efx_qword_t); index++) {
248 if (offset / 256 == 0)
249 byte = (uint8_t)((offset % 257) % 256);
251 byte = (uint8_t)(~((offset - 8) % 257) % 256);
253 eqp->eq_u8[index] = (negate) ? ~byte : byte;
258 efx_sram_bit_sweep_set(
260 __in boolean_t negate,
261 __out efx_qword_t *eqp)
263 size_t offset = row * FR_AZ_SRM_DBG_REG_STEP;
267 EFX_CLEAR_QWORD_BIT(*eqp, (offset / sizeof (efx_qword_t)) % 64);
269 EFX_ZERO_QWORD(*eqp);
270 EFX_SET_QWORD_BIT(*eqp, (offset / sizeof (efx_qword_t)) % 64);
274 efx_sram_pattern_fn_t __efx_sram_pattern_fns[] = {
275 efx_sram_byte_increment_set,
276 efx_sram_all_the_same_set,
277 efx_sram_bit_alternate_set,
278 efx_sram_byte_alternate_set,
279 efx_sram_byte_changing_set,
280 efx_sram_bit_sweep_set
283 __checkReturn efx_rc_t
286 __in efx_pattern_type_t type)
288 efx_sram_pattern_fn_t func;
290 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
292 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NIC);
294 EFSYS_ASSERT(!(enp->en_mod_flags & EFX_MOD_RX));
295 EFSYS_ASSERT(!(enp->en_mod_flags & EFX_MOD_TX));
296 EFSYS_ASSERT(!(enp->en_mod_flags & EFX_MOD_EV));
298 /* SRAM testing is only available on Siena. */
299 if (enp->en_family != EFX_FAMILY_SIENA)
302 /* Select pattern generator */
303 EFSYS_ASSERT3U(type, <, EFX_PATTERN_NTYPES);
304 func = __efx_sram_pattern_fns[type];
306 return (siena_sram_test(enp, func));
309 #endif /* EFSYS_OPT_DIAG */