From owner-freebsd-current@FreeBSD.ORG Thu Jun 3 08:54:56 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B523816A4CF for ; Thu, 3 Jun 2004 08:54:56 -0700 (PDT) Received: from mail-in-01.arcor-online.net (mail-in-01.arcor-online.net [151.189.21.41]) by mx1.FreeBSD.org (Postfix) with ESMTP id EE7C943D45 for ; Thu, 3 Jun 2004 08:54:55 -0700 (PDT) (envelope-from mailnull@mips.inka.de) Received: from kemoauc.mips.inka.de (dsl-213-023-058-089.arcor-ip.net [213.23.58.89]) by mail-in-01.arcor-online.net (Postfix) with ESMTP id 56607C0042F for ; Thu, 3 Jun 2004 17:54:54 +0200 (CEST) Received: from kemoauc.mips.inka.de (localhost [127.0.0.1]) i53Fsr8C087435 for ; Thu, 3 Jun 2004 17:54:53 +0200 (CEST) (envelope-from mailnull@kemoauc.mips.inka.de) Received: (from mailnull@localhost) by kemoauc.mips.inka.de (8.12.11/8.12.11/Submit) id i53FsrS8087434 for freebsd-current@freebsd.org; Thu, 3 Jun 2004 17:54:53 +0200 (CEST) (envelope-from mailnull) From: naddy@mips.inka.de (Christian Weisgerber) Date: Thu, 3 Jun 2004 15:54:52 +0000 (UTC) Message-ID: References: <20040603012501.GA5035@thingy.tbd.co.nz> <20040603140245.GA79548@kemoauc.mips.inka.de> <20040603142944.GJ9228@elvis.mu.org> Originator: naddy@mips.inka.de (Christian Weisgerber) To: freebsd-current@freebsd.org Subject: Re: Network driver jumbo patch (affects multicast) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Jun 2004 15:54:56 -0000 Maxime Henrion wrote: > I tend to disagree, I find this comment a valuable technical information. If you guys feel strongly about this, we can preserve it. Index: pci/if_xl.c =================================================================== RCS file: /home/ncvs/src/sys/pci/if_xl.c,v retrieving revision 1.170 diff -u -r1.170 if_xl.c --- pci/if_xl.c 30 May 2004 20:00:41 -0000 1.170 +++ pci/if_xl.c 3 Jun 2004 15:36:34 -0000 @@ -253,7 +253,6 @@ static void xl_setcfg (struct xl_softc *); static void xl_setmode (struct xl_softc *, int); -static uint32_t xl_mchash (const uint8_t *); static void xl_setmulti (struct xl_softc *); static void xl_setmulti_hash (struct xl_softc *); static void xl_reset (struct xl_softc *); @@ -812,44 +811,6 @@ } /* - * This routine is taken from the 3Com Etherlink XL manual, - * page 10-7. It calculates a CRC of the supplied multicast - * group address and returns the lower 8 bits, which are used - * as the multicast filter position. - * Note: the 3c905B currently only supports a 64-bit hash table, - * which means we really only need 6 bits, but the manual indicates - * that future chip revisions will have a 256-bit hash table, - * hence the routine is set up to calculate 8 bits of position - * info in case we need it some day. - * Note II, The Sequel: _CURRENT_ versions of the 3c905B have a - * 256 bit hash table. This means we have to use all 8 bits regardless. - * On older cards, the upper 2 bits will be ignored. Grrrr.... - */ -static u_int32_t -xl_mchash(addr) - const uint8_t *addr; -{ - uint32_t crc, carry; - int idx, bit; - uint8_t data; - - /* Compute CRC for the address value. */ - crc = 0xFFFFFFFF; /* initial value */ - - for (idx = 0; idx < 6; idx++) { - for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1) { - carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01); - crc <<= 1; - if (carry) - crc = (crc ^ 0x04c11db6) | carry; - } - } - - /* return the filter bit position */ - return(crc & 0x000000FF); -} - -/* * NICs older than the 3c905B have only one multicast option, which * is to enable reception of all multicast frames. */ @@ -920,7 +881,20 @@ TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { if (ifma->ifma_addr->sa_family != AF_LINK) continue; - h = xl_mchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); + /* + * Note: the 3c905B currently only supports a 64-bit hash + * table, which means we really only need 6 bits, but the + * manual indicates that future chip revisions will have a + * 256-bit hash table, hence the routine is set up to + * calculate 8 bits of position info in case we need it some + * day. + * Note II, The Sequel: _CURRENT_ versions of the 3c905B have + * a 256 bit hash table. This means we have to use all 8 bits + * regardless. On older cards, the upper 2 bits will be + * ignored. Grrrr.... + */ + h = ether_crc32_be(LLADDR((struct sockaddr_dl *) + ifma->ifma_addr), ETHER_ADDR_LEN) & 0xFF; CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_RX_SET_HASH|XL_HASH_SET|h); mcnt++; } -- Christian "naddy" Weisgerber naddy@mips.inka.de