robotxrx.c
上传用户:yuanda199
上传日期:2022-06-26
资源大小:412k
文件大小:14k
源码类别:

VxWorks

开发平台:

C/C++

  1. /*
  2.  * $Id: robotxrx.c,v 1.1 Broadcom SDK $
  3.  * $Copyright: (c) 2003 Broadcom Corp.
  4.  */
  5. #include <stdlib.h>
  6. #include <end.h>
  7. #include <taskLib.h>
  8. #include <muxLib.h>
  9. #include <muxTkLib.h>
  10. #include <netBufLib.h>
  11. #include <errnoLib.h>
  12. #include <time.h>
  13. #include <cacheLib.h>
  14. #include <logLib.h>
  15. #include <intLib.h>
  16. #define ROBO_TXRX_DEBUG
  17. #define ROBO_TX_TEST_XXXX
  18. #define ROBO_MII_DEVICE_NAME "et"
  19. #define ROBO_MII_DEV_UNIT 1
  20. #define LINK_HDR_LEN 14
  21. #define ROBO_TX_RX_PK_SZ    2048
  22. #define ROBO_TXRX_CLBLKS    256
  23. #define ROBO_TXRX_MBLKS     256
  24. #define ROBO_TXRX_CLBUFS    256
  25. typedef void (*cb_f)(void *b, int l);
  26. typedef void * (*alloc_f)(int l);
  27. typedef void (*free_f)(void *b);
  28. typedef struct robo_txrx_info_s {
  29.     void *          roboMuxBindID;
  30.     void *          roboNetPoolID;
  31.     M_CL_CONFIG     m_cl_blks;
  32.     CL_DESC         cluster;
  33.     CL_POOL_ID      clpool_id;
  34.     cb_f            rx_cb;
  35.     alloc_f         rx_alloc;
  36.     free_f          rx_free;
  37.     void *          rx_head;
  38.     void *          rx_tail;
  39.     UINT32          queue_rx_pkts;
  40.     UINT32          rx_out_of_mem;
  41.     UINT32          rx_cnt;
  42.     UINT32          tx_cnt;
  43.     UINT32          tx_fail;
  44. } robo_txrx_info_t;
  45. LOCAL robo_txrx_info_t robo_txrx_info;
  46. #ifdef ROBO_TXRX_DEBUG
  47. int  robo_txrx_debug = 0;
  48. #endif
  49. #define ROBO_TXRX_DEBUG_F   0x00000001
  50. #define ROBO_TXRX_DEBUG_P   0x00000002
  51. #define ROBO_TXRX_PRINT if (robo_txrx_debug & ROBO_TXRX_DEBUG_P) logMsg
  52. /* Public functions */
  53. void roboTxRxInit();
  54. int bcmRoboTx(UINT8 *b, int l);
  55. void bcm_robo_mii_rx(UINT8 *b, int *l);
  56. void bcm_robo_mii_rx_start();
  57. void bcm_robo_mii_rx_stop();
  58. int roboMIIRxHandlerRegister(cb_f cf, alloc_f af, free_f ff);
  59. int roboMIIRxHandlerUnRegister(cb_f f);
  60. #ifdef ROBO_TXRX_DEBUG
  61. /* debug test functions */
  62. void robo_tx_test(int l);
  63. void robo_rx_test();
  64. void robo_tx_netpool_show();
  65. #include <stdio.h>
  66. /* Debug */
  67. LOCAL void
  68. robo_txrx_pp(UINT8 *p, int l)
  69. {
  70.     int i;
  71.     for(i=0; i < l; i++) {
  72.         if ((i % 16) == 0) {
  73.             printf("n%02x :", i);
  74.         }
  75.         printf("%02x ", *p++);
  76.     }
  77.     printf("n");
  78. }
  79. /* Debug */
  80. LOCAL void
  81. robo_txrx_print_packet(M_BLK_ID pMblk)
  82. {
  83.     unsigned char *p;
  84.     pMblk->mBlkHdr.mFlags &=(~(M_BCAST | M_MCAST));
  85.     printf("pklen=%d mLen=%d mType=%d mNext=%08x mData=%08xn",
  86.         pMblk->mBlkPktHdr.len,
  87.         pMblk->mBlkHdr.mLen,
  88.         pMblk->mBlkHdr.mType,
  89.         (int)pMblk->mBlkHdr.mNext,
  90.         (int)pMblk->mBlkHdr.mData);
  91.     p = (unsigned char *)pMblk->mBlkHdr.mData;
  92.     robo_txrx_pp(p, pMblk->mBlkPktHdr.len);
  93. }
  94. UINT8 robo_tx_test_pkbuf[512] = {
  95.  0x00 ,0x01 ,0x02 ,0x03 ,0x04 ,0x05 ,0x06 ,0x07 
  96. ,0x08 ,0x09 ,0x0a ,0x0b ,0x0c ,0x0d ,0x0e ,0x0f 
  97. ,0x10 ,0x11 ,0x12 ,0x13 ,0x14 ,0x15 ,0x16 ,0x17 
  98. ,0x18 ,0x19 ,0x1a ,0x1b ,0x1c ,0x1d ,0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,0xe6 ,0xe7 
  156. ,0xe8 ,0xe9 ,0xea ,0xeb ,0xec ,0xed ,0xee ,0xef 
  157. ,0xf0 ,0xf1 ,0xf2 ,0xf3 ,0xf4 ,0xf5 ,0xf6 ,0xf7 
  158. ,0xf8 ,0xf9 ,0xfa ,0xfb ,0xfc ,0xfd ,0xfe ,0xff
  159. };
  160. #endif
  161. /* Netpool create */
  162. LOCAL int
  163. roboTxRxNetpoolCreate()
  164. {
  165.     robo_txrx_info.roboNetPoolID =  (NET_POOL_ID)calloc(1, sizeof(NET_POOL));
  166.     if (robo_txrx_info.roboNetPoolID == NULL) {
  167.         return(0);
  168.     }
  169.     robo_txrx_info.m_cl_blks.mBlkNum = ROBO_TXRX_MBLKS;
  170.     robo_txrx_info.m_cl_blks.clBlkNum = ROBO_TXRX_CLBLKS;
  171.     robo_txrx_info.m_cl_blks.memSize =
  172.             (robo_txrx_info.m_cl_blks.mBlkNum * (M_BLK_SZ + sizeof(long))) +
  173.             (robo_txrx_info.m_cl_blks.clBlkNum * (CL_BLK_SZ + sizeof(long)));;
  174.     robo_txrx_info.m_cl_blks.memArea = 
  175.             (char *)memalign (sizeof (long), robo_txrx_info.m_cl_blks.memSize);
  176.     if (robo_txrx_info.m_cl_blks.memArea == NULL) {
  177.         free(robo_txrx_info.roboNetPoolID);
  178.         robo_txrx_info.roboNetPoolID = NULL;
  179.         return(0);
  180.     }
  181.     robo_txrx_info.cluster.clNum = ROBO_TXRX_CLBUFS;
  182.     robo_txrx_info.cluster.clSize = ROBO_TX_RX_PK_SZ;
  183.     robo_txrx_info.cluster.memSize = robo_txrx_info.cluster.clNum *
  184.             (robo_txrx_info.cluster.clSize + sizeof(long)) + sizeof(long);
  185.     robo_txrx_info.cluster.memArea = cacheDmaMalloc(
  186.                                     robo_txrx_info.cluster.memSize);
  187.     if (robo_txrx_info.cluster.memArea == NULL) {
  188.         free(robo_txrx_info.roboNetPoolID);
  189.         robo_txrx_info.roboNetPoolID = NULL;
  190.         free(robo_txrx_info.m_cl_blks.memArea);
  191.         robo_txrx_info.m_cl_blks.memArea = NULL;
  192.         return(0);
  193.     }
  194.     if (netPoolInit(robo_txrx_info.roboNetPoolID,
  195.                 &robo_txrx_info.m_cl_blks,
  196.                 &robo_txrx_info.cluster, 1, NULL) != OK) {
  197.         free(robo_txrx_info.roboNetPoolID);
  198.         robo_txrx_info.roboNetPoolID = NULL;
  199.         free(robo_txrx_info.m_cl_blks.memArea);
  200.         robo_txrx_info.m_cl_blks.memArea = NULL;
  201.         free(robo_txrx_info.cluster.memArea);
  202.         robo_txrx_info.cluster.memArea = NULL;
  203.         return(0);
  204.     }
  205.     robo_txrx_info.clpool_id = netClPoolIdGet(robo_txrx_info.roboNetPoolID,
  206.                                 robo_txrx_info.cluster.clSize, FALSE);
  207.     return(1);
  208. }
  209. LOCAL int
  210. _roboTx(M_BLK_ID pMblk)
  211. {
  212.     char zd[] = {0,0,0,0,0,0};
  213. #ifdef ROBO_TXRX_DEBUG
  214.     if (robo_txrx_debug & ROBO_TXRX_DEBUG_F) {
  215.         logMsg("Sending a packet %08xn", (int)pMblk, 2, 3, 4, 5, 6);
  216.         robo_txrx_print_packet(pMblk);
  217.     }
  218. #endif
  219.     if (muxTkSend( robo_txrx_info.roboMuxBindID, pMblk, zd, 0x0806, 0) == ERROR)
  220.     {
  221.         logMsg("muxTkSend failed n", 1, 2, 3, 4, 5, 6);
  222.         netMblkClChainFree(pMblk);
  223.         robo_txrx_info.tx_fail++;
  224.         return(0);
  225.     }
  226.     robo_txrx_info.tx_cnt++;
  227.     return(1);
  228. }
  229. LOCAL BOOL
  230. roboRecv(void *netCallbackId, long type, M_BLK_ID pMblk, void *pSpareData)
  231. {
  232.     UINT8 *buf;
  233.     robo_txrx_info.rx_cnt++;
  234. #if 0
  235.     /* Adjust the data ptr and len to get back the ETH header */
  236.     pMblk->mBlkHdr.mData        -= LINK_HDR_LEN;
  237.     pMblk->mBlkHdr.mLen         += LINK_HDR_LEN;
  238.     pMblk->mBlkPktHdr.len       += LINK_HDR_LEN;
  239. #endif
  240. #ifdef ROBO_TXRX_DEBUG
  241.     if (robo_txrx_debug & ROBO_TXRX_DEBUG_F) {
  242.         robo_txrx_print_packet(pMblk);
  243.     }
  244. #endif
  245.     if (robo_txrx_info.queue_rx_pkts) {
  246.         if (robo_txrx_info.rx_cb != NULL) {
  247.             ROBO_TXRX_PRINT("Received a packet %08xn", (int)pMblk, 2, 3, 4, 5, 6);
  248.             robo_txrx_info.rx_cb(pMblk, pMblk->mBlkPktHdr.len);
  249.         } else {
  250.             netMblkClChainFree(pMblk);
  251.         }
  252.     } else {
  253.         /* copy the packet and pass it to the  application (TCL) */
  254.         /*                                                       */
  255.         if (robo_txrx_info.rx_cb != NULL) {
  256.             buf = robo_txrx_info.rx_alloc(pMblk->mBlkPktHdr.len);
  257.             if (buf != NULL) { 
  258.                 netMblkToBufCopy(pMblk, buf, NULL);
  259.                 robo_txrx_info.rx_cb(buf, pMblk->mBlkPktHdr.len);
  260.             } else {
  261.                 robo_txrx_info.rx_out_of_mem++;
  262.             }
  263.         }
  264.         /*                                                       */
  265.         /* copy the packet and pass it to the  application (TCL) */
  266.         netMblkClChainFree(pMblk);
  267.     }
  268.     return (1);
  269. }
  270. LOCAL BOOL
  271. roboTxShutdownRtn(void *netCallbackId)
  272. {
  273.     return (1);
  274. }
  275. LOCAL BOOL
  276. roboTxRestartRtn(void *netCallbackId)
  277. {
  278.     return (1);
  279. }
  280. LOCAL void
  281. roboErrorRtn(void *netCallbackId, END_ERR * pError)
  282. {
  283.     return;
  284. }
  285. /* Publicly exported functions */
  286. void roboTxRxInit()
  287. {
  288.     END_OBJ *pEndObj = NULL;
  289.     if (robo_txrx_info.roboMuxBindID != NULL) {
  290.         return;
  291.     }
  292.     roboTxRxNetpoolCreate();
  293.     /* Bind roboTxRx Network service to the END driver. */
  294.     robo_txrx_info.roboMuxBindID = (void *) muxTkBind(
  295.                         ROBO_MII_DEVICE_NAME, ROBO_MII_DEV_UNIT,
  296.                         roboRecv, roboTxShutdownRtn,
  297.                         roboTxRestartRtn, roboErrorRtn,
  298.                         MUX_PROTO_SNARF, "ROBO TX/RX",
  299.                         pEndObj,(void *) 0, (void *) 0);
  300.     if (!robo_txrx_info.roboMuxBindID)
  301.     {
  302.         logMsg("muxTkBind Failed (%08x).n", errnoGet(), 2, 3, 4, 5, 6);
  303.         return;
  304.     }
  305.     /* Promiscuous mode */
  306.     muxIoctl( robo_txrx_info.roboMuxBindID, EIOCSFLAGS, (void *)IFF_PROMISC);
  307. }
  308. int
  309. bcmRoboTx(UINT8 *b, int l)
  310. {
  311.     M_BLK_ID pMblk;
  312.     pMblk = netTupleGet(robo_txrx_info.roboNetPoolID, l,
  313.                         M_DONTWAIT, MT_DATA,FALSE);
  314.     if (pMblk == NULL) {
  315.         robo_txrx_info.tx_fail++;
  316.         return(0);
  317.     }
  318.     /* cache invalidate */
  319.     /* CACHE_INVALIDATE(pMblk->m_data, l); */
  320.     pMblk->mBlkHdr.mFlags  |= M_PKTHDR;
  321.     pMblk->mBlkHdr.mLen     = l;
  322.     pMblk->mBlkPktHdr.len   = l;
  323.     memcpy(pMblk->m_data, b, l);
  324.     return (_roboTx(pMblk));
  325. }
  326. int
  327. roboMIIRxHandlerRegister(cb_f cf, alloc_f af, free_f ff)
  328. {
  329.     if (robo_txrx_info.rx_cb == NULL) {
  330.         robo_txrx_info.rx_alloc = af;
  331.         robo_txrx_info.rx_free = ff;
  332.         robo_txrx_info.rx_cb = cf;
  333.         return(1);
  334.     } else {
  335.         return(0);
  336.     }
  337. }
  338. int
  339. roboMIIRxHandlerUnRegister(cb_f f)
  340. {
  341.     if (robo_txrx_info.rx_cb == f) {
  342.         robo_txrx_info.rx_cb = NULL;
  343.         return(1);
  344.     } else {
  345.         return(0);
  346.     }
  347. }
  348. void robo_rx_drain_pkts()
  349. {
  350.     M_BLK_ID pMblk, cMblk;
  351.     int s;
  352.     s = intLock();
  353.     pMblk = robo_txrx_info.rx_head;
  354.     robo_txrx_info.rx_tail = robo_txrx_info.rx_head = NULL;
  355.     while(pMblk) {
  356.         cMblk = pMblk;
  357.         netMblkClChainFree(cMblk);
  358.         pMblk = pMblk->mBlkHdr.mNextPkt;
  359.     }
  360. }
  361. void robo_rx_q_pkts(M_BLK_ID pMblk, int dummy)
  362. {
  363.     M_BLK_ID qMblk;
  364.     int s;
  365.     s = intLock();
  366.     if (robo_txrx_info.rx_tail == NULL ) {
  367.         robo_txrx_info.rx_tail = pMblk;
  368.         robo_txrx_info.rx_head = pMblk;
  369.     } else {
  370.         qMblk = robo_txrx_info.rx_tail;
  371.         qMblk->mBlkHdr.mNextPkt = pMblk;
  372.         robo_txrx_info.rx_tail = pMblk;
  373.         pMblk->mBlkHdr.mNextPkt = NULL;
  374.     }
  375.     intUnlock(s);
  376.     ROBO_TXRX_PRINT("Queued a packet %08xn", (int)pMblk, 2, 3, 4, 5, 6);
  377.     /* Indicate that a packet is available */
  378.     /* semTake(robo_txrx_info.rx_sem, WAIT_FOREVER); */
  379. }
  380. void bcm_robo_mii_rx(UINT8 *b, int *l)
  381. {
  382.     M_BLK_ID pMblk;
  383.     int s;
  384.     int n = 10;
  385.     *l = 0;
  386.     while(*l == 0) {
  387.         pMblk = robo_txrx_info.rx_head;
  388.         if (pMblk != NULL) {
  389.             s = intLock();
  390.             robo_txrx_info.rx_head = pMblk->mBlkHdr.mNextPkt;
  391.             if (robo_txrx_info.rx_head == NULL) {
  392.                 robo_txrx_info.rx_tail = NULL;
  393.             }
  394.             intUnlock(s);
  395.             *l = pMblk->mBlkPktHdr.len;
  396.             netMblkToBufCopy(pMblk, b, NULL);
  397.             netMblkClChainFree(pMblk);
  398.             ROBO_TXRX_PRINT("DeQueued a packet %08x len = %dn",
  399.                             (int)pMblk, *l, 3, 4, 5, 6);
  400.         } else {
  401.             /* Wait for a packet */
  402.             /* semTake(robo_txrx_info.rx_sem); */
  403.             taskDelay(1);
  404.             if (!(n--)) break;
  405.         }
  406.     }
  407. }
  408. void bcm_robo_mii_rx_start()
  409. {
  410.     ROBO_TXRX_PRINT("bcm_robo_mii_rx_startn", 1, 2, 3, 4, 5, 6);
  411.     robo_txrx_info.queue_rx_pkts = 1;
  412.     roboMIIRxHandlerRegister(robo_rx_q_pkts, NULL, NULL);
  413. }
  414. void bcm_robo_mii_rx_stop()
  415. {
  416.     ROBO_TXRX_PRINT("bcm_robo_mii_rx_stopn", 1, 2, 3, 4, 5, 6);
  417.     if (roboMIIRxHandlerUnRegister(robo_rx_q_pkts)) {
  418.         robo_txrx_info.queue_rx_pkts = 0;
  419.         robo_rx_drain_pkts();
  420.     }
  421. }
  422. #ifdef ROBO_TXRX_DEBUG
  423. /* debug */
  424. LOCAL void
  425. robo_rx_test_cb(char *buf, int len)
  426. {
  427.     logMsg("robo_rx_test_cb:",1,2,3,4,5,6);
  428.     robo_txrx_pp(buf, len);
  429.     free(buf);
  430. }
  431. void
  432. robo_tx_netpool_show()
  433. {
  434.     netPoolShow(robo_txrx_info.roboNetPoolID);
  435. }
  436. void
  437. robo_rx_test()
  438. {
  439.     roboMIIRxHandlerRegister(robo_rx_test_cb, malloc, free);
  440. }
  441. void
  442. robo_tx_test(int l)
  443. {
  444.     if (l > 512) {
  445.         l = 64;
  446.     }
  447.     if (!bcmRoboTx(robo_tx_test_pkbuf, l)) {
  448.         logMsg("Robo TX failed",1,2,3,4,5,6);
  449.     }
  450. }
  451. #endif