Skip to contentSkip to conversation

e1000: convert to use netdev_for_each_mc_addr

PATCH Applied Jiri Pirko 3 participants 4 messages Feb 22, 2010 – Feb 23, 2010

Subsystems (2)
lore
Share & tools
lore

Jiri Pirko

author
#0 lore raw

PATCH 1/1 e1000: convert to use netdev_for_each_mc_addr

---
 drivers/net/e1000/e1000_main.c |   37 +++++++++++++++++--------------------
 1 files changed, 17 insertions(+), 20 deletions(-)
drivers/net/e1000/e1000_main.c +17 -20
index 3b14dd7..c99f95c 100644
@@ -2161,29 +2161,26 @@ static void e1000_set_rx_mode(struct net_device *netdev)
 
 	WARN_ON(i == rar_entries);
 
-	mc_ptr = netdev->mc_list;
-
-	for (; i < rar_entries; i++) {
-		if (mc_ptr) {
-			e1000_rar_set(hw, mc_ptr->da_addr, i);
-			mc_ptr = mc_ptr->next;
-		} else {
-			E1000_WRITE_REG_ARRAY(hw, RA, i << 1, 0);
-			E1000_WRITE_FLUSH();
-			E1000_WRITE_REG_ARRAY(hw, RA, (i << 1) + 1, 0);
-			E1000_WRITE_FLUSH();
+	netdev_for_each_mc_addr(mc_ptr, netdev) {
+		if (i == rar_entries) {
+			/* load any remaining addresses into the hash table */
+			u32 hash_reg, hash_bit, mta;
+			hash_value = e1000_hash_mc_addr(hw, mc_ptr->da_addr);
+			hash_reg = (hash_value >> 5) & 0x7F;
+			hash_bit = hash_value & 0x1F;
+			mta = (1 << hash_bit);
+			mcarray[hash_reg] |= mta;
+		}
+		else {
+			e1000_rar_set(hw, mc_ptr->da_addr, i++);
 		}
 	}
 
-	/* load any remaining addresses into the hash table */
-
-	for (; mc_ptr; mc_ptr = mc_ptr->next) {
-		u32 hash_reg, hash_bit, mta;
-		hash_value = e1000_hash_mc_addr(hw, mc_ptr->da_addr);
-		hash_reg = (hash_value >> 5) & 0x7F;
-		hash_bit = hash_value & 0x1F;
-		mta = (1 << hash_bit);
-		mcarray[hash_reg] |= mta;
+	for (; i < rar_entries; i++) {
+		E1000_WRITE_REG_ARRAY(hw, RA, i << 1, 0);
+		E1000_WRITE_FLUSH();
+		E1000_WRITE_REG_ARRAY(hw, RA, (i << 1) + 1, 0);
+		E1000_WRITE_FLUSH();
 	}
 
 	/* write the hash table completely, write from bottom to avoid
Signature · 1 line
1.6.6
#2 lore raw
In reply to Jiri Pirko
Quoted 26 lines · Jiri Pirko

---
 drivers/net/e1000/e1000_main.c |   37 +++++++++++++++++--------------------

 1 files changed, 17 insertions(+), 20 deletions(-)
drivers/net/e1000/e1000_main.c +1 -11
index 3b14dd7..c99f95c 100644
@@ -2161,29 +2161,26 @@ static void e1000_set_rx_mode(struct net_device *netdev)
 
        WARN_ON(i == rar_entries);
 
-       mc_ptr = netdev->mc_list;
-
-       for (; i < rar_entries; i++) {
-               if (mc_ptr) {
-                       e1000_rar_set(hw, mc_ptr->da_addr, i);
-                       mc_ptr = mc_ptr->next;
-               } else {
-                       E1000_WRITE_REG_ARRAY(hw, RA, i << 1, 0);
-                       E1000_WRITE_FLUSH();
-                       E1000_WRITE_REG_ARRAY(hw, RA, (i << 1) + 1, 0);
-                       E1000_WRITE_FLUSH();
+       netdev_for_each_mc_addr(mc_ptr, netdev) {

drivers/net/e1000/e1000_main.c static void e1000_set_rx_mode(struct net_device *netdev) · line 2174

Quoted 10 lines
drivers/net/e1000/e1000_main.c +10 -0
+               if (i == rar_entries) {
+                       /* load any remaining addresses into the hash table */
+                       u32 hash_reg, hash_bit, mta;
+                       hash_value = e1000_hash_mc_addr(hw, mc_ptr->da_addr);
+                       hash_reg = (hash_value >> 5) & 0x7F;
+                       hash_bit = hash_value & 0x1F;
+                       mta = (1 << hash_bit);
+                       mcarray[hash_reg] |= mta;
+               }
+               else {

nit - else should be in the same line like "} else {"

Quoted 11 lines
drivers/net/e1000/e1000_main.c +1 -7
+                       e1000_rar_set(hw, mc_ptr->da_addr, i++);
                }
        }
 
-       /* load any remaining addresses into the hash table */
-
-       for (; mc_ptr; mc_ptr = mc_ptr->next) {
-               u32 hash_reg, hash_bit, mta;
-               hash_value = e1000_hash_mc_addr(hw, mc_ptr->da_addr);
-               hash_reg = (hash_value >> 5) & 0x7F;
-               hash_bit = hash_value & 0x1F;

drivers/net/e1000/e1000_main.c static void e1000_set_rx_mode(struct net_device *netdev) · line 2186

Quoted 10 lines
drivers/net/e1000/e1000_main.c +5 -2
-               mta = (1 << hash_bit);
-               mcarray[hash_reg] |= mta;
+       for (; i < rar_entries; i++) {
+               E1000_WRITE_REG_ARRAY(hw, RA, i << 1, 0);
+               E1000_WRITE_FLUSH();
+               E1000_WRITE_REG_ARRAY(hw, RA, (i << 1) + 1, 0);
+               E1000_WRITE_FLUSH();
        }
 
        /* write the hash table completely, write from bottom to avoid

otherwise seems okay. Thanks for your work on cleaning this stuff, we'll be testing it as part of the net next testing already going on.

author
#3 lore raw
Quoted 31 lines · Tue, Feb 23, 2010 at 01:54:13AM CET, [email protected] wrote:
Quoted 30 lines · Jiri Pirko

---
 drivers/net/e1000/e1000_main.c |   37 +++++++++++++++++--------------------

 1 files changed, 17 insertions(+), 20 deletions(-)
drivers/net/e1000/e1000_main.c +5 -11
index 3b14dd7..c99f95c 100644
@@ -2161,29 +2161,26 @@ static void e1000_set_rx_mode(struct net_device *netdev)
 
        WARN_ON(i == rar_entries);
 
-       mc_ptr = netdev->mc_list;
-
-       for (; i < rar_entries; i++) {
-               if (mc_ptr) {
-                       e1000_rar_set(hw, mc_ptr->da_addr, i);
-                       mc_ptr = mc_ptr->next;
-               } else {
-                       E1000_WRITE_REG_ARRAY(hw, RA, i << 1, 0);
-                       E1000_WRITE_FLUSH();
-                       E1000_WRITE_REG_ARRAY(hw, RA, (i << 1) + 1, 0);
-                       E1000_WRITE_FLUSH();
+       netdev_for_each_mc_addr(mc_ptr, netdev) {
+               if (i == rar_entries) {
+                       /* load any remaining addresses into the hash table */
+                       u32 hash_reg, hash_bit, mta;
+                       hash_value = e1000_hash_mc_addr(hw, mc_ptr->da_addr);
Quoted 8 lines

drivers/net/e1000/e1000_main.c static void e1000_set_rx_mode(struct net_device *netdev) · line 2174

Quoted 6 lines
drivers/net/e1000/e1000_main.c +6 -0
+                       hash_reg = (hash_value >> 5) & 0x7F;
+                       hash_bit = hash_value & 0x1F;
+                       mta = (1 << hash_bit);
+                       mcarray[hash_reg] |= mta;
+               }
+               else {

nit - else should be in the same line like "} else {"

Oh right, but patch is already applied. Will post correction.

Quoted 21 lines
Quoted 21 lines
drivers/net/e1000/e1000_main.c +6 -9
+                       e1000_rar_set(hw, mc_ptr->da_addr, i++);
                }
        }
 
-       /* load any remaining addresses into the hash table */
-
-       for (; mc_ptr; mc_ptr = mc_ptr->next) {
-               u32 hash_reg, hash_bit, mta;
-               hash_value = e1000_hash_mc_addr(hw, mc_ptr->da_addr);
-               hash_reg = (hash_value >> 5) & 0x7F;
-               hash_bit = hash_value & 0x1F;
-               mta = (1 << hash_bit);
-               mcarray[hash_reg] |= mta;
+       for (; i < rar_entries; i++) {
+               E1000_WRITE_REG_ARRAY(hw, RA, i << 1, 0);
+               E1000_WRITE_FLUSH();
+               E1000_WRITE_REG_ARRAY(hw, RA, (i << 1) + 1, 0);
+               E1000_WRITE_FLUSH();
        }
 
Quoted 4 lines

drivers/net/e1000/e1000_main.c static void e1000_set_rx_mode(struct net_device *netdev) · line 2186

Quoted 1 line
drivers/net/e1000/e1000_main.c +0 -0
        /* write the hash table completely, write from bottom to avoid

otherwise seems okay. Thanks for your work on cleaning this stuff, we'll be testing it as part of the net next testing already going on.

Cool, thanks

Jirka