patch-1.3.46 linux/drivers/net/de4x5.c

Next file: linux/drivers/net/ppp.c
Previous file: linux/drivers/net/arcnet.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.45/linux/drivers/net/de4x5.c linux/drivers/net/de4x5.c
@@ -435,7 +435,7 @@
 /*static void    srom_busy(u_int command, u_long address);*/
 static void    sendto_srom(u_int command, u_long addr);
 static int     getfrom_srom(u_long addr);
-static void    SetMulticastFilter(struct device *dev, int num_addrs, char *addrs);
+static void    SetMulticastFilter(struct device *dev);
 static int     get_hw_addr(struct device *dev);
 
 static void    eisa_probe(struct device *dev, u_long iobase);
@@ -901,7 +901,7 @@
   barrier();
 
   /* Build the setup frame depending on filtering mode */
-  SetMulticastFilter(dev, 0, NULL);
+  SetMulticastFilter(dev);
 
   if (lp->chipset != DC21140) {
     load_packet(dev, lp->setup_frame, HASH_F|TD_SET|SETUP_FRAME_LEN, NULL);
@@ -1386,40 +1386,33 @@
 static void
 set_multicast_list(struct device *dev)
 {
-	struct de4x5_private *lp = (struct de4x5_private *)dev->priv;
-	u_long iobase = dev->base_addr;
+  struct de4x5_private *lp = (struct de4x5_private *)dev->priv;
+  u_long iobase = dev->base_addr;
 
-	/* First, double check that the adapter is open */
-	if (irq2dev_map[dev->irq] != NULL) 
-	{
-		if (num_addrs >= 0) 
-		{
-		   	SetMulticastFilter(dev);
-			if (lp->setup_f == HASH_PERF) 
-			{
-				load_packet(dev, lp->setup_frame, TD_IC | HASH_F | TD_SET | 
+  /* First, double check that the adapter is open */
+  if (irq2dev_map[dev->irq] != NULL) {
+    if (dev->flags & IFF_PROMISC) {         /* set promiscuous mode */
+      u32 omr;
+      omr = inl(DE4X5_OMR);
+      omr |= OMR_PR;
+      outl(omr, DE4X5_OMR);
+    } else { 
+      SetMulticastFilter(dev);
+      if (lp->setup_f == HASH_PERF) {
+	load_packet(dev, lp->setup_frame, TD_IC | HASH_F | TD_SET | 
 		                                        SETUP_FRAME_LEN, NULL);
-      			}
-      			else
-      			{
-				load_packet(dev, lp->setup_frame, TD_IC | PERFECT_F | TD_SET | 
+      } else {
+	load_packet(dev, lp->setup_frame, TD_IC | PERFECT_F | TD_SET | 
 		                                        SETUP_FRAME_LEN, NULL);
-			}
+      }
+      
+      lp->tx_new = (++lp->tx_new) % lp->txRingSize;
+      outl(POLL_DEMAND, DE4X5_TPD);                /* Start the TX */
+      dev->trans_start = jiffies;
+    }
+  }
 
-			lp->tx_new = (++lp->tx_new) % lp->txRingSize;
-			outl(POLL_DEMAND, DE4X5_TPD);                /* Start the TX */
-			dev->trans_start = jiffies;
-		}
-		else
-		{ 
-			/* set promiscuous mode */
-			u32 omr;
-			omr = inl(DE4X5_OMR);
-			omr |= OMR_PR;
-			outl(omr, DE4X5_OMR);
-		}
-	}
-	return;
+  return;
 }
 
 /*
@@ -1439,76 +1432,49 @@
   unsigned char *addrs;
 
   omr = inl(DE4X5_OMR);
+  omr &= ~OMR_PR;
   pa = build_setup_frame(dev, ALL);          /* Build the basic frame */
 
-  if (lp->setup_f == HASH_PERF) 
-  {
-  	if (num_addrs >= HASH_TABLE_LEN || (dev->flags&IFF_ALLMULTI)) 
-  	{
-  		/* Pass all multicasts */
-     		omr |= OMR_PM;
-	}
-	else
-	{
-		omr &= ~OMR_PM;
+  if ((dev->flags & IFF_ALLMULTI) || (dev->mc_count > 14)) {
+    omr |= OMR_PM;                           /* Pass all multicasts */
+  } else if (lp->setup_f == HASH_PERF) {
                                              /* Now update the MCA table */
-		for (i=0;i<num_addrs;i++) 
-		{     
-			/* for each address in the list */
-			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);
-					}
-				}
-				hashcode = crc & HASH_BITS;        /* hashcode is 9 LSb of CRC */
-
-				byte = hashcode >> 3;              /* bit[3-8] -> byte in filter */
-				bit = 1 << (hashcode & 0x07);      /* bit[0-2] -> bit in byte */
-
-				byte <<= 1;                        /* calc offset into setup frame */
-				if (byte & 0x02) 
-				{
-					byte -= 1;
-				}
-				lp->setup_frame[byte] |= bit;
-	  
-			}
-			else
-			{                             /* skip this address */
-				addrs += ETH_ALEN;
-			}
-		}
+    for (i=0;i<dev->mc_count;i++) {          /* for each address in the list */
+      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);
+	  }
 	}
-	else
-	{                                   /* Perfect filtering */
-		omr &= ~OMR_PM;
-		for (j=0; j<dev->mc_count; j++) 
-		{
-			addrs=dmi->dmi_addr;
-			dmi=dmi->next;
-			for (i=0; i<ETH_ALEN; i++) 
-			{ 
-				*(pa + (i&1)) = *addrs++;
-				if (i & 0x01) pa += 4;
-			}
-		}
+	hashcode = crc & HASH_BITS;          /* hashcode is 9 LSb of CRC */
+	
+	byte = hashcode >> 3;                /* bit[3-8] -> byte in filter */
+	bit = 1 << (hashcode & 0x07);        /* bit[0-2] -> bit in byte */
+	
+	byte <<= 1;                          /* calc offset into setup frame */
+	if (byte & 0x02) {
+	  byte -= 1;
 	}
+	lp->setup_frame[byte] |= bit;
+      }
+    }
+  } else {                                   /* Perfect filtering */
+    for (j=0; j<dev->mc_count; j++) {
+      addrs=dmi->dmi_addr;
+      dmi=dmi->next;
+      for (i=0; i<ETH_ALEN; i++) { 
+	*(pa + (i&1)) = *addrs++;
+	if (i & 0x01) pa += 4;
+      }
+    }
+  }
+  outl(omr, DE4X5_OMR);
 
-	if (dev->mc_count == 0)
-		omr &= ~OMR_PR;
-	outl(omr, DE4X5_OMR);
-
-	return;
+  return;
 }
 
 /*
@@ -2616,10 +2582,10 @@
       if (ioc->len != HASH_TABLE_LEN) {         /* MCA changes */
 	if (!(status = verify_area(VERIFY_READ, (void *)ioc->data, ETH_ALEN * ioc->len))) {
 	  memcpy_fromfs(tmp.addr, ioc->data, ETH_ALEN * ioc->len);
-	  set_multicast_list(dev, ioc->len, tmp.addr);
+	  set_multicast_list(dev);
 	}
       } else {
-	set_multicast_list(dev, ioc->len, NULL);
+	set_multicast_list(dev);
       }
     } else {
       status = -EPERM;
@@ -2628,7 +2594,7 @@
     break;
   case DE4X5_CLR_MCA:                /* Clear all multicast addresses */
     if (suser()) {
-      set_multicast_list(dev, 0, NULL);
+      set_multicast_list(dev);
     } else {
       status = -EPERM;
     }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this