Netdev List
 help / color / mirror / Atom feed
From: Manfred Spraul <manfred@colorfullife.com>
To: Jeff Garzik <jgarzik@pobox.com>
Cc: Netdev <netdev@oss.sgi.com>, Ayaz Abdulla <AAbdulla@nvidia.com>
Subject: [PATCH] forcedeth: add set_mac_address support
Date: Fri, 22 Jul 2005 22:48:02 +0200	[thread overview]
Message-ID: <42E15B82.9020006@colorfullife.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 219 bytes --]

Hi Jeff,

Ayaz wrote a patch that adds set_mac_address to the forcedeth nic.
Could you add it to your tree? set_mac_address is required for some 
bonding modes.

Signed-Off-By: Manfred Spraul <manfred@colorfullife.com>

[-- Attachment #2: patch-forcedeth-040-set_mac_address --]
[-- Type: text/plain, Size: 2322 bytes --]

--- 2.6/drivers/net/forcedeth.c	2005-07-22 22:47:01.000000000 +0200
+++ build-2.6/drivers/net/forcedeth.c	2005-07-22 22:47:31.000000000 +0200
@@ -90,6 +90,7 @@
  *	0.38: 16 Jul 2005: tx irq rewrite: Use global flags instead of
  *			   per-packet flags.
  *      0.39: 18 Jul 2005: Add 64bit descriptor support.
+ *      0.40: 19 Jul 2005: Add support for mac address change.
  *
  * Known bugs:
  * We suspect that on some hardware no TX done interrupts are generated.
@@ -1417,6 +1418,54 @@
 }
 
 /*
+ * nv_set_mac_address: dev->set_mac_address function
+ * Called with rtnl_lock() held.
+ */
+static int nv_set_mac_address(struct net_device *dev, void *addr)
+{
+	struct fe_priv *np = get_nvpriv(dev);
+	u8 *base = get_hwbase(dev);
+	struct sockaddr *macaddr = (struct sockaddr*)addr;
+	u32 mac[2];
+
+	if(!is_valid_ether_addr(macaddr->sa_data))
+		return -EADDRNOTAVAIL;
+
+	/* synchronized against open : rtnl_lock() held by caller */
+	if (netif_running(dev)) {
+		spin_lock_bh(&dev->xmit_lock);
+		spin_lock_irq(&np->lock);
+
+		/* stop rx engine */
+		nv_stop_rx(dev);
+
+		/* set mac address */
+		memcpy(dev->dev_addr, macaddr->sa_data, ETH_ALEN);
+		mac[0] = (dev->dev_addr[0] << 0) + (dev->dev_addr[1] << 8) +
+				(dev->dev_addr[2] << 16) + (dev->dev_addr[3] << 24);
+		mac[1] = (dev->dev_addr[4] << 0) + (dev->dev_addr[5] << 8);
+
+		writel(mac[0], base + NvRegMacAddrA);
+		writel(mac[1], base + NvRegMacAddrB);
+	
+		/* restart rx engine */
+		nv_start_rx(dev);
+		spin_unlock_irq(&np->lock);
+		spin_unlock_bh(&dev->xmit_lock);
+	} else {
+		/* set mac address */
+		memcpy(dev->dev_addr, macaddr->sa_data, ETH_ALEN);
+		mac[0] = (dev->dev_addr[0] << 0) + (dev->dev_addr[1] << 8) +
+				(dev->dev_addr[2] << 16) + (dev->dev_addr[3] << 24);
+		mac[1] = (dev->dev_addr[4] << 0) + (dev->dev_addr[5] << 8);
+
+		writel(mac[0], base + NvRegMacAddrA);
+		writel(mac[1], base + NvRegMacAddrB);
+	}
+	return 0;
+}
+
+/*
  * nv_set_multicast: dev->set_multicast function
  * Called with dev->xmit_lock held.
  */
@@ -2298,6 +2347,7 @@
 	dev->hard_start_xmit = nv_start_xmit;
 	dev->get_stats = nv_get_stats;
 	dev->change_mtu = nv_change_mtu;
+	dev->set_mac_address = nv_set_mac_address;
 	dev->set_multicast_list = nv_set_multicast;
 #ifdef CONFIG_NET_POLL_CONTROLLER
 	dev->poll_controller = nv_poll_controller;

                 reply	other threads:[~2005-07-22 20:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=42E15B82.9020006@colorfullife.com \
    --to=manfred@colorfullife.com \
    --cc=AAbdulla@nvidia.com \
    --cc=jgarzik@pobox.com \
    --cc=netdev@oss.sgi.com \
    /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