1 /*- 2 * Copyright (c) 2006-2016 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_EFX_H 34 #define _SYS_EFX_H 35 36 #include "efsys.h" 37 #include "efx_check.h" 38 #include "efx_phy_ids.h" 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 #define EFX_STATIC_ASSERT(_cond) \ 45 ((void)sizeof(char[(_cond) ? 1 : -1])) 46 47 #define EFX_ARRAY_SIZE(_array) \ 48 (sizeof(_array) / sizeof((_array)[0])) 49 50 #define EFX_FIELD_OFFSET(_type, _field) \ 51 ((size_t) &(((_type *)0)->_field)) 52 53 /* Return codes */ 54 55 typedef __success(return == 0) int efx_rc_t; 56 57 58 /* Chip families */ 59 60 typedef enum efx_family_e { 61 EFX_FAMILY_INVALID, 62 EFX_FAMILY_FALCON, /* Obsolete and not supported */ 63 EFX_FAMILY_SIENA, 64 EFX_FAMILY_HUNTINGTON, 65 EFX_FAMILY_MEDFORD, 66 EFX_FAMILY_NTYPES 67 } efx_family_t; 68 69 extern __checkReturn efx_rc_t 70 efx_family( 71 __in uint16_t venid, 72 __in uint16_t devid, 73 __out efx_family_t *efp); 74 75 76 #define EFX_PCI_VENID_SFC 0x1924 77 78 #define EFX_PCI_DEVID_FALCON 0x0710 /* SFC4000 */ 79 80 #define EFX_PCI_DEVID_BETHPAGE 0x0803 /* SFC9020 */ 81 #define EFX_PCI_DEVID_SIENA 0x0813 /* SFL9021 */ 82 #define EFX_PCI_DEVID_SIENA_F1_UNINIT 0x0810 83 84 #define EFX_PCI_DEVID_HUNTINGTON_PF_UNINIT 0x0901 85 #define EFX_PCI_DEVID_FARMINGDALE 0x0903 /* SFC9120 PF */ 86 #define EFX_PCI_DEVID_GREENPORT 0x0923 /* SFC9140 PF */ 87 88 #define EFX_PCI_DEVID_FARMINGDALE_VF 0x1903 /* SFC9120 VF */ 89 #define EFX_PCI_DEVID_GREENPORT_VF 0x1923 /* SFC9140 VF */ 90 91 #define EFX_PCI_DEVID_MEDFORD_PF_UNINIT 0x0913 92 #define EFX_PCI_DEVID_MEDFORD 0x0A03 /* SFC9240 PF */ 93 #define EFX_PCI_DEVID_MEDFORD_VF 0x1A03 /* SFC9240 VF */ 94 95 #define EFX_MEM_BAR 2 96 97 /* Error codes */ 98 99 enum { 100 EFX_ERR_INVALID, 101 EFX_ERR_SRAM_OOB, 102 EFX_ERR_BUFID_DC_OOB, 103 EFX_ERR_MEM_PERR, 104 EFX_ERR_RBUF_OWN, 105 EFX_ERR_TBUF_OWN, 106 EFX_ERR_RDESQ_OWN, 107 EFX_ERR_TDESQ_OWN, 108 EFX_ERR_EVQ_OWN, 109 EFX_ERR_EVFF_OFLO, 110 EFX_ERR_ILL_ADDR, 111 EFX_ERR_SRAM_PERR, 112 EFX_ERR_NCODES 113 }; 114 115 /* Calculate the IEEE 802.3 CRC32 of a MAC addr */ 116 extern __checkReturn uint32_t 117 efx_crc32_calculate( 118 __in uint32_t crc_init, 119 __in_ecount(length) uint8_t const *input, 120 __in int length); 121 122 123 /* Type prototypes */ 124 125 typedef struct efx_rxq_s efx_rxq_t; 126 127 /* NIC */ 128 129 typedef struct efx_nic_s efx_nic_t; 130 131 extern __checkReturn efx_rc_t 132 efx_nic_create( 133 __in efx_family_t family, 134 __in efsys_identifier_t *esip, 135 __in efsys_bar_t *esbp, 136 __in efsys_lock_t *eslp, 137 __deref_out efx_nic_t **enpp); 138 139 extern __checkReturn efx_rc_t 140 efx_nic_probe( 141 __in efx_nic_t *enp); 142 143 extern __checkReturn efx_rc_t 144 efx_nic_init( 145 __in efx_nic_t *enp); 146 147 extern __checkReturn efx_rc_t 148 efx_nic_reset( 149 __in efx_nic_t *enp); 150 151 #if EFSYS_OPT_DIAG 152 153 extern __checkReturn efx_rc_t 154 efx_nic_register_test( 155 __in efx_nic_t *enp); 156 157 #endif /* EFSYS_OPT_DIAG */ 158 159 extern void 160 efx_nic_fini( 161 __in efx_nic_t *enp); 162 163 extern void 164 efx_nic_unprobe( 165 __in efx_nic_t *enp); 166 167 extern void 168 efx_nic_destroy( 169 __in efx_nic_t *enp); 170 171 #define EFX_PCIE_LINK_SPEED_GEN1 1 172 #define EFX_PCIE_LINK_SPEED_GEN2 2 173 #define EFX_PCIE_LINK_SPEED_GEN3 3 174 175 typedef enum efx_pcie_link_performance_e { 176 EFX_PCIE_LINK_PERFORMANCE_UNKNOWN_BANDWIDTH, 177 EFX_PCIE_LINK_PERFORMANCE_SUBOPTIMAL_BANDWIDTH, 178 EFX_PCIE_LINK_PERFORMANCE_SUBOPTIMAL_LATENCY, 179 EFX_PCIE_LINK_PERFORMANCE_OPTIMAL 180 } efx_pcie_link_performance_t; 181 182 extern __checkReturn efx_rc_t 183 efx_nic_calculate_pcie_link_bandwidth( 184 __in uint32_t pcie_link_width, 185 __in uint32_t pcie_link_gen, 186 __out uint32_t *bandwidth_mbpsp); 187 188 extern __checkReturn efx_rc_t 189 efx_nic_check_pcie_link_speed( 190 __in efx_nic_t *enp, 191 __in uint32_t pcie_link_width, 192 __in uint32_t pcie_link_gen, 193 __out efx_pcie_link_performance_t *resultp); 194 195 #if EFSYS_OPT_MCDI 196 197 #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD 198 /* Huntington and Medford require MCDIv2 commands */ 199 #define WITH_MCDI_V2 1 200 #endif 201 202 typedef struct efx_mcdi_req_s efx_mcdi_req_t; 203 204 typedef enum efx_mcdi_exception_e { 205 EFX_MCDI_EXCEPTION_MC_REBOOT, 206 EFX_MCDI_EXCEPTION_MC_BADASSERT, 207 } efx_mcdi_exception_t; 208 209 #if EFSYS_OPT_MCDI_LOGGING 210 typedef enum efx_log_msg_e { 211 EFX_LOG_INVALID, 212 EFX_LOG_MCDI_REQUEST, 213 EFX_LOG_MCDI_RESPONSE, 214 } efx_log_msg_t; 215 #endif /* EFSYS_OPT_MCDI_LOGGING */ 216 217 typedef struct efx_mcdi_transport_s { 218 void *emt_context; 219 efsys_mem_t *emt_dma_mem; 220 void (*emt_execute)(void *, efx_mcdi_req_t *); 221 void (*emt_ev_cpl)(void *); 222 void (*emt_exception)(void *, efx_mcdi_exception_t); 223 #if EFSYS_OPT_MCDI_LOGGING 224 void (*emt_logger)(void *, efx_log_msg_t, 225 void *, size_t, void *, size_t); 226 #endif /* EFSYS_OPT_MCDI_LOGGING */ 227 #if EFSYS_OPT_MCDI_PROXY_AUTH 228 void (*emt_ev_proxy_response)(void *, uint32_t, efx_rc_t); 229 #endif /* EFSYS_OPT_MCDI_PROXY_AUTH */ 230 } efx_mcdi_transport_t; 231 232 extern __checkReturn efx_rc_t 233 efx_mcdi_init( 234 __in efx_nic_t *enp, 235 __in const efx_mcdi_transport_t *mtp); 236 237 extern __checkReturn efx_rc_t 238 efx_mcdi_reboot( 239 __in efx_nic_t *enp); 240 241 void 242 efx_mcdi_new_epoch( 243 __in efx_nic_t *enp); 244 245 extern void 246 efx_mcdi_get_timeout( 247 __in efx_nic_t *enp, 248 __in efx_mcdi_req_t *emrp, 249 __out uint32_t *usec_timeoutp); 250 251 extern void 252 efx_mcdi_request_start( 253 __in efx_nic_t *enp, 254 __in efx_mcdi_req_t *emrp, 255 __in boolean_t ev_cpl); 256 257 extern __checkReturn boolean_t 258 efx_mcdi_request_poll( 259 __in efx_nic_t *enp); 260 261 extern __checkReturn boolean_t 262 efx_mcdi_request_abort( 263 __in efx_nic_t *enp); 264 265 extern void 266 efx_mcdi_fini( 267 __in efx_nic_t *enp); 268 269 #endif /* EFSYS_OPT_MCDI */ 270 271 /* INTR */ 272 273 #define EFX_NINTR_SIENA 1024 274 275 typedef enum efx_intr_type_e { 276 EFX_INTR_INVALID = 0, 277 EFX_INTR_LINE, 278 EFX_INTR_MESSAGE, 279 EFX_INTR_NTYPES 280 } efx_intr_type_t; 281 282 #define EFX_INTR_SIZE (sizeof (efx_oword_t)) 283 284 extern __checkReturn efx_rc_t 285 efx_intr_init( 286 __in efx_nic_t *enp, 287 __in efx_intr_type_t type, 288 __in efsys_mem_t *esmp); 289 290 extern void 291 efx_intr_enable( 292 __in efx_nic_t *enp); 293 294 extern void 295 efx_intr_disable( 296 __in efx_nic_t *enp); 297 298 extern void 299 efx_intr_disable_unlocked( 300 __in efx_nic_t *enp); 301 302 #define EFX_INTR_NEVQS 32 303 304 extern __checkReturn efx_rc_t 305 efx_intr_trigger( 306 __in efx_nic_t *enp, 307 __in unsigned int level); 308 309 extern void 310 efx_intr_status_line( 311 __in efx_nic_t *enp, 312 __out boolean_t *fatalp, 313 __out uint32_t *maskp); 314 315 extern void 316 efx_intr_status_message( 317 __in efx_nic_t *enp, 318 __in unsigned int message, 319 __out boolean_t *fatalp); 320 321 extern void 322 efx_intr_fatal( 323 __in efx_nic_t *enp); 324 325 extern void 326 efx_intr_fini( 327 __in efx_nic_t *enp); 328 329 /* MAC */ 330 331 #if EFSYS_OPT_MAC_STATS 332 333 /* START MKCONFIG GENERATED EfxHeaderMacBlock e323546097fd7c65 */ 334 typedef enum efx_mac_stat_e { 335 EFX_MAC_RX_OCTETS, 336 EFX_MAC_RX_PKTS, 337 EFX_MAC_RX_UNICST_PKTS, 338 EFX_MAC_RX_MULTICST_PKTS, 339 EFX_MAC_RX_BRDCST_PKTS, 340 EFX_MAC_RX_PAUSE_PKTS, 341 EFX_MAC_RX_LE_64_PKTS, 342 EFX_MAC_RX_65_TO_127_PKTS, 343 EFX_MAC_RX_128_TO_255_PKTS, 344 EFX_MAC_RX_256_TO_511_PKTS, 345 EFX_MAC_RX_512_TO_1023_PKTS, 346 EFX_MAC_RX_1024_TO_15XX_PKTS, 347 EFX_MAC_RX_GE_15XX_PKTS, 348 EFX_MAC_RX_ERRORS, 349 EFX_MAC_RX_FCS_ERRORS, 350 EFX_MAC_RX_DROP_EVENTS, 351 EFX_MAC_RX_FALSE_CARRIER_ERRORS, 352 EFX_MAC_RX_SYMBOL_ERRORS, 353 EFX_MAC_RX_ALIGN_ERRORS, 354 EFX_MAC_RX_INTERNAL_ERRORS, 355 EFX_MAC_RX_JABBER_PKTS, 356 EFX_MAC_RX_LANE0_CHAR_ERR, 357 EFX_MAC_RX_LANE1_CHAR_ERR, 358 EFX_MAC_RX_LANE2_CHAR_ERR, 359 EFX_MAC_RX_LANE3_CHAR_ERR, 360 EFX_MAC_RX_LANE0_DISP_ERR, 361 EFX_MAC_RX_LANE1_DISP_ERR, 362 EFX_MAC_RX_LANE2_DISP_ERR, 363 EFX_MAC_RX_LANE3_DISP_ERR, 364 EFX_MAC_RX_MATCH_FAULT, 365 EFX_MAC_RX_NODESC_DROP_CNT, 366 EFX_MAC_TX_OCTETS, 367 EFX_MAC_TX_PKTS, 368 EFX_MAC_TX_UNICST_PKTS, 369 EFX_MAC_TX_MULTICST_PKTS, 370 EFX_MAC_TX_BRDCST_PKTS, 371 EFX_MAC_TX_PAUSE_PKTS, 372 EFX_MAC_TX_LE_64_PKTS, 373 EFX_MAC_TX_65_TO_127_PKTS, 374 EFX_MAC_TX_128_TO_255_PKTS, 375 EFX_MAC_TX_256_TO_511_PKTS, 376 EFX_MAC_TX_512_TO_1023_PKTS, 377 EFX_MAC_TX_1024_TO_15XX_PKTS, 378 EFX_MAC_TX_GE_15XX_PKTS, 379 EFX_MAC_TX_ERRORS, 380 EFX_MAC_TX_SGL_COL_PKTS, 381 EFX_MAC_TX_MULT_COL_PKTS, 382 EFX_MAC_TX_EX_COL_PKTS, 383 EFX_MAC_TX_LATE_COL_PKTS, 384 EFX_MAC_TX_DEF_PKTS, 385 EFX_MAC_TX_EX_DEF_PKTS, 386 EFX_MAC_PM_TRUNC_BB_OVERFLOW, 387 EFX_MAC_PM_DISCARD_BB_OVERFLOW, 388 EFX_MAC_PM_TRUNC_VFIFO_FULL, 389 EFX_MAC_PM_DISCARD_VFIFO_FULL, 390 EFX_MAC_PM_TRUNC_QBB, 391 EFX_MAC_PM_DISCARD_QBB, 392 EFX_MAC_PM_DISCARD_MAPPING, 393 EFX_MAC_RXDP_Q_DISABLED_PKTS, 394 EFX_MAC_RXDP_DI_DROPPED_PKTS, 395 EFX_MAC_RXDP_STREAMING_PKTS, 396 EFX_MAC_RXDP_HLB_FETCH, 397 EFX_MAC_RXDP_HLB_WAIT, 398 EFX_MAC_VADAPTER_RX_UNICAST_PACKETS, 399 EFX_MAC_VADAPTER_RX_UNICAST_BYTES, 400 EFX_MAC_VADAPTER_RX_MULTICAST_PACKETS, 401 EFX_MAC_VADAPTER_RX_MULTICAST_BYTES, 402 EFX_MAC_VADAPTER_RX_BROADCAST_PACKETS, 403 EFX_MAC_VADAPTER_RX_BROADCAST_BYTES, 404 EFX_MAC_VADAPTER_RX_BAD_PACKETS, 405 EFX_MAC_VADAPTER_RX_BAD_BYTES, 406 EFX_MAC_VADAPTER_RX_OVERFLOW, 407 EFX_MAC_VADAPTER_TX_UNICAST_PACKETS, 408 EFX_MAC_VADAPTER_TX_UNICAST_BYTES, 409 EFX_MAC_VADAPTER_TX_MULTICAST_PACKETS, 410 EFX_MAC_VADAPTER_TX_MULTICAST_BYTES, 411 EFX_MAC_VADAPTER_TX_BROADCAST_PACKETS, 412 EFX_MAC_VADAPTER_TX_BROADCAST_BYTES, 413 EFX_MAC_VADAPTER_TX_BAD_PACKETS, 414 EFX_MAC_VADAPTER_TX_BAD_BYTES, 415 EFX_MAC_VADAPTER_TX_OVERFLOW, 416 EFX_MAC_NSTATS 417 } efx_mac_stat_t; 418 419 /* END MKCONFIG GENERATED EfxHeaderMacBlock */ 420 421 #endif /* EFSYS_OPT_MAC_STATS */ 422 423 typedef enum efx_link_mode_e { 424 EFX_LINK_UNKNOWN = 0, 425 EFX_LINK_DOWN, 426 EFX_LINK_10HDX, 427 EFX_LINK_10FDX, 428 EFX_LINK_100HDX, 429 EFX_LINK_100FDX, 430 EFX_LINK_1000HDX, 431 EFX_LINK_1000FDX, 432 EFX_LINK_10000FDX, 433 EFX_LINK_40000FDX, 434 EFX_LINK_NMODES 435 } efx_link_mode_t; 436 437 #define EFX_MAC_ADDR_LEN 6 438 439 #define EFX_MAC_ADDR_IS_MULTICAST(_address) (((uint8_t *)_address)[0] & 0x01) 440 441 #define EFX_MAC_MULTICAST_LIST_MAX 256 442 443 #define EFX_MAC_SDU_MAX 9202 444 445 #define EFX_MAC_PDU_ADJUSTMENT \ 446 (/* EtherII */ 14 \ 447 + /* VLAN */ 4 \ 448 + /* CRC */ 4 \ 449 + /* bug16011 */ 16) \ 450 451 #define EFX_MAC_PDU(_sdu) \ 452 P2ROUNDUP((_sdu) + EFX_MAC_PDU_ADJUSTMENT, 8) 453 454 /* 455 * Due to the P2ROUNDUP in EFX_MAC_PDU(), EFX_MAC_SDU_FROM_PDU() may give 456 * the SDU rounded up slightly. 457 */ 458 #define EFX_MAC_SDU_FROM_PDU(_pdu) ((_pdu) - EFX_MAC_PDU_ADJUSTMENT) 459 460 #define EFX_MAC_PDU_MIN 60 461 #define EFX_MAC_PDU_MAX EFX_MAC_PDU(EFX_MAC_SDU_MAX) 462 463 extern __checkReturn efx_rc_t 464 efx_mac_pdu_get( 465 __in efx_nic_t *enp, 466 __out size_t *pdu); 467 468 extern __checkReturn efx_rc_t 469 efx_mac_pdu_set( 470 __in efx_nic_t *enp, 471 __in size_t pdu); 472 473 extern __checkReturn efx_rc_t 474 efx_mac_addr_set( 475 __in efx_nic_t *enp, 476 __in uint8_t *addr); 477 478 extern __checkReturn efx_rc_t 479 efx_mac_filter_set( 480 __in efx_nic_t *enp, 481 __in boolean_t all_unicst, 482 __in boolean_t mulcst, 483 __in boolean_t all_mulcst, 484 __in boolean_t brdcst); 485 486 extern __checkReturn efx_rc_t 487 efx_mac_multicast_list_set( 488 __in efx_nic_t *enp, 489 __in_ecount(6*count) uint8_t const *addrs, 490 __in int count); 491 492 extern __checkReturn efx_rc_t 493 efx_mac_filter_default_rxq_set( 494 __in efx_nic_t *enp, 495 __in efx_rxq_t *erp, 496 __in boolean_t using_rss); 497 498 extern void 499 efx_mac_filter_default_rxq_clear( 500 __in efx_nic_t *enp); 501 502 extern __checkReturn efx_rc_t 503 efx_mac_drain( 504 __in efx_nic_t *enp, 505 __in boolean_t enabled); 506 507 extern __checkReturn efx_rc_t 508 efx_mac_up( 509 __in efx_nic_t *enp, 510 __out boolean_t *mac_upp); 511 512 #define EFX_FCNTL_RESPOND 0x00000001 513 #define EFX_FCNTL_GENERATE 0x00000002 514 515 extern __checkReturn efx_rc_t 516 efx_mac_fcntl_set( 517 __in efx_nic_t *enp, 518 __in unsigned int fcntl, 519 __in boolean_t autoneg); 520 521 extern void 522 efx_mac_fcntl_get( 523 __in efx_nic_t *enp, 524 __out unsigned int *fcntl_wantedp, 525 __out unsigned int *fcntl_linkp); 526 527 528 #if EFSYS_OPT_MAC_STATS 529 530 #if EFSYS_OPT_NAMES 531 532 extern __checkReturn const char * 533 efx_mac_stat_name( 534 __in efx_nic_t *enp, 535 __in unsigned int id); 536 537 #endif /* EFSYS_OPT_NAMES */ 538 539 #define EFX_MAC_STATS_MASK_BITS_PER_PAGE (8 * sizeof (uint32_t)) 540 541 #define EFX_MAC_STATS_MASK_NPAGES \ 542 (P2ROUNDUP(EFX_MAC_NSTATS, EFX_MAC_STATS_MASK_BITS_PER_PAGE) / \ 543 EFX_MAC_STATS_MASK_BITS_PER_PAGE) 544 545 /* 546 * Get mask of MAC statistics supported by the hardware. 547 * 548 * If mask_size is insufficient to return the mask, EINVAL error is 549 * returned. EFX_MAC_STATS_MASK_NPAGES multiplied by size of the page 550 * (which is sizeof (uint32_t)) is sufficient. 551 */ 552 extern __checkReturn efx_rc_t 553 efx_mac_stats_get_mask( 554 __in efx_nic_t *enp, 555 __out_bcount(mask_size) uint32_t *maskp, 556 __in size_t mask_size); 557 558 #define EFX_MAC_STAT_SUPPORTED(_mask, _stat) \ 559 ((_mask)[(_stat) / EFX_MAC_STATS_MASK_BITS_PER_PAGE] & \ 560 (1ULL << ((_stat) & (EFX_MAC_STATS_MASK_BITS_PER_PAGE - 1)))) 561 562 #define EFX_MAC_STATS_SIZE 0x400 563 564 /* 565 * Upload mac statistics supported by the hardware into the given buffer. 566 * 567 * The reference buffer must be at least %EFX_MAC_STATS_SIZE bytes, 568 * and page aligned. 569 * 570 * The hardware will only DMA statistics that it understands (of course). 571 * Drivers should not make any assumptions about which statistics are 572 * supported, especially when the statistics are generated by firmware. 573 * 574 * Thus, drivers should zero this buffer before use, so that not-understood 575 * statistics read back as zero. 576 */ 577 extern __checkReturn efx_rc_t 578 efx_mac_stats_upload( 579 __in efx_nic_t *enp, 580 __in efsys_mem_t *esmp); 581 582 extern __checkReturn efx_rc_t 583 efx_mac_stats_periodic( 584 __in efx_nic_t *enp, 585 __in efsys_mem_t *esmp, 586 __in uint16_t period_ms, 587 __in boolean_t events); 588 589 extern __checkReturn efx_rc_t 590 efx_mac_stats_update( 591 __in efx_nic_t *enp, 592 __in efsys_mem_t *esmp, 593 __inout_ecount(EFX_MAC_NSTATS) efsys_stat_t *stat, 594 __inout_opt uint32_t *generationp); 595 596 #endif /* EFSYS_OPT_MAC_STATS */ 597 598 /* MON */ 599 600 typedef enum efx_mon_type_e { 601 EFX_MON_INVALID = 0, 602 EFX_MON_SFC90X0, 603 EFX_MON_SFC91X0, 604 EFX_MON_SFC92X0, 605 EFX_MON_NTYPES 606 } efx_mon_type_t; 607 608 #if EFSYS_OPT_NAMES 609 610 extern const char * 611 efx_mon_name( 612 __in efx_nic_t *enp); 613 614 #endif /* EFSYS_OPT_NAMES */ 615 616 extern __checkReturn efx_rc_t 617 efx_mon_init( 618 __in efx_nic_t *enp); 619 620 #if EFSYS_OPT_MON_STATS 621 622 #define EFX_MON_STATS_PAGE_SIZE 0x100 623 #define EFX_MON_MASK_ELEMENT_SIZE 32 624 625 /* START MKCONFIG GENERATED MonitorHeaderStatsBlock 5d4ee5185e419abe */ 626 typedef enum efx_mon_stat_e { 627 EFX_MON_STAT_2_5V, 628 EFX_MON_STAT_VCCP1, 629 EFX_MON_STAT_VCC, 630 EFX_MON_STAT_5V, 631 EFX_MON_STAT_12V, 632 EFX_MON_STAT_VCCP2, 633 EFX_MON_STAT_EXT_TEMP, 634 EFX_MON_STAT_INT_TEMP, 635 EFX_MON_STAT_AIN1, 636 EFX_MON_STAT_AIN2, 637 EFX_MON_STAT_INT_COOLING, 638 EFX_MON_STAT_EXT_COOLING, 639 EFX_MON_STAT_1V, 640 EFX_MON_STAT_1_2V, 641 EFX_MON_STAT_1_8V, 642 EFX_MON_STAT_3_3V, 643 EFX_MON_STAT_1_2VA, 644 EFX_MON_STAT_VREF, 645 EFX_MON_STAT_VAOE, 646 EFX_MON_STAT_AOE_TEMP, 647 EFX_MON_STAT_PSU_AOE_TEMP, 648 EFX_MON_STAT_PSU_TEMP, 649 EFX_MON_STAT_FAN0, 650 EFX_MON_STAT_FAN1, 651 EFX_MON_STAT_FAN2, 652 EFX_MON_STAT_FAN3, 653 EFX_MON_STAT_FAN4, 654 EFX_MON_STAT_VAOE_IN, 655 EFX_MON_STAT_IAOE, 656 EFX_MON_STAT_IAOE_IN, 657 EFX_MON_STAT_NIC_POWER, 658 EFX_MON_STAT_0_9V, 659 EFX_MON_STAT_I0_9V, 660 EFX_MON_STAT_I1_2V, 661 EFX_MON_STAT_0_9V_ADC, 662 EFX_MON_STAT_INT_TEMP2, 663 EFX_MON_STAT_VREG_TEMP, 664 EFX_MON_STAT_VREG_0_9V_TEMP, 665 EFX_MON_STAT_VREG_1_2V_TEMP, 666 EFX_MON_STAT_INT_VPTAT, 667 EFX_MON_STAT_INT_ADC_TEMP, 668 EFX_MON_STAT_EXT_VPTAT, 669 EFX_MON_STAT_EXT_ADC_TEMP, 670 EFX_MON_STAT_AMBIENT_TEMP, 671 EFX_MON_STAT_AIRFLOW, 672 EFX_MON_STAT_VDD08D_VSS08D_CSR, 673 EFX_MON_STAT_VDD08D_VSS08D_CSR_EXTADC, 674 EFX_MON_STAT_HOTPOINT_TEMP, 675 EFX_MON_STAT_PHY_POWER_SWITCH_PORT0, 676 EFX_MON_STAT_PHY_POWER_SWITCH_PORT1, 677 EFX_MON_STAT_MUM_VCC, 678 EFX_MON_STAT_0V9_A, 679 EFX_MON_STAT_I0V9_A, 680 EFX_MON_STAT_0V9_A_TEMP, 681 EFX_MON_STAT_0V9_B, 682 EFX_MON_STAT_I0V9_B, 683 EFX_MON_STAT_0V9_B_TEMP, 684 EFX_MON_STAT_CCOM_AVREG_1V2_SUPPLY, 685 EFX_MON_STAT_CCOM_AVREG_1V2_SUPPLY_EXT_ADC, 686 EFX_MON_STAT_CCOM_AVREG_1V8_SUPPLY, 687 EFX_MON_STAT_CCOM_AVREG_1V8_SUPPLY_EXT_ADC, 688 EFX_MON_STAT_CONTROLLER_MASTER_VPTAT, 689 EFX_MON_STAT_CONTROLLER_MASTER_INTERNAL_TEMP, 690 EFX_MON_STAT_CONTROLLER_MASTER_VPTAT_EXT_ADC, 691 EFX_MON_STAT_CONTROLLER_MASTER_INTERNAL_TEMP_EXT_ADC, 692 EFX_MON_STAT_CONTROLLER_SLAVE_VPTAT, 693 EFX_MON_STAT_CONTROLLER_SLAVE_INTERNAL_TEMP, 694 EFX_MON_STAT_CONTROLLER_SLAVE_VPTAT_EXT_ADC, 695 EFX_MON_STAT_CONTROLLER_SLAVE_INTERNAL_TEMP_EXT_ADC, 696 EFX_MON_STAT_SODIMM_VOUT, 697 EFX_MON_STAT_SODIMM_0_TEMP, 698 EFX_MON_STAT_SODIMM_1_TEMP, 699 EFX_MON_STAT_PHY0_VCC, 700 EFX_MON_STAT_PHY1_VCC, 701 EFX_MON_STAT_CONTROLLER_TDIODE_TEMP, 702 EFX_MON_STAT_BOARD_FRONT_TEMP, 703 EFX_MON_STAT_BOARD_BACK_TEMP, 704 EFX_MON_NSTATS 705 } efx_mon_stat_t; 706 707 /* END MKCONFIG GENERATED MonitorHeaderStatsBlock */ 708 709 typedef enum efx_mon_stat_state_e { 710 EFX_MON_STAT_STATE_OK = 0, 711 EFX_MON_STAT_STATE_WARNING = 1, 712 EFX_MON_STAT_STATE_FATAL = 2, 713 EFX_MON_STAT_STATE_BROKEN = 3, 714 EFX_MON_STAT_STATE_NO_READING = 4, 715 } efx_mon_stat_state_t; 716 717 typedef struct efx_mon_stat_value_s { 718 uint16_t emsv_value; 719 uint16_t emsv_state; 720 } efx_mon_stat_value_t; 721 722 #if EFSYS_OPT_NAMES 723 724 extern const char * 725 efx_mon_stat_name( 726 __in efx_nic_t *enp, 727 __in efx_mon_stat_t id); 728 729 #endif /* EFSYS_OPT_NAMES */ 730 731 extern __checkReturn efx_rc_t 732 efx_mon_stats_update( 733 __in efx_nic_t *enp, 734 __in efsys_mem_t *esmp, 735 __inout_ecount(EFX_MON_NSTATS) efx_mon_stat_value_t *values); 736 737 #endif /* EFSYS_OPT_MON_STATS */ 738 739 extern void 740 efx_mon_fini( 741 __in efx_nic_t *enp); 742 743 /* PHY */ 744 745 extern __checkReturn efx_rc_t 746 efx_phy_verify( 747 __in efx_nic_t *enp); 748 749 #if EFSYS_OPT_PHY_LED_CONTROL 750 751 typedef enum efx_phy_led_mode_e { 752 EFX_PHY_LED_DEFAULT = 0, 753 EFX_PHY_LED_OFF, 754 EFX_PHY_LED_ON, 755 EFX_PHY_LED_FLASH, 756 EFX_PHY_LED_NMODES 757 } efx_phy_led_mode_t; 758 759 extern __checkReturn efx_rc_t 760 efx_phy_led_set( 761 __in efx_nic_t *enp, 762 __in efx_phy_led_mode_t mode); 763 764 #endif /* EFSYS_OPT_PHY_LED_CONTROL */ 765 766 extern __checkReturn efx_rc_t 767 efx_port_init( 768 __in efx_nic_t *enp); 769 770 #if EFSYS_OPT_LOOPBACK 771 772 typedef enum efx_loopback_type_e { 773 EFX_LOOPBACK_OFF = 0, 774 EFX_LOOPBACK_DATA = 1, 775 EFX_LOOPBACK_GMAC = 2, 776 EFX_LOOPBACK_XGMII = 3, 777 EFX_LOOPBACK_XGXS = 4, 778 EFX_LOOPBACK_XAUI = 5, 779 EFX_LOOPBACK_GMII = 6, 780 EFX_LOOPBACK_SGMII = 7, 781 EFX_LOOPBACK_XGBR = 8, 782 EFX_LOOPBACK_XFI = 9, 783 EFX_LOOPBACK_XAUI_FAR = 10, 784 EFX_LOOPBACK_GMII_FAR = 11, 785 EFX_LOOPBACK_SGMII_FAR = 12, 786 EFX_LOOPBACK_XFI_FAR = 13, 787 EFX_LOOPBACK_GPHY = 14, 788 EFX_LOOPBACK_PHY_XS = 15, 789 EFX_LOOPBACK_PCS = 16, 790 EFX_LOOPBACK_PMA_PMD = 17, 791 EFX_LOOPBACK_XPORT = 18, 792 EFX_LOOPBACK_XGMII_WS = 19, 793 EFX_LOOPBACK_XAUI_WS = 20, 794 EFX_LOOPBACK_XAUI_WS_FAR = 21, 795 EFX_LOOPBACK_XAUI_WS_NEAR = 22, 796 EFX_LOOPBACK_GMII_WS = 23, 797 EFX_LOOPBACK_XFI_WS = 24, 798 EFX_LOOPBACK_XFI_WS_FAR = 25, 799 EFX_LOOPBACK_PHYXS_WS = 26, 800 EFX_LOOPBACK_PMA_INT = 27, 801 EFX_LOOPBACK_SD_NEAR = 28, 802 EFX_LOOPBACK_SD_FAR = 29, 803 EFX_LOOPBACK_PMA_INT_WS = 30, 804 EFX_LOOPBACK_SD_FEP2_WS = 31, 805 EFX_LOOPBACK_SD_FEP1_5_WS = 32, 806 EFX_LOOPBACK_SD_FEP_WS = 33, 807 EFX_LOOPBACK_SD_FES_WS = 34, 808 EFX_LOOPBACK_NTYPES 809 } efx_loopback_type_t; 810 811 typedef enum efx_loopback_kind_e { 812 EFX_LOOPBACK_KIND_OFF = 0, 813 EFX_LOOPBACK_KIND_ALL, 814 EFX_LOOPBACK_KIND_MAC, 815 EFX_LOOPBACK_KIND_PHY, 816 EFX_LOOPBACK_NKINDS 817 } efx_loopback_kind_t; 818 819 extern void 820 efx_loopback_mask( 821 __in efx_loopback_kind_t loopback_kind, 822 __out efx_qword_t *maskp); 823 824 extern __checkReturn efx_rc_t 825 efx_port_loopback_set( 826 __in efx_nic_t *enp, 827 __in efx_link_mode_t link_mode, 828 __in efx_loopback_type_t type); 829 830 #if EFSYS_OPT_NAMES 831 832 extern __checkReturn const char * 833 efx_loopback_type_name( 834 __in efx_nic_t *enp, 835 __in efx_loopback_type_t type); 836 837 #endif /* EFSYS_OPT_NAMES */ 838 839 #endif /* EFSYS_OPT_LOOPBACK */ 840 841 extern __checkReturn efx_rc_t 842 efx_port_poll( 843 __in efx_nic_t *enp, 844 __out_opt efx_link_mode_t *link_modep); 845 846 extern void 847 efx_port_fini( 848 __in efx_nic_t *enp); 849 850 typedef enum efx_phy_cap_type_e { 851 EFX_PHY_CAP_INVALID = 0, 852 EFX_PHY_CAP_10HDX, 853 EFX_PHY_CAP_10FDX, 854 EFX_PHY_CAP_100HDX, 855 EFX_PHY_CAP_100FDX, 856 EFX_PHY_CAP_1000HDX, 857 EFX_PHY_CAP_1000FDX, 858 EFX_PHY_CAP_10000FDX, 859 EFX_PHY_CAP_PAUSE, 860 EFX_PHY_CAP_ASYM, 861 EFX_PHY_CAP_AN, 862 EFX_PHY_CAP_40000FDX, 863 EFX_PHY_CAP_NTYPES 864 } efx_phy_cap_type_t; 865 866 867 #define EFX_PHY_CAP_CURRENT 0x00000000 868 #define EFX_PHY_CAP_DEFAULT 0x00000001 869 #define EFX_PHY_CAP_PERM 0x00000002 870 871 extern void 872 efx_phy_adv_cap_get( 873 __in efx_nic_t *enp, 874 __in uint32_t flag, 875 __out uint32_t *maskp); 876 877 extern __checkReturn efx_rc_t 878 efx_phy_adv_cap_set( 879 __in efx_nic_t *enp, 880 __in uint32_t mask); 881 882 extern void 883 efx_phy_lp_cap_get( 884 __in efx_nic_t *enp, 885 __out uint32_t *maskp); 886 887 extern __checkReturn efx_rc_t 888 efx_phy_oui_get( 889 __in efx_nic_t *enp, 890 __out uint32_t *ouip); 891 892 typedef enum efx_phy_media_type_e { 893 EFX_PHY_MEDIA_INVALID = 0, 894 EFX_PHY_MEDIA_XAUI, 895 EFX_PHY_MEDIA_CX4, 896 EFX_PHY_MEDIA_KX4, 897 EFX_PHY_MEDIA_XFP, 898 EFX_PHY_MEDIA_SFP_PLUS, 899 EFX_PHY_MEDIA_BASE_T, 900 EFX_PHY_MEDIA_QSFP_PLUS, 901 EFX_PHY_MEDIA_NTYPES 902 } efx_phy_media_type_t; 903 904 /* Get the type of medium currently used. If the board has ports for 905 * modules, a module is present, and we recognise the media type of 906 * the module, then this will be the media type of the module. 907 * Otherwise it will be the media type of the port. 908 */ 909 extern void 910 efx_phy_media_type_get( 911 __in efx_nic_t *enp, 912 __out efx_phy_media_type_t *typep); 913 914 extern efx_rc_t 915 efx_phy_module_get_info( 916 __in efx_nic_t *enp, 917 __in uint8_t dev_addr, 918 __in uint8_t offset, 919 __in uint8_t len, 920 __out_bcount(len) uint8_t *data); 921 922 #if EFSYS_OPT_PHY_STATS 923 924 /* START MKCONFIG GENERATED PhyHeaderStatsBlock 30ed56ad501f8e36 */ 925 typedef enum efx_phy_stat_e { 926 EFX_PHY_STAT_OUI, 927 EFX_PHY_STAT_PMA_PMD_LINK_UP, 928 EFX_PHY_STAT_PMA_PMD_RX_FAULT, 929 EFX_PHY_STAT_PMA_PMD_TX_FAULT, 930 EFX_PHY_STAT_PMA_PMD_REV_A, 931 EFX_PHY_STAT_PMA_PMD_REV_B, 932 EFX_PHY_STAT_PMA_PMD_REV_C, 933 EFX_PHY_STAT_PMA_PMD_REV_D, 934 EFX_PHY_STAT_PCS_LINK_UP, 935 EFX_PHY_STAT_PCS_RX_FAULT, 936 EFX_PHY_STAT_PCS_TX_FAULT, 937 EFX_PHY_STAT_PCS_BER, 938 EFX_PHY_STAT_PCS_BLOCK_ERRORS, 939 EFX_PHY_STAT_PHY_XS_LINK_UP, 940 EFX_PHY_STAT_PHY_XS_RX_FAULT, 941 EFX_PHY_STAT_PHY_XS_TX_FAULT, 942 EFX_PHY_STAT_PHY_XS_ALIGN, 943 EFX_PHY_STAT_PHY_XS_SYNC_A, 944 EFX_PHY_STAT_PHY_XS_SYNC_B, 945 EFX_PHY_STAT_PHY_XS_SYNC_C, 946 EFX_PHY_STAT_PHY_XS_SYNC_D, 947 EFX_PHY_STAT_AN_LINK_UP, 948 EFX_PHY_STAT_AN_MASTER, 949 EFX_PHY_STAT_AN_LOCAL_RX_OK, 950 EFX_PHY_STAT_AN_REMOTE_RX_OK, 951 EFX_PHY_STAT_CL22EXT_LINK_UP, 952 EFX_PHY_STAT_SNR_A, 953 EFX_PHY_STAT_SNR_B, 954 EFX_PHY_STAT_SNR_C, 955 EFX_PHY_STAT_SNR_D, 956 EFX_PHY_STAT_PMA_PMD_SIGNAL_A, 957 EFX_PHY_STAT_PMA_PMD_SIGNAL_B, 958 EFX_PHY_STAT_PMA_PMD_SIGNAL_C, 959 EFX_PHY_STAT_PMA_PMD_SIGNAL_D, 960 EFX_PHY_STAT_AN_COMPLETE, 961 EFX_PHY_STAT_PMA_PMD_REV_MAJOR, 962 EFX_PHY_STAT_PMA_PMD_REV_MINOR, 963 EFX_PHY_STAT_PMA_PMD_REV_MICRO, 964 EFX_PHY_STAT_PCS_FW_VERSION_0, 965 EFX_PHY_STAT_PCS_FW_VERSION_1, 966 EFX_PHY_STAT_PCS_FW_VERSION_2, 967 EFX_PHY_STAT_PCS_FW_VERSION_3, 968 EFX_PHY_STAT_PCS_FW_BUILD_YY, 969 EFX_PHY_STAT_PCS_FW_BUILD_MM, 970 EFX_PHY_STAT_PCS_FW_BUILD_DD, 971 EFX_PHY_STAT_PCS_OP_MODE, 972 EFX_PHY_NSTATS 973 } efx_phy_stat_t; 974 975 /* END MKCONFIG GENERATED PhyHeaderStatsBlock */ 976 977 #if EFSYS_OPT_NAMES 978 979 extern const char * 980 efx_phy_stat_name( 981 __in efx_nic_t *enp, 982 __in efx_phy_stat_t stat); 983 984 #endif /* EFSYS_OPT_NAMES */ 985 986 #define EFX_PHY_STATS_SIZE 0x100 987 988 extern __checkReturn efx_rc_t 989 efx_phy_stats_update( 990 __in efx_nic_t *enp, 991 __in efsys_mem_t *esmp, 992 __inout_ecount(EFX_PHY_NSTATS) uint32_t *stat); 993 994 #endif /* EFSYS_OPT_PHY_STATS */ 995 996 997 #if EFSYS_OPT_BIST 998 999 typedef enum efx_bist_type_e { 1000 EFX_BIST_TYPE_UNKNOWN, 1001 EFX_BIST_TYPE_PHY_NORMAL, 1002 EFX_BIST_TYPE_PHY_CABLE_SHORT, 1003 EFX_BIST_TYPE_PHY_CABLE_LONG, 1004 EFX_BIST_TYPE_MC_MEM, /* Test the MC DMEM and IMEM */ 1005 EFX_BIST_TYPE_SAT_MEM, /* Test the DMEM and IMEM of satellite cpus*/ 1006 EFX_BIST_TYPE_REG, /* Test the register memories */ 1007 EFX_BIST_TYPE_NTYPES, 1008 } efx_bist_type_t; 1009 1010 typedef enum efx_bist_result_e { 1011 EFX_BIST_RESULT_UNKNOWN, 1012 EFX_BIST_RESULT_RUNNING, 1013 EFX_BIST_RESULT_PASSED, 1014 EFX_BIST_RESULT_FAILED, 1015 } efx_bist_result_t; 1016 1017 typedef enum efx_phy_cable_status_e { 1018 EFX_PHY_CABLE_STATUS_OK, 1019 EFX_PHY_CABLE_STATUS_INVALID, 1020 EFX_PHY_CABLE_STATUS_OPEN, 1021 EFX_PHY_CABLE_STATUS_INTRAPAIRSHORT, 1022 EFX_PHY_CABLE_STATUS_INTERPAIRSHORT, 1023 EFX_PHY_CABLE_STATUS_BUSY, 1024 } efx_phy_cable_status_t; 1025 1026 typedef enum efx_bist_value_e { 1027 EFX_BIST_PHY_CABLE_LENGTH_A, 1028 EFX_BIST_PHY_CABLE_LENGTH_B, 1029 EFX_BIST_PHY_CABLE_LENGTH_C, 1030 EFX_BIST_PHY_CABLE_LENGTH_D, 1031 EFX_BIST_PHY_CABLE_STATUS_A, 1032 EFX_BIST_PHY_CABLE_STATUS_B, 1033 EFX_BIST_PHY_CABLE_STATUS_C, 1034 EFX_BIST_PHY_CABLE_STATUS_D, 1035 EFX_BIST_FAULT_CODE, 1036 /* Memory BIST specific values. These match to the MC_CMD_BIST_POLL 1037 * response. */ 1038 EFX_BIST_MEM_TEST, 1039 EFX_BIST_MEM_ADDR, 1040 EFX_BIST_MEM_BUS, 1041 EFX_BIST_MEM_EXPECT, 1042 EFX_BIST_MEM_ACTUAL, 1043 EFX_BIST_MEM_ECC, 1044 EFX_BIST_MEM_ECC_PARITY, 1045 EFX_BIST_MEM_ECC_FATAL, 1046 EFX_BIST_NVALUES, 1047 } efx_bist_value_t; 1048 1049 extern __checkReturn efx_rc_t 1050 efx_bist_enable_offline( 1051 __in efx_nic_t *enp); 1052 1053 extern __checkReturn efx_rc_t 1054 efx_bist_start( 1055 __in efx_nic_t *enp, 1056 __in efx_bist_type_t type); 1057 1058 extern __checkReturn efx_rc_t 1059 efx_bist_poll( 1060 __in efx_nic_t *enp, 1061 __in efx_bist_type_t type, 1062 __out efx_bist_result_t *resultp, 1063 __out_opt uint32_t *value_maskp, 1064 __out_ecount_opt(count) unsigned long *valuesp, 1065 __in size_t count); 1066 1067 extern void 1068 efx_bist_stop( 1069 __in efx_nic_t *enp, 1070 __in efx_bist_type_t type); 1071 1072 #endif /* EFSYS_OPT_BIST */ 1073 1074 #define EFX_FEATURE_IPV6 0x00000001 1075 #define EFX_FEATURE_LFSR_HASH_INSERT 0x00000002 1076 #define EFX_FEATURE_LINK_EVENTS 0x00000004 1077 #define EFX_FEATURE_PERIODIC_MAC_STATS 0x00000008 1078 #define EFX_FEATURE_MCDI 0x00000020 1079 #define EFX_FEATURE_LOOKAHEAD_SPLIT 0x00000040 1080 #define EFX_FEATURE_MAC_HEADER_FILTERS 0x00000080 1081 #define EFX_FEATURE_TURBO 0x00000100 1082 #define EFX_FEATURE_MCDI_DMA 0x00000200 1083 #define EFX_FEATURE_TX_SRC_FILTERS 0x00000400 1084 #define EFX_FEATURE_PIO_BUFFERS 0x00000800 1085 #define EFX_FEATURE_FW_ASSISTED_TSO 0x00001000 1086 #define EFX_FEATURE_FW_ASSISTED_TSO_V2 0x00002000 1087 1088 typedef struct efx_nic_cfg_s { 1089 uint32_t enc_board_type; 1090 uint32_t enc_phy_type; 1091 #if EFSYS_OPT_NAMES 1092 char enc_phy_name[21]; 1093 #endif 1094 char enc_phy_revision[21]; 1095 efx_mon_type_t enc_mon_type; 1096 #if EFSYS_OPT_MON_STATS 1097 uint32_t enc_mon_stat_dma_buf_size; 1098 uint32_t enc_mon_stat_mask[(EFX_MON_NSTATS + 31) / 32]; 1099 #endif 1100 unsigned int enc_features; 1101 uint8_t enc_mac_addr[6]; 1102 uint8_t enc_port; /* PHY port number */ 1103 uint32_t enc_intr_vec_base; 1104 uint32_t enc_intr_limit; 1105 uint32_t enc_evq_limit; 1106 uint32_t enc_txq_limit; 1107 uint32_t enc_rxq_limit; 1108 uint32_t enc_buftbl_limit; 1109 uint32_t enc_piobuf_limit; 1110 uint32_t enc_piobuf_size; 1111 uint32_t enc_piobuf_min_alloc_size; 1112 uint32_t enc_evq_timer_quantum_ns; 1113 uint32_t enc_evq_timer_max_us; 1114 uint32_t enc_clk_mult; 1115 uint32_t enc_rx_prefix_size; 1116 uint32_t enc_rx_buf_align_start; 1117 uint32_t enc_rx_buf_align_end; 1118 #if EFSYS_OPT_LOOPBACK 1119 efx_qword_t enc_loopback_types[EFX_LINK_NMODES]; 1120 #endif /* EFSYS_OPT_LOOPBACK */ 1121 #if EFSYS_OPT_PHY_FLAGS 1122 uint32_t enc_phy_flags_mask; 1123 #endif /* EFSYS_OPT_PHY_FLAGS */ 1124 #if EFSYS_OPT_PHY_LED_CONTROL 1125 uint32_t enc_led_mask; 1126 #endif /* EFSYS_OPT_PHY_LED_CONTROL */ 1127 #if EFSYS_OPT_PHY_STATS 1128 uint64_t enc_phy_stat_mask; 1129 #endif /* EFSYS_OPT_PHY_STATS */ 1130 #if EFSYS_OPT_MCDI 1131 uint8_t enc_mcdi_mdio_channel; 1132 #if EFSYS_OPT_PHY_STATS 1133 uint32_t enc_mcdi_phy_stat_mask; 1134 #endif /* EFSYS_OPT_PHY_STATS */ 1135 #if EFSYS_OPT_MON_STATS 1136 uint32_t *enc_mcdi_sensor_maskp; 1137 uint32_t enc_mcdi_sensor_mask_size; 1138 #endif /* EFSYS_OPT_MON_STATS */ 1139 #endif /* EFSYS_OPT_MCDI */ 1140 #if EFSYS_OPT_BIST 1141 uint32_t enc_bist_mask; 1142 #endif /* EFSYS_OPT_BIST */ 1143 #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD 1144 uint32_t enc_pf; 1145 uint32_t enc_vf; 1146 uint32_t enc_privilege_mask; 1147 #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */ 1148 boolean_t enc_bug26807_workaround; 1149 boolean_t enc_bug35388_workaround; 1150 boolean_t enc_bug41750_workaround; 1151 boolean_t enc_bug61265_workaround; 1152 boolean_t enc_rx_batching_enabled; 1153 /* Maximum number of descriptors completed in an rx event. */ 1154 uint32_t enc_rx_batch_max; 1155 /* Number of rx descriptors the hardware requires for a push. */ 1156 uint32_t enc_rx_push_align; 1157 /* 1158 * Maximum number of bytes into the packet the TCP header can start for 1159 * the hardware to apply TSO packet edits. 1160 */ 1161 uint32_t enc_tx_tso_tcp_header_offset_limit; 1162 boolean_t enc_fw_assisted_tso_enabled; 1163 boolean_t enc_fw_assisted_tso_v2_enabled; 1164 /* Number of TSO contexts on the NIC (FATSOv2) */ 1165 uint32_t enc_fw_assisted_tso_v2_n_contexts; 1166 boolean_t enc_hw_tx_insert_vlan_enabled; 1167 /* Number of PFs on the NIC */ 1168 uint32_t enc_hw_pf_count; 1169 /* Datapath firmware vadapter/vport/vswitch support */ 1170 boolean_t enc_datapath_cap_evb; 1171 boolean_t enc_rx_disable_scatter_supported; 1172 boolean_t enc_allow_set_mac_with_installed_filters; 1173 boolean_t enc_enhanced_set_mac_supported; 1174 boolean_t enc_init_evq_v2_supported; 1175 boolean_t enc_pm_and_rxdp_counters; 1176 boolean_t enc_mac_stats_40g_tx_size_bins; 1177 /* External port identifier */ 1178 uint8_t enc_external_port; 1179 uint32_t enc_mcdi_max_payload_length; 1180 /* VPD may be per-PF or global */ 1181 boolean_t enc_vpd_is_global; 1182 /* Minimum unidirectional bandwidth in Mb/s to max out all ports */ 1183 uint32_t enc_required_pcie_bandwidth_mbps; 1184 uint32_t enc_max_pcie_link_gen; 1185 /* Firmware verifies integrity of NVRAM updates */ 1186 uint32_t enc_fw_verified_nvram_update_required; 1187 } efx_nic_cfg_t; 1188 1189 #define EFX_PCI_FUNCTION_IS_PF(_encp) ((_encp)->enc_vf == 0xffff) 1190 #define EFX_PCI_FUNCTION_IS_VF(_encp) ((_encp)->enc_vf != 0xffff) 1191 1192 #define EFX_PCI_FUNCTION(_encp) \ 1193 (EFX_PCI_FUNCTION_IS_PF(_encp) ? (_encp)->enc_pf : (_encp)->enc_vf) 1194 1195 #define EFX_PCI_VF_PARENT(_encp) ((_encp)->enc_pf) 1196 1197 extern const efx_nic_cfg_t * 1198 efx_nic_cfg_get( 1199 __in efx_nic_t *enp); 1200 1201 /* Driver resource limits (minimum required/maximum usable). */ 1202 typedef struct efx_drv_limits_s { 1203 uint32_t edl_min_evq_count; 1204 uint32_t edl_max_evq_count; 1205 1206 uint32_t edl_min_rxq_count; 1207 uint32_t edl_max_rxq_count; 1208 1209 uint32_t edl_min_txq_count; 1210 uint32_t edl_max_txq_count; 1211 1212 /* PIO blocks (sub-allocated from piobuf) */ 1213 uint32_t edl_min_pio_alloc_size; 1214 uint32_t edl_max_pio_alloc_count; 1215 } efx_drv_limits_t; 1216 1217 extern __checkReturn efx_rc_t 1218 efx_nic_set_drv_limits( 1219 __inout efx_nic_t *enp, 1220 __in efx_drv_limits_t *edlp); 1221 1222 typedef enum efx_nic_region_e { 1223 EFX_REGION_VI, /* Memory BAR UC mapping */ 1224 EFX_REGION_PIO_WRITE_VI, /* Memory BAR WC mapping */ 1225 } efx_nic_region_t; 1226 1227 extern __checkReturn efx_rc_t 1228 efx_nic_get_bar_region( 1229 __in efx_nic_t *enp, 1230 __in efx_nic_region_t region, 1231 __out uint32_t *offsetp, 1232 __out size_t *sizep); 1233 1234 extern __checkReturn efx_rc_t 1235 efx_nic_get_vi_pool( 1236 __in efx_nic_t *enp, 1237 __out uint32_t *evq_countp, 1238 __out uint32_t *rxq_countp, 1239 __out uint32_t *txq_countp); 1240 1241 1242 #if EFSYS_OPT_VPD 1243 1244 typedef enum efx_vpd_tag_e { 1245 EFX_VPD_ID = 0x02, 1246 EFX_VPD_END = 0x0f, 1247 EFX_VPD_RO = 0x10, 1248 EFX_VPD_RW = 0x11, 1249 } efx_vpd_tag_t; 1250 1251 typedef uint16_t efx_vpd_keyword_t; 1252 1253 typedef struct efx_vpd_value_s { 1254 efx_vpd_tag_t evv_tag; 1255 efx_vpd_keyword_t evv_keyword; 1256 uint8_t evv_length; 1257 uint8_t evv_value[0x100]; 1258 } efx_vpd_value_t; 1259 1260 1261 #define EFX_VPD_KEYWORD(x, y) ((x) | ((y) << 8)) 1262 1263 extern __checkReturn efx_rc_t 1264 efx_vpd_init( 1265 __in efx_nic_t *enp); 1266 1267 extern __checkReturn efx_rc_t 1268 efx_vpd_size( 1269 __in efx_nic_t *enp, 1270 __out size_t *sizep); 1271 1272 extern __checkReturn efx_rc_t 1273 efx_vpd_read( 1274 __in efx_nic_t *enp, 1275 __out_bcount(size) caddr_t data, 1276 __in size_t size); 1277 1278 extern __checkReturn efx_rc_t 1279 efx_vpd_verify( 1280 __in efx_nic_t *enp, 1281 __in_bcount(size) caddr_t data, 1282 __in size_t size); 1283 1284 extern __checkReturn efx_rc_t 1285 efx_vpd_reinit( 1286 __in efx_nic_t *enp, 1287 __in_bcount(size) caddr_t data, 1288 __in size_t size); 1289 1290 extern __checkReturn efx_rc_t 1291 efx_vpd_get( 1292 __in efx_nic_t *enp, 1293 __in_bcount(size) caddr_t data, 1294 __in size_t size, 1295 __inout efx_vpd_value_t *evvp); 1296 1297 extern __checkReturn efx_rc_t 1298 efx_vpd_set( 1299 __in efx_nic_t *enp, 1300 __inout_bcount(size) caddr_t data, 1301 __in size_t size, 1302 __in efx_vpd_value_t *evvp); 1303 1304 extern __checkReturn efx_rc_t 1305 efx_vpd_next( 1306 __in efx_nic_t *enp, 1307 __inout_bcount(size) caddr_t data, 1308 __in size_t size, 1309 __out efx_vpd_value_t *evvp, 1310 __inout unsigned int *contp); 1311 1312 extern __checkReturn efx_rc_t 1313 efx_vpd_write( 1314 __in efx_nic_t *enp, 1315 __in_bcount(size) caddr_t data, 1316 __in size_t size); 1317 1318 extern void 1319 efx_vpd_fini( 1320 __in efx_nic_t *enp); 1321 1322 #endif /* EFSYS_OPT_VPD */ 1323 1324 /* NVRAM */ 1325 1326 #if EFSYS_OPT_NVRAM 1327 1328 typedef enum efx_nvram_type_e { 1329 EFX_NVRAM_INVALID = 0, 1330 EFX_NVRAM_BOOTROM, 1331 EFX_NVRAM_BOOTROM_CFG, 1332 EFX_NVRAM_MC_FIRMWARE, 1333 EFX_NVRAM_MC_GOLDEN, 1334 EFX_NVRAM_PHY, 1335 EFX_NVRAM_NULLPHY, 1336 EFX_NVRAM_FPGA, 1337 EFX_NVRAM_FCFW, 1338 EFX_NVRAM_CPLD, 1339 EFX_NVRAM_FPGA_BACKUP, 1340 EFX_NVRAM_DYNAMIC_CFG, 1341 EFX_NVRAM_LICENSE, 1342 EFX_NVRAM_UEFIROM, 1343 EFX_NVRAM_NTYPES, 1344 } efx_nvram_type_t; 1345 1346 extern __checkReturn efx_rc_t 1347 efx_nvram_init( 1348 __in efx_nic_t *enp); 1349 1350 #if EFSYS_OPT_DIAG 1351 1352 extern __checkReturn efx_rc_t 1353 efx_nvram_test( 1354 __in efx_nic_t *enp); 1355 1356 #endif /* EFSYS_OPT_DIAG */ 1357 1358 extern __checkReturn efx_rc_t 1359 efx_nvram_size( 1360 __in efx_nic_t *enp, 1361 __in efx_nvram_type_t type, 1362 __out size_t *sizep); 1363 1364 extern __checkReturn efx_rc_t 1365 efx_nvram_rw_start( 1366 __in efx_nic_t *enp, 1367 __in efx_nvram_type_t type, 1368 __out_opt size_t *pref_chunkp); 1369 1370 extern __checkReturn efx_rc_t 1371 efx_nvram_rw_finish( 1372 __in efx_nic_t *enp, 1373 __in efx_nvram_type_t type); 1374 1375 extern __checkReturn efx_rc_t 1376 efx_nvram_get_version( 1377 __in efx_nic_t *enp, 1378 __in efx_nvram_type_t type, 1379 __out uint32_t *subtypep, 1380 __out_ecount(4) uint16_t version[4]); 1381 1382 extern __checkReturn efx_rc_t 1383 efx_nvram_read_chunk( 1384 __in efx_nic_t *enp, 1385 __in efx_nvram_type_t type, 1386 __in unsigned int offset, 1387 __out_bcount(size) caddr_t data, 1388 __in size_t size); 1389 1390 extern __checkReturn efx_rc_t 1391 efx_nvram_set_version( 1392 __in efx_nic_t *enp, 1393 __in efx_nvram_type_t type, 1394 __in_ecount(4) uint16_t version[4]); 1395 1396 extern __checkReturn efx_rc_t 1397 efx_nvram_validate( 1398 __in efx_nic_t *enp, 1399 __in efx_nvram_type_t type, 1400 __in_bcount(partn_size) caddr_t partn_data, 1401 __in size_t partn_size); 1402 1403 extern __checkReturn efx_rc_t 1404 efx_nvram_erase( 1405 __in efx_nic_t *enp, 1406 __in efx_nvram_type_t type); 1407 1408 extern __checkReturn efx_rc_t 1409 efx_nvram_write_chunk( 1410 __in efx_nic_t *enp, 1411 __in efx_nvram_type_t type, 1412 __in unsigned int offset, 1413 __in_bcount(size) caddr_t data, 1414 __in size_t size); 1415 1416 extern void 1417 efx_nvram_fini( 1418 __in efx_nic_t *enp); 1419 1420 #endif /* EFSYS_OPT_NVRAM */ 1421 1422 #if EFSYS_OPT_BOOTCFG 1423 1424 /* Report size and offset of bootcfg sector in NVRAM partition. */ 1425 extern __checkReturn efx_rc_t 1426 efx_bootcfg_sector_info( 1427 __in efx_nic_t *enp, 1428 __in uint32_t pf, 1429 __out_opt uint32_t *sector_countp, 1430 __out size_t *offsetp, 1431 __out size_t *max_sizep); 1432 1433 /* 1434 * Copy bootcfg sector data to a target buffer which may differ in size. 1435 * Optionally corrects format errors in source buffer. 1436 */ 1437 extern efx_rc_t 1438 efx_bootcfg_copy_sector( 1439 __in efx_nic_t *enp, 1440 __inout_bcount(sector_length) 1441 uint8_t *sector, 1442 __in size_t sector_length, 1443 __out_bcount(data_size) uint8_t *data, 1444 __in size_t data_size, 1445 __in boolean_t handle_format_errors); 1446 1447 extern efx_rc_t 1448 efx_bootcfg_read( 1449 __in efx_nic_t *enp, 1450 __out_bcount(size) caddr_t data, 1451 __in size_t size); 1452 1453 extern efx_rc_t 1454 efx_bootcfg_write( 1455 __in efx_nic_t *enp, 1456 __in_bcount(size) caddr_t data, 1457 __in size_t size); 1458 1459 #endif /* EFSYS_OPT_BOOTCFG */ 1460 1461 #if EFSYS_OPT_DIAG 1462 1463 typedef enum efx_pattern_type_t { 1464 EFX_PATTERN_BYTE_INCREMENT = 0, 1465 EFX_PATTERN_ALL_THE_SAME, 1466 EFX_PATTERN_BIT_ALTERNATE, 1467 EFX_PATTERN_BYTE_ALTERNATE, 1468 EFX_PATTERN_BYTE_CHANGING, 1469 EFX_PATTERN_BIT_SWEEP, 1470 EFX_PATTERN_NTYPES 1471 } efx_pattern_type_t; 1472 1473 typedef void 1474 (*efx_sram_pattern_fn_t)( 1475 __in size_t row, 1476 __in boolean_t negate, 1477 __out efx_qword_t *eqp); 1478 1479 extern __checkReturn efx_rc_t 1480 efx_sram_test( 1481 __in efx_nic_t *enp, 1482 __in efx_pattern_type_t type); 1483 1484 #endif /* EFSYS_OPT_DIAG */ 1485 1486 extern __checkReturn efx_rc_t 1487 efx_sram_buf_tbl_set( 1488 __in efx_nic_t *enp, 1489 __in uint32_t id, 1490 __in efsys_mem_t *esmp, 1491 __in size_t n); 1492 1493 extern void 1494 efx_sram_buf_tbl_clear( 1495 __in efx_nic_t *enp, 1496 __in uint32_t id, 1497 __in size_t n); 1498 1499 #define EFX_BUF_TBL_SIZE 0x20000 1500 1501 #define EFX_BUF_SIZE 4096 1502 1503 /* EV */ 1504 1505 typedef struct efx_evq_s efx_evq_t; 1506 1507 #if EFSYS_OPT_QSTATS 1508 1509 /* START MKCONFIG GENERATED EfxHeaderEventQueueBlock 6f3843f5fe7cc843 */ 1510 typedef enum efx_ev_qstat_e { 1511 EV_ALL, 1512 EV_RX, 1513 EV_RX_OK, 1514 EV_RX_FRM_TRUNC, 1515 EV_RX_TOBE_DISC, 1516 EV_RX_PAUSE_FRM_ERR, 1517 EV_RX_BUF_OWNER_ID_ERR, 1518 EV_RX_IPV4_HDR_CHKSUM_ERR, 1519 EV_RX_TCP_UDP_CHKSUM_ERR, 1520 EV_RX_ETH_CRC_ERR, 1521 EV_RX_IP_FRAG_ERR, 1522 EV_RX_MCAST_PKT, 1523 EV_RX_MCAST_HASH_MATCH, 1524 EV_RX_TCP_IPV4, 1525 EV_RX_TCP_IPV6, 1526 EV_RX_UDP_IPV4, 1527 EV_RX_UDP_IPV6, 1528 EV_RX_OTHER_IPV4, 1529 EV_RX_OTHER_IPV6, 1530 EV_RX_NON_IP, 1531 EV_RX_BATCH, 1532 EV_TX, 1533 EV_TX_WQ_FF_FULL, 1534 EV_TX_PKT_ERR, 1535 EV_TX_PKT_TOO_BIG, 1536 EV_TX_UNEXPECTED, 1537 EV_GLOBAL, 1538 EV_GLOBAL_MNT, 1539 EV_DRIVER, 1540 EV_DRIVER_SRM_UPD_DONE, 1541 EV_DRIVER_TX_DESCQ_FLS_DONE, 1542 EV_DRIVER_RX_DESCQ_FLS_DONE, 1543 EV_DRIVER_RX_DESCQ_FLS_FAILED, 1544 EV_DRIVER_RX_DSC_ERROR, 1545 EV_DRIVER_TX_DSC_ERROR, 1546 EV_DRV_GEN, 1547 EV_MCDI_RESPONSE, 1548 EV_NQSTATS 1549 } efx_ev_qstat_t; 1550 1551 /* END MKCONFIG GENERATED EfxHeaderEventQueueBlock */ 1552 1553 #endif /* EFSYS_OPT_QSTATS */ 1554 1555 extern __checkReturn efx_rc_t 1556 efx_ev_init( 1557 __in efx_nic_t *enp); 1558 1559 extern void 1560 efx_ev_fini( 1561 __in efx_nic_t *enp); 1562 1563 #define EFX_EVQ_MAXNEVS 32768 1564 #define EFX_EVQ_MINNEVS 512 1565 1566 #define EFX_EVQ_SIZE(_nevs) ((_nevs) * sizeof (efx_qword_t)) 1567 #define EFX_EVQ_NBUFS(_nevs) (EFX_EVQ_SIZE(_nevs) / EFX_BUF_SIZE) 1568 1569 #define EFX_EVQ_FLAGS_TYPE_MASK (0x3) 1570 #define EFX_EVQ_FLAGS_TYPE_AUTO (0x0) 1571 #define EFX_EVQ_FLAGS_TYPE_THROUGHPUT (0x1) 1572 #define EFX_EVQ_FLAGS_TYPE_LOW_LATENCY (0x2) 1573 1574 #define EFX_EVQ_FLAGS_NOTIFY_MASK (0xC) 1575 #define EFX_EVQ_FLAGS_NOTIFY_INTERRUPT (0x0) /* Interrupting (default) */ 1576 #define EFX_EVQ_FLAGS_NOTIFY_DISABLED (0x4) /* Non-interrupting */ 1577 1578 extern __checkReturn efx_rc_t 1579 efx_ev_qcreate( 1580 __in efx_nic_t *enp, 1581 __in unsigned int index, 1582 __in efsys_mem_t *esmp, 1583 __in size_t n, 1584 __in uint32_t id, 1585 __in uint32_t us, 1586 __in uint32_t flags, 1587 __deref_out efx_evq_t **eepp); 1588 1589 extern void 1590 efx_ev_qpost( 1591 __in efx_evq_t *eep, 1592 __in uint16_t data); 1593 1594 typedef __checkReturn boolean_t 1595 (*efx_initialized_ev_t)( 1596 __in_opt void *arg); 1597 1598 #define EFX_PKT_UNICAST 0x0004 1599 #define EFX_PKT_START 0x0008 1600 1601 #define EFX_PKT_VLAN_TAGGED 0x0010 1602 #define EFX_CKSUM_TCPUDP 0x0020 1603 #define EFX_CKSUM_IPV4 0x0040 1604 #define EFX_PKT_CONT 0x0080 1605 1606 #define EFX_CHECK_VLAN 0x0100 1607 #define EFX_PKT_TCP 0x0200 1608 #define EFX_PKT_UDP 0x0400 1609 #define EFX_PKT_IPV4 0x0800 1610 1611 #define EFX_PKT_IPV6 0x1000 1612 #define EFX_PKT_PREFIX_LEN 0x2000 1613 #define EFX_ADDR_MISMATCH 0x4000 1614 #define EFX_DISCARD 0x8000 1615 1616 #define EFX_EV_RX_NLABELS 32 1617 #define EFX_EV_TX_NLABELS 32 1618 1619 typedef __checkReturn boolean_t 1620 (*efx_rx_ev_t)( 1621 __in_opt void *arg, 1622 __in uint32_t label, 1623 __in uint32_t id, 1624 __in uint32_t size, 1625 __in uint16_t flags); 1626 1627 typedef __checkReturn boolean_t 1628 (*efx_tx_ev_t)( 1629 __in_opt void *arg, 1630 __in uint32_t label, 1631 __in uint32_t id); 1632 1633 #define EFX_EXCEPTION_RX_RECOVERY 0x00000001 1634 #define EFX_EXCEPTION_RX_DSC_ERROR 0x00000002 1635 #define EFX_EXCEPTION_TX_DSC_ERROR 0x00000003 1636 #define EFX_EXCEPTION_UNKNOWN_SENSOREVT 0x00000004 1637 #define EFX_EXCEPTION_FWALERT_SRAM 0x00000005 1638 #define EFX_EXCEPTION_UNKNOWN_FWALERT 0x00000006 1639 #define EFX_EXCEPTION_RX_ERROR 0x00000007 1640 #define EFX_EXCEPTION_TX_ERROR 0x00000008 1641 #define EFX_EXCEPTION_EV_ERROR 0x00000009 1642 1643 typedef __checkReturn boolean_t 1644 (*efx_exception_ev_t)( 1645 __in_opt void *arg, 1646 __in uint32_t label, 1647 __in uint32_t data); 1648 1649 typedef __checkReturn boolean_t 1650 (*efx_rxq_flush_done_ev_t)( 1651 __in_opt void *arg, 1652 __in uint32_t rxq_index); 1653 1654 typedef __checkReturn boolean_t 1655 (*efx_rxq_flush_failed_ev_t)( 1656 __in_opt void *arg, 1657 __in uint32_t rxq_index); 1658 1659 typedef __checkReturn boolean_t 1660 (*efx_txq_flush_done_ev_t)( 1661 __in_opt void *arg, 1662 __in uint32_t txq_index); 1663 1664 typedef __checkReturn boolean_t 1665 (*efx_software_ev_t)( 1666 __in_opt void *arg, 1667 __in uint16_t magic); 1668 1669 typedef __checkReturn boolean_t 1670 (*efx_sram_ev_t)( 1671 __in_opt void *arg, 1672 __in uint32_t code); 1673 1674 #define EFX_SRAM_CLEAR 0 1675 #define EFX_SRAM_UPDATE 1 1676 #define EFX_SRAM_ILLEGAL_CLEAR 2 1677 1678 typedef __checkReturn boolean_t 1679 (*efx_wake_up_ev_t)( 1680 __in_opt void *arg, 1681 __in uint32_t label); 1682 1683 typedef __checkReturn boolean_t 1684 (*efx_timer_ev_t)( 1685 __in_opt void *arg, 1686 __in uint32_t label); 1687 1688 typedef __checkReturn boolean_t 1689 (*efx_link_change_ev_t)( 1690 __in_opt void *arg, 1691 __in efx_link_mode_t link_mode); 1692 1693 #if EFSYS_OPT_MON_STATS 1694 1695 typedef __checkReturn boolean_t 1696 (*efx_monitor_ev_t)( 1697 __in_opt void *arg, 1698 __in efx_mon_stat_t id, 1699 __in efx_mon_stat_value_t value); 1700 1701 #endif /* EFSYS_OPT_MON_STATS */ 1702 1703 #if EFSYS_OPT_MAC_STATS 1704 1705 typedef __checkReturn boolean_t 1706 (*efx_mac_stats_ev_t)( 1707 __in_opt void *arg, 1708 __in uint32_t generation 1709 ); 1710 1711 #endif /* EFSYS_OPT_MAC_STATS */ 1712 1713 typedef struct efx_ev_callbacks_s { 1714 efx_initialized_ev_t eec_initialized; 1715 efx_rx_ev_t eec_rx; 1716 efx_tx_ev_t eec_tx; 1717 efx_exception_ev_t eec_exception; 1718 efx_rxq_flush_done_ev_t eec_rxq_flush_done; 1719 efx_rxq_flush_failed_ev_t eec_rxq_flush_failed; 1720 efx_txq_flush_done_ev_t eec_txq_flush_done; 1721 efx_software_ev_t eec_software; 1722 efx_sram_ev_t eec_sram; 1723 efx_wake_up_ev_t eec_wake_up; 1724 efx_timer_ev_t eec_timer; 1725 efx_link_change_ev_t eec_link_change; 1726 #if EFSYS_OPT_MON_STATS 1727 efx_monitor_ev_t eec_monitor; 1728 #endif /* EFSYS_OPT_MON_STATS */ 1729 #if EFSYS_OPT_MAC_STATS 1730 efx_mac_stats_ev_t eec_mac_stats; 1731 #endif /* EFSYS_OPT_MAC_STATS */ 1732 } efx_ev_callbacks_t; 1733 1734 extern __checkReturn boolean_t 1735 efx_ev_qpending( 1736 __in efx_evq_t *eep, 1737 __in unsigned int count); 1738 1739 #if EFSYS_OPT_EV_PREFETCH 1740 1741 extern void 1742 efx_ev_qprefetch( 1743 __in efx_evq_t *eep, 1744 __in unsigned int count); 1745 1746 #endif /* EFSYS_OPT_EV_PREFETCH */ 1747 1748 extern void 1749 efx_ev_qpoll( 1750 __in efx_evq_t *eep, 1751 __inout unsigned int *countp, 1752 __in const efx_ev_callbacks_t *eecp, 1753 __in_opt void *arg); 1754 1755 extern __checkReturn efx_rc_t 1756 efx_ev_usecs_to_ticks( 1757 __in efx_nic_t *enp, 1758 __in unsigned int usecs, 1759 __out unsigned int *ticksp); 1760 1761 extern __checkReturn efx_rc_t 1762 efx_ev_qmoderate( 1763 __in efx_evq_t *eep, 1764 __in unsigned int us); 1765 1766 extern __checkReturn efx_rc_t 1767 efx_ev_qprime( 1768 __in efx_evq_t *eep, 1769 __in unsigned int count); 1770 1771 #if EFSYS_OPT_QSTATS 1772 1773 #if EFSYS_OPT_NAMES 1774 1775 extern const char * 1776 efx_ev_qstat_name( 1777 __in efx_nic_t *enp, 1778 __in unsigned int id); 1779 1780 #endif /* EFSYS_OPT_NAMES */ 1781 1782 extern void 1783 efx_ev_qstats_update( 1784 __in efx_evq_t *eep, 1785 __inout_ecount(EV_NQSTATS) efsys_stat_t *stat); 1786 1787 #endif /* EFSYS_OPT_QSTATS */ 1788 1789 extern void 1790 efx_ev_qdestroy( 1791 __in efx_evq_t *eep); 1792 1793 /* RX */ 1794 1795 extern __checkReturn efx_rc_t 1796 efx_rx_init( 1797 __inout efx_nic_t *enp); 1798 1799 extern void 1800 efx_rx_fini( 1801 __in efx_nic_t *enp); 1802 1803 #if EFSYS_OPT_RX_SCATTER 1804 __checkReturn efx_rc_t 1805 efx_rx_scatter_enable( 1806 __in efx_nic_t *enp, 1807 __in unsigned int buf_size); 1808 #endif /* EFSYS_OPT_RX_SCATTER */ 1809 1810 #if EFSYS_OPT_RX_SCALE 1811 1812 typedef enum efx_rx_hash_alg_e { 1813 EFX_RX_HASHALG_LFSR = 0, 1814 EFX_RX_HASHALG_TOEPLITZ 1815 } efx_rx_hash_alg_t; 1816 1817 #define EFX_RX_HASH_IPV4 (1U << 0) 1818 #define EFX_RX_HASH_TCPIPV4 (1U << 1) 1819 #define EFX_RX_HASH_IPV6 (1U << 2) 1820 #define EFX_RX_HASH_TCPIPV6 (1U << 3) 1821 1822 typedef unsigned int efx_rx_hash_type_t; 1823 1824 typedef enum efx_rx_hash_support_e { 1825 EFX_RX_HASH_UNAVAILABLE = 0, /* Hardware hash not inserted */ 1826 EFX_RX_HASH_AVAILABLE /* Insert hash with/without RSS */ 1827 } efx_rx_hash_support_t; 1828 1829 #define EFX_RSS_TBL_SIZE 128 /* Rows in RX indirection table */ 1830 #define EFX_MAXRSS 64 /* RX indirection entry range */ 1831 #define EFX_MAXRSS_LEGACY 16 /* See bug16611 and bug17213 */ 1832 1833 typedef enum efx_rx_scale_support_e { 1834 EFX_RX_SCALE_UNAVAILABLE = 0, /* Not supported */ 1835 EFX_RX_SCALE_EXCLUSIVE, /* Writable key/indirection table */ 1836 EFX_RX_SCALE_SHARED /* Read-only key/indirection table */ 1837 } efx_rx_scale_support_t; 1838 1839 extern __checkReturn efx_rc_t 1840 efx_rx_hash_support_get( 1841 __in efx_nic_t *enp, 1842 __out efx_rx_hash_support_t *supportp); 1843 1844 1845 extern __checkReturn efx_rc_t 1846 efx_rx_scale_support_get( 1847 __in efx_nic_t *enp, 1848 __out efx_rx_scale_support_t *supportp); 1849 1850 extern __checkReturn efx_rc_t 1851 efx_rx_scale_mode_set( 1852 __in efx_nic_t *enp, 1853 __in efx_rx_hash_alg_t alg, 1854 __in efx_rx_hash_type_t type, 1855 __in boolean_t insert); 1856 1857 extern __checkReturn efx_rc_t 1858 efx_rx_scale_tbl_set( 1859 __in efx_nic_t *enp, 1860 __in_ecount(n) unsigned int *table, 1861 __in size_t n); 1862 1863 extern __checkReturn efx_rc_t 1864 efx_rx_scale_key_set( 1865 __in efx_nic_t *enp, 1866 __in_ecount(n) uint8_t *key, 1867 __in size_t n); 1868 1869 extern __checkReturn uint32_t 1870 efx_pseudo_hdr_hash_get( 1871 __in efx_rxq_t *erp, 1872 __in efx_rx_hash_alg_t func, 1873 __in uint8_t *buffer); 1874 1875 #endif /* EFSYS_OPT_RX_SCALE */ 1876 1877 extern __checkReturn efx_rc_t 1878 efx_pseudo_hdr_pkt_length_get( 1879 __in efx_rxq_t *erp, 1880 __in uint8_t *buffer, 1881 __out uint16_t *pkt_lengthp); 1882 1883 #define EFX_RXQ_MAXNDESCS 4096 1884 #define EFX_RXQ_MINNDESCS 512 1885 1886 #define EFX_RXQ_SIZE(_ndescs) ((_ndescs) * sizeof (efx_qword_t)) 1887 #define EFX_RXQ_NBUFS(_ndescs) (EFX_RXQ_SIZE(_ndescs) / EFX_BUF_SIZE) 1888 #define EFX_RXQ_LIMIT(_ndescs) ((_ndescs) - 16) 1889 #define EFX_RXQ_DC_NDESCS(_dcsize) (8 << _dcsize) 1890 1891 typedef enum efx_rxq_type_e { 1892 EFX_RXQ_TYPE_DEFAULT, 1893 EFX_RXQ_TYPE_SCATTER, 1894 EFX_RXQ_NTYPES 1895 } efx_rxq_type_t; 1896 1897 extern __checkReturn efx_rc_t 1898 efx_rx_qcreate( 1899 __in efx_nic_t *enp, 1900 __in unsigned int index, 1901 __in unsigned int label, 1902 __in efx_rxq_type_t type, 1903 __in efsys_mem_t *esmp, 1904 __in size_t n, 1905 __in uint32_t id, 1906 __in efx_evq_t *eep, 1907 __deref_out efx_rxq_t **erpp); 1908 1909 typedef struct efx_buffer_s { 1910 efsys_dma_addr_t eb_addr; 1911 size_t eb_size; 1912 boolean_t eb_eop; 1913 } efx_buffer_t; 1914 1915 typedef struct efx_desc_s { 1916 efx_qword_t ed_eq; 1917 } efx_desc_t; 1918 1919 extern void 1920 efx_rx_qpost( 1921 __in efx_rxq_t *erp, 1922 __in_ecount(n) efsys_dma_addr_t *addrp, 1923 __in size_t size, 1924 __in unsigned int n, 1925 __in unsigned int completed, 1926 __in unsigned int added); 1927 1928 extern void 1929 efx_rx_qpush( 1930 __in efx_rxq_t *erp, 1931 __in unsigned int added, 1932 __inout unsigned int *pushedp); 1933 1934 extern __checkReturn efx_rc_t 1935 efx_rx_qflush( 1936 __in efx_rxq_t *erp); 1937 1938 extern void 1939 efx_rx_qenable( 1940 __in efx_rxq_t *erp); 1941 1942 extern void 1943 efx_rx_qdestroy( 1944 __in efx_rxq_t *erp); 1945 1946 /* TX */ 1947 1948 typedef struct efx_txq_s efx_txq_t; 1949 1950 #if EFSYS_OPT_QSTATS 1951 1952 /* START MKCONFIG GENERATED EfxHeaderTransmitQueueBlock 12dff8778598b2db */ 1953 typedef enum efx_tx_qstat_e { 1954 TX_POST, 1955 TX_POST_PIO, 1956 TX_NQSTATS 1957 } efx_tx_qstat_t; 1958 1959 /* END MKCONFIG GENERATED EfxHeaderTransmitQueueBlock */ 1960 1961 #endif /* EFSYS_OPT_QSTATS */ 1962 1963 extern __checkReturn efx_rc_t 1964 efx_tx_init( 1965 __in efx_nic_t *enp); 1966 1967 extern void 1968 efx_tx_fini( 1969 __in efx_nic_t *enp); 1970 1971 #define EFX_BUG35388_WORKAROUND(_encp) \ 1972 (((_encp) == NULL) ? 1 : ((_encp)->enc_bug35388_workaround != 0)) 1973 1974 #define EFX_TXQ_MAXNDESCS(_encp) \ 1975 ((EFX_BUG35388_WORKAROUND(_encp)) ? 2048 : 4096) 1976 1977 #define EFX_TXQ_MINNDESCS 512 1978 1979 #define EFX_TXQ_SIZE(_ndescs) ((_ndescs) * sizeof (efx_qword_t)) 1980 #define EFX_TXQ_NBUFS(_ndescs) (EFX_TXQ_SIZE(_ndescs) / EFX_BUF_SIZE) 1981 #define EFX_TXQ_LIMIT(_ndescs) ((_ndescs) - 16) 1982 #define EFX_TXQ_DC_NDESCS(_dcsize) (8 << _dcsize) 1983 1984 #define EFX_TXQ_MAX_BUFS 8 /* Maximum independent of EFX_BUG35388_WORKAROUND. */ 1985 1986 #define EFX_TXQ_CKSUM_IPV4 0x0001 1987 #define EFX_TXQ_CKSUM_TCPUDP 0x0002 1988 #define EFX_TXQ_FATSOV2 0x0004 1989 1990 extern __checkReturn efx_rc_t 1991 efx_tx_qcreate( 1992 __in efx_nic_t *enp, 1993 __in unsigned int index, 1994 __in unsigned int label, 1995 __in efsys_mem_t *esmp, 1996 __in size_t n, 1997 __in uint32_t id, 1998 __in uint16_t flags, 1999 __in efx_evq_t *eep, 2000 __deref_out efx_txq_t **etpp, 2001 __out unsigned int *addedp); 2002 2003 extern __checkReturn efx_rc_t 2004 efx_tx_qpost( 2005 __in efx_txq_t *etp, 2006 __in_ecount(n) efx_buffer_t *eb, 2007 __in unsigned int n, 2008 __in unsigned int completed, 2009 __inout unsigned int *addedp); 2010 2011 extern __checkReturn efx_rc_t 2012 efx_tx_qpace( 2013 __in efx_txq_t *etp, 2014 __in unsigned int ns); 2015 2016 extern void 2017 efx_tx_qpush( 2018 __in efx_txq_t *etp, 2019 __in unsigned int added, 2020 __in unsigned int pushed); 2021 2022 extern __checkReturn efx_rc_t 2023 efx_tx_qflush( 2024 __in efx_txq_t *etp); 2025 2026 extern void 2027 efx_tx_qenable( 2028 __in efx_txq_t *etp); 2029 2030 extern __checkReturn efx_rc_t 2031 efx_tx_qpio_enable( 2032 __in efx_txq_t *etp); 2033 2034 extern void 2035 efx_tx_qpio_disable( 2036 __in efx_txq_t *etp); 2037 2038 extern __checkReturn efx_rc_t 2039 efx_tx_qpio_write( 2040 __in efx_txq_t *etp, 2041 __in_ecount(buf_length) uint8_t *buffer, 2042 __in size_t buf_length, 2043 __in size_t pio_buf_offset); 2044 2045 extern __checkReturn efx_rc_t 2046 efx_tx_qpio_post( 2047 __in efx_txq_t *etp, 2048 __in size_t pkt_length, 2049 __in unsigned int completed, 2050 __inout unsigned int *addedp); 2051 2052 extern __checkReturn efx_rc_t 2053 efx_tx_qdesc_post( 2054 __in efx_txq_t *etp, 2055 __in_ecount(n) efx_desc_t *ed, 2056 __in unsigned int n, 2057 __in unsigned int completed, 2058 __inout unsigned int *addedp); 2059 2060 extern void 2061 efx_tx_qdesc_dma_create( 2062 __in efx_txq_t *etp, 2063 __in efsys_dma_addr_t addr, 2064 __in size_t size, 2065 __in boolean_t eop, 2066 __out efx_desc_t *edp); 2067 2068 extern void 2069 efx_tx_qdesc_tso_create( 2070 __in efx_txq_t *etp, 2071 __in uint16_t ipv4_id, 2072 __in uint32_t tcp_seq, 2073 __in uint8_t tcp_flags, 2074 __out efx_desc_t *edp); 2075 2076 /* Number of FATSOv2 option descriptors */ 2077 #define EFX_TX_FATSOV2_OPT_NDESCS 2 2078 2079 /* Maximum number of DMA segments per TSO packet (not superframe) */ 2080 #define EFX_TX_FATSOV2_DMA_SEGS_PER_PKT_MAX 24 2081 2082 extern void 2083 efx_tx_qdesc_tso2_create( 2084 __in efx_txq_t *etp, 2085 __in uint16_t ipv4_id, 2086 __in uint32_t tcp_seq, 2087 __in uint16_t tcp_mss, 2088 __out_ecount(count) efx_desc_t *edp, 2089 __in int count); 2090 2091 extern void 2092 efx_tx_qdesc_vlantci_create( 2093 __in efx_txq_t *etp, 2094 __in uint16_t tci, 2095 __out efx_desc_t *edp); 2096 2097 #if EFSYS_OPT_QSTATS 2098 2099 #if EFSYS_OPT_NAMES 2100 2101 extern const char * 2102 efx_tx_qstat_name( 2103 __in efx_nic_t *etp, 2104 __in unsigned int id); 2105 2106 #endif /* EFSYS_OPT_NAMES */ 2107 2108 extern void 2109 efx_tx_qstats_update( 2110 __in efx_txq_t *etp, 2111 __inout_ecount(TX_NQSTATS) efsys_stat_t *stat); 2112 2113 #endif /* EFSYS_OPT_QSTATS */ 2114 2115 extern void 2116 efx_tx_qdestroy( 2117 __in efx_txq_t *etp); 2118 2119 2120 /* FILTER */ 2121 2122 #if EFSYS_OPT_FILTER 2123 2124 #define EFX_ETHER_TYPE_IPV4 0x0800 2125 #define EFX_ETHER_TYPE_IPV6 0x86DD 2126 2127 #define EFX_IPPROTO_TCP 6 2128 #define EFX_IPPROTO_UDP 17 2129 2130 /* Use RSS to spread across multiple queues */ 2131 #define EFX_FILTER_FLAG_RX_RSS 0x01 2132 /* Enable RX scatter */ 2133 #define EFX_FILTER_FLAG_RX_SCATTER 0x02 2134 /* 2135 * Override an automatic filter (priority EFX_FILTER_PRI_AUTO). 2136 * May only be set by the filter implementation for each type. 2137 * A removal request will restore the automatic filter in its place. 2138 */ 2139 #define EFX_FILTER_FLAG_RX_OVER_AUTO 0x04 2140 /* Filter is for RX */ 2141 #define EFX_FILTER_FLAG_RX 0x08 2142 /* Filter is for TX */ 2143 #define EFX_FILTER_FLAG_TX 0x10 2144 2145 typedef unsigned int efx_filter_flags_t; 2146 2147 typedef enum efx_filter_match_flags_e { 2148 EFX_FILTER_MATCH_REM_HOST = 0x0001, /* Match by remote IP host 2149 * address */ 2150 EFX_FILTER_MATCH_LOC_HOST = 0x0002, /* Match by local IP host 2151 * address */ 2152 EFX_FILTER_MATCH_REM_MAC = 0x0004, /* Match by remote MAC address */ 2153 EFX_FILTER_MATCH_REM_PORT = 0x0008, /* Match by remote TCP/UDP port */ 2154 EFX_FILTER_MATCH_LOC_MAC = 0x0010, /* Match by remote TCP/UDP port */ 2155 EFX_FILTER_MATCH_LOC_PORT = 0x0020, /* Match by local TCP/UDP port */ 2156 EFX_FILTER_MATCH_ETHER_TYPE = 0x0040, /* Match by Ether-type */ 2157 EFX_FILTER_MATCH_INNER_VID = 0x0080, /* Match by inner VLAN ID */ 2158 EFX_FILTER_MATCH_OUTER_VID = 0x0100, /* Match by outer VLAN ID */ 2159 EFX_FILTER_MATCH_IP_PROTO = 0x0200, /* Match by IP transport 2160 * protocol */ 2161 /* Match otherwise-unmatched multicast and broadcast packets */ 2162 EFX_FILTER_MATCH_UNKNOWN_MCAST_DST = 0x40000000, 2163 /* Match otherwise-unmatched unicast packets */ 2164 EFX_FILTER_MATCH_UNKNOWN_UCAST_DST = 0x80000000, 2165 } efx_filter_match_flags_t; 2166 2167 typedef enum efx_filter_priority_s { 2168 EFX_FILTER_PRI_HINT = 0, /* Performance hint */ 2169 EFX_FILTER_PRI_AUTO, /* Automatic filter based on device 2170 * address list or hardware 2171 * requirements. This may only be used 2172 * by the filter implementation for 2173 * each NIC type. */ 2174 EFX_FILTER_PRI_MANUAL, /* Manually configured filter */ 2175 EFX_FILTER_PRI_REQUIRED, /* Required for correct behaviour of the 2176 * client (e.g. SR-IOV, HyperV VMQ etc.) 2177 */ 2178 } efx_filter_priority_t; 2179 2180 /* 2181 * FIXME: All these fields are assumed to be in little-endian byte order. 2182 * It may be better for some to be big-endian. See bug42804. 2183 */ 2184 2185 typedef struct efx_filter_spec_s { 2186 uint32_t efs_match_flags; 2187 uint32_t efs_priority:2; 2188 uint32_t efs_flags:6; 2189 uint32_t efs_dmaq_id:12; 2190 uint32_t efs_rss_context; 2191 uint16_t efs_outer_vid; 2192 uint16_t efs_inner_vid; 2193 uint8_t efs_loc_mac[EFX_MAC_ADDR_LEN]; 2194 uint8_t efs_rem_mac[EFX_MAC_ADDR_LEN]; 2195 uint16_t efs_ether_type; 2196 uint8_t efs_ip_proto; 2197 uint16_t efs_loc_port; 2198 uint16_t efs_rem_port; 2199 efx_oword_t efs_rem_host; 2200 efx_oword_t efs_loc_host; 2201 } efx_filter_spec_t; 2202 2203 2204 /* Default values for use in filter specifications */ 2205 #define EFX_FILTER_SPEC_RSS_CONTEXT_DEFAULT 0xffffffff 2206 #define EFX_FILTER_SPEC_RX_DMAQ_ID_DROP 0xfff 2207 #define EFX_FILTER_SPEC_VID_UNSPEC 0xffff 2208 2209 extern __checkReturn efx_rc_t 2210 efx_filter_init( 2211 __in efx_nic_t *enp); 2212 2213 extern void 2214 efx_filter_fini( 2215 __in efx_nic_t *enp); 2216 2217 extern __checkReturn efx_rc_t 2218 efx_filter_insert( 2219 __in efx_nic_t *enp, 2220 __inout efx_filter_spec_t *spec); 2221 2222 extern __checkReturn efx_rc_t 2223 efx_filter_remove( 2224 __in efx_nic_t *enp, 2225 __inout efx_filter_spec_t *spec); 2226 2227 extern __checkReturn efx_rc_t 2228 efx_filter_restore( 2229 __in efx_nic_t *enp); 2230 2231 extern __checkReturn efx_rc_t 2232 efx_filter_supported_filters( 2233 __in efx_nic_t *enp, 2234 __out_ecount(buffer_length) uint32_t *buffer, 2235 __in size_t buffer_length, 2236 __out size_t *list_lengthp); 2237 2238 extern void 2239 efx_filter_spec_init_rx( 2240 __out efx_filter_spec_t *spec, 2241 __in efx_filter_priority_t priority, 2242 __in efx_filter_flags_t flags, 2243 __in efx_rxq_t *erp); 2244 2245 extern void 2246 efx_filter_spec_init_tx( 2247 __out efx_filter_spec_t *spec, 2248 __in efx_txq_t *etp); 2249 2250 extern __checkReturn efx_rc_t 2251 efx_filter_spec_set_ipv4_local( 2252 __inout efx_filter_spec_t *spec, 2253 __in uint8_t proto, 2254 __in uint32_t host, 2255 __in uint16_t port); 2256 2257 extern __checkReturn efx_rc_t 2258 efx_filter_spec_set_ipv4_full( 2259 __inout efx_filter_spec_t *spec, 2260 __in uint8_t proto, 2261 __in uint32_t lhost, 2262 __in uint16_t lport, 2263 __in uint32_t rhost, 2264 __in uint16_t rport); 2265 2266 extern __checkReturn efx_rc_t 2267 efx_filter_spec_set_eth_local( 2268 __inout efx_filter_spec_t *spec, 2269 __in uint16_t vid, 2270 __in const uint8_t *addr); 2271 2272 extern __checkReturn efx_rc_t 2273 efx_filter_spec_set_uc_def( 2274 __inout efx_filter_spec_t *spec); 2275 2276 extern __checkReturn efx_rc_t 2277 efx_filter_spec_set_mc_def( 2278 __inout efx_filter_spec_t *spec); 2279 2280 #endif /* EFSYS_OPT_FILTER */ 2281 2282 /* HASH */ 2283 2284 extern __checkReturn uint32_t 2285 efx_hash_dwords( 2286 __in_ecount(count) uint32_t const *input, 2287 __in size_t count, 2288 __in uint32_t init); 2289 2290 extern __checkReturn uint32_t 2291 efx_hash_bytes( 2292 __in_ecount(length) uint8_t const *input, 2293 __in size_t length, 2294 __in uint32_t init); 2295 2296 #if EFSYS_OPT_LICENSING 2297 2298 /* LICENSING */ 2299 2300 typedef struct efx_key_stats_s { 2301 uint32_t eks_valid; 2302 uint32_t eks_invalid; 2303 uint32_t eks_blacklisted; 2304 uint32_t eks_unverifiable; 2305 uint32_t eks_wrong_node; 2306 uint32_t eks_licensed_apps_lo; 2307 uint32_t eks_licensed_apps_hi; 2308 uint32_t eks_licensed_features_lo; 2309 uint32_t eks_licensed_features_hi; 2310 } efx_key_stats_t; 2311 2312 extern __checkReturn efx_rc_t 2313 efx_lic_init( 2314 __in efx_nic_t *enp); 2315 2316 extern void 2317 efx_lic_fini( 2318 __in efx_nic_t *enp); 2319 2320 extern __checkReturn boolean_t 2321 efx_lic_check_support( 2322 __in efx_nic_t *enp); 2323 2324 extern __checkReturn efx_rc_t 2325 efx_lic_update_licenses( 2326 __in efx_nic_t *enp); 2327 2328 extern __checkReturn efx_rc_t 2329 efx_lic_get_key_stats( 2330 __in efx_nic_t *enp, 2331 __out efx_key_stats_t *ksp); 2332 2333 extern __checkReturn efx_rc_t 2334 efx_lic_app_state( 2335 __in efx_nic_t *enp, 2336 __in uint64_t app_id, 2337 __out boolean_t *licensedp); 2338 2339 extern __checkReturn efx_rc_t 2340 efx_lic_get_id( 2341 __in efx_nic_t *enp, 2342 __in size_t buffer_size, 2343 __out uint32_t *typep, 2344 __out size_t *lengthp, 2345 __out_opt uint8_t *bufferp); 2346 2347 2348 extern __checkReturn efx_rc_t 2349 efx_lic_find_start( 2350 __in efx_nic_t *enp, 2351 __in_bcount(buffer_size) 2352 caddr_t bufferp, 2353 __in size_t buffer_size, 2354 __out uint32_t *startp 2355 ); 2356 2357 extern __checkReturn efx_rc_t 2358 efx_lic_find_end( 2359 __in efx_nic_t *enp, 2360 __in_bcount(buffer_size) 2361 caddr_t bufferp, 2362 __in size_t buffer_size, 2363 __in uint32_t offset, 2364 __out uint32_t *endp 2365 ); 2366 2367 extern __checkReturn __success(return != B_FALSE) boolean_t 2368 efx_lic_find_key( 2369 __in efx_nic_t *enp, 2370 __in_bcount(buffer_size) 2371 caddr_t bufferp, 2372 __in size_t buffer_size, 2373 __in uint32_t offset, 2374 __out uint32_t *startp, 2375 __out uint32_t *lengthp 2376 ); 2377 2378 extern __checkReturn __success(return != B_FALSE) boolean_t 2379 efx_lic_validate_key( 2380 __in efx_nic_t *enp, 2381 __in_bcount(length) caddr_t keyp, 2382 __in uint32_t length 2383 ); 2384 2385 extern __checkReturn efx_rc_t 2386 efx_lic_read_key( 2387 __in efx_nic_t *enp, 2388 __in_bcount(buffer_size) 2389 caddr_t bufferp, 2390 __in size_t buffer_size, 2391 __in uint32_t offset, 2392 __in uint32_t length, 2393 __out_bcount_part(key_max_size, *lengthp) 2394 caddr_t keyp, 2395 __in size_t key_max_size, 2396 __out uint32_t *lengthp 2397 ); 2398 2399 extern __checkReturn efx_rc_t 2400 efx_lic_write_key( 2401 __in efx_nic_t *enp, 2402 __in_bcount(buffer_size) 2403 caddr_t bufferp, 2404 __in size_t buffer_size, 2405 __in uint32_t offset, 2406 __in_bcount(length) caddr_t keyp, 2407 __in uint32_t length, 2408 __out uint32_t *lengthp 2409 ); 2410 2411 __checkReturn efx_rc_t 2412 efx_lic_delete_key( 2413 __in efx_nic_t *enp, 2414 __in_bcount(buffer_size) 2415 caddr_t bufferp, 2416 __in size_t buffer_size, 2417 __in uint32_t offset, 2418 __in uint32_t length, 2419 __in uint32_t end, 2420 __out uint32_t *deltap 2421 ); 2422 2423 extern __checkReturn efx_rc_t 2424 efx_lic_create_partition( 2425 __in efx_nic_t *enp, 2426 __in_bcount(buffer_size) 2427 caddr_t bufferp, 2428 __in size_t buffer_size 2429 ); 2430 2431 extern __checkReturn efx_rc_t 2432 efx_lic_finish_partition( 2433 __in efx_nic_t *enp, 2434 __in_bcount(buffer_size) 2435 caddr_t bufferp, 2436 __in size_t buffer_size 2437 ); 2438 2439 #endif /* EFSYS_OPT_LICENSING */ 2440 2441 2442 2443 #ifdef __cplusplus 2444 } 2445 #endif 2446 2447 #endif /* _SYS_EFX_H */ 2448