⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cisaironetend.c

📁 vworks 下wlan的实现代码
💻 C
📖 第 1 页 / 共 4 页
字号:
/* cisAironetEnd.c - END driver for the Cisco Aironet 340/350 WLAN card *//* Copyright 2001-2003 Wind River Systems, Inc. *//*modification history--------------------02z,09may03,rb  Removed warnings caused by IPv6 integration02y,30apr03,ss  removed SUBEND references02x,26feb03,ss  Fixed diab compiler warnings02w,25oct02,ss  Fixed bug in ISR - Ack only events that just occurred, not all                 events02v,18may02,eja  performance enhancements02u,17may02,eja  Fix for data sent at fast rate.02t,09may02,dxb  Removed CIS_AIRONET_SLEEP and CIS_AIRONET_WAKEUP.02s,06may02,cjl  Diab warning suppression: added # to if _BYTE_ORDER...02r,06may02,cjl  Diab warning suppression: int to unsigned int in                 cisAironetEndIoctl02q,03may02,dxb  Updated header comments.02p,24apr02,dxb  Initialize pMCTable in cisAironetEndMCastAdd() to fix                 stormpad boot problem.02o,20apr02,ss  changed function ptr's for endian safe in/out routines02n,18apr02,eja  Added sub-end functionality.02m,16apr02,ss  changed use of pBSP in cisAironetEndLoad02l,09apr02,ss  Updated to set card access func ptr's in dev struct02k,09apr02,dxb  Removed compiler warnings.02j,08apr02,eja  Code clean up for FCS.02i,05apr02,eja  Got rid of packet snoop code.02h,20mar02,dxb  Removed compiler warnings.02g,08mar02,eja  Added bug fixes for power save mode.02f,19feb02,cjl  Changed cisAironetEndIoctl from LOCAL to public, so relocated                 prototype to cisAironet.h02e,19feb02,cjl  Removed #include "etherLib.h"02d,14feb02,eja  Got Rid of DOT11 references.02c,06feb02,dxb  More changes for wlanEnd.h.02b,05feb02,dxb  Updated to include changes in wlanEnd.h.02a,04feb02,eja  Made changes to ISR to optimize speed and fix                 interoperability issues.01z,26nov01,eja  Fixed MTU size to 1500 bytes.01y,26nov01,rb  Removed keep-alive thread01x,26nov01,eja  Changed priority of keep alive thread to 60.01w,26nov01,eja  Added keep alive thread for stormpad bsp.01v,19nov01,rb   Made driver big endian compatible01a,07nov01,eja  Fix header path error.*//*DESCRIPTIONThis module provides the END functionality for the Cisco Aironet 340/350wireless 802.11b driver.PARAMETERSSome 802.11b-specific parameters must be configured by the host applicationin order to ensure proper 802.11b operation.  The default values for theseparameters can be found in configWlan.h, and can also be set using theappropriate ioctl() value.  For more information, refer to configWlan.h.INCLUDE FILES: cisAironet.h, wlanEnd.hSEE ALSO: cisAironetHw,c, cisAironetShow.c, configWlan.h*/#include <vxWorks.h>#include <string.h>#include "cacheLib.h"#include "intLib.h"#include "semLib.h"#include "logLib.h"#include "netLib.h"#include "stdio.h"#include "sysLib.h"#include "memLib.h"#include "end.h"			/* Common END structures. */#include "endLib.h"#ifdef  ETHER_MAP_IP_MULTICAST#undef  ETHER_MAP_IP_MULTICAST#endif#include "etherMultiLib.h"		/* multicast stuff. */#include "net/mbuf.h"#include <taskLib.h>#include <rngLib.h>#include "wrn/wlan/wlanEnd.h"#include "wrn/wlan/cisAironet.h"/*************************************************************************** *  Debugging facilities - these may be enabled from the shell by changing *  the value of ANET_DEBUG.  Error levels are defined in aironet.h ***************************************************************************/INT32 anetDebug = DEBUG_ERROR;/*************************************************************************** * Local variables ***************************************************************************//* Pointer to a linked list of all instances of the driver */LOCAL CARD_CTRL_T * pAnetHead = NULL; /*************************************************************************** * Local Prototypes ***************************************************************************/LOCAL STATUS cisAironetEndMCastAdd (END_OBJ *, UINT8 *);LOCAL STATUS cisAironetEndMCastDel (END_OBJ *, UINT8 *);LOCAL STATUS cisAironetEndMCastGet (END_OBJ *, MULTI_TABLE *);LOCAL STATUS cisAironetEndStart    (END_OBJ *); LOCAL STATUS cisAironetEndStop     (END_OBJ *); LOCAL STATUS cisAironetEndSend     (CARD_CTRL_T *, M_BLK_ID);LOCAL STATUS cisAironetEndUnload   (END_OBJ *); LOCAL STATUS cisAironetEndMemInit  (CARD_CTRL_T *);  LOCAL STATUS cisAironetEndISR      (CARD_CTRL_T *);LOCAL STATUS cisAironetEndParse    (CARD_CTRL_T *, UINT8 *);LOCAL STATUS cisAironetEndReceive  (CARD_CTRL_T *, UINT8 *, INT32);LOCAL STATUS cisAironetEndFlags    (CARD_CTRL_T *);LOCAL int    cisAironetEndIoctl    (END_OBJ *, unsigned int, caddr_t); /* External references */IMPORT INT32 endMultiLstCnt (END_OBJ *);IMPORT STATUS sysWlanCfgParamGet (UINT32 cmd, INT32 data);/* BSP specific card access routines */IMPORT UINT8  sysWlanIOInByte        (UINT32);IMPORT void   sysWlanIOOutByte       (UINT32, UINT8);IMPORT UINT16 sysWlanIOInWord        (UINT32);IMPORT void   sysWlanIOOutWord       (UINT32, UINT16);IMPORT UINT32 sysWlanIOInLong        (UINT32);IMPORT void   sysWlanIOOutLong       (UINT32, UINT32);IMPORT UINT8  sysWlanMemInByte       (UINT32);IMPORT void   sysWlanMemOutByte      (UINT32, UINT8);IMPORT UINT16 sysWlanMemInWord       (UINT32);IMPORT void   sysWlanMemOutWord      (UINT32, UINT16);IMPORT UINT32 sysWlanMemInLong       (UINT32);IMPORT void   sysWlanMemOutLong      (UINT32, UINT32);IMPORT UINT16 sysWlanIOInWord        (UINT32);IMPORT void   sysWlanIOOutWord       (UINT32, UINT16);IMPORT UINT32 sysWlanIOInLong        (UINT32);IMPORT void   sysWlanIOOutLong       (UINT32, UINT32);IMPORT UINT8  sysWlanMemInByte       (UINT32);IMPORT void   sysWlanMemOutByte      (UINT32, UINT8);IMPORT UINT16 sysWlanMemInWord       (UINT32);IMPORT void   sysWlanMemOutWord      (UINT32, UINT16);IMPORT UINT32 sysWlanMemInLong       (UINT32);IMPORT void   sysWlanMemOutLong      (UINT32, UINT32);UINT16 sysWlanMemEndianInWord        (UINT32);void   sysWlanMemEndianOutWord       (UINT32, UINT16);UINT16 sysWlanIOEndianInWord         (UINT32);void   sysWlanIOEndianOutWord        (UINT32, UINT16);/*************************************************************************** *       Basic END functions * These are the basic functions that are required to implement an END driver ***************************************************************************/NET_FUNCS cisAironetEndFuncTable =     {    (FUNCPTR)cisAironetEndStart,     /* Function to start the device.      */    (FUNCPTR)cisAironetEndStop,      /* Function to stop the device.       */    (FUNCPTR)cisAironetEndUnload,    /* Unloading function for the drive   */    (FUNCPTR)cisAironetEndIoctl,     /* Ioctl function for the driver.     */    (FUNCPTR)cisAironetEndSend,	     /* Send function for the driver.      */    (FUNCPTR)cisAironetEndMCastAdd,  /* Multicast add function for the drv */    (FUNCPTR)cisAironetEndMCastDel,  /* Multicast delete function          */    (FUNCPTR)cisAironetEndMCastGet,  /* Multicast retrieve function        */    (FUNCPTR)NULL,	                 /* Polling send function              */    (FUNCPTR)NULL,	                 /* Polling receive function           */    endEtherAddressForm,	         /* put address info into a NET_BUFFER */    endEtherPacketDataGet,           /* get pointer to data in NET_BUFFER  */    endEtherPacketAddrGet            /* Get packet addresses.              */    };/**************************************************************************** cisAironetEndLoad - END load function for the WLAN driver** This routine is an END load routine, designed to be called twice* per instance of the driver.  The first time, it is called with a null * (empty) initString and the device name is copied into the init string.* The second time, a proper init string is passed in.  The routine examines* the linked list of existing instances to determine if the unit number * already exists.  If this is not the case, it creates a new instance of the* driver.** Parameters are passed to the Cisco Aironet Load routine in an* initialization string of the form: <ioBase>:<iVector>:<iLevel>:<offset>* *    ioBase  :  Base address of the I/O space for the card which should*               be determined by the PCMCIA module*    iVector :  Interrupt vector for the card that is system dependent*    iLevel  :  Interrupt level for the card that is system dependent*    offset  :  a value of 2 enables word alignment* * RETURNS: Pointer to the device handle created, or NULL on error** ERRNO: N/A** SEE ALSO: muxLib, muxDevLoad()*/END_OBJ * cisAironetEndLoad    (    char * initString,   /* Initial parameters to initialize device with */    void * pBSP          /* A UINT8 value that identifies card access method */    )    {    CARD_CTRL_T * pWlanDev    = NULL;    INT32         unitNum = 0;    STATUS        result  = 0;    UINT32        i       = 0;    UINT16        txFID   = 0;    ANET_DEBUG(DEBUG_INFO,                ("cisAironetEndLoad : Loading Wireless Local Area Network"                " Driver \n"));      /* Check that we got a valid init string.  "Null string" for the first    pass means it contains no data.  The string must still exist */    if (initString == NULL)        {        ANET_DEBUG(DEBUG_ERROR,                    ("cisAironetEndLoad : NULL initString\n"));        return (NULL);        }    /*      * If we're on the first pass, then the first character of the      * initstring must be 0x00      */    if (initString[0] == 0x00)        {        ANET_DEBUG(DEBUG_INFO,                    ("cisAironetEndLoad : First Pass.  Returning i/f name"                    "%s\n",ANET_IFNAME));        (void) bcopy (ANET_IFNAME, initString, strlen (ANET_IFNAME) );         /* Add a terminating NULL char, so we don't have to rely on the init        string to be initially zeroed */        initString[strlen (ANET_IFNAME)] = 0x00;        return (NULL);        }    ANET_DEBUG(DEBUG_INFO,                ("cisAironetEndLoad : Second Pass!\n"));      /* If we got this far, then we're on our second pass, and the unit number    is the first character of the string (assuming we have <10 devices,     which is probably a reasonable assumption */    unitNum = (INT32)initString[0] - 0x30;        /* Search the list of instances of this driver, to see if a device with    this unit num already exists */    for (pWlanDev = pAnetHead; (pWlanDev != NULL)&&(pWlanDev->pNext != NULL);          pWlanDev = pWlanDev->pNext)        if (pWlanDev->unitNum == unitNum)            {            ANET_DEBUG(DEBUG_FATAL,                       ("cisAironetEndLoad : driver with unitnum %d already"                        "exists.\n", unitNum));            goto fatal_error;            }    /*     Since one doesn't exist, we need to create one.  Go to the end of the    list and do so.  Check if this is the first node, handle that     specially.    */    if (pAnetHead == (CARD_CTRL_T *)NULL) /* Check for empty list */        {        ANET_DEBUG(DEBUG_INFO,                    ("cisAironetEndLoad: Creating initial node\n"));        pWlanDev = (CARD_CTRL_T *) calloc(1, sizeof (CARD_CTRL_T));        pAnetHead = pWlanDev;        ANET_DEBUG(DEBUG_INFO,                   ("pAnetHead = 0x%08x\n", (UINT32) pAnetHead));        if (pWlanDev == NULL )            {            ANET_DEBUG(DEBUG_FATAL,                        ("cisAironetEndLoad : Error allocating memory\n"));            goto fatal_error;            }                }        else /* Add instance at end of linked list */        {        ANET_DEBUG(DEBUG_INFO, ("cisAironetEndLoad: Adding new node\n"));        for (pWlanDev = pAnetHead; pWlanDev->pNext != NULL;              pWlanDev = pWlanDev->pNext);               pWlanDev->pNext = (CARD_CTRL_T *)calloc(1, sizeof(CARD_CTRL_T));        if (pWlanDev->pNext == NULL)            {            ANET_DEBUG(DEBUG_FATAL,                        ("cisAironetEndLoad : Error allocating memory\n"));            goto fatal_error;            }        pWlanDev = pWlanDev->pNext;        }    /* Set the new next pointer to Null,because we're at the end of the list */    pWlanDev->pNext = NULL;        ANET_DEBUG(DEBUG_INFO,                ("cisAironetEndLoad: Structure Allocated\n"));        /* set the card access type and access functon ptr's */    pWlanDev->accessType = (UINT32) ((void *) pBSP);    if ( (pWlanDev->accessType & WLAN_ACCESS_TYPE_MASK) == WLAN_IO_ACCESS)         {        /* set card access function ptr's to the BSP specific I/O           access routines */        pWlanDev->IN_8 =   sysWlanIOInByte;        pWlanDev->IN_16 =  sysWlanIOInWord;        pWlanDev->IN_32 =  sysWlanIOInLong;        pWlanDev->OUT_8 =  sysWlanIOOutByte;        pWlanDev->OUT_16 = sysWlanIOOutWord;        pWlanDev->OUT_32 = sysWlanIOOutLong;        #if (_BYTE_ORDER == _BIG_ENDIAN)             {            pWlanDev->IN_16_ENDIAN = sysWlanIOEndianInWord;            pWlanDev->OUT_16_ENDIAN = sysWlanIOEndianOutWord;            }#else             {            pWlanDev->IN_16_ENDIAN = sysWlanIOInWord;            pWlanDev->OUT_16_ENDIAN = sysWlanIOOutWord;            }#endif                ANET_DEBUG(DEBUG_FLOOD,("cisAironetEndLoad: configuring card access "                                "routines as I/O based\n"));                   }    else if ( (pWlanDev->accessType & WLAN_ACCESS_TYPE_MASK) ==              WLAN_MEM_ACCESS)         {        /* set card access function ptr's to the BSP specific direct            Memory access routines */                pWlanDev->IN_8 = sysWlanMemInByte;        pWlanDev->IN_16 = sysWlanMemInWord;        pWlanDev->IN_32 = sysWlanMemInLong;        pWlanDev->OUT_8 = sysWlanMemOutByte;        pWlanDev->OUT_16 = sysWlanMemOutWord;        pWlanDev->OUT_32 = sysWlanMemOutLong;        #if (_BYTE_ORDER == _BIG_ENDIAN)             {            pWlanDev->IN_16_ENDIAN = sysWlanMemEndianInWord;            pWlanDev->OUT_16_ENDIAN = sysWlanMemEndianOutWord;            }#else             {            pWlanDev->IN_16_ENDIAN = sysWlanMemInWord;            pWlanDev->OUT_16_ENDIAN = sysWlanMemOutWord;            }#endif        ANET_DEBUG(DEBUG_FLOOD,("cisAironetEndLoad: configuring card access "                                "routines as Mem mapped\n"));       }            /* Fill the strucuture with data gleaned from the initString */    if ( cisAironetEndParse(pWlanDev, (UINT8 *)initString)          == ERROR )        {        ANET_DEBUG(DEBUG_FATAL,                   ("cisAironetEndLoad: Error in cisAironetEndParse\n"));        goto fatal_error;        }    ANET_DEBUG(DEBUG_INFO,               ("cisAironetEndLoad: pWlanDev = 0x%08x\n", (UINT32)pWlanDev));    if ((pWlanDev->txComplete = semCCreate(SEM_Q_FIFO, 6))         == NULL)        {        ANET_DEBUG(DEBUG_FATAL, ("cisAironetEndLoad: semCCreate failed\n"));        goto fatal_error;        }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -