netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shahed Shaikh <shahed.shaikh@qlogic.com>
To: <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>, <Dept_NX_Linux_NIC_Driver@qlogic.com>,
	Manish Chopra <manish.chopra@qlogic.com>
Subject: [PATCH net v2 1/8] qlcnic: Fix setting MAC address
Date: Thu, 9 May 2013 15:25:09 -0400	[thread overview]
Message-ID: <1368127516-9943-2-git-send-email-shahed.shaikh@qlogic.com> (raw)
In-Reply-To: <1368127516-9943-1-git-send-email-shahed.shaikh@qlogic.com>

From: Manish Chopra <manish.chopra@qlogic.com>

o Delete previous unicast MAC which is already programmed
  in adapter before setting new unicast MAC

Signed-off-by: Manish Chopra <manish.chopra@qlogic.com>
Signed-off-by: Shahed Shaikh <shahed.shaikh@qlogic.com>
---
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
index 264d5a4..04037b5 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
@@ -308,6 +308,23 @@ int qlcnic_read_mac_addr(struct qlcnic_adapter *adapter)
 	return 0;
 }
 
+static void qlcnic_delete_adapter_mac(struct qlcnic_adapter *adapter)
+{
+	struct qlcnic_mac_list_s *cur;
+	struct list_head *head;
+
+	list_for_each(head, &adapter->mac_list) {
+		cur = list_entry(head, struct qlcnic_mac_list_s, list);
+		if (!memcmp(adapter->mac_addr, cur->mac_addr, ETH_ALEN)) {
+			qlcnic_sre_macaddr_change(adapter, cur->mac_addr,
+						  0, QLCNIC_MAC_DEL);
+			list_del(&cur->list);
+			kfree(cur);
+			return;
+		}
+	}
+}
+
 static int qlcnic_set_mac(struct net_device *netdev, void *p)
 {
 	struct qlcnic_adapter *adapter = netdev_priv(netdev);
@@ -322,11 +339,15 @@ static int qlcnic_set_mac(struct net_device *netdev, void *p)
 	if (!is_valid_ether_addr(addr->sa_data))
 		return -EINVAL;
 
+	if (!memcmp(adapter->mac_addr, addr->sa_data, ETH_ALEN))
+		return 0;
+
 	if (test_bit(__QLCNIC_DEV_UP, &adapter->state)) {
 		netif_device_detach(netdev);
 		qlcnic_napi_disable(adapter);
 	}
 
+	qlcnic_delete_adapter_mac(adapter);
 	memcpy(adapter->mac_addr, addr->sa_data, netdev->addr_len);
 	memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
 	qlcnic_set_multi(adapter->netdev);
-- 
1.5.6

  reply	other threads:[~2013-05-09 19:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-09 19:25 [PATCH net v2 0/8] qlcnic: Bug fixes Shahed Shaikh
2013-05-09 19:25 ` Shahed Shaikh [this message]
2013-05-09 19:25 ` [PATCH net v2 2/8] qlcnic: Fix ethtool strings Shahed Shaikh
2013-05-09 19:25 ` [PATCH net v2 3/8] qlcnic: Fix missing bracket in module parameter Shahed Shaikh
2013-05-09 19:25 ` [PATCH net v2 4/8] qlcnic: Fix ethtool supported port status for 83xx Shahed Shaikh
2013-05-09 19:25 ` [PATCH net v2 5/8] qlcnic: Fix reset recovery after transmit timeout Shahed Shaikh
2013-05-09 19:25 ` [PATCH net v2 6/8] qlcnic: Fix bug in diagnostics test reset recovery path Shahed Shaikh
2013-05-09 19:25 ` [PATCH net v2 7/8] qlcnic: Fix mailbox response handling Shahed Shaikh
2013-05-09 19:25 ` [PATCH net v2 8/8] qlcnic: Fix validation of link event command Shahed Shaikh
2013-05-11 23:01 ` [PATCH net v2 0/8] qlcnic: Bug fixes David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1368127516-9943-2-git-send-email-shahed.shaikh@qlogic.com \
    --to=shahed.shaikh@qlogic.com \
    --cc=Dept_NX_Linux_NIC_Driver@qlogic.com \
    --cc=davem@davemloft.net \
    --cc=manish.chopra@qlogic.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).