Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Nov 2001 00:20:35 +0000
From:      Scott Mitchell <scott.mitchell@mail.com>
To:        freebsd-mobile@freebsd.org
Subject:   Xircom Ethernet driver patch for CE2 & CEM33
Message-ID:  <20011119002035.B30992@localhost>

next in thread | raw e-mail | index | archive | help

--5vNYLRcllDrimb99
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: 8bit

Hi all,

The attached patch (against -STABLE or anything close to it; these files
haven't changed for ages) is hopefully a long-overdue fix to the support
for CE2, CEM28 and CEM33 cards in the xe driver.  Specifically:

  - Most, if not all, CE2 cards should now be probed correctly
  - Some changes supplied by Peter Fürst to prevent the driver becoming
    confused about the number of bytes to send, and not sending any
  - A few other minor tweaks

Peter also informed me of some restrictions in the memory ranges and I/O
addresses supported by the CEM33 (this may be true for the CE2 and CEM28 as
well).  He says:

>There are restrictions on IO addresses and memory range, as
>the Xircom CEM33 readme, Release 1.21, July 9, 1998 says:
>
>  -The CreditCard Ethernet+Modem 33.6 does not support the memory
>   range D000-D0FF.
>
>  -On some machines D600-D6FF is not supported.
>
>  -The CreditCard Ethernet+Modem 33.6 supports only "even" IO addresses
>   (example: 240, 260, 280, 300, 320, 340, 360).  If you use an "odd" IO
>   address (example: 310, 330, 250), the adapter will fail to initialize.

It may be worthwhile fixing your pccard.conf to match these restrictions if
your card isn't being configured correctly.

Question: is there any way to enforce these restrictions from within the
driver?  The CIS on these cards doesn't appear to give any indication that
these addresses are not allowed.

To apply the patch:

	patch -p < xe_drv-20011118.patch

Then rebuild your kernel, reboot and see what happens.  The patch turns on
some more debugging output from the driver, so expect more verbose messages
than usual.  It may also be worthwhile running pccardd manually with the -d
flag if there are problems configuring the card.

I don't have a CE2 card, so I can't verify that these changes will do any
good at all... however, it still works with my CE3 so I don't think I've
made anything worse :-)

Please let me know if this works or not, whatever variety of Xircom card
you're using.  If it doesn't work, please include relevant messages,
'pccardc dumpcis' output and pccard.conf file.

A fix for the broken xe multicast code is coming soon...

	Scott

-- 
===========================================================================
Scott Mitchell          | PGP Key ID | "Eagles may soar, but weasels
Cambridge, England      | 0x54B171B9 |  don't get sucked into jet engines"
scott.mitchell@mail.com | 0xAA775B8B |      -- Anon

--5vNYLRcllDrimb99
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="xe_drv-20011118.patch"

*** /sys/dev/xe/if_xe.c.orig	Fri Jul 21 23:38:24 2000
--- /sys/dev/xe/if_xe.c	Sun Nov 18 21:46:30 2001
***************
*** 1,5 ****
  /*-
!  * Copyright (c) 1998, 1999 Scott Mitchell
   * All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
--- 1,5 ----
  /*-
!  * Copyright (c) 1998-2001 Scott Mitchell
   * All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
***************
*** 23,29 ****
   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   *
-  *	$Id: if_xe.c,v 1.20 1999/06/13 19:17:40 scott Exp $
   * $FreeBSD: src/sys/dev/xe/if_xe.c,v 1.13.2.5 2000/07/21 22:38:24 imp Exp $
   */
  
--- 23,28 ----
***************
*** 90,97 ****
   *
   * Thanks to all who assisted with the development and testing of the driver,
   * especially: Werner Koch, Duke Kamstra, Duncan Barclay, Jason George, Dru
!  * Nelson, Mike Kephart, Bill Rainey and Douglas Rand.  Apologies if I've left
!  * out anyone who deserves a mention here.
   *
   * Special thanks to Ade Lovett for both hosting the mailing list and doing
   * the CEM56/REM56 support code; and the FreeBSD UK Users' Group for hosting
--- 89,96 ----
   *
   * Thanks to all who assisted with the development and testing of the driver,
   * especially: Werner Koch, Duke Kamstra, Duncan Barclay, Jason George, Dru
!  * Nelson, Mike Kephart, Bill Rainey, Douglas Rand and DocWilco.
!  * Apologies if I've left out anyone who deserves a mention here.
   *
   * Special thanks to Ade Lovett for both hosting the mailing list and doing
   * the CEM56/REM56 support code; and the FreeBSD UK Users' Group for hosting
***************
*** 100,109 ****
   * Contact points:
   *
   * Driver web page: http://ukug.uk.freebsd.org/~scott/xe_drv/
-  *
-  * Mailing list: http://www.lovett.com/lists/freebsd-xircom/
-  * or send "subscribe freebsd-xircom" to <majordomo@lovett.com>
-  *
   * Author email: <scott@uk.freebsd.org>
   */
  
--- 99,104 ----
***************
*** 202,210 ****
  static void      xe_phy_writereg	(struct xe_softc *scp, u_int16_t reg, u_int16_t data);
  
  /*
!  * Debug functions -- uncomment for VERY verbose dignostic information.
   * Set to 1 for less verbose information
   */
  /* #define XE_DEBUG 2 */
  #ifdef XE_DEBUG
  #define XE_REG_DUMP(scp)		xe_reg_dump((scp))
--- 197,207 ----
  static void      xe_phy_writereg	(struct xe_softc *scp, u_int16_t reg, u_int16_t data);
  
  /*
!  * Debug functions -- uncomment the first line for extra debug output,
!  * uncomment the second for VERY verbose diagnostic information.
   * Set to 1 for less verbose information
   */
+ #define XE_DEBUG 1
  /* #define XE_DEBUG 2 */
  #ifdef XE_DEBUG
  #define XE_REG_DUMP(scp)		xe_reg_dump((scp))
***************
*** 331,337 ****
  #endif
        for (i = 0; i < CISTPL_LEN(buf); ver_str[i] = CISTPL_DATA(buf, i++));
        ver_str[i] = '\0';
-       ver_str[(CISTPL_BUFSIZE>>1) - 1] = CISTPL_LEN(buf);
        success++;
        break;
  
--- 328,333 ----
***************
*** 443,458 ****
  
    /* Check for certain strange CE2's that look like CE's */
    if (strcmp(scp->card_type, "CE") == 0) {
!     u_char *str = ver_str;
  #if XE_DEBUG > 1
      device_printf(dev, "Checking for weird CE2 string\n");
  #endif
      str += strlen(str) + 1;			/* Skip forward to 3rd version string */
      str += strlen(str) + 1;
-     str += strlen(str) + 1;
      for (i = 0; i < strlen(str) - 2; i++) {
        if (bcmp(&str[i], "CE2", 3) ==0) {	/* Look for "CE2" string */
  	scp->card_type = "CE2";
        }
      }
    }
--- 439,454 ----
  
    /* Check for certain strange CE2's that look like CE's */
    if (strcmp(scp->card_type, "CE") == 0) {
!       u_char *str = ver_str + 2;		/* Skip over version bytes */
  #if XE_DEBUG > 1
      device_printf(dev, "Checking for weird CE2 string\n");
  #endif
      str += strlen(str) + 1;			/* Skip forward to 3rd version string */
      str += strlen(str) + 1;
      for (i = 0; i < strlen(str) - 2; i++) {
        if (bcmp(&str[i], "CE2", 3) ==0) {	/* Look for "CE2" string */
  	scp->card_type = "CE2";
+ 	scp->ce2 = 1;
        }
      }
    }
***************
*** 684,689 ****
--- 680,686 ----
     * Loop while there are packets to be sent, and space to send them.
     */
    while (1) {
+     int busy;
      IF_DEQUEUE(&ifp->if_snd, mbp);	/* Suck a packet off the send queue */
  
      if (mbp == NULL) {
***************
*** 698,704 ****
        return;
      }
  
!     if (xe_pio_write_packet(scp, mbp) != 0) {
        IF_PREPEND(&ifp->if_snd, mbp);	/* Push the packet back onto the queue */
        ifp->if_flags |= IFF_OACTIVE;
        return;
--- 695,712 ----
        return;
      }
  
!     if ( (busy = xe_pio_write_packet(scp, mbp)) ) {
!       if (!scp->tx_queued) {
!         /*
!          * No space available, although nothing is queued ?
!          * This suggests that initialization was not complete,
!          * so we do an immediate reset and try again. (CEM33)
!          */
!         xe_watchdog(ifp);
!         busy = xe_pio_write_packet(scp, mbp);
!       }
!     }
!     if (busy) {
        IF_PREPEND(&ifp->if_snd, mbp);	/* Push the packet back onto the queue */
        ifp->if_flags |= IFF_OACTIVE;
        return;
***************
*** 828,834 ****
     * Read ISR to see what caused this interrupt.  Note that this clears the
     * ISR on CE2 type cards.
     */
!   if ((isr = XE_INB(XE_ISR)) && isr != 0xff) {
  
      result = 1;			/* This device did generate an int */
      esr = XE_INB(XE_ESR);	/* Read the other status registers */
--- 836,842 ----
     * Read ISR to see what caused this interrupt.  Note that this clears the
     * ISR on CE2 type cards.
     */
!   if ((isr = XE_INB(XE_ISR)) != 0xff) {
  
      result = 1;			/* This device did generate an int */
      esr = XE_INB(XE_ESR);	/* Read the other status registers */
***************
*** 910,915 ****
--- 918,925 ----
      if (txs & 0x0040)		/* Transmit aborted -- probably collisions */
        scp->tx_collisions++;
  
+     if (txs & XE_TXST0_TX_UNDERRUN)	/* make the transmitter work again (CEM33) */
+       XE_OUTB(XE_CR, XE_CR_RESTART_TX);
  
      /*
       * Handle receive interrupts 
***************
*** 1703,1708 ****
--- 1713,1727 ----
    /* Get total packet length */
    for (len = 0, mbp2 = mbp; mbp2 != NULL; len += mbp2->m_len, mbp2 = mbp2->m_next);
  
+   /*
+    * For the CEM33 (all CE2 cards ?) the number of packet-bytes written must
+    * exactly match the packet-length sent to the card.  The easiest way to
+    * achieve this, is to increase "len" to the next even value just here
+    * (supposed ETHER_MIN_LEN-ETHER_CRC_LEN is even).
+    */
+   if (len & 1)
+     ++len;
+ 
    /* Packets < minimum length may need to be padded out */
    pad = 0;
    if (len < ETHER_MIN_LEN - ETHER_CRC_LEN) {
***************
*** 1757,1762 ****
--- 1776,1784 ----
     * For CE3 cards, just tell 'em to send -- apparently the card will pad out
     * short packets with random cruft.  Otherwise, write nonsense words to fill 
     * out the packet.  I guess it is then sent automatically (?)
+    * Yes, the CE2 appears to count the bytes written and start transmission
+    * when it has received "len" bytes, XE_CR_TX_PACKET being a NOP. (And any
+    * following two bytes will be interpreted as a new "len" and so on...)
     */
    if (scp->mohawk)
      XE_OUTB(XE_CR, XE_CR_TX_PACKET|XE_CR_ENABLE_INTR);

--5vNYLRcllDrimb99--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-mobile" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011119002035.B30992>