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