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