aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/e1000e
diff options
context:
space:
mode:
authorBruce Allan <bruce.w.allan@intel.com>2010-01-12 21:05:38 -0500
committerDavid S. Miller <davem@davemloft.net>2010-01-13 23:31:57 -0500
commitab8932f3e8e07df92d6ce3fa41f5af0dda865429 (patch)
treeadfd802b04591e62b4743790ea8308f24f46d3e4 /drivers/net/e1000e
parentf4d2dd4cd4d001f5dc20fc76c780c0c20c000c23 (diff)
e1000e: genericize the update multicast address list
Make updating the multicast address list generic for all families and enforce the requirement to update the entire multicast table array all at once instead of piecemeal which causes problems on some parts. Signed-off-by: Bruce Allan <bruce.w.allan@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/e1000e')
-rw-r--r--drivers/net/e1000e/82571.c28
-rw-r--r--drivers/net/e1000e/e1000.h4
-rw-r--r--drivers/net/e1000e/hw.h6
-rw-r--r--drivers/net/e1000e/lib.c58
-rw-r--r--drivers/net/e1000e/netdev.c20
5 files changed, 27 insertions, 89 deletions
diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c
index 7674a91824bc..3c95acb3a87d 100644
--- a/drivers/net/e1000e/82571.c
+++ b/drivers/net/e1000e/82571.c
@@ -1234,32 +1234,6 @@ static s32 e1000_led_on_82574(struct e1000_hw *hw)
1234} 1234}
1235 1235
1236/** 1236/**
1237 * e1000_update_mc_addr_list_82571 - Update Multicast addresses
1238 * @hw: pointer to the HW structure
1239 * @mc_addr_list: array of multicast addresses to program
1240 * @mc_addr_count: number of multicast addresses to program
1241 * @rar_used_count: the first RAR register free to program
1242 * @rar_count: total number of supported Receive Address Registers
1243 *
1244 * Updates the Receive Address Registers and Multicast Table Array.
1245 * The caller must have a packed mc_addr_list of multicast addresses.
1246 * The parameter rar_count will usually be hw->mac.rar_entry_count
1247 * unless there are workarounds that change this.
1248 **/
1249static void e1000_update_mc_addr_list_82571(struct e1000_hw *hw,
1250 u8 *mc_addr_list,
1251 u32 mc_addr_count,
1252 u32 rar_used_count,
1253 u32 rar_count)
1254{
1255 if (e1000e_get_laa_state_82571(hw))
1256 rar_count--;
1257
1258 e1000e_update_mc_addr_list_generic(hw, mc_addr_list, mc_addr_count,
1259 rar_used_count, rar_count);
1260}
1261
1262/**
1263 * e1000_setup_link_82571 - Setup flow control and link settings 1237 * e1000_setup_link_82571 - Setup flow control and link settings
1264 * @hw: pointer to the HW structure 1238 * @hw: pointer to the HW structure
1265 * 1239 *
@@ -1731,7 +1705,7 @@ static struct e1000_mac_operations e82571_mac_ops = {
1731 /* .get_link_up_info: media type dependent */ 1705 /* .get_link_up_info: media type dependent */
1732 /* .led_on: mac type dependent */ 1706 /* .led_on: mac type dependent */
1733 .led_off = e1000e_led_off_generic, 1707 .led_off = e1000e_led_off_generic,
1734 .update_mc_addr_list = e1000_update_mc_addr_list_82571, 1708 .update_mc_addr_list = e1000e_update_mc_addr_list_generic,
1735 .write_vfta = e1000_write_vfta_generic, 1709 .write_vfta = e1000_write_vfta_generic,
1736 .clear_vfta = e1000_clear_vfta_82571, 1710 .clear_vfta = e1000_clear_vfta_82571,
1737 .reset_hw = e1000_reset_hw_82571, 1711 .reset_hw = e1000_reset_hw_82571,
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index 8b311ce0400e..aec378e7441d 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -518,9 +518,7 @@ extern void e1000_clear_vfta_generic(struct e1000_hw *hw);
518extern void e1000e_init_rx_addrs(struct e1000_hw *hw, u16 rar_count); 518extern void e1000e_init_rx_addrs(struct e1000_hw *hw, u16 rar_count);
519extern void e1000e_update_mc_addr_list_generic(struct e1000_hw *hw, 519extern void e1000e_update_mc_addr_list_generic(struct e1000_hw *hw,
520 u8 *mc_addr_list, 520 u8 *mc_addr_list,
521 u32 mc_addr_count, 521 u32 mc_addr_count);
522 u32 rar_used_count,
523 u32 rar_count);
524extern void e1000e_rar_set(struct e1000_hw *hw, u8 *addr, u32 index); 522extern void e1000e_rar_set(struct e1000_hw *hw, u8 *addr, u32 index);
525extern s32 e1000e_set_fc_watermarks(struct e1000_hw *hw); 523extern s32 e1000e_set_fc_watermarks(struct e1000_hw *hw);
526extern void e1000e_set_pcie_no_snoop(struct e1000_hw *hw, u32 no_snoop); 524extern void e1000e_set_pcie_no_snoop(struct e1000_hw *hw, u32 no_snoop);
diff --git a/drivers/net/e1000e/hw.h b/drivers/net/e1000e/hw.h
index 9cac5d9b94b8..8bdcd5f24eff 100644
--- a/drivers/net/e1000e/hw.h
+++ b/drivers/net/e1000e/hw.h
@@ -753,7 +753,7 @@ struct e1000_mac_operations {
753 s32 (*get_link_up_info)(struct e1000_hw *, u16 *, u16 *); 753 s32 (*get_link_up_info)(struct e1000_hw *, u16 *, u16 *);
754 s32 (*led_on)(struct e1000_hw *); 754 s32 (*led_on)(struct e1000_hw *);
755 s32 (*led_off)(struct e1000_hw *); 755 s32 (*led_off)(struct e1000_hw *);
756 void (*update_mc_addr_list)(struct e1000_hw *, u8 *, u32, u32, u32); 756 void (*update_mc_addr_list)(struct e1000_hw *, u8 *, u32);
757 s32 (*reset_hw)(struct e1000_hw *); 757 s32 (*reset_hw)(struct e1000_hw *);
758 s32 (*init_hw)(struct e1000_hw *); 758 s32 (*init_hw)(struct e1000_hw *);
759 s32 (*setup_link)(struct e1000_hw *); 759 s32 (*setup_link)(struct e1000_hw *);
@@ -819,6 +819,10 @@ struct e1000_mac_info {
819 u16 ifs_ratio; 819 u16 ifs_ratio;
820 u16 ifs_step_size; 820 u16 ifs_step_size;
821 u16 mta_reg_count; 821 u16 mta_reg_count;
822
823 /* Maximum size of the MTA register table in all supported adapters */
824 #define MAX_MTA_REG 128
825 u32 mta_shadow[MAX_MTA_REG];
822 u16 rar_entry_count; 826 u16 rar_entry_count;
823 827
824 u8 forced_speed_duplex; 828 u8 forced_speed_duplex;
diff --git a/drivers/net/e1000e/lib.c b/drivers/net/e1000e/lib.c
index 5f6b17148d34..2425ed11d5cc 100644
--- a/drivers/net/e1000e/lib.c
+++ b/drivers/net/e1000e/lib.c
@@ -340,62 +340,34 @@ static u32 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr)
340 * @hw: pointer to the HW structure 340 * @hw: pointer to the HW structure
341 * @mc_addr_list: array of multicast addresses to program 341 * @mc_addr_list: array of multicast addresses to program
342 * @mc_addr_count: number of multicast addresses to program 342 * @mc_addr_count: number of multicast addresses to program
343 * @rar_used_count: the first RAR register free to program
344 * @rar_count: total number of supported Receive Address Registers
345 * 343 *
346 * Updates the Receive Address Registers and Multicast Table Array. 344 * Updates entire Multicast Table Array.
347 * The caller must have a packed mc_addr_list of multicast addresses. 345 * The caller must have a packed mc_addr_list of multicast addresses.
348 * The parameter rar_count will usually be hw->mac.rar_entry_count
349 * unless there are workarounds that change this.
350 **/ 346 **/
351void e1000e_update_mc_addr_list_generic(struct e1000_hw *hw, 347void e1000e_update_mc_addr_list_generic(struct e1000_hw *hw,
352 u8 *mc_addr_list, u32 mc_addr_count, 348 u8 *mc_addr_list, u32 mc_addr_count)
353 u32 rar_used_count, u32 rar_count)
354{ 349{
355 u32 i; 350 u32 hash_value, hash_bit, hash_reg;
356 u32 *mcarray = kzalloc(hw->mac.mta_reg_count * sizeof(u32), GFP_ATOMIC); 351 int i;
357 352
358 if (!mcarray) { 353 /* clear mta_shadow */
359 printk(KERN_ERR "multicast array memory allocation failed\n"); 354 memset(&hw->mac.mta_shadow, 0, sizeof(hw->mac.mta_shadow));
360 return;
361 }
362 355
363 /* 356 /* update mta_shadow from mc_addr_list */
364 * Load the first set of multicast addresses into the exact 357 for (i = 0; (u32) i < mc_addr_count; i++) {
365 * filters (RAR). If there are not enough to fill the RAR
366 * array, clear the filters.
367 */
368 for (i = rar_used_count; i < rar_count; i++) {
369 if (mc_addr_count) {
370 e1000e_rar_set(hw, mc_addr_list, i);
371 mc_addr_count--;
372 mc_addr_list += ETH_ALEN;
373 } else {
374 E1000_WRITE_REG_ARRAY(hw, E1000_RA, i << 1, 0);
375 e1e_flush();
376 E1000_WRITE_REG_ARRAY(hw, E1000_RA, (i << 1) + 1, 0);
377 e1e_flush();
378 }
379 }
380
381 /* Load any remaining multicast addresses into the hash table. */
382 for (; mc_addr_count > 0; mc_addr_count--) {
383 u32 hash_value, hash_reg, hash_bit, mta;
384 hash_value = e1000_hash_mc_addr(hw, mc_addr_list); 358 hash_value = e1000_hash_mc_addr(hw, mc_addr_list);
385 e_dbg("Hash value = 0x%03X\n", hash_value); 359
386 hash_reg = (hash_value >> 5) & (hw->mac.mta_reg_count - 1); 360 hash_reg = (hash_value >> 5) & (hw->mac.mta_reg_count - 1);
387 hash_bit = hash_value & 0x1F; 361 hash_bit = hash_value & 0x1F;
388 mta = (1 << hash_bit);
389 mcarray[hash_reg] |= mta;
390 mc_addr_list += ETH_ALEN;
391 }
392 362
393 /* write the hash table completely */ 363 hw->mac.mta_shadow[hash_reg] |= (1 << hash_bit);
394 for (i = 0; i < hw->mac.mta_reg_count; i++) 364 mc_addr_list += (ETH_ALEN);
395 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, mcarray[i]); 365 }
396 366
367 /* replace the entire MTA table */
368 for (i = hw->mac.mta_reg_count - 1; i >= 0; i--)
369 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, hw->mac.mta_shadow[i]);
397 e1e_flush(); 370 e1e_flush();
398 kfree(mcarray);
399} 371}
400 372
401/** 373/**
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 0d5ef4c5c6db..3d57ca5482f4 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -2536,22 +2536,14 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)
2536 * @hw: pointer to the HW structure 2536 * @hw: pointer to the HW structure
2537 * @mc_addr_list: array of multicast addresses to program 2537 * @mc_addr_list: array of multicast addresses to program
2538 * @mc_addr_count: number of multicast addresses to program 2538 * @mc_addr_count: number of multicast addresses to program
2539 * @rar_used_count: the first RAR register free to program
2540 * @rar_count: total number of supported Receive Address Registers
2541 * 2539 *
2542 * Updates the Receive Address Registers and Multicast Table Array. 2540 * Updates the Multicast Table Array.
2543 * The caller must have a packed mc_addr_list of multicast addresses. 2541 * The caller must have a packed mc_addr_list of multicast addresses.
2544 * The parameter rar_count will usually be hw->mac.rar_entry_count
2545 * unless there are workarounds that change this. Currently no func pointer
2546 * exists and all implementations are handled in the generic version of this
2547 * function.
2548 **/ 2542 **/
2549static void e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list, 2543static void e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list,
2550 u32 mc_addr_count, u32 rar_used_count, 2544 u32 mc_addr_count)
2551 u32 rar_count)
2552{ 2545{
2553 hw->mac.ops.update_mc_addr_list(hw, mc_addr_list, mc_addr_count, 2546 hw->mac.ops.update_mc_addr_list(hw, mc_addr_list, mc_addr_count);
2554 rar_used_count, rar_count);
2555} 2547}
2556 2548
2557/** 2549/**
@@ -2567,7 +2559,6 @@ static void e1000_set_multi(struct net_device *netdev)
2567{ 2559{
2568 struct e1000_adapter *adapter = netdev_priv(netdev); 2560 struct e1000_adapter *adapter = netdev_priv(netdev);
2569 struct e1000_hw *hw = &adapter->hw; 2561 struct e1000_hw *hw = &adapter->hw;
2570 struct e1000_mac_info *mac = &hw->mac;
2571 struct dev_mc_list *mc_ptr; 2562 struct dev_mc_list *mc_ptr;
2572 u8 *mta_list; 2563 u8 *mta_list;
2573 u32 rctl; 2564 u32 rctl;
@@ -2609,15 +2600,14 @@ static void e1000_set_multi(struct net_device *netdev)
2609 mc_ptr = mc_ptr->next; 2600 mc_ptr = mc_ptr->next;
2610 } 2601 }
2611 2602
2612 e1000_update_mc_addr_list(hw, mta_list, i, 1, 2603 e1000_update_mc_addr_list(hw, mta_list, i);
2613 mac->rar_entry_count);
2614 kfree(mta_list); 2604 kfree(mta_list);
2615 } else { 2605 } else {
2616 /* 2606 /*
2617 * if we're called from probe, we might not have 2607 * if we're called from probe, we might not have
2618 * anything to do here, so clear out the list 2608 * anything to do here, so clear out the list
2619 */ 2609 */
2620 e1000_update_mc_addr_list(hw, NULL, 0, 1, mac->rar_entry_count); 2610 e1000_update_mc_addr_list(hw, NULL, 0);
2621 } 2611 }
2622} 2612}
2623 2613