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