Changeset 811115de in rtems


Ignore:
Timestamp:
Feb 2, 1999, 4:28:42 PM (20 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
9b9c4dfd
Parents:
14faf00
Message:

Added debug print routines for TX and RX descriptors.

Fixed bug where only the mbuf associated with the first TX fragment was
being freed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/powerpc/dmv177/sonic/sonic.c

    r14faf00 r811115de  
    3131 */
    3232
     33#include <bsp.h>   /* XXX JRS changed order */
     34#include "sonic.h"
    3335#include <rtems/rtems_bsdnet.h>
    34 #include "sonic.h"
    3536
    3637#include <stdio.h>
     
    5556 */
    5657
    57 #define SONIC_DEBUG_NONE             0x0000
    58 #define SONIC_DEBUG_ALL              0xFFFF
    59 #define SONIC_DEBUG_PRINT_REGISTERS  0x0001
    60 #define SONIC_DEBUG_MEMORY           0x0002
    61 #define SONIC_DEBUG_MEMORY_ALLOCATE  0x0004
    62 #define SONIC_DEBUG_FRAGMENTS        0x0008
    63 #define SONIC_DEBUG_CAM              0x0008
    64 #define SONIC_DEBUG_DESCRIPTORS      0x0010
    65 #define SONIC_DEBUG_ERRORS           0x0020
    66 #define SONIC_DEBUG_DUMP_TX_MBUFS    0x0040
    67 #define SONIC_DEBUG_DUMP_RX_MBUFS    0x0080
     58#define SONIC_DEBUG_NONE                0x0000
     59#define SONIC_DEBUG_ALL                 0xFFFF
     60#define SONIC_DEBUG_PRINT_REGISTERS     0x0001
     61#define SONIC_DEBUG_MEMORY              0x0002
     62#define SONIC_DEBUG_MEMORY_ALLOCATE     0x0004
     63#define SONIC_DEBUG_MEMORY_DESCRIPTORS  0x0008
     64#define SONIC_DEBUG_FRAGMENTS           0x0008
     65#define SONIC_DEBUG_CAM                 0x0010
     66#define SONIC_DEBUG_DESCRIPTORS         0x0020
     67#define SONIC_DEBUG_ERRORS              0x0040
     68#define SONIC_DEBUG_DUMP_TX_MBUFS       0x0080
     69#define SONIC_DEBUG_DUMP_RX_MBUFS       0x0100
    6870
    6971#define SONIC_DEBUG_DUMP_MBUFS \
    7072  (SONIC_DEBUG_DUMP_TX_MBUFS|SONIC_DEBUG_DUMP_RX_MBUFS)
    7173
    72 #define SONIC_DEBUG_MEDIUM \
     74#define SONIC_DEBUG  (SONIC_DEBUG_ERRORS)
     75
     76/*
    7377  ((SONIC_DEBUG_ALL) & ~(SONIC_DEBUG_PRINT_REGISTERS|SONIC_DEBUG_DUMP_MBUFS))
    74   /*
    7578  ((SONIC_DEBUG_ALL) & ~(SONIC_DEBUG_DUMP_MBUFS))
    7679*/
    7780
    78 #define SONIC_DEBUG  SONIC_DEBUG_ALL
    79 
    80 /* ((SONIC_DEBUG_ALL) & ~SONIC_DEBUG_PRINT_REGISTERS)  */
    81   /* (SONIC_DEBUG_ALL) */
    82 
    83 /* (SONIC_DEBUG_ALL) */
    84 /* (SONIC_DEBUG_ERRORS) */
    85 
    86 /* (SONIC_DEBUG_MEMORY|SONIC_DEBUG_DESCRIPTORS) */
    8781
    8882#if (SONIC_DEBUG & SONIC_DEBUG_DUMP_MBUFS)
     
    157151 * Default sizes of transmit and receive descriptor areas
    158152 */
    159 #define RDA_COUNT     20
    160 #define TDA_COUNT     10
     153#define RDA_COUNT     20 /* 20 */
     154#define TDA_COUNT     10 /* 10 */
    161155
    162156/*
     
    164158 * As suggested by National Application Note 746, make the
    165159 * receive resource area bigger than the receive descriptor area.
     160 *
     161 * NOTE:  Changing this may break this driver since it currently
     162 *        assumes a 1<->1 mapping.
    166163 */
    167164#define RRA_EXTRA_COUNT  0
     
    189186 */
    190187#define RBUF_SIZE  ((sizeof (void *) + (MAXIMUM_FRAME_SIZE) + 3) & ~3)
    191 #define RBUF_WC    ((((MAXIMUM_FRAME_SIZE) + 3) & ~3) / 2)
     188/* #define RBUF_WC    ((((MAXIMUM_FRAME_SIZE) + 3) & ~3) / 2) */
     189#define RBUF_WC    (RBUF_SIZE / 2)
    192190
    193191/*
     
    214212   */
    215213  void                             *sonic;
    216 
    217   /*
    218    *  Tables to map the mbufs from chip to stack
    219    */
    220 
    221   struct mbuf             **rxMbuf;
    222   struct mbuf             **txMbuf;
    223214
    224215  /*
     
    281272SONIC_STATIC struct sonic_softc sonic_softc[NSONIC];
    282273
     274
     275/*
     276 ******************************************************************
     277 *                                                                *
     278 *                         Debug Routines                         *
     279 *                                                                *
     280 ******************************************************************
     281 */
     282
     283#if (SONIC_DEBUG & SONIC_DEBUG_MEMORY_DESCRIPTORS)
     284void sonic_print_tx_descriptor(
     285  TransmitDescriptorPointer_t tdp
     286)
     287{
     288  printf( "TXD ==> %p", tdp );
     289  printf( "  pkt_config = 0x%04x", tdp->pkt_config & 0xffff);
     290  printf( "  pkt_size = 0x%04x\n", tdp->pkt_size & 0xffff );
     291  printf( "  frag_count = %d", tdp->frag_count & 0xffff );
     292  /* could print all the fragments */
     293  printf( "  next = %p", tdp->next );
     294  printf( "  linkp = %p\n", tdp->linkp );
     295  printf( "  mbufp = %p", tdp->mbufp );
     296  if ( tdp->mbufp )
     297    printf( "  mbufp->data = %p", mtod ( tdp->mbufp, void *) );
     298  puts("");
     299}
     300
     301void sonic_print_rx_descriptor(
     302  ReceiveDescriptorPointer_t rdp
     303)
     304{
     305  printf( "RXD ==> %p\n", rdp );
     306  printf( "  status = 0x%04x", rdp->status & 0xffff );
     307  printf( "  byte_count = 0x%04x\n", rdp->byte_count & 0xffff );
     308  printf( "  pkt = 0x%04x%04x", rdp->pkt_msw, rdp->pkt_lsw );
     309  printf( "  seq_no = %d", rdp->seq_no );
     310  printf( "  link = %d\n", rdp->link );
     311  printf( "  in_use = %d", rdp->in_use );
     312  printf( "  next = %p", rdp->next );
     313  printf( "  mbufp = %p", rdp->mbufp );
     314  if ( rdp->mbufp )
     315    printf( "  mbufp->data = %p", mtod ( rdp->mbufp, void *) );
     316  puts("");
     317}
     318#endif
     319
    283320/*
    284321 ******************************************************************
     
    476513#if (SONIC_DEBUG & SONIC_DEBUG_ERRORS)
    477514    if ( status != 0x0001 )
    478       printf( "ERROR: retire TDA %p (0x%04x)\n", sc->tdaTail, status );
     515      printf( "ERROR: retire TDA %p (0x%08x)\n",
     516                sc->tdaTail, sc->tdaTail->status );
    479517#endif
    480518
     
    529567     */
    530568    sc->tdaActiveCount--;
    531     m = (struct mbuf *)&sc->tdaTail->mbufp;
    532     MFREE(m, n);
     569    m = sc->tdaTail->mbufp;
     570    while ( m ) {
     571      MFREE(m, n);
     572      m = n;
     573    }
    533574
    534575    sc->tdaTail->frag[0].frag_link = LSW(sc->tdaTail->link_pad);
     
    888929  ReceiveResourcePointer_t rwp, rea;
    889930  rtems_unsigned16 newMissedTally, oldMissedTally;
    890   unsigned32 rxMbufIndex;
    891931
    892932  rwp = sc->rsa;
     
    902942   * Input packet handling loop
    903943   */
    904   rxMbufIndex = 0;
    905944  for (;;) {
    906945    /*
     
    931970       * Invalidate cache entries for this memory.
    932971       */
     972#if (SONIC_DEBUG & SONIC_DEBUG_MEMORY_DESCRIPTORS)
     973      sonic_print_rx_descriptor( rdp );
     974#endif
    933975      m = rdp->mbufp;
    934976      m->m_len = m->m_pkthdr.len = rdp->byte_count -
     
    9631005       */
    9641006
    965       m= (void *)0xA0000000; /* hope for a fault :) */
    9661007      MGETHDR (m, M_WAIT, MT_DATA);
    9671008      MCLGET (m, M_WAIT);
     
    10601101 
    10611102  /*
    1062    *  Allocate memory so we can figure out from the descriptor which
    1063    *  mbuf to send to the stack.
    1064    */
    1065 
    1066   sc->txMbuf = malloc (sc->tdaCount * sizeof *sc->txMbuf, M_MBUF, M_NOWAIT);
    1067   if (!sc->txMbuf)
    1068      rtems_panic ("No memory for TX mbuf pointers");
    1069 
    1070   sc->rxMbuf = malloc (sc->rdaCount * sizeof *sc->rxMbuf, M_MBUF, M_NOWAIT);
    1071   if (!sc->rxMbuf)
    1072      rtems_panic ("No memory for RX mbuf pointers");
    1073 
    1074   /*
    10751103   *  Set up circular linked list in Transmit Descriptor Area.
    10761104   *  Use the PINT bit in the transmit configuration field to
     
    10901118     *  Start off with the table of outstanding mbuf's
    10911119     */
    1092     sc->txMbuf[i] = NULL;
    10931120
    10941121    /*
     
    11071134    tdp->linkp             = &((tdp + 1)->frag[0].frag_link);
    11081135    tdp->next              = (TransmitDescriptor_t *)(tdp + 1);
     1136#if (SONIC_DEBUG & SONIC_DEBUG_MEMORY_DESCRIPTORS)
     1137    sonic_print_tx_descriptor( tdp );
     1138#endif
    11091139    tdp++;
    11101140  }
     
    11831213    MCLGET (m, M_WAIT);
    11841214    m->m_pkthdr.rcvif = &sc->arpcom.ac_if;
    1185     sc->rxMbuf[i] = m;
    11861215    sc->rda[i].mbufp = m;
    11871216
     
    11951224    rwp->buff_wc_lsw = RBUF_WC;
    11961225    rwp->buff_wc_msw = 0;
     1226#if (SONIC_DEBUG & SONIC_DEBUG_MEMORY_DESCRIPTORS)
     1227    sonic_print_rx_descriptor( &sc->rda[i] );
     1228#endif
    11971229  }
    11981230  sc->rea = rwp;
     
    16241656};
    16251657#endif
    1626 void sonic_write_register(
     1658
     1659inline void sonic_write_register(
    16271660  void       *base,
    16281661  unsigned32  regno,
     
    16311664{
    16321665  volatile unsigned32 *p = base;
    1633 {
    1634   volatile unsigned32 *C = (void *)0x34CDF0;
    1635   if ( *C ) printf( "W. *C = 0x%x\n", *C );
    1636 }
    16371666
    16381667#if (SONIC_DEBUG & SONIC_DEBUG_PRINT_REGISTERS)
     
    16441673}
    16451674
    1646 unsigned32 sonic_read_register(
     1675inline unsigned32 sonic_read_register(
    16471676  void       *base,
    16481677  unsigned32  regno
     
    16511680  volatile unsigned32 *p = base;
    16521681  unsigned32           value;
    1653 
    1654 {
    1655   volatile unsigned32 *C = (void *)0x34CDF0;
    1656   if ( *C ) printf( "R. *C = 0x%x\n", *C );
    1657 }
    16581682
    16591683  value = p[regno];
Note: See TracChangeset for help on using the changeset viewer.