📄 cisaironetend.c
字号:
{ case EIOCSADDR: /* Set the MAC addr */ { /* * This is extremely dangerous and a security risk. Make sure * the developer knows what's going on */ CFG_RID_T cfg; CFG_RID_T * pCfg = (CFG_RID_T *) &cfg; ANET_DEBUG(DEBUG_FATAL, ("WARNING: MAC address change!!!!\n")); if (data == NULL) { status = EINVAL; break; } /* get the card config */ if ( cisAironetHwRidConfigGet (pDev, (void *) pCfg) == ERROR ) { ANET_LOG(DEBUG_ERROR, ("cisAironetEndIoctl: Error reading card config\n", 1,2,3,4,5,6)); status = EINVAL; break; } /* Save the new mac to the RID */ (void) cisAironetBcopy ( pDev, (const UINT8 *) data, (UINT8 *) pCfg->macAddr, WLAN_ENET_ADDR_LEN ); /* disable the card */ if ( cisAironetHwMacDisable (pDev) == ERROR ) { ANET_LOG(DEBUG_ERROR, ("cisAironetEndIoctl: Error disabling MAC\n", 1,2,3,4,5,6)); status = EINVAL; break; } /* commit the new RID data */ if ( cisAironetHwRidConfigSet (pDev, (void *) pCfg) == ERROR ) { ANET_LOG(DEBUG_ERROR, ("cisAironetEndIoctl: Error setting MAC address\n", 1,2,3,4,5,6)); status = EINVAL; break; } /* enable the card */ if ( cisAironetHwMacEnable (pDev) == ERROR ) { ANET_LOG(DEBUG_ERROR, ("cisAironetEndIoctl: Error enabling MAC\n", 1,2,3,4,5,6)); status = EINVAL; break; } /* copy the new mac addr to the driver */ (void) bcopy ((INT8 *) data, (INT8 *) END_HADDR(pDrvCtrl), END_HADDR_LEN(pDrvCtrl)); } break; case EIOCGADDR: /* Get the MAC addr */ if (data == NULL) { status = EINVAL; break; } (void) bcopy ( (INT8 *) END_HADDR(pDrvCtrl), (INT8 *) data, END_HADDR_LEN(pDrvCtrl)); break; case EIOCSFLAGS: /* Set device flags */ value = (INT32) data; /* A negative flag means remove the flag */ if (value < 0) { value = -(--value); /* Convert from two's complement */ END_FLAGS_CLR (pDrvCtrl, value); } else { END_FLAGS_SET (pDrvCtrl, value); } cisAironetEndFlags ((CARD_CTRL_T *) pDrvCtrl); break; case EIOCGFLAGS: /* Retrieve device flags */ *(int *)data = END_FLAGS_GET(pDrvCtrl); break; case EIOCPOLLSTART: /* Begin polled operation */ break; case EIOCPOLLSTOP: /* End polled operation */ break; case EIOCGMIB2: /* return MIB information */ if (data == NULL) { status = ERROR; break; } (void) bcopy ((INT8 *) &pDrvCtrl->mib2Tbl, (INT8 *) data, sizeof (pDrvCtrl->mib2Tbl)); break; case EIOCGFBUF: /* return minimum First Buffer for chaining */ if (data == NULL) { status = ERROR; break; } *(INT32 *) data = WLAN_MIN_FBUF; break; case EIOCGHDRLEN: if (data == NULL) { status = ERROR; break; } *(INT32 *) data = WLAN_EH_SIZE; break; default: status = cisAironetHwIoctlExt((CARD_CTRL_T *) pDrvCtrl,cmd,data); } return status; }/**************************************************************************** cisAironetEndUnload - Unloads this instance of the WLAN driver** De-allocates all memory allocated in cisAironetEndLoad, and returns the * system to the pre-initialized state. It is assumed that any device * power-down/disabling is done in a high-level PCI or PCMCIA driver.** RETURNS: OK or ERROR** ERRNO: N/A*/LOCAL STATUS cisAironetEndUnload ( END_OBJ * pDrvCtrl /* Pointer to device handle */ ) { CARD_CTRL_T * pDev = NULL; CARD_CTRL_T * pBug = NULL; if (pDrvCtrl == NULL) { return (ERROR); } pDev = (CARD_CTRL_T *) pDrvCtrl; ANET_DEBUG(DEBUG_INFO, ("Unloading Driver\n")); END_OBJECT_UNLOAD (pDrvCtrl); (void) cacheDmaFree( pDev->clDescTbl.memArea); (void) free (pDev->mClBlkConfig.memArea); /* Free the entry in the LL corresponding to this instance of the driver */ for (pBug = pAnetHead; pBug->pNext != pDev; pBug = pBug->pNext); pBug->pNext = pDev->pNext; return (OK); }/**************************************************************************** cisAironetEndISR - ISR for Cisco Aironet WLAN driver** This is the ISR for the WLAN driver. Events on the card are shown in the * event status register. These events do not trigger a card interrupt* unless they have been enabled as an interrupt source. Currently the only* events that are interrupt sources are: RX, TX, TXE and LSTATUS. Alloc* events are ignored (they occur for every transmitted packet to let you* know the buffer was reclaimed - see cisAironetEndSend() ). CMD events are* polled for in the anetCmd() routine as we still want card commands to work* when interrupts are disabled. INFO events are not an interrupt since* they do not need to be read in a timely manner, and reducing the number of* interrupt sources improves stability on some platforms.** RETURNS: OK or ERROR** ERRNO: N/A*/LOCAL STATUS cisAironetEndISR ( CARD_CTRL_T * pWlanDev /* Pointer to device handle */ ) { /* Disable the board level interrupts */ CISAIR_CARD_INTS_DISABLE (pWlanDev); /* Get the event status */ CISAIR_EVENT_STS_GET (pWlanDev, pWlanDev->stackVars.evStatus); /* If in sleep mode and a valid packet is rx'd */ if (ANET_AWAKE_EVENT(pWlanDev->stackVars.evStatus)) { if (pWlanDev->intMask & ANET_EVENT_AWAKE) { /* Wake up the card */ (void) cisAironetHwWakeup (pWlanDev); /* Ack the event */ (void) cisAironetHwEventAwakenAck (pWlanDev); } } /* Check for TX complete */ if (ANET_TX_EVENT(pWlanDev->stackVars.evStatus)) { /* release the txFid back to the host */ CISAIR_TX_COMPL_FID_GET (pWlanDev, pWlanDev->stackVars.txComplFid); /* Check for tx errors */ if ( WLAN_IN_16((UINT32) &pWlanDev->macReg->evStat) & ANET_EVENT_TX_EXC ) { (void) cisAironetTxCtrlHdrGet (pWlanDev, &pWlanDev->stackVars.txHdr, pWlanDev->stackVars.txComplFid); } /* Put the completed txFid into the ring buffer */ (void) rngBufPut ((RING_ID) pWlanDev->ringID, (char *) &pWlanDev->stackVars.txComplFid, sizeof (UINT16)); /* tx complete so increment the counting semaphore */ semGive (pWlanDev->txComplete); } /* Check for Rx packet */ if (ANET_RX_EVENT(pWlanDev->stackVars.evStatus)) { /* Get a net cluster */ pWlanDev->stackVars.pNetCluster = (UINT16 *) netClusterGet ( pWlanDev->endObj.pNetPool, pWlanDev->pClPool); /* Get the packet from the card */ CISAIR_ENET_PKT_GET (pWlanDev, pWlanDev->stackVars, pWlanDev->stackVars.rxStatus, (pWlanDev->stackVars.pNetCluster + (IP_HDR_OFFSET >> 1)), pWlanDev->stackVars.numBytes); /* Test the read status */ if ( (pWlanDev->stackVars.numBytes == 0) || ANET_RX_EVENT_ERRSTAT(pWlanDev->stackVars.rxStatus) ) { pWlanDev->stackVars.status = ERROR; goto error; } /* Add the processing job to the netTask */ pWlanDev->stackVars.status = netJobAdd((FUNCPTR)cisAironetEndReceive, (INT32)pWlanDev, (INT32)pWlanDev->stackVars.pNetCluster, (INT32)pWlanDev->stackVars.numBytes, 0, 0); } goto done; error: /* Add error to the MIB-II table */ END_ERR_ADD (&pWlanDev->endObj, MIB2_IN_ERRS, +1); done: /* Acknowledge the interrupt */ WLAN_OUT_16((INT32) &pWlanDev->macReg->evAck, (pWlanDev->stackVars.evStatus) & ANET_STATUS_INTS ); /* Enable board level interrupts */ CISAIR_CARD_INTS_ENABLE (pWlanDev); /* return - status */ return (pWlanDev->stackVars.status); }/**************************************************************************** cisAironetEndReceive - Task-level routine that receives packets from * the card** This routine is called from the ISR via netJobAdd to handle received packets.* In the ISR the packet was copied into a cluster, so in this routine the * cluster block is attached to an MBLK and passed to the MUX.** RETURNS: OK or ERROR** ERRNO: N/A*/LOCAL STATUS cisAironetEndReceive ( CARD_CTRL_T * pWlanDev, /* Pointer to device control structure */ UINT8 * pData, /* Pointer to cluster in netPool */ INT32 datalen ) { if((pWlanDev->stackVars.pClBlk = netClBlkGet (pWlanDev->endObj.pNetPool, M_DONTWAIT)) == NULL) { netClFree (pWlanDev->endObj.pNetPool, pData); ANET_LOG(DEBUG_ERROR, ("cisAironetEndReceive: Error alloc ClBlk\n", 1,2,3,4,5,6)); return (ERROR); } if((pWlanDev->stackVars.pMBlk = mBlkGet (pWlanDev->endObj.pNetPool, M_DONTWAIT, MT_DATA)) == NULL) { netClBlkFree (pWlanDev->endObj.pNetPool, pWlanDev->stackVars.pClBlk); netClFree (pWlanDev->endObj.pNetPool, pData); ANET_LOG(DEBUG_ERROR, ("cisAironetEndReceive: Error getting MBlk\n", 1,2,3,4,5,6)); return (ERROR); } if (netClBlkJoin (pWlanDev->stackVars.pClBlk, (INT8 *) pData, pWlanDev->clDescTbl.clSize, NULL, 0, 0, 0) == NULL) { ANET_LOG(DEBUG_ERROR, ("cisAironetEndReceive: Error in netClBlkJoin\n", 1,2,3,4,5,6)); return (ERROR); } if (netMblkClJoin (pWlanDev->stackVars.pMBlk, pWlanDev->stackVars.pClBlk) == NULL) { ANET_LOG(DEBUG_ERROR, ("cisAironetEndReceive: Error om netMblkClJoin\n",
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -