Changeset 811115de in rtems
- Timestamp:
- 02/02/99 16:28:42 (24 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- 9b9c4dfd
- Parents:
- 14faf00
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libbsp/powerpc/dmv177/sonic/sonic.c
r14faf00 r811115de 31 31 */ 32 32 33 #include <bsp.h> /* XXX JRS changed order */ 34 #include "sonic.h" 33 35 #include <rtems/rtems_bsdnet.h> 34 #include "sonic.h"35 36 36 37 #include <stdio.h> … … 55 56 */ 56 57 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 68 70 69 71 #define SONIC_DEBUG_DUMP_MBUFS \ 70 72 (SONIC_DEBUG_DUMP_TX_MBUFS|SONIC_DEBUG_DUMP_RX_MBUFS) 71 73 72 #define SONIC_DEBUG_MEDIUM \ 74 #define SONIC_DEBUG (SONIC_DEBUG_ERRORS) 75 76 /* 73 77 ((SONIC_DEBUG_ALL) & ~(SONIC_DEBUG_PRINT_REGISTERS|SONIC_DEBUG_DUMP_MBUFS)) 74 /*75 78 ((SONIC_DEBUG_ALL) & ~(SONIC_DEBUG_DUMP_MBUFS)) 76 79 */ 77 80 78 #define SONIC_DEBUG SONIC_DEBUG_ALL79 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) */87 81 88 82 #if (SONIC_DEBUG & SONIC_DEBUG_DUMP_MBUFS) … … 157 151 * Default sizes of transmit and receive descriptor areas 158 152 */ 159 #define RDA_COUNT 20 160 #define TDA_COUNT 10 153 #define RDA_COUNT 20 /* 20 */ 154 #define TDA_COUNT 10 /* 10 */ 161 155 162 156 /* … … 164 158 * As suggested by National Application Note 746, make the 165 159 * 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. 166 163 */ 167 164 #define RRA_EXTRA_COUNT 0 … … 189 186 */ 190 187 #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) 192 190 193 191 /* … … 214 212 */ 215 213 void *sonic; 216 217 /*218 * Tables to map the mbufs from chip to stack219 */220 221 struct mbuf **rxMbuf;222 struct mbuf **txMbuf;223 214 224 215 /* … … 281 272 SONIC_STATIC struct sonic_softc sonic_softc[NSONIC]; 282 273 274 275 /* 276 ****************************************************************** 277 * * 278 * Debug Routines * 279 * * 280 ****************************************************************** 281 */ 282 283 #if (SONIC_DEBUG & SONIC_DEBUG_MEMORY_DESCRIPTORS) 284 void 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 301 void 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 283 320 /* 284 321 ****************************************************************** … … 476 513 #if (SONIC_DEBUG & SONIC_DEBUG_ERRORS) 477 514 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 ); 479 517 #endif 480 518 … … 529 567 */ 530 568 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 } 533 574 534 575 sc->tdaTail->frag[0].frag_link = LSW(sc->tdaTail->link_pad); … … 888 929 ReceiveResourcePointer_t rwp, rea; 889 930 rtems_unsigned16 newMissedTally, oldMissedTally; 890 unsigned32 rxMbufIndex;891 931 892 932 rwp = sc->rsa; … … 902 942 * Input packet handling loop 903 943 */ 904 rxMbufIndex = 0;905 944 for (;;) { 906 945 /* … … 931 970 * Invalidate cache entries for this memory. 932 971 */ 972 #if (SONIC_DEBUG & SONIC_DEBUG_MEMORY_DESCRIPTORS) 973 sonic_print_rx_descriptor( rdp ); 974 #endif 933 975 m = rdp->mbufp; 934 976 m->m_len = m->m_pkthdr.len = rdp->byte_count - … … 963 1005 */ 964 1006 965 m= (void *)0xA0000000; /* hope for a fault :) */966 1007 MGETHDR (m, M_WAIT, MT_DATA); 967 1008 MCLGET (m, M_WAIT); … … 1060 1101 1061 1102 /* 1062 * Allocate memory so we can figure out from the descriptor which1063 * 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 /*1075 1103 * Set up circular linked list in Transmit Descriptor Area. 1076 1104 * Use the PINT bit in the transmit configuration field to … … 1090 1118 * Start off with the table of outstanding mbuf's 1091 1119 */ 1092 sc->txMbuf[i] = NULL;1093 1120 1094 1121 /* … … 1107 1134 tdp->linkp = &((tdp + 1)->frag[0].frag_link); 1108 1135 tdp->next = (TransmitDescriptor_t *)(tdp + 1); 1136 #if (SONIC_DEBUG & SONIC_DEBUG_MEMORY_DESCRIPTORS) 1137 sonic_print_tx_descriptor( tdp ); 1138 #endif 1109 1139 tdp++; 1110 1140 } … … 1183 1213 MCLGET (m, M_WAIT); 1184 1214 m->m_pkthdr.rcvif = &sc->arpcom.ac_if; 1185 sc->rxMbuf[i] = m;1186 1215 sc->rda[i].mbufp = m; 1187 1216 … … 1195 1224 rwp->buff_wc_lsw = RBUF_WC; 1196 1225 rwp->buff_wc_msw = 0; 1226 #if (SONIC_DEBUG & SONIC_DEBUG_MEMORY_DESCRIPTORS) 1227 sonic_print_rx_descriptor( &sc->rda[i] ); 1228 #endif 1197 1229 } 1198 1230 sc->rea = rwp; … … 1624 1656 }; 1625 1657 #endif 1626 void sonic_write_register( 1658 1659 inline void sonic_write_register( 1627 1660 void *base, 1628 1661 unsigned32 regno, … … 1631 1664 { 1632 1665 volatile unsigned32 *p = base; 1633 {1634 volatile unsigned32 *C = (void *)0x34CDF0;1635 if ( *C ) printf( "W. *C = 0x%x\n", *C );1636 }1637 1666 1638 1667 #if (SONIC_DEBUG & SONIC_DEBUG_PRINT_REGISTERS) … … 1644 1673 } 1645 1674 1646 unsigned32 sonic_read_register(1675 inline unsigned32 sonic_read_register( 1647 1676 void *base, 1648 1677 unsigned32 regno … … 1651 1680 volatile unsigned32 *p = base; 1652 1681 unsigned32 value; 1653 1654 {1655 volatile unsigned32 *C = (void *)0x34CDF0;1656 if ( *C ) printf( "R. *C = 0x%x\n", *C );1657 }1658 1682 1659 1683 value = p[regno];
Note: See TracChangeset
for help on using the changeset viewer.