Changeset 7dbab72 in rtems


Ignore:
Timestamp:
Jan 31, 1999, 8:46:52 PM (20 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
d93b23d
Parents:
07d880f4
Message:

Can send and receive packets but fails when TDA wraps. There appears
to be a problem with overwriting the TX descriptors during an RX.

Location:
c/src/lib/libbsp/powerpc/dmv177/sonic
Files:
2 edited

Legend:

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

    r07d880f4 r7dbab72  
    6464#define SONIC_DEBUG_DESCRIPTORS      0x0010
    6565#define SONIC_DEBUG_ERRORS           0x0020
    66 
    67 #define SONIC_DEBUG (SONIC_DEBUG_ERRORS)
     66#define SONIC_DEBUG_DUMP_TX_MBUFS    0x0040
     67#define SONIC_DEBUG_DUMP_RX_MBUFS    0x0080
     68
     69#define SONIC_DEBUG_DUMP_MBUFS \
     70  (SONIC_DEBUG_DUMP_TX_MBUFS|SONIC_DEBUG_DUMP_RX_MBUFS)
     71
     72#define SONIC_DEBUG_MEDIUM \
     73  ((SONIC_DEBUG_ALL) & ~(SONIC_DEBUG_PRINT_REGISTERS|SONIC_DEBUG_DUMP_MBUFS))
     74  /*
     75  ((SONIC_DEBUG_ALL) & ~(SONIC_DEBUG_DUMP_MBUFS))
     76*/
     77
     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) */
    6885
    6986/* (SONIC_DEBUG_MEMORY|SONIC_DEBUG_DESCRIPTORS) */
    7087
    71 /* SONIC_DEBUG_ALL */
    72 
     88#if (SONIC_DEBUG & SONIC_DEBUG_DUMP_MBUFS)
     89#include <rtems/dumpbuf.h>
     90#endif
    7391
    7492/*
     
    140158 */
    141159#define RDA_COUNT     20
    142 #define TDA_COUNT     100
     160#define TDA_COUNT     10
    143161
    144162/*
     
    196214   */
    197215  void                             *sonic;
     216
     217  /*
     218   *  Tables to map the mbufs from chip to stack
     219   */
     220
     221  struct mbuf             **rxMbuf;
     222  struct mbuf             **txMbuf;
    198223
    199224  /*
     
    306331     */
    307332    p = malloc( nbytes, M_MBUF, M_NOWAIT );
    308     memset (p, '\0', nbytes);
    309333    if (p == NULL)
    310334      rtems_panic ("No memory!");
     335    memset (p, '\0', nbytes);
    311336    a1 = (unsigned long)p;
    312337    a2 = a1 + nbytes - 1;
     
    373398{
    374399  struct sonic_softc *sc = sonic_softc;
     400  unsigned32 isr, imr;
    375401  void *rp;
    376402
     
    394420  sc->Interrupts++;
    395421
     422  isr = sonic_read_register( rp, SONIC_REG_ISR );
     423  imr = sonic_read_register( rp, SONIC_REG_IMR );
     424
    396425  /*
    397426   * Packet received or receive buffer area exceeded?
    398427   */
    399   if ((sonic_read_register( rp, SONIC_REG_IMR ) & (IMR_PRXEN | IMR_RBAEEN)) &&
    400       (sonic_read_register( rp, SONIC_REG_ISR ) & (ISR_PKTRX | ISR_RBAE))) {
    401     sonic_write_register(
    402        rp,
    403        SONIC_REG_IMR,
    404        sonic_read_register( rp, SONIC_REG_IMR) & ~(IMR_PRXEN | IMR_RBAEEN)
    405     );
     428  if ((imr & (IMR_PRXEN | IMR_RBAEEN)) &&
     429      (isr & (ISR_PKTRX | ISR_RBAE))) {
     430    imr &= ~(IMR_PRXEN | IMR_RBAEEN);
    406431    sc->rxInterrupts++;
    407432    rtems_event_send (sc->rxDaemonTid, INTERRUPT_EVENT);
     
    411436   * Packet started, transmitter done or transmitter error?
    412437   */
    413   if ((sonic_read_register( rp, SONIC_REG_IMR ) & (IMR_PINTEN | IMR_PTXEN | IMR_TXEREN))
    414    && (sonic_read_register( rp, SONIC_REG_ISR ) & (ISR_PINT | ISR_TXDN | ISR_TXER))) {
    415     sonic_write_register(
    416        rp,
    417        SONIC_REG_IMR,
    418        sonic_read_register( rp, SONIC_REG_IMR) &
    419                   ~(IMR_PINTEN | IMR_PTXEN | IMR_TXEREN)
    420     );
     438  if ((imr & (IMR_PINTEN | IMR_PTXEN | IMR_TXEREN)) &&
     439      (isr & (ISR_PINT | ISR_TXDN | ISR_TXER))) {
     440    imr &= ~(IMR_PINTEN | IMR_PTXEN | IMR_TXEREN);
    421441    sc->txInterrupts++;
    422442    rtems_event_send (sc->txDaemonTid, INTERRUPT_EVENT);
    423443  }
     444
     445  sonic_write_register( rp, SONIC_REG_IMR, imr );
    424446}
    425447
     
    602624      fp->frag_size = m->m_len;
    603625      packetSize += m->m_len;
     626#if (SONIC_DEBUG & SONIC_DEBUG_FRAGMENTS)
     627      printf( "fp %p 0x%04x%04x %d=%d .. %d\n",
     628        fp, fp->frag_msw, fp->frag_lsw, fp->frag_size, m->m_len, packetSize );
     629#endif
     630#if (SONIC_DEBUG & SONIC_DEBUG_DUMP_TX_MBUFS)
     631      Dump_Buffer(
     632        p,
     633        (fp->frag_size > MAXIMUM_FRAME_SIZE) ? MAXIMUM_FRAME_SIZE : fp->frag_size
     634      );
     635#endif
    604636      l = m;
    605637      m = m->m_next;
    606 #if (SONIC_DEBUG & SONIC_DEBUG_FRAGMENTS)
    607       printf( "fp %p 0x%04x%04x %d\n",
    608                     fp, fp->frag_msw, fp->frag_lsw, fp->frag_size );
    609 #endif
    610638    }
    611639    else {
     
    658686  sc->tdaHead = tdp;
    659687
    660   sonic_enable_interrupts( rp, (IMR_PINTEN | IMR_PTXEN | IMR_TXEREN) );
     688/* XXX */
     689/*   sonic_enable_interrupts( rp, (IMR_PINTEN | IMR_PTXEN | IMR_TXEREN) ); */
    661690  sonic_write_register( rp, SONIC_REG_CR, CR_TXP );
    662691}
     
    859888  ReceiveResourcePointer_t rwp, rea;
    860889  rtems_unsigned16 newMissedTally, oldMissedTally;
     890  unsigned32 rxMbufIndex;
    861891
    862892  rwp = sc->rsa;
     
    868898   */
    869899  oldMissedTally = sonic_read_register( rp, SONIC_REG_MPT );
    870   sonic_write_register( rp, SONIC_REG_CR, CR_RRRA );
    871   sonic_write_register( rp, SONIC_REG_CR, CR_RXEN );
    872900
    873901  /*
    874902   * Input packet handling loop
    875903   */
     904  rxMbufIndex = 0;
    876905  for (;;) {
    877906    /*
     
    891920    status = rdp->status;
    892921    if (status & RDA_STATUS_PRX) {
    893       struct mbuf **mp;
    894922      struct ether_header *eh;
    895923      void *p;
    896 
    897       /*
    898        * Get the mbuf pointer
    899        */
    900       p = PTR(rdp->pkt_msw, rdp->pkt_lsw);
    901       mp = (struct mbuf **)p - 1;
    902       m = *mp;
    903924
    904925      /*
     
    910931       * Invalidate cache entries for this memory.
    911932       */
     933      m = rdp->mbufp;
    912934      m->m_len = m->m_pkthdr.len = rdp->byte_count -
    913935                          sizeof(rtems_unsigned32) -
     
    915937      eh = mtod (m, struct ether_header *);
    916938      m->m_data += sizeof(struct ether_header);
     939 
     940#if (SONIC_DEBUG & SONIC_DEBUG_DUMP_RX_MBUFS)
     941      Dump_Buffer( (void *) eh, sizeof(struct ether_header) );
     942      Dump_Buffer( (void *) m, 96 /* m->m_len*/ );
     943#endif
     944
    917945      ether_input (ifp, eh, m);
    918946
     
    934962       * Allocate a new mbuf.
    935963       */
     964
     965      m= (void *)0xA0000000; /* hope for a fault :) */
    936966      MGETHDR (m, M_WAIT, MT_DATA);
    937967      MCLGET (m, M_WAIT);
    938968      m->m_pkthdr.rcvif = ifp;
    939       mp = mtod (m, struct mbuf **);
    940       m->m_data += sizeof *mp;
    941       *mp = m;
     969      rdp->mbufp = m;
    942970      p = mtod (m, void *);
    943971
     
    945973       * Reuse Receive Resource.
    946974       */
     975
    947976      rwp->buff_ptr_lsw = LSW(p);
    948977      rwp->buff_ptr_msw = MSW(p);
     978      rwp->buff_wc_lsw = RBUF_WC;
     979      rwp->buff_wc_msw = 0;
    949980      rwp++;
     981
    950982      if (rwp == rea) {
    951983#if (SONIC_DEBUG & SONIC_DEBUG_MEMORY)
     
    9831015     * Move to next receive descriptor
    9841016     */
     1017
    9851018    rdp->in_use = RDA_FREE;
    9861019    rdp = rdp->next;
    9871020    rdp->link &= ~RDA_LINK_EOL;
     1021
    9881022  }
    9891023}
     
    10261060 
    10271061  /*
     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  /*
    10281075   *  Set up circular linked list in Transmit Descriptor Area.
    10291076   *  Use the PINT bit in the transmit configuration field to
     
    10401087  tdp = sc->tdaTail;
    10411088  for (i = 0 ; i < sc->tdaCount ; i++) {
     1089    /*
     1090     *  Start off with the table of outstanding mbuf's
     1091     */
     1092    sc->txMbuf[i] = NULL;
     1093
    10421094    /*
    10431095     *  status, pkt_config, pkt_size, and all fragment fields
     
    11201172  rwp = sc->rsa;
    11211173  for (i = 0 ; i < (sc->rdaCount + RRA_EXTRA_COUNT) ; i++, rwp++) {
    1122     struct mbuf **mp;
    11231174
    11241175    /*
     
    11321183    MCLGET (m, M_WAIT);
    11331184    m->m_pkthdr.rcvif = &sc->arpcom.ac_if;
    1134     mp = mtod (m, struct mbuf **);
    1135 
    1136     m->m_data += sizeof *mp;
    1137     *mp = m;
     1185    sc->rxMbuf[i] = m;
     1186    sc->rda[i].mbufp = m;
     1187
    11381188    p = mtod (m, void *);
    11391189
     
    11681218   * Mask all interrupts
    11691219   */
    1170   sonic_write_register( rp, SONIC_REG_IMR, 0x3fff );
     1220  sonic_write_register( rp, SONIC_REG_IMR, 0x0 ); /* XXX was backwards */
    11711221
    11721222  /*
     
    12931343  }
    12941344
    1295   sonic_write_register(rp, SONIC_REG_CR, CR_TXP | CR_RXEN | CR_STP);
     1345  sonic_write_register(rp, SONIC_REG_CR, /* CR_TXP | */CR_RXEN | CR_STP);
    12961346
    12971347  /*
    12981348   * Attach SONIC interrupt handler
    12991349   */
     1350/* XXX
    13001351  sonic_write_register( rp, SONIC_REG_IMR, 0 );
     1352*/
    13011353  old_handler = set_vector(sonic_interrupt_handler, sc->vector, 0);
    13021354
     
    13621414   * Enable receiver and transmitter
    13631415   */
    1364   sonic_write_register(rp, SONIC_REG_CR, CR_TXP | CR_RXEN);
     1416  /* sonic_write_register( rp, SONIC_REG_IMR, 0 ); */
     1417  sonic_enable_interrupts( rp, (IMR_PRXEN | IMR_RBAEEN) );
     1418
     1419  sonic_write_register(rp, SONIC_REG_CR, /* CR_TXP | */ CR_RXEN);
    13651420}
    13661421
     
    14721527    sc->tdaCount = TDA_COUNT;
    14731528  sc->acceptBroadcast = !config->ignore_broadcast;
     1529
     1530  sc->sonic = (void *) SONIC_BASE_ADDRESS;
     1531  sc->vector = SONIC_VECTOR;
    14741532
    14751533  /*
     
    15731631{
    15741632  volatile unsigned32 *p = base;
     1633{
     1634  volatile unsigned32 *C = (void *)0x34CDF0;
     1635  if ( *C ) printf( "W. *C = 0x%x\n", *C );
     1636}
    15751637
    15761638#if (SONIC_DEBUG & SONIC_DEBUG_PRINT_REGISTERS)
     
    15891651  volatile unsigned32 *p = base;
    15901652  unsigned32           value;
     1653
     1654{
     1655  volatile unsigned32 *C = (void *)0x34CDF0;
     1656  if ( *C ) printf( "R. *C = 0x%x\n", *C );
     1657}
    15911658
    15921659  value = p[regno];
  • c/src/lib/libbsp/powerpc/dmv177/sonic/sonic.h

    r07d880f4 r7dbab72  
    330330   */
    331331  volatile struct ReceiveDescriptor  *next;  /* Circularly-linked list */
     332  struct mbuf                        *mbufp; /* First mbuf in packet */
    332333};
    333334typedef struct ReceiveDescriptor ReceiveDescriptor_t;
Note: See TracChangeset for help on using the changeset viewer.