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