1 // SPDX-License-Identifier: GPL-2.0
2 /*******************************************************************************
4 Intel(R) Gigabit Ethernet Linux driver
5 Copyright(c) 2007-2013 Intel Corporation.
8 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
9 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
11 *******************************************************************************/
13 #include "e1000_api.h"
16 * e1000_init_mac_params - Initialize MAC function pointers
17 * @hw: pointer to the HW structure
19 * This function initializes the function pointers for the MAC
20 * set of functions. Called by drivers or by e1000_setup_init_funcs.
22 s32 e1000_init_mac_params(struct e1000_hw *hw)
24 s32 ret_val = E1000_SUCCESS;
26 if (hw->mac.ops.init_params) {
27 ret_val = hw->mac.ops.init_params(hw);
29 DEBUGOUT("MAC Initialization Error\n");
33 DEBUGOUT("mac.init_mac_params was NULL\n");
34 ret_val = -E1000_ERR_CONFIG;
42 * e1000_init_nvm_params - Initialize NVM function pointers
43 * @hw: pointer to the HW structure
45 * This function initializes the function pointers for the NVM
46 * set of functions. Called by drivers or by e1000_setup_init_funcs.
48 s32 e1000_init_nvm_params(struct e1000_hw *hw)
50 s32 ret_val = E1000_SUCCESS;
52 if (hw->nvm.ops.init_params) {
53 ret_val = hw->nvm.ops.init_params(hw);
55 DEBUGOUT("NVM Initialization Error\n");
59 DEBUGOUT("nvm.init_nvm_params was NULL\n");
60 ret_val = -E1000_ERR_CONFIG;
68 * e1000_init_phy_params - Initialize PHY function pointers
69 * @hw: pointer to the HW structure
71 * This function initializes the function pointers for the PHY
72 * set of functions. Called by drivers or by e1000_setup_init_funcs.
74 s32 e1000_init_phy_params(struct e1000_hw *hw)
76 s32 ret_val = E1000_SUCCESS;
78 if (hw->phy.ops.init_params) {
79 ret_val = hw->phy.ops.init_params(hw);
81 DEBUGOUT("PHY Initialization Error\n");
85 DEBUGOUT("phy.init_phy_params was NULL\n");
86 ret_val = -E1000_ERR_CONFIG;
94 * e1000_init_mbx_params - Initialize mailbox function pointers
95 * @hw: pointer to the HW structure
97 * This function initializes the function pointers for the PHY
98 * set of functions. Called by drivers or by e1000_setup_init_funcs.
100 s32 e1000_init_mbx_params(struct e1000_hw *hw)
102 s32 ret_val = E1000_SUCCESS;
104 if (hw->mbx.ops.init_params) {
105 ret_val = hw->mbx.ops.init_params(hw);
107 DEBUGOUT("Mailbox Initialization Error\n");
111 DEBUGOUT("mbx.init_mbx_params was NULL\n");
112 ret_val = -E1000_ERR_CONFIG;
120 * e1000_set_mac_type - Sets MAC type
121 * @hw: pointer to the HW structure
123 * This function sets the mac type of the adapter based on the
124 * device ID stored in the hw structure.
125 * MUST BE FIRST FUNCTION CALLED (explicitly or through
126 * e1000_setup_init_funcs()).
128 s32 e1000_set_mac_type(struct e1000_hw *hw)
130 struct e1000_mac_info *mac = &hw->mac;
131 s32 ret_val = E1000_SUCCESS;
133 DEBUGFUNC("e1000_set_mac_type");
135 switch (hw->device_id) {
136 case E1000_DEV_ID_82575EB_COPPER:
137 case E1000_DEV_ID_82575EB_FIBER_SERDES:
138 case E1000_DEV_ID_82575GB_QUAD_COPPER:
139 mac->type = e1000_82575;
141 case E1000_DEV_ID_82576:
142 case E1000_DEV_ID_82576_FIBER:
143 case E1000_DEV_ID_82576_SERDES:
144 case E1000_DEV_ID_82576_QUAD_COPPER:
145 case E1000_DEV_ID_82576_QUAD_COPPER_ET2:
146 case E1000_DEV_ID_82576_NS:
147 case E1000_DEV_ID_82576_NS_SERDES:
148 case E1000_DEV_ID_82576_SERDES_QUAD:
149 mac->type = e1000_82576;
151 case E1000_DEV_ID_82580_COPPER:
152 case E1000_DEV_ID_82580_FIBER:
153 case E1000_DEV_ID_82580_SERDES:
154 case E1000_DEV_ID_82580_SGMII:
155 case E1000_DEV_ID_82580_COPPER_DUAL:
156 case E1000_DEV_ID_82580_QUAD_FIBER:
157 case E1000_DEV_ID_DH89XXCC_SGMII:
158 case E1000_DEV_ID_DH89XXCC_SERDES:
159 case E1000_DEV_ID_DH89XXCC_BACKPLANE:
160 case E1000_DEV_ID_DH89XXCC_SFP:
161 mac->type = e1000_82580;
163 case E1000_DEV_ID_I350_COPPER:
164 case E1000_DEV_ID_I350_FIBER:
165 case E1000_DEV_ID_I350_SERDES:
166 case E1000_DEV_ID_I350_SGMII:
167 case E1000_DEV_ID_I350_DA4:
168 mac->type = e1000_i350;
170 case E1000_DEV_ID_I210_COPPER_FLASHLESS:
171 case E1000_DEV_ID_I210_SERDES_FLASHLESS:
172 case E1000_DEV_ID_I210_COPPER:
173 case E1000_DEV_ID_I210_COPPER_OEM1:
174 case E1000_DEV_ID_I210_COPPER_IT:
175 case E1000_DEV_ID_I210_FIBER:
176 case E1000_DEV_ID_I210_SERDES:
177 case E1000_DEV_ID_I210_SGMII:
178 mac->type = e1000_i210;
180 case E1000_DEV_ID_I211_COPPER:
181 mac->type = e1000_i211;
184 case E1000_DEV_ID_I354_BACKPLANE_1GBPS:
185 case E1000_DEV_ID_I354_SGMII:
186 case E1000_DEV_ID_I354_BACKPLANE_2_5GBPS:
187 mac->type = e1000_i354;
190 /* Should never have loaded on this device */
191 ret_val = -E1000_ERR_MAC_INIT;
199 * e1000_setup_init_funcs - Initializes function pointers
200 * @hw: pointer to the HW structure
201 * @init_device: true will initialize the rest of the function pointers
202 * getting the device ready for use. false will only set
203 * MAC type and the function pointers for the other init
204 * functions. Passing false will not generate any hardware
207 * This function must be called by a driver in order to use the rest
208 * of the 'shared' code files. Called by drivers only.
210 s32 e1000_setup_init_funcs(struct e1000_hw *hw, bool init_device)
214 /* Can't do much good without knowing the MAC type. */
215 ret_val = e1000_set_mac_type(hw);
217 DEBUGOUT("ERROR: MAC type could not be set properly.\n");
222 DEBUGOUT("ERROR: Registers not mapped\n");
223 ret_val = -E1000_ERR_CONFIG;
228 * Init function pointers to generic implementations. We do this first
229 * allowing a driver module to override it afterward.
231 e1000_init_mac_ops_generic(hw);
232 e1000_init_phy_ops_generic(hw);
233 e1000_init_nvm_ops_generic(hw);
234 e1000_init_mbx_ops_generic(hw);
237 * Set up the init function pointers. These are functions within the
238 * adapter family file that sets up function pointers for the rest of
239 * the functions in that family.
241 switch (hw->mac.type) {
247 e1000_init_function_pointers_82575(hw);
251 e1000_init_function_pointers_i210(hw);
254 DEBUGOUT("Hardware not supported\n");
255 ret_val = -E1000_ERR_CONFIG;
260 * Initialize the rest of the function pointers. These require some
261 * register reads/writes in some cases.
263 if (!(ret_val) && init_device) {
264 ret_val = e1000_init_mac_params(hw);
268 ret_val = e1000_init_nvm_params(hw);
272 ret_val = e1000_init_phy_params(hw);
276 ret_val = e1000_init_mbx_params(hw);
286 * e1000_get_bus_info - Obtain bus information for adapter
287 * @hw: pointer to the HW structure
289 * This will obtain information about the HW bus for which the
290 * adapter is attached and stores it in the hw structure. This is a
291 * function pointer entry point called by drivers.
293 s32 e1000_get_bus_info(struct e1000_hw *hw)
295 if (hw->mac.ops.get_bus_info)
296 return hw->mac.ops.get_bus_info(hw);
298 return E1000_SUCCESS;
302 * e1000_clear_vfta - Clear VLAN filter table
303 * @hw: pointer to the HW structure
305 * This clears the VLAN filter table on the adapter. This is a function
306 * pointer entry point called by drivers.
308 void e1000_clear_vfta(struct e1000_hw *hw)
310 if (hw->mac.ops.clear_vfta)
311 hw->mac.ops.clear_vfta(hw);
315 * e1000_write_vfta - Write value to VLAN filter table
316 * @hw: pointer to the HW structure
317 * @offset: the 32-bit offset in which to write the value to.
318 * @value: the 32-bit value to write at location offset.
320 * This writes a 32-bit value to a 32-bit offset in the VLAN filter
321 * table. This is a function pointer entry point called by drivers.
323 void e1000_write_vfta(struct e1000_hw *hw, u32 offset, u32 value)
325 if (hw->mac.ops.write_vfta)
326 hw->mac.ops.write_vfta(hw, offset, value);
330 * e1000_update_mc_addr_list - Update Multicast addresses
331 * @hw: pointer to the HW structure
332 * @mc_addr_list: array of multicast addresses to program
333 * @mc_addr_count: number of multicast addresses to program
335 * Updates the Multicast Table Array.
336 * The caller must have a packed mc_addr_list of multicast addresses.
338 void e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list,
341 if (hw->mac.ops.update_mc_addr_list)
342 hw->mac.ops.update_mc_addr_list(hw, mc_addr_list,
347 * e1000_force_mac_fc - Force MAC flow control
348 * @hw: pointer to the HW structure
350 * Force the MAC's flow control settings. Currently no func pointer exists
351 * and all implementations are handled in the generic version of this
354 s32 e1000_force_mac_fc(struct e1000_hw *hw)
356 return e1000_force_mac_fc_generic(hw);
360 * e1000_check_for_link - Check/Store link connection
361 * @hw: pointer to the HW structure
363 * This checks the link condition of the adapter and stores the
364 * results in the hw->mac structure. This is a function pointer entry
365 * point called by drivers.
367 s32 e1000_check_for_link(struct e1000_hw *hw)
369 if (hw->mac.ops.check_for_link)
370 return hw->mac.ops.check_for_link(hw);
372 return -E1000_ERR_CONFIG;
376 * e1000_check_mng_mode - Check management mode
377 * @hw: pointer to the HW structure
379 * This checks if the adapter has manageability enabled.
380 * This is a function pointer entry point called by drivers.
382 bool e1000_check_mng_mode(struct e1000_hw *hw)
384 if (hw->mac.ops.check_mng_mode)
385 return hw->mac.ops.check_mng_mode(hw);
391 * e1000_mng_write_dhcp_info - Writes DHCP info to host interface
392 * @hw: pointer to the HW structure
393 * @buffer: pointer to the host interface
394 * @length: size of the buffer
396 * Writes the DHCP information to the host interface.
398 s32 e1000_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length)
400 return e1000_mng_write_dhcp_info_generic(hw, buffer, length);
404 * e1000_reset_hw - Reset hardware
405 * @hw: pointer to the HW structure
407 * This resets the hardware into a known state. This is a function pointer
408 * entry point called by drivers.
410 s32 e1000_reset_hw(struct e1000_hw *hw)
412 if (hw->mac.ops.reset_hw)
413 return hw->mac.ops.reset_hw(hw);
415 return -E1000_ERR_CONFIG;
419 * e1000_init_hw - Initialize hardware
420 * @hw: pointer to the HW structure
422 * This inits the hardware readying it for operation. This is a function
423 * pointer entry point called by drivers.
425 s32 e1000_init_hw(struct e1000_hw *hw)
427 if (hw->mac.ops.init_hw)
428 return hw->mac.ops.init_hw(hw);
430 return -E1000_ERR_CONFIG;
434 * e1000_setup_link - Configures link and flow control
435 * @hw: pointer to the HW structure
437 * This configures link and flow control settings for the adapter. This
438 * is a function pointer entry point called by drivers. While modules can
439 * also call this, they probably call their own version of this function.
441 s32 e1000_setup_link(struct e1000_hw *hw)
443 if (hw->mac.ops.setup_link)
444 return hw->mac.ops.setup_link(hw);
446 return -E1000_ERR_CONFIG;
450 * e1000_get_speed_and_duplex - Returns current speed and duplex
451 * @hw: pointer to the HW structure
452 * @speed: pointer to a 16-bit value to store the speed
453 * @duplex: pointer to a 16-bit value to store the duplex.
455 * This returns the speed and duplex of the adapter in the two 'out'
456 * variables passed in. This is a function pointer entry point called
459 s32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex)
461 if (hw->mac.ops.get_link_up_info)
462 return hw->mac.ops.get_link_up_info(hw, speed, duplex);
464 return -E1000_ERR_CONFIG;
468 * e1000_setup_led - Configures SW controllable LED
469 * @hw: pointer to the HW structure
471 * This prepares the SW controllable LED for use and saves the current state
472 * of the LED so it can be later restored. This is a function pointer entry
473 * point called by drivers.
475 s32 e1000_setup_led(struct e1000_hw *hw)
477 if (hw->mac.ops.setup_led)
478 return hw->mac.ops.setup_led(hw);
480 return E1000_SUCCESS;
484 * e1000_cleanup_led - Restores SW controllable LED
485 * @hw: pointer to the HW structure
487 * This restores the SW controllable LED to the value saved off by
488 * e1000_setup_led. This is a function pointer entry point called by drivers.
490 s32 e1000_cleanup_led(struct e1000_hw *hw)
492 if (hw->mac.ops.cleanup_led)
493 return hw->mac.ops.cleanup_led(hw);
495 return E1000_SUCCESS;
499 * e1000_blink_led - Blink SW controllable LED
500 * @hw: pointer to the HW structure
502 * This starts the adapter LED blinking. Request the LED to be setup first
503 * and cleaned up after. This is a function pointer entry point called by
506 s32 e1000_blink_led(struct e1000_hw *hw)
508 if (hw->mac.ops.blink_led)
509 return hw->mac.ops.blink_led(hw);
511 return E1000_SUCCESS;
515 * e1000_id_led_init - store LED configurations in SW
516 * @hw: pointer to the HW structure
518 * Initializes the LED config in SW. This is a function pointer entry point
521 s32 e1000_id_led_init(struct e1000_hw *hw)
523 if (hw->mac.ops.id_led_init)
524 return hw->mac.ops.id_led_init(hw);
526 return E1000_SUCCESS;
530 * e1000_led_on - Turn on SW controllable LED
531 * @hw: pointer to the HW structure
533 * Turns the SW defined LED on. This is a function pointer entry point
536 s32 e1000_led_on(struct e1000_hw *hw)
538 if (hw->mac.ops.led_on)
539 return hw->mac.ops.led_on(hw);
541 return E1000_SUCCESS;
545 * e1000_led_off - Turn off SW controllable LED
546 * @hw: pointer to the HW structure
548 * Turns the SW defined LED off. This is a function pointer entry point
551 s32 e1000_led_off(struct e1000_hw *hw)
553 if (hw->mac.ops.led_off)
554 return hw->mac.ops.led_off(hw);
556 return E1000_SUCCESS;
560 * e1000_reset_adaptive - Reset adaptive IFS
561 * @hw: pointer to the HW structure
563 * Resets the adaptive IFS. Currently no func pointer exists and all
564 * implementations are handled in the generic version of this function.
566 void e1000_reset_adaptive(struct e1000_hw *hw)
568 e1000_reset_adaptive_generic(hw);
572 * e1000_update_adaptive - Update adaptive IFS
573 * @hw: pointer to the HW structure
575 * Updates adapter IFS. Currently no func pointer exists and all
576 * implementations are handled in the generic version of this function.
578 void e1000_update_adaptive(struct e1000_hw *hw)
580 e1000_update_adaptive_generic(hw);
584 * e1000_disable_pcie_master - Disable PCI-Express master access
585 * @hw: pointer to the HW structure
587 * Disables PCI-Express master access and verifies there are no pending
588 * requests. Currently no func pointer exists and all implementations are
589 * handled in the generic version of this function.
591 s32 e1000_disable_pcie_master(struct e1000_hw *hw)
593 return e1000_disable_pcie_master_generic(hw);
597 * e1000_config_collision_dist - Configure collision distance
598 * @hw: pointer to the HW structure
600 * Configures the collision distance to the default value and is used
603 void e1000_config_collision_dist(struct e1000_hw *hw)
605 if (hw->mac.ops.config_collision_dist)
606 hw->mac.ops.config_collision_dist(hw);
610 * e1000_rar_set - Sets a receive address register
611 * @hw: pointer to the HW structure
612 * @addr: address to set the RAR to
613 * @index: the RAR to set
615 * Sets a Receive Address Register (RAR) to the specified address.
617 void e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index)
619 if (hw->mac.ops.rar_set)
620 hw->mac.ops.rar_set(hw, addr, index);
624 * e1000_validate_mdi_setting - Ensures valid MDI/MDIX SW state
625 * @hw: pointer to the HW structure
627 * Ensures that the MDI/MDIX SW state is valid.
629 s32 e1000_validate_mdi_setting(struct e1000_hw *hw)
631 if (hw->mac.ops.validate_mdi_setting)
632 return hw->mac.ops.validate_mdi_setting(hw);
634 return E1000_SUCCESS;
638 * e1000_hash_mc_addr - Determines address location in multicast table
639 * @hw: pointer to the HW structure
640 * @mc_addr: Multicast address to hash.
642 * This hashes an address to determine its location in the multicast
643 * table. Currently no func pointer exists and all implementations
644 * are handled in the generic version of this function.
646 u32 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr)
648 return e1000_hash_mc_addr_generic(hw, mc_addr);
652 * e1000_enable_tx_pkt_filtering - Enable packet filtering on TX
653 * @hw: pointer to the HW structure
655 * Enables packet filtering on transmit packets if manageability is enabled
656 * and host interface is enabled.
657 * Currently no func pointer exists and all implementations are handled in the
658 * generic version of this function.
660 bool e1000_enable_tx_pkt_filtering(struct e1000_hw *hw)
662 return e1000_enable_tx_pkt_filtering_generic(hw);
666 * e1000_mng_host_if_write - Writes to the manageability host interface
667 * @hw: pointer to the HW structure
668 * @buffer: pointer to the host interface buffer
669 * @length: size of the buffer
670 * @offset: location in the buffer to write to
671 * @sum: sum of the data (not checksum)
673 * This function writes the buffer content at the offset given on the host if.
674 * It also does alignment considerations to do the writes in most efficient
675 * way. Also fills up the sum of the buffer in *buffer parameter.
677 s32 e1000_mng_host_if_write(struct e1000_hw *hw, u8 *buffer, u16 length,
680 return e1000_mng_host_if_write_generic(hw, buffer, length, offset, sum);
684 * e1000_mng_write_cmd_header - Writes manageability command header
685 * @hw: pointer to the HW structure
686 * @hdr: pointer to the host interface command header
688 * Writes the command header after does the checksum calculation.
690 s32 e1000_mng_write_cmd_header(struct e1000_hw *hw,
691 struct e1000_host_mng_command_header *hdr)
693 return e1000_mng_write_cmd_header_generic(hw, hdr);
697 * e1000_mng_enable_host_if - Checks host interface is enabled
698 * @hw: pointer to the HW structure
700 * Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND
702 * This function checks whether the HOST IF is enabled for command operation
703 * and also checks whether the previous command is completed. It busy waits
704 * in case of previous command is not completed.
706 s32 e1000_mng_enable_host_if(struct e1000_hw *hw)
708 return e1000_mng_enable_host_if_generic(hw);
712 * e1000_check_reset_block - Verifies PHY can be reset
713 * @hw: pointer to the HW structure
715 * Checks if the PHY is in a state that can be reset or if manageability
716 * has it tied up. This is a function pointer entry point called by drivers.
718 s32 e1000_check_reset_block(struct e1000_hw *hw)
720 if (hw->phy.ops.check_reset_block)
721 return hw->phy.ops.check_reset_block(hw);
723 return E1000_SUCCESS;
727 * e1000_read_phy_reg - Reads PHY register
728 * @hw: pointer to the HW structure
729 * @offset: the register to read
730 * @data: the buffer to store the 16-bit read.
732 * Reads the PHY register and returns the value in data.
733 * This is a function pointer entry point called by drivers.
735 s32 e1000_read_phy_reg(struct e1000_hw *hw, u32 offset, u16 *data)
737 if (hw->phy.ops.read_reg)
738 return hw->phy.ops.read_reg(hw, offset, data);
740 return E1000_SUCCESS;
744 * e1000_write_phy_reg - Writes PHY register
745 * @hw: pointer to the HW structure
746 * @offset: the register to write
747 * @data: the value to write.
749 * Writes the PHY register at offset with the value in data.
750 * This is a function pointer entry point called by drivers.
752 s32 e1000_write_phy_reg(struct e1000_hw *hw, u32 offset, u16 data)
754 if (hw->phy.ops.write_reg)
755 return hw->phy.ops.write_reg(hw, offset, data);
757 return E1000_SUCCESS;
761 * e1000_release_phy - Generic release PHY
762 * @hw: pointer to the HW structure
764 * Return if silicon family does not require a semaphore when accessing the
767 void e1000_release_phy(struct e1000_hw *hw)
769 if (hw->phy.ops.release)
770 hw->phy.ops.release(hw);
774 * e1000_acquire_phy - Generic acquire PHY
775 * @hw: pointer to the HW structure
777 * Return success if silicon family does not require a semaphore when
780 s32 e1000_acquire_phy(struct e1000_hw *hw)
782 if (hw->phy.ops.acquire)
783 return hw->phy.ops.acquire(hw);
785 return E1000_SUCCESS;
789 * e1000_read_kmrn_reg - Reads register using Kumeran interface
790 * @hw: pointer to the HW structure
791 * @offset: the register to read
792 * @data: the location to store the 16-bit value read.
794 * Reads a register out of the Kumeran interface. Currently no func pointer
795 * exists and all implementations are handled in the generic version of
798 s32 e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data)
800 return e1000_read_kmrn_reg_generic(hw, offset, data);
804 * e1000_write_kmrn_reg - Writes register using Kumeran interface
805 * @hw: pointer to the HW structure
806 * @offset: the register to write
807 * @data: the value to write.
809 * Writes a register to the Kumeran interface. Currently no func pointer
810 * exists and all implementations are handled in the generic version of
813 s32 e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data)
815 return e1000_write_kmrn_reg_generic(hw, offset, data);
819 * e1000_get_cable_length - Retrieves cable length estimation
820 * @hw: pointer to the HW structure
822 * This function estimates the cable length and stores them in
823 * hw->phy.min_length and hw->phy.max_length. This is a function pointer
824 * entry point called by drivers.
826 s32 e1000_get_cable_length(struct e1000_hw *hw)
828 if (hw->phy.ops.get_cable_length)
829 return hw->phy.ops.get_cable_length(hw);
831 return E1000_SUCCESS;
835 * e1000_get_phy_info - Retrieves PHY information from registers
836 * @hw: pointer to the HW structure
838 * This function gets some information from various PHY registers and
839 * populates hw->phy values with it. This is a function pointer entry
840 * point called by drivers.
842 s32 e1000_get_phy_info(struct e1000_hw *hw)
844 if (hw->phy.ops.get_info)
845 return hw->phy.ops.get_info(hw);
847 return E1000_SUCCESS;
851 * e1000_phy_hw_reset - Hard PHY reset
852 * @hw: pointer to the HW structure
854 * Performs a hard PHY reset. This is a function pointer entry point called
857 s32 e1000_phy_hw_reset(struct e1000_hw *hw)
859 if (hw->phy.ops.reset)
860 return hw->phy.ops.reset(hw);
862 return E1000_SUCCESS;
866 * e1000_phy_commit - Soft PHY reset
867 * @hw: pointer to the HW structure
869 * Performs a soft PHY reset on those that apply. This is a function pointer
870 * entry point called by drivers.
872 s32 e1000_phy_commit(struct e1000_hw *hw)
874 if (hw->phy.ops.commit)
875 return hw->phy.ops.commit(hw);
877 return E1000_SUCCESS;
881 * e1000_set_d0_lplu_state - Sets low power link up state for D0
882 * @hw: pointer to the HW structure
883 * @active: boolean used to enable/disable lplu
885 * Success returns 0, Failure returns 1
887 * The low power link up (lplu) state is set to the power management level D0
888 * and SmartSpeed is disabled when active is true, else clear lplu for D0
889 * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU
890 * is used during Dx states where the power conservation is most important.
891 * During driver activity, SmartSpeed should be enabled so performance is
892 * maintained. This is a function pointer entry point called by drivers.
894 s32 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active)
896 if (hw->phy.ops.set_d0_lplu_state)
897 return hw->phy.ops.set_d0_lplu_state(hw, active);
899 return E1000_SUCCESS;
903 * e1000_set_d3_lplu_state - Sets low power link up state for D3
904 * @hw: pointer to the HW structure
905 * @active: boolean used to enable/disable lplu
907 * Success returns 0, Failure returns 1
909 * The low power link up (lplu) state is set to the power management level D3
910 * and SmartSpeed is disabled when active is true, else clear lplu for D3
911 * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU
912 * is used during Dx states where the power conservation is most important.
913 * During driver activity, SmartSpeed should be enabled so performance is
914 * maintained. This is a function pointer entry point called by drivers.
916 s32 e1000_set_d3_lplu_state(struct e1000_hw *hw, bool active)
918 if (hw->phy.ops.set_d3_lplu_state)
919 return hw->phy.ops.set_d3_lplu_state(hw, active);
921 return E1000_SUCCESS;
925 * e1000_read_mac_addr - Reads MAC address
926 * @hw: pointer to the HW structure
928 * Reads the MAC address out of the adapter and stores it in the HW structure.
929 * Currently no func pointer exists and all implementations are handled in the
930 * generic version of this function.
932 s32 e1000_read_mac_addr(struct e1000_hw *hw)
934 if (hw->mac.ops.read_mac_addr)
935 return hw->mac.ops.read_mac_addr(hw);
937 return e1000_read_mac_addr_generic(hw);
941 * e1000_read_pba_string - Read device part number string
942 * @hw: pointer to the HW structure
943 * @pba_num: pointer to device part number
944 * @pba_num_size: size of part number buffer
946 * Reads the product board assembly (PBA) number from the EEPROM and stores
947 * the value in pba_num.
948 * Currently no func pointer exists and all implementations are handled in the
949 * generic version of this function.
951 s32 e1000_read_pba_string(struct e1000_hw *hw, u8 *pba_num, u32 pba_num_size)
953 return e1000_read_pba_string_generic(hw, pba_num, pba_num_size);
957 * e1000_read_pba_length - Read device part number string length
958 * @hw: pointer to the HW structure
959 * @pba_num_size: size of part number buffer
961 * Reads the product board assembly (PBA) number length from the EEPROM and
962 * stores the value in pba_num.
963 * Currently no func pointer exists and all implementations are handled in the
964 * generic version of this function.
966 s32 e1000_read_pba_length(struct e1000_hw *hw, u32 *pba_num_size)
968 return e1000_read_pba_length_generic(hw, pba_num_size);
972 * e1000_validate_nvm_checksum - Verifies NVM (EEPROM) checksum
973 * @hw: pointer to the HW structure
975 * Validates the NVM checksum is correct. This is a function pointer entry
976 * point called by drivers.
978 s32 e1000_validate_nvm_checksum(struct e1000_hw *hw)
980 if (hw->nvm.ops.validate)
981 return hw->nvm.ops.validate(hw);
983 return -E1000_ERR_CONFIG;
987 * e1000_update_nvm_checksum - Updates NVM (EEPROM) checksum
988 * @hw: pointer to the HW structure
990 * Updates the NVM checksum. Currently no func pointer exists and all
991 * implementations are handled in the generic version of this function.
993 s32 e1000_update_nvm_checksum(struct e1000_hw *hw)
995 if (hw->nvm.ops.update)
996 return hw->nvm.ops.update(hw);
998 return -E1000_ERR_CONFIG;
1002 * e1000_reload_nvm - Reloads EEPROM
1003 * @hw: pointer to the HW structure
1005 * Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the
1006 * extended control register.
1008 void e1000_reload_nvm(struct e1000_hw *hw)
1010 if (hw->nvm.ops.reload)
1011 hw->nvm.ops.reload(hw);
1015 * e1000_read_nvm - Reads NVM (EEPROM)
1016 * @hw: pointer to the HW structure
1017 * @offset: the word offset to read
1018 * @words: number of 16-bit words to read
1019 * @data: pointer to the properly sized buffer for the data.
1021 * Reads 16-bit chunks of data from the NVM (EEPROM). This is a function
1022 * pointer entry point called by drivers.
1024 s32 e1000_read_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
1026 if (hw->nvm.ops.read)
1027 return hw->nvm.ops.read(hw, offset, words, data);
1029 return -E1000_ERR_CONFIG;
1033 * e1000_write_nvm - Writes to NVM (EEPROM)
1034 * @hw: pointer to the HW structure
1035 * @offset: the word offset to read
1036 * @words: number of 16-bit words to write
1037 * @data: pointer to the properly sized buffer for the data.
1039 * Writes 16-bit chunks of data to the NVM (EEPROM). This is a function
1040 * pointer entry point called by drivers.
1042 s32 e1000_write_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
1044 if (hw->nvm.ops.write)
1045 return hw->nvm.ops.write(hw, offset, words, data);
1047 return E1000_SUCCESS;
1051 * e1000_write_8bit_ctrl_reg - Writes 8bit Control register
1052 * @hw: pointer to the HW structure
1053 * @reg: 32bit register offset
1054 * @offset: the register to write
1055 * @data: the value to write.
1057 * Writes the PHY register at offset with the value in data.
1058 * This is a function pointer entry point called by drivers.
1060 s32 e1000_write_8bit_ctrl_reg(struct e1000_hw *hw, u32 reg, u32 offset,
1063 return e1000_write_8bit_ctrl_reg_generic(hw, reg, offset, data);
1067 * e1000_power_up_phy - Restores link in case of PHY power down
1068 * @hw: pointer to the HW structure
1070 * The phy may be powered down to save power, to turn off link when the
1071 * driver is unloaded, or wake on lan is not enabled (among others).
1073 void e1000_power_up_phy(struct e1000_hw *hw)
1075 if (hw->phy.ops.power_up)
1076 hw->phy.ops.power_up(hw);
1078 e1000_setup_link(hw);
1082 * e1000_power_down_phy - Power down PHY
1083 * @hw: pointer to the HW structure
1085 * The phy may be powered down to save power, to turn off link when the
1086 * driver is unloaded, or wake on lan is not enabled (among others).
1088 void e1000_power_down_phy(struct e1000_hw *hw)
1090 if (hw->phy.ops.power_down)
1091 hw->phy.ops.power_down(hw);
1095 * e1000_power_up_fiber_serdes_link - Power up serdes link
1096 * @hw: pointer to the HW structure
1098 * Power on the optics and PCS.
1100 void e1000_power_up_fiber_serdes_link(struct e1000_hw *hw)
1102 if (hw->mac.ops.power_up_serdes)
1103 hw->mac.ops.power_up_serdes(hw);
1107 * e1000_shutdown_fiber_serdes_link - Remove link during power down
1108 * @hw: pointer to the HW structure
1110 * Shutdown the optics and PCS on driver unload.
1112 void e1000_shutdown_fiber_serdes_link(struct e1000_hw *hw)
1114 if (hw->mac.ops.shutdown_serdes)
1115 hw->mac.ops.shutdown_serdes(hw);
1119 * e1000_get_thermal_sensor_data - Gathers thermal sensor data
1120 * @hw: pointer to hardware structure
1122 * Updates the temperatures in mac.thermal_sensor_data
1124 s32 e1000_get_thermal_sensor_data(struct e1000_hw *hw)
1126 if (hw->mac.ops.get_thermal_sensor_data)
1127 return hw->mac.ops.get_thermal_sensor_data(hw);
1129 return E1000_SUCCESS;
1133 * e1000_init_thermal_sensor_thresh - Sets thermal sensor thresholds
1134 * @hw: pointer to hardware structure
1136 * Sets the thermal sensor thresholds according to the NVM map
1138 s32 e1000_init_thermal_sensor_thresh(struct e1000_hw *hw)
1140 if (hw->mac.ops.init_thermal_sensor_thresh)
1141 return hw->mac.ops.init_thermal_sensor_thresh(hw);
1143 return E1000_SUCCESS;