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