patch-2.4.19 linux-2.4.19/drivers/net/de4x5.c
Next file: linux-2.4.19/drivers/net/de620.c
Previous file: linux-2.4.19/drivers/net/daynaport.c
Back to the patch index
Back to the overall index
- Lines: 267
- Date:
Fri Aug 2 17:39:44 2002
- Orig file:
linux-2.4.18/drivers/net/de4x5.c
- Orig date:
Mon Feb 25 11:37:59 2002
diff -urN linux-2.4.18/drivers/net/de4x5.c linux-2.4.19/drivers/net/de4x5.c
@@ -436,6 +436,7 @@
'pb' is now only initialized if a de4x5 chip is
present.
<france@handhelds.org>
+ 0.547 08-Nov-01 Use library crc32 functions by <Matt_Domsch@dell.com>
=========================================================================
*/
@@ -457,6 +458,7 @@
#include <linux/init.h>
#include <linux/version.h>
#include <linux/spinlock.h>
+#include <linux/crc32.h>
#include <asm/bitops.h>
#include <asm/io.h>
@@ -622,9 +624,6 @@
#define QUEUE_PKT_TIMEOUT (3*HZ) /* 3 second timeout */
-#define CRC_POLYNOMIAL_BE 0x04c11db7UL /* Ethernet CRC, big endian */
-#define CRC_POLYNOMIAL_LE 0xedb88320UL /* Ethernet CRC, little endian */
-
/*
** EISA bus defines
*/
@@ -658,15 +657,15 @@
** DESC_ALIGN. ALIGN aligns the start address of the private memory area
** and hence the RX descriptor ring's first entry.
*/
-#define ALIGN4 ((u_long)4 - 1) /* 1 longword align */
-#define ALIGN8 ((u_long)8 - 1) /* 2 longword align */
-#define ALIGN16 ((u_long)16 - 1) /* 4 longword align */
-#define ALIGN32 ((u_long)32 - 1) /* 8 longword align */
-#define ALIGN64 ((u_long)64 - 1) /* 16 longword align */
-#define ALIGN128 ((u_long)128 - 1) /* 32 longword align */
+#define DE4X5_ALIGN4 ((u_long)4 - 1) /* 1 longword align */
+#define DE4X5_ALIGN8 ((u_long)8 - 1) /* 2 longword align */
+#define DE4X5_ALIGN16 ((u_long)16 - 1) /* 4 longword align */
+#define DE4X5_ALIGN32 ((u_long)32 - 1) /* 8 longword align */
+#define DE4X5_ALIGN64 ((u_long)64 - 1) /* 16 longword align */
+#define DE4X5_ALIGN128 ((u_long)128 - 1) /* 32 longword align */
-#define ALIGN ALIGN32 /* Keep the DC21040 happy... */
-#define CACHE_ALIGN CAL_16LONG
+#define DE4X5_ALIGN DE4X5_ALIGN32 /* Keep the DC21040 happy... */
+#define DE4X5_CACHE_ALIGN CAL_16LONG
#define DESC_SKIP_LEN DSL_0 /* Must agree with DESC_ALIGN */
/*#define DESC_ALIGN u32 dummy[4]; / * Must agree with DESC_SKIP_LEN */
#define DESC_ALIGN
@@ -867,7 +866,7 @@
** offsets in the PCI and EISA boards. Also note that the ethernet address
** PROM is accessed differently.
*/
-static struct bus_type {
+static struct de4x5_bus_type {
int bus;
int bus_num;
int device;
@@ -968,10 +967,10 @@
static int test_ans(struct net_device *dev, s32 irqs, s32 irq_mask, s32 msec);
static int test_tp(struct net_device *dev, s32 msec);
static int EISA_signature(char *name, s32 eisa_id);
-static int PCI_signature(char *name, struct bus_type *lp);
+static int PCI_signature(char *name, struct de4x5_bus_type *lp);
static void DevicePresent(u_long iobase);
static void enet_addr_rst(u_long aprom_addr);
-static int de4x5_bad_srom(struct bus_type *lp);
+static int de4x5_bad_srom(struct de4x5_bus_type *lp);
static short srom_rd(u_long address, u_char offset);
static void srom_latch(u_int command, u_long address);
static void srom_command(u_int command, u_long address);
@@ -999,7 +998,7 @@
static int get_hw_addr(struct net_device *dev);
static void srom_repair(struct net_device *dev, int card);
static int test_bad_enet(struct net_device *dev, int status);
-static int an_exception(struct bus_type *lp);
+static int an_exception(struct de4x5_bus_type *lp);
#if !defined(__sparc_v9__) && !defined(__powerpc__) && !defined(__alpha__)
static void eisa_probe(struct net_device *dev, u_long iobase);
#endif
@@ -1144,7 +1143,7 @@
static int __init
de4x5_hw_init(struct net_device *dev, u_long iobase, struct pci_dev *pdev)
{
- struct bus_type *lp = &bus;
+ struct de4x5_bus_type *lp = &bus;
int i, status=0;
char *tmp;
@@ -1203,7 +1202,7 @@
** Reserve a section of kernel memory for the adapter
** private area and the TX/RX descriptor rings.
*/
- dev->priv = (void *) kmalloc(sizeof(struct de4x5_private) + ALIGN,
+ dev->priv = (void *) kmalloc(sizeof(struct de4x5_private) + DE4X5_ALIGN,
GFP_KERNEL);
if (dev->priv == NULL) {
return -ENOMEM;
@@ -1213,7 +1212,7 @@
** Align to a longword boundary
*/
tmp = dev->priv;
- dev->priv = (void *)(((u_long)dev->priv + ALIGN) & ~ALIGN);
+ dev->priv = (void *)(((u_long)dev->priv + DE4X5_ALIGN) & ~DE4X5_ALIGN);
lp = (struct de4x5_private *)dev->priv;
memset(dev->priv, 0, sizeof(struct de4x5_private));
lp->bus = bus.bus;
@@ -1249,7 +1248,7 @@
lp->dma_size = (NUM_RX_DESC + NUM_TX_DESC) * sizeof(struct de4x5_desc);
#if defined(__alpha__) || defined(__powerpc__) || defined(__sparc_v9__) || defined(DE4X5_DO_MEMCPY)
- lp->dma_size += RX_BUFF_SZ * NUM_RX_DESC + ALIGN;
+ lp->dma_size += RX_BUFF_SZ * NUM_RX_DESC + DE4X5_ALIGN;
#endif
lp->rx_ring = pci_alloc_consistent(pdev, lp->dma_size, &lp->dma_rings);
if (lp->rx_ring == NULL) {
@@ -1279,9 +1278,9 @@
dma_rx_bufs = lp->dma_rings + (NUM_RX_DESC + NUM_TX_DESC)
* sizeof(struct de4x5_desc);
- dma_rx_bufs = (dma_rx_bufs + ALIGN) & ~ALIGN;
+ dma_rx_bufs = (dma_rx_bufs + DE4X5_ALIGN) & ~DE4X5_ALIGN;
lp->rx_bufs = (char *)(((long)(lp->rx_ring + NUM_RX_DESC
- + NUM_TX_DESC) + ALIGN) & ~ALIGN);
+ + NUM_TX_DESC) + DE4X5_ALIGN) & ~DE4X5_ALIGN);
for (i=0; i<NUM_RX_DESC; i++) {
lp->rx_ring[i].status = 0;
lp->rx_ring[i].des1 = cpu_to_le32(RX_BUFF_SZ);
@@ -1490,7 +1489,7 @@
** Fasternet chips and 4 longwords for all others: DMA errors result
** without these values. Cache align 16 long.
*/
- bmr = (lp->chipset==DC21140 ? PBL_8 : PBL_4) | DESC_SKIP_LEN | CACHE_ALIGN;
+ bmr = (lp->chipset==DC21140 ? PBL_8 : PBL_4) | DESC_SKIP_LEN | DE4X5_CACHE_ALIGN;
bmr |= ((lp->chipset & ~0x00ff)==DC2114x ? BMR_RML : 0);
outl(bmr, DE4X5_BMR);
@@ -2050,7 +2049,7 @@
u_long iobase = dev->base_addr;
int i, j, bit, byte;
u16 hashcode;
- u32 omr, crc, poly = CRC_POLYNOMIAL_LE;
+ u32 omr, crc;
char *pa;
unsigned char *addrs;
@@ -2065,13 +2064,7 @@
addrs=dmi->dmi_addr;
dmi=dmi->next;
if ((*addrs & 0x01) == 1) { /* multicast address? */
- crc = 0xffffffff; /* init CRC for each address */
- for (byte=0;byte<ETH_ALEN;byte++) {/* for each address byte */
- /* process each address bit */
- for (bit = *addrs++,j=0;j<8;j++, bit>>=1) {
- crc = (crc >> 1) ^ (((crc ^ bit) & 0x01) ? poly : 0);
- }
- }
+ crc = ether_crc_le(ETH_ALEN, addrs);
hashcode = crc & HASH_BITS; /* hashcode is 9 LSb of CRC */
byte = hashcode >> 3; /* bit[3-8] -> byte in filter */
@@ -2112,7 +2105,7 @@
u_short vendor;
u32 cfid;
u_long iobase;
- struct bus_type *lp = &bus;
+ struct de4x5_bus_type *lp = &bus;
char name[DE4X5_STRLEN];
if (lastEISA == MAX_EISA_SLOTS) return;/* No more EISA devices to search */
@@ -2193,7 +2186,7 @@
u_short vendor, index, status;
u_int irq = 0, device, class = DE4X5_CLASS_CODE;
u_long iobase = 0; /* Clear upper 32 bits in Alphas */
- struct bus_type *lp = &bus;
+ struct de4x5_bus_type *lp = &bus;
if (lastPCI == NO_MORE_PCI) return;
@@ -2306,7 +2299,7 @@
u_int irq = 0, device;
u_long iobase = 0; /* Clear upper 32 bits in Alphas */
int i, j;
- struct bus_type *lp = &bus;
+ struct de4x5_bus_type *lp = &bus;
struct list_head *walk = &dev->bus_list;
for (walk = walk->next; walk != &dev->bus_list; walk = walk->next) {
@@ -3645,12 +3638,12 @@
struct sk_buff *ret;
u_long i=0, tmp;
- p = dev_alloc_skb(IEEE802_3_SZ + ALIGN + 2);
+ p = dev_alloc_skb(IEEE802_3_SZ + DE4X5_ALIGN + 2);
if (!p) return NULL;
p->dev = dev;
tmp = virt_to_bus(p->data);
- i = ((tmp + ALIGN) & ~ALIGN) - tmp;
+ i = ((tmp + DE4X5_ALIGN) & ~DE4X5_ALIGN) - tmp;
skb_reserve(p, i);
lp->rx_ring[index].buf = cpu_to_le32(tmp + i);
@@ -3999,7 +3992,7 @@
** Look for a particular board name in the PCI configuration space
*/
static int
-PCI_signature(char *name, struct bus_type *lp)
+PCI_signature(char *name, struct de4x5_bus_type *lp)
{
static c_char *de4x5_signatures[] = DE4X5_SIGNATURE;
int i, status = 0, siglen = sizeof(de4x5_signatures)/sizeof(c_char *);
@@ -4048,7 +4041,7 @@
DevicePresent(u_long aprom_addr)
{
int i, j=0;
- struct bus_type *lp = &bus;
+ struct de4x5_bus_type *lp = &bus;
if (lp->chipset == DC21040) {
if (lp->bus == EISA) {
@@ -4129,7 +4122,7 @@
u_long iobase = dev->base_addr;
int broken, i, k, tmp, status = 0;
u_short j,chksum;
- struct bus_type *lp = &bus;
+ struct de4x5_bus_type *lp = &bus;
broken = de4x5_bad_srom(lp);
@@ -4210,7 +4203,7 @@
** didn't seem to work here...?
*/
static int
-de4x5_bad_srom(struct bus_type *lp)
+de4x5_bad_srom(struct de4x5_bus_type *lp)
{
int i, status = 0;
@@ -4244,7 +4237,7 @@
static void
srom_repair(struct net_device *dev, int card)
{
- struct bus_type *lp = &bus;
+ struct de4x5_bus_type *lp = &bus;
switch(card) {
case SMC:
@@ -4265,7 +4258,7 @@
static int
test_bad_enet(struct net_device *dev, int status)
{
- struct bus_type *lp = &bus;
+ struct de4x5_bus_type *lp = &bus;
int i, tmp;
for (tmp=0,i=0; i<ETH_ALEN; i++) tmp += (u_char)dev->dev_addr[i];
@@ -4298,7 +4291,7 @@
** List of board exceptions with correctly wired IRQs
*/
static int
-an_exception(struct bus_type *lp)
+an_exception(struct de4x5_bus_type *lp)
{
if ((*(u_short *)lp->srom.sub_vendor_id == 0x00c0) &&
(*(u_short *)lp->srom.sub_system_id == 0x95e0)) {
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)