Imported Upstream version 16.11
[deb_dpdk.git] / lib / librte_eal / linuxapp / kni / ethtool / ixgbe / ixgbe_api.c
1 /*******************************************************************************
2
3   Intel 10 Gigabit PCI Express Linux driver
4   Copyright(c) 1999 - 2012 Intel Corporation.
5
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.
9
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.
14
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.
18
19   The full GNU General Public License is included in this distribution in
20   the file called "LICENSE.GPL".
21
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
25
26 *******************************************************************************/
27
28 #include "ixgbe_api.h"
29 #include "ixgbe_common.h"
30
31 /**
32  *  ixgbe_init_shared_code - Initialize the shared code
33  *  @hw: pointer to hardware structure
34  *
35  *  This will assign function pointers and assign the MAC type and PHY code.
36  *  Does not touch the hardware. This function must be called prior to any
37  *  other function in the shared code. The ixgbe_hw structure should be
38  *  memset to 0 prior to calling this function.  The following fields in
39  *  hw structure should be filled in prior to calling this function:
40  *  hw_addr, back, device_id, vendor_id, subsystem_device_id,
41  *  subsystem_vendor_id, and revision_id
42  **/
43 s32 ixgbe_init_shared_code(struct ixgbe_hw *hw)
44 {
45         s32 status;
46
47         /*
48          * Set the mac type
49          */
50         ixgbe_set_mac_type(hw);
51
52         switch (hw->mac.type) {
53         case ixgbe_mac_82598EB:
54                 status = ixgbe_init_ops_82598(hw);
55                 break;
56         case ixgbe_mac_82599EB:
57                 status = ixgbe_init_ops_82599(hw);
58                 break;
59         case ixgbe_mac_X540:
60                 status = ixgbe_init_ops_X540(hw);
61                 break;
62         default:
63                 status = IXGBE_ERR_DEVICE_NOT_SUPPORTED;
64                 break;
65         }
66
67         return status;
68 }
69
70 /**
71  *  ixgbe_set_mac_type - Sets MAC type
72  *  @hw: pointer to the HW structure
73  *
74  *  This function sets the mac type of the adapter based on the
75  *  vendor ID and device ID stored in the hw structure.
76  **/
77 s32 ixgbe_set_mac_type(struct ixgbe_hw *hw)
78 {
79         s32 ret_val = 0;
80
81         if (hw->vendor_id == IXGBE_INTEL_VENDOR_ID) {
82                 switch (hw->device_id) {
83                 case IXGBE_DEV_ID_82598:
84                 case IXGBE_DEV_ID_82598_BX:
85                 case IXGBE_DEV_ID_82598AF_SINGLE_PORT:
86                 case IXGBE_DEV_ID_82598AF_DUAL_PORT:
87                 case IXGBE_DEV_ID_82598AT:
88                 case IXGBE_DEV_ID_82598AT2:
89                 case IXGBE_DEV_ID_82598EB_CX4:
90                 case IXGBE_DEV_ID_82598_CX4_DUAL_PORT:
91                 case IXGBE_DEV_ID_82598_DA_DUAL_PORT:
92                 case IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM:
93                 case IXGBE_DEV_ID_82598EB_XF_LR:
94                 case IXGBE_DEV_ID_82598EB_SFP_LOM:
95                         hw->mac.type = ixgbe_mac_82598EB;
96                         break;
97                 case IXGBE_DEV_ID_82599_KX4:
98                 case IXGBE_DEV_ID_82599_KX4_MEZZ:
99                 case IXGBE_DEV_ID_82599_XAUI_LOM:
100                 case IXGBE_DEV_ID_82599_COMBO_BACKPLANE:
101                 case IXGBE_DEV_ID_82599_KR:
102                 case IXGBE_DEV_ID_82599_SFP:
103                 case IXGBE_DEV_ID_82599_BACKPLANE_FCOE:
104                 case IXGBE_DEV_ID_82599_SFP_FCOE:
105                 case IXGBE_DEV_ID_82599_SFP_EM:
106                 case IXGBE_DEV_ID_82599_SFP_SF2:
107                 case IXGBE_DEV_ID_82599_QSFP_SF_QP:
108                 case IXGBE_DEV_ID_82599EN_SFP:
109                 case IXGBE_DEV_ID_82599_CX4:
110                 case IXGBE_DEV_ID_82599_LS:
111                 case IXGBE_DEV_ID_82599_T3_LOM:
112                         hw->mac.type = ixgbe_mac_82599EB;
113                         break;
114                 case IXGBE_DEV_ID_X540T:
115                         hw->mac.type = ixgbe_mac_X540;
116                         break;
117                 default:
118                         ret_val = IXGBE_ERR_DEVICE_NOT_SUPPORTED;
119                         break;
120                 }
121         } else {
122                 ret_val = IXGBE_ERR_DEVICE_NOT_SUPPORTED;
123         }
124
125         hw_dbg(hw, "ixgbe_set_mac_type found mac: %d, returns: %d\n",
126                   hw->mac.type, ret_val);
127         return ret_val;
128 }
129
130 /**
131  *  ixgbe_init_hw - Initialize the hardware
132  *  @hw: pointer to hardware structure
133  *
134  *  Initialize the hardware by resetting and then starting the hardware
135  **/
136 s32 ixgbe_init_hw(struct ixgbe_hw *hw)
137 {
138         return ixgbe_call_func(hw, hw->mac.ops.init_hw, (hw),
139                                IXGBE_NOT_IMPLEMENTED);
140 }
141
142 /**
143  *  ixgbe_reset_hw - Performs a hardware reset
144  *  @hw: pointer to hardware structure
145  *
146  *  Resets the hardware by resetting the transmit and receive units, masks and
147  *  clears all interrupts, performs a PHY reset, and performs a MAC reset
148  **/
149 s32 ixgbe_reset_hw(struct ixgbe_hw *hw)
150 {
151         return ixgbe_call_func(hw, hw->mac.ops.reset_hw, (hw),
152                                IXGBE_NOT_IMPLEMENTED);
153 }
154
155 /**
156  *  ixgbe_start_hw - Prepares hardware for Rx/Tx
157  *  @hw: pointer to hardware structure
158  *
159  *  Starts the hardware by filling the bus info structure and media type,
160  *  clears all on chip counters, initializes receive address registers,
161  *  multicast table, VLAN filter table, calls routine to setup link and
162  *  flow control settings, and leaves transmit and receive units disabled
163  *  and uninitialized.
164  **/
165 s32 ixgbe_start_hw(struct ixgbe_hw *hw)
166 {
167         return ixgbe_call_func(hw, hw->mac.ops.start_hw, (hw),
168                                IXGBE_NOT_IMPLEMENTED);
169 }
170
171 /**
172  *  ixgbe_clear_hw_cntrs - Clear hardware counters
173  *  @hw: pointer to hardware structure
174  *
175  *  Clears all hardware statistics counters by reading them from the hardware
176  *  Statistics counters are clear on read.
177  **/
178 s32 ixgbe_clear_hw_cntrs(struct ixgbe_hw *hw)
179 {
180         return ixgbe_call_func(hw, hw->mac.ops.clear_hw_cntrs, (hw),
181                                IXGBE_NOT_IMPLEMENTED);
182 }
183
184 /**
185  *  ixgbe_get_media_type - Get media type
186  *  @hw: pointer to hardware structure
187  *
188  *  Returns the media type (fiber, copper, backplane)
189  **/
190 enum ixgbe_media_type ixgbe_get_media_type(struct ixgbe_hw *hw)
191 {
192         return ixgbe_call_func(hw, hw->mac.ops.get_media_type, (hw),
193                                ixgbe_media_type_unknown);
194 }
195
196 /**
197  *  ixgbe_get_mac_addr - Get MAC address
198  *  @hw: pointer to hardware structure
199  *  @mac_addr: Adapter MAC address
200  *
201  *  Reads the adapter's MAC address from the first Receive Address Register
202  *  (RAR0) A reset of the adapter must have been performed prior to calling
203  *  this function in order for the MAC address to have been loaded from the
204  *  EEPROM into RAR0
205  **/
206 s32 ixgbe_get_mac_addr(struct ixgbe_hw *hw, u8 *mac_addr)
207 {
208         return ixgbe_call_func(hw, hw->mac.ops.get_mac_addr,
209                                (hw, mac_addr), IXGBE_NOT_IMPLEMENTED);
210 }
211
212 /**
213  *  ixgbe_get_san_mac_addr - Get SAN MAC address
214  *  @hw: pointer to hardware structure
215  *  @san_mac_addr: SAN MAC address
216  *
217  *  Reads the SAN MAC address from the EEPROM, if it's available.  This is
218  *  per-port, so set_lan_id() must be called before reading the addresses.
219  **/
220 s32 ixgbe_get_san_mac_addr(struct ixgbe_hw *hw, u8 *san_mac_addr)
221 {
222         return ixgbe_call_func(hw, hw->mac.ops.get_san_mac_addr,
223                                (hw, san_mac_addr), IXGBE_NOT_IMPLEMENTED);
224 }
225
226 /**
227  *  ixgbe_set_san_mac_addr - Write a SAN MAC address
228  *  @hw: pointer to hardware structure
229  *  @san_mac_addr: SAN MAC address
230  *
231  *  Writes A SAN MAC address to the EEPROM.
232  **/
233 s32 ixgbe_set_san_mac_addr(struct ixgbe_hw *hw, u8 *san_mac_addr)
234 {
235         return ixgbe_call_func(hw, hw->mac.ops.set_san_mac_addr,
236                                (hw, san_mac_addr), IXGBE_NOT_IMPLEMENTED);
237 }
238
239 /**
240  *  ixgbe_get_device_caps - Get additional device capabilities
241  *  @hw: pointer to hardware structure
242  *  @device_caps: the EEPROM word for device capabilities
243  *
244  *  Reads the extra device capabilities from the EEPROM
245  **/
246 s32 ixgbe_get_device_caps(struct ixgbe_hw *hw, u16 *device_caps)
247 {
248         return ixgbe_call_func(hw, hw->mac.ops.get_device_caps,
249                                (hw, device_caps), IXGBE_NOT_IMPLEMENTED);
250 }
251
252 /**
253  *  ixgbe_get_wwn_prefix - Get alternative WWNN/WWPN prefix from the EEPROM
254  *  @hw: pointer to hardware structure
255  *  @wwnn_prefix: the alternative WWNN prefix
256  *  @wwpn_prefix: the alternative WWPN prefix
257  *
258  *  This function will read the EEPROM from the alternative SAN MAC address
259  *  block to check the support for the alternative WWNN/WWPN prefix support.
260  **/
261 s32 ixgbe_get_wwn_prefix(struct ixgbe_hw *hw, u16 *wwnn_prefix,
262                          u16 *wwpn_prefix)
263 {
264         return ixgbe_call_func(hw, hw->mac.ops.get_wwn_prefix,
265                                (hw, wwnn_prefix, wwpn_prefix),
266                                IXGBE_NOT_IMPLEMENTED);
267 }
268
269 /**
270  *  ixgbe_get_fcoe_boot_status -  Get FCOE boot status from EEPROM
271  *  @hw: pointer to hardware structure
272  *  @bs: the fcoe boot status
273  *
274  *  This function will read the FCOE boot status from the iSCSI FCOE block
275  **/
276 s32 ixgbe_get_fcoe_boot_status(struct ixgbe_hw *hw, u16 *bs)
277 {
278         return ixgbe_call_func(hw, hw->mac.ops.get_fcoe_boot_status,
279                                (hw, bs),
280                                IXGBE_NOT_IMPLEMENTED);
281 }
282
283 /**
284  *  ixgbe_get_bus_info - Set PCI bus info
285  *  @hw: pointer to hardware structure
286  *
287  *  Sets the PCI bus info (speed, width, type) within the ixgbe_hw structure
288  **/
289 s32 ixgbe_get_bus_info(struct ixgbe_hw *hw)
290 {
291         return ixgbe_call_func(hw, hw->mac.ops.get_bus_info, (hw),
292                                IXGBE_NOT_IMPLEMENTED);
293 }
294
295 /**
296  *  ixgbe_get_num_of_tx_queues - Get Tx queues
297  *  @hw: pointer to hardware structure
298  *
299  *  Returns the number of transmit queues for the given adapter.
300  **/
301 u32 ixgbe_get_num_of_tx_queues(struct ixgbe_hw *hw)
302 {
303         return hw->mac.max_tx_queues;
304 }
305
306 /**
307  *  ixgbe_get_num_of_rx_queues - Get Rx queues
308  *  @hw: pointer to hardware structure
309  *
310  *  Returns the number of receive queues for the given adapter.
311  **/
312 u32 ixgbe_get_num_of_rx_queues(struct ixgbe_hw *hw)
313 {
314         return hw->mac.max_rx_queues;
315 }
316
317 /**
318  *  ixgbe_stop_adapter - Disable Rx/Tx units
319  *  @hw: pointer to hardware structure
320  *
321  *  Sets the adapter_stopped flag within ixgbe_hw struct. Clears interrupts,
322  *  disables transmit and receive units. The adapter_stopped flag is used by
323  *  the shared code and drivers to determine if the adapter is in a stopped
324  *  state and should not touch the hardware.
325  **/
326 s32 ixgbe_stop_adapter(struct ixgbe_hw *hw)
327 {
328         return ixgbe_call_func(hw, hw->mac.ops.stop_adapter, (hw),
329                                IXGBE_NOT_IMPLEMENTED);
330 }
331
332 /**
333  *  ixgbe_read_pba_string - Reads part number string from EEPROM
334  *  @hw: pointer to hardware structure
335  *  @pba_num: stores the part number string from the EEPROM
336  *  @pba_num_size: part number string buffer length
337  *
338  *  Reads the part number string from the EEPROM.
339  **/
340 s32 ixgbe_read_pba_string(struct ixgbe_hw *hw, u8 *pba_num, u32 pba_num_size)
341 {
342         return ixgbe_read_pba_string_generic(hw, pba_num, pba_num_size);
343 }
344
345 /**
346  *  ixgbe_identify_phy - Get PHY type
347  *  @hw: pointer to hardware structure
348  *
349  *  Determines the physical layer module found on the current adapter.
350  **/
351 s32 ixgbe_identify_phy(struct ixgbe_hw *hw)
352 {
353         s32 status = 0;
354
355         if (hw->phy.type == ixgbe_phy_unknown) {
356                 status = ixgbe_call_func(hw, hw->phy.ops.identify, (hw),
357                                          IXGBE_NOT_IMPLEMENTED);
358         }
359
360         return status;
361 }
362
363 /**
364  *  ixgbe_reset_phy - Perform a PHY reset
365  *  @hw: pointer to hardware structure
366  **/
367 s32 ixgbe_reset_phy(struct ixgbe_hw *hw)
368 {
369         s32 status = 0;
370
371         if (hw->phy.type == ixgbe_phy_unknown) {
372                 if (ixgbe_identify_phy(hw) != 0)
373                         status = IXGBE_ERR_PHY;
374         }
375
376         if (status == 0) {
377                 status = ixgbe_call_func(hw, hw->phy.ops.reset, (hw),
378                                          IXGBE_NOT_IMPLEMENTED);
379         }
380         return status;
381 }
382
383 /**
384  *  ixgbe_get_phy_firmware_version -
385  *  @hw: pointer to hardware structure
386  *  @firmware_version: pointer to firmware version
387  **/
388 s32 ixgbe_get_phy_firmware_version(struct ixgbe_hw *hw, u16 *firmware_version)
389 {
390         s32 status = 0;
391
392         status = ixgbe_call_func(hw, hw->phy.ops.get_firmware_version,
393                                  (hw, firmware_version),
394                                  IXGBE_NOT_IMPLEMENTED);
395         return status;
396 }
397
398 /**
399  *  ixgbe_read_phy_reg - Read PHY register
400  *  @hw: pointer to hardware structure
401  *  @reg_addr: 32 bit address of PHY register to read
402  *  @phy_data: Pointer to read data from PHY register
403  *
404  *  Reads a value from a specified PHY register
405  **/
406 s32 ixgbe_read_phy_reg(struct ixgbe_hw *hw, u32 reg_addr, u32 device_type,
407                        u16 *phy_data)
408 {
409         if (hw->phy.id == 0)
410                 ixgbe_identify_phy(hw);
411
412         return ixgbe_call_func(hw, hw->phy.ops.read_reg, (hw, reg_addr,
413                                device_type, phy_data), IXGBE_NOT_IMPLEMENTED);
414 }
415
416 /**
417  *  ixgbe_write_phy_reg - Write PHY register
418  *  @hw: pointer to hardware structure
419  *  @reg_addr: 32 bit PHY register to write
420  *  @phy_data: Data to write to the PHY register
421  *
422  *  Writes a value to specified PHY register
423  **/
424 s32 ixgbe_write_phy_reg(struct ixgbe_hw *hw, u32 reg_addr, u32 device_type,
425                         u16 phy_data)
426 {
427         if (hw->phy.id == 0)
428                 ixgbe_identify_phy(hw);
429
430         return ixgbe_call_func(hw, hw->phy.ops.write_reg, (hw, reg_addr,
431                                device_type, phy_data), IXGBE_NOT_IMPLEMENTED);
432 }
433
434 /**
435  *  ixgbe_setup_phy_link - Restart PHY autoneg
436  *  @hw: pointer to hardware structure
437  *
438  *  Restart autonegotiation and PHY and waits for completion.
439  **/
440 s32 ixgbe_setup_phy_link(struct ixgbe_hw *hw)
441 {
442         return ixgbe_call_func(hw, hw->phy.ops.setup_link, (hw),
443                                IXGBE_NOT_IMPLEMENTED);
444 }
445
446 /**
447  *  ixgbe_check_phy_link - Determine link and speed status
448  *  @hw: pointer to hardware structure
449  *
450  *  Reads a PHY register to determine if link is up and the current speed for
451  *  the PHY.
452  **/
453 s32 ixgbe_check_phy_link(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
454                          bool *link_up)
455 {
456         return ixgbe_call_func(hw, hw->phy.ops.check_link, (hw, speed,
457                                link_up), IXGBE_NOT_IMPLEMENTED);
458 }
459
460 /**
461  *  ixgbe_setup_phy_link_speed - Set auto advertise
462  *  @hw: pointer to hardware structure
463  *  @speed: new link speed
464  *  @autoneg: true if autonegotiation enabled
465  *
466  *  Sets the auto advertised capabilities
467  **/
468 s32 ixgbe_setup_phy_link_speed(struct ixgbe_hw *hw, ixgbe_link_speed speed,
469                                bool autoneg,
470                                bool autoneg_wait_to_complete)
471 {
472         return ixgbe_call_func(hw, hw->phy.ops.setup_link_speed, (hw, speed,
473                                autoneg, autoneg_wait_to_complete),
474                                IXGBE_NOT_IMPLEMENTED);
475 }
476
477 /**
478  *  ixgbe_check_link - Get link and speed status
479  *  @hw: pointer to hardware structure
480  *
481  *  Reads the links register to determine if link is up and the current speed
482  **/
483 s32 ixgbe_check_link(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
484                      bool *link_up, bool link_up_wait_to_complete)
485 {
486         return ixgbe_call_func(hw, hw->mac.ops.check_link, (hw, speed,
487                                link_up, link_up_wait_to_complete),
488                                IXGBE_NOT_IMPLEMENTED);
489 }
490
491 /**
492  *  ixgbe_disable_tx_laser - Disable Tx laser
493  *  @hw: pointer to hardware structure
494  *
495  *  If the driver needs to disable the laser on SFI optics.
496  **/
497 void ixgbe_disable_tx_laser(struct ixgbe_hw *hw)
498 {
499         if (hw->mac.ops.disable_tx_laser)
500                 hw->mac.ops.disable_tx_laser(hw);
501 }
502
503 /**
504  *  ixgbe_enable_tx_laser - Enable Tx laser
505  *  @hw: pointer to hardware structure
506  *
507  *  If the driver needs to enable the laser on SFI optics.
508  **/
509 void ixgbe_enable_tx_laser(struct ixgbe_hw *hw)
510 {
511         if (hw->mac.ops.enable_tx_laser)
512                 hw->mac.ops.enable_tx_laser(hw);
513 }
514
515 /**
516  *  ixgbe_flap_tx_laser - flap Tx laser to start autotry process
517  *  @hw: pointer to hardware structure
518  *
519  *  When the driver changes the link speeds that it can support then
520  *  flap the tx laser to alert the link partner to start autotry
521  *  process on its end.
522  **/
523 void ixgbe_flap_tx_laser(struct ixgbe_hw *hw)
524 {
525         if (hw->mac.ops.flap_tx_laser)
526                 hw->mac.ops.flap_tx_laser(hw);
527 }
528
529 /**
530  *  ixgbe_setup_link - Set link speed
531  *  @hw: pointer to hardware structure
532  *  @speed: new link speed
533  *  @autoneg: true if autonegotiation enabled
534  *
535  *  Configures link settings.  Restarts the link.
536  *  Performs autonegotiation if needed.
537  **/
538 s32 ixgbe_setup_link(struct ixgbe_hw *hw, ixgbe_link_speed speed,
539                      bool autoneg,
540                      bool autoneg_wait_to_complete)
541 {
542         return ixgbe_call_func(hw, hw->mac.ops.setup_link, (hw, speed,
543                                autoneg, autoneg_wait_to_complete),
544                                IXGBE_NOT_IMPLEMENTED);
545 }
546
547 /**
548  *  ixgbe_get_link_capabilities - Returns link capabilities
549  *  @hw: pointer to hardware structure
550  *
551  *  Determines the link capabilities of the current configuration.
552  **/
553 s32 ixgbe_get_link_capabilities(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
554                                 bool *autoneg)
555 {
556         return ixgbe_call_func(hw, hw->mac.ops.get_link_capabilities, (hw,
557                                speed, autoneg), IXGBE_NOT_IMPLEMENTED);
558 }
559
560 /**
561  *  ixgbe_led_on - Turn on LEDs
562  *  @hw: pointer to hardware structure
563  *  @index: led number to turn on
564  *
565  *  Turns on the software controllable LEDs.
566  **/
567 s32 ixgbe_led_on(struct ixgbe_hw *hw, u32 index)
568 {
569         return ixgbe_call_func(hw, hw->mac.ops.led_on, (hw, index),
570                                IXGBE_NOT_IMPLEMENTED);
571 }
572
573 /**
574  *  ixgbe_led_off - Turn off LEDs
575  *  @hw: pointer to hardware structure
576  *  @index: led number to turn off
577  *
578  *  Turns off the software controllable LEDs.
579  **/
580 s32 ixgbe_led_off(struct ixgbe_hw *hw, u32 index)
581 {
582         return ixgbe_call_func(hw, hw->mac.ops.led_off, (hw, index),
583                                IXGBE_NOT_IMPLEMENTED);
584 }
585
586 /**
587  *  ixgbe_blink_led_start - Blink LEDs
588  *  @hw: pointer to hardware structure
589  *  @index: led number to blink
590  *
591  *  Blink LED based on index.
592  **/
593 s32 ixgbe_blink_led_start(struct ixgbe_hw *hw, u32 index)
594 {
595         return ixgbe_call_func(hw, hw->mac.ops.blink_led_start, (hw, index),
596                                IXGBE_NOT_IMPLEMENTED);
597 }
598
599 /**
600  *  ixgbe_blink_led_stop - Stop blinking LEDs
601  *  @hw: pointer to hardware structure
602  *
603  *  Stop blinking LED based on index.
604  **/
605 s32 ixgbe_blink_led_stop(struct ixgbe_hw *hw, u32 index)
606 {
607         return ixgbe_call_func(hw, hw->mac.ops.blink_led_stop, (hw, index),
608                                IXGBE_NOT_IMPLEMENTED);
609 }
610
611 /**
612  *  ixgbe_init_eeprom_params - Initialize EEPROM parameters
613  *  @hw: pointer to hardware structure
614  *
615  *  Initializes the EEPROM parameters ixgbe_eeprom_info within the
616  *  ixgbe_hw struct in order to set up EEPROM access.
617  **/
618 s32 ixgbe_init_eeprom_params(struct ixgbe_hw *hw)
619 {
620         return ixgbe_call_func(hw, hw->eeprom.ops.init_params, (hw),
621                                IXGBE_NOT_IMPLEMENTED);
622 }
623
624
625 /**
626  *  ixgbe_write_eeprom - Write word to EEPROM
627  *  @hw: pointer to hardware structure
628  *  @offset: offset within the EEPROM to be written to
629  *  @data: 16 bit word to be written to the EEPROM
630  *
631  *  Writes 16 bit value to EEPROM. If ixgbe_eeprom_update_checksum is not
632  *  called after this function, the EEPROM will most likely contain an
633  *  invalid checksum.
634  **/
635 s32 ixgbe_write_eeprom(struct ixgbe_hw *hw, u16 offset, u16 data)
636 {
637         return ixgbe_call_func(hw, hw->eeprom.ops.write, (hw, offset, data),
638                                IXGBE_NOT_IMPLEMENTED);
639 }
640
641 /**
642  *  ixgbe_write_eeprom_buffer - Write word(s) to EEPROM
643  *  @hw: pointer to hardware structure
644  *  @offset: offset within the EEPROM to be written to
645  *  @data: 16 bit word(s) to be written to the EEPROM
646  *  @words: number of words
647  *
648  *  Writes 16 bit word(s) to EEPROM. If ixgbe_eeprom_update_checksum is not
649  *  called after this function, the EEPROM will most likely contain an
650  *  invalid checksum.
651  **/
652 s32 ixgbe_write_eeprom_buffer(struct ixgbe_hw *hw, u16 offset, u16 words,
653                               u16 *data)
654 {
655         return ixgbe_call_func(hw, hw->eeprom.ops.write_buffer,
656                                (hw, offset, words, data),
657                                IXGBE_NOT_IMPLEMENTED);
658 }
659
660 /**
661  *  ixgbe_read_eeprom - Read word from EEPROM
662  *  @hw: pointer to hardware structure
663  *  @offset: offset within the EEPROM to be read
664  *  @data: read 16 bit value from EEPROM
665  *
666  *  Reads 16 bit value from EEPROM
667  **/
668 s32 ixgbe_read_eeprom(struct ixgbe_hw *hw, u16 offset, u16 *data)
669 {
670         return ixgbe_call_func(hw, hw->eeprom.ops.read, (hw, offset, data),
671                                IXGBE_NOT_IMPLEMENTED);
672 }
673
674 /**
675  *  ixgbe_read_eeprom_buffer - Read word(s) from EEPROM
676  *  @hw: pointer to hardware structure
677  *  @offset: offset within the EEPROM to be read
678  *  @data: read 16 bit word(s) from EEPROM
679  *  @words: number of words
680  *
681  *  Reads 16 bit word(s) from EEPROM
682  **/
683 s32 ixgbe_read_eeprom_buffer(struct ixgbe_hw *hw, u16 offset,
684                              u16 words, u16 *data)
685 {
686         return ixgbe_call_func(hw, hw->eeprom.ops.read_buffer,
687                                (hw, offset, words, data),
688                                IXGBE_NOT_IMPLEMENTED);
689 }
690
691 /**
692  *  ixgbe_validate_eeprom_checksum - Validate EEPROM checksum
693  *  @hw: pointer to hardware structure
694  *  @checksum_val: calculated checksum
695  *
696  *  Performs checksum calculation and validates the EEPROM checksum
697  **/
698 s32 ixgbe_validate_eeprom_checksum(struct ixgbe_hw *hw, u16 *checksum_val)
699 {
700         return ixgbe_call_func(hw, hw->eeprom.ops.validate_checksum,
701                                (hw, checksum_val), IXGBE_NOT_IMPLEMENTED);
702 }
703
704 /**
705  *  ixgbe_eeprom_update_checksum - Updates the EEPROM checksum
706  *  @hw: pointer to hardware structure
707  **/
708 s32 ixgbe_update_eeprom_checksum(struct ixgbe_hw *hw)
709 {
710         return ixgbe_call_func(hw, hw->eeprom.ops.update_checksum, (hw),
711                                IXGBE_NOT_IMPLEMENTED);
712 }
713
714 /**
715  *  ixgbe_insert_mac_addr - Find a RAR for this mac address
716  *  @hw: pointer to hardware structure
717  *  @addr: Address to put into receive address register
718  *  @vmdq: VMDq pool to assign
719  *
720  *  Puts an ethernet address into a receive address register, or
721  *  finds the rar that it is aleady in; adds to the pool list
722  **/
723 s32 ixgbe_insert_mac_addr(struct ixgbe_hw *hw, u8 *addr, u32 vmdq)
724 {
725         return ixgbe_call_func(hw, hw->mac.ops.insert_mac_addr,
726                                (hw, addr, vmdq),
727                                IXGBE_NOT_IMPLEMENTED);
728 }
729
730 /**
731  *  ixgbe_set_rar - Set Rx address register
732  *  @hw: pointer to hardware structure
733  *  @index: Receive address register to write
734  *  @addr: Address to put into receive address register
735  *  @vmdq: VMDq "set"
736  *  @enable_addr: set flag that address is active
737  *
738  *  Puts an ethernet address into a receive address register.
739  **/
740 s32 ixgbe_set_rar(struct ixgbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
741                   u32 enable_addr)
742 {
743         return ixgbe_call_func(hw, hw->mac.ops.set_rar, (hw, index, addr, vmdq,
744                                enable_addr), IXGBE_NOT_IMPLEMENTED);
745 }
746
747 /**
748  *  ixgbe_clear_rar - Clear Rx address register
749  *  @hw: pointer to hardware structure
750  *  @index: Receive address register to write
751  *
752  *  Puts an ethernet address into a receive address register.
753  **/
754 s32 ixgbe_clear_rar(struct ixgbe_hw *hw, u32 index)
755 {
756         return ixgbe_call_func(hw, hw->mac.ops.clear_rar, (hw, index),
757                                IXGBE_NOT_IMPLEMENTED);
758 }
759
760 /**
761  *  ixgbe_set_vmdq - Associate a VMDq index with a receive address
762  *  @hw: pointer to hardware structure
763  *  @rar: receive address register index to associate with VMDq index
764  *  @vmdq: VMDq set or pool index
765  **/
766 s32 ixgbe_set_vmdq(struct ixgbe_hw *hw, u32 rar, u32 vmdq)
767 {
768         return ixgbe_call_func(hw, hw->mac.ops.set_vmdq, (hw, rar, vmdq),
769                                IXGBE_NOT_IMPLEMENTED);
770
771 }
772
773 /**
774  *  ixgbe_set_vmdq_san_mac - Associate VMDq index 127 with a receive address
775  *  @hw: pointer to hardware structure
776  *  @vmdq: VMDq default pool index
777  **/
778 s32 ixgbe_set_vmdq_san_mac(struct ixgbe_hw *hw, u32 vmdq)
779 {
780         return ixgbe_call_func(hw, hw->mac.ops.set_vmdq_san_mac,
781                                (hw, vmdq), IXGBE_NOT_IMPLEMENTED);
782 }
783
784 /**
785  *  ixgbe_clear_vmdq - Disassociate a VMDq index from a receive address
786  *  @hw: pointer to hardware structure
787  *  @rar: receive address register index to disassociate with VMDq index
788  *  @vmdq: VMDq set or pool index
789  **/
790 s32 ixgbe_clear_vmdq(struct ixgbe_hw *hw, u32 rar, u32 vmdq)
791 {
792         return ixgbe_call_func(hw, hw->mac.ops.clear_vmdq, (hw, rar, vmdq),
793                                IXGBE_NOT_IMPLEMENTED);
794 }
795
796 /**
797  *  ixgbe_init_rx_addrs - Initializes receive address filters.
798  *  @hw: pointer to hardware structure
799  *
800  *  Places the MAC address in receive address register 0 and clears the rest
801  *  of the receive address registers. Clears the multicast table. Assumes
802  *  the receiver is in reset when the routine is called.
803  **/
804 s32 ixgbe_init_rx_addrs(struct ixgbe_hw *hw)
805 {
806         return ixgbe_call_func(hw, hw->mac.ops.init_rx_addrs, (hw),
807                                IXGBE_NOT_IMPLEMENTED);
808 }
809
810 /**
811  *  ixgbe_get_num_rx_addrs - Returns the number of RAR entries.
812  *  @hw: pointer to hardware structure
813  **/
814 u32 ixgbe_get_num_rx_addrs(struct ixgbe_hw *hw)
815 {
816         return hw->mac.num_rar_entries;
817 }
818
819 /**
820  *  ixgbe_update_uc_addr_list - Updates the MAC's list of secondary addresses
821  *  @hw: pointer to hardware structure
822  *  @addr_list: the list of new multicast addresses
823  *  @addr_count: number of addresses
824  *  @func: iterator function to walk the multicast address list
825  *
826  *  The given list replaces any existing list. Clears the secondary addrs from
827  *  receive address registers. Uses unused receive address registers for the
828  *  first secondary addresses, and falls back to promiscuous mode as needed.
829  **/
830 s32 ixgbe_update_uc_addr_list(struct ixgbe_hw *hw, u8 *addr_list,
831                               u32 addr_count, ixgbe_mc_addr_itr func)
832 {
833         return ixgbe_call_func(hw, hw->mac.ops.update_uc_addr_list, (hw,
834                                addr_list, addr_count, func),
835                                IXGBE_NOT_IMPLEMENTED);
836 }
837
838 /**
839  *  ixgbe_update_mc_addr_list - Updates the MAC's list of multicast addresses
840  *  @hw: pointer to hardware structure
841  *  @mc_addr_list: the list of new multicast addresses
842  *  @mc_addr_count: number of addresses
843  *  @func: iterator function to walk the multicast address list
844  *
845  *  The given list replaces any existing list. Clears the MC addrs from receive
846  *  address registers and the multicast table. Uses unused receive address
847  *  registers for the first multicast addresses, and hashes the rest into the
848  *  multicast table.
849  **/
850 s32 ixgbe_update_mc_addr_list(struct ixgbe_hw *hw, u8 *mc_addr_list,
851                               u32 mc_addr_count, ixgbe_mc_addr_itr func,
852                               bool clear)
853 {
854         return ixgbe_call_func(hw, hw->mac.ops.update_mc_addr_list, (hw,
855                                mc_addr_list, mc_addr_count, func, clear),
856                                IXGBE_NOT_IMPLEMENTED);
857 }
858
859 /**
860  *  ixgbe_enable_mc - Enable multicast address in RAR
861  *  @hw: pointer to hardware structure
862  *
863  *  Enables multicast address in RAR and the use of the multicast hash table.
864  **/
865 s32 ixgbe_enable_mc(struct ixgbe_hw *hw)
866 {
867         return ixgbe_call_func(hw, hw->mac.ops.enable_mc, (hw),
868                                IXGBE_NOT_IMPLEMENTED);
869 }
870
871 /**
872  *  ixgbe_disable_mc - Disable multicast address in RAR
873  *  @hw: pointer to hardware structure
874  *
875  *  Disables multicast address in RAR and the use of the multicast hash table.
876  **/
877 s32 ixgbe_disable_mc(struct ixgbe_hw *hw)
878 {
879         return ixgbe_call_func(hw, hw->mac.ops.disable_mc, (hw),
880                                IXGBE_NOT_IMPLEMENTED);
881 }
882
883 /**
884  *  ixgbe_clear_vfta - Clear VLAN filter table
885  *  @hw: pointer to hardware structure
886  *
887  *  Clears the VLAN filer table, and the VMDq index associated with the filter
888  **/
889 s32 ixgbe_clear_vfta(struct ixgbe_hw *hw)
890 {
891         return ixgbe_call_func(hw, hw->mac.ops.clear_vfta, (hw),
892                                IXGBE_NOT_IMPLEMENTED);
893 }
894
895 /**
896  *  ixgbe_set_vfta - Set VLAN filter table
897  *  @hw: pointer to hardware structure
898  *  @vlan: VLAN id to write to VLAN filter
899  *  @vind: VMDq output index that maps queue to VLAN id in VFTA
900  *  @vlan_on: boolean flag to turn on/off VLAN in VFTA
901  *
902  *  Turn on/off specified VLAN in the VLAN filter table.
903  **/
904 s32 ixgbe_set_vfta(struct ixgbe_hw *hw, u32 vlan, u32 vind, bool vlan_on)
905 {
906         return ixgbe_call_func(hw, hw->mac.ops.set_vfta, (hw, vlan, vind,
907                                vlan_on), IXGBE_NOT_IMPLEMENTED);
908 }
909
910 /**
911  *  ixgbe_set_vlvf - Set VLAN Pool Filter
912  *  @hw: pointer to hardware structure
913  *  @vlan: VLAN id to write to VLAN filter
914  *  @vind: VMDq output index that maps queue to VLAN id in VFVFB
915  *  @vlan_on: boolean flag to turn on/off VLAN in VFVF
916  *  @vfta_changed: pointer to boolean flag which indicates whether VFTA
917  *                 should be changed
918  *
919  *  Turn on/off specified bit in VLVF table.
920  **/
921 s32 ixgbe_set_vlvf(struct ixgbe_hw *hw, u32 vlan, u32 vind, bool vlan_on,
922                     bool *vfta_changed)
923 {
924         return ixgbe_call_func(hw, hw->mac.ops.set_vlvf, (hw, vlan, vind,
925                                vlan_on, vfta_changed), IXGBE_NOT_IMPLEMENTED);
926 }
927
928 /**
929  *  ixgbe_fc_enable - Enable flow control
930  *  @hw: pointer to hardware structure
931  *
932  *  Configures the flow control settings based on SW configuration.
933  **/
934 s32 ixgbe_fc_enable(struct ixgbe_hw *hw)
935 {
936         return ixgbe_call_func(hw, hw->mac.ops.fc_enable, (hw),
937                                IXGBE_NOT_IMPLEMENTED);
938 }
939
940 /**
941  * ixgbe_set_fw_drv_ver - Try to send the driver version number FW
942  * @hw: pointer to hardware structure
943  * @maj: driver major number to be sent to firmware
944  * @min: driver minor number to be sent to firmware
945  * @build: driver build number to be sent to firmware
946  * @ver: driver version number to be sent to firmware
947  **/
948 s32 ixgbe_set_fw_drv_ver(struct ixgbe_hw *hw, u8 maj, u8 min, u8 build,
949                          u8 ver)
950 {
951         return ixgbe_call_func(hw, hw->mac.ops.set_fw_drv_ver, (hw, maj, min,
952                                build, ver), IXGBE_NOT_IMPLEMENTED);
953 }
954
955
956 /**
957  *  ixgbe_get_thermal_sensor_data - Gathers thermal sensor data
958  *  @hw: pointer to hardware structure
959  *
960  *  Updates the temperatures in mac.thermal_sensor_data
961  **/
962 s32 ixgbe_get_thermal_sensor_data(struct ixgbe_hw *hw)
963 {
964         return ixgbe_call_func(hw, hw->mac.ops.get_thermal_sensor_data, (hw),
965                                 IXGBE_NOT_IMPLEMENTED);
966 }
967
968 /**
969  *  ixgbe_init_thermal_sensor_thresh - Inits thermal sensor thresholds
970  *  @hw: pointer to hardware structure
971  *
972  *  Inits the thermal sensor thresholds according to the NVM map
973  **/
974 s32 ixgbe_init_thermal_sensor_thresh(struct ixgbe_hw *hw)
975 {
976         return ixgbe_call_func(hw, hw->mac.ops.init_thermal_sensor_thresh, (hw),
977                                 IXGBE_NOT_IMPLEMENTED);
978 }
979 /**
980  *  ixgbe_read_analog_reg8 - Reads 8 bit analog register
981  *  @hw: pointer to hardware structure
982  *  @reg: analog register to read
983  *  @val: read value
984  *
985  *  Performs write operation to analog register specified.
986  **/
987 s32 ixgbe_read_analog_reg8(struct ixgbe_hw *hw, u32 reg, u8 *val)
988 {
989         return ixgbe_call_func(hw, hw->mac.ops.read_analog_reg8, (hw, reg,
990                                val), IXGBE_NOT_IMPLEMENTED);
991 }
992
993 /**
994  *  ixgbe_write_analog_reg8 - Writes 8 bit analog register
995  *  @hw: pointer to hardware structure
996  *  @reg: analog register to write
997  *  @val: value to write
998  *
999  *  Performs write operation to Atlas analog register specified.
1000  **/
1001 s32 ixgbe_write_analog_reg8(struct ixgbe_hw *hw, u32 reg, u8 val)
1002 {
1003         return ixgbe_call_func(hw, hw->mac.ops.write_analog_reg8, (hw, reg,
1004                                val), IXGBE_NOT_IMPLEMENTED);
1005 }
1006
1007 /**
1008  *  ixgbe_init_uta_tables - Initializes Unicast Table Arrays.
1009  *  @hw: pointer to hardware structure
1010  *
1011  *  Initializes the Unicast Table Arrays to zero on device load.  This
1012  *  is part of the Rx init addr execution path.
1013  **/
1014 s32 ixgbe_init_uta_tables(struct ixgbe_hw *hw)
1015 {
1016         return ixgbe_call_func(hw, hw->mac.ops.init_uta_tables, (hw),
1017                                IXGBE_NOT_IMPLEMENTED);
1018 }
1019
1020 /**
1021  *  ixgbe_read_i2c_byte - Reads 8 bit word over I2C at specified device address
1022  *  @hw: pointer to hardware structure
1023  *  @byte_offset: byte offset to read
1024  *  @data: value read
1025  *
1026  *  Performs byte read operation to SFP module's EEPROM over I2C interface.
1027  **/
1028 s32 ixgbe_read_i2c_byte(struct ixgbe_hw *hw, u8 byte_offset, u8 dev_addr,
1029                         u8 *data)
1030 {
1031         return ixgbe_call_func(hw, hw->phy.ops.read_i2c_byte, (hw, byte_offset,
1032                                dev_addr, data), IXGBE_NOT_IMPLEMENTED);
1033 }
1034
1035 /**
1036  *  ixgbe_write_i2c_byte - Writes 8 bit word over I2C
1037  *  @hw: pointer to hardware structure
1038  *  @byte_offset: byte offset to write
1039  *  @data: value to write
1040  *
1041  *  Performs byte write operation to SFP module's EEPROM over I2C interface
1042  *  at a specified device address.
1043  **/
1044 s32 ixgbe_write_i2c_byte(struct ixgbe_hw *hw, u8 byte_offset, u8 dev_addr,
1045                          u8 data)
1046 {
1047         return ixgbe_call_func(hw, hw->phy.ops.write_i2c_byte, (hw, byte_offset,
1048                                dev_addr, data), IXGBE_NOT_IMPLEMENTED);
1049 }
1050
1051 /**
1052  *  ixgbe_write_i2c_eeprom - Writes 8 bit EEPROM word over I2C interface
1053  *  @hw: pointer to hardware structure
1054  *  @byte_offset: EEPROM byte offset to write
1055  *  @eeprom_data: value to write
1056  *
1057  *  Performs byte write operation to SFP module's EEPROM over I2C interface.
1058  **/
1059 s32 ixgbe_write_i2c_eeprom(struct ixgbe_hw *hw,
1060                            u8 byte_offset, u8 eeprom_data)
1061 {
1062         return ixgbe_call_func(hw, hw->phy.ops.write_i2c_eeprom,
1063                                (hw, byte_offset, eeprom_data),
1064                                IXGBE_NOT_IMPLEMENTED);
1065 }
1066
1067 /**
1068  *  ixgbe_read_i2c_eeprom - Reads 8 bit EEPROM word over I2C interface
1069  *  @hw: pointer to hardware structure
1070  *  @byte_offset: EEPROM byte offset to read
1071  *  @eeprom_data: value read
1072  *
1073  *  Performs byte read operation to SFP module's EEPROM over I2C interface.
1074  **/
1075 s32 ixgbe_read_i2c_eeprom(struct ixgbe_hw *hw, u8 byte_offset, u8 *eeprom_data)
1076 {
1077         return ixgbe_call_func(hw, hw->phy.ops.read_i2c_eeprom,
1078                               (hw, byte_offset, eeprom_data),
1079                               IXGBE_NOT_IMPLEMENTED);
1080 }
1081
1082 /**
1083  *  ixgbe_get_supported_physical_layer - Returns physical layer type
1084  *  @hw: pointer to hardware structure
1085  *
1086  *  Determines physical layer capabilities of the current configuration.
1087  **/
1088 u32 ixgbe_get_supported_physical_layer(struct ixgbe_hw *hw)
1089 {
1090         return ixgbe_call_func(hw, hw->mac.ops.get_supported_physical_layer,
1091                                (hw), IXGBE_PHYSICAL_LAYER_UNKNOWN);
1092 }
1093
1094 /**
1095  *  ixgbe_enable_rx_dma - Enables Rx DMA unit, dependent on device specifics
1096  *  @hw: pointer to hardware structure
1097  *  @regval: bitfield to write to the Rx DMA register
1098  *
1099  *  Enables the Rx DMA unit of the device.
1100  **/
1101 s32 ixgbe_enable_rx_dma(struct ixgbe_hw *hw, u32 regval)
1102 {
1103         return ixgbe_call_func(hw, hw->mac.ops.enable_rx_dma,
1104                                (hw, regval), IXGBE_NOT_IMPLEMENTED);
1105 }
1106
1107 /**
1108  *  ixgbe_disable_sec_rx_path - Stops the receive data path
1109  *  @hw: pointer to hardware structure
1110  *
1111  *  Stops the receive data path.
1112  **/
1113 s32 ixgbe_disable_sec_rx_path(struct ixgbe_hw *hw)
1114 {
1115         return ixgbe_call_func(hw, hw->mac.ops.disable_sec_rx_path,
1116                                 (hw), IXGBE_NOT_IMPLEMENTED);
1117 }
1118
1119 /**
1120  *  ixgbe_enable_sec_rx_path - Enables the receive data path
1121  *  @hw: pointer to hardware structure
1122  *
1123  *  Enables the receive data path.
1124  **/
1125 s32 ixgbe_enable_sec_rx_path(struct ixgbe_hw *hw)
1126 {
1127         return ixgbe_call_func(hw, hw->mac.ops.enable_sec_rx_path,
1128                                 (hw), IXGBE_NOT_IMPLEMENTED);
1129 }
1130
1131 /**
1132  *  ixgbe_acquire_swfw_semaphore - Acquire SWFW semaphore
1133  *  @hw: pointer to hardware structure
1134  *  @mask: Mask to specify which semaphore to acquire
1135  *
1136  *  Acquires the SWFW semaphore through SW_FW_SYNC register for the specified
1137  *  function (CSR, PHY0, PHY1, EEPROM, Flash)
1138  **/
1139 s32 ixgbe_acquire_swfw_semaphore(struct ixgbe_hw *hw, u16 mask)
1140 {
1141         return ixgbe_call_func(hw, hw->mac.ops.acquire_swfw_sync,
1142                                (hw, mask), IXGBE_NOT_IMPLEMENTED);
1143 }
1144
1145 /**
1146  *  ixgbe_release_swfw_semaphore - Release SWFW semaphore
1147  *  @hw: pointer to hardware structure
1148  *  @mask: Mask to specify which semaphore to release
1149  *
1150  *  Releases the SWFW semaphore through SW_FW_SYNC register for the specified
1151  *  function (CSR, PHY0, PHY1, EEPROM, Flash)
1152  **/
1153 void ixgbe_release_swfw_semaphore(struct ixgbe_hw *hw, u16 mask)
1154 {
1155         if (hw->mac.ops.release_swfw_sync)
1156                 hw->mac.ops.release_swfw_sync(hw, mask);
1157 }