[xtensa-cvscommit] linux/drivers/net sonic.c,1.1.1.1,1.2 sonic.h,1.3,1.4 xtsonic.c,1.2,1.3
Brought to you by:
zankel
|
From: <ma...@us...> - 2003-02-06 01:23:57
|
Update of /cvsroot/xtensa/linux/drivers/net
In directory sc8-pr-cvs1:/tmp/cvs-serv16891
Modified Files:
sonic.c sonic.h xtsonic.c
Log Message:
Fix rx buffer size bug with generic SONIC Ethernet driver
(not large enough to accept max sized frames on DP83934C parts).
Also cleanup XT2000 specific SONIC driver wrapper.
Index: sonic.c
===================================================================
RCS file: /cvsroot/xtensa/linux/drivers/net/sonic.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** sonic.c 28 Aug 2002 16:10:45 -0000 1.1.1.1
--- sonic.c 6 Feb 2003 01:23:48 -0000 1.2
***************
*** 502,506 ****
SONIC_WRITE(SONIC_RWP, rra_end);
SONIC_WRITE(SONIC_URRA, lp->rra_laddr >> 16);
! SONIC_WRITE(SONIC_EOBC, (SONIC_RBSIZE - 2) >> 1);
lp->cur_rra =
--- 502,506 ----
SONIC_WRITE(SONIC_RWP, rra_end);
SONIC_WRITE(SONIC_URRA, lp->rra_laddr >> 16);
! SONIC_WRITE(SONIC_EOBC, (SONIC_RBSIZE - SONIC_MODESIZE) >> 1);
lp->cur_rra =
Index: sonic.h
===================================================================
RCS file: /cvsroot/xtensa/linux/drivers/net/sonic.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** sonic.h 5 Nov 2002 19:38:58 -0000 1.3
--- sonic.h 6 Feb 2003 01:23:49 -0000 1.4
***************
*** 426,430 ****
* MSch: use more buffer space for the slow m68k Macs!
*/
! #ifdef CONFIG_MACSONIC
#define SONIC_NUM_RRS 32 /* number of receive resources */
#define SONIC_NUM_RDS SONIC_NUM_RRS /* number of receive descriptors */
--- 426,430 ----
* MSch: use more buffer space for the slow m68k Macs!
*/
! #if defined(CONFIG_MACSONIC) || defined(CONFIG_XTENSA_PLATFORM_XT2000_SONIC)
#define SONIC_NUM_RRS 32 /* number of receive resources */
#define SONIC_NUM_RDS SONIC_NUM_RRS /* number of receive descriptors */
***************
*** 435,439 ****
#define SONIC_NUM_TDS 16 /* number of transmit descriptors */
#endif
! #define SONIC_RBSIZE 1520 /* size of one resource buffer */
#define SONIC_RDS_MASK (SONIC_NUM_RDS-1)
--- 435,449 ----
#define SONIC_NUM_TDS 16 /* number of transmit descriptors */
#endif
! /*
! * The SONIC DP83934C datasheets recommend setting EOBC 2 or 4 bytes less
! * than the buffer size (for 16-bit and 32-bit modes respectively)
! * when buffering a single packet per RBA, as this driver does.
! * And they indicate EOBC must be set to 1518 or 1520 for 16-bit
! * and 32-bit modes respectively. To test which case, construct
! * a small structure whose size (2 or 4 bytes) depends on the mode:
! */
! struct _sonic_size_test { u16 dummy; SREGS_PAD(pad); };
! #define SONIC_MODESIZE sizeof(struct _sonic_size_test) /* 2 or 4 */
! #define SONIC_RBSIZE ((SONIC_MODESIZE > 2) ? 1524 : 1518) /* size of one resource buffer */
#define SONIC_RDS_MASK (SONIC_NUM_RDS-1)
Index: xtsonic.c
===================================================================
RCS file: /cvsroot/xtensa/linux/drivers/net/xtsonic.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** xtsonic.c 29 Oct 2002 01:20:32 -0000 1.2
--- xtsonic.c 6 Feb 2003 01:23:49 -0000 1.3
***************
*** 2,6 ****
* xtsonic.c
*
! * (C) 2001 by Kevin Chea (kc...@te...)
* (C) 1996,1998 by Thomas Bogendoerfer (tsb...@al...)
*
--- 2,9 ----
* xtsonic.c
*
! * (C) 2001 - 2003 Tensilica Inc.
! * by Kevin Chea <kc...@ya...> (2001)
! * by Marc Gauthier (ma...@te..., ma...@al...) (2003)
! *
* (C) 1996,1998 by Thomas Bogendoerfer (tsb...@al...)
*
***************
*** 10,14 ****
* (C) 1995 by Andreas Busse (an...@wa...)
*
! * A driver for the onboard Sonic ethernet controller on the XT-2000.
*/
--- 13,17 ----
* (C) 1995 by Andreas Busse (an...@wa...)
*
! * A driver for the onboard Sonic ethernet controller on the XT2000.
*/
***************
*** 106,109 ****
--- 109,113 ----
unsigned int silicon_revision;
struct sonic_local *lp;
+ unsigned char *priv;
dma_addr_t dma;
int i;
***************
*** 133,137 ****
/* Allocate a new 'dev' if needed. */
if (dev == NULL)
! dev = init_etherdev(0, sizeof(struct sonic_local));
if (sonic_debug && version_printed++ == 0)
--- 137,141 ----
/* Allocate a new 'dev' if needed. */
if (dev == NULL)
! dev = init_etherdev(0, 0);
if (sonic_debug && version_printed++ == 0)
***************
*** 158,162 ****
if (xtboard_nvram_valid()) {
! xtboard_get_ether_addr(&dev->dev_addr);
} else {
/* XTFIXME [kcc] Bogus ethernet address */
--- 162,166 ----
if (xtboard_nvram_valid()) {
! xtboard_get_ether_addr(dev->dev_addr);
} else {
/* XTFIXME [kcc] Bogus ethernet address */
***************
*** 167,170 ****
--- 171,175 ----
dev->dev_addr[4]=0x4;
dev->dev_addr[5]=0x5;
+ printk("Bogus ");
}
***************
*** 179,230 ****
/* Initialize the device structure. */
! if (dev->priv == NULL) {
! /*
! * the memory must be located in the same 64kb segment
! */
! i = 0;
! do {
! lp = pci_alloc_consistent(NULL,sizeof(struct sonic_local),&dma);
! if ((unsigned long) lp >> 16
! != ((unsigned long)lp + sizeof(*lp) ) >> 16) {
! pci_free_consistent(NULL, sizeof(struct sonic_local),
! lp, dma);
! lp = NULL;
! }
! } while (lp == NULL && i++ < 20);
! if (lp == NULL) {
! printk ("%s: couldn't allocate memory for descriptors\n",
! dev->name);
! return -ENOMEM;
! }
!
! memset(lp, 0, sizeof(struct sonic_local));
!
! /* get the virtual dma address */
! lp->cda_laddr = dma;
! lp->tda_laddr = lp->cda_laddr + sizeof (lp->cda);
! lp->rra_laddr = lp->tda_laddr + sizeof (lp->tda);
! lp->rda_laddr = lp->rra_laddr + sizeof (lp->rra);
!
! /* allocate receive buffer area */
! /* FIXME, maybe we should use skbs */
! lp->rba = (char *)kmalloc(SONIC_NUM_RRS * SONIC_RBSIZE, GFP_KERNEL);
! if (lp->rba == NULL) {
! printk ("%s: couldn't allocate receive buffers\n",dev->name);
! return -ENOMEM;
! }
! lp->rba_laddr = virt_to_phys(lp->rba);
! flush_cache_all();
! dev->priv = (struct sonic_local *)lp;
}
- lp = (struct sonic_local *)dev->priv;
dev->open = sonic_open;
dev->stop = sonic_close;
! dev->hard_start_xmit = sonic_send_packet;
! dev->get_stats = sonic_get_stats;
dev->set_multicast_list = &sonic_multicast_list;
--- 184,243 ----
/* Initialize the device structure. */
! if (dev->priv != NULL)
! printk("%s: preallocated priv field ignored\n", dev->name);
! /*
! * Allocate local private descriptor areas in uncached space.
! * The entire structure must be located within the same 64kb segment.
! * A simple way to ensure this is to allocate twice the
! * size of the structure -- given that the structure is
! * much less than 64 kB, at least one of the halves of
! * the allocated area will be contained entirely in 64 kB.
! * We also allocate extra space for a pointer to allow freeing
! * this structure later on (in xtsonic_cleanup_module()).
! */
! priv = pci_alloc_consistent(NULL, sizeof(struct sonic_local)*2
! + sizeof(unsigned char*), &dma);
! priv += sizeof(unsigned char*); /* skip pointer */
! dma += sizeof(unsigned char*); /* ditto */
! lp = (struct sonic_local*) \
! ( ((unsigned)priv + sizeof(struct sonic_local) - 1) & 0xFFFF0000 );
! if( (unsigned char*)lp < priv )
! /* Returned address is okay, fits in 64 kB: */
! lp = (struct sonic_local*)priv;
! else
! /* Aligned returned address to 64 kB, adjust 'dma' similarly: */
! dma = (dma_addr_t)( (unsigned)dma + ((unsigned char*)lp - priv) );
! *((unsigned char**)lp - 1) = priv - sizeof(unsigned char*);
! /* For debugging: */
! printk("%s: SONIC priv area at 0x%X, dev at 0x%X\n",
! dev->name, (unsigned) lp, (unsigned) dev);
! memset(lp, 0, sizeof(struct sonic_local));
!
! /* get the virtual dma address */
! lp->cda_laddr = dma;
! lp->tda_laddr = lp->cda_laddr + sizeof (lp->cda);
! lp->rra_laddr = lp->tda_laddr + sizeof (lp->tda);
! lp->rda_laddr = lp->rra_laddr + sizeof (lp->rra);
!
! /* allocate receive buffer area */
! /* FIXME, maybe we should use skbs */
! lp->rba = (char *)kmalloc(SONIC_NUM_RRS * SONIC_RBSIZE, GFP_KERNEL);
! if (lp->rba == NULL) {
! printk ("%s: couldn't allocate receive buffers\n",dev->name);
! return -ENOMEM;
}
+ lp->rba_laddr = virt_to_phys(lp->rba);
+
+ flush_cache_all();
+
+ dev->priv = lp;
dev->open = sonic_open;
dev->stop = sonic_close;
! dev->hard_start_xmit = sonic_send_packet;
! dev->get_stats = sonic_get_stats;
dev->set_multicast_list = &sonic_multicast_list;
***************
*** 261,265 ****
if (dev_xtsonic.priv != NULL) {
unregister_netdev(&dev_xtsonic);
! kfree(dev_xtsonic.priv);
dev_xtsonic.priv = NULL;
}
--- 274,278 ----
if (dev_xtsonic.priv != NULL) {
unregister_netdev(&dev_xtsonic);
! kfree(*((unsigned char**)dev_xtsonic.priv-1));
dev_xtsonic.priv = NULL;
}
|