Changeset 301a2a3c in rtems


Ignore:
Timestamp:
Aug 8, 1998, 4:37:25 PM (21 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
870284d
Parents:
7e2187f4
Message:

Changed debug level.

Moved CAM Descriptor types to sonic.h.

CAM memory is now malloced to insure it shares the same upper address bits.

Removed increment of RX interrupt count on TX interrupt path.

Added SONIC_DEBUG_FRAGMENTS and SONIC_DEBUG_CAM conditionals.

Fixed bugs in fragment manipulation. First bug was that the pad overwrote
the last fragment. The second bug was that the link information overwrote
the size of the last fragment.

Rewrote initialization of TDA to simplify it.

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

Legend:

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

    r7e2187f4 r301a2a3c  
     1void break_when_you_get_here();
    12/*
    23 *******************************************************************
     
    5152#define SONIC_DEBUG_MEMORY           0x0002
    5253#define SONIC_DEBUG_MEMORY_ALLOCATE  0x0004
    53 
    54 #define SONIC_DEBUG      (SONIC_DEBUG_PRINT_REGISTERS|SONIC_DEBUG_MEMORY)
     54#define SONIC_DEBUG_FRAGMENTS        0x0008
     55#define SONIC_DEBUG_CAM              0x0008
     56
     57#define SONIC_DEBUG      (SONIC_DEBUG_MEMORY|SONIC_DEBUG_CAM)
     58/* SONIC_DEBUG_ALL */
     59
    5560
    5661/*
     
    187192  int                             rdaCount;
    188193  ReceiveResourcePointer_t        rsa;
     194  CamDescriptorPointer_t          cdp;
    189195  ReceiveDescriptorPointer_t      rda;
    190196  ReceiveDescriptorPointer_t      rdp_last;
     
    245251 * Very simple minded -- just keeps trying till the memory is on a single page.
    246252 */
    247 SONIC_STATIC void * sonic_allocate (unsigned int nbytes)
     253SONIC_STATIC void * sonic_allocate(unsigned int nbytes)
    248254{
    249255  void *p;
     
    386392                  ~(IMR_PINTEN | IMR_PTXEN | IMR_TXEREN)
    387393    );
    388     dp->rxInterrupts++;
    389394    dp->txInterrupts++;
    390395    rtems_event_send (dp->txWaitTid, INTERRUPT_EVENT);
     
    414419  while ((dp->tdaActiveCount != 0)
    415420      && ((status = dp->tdaTail->status) != 0)) {
     421
     422/* printf( "retire TDA %p (0x%04x)\n", dp->tdaTail, status ); */
    416423    /*
    417424     * Check for errors which stop the transmitter.
     
    589596    packetSize += bp->cnt;
    590597
     598#if (SONIC_DEBUG & SONIC_DEBUG_FRAGMENTS)
     599    printf( "fp %p 0x%04x%04x %d\n",
     600      fp, fp->frag_msw, fp->frag_lsw, fp->frag_size );
     601#endif
    591602    /*
    592603     * Break out of the loop if this mbuf is the last in the frame.
     
    601612  if  ((packetSize < 64) && (i < MAXIMUM_FRAGS_PER_DESCRIPTOR)) {
    602613    int padSize = 64 - packetSize;
     614    fp++;
    603615    fp->frag_lsw = LSW(padBuf);
    604616    fp->frag_msw = MSW(padBuf);
    605617    fp->frag_size = padSize;
     618#if (SONIC_DEBUG & SONIC_DEBUG_FRAGMENTS)
     619    printf( "PAD fp %p 0x%04x%04x %d\n",
     620         fp, fp->frag_msw, fp->frag_lsw, fp->frag_size );
     621#endif
    606622    packetSize += padSize;
    607623    i++;
    608     fp++;
    609624  }
    610625
     
    613628   */
    614629  tdp->pkt_size = packetSize;
    615   tdp->frag_count = i;
     630  tdp->frag_count = i + 1;
    616631  tdp->status = 0;
    617632
     
    619634   * Chain onto list and start transmission.
    620635   */
    621   tdp->linkp = &fp->frag_link;
     636  tdp->linkp = &(fp+1)->frag_link;
    622637  *tdp->linkp = LSW(tdp->next) | TDA_LINK_EOL;
    623638  *dp->tdaHead->linkp &= ~TDA_LINK_EOL;
     639  sonic_write_register(
     640     rp,
     641     SONIC_REG_IMR,
     642     sonic_read_register( rp, SONIC_REG_IMR) |
     643            (IMR_PINTEN | IMR_PTXEN | IMR_TXEREN)
     644  );
    624645  sonic_write_register( rp, SONIC_REG_CR, CR_TXP );
    625646  dp->tdaActiveCount++;
     
    803824    }
    804825
    805 printf( "Incoming packet %p\n", rdp );
     826/* printf( "Incoming packet %p\n", rdp ); */
    806827
    807828    /*
     
    813834      void *p;
    814835
     836/* printf( "Valid packet\n" ); */
    815837      /*
    816838       * Get the mbuf pointer
     
    829851       */
    830852      bp->cnt = rdp->byte_count - sizeof (uint32);
     853/* printf( "Routing the packet\n" ); */
    831854      net_route (iface, &bp);
    832855
     
    930953  ReceiveResourcePointer_t rwp, rea;
    931954  struct mbuf *bp;
    932   struct CamDescriptor{
    933     struct {
    934       rtems_unsigned32  cep;  /* CAM Entry Pointer */
    935       rtems_unsigned32  cap0; /* CAM Address Port 0 xx-xx-xx-xx-YY-YY */
    936       rtems_unsigned32  cap1; /* CAM Address Port 1 xx-xx-YY-YY-xxxx */
    937       rtems_unsigned32  cap2; /* CAM Address Port 2 YY-YY-xx-xx-xx-xx */
    938     } desc[16];
    939     rtems_unsigned32  ce;
    940   };
    941   volatile struct CamDescriptor *cdp;
     955  CamDescriptorPointer_t cdp;
    942956
    943957  /*
     
    962976
    963977  dp->tdaActiveCount = 0;
    964   dp->tdaTail = sonic_allocate (dp->tdaCount * sizeof *tdp);
     978  dp->tdaTail = sonic_allocate(dp->tdaCount * sizeof *tdp);
    965979#if (SONIC_DEBUG & SONIC_DEBUG_MEMORY)
    966980  printf( "tdaTail = %p\n", dp->tdaTail );
     
    968982  otdp = tdp = dp->tdaTail;
    969983  for (i = 0 ; i < dp->tdaCount ; i++) {
     984    /*
     985     *  status, pkt_config, pkt_size, and all fragment fields
     986     *  are set to zero by sonic_allocate.
     987     */
     988
     989/* XXX not used by other drivers
    970990    if (i & 1)
    971991      tdp->pkt_config = TDA_CONFIG_PINT;
    972     else
    973       tdp->pkt_config = 0;
    974     tdp->frag_count = 1;
    975     if (i == (dp->tdaCount - 1))
    976       tdp->next = (TransmitDescriptor_t *)dp->tdaTail;
    977     else
    978       tdp->next = (TransmitDescriptor_t *)(tdp + 1);
     992*/
     993
     994    tdp->frag_count        = 1;
     995    tdp->frag[0].frag_link = LSW(tdp + 1);
     996    tdp->link_pad          = LSW(tdp + 1) | TDA_LINK_EOL;
     997    otdp->linkp            = &((tdp + 1)->frag[0].frag_link);
     998    tdp->next              = (TransmitDescriptor_t *)(tdp + 1);
    979999    otdp = tdp;
    980     tdp = tdp->next;
    981   }
    982   dp->tdaHead = otdp;
    983   dp->tdaHead->linkp = &dp->tdaHead->frag[0].frag_link;
     1000    tdp++;
     1001  }
     1002  dp->tdaHead = otdp;  /* XXX why? */
     1003  otdp->link_pad = LSW(dp->tdaTail) | TDA_LINK_EOL;
     1004  otdp->next = (TransmitDescriptor_t *)dp->tdaTail;
     1005  otdp->linkp = &dp->tdaHead->frag[0].frag_link;
    9841006
    9851007  /*
     
    9871009   *  Leaves ordp pointing at the `end' of the list and
    9881010   *  dp->rda pointing at the `beginning' of the list.
    989    */
    990 
    991   dp->rda = sonic_allocate (dp->rdaCount * sizeof(ReceiveDescriptor_t));
     1011   *
     1012   *  NOTE: The RDA and CDP must have the same MSW for their addresses.
     1013   */
     1014
     1015  dp->rda = sonic_allocate(
     1016              (dp->rdaCount * sizeof(ReceiveDescriptor_t)) +
     1017                sizeof(CamDescriptor_t) );
     1018  dp->cdp = (CamDescriptorPointer_t) ((unsigned char *)dp->rda +
     1019        (dp->rdaCount * sizeof(ReceiveDescriptor_t)));
    9921020#if (SONIC_DEBUG & SONIC_DEBUG_MEMORY)
    9931021  printf( "rda area = %p\n", dp->rda );
     1022  printf( "cdp area = %p\n", dp->cdp );
    9941023#endif
    9951024
     
    10221051   */
    10231052
    1024   dp->rsa = sonic_allocate ((dp->rdaCount + RRA_EXTRA_COUNT) * sizeof *dp->rsa);
     1053  dp->rsa = sonic_allocate((dp->rdaCount + RRA_EXTRA_COUNT) * sizeof *dp->rsa);
    10251054#if (SONIC_DEBUG & SONIC_DEBUG_MEMORY)
    10261055  printf( "rsa area = %p\n", dp->rsa );
     
    10501079     * Set up RRA entry
    10511080     */
     1081
    10521082    rwp->buff_ptr_lsw = LSW(bp->data);
    10531083    rwp->buff_ptr_msw = MSW(bp->data);
     
    10871117  sonic_write_register( rp, SONIC_REG_FAET, 0xFFFF );
    10881118  sonic_write_register( rp, SONIC_REG_MPT, 0xFFFF );
     1119  sonic_write_register( rp, SONIC_REG_RSC, 0 );
    10891120
    10901121  /*
     
    11021133   * Set up Resource Area pointers
    11031134   */
     1135
    11041136  sonic_write_register( rp, SONIC_REG_URRA, MSW(dp->rsa) );
    11051137  sonic_write_register( rp, SONIC_REG_RSA, LSW(dp->rsa) );
     
    11091141  sonic_write_register( rp, SONIC_REG_RRP, LSW(dp->rsa) );
    11101142  sonic_write_register( rp, SONIC_REG_RWP, LSW(dp->rsa) ); /* XXX was rea */
    1111   sonic_write_register( rp, SONIC_REG_RSC, 0 );
    11121143
    11131144  sonic_write_register( rp, SONIC_REG_URDA, MSW(dp->rda) );
     
    11451176   */
    11461177  hwaddr = dp->iface->hwaddr;
    1147   cdp = (struct CamDescriptor *)dp->rsa;
     1178  cdp = dp->cdp;
     1179
    11481180  for (i=0 ; i<16 ; i++ ) {
     1181    /*
     1182     *  cap0, cap1, and cap2 are zeroed by sonic_allocate.
     1183     */
    11491184    cdp->desc[i].cep = i;
    11501185  }
    11511186
    11521187  cdp->desc[0].cep = 0;      /* Fill first entry in CAM */
     1188#if (SONIC_DEBUG & SONIC_DEBUG_CAM)
     1189  printf( "hwaddr: %2x:%2x:%2x:%2x:%2x:%2x\n",
     1190     hwaddr[0], hwaddr[1], hwaddr[2], hwaddr[3], hwaddr[4], hwaddr[5] );
     1191#endif
    11531192  cdp->desc[0].cap2 = hwaddr[0] << 8 | hwaddr[1];
    11541193  cdp->desc[0].cap1 = hwaddr[2] << 8 | hwaddr[3];
     
    11671206
    11681207  sonic_write_register( rp, SONIC_REG_CR, CR_RST | CR_STP | CR_RXDIS | CR_HTX );
     1208
     1209#if (SONIC_DEBUG & SONIC_DEBUG_CAM)
     1210  sonic_write_register( rp, SONIC_REG_CEP, 0 );  /* Select first entry in CAM */
     1211    printf ("Loaded Ethernet address into SONIC CAM.\n"
     1212      "  Wrote %04x%04x%04x - %#x\n"
     1213      "   Read %04x%04x%04x - %#x\n",
     1214        cdp->desc[0].cap2, cdp->desc[0].cap1, cdp->desc[0].cap0, cdp->ce,
     1215        sonic_read_register( rp, SONIC_REG_CAP2 ),
     1216        sonic_read_register( rp, SONIC_REG_CAP1 ),
     1217        sonic_read_register( rp, SONIC_REG_CAP0 ),
     1218        sonic_read_register( rp, SONIC_REG_CE ));
     1219#endif
    11691220
    11701221  sonic_write_register( rp, SONIC_REG_CEP, 0 );  /* Select first entry in CAM */
     
    11811232        sonic_read_register( rp, SONIC_REG_CAP0 ),
    11821233        sonic_read_register( rp, SONIC_REG_CE ));
    1183 #if 0
    11841234    rtems_panic ("SONIC LCAM");
    1185 #endif
    1186   }
    1187 
    1188   sonic_write_register( rp, SONIC_REG_CR, CR_STP | CR_RXDIS | CR_HTX );
     1235  }
     1236
     1237  sonic_write_register(rp, SONIC_REG_CR, CR_TXP | CR_RXEN | CR_STP);
    11891238
    11901239  /*
     
    14441493  return value;
    14451494}
    1446 
  • c/src/lib/libbsp/powerpc/dmv177/sonic/sonic.h

    r7e2187f4 r301a2a3c  
    333333typedef volatile ReceiveDescriptor_t *ReceiveDescriptorPointer_t;
    334334
     335typedef struct {
     336  struct {
     337    rtems_unsigned32  cep;  /* CAM Entry Pointer */
     338    rtems_unsigned32  cap0; /* CAM Address Port 0 xx-xx-xx-xx-YY-YY */
     339    rtems_unsigned32  cap1; /* CAM Address Port 1 xx-xx-YY-YY-xxxx */
     340    rtems_unsigned32  cap2; /* CAM Address Port 2 YY-YY-xx-xx-xx-xx */
     341  } desc[16];
     342  rtems_unsigned32  ce;
     343} CamDescriptor_t;
     344
     345typedef volatile CamDescriptor_t *CamDescriptorPointer_t;
     346
    335347/*
    336348 * Receive status
Note: See TracChangeset for help on using the changeset viewer.