1 /*- 2 * Copyright (c) 2009-2015 Solarflare Communications Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 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. 13 * 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. 25 * 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. 29 * 30 * $FreeBSD$ 31 */ 32 33 #ifndef _SYS_SIENA_IMPL_H 34 #define _SYS_SIENA_IMPL_H 35 36 #include "efx.h" 37 #include "efx_regs.h" 38 #include "efx_mcdi.h" 39 #include "siena_flash.h" 40 41 #ifdef __cplusplus 42 extern "C" { 43 #endif 44 45 #if EFSYS_OPT_PHY_PROPS 46 47 /* START MKCONFIG GENERATED SienaPhyHeaderPropsBlock a8db1f8eb5106efd */ 48 typedef enum siena_phy_prop_e { 49 SIENA_PHY_NPROPS 50 } siena_phy_prop_t; 51 52 /* END MKCONFIG GENERATED SienaPhyHeaderPropsBlock */ 53 54 #endif /* EFSYS_OPT_PHY_PROPS */ 55 56 #define SIENA_NVRAM_CHUNK 0x80 57 58 extern __checkReturn efx_rc_t 59 siena_nic_probe( 60 __in efx_nic_t *enp); 61 62 #if EFSYS_OPT_PCIE_TUNE 63 64 extern __checkReturn efx_rc_t 65 siena_nic_pcie_extended_sync( 66 __in efx_nic_t *enp); 67 68 #endif 69 70 extern __checkReturn efx_rc_t 71 siena_nic_reset( 72 __in efx_nic_t *enp); 73 74 extern __checkReturn efx_rc_t 75 siena_nic_init( 76 __in efx_nic_t *enp); 77 78 #if EFSYS_OPT_DIAG 79 80 extern __checkReturn efx_rc_t 81 siena_nic_register_test( 82 __in efx_nic_t *enp); 83 84 #endif /* EFSYS_OPT_DIAG */ 85 86 extern void 87 siena_nic_fini( 88 __in efx_nic_t *enp); 89 90 extern void 91 siena_nic_unprobe( 92 __in efx_nic_t *enp); 93 94 #define SIENA_SRAM_ROWS 0x12000 95 96 extern void 97 siena_sram_init( 98 __in efx_nic_t *enp); 99 100 #if EFSYS_OPT_DIAG 101 102 extern __checkReturn efx_rc_t 103 siena_sram_test( 104 __in efx_nic_t *enp, 105 __in efx_sram_pattern_fn_t func); 106 107 #endif /* EFSYS_OPT_DIAG */ 108 109 #if EFSYS_OPT_MCDI 110 111 extern __checkReturn efx_rc_t 112 siena_mcdi_init( 113 __in efx_nic_t *enp, 114 __in const efx_mcdi_transport_t *mtp); 115 116 extern void 117 siena_mcdi_request_copyin( 118 __in efx_nic_t *enp, 119 __in efx_mcdi_req_t *emrp, 120 __in unsigned int seq, 121 __in boolean_t ev_cpl, 122 __in boolean_t new_epoch); 123 124 extern __checkReturn boolean_t 125 siena_mcdi_poll_response( 126 __in efx_nic_t *enp); 127 128 extern void 129 siena_mcdi_read_response( 130 __in efx_nic_t *enp, 131 __out void *bufferp, 132 __in size_t offset, 133 __in size_t length); 134 135 extern void 136 siena_mcdi_request_copyout( 137 __in efx_nic_t *enp, 138 __in efx_mcdi_req_t *emrp); 139 140 extern efx_rc_t 141 siena_mcdi_poll_reboot( 142 __in efx_nic_t *enp); 143 144 extern void 145 siena_mcdi_fini( 146 __in efx_nic_t *enp); 147 148 extern __checkReturn efx_rc_t 149 siena_mcdi_feature_supported( 150 __in efx_nic_t *enp, 151 __in efx_mcdi_feature_id_t id, 152 __out boolean_t *supportedp); 153 154 #endif /* EFSYS_OPT_MCDI */ 155 156 #if EFSYS_OPT_NVRAM || EFSYS_OPT_VPD 157 158 extern __checkReturn efx_rc_t 159 siena_nvram_partn_size( 160 __in efx_nic_t *enp, 161 __in unsigned int partn, 162 __out size_t *sizep); 163 164 extern __checkReturn efx_rc_t 165 siena_nvram_partn_lock( 166 __in efx_nic_t *enp, 167 __in unsigned int partn); 168 169 extern __checkReturn efx_rc_t 170 siena_nvram_partn_read( 171 __in efx_nic_t *enp, 172 __in unsigned int partn, 173 __in unsigned int offset, 174 __out_bcount(size) caddr_t data, 175 __in size_t size); 176 177 extern __checkReturn efx_rc_t 178 siena_nvram_partn_erase( 179 __in efx_nic_t *enp, 180 __in unsigned int partn, 181 __in unsigned int offset, 182 __in size_t size); 183 184 extern __checkReturn efx_rc_t 185 siena_nvram_partn_write( 186 __in efx_nic_t *enp, 187 __in unsigned int partn, 188 __in unsigned int offset, 189 __out_bcount(size) caddr_t data, 190 __in size_t size); 191 192 extern void 193 siena_nvram_partn_unlock( 194 __in efx_nic_t *enp, 195 __in unsigned int partn); 196 197 extern __checkReturn efx_rc_t 198 siena_nvram_get_dynamic_cfg( 199 __in efx_nic_t *enp, 200 __in unsigned int index, 201 __in boolean_t vpd, 202 __out siena_mc_dynamic_config_hdr_t **dcfgp, 203 __out size_t *sizep); 204 205 #endif /* EFSYS_OPT_VPD || EFSYS_OPT_NVRAM */ 206 207 #if EFSYS_OPT_NVRAM 208 209 #if EFSYS_OPT_DIAG 210 211 extern __checkReturn efx_rc_t 212 siena_nvram_test( 213 __in efx_nic_t *enp); 214 215 #endif /* EFSYS_OPT_DIAG */ 216 217 extern __checkReturn efx_rc_t 218 siena_nvram_size( 219 __in efx_nic_t *enp, 220 __in efx_nvram_type_t type, 221 __out size_t *sizep); 222 223 extern __checkReturn efx_rc_t 224 siena_nvram_get_subtype( 225 __in efx_nic_t *enp, 226 __in unsigned int partn, 227 __out uint32_t *subtypep); 228 229 extern __checkReturn efx_rc_t 230 siena_nvram_get_version( 231 __in efx_nic_t *enp, 232 __in efx_nvram_type_t type, 233 __out uint32_t *subtypep, 234 __out_ecount(4) uint16_t version[4]); 235 236 extern __checkReturn efx_rc_t 237 siena_nvram_rw_start( 238 __in efx_nic_t *enp, 239 __in efx_nvram_type_t type, 240 __out size_t *pref_chunkp); 241 242 extern __checkReturn efx_rc_t 243 siena_nvram_read_chunk( 244 __in efx_nic_t *enp, 245 __in efx_nvram_type_t type, 246 __in unsigned int offset, 247 __out_bcount(size) caddr_t data, 248 __in size_t size); 249 250 extern __checkReturn efx_rc_t 251 siena_nvram_erase( 252 __in efx_nic_t *enp, 253 __in efx_nvram_type_t type); 254 255 extern __checkReturn efx_rc_t 256 siena_nvram_write_chunk( 257 __in efx_nic_t *enp, 258 __in efx_nvram_type_t type, 259 __in unsigned int offset, 260 __in_bcount(size) caddr_t data, 261 __in size_t size); 262 263 extern void 264 siena_nvram_rw_finish( 265 __in efx_nic_t *enp, 266 __in efx_nvram_type_t type); 267 268 extern __checkReturn efx_rc_t 269 siena_nvram_set_version( 270 __in efx_nic_t *enp, 271 __in efx_nvram_type_t type, 272 __in_ecount(4) uint16_t version[4]); 273 274 #endif /* EFSYS_OPT_NVRAM */ 275 276 #if EFSYS_OPT_VPD 277 278 extern __checkReturn efx_rc_t 279 siena_vpd_init( 280 __in efx_nic_t *enp); 281 282 extern __checkReturn efx_rc_t 283 siena_vpd_size( 284 __in efx_nic_t *enp, 285 __out size_t *sizep); 286 287 extern __checkReturn efx_rc_t 288 siena_vpd_read( 289 __in efx_nic_t *enp, 290 __out_bcount(size) caddr_t data, 291 __in size_t size); 292 293 extern __checkReturn efx_rc_t 294 siena_vpd_verify( 295 __in efx_nic_t *enp, 296 __in_bcount(size) caddr_t data, 297 __in size_t size); 298 299 extern __checkReturn efx_rc_t 300 siena_vpd_reinit( 301 __in efx_nic_t *enp, 302 __in_bcount(size) caddr_t data, 303 __in size_t size); 304 305 extern __checkReturn efx_rc_t 306 siena_vpd_get( 307 __in efx_nic_t *enp, 308 __in_bcount(size) caddr_t data, 309 __in size_t size, 310 __inout efx_vpd_value_t *evvp); 311 312 extern __checkReturn efx_rc_t 313 siena_vpd_set( 314 __in efx_nic_t *enp, 315 __in_bcount(size) caddr_t data, 316 __in size_t size, 317 __in efx_vpd_value_t *evvp); 318 319 extern __checkReturn efx_rc_t 320 siena_vpd_next( 321 __in efx_nic_t *enp, 322 __in_bcount(size) caddr_t data, 323 __in size_t size, 324 __out efx_vpd_value_t *evvp, 325 __inout unsigned int *contp); 326 327 extern __checkReturn efx_rc_t 328 siena_vpd_write( 329 __in efx_nic_t *enp, 330 __in_bcount(size) caddr_t data, 331 __in size_t size); 332 333 extern void 334 siena_vpd_fini( 335 __in efx_nic_t *enp); 336 337 #endif /* EFSYS_OPT_VPD */ 338 339 typedef struct siena_link_state_s { 340 uint32_t sls_adv_cap_mask; 341 uint32_t sls_lp_cap_mask; 342 unsigned int sls_fcntl; 343 efx_link_mode_t sls_link_mode; 344 #if EFSYS_OPT_LOOPBACK 345 efx_loopback_type_t sls_loopback; 346 #endif 347 boolean_t sls_mac_up; 348 } siena_link_state_t; 349 350 extern void 351 siena_phy_link_ev( 352 __in efx_nic_t *enp, 353 __in efx_qword_t *eqp, 354 __out efx_link_mode_t *link_modep); 355 356 extern __checkReturn efx_rc_t 357 siena_phy_get_link( 358 __in efx_nic_t *enp, 359 __out siena_link_state_t *slsp); 360 361 extern __checkReturn efx_rc_t 362 siena_phy_power( 363 __in efx_nic_t *enp, 364 __in boolean_t on); 365 366 extern __checkReturn efx_rc_t 367 siena_phy_reconfigure( 368 __in efx_nic_t *enp); 369 370 extern __checkReturn efx_rc_t 371 siena_phy_verify( 372 __in efx_nic_t *enp); 373 374 extern __checkReturn efx_rc_t 375 siena_phy_oui_get( 376 __in efx_nic_t *enp, 377 __out uint32_t *ouip); 378 379 #if EFSYS_OPT_PHY_STATS 380 381 extern void 382 siena_phy_decode_stats( 383 __in efx_nic_t *enp, 384 __in uint32_t vmask, 385 __in_opt efsys_mem_t *esmp, 386 __out_opt uint64_t *smaskp, 387 __inout_ecount_opt(EFX_PHY_NSTATS) uint32_t *stat); 388 389 extern __checkReturn efx_rc_t 390 siena_phy_stats_update( 391 __in efx_nic_t *enp, 392 __in efsys_mem_t *esmp, 393 __inout_ecount(EFX_PHY_NSTATS) uint32_t *stat); 394 395 #endif /* EFSYS_OPT_PHY_STATS */ 396 397 #if EFSYS_OPT_PHY_PROPS 398 399 #if EFSYS_OPT_NAMES 400 401 extern const char * 402 siena_phy_prop_name( 403 __in efx_nic_t *enp, 404 __in unsigned int id); 405 406 #endif /* EFSYS_OPT_NAMES */ 407 408 extern __checkReturn efx_rc_t 409 siena_phy_prop_get( 410 __in efx_nic_t *enp, 411 __in unsigned int id, 412 __in uint32_t flags, 413 __out uint32_t *valp); 414 415 extern __checkReturn efx_rc_t 416 siena_phy_prop_set( 417 __in efx_nic_t *enp, 418 __in unsigned int id, 419 __in uint32_t val); 420 421 #endif /* EFSYS_OPT_PHY_PROPS */ 422 423 #if EFSYS_OPT_BIST 424 425 extern __checkReturn efx_rc_t 426 siena_phy_bist_start( 427 __in efx_nic_t *enp, 428 __in efx_bist_type_t type); 429 430 extern __checkReturn efx_rc_t 431 siena_phy_bist_poll( 432 __in efx_nic_t *enp, 433 __in efx_bist_type_t type, 434 __out efx_bist_result_t *resultp, 435 __out_opt __drv_when(count > 0, __notnull) 436 uint32_t *value_maskp, 437 __out_ecount_opt(count) __drv_when(count > 0, __notnull) 438 unsigned long *valuesp, 439 __in size_t count); 440 441 extern void 442 siena_phy_bist_stop( 443 __in efx_nic_t *enp, 444 __in efx_bist_type_t type); 445 446 #endif /* EFSYS_OPT_BIST */ 447 448 extern __checkReturn efx_rc_t 449 siena_mac_poll( 450 __in efx_nic_t *enp, 451 __out efx_link_mode_t *link_modep); 452 453 extern __checkReturn efx_rc_t 454 siena_mac_up( 455 __in efx_nic_t *enp, 456 __out boolean_t *mac_upp); 457 458 extern __checkReturn efx_rc_t 459 siena_mac_reconfigure( 460 __in efx_nic_t *enp); 461 462 #if EFSYS_OPT_LOOPBACK 463 464 extern __checkReturn efx_rc_t 465 siena_mac_loopback_set( 466 __in efx_nic_t *enp, 467 __in efx_link_mode_t link_mode, 468 __in efx_loopback_type_t loopback_type); 469 470 #endif /* EFSYS_OPT_LOOPBACK */ 471 472 #if EFSYS_OPT_MAC_STATS 473 474 extern __checkReturn efx_rc_t 475 siena_mac_stats_update( 476 __in efx_nic_t *enp, 477 __in efsys_mem_t *esmp, 478 __inout_ecount(EFX_MAC_NSTATS) efsys_stat_t *stat, 479 __inout_opt uint32_t *generationp); 480 481 #endif /* EFSYS_OPT_MAC_STATS */ 482 483 #ifdef __cplusplus 484 } 485 #endif 486 487 #endif /* _SYS_SIENA_IMPL_H */ 488