📄 cisaironethw.c
字号:
void cisAironetHwEventUnknownAck ( CARD_CTRL_T * pWlanDev /* Driver control struct */ ) { WLAN_OUT_16( (UINT32) &pWlanDev->macReg->evAck, ANET_EVENT_UNKNOWN); }/*=========================================================================*//* *//* CARD MEMORY ACCESS ROUTINES *//* *//*=========================================================================*//**************************************************************************** cisAironetTxCtrlHdrGet - Reads a ethernet packet tx control header.* * RETURNS : OK** ERRNO : N/A** SEE ALSO: Cisco Aironet 340/350 Driver Programmer's Manual** NOMANUAL*/STATUS cisAironetTxCtrlHdrGet ( CARD_CTRL_T * pWlanDev, CARD_TX_CTRL_HDR_T * pHdr, UINT16 txFID ) { /* Set up the BAP */ (void) cisAironetHwBapSetup (pWlanDev, txFID, PKT_CTRL_HDR_OFFSET, ANET_BAP1); /* Read the 802.11 tx header data */ (void) cisAironetHwBapRead (pWlanDev, (UINT16 *) pHdr, sizeof (ANET_TX_CTRL_HDR_T), ANET_BAP1); return (OK); }/**************************************************************************** cisAironetHwEthernetPktGet - Reads an ethernet packet from the aironet card.* * Copies the aironet cards ethernet packet into the data buffer which is * passed in.** RETURNS : numBytes (number of bytes read), or 0 on ERROR** ERRNO : N/A** SEE ALSO: Cisco Aironet 340/350 Driver Programmer's Manual** NOMANUAL*/UINT16 cisAironetHwEthernetPktGet ( CARD_CTRL_T * pWlanDev, /* Driver control struct */ UINT16 * rxStatus, UINT16 * pData /* data buffer */ ) { FAST UINT16 numBytes = 0; FAST UINT16 nBytes = 0; FAST UINT16 payloadLen = 0; UINT16 buf[2]; /* Set up the buffer access path to point to 802.3 header on card */ (void) cisAironetHwBapSetup(pWlanDev, WLAN_IN_16((UINT32)&pWlanDev->macReg->rxFID), PKT_802_3_HDR_OFFSET, ANET_BAP0); /* * Get the first 2 words from the enet packet , * status, and payload length. */ (void) cisAironetHwBapRead (pWlanDev, &buf[0], 4, ANET_BAP0); /* get the status and payload size */ *rxStatus = buf[0]; payloadLen = buf[1]; /* * Add 12 bytes (dest and src address) to the data size * Note: The payload length includes the Enet_Hdr + data + * type field. The extra 12 bytes added on are part * of the cards 802.3 header (see Cisco Aironet 340/350 * developers manual). */ numBytes = payloadLen + (WLAN_ENET_ADDR_LEN << 1); /* Boundary check - small or large packet */ if (numBytes < 12) { numBytes = 0; goto done; } /* * copy the data into the network buffer * (including dest and src adresses). */ /* round length up to a 16 bit aligned value */ nBytes = numBytes = ROUND_UP (numBytes, 2); /* Pass the data from the Card into the buffer * Note: each access to DATA0 or DATA1 will auto-increment * the buffer pointer. */ while (nBytes > 0) { *pData = WLAN_IN_16_ENDIAN (((UINT32) &pWlanDev->macReg->data0) + ANET_BAP0); pData++; nBytes -= 2; } done: /* return - number of bytes read from the card */ return (numBytes); }/**************************************************************************** cisAironetHwTxFidGet - Gets a transmit buffer ID and sets up the payload * length, and control header on the card.* * Gets a transmit buffer ID and sets up the payload length, and control * header on the card.** RETURNS : transmit buffer ID or 0 on ERROR** ERRNO : N/A** SEE ALSO: Cisco Aironet 340/350 Driver Programmer's Manual** NOMANUAL*/UINT16 cisAironetHwTxFidGet ( CARD_CTRL_T * pWlanDev, /* Driver control struct */ UINT32 payloadLen /* number of payload data bytes */ ) { CARD_CMD_T * pCmdObj = NULL; CARD_RESP_T * pRespObj = NULL; UINT32 timeOut = ANET_CMD_TIMEOUT; UINT16 txControl = 0; UINT16 txFid = 0; /* Get reference into command objects */ pCmdObj = (CARD_CMD_T *) &pWlanDev->macCmd; pRespObj = (CARD_RESP_T *) &pWlanDev->macResp; /* Set up the command */ pCmdObj->param0 = payloadLen; pCmdObj->param1 = 0; pCmdObj->param2 = 0; pCmdObj->command = ANET_ALLOC_TX_BUF; /* issue the command and check the response */ if ( (cisAironetHwCmdIssue (pWlanDev) == ERROR) || (cisAironetHwErrorCheck (pWlanDev) != 0) ) { logMsg ("cisAironetHwTxFidGet: error %s\n", (INT32) cisAironetHwErrorDesc (),2,3,4,5,6); goto done; } /* wait for the allocation event request to complete */ while ( (WLAN_IN_16( (UINT32) &pWlanDev->macReg->evStat ) & ANET_EVENT_ALLOC) != ANET_EVENT_ALLOC) { if (timeOut-- == 0) { /* Exit on a timeout */ logMsg ("cisAironetHwTxFidGet: error timeout\n", 1,2,3,4,5,6); goto done; } } /* Get the FID from the card and ack the request */ txFid = WLAN_IN_16( (UINT32) &pWlanDev->macReg->txAllocFID ); /* Ack the Alloc event */ WLAN_OUT_16( (UINT32) &pWlanDev->macReg->evAck, ANET_EVENT_ALLOC ); /* set up the tx control flag */ txControl = (ANET_TX_OK | ANET_TX_EX | ANET_PKT_802_3 | ANET_PLOAD_ETHERNET | ANET_NO_RELEASE); /* set up the buffer access path */ if ( cisAironetHwBapSetup (pWlanDev, txFid, PKT_CTRL_HDR_TX_OFFSET, ANET_BAP1) == ERROR ) { logMsg ("cisAironetHwTxFidGet: error setting BAP1\n", 1,2,3,4,5,6); txFid = 0; goto done; } /* Commit tx control data to the card */ if ( cisAironetHwBapWrite (pWlanDev, (UINT16 *) &txControl, sizeof (txControl), ANET_BAP1) == ERROR) { logMsg ("cisAironetHwTxFidGet: error writing to BAP1\n", 1,2,3,4,5,6); txFid = 0; } done: return (txFid); }/**************************************************************************** cisAironetHwEthernetPktPut - Sends an ethernet packet onto the wlan.* * Copies the ethernet packet buffer that is passed via reference into the * aironet cards tranmit buffer. It then issues the transmit command.** RETURNS : OK or ERROR on tx fail or NULL pointer parameters.** ERRNO : N/A** SEE ALSO: Cisco Aironet 340/350 Driver Programmer's Manual** NOMANUAL*/STATUS cisAironetHwEthernetPktPut ( CARD_CTRL_T * pWlanDev, UINT32 nBytes /* number of bytes */ ) { FAST UINT32 numBytes = 0; UINT16 payloadLen = 0; CARD_CMD_T * pCmdObj = NULL; CARD_RESP_T * pRespObj = NULL; UINT16 * pSrc = (UINT16 *) &pWlanDev->enetPkt.header.dstAddr; /* Check for small packet */ if (nBytes < (WLAN_ENET_ADDR_LEN << 1)) { return (ERROR); } /* Get the txFid from the ring buffer */ (void) rngBufGet ((RING_ID) pWlanDev->ringID, (char *) &pWlanDev->txFID, sizeof (UINT16)); /* Get reference into command objects */ pCmdObj = (CARD_CMD_T *) &pWlanDev->macCmd; pRespObj = (CARD_RESP_T *) &pWlanDev->macResp; /* * Adjust the payload length to exclude the dest and src * enet addresses (12 bytes). */ payloadLen = nBytes - (WLAN_ENET_ADDR_LEN << 1); /* Request a tx buffer for data transfer if not already pre-allocated */ (void) cisAironetHwBapSetup (pWlanDev, pWlanDev->txFID, PKT_PAYLOAD_LEN_OFFSET, ANET_BAP1); /* Write the payload length to the card */ (void) cisAironetHwBapWrite (pWlanDev, (UINT16 *) &payloadLen, sizeof (payloadLen), ANET_BAP1); /* Write data the buffer into the Card. * Note: each access to DATA0 or DATA1 will auto-increment * the buffer pointer. */ numBytes = ROUND_UP (nBytes, 2); /* Write the ethernet packet */ while (numBytes > 0) { WLAN_OUT_16_ENDIAN (((UINT32) &pWlanDev->macReg->data0) + ANET_BAP1, *pSrc); pSrc++; numBytes -= 2; } /* Once the buffer is written to issue the tx commmand */ pCmdObj->param0 = pWlanDev->txFID; pCmdObj->param1 = 0; pCmdObj->param2 = 0; pCmdObj->command = ANET_TX_BUF; /* issue the command and check the response */ (void) cisAironetHwCmdIssue (pWlanDev); /* return - status */ return (OK); }/*=========================================================================*//* *//* CARD DIAGNOSTIC ROUTINES *//* *//*=========================================================================*//**************************************************************************** cisAironetHwLinkStatusShow - Displays the contents of the link status * register and interprets the error * code if necessary.* * Displays the contents of the link status register, and interprets the * error code if necessary.** RETURNS : N/A** ERRNO : N/A** SEE ALSO: Cisco Aironet 340/350 Driver Programmer's Manual** NOMANUAL*/void cisAironetHwLinkStatusShow ( CARD_CTRL_T * pWlanDev, UINT16 linkStatus ) { UINT16 code = 0; UINT16 status = 0; /* Get the reason code */ ANET_LINK_STATUS_CODE_GET(code); /* Get the link status */ ANET_LINK_STATUS_GET(status, linkStatus); /* Check for Authentication or Association status */ switch (status) { case ANET_ASSOCIATED: ANET_LOG(DEBUG_FLOOD, ("(linkStat) Station associated with AP ok\n", 1,2,3,4,5,6)); break; case ANET_LOSS_OF_SYNC: ANET_LOG(DEBUG_FLOOD, ("(inkStat) Loss of sync reason ($%04x)\n %s\n", (INT32) status, (INT32) lossOfSync[code],3,4,5,6)); break; case ANET_DEAUTHENTICATION: ANET_LOG(DEBUG_FLOOD, ("(linkStat) Deauthentication ($%04x)\n", (INT32) status, (INT32) linkStsReason[code],3,4,5,6)); break; case ANET_DISASSOCIATION: ANET_LOG(DEBUG_FLOOD, ("(linkStat) Disassociation ($%04x)\n", (INT32) status, (INT32) linkStsReason[code],3,4,5,6)); break; case ANET_ASSOCIATION_FAIL: ANET_LOG(DEBUG_FLOOD, ("(linkStat) Association failed ($%04x)\n", (INT32) status, (INT32) linkStsReason[code],3,4,5,6)); break; case ANET_AUTHENTICATION_FAIL: ANET_LOG(DEBUG_FLOOD, ("(linkStat) Authentication failed ($%04x)\n", (INT32) status, (INT32) linkStsReason[code],3,4,5,6)); break; default: ANET_LOG(DEBUG_FLOOD, ("(linkStat) unknown error source ($%04x)\n", (INT32) linkStatus,2,3,4,5,6)); } }/**************************************************************************** cisAironetHwErrorDesc - Formats the aironet card error code into a usable * message.* * Formats the aironet card error code into a usable message. This message can* then be displayed on the system console to give a accurate description of * the most recent card command failure.** RETURNS : N/A** ERRNO : N/A** SEE ALSO: Cisco Aironet 340/350 Driver Programmer's Manual*/LOCAL void * cisAironetHwErrorDesc (void) { LOCAL UINT8 errorDescriptor [200]; UINT8 buf0 [80]; UINT8 buf1 [80]; UINT8 buf2 [80]; /* Check if error logged */ if (cisAironetHwErrors.desc == NULL) { return ((void *) "NULL"); } /* Form the error string */ (void) sprintf ((char *) buf0, "\n\r\tCommand : " "c (0x%04x) p0 (0x%04x) p1 (0x%04x) p2 (0x%04x)", cisAironetHwErrors.cmd.command, cisAironetHwErrors.cmd.param0, cisAironetHwErrors.cmd.param1, cisAironetHwErrors.cmd.param2); (void) sprintf ((char *) buf1, "\n\r\tResponse : " "s (0x%04x) r0 (0x%04x) r1 (0x%04x) r2 (0x%04x)", cisAironetHwErrors.resp.status, cisAironetHwErrors.resp.resp0, cisAironetHwErrors.resp.resp1, cisAironet
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -