efx_sram.c (4d846d26) | efx_sram.c (e948693e) |
---|---|
1/*- | 1/*- |
2 * SPDX-License-Identifier: BSD-2-Clause | 2 * Copyright 2007-2009 Solarflare Communications Inc. All rights reserved. |
3 * | 3 * |
4 * Copyright (c) 2007-2016 Solarflare Communications Inc. 5 * All rights reserved. 6 * | |
7 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
8 * modification, are permitted provided that the following conditions are met: | 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. |
9 * | 12 * |
10 * 1. Redistributions of source code must retain the above copyright notice, 11 * this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright notice, 13 * this list of conditions and the following disclaimer in the documentation 14 * and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 18 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 23 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * The views and conclusions contained in the software and documentation are 29 * those of the authors and should not be interpreted as representing official 30 * policies, either expressed or implied, of the FreeBSD Project. | 13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS AND 14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 * SUCH DAMAGE. |
31 */ 32 | 24 */ 25 |
33#include <sys/cdefs.h> 34__FBSDID("$FreeBSD$"); 35 | 26#include "efsys.h" |
36#include "efx.h" | 27#include "efx.h" |
28#include "efx_types.h" 29#include "efx_regs.h" |
|
37#include "efx_impl.h" 38 | 30#include "efx_impl.h" 31 |
39 __checkReturn efx_rc_t | 32 __checkReturn int |
40efx_sram_buf_tbl_set( 41 __in efx_nic_t *enp, 42 __in uint32_t id, 43 __in efsys_mem_t *esmp, 44 __in size_t n) 45{ 46 efx_qword_t qword; 47 uint32_t start = id; 48 uint32_t stop = start + n; 49 efsys_dma_addr_t addr; 50 efx_oword_t oword; 51 unsigned int count; | 33efx_sram_buf_tbl_set( 34 __in efx_nic_t *enp, 35 __in uint32_t id, 36 __in efsys_mem_t *esmp, 37 __in size_t n) 38{ 39 efx_qword_t qword; 40 uint32_t start = id; 41 uint32_t stop = start + n; 42 efsys_dma_addr_t addr; 43 efx_oword_t oword; 44 unsigned int count; |
52 efx_rc_t rc; | 45 int rc; |
53 54 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); 55 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NIC); 56 | 46 47 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); 48 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NIC); 49 |
57#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 58 if (enp->en_family == EFX_FAMILY_HUNTINGTON || 59 enp->en_family == EFX_FAMILY_MEDFORD || 60 enp->en_family == EFX_FAMILY_MEDFORD2) { 61 /* 62 * FIXME: the efx_sram_buf_tbl_*() functionality needs to be 63 * pulled inside the Falcon/Siena queue create/destroy code, 64 * and then the original functions can be removed (see bug30834 65 * comment #1). But, for now, we just ensure that they are 66 * no-ops for EF10, to allow bringing up existing drivers 67 * without modification. 68 */ 69 70 return (0); 71 } 72#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */ 73 | |
74 if (stop >= EFX_BUF_TBL_SIZE) { 75 rc = EFBIG; 76 goto fail1; 77 } 78 79 /* Add the entries into the buffer table */ 80 addr = EFSYS_MEM_ADDR(esmp); 81 for (id = start; id != stop; id++) { --- 72 unchanged lines hidden (view full) --- 154 EFSYS_PROBE(fail2); 155 156 EFX_POPULATE_OWORD_4(oword, FRF_AZ_BUF_UPD_CMD, 0, 157 FRF_AZ_BUF_CLR_CMD, 1, FRF_AZ_BUF_CLR_END_ID, id - 1, 158 FRF_AZ_BUF_CLR_START_ID, start); 159 EFX_BAR_WRITEO(enp, FR_AZ_BUF_TBL_UPD_REG, &oword); 160 161fail1: | 50 if (stop >= EFX_BUF_TBL_SIZE) { 51 rc = EFBIG; 52 goto fail1; 53 } 54 55 /* Add the entries into the buffer table */ 56 addr = EFSYS_MEM_ADDR(esmp); 57 for (id = start; id != stop; id++) { --- 72 unchanged lines hidden (view full) --- 130 EFSYS_PROBE(fail2); 131 132 EFX_POPULATE_OWORD_4(oword, FRF_AZ_BUF_UPD_CMD, 0, 133 FRF_AZ_BUF_CLR_CMD, 1, FRF_AZ_BUF_CLR_END_ID, id - 1, 134 FRF_AZ_BUF_CLR_START_ID, start); 135 EFX_BAR_WRITEO(enp, FR_AZ_BUF_TBL_UPD_REG, &oword); 136 137fail1: |
162 EFSYS_PROBE1(fail1, efx_rc_t, rc); | 138 EFSYS_PROBE1(fail1, int, rc); |
163 164 return (rc); 165} 166 167 void 168efx_sram_buf_tbl_clear( 169 __in efx_nic_t *enp, 170 __in uint32_t id, 171 __in size_t n) 172{ 173 efx_oword_t oword; 174 uint32_t start = id; 175 uint32_t stop = start + n; 176 177 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); 178 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NIC); 179 | 139 140 return (rc); 141} 142 143 void 144efx_sram_buf_tbl_clear( 145 __in efx_nic_t *enp, 146 __in uint32_t id, 147 __in size_t n) 148{ 149 efx_oword_t oword; 150 uint32_t start = id; 151 uint32_t stop = start + n; 152 153 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); 154 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NIC); 155 |
180#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 181 if (enp->en_family == EFX_FAMILY_HUNTINGTON || 182 enp->en_family == EFX_FAMILY_MEDFORD || 183 enp->en_family == EFX_FAMILY_MEDFORD2) { 184 /* 185 * FIXME: the efx_sram_buf_tbl_*() functionality needs to be 186 * pulled inside the Falcon/Siena queue create/destroy code, 187 * and then the original functions can be removed (see bug30834 188 * comment #1). But, for now, we just ensure that they are 189 * no-ops for EF10, to allow bringing up existing drivers 190 * without modification. 191 */ 192 193 return; 194 } 195#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */ 196 | |
197 EFSYS_ASSERT3U(stop, <, EFX_BUF_TBL_SIZE); 198 199 EFSYS_PROBE2(buf, uint32_t, start, uint32_t, stop - 1); 200 201 EFX_POPULATE_OWORD_4(oword, FRF_AZ_BUF_UPD_CMD, 0, 202 FRF_AZ_BUF_CLR_CMD, 1, FRF_AZ_BUF_CLR_END_ID, stop - 1, 203 FRF_AZ_BUF_CLR_START_ID, start); 204 EFX_BAR_WRITEO(enp, FR_AZ_BUF_TBL_UPD_REG, &oword); 205} 206 | 156 EFSYS_ASSERT3U(stop, <, EFX_BUF_TBL_SIZE); 157 158 EFSYS_PROBE2(buf, uint32_t, start, uint32_t, stop - 1); 159 160 EFX_POPULATE_OWORD_4(oword, FRF_AZ_BUF_UPD_CMD, 0, 161 FRF_AZ_BUF_CLR_CMD, 1, FRF_AZ_BUF_CLR_END_ID, stop - 1, 162 FRF_AZ_BUF_CLR_START_ID, start); 163 EFX_BAR_WRITEO(enp, FR_AZ_BUF_TBL_UPD_REG, &oword); 164} 165 |
166 |
|
207#if EFSYS_OPT_DIAG 208 209static void 210efx_sram_byte_increment_set( 211 __in size_t row, 212 __in boolean_t negate, 213 __out efx_qword_t *eqp) 214{ --- 79 unchanged lines hidden (view full) --- 294 EFX_SET_QWORD(*eqp); 295 EFX_CLEAR_QWORD_BIT(*eqp, (offset / sizeof (efx_qword_t)) % 64); 296 } else { 297 EFX_ZERO_QWORD(*eqp); 298 EFX_SET_QWORD_BIT(*eqp, (offset / sizeof (efx_qword_t)) % 64); 299 } 300} 301 | 167#if EFSYS_OPT_DIAG 168 169static void 170efx_sram_byte_increment_set( 171 __in size_t row, 172 __in boolean_t negate, 173 __out efx_qword_t *eqp) 174{ --- 79 unchanged lines hidden (view full) --- 254 EFX_SET_QWORD(*eqp); 255 EFX_CLEAR_QWORD_BIT(*eqp, (offset / sizeof (efx_qword_t)) % 64); 256 } else { 257 EFX_ZERO_QWORD(*eqp); 258 EFX_SET_QWORD_BIT(*eqp, (offset / sizeof (efx_qword_t)) % 64); 259 } 260} 261 |
302efx_sram_pattern_fn_t __efx_sram_pattern_fns[] = { | 262efx_sram_pattern_fn_t __cs __efx_sram_pattern_fns[] = { |
303 efx_sram_byte_increment_set, 304 efx_sram_all_the_same_set, 305 efx_sram_bit_alternate_set, 306 efx_sram_byte_alternate_set, 307 efx_sram_byte_changing_set, 308 efx_sram_bit_sweep_set 309}; 310 | 263 efx_sram_byte_increment_set, 264 efx_sram_all_the_same_set, 265 efx_sram_bit_alternate_set, 266 efx_sram_byte_alternate_set, 267 efx_sram_byte_changing_set, 268 efx_sram_bit_sweep_set 269}; 270 |
311 __checkReturn efx_rc_t | 271 __checkReturn int |
312efx_sram_test( 313 __in efx_nic_t *enp, 314 __in efx_pattern_type_t type) 315{ | 272efx_sram_test( 273 __in efx_nic_t *enp, 274 __in efx_pattern_type_t type) 275{ |
276 efx_nic_ops_t *enop = enp->en_enop; |
|
316 efx_sram_pattern_fn_t func; 317 318 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); 319 320 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NIC); 321 322 EFSYS_ASSERT(!(enp->en_mod_flags & EFX_MOD_RX)); 323 EFSYS_ASSERT(!(enp->en_mod_flags & EFX_MOD_TX)); 324 EFSYS_ASSERT(!(enp->en_mod_flags & EFX_MOD_EV)); 325 | 277 efx_sram_pattern_fn_t func; 278 279 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); 280 281 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NIC); 282 283 EFSYS_ASSERT(!(enp->en_mod_flags & EFX_MOD_RX)); 284 EFSYS_ASSERT(!(enp->en_mod_flags & EFX_MOD_TX)); 285 EFSYS_ASSERT(!(enp->en_mod_flags & EFX_MOD_EV)); 286 |
326 /* SRAM testing is only available on Siena. */ 327 if (enp->en_family != EFX_FAMILY_SIENA) 328 return (0); 329 | |
330 /* Select pattern generator */ 331 EFSYS_ASSERT3U(type, <, EFX_PATTERN_NTYPES); 332 func = __efx_sram_pattern_fns[type]; 333 | 287 /* Select pattern generator */ 288 EFSYS_ASSERT3U(type, <, EFX_PATTERN_NTYPES); 289 func = __efx_sram_pattern_fns[type]; 290 |
334 return (siena_sram_test(enp, func)); | 291 return (enop->eno_sram_test(enp, func)); |
335} 336 337#endif /* EFSYS_OPT_DIAG */ | 292} 293 294#endif /* EFSYS_OPT_DIAG */ |