aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ixgbe/ixgbe_common.c
diff options
context:
space:
mode:
authorJesse Brandeburg <jesse.brandeburg@intel.com>2008-09-11 22:59:59 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-09-24 18:54:59 -0400
commitc44ade9ef8ffd73cb8b026065ade78bc0040f0b4 (patch)
tree4e873bc57bccb30e23cec99ed06ec58ba7251e39 /drivers/net/ixgbe/ixgbe_common.c
parentf08482766b7e3c0b2aaac4b68b30f33a91703aa3 (diff)
ixgbe: update to latest common code module
This is a massive update that includes infrastructure for further patches where we will add support for more phy types and eeprom types. This code is shared as much as possible with other drivers, so the code may seem a little obtuse at times but wherever possible we keep to the linux style and methods. Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/net/ixgbe/ixgbe_common.c')
-rw-r--r--drivers/net/ixgbe/ixgbe_common.c914
1 files changed, 608 insertions, 306 deletions
diff --git a/drivers/net/ixgbe/ixgbe_common.c b/drivers/net/ixgbe/ixgbe_common.c
index f5b2617111aa..a11ff0db9d25 100644
--- a/drivers/net/ixgbe/ixgbe_common.c
+++ b/drivers/net/ixgbe/ixgbe_common.c
@@ -33,20 +33,28 @@
33#include "ixgbe_common.h" 33#include "ixgbe_common.h"
34#include "ixgbe_phy.h" 34#include "ixgbe_phy.h"
35 35
36static s32 ixgbe_clear_hw_cntrs(struct ixgbe_hw *hw);
37
38static s32 ixgbe_poll_eeprom_eerd_done(struct ixgbe_hw *hw); 36static s32 ixgbe_poll_eeprom_eerd_done(struct ixgbe_hw *hw);
37static s32 ixgbe_acquire_eeprom(struct ixgbe_hw *hw);
39static s32 ixgbe_get_eeprom_semaphore(struct ixgbe_hw *hw); 38static s32 ixgbe_get_eeprom_semaphore(struct ixgbe_hw *hw);
40static void ixgbe_release_eeprom_semaphore(struct ixgbe_hw *hw); 39static void ixgbe_release_eeprom_semaphore(struct ixgbe_hw *hw);
40static s32 ixgbe_ready_eeprom(struct ixgbe_hw *hw);
41static void ixgbe_standby_eeprom(struct ixgbe_hw *hw);
42static void ixgbe_shift_out_eeprom_bits(struct ixgbe_hw *hw, u16 data,
43 u16 count);
44static u16 ixgbe_shift_in_eeprom_bits(struct ixgbe_hw *hw, u16 count);
45static void ixgbe_raise_eeprom_clk(struct ixgbe_hw *hw, u32 *eec);
46static void ixgbe_lower_eeprom_clk(struct ixgbe_hw *hw, u32 *eec);
47static void ixgbe_release_eeprom(struct ixgbe_hw *hw);
41static u16 ixgbe_calc_eeprom_checksum(struct ixgbe_hw *hw); 48static u16 ixgbe_calc_eeprom_checksum(struct ixgbe_hw *hw);
42 49
43static s32 ixgbe_clear_vfta(struct ixgbe_hw *hw); 50static void ixgbe_enable_rar(struct ixgbe_hw *hw, u32 index);
44static s32 ixgbe_init_rx_addrs(struct ixgbe_hw *hw); 51static void ixgbe_disable_rar(struct ixgbe_hw *hw, u32 index);
45static s32 ixgbe_mta_vector(struct ixgbe_hw *hw, u8 *mc_addr); 52static s32 ixgbe_mta_vector(struct ixgbe_hw *hw, u8 *mc_addr);
46static void ixgbe_add_mc_addr(struct ixgbe_hw *hw, u8 *mc_addr); 53static void ixgbe_add_mc_addr(struct ixgbe_hw *hw, u8 *mc_addr);
54static void ixgbe_add_uc_addr(struct ixgbe_hw *hw, u8 *addr, u32 vmdq);
47 55
48/** 56/**
49 * ixgbe_start_hw - Prepare hardware for TX/RX 57 * ixgbe_start_hw_generic - Prepare hardware for Tx/Rx
50 * @hw: pointer to hardware structure 58 * @hw: pointer to hardware structure
51 * 59 *
52 * Starts the hardware by filling the bus info structure and media type, clears 60 * Starts the hardware by filling the bus info structure and media type, clears
@@ -54,7 +62,7 @@ static void ixgbe_add_mc_addr(struct ixgbe_hw *hw, u8 *mc_addr);
54 * table, VLAN filter table, calls routine to set up link and flow control 62 * table, VLAN filter table, calls routine to set up link and flow control
55 * settings, and leaves transmit and receive units disabled and uninitialized 63 * settings, and leaves transmit and receive units disabled and uninitialized
56 **/ 64 **/
57s32 ixgbe_start_hw(struct ixgbe_hw *hw) 65s32 ixgbe_start_hw_generic(struct ixgbe_hw *hw)
58{ 66{
59 u32 ctrl_ext; 67 u32 ctrl_ext;
60 68
@@ -62,22 +70,22 @@ s32 ixgbe_start_hw(struct ixgbe_hw *hw)
62 hw->phy.media_type = hw->mac.ops.get_media_type(hw); 70 hw->phy.media_type = hw->mac.ops.get_media_type(hw);
63 71
64 /* Identify the PHY */ 72 /* Identify the PHY */
65 ixgbe_identify_phy(hw); 73 hw->phy.ops.identify(hw);
66 74
67 /* 75 /*
68 * Store MAC address from RAR0, clear receive address registers, and 76 * Store MAC address from RAR0, clear receive address registers, and
69 * clear the multicast table 77 * clear the multicast table
70 */ 78 */
71 ixgbe_init_rx_addrs(hw); 79 hw->mac.ops.init_rx_addrs(hw);
72 80
73 /* Clear the VLAN filter table */ 81 /* Clear the VLAN filter table */
74 ixgbe_clear_vfta(hw); 82 hw->mac.ops.clear_vfta(hw);
75 83
76 /* Set up link */ 84 /* Set up link */
77 hw->mac.ops.setup_link(hw); 85 hw->mac.ops.setup_link(hw);
78 86
79 /* Clear statistics registers */ 87 /* Clear statistics registers */
80 ixgbe_clear_hw_cntrs(hw); 88 hw->mac.ops.clear_hw_cntrs(hw);
81 89
82 /* Set No Snoop Disable */ 90 /* Set No Snoop Disable */
83 ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT); 91 ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
@@ -92,34 +100,34 @@ s32 ixgbe_start_hw(struct ixgbe_hw *hw)
92} 100}
93 101
94/** 102/**
95 * ixgbe_init_hw - Generic hardware initialization 103 * ixgbe_init_hw_generic - Generic hardware initialization
96 * @hw: pointer to hardware structure 104 * @hw: pointer to hardware structure
97 * 105 *
98 * Initialize the hardware by reseting the hardware, filling the bus info 106 * Initialize the hardware by resetting the hardware, filling the bus info
99 * structure and media type, clears all on chip counters, initializes receive 107 * structure and media type, clears all on chip counters, initializes receive
100 * address registers, multicast table, VLAN filter table, calls routine to set 108 * address registers, multicast table, VLAN filter table, calls routine to set
101 * up link and flow control settings, and leaves transmit and receive units 109 * up link and flow control settings, and leaves transmit and receive units
102 * disabled and uninitialized 110 * disabled and uninitialized
103 **/ 111 **/
104s32 ixgbe_init_hw(struct ixgbe_hw *hw) 112s32 ixgbe_init_hw_generic(struct ixgbe_hw *hw)
105{ 113{
106 /* Reset the hardware */ 114 /* Reset the hardware */
107 hw->mac.ops.reset(hw); 115 hw->mac.ops.reset_hw(hw);
108 116
109 /* Start the HW */ 117 /* Start the HW */
110 ixgbe_start_hw(hw); 118 hw->mac.ops.start_hw(hw);
111 119
112 return 0; 120 return 0;
113} 121}
114 122
115/** 123/**
116 * ixgbe_clear_hw_cntrs - Generic clear hardware counters 124 * ixgbe_clear_hw_cntrs_generic - Generic clear hardware counters
117 * @hw: pointer to hardware structure 125 * @hw: pointer to hardware structure
118 * 126 *
119 * Clears all hardware statistics counters by reading them from the hardware 127 * Clears all hardware statistics counters by reading them from the hardware
120 * Statistics counters are clear on read. 128 * Statistics counters are clear on read.
121 **/ 129 **/
122static s32 ixgbe_clear_hw_cntrs(struct ixgbe_hw *hw) 130s32 ixgbe_clear_hw_cntrs_generic(struct ixgbe_hw *hw)
123{ 131{
124 u16 i = 0; 132 u16 i = 0;
125 133
@@ -191,7 +199,36 @@ static s32 ixgbe_clear_hw_cntrs(struct ixgbe_hw *hw)
191} 199}
192 200
193/** 201/**
194 * ixgbe_get_mac_addr - Generic get MAC address 202 * ixgbe_read_pba_num_generic - Reads part number from EEPROM
203 * @hw: pointer to hardware structure
204 * @pba_num: stores the part number from the EEPROM
205 *
206 * Reads the part number from the EEPROM.
207 **/
208s32 ixgbe_read_pba_num_generic(struct ixgbe_hw *hw, u32 *pba_num)
209{
210 s32 ret_val;
211 u16 data;
212
213 ret_val = hw->eeprom.ops.read(hw, IXGBE_PBANUM0_PTR, &data);
214 if (ret_val) {
215 hw_dbg(hw, "NVM Read Error\n");
216 return ret_val;
217 }
218 *pba_num = (u32)(data << 16);
219
220 ret_val = hw->eeprom.ops.read(hw, IXGBE_PBANUM1_PTR, &data);
221 if (ret_val) {
222 hw_dbg(hw, "NVM Read Error\n");
223 return ret_val;
224 }
225 *pba_num |= data;
226
227 return 0;
228}
229
230/**
231 * ixgbe_get_mac_addr_generic - Generic get MAC address
195 * @hw: pointer to hardware structure 232 * @hw: pointer to hardware structure
196 * @mac_addr: Adapter MAC address 233 * @mac_addr: Adapter MAC address
197 * 234 *
@@ -199,7 +236,7 @@ static s32 ixgbe_clear_hw_cntrs(struct ixgbe_hw *hw)
199 * A reset of the adapter must be performed prior to calling this function 236 * A reset of the adapter must be performed prior to calling this function
200 * in order for the MAC address to have been loaded from the EEPROM into RAR0 237 * in order for the MAC address to have been loaded from the EEPROM into RAR0
201 **/ 238 **/
202s32 ixgbe_get_mac_addr(struct ixgbe_hw *hw, u8 *mac_addr) 239s32 ixgbe_get_mac_addr_generic(struct ixgbe_hw *hw, u8 *mac_addr)
203{ 240{
204 u32 rar_high; 241 u32 rar_high;
205 u32 rar_low; 242 u32 rar_low;
@@ -217,30 +254,8 @@ s32 ixgbe_get_mac_addr(struct ixgbe_hw *hw, u8 *mac_addr)
217 return 0; 254 return 0;
218} 255}
219 256
220s32 ixgbe_read_part_num(struct ixgbe_hw *hw, u32 *part_num)
221{
222 s32 ret_val;
223 u16 data;
224
225 ret_val = ixgbe_read_eeprom(hw, IXGBE_PBANUM0_PTR, &data);
226 if (ret_val) {
227 hw_dbg(hw, "NVM Read Error\n");
228 return ret_val;
229 }
230 *part_num = (u32)(data << 16);
231
232 ret_val = ixgbe_read_eeprom(hw, IXGBE_PBANUM1_PTR, &data);
233 if (ret_val) {
234 hw_dbg(hw, "NVM Read Error\n");
235 return ret_val;
236 }
237 *part_num |= data;
238
239 return 0;
240}
241
242/** 257/**
243 * ixgbe_stop_adapter - Generic stop TX/RX units 258 * ixgbe_stop_adapter_generic - Generic stop Tx/Rx units
244 * @hw: pointer to hardware structure 259 * @hw: pointer to hardware structure
245 * 260 *
246 * Sets the adapter_stopped flag within ixgbe_hw struct. Clears interrupts, 261 * Sets the adapter_stopped flag within ixgbe_hw struct. Clears interrupts,
@@ -248,7 +263,7 @@ s32 ixgbe_read_part_num(struct ixgbe_hw *hw, u32 *part_num)
248 * the shared code and drivers to determine if the adapter is in a stopped 263 * the shared code and drivers to determine if the adapter is in a stopped
249 * state and should not touch the hardware. 264 * state and should not touch the hardware.
250 **/ 265 **/
251s32 ixgbe_stop_adapter(struct ixgbe_hw *hw) 266s32 ixgbe_stop_adapter_generic(struct ixgbe_hw *hw)
252{ 267{
253 u32 number_of_queues; 268 u32 number_of_queues;
254 u32 reg_val; 269 u32 reg_val;
@@ -264,6 +279,7 @@ s32 ixgbe_stop_adapter(struct ixgbe_hw *hw)
264 reg_val = IXGBE_READ_REG(hw, IXGBE_RXCTRL); 279 reg_val = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
265 reg_val &= ~(IXGBE_RXCTRL_RXEN); 280 reg_val &= ~(IXGBE_RXCTRL_RXEN);
266 IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, reg_val); 281 IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, reg_val);
282 IXGBE_WRITE_FLUSH(hw);
267 msleep(2); 283 msleep(2);
268 284
269 /* Clear interrupt mask to stop from interrupts being generated */ 285 /* Clear interrupt mask to stop from interrupts being generated */
@@ -273,7 +289,7 @@ s32 ixgbe_stop_adapter(struct ixgbe_hw *hw)
273 IXGBE_READ_REG(hw, IXGBE_EICR); 289 IXGBE_READ_REG(hw, IXGBE_EICR);
274 290
275 /* Disable the transmit unit. Each queue must be disabled. */ 291 /* Disable the transmit unit. Each queue must be disabled. */
276 number_of_queues = hw->mac.num_tx_queues; 292 number_of_queues = hw->mac.max_tx_queues;
277 for (i = 0; i < number_of_queues; i++) { 293 for (i = 0; i < number_of_queues; i++) {
278 reg_val = IXGBE_READ_REG(hw, IXGBE_TXDCTL(i)); 294 reg_val = IXGBE_READ_REG(hw, IXGBE_TXDCTL(i));
279 if (reg_val & IXGBE_TXDCTL_ENABLE) { 295 if (reg_val & IXGBE_TXDCTL_ENABLE) {
@@ -282,15 +298,22 @@ s32 ixgbe_stop_adapter(struct ixgbe_hw *hw)
282 } 298 }
283 } 299 }
284 300
301 /*
302 * Prevent the PCI-E bus from from hanging by disabling PCI-E master
303 * access and verify no pending requests
304 */
305 if (ixgbe_disable_pcie_master(hw) != 0)
306 hw_dbg(hw, "PCI-E Master disable polling has failed.\n");
307
285 return 0; 308 return 0;
286} 309}
287 310
288/** 311/**
289 * ixgbe_led_on - Turns on the software controllable LEDs. 312 * ixgbe_led_on_generic - Turns on the software controllable LEDs.
290 * @hw: pointer to hardware structure 313 * @hw: pointer to hardware structure
291 * @index: led number to turn on 314 * @index: led number to turn on
292 **/ 315 **/
293s32 ixgbe_led_on(struct ixgbe_hw *hw, u32 index) 316s32 ixgbe_led_on_generic(struct ixgbe_hw *hw, u32 index)
294{ 317{
295 u32 led_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL); 318 u32 led_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL);
296 319
@@ -304,11 +327,11 @@ s32 ixgbe_led_on(struct ixgbe_hw *hw, u32 index)
304} 327}
305 328
306/** 329/**
307 * ixgbe_led_off - Turns off the software controllable LEDs. 330 * ixgbe_led_off_generic - Turns off the software controllable LEDs.
308 * @hw: pointer to hardware structure 331 * @hw: pointer to hardware structure
309 * @index: led number to turn off 332 * @index: led number to turn off
310 **/ 333 **/
311s32 ixgbe_led_off(struct ixgbe_hw *hw, u32 index) 334s32 ixgbe_led_off_generic(struct ixgbe_hw *hw, u32 index)
312{ 335{
313 u32 led_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL); 336 u32 led_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL);
314 337
@@ -321,15 +344,14 @@ s32 ixgbe_led_off(struct ixgbe_hw *hw, u32 index)
321 return 0; 344 return 0;
322} 345}
323 346
324
325/** 347/**
326 * ixgbe_init_eeprom - Initialize EEPROM params 348 * ixgbe_init_eeprom_params_generic - Initialize EEPROM params
327 * @hw: pointer to hardware structure 349 * @hw: pointer to hardware structure
328 * 350 *
329 * Initializes the EEPROM parameters ixgbe_eeprom_info within the 351 * Initializes the EEPROM parameters ixgbe_eeprom_info within the
330 * ixgbe_hw struct in order to set up EEPROM access. 352 * ixgbe_hw struct in order to set up EEPROM access.
331 **/ 353 **/
332s32 ixgbe_init_eeprom(struct ixgbe_hw *hw) 354s32 ixgbe_init_eeprom_params_generic(struct ixgbe_hw *hw)
333{ 355{
334 struct ixgbe_eeprom_info *eeprom = &hw->eeprom; 356 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
335 u32 eec; 357 u32 eec;
@@ -337,6 +359,9 @@ s32 ixgbe_init_eeprom(struct ixgbe_hw *hw)
337 359
338 if (eeprom->type == ixgbe_eeprom_uninitialized) { 360 if (eeprom->type == ixgbe_eeprom_uninitialized) {
339 eeprom->type = ixgbe_eeprom_none; 361 eeprom->type = ixgbe_eeprom_none;
362 /* Set default semaphore delay to 10ms which is a well
363 * tested value */
364 eeprom->semaphore_delay = 10;
340 365
341 /* 366 /*
342 * Check for EEPROM present first. 367 * Check for EEPROM present first.
@@ -369,18 +394,85 @@ s32 ixgbe_init_eeprom(struct ixgbe_hw *hw)
369} 394}
370 395
371/** 396/**
372 * ixgbe_read_eeprom - Read EEPROM word using EERD 397 * ixgbe_read_eeprom_bit_bang_generic - Read EEPROM word using bit-bang
398 * @hw: pointer to hardware structure
399 * @offset: offset within the EEPROM to be read
400 * @data: read 16 bit value from EEPROM
401 *
402 * Reads 16 bit value from EEPROM through bit-bang method
403 **/
404s32 ixgbe_read_eeprom_bit_bang_generic(struct ixgbe_hw *hw, u16 offset,
405 u16 *data)
406{
407 s32 status;
408 u16 word_in;
409 u8 read_opcode = IXGBE_EEPROM_READ_OPCODE_SPI;
410
411 hw->eeprom.ops.init_params(hw);
412
413 if (offset >= hw->eeprom.word_size) {
414 status = IXGBE_ERR_EEPROM;
415 goto out;
416 }
417
418 /* Prepare the EEPROM for reading */
419 status = ixgbe_acquire_eeprom(hw);
420
421 if (status == 0) {
422 if (ixgbe_ready_eeprom(hw) != 0) {
423 ixgbe_release_eeprom(hw);
424 status = IXGBE_ERR_EEPROM;
425 }
426 }
427
428 if (status == 0) {
429 ixgbe_standby_eeprom(hw);
430
431 /*
432 * Some SPI eeproms use the 8th address bit embedded in the
433 * opcode
434 */
435 if ((hw->eeprom.address_bits == 8) && (offset >= 128))
436 read_opcode |= IXGBE_EEPROM_A8_OPCODE_SPI;
437
438 /* Send the READ command (opcode + addr) */
439 ixgbe_shift_out_eeprom_bits(hw, read_opcode,
440 IXGBE_EEPROM_OPCODE_BITS);
441 ixgbe_shift_out_eeprom_bits(hw, (u16)(offset*2),
442 hw->eeprom.address_bits);
443
444 /* Read the data. */
445 word_in = ixgbe_shift_in_eeprom_bits(hw, 16);
446 *data = (word_in >> 8) | (word_in << 8);
447
448 /* End this read operation */
449 ixgbe_release_eeprom(hw);
450 }
451
452out:
453 return status;
454}
455
456/**
457 * ixgbe_read_eeprom_generic - Read EEPROM word using EERD
373 * @hw: pointer to hardware structure 458 * @hw: pointer to hardware structure
374 * @offset: offset of word in the EEPROM to read 459 * @offset: offset of word in the EEPROM to read
375 * @data: word read from the EEPROM 460 * @data: word read from the EEPROM
376 * 461 *
377 * Reads a 16 bit word from the EEPROM using the EERD register. 462 * Reads a 16 bit word from the EEPROM using the EERD register.
378 **/ 463 **/
379s32 ixgbe_read_eeprom(struct ixgbe_hw *hw, u16 offset, u16 *data) 464s32 ixgbe_read_eeprom_generic(struct ixgbe_hw *hw, u16 offset, u16 *data)
380{ 465{
381 u32 eerd; 466 u32 eerd;
382 s32 status; 467 s32 status;
383 468
469 hw->eeprom.ops.init_params(hw);
470
471 if (offset >= hw->eeprom.word_size) {
472 status = IXGBE_ERR_EEPROM;
473 goto out;
474 }
475
384 eerd = (offset << IXGBE_EEPROM_READ_ADDR_SHIFT) + 476 eerd = (offset << IXGBE_EEPROM_READ_ADDR_SHIFT) +
385 IXGBE_EEPROM_READ_REG_START; 477 IXGBE_EEPROM_READ_REG_START;
386 478
@@ -393,6 +485,7 @@ s32 ixgbe_read_eeprom(struct ixgbe_hw *hw, u16 offset, u16 *data)
393 else 485 else
394 hw_dbg(hw, "Eeprom read timed out\n"); 486 hw_dbg(hw, "Eeprom read timed out\n");
395 487
488out:
396 return status; 489 return status;
397} 490}
398 491
@@ -420,6 +513,58 @@ static s32 ixgbe_poll_eeprom_eerd_done(struct ixgbe_hw *hw)
420} 513}
421 514
422/** 515/**
516 * ixgbe_acquire_eeprom - Acquire EEPROM using bit-bang
517 * @hw: pointer to hardware structure
518 *
519 * Prepares EEPROM for access using bit-bang method. This function should
520 * be called before issuing a command to the EEPROM.
521 **/
522static s32 ixgbe_acquire_eeprom(struct ixgbe_hw *hw)
523{
524 s32 status = 0;
525 u32 eec;
526 u32 i;
527
528 if (ixgbe_acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) != 0)
529 status = IXGBE_ERR_SWFW_SYNC;
530
531 if (status == 0) {
532 eec = IXGBE_READ_REG(hw, IXGBE_EEC);
533
534 /* Request EEPROM Access */
535 eec |= IXGBE_EEC_REQ;
536 IXGBE_WRITE_REG(hw, IXGBE_EEC, eec);
537
538 for (i = 0; i < IXGBE_EEPROM_GRANT_ATTEMPTS; i++) {
539 eec = IXGBE_READ_REG(hw, IXGBE_EEC);
540 if (eec & IXGBE_EEC_GNT)
541 break;
542 udelay(5);
543 }
544
545 /* Release if grant not acquired */
546 if (!(eec & IXGBE_EEC_GNT)) {
547 eec &= ~IXGBE_EEC_REQ;
548 IXGBE_WRITE_REG(hw, IXGBE_EEC, eec);
549 hw_dbg(hw, "Could not acquire EEPROM grant\n");
550
551 ixgbe_release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
552 status = IXGBE_ERR_EEPROM;
553 }
554 }
555
556 /* Setup EEPROM for Read/Write */
557 if (status == 0) {
558 /* Clear CS and SK */
559 eec &= ~(IXGBE_EEC_CS | IXGBE_EEC_SK);
560 IXGBE_WRITE_REG(hw, IXGBE_EEC, eec);
561 IXGBE_WRITE_FLUSH(hw);
562 udelay(1);
563 }
564 return status;
565}
566
567/**
423 * ixgbe_get_eeprom_semaphore - Get hardware semaphore 568 * ixgbe_get_eeprom_semaphore - Get hardware semaphore
424 * @hw: pointer to hardware structure 569 * @hw: pointer to hardware structure
425 * 570 *
@@ -503,6 +648,217 @@ static void ixgbe_release_eeprom_semaphore(struct ixgbe_hw *hw)
503} 648}
504 649
505/** 650/**
651 * ixgbe_ready_eeprom - Polls for EEPROM ready
652 * @hw: pointer to hardware structure
653 **/
654static s32 ixgbe_ready_eeprom(struct ixgbe_hw *hw)
655{
656 s32 status = 0;
657 u16 i;
658 u8 spi_stat_reg;
659
660 /*
661 * Read "Status Register" repeatedly until the LSB is cleared. The
662 * EEPROM will signal that the command has been completed by clearing
663 * bit 0 of the internal status register. If it's not cleared within
664 * 5 milliseconds, then error out.
665 */
666 for (i = 0; i < IXGBE_EEPROM_MAX_RETRY_SPI; i += 5) {
667 ixgbe_shift_out_eeprom_bits(hw, IXGBE_EEPROM_RDSR_OPCODE_SPI,
668 IXGBE_EEPROM_OPCODE_BITS);
669 spi_stat_reg = (u8)ixgbe_shift_in_eeprom_bits(hw, 8);
670 if (!(spi_stat_reg & IXGBE_EEPROM_STATUS_RDY_SPI))
671 break;
672
673 udelay(5);
674 ixgbe_standby_eeprom(hw);
675 };
676
677 /*
678 * On some parts, SPI write time could vary from 0-20mSec on 3.3V
679 * devices (and only 0-5mSec on 5V devices)
680 */
681 if (i >= IXGBE_EEPROM_MAX_RETRY_SPI) {
682 hw_dbg(hw, "SPI EEPROM Status error\n");
683 status = IXGBE_ERR_EEPROM;
684 }
685
686 return status;
687}
688
689/**
690 * ixgbe_standby_eeprom - Returns EEPROM to a "standby" state
691 * @hw: pointer to hardware structure
692 **/
693static void ixgbe_standby_eeprom(struct ixgbe_hw *hw)
694{
695 u32 eec;
696
697 eec = IXGBE_READ_REG(hw, IXGBE_EEC);
698
699 /* Toggle CS to flush commands */
700 eec |= IXGBE_EEC_CS;
701 IXGBE_WRITE_REG(hw, IXGBE_EEC, eec);
702 IXGBE_WRITE_FLUSH(hw);
703 udelay(1);
704 eec &= ~IXGBE_EEC_CS;
705 IXGBE_WRITE_REG(hw, IXGBE_EEC, eec);
706 IXGBE_WRITE_FLUSH(hw);
707 udelay(1);
708}
709
710/**
711 * ixgbe_shift_out_eeprom_bits - Shift data bits out to the EEPROM.
712 * @hw: pointer to hardware structure
713 * @data: data to send to the EEPROM
714 * @count: number of bits to shift out
715 **/
716static void ixgbe_shift_out_eeprom_bits(struct ixgbe_hw *hw, u16 data,
717 u16 count)
718{
719 u32 eec;
720 u32 mask;
721 u32 i;
722
723 eec = IXGBE_READ_REG(hw, IXGBE_EEC);
724
725 /*
726 * Mask is used to shift "count" bits of "data" out to the EEPROM
727 * one bit at a time. Determine the starting bit based on count
728 */
729 mask = 0x01 << (count - 1);
730
731 for (i = 0; i < count; i++) {
732 /*
733 * A "1" is shifted out to the EEPROM by setting bit "DI" to a
734 * "1", and then raising and then lowering the clock (the SK
735 * bit controls the clock input to the EEPROM). A "0" is
736 * shifted out to the EEPROM by setting "DI" to "0" and then
737 * raising and then lowering the clock.
738 */
739 if (data & mask)
740 eec |= IXGBE_EEC_DI;
741 else
742 eec &= ~IXGBE_EEC_DI;
743
744 IXGBE_WRITE_REG(hw, IXGBE_EEC, eec);
745 IXGBE_WRITE_FLUSH(hw);
746
747 udelay(1);
748
749 ixgbe_raise_eeprom_clk(hw, &eec);
750 ixgbe_lower_eeprom_clk(hw, &eec);
751
752 /*
753 * Shift mask to signify next bit of data to shift in to the
754 * EEPROM
755 */
756 mask = mask >> 1;
757 };
758
759 /* We leave the "DI" bit set to "0" when we leave this routine. */
760 eec &= ~IXGBE_EEC_DI;
761 IXGBE_WRITE_REG(hw, IXGBE_EEC, eec);
762 IXGBE_WRITE_FLUSH(hw);
763}
764
765/**
766 * ixgbe_shift_in_eeprom_bits - Shift data bits in from the EEPROM
767 * @hw: pointer to hardware structure
768 **/
769static u16 ixgbe_shift_in_eeprom_bits(struct ixgbe_hw *hw, u16 count)
770{
771 u32 eec;
772 u32 i;
773 u16 data = 0;
774
775 /*
776 * In order to read a register from the EEPROM, we need to shift
777 * 'count' bits in from the EEPROM. Bits are "shifted in" by raising
778 * the clock input to the EEPROM (setting the SK bit), and then reading
779 * the value of the "DO" bit. During this "shifting in" process the
780 * "DI" bit should always be clear.
781 */
782 eec = IXGBE_READ_REG(hw, IXGBE_EEC);
783
784 eec &= ~(IXGBE_EEC_DO | IXGBE_EEC_DI);
785
786 for (i = 0; i < count; i++) {
787 data = data << 1;
788 ixgbe_raise_eeprom_clk(hw, &eec);
789
790 eec = IXGBE_READ_REG(hw, IXGBE_EEC);
791
792 eec &= ~(IXGBE_EEC_DI);
793 if (eec & IXGBE_EEC_DO)
794 data |= 1;
795
796 ixgbe_lower_eeprom_clk(hw, &eec);
797 }
798
799 return data;
800}
801
802/**
803 * ixgbe_raise_eeprom_clk - Raises the EEPROM's clock input.
804 * @hw: pointer to hardware structure
805 * @eec: EEC register's current value
806 **/
807static void ixgbe_raise_eeprom_clk(struct ixgbe_hw *hw, u32 *eec)
808{
809 /*
810 * Raise the clock input to the EEPROM
811 * (setting the SK bit), then delay
812 */
813 *eec = *eec | IXGBE_EEC_SK;
814 IXGBE_WRITE_REG(hw, IXGBE_EEC, *eec);
815 IXGBE_WRITE_FLUSH(hw);
816 udelay(1);
817}
818
819/**
820 * ixgbe_lower_eeprom_clk - Lowers the EEPROM's clock input.
821 * @hw: pointer to hardware structure
822 * @eecd: EECD's current value
823 **/
824static void ixgbe_lower_eeprom_clk(struct ixgbe_hw *hw, u32 *eec)
825{
826 /*
827 * Lower the clock input to the EEPROM (clearing the SK bit), then
828 * delay
829 */
830 *eec = *eec & ~IXGBE_EEC_SK;
831 IXGBE_WRITE_REG(hw, IXGBE_EEC, *eec);
832 IXGBE_WRITE_FLUSH(hw);
833 udelay(1);
834}
835
836/**
837 * ixgbe_release_eeprom - Release EEPROM, release semaphores
838 * @hw: pointer to hardware structure
839 **/
840static void ixgbe_release_eeprom(struct ixgbe_hw *hw)
841{
842 u32 eec;
843
844 eec = IXGBE_READ_REG(hw, IXGBE_EEC);
845
846 eec |= IXGBE_EEC_CS; /* Pull CS high */
847 eec &= ~IXGBE_EEC_SK; /* Lower SCK */
848
849 IXGBE_WRITE_REG(hw, IXGBE_EEC, eec);
850 IXGBE_WRITE_FLUSH(hw);
851
852 udelay(1);
853
854 /* Stop requesting EEPROM access */
855 eec &= ~IXGBE_EEC_REQ;
856 IXGBE_WRITE_REG(hw, IXGBE_EEC, eec);
857
858 ixgbe_release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
859}
860
861/**
506 * ixgbe_calc_eeprom_checksum - Calculates and returns the checksum 862 * ixgbe_calc_eeprom_checksum - Calculates and returns the checksum
507 * @hw: pointer to hardware structure 863 * @hw: pointer to hardware structure
508 **/ 864 **/
@@ -517,7 +873,7 @@ static u16 ixgbe_calc_eeprom_checksum(struct ixgbe_hw *hw)
517 873
518 /* Include 0x0-0x3F in the checksum */ 874 /* Include 0x0-0x3F in the checksum */
519 for (i = 0; i < IXGBE_EEPROM_CHECKSUM; i++) { 875 for (i = 0; i < IXGBE_EEPROM_CHECKSUM; i++) {
520 if (ixgbe_read_eeprom(hw, i, &word) != 0) { 876 if (hw->eeprom.ops.read(hw, i, &word) != 0) {
521 hw_dbg(hw, "EEPROM read failed\n"); 877 hw_dbg(hw, "EEPROM read failed\n");
522 break; 878 break;
523 } 879 }
@@ -526,15 +882,15 @@ static u16 ixgbe_calc_eeprom_checksum(struct ixgbe_hw *hw)
526 882
527 /* Include all data from pointers except for the fw pointer */ 883 /* Include all data from pointers except for the fw pointer */
528 for (i = IXGBE_PCIE_ANALOG_PTR; i < IXGBE_FW_PTR; i++) { 884 for (i = IXGBE_PCIE_ANALOG_PTR; i < IXGBE_FW_PTR; i++) {
529 ixgbe_read_eeprom(hw, i, &pointer); 885 hw->eeprom.ops.read(hw, i, &pointer);
530 886
531 /* Make sure the pointer seems valid */ 887 /* Make sure the pointer seems valid */
532 if (pointer != 0xFFFF && pointer != 0) { 888 if (pointer != 0xFFFF && pointer != 0) {
533 ixgbe_read_eeprom(hw, pointer, &length); 889 hw->eeprom.ops.read(hw, pointer, &length);
534 890
535 if (length != 0xFFFF && length != 0) { 891 if (length != 0xFFFF && length != 0) {
536 for (j = pointer+1; j <= pointer+length; j++) { 892 for (j = pointer+1; j <= pointer+length; j++) {
537 ixgbe_read_eeprom(hw, j, &word); 893 hw->eeprom.ops.read(hw, j, &word);
538 checksum += word; 894 checksum += word;
539 } 895 }
540 } 896 }
@@ -547,14 +903,15 @@ static u16 ixgbe_calc_eeprom_checksum(struct ixgbe_hw *hw)
547} 903}
548 904
549/** 905/**
550 * ixgbe_validate_eeprom_checksum - Validate EEPROM checksum 906 * ixgbe_validate_eeprom_checksum_generic - Validate EEPROM checksum
551 * @hw: pointer to hardware structure 907 * @hw: pointer to hardware structure
552 * @checksum_val: calculated checksum 908 * @checksum_val: calculated checksum
553 * 909 *
554 * Performs checksum calculation and validates the EEPROM checksum. If the 910 * Performs checksum calculation and validates the EEPROM checksum. If the
555 * caller does not need checksum_val, the value can be NULL. 911 * caller does not need checksum_val, the value can be NULL.
556 **/ 912 **/
557s32 ixgbe_validate_eeprom_checksum(struct ixgbe_hw *hw, u16 *checksum_val) 913s32 ixgbe_validate_eeprom_checksum_generic(struct ixgbe_hw *hw,
914 u16 *checksum_val)
558{ 915{
559 s32 status; 916 s32 status;
560 u16 checksum; 917 u16 checksum;
@@ -565,12 +922,12 @@ s32 ixgbe_validate_eeprom_checksum(struct ixgbe_hw *hw, u16 *checksum_val)
565 * not continue or we could be in for a very long wait while every 922 * not continue or we could be in for a very long wait while every
566 * EEPROM read fails 923 * EEPROM read fails
567 */ 924 */
568 status = ixgbe_read_eeprom(hw, 0, &checksum); 925 status = hw->eeprom.ops.read(hw, 0, &checksum);
569 926
570 if (status == 0) { 927 if (status == 0) {
571 checksum = ixgbe_calc_eeprom_checksum(hw); 928 checksum = ixgbe_calc_eeprom_checksum(hw);
572 929
573 ixgbe_read_eeprom(hw, IXGBE_EEPROM_CHECKSUM, &read_checksum); 930 hw->eeprom.ops.read(hw, IXGBE_EEPROM_CHECKSUM, &read_checksum);
574 931
575 /* 932 /*
576 * Verify read checksum from EEPROM is the same as 933 * Verify read checksum from EEPROM is the same as
@@ -590,6 +947,33 @@ s32 ixgbe_validate_eeprom_checksum(struct ixgbe_hw *hw, u16 *checksum_val)
590} 947}
591 948
592/** 949/**
950 * ixgbe_update_eeprom_checksum_generic - Updates the EEPROM checksum
951 * @hw: pointer to hardware structure
952 **/
953s32 ixgbe_update_eeprom_checksum_generic(struct ixgbe_hw *hw)
954{
955 s32 status;
956 u16 checksum;
957
958 /*
959 * Read the first word from the EEPROM. If this times out or fails, do
960 * not continue or we could be in for a very long wait while every
961 * EEPROM read fails
962 */
963 status = hw->eeprom.ops.read(hw, 0, &checksum);
964
965 if (status == 0) {
966 checksum = ixgbe_calc_eeprom_checksum(hw);
967 status = hw->eeprom.ops.write(hw, IXGBE_EEPROM_CHECKSUM,
968 checksum);
969 } else {
970 hw_dbg(hw, "EEPROM read failed\n");
971 }
972
973 return status;
974}
975
976/**
593 * ixgbe_validate_mac_addr - Validate MAC address 977 * ixgbe_validate_mac_addr - Validate MAC address
594 * @mac_addr: pointer to MAC address. 978 * @mac_addr: pointer to MAC address.
595 * 979 *
@@ -607,58 +991,137 @@ s32 ixgbe_validate_mac_addr(u8 *mac_addr)
607 status = IXGBE_ERR_INVALID_MAC_ADDR; 991 status = IXGBE_ERR_INVALID_MAC_ADDR;
608 /* Reject the zero address */ 992 /* Reject the zero address */
609 else if (mac_addr[0] == 0 && mac_addr[1] == 0 && mac_addr[2] == 0 && 993 else if (mac_addr[0] == 0 && mac_addr[1] == 0 && mac_addr[2] == 0 &&
610 mac_addr[3] == 0 && mac_addr[4] == 0 && mac_addr[5] == 0) 994 mac_addr[3] == 0 && mac_addr[4] == 0 && mac_addr[5] == 0)
611 status = IXGBE_ERR_INVALID_MAC_ADDR; 995 status = IXGBE_ERR_INVALID_MAC_ADDR;
612 996
613 return status; 997 return status;
614} 998}
615 999
616/** 1000/**
617 * ixgbe_set_rar - Set RX address register 1001 * ixgbe_set_rar_generic - Set Rx address register
618 * @hw: pointer to hardware structure 1002 * @hw: pointer to hardware structure
619 * @addr: Address to put into receive address register
620 * @index: Receive address register to write 1003 * @index: Receive address register to write
621 * @vind: Vind to set RAR to 1004 * @addr: Address to put into receive address register
1005 * @vmdq: VMDq "set" or "pool" index
622 * @enable_addr: set flag that address is active 1006 * @enable_addr: set flag that address is active
623 * 1007 *
624 * Puts an ethernet address into a receive address register. 1008 * Puts an ethernet address into a receive address register.
625 **/ 1009 **/
626s32 ixgbe_set_rar(struct ixgbe_hw *hw, u32 index, u8 *addr, u32 vind, 1010s32 ixgbe_set_rar_generic(struct ixgbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
627 u32 enable_addr) 1011 u32 enable_addr)
628{ 1012{
629 u32 rar_low, rar_high; 1013 u32 rar_low, rar_high;
1014 u32 rar_entries = hw->mac.num_rar_entries;
1015
1016 /* setup VMDq pool selection before this RAR gets enabled */
1017 hw->mac.ops.set_vmdq(hw, index, vmdq);
630 1018
1019 /* Make sure we are using a valid rar index range */
1020 if (index < rar_entries) {
631 /* 1021 /*
632 * HW expects these in little endian so we reverse the byte order from 1022 * HW expects these in little endian so we reverse the byte
633 * network order (big endian) to little endian 1023 * order from network order (big endian) to little endian
634 */ 1024 */
635 rar_low = ((u32)addr[0] | 1025 rar_low = ((u32)addr[0] |
636 ((u32)addr[1] << 8) | 1026 ((u32)addr[1] << 8) |
637 ((u32)addr[2] << 16) | 1027 ((u32)addr[2] << 16) |
638 ((u32)addr[3] << 24)); 1028 ((u32)addr[3] << 24));
639 1029 /*
640 rar_high = ((u32)addr[4] | 1030 * Some parts put the VMDq setting in the extra RAH bits,
641 ((u32)addr[5] << 8) | 1031 * so save everything except the lower 16 bits that hold part
642 ((vind << IXGBE_RAH_VIND_SHIFT) & IXGBE_RAH_VIND_MASK)); 1032 * of the address and the address valid bit.
1033 */
1034 rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(index));
1035 rar_high &= ~(0x0000FFFF | IXGBE_RAH_AV);
1036 rar_high |= ((u32)addr[4] | ((u32)addr[5] << 8));
643 1037
644 if (enable_addr != 0) 1038 if (enable_addr != 0)
645 rar_high |= IXGBE_RAH_AV; 1039 rar_high |= IXGBE_RAH_AV;
646 1040
647 IXGBE_WRITE_REG(hw, IXGBE_RAL(index), rar_low); 1041 IXGBE_WRITE_REG(hw, IXGBE_RAL(index), rar_low);
648 IXGBE_WRITE_REG(hw, IXGBE_RAH(index), rar_high); 1042 IXGBE_WRITE_REG(hw, IXGBE_RAH(index), rar_high);
1043 } else {
1044 hw_dbg(hw, "RAR index %d is out of range.\n", index);
1045 }
1046
1047 return 0;
1048}
1049
1050/**
1051 * ixgbe_clear_rar_generic - Remove Rx address register
1052 * @hw: pointer to hardware structure
1053 * @index: Receive address register to write
1054 *
1055 * Clears an ethernet address from a receive address register.
1056 **/
1057s32 ixgbe_clear_rar_generic(struct ixgbe_hw *hw, u32 index)
1058{
1059 u32 rar_high;
1060 u32 rar_entries = hw->mac.num_rar_entries;
1061
1062 /* Make sure we are using a valid rar index range */
1063 if (index < rar_entries) {
1064 /*
1065 * Some parts put the VMDq setting in the extra RAH bits,
1066 * so save everything except the lower 16 bits that hold part
1067 * of the address and the address valid bit.
1068 */
1069 rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(index));
1070 rar_high &= ~(0x0000FFFF | IXGBE_RAH_AV);
1071
1072 IXGBE_WRITE_REG(hw, IXGBE_RAL(index), 0);
1073 IXGBE_WRITE_REG(hw, IXGBE_RAH(index), rar_high);
1074 } else {
1075 hw_dbg(hw, "RAR index %d is out of range.\n", index);
1076 }
1077
1078 /* clear VMDq pool/queue selection for this RAR */
1079 hw->mac.ops.clear_vmdq(hw, index, IXGBE_CLEAR_VMDQ_ALL);
649 1080
650 return 0; 1081 return 0;
651} 1082}
652 1083
653/** 1084/**
654 * ixgbe_init_rx_addrs - Initializes receive address filters. 1085 * ixgbe_enable_rar - Enable Rx address register
1086 * @hw: pointer to hardware structure
1087 * @index: index into the RAR table
1088 *
1089 * Enables the select receive address register.
1090 **/
1091static void ixgbe_enable_rar(struct ixgbe_hw *hw, u32 index)
1092{
1093 u32 rar_high;
1094
1095 rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(index));
1096 rar_high |= IXGBE_RAH_AV;
1097 IXGBE_WRITE_REG(hw, IXGBE_RAH(index), rar_high);
1098}
1099
1100/**
1101 * ixgbe_disable_rar - Disable Rx address register
1102 * @hw: pointer to hardware structure
1103 * @index: index into the RAR table
1104 *
1105 * Disables the select receive address register.
1106 **/
1107static void ixgbe_disable_rar(struct ixgbe_hw *hw, u32 index)
1108{
1109 u32 rar_high;
1110
1111 rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(index));
1112 rar_high &= (~IXGBE_RAH_AV);
1113 IXGBE_WRITE_REG(hw, IXGBE_RAH(index), rar_high);
1114}
1115
1116/**
1117 * ixgbe_init_rx_addrs_generic - Initializes receive address filters.
655 * @hw: pointer to hardware structure 1118 * @hw: pointer to hardware structure
656 * 1119 *
657 * Places the MAC address in receive address register 0 and clears the rest 1120 * Places the MAC address in receive address register 0 and clears the rest
658 * of the receive addresss registers. Clears the multicast table. Assumes 1121 * of the receive address registers. Clears the multicast table. Assumes
659 * the receiver is in reset when the routine is called. 1122 * the receiver is in reset when the routine is called.
660 **/ 1123 **/
661static s32 ixgbe_init_rx_addrs(struct ixgbe_hw *hw) 1124s32 ixgbe_init_rx_addrs_generic(struct ixgbe_hw *hw)
662{ 1125{
663 u32 i; 1126 u32 i;
664 u32 rar_entries = hw->mac.num_rar_entries; 1127 u32 rar_entries = hw->mac.num_rar_entries;
@@ -671,7 +1134,7 @@ static s32 ixgbe_init_rx_addrs(struct ixgbe_hw *hw)
671 if (ixgbe_validate_mac_addr(hw->mac.addr) == 1134 if (ixgbe_validate_mac_addr(hw->mac.addr) ==
672 IXGBE_ERR_INVALID_MAC_ADDR) { 1135 IXGBE_ERR_INVALID_MAC_ADDR) {
673 /* Get the MAC address from the RAR0 for later reference */ 1136 /* Get the MAC address from the RAR0 for later reference */
674 ixgbe_get_mac_addr(hw, hw->mac.addr); 1137 hw->mac.ops.get_mac_addr(hw, hw->mac.addr);
675 1138
676 hw_dbg(hw, " Keeping Current RAR0 Addr =%.2X %.2X %.2X ", 1139 hw_dbg(hw, " Keeping Current RAR0 Addr =%.2X %.2X %.2X ",
677 hw->mac.addr[0], hw->mac.addr[1], 1140 hw->mac.addr[0], hw->mac.addr[1],
@@ -687,13 +1150,14 @@ static s32 ixgbe_init_rx_addrs(struct ixgbe_hw *hw)
687 hw_dbg(hw, "%.2X %.2X %.2X\n", hw->mac.addr[3], 1150 hw_dbg(hw, "%.2X %.2X %.2X\n", hw->mac.addr[3],
688 hw->mac.addr[4], hw->mac.addr[5]); 1151 hw->mac.addr[4], hw->mac.addr[5]);
689 1152
690 ixgbe_set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV); 1153 hw->mac.ops.set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV);
691 } 1154 }
1155 hw->addr_ctrl.overflow_promisc = 0;
692 1156
693 hw->addr_ctrl.rar_used_count = 1; 1157 hw->addr_ctrl.rar_used_count = 1;
694 1158
695 /* Zero out the other receive addresses. */ 1159 /* Zero out the other receive addresses. */
696 hw_dbg(hw, "Clearing RAR[1-15]\n"); 1160 hw_dbg(hw, "Clearing RAR[1-%d]\n", rar_entries - 1);
697 for (i = 1; i < rar_entries; i++) { 1161 for (i = 1; i < rar_entries; i++) {
698 IXGBE_WRITE_REG(hw, IXGBE_RAL(i), 0); 1162 IXGBE_WRITE_REG(hw, IXGBE_RAL(i), 0);
699 IXGBE_WRITE_REG(hw, IXGBE_RAH(i), 0); 1163 IXGBE_WRITE_REG(hw, IXGBE_RAH(i), 0);
@@ -708,6 +1172,9 @@ static s32 ixgbe_init_rx_addrs(struct ixgbe_hw *hw)
708 for (i = 0; i < hw->mac.mcft_size; i++) 1172 for (i = 0; i < hw->mac.mcft_size; i++)
709 IXGBE_WRITE_REG(hw, IXGBE_MTA(i), 0); 1173 IXGBE_WRITE_REG(hw, IXGBE_MTA(i), 0);
710 1174
1175 if (hw->mac.ops.init_uta_tables)
1176 hw->mac.ops.init_uta_tables(hw);
1177
711 return 0; 1178 return 0;
712} 1179}
713 1180
@@ -718,7 +1185,7 @@ static s32 ixgbe_init_rx_addrs(struct ixgbe_hw *hw)
718 * 1185 *
719 * Adds it to unused receive address register or goes into promiscuous mode. 1186 * Adds it to unused receive address register or goes into promiscuous mode.
720 **/ 1187 **/
721void ixgbe_add_uc_addr(struct ixgbe_hw *hw, u8 *addr) 1188static void ixgbe_add_uc_addr(struct ixgbe_hw *hw, u8 *addr, u32 vmdq)
722{ 1189{
723 u32 rar_entries = hw->mac.num_rar_entries; 1190 u32 rar_entries = hw->mac.num_rar_entries;
724 u32 rar; 1191 u32 rar;
@@ -733,7 +1200,7 @@ void ixgbe_add_uc_addr(struct ixgbe_hw *hw, u8 *addr)
733 if (hw->addr_ctrl.rar_used_count < rar_entries) { 1200 if (hw->addr_ctrl.rar_used_count < rar_entries) {
734 rar = hw->addr_ctrl.rar_used_count - 1201 rar = hw->addr_ctrl.rar_used_count -
735 hw->addr_ctrl.mc_addr_in_rar_count; 1202 hw->addr_ctrl.mc_addr_in_rar_count;
736 ixgbe_set_rar(hw, rar, addr, 0, IXGBE_RAH_AV); 1203 hw->mac.ops.set_rar(hw, rar, addr, vmdq, IXGBE_RAH_AV);
737 hw_dbg(hw, "Added a secondary address to RAR[%d]\n", rar); 1204 hw_dbg(hw, "Added a secondary address to RAR[%d]\n", rar);
738 hw->addr_ctrl.rar_used_count++; 1205 hw->addr_ctrl.rar_used_count++;
739 } else { 1206 } else {
@@ -744,7 +1211,7 @@ void ixgbe_add_uc_addr(struct ixgbe_hw *hw, u8 *addr)
744} 1211}
745 1212
746/** 1213/**
747 * ixgbe_update_uc_addr_list - Updates MAC list of secondary addresses 1214 * ixgbe_update_uc_addr_list_generic - Updates MAC list of secondary addresses
748 * @hw: pointer to hardware structure 1215 * @hw: pointer to hardware structure
749 * @addr_list: the list of new addresses 1216 * @addr_list: the list of new addresses
750 * @addr_count: number of addresses 1217 * @addr_count: number of addresses
@@ -757,7 +1224,7 @@ void ixgbe_add_uc_addr(struct ixgbe_hw *hw, u8 *addr)
757 * Drivers using secondary unicast addresses must set user_set_promisc when 1224 * Drivers using secondary unicast addresses must set user_set_promisc when
758 * manually putting the device into promiscuous mode. 1225 * manually putting the device into promiscuous mode.
759 **/ 1226 **/
760s32 ixgbe_update_uc_addr_list(struct ixgbe_hw *hw, u8 *addr_list, 1227s32 ixgbe_update_uc_addr_list_generic(struct ixgbe_hw *hw, u8 *addr_list,
761 u32 addr_count, ixgbe_mc_addr_itr next) 1228 u32 addr_count, ixgbe_mc_addr_itr next)
762{ 1229{
763 u8 *addr; 1230 u8 *addr;
@@ -787,7 +1254,7 @@ s32 ixgbe_update_uc_addr_list(struct ixgbe_hw *hw, u8 *addr_list,
787 for (i = 0; i < addr_count; i++) { 1254 for (i = 0; i < addr_count; i++) {
788 hw_dbg(hw, " Adding the secondary addresses:\n"); 1255 hw_dbg(hw, " Adding the secondary addresses:\n");
789 addr = next(hw, &addr_list, &vmdq); 1256 addr = next(hw, &addr_list, &vmdq);
790 ixgbe_add_uc_addr(hw, addr); 1257 ixgbe_add_uc_addr(hw, addr, vmdq);
791 } 1258 }
792 1259
793 if (hw->addr_ctrl.overflow_promisc) { 1260 if (hw->addr_ctrl.overflow_promisc) {
@@ -808,7 +1275,7 @@ s32 ixgbe_update_uc_addr_list(struct ixgbe_hw *hw, u8 *addr_list,
808 } 1275 }
809 } 1276 }
810 1277
811 hw_dbg(hw, "ixgbe_update_uc_addr_list Complete\n"); 1278 hw_dbg(hw, "ixgbe_update_uc_addr_list_generic Complete\n");
812 return 0; 1279 return 0;
813} 1280}
814 1281
@@ -821,7 +1288,7 @@ s32 ixgbe_update_uc_addr_list(struct ixgbe_hw *hw, u8 *addr_list,
821 * bit-vector to set in the multicast table. The hardware uses 12 bits, from 1288 * bit-vector to set in the multicast table. The hardware uses 12 bits, from
822 * incoming rx multicast addresses, to determine the bit-vector to check in 1289 * incoming rx multicast addresses, to determine the bit-vector to check in
823 * the MTA. Which of the 4 combination, of 12-bits, the hardware uses is set 1290 * the MTA. Which of the 4 combination, of 12-bits, the hardware uses is set
824 * by the MO field of the MCSTCTRL. The MO field is set during initalization 1291 * by the MO field of the MCSTCTRL. The MO field is set during initialization
825 * to mc_filter_type. 1292 * to mc_filter_type.
826 **/ 1293 **/
827static s32 ixgbe_mta_vector(struct ixgbe_hw *hw, u8 *mc_addr) 1294static s32 ixgbe_mta_vector(struct ixgbe_hw *hw, u8 *mc_addr)
@@ -907,10 +1374,10 @@ static void ixgbe_add_mc_addr(struct ixgbe_hw *hw, u8 *mc_addr)
907 * else put it in the MTA 1374 * else put it in the MTA
908 */ 1375 */
909 if (hw->addr_ctrl.rar_used_count < rar_entries) { 1376 if (hw->addr_ctrl.rar_used_count < rar_entries) {
1377 /* use RAR from the end up for multicast */
910 rar = rar_entries - hw->addr_ctrl.mc_addr_in_rar_count - 1; 1378 rar = rar_entries - hw->addr_ctrl.mc_addr_in_rar_count - 1;
911 ixgbe_set_rar(hw, rar, mc_addr, 0, IXGBE_RAH_AV); 1379 hw->mac.ops.set_rar(hw, rar, mc_addr, 0, IXGBE_RAH_AV);
912 hw_dbg(hw, "Added a multicast address to RAR[%d]\n", 1380 hw_dbg(hw, "Added a multicast address to RAR[%d]\n", rar);
913 hw->addr_ctrl.rar_used_count);
914 hw->addr_ctrl.rar_used_count++; 1381 hw->addr_ctrl.rar_used_count++;
915 hw->addr_ctrl.mc_addr_in_rar_count++; 1382 hw->addr_ctrl.mc_addr_in_rar_count++;
916 } else { 1383 } else {
@@ -921,18 +1388,18 @@ static void ixgbe_add_mc_addr(struct ixgbe_hw *hw, u8 *mc_addr)
921} 1388}
922 1389
923/** 1390/**
924 * ixgbe_update_mc_addr_list - Updates MAC list of multicast addresses 1391 * ixgbe_update_mc_addr_list_generic - Updates MAC list of multicast addresses
925 * @hw: pointer to hardware structure 1392 * @hw: pointer to hardware structure
926 * @mc_addr_list: the list of new multicast addresses 1393 * @mc_addr_list: the list of new multicast addresses
927 * @mc_addr_count: number of addresses 1394 * @mc_addr_count: number of addresses
928 * @next: iterator function to walk the multicast address list 1395 * @next: iterator function to walk the multicast address list
929 * 1396 *
930 * The given list replaces any existing list. Clears the MC addrs from receive 1397 * The given list replaces any existing list. Clears the MC addrs from receive
931 * address registers and the multicast table. Uses unsed receive address 1398 * address registers and the multicast table. Uses unused receive address
932 * registers for the first multicast addresses, and hashes the rest into the 1399 * registers for the first multicast addresses, and hashes the rest into the
933 * multicast table. 1400 * multicast table.
934 **/ 1401 **/
935s32 ixgbe_update_mc_addr_list(struct ixgbe_hw *hw, u8 *mc_addr_list, 1402s32 ixgbe_update_mc_addr_list_generic(struct ixgbe_hw *hw, u8 *mc_addr_list,
936 u32 mc_addr_count, ixgbe_mc_addr_itr next) 1403 u32 mc_addr_count, ixgbe_mc_addr_itr next)
937{ 1404{
938 u32 i; 1405 u32 i;
@@ -949,7 +1416,8 @@ s32 ixgbe_update_mc_addr_list(struct ixgbe_hw *hw, u8 *mc_addr_list,
949 hw->addr_ctrl.mta_in_use = 0; 1416 hw->addr_ctrl.mta_in_use = 0;
950 1417
951 /* Zero out the other receive addresses. */ 1418 /* Zero out the other receive addresses. */
952 hw_dbg(hw, "Clearing RAR[1-15]\n"); 1419 hw_dbg(hw, "Clearing RAR[%d-%d]\n", hw->addr_ctrl.rar_used_count,
1420 rar_entries - 1);
953 for (i = hw->addr_ctrl.rar_used_count; i < rar_entries; i++) { 1421 for (i = hw->addr_ctrl.rar_used_count; i < rar_entries; i++) {
954 IXGBE_WRITE_REG(hw, IXGBE_RAL(i), 0); 1422 IXGBE_WRITE_REG(hw, IXGBE_RAL(i), 0);
955 IXGBE_WRITE_REG(hw, IXGBE_RAH(i), 0); 1423 IXGBE_WRITE_REG(hw, IXGBE_RAH(i), 0);
@@ -971,188 +1439,53 @@ s32 ixgbe_update_mc_addr_list(struct ixgbe_hw *hw, u8 *mc_addr_list,
971 IXGBE_WRITE_REG(hw, IXGBE_MCSTCTRL, 1439 IXGBE_WRITE_REG(hw, IXGBE_MCSTCTRL,
972 IXGBE_MCSTCTRL_MFE | hw->mac.mc_filter_type); 1440 IXGBE_MCSTCTRL_MFE | hw->mac.mc_filter_type);
973 1441
974 hw_dbg(hw, "ixgbe_update_mc_addr_list Complete\n"); 1442 hw_dbg(hw, "ixgbe_update_mc_addr_list_generic Complete\n");
975 return 0; 1443 return 0;
976} 1444}
977 1445
978/** 1446/**
979 * ixgbe_clear_vfta - Clear VLAN filter table 1447 * ixgbe_enable_mc_generic - Enable multicast address in RAR
980 * @hw: pointer to hardware structure 1448 * @hw: pointer to hardware structure
981 * 1449 *
982 * Clears the VLAN filer table, and the VMDq index associated with the filter 1450 * Enables multicast address in RAR and the use of the multicast hash table.
983 **/ 1451 **/
984static s32 ixgbe_clear_vfta(struct ixgbe_hw *hw) 1452s32 ixgbe_enable_mc_generic(struct ixgbe_hw *hw)
985{ 1453{
986 u32 offset; 1454 u32 i;
987 u32 vlanbyte; 1455 u32 rar_entries = hw->mac.num_rar_entries;
1456 struct ixgbe_addr_filter_info *a = &hw->addr_ctrl;
988 1457
989 for (offset = 0; offset < hw->mac.vft_size; offset++) 1458 if (a->mc_addr_in_rar_count > 0)
990 IXGBE_WRITE_REG(hw, IXGBE_VFTA(offset), 0); 1459 for (i = (rar_entries - a->mc_addr_in_rar_count);
1460 i < rar_entries; i++)
1461 ixgbe_enable_rar(hw, i);
991 1462
992 for (vlanbyte = 0; vlanbyte < 4; vlanbyte++) 1463 if (a->mta_in_use > 0)
993 for (offset = 0; offset < hw->mac.vft_size; offset++) 1464 IXGBE_WRITE_REG(hw, IXGBE_MCSTCTRL, IXGBE_MCSTCTRL_MFE |
994 IXGBE_WRITE_REG(hw, IXGBE_VFTAVIND(vlanbyte, offset), 1465 hw->mac.mc_filter_type);
995 0);
996 1466
997 return 0; 1467 return 0;
998} 1468}
999 1469
1000/** 1470/**
1001 * ixgbe_set_vfta - Set VLAN filter table 1471 * ixgbe_disable_mc_generic - Disable multicast address in RAR
1002 * @hw: pointer to hardware structure 1472 * @hw: pointer to hardware structure
1003 * @vlan: VLAN id to write to VLAN filter
1004 * @vind: VMDq output index that maps queue to VLAN id in VFTA
1005 * @vlan_on: boolean flag to turn on/off VLAN in VFTA
1006 * 1473 *
1007 * Turn on/off specified VLAN in the VLAN filter table. 1474 * Disables multicast address in RAR and the use of the multicast hash table.
1008 **/ 1475 **/
1009s32 ixgbe_set_vfta(struct ixgbe_hw *hw, u32 vlan, u32 vind, 1476s32 ixgbe_disable_mc_generic(struct ixgbe_hw *hw)
1010 bool vlan_on)
1011{ 1477{
1012 u32 VftaIndex; 1478 u32 i;
1013 u32 BitOffset; 1479 u32 rar_entries = hw->mac.num_rar_entries;
1014 u32 VftaReg; 1480 struct ixgbe_addr_filter_info *a = &hw->addr_ctrl;
1015 u32 VftaByte;
1016
1017 /* Determine 32-bit word position in array */
1018 VftaIndex = (vlan >> 5) & 0x7F; /* upper seven bits */
1019
1020 /* Determine the location of the (VMD) queue index */
1021 VftaByte = ((vlan >> 3) & 0x03); /* bits (4:3) indicating byte array */
1022 BitOffset = (vlan & 0x7) << 2; /* lower 3 bits indicate nibble */
1023
1024 /* Set the nibble for VMD queue index */
1025 VftaReg = IXGBE_READ_REG(hw, IXGBE_VFTAVIND(VftaByte, VftaIndex));
1026 VftaReg &= (~(0x0F << BitOffset));
1027 VftaReg |= (vind << BitOffset);
1028 IXGBE_WRITE_REG(hw, IXGBE_VFTAVIND(VftaByte, VftaIndex), VftaReg);
1029
1030 /* Determine the location of the bit for this VLAN id */
1031 BitOffset = vlan & 0x1F; /* lower five bits */
1032
1033 VftaReg = IXGBE_READ_REG(hw, IXGBE_VFTA(VftaIndex));
1034 if (vlan_on)
1035 /* Turn on this VLAN id */
1036 VftaReg |= (1 << BitOffset);
1037 else
1038 /* Turn off this VLAN id */
1039 VftaReg &= ~(1 << BitOffset);
1040 IXGBE_WRITE_REG(hw, IXGBE_VFTA(VftaIndex), VftaReg);
1041
1042 return 0;
1043}
1044
1045/**
1046 * ixgbe_setup_fc - Configure flow control settings
1047 * @hw: pointer to hardware structure
1048 * @packetbuf_num: packet buffer number (0-7)
1049 *
1050 * Configures the flow control settings based on SW configuration.
1051 * This function is used for 802.3x flow control configuration only.
1052 **/
1053s32 ixgbe_setup_fc(struct ixgbe_hw *hw, s32 packetbuf_num)
1054{
1055 u32 frctl_reg;
1056 u32 rmcs_reg;
1057
1058 if (packetbuf_num < 0 || packetbuf_num > 7)
1059 hw_dbg(hw, "Invalid packet buffer number [%d], expected range "
1060 "is 0-7\n", packetbuf_num);
1061
1062 frctl_reg = IXGBE_READ_REG(hw, IXGBE_FCTRL);
1063 frctl_reg &= ~(IXGBE_FCTRL_RFCE | IXGBE_FCTRL_RPFCE);
1064
1065 rmcs_reg = IXGBE_READ_REG(hw, IXGBE_RMCS);
1066 rmcs_reg &= ~(IXGBE_RMCS_TFCE_PRIORITY | IXGBE_RMCS_TFCE_802_3X);
1067
1068 /*
1069 * 10 gig parts do not have a word in the EEPROM to determine the
1070 * default flow control setting, so we explicitly set it to full.
1071 */
1072 if (hw->fc.type == ixgbe_fc_default)
1073 hw->fc.type = ixgbe_fc_full;
1074
1075 /*
1076 * We want to save off the original Flow Control configuration just in
1077 * case we get disconnected and then reconnected into a different hub
1078 * or switch with different Flow Control capabilities.
1079 */
1080 hw->fc.type = hw->fc.original_type;
1081
1082 /*
1083 * The possible values of the "flow_control" parameter are:
1084 * 0: Flow control is completely disabled
1085 * 1: Rx flow control is enabled (we can receive pause frames but not
1086 * send pause frames).
1087 * 2: Tx flow control is enabled (we can send pause frames but we do not
1088 * support receiving pause frames)
1089 * 3: Both Rx and TX flow control (symmetric) are enabled.
1090 * other: Invalid.
1091 */
1092 switch (hw->fc.type) {
1093 case ixgbe_fc_none:
1094 break;
1095 case ixgbe_fc_rx_pause:
1096 /*
1097 * RX Flow control is enabled,
1098 * and TX Flow control is disabled.
1099 */
1100 frctl_reg |= IXGBE_FCTRL_RFCE;
1101 break;
1102 case ixgbe_fc_tx_pause:
1103 /*
1104 * TX Flow control is enabled, and RX Flow control is disabled,
1105 * by a software over-ride.
1106 */
1107 rmcs_reg |= IXGBE_RMCS_TFCE_802_3X;
1108 break;
1109 case ixgbe_fc_full:
1110 /*
1111 * Flow control (both RX and TX) is enabled by a software
1112 * over-ride.
1113 */
1114 frctl_reg |= IXGBE_FCTRL_RFCE;
1115 rmcs_reg |= IXGBE_RMCS_TFCE_802_3X;
1116 break;
1117 default:
1118 /* We should never get here. The value should be 0-3. */
1119 hw_dbg(hw, "Flow control param set incorrectly\n");
1120 break;
1121 }
1122
1123 /* Enable 802.3x based flow control settings. */
1124 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, frctl_reg);
1125 IXGBE_WRITE_REG(hw, IXGBE_RMCS, rmcs_reg);
1126
1127 /*
1128 * Check for invalid software configuration, zeros are completely
1129 * invalid for all parameters used past this point, and if we enable
1130 * flow control with zero water marks, we blast flow control packets.
1131 */
1132 if (!hw->fc.low_water || !hw->fc.high_water || !hw->fc.pause_time) {
1133 hw_dbg(hw, "Flow control structure initialized incorrectly\n");
1134 return IXGBE_ERR_INVALID_LINK_SETTINGS;
1135 }
1136 1481
1137 /* 1482 if (a->mc_addr_in_rar_count > 0)
1138 * We need to set up the Receive Threshold high and low water 1483 for (i = (rar_entries - a->mc_addr_in_rar_count);
1139 * marks as well as (optionally) enabling the transmission of 1484 i < rar_entries; i++)
1140 * XON frames. 1485 ixgbe_disable_rar(hw, i);
1141 */
1142 if (hw->fc.type & ixgbe_fc_tx_pause) {
1143 if (hw->fc.send_xon) {
1144 IXGBE_WRITE_REG(hw, IXGBE_FCRTL(packetbuf_num),
1145 (hw->fc.low_water | IXGBE_FCRTL_XONE));
1146 } else {
1147 IXGBE_WRITE_REG(hw, IXGBE_FCRTL(packetbuf_num),
1148 hw->fc.low_water);
1149 }
1150 IXGBE_WRITE_REG(hw, IXGBE_FCRTH(packetbuf_num),
1151 (hw->fc.high_water)|IXGBE_FCRTH_FCEN);
1152 }
1153 1486
1154 IXGBE_WRITE_REG(hw, IXGBE_FCTTV(0), hw->fc.pause_time); 1487 if (a->mta_in_use > 0)
1155 IXGBE_WRITE_REG(hw, IXGBE_FCRTV, (hw->fc.pause_time >> 1)); 1488 IXGBE_WRITE_REG(hw, IXGBE_MCSTCTRL, hw->mac.mc_filter_type);
1156 1489
1157 return 0; 1490 return 0;
1158} 1491}
@@ -1168,13 +1501,24 @@ s32 ixgbe_setup_fc(struct ixgbe_hw *hw, s32 packetbuf_num)
1168 **/ 1501 **/
1169s32 ixgbe_disable_pcie_master(struct ixgbe_hw *hw) 1502s32 ixgbe_disable_pcie_master(struct ixgbe_hw *hw)
1170{ 1503{
1171 u32 ctrl; 1504 u32 i;
1172 s32 i; 1505 u32 reg_val;
1506 u32 number_of_queues;
1173 s32 status = IXGBE_ERR_MASTER_REQUESTS_PENDING; 1507 s32 status = IXGBE_ERR_MASTER_REQUESTS_PENDING;
1174 1508
1175 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL); 1509 /* Disable the receive unit by stopping each queue */
1176 ctrl |= IXGBE_CTRL_GIO_DIS; 1510 number_of_queues = hw->mac.max_rx_queues;
1177 IXGBE_WRITE_REG(hw, IXGBE_CTRL, ctrl); 1511 for (i = 0; i < number_of_queues; i++) {
1512 reg_val = IXGBE_READ_REG(hw, IXGBE_RXDCTL(i));
1513 if (reg_val & IXGBE_RXDCTL_ENABLE) {
1514 reg_val &= ~IXGBE_RXDCTL_ENABLE;
1515 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(i), reg_val);
1516 }
1517 }
1518
1519 reg_val = IXGBE_READ_REG(hw, IXGBE_CTRL);
1520 reg_val |= IXGBE_CTRL_GIO_DIS;
1521 IXGBE_WRITE_REG(hw, IXGBE_CTRL, reg_val);
1178 1522
1179 for (i = 0; i < IXGBE_PCI_MASTER_DISABLE_TIMEOUT; i++) { 1523 for (i = 0; i < IXGBE_PCI_MASTER_DISABLE_TIMEOUT; i++) {
1180 if (!(IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_GIO)) { 1524 if (!(IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_GIO)) {
@@ -1189,11 +1533,11 @@ s32 ixgbe_disable_pcie_master(struct ixgbe_hw *hw)
1189 1533
1190 1534
1191/** 1535/**
1192 * ixgbe_acquire_swfw_sync - Aquire SWFW semaphore 1536 * ixgbe_acquire_swfw_sync - Acquire SWFW semaphore
1193 * @hw: pointer to hardware structure 1537 * @hw: pointer to hardware structure
1194 * @mask: Mask to specify wich semaphore to acquire 1538 * @mask: Mask to specify which semaphore to acquire
1195 * 1539 *
1196 * Aquires the SWFW semaphore throught the GSSR register for the specified 1540 * Acquires the SWFW semaphore thought the GSSR register for the specified
1197 * function (CSR, PHY0, PHY1, EEPROM, Flash) 1541 * function (CSR, PHY0, PHY1, EEPROM, Flash)
1198 **/ 1542 **/
1199s32 ixgbe_acquire_swfw_sync(struct ixgbe_hw *hw, u16 mask) 1543s32 ixgbe_acquire_swfw_sync(struct ixgbe_hw *hw, u16 mask)
@@ -1235,9 +1579,9 @@ s32 ixgbe_acquire_swfw_sync(struct ixgbe_hw *hw, u16 mask)
1235/** 1579/**
1236 * ixgbe_release_swfw_sync - Release SWFW semaphore 1580 * ixgbe_release_swfw_sync - Release SWFW semaphore
1237 * @hw: pointer to hardware structure 1581 * @hw: pointer to hardware structure
1238 * @mask: Mask to specify wich semaphore to release 1582 * @mask: Mask to specify which semaphore to release
1239 * 1583 *
1240 * Releases the SWFW semaphore throught the GSSR register for the specified 1584 * Releases the SWFW semaphore thought the GSSR register for the specified
1241 * function (CSR, PHY0, PHY1, EEPROM, Flash) 1585 * function (CSR, PHY0, PHY1, EEPROM, Flash)
1242 **/ 1586 **/
1243void ixgbe_release_swfw_sync(struct ixgbe_hw *hw, u16 mask) 1587void ixgbe_release_swfw_sync(struct ixgbe_hw *hw, u16 mask)
@@ -1254,45 +1598,3 @@ void ixgbe_release_swfw_sync(struct ixgbe_hw *hw, u16 mask)
1254 ixgbe_release_eeprom_semaphore(hw); 1598 ixgbe_release_eeprom_semaphore(hw);
1255} 1599}
1256 1600
1257/**
1258 * ixgbe_read_analog_reg8 - Reads 8 bit Atlas analog register
1259 * @hw: pointer to hardware structure
1260 * @reg: analog register to read
1261 * @val: read value
1262 *
1263 * Performs write operation to analog register specified.
1264 **/
1265s32 ixgbe_read_analog_reg8(struct ixgbe_hw *hw, u32 reg, u8 *val)
1266{
1267 u32 atlas_ctl;
1268
1269 IXGBE_WRITE_REG(hw, IXGBE_ATLASCTL,
1270 IXGBE_ATLASCTL_WRITE_CMD | (reg << 8));
1271 IXGBE_WRITE_FLUSH(hw);
1272 udelay(10);
1273 atlas_ctl = IXGBE_READ_REG(hw, IXGBE_ATLASCTL);
1274 *val = (u8)atlas_ctl;
1275
1276 return 0;
1277}
1278
1279/**
1280 * ixgbe_write_analog_reg8 - Writes 8 bit Atlas analog register
1281 * @hw: pointer to hardware structure
1282 * @reg: atlas register to write
1283 * @val: value to write
1284 *
1285 * Performs write operation to Atlas analog register specified.
1286 **/
1287s32 ixgbe_write_analog_reg8(struct ixgbe_hw *hw, u32 reg, u8 val)
1288{
1289 u32 atlas_ctl;
1290
1291 atlas_ctl = (reg << 8) | val;
1292 IXGBE_WRITE_REG(hw, IXGBE_ATLASCTL, atlas_ctl);
1293 IXGBE_WRITE_FLUSH(hw);
1294 udelay(10);
1295
1296 return 0;
1297}
1298