Setting tag linux-2.6-27-38
[linux-2.6.git] / linux-2.6-011-e1000e-82574L.patch
1 diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c
2 index 462351c..b2c910c 100644
3 --- a/drivers/net/e1000e/82571.c
4 +++ b/drivers/net/e1000e/82571.c
5 @@ -38,6 +38,7 @@
6   * 82573V Gigabit Ethernet Controller (Copper)
7   * 82573E Gigabit Ethernet Controller (Copper)
8   * 82573L Gigabit Ethernet Controller
9 + * 82574L Gigabit Network Connection
10   */
11  
12  #include <linux/netdevice.h>
13 @@ -54,6 +55,8 @@
14  
15  #define E1000_GCR_L1_ACT_WITHOUT_L0S_RX 0x08000000
16  
17 +#define E1000_NVM_INIT_CTRL2_MNGM 0x6000 /* Manageability Operation Mode mask */
18 +
19  static s32 e1000_get_phy_id_82571(struct e1000_hw *hw);
20  static s32 e1000_setup_copper_link_82571(struct e1000_hw *hw);
21  static s32 e1000_setup_fiber_serdes_link_82571(struct e1000_hw *hw);
22 @@ -63,6 +66,8 @@ static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw);
23  static void e1000_initialize_hw_bits_82571(struct e1000_hw *hw);
24  static s32 e1000_setup_link_82571(struct e1000_hw *hw);
25  static void e1000_clear_hw_cntrs_82571(struct e1000_hw *hw);
26 +static bool e1000_check_mng_mode_82574(struct e1000_hw *hw);
27 +static s32 e1000_led_on_82574(struct e1000_hw *hw);
28  
29  /**
30   *  e1000_init_phy_params_82571 - Init PHY func ptrs.
31 @@ -92,6 +97,9 @@ static s32 e1000_init_phy_params_82571(struct e1000_hw *hw)
32         case e1000_82573:
33                 phy->type                = e1000_phy_m88;
34                 break;
35 +       case e1000_82574:
36 +               phy->type                = e1000_phy_bm;
37 +               break;
38         default:
39                 return -E1000_ERR_PHY;
40                 break;
41 @@ -111,6 +119,10 @@ static s32 e1000_init_phy_params_82571(struct e1000_hw *hw)
42                 if (phy->id != M88E1111_I_PHY_ID)
43                         return -E1000_ERR_PHY;
44                 break;
45 +       case e1000_82574:
46 +               if (phy->id != BME1000_E_PHY_ID_R2)
47 +                       return -E1000_ERR_PHY;
48 +               break;
49         default:
50                 return -E1000_ERR_PHY;
51                 break;
52 @@ -150,6 +162,7 @@ static s32 e1000_init_nvm_params_82571(struct e1000_hw *hw)
53  
54         switch (hw->mac.type) {
55         case e1000_82573:
56 +       case e1000_82574:
57                 if (((eecd >> 15) & 0x3) == 0x3) {
58                         nvm->type = e1000_nvm_flash_hw;
59                         nvm->word_size = 2048;
60 @@ -245,6 +258,17 @@ static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter)
61                 break;
62         }
63  
64 +       switch (hw->mac.type) {
65 +       case e1000_82574:
66 +               func->check_mng_mode = e1000_check_mng_mode_82574;
67 +               func->led_on = e1000_led_on_82574;
68 +               break;
69 +       default:
70 +               func->check_mng_mode = e1000e_check_mng_mode_generic;
71 +               func->led_on = e1000e_led_on_generic;
72 +               break;
73 +       }
74 +
75         return 0;
76  }
77  
78 @@ -330,6 +354,8 @@ static s32 e1000_get_variants_82571(struct e1000_adapter *adapter)
79  static s32 e1000_get_phy_id_82571(struct e1000_hw *hw)
80  {
81         struct e1000_phy_info *phy = &hw->phy;
82 +       s32 ret_val;
83 +       u16 phy_id = 0;
84  
85         switch (hw->mac.type) {
86         case e1000_82571:
87 @@ -345,6 +371,20 @@ static s32 e1000_get_phy_id_82571(struct e1000_hw *hw)
88         case e1000_82573:
89                 return e1000e_get_phy_id(hw);
90                 break;
91 +       case e1000_82574:
92 +               ret_val = e1e_rphy(hw, PHY_ID1, &phy_id);
93 +               if (ret_val)
94 +                       return ret_val;
95 +
96 +               phy->id = (u32)(phy_id << 16);
97 +               udelay(20);
98 +               ret_val = e1e_rphy(hw, PHY_ID2, &phy_id);
99 +               if (ret_val)
100 +                       return ret_val;
101 +
102 +               phy->id |= (u32)(phy_id);
103 +               phy->revision = (u32)(phy_id & ~PHY_REVISION_MASK);
104 +               break;
105         default:
106                 return -E1000_ERR_PHY;
107                 break;
108 @@ -421,7 +461,7 @@ static s32 e1000_acquire_nvm_82571(struct e1000_hw *hw)
109         if (ret_val)
110                 return ret_val;
111  
112 -       if (hw->mac.type != e1000_82573)
113 +       if (hw->mac.type != e1000_82573 && hw->mac.type != e1000_82574)
114                 ret_val = e1000e_acquire_nvm(hw);
115  
116         if (ret_val)
117 @@ -461,6 +501,7 @@ static s32 e1000_write_nvm_82571(struct e1000_hw *hw, u16 offset, u16 words,
118  
119         switch (hw->mac.type) {
120         case e1000_82573:
121 +       case e1000_82574:
122                 ret_val = e1000_write_nvm_eewr_82571(hw, offset, words, data);
123                 break;
124         case e1000_82571:
125 @@ -735,7 +776,7 @@ static s32 e1000_reset_hw_82571(struct e1000_hw *hw)
126          * Must acquire the MDIO ownership before MAC reset.
127          * Ownership defaults to firmware after a reset.
128          */
129 -       if (hw->mac.type == e1000_82573) {
130 +       if (hw->mac.type == e1000_82573 || hw->mac.type == e1000_82574) {
131                 extcnf_ctrl = er32(EXTCNF_CTRL);
132                 extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
133  
134 @@ -776,7 +817,7 @@ static s32 e1000_reset_hw_82571(struct e1000_hw *hw)
135          * Need to wait for Phy configuration completion before accessing
136          * NVM and Phy.
137          */
138 -       if (hw->mac.type == e1000_82573)
139 +       if (hw->mac.type == e1000_82573 || hw->mac.type == e1000_82574)
140                 msleep(25);
141  
142         /* Clear any pending interrupt events. */
143 @@ -843,7 +884,7 @@ static s32 e1000_init_hw_82571(struct e1000_hw *hw)
144         ew32(TXDCTL(0), reg_data);
145  
146         /* ...for both queues. */
147 -       if (mac->type != e1000_82573) {
148 +       if (mac->type != e1000_82573 && mac->type != e1000_82574) {
149                 reg_data = er32(TXDCTL(1));
150                 reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) |
151                            E1000_TXDCTL_FULL_TX_DESC_WB |
152 @@ -918,19 +959,28 @@ static void e1000_initialize_hw_bits_82571(struct e1000_hw *hw)
153         }
154  
155         /* Device Control */
156 -       if (hw->mac.type == e1000_82573) {
157 +       if (hw->mac.type == e1000_82573 || hw->mac.type == e1000_82574) {
158                 reg = er32(CTRL);
159                 reg &= ~(1 << 29);
160                 ew32(CTRL, reg);
161         }
162  
163         /* Extended Device Control */
164 -       if (hw->mac.type == e1000_82573) {
165 +       if (hw->mac.type == e1000_82573 || hw->mac.type == e1000_82574) {
166                 reg = er32(CTRL_EXT);
167                 reg &= ~(1 << 23);
168                 reg |= (1 << 22);
169                 ew32(CTRL_EXT, reg);
170         }
171 +
172 +       /* PCI-Ex Control Register */
173 +       if (hw->mac.type == e1000_82574) {
174 +               reg = er32(GCR);
175 +               reg |= (1 << 22);
176 +               ew32(GCR, reg);
177 +       }
178 +
179 +       return;
180  }
181  
182  /**
183 @@ -947,7 +997,7 @@ void e1000e_clear_vfta(struct e1000_hw *hw)
184         u32 vfta_offset = 0;
185         u32 vfta_bit_in_reg = 0;
186  
187 -       if (hw->mac.type == e1000_82573) {
188 +       if (hw->mac.type == e1000_82573 || hw->mac.type == e1000_82574) {
189                 if (hw->mng_cookie.vlan_id != 0) {
190                         /*
191                          * The VFTA is a 4096b bit-field, each identifying
192 @@ -976,6 +1026,48 @@ void e1000e_clear_vfta(struct e1000_hw *hw)
193  }
194  
195  /**
196 + *  e1000_check_mng_mode_82574 - Check manageability is enabled
197 + *  @hw: pointer to the HW structure
198 + *
199 + *  Reads the NVM Initialization Control Word 2 and returns true
200 + *  (>0) if any manageability is enabled, else false (0).
201 + **/
202 +static bool e1000_check_mng_mode_82574(struct e1000_hw *hw)
203 +{
204 +       u16 data;
205 +
206 +       e1000_read_nvm(hw, NVM_INIT_CONTROL2_REG, 1, &data);
207 +       return (data & E1000_NVM_INIT_CTRL2_MNGM) != 0;
208 +}
209 +
210 +/**
211 + *  e1000_led_on_82574 - Turn LED on
212 + *  @hw: pointer to the HW structure
213 + *
214 + *  Turn LED on.
215 + **/
216 +static s32 e1000_led_on_82574(struct e1000_hw *hw)
217 +{
218 +       u32 ctrl;
219 +       u32 i;
220 +
221 +       ctrl = hw->mac.ledctl_mode2;
222 +       if (!(E1000_STATUS_LU & er32(STATUS))) {
223 +               /*
224 +                * If no link, then turn LED on by setting the invert bit
225 +                * for each LED that's "on" (0x0E) in ledctl_mode2.
226 +                */
227 +               for (i = 0; i < 4; i++)
228 +                       if (((hw->mac.ledctl_mode2 >> (i * 8)) & 0xFF) ==
229 +                           E1000_LEDCTL_MODE_LED_ON)
230 +                               ctrl |= (E1000_LEDCTL_LED0_IVRT << (i * 8));
231 +       }
232 +       ew32(LEDCTL, ctrl);
233 +
234 +       return 0;
235 +}
236 +
237 +/**
238   *  e1000_update_mc_addr_list_82571 - Update Multicast addresses
239   *  @hw: pointer to the HW structure
240   *  @mc_addr_list: array of multicast addresses to program
241 @@ -1018,7 +1110,8 @@ static s32 e1000_setup_link_82571(struct e1000_hw *hw)
242          * the default flow control setting, so we explicitly
243          * set it to full.
244          */
245 -       if (hw->mac.type == e1000_82573)
246 +       if ((hw->mac.type == e1000_82573 || hw->mac.type == e1000_82574) &&
247 +           hw->fc.type == e1000_fc_default)
248                 hw->fc.type = e1000_fc_full;
249  
250         return e1000e_setup_link(hw);
251 @@ -1045,6 +1138,7 @@ static s32 e1000_setup_copper_link_82571(struct e1000_hw *hw)
252  
253         switch (hw->phy.type) {
254         case e1000_phy_m88:
255 +       case e1000_phy_bm:
256                 ret_val = e1000e_copper_link_setup_m88(hw);
257                 break;
258         case e1000_phy_igp_2:
259 @@ -1114,11 +1208,10 @@ static s32 e1000_valid_led_default_82571(struct e1000_hw *hw, u16 *data)
260                 return ret_val;
261         }
262  
263 -       if (hw->mac.type == e1000_82573 &&
264 +       if ((hw->mac.type == e1000_82573 || hw->mac.type == e1000_82574) &&
265             *data == ID_LED_RESERVED_F746)
266                 *data = ID_LED_DEFAULT_82573;
267 -       else if (*data == ID_LED_RESERVED_0000 ||
268 -                *data == ID_LED_RESERVED_FFFF)
269 +       else if (*data == ID_LED_RESERVED_0000 || *data == ID_LED_RESERVED_FFFF)
270                 *data = ID_LED_DEFAULT;
271  
272         return 0;
273 @@ -1265,13 +1358,13 @@ static void e1000_clear_hw_cntrs_82571(struct e1000_hw *hw)
274  }
275  
276  static struct e1000_mac_operations e82571_mac_ops = {
277 -       .mng_mode_enab          = E1000_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT,
278 +       /* .check_mng_mode: mac type dependent */
279         /* .check_for_link: media type dependent */
280         .cleanup_led            = e1000e_cleanup_led_generic,
281         .clear_hw_cntrs         = e1000_clear_hw_cntrs_82571,
282         .get_bus_info           = e1000e_get_bus_info_pcie,
283         /* .get_link_up_info: media type dependent */
284 -       .led_on                 = e1000e_led_on_generic,
285 +       /* .led_on: mac type dependent */
286         .led_off                = e1000e_led_off_generic,
287         .update_mc_addr_list    = e1000_update_mc_addr_list_82571,
288         .reset_hw               = e1000_reset_hw_82571,
289 @@ -1312,6 +1405,22 @@ static struct e1000_phy_operations e82_phy_ops_m88 = {
290         .write_phy_reg          = e1000e_write_phy_reg_m88,
291  };
292  
293 +static struct e1000_phy_operations e82_phy_ops_bm = {
294 +       .acquire_phy            = e1000_get_hw_semaphore_82571,
295 +       .check_reset_block      = e1000e_check_reset_block_generic,
296 +       .commit_phy             = e1000e_phy_sw_reset,
297 +       .force_speed_duplex     = e1000e_phy_force_speed_duplex_m88,
298 +       .get_cfg_done           = e1000e_get_cfg_done,
299 +       .get_cable_length       = e1000e_get_cable_length_m88,
300 +       .get_phy_info           = e1000e_get_phy_info_m88,
301 +       .read_phy_reg           = e1000e_read_phy_reg_bm2,
302 +       .release_phy            = e1000_put_hw_semaphore_82571,
303 +       .reset_phy              = e1000e_phy_hw_reset_generic,
304 +       .set_d0_lplu_state      = e1000_set_d0_lplu_state_82571,
305 +       .set_d3_lplu_state      = e1000e_set_d3_lplu_state,
306 +       .write_phy_reg          = e1000e_write_phy_reg_bm2,
307 +};
308 +
309  static struct e1000_nvm_operations e82571_nvm_ops = {
310         .acquire_nvm            = e1000_acquire_nvm_82571,
311         .read_nvm               = e1000e_read_nvm_eerd,
312 @@ -1375,3 +1484,21 @@ struct e1000_info e1000_82573_info = {
313         .nvm_ops                = &e82571_nvm_ops,
314  };
315  
316 +struct e1000_info e1000_82574_info = {
317 +       .mac                    = e1000_82574,
318 +       .flags                  = FLAG_HAS_HW_VLAN_FILTER
319 +                                 | FLAG_HAS_MSIX
320 +                                 | FLAG_HAS_JUMBO_FRAMES
321 +                                 | FLAG_HAS_WOL
322 +                                 | FLAG_APME_IN_CTRL3
323 +                                 | FLAG_RX_CSUM_ENABLED
324 +                                 | FLAG_HAS_SMART_POWER_DOWN
325 +                                 | FLAG_HAS_AMT
326 +                                 | FLAG_HAS_CTRLEXT_ON_LOAD,
327 +       .pba                    = 20,
328 +       .get_variants           = e1000_get_variants_82571,
329 +       .mac_ops                = &e82571_mac_ops,
330 +       .phy_ops                = &e82_phy_ops_bm,
331 +       .nvm_ops                = &e82571_nvm_ops,
332 +};
333 +
334 diff --git a/drivers/net/e1000e/defines.h b/drivers/net/e1000e/defines.h
335 index 4b21fa9..48f79ec 100644
336 --- a/drivers/net/e1000e/defines.h
337 +++ b/drivers/net/e1000e/defines.h
338 @@ -71,9 +71,11 @@
339  #define E1000_CTRL_EXT_RO_DIS    0x00020000 /* Relaxed Ordering disable */
340  #define E1000_CTRL_EXT_LINK_MODE_MASK 0x00C00000
341  #define E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES  0x00C00000
342 +#define E1000_CTRL_EXT_EIAME          0x01000000
343  #define E1000_CTRL_EXT_DRV_LOAD       0x10000000 /* Driver loaded bit for FW */
344  #define E1000_CTRL_EXT_IAME           0x08000000 /* Interrupt acknowledge Auto-mask */
345  #define E1000_CTRL_EXT_INT_TIMER_CLR  0x20000000 /* Clear Interrupt timers after IMS clear */
346 +#define E1000_CTRL_EXT_PBA_CLR        0x80000000 /* PBA Clear */
347  
348  /* Receive Descriptor bit definitions */
349  #define E1000_RXD_STAT_DD       0x01    /* Descriptor Done */
350 @@ -299,6 +301,7 @@
351  #define E1000_RXCSUM_IPPCSE    0x00001000   /* IP payload checksum enable */
352  
353  /* Header split receive */
354 +#define E1000_RFCTL_ACK_DIS             0x00001000
355  #define E1000_RFCTL_EXTEN               0x00008000
356  #define E1000_RFCTL_IPV6_EX_DIS         0x00010000
357  #define E1000_RFCTL_NEW_IPV6_EXT_DIS    0x00020000
358 @@ -363,6 +366,11 @@
359  #define E1000_ICR_RXDMT0        0x00000010 /* Rx desc min. threshold (0) */
360  #define E1000_ICR_RXT0          0x00000080 /* Rx timer intr (ring 0) */
361  #define E1000_ICR_INT_ASSERTED  0x80000000 /* If this bit asserted, the driver should claim the interrupt */
362 +#define E1000_ICR_RXQ0          0x00100000 /* Rx Queue 0 Interrupt */
363 +#define E1000_ICR_RXQ1          0x00200000 /* Rx Queue 1 Interrupt */
364 +#define E1000_ICR_TXQ0          0x00400000 /* Tx Queue 0 Interrupt */
365 +#define E1000_ICR_TXQ1          0x00800000 /* Tx Queue 1 Interrupt */
366 +#define E1000_ICR_OTHER         0x01000000 /* Other Interrupts */
367  
368  /*
369   * This defines the bits that are set in the Interrupt Mask
370 @@ -386,6 +394,11 @@
371  #define E1000_IMS_RXSEQ     E1000_ICR_RXSEQ     /* Rx sequence error */
372  #define E1000_IMS_RXDMT0    E1000_ICR_RXDMT0    /* Rx desc min. threshold */
373  #define E1000_IMS_RXT0      E1000_ICR_RXT0      /* Rx timer intr */
374 +#define E1000_IMS_RXQ0      E1000_ICR_RXQ0      /* Rx Queue 0 Interrupt */
375 +#define E1000_IMS_RXQ1      E1000_ICR_RXQ1      /* Rx Queue 1 Interrupt */
376 +#define E1000_IMS_TXQ0      E1000_ICR_TXQ0      /* Tx Queue 0 Interrupt */
377 +#define E1000_IMS_TXQ1      E1000_ICR_TXQ1      /* Tx Queue 1 Interrupt */
378 +#define E1000_IMS_OTHER     E1000_ICR_OTHER     /* Other Interrupts */
379  
380  /* Interrupt Cause Set */
381  #define E1000_ICS_LSC       E1000_ICR_LSC       /* Link Status Change */
382 diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
383 index d5f8e8a..c55fd6f 100644
384 --- a/drivers/net/e1000e/e1000.h
385 +++ b/drivers/net/e1000e/e1000.h
386 @@ -62,6 +62,11 @@ struct e1000_info;
387         e_printk(KERN_NOTICE, adapter, format, ## arg)
388  
389  
390 +/* Interrupt modes, as used by the IntMode paramter */
391 +#define E1000E_INT_MODE_LEGACY         0
392 +#define E1000E_INT_MODE_MSI            1
393 +#define E1000E_INT_MODE_MSIX           2
394 +
395  /* Tx/Rx descriptor defines */
396  #define E1000_DEFAULT_TXD              256
397  #define E1000_MAX_TXD                  4096
398 @@ -95,6 +100,7 @@ enum e1000_boards {
399         board_82571,
400         board_82572,
401         board_82573,
402 +       board_82574,
403         board_80003es2lan,
404         board_ich8lan,
405         board_ich9lan,
406 @@ -147,6 +153,12 @@ struct e1000_ring {
407         /* array of buffer information structs */
408         struct e1000_buffer *buffer_info;
409  
410 +       char name[IFNAMSIZ + 5];
411 +       u32 ims_val;
412 +       u32 itr_val;
413 +       u16 itr_register;
414 +       int set_itr;
415 +
416         struct sk_buff *rx_skb_top;
417  
418         struct e1000_queue_stats stats;
419 @@ -274,6 +286,9 @@ struct e1000_adapter {
420         u32 test_icr;
421  
422         u32 msg_enable;
423 +       struct msix_entry *msix_entries;
424 +       int int_mode;
425 +       u32 eiac_mask;
426  
427         u32 eeprom_wol;
428         u32 wol;
429 @@ -311,6 +326,7 @@ struct e1000_info {
430  #define FLAG_HAS_JUMBO_FRAMES             (1 << 7)
431  #define FLAG_READ_ONLY_NVM                (1 << 8)
432  #define FLAG_IS_ICH                       (1 << 9)
433 +#define FLAG_HAS_MSIX                     (1 << 10)
434  #define FLAG_HAS_SMART_POWER_DOWN         (1 << 11)
435  #define FLAG_IS_QUAD_PORT_A               (1 << 12)
436  #define FLAG_IS_QUAD_PORT                 (1 << 13)
437 @@ -372,6 +388,8 @@ extern int e1000e_setup_tx_resources(struct e1000_adapter *adapter);
438  extern void e1000e_free_rx_resources(struct e1000_adapter *adapter);
439  extern void e1000e_free_tx_resources(struct e1000_adapter *adapter);
440  extern void e1000e_update_stats(struct e1000_adapter *adapter);
441 +extern void e1000e_set_interrupt_capability(struct e1000_adapter *adapter);
442 +extern void e1000e_reset_interrupt_capability(struct e1000_adapter *adapter);
443  
444  extern unsigned int copybreak;
445  
446 @@ -380,6 +398,7 @@ extern char *e1000e_get_hw_dev_name(struct e1000_hw *hw);
447  extern struct e1000_info e1000_82571_info;
448  extern struct e1000_info e1000_82572_info;
449  extern struct e1000_info e1000_82573_info;
450 +extern struct e1000_info e1000_82574_info;
451  extern struct e1000_info e1000_ich8_info;
452  extern struct e1000_info e1000_ich9_info;
453  extern struct e1000_info e1000_ich10_info;
454 @@ -461,6 +480,8 @@ extern enum e1000_phy_type e1000e_get_phy_type_from_id(u32 phy_id);
455  extern s32 e1000e_determine_phy_address(struct e1000_hw *hw);
456  extern s32 e1000e_write_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 data);
457  extern s32 e1000e_read_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 *data);
458 +extern s32 e1000e_read_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 *data);
459 +extern s32 e1000e_write_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 data);
460  extern void e1000e_phy_force_speed_duplex_setup(struct e1000_hw *hw, u16 *phy_ctrl);
461  extern s32 e1000e_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data);
462  extern s32 e1000e_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data);
463 @@ -531,7 +552,12 @@ static inline s32 e1000_get_phy_info(struct e1000_hw *hw)
464         return hw->phy.ops.get_phy_info(hw);
465  }
466  
467 -extern bool e1000e_check_mng_mode(struct e1000_hw *hw);
468 +static inline s32 e1000e_check_mng_mode(struct e1000_hw *hw)
469 +{
470 +       return hw->mac.ops.check_mng_mode(hw);
471 +}
472 +
473 +extern bool e1000e_check_mng_mode_generic(struct e1000_hw *hw);
474  extern bool e1000e_enable_tx_pkt_filtering(struct e1000_hw *hw);
475  extern s32 e1000e_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length);
476  
477 diff --git a/drivers/net/e1000e/es2lan.c b/drivers/net/e1000e/es2lan.c
478 index dc552d7..da9c09c 100644
479 --- a/drivers/net/e1000e/es2lan.c
480 +++ b/drivers/net/e1000e/es2lan.c
481 @@ -1247,7 +1247,7 @@ static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw)
482  }
483  
484  static struct e1000_mac_operations es2_mac_ops = {
485 -       .mng_mode_enab          = E1000_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT,
486 +       .check_mng_mode         = e1000e_check_mng_mode_generic,
487         /* check_for_link dependent on media type */
488         .cleanup_led            = e1000e_cleanup_led_generic,
489         .clear_hw_cntrs         = e1000_clear_hw_cntrs_80003es2lan,
490 diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c
491 index 5b7e6b5..62421ce 100644
492 --- a/drivers/net/e1000e/ethtool.c
493 +++ b/drivers/net/e1000e/ethtool.c
494 @@ -575,6 +575,7 @@ static int e1000_set_eeprom(struct net_device *netdev,
495          * and flush shadow RAM for 82573 controllers
496          */
497         if ((ret_val == 0) && ((first_word <= NVM_CHECKSUM_REG) ||
498 +                              (hw->mac.type == e1000_82574) ||
499                                (hw->mac.type == e1000_82573)))
500                 e1000e_update_nvm_checksum(hw);
501  
502 @@ -786,6 +787,7 @@ static int e1000_reg_test(struct e1000_adapter *adapter, u64 *data)
503                 toggle = 0x7FFFF3FF;
504                 break;
505         case e1000_82573:
506 +       case e1000_82574:
507         case e1000_ich8lan:
508         case e1000_ich9lan:
509         case e1000_ich10lan:
510 @@ -894,10 +896,18 @@ static int e1000_intr_test(struct e1000_adapter *adapter, u64 *data)
511         u32 shared_int = 1;
512         u32 irq = adapter->pdev->irq;
513         int i;
514 +       int ret_val = 0;
515 +       int int_mode = E1000E_INT_MODE_LEGACY;
516  
517         *data = 0;
518  
519 -       /* NOTE: we don't test MSI interrupts here, yet */
520 +       /* NOTE: we don't test MSI/MSI-X interrupts here, yet */
521 +       if (adapter->int_mode == E1000E_INT_MODE_MSIX) {
522 +               int_mode = adapter->int_mode;
523 +               e1000e_reset_interrupt_capability(adapter);
524 +               adapter->int_mode = E1000E_INT_MODE_LEGACY;
525 +               e1000e_set_interrupt_capability(adapter);
526 +       }
527         /* Hook up test interrupt handler just for this test */
528         if (!request_irq(irq, &e1000_test_intr, IRQF_PROBE_SHARED, netdev->name,
529                          netdev)) {
530 @@ -905,7 +915,8 @@ static int e1000_intr_test(struct e1000_adapter *adapter, u64 *data)
531         } else if (request_irq(irq, &e1000_test_intr, IRQF_SHARED,
532                  netdev->name, netdev)) {
533                 *data = 1;
534 -               return -1;
535 +               ret_val = -1;
536 +               goto out;
537         }
538         e_info("testing %s interrupt\n", (shared_int ? "shared" : "unshared"));
539  
540 @@ -995,7 +1006,14 @@ static int e1000_intr_test(struct e1000_adapter *adapter, u64 *data)
541         /* Unhook test interrupt handler */
542         free_irq(irq, netdev);
543  
544 -       return *data;
545 +out:
546 +       if (int_mode == E1000E_INT_MODE_MSIX) {
547 +               e1000e_reset_interrupt_capability(adapter);
548 +               adapter->int_mode = int_mode;
549 +               e1000e_set_interrupt_capability(adapter);
550 +       }
551 +
552 +       return ret_val;
553  }
554  
555  static void e1000_free_desc_rings(struct e1000_adapter *adapter)
556 @@ -1780,11 +1798,13 @@ static void e1000_led_blink_callback(unsigned long data)
557  static int e1000_phys_id(struct net_device *netdev, u32 data)
558  {
559         struct e1000_adapter *adapter = netdev_priv(netdev);
560 +       struct e1000_hw *hw = &adapter->hw;
561  
562         if (!data)
563                 data = INT_MAX;
564  
565 -       if (adapter->hw.phy.type == e1000_phy_ife) {
566 +       if ((hw->phy.type == e1000_phy_ife) ||
567 +           (hw->mac.type == e1000_82574)) {
568                 if (!adapter->blink_timer.function) {
569                         init_timer(&adapter->blink_timer);
570                         adapter->blink_timer.function =
571 @@ -1794,16 +1814,16 @@ static int e1000_phys_id(struct net_device *netdev, u32 data)
572                 mod_timer(&adapter->blink_timer, jiffies);
573                 msleep_interruptible(data * 1000);
574                 del_timer_sync(&adapter->blink_timer);
575 -               e1e_wphy(&adapter->hw,
576 -                                   IFE_PHY_SPECIAL_CONTROL_LED, 0);
577 +               if (hw->phy.type == e1000_phy_ife)
578 +                       e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, 0);
579         } else {
580 -               e1000e_blink_led(&adapter->hw);
581 +               e1000e_blink_led(hw);
582                 msleep_interruptible(data * 1000);
583         }
584  
585 -       adapter->hw.mac.ops.led_off(&adapter->hw);
586 +       hw->mac.ops.led_off(hw);
587         clear_bit(E1000_LED_ON, &adapter->led_status);
588 -       adapter->hw.mac.ops.cleanup_led(&adapter->hw);
589 +       hw->mac.ops.cleanup_led(hw);
590  
591         return 0;
592  }
593 diff --git a/drivers/net/e1000e/hw.h b/drivers/net/e1000e/hw.h
594 index 3005394..52612da 100644
595 --- a/drivers/net/e1000e/hw.h
596 +++ b/drivers/net/e1000e/hw.h
597 @@ -65,7 +65,11 @@ enum e1e_registers {
598         E1000_ICS      = 0x000C8, /* Interrupt Cause Set - WO */
599         E1000_IMS      = 0x000D0, /* Interrupt Mask Set - RW */
600         E1000_IMC      = 0x000D8, /* Interrupt Mask Clear - WO */
601 +       E1000_EIAC_82574 = 0x000DC, /* Ext. Interrupt Auto Clear - RW */
602         E1000_IAM      = 0x000E0, /* Interrupt Acknowledge Auto Mask */
603 +       E1000_IVAR     = 0x000E4, /* Interrupt Vector Allocation - RW */
604 +       E1000_EITR_82574_BASE = 0x000E8, /* Interrupt Throttling - RW */
605 +#define E1000_EITR_82574(_n) (E1000_EITR_82574_BASE + (_n << 2))
606         E1000_RCTL     = 0x00100, /* Rx Control - RW */
607         E1000_FCTTV    = 0x00170, /* Flow Control Transmit Timer Value - RW */
608         E1000_TXCW     = 0x00178, /* Tx Configuration Word - RW */
609 @@ -332,6 +336,7 @@ enum e1e_registers {
610  #define E1000_DEV_ID_82573E                    0x108B
611  #define E1000_DEV_ID_82573E_IAMT               0x108C
612  #define E1000_DEV_ID_82573L                    0x109A
613 +#define E1000_DEV_ID_82574L                    0x10D3
614  
615  #define E1000_DEV_ID_80003ES2LAN_COPPER_DPT    0x1096
616  #define E1000_DEV_ID_80003ES2LAN_SERDES_DPT    0x1098
617 @@ -359,12 +364,15 @@ enum e1e_registers {
618  #define E1000_DEV_ID_ICH10_D_BM_LM             0x10DE
619  #define E1000_DEV_ID_ICH10_D_BM_LF             0x10DF
620  
621 +#define E1000_REVISION_4 4
622 +
623  #define E1000_FUNC_1 1
624  
625  enum e1000_mac_type {
626         e1000_82571,
627         e1000_82572,
628         e1000_82573,
629 +       e1000_82574,
630         e1000_80003es2lan,
631         e1000_ich8lan,
632         e1000_ich9lan,
633 @@ -699,8 +707,7 @@ struct e1000_host_mng_command_info {
634  
635  /* Function pointers and static data for the MAC. */
636  struct e1000_mac_operations {
637 -       u32                     mng_mode_enab;
638 -
639 +       bool (*check_mng_mode)(struct e1000_hw *);
640         s32  (*check_for_link)(struct e1000_hw *);
641         s32  (*cleanup_led)(struct e1000_hw *);
642         void (*clear_hw_cntrs)(struct e1000_hw *);
643 diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c
644 index d2acf48..8e0bd0f 100644
645 --- a/drivers/net/e1000e/ich8lan.c
646 +++ b/drivers/net/e1000e/ich8lan.c
647 @@ -451,6 +451,22 @@ static void e1000_release_swflag_ich8lan(struct e1000_hw *hw)
648  }
649  
650  /**
651 + *  e1000_check_mng_mode_ich8lan - Checks management mode
652 + *  @hw: pointer to the HW structure
653 + *
654 + *  This checks if the adapter has manageability enabled.
655 + *  This is a function pointer entry point only called by read/write
656 + *  routines for the PHY and NVM parts.
657 + **/
658 +static bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw)
659 +{
660 +       u32 fwsm = er32(FWSM);
661 +
662 +       return (fwsm & E1000_FWSM_MODE_MASK) ==
663 +               (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT);
664 +}
665 +
666 +/**
667   *  e1000_check_reset_block_ich8lan - Check if PHY reset is blocked
668   *  @hw: pointer to the HW structure
669   *
670 @@ -2481,7 +2497,7 @@ static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw)
671  }
672  
673  static struct e1000_mac_operations ich8_mac_ops = {
674 -       .mng_mode_enab          = E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT,
675 +       .check_mng_mode         = e1000_check_mng_mode_ich8lan,
676         .check_for_link         = e1000e_check_for_copper_link,
677         .cleanup_led            = e1000_cleanup_led_ich8lan,
678         .clear_hw_cntrs         = e1000_clear_hw_cntrs_ich8lan,
679 diff --git a/drivers/net/e1000e/lib.c b/drivers/net/e1000e/lib.c
680 index f1f4e9d..c733730 100644
681 --- a/drivers/net/e1000e/lib.c
682 +++ b/drivers/net/e1000e/lib.c
683 @@ -2222,17 +2222,18 @@ static s32 e1000_mng_enable_host_if(struct e1000_hw *hw)
684  }
685  
686  /**
687 - *  e1000e_check_mng_mode - check management mode
688 + *  e1000e_check_mng_mode_generic - check management mode
689   *  @hw: pointer to the HW structure
690   *
691   *  Reads the firmware semaphore register and returns true (>0) if
692   *  manageability is enabled, else false (0).
693   **/
694 -bool e1000e_check_mng_mode(struct e1000_hw *hw)
695 +bool e1000e_check_mng_mode_generic(struct e1000_hw *hw)
696  {
697         u32 fwsm = er32(FWSM);
698  
699 -       return (fwsm & E1000_FWSM_MODE_MASK) == hw->mac.ops.mng_mode_enab;
700 +       return (fwsm & E1000_FWSM_MODE_MASK) ==
701 +               (E1000_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT);
702  }
703  
704  /**
705 diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
706 index c4287ca..51f4dcc 100644
707 --- a/drivers/net/e1000e/netdev.c
708 +++ b/drivers/net/e1000e/netdev.c
709 @@ -55,6 +55,7 @@ static const struct e1000_info *e1000_info_tbl[] = {
710         [board_82571]           = &e1000_82571_info,
711         [board_82572]           = &e1000_82572_info,
712         [board_82573]           = &e1000_82573_info,
713 +       [board_82574]           = &e1000_82574_info,
714         [board_80003es2lan]     = &e1000_es2_info,
715         [board_ich8lan]         = &e1000_ich8_info,
716         [board_ich9lan]         = &e1000_ich9_info,
717 @@ -1202,8 +1203,8 @@ static irqreturn_t e1000_intr(int irq, void *data)
718         struct net_device *netdev = data;
719         struct e1000_adapter *adapter = netdev_priv(netdev);
720         struct e1000_hw *hw = &adapter->hw;
721 -
722         u32 rctl, icr = er32(ICR);
723 +
724         if (!icr)
725                 return IRQ_NONE;  /* Not our interrupt */
726  
727 @@ -1259,6 +1260,263 @@ static irqreturn_t e1000_intr(int irq, void *data)
728         return IRQ_HANDLED;
729  }
730  
731 +static irqreturn_t e1000_msix_other(int irq, void *data)
732 +{
733 +       struct net_device *netdev = data;
734 +       struct e1000_adapter *adapter = netdev_priv(netdev);
735 +       struct e1000_hw *hw = &adapter->hw;
736 +       u32 icr = er32(ICR);
737 +
738 +       if (!(icr & E1000_ICR_INT_ASSERTED)) {
739 +               ew32(IMS, E1000_IMS_OTHER);
740 +               return IRQ_NONE;
741 +       }
742 +
743 +       if (icr & adapter->eiac_mask)
744 +               ew32(ICS, (icr & adapter->eiac_mask));
745 +
746 +       if (icr & E1000_ICR_OTHER) {
747 +               if (!(icr & E1000_ICR_LSC))
748 +                       goto no_link_interrupt;
749 +               hw->mac.get_link_status = 1;
750 +               /* guard against interrupt when we're going down */
751 +               if (!test_bit(__E1000_DOWN, &adapter->state))
752 +                       mod_timer(&adapter->watchdog_timer, jiffies + 1);
753 +       }
754 +
755 +no_link_interrupt:
756 +       ew32(IMS, E1000_IMS_LSC | E1000_IMS_OTHER);
757 +
758 +       return IRQ_HANDLED;
759 +}
760 +
761 +
762 +static irqreturn_t e1000_intr_msix_tx(int irq, void *data)
763 +{
764 +       struct net_device *netdev = data;
765 +       struct e1000_adapter *adapter = netdev_priv(netdev);
766 +       struct e1000_hw *hw = &adapter->hw;
767 +       struct e1000_ring *tx_ring = adapter->tx_ring;
768 +
769 +
770 +       adapter->total_tx_bytes = 0;
771 +       adapter->total_tx_packets = 0;
772 +
773 +       if (!e1000_clean_tx_irq(adapter))
774 +               /* Ring was not completely cleaned, so fire another interrupt */
775 +               ew32(ICS, tx_ring->ims_val);
776 +
777 +       return IRQ_HANDLED;
778 +}
779 +
780 +static irqreturn_t e1000_intr_msix_rx(int irq, void *data)
781 +{
782 +       struct net_device *netdev = data;
783 +       struct e1000_adapter *adapter = netdev_priv(netdev);
784 +
785 +       /* Write the ITR value calculated at the end of the
786 +        * previous interrupt.
787 +        */
788 +       if (adapter->rx_ring->set_itr) {
789 +               writel(1000000000 / (adapter->rx_ring->itr_val * 256),
790 +                      adapter->hw.hw_addr + adapter->rx_ring->itr_register);
791 +               adapter->rx_ring->set_itr = 0;
792 +       }
793 +
794 +       if (netif_rx_schedule_prep(netdev, &adapter->napi)) {
795 +               adapter->total_rx_bytes = 0;
796 +               adapter->total_rx_packets = 0;
797 +               __netif_rx_schedule(netdev, &adapter->napi);
798 +       }
799 +       return IRQ_HANDLED;
800 +}
801 +
802 +/**
803 + * e1000_configure_msix - Configure MSI-X hardware
804 + *
805 + * e1000_configure_msix sets up the hardware to properly
806 + * generate MSI-X interrupts.
807 + **/
808 +static void e1000_configure_msix(struct e1000_adapter *adapter)
809 +{
810 +       struct e1000_hw *hw = &adapter->hw;
811 +       struct e1000_ring *rx_ring = adapter->rx_ring;
812 +       struct e1000_ring *tx_ring = adapter->tx_ring;
813 +       int vector = 0;
814 +       u32 ctrl_ext, ivar = 0;
815 +
816 +       adapter->eiac_mask = 0;
817 +
818 +       /* Workaround issue with spurious interrupts on 82574 in MSI-X mode */
819 +       if (hw->mac.type == e1000_82574) {
820 +               u32 rfctl = er32(RFCTL);
821 +               rfctl |= E1000_RFCTL_ACK_DIS;
822 +               ew32(RFCTL, rfctl);
823 +       }
824 +
825 +#define E1000_IVAR_INT_ALLOC_VALID     0x8
826 +       /* Configure Rx vector */
827 +       rx_ring->ims_val = E1000_IMS_RXQ0;
828 +       adapter->eiac_mask |= rx_ring->ims_val;
829 +       if (rx_ring->itr_val)
830 +               writel(1000000000 / (rx_ring->itr_val * 256),
831 +                      hw->hw_addr + rx_ring->itr_register);
832 +       else
833 +               writel(1, hw->hw_addr + rx_ring->itr_register);
834 +       ivar = E1000_IVAR_INT_ALLOC_VALID | vector;
835 +
836 +       /* Configure Tx vector */
837 +       tx_ring->ims_val = E1000_IMS_TXQ0;
838 +       vector++;
839 +       if (tx_ring->itr_val)
840 +               writel(1000000000 / (tx_ring->itr_val * 256),
841 +                      hw->hw_addr + tx_ring->itr_register);
842 +       else
843 +               writel(1, hw->hw_addr + tx_ring->itr_register);
844 +       adapter->eiac_mask |= tx_ring->ims_val;
845 +       ivar |= ((E1000_IVAR_INT_ALLOC_VALID | vector) << 8);
846 +
847 +       /* set vector for Other Causes, e.g. link changes */
848 +       vector++;
849 +       ivar |= ((E1000_IVAR_INT_ALLOC_VALID | vector) << 16);
850 +       if (rx_ring->itr_val)
851 +               writel(1000000000 / (rx_ring->itr_val * 256),
852 +                      hw->hw_addr + E1000_EITR_82574(vector));
853 +       else
854 +               writel(1, hw->hw_addr + E1000_EITR_82574(vector));
855 +
856 +       /* Cause Tx interrupts on every write back */
857 +       ivar |= (1 << 31);
858 +
859 +       ew32(IVAR, ivar);
860 +
861 +       /* enable MSI-X PBA support */
862 +       ctrl_ext = er32(CTRL_EXT);
863 +       ctrl_ext |= E1000_CTRL_EXT_PBA_CLR;
864 +
865 +       /* Auto-Mask Other interrupts upon ICR read */
866 +#define E1000_EIAC_MASK_82574   0x01F00000
867 +       ew32(IAM, ~E1000_EIAC_MASK_82574 | E1000_IMS_OTHER);
868 +       ctrl_ext |= E1000_CTRL_EXT_EIAME;
869 +       ew32(CTRL_EXT, ctrl_ext);
870 +       e1e_flush();
871 +}
872 +
873 +void e1000e_reset_interrupt_capability(struct e1000_adapter *adapter)
874 +{
875 +       if (adapter->msix_entries) {
876 +               pci_disable_msix(adapter->pdev);
877 +               kfree(adapter->msix_entries);
878 +               adapter->msix_entries = NULL;
879 +       } else if (adapter->flags & FLAG_MSI_ENABLED) {
880 +               pci_disable_msi(adapter->pdev);
881 +               adapter->flags &= ~FLAG_MSI_ENABLED;
882 +       }
883 +
884 +       return;
885 +}
886 +
887 +/**
888 + * e1000e_set_interrupt_capability - set MSI or MSI-X if supported
889 + *
890 + * Attempt to configure interrupts using the best available
891 + * capabilities of the hardware and kernel.
892 + **/
893 +void e1000e_set_interrupt_capability(struct e1000_adapter *adapter)
894 +{
895 +       int err;
896 +       int numvecs, i;
897 +
898 +
899 +       switch (adapter->int_mode) {
900 +       case E1000E_INT_MODE_MSIX:
901 +               if (adapter->flags & FLAG_HAS_MSIX) {
902 +                       numvecs = 3; /* RxQ0, TxQ0 and other */
903 +                       adapter->msix_entries = kcalloc(numvecs,
904 +                                                     sizeof(struct msix_entry),
905 +                                                     GFP_KERNEL);
906 +                       if (adapter->msix_entries) {
907 +                               for (i = 0; i < numvecs; i++)
908 +                                       adapter->msix_entries[i].entry = i;
909 +
910 +                               err = pci_enable_msix(adapter->pdev,
911 +                                                     adapter->msix_entries,
912 +                                                     numvecs);
913 +                               if (err == 0)
914 +                                       return;
915 +                       }
916 +                       /* MSI-X failed, so fall through and try MSI */
917 +                       e_err("Failed to initialize MSI-X interrupts.  "
918 +                             "Falling back to MSI interrupts.\n");
919 +                       e1000e_reset_interrupt_capability(adapter);
920 +               }
921 +               adapter->int_mode = E1000E_INT_MODE_MSI;
922 +               /* Fall through */
923 +       case E1000E_INT_MODE_MSI:
924 +               if (!pci_enable_msi(adapter->pdev)) {
925 +                       adapter->flags |= FLAG_MSI_ENABLED;
926 +               } else {
927 +                       adapter->int_mode = E1000E_INT_MODE_LEGACY;
928 +                       e_err("Failed to initialize MSI interrupts.  Falling "
929 +                             "back to legacy interrupts.\n");
930 +               }
931 +               /* Fall through */
932 +       case E1000E_INT_MODE_LEGACY:
933 +               /* Don't do anything; this is the system default */
934 +               break;
935 +       }
936 +
937 +       return;
938 +}
939 +
940 +/**
941 + * e1000_request_msix - Initialize MSI-X interrupts
942 + *
943 + * e1000_request_msix allocates MSI-X vectors and requests interrupts from the
944 + * kernel.
945 + **/
946 +static int e1000_request_msix(struct e1000_adapter *adapter)
947 +{
948 +       struct net_device *netdev = adapter->netdev;
949 +       int err = 0, vector = 0;
950 +
951 +       if (strlen(netdev->name) < (IFNAMSIZ - 5))
952 +               sprintf(adapter->rx_ring->name, "%s-rx0", netdev->name);
953 +       else
954 +               memcpy(adapter->rx_ring->name, netdev->name, IFNAMSIZ);
955 +       err = request_irq(adapter->msix_entries[vector].vector,
956 +                         &e1000_intr_msix_rx, 0, adapter->rx_ring->name,
957 +                         netdev);
958 +       if (err)
959 +               goto out;
960 +       adapter->rx_ring->itr_register = E1000_EITR_82574(vector);
961 +       adapter->rx_ring->itr_val = adapter->itr;
962 +       vector++;
963 +
964 +       if (strlen(netdev->name) < (IFNAMSIZ - 5))
965 +               sprintf(adapter->tx_ring->name, "%s-tx0", netdev->name);
966 +       else
967 +               memcpy(adapter->tx_ring->name, netdev->name, IFNAMSIZ);
968 +       err = request_irq(adapter->msix_entries[vector].vector,
969 +                         &e1000_intr_msix_tx, 0, adapter->tx_ring->name,
970 +                         netdev);
971 +       if (err)
972 +               goto out;
973 +       adapter->tx_ring->itr_register = E1000_EITR_82574(vector);
974 +       adapter->tx_ring->itr_val = adapter->itr;
975 +       vector++;
976 +
977 +       err = request_irq(adapter->msix_entries[vector].vector,
978 +                         &e1000_msix_other, 0, netdev->name, netdev);
979 +       if (err)
980 +               goto out;
981 +
982 +       e1000_configure_msix(adapter);
983 +       return 0;
984 +out:
985 +       return err;
986 +}
987 +
988  /**
989   * e1000_request_irq - initialize interrupts
990   *
991 @@ -1268,29 +1526,33 @@ static irqreturn_t e1000_intr(int irq, void *data)
992  static int e1000_request_irq(struct e1000_adapter *adapter)
993  {
994         struct net_device *netdev = adapter->netdev;
995 -       int irq_flags = IRQF_SHARED;
996         int err;
997  
998 -       if (!(adapter->flags & FLAG_MSI_TEST_FAILED)) {
999 -               err = pci_enable_msi(adapter->pdev);
1000 -               if (!err) {
1001 -                       adapter->flags |= FLAG_MSI_ENABLED;
1002 -                       irq_flags = 0;
1003 -               }
1004 +       if (adapter->msix_entries) {
1005 +               err = e1000_request_msix(adapter);
1006 +               if (!err)
1007 +                       return err;
1008 +               /* fall back to MSI */
1009 +               e1000e_reset_interrupt_capability(adapter);
1010 +               adapter->int_mode = E1000E_INT_MODE_MSI;
1011 +               e1000e_set_interrupt_capability(adapter);
1012         }
1013 +       if (adapter->flags & FLAG_MSI_ENABLED) {
1014 +               err = request_irq(adapter->pdev->irq, &e1000_intr_msi, 0,
1015 +                                 netdev->name, netdev);
1016 +               if (!err)
1017 +                       return err;
1018  
1019 -       err = request_irq(adapter->pdev->irq,
1020 -                         ((adapter->flags & FLAG_MSI_ENABLED) ?
1021 -                               &e1000_intr_msi : &e1000_intr),
1022 -                         irq_flags, netdev->name, netdev);
1023 -       if (err) {
1024 -               if (adapter->flags & FLAG_MSI_ENABLED) {
1025 -                       pci_disable_msi(adapter->pdev);
1026 -                       adapter->flags &= ~FLAG_MSI_ENABLED;
1027 -               }
1028 -               e_err("Unable to allocate interrupt, Error: %d\n", err);
1029 +               /* fall back to legacy interrupt */
1030 +               e1000e_reset_interrupt_capability(adapter);
1031 +               adapter->int_mode = E1000E_INT_MODE_LEGACY;
1032         }
1033  
1034 +       err = request_irq(adapter->pdev->irq, &e1000_intr, IRQF_SHARED,
1035 +                         netdev->name, netdev);
1036 +       if (err)
1037 +               e_err("Unable to allocate interrupt, Error: %d\n", err);
1038 +
1039         return err;
1040  }
1041  
1042 @@ -1298,11 +1560,21 @@ static void e1000_free_irq(struct e1000_adapter *adapter)
1043  {
1044         struct net_device *netdev = adapter->netdev;
1045  
1046 -       free_irq(adapter->pdev->irq, netdev);
1047 -       if (adapter->flags & FLAG_MSI_ENABLED) {
1048 -               pci_disable_msi(adapter->pdev);
1049 -               adapter->flags &= ~FLAG_MSI_ENABLED;
1050 +       if (adapter->msix_entries) {
1051 +               int vector = 0;
1052 +
1053 +               free_irq(adapter->msix_entries[vector].vector, netdev);
1054 +               vector++;
1055 +
1056 +               free_irq(adapter->msix_entries[vector].vector, netdev);
1057 +               vector++;
1058 +
1059 +               /* Other Causes interrupt vector */
1060 +               free_irq(adapter->msix_entries[vector].vector, netdev);
1061 +               return;
1062         }
1063 +
1064 +       free_irq(adapter->pdev->irq, netdev);
1065  }
1066  
1067  /**
1068 @@ -1313,6 +1585,8 @@ static void e1000_irq_disable(struct e1000_adapter *adapter)
1069         struct e1000_hw *hw = &adapter->hw;
1070  
1071         ew32(IMC, ~0);
1072 +       if (adapter->msix_entries)
1073 +               ew32(EIAC_82574, 0);
1074         e1e_flush();
1075         synchronize_irq(adapter->pdev->irq);
1076  }
1077 @@ -1324,7 +1598,12 @@ static void e1000_irq_enable(struct e1000_adapter *adapter)
1078  {
1079         struct e1000_hw *hw = &adapter->hw;
1080  
1081 -       ew32(IMS, IMS_ENABLE_MASK);
1082 +       if (adapter->msix_entries) {
1083 +               ew32(EIAC_82574, adapter->eiac_mask & E1000_EIAC_MASK_82574);
1084 +               ew32(IMS, adapter->eiac_mask | E1000_IMS_OTHER | E1000_IMS_LSC);
1085 +       } else {
1086 +               ew32(IMS, IMS_ENABLE_MASK);
1087 +       }
1088         e1e_flush();
1089  }
1090  
1091 @@ -1574,9 +1853,8 @@ void e1000e_free_rx_resources(struct e1000_adapter *adapter)
1092   *      traffic pattern.  Constants in this function were computed
1093   *      based on theoretical maximum wire speed and thresholds were set based
1094   *      on testing data as well as attempting to minimize response time
1095 - *      while increasing bulk throughput.
1096 - *      this functionality is controlled by the InterruptThrottleRate module
1097 - *      parameter (see e1000_param.c)
1098 + *      while increasing bulk throughput.  This functionality is controlled
1099 + *      by the InterruptThrottleRate module parameter.
1100   **/
1101  static unsigned int e1000_update_itr(struct e1000_adapter *adapter,
1102                                      u16 itr_setting, int packets,
1103 @@ -1684,11 +1962,37 @@ set_itr_now:
1104                              min(adapter->itr + (new_itr >> 2), new_itr) :
1105                              new_itr;
1106                 adapter->itr = new_itr;
1107 -               ew32(ITR, 1000000000 / (new_itr * 256));
1108 +               adapter->rx_ring->itr_val = new_itr;
1109 +               if (adapter->msix_entries)
1110 +                       adapter->rx_ring->set_itr = 1;
1111 +               else
1112 +                       ew32(ITR, 1000000000 / (new_itr * 256));
1113         }
1114  }
1115  
1116  /**
1117 + * e1000_alloc_queues - Allocate memory for all rings
1118 + * @adapter: board private structure to initialize
1119 + **/
1120 +static int __devinit e1000_alloc_queues(struct e1000_adapter *adapter)
1121 +{
1122 +       adapter->tx_ring = kzalloc(sizeof(struct e1000_ring), GFP_KERNEL);
1123 +       if (!adapter->tx_ring)
1124 +               goto err;
1125 +
1126 +       adapter->rx_ring = kzalloc(sizeof(struct e1000_ring), GFP_KERNEL);
1127 +       if (!adapter->rx_ring)
1128 +               goto err;
1129 +
1130 +       return 0;
1131 +err:
1132 +       e_err("Unable to allocate memory for queues\n");
1133 +       kfree(adapter->rx_ring);
1134 +       kfree(adapter->tx_ring);
1135 +       return -ENOMEM;
1136 +}
1137 +
1138 +/**
1139   * e1000_clean - NAPI Rx polling callback
1140   * @napi: struct associated with this polling callback
1141   * @budget: amount of packets driver is allowed to process this poll
1142 @@ -1696,12 +2000,17 @@ set_itr_now:
1143  static int e1000_clean(struct napi_struct *napi, int budget)
1144  {
1145         struct e1000_adapter *adapter = container_of(napi, struct e1000_adapter, napi);
1146 +       struct e1000_hw *hw = &adapter->hw;
1147         struct net_device *poll_dev = adapter->netdev;
1148         int tx_cleaned = 0, work_done = 0;
1149  
1150         /* Must NOT use netdev_priv macro here. */
1151         adapter = poll_dev->priv;
1152  
1153 +       if (adapter->msix_entries &&
1154 +           !(adapter->rx_ring->ims_val & adapter->tx_ring->ims_val))
1155 +               goto clean_rx;
1156 +
1157         /*
1158          * e1000_clean is called per-cpu.  This lock protects
1159          * tx_ring from being cleaned by multiple cpus
1160 @@ -1713,6 +2022,7 @@ static int e1000_clean(struct napi_struct *napi, int budget)
1161                 spin_unlock(&adapter->tx_queue_lock);
1162         }
1163  
1164 +clean_rx:
1165         adapter->clean_rx(adapter, &work_done, budget);
1166  
1167         if (tx_cleaned)
1168 @@ -1723,7 +2033,10 @@ static int e1000_clean(struct napi_struct *napi, int budget)
1169                 if (adapter->itr_setting & 3)
1170                         e1000_set_itr(adapter);
1171                 netif_rx_complete(poll_dev, napi);
1172 -               e1000_irq_enable(adapter);
1173 +               if (adapter->msix_entries)
1174 +                       ew32(IMS, adapter->rx_ring->ims_val);
1175 +               else
1176 +                       e1000_irq_enable(adapter);
1177         }
1178  
1179         return work_done;
1180 @@ -2523,6 +2836,8 @@ int e1000e_up(struct e1000_adapter *adapter)
1181         clear_bit(__E1000_DOWN, &adapter->state);
1182  
1183         napi_enable(&adapter->napi);
1184 +       if (adapter->msix_entries)
1185 +               e1000_configure_msix(adapter);
1186         e1000_irq_enable(adapter);
1187  
1188         /* fire a link change interrupt to start the watchdog */
1189 @@ -2606,13 +2921,10 @@ static int __devinit e1000_sw_init(struct e1000_adapter *adapter)
1190         adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN;
1191         adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN;
1192  
1193 -       adapter->tx_ring = kzalloc(sizeof(struct e1000_ring), GFP_KERNEL);
1194 -       if (!adapter->tx_ring)
1195 -               goto err;
1196 +       e1000e_set_interrupt_capability(adapter);
1197  
1198 -       adapter->rx_ring = kzalloc(sizeof(struct e1000_ring), GFP_KERNEL);
1199 -       if (!adapter->rx_ring)
1200 -               goto err;
1201 +       if (e1000_alloc_queues(adapter))
1202 +               return -ENOMEM;
1203  
1204         spin_lock_init(&adapter->tx_queue_lock);
1205  
1206 @@ -2621,12 +2933,6 @@ static int __devinit e1000_sw_init(struct e1000_adapter *adapter)
1207  
1208         set_bit(__E1000_DOWN, &adapter->state);
1209         return 0;
1210 -
1211 -err:
1212 -       e_err("Unable to allocate memory for queues\n");
1213 -       kfree(adapter->rx_ring);
1214 -       kfree(adapter->tx_ring);
1215 -       return -ENOMEM;
1216  }
1217  
1218  /**
1219 @@ -2668,6 +2974,7 @@ static int e1000_test_msi_interrupt(struct e1000_adapter *adapter)
1220  
1221         /* free the real vector and request a test handler */
1222         e1000_free_irq(adapter);
1223 +       e1000e_reset_interrupt_capability(adapter);
1224  
1225         /* Assume that the test fails, if it succeeds then the test
1226          * MSI irq handler will unset this flag */
1227 @@ -2698,6 +3005,7 @@ static int e1000_test_msi_interrupt(struct e1000_adapter *adapter)
1228         rmb();
1229  
1230         if (adapter->flags & FLAG_MSI_TEST_FAILED) {
1231 +               adapter->int_mode = E1000E_INT_MODE_LEGACY;
1232                 err = -EIO;
1233                 e_info("MSI interrupt test failed!\n");
1234         }
1235 @@ -2711,7 +3019,7 @@ static int e1000_test_msi_interrupt(struct e1000_adapter *adapter)
1236         /* okay so the test worked, restore settings */
1237         e_dbg("%s: MSI interrupt test succeeded!\n", netdev->name);
1238  msi_test_failed:
1239 -       /* restore the original vector, even if it failed */
1240 +       e1000e_set_interrupt_capability(adapter);
1241         e1000_request_irq(adapter);
1242         return err;
1243  }
1244 @@ -2821,7 +3129,7 @@ static int e1000_open(struct net_device *netdev)
1245          * ignore e1000e MSI messages, which means we need to test our MSI
1246          * interrupt now
1247          */
1248 -       {
1249 +       if (adapter->int_mode != E1000E_INT_MODE_LEGACY) {
1250                 err = e1000_test_msi(adapter);
1251                 if (err) {
1252                         e_err("Interrupt allocation failed\n");
1253 @@ -3016,7 +3324,8 @@ void e1000e_update_stats(struct e1000_adapter *adapter)
1254  
1255         adapter->stats.algnerrc += er32(ALGNERRC);
1256         adapter->stats.rxerrc += er32(RXERRC);
1257 -       adapter->stats.tncrs += er32(TNCRS);
1258 +       if (hw->mac.type != e1000_82574)
1259 +               adapter->stats.tncrs += er32(TNCRS);
1260         adapter->stats.cexterr += er32(CEXTERR);
1261         adapter->stats.tsctc += er32(TSCTC);
1262         adapter->stats.tsctfc += er32(TSCTFC);
1263 @@ -3347,7 +3656,10 @@ link_up:
1264         }
1265  
1266         /* Cause software interrupt to ensure Rx ring is cleaned */
1267 -       ew32(ICS, E1000_ICS_RXDMT0);
1268 +       if (adapter->msix_entries)
1269 +               ew32(ICS, adapter->rx_ring->ims_val);
1270 +       else
1271 +               ew32(ICS, E1000_ICS_RXDMT0);
1272  
1273         /* Force detection of hung controller every watchdog period */
1274         adapter->detect_tx_hung = 1;
1275 @@ -4064,6 +4376,7 @@ static int e1000_suspend(struct pci_dev *pdev, pm_message_t state)
1276                 e1000e_down(adapter);
1277                 e1000_free_irq(adapter);
1278         }
1279 +       e1000e_reset_interrupt_capability(adapter);
1280  
1281         retval = pci_save_state(pdev);
1282         if (retval)
1283 @@ -4190,6 +4503,7 @@ static int e1000_resume(struct pci_dev *pdev)
1284         pci_enable_wake(pdev, PCI_D3hot, 0);
1285         pci_enable_wake(pdev, PCI_D3cold, 0);
1286  
1287 +       e1000e_set_interrupt_capability(adapter);
1288         if (netif_running(netdev)) {
1289                 err = e1000_request_irq(adapter);
1290                 if (err)
1291 @@ -4502,6 +4816,8 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
1292  
1293         e1000e_check_options(adapter);
1294  
1295 +       e1000e_check_options(adapter);
1296 +
1297         /* setup adapter struct */
1298         err = e1000_sw_init(adapter);
1299         if (err)
1300 @@ -4744,6 +5060,7 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
1301         if (!e1000_check_reset_block(&adapter->hw))
1302                 e1000_phy_hw_reset(&adapter->hw);
1303  
1304 +       e1000e_reset_interrupt_capability(adapter);
1305         kfree(adapter->tx_ring);
1306         kfree(adapter->rx_ring);
1307  
1308 @@ -4785,6 +5102,8 @@ static struct pci_device_id e1000_pci_tbl[] = {
1309         { PCI_VDEVICE(INTEL, E1000_DEV_ID_82573E_IAMT), board_82573 },
1310         { PCI_VDEVICE(INTEL, E1000_DEV_ID_82573L), board_82573 },
1311  
1312 +       { PCI_VDEVICE(INTEL, E1000_DEV_ID_82574L), board_82574 },
1313 +
1314         { PCI_VDEVICE(INTEL, E1000_DEV_ID_80003ES2LAN_COPPER_DPT),
1315           board_80003es2lan },
1316         { PCI_VDEVICE(INTEL, E1000_DEV_ID_80003ES2LAN_COPPER_SPT),
1317 diff --git a/drivers/net/e1000e/param.c b/drivers/net/e1000e/param.c
1318 index a7c8b99..e909f96 100644
1319 --- a/drivers/net/e1000e/param.c
1320 +++ b/drivers/net/e1000e/param.c
1321 @@ -114,6 +114,15 @@ E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate");
1322  #define DEFAULT_ITR 3
1323  #define MAX_ITR 100000
1324  #define MIN_ITR 100
1325 +/* IntMode (Interrupt Mode)
1326 + *
1327 + * Valid Range: 0 - 2
1328 + *
1329 + * Default Value: 2 (MSI-X)
1330 + */
1331 +E1000_PARAM(IntMode, "Interrupt Mode");
1332 +#define MAX_INTMODE    2
1333 +#define MIN_INTMODE    0
1334  
1335  /*
1336   * Enable Smart Power Down of the PHY
1337 @@ -371,6 +380,24 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter)
1338                         adapter->itr = 20000;
1339                 }
1340         }
1341 +       { /* Interrupt Mode */
1342 +               struct e1000_option opt = {
1343 +                       .type = range_option,
1344 +                       .name = "Interrupt Mode",
1345 +                       .err  = "defaulting to 2 (MSI-X)",
1346 +                       .def  = E1000E_INT_MODE_MSIX,
1347 +                       .arg  = { .r = { .min = MIN_INTMODE,
1348 +                                        .max = MAX_INTMODE } }
1349 +               };
1350 +
1351 +               if (num_IntMode > bd) {
1352 +                       unsigned int int_mode = IntMode[bd];
1353 +                       e1000_validate_option(&int_mode, &opt, adapter);
1354 +                       adapter->int_mode = int_mode;
1355 +               } else {
1356 +                       adapter->int_mode = opt.def;
1357 +               }
1358 +       }
1359         { /* Smart Power Down */
1360                 const struct e1000_option opt = {
1361                         .type = enable_option,
1362 diff --git a/drivers/net/e1000e/phy.c b/drivers/net/e1000e/phy.c
1363 index 16724f8..6cd333a 100644
1364 --- a/drivers/net/e1000e/phy.c
1365 +++ b/drivers/net/e1000e/phy.c
1366 @@ -476,7 +476,9 @@ s32 e1000e_copper_link_setup_m88(struct e1000_hw *hw)
1367         if (ret_val)
1368                 return ret_val;
1369  
1370 -       if ((phy->type == e1000_phy_m88) && (phy->revision < 4)) {
1371 +       if ((phy->type == e1000_phy_m88) &&
1372 +           (phy->revision < E1000_REVISION_4) &&
1373 +           (phy->id != BME1000_E_PHY_ID_R2)) {
1374                 /*
1375                  * Force TX_CLK in the Extended PHY Specific Control Register
1376                  * to 25MHz clock.
1377 @@ -504,6 +506,18 @@ s32 e1000e_copper_link_setup_m88(struct e1000_hw *hw)
1378                         return ret_val;
1379         }
1380  
1381 +       if ((phy->type == e1000_phy_bm) && (phy->id == BME1000_E_PHY_ID_R2)) {
1382 +               /* Set PHY page 0, register 29 to 0x0003 */
1383 +               ret_val = e1e_wphy(hw, 29, 0x0003);
1384 +               if (ret_val)
1385 +                       return ret_val;
1386 +
1387 +               /* Set PHY page 0, register 30 to 0x0000 */
1388 +               ret_val = e1e_wphy(hw, 30, 0x0000);
1389 +               if (ret_val)
1390 +                       return ret_val;
1391 +       }
1392 +
1393         /* Commit the changes. */
1394         ret_val = e1000e_commit_phy(hw);
1395         if (ret_val)
1396 @@ -2054,6 +2068,99 @@ out:
1397  }
1398  
1399  /**
1400 + *  e1000e_read_phy_reg_bm2 - Read BM PHY register
1401 + *  @hw: pointer to the HW structure
1402 + *  @offset: register offset to be read
1403 + *  @data: pointer to the read data
1404 + *
1405 + *  Acquires semaphore, if necessary, then reads the PHY register at offset
1406 + *  and storing the retrieved information in data.  Release any acquired
1407 + *  semaphores before exiting.
1408 + **/
1409 +s32 e1000e_read_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 *data)
1410 +{
1411 +       s32 ret_val;
1412 +       u16 page = (u16)(offset >> IGP_PAGE_SHIFT);
1413 +
1414 +       /* Page 800 works differently than the rest so it has its own func */
1415 +       if (page == BM_WUC_PAGE) {
1416 +               ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, data,
1417 +                                                        true);
1418 +               return ret_val;
1419 +       }
1420 +
1421 +       ret_val = hw->phy.ops.acquire_phy(hw);
1422 +       if (ret_val)
1423 +               return ret_val;
1424 +
1425 +       hw->phy.addr = 1;
1426 +
1427 +       if (offset > MAX_PHY_MULTI_PAGE_REG) {
1428 +
1429 +               /* Page is shifted left, PHY expects (page x 32) */
1430 +               ret_val = e1000e_write_phy_reg_mdic(hw, BM_PHY_PAGE_SELECT,
1431 +                                                   page);
1432 +
1433 +               if (ret_val) {
1434 +                       hw->phy.ops.release_phy(hw);
1435 +                       return ret_val;
1436 +               }
1437 +       }
1438 +
1439 +       ret_val = e1000e_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
1440 +                                          data);
1441 +       hw->phy.ops.release_phy(hw);
1442 +
1443 +       return ret_val;
1444 +}
1445 +
1446 +/**
1447 + *  e1000e_write_phy_reg_bm2 - Write BM PHY register
1448 + *  @hw: pointer to the HW structure
1449 + *  @offset: register offset to write to
1450 + *  @data: data to write at register offset
1451 + *
1452 + *  Acquires semaphore, if necessary, then writes the data to PHY register
1453 + *  at the offset.  Release any acquired semaphores before exiting.
1454 + **/
1455 +s32 e1000e_write_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 data)
1456 +{
1457 +       s32 ret_val;
1458 +       u16 page = (u16)(offset >> IGP_PAGE_SHIFT);
1459 +
1460 +       /* Page 800 works differently than the rest so it has its own func */
1461 +       if (page == BM_WUC_PAGE) {
1462 +               ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, &data,
1463 +                                                        false);
1464 +               return ret_val;
1465 +       }
1466 +
1467 +       ret_val = hw->phy.ops.acquire_phy(hw);
1468 +       if (ret_val)
1469 +               return ret_val;
1470 +
1471 +       hw->phy.addr = 1;
1472 +
1473 +       if (offset > MAX_PHY_MULTI_PAGE_REG) {
1474 +               /* Page is shifted left, PHY expects (page x 32) */
1475 +               ret_val = e1000e_write_phy_reg_mdic(hw, BM_PHY_PAGE_SELECT,
1476 +                                                   page);
1477 +
1478 +               if (ret_val) {
1479 +                       hw->phy.ops.release_phy(hw);
1480 +                       return ret_val;
1481 +               }
1482 +       }
1483 +
1484 +       ret_val = e1000e_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
1485 +                                           data);
1486 +
1487 +       hw->phy.ops.release_phy(hw);
1488 +
1489 +       return ret_val;
1490 +}
1491 +
1492 +/**
1493   *  e1000_access_phy_wakeup_reg_bm - Read BM PHY wakeup register
1494   *  @hw: pointer to the HW structure
1495   *  @offset: register offset to be read or written