📄 cisaironetend.c
字号:
/* Create a ring buffer to be used for FIDS */ if ( (pWlanDev->ringID = (int) rngCreate (sizeof (UINT16) * 6)) == (int)NULL ) { ANET_DEBUG(DEBUG_FATAL, ("cisAironetEndLoad: Error creating ring buf\n")); goto fatal_error; } /* Set the card up, initialize it and run diagnostics. Interrupts are disabled, but the card is left in the enabled state */ if (cisAironetHwInit (pWlanDev) == ERROR) { ANET_DEBUG(DEBUG_FATAL, ("cisAironetEndLoad: Error in cisAironetEndInit\n")); return NULL; } /* Add fid's to the ring buffer */ for (i = 0; i < 6; i++) { txFID = cisAironetHwTxFidGet (pWlanDev, 2312); (void) rngBufPut ((RING_ID) pWlanDev->ringID, (char *) &txFID, sizeof (UINT16)); } /* Set the default mask (this modifies the structure only. The actual enabling of card interrupts is done in cisAironetEndStart() */ pWlanDev->intMask = ANET_STATUS_INTS; pWlanDev->unitNum = unitNum; /* Do standard END structure initialization. Must be done after card initialization, as we need the MAC address to initialize MIB2 stuff*/ if ((END_OBJ_INIT (&pWlanDev->endObj, (DEV_OBJ *)pWlanDev, (char *) ANET_IFNAME, pWlanDev->unitNum, &cisAironetEndFuncTable, "Wind River Systems WLAN END driver") == ERROR)) { ANET_DEBUG(DEBUG_FATAL, ("cisAironetEndLoad: END or MIB2 init failed\n")); goto fatal_error; } /* Clear statistics */ (void) bzero ( (char *) &pWlanDev->stats, sizeof (WLAN_STATS) ); /* Init the MIB-II table */ if ( END_MIB_INIT (&pWlanDev->endObj, M2_ifType_ethernet_csmacd, &pWlanDev->MACAddr[0], WLAN_ENET_ADDR_LEN, ETHERMTU, WLAN_END_SPEED) == ERROR) { ANET_DEBUG(DEBUG_FATAL, ("cisAironetEndLoad: Failed MIB-II init.\n")); goto fatal_error; } /* Allocate memory for clusters, net pool */ if ( cisAironetEndMemInit(pWlanDev) == ERROR ) { ANET_DEBUG(DEBUG_FATAL, ("cisAironetEndLoad: Memory Error\n")); goto fatal_error; } /* Now that memory for the MUX is initialized, complete END init*/ END_OBJ_READY(&pWlanDev->endObj, IFF_NOTRAILERS | IFF_BROADCAST | IFF_MULTICAST | IFF_RUNNING | IFF_UP); /* Connect here, but don't enable until cisAironetEndStart */ WLAN_INT_CONNECT( ((CARD_CTRL_T *)pWlanDev)->iVec, (INT32) cisAironetEndISR, (INT32) pWlanDev, &result); if (result != OK) { ANET_DEBUG(DEBUG_FATAL, ("cisAironetEndLoad: Error connecting interrupts\n")); goto fatal_error; } /* Return the address of the control structure we've just allocated and initialized */ return (END_OBJ *)(&pWlanDev->endObj); fatal_error: /* Clean up the allocated memory */ for (pWlanDev = pAnetHead; (pWlanDev != NULL)&&(pWlanDev->pNext != NULL); pWlanDev = pWlanDev->pNext) { free (pWlanDev); } return (NULL); }/*************************************************************************** * cisAironetEndParse - Parses the initString and fills in the device struct** This function parses the init string, which is colon delimited. The * default station name and BSS name are also setup here.** RETURNS: OK or ERROR** ERRNO: N/A*/LOCAL STATUS cisAironetEndParse ( CARD_CTRL_T * pDev, /* Pointer to device structure */ UINT8 * initString /* Initialization string to parse */ ) { INT8 * tok = NULL; INT8 * holder = NULL; /* Sanity check */ if ( (pDev == NULL) || (initString == NULL) ) { return (ERROR); } /* Unit number. */ tok = strtok_r ((char *) initString, ":", &holder); if (tok == NULL) { return (ERROR); } pDev->unitNum = atoi (tok); /* IO Base */ tok = strtok_r (NULL, ":", &holder); if (tok == NULL) { return (ERROR); } pDev->ioBase = strtoul (tok, NULL, 16); /* iVec */ tok = strtok_r (NULL, ":", &holder); if (tok == NULL) { return (ERROR); } pDev->iVec = strtoul (tok, NULL, 16); /* iLevel */ tok = strtok_r (NULL, ":", &holder); if (tok == NULL) { return (ERROR); } pDev->iLevel = strtoul (tok, NULL, 16); /* Get the SSID */ (void) sysWlanCfgParamGet (WLAN_SSID, (INT32) pDev->networkName); /* Get the default station name */ (void) sysWlanCfgParamGet (WLAN_STATION_NAME, (INT32) pDev->stationName); return OK; }/**************************************************************************** cisAironetEndMemInit - Initializes global memory structures for END** Allocates the netPool and sets up the buffer management library as* specified in the NPT: User's guide.** RETURNS: OK or ERROR** ERRNO: N/A* * SEE ALSO: netPoolInit(), Network Protocol Toolkit User's Guide*/LOCAL STATUS cisAironetEndMemInit ( CARD_CTRL_T * pDev /* Pointer to device handle */ ) { /* Sanity check */ if (pDev == NULL) { return (ERROR); } pDev->mClBlkConfig.mBlkNum = WLAN_NUMCL; pDev->mClBlkConfig.clBlkNum = WLAN_NUMCL; pDev->mClBlkConfig.memSize = (pDev->mClBlkConfig.mBlkNum * (M_BLK_SZ + sizeof(long))) + (pDev->mClBlkConfig.clBlkNum * (CL_BLK_SZ)); if ((pDev->mClBlkConfig.memArea = (char *) memalign (sizeof(INT32), pDev->mClBlkConfig.memSize)) == NULL) { ANET_DEBUG(DEBUG_FATAL, ("cisAironetEndMemInit: Error allocating" " mClBlkConfig.memarea\n")); return ERROR; } pDev->clDescTbl.clSize = WLAN_MAX_PACKET; pDev->clDescTbl.clNum = WLAN_NUMCL; pDev->clDescTbl.memSize = pDev->clDescTbl.clNum * (WLAN_MAX_PACKET + sizeof(INT32)); /* The clusters should be from cache safe memory */ if ((pDev->clDescTbl.memArea = (char*) cacheDmaMalloc(pDev->clDescTbl.memSize)) == NULL) { ANET_DEBUG(DEBUG_FATAL, ("cisAironetEndMemInit: Error allocating" "clDescTbl.memArea\n")); return ERROR; } /* Initialize the memory pool, with one entry in the cluster table */ pDev->endObj.pNetPool = & pDev->netPool; if (netPoolInit(pDev->endObj.pNetPool, &pDev->mClBlkConfig, &pDev->clDescTbl, 1, NULL) == ERROR) { ANET_DEBUG(DEBUG_FATAL, ("cisAironetEndMemInit: Could not init net pool\n")); return (ERROR); } if ((pDev->pClPool = netClPoolIdGet (pDev->endObj.pNetPool, WLAN_MAX_PACKET, FALSE)) == NULL) { ANET_DEBUG(DEBUG_FATAL, ("cisAironetEndMemInit: Could not read net pool\n")); return (ERROR); } return OK; }/**************************************************************************** cisAironetEndStart - MUX routine to start card operation** Called via muxDevStart(), this function enables interrupts on the card, * then enables system interrupts. On successful completion of this * routine the card is fully operational.** RETURNS: OK or ERROR** ERRNO: N/A*/LOCAL STATUS cisAironetEndStart ( END_OBJ * pDrvCtrl /* Pointer to END object structure */ ) { CARD_CTRL_T * pDriver = (CARD_CTRL_T *) pDrvCtrl; STATUS pResult = 0; /* Clear any pending interrupts */ (void) cisAironetHwIntAckAll (pDriver); /* Ack any pending interrupts */ (void) cisAironetHwIntDisableAll (pDriver); /* enable system level interrupts */ WLAN_INT_ENABLE(((CARD_CTRL_T*) pDriver)->iLevel, (STATUS *) &pResult); if (pResult == ERROR) { ANET_DEBUG(DEBUG_FATAL, ("cisAironetEndStart: Error enabling interrupts")); return (ERROR); } /* * OK. Now that all the interrupt infrastructure is in place, * setup our interrupts */ if ( cisAironetHwIntEnable (pDriver) == ERROR ) { WLAN_INT_DISABLE(((CARD_CTRL_T*) pDriver)->iLevel, (STATUS *) &pResult); return (ERROR); } /* return - status */ return (OK); }/**************************************************************************** cisAironetEndStop - MUX routine to stop card operation** Called via muxDevStop(), this function disables interrupts on the card, * then disables system interrupts. On successful completion of this * routine the card is non-operational.** RETURNS: OK or ERROR** ERRNO: N/A*/LOCAL STATUS cisAironetEndStop ( END_OBJ * pDrvCtrl /* Pointer to END object structure */ ) { CARD_CTRL_T * pDriver = (CARD_CTRL_T *) pDrvCtrl; STATUS pResult = 0; /* Clear any pending interrupts and disable */ (void) cisAironetHwIntAckAll (pDriver); /* Disable board level interrupts */ (void) cisAironetHwIntDisableAll (pDriver); /* Disable system interrupts*/ WLAN_INT_DISABLE(((CARD_CTRL_T*) pDriver)->iLevel, (STATUS *) &pResult); if (pResult == ERROR) { ANET_DEBUG(DEBUG_FATAL, ("cisAironetEndStop: Error disabling interrupts")); return (ERROR); } return (OK); }/**************************************************************************** cisAironetEndIoctl - MUX Ioctl routine for the WLAN Driver** Handles the basic END IOCTL calls required to support a network device. * If the IOCTL call is not recognized, it is passed to cisAironetEndIoctlExt,* which handles private (WLAN only) IOCTL calls used to manage the card. * These private IOCTLs are defined in wlanEnd.h.** RETURNS: OK if successful, EINVAL for invalid ioctl() value, ERROR on error** ERRNO: N/A*/LOCAL int cisAironetEndIoctl ( END_OBJ * pDrvCtrl, /* Device handle for this card */ unsigned int cmd, /* IOCTL command */ caddr_t data /* Generic data pointer */ ) { INT32 status = 0; /* return code of IOCTL */ INT32 value = 0; /* temp variable */ CARD_CTRL_T * pDev = NULL; if (pDrvCtrl == NULL) { ANET_DEBUG(DEBUG_ERROR, ("cisAironetEndIoctl: Null device pointer\n")); return ERROR; } pDev = (CARD_CTRL_T *) pDrvCtrl; switch(cmd)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -