[tcp] Merge boolean flags into a single "flags" field
[gpxe.git] / src / drivers / net / igb / igb_api.c
blobeda6bc01831a40f7684d253d7bc630f2382c6886
1 /*******************************************************************************
3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2009 Intel Corporation.
6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License,
8 version 2, as published by the Free Software Foundation.
10 This program is distributed in the hope it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 more details.
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
22 Contact Information:
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26 *******************************************************************************/
28 FILE_LICENCE ( GPL2_ONLY );
30 #include "igb.h"
32 /**
33 * igb_init_mac_params - Initialize MAC function pointers
34 * @hw: pointer to the HW structure
36 * This function initializes the function pointers for the MAC
37 * set of functions. Called by drivers or by e1000_setup_init_funcs.
38 **/
39 s32 igb_init_mac_params(struct e1000_hw *hw)
41 s32 ret_val = E1000_SUCCESS;
43 if (hw->mac.ops.init_params) {
44 ret_val = hw->mac.ops.init_params(hw);
45 if (ret_val) {
46 DEBUGOUT("MAC Initialization Error\n");
47 goto out;
49 } else {
50 DEBUGOUT("mac.init_mac_params was NULL\n");
51 ret_val = -E1000_ERR_CONFIG;
54 out:
55 return ret_val;
58 /**
59 * igb_init_nvm_params - Initialize NVM function pointers
60 * @hw: pointer to the HW structure
62 * This function initializes the function pointers for the NVM
63 * set of functions. Called by drivers or by e1000_setup_init_funcs.
64 **/
65 s32 igb_init_nvm_params(struct e1000_hw *hw)
67 s32 ret_val = E1000_SUCCESS;
69 if (hw->nvm.ops.init_params) {
70 ret_val = hw->nvm.ops.init_params(hw);
71 if (ret_val) {
72 DEBUGOUT("NVM Initialization Error\n");
73 goto out;
75 } else {
76 DEBUGOUT("nvm.init_nvm_params was NULL\n");
77 ret_val = -E1000_ERR_CONFIG;
80 out:
81 return ret_val;
84 /**
85 * igb_init_phy_params - Initialize PHY function pointers
86 * @hw: pointer to the HW structure
88 * This function initializes the function pointers for the PHY
89 * set of functions. Called by drivers or by e1000_setup_init_funcs.
90 **/
91 s32 igb_init_phy_params(struct e1000_hw *hw)
93 s32 ret_val = E1000_SUCCESS;
95 if (hw->phy.ops.init_params) {
96 ret_val = hw->phy.ops.init_params(hw);
97 if (ret_val) {
98 DEBUGOUT("PHY Initialization Error\n");
99 goto out;
101 } else {
102 DEBUGOUT("phy.init_phy_params was NULL\n");
103 ret_val = -E1000_ERR_CONFIG;
106 out:
107 return ret_val;
110 #if 0
112 * igb_init_mbx_params - Initialize mailbox function pointers
113 * @hw: pointer to the HW structure
115 * This function initializes the function pointers for the PHY
116 * set of functions. Called by drivers or by e1000_setup_init_funcs.
118 s32 igb_init_mbx_params(struct e1000_hw *hw)
120 s32 ret_val = E1000_SUCCESS;
122 if (hw->mbx.ops.init_params) {
123 ret_val = hw->mbx.ops.init_params(hw);
124 if (ret_val) {
125 DEBUGOUT("Mailbox Initialization Error\n");
126 goto out;
128 } else {
129 DEBUGOUT("mbx.init_mbx_params was NULL\n");
130 ret_val = -E1000_ERR_CONFIG;
133 out:
134 return ret_val;
136 #endif
139 * igb_set_mac_type - Sets MAC type
140 * @hw: pointer to the HW structure
142 * This function sets the mac type of the adapter based on the
143 * device ID stored in the hw structure.
144 * MUST BE FIRST FUNCTION CALLED (explicitly or through
145 * igb_setup_init_funcs()).
147 s32 igb_set_mac_type(struct e1000_hw *hw)
149 struct e1000_mac_info *mac = &hw->mac;
150 s32 ret_val = E1000_SUCCESS;
152 DEBUGFUNC("igb_set_mac_type");
154 switch (hw->device_id) {
155 case E1000_DEV_ID_82575EB_COPPER:
156 case E1000_DEV_ID_82575EB_FIBER_SERDES:
157 case E1000_DEV_ID_82575GB_QUAD_COPPER:
158 mac->type = e1000_82575;
159 break;
160 case E1000_DEV_ID_82576:
161 case E1000_DEV_ID_82576_FIBER:
162 case E1000_DEV_ID_82576_SERDES:
163 case E1000_DEV_ID_82576_QUAD_COPPER:
164 case E1000_DEV_ID_82576_NS:
165 case E1000_DEV_ID_82576_NS_SERDES:
166 case E1000_DEV_ID_82576_SERDES_QUAD:
167 mac->type = e1000_82576;
168 break;
169 default:
170 /* Should never have loaded on this device */
171 ret_val = -E1000_ERR_MAC_INIT;
172 break;
175 return ret_val;
179 * igb_setup_init_funcs - Initializes function pointers
180 * @hw: pointer to the HW structure
181 * @init_device: true will initialize the rest of the function pointers
182 * getting the device ready for use. false will only set
183 * MAC type and the function pointers for the other init
184 * functions. Passing false will not generate any hardware
185 * reads or writes.
187 * This function must be called by a driver in order to use the rest
188 * of the 'shared' code files. Called by drivers only.
190 s32 igb_setup_init_funcs(struct e1000_hw *hw, bool init_device)
192 s32 ret_val;
194 /* Can't do much good without knowing the MAC type. */
195 ret_val = igb_set_mac_type(hw);
196 if (ret_val) {
197 DEBUGOUT("ERROR: MAC type could not be set properly.\n");
198 goto out;
201 if (!hw->hw_addr) {
202 DEBUGOUT("ERROR: Registers not mapped\n");
203 ret_val = -E1000_ERR_CONFIG;
204 goto out;
208 * Init function pointers to generic implementations. We do this first
209 * allowing a driver module to override it afterward.
211 igb_init_mac_ops_generic(hw);
212 igb_init_nvm_ops_generic(hw);
213 #if 0
214 igb_init_mbx_ops_generic(hw);
215 #endif
217 * Set up the init function pointers. These are functions within the
218 * adapter family file that sets up function pointers for the rest of
219 * the functions in that family.
221 switch (hw->mac.type) {
222 case e1000_82575:
223 case e1000_82576:
224 igb_init_function_pointers_82575(hw);
225 break;
226 default:
227 DEBUGOUT("Hardware not supported\n");
228 ret_val = -E1000_ERR_CONFIG;
229 break;
233 * Initialize the rest of the function pointers. These require some
234 * register reads/writes in some cases.
236 if (!(ret_val) && init_device) {
237 ret_val = igb_init_mac_params(hw);
238 if (ret_val)
239 goto out;
241 ret_val = igb_init_nvm_params(hw);
242 if (ret_val)
243 goto out;
245 ret_val = igb_init_phy_params(hw);
246 if (ret_val)
247 goto out;
248 #if 0
249 ret_val = igb_init_mbx_params(hw);
250 if (ret_val)
251 goto out;
252 #endif
255 out:
256 return ret_val;
260 * igb_get_bus_info - Obtain bus information for adapter
261 * @hw: pointer to the HW structure
263 * This will obtain information about the HW bus for which the
264 * adapter is attached and stores it in the hw structure. This is a
265 * function pointer entry point called by drivers.
267 s32 igb_get_bus_info(struct e1000_hw *hw)
269 if (hw->mac.ops.get_bus_info)
270 return hw->mac.ops.get_bus_info(hw);
272 return E1000_SUCCESS;
276 * igb_clear_vfta - Clear VLAN filter table
277 * @hw: pointer to the HW structure
279 * This clears the VLAN filter table on the adapter. This is a function
280 * pointer entry point called by drivers.
282 void igb_clear_vfta(struct e1000_hw *hw)
284 if (hw->mac.ops.clear_vfta)
285 hw->mac.ops.clear_vfta(hw);
289 * igb_write_vfta - Write value to VLAN filter table
290 * @hw: pointer to the HW structure
291 * @offset: the 32-bit offset in which to write the value to.
292 * @value: the 32-bit value to write at location offset.
294 * This writes a 32-bit value to a 32-bit offset in the VLAN filter
295 * table. This is a function pointer entry point called by drivers.
297 void igb_write_vfta(struct e1000_hw *hw, u32 offset, u32 value)
299 if (hw->mac.ops.write_vfta)
300 hw->mac.ops.write_vfta(hw, offset, value);
304 * igb_update_mc_addr_list - Update Multicast addresses
305 * @hw: pointer to the HW structure
306 * @mc_addr_list: array of multicast addresses to program
307 * @mc_addr_count: number of multicast addresses to program
309 * Updates the Multicast Table Array.
310 * The caller must have a packed mc_addr_list of multicast addresses.
312 void igb_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list,
313 u32 mc_addr_count)
315 if (hw->mac.ops.update_mc_addr_list)
316 hw->mac.ops.update_mc_addr_list(hw, mc_addr_list,
317 mc_addr_count);
321 * igb_force_mac_fc - Force MAC flow control
322 * @hw: pointer to the HW structure
324 * Force the MAC's flow control settings. Currently no func pointer exists
325 * and all implementations are handled in the generic version of this
326 * function.
328 s32 igb_force_mac_fc(struct e1000_hw *hw)
330 return igb_force_mac_fc_generic(hw);
334 * igb_check_for_link - Check/Store link connection
335 * @hw: pointer to the HW structure
337 * This checks the link condition of the adapter and stores the
338 * results in the hw->mac structure. This is a function pointer entry
339 * point called by drivers.
341 s32 igb_check_for_link(struct e1000_hw *hw)
343 if (hw->mac.ops.check_for_link)
344 return hw->mac.ops.check_for_link(hw);
346 return -E1000_ERR_CONFIG;
350 * igb_check_mng_mode - Check management mode
351 * @hw: pointer to the HW structure
353 * This checks if the adapter has manageability enabled.
354 * This is a function pointer entry point called by drivers.
356 bool igb_check_mng_mode(struct e1000_hw *hw)
358 if (hw->mac.ops.check_mng_mode)
359 return hw->mac.ops.check_mng_mode(hw);
361 return false;
364 #if 0
366 * igb_mng_write_dhcp_info - Writes DHCP info to host interface
367 * @hw: pointer to the HW structure
368 * @buffer: pointer to the host interface
369 * @length: size of the buffer
371 * Writes the DHCP information to the host interface.
373 s32 igb_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length)
375 return igb_mng_write_dhcp_info_generic(hw, buffer, length);
377 #endif
380 * igb_reset_hw - Reset hardware
381 * @hw: pointer to the HW structure
383 * This resets the hardware into a known state. This is a function pointer
384 * entry point called by drivers.
386 s32 igb_reset_hw(struct e1000_hw *hw)
388 if (hw->mac.ops.reset_hw)
389 return hw->mac.ops.reset_hw(hw);
391 return -E1000_ERR_CONFIG;
395 * igb_init_hw - Initialize hardware
396 * @hw: pointer to the HW structure
398 * This inits the hardware readying it for operation. This is a function
399 * pointer entry point called by drivers.
401 s32 igb_init_hw(struct e1000_hw *hw)
403 if (hw->mac.ops.init_hw)
404 return hw->mac.ops.init_hw(hw);
406 return -E1000_ERR_CONFIG;
410 * igb_setup_link - Configures link and flow control
411 * @hw: pointer to the HW structure
413 * This configures link and flow control settings for the adapter. This
414 * is a function pointer entry point called by drivers. While modules can
415 * also call this, they probably call their own version of this function.
417 s32 igb_setup_link(struct e1000_hw *hw)
419 if (hw->mac.ops.setup_link)
420 return hw->mac.ops.setup_link(hw);
422 return -E1000_ERR_CONFIG;
426 * igb_get_speed_and_duplex - Returns current speed and duplex
427 * @hw: pointer to the HW structure
428 * @speed: pointer to a 16-bit value to store the speed
429 * @duplex: pointer to a 16-bit value to store the duplex.
431 * This returns the speed and duplex of the adapter in the two 'out'
432 * variables passed in. This is a function pointer entry point called
433 * by drivers.
435 s32 igb_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex)
437 if (hw->mac.ops.get_link_up_info)
438 return hw->mac.ops.get_link_up_info(hw, speed, duplex);
440 return -E1000_ERR_CONFIG;
444 * igb_setup_led - Configures SW controllable LED
445 * @hw: pointer to the HW structure
447 * This prepares the SW controllable LED for use and saves the current state
448 * of the LED so it can be later restored. This is a function pointer entry
449 * point called by drivers.
451 s32 igb_setup_led(struct e1000_hw *hw)
453 if (hw->mac.ops.setup_led)
454 return hw->mac.ops.setup_led(hw);
456 return E1000_SUCCESS;
460 * igb_cleanup_led - Restores SW controllable LED
461 * @hw: pointer to the HW structure
463 * This restores the SW controllable LED to the value saved off by
464 * e1000_setup_led. This is a function pointer entry point called by drivers.
466 s32 igb_cleanup_led(struct e1000_hw *hw)
468 if (hw->mac.ops.cleanup_led)
469 return hw->mac.ops.cleanup_led(hw);
471 return E1000_SUCCESS;
475 * igb_blink_led - Blink SW controllable LED
476 * @hw: pointer to the HW structure
478 * This starts the adapter LED blinking. Request the LED to be setup first
479 * and cleaned up after. This is a function pointer entry point called by
480 * drivers.
482 s32 igb_blink_led(struct e1000_hw *hw)
484 if (hw->mac.ops.blink_led)
485 return hw->mac.ops.blink_led(hw);
487 return E1000_SUCCESS;
491 * igb_id_led_init - store LED configurations in SW
492 * @hw: pointer to the HW structure
494 * Initializes the LED config in SW. This is a function pointer entry point
495 * called by drivers.
497 s32 igb_id_led_init(struct e1000_hw *hw)
499 if (hw->mac.ops.id_led_init)
500 return hw->mac.ops.id_led_init(hw);
502 return E1000_SUCCESS;
506 * igb_led_on - Turn on SW controllable LED
507 * @hw: pointer to the HW structure
509 * Turns the SW defined LED on. This is a function pointer entry point
510 * called by drivers.
512 s32 igb_led_on(struct e1000_hw *hw)
514 if (hw->mac.ops.led_on)
515 return hw->mac.ops.led_on(hw);
517 return E1000_SUCCESS;
521 * igb_led_off - Turn off SW controllable LED
522 * @hw: pointer to the HW structure
524 * Turns the SW defined LED off. This is a function pointer entry point
525 * called by drivers.
527 s32 igb_led_off(struct e1000_hw *hw)
529 if (hw->mac.ops.led_off)
530 return hw->mac.ops.led_off(hw);
532 return E1000_SUCCESS;
536 * igb_reset_adaptive - Reset adaptive IFS
537 * @hw: pointer to the HW structure
539 * Resets the adaptive IFS. Currently no func pointer exists and all
540 * implementations are handled in the generic version of this function.
542 void igb_reset_adaptive(struct e1000_hw *hw)
544 igb_reset_adaptive_generic(hw);
548 * igb_update_adaptive - Update adaptive IFS
549 * @hw: pointer to the HW structure
551 * Updates adapter IFS. Currently no func pointer exists and all
552 * implementations are handled in the generic version of this function.
554 void igb_update_adaptive(struct e1000_hw *hw)
556 igb_update_adaptive_generic(hw);
560 * igb_disable_pcie_master - Disable PCI-Express master access
561 * @hw: pointer to the HW structure
563 * Disables PCI-Express master access and verifies there are no pending
564 * requests. Currently no func pointer exists and all implementations are
565 * handled in the generic version of this function.
567 s32 igb_disable_pcie_master(struct e1000_hw *hw)
569 return igb_disable_pcie_master_generic(hw);
573 * igb_config_collision_dist - Configure collision distance
574 * @hw: pointer to the HW structure
576 * Configures the collision distance to the default value and is used
577 * during link setup.
579 void igb_config_collision_dist(struct e1000_hw *hw)
581 if (hw->mac.ops.config_collision_dist)
582 hw->mac.ops.config_collision_dist(hw);
586 * igb_rar_set - Sets a receive address register
587 * @hw: pointer to the HW structure
588 * @addr: address to set the RAR to
589 * @index: the RAR to set
591 * Sets a Receive Address Register (RAR) to the specified address.
593 void igb_rar_set(struct e1000_hw *hw, u8 *addr, u32 index)
595 if (hw->mac.ops.rar_set)
596 hw->mac.ops.rar_set(hw, addr, index);
600 * igb_validate_mdi_setting - Ensures valid MDI/MDIX SW state
601 * @hw: pointer to the HW structure
603 * Ensures that the MDI/MDIX SW state is valid.
605 s32 igb_validate_mdi_setting(struct e1000_hw *hw)
607 if (hw->mac.ops.validate_mdi_setting)
608 return hw->mac.ops.validate_mdi_setting(hw);
610 return E1000_SUCCESS;
614 * igb_mta_set - Sets multicast table bit
615 * @hw: pointer to the HW structure
616 * @hash_value: Multicast hash value.
618 * This sets the bit in the multicast table corresponding to the
619 * hash value. This is a function pointer entry point called by drivers.
621 void igb_mta_set(struct e1000_hw *hw, u32 hash_value)
623 if (hw->mac.ops.mta_set)
624 hw->mac.ops.mta_set(hw, hash_value);
628 * igb_hash_mc_addr - Determines address location in multicast table
629 * @hw: pointer to the HW structure
630 * @mc_addr: Multicast address to hash.
632 * This hashes an address to determine its location in the multicast
633 * table. Currently no func pointer exists and all implementations
634 * are handled in the generic version of this function.
636 u32 igb_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr)
638 return igb_hash_mc_addr_generic(hw, mc_addr);
642 * igb_enable_tx_pkt_filtering - Enable packet filtering on TX
643 * @hw: pointer to the HW structure
645 * Enables packet filtering on transmit packets if manageability is enabled
646 * and host interface is enabled.
647 * Currently no func pointer exists and all implementations are handled in the
648 * generic version of this function.
650 #if 0
651 bool igb_enable_tx_pkt_filtering(struct e1000_hw *hw)
653 return igb_enable_tx_pkt_filtering_generic(hw);
655 #endif
658 * igb_mng_host_if_write - Writes to the manageability host interface
659 * @hw: pointer to the HW structure
660 * @buffer: pointer to the host interface buffer
661 * @length: size of the buffer
662 * @offset: location in the buffer to write to
663 * @sum: sum of the data (not checksum)
665 * This function writes the buffer content at the offset given on the host if.
666 * It also does alignment considerations to do the writes in most efficient
667 * way. Also fills up the sum of the buffer in *buffer parameter.
669 s32 igb_mng_host_if_write(struct e1000_hw * hw, u8 *buffer, u16 length,
670 u16 offset, u8 *sum)
672 if (hw->mac.ops.mng_host_if_write)
673 return hw->mac.ops.mng_host_if_write(hw, buffer, length,
674 offset, sum);
676 return E1000_NOT_IMPLEMENTED;
680 * igb_mng_write_cmd_header - Writes manageability command header
681 * @hw: pointer to the HW structure
682 * @hdr: pointer to the host interface command header
684 * Writes the command header after does the checksum calculation.
686 s32 igb_mng_write_cmd_header(struct e1000_hw *hw,
687 struct e1000_host_mng_command_header *hdr)
689 if (hw->mac.ops.mng_write_cmd_header)
690 return hw->mac.ops.mng_write_cmd_header(hw, hdr);
692 return E1000_NOT_IMPLEMENTED;
696 * igb_mng_enable_host_if - Checks host interface is enabled
697 * @hw: pointer to the HW structure
699 * Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND
701 * This function checks whether the HOST IF is enabled for command operation
702 * and also checks whether the previous command is completed. It busy waits
703 * in case of previous command is not completed.
705 s32 igb_mng_enable_host_if(struct e1000_hw * hw)
707 if (hw->mac.ops.mng_enable_host_if)
708 return hw->mac.ops.mng_enable_host_if(hw);
710 return E1000_NOT_IMPLEMENTED;
714 * igb_wait_autoneg - Waits for autonegotiation completion
715 * @hw: pointer to the HW structure
717 * Waits for autoneg to complete. Currently no func pointer exists and all
718 * implementations are handled in the generic version of this function.
720 s32 igb_wait_autoneg(struct e1000_hw *hw)
722 if (hw->mac.ops.wait_autoneg)
723 return hw->mac.ops.wait_autoneg(hw);
725 return E1000_SUCCESS;
729 * igb_check_reset_block - Verifies PHY can be reset
730 * @hw: pointer to the HW structure
732 * Checks if the PHY is in a state that can be reset or if manageability
733 * has it tied up. This is a function pointer entry point called by drivers.
735 s32 igb_check_reset_block(struct e1000_hw *hw)
737 if (hw->phy.ops.check_reset_block)
738 return hw->phy.ops.check_reset_block(hw);
740 return E1000_SUCCESS;
744 * igb_read_phy_reg - Reads PHY register
745 * @hw: pointer to the HW structure
746 * @offset: the register to read
747 * @data: the buffer to store the 16-bit read.
749 * Reads the PHY register and returns the value in data.
750 * This is a function pointer entry point called by drivers.
752 s32 igb_read_phy_reg(struct e1000_hw *hw, u32 offset, u16 *data)
754 if (hw->phy.ops.read_reg)
755 return hw->phy.ops.read_reg(hw, offset, data);
757 return E1000_SUCCESS;
761 * igb_write_phy_reg - Writes PHY register
762 * @hw: pointer to the HW structure
763 * @offset: the register to write
764 * @data: the value to write.
766 * Writes the PHY register at offset with the value in data.
767 * This is a function pointer entry point called by drivers.
769 s32 igb_write_phy_reg(struct e1000_hw *hw, u32 offset, u16 data)
771 if (hw->phy.ops.write_reg)
772 return hw->phy.ops.write_reg(hw, offset, data);
774 return E1000_SUCCESS;
778 * igb_release_phy - Generic release PHY
779 * @hw: pointer to the HW structure
781 * Return if silicon family does not require a semaphore when accessing the
782 * PHY.
784 void igb_release_phy(struct e1000_hw *hw)
786 if (hw->phy.ops.release)
787 hw->phy.ops.release(hw);
791 * igb_acquire_phy - Generic acquire PHY
792 * @hw: pointer to the HW structure
794 * Return success if silicon family does not require a semaphore when
795 * accessing the PHY.
797 s32 igb_acquire_phy(struct e1000_hw *hw)
799 if (hw->phy.ops.acquire)
800 return hw->phy.ops.acquire(hw);
802 return E1000_SUCCESS;
806 * igb_read_kmrn_reg - Reads register using Kumeran interface
807 * @hw: pointer to the HW structure
808 * @offset: the register to read
809 * @data: the location to store the 16-bit value read.
811 * Reads a register out of the Kumeran interface. Currently no func pointer
812 * exists and all implementations are handled in the generic version of
813 * this function.
815 s32 igb_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data)
817 return igb_read_kmrn_reg_generic(hw, offset, data);
821 * igb_write_kmrn_reg - Writes register using Kumeran interface
822 * @hw: pointer to the HW structure
823 * @offset: the register to write
824 * @data: the value to write.
826 * Writes a register to the Kumeran interface. Currently no func pointer
827 * exists and all implementations are handled in the generic version of
828 * this function.
830 s32 igb_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data)
832 return igb_write_kmrn_reg_generic(hw, offset, data);
835 #if 0
837 * igb_get_cable_length - Retrieves cable length estimation
838 * @hw: pointer to the HW structure
840 * This function estimates the cable length and stores them in
841 * hw->phy.min_length and hw->phy.max_length. This is a function pointer
842 * entry point called by drivers.
844 s32 igb_get_cable_length(struct e1000_hw *hw)
846 if (hw->phy.ops.get_cable_length)
847 return hw->phy.ops.get_cable_length(hw);
849 return E1000_SUCCESS;
851 #endif
854 * igb_get_phy_info - Retrieves PHY information from registers
855 * @hw: pointer to the HW structure
857 * This function gets some information from various PHY registers and
858 * populates hw->phy values with it. This is a function pointer entry
859 * point called by drivers.
861 s32 igb_get_phy_info(struct e1000_hw *hw)
863 if (hw->phy.ops.get_info)
864 return hw->phy.ops.get_info(hw);
866 return E1000_SUCCESS;
870 * igb_phy_hw_reset - Hard PHY reset
871 * @hw: pointer to the HW structure
873 * Performs a hard PHY reset. This is a function pointer entry point called
874 * by drivers.
876 s32 igb_phy_hw_reset(struct e1000_hw *hw)
878 if (hw->phy.ops.reset)
879 return hw->phy.ops.reset(hw);
881 return E1000_SUCCESS;
885 * igb_phy_commit - Soft PHY reset
886 * @hw: pointer to the HW structure
888 * Performs a soft PHY reset on those that apply. This is a function pointer
889 * entry point called by drivers.
891 s32 igb_phy_commit(struct e1000_hw *hw)
893 if (hw->phy.ops.commit)
894 return hw->phy.ops.commit(hw);
896 return E1000_SUCCESS;
900 * igb_set_d0_lplu_state - Sets low power link up state for D0
901 * @hw: pointer to the HW structure
902 * @active: boolean used to enable/disable lplu
904 * Success returns 0, Failure returns 1
906 * The low power link up (lplu) state is set to the power management level D0
907 * and SmartSpeed is disabled when active is true, else clear lplu for D0
908 * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU
909 * is used during Dx states where the power conservation is most important.
910 * During driver activity, SmartSpeed should be enabled so performance is
911 * maintained. This is a function pointer entry point called by drivers.
913 s32 igb_set_d0_lplu_state(struct e1000_hw *hw, bool active)
915 if (hw->phy.ops.set_d0_lplu_state)
916 return hw->phy.ops.set_d0_lplu_state(hw, active);
918 return E1000_SUCCESS;
922 * igb_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
926 * Success returns 0, Failure returns 1
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.
935 s32 igb_set_d3_lplu_state(struct e1000_hw *hw, bool active)
937 if (hw->phy.ops.set_d3_lplu_state)
938 return hw->phy.ops.set_d3_lplu_state(hw, active);
940 return E1000_SUCCESS;
944 * igb_read_mac_addr - Reads MAC address
945 * @hw: pointer to the HW structure
947 * Reads the MAC address out of the adapter and stores it in the HW structure.
948 * Currently no func pointer exists and all implementations are handled in the
949 * generic version of this function.
951 s32 igb_read_mac_addr(struct e1000_hw *hw)
953 if (hw->mac.ops.read_mac_addr)
954 return hw->mac.ops.read_mac_addr(hw);
956 return igb_read_mac_addr_generic(hw);
960 * igb_read_pba_num - Read device part number
961 * @hw: pointer to the HW structure
962 * @pba_num: pointer to device part number
964 * Reads the product board assembly (PBA) number from the EEPROM and stores
965 * the value in pba_num.
966 * Currently no func pointer exists and all implementations are handled in the
967 * generic version of this function.
969 s32 igb_read_pba_num(struct e1000_hw *hw, u32 *pba_num)
971 return igb_read_pba_num_generic(hw, pba_num);
975 * igb_validate_nvm_checksum - Verifies NVM (EEPROM) checksum
976 * @hw: pointer to the HW structure
978 * Validates the NVM checksum is correct. This is a function pointer entry
979 * point called by drivers.
981 s32 igb_validate_nvm_checksum(struct e1000_hw *hw)
983 if (hw->nvm.ops.validate)
984 return hw->nvm.ops.validate(hw);
986 return -E1000_ERR_CONFIG;
990 * igb_update_nvm_checksum - Updates NVM (EEPROM) checksum
991 * @hw: pointer to the HW structure
993 * Updates the NVM checksum. Currently no func pointer exists and all
994 * implementations are handled in the generic version of this function.
996 s32 igb_update_nvm_checksum(struct e1000_hw *hw)
998 if (hw->nvm.ops.update)
999 return hw->nvm.ops.update(hw);
1001 return -E1000_ERR_CONFIG;
1005 * igb_reload_nvm - Reloads EEPROM
1006 * @hw: pointer to the HW structure
1008 * Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the
1009 * extended control register.
1011 void igb_reload_nvm(struct e1000_hw *hw)
1013 if (hw->nvm.ops.reload)
1014 hw->nvm.ops.reload(hw);
1018 * igb_read_nvm - Reads NVM (EEPROM)
1019 * @hw: pointer to the HW structure
1020 * @offset: the word offset to read
1021 * @words: number of 16-bit words to read
1022 * @data: pointer to the properly sized buffer for the data.
1024 * Reads 16-bit chunks of data from the NVM (EEPROM). This is a function
1025 * pointer entry point called by drivers.
1027 s32 igb_read_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
1029 if (hw->nvm.ops.read)
1030 return hw->nvm.ops.read(hw, offset, words, data);
1032 return -E1000_ERR_CONFIG;
1036 * igb_write_nvm - Writes to NVM (EEPROM)
1037 * @hw: pointer to the HW structure
1038 * @offset: the word offset to read
1039 * @words: number of 16-bit words to write
1040 * @data: pointer to the properly sized buffer for the data.
1042 * Writes 16-bit chunks of data to the NVM (EEPROM). This is a function
1043 * pointer entry point called by drivers.
1045 s32 igb_write_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
1047 if (hw->nvm.ops.write)
1048 return hw->nvm.ops.write(hw, offset, words, data);
1050 return E1000_SUCCESS;
1054 * igb_write_8bit_ctrl_reg - Writes 8bit Control register
1055 * @hw: pointer to the HW structure
1056 * @reg: 32bit register offset
1057 * @offset: the register to write
1058 * @data: the value to write.
1060 * Writes the PHY register at offset with the value in data.
1061 * This is a function pointer entry point called by drivers.
1063 s32 igb_write_8bit_ctrl_reg(struct e1000_hw *hw, u32 reg, u32 offset,
1064 u8 data)
1066 return igb_write_8bit_ctrl_reg_generic(hw, reg, offset, data);
1070 * igb_power_up_phy - Restores link in case of PHY power down
1071 * @hw: pointer to the HW structure
1073 * The phy may be powered down to save power, to turn off link when the
1074 * driver is unloaded, or wake on lan is not enabled (among others).
1076 void igb_power_up_phy(struct e1000_hw *hw)
1078 if (hw->phy.ops.power_up)
1079 hw->phy.ops.power_up(hw);
1081 igb_setup_link(hw);
1085 * igb_power_down_phy - Power down PHY
1086 * @hw: pointer to the HW structure
1088 * The phy may be powered down to save power, to turn off link when the
1089 * driver is unloaded, or wake on lan is not enabled (among others).
1091 void igb_power_down_phy(struct e1000_hw *hw)
1093 if (hw->phy.ops.power_down)
1094 hw->phy.ops.power_down(hw);
1098 * igb_shutdown_fiber_serdes_link - Remove link during power down
1099 * @hw: pointer to the HW structure
1101 * Shutdown the optics and PCS on driver unload.
1103 void igb_shutdown_fiber_serdes_link(struct e1000_hw *hw)
1105 if (hw->mac.ops.shutdown_serdes)
1106 hw->mac.ops.shutdown_serdes(hw);