natsemi.c - patching for ifconfig hw ether

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Greetings,

We are using the National DP83815 on a platform which has no EEPROM
attached.  The MAC address obtained during eeprom_read() call comes back
all 0xff's.  Interestingly, no error messages are noted in the kernel
log related to eeprom read timeouts (not important).

It is necessary that we set the hardware address using the 
	ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx
command after reading data burned into FLASH rather than EEPROM.

As currently implemented in the 2.4.19 distribution, calling ifconfig
eth0 hw ether ... for this driver does not set the "PMATCH" registers
for the device, and is not an effective way to set a new hardware
address after the EEPROM read.

I'd like to submit the following patch which allows for the natsemi.c
driver to properly set the PMATCH registers when from the ifconfig
command (below).  Please respond to my email address as well.  I am not
a subscriber (too much mail).

Thanks,

Nat
nat.ersoz@myrio.com



*** natsemi.c	Mon Oct  7 12:11:34 2002
--- ../../../linux-2.4.18-i3p/drivers/net/natsemi.c	Mon Oct  7 12:17:43 2002
***************
*** 668,673 ****
--- 668,674 ----
  static void netdev_tx_done(struct net_device *dev);
  static void __set_rx_mode(struct net_device *dev);
  static void set_rx_mode(struct net_device *dev);
+ static int netdev_mac_address(struct net_device *dev, void *p);
  static void __get_stats(struct net_device *dev);
  static struct net_device_stats *get_stats(struct net_device *dev);
  static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
***************
*** 793,798 ****
--- 794,800 ----
  	dev->set_multicast_list = &set_rx_mode;
  	dev->do_ioctl = &netdev_ioctl;
  	dev->tx_timeout = &tx_timeout;
+ 	dev->set_mac_address = netdev_mac_address;
  	dev->watchdog_timeo = TX_TIMEOUT;
  
  	if (mtu)
***************
*** 933,939 ****
  	u32 cfg;
  	u32 wcsr;
  	u32 rfcr;
! 	u16 pmatch[3];
  	u16 sopass[3];
  	struct netdev_private *np = dev->priv;
  
--- 935,941 ----
  	u32 cfg;
  	u32 wcsr;
  	u32 rfcr;
! 	u16 *pmatch = (u16*)dev->dev_addr;
  	u16 sopass[3];
  	struct netdev_private *np = dev->priv;
  
***************
*** 951,961 ****
  	wcsr = readl(dev->base_addr + WOLCmd) & WCSR_RESET_SAVE;
  	/* RFCR */
  	rfcr = readl(dev->base_addr + RxFilterAddr) & RFCR_RESET_SAVE;
! 	/* PMATCH */
! 	for (i = 0; i < 3; i++) {
! 		writel(i*2, dev->base_addr + RxFilterAddr);
! 		pmatch[i] = readw(dev->base_addr + RxFilterData);
! 	}
  	/* SOPAS */
  	for (i = 0; i < 3; i++) {
  		writel(0xa+(i*2), dev->base_addr + RxFilterAddr);
--- 953,959 ----
  	wcsr = readl(dev->base_addr + WOLCmd) & WCSR_RESET_SAVE;
  	/* RFCR */
  	rfcr = readl(dev->base_addr + RxFilterAddr) & RFCR_RESET_SAVE;
! 	/* PMATCH  - Nat: don't read, its stored in dev->dev_addr */
  	/* SOPAS */
  	for (i = 0; i < 3; i++) {
  		writel(0xa+(i*2), dev->base_addr + RxFilterAddr);
***************
*** 1820,1825 ****
--- 1818,1846 ----
  	spin_unlock_irq(&np->lock);
  }
  
+ static int netdev_mac_address(struct net_device *dev, void *p)
+ {
+ 	struct sockaddr *addr = p;
+ 	int i;
+ 
+ 	if (netif_running(dev))
+ 		return -EBUSY;
+ 
+ 	/* copy the hw addr info from void *p just like eth_mac_addr
+ 	does, which is found in linux/drivers/net/net_init.c */
+ 	memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
+ 
+ 	printk(KERN_INFO "%s: set mac address: ", dev->name );
+ 	for (i = 0; i < ETH_ALEN-1; i++)
+ 			printk("%02x:", dev->dev_addr[i]);
+ 	printk("%02x\n", dev->dev_addr[i]);
+ 
+ 	/* Reset the chip to enable new mac address */
+ 	natsemi_reset(dev);
+ 
+ 	return 0;
+ }
+ 
  static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
  {
  	struct netdev_private *np = dev->priv;
-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux