AF:
NF:0
PS:10
SRH:1
SFN:
DSR:
MID:
CFG:
PT:0
S:andy.sharp@lsi.com
RQ:
SSV:mhbs.lsil.com
NSV:
SSH:
R:<bfisher@lsi.com>
MAID:2
X-Sylpheed-Privacy-System:
X-Sylpheed-Sign:0
SCF:#mh/Mailbox/sent
RMID:#imap/LSI/INBOX	0	4A8C5F73.2010602@lsi.com
X-Sylpheed-End-Special-Headers: 1
Date: Wed, 19 Aug 2009 13:31:14 -0700
From: Andrew Sharp <andy.sharp@lsi.com>
To: William Fisher <bfisher@lsi.com>
Subject: Re: mac addr fix for tuxrx
Message-ID: <20090819133114.75953029@ripper.onstor.net>
In-Reply-To: <4A8C5F73.2010602@lsi.com>
References: <20090818150535.685fb288@ripper.onstor.net>
	<4A8C5F73.2010602@lsi.com>
Organization: LSI
X-Mailer: Sylpheed-Claws 2.6.0 (GTK+ 2.8.20; x86_64-pc-linux-gnu)
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

On Wed, 19 Aug 2009 14:24:19 -0600 William Fisher <bfisher@lsi.com>
wrote:

> Andrew Sharp wrote:
> > Resend of patch I sent out in march, apparently.
> > 
> > Begin forwarded message:
> > 
> > Date: Tue, 31 Mar 2009 13:25:24 -0700
> > From: Andrew Sharp <andy.sharp@onstor.com>
> > To: Rendell Fong <rendell.fong@onstor.com>, Bill Fisher
> > <bfisher@onstor.com> Subject: mac addr fix for tuxrx
> > 
> > 
> > Howdy folksez,
> > 
> > Apply the attached patch at the top level of your kernel tree to fix
> > the mac address problem on tuxrx.  This should put an end to the
> > "NFS server not reponding" messages/problem.
> > 
> > To apply patch, save attachment to a file.
> > 
> > at the top level of the kernel tree, run this command
> > 
> > patch -p 1 < patch-file
> > 
> > It should say "patching file sb1250-mac.c" and that's all.
> > 
> > Let me know if you have any problems.
> > 
> > Cheers,
> > 
> > a
> > 
> > 
> > ------------------------------------------------------------------------
> > 
> > diff --git a/drivers/net/sb1250-mac.c b/drivers/net/sb1250-mac.c
> > index 15e8605..2ce4c19 100644
> > --- a/drivers/net/sb1250-mac.c
> > +++ b/drivers/net/sb1250-mac.c
> > @@ -35,6 +35,9 @@
> >  #include <asm/processor.h>		/* Processor type for
> > cache alignment. */ #include <asm/io.h>
> >  #include <asm/cache.h>
> > +#ifdef CONFIG_ONSTOR_TUXRX
> > +#include <asm/mach-tuxrx/tuxrx.h>
> > +#endif
> >  
> >  /* This is only here until the firmware is ready.  In that case,
> >     the firmware leaves the ethernet address in the register for
> > us. */ @@ -1746,10 +1749,10 @@ static void
> > sbmac_channel_start(struct sbmac_softc *s)
> >   *  Stop packet processing on this MAC.
> >   *
> >   *  Input parameters:
> > - *  	   s - sbmac structure
> > + *	   s - sbmac structure
> >   *
> >   *  Return value:
> > - *  	   nothing
> > + *	   nothing
> >   *********************************************************************
> > */ 
> >  static void sbmac_channel_stop(struct sbmac_softc *s)
> > @@ -1796,10 +1799,10 @@ static void sbmac_channel_stop(struct
> > sbmac_softc *s)
> >   *  Set the channel's state ON or OFF
> >   *
> >   *  Input parameters:
> > - *  	   state - new state
> > + *	   state - new state
> >   *
> >   *  Return value:
> > - *  	   old state
> > + *	   old state
> >   *********************************************************************
> > */ static sbmac_state_t sbmac_set_channel_state(struct sbmac_softc
> > *sc, sbmac_state_t state)
> > @@ -1839,11 +1842,11 @@ static sbmac_state_t
> > sbmac_set_channel_state(struct sbmac_softc *sc,
> >   *  Turn on or off promiscuous mode
> >   *
> >   *  Input parameters:
> > - *  	   sc - softc
> > + *	   sc - softc
> >   *      onoff - 1 to turn on, 0 to turn off
> >   *
> >   *  Return value:
> > - *  	   nothing
> > + *	   nothing
> >   *********************************************************************
> > */ 
> >  static void sbmac_promiscuous_mode(struct sbmac_softc *sc,int
> > onoff) @@ -1871,10 +1874,10 @@ static void
> > sbmac_promiscuous_mode(struct sbmac_softc *sc,int onoff)
> >   *  Set the iphdr offset as 15 assuming ethernet encapsulation
> >   *
> >   *  Input parameters:
> > - *  	   sc - softc
> > + *	   sc - softc
> >   *
> >   *  Return value:
> > - *  	   nothing
> > + *	   nothing
> >   *********************************************************************
> > */ 
> >  static void sbmac_set_iphdr_offset(struct sbmac_softc *sc)
> > @@ -1903,10 +1906,10 @@ static void sbmac_set_iphdr_offset(struct
> > sbmac_softc *sc)
> >   *  we typically write into the SBMAC's address/mcast registers
> >   *
> >   *  Input parameters:
> > - *  	   ptr - pointer to 6 bytes
> > + *	   ptr - pointer to 6 bytes
> >   *
> >   *  Return value:
> > - *  	   register value
> > + *	   register value
> >   *********************************************************************
> > */ 
> >  static uint64_t sbmac_addr2reg(unsigned char *ptr)
> > @@ -1938,11 +1941,11 @@ static uint64_t sbmac_addr2reg(unsigned
> > char *ptr)
> >   *  Warning: must be called when MAC is off!
> >   *
> >   *  Input parameters:
> > - *  	   s - sbmac structure
> > - *  	   speed - speed to set MAC to (see sbmac_speed_t enum)
> > + *	   s - sbmac structure
> > + *	   speed - speed to set MAC to (see sbmac_speed_t enum)
> >   *
> >   *  Return value:
> > - *  	   1 if successful
> > + *	   1 if successful
> >   *      0 indicates invalid parameters
> >   *********************************************************************
> > */ 
> > @@ -2308,17 +2311,17 @@ static void sbmac_setmulti(struct
> > sbmac_softc *sc) }
> >  }
> >  
> > -#if defined(SBMAC_ETH0_HWADDR) || defined(SBMAC_ETH1_HWADDR) ||
> > defined(SBMAC_ETH2_HWADDR) || defined(SBMAC_ETH3_HWADDR) +#if
> > defined(SBMAC_ETH0_HWADDR) || defined(SBMAC_ETH1_HWADDR) ||
> > defined(SBMAC_ETH2_HWADDR) || defined(SBMAC_ETH3_HWADDR) ||
> > defined(CONFIG_ONSTOR_TUXRX) /**********************************************************************
> >   *  SBMAC_PARSE_XDIGIT(str)
> >   *
> >   *  Parse a hex digit, returning its value
> >   *
> >   *  Input parameters:
> > - *  	   str - character
> > + *	   str - character
> >   *
> >   *  Return value:
> > - *  	   hex value, or -1 if invalid
> > + *	   hex value, or -1 if invalid
> >   *********************************************************************
> > */ 
> >  static int sbmac_parse_xdigit(char str)
> > @@ -2344,11 +2347,11 @@ static int sbmac_parse_xdigit(char str)
> >   *  Ethernet address.
> >   *
> >   *  Input parameters:
> > - *  	   str - string
> > - *  	   hwaddr - pointer to hardware address
> > + *	   str - string
> > + *	   hwaddr - pointer to hardware address
> >   *
> >   *  Return value:
> > - *  	   0 if ok, else -1
> > + *	   0 if ok, else -1
> >   *********************************************************************
> > */ 
> >  static int sbmac_parse_hwaddr(char *str, unsigned char *hwaddr)
> > @@ -2514,9 +2517,9 @@ static int sbmac_open(struct net_device *dev)
> >  {
> >  	struct sbmac_softc *sc = netdev_priv(dev);
> >  
> > -	//if (debug > 1) {
> > +	if (debug > 1) {
> >  		printk(KERN_INFO "%s: sbmac_open() irq %d.\n",
> > dev->name, dev->irq);
> > -	//}
> > +	}
> >  
> >  	/*
> >  	 * map/route interrupt (clear status first, in case
> > something @@ -2917,7 +2920,7 @@ static int sbmac_poll(struct
> > net_device *dev, int *budget) return (work_done >= work_to_do);
> >  }
> >  
> > -#if defined(SBMAC_ETH0_HWADDR) || defined(SBMAC_ETH1_HWADDR) ||
> > defined(SBMAC_ETH2_HWADDR) || defined(SBMAC_ETH3_HWADDR) +#if
> > defined(SBMAC_ETH0_HWADDR) || defined(SBMAC_ETH1_HWADDR) ||
> > defined(SBMAC_ETH2_HWADDR) || defined(SBMAC_ETH3_HWADDR) ||
> > defined(CONFIG_ONSTOR_TUXRX) static void sbmac_setup_hwaddr(int
> > chan,char *addr) { @@ -2931,6 +2934,12 @@ sbmac_setup_hwaddr(int
> > chan,char *addr) __raw_writeq(val,
> > IOADDR(port+R_MAC_ETHERNET_ADDR)); val =
> > __raw_readq(IOADDR(port+R_MAC_ETHERNET_ADDR)); }
> > +
> > +#ifndef CONFIG_MGMT_BUS
> > +char *magicmanagementbusringconfig;
> > +#else
> > +extern char *magicmanagementbusringconfig;
> > +#endif
> >  #endif
> >  
> >  static struct net_device *dev_sbmac[MAX_UNITS];
> > @@ -2988,17 +2997,38 @@ sbmac_init_module(void)
> >  	  sbmac_setup_hwaddr(3,SBMAC_ETH3_HWADDR);
> >  #endif
> >  
> > +#ifdef CONFIG_ONSTOR_TUXRX
> > +	/*
> > +	 * on the tuxrx, the upper 3 bytes are onstor device
> > identifier,
> > +	 * lower 3 bytes are copied from SSC mac addresses, with
> > 0x10 or'd
> > +	 * into the last byte to indicate that it's a tuxrx port
> > +	 */

If you notice in the original code snippet I sent, this ifndef and it's
matching endif were commented out, but not in the patch, hence your
problem. I guess it was written that way originally for some reason,
but the code is always needed, so the ifndef was commented out.


> > +#ifndef CONFIG_MGMT_BUS
> > +	magicmanagementbusringconfig = (char
> > *)ioremap(0x1000000000ULL
> > +			| PCI_SHARED_MEM_OFF, 0x100);
> > +#endif
> > +	for (idx = 0; idx < chip_max_units; idx++) {
> > +		char ons_mac_str[] = "00:07:34:00:00:00";
> > +
> > +		sprintf(&ons_mac_str[9], "%02X:%02X:%02X",
> > +				*(magicmanagementbusringconfig +
> > 198),
> > +				*(magicmanagementbusringconfig +
> > 197),
> > +				*(magicmanagementbusringconfig +
> > 196) | (0x10 | idx));
> > +		sbmac_setup_hwaddr(idx, ons_mac_str);
> > +	}
> > +#endif
> > +
> >  	/*
> >  	 * Walk through the Ethernet controllers and find
> >  	 * those who have their MAC addresses set.
> >  	 */
> >  	for (idx = 0; idx < chip_max_units; idx++) {
> >  
> > -	        /*
> > -	         * This is the base address of the MAC.
> > +		/*
> > +		 * This is the base address of the MAC.
> >  		 */
> >  
> > -	        port = A_MAC_CHANNEL_BASE(idx);
> > +		port = A_MAC_CHANNEL_BASE(idx);
> >  
> >  		/*
> >  		 * The R_MAC_ETHERNET_ADDR register will be set to
> > some nonzero
> 
> Ok, I applied the patch and the kernel dies since 
> *(magicmanagementbusringconfig is ZERO when the sb1250 mac init 
> procedure is called.
> 
> I added the following:
> 
> #ifdef CONFIG_ONSTOR_TUXRX
>          /*
>           * on the tuxrx, the upper 3 bytes are onstor device
> identifier,
>           * lower 3 bytes are copied from SSC mac addresses, with
> 0x10 or'd
>           * into the last byte to indicate that it's a tuxrx port
>           */
>          if (magicmanagementbusringconfig == NULL) { /* set it */
>                  magicmanagementbusringconfig =
>                          (char *)ioremap(0x1000000000ULL | 
> PCI_SHARED_MEM_OFF, 0x100);
>          }
>          printk("sbmac_init_module: magicmanagementbusringconfig 
> 0x%p\n", magicmanagementbusringconfig);
> 
> and now the Ethernet MAC is set to:
> 
> ==================
> tuxrx0:~# ifconfig eth0
> eth0      Link encap:Ethernet  HWaddr 00:07:34:01:03:10
>            inet addr:10.3.7.41  Bcast:10.3.255.255  Mask:255.255.0.0
>            inet6 addr: fe80::207:34ff:fe01:310/64 Scope:Link
>            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
>            RX packets:18524 errors:0 dropped:0 overruns:272 frame:0
>            TX packets:16410 errors:0 dropped:0 overruns:0 carrier:0
>            collisions:0 txqueuelen:1000
>            RX bytes:15334563 (14.6 MiB)  TX bytes:2465332 (2.3 MiB)
>            Interrupt:36 Base address:0x4000
> 
> 
> 
> This implies that the sb1250_mac_init() is called before the mgmbtbus
> driver load, which all sounds reasonable.
> 
> Am I missing something else?
> 
> -- Bill
> 
> 
> 
> 
