1 /* 2 * This file is provided under a CDDLv1 license. When using or 3 * redistributing this file, you may do so under this license. 4 * In redistributing this file this license must be included 5 * and no other modification of this header file is permitted. 6 * 7 * CDDL LICENSE SUMMARY 8 * 9 * Copyright(c) 1999 - 2007 Intel Corporation. All rights reserved. 10 * 11 * The contents of this file are subject to the terms of Version 12 * 1.0 of the Common Development and Distribution License (the "License"). 13 * 14 * You should have received a copy of the License with this software. 15 * You can obtain a copy of the License at 16 * http://www.opensolaris.org/os/licensing. 17 * See the License for the specific language governing permissions 18 * and limitations under the License. 19 */ 20 21 /* 22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms of the CDDLv1. 24 */ 25 26 #pragma ident "%Z%%M% %I% %E% SMI" 27 28 /* 29 * IntelVersion: HSD_2343720b_DragonLake3 v2007-06-14_HSD_2343720b_DragonLake3 30 */ 31 #include "e1000_api.h" 32 #include "e1000_mac.h" 33 #include "e1000_nvm.h" 34 #include "e1000_phy.h" 35 36 extern void e1000_init_function_pointers_82542(struct e1000_hw *hw); 37 extern void e1000_init_function_pointers_82543(struct e1000_hw *hw); 38 extern void e1000_init_function_pointers_82540(struct e1000_hw *hw); 39 extern void e1000_init_function_pointers_82571(struct e1000_hw *hw); 40 extern void e1000_init_function_pointers_82541(struct e1000_hw *hw); 41 extern void e1000_init_function_pointers_80003es2lan(struct e1000_hw *hw); 42 extern void e1000_init_function_pointers_ich8lan(struct e1000_hw *hw); 43 extern void e1000_init_function_pointers_vf(struct e1000_hw *hw); 44 45 /* 46 * e1000_init_mac_params - Initialize MAC function pointers 47 * @hw: pointer to the HW structure 48 * 49 * This function initializes the function pointers for the MAC 50 * set of functions. Called by drivers or by e1000_setup_init_funcs. 51 */ 52 s32 53 e1000_init_mac_params(struct e1000_hw *hw) 54 { 55 s32 ret_val = E1000_SUCCESS; 56 57 if (hw->func.init_mac_params) { 58 ret_val = hw->func.init_mac_params(hw); 59 if (ret_val) { 60 DEBUGOUT("MAC Initialization Error\n"); 61 goto out; 62 } 63 } else { 64 DEBUGOUT("mac.init_mac_params was NULL\n"); 65 ret_val = -E1000_ERR_CONFIG; 66 } 67 68 out: 69 return (ret_val); 70 } 71 72 /* 73 * e1000_init_nvm_params - Initialize NVM function pointers 74 * @hw: pointer to the HW structure 75 * 76 * This function initializes the function pointers for the NVM 77 * set of functions. Called by drivers or by e1000_setup_init_funcs. 78 */ 79 s32 80 e1000_init_nvm_params(struct e1000_hw *hw) 81 { 82 s32 ret_val = E1000_SUCCESS; 83 84 if (hw->func.init_nvm_params) { 85 ret_val = hw->func.init_nvm_params(hw); 86 if (ret_val) { 87 DEBUGOUT("NVM Initialization Error\n"); 88 goto out; 89 } 90 } else { 91 DEBUGOUT("nvm.init_nvm_params was NULL\n"); 92 ret_val = -E1000_ERR_CONFIG; 93 } 94 95 out: 96 return (ret_val); 97 } 98 99 /* 100 * e1000_init_phy_params - Initialize PHY function pointers 101 * @hw: pointer to the HW structure 102 * 103 * This function initializes the function pointers for the PHY 104 * set of functions. Called by drivers or by e1000_setup_init_funcs. 105 */ 106 s32 107 e1000_init_phy_params(struct e1000_hw *hw) 108 { 109 s32 ret_val = E1000_SUCCESS; 110 111 if (hw->func.init_phy_params) { 112 ret_val = hw->func.init_phy_params(hw); 113 if (ret_val) { 114 DEBUGOUT("PHY Initialization Error\n"); 115 goto out; 116 } 117 } else { 118 DEBUGOUT("phy.init_phy_params was NULL\n"); 119 ret_val = -E1000_ERR_CONFIG; 120 } 121 122 out: 123 return (ret_val); 124 } 125 126 /* 127 * e1000_set_mac_type - Sets MAC type 128 * @hw: pointer to the HW structure 129 * 130 * This function sets the mac type of the adapter based on the 131 * device ID stored in the hw structure. 132 * MUST BE FIRST FUNCTION CALLED (explicitly or through 133 * e1000_setup_init_funcs()). 134 */ 135 s32 136 e1000_set_mac_type(struct e1000_hw *hw) 137 { 138 struct e1000_mac_info *mac = &hw->mac; 139 s32 ret_val = E1000_SUCCESS; 140 141 DEBUGFUNC("e1000_set_mac_type"); 142 143 switch (hw->device_id) { 144 case E1000_DEV_ID_82542: 145 mac->type = e1000_82542; 146 break; 147 case E1000_DEV_ID_82543GC_FIBER: 148 case E1000_DEV_ID_82543GC_COPPER: 149 mac->type = e1000_82543; 150 break; 151 case E1000_DEV_ID_82544EI_COPPER: 152 case E1000_DEV_ID_82544EI_FIBER: 153 case E1000_DEV_ID_82544GC_COPPER: 154 case E1000_DEV_ID_82544GC_LOM: 155 mac->type = e1000_82544; 156 break; 157 case E1000_DEV_ID_82540EM: 158 case E1000_DEV_ID_82540EM_LOM: 159 case E1000_DEV_ID_82540EP: 160 case E1000_DEV_ID_82540EP_LOM: 161 case E1000_DEV_ID_82540EP_LP: 162 mac->type = e1000_82540; 163 break; 164 case E1000_DEV_ID_82545EM_COPPER: 165 case E1000_DEV_ID_82545EM_FIBER: 166 mac->type = e1000_82545; 167 break; 168 case E1000_DEV_ID_82545GM_COPPER: 169 case E1000_DEV_ID_82545GM_FIBER: 170 case E1000_DEV_ID_82545GM_SERDES: 171 mac->type = e1000_82545_rev_3; 172 break; 173 case E1000_DEV_ID_82546EB_COPPER: 174 case E1000_DEV_ID_82546EB_FIBER: 175 case E1000_DEV_ID_82546EB_QUAD_COPPER: 176 mac->type = e1000_82546; 177 break; 178 case E1000_DEV_ID_82546GB_COPPER: 179 case E1000_DEV_ID_82546GB_FIBER: 180 case E1000_DEV_ID_82546GB_SERDES: 181 case E1000_DEV_ID_82546GB_PCIE: 182 case E1000_DEV_ID_82546GB_QUAD_COPPER: 183 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3: 184 mac->type = e1000_82546_rev_3; 185 break; 186 case E1000_DEV_ID_82541EI: 187 case E1000_DEV_ID_82541EI_MOBILE: 188 case E1000_DEV_ID_82541ER_LOM: 189 mac->type = e1000_82541; 190 break; 191 case E1000_DEV_ID_82541ER: 192 case E1000_DEV_ID_82541GI: 193 case E1000_DEV_ID_82541GI_LF: 194 case E1000_DEV_ID_82541GI_MOBILE: 195 mac->type = e1000_82541_rev_2; 196 break; 197 case E1000_DEV_ID_82547EI: 198 case E1000_DEV_ID_82547EI_MOBILE: 199 mac->type = e1000_82547; 200 break; 201 case E1000_DEV_ID_82547GI: 202 mac->type = e1000_82547_rev_2; 203 break; 204 case E1000_DEV_ID_82571EB_COPPER: 205 case E1000_DEV_ID_82571EB_FIBER: 206 case E1000_DEV_ID_82571EB_SERDES: 207 case E1000_DEV_ID_82571EB_SERDES_DUAL: 208 case E1000_DEV_ID_82571EB_SERDES_QUAD: 209 case E1000_DEV_ID_82571EB_QUAD_COPPER: 210 case E1000_DEV_ID_82571PT_QUAD_COPPER: 211 case E1000_DEV_ID_82571EB_QUAD_FIBER: 212 case E1000_DEV_ID_82571EB_QUAD_COPPER_LP: 213 mac->type = e1000_82571; 214 break; 215 case E1000_DEV_ID_82572EI: 216 case E1000_DEV_ID_82572EI_COPPER: 217 case E1000_DEV_ID_82572EI_FIBER: 218 case E1000_DEV_ID_82572EI_SERDES: 219 mac->type = e1000_82572; 220 break; 221 case E1000_DEV_ID_82573E: 222 case E1000_DEV_ID_82573E_IAMT: 223 case E1000_DEV_ID_82573L: 224 mac->type = e1000_82573; 225 break; 226 case E1000_DEV_ID_80003ES2LAN_COPPER_DPT: 227 case E1000_DEV_ID_80003ES2LAN_SERDES_DPT: 228 case E1000_DEV_ID_80003ES2LAN_COPPER_SPT: 229 case E1000_DEV_ID_80003ES2LAN_SERDES_SPT: 230 mac->type = e1000_80003es2lan; 231 break; 232 case E1000_DEV_ID_ICH8_IFE: 233 case E1000_DEV_ID_ICH8_IFE_GT: 234 case E1000_DEV_ID_ICH8_IFE_G: 235 case E1000_DEV_ID_ICH8_IGP_M: 236 case E1000_DEV_ID_ICH8_IGP_M_AMT: 237 case E1000_DEV_ID_ICH8_IGP_AMT: 238 case E1000_DEV_ID_ICH8_IGP_C: 239 mac->type = e1000_ich8lan; 240 break; 241 case E1000_DEV_ID_ICH9_IFE: 242 case E1000_DEV_ID_ICH9_IFE_GT: 243 case E1000_DEV_ID_ICH9_IFE_G: 244 case E1000_DEV_ID_ICH9_IGP_AMT: 245 case E1000_DEV_ID_ICH9_IGP_C: 246 mac->type = e1000_ich9lan; 247 break; 248 default: 249 /* Should never have loaded on this device */ 250 ret_val = -E1000_ERR_MAC_INIT; 251 break; 252 } 253 254 return (ret_val); 255 } 256 257 /* 258 * e1000_setup_init_funcs - Initializes function pointers 259 * @hw: pointer to the HW structure 260 * @init_device: TRUE will initialize the rest of the function pointers 261 * getting the device ready for use. FALSE will only set 262 * MAC type and the function pointers for the other init 263 * functions. Passing FALSE will not generate any hardware 264 * reads or writes. 265 * 266 * This function must be called by a driver in order to use the rest 267 * of the 'shared' code files. Called by drivers only. 268 */ 269 s32 270 e1000_setup_init_funcs(struct e1000_hw *hw, boolean_t init_device) 271 { 272 s32 ret_val; 273 274 /* Can't do much good without knowing the MAC type. */ 275 ret_val = e1000_set_mac_type(hw); 276 if (ret_val) { 277 DEBUGOUT("ERROR: MAC type could not be set properly.\n"); 278 goto out; 279 } 280 if (!hw->hw_addr) { 281 DEBUGOUT("ERROR: Registers not mapped\n"); 282 ret_val = -E1000_ERR_CONFIG; 283 goto out; 284 } 285 286 /* 287 * Init some generic function pointers that are currently all pointing 288 * to generic implementations. We do this first allowing a driver 289 * module to override it afterwards. 290 */ 291 hw->func.config_collision_dist = e1000_config_collision_dist_generic; 292 hw->func.rar_set = e1000_rar_set_generic; 293 hw->func.validate_mdi_setting = e1000_validate_mdi_setting_generic; 294 hw->func.mng_host_if_write = e1000_mng_host_if_write_generic; 295 hw->func.mng_write_cmd_header = e1000_mng_write_cmd_header_generic; 296 hw->func.mng_enable_host_if = e1000_mng_enable_host_if_generic; 297 hw->func.wait_autoneg = e1000_wait_autoneg_generic; 298 hw->func.reload_nvm = e1000_reload_nvm_generic; 299 300 /* 301 * Set up the init function pointers. These are functions within the 302 * adapter family file that sets up function pointers for the rest of 303 * the functions in that family. 304 */ 305 switch (hw->mac.type) { 306 case e1000_82542: 307 e1000_init_function_pointers_82542(hw); 308 break; 309 case e1000_82543: 310 case e1000_82544: 311 e1000_init_function_pointers_82543(hw); 312 break; 313 case e1000_82540: 314 case e1000_82545: 315 case e1000_82545_rev_3: 316 case e1000_82546: 317 case e1000_82546_rev_3: 318 e1000_init_function_pointers_82540(hw); 319 break; 320 case e1000_82541: 321 case e1000_82541_rev_2: 322 case e1000_82547: 323 case e1000_82547_rev_2: 324 e1000_init_function_pointers_82541(hw); 325 break; 326 case e1000_82571: 327 case e1000_82572: 328 case e1000_82573: 329 e1000_init_function_pointers_82571(hw); 330 break; 331 case e1000_80003es2lan: 332 e1000_init_function_pointers_80003es2lan(hw); 333 break; 334 case e1000_ich8lan: 335 case e1000_ich9lan: 336 e1000_init_function_pointers_ich8lan(hw); 337 break; 338 default: 339 DEBUGOUT("Hardware not supported\n"); 340 ret_val = -E1000_ERR_CONFIG; 341 break; 342 } 343 344 /* 345 * Initialize the rest of the function pointers. These require some 346 * register reads/writes in some cases. 347 */ 348 if (!(ret_val) && init_device) { 349 ret_val = e1000_init_mac_params(hw); 350 if (ret_val) 351 goto out; 352 353 ret_val = e1000_init_nvm_params(hw); 354 if (ret_val) 355 goto out; 356 357 ret_val = e1000_init_phy_params(hw); 358 if (ret_val) 359 goto out; 360 361 } 362 363 out: 364 return (ret_val); 365 } 366 367 /* 368 * e1000_remove_device - Free device specific structure 369 * @hw: pointer to the HW structure 370 * 371 * If a device specific structure was allocated, this function will 372 * free it. This is a function pointer entry point called by drivers. 373 */ 374 void 375 e1000_remove_device(struct e1000_hw *hw) 376 { 377 if (hw->func.remove_device) 378 hw->func.remove_device(hw); 379 } 380 381 /* 382 * e1000_get_bus_info - Obtain bus information for adapter 383 * @hw: pointer to the HW structure 384 * 385 * This will obtain information about the HW bus for which the 386 * adaper is attached and stores it in the hw structure. This is a 387 * function pointer entry point called by drivers. 388 */ 389 s32 390 e1000_get_bus_info(struct e1000_hw *hw) 391 { 392 if (hw->func.get_bus_info) 393 return (hw->func.get_bus_info(hw)); 394 395 return (E1000_SUCCESS); 396 } 397 398 /* 399 * e1000_clear_vfta - Clear VLAN filter table 400 * @hw: pointer to the HW structure 401 * 402 * This clears the VLAN filter table on the adapter. This is a function 403 * pointer entry point called by drivers. 404 */ 405 void 406 e1000_clear_vfta(struct e1000_hw *hw) 407 { 408 if (hw->func.clear_vfta) 409 hw->func.clear_vfta(hw); 410 } 411 412 /* 413 * e1000_write_vfta - Write value to VLAN filter table 414 * @hw: pointer to the HW structure 415 * @offset: the 32-bit offset in which to write the value to. 416 * @value: the 32-bit value to write at location offset. 417 * 418 * This writes a 32-bit value to a 32-bit offset in the VLAN filter 419 * table. This is a function pointer entry point called by drivers. 420 */ 421 void 422 e1000_write_vfta(struct e1000_hw *hw, u32 offset, u32 value) 423 { 424 if (hw->func.write_vfta) 425 hw->func.write_vfta(hw, offset, value); 426 } 427 428 /* 429 * e1000_mc_addr_list_update - Update Multicast addresses 430 * @hw: pointer to the HW structure 431 * @mc_addr_list: array of multicast addresses to program 432 * @mc_addr_count: number of multicast addresses to program 433 * @rar_used_count: the first RAR register free to program 434 * @rar_count: total number of supported Receive Address Registers 435 * 436 * Updates the Receive Address Registers and Multicast Table Array. 437 * The caller must have a packed mc_addr_list of multicast addresses. 438 * The parameter rar_count will usually be hw->mac.rar_entry_count 439 * unless there are workarounds that change this. Currently no func pointer 440 * exists and all implementations are handled in the generic version of this 441 * function. 442 */ 443 void 444 e1000_mc_addr_list_update(struct e1000_hw *hw, u8 *mc_addr_list, 445 u32 mc_addr_count, u32 rar_used_count, u32 rar_count) 446 { 447 if (hw->func.mc_addr_list_update) 448 hw->func.mc_addr_list_update(hw, 449 mc_addr_list, 450 mc_addr_count, 451 rar_used_count, 452 rar_count); 453 } 454 455 /* 456 * e1000_force_mac_fc - Force MAC flow control 457 * @hw: pointer to the HW structure 458 * 459 * Force the MAC's flow control settings. Currently no func pointer exists 460 * and all implementations are handled in the generic version of this 461 * function. 462 */ 463 s32 464 e1000_force_mac_fc(struct e1000_hw *hw) 465 { 466 return (e1000_force_mac_fc_generic(hw)); 467 } 468 469 /* 470 * e1000_check_for_link - Check/Store link connection 471 * @hw: pointer to the HW structure 472 * 473 * This checks the link condition of the adapter and stores the 474 * results in the hw->mac structure. This is a function pointer entry 475 * point called by drivers. 476 */ 477 s32 478 e1000_check_for_link(struct e1000_hw *hw) 479 { 480 if (hw->func.check_for_link) 481 return (hw->func.check_for_link(hw)); 482 483 return (-E1000_ERR_CONFIG); 484 } 485 486 /* 487 * e1000_check_mng_mode - Check management mode 488 * @hw: pointer to the HW structure 489 * 490 * This checks if the adapter has manageability enabled. 491 * This is a function pointer entry point called by drivers. 492 */ 493 boolean_t 494 e1000_check_mng_mode(struct e1000_hw *hw) 495 { 496 if (hw->func.check_mng_mode) 497 return (hw->func.check_mng_mode(hw)); 498 499 return (FALSE); 500 } 501 502 /* 503 * e1000_mng_write_dhcp_info - Writes DHCP info to host interface 504 * @hw: pointer to the HW structure 505 * @buffer: pointer to the host interface 506 * @length: size of the buffer 507 * 508 * Writes the DHCP information to the host interface. 509 */ 510 s32 511 e1000_mng_write_dhcp_info(struct e1000_hw *hw, u8 * buffer, u16 length) 512 { 513 return (e1000_mng_write_dhcp_info_generic(hw, buffer, length)); 514 } 515 516 /* 517 * e1000_reset_hw - Reset hardware 518 * @hw: pointer to the HW structure 519 * 520 * This resets the hardware into a known state. This is a function pointer 521 * entry point called by drivers. 522 */ 523 s32 524 e1000_reset_hw(struct e1000_hw *hw) 525 { 526 if (hw->func.reset_hw) 527 return (hw->func.reset_hw(hw)); 528 529 return (-E1000_ERR_CONFIG); 530 } 531 532 /* 533 * e1000_init_hw - Initialize hardware 534 * @hw: pointer to the HW structure 535 * 536 * This inits the hardware readying it for operation. This is a function 537 * pointer entry point called by drivers. 538 */ 539 s32 540 e1000_init_hw(struct e1000_hw *hw) 541 { 542 if (hw->func.init_hw) 543 return (hw->func.init_hw(hw)); 544 545 return (-E1000_ERR_CONFIG); 546 } 547 548 /* 549 * e1000_setup_link - Configures link and flow control 550 * @hw: pointer to the HW structure 551 * 552 * This configures link and flow control settings for the adapter. This 553 * is a function pointer entry point called by drivers. While modules can 554 * also call this, they probably call their own version of this function. 555 */ 556 s32 557 e1000_setup_link(struct e1000_hw *hw) 558 { 559 if (hw->func.setup_link) 560 return (hw->func.setup_link(hw)); 561 562 return (-E1000_ERR_CONFIG); 563 } 564 565 /* 566 * e1000_get_speed_and_duplex - Returns current speed and duplex 567 * @hw: pointer to the HW structure 568 * @speed: pointer to a 16-bit value to store the speed 569 * @duplex: pointer to a 16-bit value to store the duplex. 570 * 571 * This returns the speed and duplex of the adapter in the two 'out' 572 * variables passed in. This is a function pointer entry point called 573 * by drivers. 574 */ 575 s32 576 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 * speed, u16 * duplex) 577 { 578 if (hw->func.get_link_up_info) 579 return (hw->func.get_link_up_info(hw, speed, duplex)); 580 581 return (-E1000_ERR_CONFIG); 582 } 583 584 /* 585 * e1000_setup_led - Configures SW controllable LED 586 * @hw: pointer to the HW structure 587 * 588 * This prepares the SW controllable LED for use and saves the current state 589 * of the LED so it can be later restored. This is a function pointer entry 590 * point called by drivers. 591 */ 592 s32 593 e1000_setup_led(struct e1000_hw *hw) 594 { 595 if (hw->func.setup_led) 596 return (hw->func.setup_led(hw)); 597 598 return (E1000_SUCCESS); 599 } 600 601 /* 602 * e1000_cleanup_led - Restores SW controllable LED 603 * @hw: pointer to the HW structure 604 * 605 * This restores the SW controllable LED to the value saved off by 606 * e1000_setup_led. This is a function pointer entry point called by drivers. 607 */ 608 s32 609 e1000_cleanup_led(struct e1000_hw *hw) 610 { 611 if (hw->func.cleanup_led) 612 return (hw->func.cleanup_led(hw)); 613 614 return (E1000_SUCCESS); 615 } 616 617 /* 618 * e1000_blink_led - Blink SW controllable LED 619 * @hw: pointer to the HW structure 620 * 621 * This starts the adapter LED blinking. Request the LED to be setup first 622 * and cleaned up after. This is a function pointer entry point called by 623 * drivers. 624 */ 625 s32 626 e1000_blink_led(struct e1000_hw *hw) 627 { 628 if (hw->func.blink_led) 629 return (hw->func.blink_led(hw)); 630 631 return (E1000_SUCCESS); 632 } 633 634 /* 635 * e1000_led_on - Turn on SW controllable LED 636 * @hw: pointer to the HW structure 637 * 638 * Turns the SW defined LED on. This is a function pointer entry point 639 * called by drivers. 640 */ 641 s32 642 e1000_led_on(struct e1000_hw *hw) 643 { 644 if (hw->func.led_on) 645 return (hw->func.led_on(hw)); 646 647 return (E1000_SUCCESS); 648 } 649 650 /* 651 * e1000_led_off - Turn off SW controllable LED 652 * @hw: pointer to the HW structure 653 * 654 * Turns the SW defined LED off. This is a function pointer entry point 655 * called by drivers. 656 */ 657 s32 658 e1000_led_off(struct e1000_hw *hw) 659 { 660 if (hw->func.led_off) 661 return (hw->func.led_off(hw)); 662 663 return (E1000_SUCCESS); 664 } 665 666 /* 667 * e1000_reset_adaptive - Reset adaptive IFS 668 * @hw: pointer to the HW structure 669 * 670 * Resets the adaptive IFS. Currently no func pointer exists and all 671 * implementations are handled in the generic version of this function. 672 */ 673 void 674 e1000_reset_adaptive(struct e1000_hw *hw) 675 { 676 e1000_reset_adaptive_generic(hw); 677 } 678 679 /* 680 * e1000_update_adaptive - Update adaptive IFS 681 * @hw: pointer to the HW structure 682 * 683 * Updates adapter IFS. Currently no func pointer exists and all 684 * implementations are handled in the generic version of this function. 685 */ 686 void 687 e1000_update_adaptive(struct e1000_hw *hw) 688 { 689 e1000_update_adaptive_generic(hw); 690 } 691 692 /* 693 * e1000_disable_pcie_master - Disable PCI-Express master access 694 * @hw: pointer to the HW structure 695 * 696 * Disables PCI-Express master access and verifies there are no pending 697 * requests. Currently no func pointer exists and all implementations are 698 * handled in the generic version of this function. 699 */ 700 s32 701 e1000_disable_pcie_master(struct e1000_hw *hw) 702 { 703 return (e1000_disable_pcie_master_generic(hw)); 704 } 705 706 /* 707 * e1000_config_collision_dist - Configure collision distance 708 * @hw: pointer to the HW structure 709 * 710 * Configures the collision distance to the default value and is used 711 * during link setup. 712 */ 713 void 714 e1000_config_collision_dist(struct e1000_hw *hw) 715 { 716 if (hw->func.config_collision_dist) 717 hw->func.config_collision_dist(hw); 718 } 719 720 /* 721 * e1000_rar_set - Sets a receive address register 722 * @hw: pointer to the HW structure 723 * @addr: address to set the RAR to 724 * @index: the RAR to set 725 * 726 * Sets a Receive Address Register (RAR) to the specified address. 727 */ 728 void 729 e1000_rar_set(struct e1000_hw *hw, u8 * addr, u32 index) 730 { 731 if (hw->func.rar_set) 732 hw->func.rar_set(hw, addr, index); 733 } 734 735 /* 736 * e1000_validate_mdi_setting - Ensures valid MDI/MDIX SW state 737 * @hw: pointer to the HW structure 738 * 739 * Ensures that the MDI/MDIX SW state is valid. 740 */ 741 s32 742 e1000_validate_mdi_setting(struct e1000_hw *hw) 743 { 744 if (hw->func.validate_mdi_setting) 745 return (hw->func.validate_mdi_setting(hw)); 746 747 return (E1000_SUCCESS); 748 } 749 750 /* 751 * e1000_mta_set - Sets multicast table bit 752 * @hw: pointer to the HW structure 753 * @hash_value: Multicast hash value. 754 * 755 * This sets the bit in the multicast table corresponding to the 756 * hash value. This is a function pointer entry point called by drivers. 757 */ 758 void 759 e1000_mta_set(struct e1000_hw *hw, u32 hash_value) 760 { 761 if (hw->func.mta_set) 762 hw->func.mta_set(hw, hash_value); 763 } 764 765 /* 766 * e1000_hash_mc_addr - Determines address location in multicast table 767 * @hw: pointer to the HW structure 768 * @mc_addr: Multicast address to hash. 769 * 770 * This hashes an address to determine its location in the multicast 771 * table. Currently no func pointer exists and all implementations 772 * are handled in the generic version of this function. 773 */ 774 u32 775 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr) 776 { 777 return (e1000_hash_mc_addr_generic(hw, mc_addr)); 778 } 779 780 /* 781 * e1000_enable_tx_pkt_filtering - Enable packet filtering on TX 782 * @hw: pointer to the HW structure 783 * 784 * Enables packet filtering on transmit packets if manageability is enabled 785 * and host interface is enabled. 786 * Currently no func pointer exists and all implementations are handled in the 787 * generic version of this function. 788 */ 789 boolean_t 790 e1000_enable_tx_pkt_filtering(struct e1000_hw *hw) 791 { 792 return (e1000_enable_tx_pkt_filtering_generic(hw)); 793 } 794 795 /* 796 * e1000_mng_host_if_write - Writes to the manageability host interface 797 * @hw: pointer to the HW structure 798 * @buffer: pointer to the host interface buffer 799 * @length: size of the buffer 800 * @offset: location in the buffer to write to 801 * @sum: sum of the data (not checksum) 802 * 803 * This function writes the buffer content at the offset given on the host if. 804 * It also does alignment considerations to do the writes in most efficient 805 * way. Also fills up the sum of the buffer in *buffer parameter. 806 */ 807 s32 808 e1000_mng_host_if_write(struct e1000_hw *hw, u8 *buffer, u16 length, 809 u16 offset, u8 *sum) 810 { 811 if (hw->func.mng_host_if_write) 812 return (hw->func.mng_host_if_write(hw, buffer, length, offset, 813 sum)); 814 815 return (E1000_NOT_IMPLEMENTED); 816 } 817 818 /* 819 * e1000_mng_write_cmd_header - Writes manageability command header 820 * @hw: pointer to the HW structure 821 * @hdr: pointer to the host interface command header 822 * 823 * Writes the command header after does the checksum calculation. 824 */ 825 s32 826 e1000_mng_write_cmd_header(struct e1000_hw *hw, 827 struct e1000_host_mng_command_header *hdr) 828 { 829 if (hw->func.mng_write_cmd_header) 830 return (hw->func.mng_write_cmd_header(hw, hdr)); 831 832 return (E1000_NOT_IMPLEMENTED); 833 } 834 835 /* 836 * e1000_mng_enable_host_if - Checks host interface is enabled 837 * @hw: pointer to the HW structure 838 * 839 * Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND 840 * 841 * This function checks whether the HOST IF is enabled for command operaton 842 * and also checks whether the previous command is completed. It busy waits 843 * in case of previous command is not completed. 844 */ 845 s32 846 e1000_mng_enable_host_if(struct e1000_hw *hw) 847 { 848 if (hw->func.mng_enable_host_if) 849 return (hw->func.mng_enable_host_if(hw)); 850 851 return (E1000_NOT_IMPLEMENTED); 852 } 853 854 /* 855 * e1000_wait_autoneg - Waits for autonegotiation completion 856 * @hw: pointer to the HW structure 857 * 858 * Waits for autoneg to complete. Currently no func pointer exists and all 859 * implementations are handled in the generic version of this function. 860 */ 861 s32 862 e1000_wait_autoneg(struct e1000_hw *hw) 863 { 864 if (hw->func.wait_autoneg) 865 return (hw->func.wait_autoneg(hw)); 866 867 return (E1000_SUCCESS); 868 } 869 870 /* 871 * e1000_check_reset_block - Verifies PHY can be reset 872 * @hw: pointer to the HW structure 873 * 874 * Checks if the PHY is in a state that can be reset or if manageability 875 * has it tied up. This is a function pointer entry point called by drivers. 876 */ 877 s32 878 e1000_check_reset_block(struct e1000_hw *hw) 879 { 880 if (hw->func.check_reset_block) 881 return (hw->func.check_reset_block(hw)); 882 883 return (E1000_SUCCESS); 884 } 885 886 /* 887 * e1000_read_phy_reg - Reads PHY register 888 * @hw: pointer to the HW structure 889 * @offset: the register to read 890 * @data: the buffer to store the 16-bit read. 891 * 892 * Reads the PHY register and returns the value in data. 893 * This is a function pointer entry point called by drivers. 894 */ 895 s32 896 e1000_read_phy_reg(struct e1000_hw *hw, u32 offset, u16 *data) 897 { 898 if (hw->func.read_phy_reg) 899 return (hw->func.read_phy_reg(hw, offset, data)); 900 901 return (E1000_SUCCESS); 902 } 903 904 /* 905 * e1000_write_phy_reg - Writes PHY register 906 * @hw: pointer to the HW structure 907 * @offset: the register to write 908 * @data: the value to write. 909 * 910 * Writes the PHY register at offset with the value in data. 911 * This is a function pointer entry point called by drivers. 912 */ 913 s32 914 e1000_write_phy_reg(struct e1000_hw *hw, u32 offset, u16 data) 915 { 916 if (hw->func.write_phy_reg) 917 return (hw->func.write_phy_reg(hw, offset, data)); 918 919 return (E1000_SUCCESS); 920 } 921 922 /* 923 * e1000_read_kmrn_reg - Reads register using Kumeran interface 924 * @hw: pointer to the HW structure 925 * @offset: the register to read 926 * @data: the location to store the 16-bit value read. 927 * 928 * Reads a register out of the Kumeran interface. Currently no func pointer 929 * exists and all implementations are handled in the generic version of 930 * this function. 931 */ 932 s32 933 e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data) 934 { 935 return (e1000_read_kmrn_reg_generic(hw, offset, data)); 936 } 937 938 /* 939 * e1000_write_kmrn_reg - Writes register using Kumeran interface 940 * @hw: pointer to the HW structure 941 * @offset: the register to write 942 * @data: the value to write. 943 * 944 * Writes a register to the Kumeran interface. Currently no func pointer 945 * exists and all implementations are handled in the generic version of 946 * this function. 947 */ 948 s32 949 e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data) 950 { 951 return (e1000_write_kmrn_reg_generic(hw, offset, data)); 952 } 953 954 /* 955 * e1000_get_cable_length - Retrieves cable length estimation 956 * @hw: pointer to the HW structure 957 * 958 * This function estimates the cable length and stores them in 959 * hw->phy.min_length and hw->phy.max_length. This is a function pointer 960 * entry point called by drivers. 961 */ 962 s32 963 e1000_get_cable_length(struct e1000_hw *hw) 964 { 965 if (hw->func.get_cable_length) 966 return (hw->func.get_cable_length(hw)); 967 968 return (E1000_SUCCESS); 969 } 970 971 /* 972 * e1000_get_phy_info - Retrieves PHY information from registers 973 * @hw: pointer to the HW structure 974 * 975 * This function gets some information from various PHY registers and 976 * populates hw->phy values with it. This is a function pointer entry 977 * point called by drivers. 978 */ 979 s32 980 e1000_get_phy_info(struct e1000_hw *hw) 981 { 982 if (hw->func.get_phy_info) 983 return (hw->func.get_phy_info(hw)); 984 985 return (E1000_SUCCESS); 986 } 987 988 /* 989 * e1000_phy_hw_reset - Hard PHY reset 990 * @hw: pointer to the HW structure 991 * 992 * Performs a hard PHY reset. This is a function pointer entry point called 993 * by drivers. 994 */ 995 s32 996 e1000_phy_hw_reset(struct e1000_hw *hw) 997 { 998 if (hw->func.reset_phy) 999 return (hw->func.reset_phy(hw)); 1000 1001 return (E1000_SUCCESS); 1002 } 1003 1004 /* 1005 * e1000_phy_commit - Soft PHY reset 1006 * @hw: pointer to the HW structure 1007 * 1008 * Performs a soft PHY reset on those that apply. This is a function pointer 1009 * entry point called by drivers. 1010 */ 1011 s32 1012 e1000_phy_commit(struct e1000_hw *hw) 1013 { 1014 if (hw->func.commit_phy) 1015 return (hw->func.commit_phy(hw)); 1016 1017 return (E1000_SUCCESS); 1018 } 1019 1020 /* 1021 * e1000_set_d3_lplu_state - Sets low power link up state for D0 1022 * @hw: pointer to the HW structure 1023 * @active: boolean used to enable/disable lplu 1024 * 1025 * Success returns 0, Failure returns 1 1026 * 1027 * The low power link up (lplu) state is set to the power management level D0 1028 * and SmartSpeed is disabled when active is true, else clear lplu for D0 1029 * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU 1030 * is used during Dx states where the power conservation is most important. 1031 * During driver activity, SmartSpeed should be enabled so performance is 1032 * maintained. This is a function pointer entry point called by drivers. 1033 */ 1034 s32 1035 e1000_set_d0_lplu_state(struct e1000_hw *hw, boolean_t active) 1036 { 1037 if (hw->func.set_d0_lplu_state) 1038 return (hw->func.set_d0_lplu_state(hw, active)); 1039 1040 return (E1000_SUCCESS); 1041 } 1042 1043 /* 1044 * e1000_set_d3_lplu_state - Sets low power link up state for D3 1045 * @hw: pointer to the HW structure 1046 * @active: boolean used to enable/disable lplu 1047 * 1048 * Success returns 0, Failure returns 1 1049 * 1050 * The low power link up (lplu) state is set to the power management level D3 1051 * and SmartSpeed is disabled when active is true, else clear lplu for D3 1052 * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU 1053 * is used during Dx states where the power conservation is most important. 1054 * During driver activity, SmartSpeed should be enabled so performance is 1055 * maintained. This is a function pointer entry point called by drivers. 1056 */ 1057 s32 1058 e1000_set_d3_lplu_state(struct e1000_hw *hw, boolean_t active) 1059 { 1060 if (hw->func.set_d3_lplu_state) 1061 return (hw->func.set_d3_lplu_state(hw, active)); 1062 1063 return (E1000_SUCCESS); 1064 } 1065 1066 /* 1067 * e1000_read_mac_addr - Reads MAC address 1068 * @hw: pointer to the HW structure 1069 * 1070 * Reads the MAC address out of the adapter and stores it in the HW structure. 1071 * Currently no func pointer exists and all implementations are handled in the 1072 * generic version of this function. 1073 */ 1074 s32 1075 e1000_read_mac_addr(struct e1000_hw *hw) 1076 { 1077 return (e1000_read_mac_addr_generic(hw)); 1078 } 1079 1080 /* 1081 * e1000_read_part_num - Read device part number 1082 * @hw: pointer to the HW structure 1083 * @part_num: pointer to device part number 1084 * 1085 * Reads the product board assembly (PBA) number from the EEPROM and stores 1086 * the value in part_num. 1087 * Currently no func pointer exists and all implementations are handled in the 1088 * generic version of this function. 1089 */ 1090 s32 1091 e1000_read_part_num(struct e1000_hw *hw, u32 * part_num) 1092 { 1093 return (e1000_read_part_num_generic(hw, part_num)); 1094 } 1095 1096 /* 1097 * e1000_validate_nvm_checksum - Verifies NVM (EEPROM) checksum 1098 * @hw: pointer to the HW structure 1099 * 1100 * Validates the NVM checksum is correct. This is a function pointer entry 1101 * point called by drivers. 1102 */ 1103 s32 1104 e1000_validate_nvm_checksum(struct e1000_hw *hw) 1105 { 1106 if (hw->func.validate_nvm) 1107 return (hw->func.validate_nvm(hw)); 1108 1109 return (-E1000_ERR_CONFIG); 1110 } 1111 1112 /* 1113 * e1000_update_nvm_checksum - Updates NVM (EEPROM) checksum 1114 * @hw: pointer to the HW structure 1115 * 1116 * Updates the NVM checksum. Currently no func pointer exists and all 1117 * implementations are handled in the generic version of this function. 1118 */ 1119 s32 1120 e1000_update_nvm_checksum(struct e1000_hw *hw) 1121 { 1122 if (hw->func.update_nvm) 1123 return (hw->func.update_nvm(hw)); 1124 1125 return (-E1000_ERR_CONFIG); 1126 } 1127 1128 /* 1129 * e1000_reload_nvm - Reloads EEPROM 1130 * @hw: pointer to the HW structure 1131 * 1132 * Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the 1133 * extended control register. 1134 */ 1135 void 1136 e1000_reload_nvm(struct e1000_hw *hw) 1137 { 1138 if (hw->func.reload_nvm) 1139 hw->func.reload_nvm(hw); 1140 } 1141 1142 /* 1143 * e1000_read_nvm - Reads NVM (EEPROM) 1144 * @hw: pointer to the HW structure 1145 * @offset: the word offset to read 1146 * @words: number of 16-bit words to read 1147 * @data: pointer to the properly sized buffer for the data. 1148 * 1149 * Reads 16-bit chunks of data from the NVM (EEPROM). This is a function 1150 * pointer entry point called by drivers. 1151 */ 1152 s32 1153 e1000_read_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) 1154 { 1155 if (hw->func.read_nvm) 1156 return (hw->func.read_nvm(hw, offset, words, data)); 1157 1158 return (-E1000_ERR_CONFIG); 1159 } 1160 1161 /* 1162 * e1000_write_nvm - Writes to NVM (EEPROM) 1163 * @hw: pointer to the HW structure 1164 * @offset: the word offset to read 1165 * @words: number of 16-bit words to write 1166 * @data: pointer to the properly sized buffer for the data. 1167 * 1168 * Writes 16-bit chunks of data to the NVM (EEPROM). This is a function 1169 * pointer entry point called by drivers. 1170 */ 1171 s32 1172 e1000_write_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) 1173 { 1174 if (hw->func.write_nvm) 1175 return (hw->func.write_nvm(hw, offset, words, data)); 1176 1177 return (E1000_SUCCESS); 1178 } 1179 1180 /* 1181 * e1000_write_8bit_ctrl_reg - Writes 8bit Control register 1182 * @hw: pointer to the HW structure 1183 * @reg: 32bit register offset 1184 * @offset: the register to write 1185 * @data: the value to write. 1186 * 1187 * Writes the PHY register at offset with the value in data. 1188 * This is a function pointer entry point called by drivers. 1189 */ 1190 s32 1191 e1000_write_8bit_ctrl_reg(struct e1000_hw *hw, u32 reg, u32 offset, u8 data) 1192 { 1193 return (e1000_write_8bit_ctrl_reg_generic(hw, reg, offset, data)); 1194 } 1195