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