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

📄 cisaironethw.c

📁 vworks 下wlan的实现代码
💻 C
📖 第 1 页 / 共 5 页
字号:
        rates[count] = rate;        count += 1;        }    if (pDev->txRate & WLAN_2_MBIT) /* 2 Mbit */        {        rate = 0x04;        if (pDev->basicRates & WLAN_2_MBIT)            {            rate |= ANET_BASIC_RATE_SET;            }         rates[count] = rate;        count += 1;        }    if (pDev->txRate & WLAN_5_MBIT) /* 5.5 MBit */        {        rate = 0x0B;         if (pDev->basicRates & WLAN_5_MBIT)            {            rate |= ANET_BASIC_RATE_SET;            }         rates[count] = rate;        count += 1;        }    if (pDev->txRate & WLAN_11_MBIT) /* 11 Mbit */        {        rate = 0x16;        if (pDev->basicRates & WLAN_11_MBIT)            {            rate |= ANET_BASIC_RATE_SET;            }         rates[count] = rate;        count += 1;         }                           /* set the last rate entry to be zero */    rates[count] = 0x00;         /* write the rates to the config RID */    cisAironetBcopy (pDev, rates, pCfg->rates, count+1);          /* Get the default station name and save it to the config RID */    (void) sysWlanCfgParamGet (WLAN_STATION_NAME, (INT32) pCfg->nodeName);    /* get temp buffer */    pBuf = (UINT8*) calloc (80, sizeof (UINT8));    /* Get the SSID */    (void) sysWlanCfgParamGet (WLAN_SSID, (INT32) pBuf);    /* Save the SSID to the card and swap if big endian machine */    cisAironetBcopy (pDev, (const UINT8 *) pBuf,                     (UINT8 *) pSsid->ssid, (UINT16) strlen((char *) pBuf));        /* Set the SSID length */    pSsid->len = strlen ((char *) pBuf);    /* release the resource */    free (pBuf);    /* Commit the config RID to the card */    if ( cisAironetHwRidConfigSet (pDev, (void *) &cfg)        == ERROR )        {        ANET_DEBUG(DEBUG_FATAL,                ("cisAironetHwInit: error setting card config\n"));        return (ERROR);        }    /* Commit the SSID RID to the card */    if ( cisAironetHwRidSSIDSet (pDev, (void *) &ssidList)        == ERROR )        {        ANET_DEBUG(DEBUG_FATAL,                ("cisAironetHwInit: error setting ssid\n"));        return (ERROR);        }   /* Enable the Mac again */    if ( cisAironetHwMacEnable (pDev)          == ERROR )        {        ANET_DEBUG(DEBUG_FATAL,                ("cisAironetHwInit: error enabling mac\n"));        return (ERROR);        }       /* Get the driver power save state */    (void) sysWlanCfgParamGet (WLAN_PMANAGE_ENABLE, (INT32) &powerSave);    if (powerSave == WLAN_PMANAGE_ENABLED)        {        /* Set the card into PSP (Power Save Protocol) */        if (cisAironetHwPwrModeSet (pDev, ANET_POWERSAVE_PSP) == ERROR)            {            ANET_DEBUG(DEBUG_ERROR,                       ("cisAironetHwInit: error enabling powersave mode\n"));            }        }    else        {        /* Set the card into CAM (Constant Awake Mode) */        if (cisAironetHwPwrModeSet (pDev, ANET_POWERSAVE_CAM) == ERROR)            {            ANET_DEBUG(DEBUG_ERROR,                       ("cisAironetHwInit: error disabling powersave mode\n"));            }        }    /* Assume 802.1x mode is diabled on boot up */    pDev->dot1XStatus = ONEX_MODE_DISABLED;        /* Save reference to control object */    pDrv = pDev;    /* return - status */    return (OK);    }/**************************************************************************** cisAironetHwDrvIDGet - Returns address of driver control structure.  ** Returns address of the driver control structure.* * RETURNS : address of the driver control structure    ** ERRNO : N/A** SEE ALSO:** NOMANUAL*/INT32 cisAironetHwDrvIDGet (void)    {    /* return - driver ID */    return ( (INT32) pDrv );    }/*=========================================================================*//*                                                                         *//*                       CARD COMMAND ROUTINES                             *//*                                                                         *//*=========================================================================*//**************************************************************************** cisAironetHwCmdIssue - Issues a command to the aironet card.  ** Sends the command to the card. The command is contained in a command object* that is passed in via the driver control structure.  * * RETURNS : OK or ERROR if command fails, or a NULL pointer is passed in.     ** ERRNO : N/A** SEE ALSO: Cisco Aironet 340/350 Driver Programmer's Manual*/LOCAL STATUS cisAironetHwCmdIssue     (    CARD_CTRL_T * pWlanDev  /* Driver control struct */     )    {    INT16         status    = OK;    UINT32        timeOut   = ANET_CMD_TIMEOUT;     CARD_CMD_T *  pCmdObj   = NULL;    CARD_RESP_T * pRespObj  = NULL;        /* Sanity check */    if (pWlanDev == NULL)         {        ANET_DEBUG(DEBUG_ERROR,                    ("CmdIssue: Error NULL pointer\n"));        return (ERROR);        }    /* Set up pointers to response and param objects */    pCmdObj  = (CARD_CMD_T *) &pWlanDev->macCmd;    pRespObj = (CARD_RESP_T *) &pWlanDev->macResp;    /* Issue the command to the MAC */    WLAN_OUT_16( (UINT32) &pWlanDev->macReg->param0,  pCmdObj->param0);    WLAN_OUT_16( (UINT32) &pWlanDev->macReg->param1,  pCmdObj->param1);    WLAN_OUT_16( (UINT32) &pWlanDev->macReg->param2,  pCmdObj->param2);    WLAN_OUT_16( (UINT32) &pWlanDev->macReg->command, pCmdObj->command);    /* Wait until command complete or time out expires */    while ( ((WLAN_IN_16((UINT32) &pWlanDev->macReg->evStat) &               ANET_EVENT_CMD) == 0) &&             (timeOut-- > 0))        {        /* Check if the 340/350 got the command */        if ( WLAN_IN_16((UINT32) &pWlanDev->macReg->command)              == pCmdObj->command)            {            /* Must have missed the command so try again */            WLAN_OUT_16((UINT32) &pWlanDev->macReg->command,pCmdObj->command);            }        }    /* Check to see if we timed out */    if (timeOut == 0)        {        status = ERROR;        ANET_DEBUG(DEBUG_ERROR,                    ("CmdIssue: Error command timeout\n"));        }    /*      * Command must have succeeded - so lets get      * the status and response      */    pRespObj->status = WLAN_IN_16( (UINT32) &pWlanDev->macReg->status);    pRespObj->resp0  = WLAN_IN_16( (UINT32) &pWlanDev->macReg->resp0);    pRespObj->resp1  = WLAN_IN_16( (UINT32) &pWlanDev->macReg->resp1);    pRespObj->resp2  = WLAN_IN_16( (UINT32) &pWlanDev->macReg->resp2);    /* Clear the stuck command busy bit if busy */    if ( (WLAN_IN_16( (UINT32) &pWlanDev->macReg->command) & ANET_CMD_BUSY)         == ANET_CMD_BUSY )        {        /* Clear the busy bit */        WLAN_OUT_16( (UINT32) &pWlanDev->macReg->evAck,                     ANET_EVENT_CLR_CMD_BUSY);        }    /* Acknowledge the event */    WLAN_OUT_16( (UINT32) &pWlanDev->macReg->evAck, ANET_EVENT_CMD);    /* Return the status */    return (status);    }/**************************************************************************** cisAironetHwCardReset - Issues the aironet card reset command.* * Sets the aironet cards firmware into a starting state.* * RETURNS : OK or ERROR if a NULL pointer is passed in or the card init *           command fails.** ERRNO : N/A** SEE ALSO: Cisco Aironet 340/350 Driver Programmer's Manual** NOMANUAL*/STATUS cisAironetHwCardReset     (    CARD_CTRL_T * pWlanDev /* Driver control struct */    )    {    STATUS       status  = OK;    CARD_CMD_T * pCmdObj = NULL;    /* sanity check */    if (pWlanDev == NULL)        {        ANET_DEBUG(DEBUG_ERROR,                   ("cisAironetHwCardReset: error NULL pointer\n"));        return (ERROR);        }    /* Get reference to command object */    pCmdObj  = (CARD_CMD_T *) &pWlanDev->macCmd;    /* Send the Init command to the card */    pCmdObj->param0  = 0;    pCmdObj->param1  = 0;    pCmdObj->param2  = 0;    pCmdObj->command = ANET_FWARE_RESTART;    (void) cisAironetHwCmdIssue (pWlanDev);    /* return - status */    return (status);    }/**************************************************************************** cisAironetHwCardInit - Issues the aironet card init command (NOP).* * Sets the aironet cards firmware into a starting state.* * RETURNS : OK or ERROR if a NULL pointer is passed in or the card init *           command fails.** ERRNO : N/A** SEE ALSO: Cisco Aironet 340/350 Driver Programmer's Manual*/LOCAL STATUS cisAironetHwCardInit    (    CARD_CTRL_T * pWlanDev    )    {    CARD_CMD_T * pCmdObj = NULL;    /* sanity check */    if (pWlanDev == NULL)        {        ANET_DEBUG(DEBUG_ERROR,                   ("cisAironetHwCardInit: error NULL pointer\n"));        return (ERROR);        }    /* Get reference to command object */    pCmdObj  = (CARD_CMD_T *) &pWlanDev->macCmd;    /* Send the Init command to the card */    pCmdObj->param0  = 0;    pCmdObj->param1  = 0;    pCmdObj->param2  = 0;    pCmdObj->command = ANET_NOP;    if ( (cisAironetHwCmdIssue (pWlanDev)   == ERROR) ||         (cisAironetHwErrorCheck (pWlanDev) != 0) )        {        ANET_DEBUG(DEBUG_ERROR,                   ("cisAironetHwCardInit: command failed %s\n",                     (UINT8 *) cisAironetHwErrorDesc ()));        return (ERROR);        }    ANET_DEBUG(DEBUG_INFO,               ("cisAironetHwCardInit: command success\n"));    /* return - status */    return (OK);    }/**************************************************************************** cisAironetHwMacDisable - Issues the aironet card mac disable command.* * Sets the aironet cards mac into a non-operational state.* * RETURNS : OK or ERROR if a NULL pointer is passed in or the mac disable *           command fails.** ERRNO : N/A** SEE ALSO: Cisco Aironet 340/350 Driver Programmer's Manual** NOMANUAL*/STATUS cisAironetHwMacDisable    (    CARD_CTRL_T * pWlanDev    )    {    CARD_CMD_T * pCmdObj = NULL;    /* sanity check */    if (pWlanDev == NULL)        {        ANET_DEBUG(DEBUG_ERROR,                   ("cisAironetHwMacDisable: error NULL pointer\n"));        return (ERROR);        }        /* Get reference to command object */    pCmdObj  = (CARD_CMD_T *) &pWlanDev->macCmd;    /* Disable MAC */    pCmdObj->param0  = 0;    pCmdObj->param1  = 0;    pCmdObj->param2  = 0;    pCmdObj->command = ANET_DISABLE;        if ( cisAironetHwCmdIssue (pWlanDev) == ERROR )         {        ANET_DEBUG(DEBUG_ERROR,                   ("cisAironetHwMacDisable: command failed\n"));        return (ERROR);        }    /* return - status */    return (OK);    }/**************************************************************************** cisAironetHwMacEnable - Issues the aironet card mac enable command.* * Sets the aironet cards mac into a operational state.* * RETURNS : OK or ERROR if a NULL pointer is passed in or the mac enable *           command fails.** ERRNO : N/A** SEE ALSO: Cisco Aironet 340/350 Driver Programmer's Manual* * NOMANUAL*/STATUS cisAironetHwMacEnable    (    CARD_CTRL_T * pWlanDev    )    {    CARD_CMD_T * pCmdObj = NULL;   /* Sanity check */    if (pWlanDev == NULL)        {        ANET_DEBUG(DEBUG_ERROR,                    ("cisAironetHwMacEnable: Error NULL pointer\n"));        return (ERROR);        }    /* Set up pointers to response and param objects */    pCmdObj  = (CARD_CMD_T *) &pWlanDev->macCmd;    /* Enable the Mac */    pCmdObj->param0  = 0;    pCmdObj->param1  = 0;    pCmdObj->param2  = 0;    pCmdObj->command = ANET_ENABLE;    if ( (cisAironetHwCmdIssue (pWlanDev)   == ERROR) ||         (cisAironetHwErrorCheck (pWlanDev) != 0) )        {        ANET_DEBUG(DEBUG_ERROR,                    ("cisAironetHwMacEnable: Error issuing command %s\n",                    (UINT8 *) cisAironetHwErrorDesc ()));        return (ERROR);        }    /* return - status */    return (OK);    }/**************************************************************************** cisAironetHwScanStart - Start scanning for a new SSID.* * * RETURNS : OK or ERROR on NULL pointer passed in as a parameter. ** ERRNO : N/A** SEE ALSO: Cisco Aironet 340/350 Driver Programmer's Manual** NOMANUAL*/STATUS cisAironetHwScanStart 

⌨️ 快捷键说明

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