Skip to contentSkip to conversation

fm10k: use ether_addr_copy to copy MAC address

PATCH New Jacob Keller 2 participants 13 messages Oct 26, 2015 – Nov 3, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/6 fm10k: use ether_addr_copy to copy MAC address

Use the ether_addr_copy function instead of copying byte-by-byte in a for-loop by hand.

---
 drivers/net/ethernet/intel/fm10k/fm10k_pf.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/fm10k/fm10k_pf.c +2 -5
index 8b9b6ba5b92b..bbf0b4aef241 100644
@@ -266,7 +266,6 @@ static s32 fm10k_read_mac_addr_pf(struct fm10k_hw *hw)
 {
 	u8 perm_addr[ETH_ALEN];
 	u32 serial_num;
-	int i;
 
 	serial_num = fm10k_read_reg(hw, FM10K_SM_AREA(1));
 
@@ -288,10 +287,8 @@ static s32 fm10k_read_mac_addr_pf(struct fm10k_hw *hw)
 	perm_addr[4] = (u8)(serial_num >> 8);
 	perm_addr[5] = (u8)(serial_num);
 
-	for (i = 0; i < ETH_ALEN; i++) {
-		hw->mac.perm_addr[i] = perm_addr[i];
-		hw->mac.addr[i] = perm_addr[i];
-	}
+	ether_addr_copy(hw->mac.perm_addr, perm_addr);
+	ether_addr_copy(hw->mac.addr, perm_addr);
 
 	return 0;
 }
Signature · 1 line
2.6.1.264.gbab76a9
#1 lore raw

PATCH 2/6 fm10k: use ether_addr_equal instead of memcmp

When comparing MAC addresses, use ether_addr_equal instead of memcmp to ETH_ALEN length. Found and replaced using the following sed:

sed -e 's/memcmp\x28\(.*\), ETH_ALEN\x29/ether_addr_equal\x28\1\x29/'

---
 drivers/net/ethernet/intel/fm10k/fm10k_pci.c | 2 +-
 drivers/net/ethernet/intel/fm10k/fm10k_pf.c  | 2 +-
 drivers/net/ethernet/intel/fm10k/fm10k_tlv.c | 2 +-
 drivers/net/ethernet/intel/fm10k/fm10k_vf.c  | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/fm10k/fm10k_pci.c +1 -1
index 15e67a383d27..73254b2b0a51 100644
@@ -1171,7 +1171,7 @@ static s32 fm10k_mbx_mac_addr(struct fm10k_hw *hw, u32 **results,
 
 	/* MAC was changed so we need reset */
 	if (is_valid_ether_addr(hw->mac.perm_addr) &&
-	    memcmp(hw->mac.perm_addr, hw->mac.addr, ETH_ALEN))
+	    ether_addr_equal(hw->mac.perm_addr, hw->mac.addr))
 		interface->flags |= FM10K_FLAG_RESET_REQUESTED;
 
 	/* VLAN override was changed, or default VLAN changed */
drivers/net/ethernet/intel/fm10k/fm10k_pf.c +1 -1
index bbf0b4aef241..f45e0bad41a9 100644
@@ -1249,7 +1249,7 @@ s32 fm10k_iov_msg_mac_vlan_pf(struct fm10k_hw *hw, u32 **results,
 
 		/* block attempts to set MAC for a locked device */
 		if (is_valid_ether_addr(vf_info->mac) &&
-		    memcmp(mac, vf_info->mac, ETH_ALEN))
+		    ether_addr_equal(mac, vf_info->mac))
 			return FM10K_ERR_PARAM;
 
 		set = !(vlan & FM10K_VLAN_CLEAR);
drivers/net/ethernet/intel/fm10k/fm10k_tlv.c +1 -1
index 9b29d7b0377a..d6ff1e8d89fa 100644
@@ -755,7 +755,7 @@ s32 fm10k_tlv_msg_test(struct fm10k_hw *hw, u32 **results,
 		err = fm10k_tlv_attr_get_mac_vlan(
 					results[FM10K_TEST_MSG_MAC_ADDR],
 					result_mac, &result_vlan);
-		if (!err && memcmp(test_mac, result_mac, ETH_ALEN))
+		if (!err && ether_addr_equal(test_mac, result_mac))
 			err = FM10K_ERR_INVALID_VALUE;
 		if (!err && test_vlan != result_vlan)
 			err = FM10K_ERR_INVALID_VALUE;
drivers/net/ethernet/intel/fm10k/fm10k_vf.c +1 -1
index 2af697df5abc..53345b1c29ce 100644
@@ -298,7 +298,7 @@ static s32 fm10k_update_uc_addr_vf(struct fm10k_hw *hw, u16 glort,
 
 	/* verify we are not locked down on the MAC address */
 	if (is_valid_ether_addr(hw->mac.perm_addr) &&
-	    memcmp(hw->mac.perm_addr, mac, ETH_ALEN))
+	    ether_addr_equal(hw->mac.perm_addr, mac))
 		return FM10K_ERR_PARAM;
 
 	/* add bit to notify us if this is a set or clear operation */
Signature · 1 line
2.6.1.264.gbab76a9
#2 lore raw

PATCH 2/6 fm10k: use ether_addr_equal instead of memcmp

-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Jacob Keller
Sent: Monday, October 26, 2015 4:32 PM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [next-queue 2/6] fm10k: use ether_addr_equal instead of memcmp

When comparing MAC addresses, use ether_addr_equal instead of memcmp to ETH_ALEN length. Found and replaced using the following sed:

sed -e 's/memcmp\x28\(.*\), ETH_ALEN\x29/ether_addr_equal\x28\1\x29/'

---

#3 lore raw

PATCH 3/6 fm10k: do not use CamelCase

In reply to Jacob Keller

From: Bruce Allan <[email protected]>

Avoid the use of CamelCase for some variable names that previously slipped through review.

---
 drivers/net/ethernet/intel/fm10k/fm10k_pci.c  | 12 ++++++------
 drivers/net/ethernet/intel/fm10k/fm10k_type.h | 14 +++++++-------
 2 files changed, 13 insertions(+), 13 deletions(-)
drivers/net/ethernet/intel/fm10k/fm10k_pci.c +6 -6
index 73254b2b0a51..e68000c35e02 100644
@@ -1418,14 +1418,14 @@ static int fm10k_mbx_request_irq_pf(struct fm10k_intfc *interface)
 	}
 
 	/* Enable interrupts w/ no moderation for "other" interrupts */
-	fm10k_write_reg(hw, FM10K_INT_MAP(fm10k_int_PCIeFault), other_itr);
-	fm10k_write_reg(hw, FM10K_INT_MAP(fm10k_int_SwitchUpDown), other_itr);
-	fm10k_write_reg(hw, FM10K_INT_MAP(fm10k_int_SRAM), other_itr);
-	fm10k_write_reg(hw, FM10K_INT_MAP(fm10k_int_MaxHoldTime), other_itr);
-	fm10k_write_reg(hw, FM10K_INT_MAP(fm10k_int_VFLR), other_itr);
+	fm10k_write_reg(hw, FM10K_INT_MAP(fm10k_int_pcie_fault), other_itr);
+	fm10k_write_reg(hw, FM10K_INT_MAP(fm10k_int_switch_up_down), other_itr);
+	fm10k_write_reg(hw, FM10K_INT_MAP(fm10k_int_sram), other_itr);
+	fm10k_write_reg(hw, FM10K_INT_MAP(fm10k_int_max_hold_time), other_itr);
+	fm10k_write_reg(hw, FM10K_INT_MAP(fm10k_int_vflr), other_itr);
 
 	/* Enable interrupts w/ moderation for mailbox */
-	fm10k_write_reg(hw, FM10K_INT_MAP(fm10k_int_Mailbox), mbx_itr);
+	fm10k_write_reg(hw, FM10K_INT_MAP(fm10k_int_mailbox), mbx_itr);
 
 	/* Enable individual interrupt causes */
 	fm10k_write_reg(hw, FM10K_EIMR, FM10K_EIMR_ENABLE(PCA_FAULT) |
drivers/net/ethernet/intel/fm10k/fm10k_type.h +7 -7
index 02727250ce1f..2fd962f97cb9 100644
@@ -388,13 +388,13 @@ struct fm10k_hw;
 #define FM10K_SW_SYSTIME_PULSE(_n)	((_n) + 0x02252)
 
 enum fm10k_int_source {
-	fm10k_int_Mailbox	= 0,
-	fm10k_int_PCIeFault	= 1,
-	fm10k_int_SwitchUpDown	= 2,
-	fm10k_int_SwitchEvent	= 3,
-	fm10k_int_SRAM		= 4,
-	fm10k_int_VFLR		= 5,
-	fm10k_int_MaxHoldTime	= 6,
+	fm10k_int_mailbox		= 0,
+	fm10k_int_pcie_fault		= 1,
+	fm10k_int_switch_up_down	= 2,
+	fm10k_int_switch_event		= 3,
+	fm10k_int_sram			= 4,
+	fm10k_int_vflr			= 5,
+	fm10k_int_max_hold_time		= 6,
 	fm10k_int_sources_max_pf
 };
 
Signature · 1 line
2.6.1.264.gbab76a9
#4 lore raw

PATCH 3/6 fm10k: do not use CamelCase

-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Jacob Keller
Sent: Monday, October 26, 2015 4:32 PM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [next-queue 3/6] fm10k: do not use CamelCase

From: Bruce Allan <[email protected]>

Avoid the use of CamelCase for some variable names that previously slipped through review.

---

#5 lore raw

PATCH 4/6 fm10k: remove unnecessary else block from if statements with return

In reply to Jacob Keller

Improve code style by removing the unnecessary else block of an if statement which immediately returns.

---
 drivers/net/ethernet/intel/fm10k/fm10k_pf.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/ethernet/intel/fm10k/fm10k_pf.c +6 -6
index f45e0bad41a9..3f9aa2f4311d 100644
@@ -1232,8 +1232,8 @@ s32 fm10k_iov_msg_mac_vlan_pf(struct fm10k_hw *hw, u32 **results,
 		err = fm10k_iov_select_vid(vf_info, (u16)vid);
 		if (err < 0)
 			return err;
-		else
-			vid = err;
+
+		vid = err;
 
 		/* update VSI info for VF in regards to VLAN table */
 		err = hw->mac.ops.update_vlan(hw, vid, vf_info->vsi, set);
@@ -1258,8 +1258,8 @@ s32 fm10k_iov_msg_mac_vlan_pf(struct fm10k_hw *hw, u32 **results,
 		err = fm10k_iov_select_vid(vf_info, vlan);
 		if (err < 0)
 			return err;
-		else
-			vlan = (u16)err;
+
+		vlan = (u16)err;
 
 		/* notify switch of request for new unicast address */
 		err = hw->mac.ops.update_uc_addr(hw, vf_info->glort,
@@ -1284,8 +1284,8 @@ s32 fm10k_iov_msg_mac_vlan_pf(struct fm10k_hw *hw, u32 **results,
 		err = fm10k_iov_select_vid(vf_info, vlan);
 		if (err < 0)
 			return err;
-		else
-			vlan = (u16)err;
+
+		vlan = (u16)err;
 
 		/* notify switch of request for new multicast address */
 		err = hw->mac.ops.update_mc_addr(hw, vf_info->glort,
Signature · 1 line
2.6.1.264.gbab76a9
#6 lore raw

PATCH 4/6 fm10k: remove unnecessary else block from if statements with return

-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Jacob Keller
Sent: Monday, October 26, 2015 4:32 PM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [next-queue 4/6] fm10k: remove unnecessary else block from if statements with return

Improve code style by removing the unnecessary else block of an if statement which immediately returns.

---

#7 lore raw

PATCH 5/6 fm10k: remove namespace pollution of fm10k_iov_msg_data_pf

In reply to Jacob Keller
---
 drivers/net/ethernet/intel/fm10k/fm10k_pf.c | 8 --------
 drivers/net/ethernet/intel/fm10k/fm10k_pf.h | 1 -
 2 files changed, 9 deletions(-)
drivers/net/ethernet/intel/fm10k/fm10k_pf.c +0 -8
index 3f9aa2f4311d..c7e09592c1f6 100644
@@ -1413,14 +1413,6 @@ s32 fm10k_iov_msg_lport_state_pf(struct fm10k_hw *hw, u32 **results,
 	return err;
 }
 
-const struct fm10k_msg_data fm10k_iov_msg_data_pf[] = {
-	FM10K_TLV_MSG_TEST_HANDLER(fm10k_tlv_msg_test),
-	FM10K_VF_MSG_MSIX_HANDLER(fm10k_iov_msg_msix_pf),
-	FM10K_VF_MSG_MAC_VLAN_HANDLER(fm10k_iov_msg_mac_vlan_pf),
-	FM10K_VF_MSG_LPORT_STATE_HANDLER(fm10k_iov_msg_lport_state_pf),
-	FM10K_TLV_MSG_ERROR_HANDLER(fm10k_tlv_msg_error),
-};
-
 /**
  *  fm10k_update_stats_hw_pf - Updates hardware related statistics of PF
  *  @hw: pointer to hardware structure
drivers/net/ethernet/intel/fm10k/fm10k_pf.h +0 -1
index 40a0dbc62a04..9d77daa777bb 100644
@@ -129,7 +129,6 @@ s32 fm10k_iov_msg_mac_vlan_pf(struct fm10k_hw *, u32 **,
 			      struct fm10k_mbx_info *);
 s32 fm10k_iov_msg_lport_state_pf(struct fm10k_hw *, u32 **,
 				 struct fm10k_mbx_info *);
-extern const struct fm10k_msg_data fm10k_iov_msg_data_pf[];
 
 extern struct fm10k_info fm10k_pf_info;
 #endif /* _FM10K_PF_H */
Signature · 1 line
2.6.1.264.gbab76a9
#8 lore raw

PATCH 5/6 fm10k: remove namespace pollution of fm10k_iov_msg_data_pf

Quoted 8 lines

-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Jacob Keller
Sent: Monday, October 26, 2015 4:32 PM
To: Intel Wired LAN
Subject: [Intel-wired-lan] [next-queue 5/6] fm10k: remove namespace pollution of fm10k_iov_msg_data_pf

Quoted 5 lines
---
 drivers/net/ethernet/intel/fm10k/fm10k_pf.c | 8 --------
 drivers/net/ethernet/intel/fm10k/fm10k_pf.h | 1 -
 2 files changed, 9 deletions(-)
#9 lore raw

PATCH 5/6 fm10k: remove namespace pollution of fm10k_iov_msg_data_pf

In reply to Jacob Keller

-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Jacob Keller
Sent: Monday, October 26, 2015 4:32 PM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [next-queue 5/6] fm10k: remove namespace pollution of fm10k_iov_msg_data_pf

---

#10 lore raw

PATCH 6/6 fm10k: consistently refer to VLANs and VLAN IDs

In reply to Jacob Keller

Instead of using lowercase vlan, vid, or VID, always use VLAN or VLAN ID in comments when referring to VLANs. The original driver code was consistent, but recent patches have not been as consistent with this naming scheme.

---
 drivers/net/ethernet/intel/fm10k/fm10k.h        |  4 ++--
 drivers/net/ethernet/intel/fm10k/fm10k_netdev.c |  8 ++++----
 drivers/net/ethernet/intel/fm10k/fm10k_pci.c    |  4 ++--
 drivers/net/ethernet/intel/fm10k/fm10k_pf.c     | 10 +++++-----
 4 files changed, 13 insertions(+), 13 deletions(-)
drivers/net/ethernet/intel/fm10k/fm10k.h +2 -2
index 4cdabfc483d2..cc919cae7ed1 100644
@@ -140,7 +140,7 @@ struct fm10k_ring {
 					 * different for DCB and RSS modes
 					 */
 	u8 qos_pc;			/* priority class of queue */
-	u16 vid;			/* default vlan ID of queue */
+	u16 vid;			/* default VLAN ID of queue */
 	u16 count;			/* amount of descriptors */
 
 	u16 next_to_alloc;
@@ -443,7 +443,7 @@ union fm10k_ftag_info {
 	struct {
 		/* dglort and sglort combined into a single 32bit desc read */
 		__le32 glort;
-		/* upper 16 bits of vlan are reserved 0 for swpri_type_user */
+		/* upper 16 bits of VLAN are reserved 0 for swpri_type_user */
 		__le32 vlan;
 	} d;
 	struct {
drivers/net/ethernet/intel/fm10k/fm10k_netdev.c +4 -4
index 38fe2d8c8388..4307f1808d3a 100644
@@ -630,7 +630,7 @@ static netdev_tx_t fm10k_xmit_frame(struct sk_buff *skb, struct net_device *dev)
 		if (err)
 			return NETDEV_TX_OK;
 
-		/* locate vlan header */
+		/* locate VLAN header */
 		vhdr = (struct vlan_hdr *)(skb->data + ETH_HLEN);
 
 		/* pull the 2 key pieces of data out of it */
@@ -776,7 +776,7 @@ static int fm10k_update_vid(struct net_device *netdev, u16 vid, bool set)
 	if (!set)
 		clear_bit(vid, interface->active_vlans);
 
-	/* disable the default VID on ring if we have an active VLAN */
+	/* disable the default VLAN ID on ring if we have an active VLAN */
 	for (i = 0; i < interface->num_rx_queues; i++) {
 		struct fm10k_ring *rx_ring = interface->rx_ring[i];
 		u16 rx_vid = rx_ring->vid & (VLAN_N_VID - 1);
@@ -787,7 +787,7 @@ static int fm10k_update_vid(struct net_device *netdev, u16 vid, bool set)
 			rx_ring->vid &= ~FM10K_VLAN_CLEAR;
 	}
 
-	/* Do not remove default VID related entries from VLAN and MAC tables */
+	/* Do not remove default VLAN ID related entries from VLAN and MAC tables */
 	if (!set && vid == hw->mac.default_vid)
 		return 0;
 
@@ -812,7 +812,7 @@ static int fm10k_update_vid(struct net_device *netdev, u16 vid, bool set)
 	if (err)
 		goto err_out;
 
-	/* set vid prior to syncing/unsyncing the VLAN */
+	/* set VLAN ID prior to syncing/unsyncing the VLAN */
 	interface->vid = vid + (set ? VLAN_N_VID : 0);
 
 	/* Update the unicast and multicast address list to add/drop VLAN */
drivers/net/ethernet/intel/fm10k/fm10k_pci.c +2 -2
index e68000c35e02..3e1c65706736 100644
@@ -715,7 +715,7 @@ static void fm10k_configure_rx_ring(struct fm10k_intfc *interface,
 	/* assign default VLAN to queue */
 	ring->vid = hw->mac.default_vid;
 
-	/* if we have an active VLAN, disable default VID */
+	/* if we have an active VLAN, disable default VLAN ID */
 	if (test_bit(hw->mac.default_vid, interface->active_vlans))
 		ring->vid |= FM10K_VLAN_CLEAR;
 
@@ -1299,7 +1299,7 @@ static s32 fm10k_update_pvid(struct fm10k_hw *hw, u32 **results,
 	if (!fm10k_glort_valid_pf(hw, glort))
 		return FM10K_ERR_PARAM;
 
-	/* verify VID is valid */
+	/* verify VLAN ID is valid */
 	if (pvid >= FM10K_VLAN_TABLE_VID_MAX)
 		return FM10K_ERR_PARAM;
 
drivers/net/ethernet/intel/fm10k/fm10k_pf.c +5 -5
index c7e09592c1f6..7c06dbcae589 100644
@@ -329,7 +329,7 @@ static s32 fm10k_update_xc_addr_pf(struct fm10k_hw *hw, u16 glort,
 	/* clear set bit from VLAN ID */
 	vid &= ~FM10K_VLAN_CLEAR;
 
-	/* if glort or vlan are not valid return error */
+	/* if glort or VLAN are not valid return error */
 	if (!fm10k_glort_valid_pf(hw, glort) || vid >= FM10K_VLAN_TABLE_VID_MAX)
 		return FM10K_ERR_PARAM;
 
@@ -1172,12 +1172,12 @@ s32 fm10k_iov_msg_msix_pf(struct fm10k_hw *hw, u32 **results,
 }
 
 /**
- * fm10k_iov_select_vid - Select correct default VID
+ * fm10k_iov_select_vid - Select correct default VLAN ID
  * @hw: Pointer to hardware structure
- * @vid: VID to correct
+ * @vid: VLAN ID to correct
  *
- * Will report an error if VID is out of range. For VID = 0, it will return
- * either the pf_vid or sw_vid depending on which one is set.
+ * Will report an error if the VLAN ID is out of range. For VID = 0, it will
+ * return either the pf_vid or sw_vid depending on which one is set.
  */
 static inline s32 fm10k_iov_select_vid(struct fm10k_vf_info *vf_info, u16 vid)
 {
Signature · 1 line
2.6.1.264.gbab76a9
#11 lore raw

PATCH 6/6 fm10k: consistently refer to VLANs and VLAN IDs

Quoted 13 lines

-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Jacob Keller
Sent: Monday, October 26, 2015 4:32 PM
To: Intel Wired LAN
Subject: [Intel-wired-lan] [next-queue 6/6] fm10k: consistently refer to VLANs and VLAN IDs

Instead of using lowercase vlan, vid, or VID, always use VLAN or VLAN ID in comments when referring to VLANs. The original driver code was consistent, but recent patches have not been as consistent with this naming scheme.

Quoted 7 lines
---
 drivers/net/ethernet/intel/fm10k/fm10k.h        |  4 ++--
 drivers/net/ethernet/intel/fm10k/fm10k_netdev.c |  8 ++++----
 drivers/net/ethernet/intel/fm10k/fm10k_pci.c    |  4 ++--
 drivers/net/ethernet/intel/fm10k/fm10k_pf.c     | 10 +++++-----
 4 files changed, 13 insertions(+), 13 deletions(-)
#12 lore raw

PATCH 1/6 fm10k: use ether_addr_copy to copy MAC address

In reply to Jacob Keller

-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Jacob Keller
Sent: Monday, October 26, 2015 4:32 PM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [next-queue 1/6] fm10k: use ether_addr_copy to copy MAC address

Use the ether_addr_copy function instead of copying byte-by-byte in a for-loop by hand.

---