1 /******************************************************************************* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 * 21 * Copyright 2014 QLogic Corporation 22 * The contents of this file are subject to the terms of the 23 * QLogic End User License (the "License"). 24 * You may not use this file except in compliance with the License. 25 * 26 * You can obtain a copy of the License at 27 * http://www.qlogic.com/Resources/Documents/DriverDownloadHelp/ 28 * QLogic_End_User_Software_License.txt 29 * See the License for the specific language governing permissions 30 * and limitations under the License. 31 * 32 * 33 * Module Description: 34 * 35 * 36 * History: 37 * 10/09/01 Hav Khauv Inception. 38 ******************************************************************************/ 39 40 #ifndef _LM_H 41 #define _LM_H 42 43 #include "lm_defs.h" 44 #include "listq.h" 45 #include "iscsi_info.h" 46 47 /******************************************************************************* 48 * Constants. 49 ******************************************************************************/ 50 51 #define BAD_DEFAULT_VALUE 0xffffffff 52 53 #define ETHERNET_ADDRESS_SIZE 6 54 #define ETHERNET_PACKET_HEADER_SIZE 14 55 #define ETHERNET_VLAN_TAG_SIZE 4 56 #define ETHERNET_LLC_SNAP_SIZE 8 57 #define ETHERNET_CRC32_SIZE 4 58 #define ETHERNET_GRE_SIZE 8 59 60 #define MIN_ETHERNET_PACKET_SIZE 60 61 62 // VLAN TAG 63 #define ETHERNET_VLAN_ID_MASK (0xFFF<<0) 64 #define ETHERNET_VLAN_ID_OFFSET (0) 65 #define ETHERNET_CFI_MASK (0x1<<12) 66 #define ETHERNET_CFI_OFFSET (12) 67 #define ETHERNET_PRIORITY_MASK (0x7<<13) 68 #define ETHERNET_PRIORITY_OFFSET (13) 69 70 #define VLAN_TAGGED_FRAME_ETH_TYPE 0x8100 71 72 #define ATOMIC_MOVE_MAC 1 73 /******************************************************************************* 74 * Forward definition. 75 ******************************************************************************/ 76 77 /* Main device structure. */ 78 /* typedef struct _lm_device_t lm_device_t; */ 79 struct _lm_device_t; 80 81 /* Packet descriptor for sending/receiving packets. */ 82 /* typedef struct _lm_packet_t lm_packet_t; */ 83 struct _lm_packet_t; 84 85 86 /* Current link information */ 87 struct _lm_reported_link_params_t; 88 89 /* typedef struct _lm_dcbx_ie_local_classif_vars_t lm_dcbx_ie_local_classif_vars_t; */ 90 struct _lm_dcbx_ie_local_classif_vars_t; 91 /* structure for represnting an array of slow-path cqes */ 92 struct _sp_cqes_info; 93 94 /* LLDP structure for GET_LLDP_PARAMS */ 95 struct _b10_lldp_params_get_t; 96 97 /* DCBX structure for GET_DCBX_PARAMS */ 98 struct _b10_dcbx_params_get_t; 99 100 /* structure for B10_IOC_GET_TRANSCEIVER_DATA */ 101 struct _b10_transceiver_data_t; 102 103 /******************************************************************************* 104 * Network wake-up frame. 105 ******************************************************************************/ 106 107 #ifndef LM_NWUF_PATTERN_SIZE 108 #define LM_NWUF_PATTERN_SIZE 128 109 #endif 110 #define LM_NWUF_PATTERN_MASK_SIZE (LM_NWUF_PATTERN_SIZE/8) // (8 = sizeof(byte)) ==> 16 111 #define MAX_IGU_ATTN_ACK_TO 100 112 /* Wake-up frame pattern. */ 113 typedef struct _lm_nwuf_pattern_t 114 { 115 u32_t size; /* Mask size */ 116 u32_t pattern_size; /* Pattern size */ 117 u8_t mask [LM_NWUF_PATTERN_MASK_SIZE]; // 16 bytes --> (128 bits - each bit represents pattern byte) 118 u8_t pattern [LM_NWUF_PATTERN_SIZE]; // 128 bytes --> (1024 bits) 119 u32_t crc32 ; // crc32 on (pattern & mask) 120 } lm_nwuf_t; 121 122 123 #ifndef LM_MAX_NWUF_CNT 124 #define LM_MAX_NWUF_CNT 8 125 #endif 126 127 typedef struct _lm_nwuf_list_t 128 { 129 lm_nwuf_t nwuf_arr[LM_MAX_NWUF_CNT]; 130 u32_t cnt; 131 } lm_nwuf_list_t; 132 133 134 135 136 typedef u32_t lm_interrupt_status_t; 137 138 139 140 /******************************************************************************* 141 * Function prototypes. 142 ******************************************************************************/ 143 144 /* Description: 145 * 1. Retrieves the adapter information, such as IRQ, BAR, chip 146 * IDs, MAC address, etc. 147 * 2. Maps the BAR to system address space so hardware registers are 148 * accessible. 149 * 3. Initializes the default parameters in 'pdev'. 150 * 4. Reads user configurations. 151 * 5. Resets the transceiver. 152 * This routine calls the following mm routines: 153 * mm_map_io_base, mm_get_user_config. */ 154 lm_status_t 155 lm_get_dev_info( 156 struct _lm_device_t *pdev); 157 158 /** 159 * @Description 160 * This function is responsible for reading all the data 161 * that the driver needs before loading from the shmem. 162 * 163 * @param pdev 164 * 165 * @return lm_status_t 166 */ 167 lm_status_t 168 lm_get_shmem_info( 169 struct _lm_device_t *pdev); 170 171 /* Description: 172 * This routine is called during driver initialization. It is responsible 173 * for allocating memory resources needed by the driver for common init. 174 * This routine calls the following mm routines: 175 * mm_alloc_mem, mm_alloc_phys_mem, and mm_init_packet_desc. */ 176 lm_status_t 177 lm_alloc_resc( 178 struct _lm_device_t *pdev); 179 180 /* Description: 181 * This routine is called during driver initialization. It is responsible 182 * for initilazing memory resources needed by the driver for common init. 183 * This routine calls the following mm routines: 184 * mm_alloc_mem, mm_alloc_phys_mem, and mm_init_packet_desc. */ 185 lm_status_t 186 lm_setup_resc( 187 struct _lm_device_t *pdev); 188 189 190 lm_status_t lm_service_eq_intr(struct _lm_device_t * pdev); 191 192 typedef enum _lm_abort_op_t 193 { 194 ABORT_OP_RX_CHAIN = 1, 195 ABORT_OP_TPA_CHAIN = 2, 196 ABORT_OP_INDICATE_TX_CHAIN = 3, 197 ABORT_OP_INDICATE_RX_CHAIN = 4, 198 ABORT_OP_INDICATE_TPA_CHAIN = 5, 199 ABORT_OP_MAX = 6, 200 } lm_abort_op_t ; 201 202 /* Each log type has its own parameters |-------------------------------------------------------------------------------------------------------| */ 203 typedef enum lm_log_id { /* | MSGLOG name (msglog.mc) | (req params) | elink cb name | elink cb params| */ 204 /* | ---------------------------------|----------------|----------------------------------|----------------| */ 205 LM_LOG_ID_UNQUAL_IO_MODULE = 0, /* | MSGLOG_SFP_PLUS_UNQUAL_IO_MODULE | port, name, pn | ELINK_LOG_ID_UNQUAL_IO_MODULE | port, name, pn | */ 206 LM_LOG_ID_OVER_CURRENT = 1, /* | MSGLOG_SFP_PLUS_OVER_CURRENT | port | ELINK_LOG_ID_OVER_CURRENT | port | */ 207 LM_LOG_ID_PHY_UNINITIALIZED = 2, /* | MSGLOG_PHY_UNINITIALIZED | port | ELINK_LOG_ID_PHY_UNINITIALIZED | port | */ 208 LM_LOG_ID_NO_10G_SUPPORT = 3, /* | MSGLOG_NO_10G_SUPPORT | port | N/A | N/A | */ 209 LM_LOG_ID_FAN_FAILURE = 4, /* | MSGLOG_DELL_FAN_FAILURE | none | N/A | N/A | */ 210 LM_LOG_ID_MDIO_ACCESS_TIMEOUT = 5, /* | MSGLOG_MDIO_ACCESS_TIMEOUT | port | ELINK_LOG_ID_MDIO_ACCESS_TIMEOUT | (none) | */ 211 LM_LOG_ID_NON_10G_MODULE = 6, /* | MSGLOG_SFP_NON_10G_MODULE | port | ELINK_LOG_ID_NON_10G_MODULE | port | */ 212 /* |-------------------------------------------------------------------------------------------------------| */ 213 LM_LOG_ID_MAX = 7 /* | Invalid */ 214 } lm_log_id_t; 215 216 /* Description: 217 * This routine is responsible for stopping the hardware from running, 218 * cleaning up various request queues, aborting transmit requests, and 219 * reclaiming all the receive buffers. 220 * This routine calls the following mm routines: 221 * mm_indicate_tx, mm_free_rx_buf. */ 222 void lm_abort( IN OUT struct _lm_device_t* pdev, 223 IN const lm_abort_op_t abort_op, 224 IN const u32_t idx); 225 226 227 /* Description: 228 * The main function of this routine is to reset and initialize the 229 * hardware. Upon exit, interrupt generation is not enable; however, 230 * the hardware is ready to accept transmit requests and receive receive 231 * packets. 'lm_abort' must be called prior to calling 'lm_reset'. 232 * This routine is a wrapper for lm_reset_setup and lm_reset_run. */ 233 lm_status_t 234 lm_reset( 235 struct _lm_device_t *pdev); 236 237 /* Description: 238 * The main function of this routine is to initialize the 239 * hardware. it configues all hw blocks in several phases acording to mcp response: 240 * 1. common blocks 241 * 2. per function blocks 242 */ 243 lm_status_t 244 lm_chip_init( 245 struct _lm_device_t *pdev); 246 247 lm_resource_idx_t cid_to_resource( 248 struct _lm_device_t *pdev, u32_t cid); 249 250 void init_nig_func(struct _lm_device_t *pdev); 251 252 void init_nig_common_llh(struct _lm_device_t *pdev); 253 254 /* Description: 255 * Verify that the MCP validity bit already up 256 */ 257 lm_status_t lm_verify_validity_map( 258 struct _lm_device_t *pdev); 259 260 /* Description: 261 * Calls lm_function_start. add here other stuff to follow if any. 262 */ 263 lm_status_t 264 lm_chip_start(struct _lm_device_t *pdev); 265 266 /* Description: 267 * This routine close port or assert reset for all needed blocks 268 */ 269 void lm_chip_reset(struct _lm_device_t *pdev, lm_reason_t reason) ; 270 271 /** Description: 272 * Resets all "needed" blacks plus NIG. 273 * It's a pure reset: no locks are taken. 274 */ 275 void lm_chip_reset_with_nig(struct _lm_device_t *pdev); 276 277 /* This function reset a path (e2) or a chip (e1/e1.5) 278 * includeing or excluding the nig (b_with_nig) 279 */ 280 void lm_reset_path(struct _lm_device_t *pdev, const u8_t b_with_nig ); 281 282 /** Description: 283 * Resets MCP. Waits until MCP wakes up. 284 * 285 * This function sleeps!!! 286 * 287 * Returns: 288 * LM_STATUS_SUCCESS if MCP reset and woke up successfully, 289 * LM_STATUS_FAILURE otherwise. 290 */ 291 lm_status_t lm_reset_mcp(struct _lm_device_t *pdev); 292 293 /** 294 * 295 * @param pdev Device instance 296 * 297 * @return TRUE if MCP was detected. 298 */ 299 u8_t lm_is_mcp_detected( 300 IN struct _lm_device_t *pdev 301 ); 302 303 304 /* Description: 305 * Configures nwuf packets. 306 * Must be called before chip reset since it uses DMAE block 307 * (for wide bus) 308 */ 309 void lm_set_d3_nwuf( struct _lm_device_t* pdev, 310 const lm_wake_up_mode_t wake_up_mode ); 311 312 /* Description: 313 * Configures magic packets. 314 */ 315 void lm_set_d3_mpkt( struct _lm_device_t* pdev, 316 const lm_wake_up_mode_t wake_up_mode ); 317 318 /* Description: 319 * Sets the FLR flag 320 */ 321 void lm_fl_reset_set_inprogress(struct _lm_device_t *pdev); 322 323 /* Description: 324 * Clears the FLR flag 325 */ 326 void lm_fl_reset_clear_inprogress(struct _lm_device_t *pdev); 327 328 /* Description: 329 * Returns true when the FLR flag is set 330 */ 331 u8_t lm_fl_reset_is_inprogress(struct _lm_device_t *pdev); 332 333 /* Description: 334 * Sets the global shutdown-in-progress flag 335 */ 336 void lm_reset_set_inprogress(struct _lm_device_t *pdev); 337 338 /* Description: 339 * Clears the global shutdown-in-progress flag 340 */ 341 void lm_reset_clear_inprogress(struct _lm_device_t *pdev); 342 343 /* Description: 344 * Returns true when the global shutdown-in-progress flag is set 345 */ 346 u8_t lm_pm_reset_is_inprogress(struct _lm_device_t *pdev); 347 348 /* Description: 349 * Returns true when the global shutdown-in-progress flag is set 350 * OR FLR_PF (both PF and VF) flag is set 351 * OR FLR_VF (VF only) flag is set 352 */ 353 u8_t lm_reset_is_inprogress(struct _lm_device_t *pdev); 354 355 /* Description 356 * marks the function to be enabled after reseting nig: used for WOL 357 */ 358 void lm_set_func_en(struct _lm_device_t *pdev, const u8_t b_enable); 359 360 /* Description 361 * returns the value of function enabled. 362 */ 363 u8_t lm_get_func_en(struct _lm_device_t *pdev, const u8_t pfunc_abs); 364 365 /* Description: 366 * Masks the HW attention as part of the shutdown flow 367 */ 368 void lm_reset_mask_attn(struct _lm_device_t *pdev); 369 370 371 void lm_setup_read_mgmt_stats_ptr( struct _lm_device_t* pdev, 372 IN const u32_t func_mailbox_num, 373 OUT u32_t* fw_port_stats_ptr, 374 OUT u32_t* fw_func_stats_ptr ); 375 376 377 /* Description: 378 * Acquiring the HW lock for a specific resource. 379 * The assumption is that only 1 bit is set in the resource parameter 380 * There is a HW attention in case the same function attempts to 381 * acquire the same lock more than once 382 * 383 * Params: 384 * resource: the HW LOCK Register name 385 * b_block: Try to get lock until succesful, or backout immediately on failure. 386 * Return: 387 * Success - got the lock 388 * Fail - Invalid parameter or could not obtain the lock for over 1 sec in block mode 389 * or couldn't obtain lock one-shot in non block mode 390 */ 391 lm_status_t lm_hw_lock(struct _lm_device_t* pdev, 392 const u32_t resource, 393 const u8_t b_block); 394 /* Description: 395 * Releasing the HW lock for a specific resource. 396 * There is a HW attention in case the a function attempts to release 397 * a lock that it did not acquire 398 * Return: 399 * Success - if the parameter is valid, the assumption is that it 400 * will succeed 401 * Fail - Invalid parameter 402 */ 403 lm_status_t lm_hw_unlock(struct _lm_device_t* pdev, 404 const u32_t resource); 405 406 lm_status_t lm_hw_unlock_ex(struct _lm_device_t* pdev, 407 const u32_t resource, 408 const u8_t b_verify_locked ); 409 410 411 lm_status_t 412 lm_ncsi_fcoe_cap_to_scratchpad( struct _lm_device_t *pdev); 413 414 /** 415 * @Desription 416 * This function is used to recover from a state where the 417 * locks stayed in "taken" state during a reboot. We want 418 * to clear all the locks before proceeding. 419 * 420 * @param pdev 421 */ 422 void lm_hw_clear_all_locks(struct _lm_device_t *pdev); 423 424 /* Description: 425 * This routine post the indicate buffer or receive buffers in the 426 * free buffer pool. If 'packet' is null, all buffers in the free poll 427 * will be posted; otherwise, only the 'packet' will be posted. */ 428 u32_t 429 lm_post_buffers( 430 struct _lm_device_t *pdev, 431 u32_t chain_idx, 432 struct _lm_packet_t *packet,/* optional. */ 433 u8_t const is_tpa); 434 435 /* Description: 436 * This routine sends the given packet. Resources required to send this 437 * must have already been reserved. The upper moduel is resposible for 438 * any necessary queueing. */ 439 lm_status_t 440 lm_send_packet( 441 struct _lm_device_t *pdev, 442 u32_t chain_idx, 443 struct _lm_packet_t *packet, 444 lm_frag_list_t *frags); 445 446 /** 447 * @description 448 * Check if VLAN exist and if the VLAN exists get priority. 449 * @param pdev 450 * @param packet 451 * 452 * @return u32_t 453 */ 454 u8_t 455 lm_get_pri_from_send_packet_param( 456 struct _lm_device_t *pdev, 457 struct _lm_packet_t *packet); 458 /* Description: 459 * This routine sends the given cmd. Resources required to send this 460 * must have already been reserved. The upper moduel is resposible for 461 * any necessary queueing. */ 462 lm_status_t 463 lm_send_sq_cmd( 464 struct _lm_device_t *pdev, 465 u32_t cid, 466 u8_t cmd_id); 467 468 /* Description: 469 * This routine completes the cmd. it should safely increment the number 470 * of pending comands and send the next commnad if any 471 */ 472 lm_status_t 473 lm_complete_sq_cmd( 474 struct _lm_device_t *pdev, 475 u32_t cid, 476 u8_t cmd_id); 477 478 479 /* Description: 480 * This routine sends ring pending commands. it should be safely increment the number 481 * of pending comands and send the next commnad if any 482 */ 483 lm_status_t 484 lm_enlist_sq_cmd( 485 struct _lm_device_t *pdev 486 ); 487 488 /* Description: 489 * This routine is called to get all pending interrupts. */ 490 lm_interrupt_status_t 491 lm_get_interrupt_status( 492 struct _lm_device_t *pdev); 493 494 /* Description: 495 * Replacement function for lm_get_interrupt_status for dedicated IGU tests */ 496 u64_t 497 lm_igutest_get_isr64(struct _lm_device_t *pdev); 498 u64_t 499 lm_igutest_get_isr32(struct _lm_device_t *pdev); 500 501 /* Description: 502 * This routine is called to get all pending interrupts. */ 503 lm_interrupt_status_t 504 lm_get_interrupt_status_wo_mask( 505 struct _lm_device_t *pdev); 506 507 /* Description: 508 * This routine is called to get all pending interrupts for ediag dummy interrupt. */ 509 lm_interrupt_status_t 510 lm_get_interrupt_status_and_mask( 511 struct _lm_device_t *pdev); 512 513 514 u32_t 515 lm_get_packets_rcvd( 516 struct _lm_device_t *pdev, 517 u32_t const chain_idx, 518 s_list_t *rcvd_list, 519 struct _sp_cqes_info *sp_cqes); 520 521 lm_status_t 522 lm_complete_ramrods( 523 struct _lm_device_t *pdev, 524 struct _sp_cqes_info *sp_cqes); 525 526 u32_t 527 lm_get_packets_sent( 528 struct _lm_device_t *pdev, 529 u32_t chain_idx, 530 s_list_t *sent_list); 531 532 533 /* Description: 534 * This routine is called to mask out interrupt from the hardware. */ 535 void lm_disable_int(struct _lm_device_t *pdev); 536 537 /* Description: 538 * This routine is called to enable interrupt generation. */ 539 void lm_enable_int(struct _lm_device_t *pdev); 540 541 /** 542 * @Description: This routine is called to set the receive 543 * filter. drop unicast/multicast/broadcast for a fast-path 544 * chain-idx 545 * 546 * @param pdev 547 * @param chain_idx - which chain to set the filtering on 548 * @param rx_mask - the rx mask information 549 * @param cookie - will be returned when indicating to "mm" that 550 * the operation completed. 551 * 552 * @return lm_status_t - SUCCESS (if completed synchrounously) 553 * PENDING (if completion will arrive 554 * asynchrounously) 555 * FAILURE o/w 556 */ 557 lm_status_t lm_set_rx_mask(struct _lm_device_t *pdev, u8_t chain_idx, lm_rx_mask_t rx_mask, void * cookie); 558 559 /** 560 * @Description: This function waits for the rx mask to complete 561 * 562 * @param pdev 563 * @param chain_idx- which chain to wait on 564 * 565 * @return lm_status_t 566 */ 567 lm_status_t lm_wait_set_rx_mask_done(struct _lm_device_t *pdev, u8_t chain_idx); 568 569 570 /************************* MULTICAST *****************************************/ 571 572 573 /** 574 * @Description 575 * Function configures a list of multicast addresses. Or 576 * resets the list previously configured 577 * 578 * @param pdev 579 * @param mc_addrs - array of multicast addresses. NULL if unset is required 580 * @param buf_len - length of the buffer - 0 if unset is required 581 * @param cookie - will be returned on completion 582 * @param lm_cli_idx - which lm client to send request on 583 * 584 * @return lm_status_t - SUCCESS on syncrounous completion 585 * PENDING on asyncounous completion 586 * FAILURE o/w 587 */ 588 lm_status_t lm_set_mc(struct _lm_device_t *pdev, u8_t* mc_addrs, u32_t buf_len, void * cookie, lm_cli_idx_t lm_cli_idx); 589 590 lm_status_t lm_set_mc_list(struct _lm_device_t *pdev, 591 d_list_t * mc_addrs, /* may be NULL (for unset) */ 592 void * cookie, 593 lm_cli_idx_t lm_cli_idx); 594 595 /** 596 * Description 597 * This routine is called to wait for the multicast set 598 * completion. It must be called in passive level since it 599 * may sleep 600 * @param pdev 601 * @param lm_cli_idx the cli-idx that the multicast was sent on. 602 * 603 * @return lm_status SUCCESS on done, TIMEOUT o/w 604 */ 605 lm_status_t lm_wait_set_mc_done(struct _lm_device_t *pdev, lm_cli_idx_t lm_cli_idx); 606 607 608 lm_status_t lm_eth_wait_state_change(struct _lm_device_t *pdev, u32_t new_state, u32_t cid); 609 610 611 /** 612 * Set/Unset a mac-address or mac-vlan pair on a given chain. 613 * 614 * @param pdev 615 * @param mac_addr - array of size ETHERNET_ADDRESS_SIZE 616 * containing a valid mac addresses 617 * @param vlan_tag - vlan tag to be set with mac address 618 * @param chain_idx - which chain to set the mac on. Chain_idx 619 * will be transformed to a l2 client-id 620 * @param cookie - will be returned to MM layer on completion 621 * @param set - set or remove mac address 622 * @param is_encap_inner_mac_filter - set if we filter according 623 * to inner mac (VMQ offload of 624 * encapsulated packets) 625 * 626 * @return lm_status_t SUCCESS on syncrounous success, PENDING 627 * if completion will be called later, FAILURE o/w 628 */ 629 lm_status_t lm_set_mac_addr(struct _lm_device_t *pdev, u8_t *mac_addr, u16_t vlan_tag, u8_t chain_idx, void * cookie, const u8_t b_set, u8_t is_encap_inner_mac_filter); 630 631 /** 632 * Set/Unset a vlan on a given chain. 633 * Setting/unsetting a vlan is a bit more complex than 634 * setting a mac address and is therefore implemented in a 635 * separate function. It require deleting a previous vlan 636 * tag if one was set, and changing rx-filtering rules. The 637 * change in rx-filtering rules has to do with "any-vlan". 638 * If no vlan is set we want "any-vlan" otherwise we want 639 * to remove the any-vlan, this requires another ramrod. 640 * The way this is implemented is as follows: 641 * 1. prepare vlan add/remove commands without 642 * executing them (sp-verbs feature don't send EXEC) 643 * 2. If need to set rx-mask, turn on a flag that will 644 * be checked on completion of rx-mask, in 645 * lm_eq_handle_rx_filter.., we look at this flag and 646 * if it's on execute the vlan pending command 647 * (sp-verbs CONT feature). 648 * 649 * @param pdev 650 * @param vlan_tag - vlan tag to be set 651 * @param chain_idx - which chain to set the vlan on. Chain_idx 652 * will be transformed to a l2 client-id 653 * @param cookie - will be returned to MM layer on completion 654 * @param set - set or remove vlan 655 * 656 * @return lm_status_t SUCCESS on syncrounous success, PENDING 657 * if completion will be called later, FAILURE o/w 658 */ 659 lm_status_t lm_set_vlan_only(struct _lm_device_t *pdev, u16_t vlan_tag, u8_t chain_idx, void * cookie, const u8_t b_set); 660 661 /** 662 * Move a filter from one chain idx to another atomically 663 * 664 * @param pdev 665 * 666 * @param mac_addr - array of size ETHERNET_ADDRESS_SIZE 667 * containing a valid mac addresses 668 * @param vlan_tag - vlan tag to be set with mac address 669 * @param src_chain_idx - which chain to remove the mac from 670 * @param dest_chain_idx - which chain to set the mac on 671 * @param cookie - will be returned to MM layer on completion 672 * 673 * @return lm_status_t 674 */ 675 lm_status_t lm_move_mac_addr(struct _lm_device_t *pdev, u8_t *mac_addr, u16_t vlan_tag, 676 u8_t src_chain_idx, u8_t dest_chain_idx, void * cookie, u8_t is_encap_inner_mac_filter); 677 678 /** 679 * @Description 680 * Waits for the last set-mac called to complete 681 * @param pdev 682 * @param chain_idx - the same chain-idx that the set-mac was 683 * called on 684 * 685 * @return lm_status_t SUCCESS or TIMEOUT 686 */ 687 lm_status_t lm_wait_set_mac_done(struct _lm_device_t *pdev, u8_t chain_idx); 688 689 690 /** 691 * @Description 692 * Waits for the last set-vlan called to complete 693 * @param pdev 694 * @param chain_idx - the same chain-idx that the set-vlan was 695 * called on 696 * 697 * @return lm_status_t SUCCESS or TIMEOUT 698 */ 699 lm_status_t lm_wait_set_vlan_done(struct _lm_device_t *pdev, u8_t chain_idx); 700 701 /* Description: 702 * Clears all the mac address that are set on a certain cid... 703 */ 704 lm_status_t lm_clear_all_mac_addr(struct _lm_device_t *pdev, const u8_t chain_idx); 705 706 /** 707 * Description 708 * Restores all the mac address that are set on a certain 709 * cid (after sleep / hibernate...) 710 * @param pdev 711 * @param chain_idx - which chain_idx to clear macs on... 712 * 713 * @assumptions: Called in PASSIVE_LEVEL!! function sleeps... 714 * @return lm_status_t 715 */ 716 lm_status_t lm_restore_all_mac_addr(struct _lm_device_t *pdev, u8_t chain_idx); 717 718 /**insert_nig_entry 719 * Reference an entry for a given MAC address. If this is the 720 * first reference, add it to the NIG, otherwise increase its 721 * refcount. 722 * 723 * @param pdev 724 * @param addr the MAC address 725 * 726 * @return lm_status_t LM_STATUS_SUCCESS on success, 727 * LM_STATUS_RESOURCE if no more NIG entries are 728 * available, other failure codes on other errors. 729 */ 730 lm_status_t lm_insert_nig_entry( struct _lm_device_t *pdev, 731 u8_t *addr); 732 733 734 /**remove_nig_entry 735 * Dereference the entry for a given MAC address. If this was 736 * the last reference the MAC address is removed from the NIG. 737 * 738 * @param pdev 739 * @param addr the MAC address 740 * 741 * @return lm_status_t LM_STATUS_SUCCESS on success, 742 * LM_STATUS_FAILURE if the given MAC is not in the NIG, 743 * other failure codes on other errors. 744 */ 745 lm_status_t lm_remove_nig_entry( struct _lm_device_t *pdev, 746 u8_t *addr); 747 748 lm_status_t lm_set_mac_in_nig(struct _lm_device_t * pdev, u8_t * mac_addr, lm_cli_idx_t lm_cli_idx, u8_t offset); 749 750 751 /************************* RSS *****************************************/ 752 /** 753 * @Description 754 * Enable RSS for Eth with given indirection table also updates the rss key 755 756 * @param pdev 757 * @param chain_indirection_table - array of size @table_size containing chain numbers 758 * @param table_size - size of @indirection_table 759 * @param hash_key - new hash_key to be configured. 0 means no key 760 * @param key_size 761 * @param hash_type 762 * @param sync_with_toe - This field indicates that the completion to the mm layer 763 * should take into account the fact that toe rss update will 764 * be sent as well. A counter will be increased in lm for this purpose 765 * @param cookie - will be returned on completion 766 * 767 * @return lm_status_t - SUCCESS on syncrounous completion 768 * PENDING on asyncounous completion 769 * FAILURE o/w 770 */ 771 lm_status_t lm_enable_rss(struct _lm_device_t *pdev, u8_t *chain_indirection_table, 772 u32_t table_size, u8_t *hash_key, u32_t key_size, lm_rss_hash_t hash_type, 773 u8 sync_with_toe, void * cookie); 774 775 /** 776 * @Description 777 * This routine disables rss functionality by sending a 778 * ramrod to FW. 779 * 780 * @param pdev 781 * @param cookie - will be returned on completion 782 * @param sync_with_toe - true means this call is synced with 783 * toe, and completion will be called only 784 * when both toe + eth complete. Eth needs 785 * to know this (reason in code) 786 * 787 * @return lm_status_t - SUCCESS on syncrounous completion 788 * PENDING on asyncounous completion 789 * FAILURE o/w 790 */ 791 lm_status_t lm_disable_rss(struct _lm_device_t *pdev, u8_t sync_with_toe, void * cookie); 792 793 /** 794 * @Description 795 * Wait for the rss disable/enable configuration to 796 * complete 797 * 798 * @param pdev 799 * 800 * @return lm_status_t lm_status_t SUCCESS or TIMEOUT 801 */ 802 lm_status_t lm_wait_config_rss_done(struct _lm_device_t *pdev); 803 804 /** 805 * @description 806 * Configure cmng the firmware to the right CMNG values if this 807 * device is the PMF ,after link speed/ETS changes. 808 * 809 * @note This function must be called under PHY_LOCK 810 * @param pdev 811 */ 812 void lm_cmng_update(struct _lm_device_t *pdev); 813 /************************* NIV *****************************************/ 814 815 /**lm_niv_set_loopback_mode 816 * Configure the FW to loopback mode - Tx packets will have the VN tag 817 * of Rx packets so that they will not be dropped by the Rx path. 818 * Note that once this function enables VN-Tag loopback mode the traffic that 819 * leaves the NIG is not valid VN-Tag traffic - don't use it unless MAC/PHY/external 820 * loopback is configured. 821 * 822 * @param pdev 823 * @param b_enable TRUE if loopback mode should be enabled, false otherwise. 824 */ 825 lm_status_t lm_niv_set_loopback_mode(struct _lm_device_t *pdev, IN const u8_t b_enable); 826 827 828 /**lm_niv_event 829 * handle a NIV-related MCP general attention by scheduling the 830 * appropriate work item. 831 * 832 * @param pdev the device to use 833 * @param niv_event the DRIVER_STATUS flags that the MCP sent. 834 * It's assumed that only NIV-related flags are 835 * set. 836 * 837 * @return lm_status_t LM_STATUS_SUCCESS on success, some other 838 * failure code on failure. 839 */ 840 lm_status_t lm_niv_event(struct _lm_device_t *pdev, const u32_t niv_event); 841 842 /**lm_niv_post_command 843 * Post a NIV ramrod and wait for its completion. 844 * 845 * 846 * @param pdev the device 847 * @param command the ramrod cmd_id (NONE_CONNECTION_TYPE is 848 * assumed) 849 * @param data the ramrod data 850 * @param initial_state the type of the NIV command (one of the 851 * NIV_RAMROD_???_POSTED values) 852 * 853 * @return lm_status_t LM_STATUS_SUCCESS on success, some other 854 * failure code on failure. 855 */ 856 lm_status_t lm_niv_post_command(struct _lm_device_t *pdev, 857 IN const u8_t command, 858 IN const u64_t data, 859 IN const u32_t initial_state); 860 861 /**lm_niv_vif_update 862 * Send a VIF function update ramrod and wait for its completion. 863 * 864 * 865 * @param pdev the device 866 * @param vif_id the new VIF ID for this function 867 * @param default_vlan the new default VLAN for this function 868 * @param allowed_priorities the new allowed priorities for this function 869 * 870 * @return lm_status_t LM_STATUS_SUCCESS on success, some other failure code on failure. 871 */ 872 lm_status_t lm_niv_vif_update(struct _lm_device_t *pdev, 873 IN const u16_t vif_id, 874 IN const u16_t default_vlan, 875 IN const u8_t allowed_priorities); 876 877 /**lm_niv_vif_list_update 878 * Send a VIF lists ramrod and wait for its completion. 879 * 880 * 881 * @param pdev the device 882 * @param command the operation to perform. @see 883 * vif_list_rule_kind 884 * @param list_index the list to set/get (used in LIST_GET and 885 * LIST_SET commands) 886 * @param func_bit_map the new bitmap for the list (used in 887 * LIST_SET) 888 * @param func_to_clear the function to remove from all lists 889 * (used in CLEAR_FUNC) 890 * 891 * @return lm_status_t LM_STATUS_SUCCESS on success, some other 892 * failure code on failure. 893 */ 894 lm_status_t lm_niv_vif_list_update(struct _lm_device_t* pdev, 895 IN const enum vif_list_rule_kind opcode, 896 IN const u16_t list_index, 897 IN const u8_t func_bit_map, 898 IN const u8_t func_to_clear); 899 900 901 /**lm_get_shmem_mf_cfg_info_niv 902 * Refresh NIV-related MF HW info from SHMEM. 903 * 904 * @param pdev the device to use 905 * 906 * @return lm_status_t LM_STATUS_SUCCESS on success, some other 907 * failure code on failure. 908 */ 909 lm_status_t lm_get_shmem_mf_cfg_info_niv(struct _lm_device_t *pdev); 910 911 /** 912 * @brief Update mf configuration from SHMEM 913 * 914 * @param pdev the device to use 915 * 916 * @return lm_status_t LM_STATUS_SUCCESS on success, some other 917 * failure code on failure. 918 */ 919 920 lm_status_t lm_get_shmem_mf_cfg_info(struct _lm_device_t *pdev); 921 922 923 #define LM_SET_CAM_NO_VLAN_FILTER 0xFFFF 924 925 #define PHY_HW_LOCK(pdev) lm_hw_lock(pdev, HW_LOCK_RESOURCE_MDIO, TRUE); 926 927 #define PHY_HW_UNLOCK(pdev) lm_hw_unlock(pdev, HW_LOCK_RESOURCE_MDIO); 928 929 /* Description: 930 * This routine is called to retrieve statistics. */ 931 932 struct _lm_vf_info_t; 933 lm_status_t 934 lm_get_stats( 935 struct _lm_device_t *pdev, 936 lm_stats_t stats_type, 937 u64_t *stats_cnt 938 #ifdef VF_INVOLVED 939 ,struct _lm_vf_info_t * vf_info 940 #endif 941 ); 942 943 944 void lm_stats_reset( struct _lm_device_t* pdev) ; 945 946 /* Description: 947 * This routine is called to add a wake-up pattern to the main list that 948 * contains all the wake-up frame. */ 949 lm_status_t 950 lm_add_nwuf( 951 struct _lm_device_t *pdev, 952 u32_t byte_mask_size, 953 u8_t *byte_mask, 954 u8_t *byte_pattern); 955 956 /* Description: 957 * This routine is called to remove the wake-up pattern from the main list 958 * that contains all the wake-up frame. */ 959 lm_status_t 960 lm_del_nwuf( 961 struct _lm_device_t *pdev, 962 u32_t byte_mask_size, 963 u8_t *byte_mask, 964 u8_t *byte_pattern); 965 966 /* Description: 967 * Delete all the NWUF entries. */ 968 void 969 lm_clear_nwuf( 970 struct _lm_device_t *pdev); 971 972 973 /**lm_save_hw_state_for_d3 974 * Save whatever HW state is needed before the device goes to 975 * D3, so that it can be restored when returning to D0 by 976 * lm_pcie_state_restore_for_d0 977 * 978 * 979 * @param pdev the device to use. 980 */ 981 void lm_pcie_state_save_for_d3(struct _lm_device_t *pdev); 982 983 /**lm_save_hw_state_for_d3 984 * Restore whatever HW state was saved by 985 * lm_pcie_state_save_for_d3 before the device's power state was 986 * changed to D3. 987 * 988 * @param pdev the device to use. 989 */ 990 void lm_pcie_state_restore_for_d0(struct _lm_device_t *pdev); 991 992 /* Description: 993 * This routine is called to set up the device power state. */ 994 void 995 lm_set_power_state( 996 struct _lm_device_t *pdev, 997 lm_power_state_t power_state, 998 lm_wake_up_mode_t wake_up_mode, /* Valid when power_state is D3. */ 999 u8_t set_pci_pm); 1000 1001 lm_status_t lm_check_phy_link_params(struct _lm_device_t *pdev, lm_medium_t req_medium); 1002 1003 /* Description: 1004 * This routine is called to initialize the PHY based one 'media_type' 1005 * setting. 'wait_for_link_timeout' specifies how long to poll for 1006 * link before returning. */ 1007 lm_status_t 1008 lm_init_phy( 1009 struct _lm_device_t *pdev, 1010 lm_medium_t req_medium, 1011 lm_flow_control_t flow_control, 1012 u32_t selective_autoneg, 1013 u32_t wire_speed, 1014 u32_t wait_for_link_timeout); 1015 1016 lm_status_t 1017 lm_link_update(struct _lm_device_t *pdev); 1018 1019 u32_t lm_get_speed_real_from_elink_line_speed( IN const struct elink_vars* link_vars ); 1020 u32_t lm_get_speed_medium_from_elink_line_speed( IN const struct elink_vars* link_vars ); 1021 1022 lm_medium_t lm_loopback_req_medium_convert( IN struct _lm_device_t *pdev, IN const lm_medium_t req_medium ); 1023 1024 /**lm_get_port_max_speed 1025 * 1026 * @param pdev the device to check 1027 * 1028 * @return u32_t the maximum speed (in Mbps) the physical port 1029 * that pdev is on is capable of. This may be different 1030 * than the current medium's speed. 1031 */ 1032 u32_t lm_get_port_max_speed(IN struct _lm_device_t *pdev); 1033 1034 /** 1035 * @Description 1036 * This function is called periodically, every time the link 1037 * timer expires, it's main purpose is to call elink under 1038 * appropriate locks to perform any periodic tasks 1039 * @param pdev 1040 * 1041 * @return lm_status_t 1042 */ 1043 lm_status_t 1044 lm_link_on_timer(struct _lm_device_t *pdev); 1045 1046 /* Description: 1047 * This routine is called to report link to the OS and sync 1048 * Statistic gathering. 1049 */ 1050 void 1051 lm_link_report(struct _lm_device_t *pdev); 1052 1053 /* Description: 1054 * Fills struct from type _lm_reported_link_params_t with 1055 * current link information 1056 */ 1057 void lm_link_fill_reported_data( IN struct _lm_device_t *pdev, 1058 OUT struct _lm_reported_link_params_t *lm_reported_link_params ); 1059 1060 /* Description: 1061 * This routine is called to get the external phy fw version 1062 * will return zero in case no external phy or failure type 1063 */ 1064 lm_status_t 1065 lm_get_external_phy_fw_version( 1066 struct _lm_device_t *pdev, 1067 u8_t * version, 1068 u8_t len ); 1069 1070 /* Description: 1071 * This routine is called to update ext phy fw 1072 */ 1073 lm_status_t 1074 lm_update_external_phy_fw( 1075 struct _lm_device_t *pdev, 1076 u32_t offset, 1077 u8_t * data, 1078 u32_t size); 1079 1080 /* Description: 1081 * This routine is called before update ext phy fw file 1082 */ 1083 lm_status_t 1084 lm_update_external_phy_fw_prepare( struct _lm_device_t *pdev ); 1085 1086 /* Description: 1087 * This routine is called after update ext phy fw file 1088 */ 1089 lm_status_t 1090 lm_update_external_phy_fw_reinit( struct _lm_device_t *pdev ); 1091 1092 /* Description: 1093 * This routine is called after update ext phy fw file 1094 */ 1095 lm_status_t 1096 lm_update_external_phy_fw_done( struct _lm_device_t *pdev ); 1097 1098 /* Description: 1099 * This routine check if there is a fan failure in board 1100 * in case there is - event log will be sent 1101 */ 1102 void lm_check_fan_failure(struct _lm_device_t *pdev); 1103 1104 /* Description: 1105 * Checks if all the HW is in idle state 1106 * Returned Value 1107 * Number of errors (not idle items) */ 1108 /* Description: 1109 * Sends keepalive to mcp 1110 */ 1111 lm_status_t lm_send_driver_pulse( struct _lm_device_t *pdev ); 1112 1113 /* Description: 1114 * Set driver pulse to MCP to always alive 1115 */ 1116 void lm_driver_pulse_always_alive(struct _lm_device_t *pdev); 1117 1118 /* Description: 1119 * stop any dma transactions to/from chip and verify no pending requests 1120 */ 1121 void lm_disable_pci_dma(struct _lm_device_t *pdev, u8_t b_wait_for_done); 1122 1123 /* Description: 1124 * enable dma transactions to/from chip 1125 */ 1126 void lm_enable_pci_dma(struct _lm_device_t *pdev); 1127 1128 /* Description: 1129 * Disables all the attention 1130 */ 1131 void disable_blocks_attention(struct _lm_device_t *pdev); 1132 1133 1134 // This code section is for WinDbg Extension (b10kd) 1135 #if !defined(_B10KD_EXT) 1136 u32_t lm_idle_chk( struct _lm_device_t *pdev); 1137 lm_status_t lm_get_storms_assert( struct _lm_device_t *pdev ); 1138 #endif // (_B10KD_EXT) 1139 1140 void lm_collect_idle_storms_dorrbell_asserts( struct _lm_device_t *pdev, 1141 const u8_t b_idle_chk, 1142 const u8_t b_storms_asserts, 1143 const u8_t b_dorrbell_info ); 1144 1145 /* Description: 1146 * cmng interface 1147 */ 1148 void lm_cmng_calc_params( struct _lm_device_t *pdev ); 1149 void lm_cmng_get_shmem_info( struct _lm_device_t *pdev ); 1150 1151 lm_status_t 1152 lm_get_doorbell_info( 1153 struct _lm_device_t *pdev); 1154 1155 lm_status_t 1156 lm_gpio_read(struct _lm_device_t *pdev, u32_t pin_num, u32_t* value_ptr, u8_t port); 1157 1158 lm_status_t 1159 lm_gpio_write(struct _lm_device_t *pdev, u32_t pin_num, u32_t value, u8_t port); 1160 1161 lm_status_t 1162 lm_gpio_mult_write(struct _lm_device_t *pdev, u8_t pins, u32_t value); 1163 1164 lm_status_t 1165 lm_gpio_int_write(struct _lm_device_t *pdev, u32_t pin_num, u32_t value, u8_t port); 1166 1167 lm_status_t 1168 lm_spio_read(struct _lm_device_t *pdev, u32_t pin_num, u32_t* value_ptr); 1169 1170 lm_status_t 1171 lm_spio_write(struct _lm_device_t *pdev, u32_t pin_num, u32_t value); 1172 1173 lm_status_t 1174 lm_set_led_mode(struct _lm_device_t *pdev, u32_t port_idx, u32_t mode_idx); 1175 1176 lm_status_t 1177 lm_get_led_mode(struct _lm_device_t *pdev, u32_t port_idx, u32_t* mode_idx_ptr); 1178 1179 lm_status_t 1180 lm_override_led_value(struct _lm_device_t *pdev, u32_t port_idx, u32_t led_idx, u32_t value); 1181 1182 lm_status_t 1183 lm_blink_traffic_led(struct _lm_device_t *pdev, u32_t port_idx, u32_t rate); 1184 1185 lm_status_t 1186 lm_get_led_status(struct _lm_device_t *pdev, u32_t port_idx, u32_t led_idx, u32_t* value_ptr); 1187 1188 void 1189 lm_set_led(struct _lm_device_t *pdev, lm_medium_t speed); 1190 1191 void 1192 lm_reset_led(struct _lm_device_t *pdev); 1193 1194 void 1195 lm_return_packet_bytes( struct _lm_device_t *pdev, 1196 u32_t const qidx, 1197 u32_t const returned_bytes); 1198 1199 void 1200 lm_reg_rd_blk( 1201 struct _lm_device_t *pdev, 1202 u32_t reg_offset, 1203 u32_t *buf_ptr, 1204 u32_t u32t_cnt); 1205 1206 void 1207 lm_reg_rd_blk_ind( 1208 struct _lm_device_t *pdev, 1209 u32_t reg_offset, 1210 u32_t *buf_ptr, 1211 u32_t u32t_cnt, 1212 u8_t acquire_lock_flag); 1213 1214 void 1215 lm_reg_wr_blk( 1216 struct _lm_device_t *pdev, 1217 u32_t reg_offset, 1218 u32_t *data_ptr, 1219 u32_t u32t_cnt); 1220 1221 void 1222 lm_reg_wr_blk_ind( 1223 struct _lm_device_t *pdev, 1224 u32_t reg_offset, 1225 u32_t *data_ptr, 1226 u32_t u32t_cnt); 1227 1228 lm_status_t 1229 lm_get_ibft_physical_addr_for_efi( 1230 struct _lm_device_t *pdev, 1231 u32_t *phy_hi, 1232 u32_t *phy_lo); 1233 1234 lm_status_t lm_get_iscsi_boot_info_block( struct _lm_device_t *pdev, struct _iscsi_info_block_hdr_t* iscsi_info_block_hdr_ptr ); 1235 1236 typedef enum { 1237 lm_mcp_mb_header, 1238 lm_mcp_mb_param, 1239 lm_mcp_mb_pulse 1240 } lm_mcp_mb_type; 1241 1242 #define MCP_CMD_DEFAULT_TIMEOUT 0x0 1243 1244 // lm_mcp_cmd functions 1245 lm_status_t lm_mcp_cmd_init( struct _lm_device_t *pdev) ; 1246 lm_status_t lm_mcp_cmd_send( struct _lm_device_t *pdev, lm_mcp_mb_type mcp_mb_type, u32_t drv_msg, u32_t param) ; 1247 lm_status_t lm_mcp_cmd_response( struct _lm_device_t *pdev, 1248 lm_mcp_mb_type mcp_mb_type, 1249 u32_t drv_msg, 1250 u32_t timeout, 1251 OUT u32_t* p_fw_resp ); 1252 1253 /**Perform a send/receive transaction with the MCP. This 1254 * function is guarenteed to be atomic against all other calls 1255 * to lm_mcp_cmd_send_recieve. 1256 * 1257 * @param pdev the LM device 1258 * @param mcp_mb_type 1259 * @param drv_msg the opcode to send to the MCP 1260 * @param param the parameter to send 1261 * @param timeout 1262 * @param p_fw_resp the response from the MCP 1263 * 1264 * @return lm_status_t LM_STATUS_SUCCESS on success, some other 1265 * value on failure. 1266 */ 1267 lm_status_t lm_mcp_cmd_send_recieve( struct _lm_device_t* pdev, 1268 lm_mcp_mb_type mcp_mb_type, 1269 u32_t drv_msg, 1270 u32_t param, 1271 u32_t timeout, 1272 OUT u32_t* p_fw_resp); 1273 1274 /**Perform a send/receive transaction with the MCP, with no 1275 * atomicity guarentee. Only call this function when you know no 1276 * other context may initiate an MCP transaction (e.g from the 1277 * load/unload flow). 1278 * 1279 * @param pdev the LM device 1280 * @param mcp_mb_type 1281 * @param drv_msg the opcode to send to the MCP 1282 * @param param the parameter to send 1283 * @param timeout 1284 * @param p_fw_resp the response from the MCP 1285 * 1286 * @return lm_status_t LM_STATUS_SUCCESS on success, some other 1287 * value on failure. 1288 */ 1289 lm_status_t lm_mcp_cmd_send_recieve_non_atomic( struct _lm_device_t *pdev, 1290 lm_mcp_mb_type mcp_mb_type, 1291 u32_t drv_msg, 1292 u32_t param, 1293 u32_t timeout, 1294 OUT u32_t* p_fw_resp ); 1295 1296 u32_t lm_mcp_check( struct _lm_device_t *pdev); 1297 1298 /**lm_mcp_set_mf_bw 1299 * Set the bandwidth parameters of this function through the MCP 1300 * opcode DRV_MSG_CODE_SET_MF_BW. 1301 * 1302 * 1303 * @param pdev the LM device 1304 * @param min_bw the minimum bandwidth for this function 1305 * @param max_bw the maximum bandwidth for this function 1306 * 1307 * @return lm_status_t LM_STATUS_SUCCESS on success, 1308 * LM_STATUS_INVALID_PARAMETER if the bootcode version 1309 * is not new enough or the device is not in 1310 * multifunction mode. 1311 */ 1312 lm_status_t lm_mcp_set_mf_bw(struct _lm_device_t *pdev, IN u8_t min_bw, IN u8_t max_bw); 1313 1314 /**lm_mcp_indicate_client_bind 1315 * Update the SHMEM as needed when a client binds. 1316 * 1317 * @param pdev the LM device 1318 * @param cli_id the client that was bound. 1319 */ 1320 void lm_mcp_indicate_client_bind(struct _lm_device_t *pdev, lm_cli_idx_t cli_id); 1321 1322 /**lm_mcp_indicate_client_unbind 1323 * Update the SHMEM as needed when a client unbinds. 1324 * 1325 * 1326 * @param pdev the LM device 1327 * @param cli_id the client that was unbound. 1328 */ 1329 void lm_mcp_indicate_client_unbind(struct _lm_device_t *pdev, lm_cli_idx_t cli_id); 1330 1331 // lm_lodaer interface 1332 1333 typedef enum { 1334 LM_LOADER_OPCODE_LOAD = 0x10, 1335 LM_LOADER_OPCODE_UNLOAD_WOL_EN = 0x11, 1336 LM_LOADER_OPCODE_UNLOAD_WOL_DIS = 0x12, 1337 LM_LOADER_OPCODE_UNLOAD_WOL_MCP = 0x13 1338 } lm_loader_opcode; 1339 1340 #define LM_LOADER_OPCODE_UNLOAD_SUSPEND 0x80 1341 #define LM_LOADER_OPCODE_MASK 0x7F 1342 1343 typedef enum { 1344 LM_LOADER_RESPONSE_LOAD_COMMON = 0x100, 1345 LM_LOADER_RESPONSE_LOAD_PORT = 0x101, 1346 LM_LOADER_RESPONSE_LOAD_FUNCTION = 0x102, 1347 LM_LOADER_RESPONSE_LOAD_DONE = 0x103, 1348 LM_LOADER_RESPONSE_UNLOAD_COMMON = 0x104, 1349 LM_LOADER_RESPONSE_UNLOAD_PORT = 0x105, 1350 LM_LOADER_RESPONSE_UNLOAD_FUNCTION = 0x106, 1351 LM_LOADER_RESPONSE_UNLOAD_DONE = 0x107, 1352 LM_LOADER_RESPONSE_LOAD_COMMON_CHIP = 0x108, 1353 LM_LOADER_RESPONSE_INVALID = -1 1354 } lm_loader_response; 1355 1356 // lm_loader functions 1357 lm_loader_response lm_loader_lock( struct _lm_device_t *pdev, lm_loader_opcode opcode ) ; 1358 lm_loader_response lm_loader_unlock( struct _lm_device_t *pdev, lm_loader_opcode opcode, OPTIONAL const u32_t* IN p_param ); 1359 void lm_loader_reset ( struct _lm_device_t *pdev ); 1360 1361 /* Get limit function[s]*/ 1362 u32_t lm_get_max_supported_toe_cons(struct _lm_device_t *pdev); 1363 u8_t lm_get_toe_rss_possibility(struct _lm_device_t *pdev); 1364 1365 /** 1366 * Returns TRUE is device is not ASIC. May be called even when 1367 * device is not in D0 power state. 1368 * 1369 * @param pdev Device handle 1370 * 1371 * @return 0 if device is ASIC. 1372 */ 1373 int lm_chip_is_slow(struct _lm_device_t *pdev); 1374 1375 /* 1376 * returns the first MSI-X message for the given function 1377 */ 1378 u8_t lm_get_base_msix_msg(struct _lm_device_t *pdev); 1379 1380 /* 1381 * returns the first MSI-X message for the given function 1382 */ 1383 u8_t lm_get_base_msix_msg(struct _lm_device_t *pdev); 1384 1385 1386 /* 1387 * returns the number of msix messages for the given function 1388 */ 1389 u8_t lm_get_num_fp_msix_messages(struct _lm_device_t *pdev); 1390 1391 /** 1392 * Set/Get IGU test mode 1393 */ 1394 void lm_set_igu_tmode(struct _lm_device_t *pdev, u8_t tmode); 1395 u8_t lm_get_igu_tmode(struct _lm_device_t *pdev); 1396 1397 /** 1398 * Set/Get interrupt mode. 1399 */ 1400 void lm_set_interrupt_mode(struct _lm_device_t *pdev, u32_t mode); 1401 u32_t lm_get_interrupt_mode(struct _lm_device_t *pdev); 1402 1403 1404 /* 1405 * Check if, pdev has sp-vector i.e. pf / vf... 1406 */ 1407 u8_t lm_has_sp_msix_vector(struct _lm_device_t *pdev); 1408 1409 1410 u8_t lm_is_function_after_flr(struct _lm_device_t * pdev); 1411 lm_status_t lm_cleanup_after_flr(struct _lm_device_t * pdev); 1412 1413 lm_status_t 1414 lm_set_cam_params(struct _lm_device_t * pdev, 1415 u32_t mac_requestors_mask, 1416 u32_t base_offset_in_cam_table, 1417 u32_t cam_size, 1418 u32_t mma_size, 1419 u32_t mc_size); 1420 1421 void 1422 lm_dcbx_pmf_migration( 1423 IN struct _lm_device_t *pdev); 1424 /******************************************************************************* 1425 * Description: 1426 * 1427 * 1428 * Return: 1429 ******************************************************************************/ 1430 lm_status_t 1431 lm_dcbx_free_resc( 1432 IN struct _lm_device_t *pdev 1433 ); 1434 1435 /** 1436 * @description 1437 * Called to clean dcbx info after D3 1438 * @param pdev 1439 * 1440 * @return lm_status_t 1441 */ 1442 lm_status_t 1443 lm_dcbx_init_info( 1444 IN struct _lm_device_t *pdev 1445 ); 1446 /******************************************************************************* 1447 * Description: 1448 * 1449 * Return: 1450 ******************************************************************************/ 1451 void 1452 lm_dcbx_init(IN struct _lm_device_t *pdev, 1453 IN const u8_t b_only_setup); 1454 1455 void 1456 lm_dcbx_init_default_params(struct _lm_device_t *pdev); 1457 /******************************************************************************* 1458 * Description: 1459 * 1460 * Return: 1461 ******************************************************************************/ 1462 lm_status_t 1463 lm_dcbx_lldp_read_params(struct _lm_device_t * pdev, 1464 struct _b10_lldp_params_get_t * lldp_params); 1465 1466 /******************************************************************************* 1467 * Description: 1468 * 1469 * Return: 1470 ******************************************************************************/ 1471 lm_status_t 1472 lm_dcbx_read_params(struct _lm_device_t * pdev, 1473 struct _b10_dcbx_params_get_t * dcbx_params); 1474 1475 u8_t lm_dcbx_cos_max_num( 1476 INOUT const struct _lm_device_t * pdev); 1477 1478 lm_status_t 1479 lm_dcbx_ie_check_if_param_change( 1480 INOUT struct _lm_device_t *pdev, 1481 IN lldp_local_mib_t *p_local_mib, 1482 IN lldp_local_mib_ext_t *p_local_mib_ext, 1483 IN u8_t is_local_ets_change); 1484 1485 /** 1486 * @description 1487 * Enable indicate event to upper layer 1488 * @param pdev 1489 */ 1490 void lm_dcbx_ie_update_state( 1491 INOUT struct _lm_device_t *pdev, 1492 IN const u8_t is_en); 1493 1494 1495 lm_status_t 1496 lm_dcbx_ie_params_updated_validate( 1497 INOUT struct _lm_device_t *pdev, 1498 OUT dcb_indicate_event_params_t *dcb_params, 1499 OUT dcb_indicate_event_params_t *dcb_params_copy, 1500 IN const u8_t lm_cli_idx); 1501 1502 lm_status_t 1503 lm_dcbx_ie_runtime_params_updated( 1504 INOUT struct _lm_device_t *pdev, 1505 INOUT dcb_indicate_event_params_t *dcb_params, 1506 IN const u8_t lm_cli_idx); 1507 1508 lm_status_t 1509 lm_dcbx_ie_initialize( 1510 INOUT struct _lm_device_t *pdev, 1511 IN const u8_t lm_cli_idx); 1512 1513 void 1514 lm_dcbx_ie_deinitialize( 1515 INOUT struct _lm_device_t *pdev, 1516 IN const u8_t lm_cli_idx); 1517 1518 /** 1519 * @description 1520 * Return chain type. 1521 * @param pdev 1522 * @param chain 1523 * 1524 * @return lm_chain_type_t 1525 */ 1526 lm_chain_type_t 1527 lm_mp_get_chain_type(IN struct _lm_device_t *pdev, 1528 IN const u32_t chain); 1529 /** 1530 * @description 1531 * Get regular chain from chain. 1532 * If chain isn't a COS chain(e.g. ISCSI L2) than return 1533 * original value. 1534 * @param pdev 1535 * @param chain 1536 * 1537 * @return u32_t 1538 */ 1539 u32_t 1540 lm_mp_get_reg_chain_from_chain(IN struct _lm_device_t *pdev, 1541 IN u32_t chain); 1542 1543 1544 /** 1545 * @description 1546 * Get COS chain from regular chain. 1547 * @param pdev 1548 * @param chain 1549 * @param cos 1550 * 1551 * @return u32_t 1552 */ 1553 u8_t 1554 lm_mp_get_cos_chain_from_reg_chain( 1555 IN struct _lm_device_t *pdev, 1556 INOUT u8_t chain, 1557 INOUT const u8_t cos); 1558 1559 lm_status_t 1560 lm_get_transceiver_data(struct _lm_device_t* pdev, 1561 struct _b10_transceiver_data_t* b10_transceiver_data ); 1562 1563 lm_status_t 1564 lm_set_led_wrapper(struct _lm_device_t* pdev, 1565 const u8_t led_mode ); 1566 1567 /******************************************************************************* 1568 * Description: 1569 * Runtime changes can take more than 1 second and can't be handled 1570 * from DPC. 1571 * When the PMF detects a DCBX update it will schedule a WI that 1572 * will handle the job. 1573 * Also the function lm_dcbx_stop_HW_TX/lm_dcbx_resume_HW_TX must be 1574 * called in mutual exclusion. 1575 * lm_mcp_cmd_send_recieve must be called from default DPC, so when the 1576 * WI will finish the processing an interrupt that will be called from 1577 * The WI will cause us to enter this function again and send the Ack. 1578 * 1579 * Return: 1580 ******************************************************************************/ 1581 void 1582 lm_dcbx_event(struct _lm_device_t * pdev, 1583 u32_t drv_status); 1584 1585 /** 1586 * Function takes care of resetting everything related to the 1587 * function stage 1588 * 1589 * @param pdev 1590 * @param cleanup - this indicates whether we are in the last 1591 * "Reset" function to be called, if so we need 1592 * to do some cleanups here, otherwise they'll be 1593 * done in later stages 1594 * 1595 * @return lm_status_t 1596 */ 1597 lm_status_t lm_reset_function_part(struct _lm_device_t *pdev, u8_t cleanup); 1598 1599 lm_status_t lm_reset_port_part(struct _lm_device_t *pdev); 1600 1601 lm_status_t lm_set_hc_flag(struct _lm_device_t *pdev, u8_t sb_id, u8_t idx, u8_t is_enable); 1602 1603 lm_status_t lm_set_interrupt_moderation(struct _lm_device_t *pdev, u8_t is_enable); 1604 unsigned long power2_lower_align(unsigned long n); 1605 1606 lm_status_t lm_tpa_send_ramrods(IN struct _lm_device_t *pdev, 1607 IN const u8_t chain_idx_base); 1608 1609 u8_t lm_tpa_ramrod_update_ipvx(IN struct _lm_device_t *pdev, 1610 IN const u8_t chain_idx, 1611 IN const u8_t vbd_tpa_ipvx_bit); 1612 1613 /** 1614 * @description 1615 * Send all the ramrods and wait for there return. 1616 * @param pdev 1617 * @param chain_idx_base 1618 * 1619 * @return lm_status_t 1620 * status success is returned if all the ramrods where received. 1621 * Status failure is returned if not all the ramrods were 1622 * received. 1623 */ 1624 lm_status_t 1625 lm_tpa_send_ramrods_wait( IN struct _lm_device_t *pdev, 1626 IN const u8_t chain_idx_base); 1627 1628 lm_status_t lm_setup_tpa_chain( IN struct _lm_device_t *pdev, 1629 IN u32_t const cid); 1630 1631 /** 1632 * @description 1633 * Clear TPA parameters. TPA can be disabled between NDIS bind 1634 * unbind but the RX cahin will stay used. 1635 * @param pdev 1636 * @param cid 1637 */ 1638 lm_status_t 1639 lm_tpa_chain_reset(IN struct _lm_device_t *pdev, 1640 IN u32_t const cid); 1641 1642 1643 /** 1644 * @description 1645 * Fill and send function_update_data ramrod. 1646 * @param pdev 1647 */ 1648 lm_status_t 1649 lm_encap_send_ramrod(IN struct _lm_device_t *pdev, u8_t new_encap_offload_state, void* cookie); 1650 1651 /** 1652 * @Description 1653 * Function is the callback function for completing eq 1654 * completions when no chip access exists. Part of 1655 * "complete-pending-sq" flow 1656 * @param pdev 1657 * @param pending 1658 */ 1659 void lm_eq_comp_cb(struct _lm_device_t *pdev, struct sq_pending_command * pending); 1660 1661 /** 1662 * @Description 1663 * Function is the callback function for completing eth 1664 * completions when no chip access exists. Part of 1665 * "complete-pending-sq" flow 1666 * @param pdev 1667 * @param pending 1668 */ 1669 void lm_eth_comp_cb(struct _lm_device_t *pdev, struct sq_pending_command * pending); 1670 1671 /********************************* ERROR Recovery Related *****************************/ 1672 /** 1673 * @Description 1674 * This function should be called to acquire the leader lock. the leader 1675 * lock should not be released until recovery process id done. 1676 * The leader lock is not waited for, its a non-blockinf function 1677 * 1678 * @param pdev 1679 * 1680 * @return lm_status_t SUCCESS or FAILURE 1681 */ 1682 lm_status_t lm_er_acquire_leader_lock(struct _lm_device_t * pdev); 1683 1684 /** 1685 * @Description 1686 * release the lock acquired in the previous function 1687 * @param pdev 1688 * 1689 * @return lm_status_t SUCCESS, INVALID_PARAM: if invalid input 1690 * is provided, LM_STATUS_OBJECT_NOT_FOUND if the lock 1691 * isn't taken. 1692 */ 1693 lm_status_t lm_er_release_leader_lock(struct _lm_device_t * pdev); 1694 1695 /** 1696 * @Description 1697 * Perform the error recovery leader process kill flow. 1698 * 1699 * @param pdev 1700 * 1701 * @return lm_status_t SUCCESS or FAILURE 1702 */ 1703 lm_status_t lm_er_leader_reset(struct _lm_device_t *pdev); 1704 1705 /** 1706 * @Description 1707 * This function disables close the gate functionality 1708 * should be called from the last driver that unloads 1709 * (unless recovery is in progress) 1710 * 1711 * @param pdev 1712 */ 1713 void lm_er_disable_close_the_gate(struct _lm_device_t *pdev); 1714 1715 /** 1716 * @Description 1717 * This function notifies the second engine that a 1718 * attention occured and error recovery will initiate on 1719 * second engine as well 1720 * @param pdev 1721 * 1722 * @return lm_status_t 1723 */ 1724 lm_status_t lm_er_notify_other_path(struct _lm_device_t *pdev); 1725 1726 /** 1727 * @Description 1728 * This function attaches attentions to NIG / PXP 1729 * close-the-g8, any attention that is added here should 1730 * also be added to the lm_recoverable_error function. 1731 * @param pdev 1732 */ 1733 void lm_er_config_close_the_g8(struct _lm_device_t *pdev); 1734 1735 u32_t lm_er_get_func_bit(struct _lm_device_t *pdev); 1736 u32_t lm_er_get_number_of_functions(u32_t er_register); 1737 u8_t lm_er_get_first_func_of_opp_path(struct _lm_device_t *pdev); 1738 u32_t lm_er_inc_load_cnt(struct _lm_device_t *pdev, u8_t sync_it); 1739 u32_t lm_er_dec_load_cnt(struct _lm_device_t *pdev, u8_t sync_it); 1740 u32_t lm_er_get_load_cnt(struct _lm_device_t *pdev, u8_t sync_it); 1741 void lm_er_clear_load_cnt(struct _lm_device_t *pdev, u8_t sync_it); 1742 void lm_er_set_recover_done(struct _lm_device_t *pdev, u8_t sync_it); 1743 void lm_er_set_recover_in_progress(struct _lm_device_t *pdev, u8_t sync_it); 1744 u8_t lm_er_recovery_in_progress(struct _lm_device_t *pdev, u8_t sync_it); 1745 1746 #define LM_ERROR_RECOVERY_COUNTER_HW_REGISTER MISC_REG_GENERIC_POR_1 1747 #define LM_ERROR_RECOVERY_IN_PROGRESS_FLAG 0x80000000 1748 1749 /** 1750 * Calculate CRC32_BE. 1751 * 1752 * @param crc32_packet 1753 * @param crc32_length 1754 * @param crc32_seed 1755 * @param complement 1756 * 1757 * @return u32_t 1758 */ 1759 u32_t calc_crc32(u8_t *crc32_packet, u32_t crc32_length, u32_t crc32_seed, u8_t complement); 1760 u32_t convert_to_bcd( const u8_t IN ver_arr[4] ); 1761 /** 1762 * General function that waits for a certain state to change, 1763 * not protocol specific. It takes into account vbd-commander 1764 * and reset-is-in-progress 1765 * 1766 * @param pdev 1767 * @param curr_state -> what to poll on 1768 * @param new_state -> what we're waiting for 1769 * 1770 * @return lm_status_t TIMEOUT if state didn't change, SUCCESS 1771 * otherwise 1772 */ 1773 lm_status_t lm_wait_state_change(struct _lm_device_t *pdev, volatile u32_t * curr_state, u32_t new_state); 1774 1775 /**lm_func_update_post_command Post a func_update ramrod and 1776 * wait for its completion. 1777 * 1778 * @param pdev the device 1779 * @param command the ramrod cmd_id (NONE_CONNECTION_TYPE is 1780 * assumed) 1781 * @param data the ramrod data 1782 * 1783 * @return lm_status_t LM_STATUS_SUCCESS on success, some other 1784 * failure code on failure. 1785 */ 1786 lm_status_t 1787 lm_l2mp_func_update_command( IN struct _lm_device_t *pdev, 1788 IN const struct function_update_data *func_data); 1789 lm_status_t 1790 lm_dcbx_set_params_and_read_mib( 1791 IN struct _lm_device_t *pdev, 1792 IN const u8_t is_local_ets_change, 1793 IN const u8_t b_can_update_ie); 1794 1795 lm_status_t 1796 lm_dcbx_disable_dcb_at_fw_and_hw( 1797 IN struct _lm_device_t *pdev, 1798 IN const u8_t b_can_update_ie); 1799 1800 u8_t 1801 lm_dcbx_is_dcb_config(IN struct _lm_device_t *pdev); 1802 1803 u8_t 1804 lm_ncsi_prev_drv_ver_is_win8_inbox( struct _lm_device_t *pdev); 1805 1806 u8_t lm_check_mac_addr_exist(struct _lm_device_t *pdev, u8_t chain_idx, u8_t *mac_addr, u16_t vlan_tag, u8_t is_encap_inner_mac_filter); 1807 1808 lm_status_t lm_update_default_vlan(IN struct _lm_device_t *pdev, IN u8_t client_idx, 1809 IN const u16_t silent_vlan_value, 1810 IN const u16_t silent_vlan_mask, 1811 IN const u8_t silent_vlan_removal_flg, 1812 IN const u8_t silent_vlan_change_flg, 1813 IN const u16_t default_vlan, 1814 IN const u8_t default_vlan_enable_flg, 1815 IN const u8_t default_vlan_change_flg); 1816 1817 u8_t lm_is_mac_locally_administrated(IN struct _lm_device_t *pdev, IN u8_t * mac); 1818 #endif /* _LM_H */ 1819