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