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

📄 zdreq.c

📁 zd1211b芯片的无线网卡的驱动,移植到s3c2410平台
💻 C
📖 第 1 页 / 共 5 页
字号:
                    pZDRD->Buffer[6] = cpu_to_le32(macp->retryFailCnt);//Hardware total Tx Frame                    pZDRD->Buffer[7] = cpu_to_le32(macp->hwTotalTxFrm);//txMultipleRetriesFrames                    pZDRD->Buffer[8] = cpu_to_le32(macp->hwRetryCnt);//                    pZDRD->Buffer[9] = cpu_to_le32(macp->hwUnderrunCnt);//                    pZDRD->Buffer[10] = cpu_to_le32(macp->DriverRxFrmCnt);//rxUnicastFrames                    pZDRD->Buffer[11] = cpu_to_le32(macp->rxUnicastFrm);//rxMulticastFrames                    pZDRD->Buffer[12] = cpu_to_le32(macp->rxMulticastFrm);//rxTotalCnt                    pZDRD->Buffer[13] = cpu_to_le32(macp->rxUnicastFrm+macp->rxMulticastFrm);//NotifyNDISRxFrmCnt                    pZDRD->Buffer[14] = cpu_to_le32(macp->rxCnt);//rxUniOctets  byte size                    pZDRD->Buffer[15] = cpu_to_le32(macp->rxUnicastOctets);//rxMultiOctets  byte size                    pZDRD->Buffer[16] = cpu_to_le32(macp->rxMulticastOctets);// Discard by ValidateFrame                    pZDRD->Buffer[17] = cpu_to_le32(macp->invalid_frame_good_crc);//                    pZDRD->Buffer[18] = cpu_to_le32(macp->ErrShortFrmCnt);//                    pZDRD->Buffer[19] = cpu_to_le32(macp->ErrLongFrmCnt);                    pZDRD->Buffer[20] = 0;        //DriverDiscardedFrmCauseByMulticastList                    pZDRD->Buffer[21] = 0;        //DriverDiscardedFrmCauseByFrmCtrl//rxNeedFrgFrm                    pZDRD->Buffer[22] = cpu_to_le32(macp->rxNeedFrag);//DriverRxMgtFrmCnt                    pZDRD->Buffer[23] = cpu_to_le32(macp->rxMgtFrm);//Receive broadcast frame count                    pZDRD->Buffer[24] = cpu_to_le32(macp->rxBroadcastFrm);//Receive broadcast frame byte size                    pZDRD->Buffer[25] = cpu_to_le32(macp->rxBroadcastOctets);//Measured quality 11b data frame count                    pZDRD->Buffer[26] = cpu_to_le32(macp->rx11bDataFrame);//Measured quality 11g data frame count                    pZDRD->Buffer[27] = cpu_to_le32(macp->rxOFDMDataFrame);//                    pZDRD->Buffer[28] = cpu_to_le32(macp->hwTotalRxFrm);//rxPLCPCRCErrCnt                    pZDRD->Buffer[29] = cpu_to_le32(macp->hwCRC16Cnt);//rxCRC32ErrCnt                    pZDRD->Buffer[30] = cpu_to_le32(macp->hwCRC32Cnt);//                    pZDRD->Buffer[31] = cpu_to_le32(macp->hwDecrypErr_UNI);//                    pZDRD->Buffer[32] = cpu_to_le32(macp->hwDecrypErr_Mul);//rxDecrypFailCnt                    pZDRD->Buffer[33] = cpu_to_le32(macp->hwDecrypErr_UNI+macp->hwDecrypErr_Mul);//                    pZDRD->Buffer[34] = cpu_to_le32(macp->hwRxFIFOOverrun);                    pZDRD->Buffer[35] = 0;        //LossAP                    pZDRD->Buffer[36] = cpu_to_le32(macp->rxDiscardByNotPIBSS);                    pZDRD->Buffer[37] = cpu_to_le32(macp->rxDiscardByAllocateBuf);;                    pZDRD->ZDRdLength = cpu_to_le32(sizeof(ZD_RD_STRUCT) + sizeof(ULONG)*36);                    *BytesWritten = sizeof(ZD_RD_STRUCT) + sizeof(ULONG)*36;                    break;                case ZDContinuousTx:                    ZDPRODUCTDBG("ZDContinuousTx\r\n");                    if (le32_to_cpu(pZDRD->ZDRdLength) < sizeof(ZD_RD_STRUCT))                    {                        pZDRD->ZDRdLength = cpu_to_le32(sizeof(ZD_RD_STRUCT));                        *BytesNeeded = sizeof(ZD_RD_STRUCT);                        *BytesWritten = 0;                        Status = NDIS_STATUS_BUFFER_TOO_SHORT;                        break;                    }                    pZDRD->Buffer[0] = cpu_to_le32(macp->bContinueTxMode);                    if(macp->bContinueTx == 1)                        pZDRD->Buffer[1] = 0x00;                    else                        pZDRD->Buffer[1] = cpu_to_le32(0x01);                    pZDRD->ZDRdLength = cpu_to_le32(sizeof(ZD_RD_STRUCT));                    break;                default:                    ZDPRODUCTDBG("Unknown FunctionID: 0x%08x\r\n", le32_to_cpu(pZDRD->ZDRdFuncId));                    break;            }            break;        case OID_ZD_CUSTOM:            ZDPRODUCTDBG("OID_ZD_CUSTOM\r\n");            pZDCustom = (ZD_CUSTOM_STRUCT *) InformationBuffer;            switch (le32_to_cpu(pZDCustom->ZDFuncId))            {                case ZDPreambleMode:                    ZDPRODUCTDBG("ZDPreambleMode\r\n");                    switch (macp->cardSetting.PreambleType)                    {                        case LONG_PREAMBLE:                            pZDCustom->DataBuffer[0] = cpu_to_le32(ZD_PreambleLong);                            break;                        case SHORT_PREAMBLE:                            pZDCustom->DataBuffer[0] = cpu_to_le32(ZD_PreambleShort);                            break;                        default:                            pZDCustom->DataBuffer[0] = cpu_to_le32(ZD_PreambleAuto);                            break;                    }                    break;                case ZDAdapterRegion:                    ZDPRODUCTDBG("ZDAdapterRegion 0x%x\r\n", macp->RegionCode);                    pZDCustom->DataBuffer[0] = cpu_to_le32(macp->RegionCode);                    *BytesWritten = sizeof(macp->RegionCode);                    break;                case ZDAdapterSupportChannel:                {                    int i;                    int AllowChannelCount = 0;                    ULONG tmpAllowChannel = dot11Obj.AllowedChannel;                    char *pChannelNumber = (char *)(pZDCustom->DataBuffer);                    printk(KERN_ERR "ZDAdapterSupportChannel\n");                    for (i = 0; i < 14; i++)                    {                        if (tmpAllowChannel & (1 << i))                            AllowChannelCount++;                    }                    if (pZDCustom->ZDCustomLength < (AllowChannelCount + sizeof(ZD_RD_STRUCT) - sizeof(ULONG)))                    {                        pZDCustom->ZDCustomLength = (AllowChannelCount + sizeof(ZD_RD_STRUCT) - sizeof(ULONG));                        *BytesNeeded = pZDCustom->ZDCustomLength;                        *BytesWritten = 0;                        Status = NDIS_STATUS_BUFFER_TOO_SHORT;                        break;                    }                    for (i = 0; i < 14; i++)                    {                        if (tmpAllowChannel & (1 << i))                            *(pChannelNumber++) = i+1;                    }                    pZDCustom->ZDCustomLength = (AllowChannelCount + sizeof(ZD_RD_STRUCT) - sizeof(ULONG));                    *BytesWritten = pZDCustom->ZDCustomLength;                }                break;            }            break;        case OID_ZD_GETRID:            ZDPRODUCTDBG("OID_ZD_GETRID\r\n");            rid_p = (PRID_STRUCT)InformationBuffer;            switch(le16_to_cpu(rid_p->rid))            {                case RID_MONITOR:                    ZDPRODUCTDBG("RID_MONITOR\r\n");                    zd1205_CollectHwTally(macp);                    rid_p->data[0] = (USHORT)macp->hwCRC32Cnt;                    rid_p->data[1] = (USHORT)macp->hwCRC16Cnt;                    rid_p->data[2] = (USHORT)macp->hwRetryCnt;                    rid_p->data[3] = (USHORT)macp->hwTotalRxFrm;                    rid_p->data[4] = (USHORT)macp->hwTotalTxFrm;                    rid_p->data[5] = 0;                    rid_p->data[6] = 0;                    rid_p->data[7] = 0;                    rid_p->data[8] = 0;                    rid_p->data[9] = 0;                    Reset_Tally(macp);                    *BytesWritten = sizeof(RID_STRUCT);                    break;                case 0xFC7F:                    ZDPRODUCTDBG("Get UDP Port\r\n");                    rid_p->data[0] = 0;                    *BytesWritten = sizeof(RID_STRUCT);                    break;                default:                    ZDPRODUCTDBG("RID: 0x%04x not support\r\n", le16_to_cpu(rid_p->rid));                    Status = NDIS_STATUS_NOT_SUPPORTED;                    break;            }            break;        case OID_ZD_GET_TALLIES:            ZDPRODUCTDBG("OID_ZD_GET_TALLIES\r\n");            pLocalTally = (PLOCAL_TALLY_STRUCT)InformationBuffer;/* Zero the buffer */            memset(pLocalTally, 0, sizeof(LOCAL_TALLY_STRUCT));            zd1205_CollectHwTally(macp);#if (defined(GCCK) && defined(OFDM))            pLocalTally->reserved2_L = cpu_to_le32(macp->rx11bDataFrame);            pLocalTally->reserved3_L = cpu_to_le32(macp->rxOFDMDataFrame);#else//pLocalTally->reserved2 = 0;//pLocalTally->reserved3 = 0;#endif            pLocalTally->reserved7_L = cpu_to_le32(macp->rxBroadcastFrm);            pLocalTally->reserved8_L = cpu_to_le32(macp->rxBroadcastOctets);            pLocalTally->rxCRC32ErrCnt_L = cpu_to_le32(macp->hwCRC32Cnt);            pLocalTally->rxDecrypFailCnt_L = cpu_to_le32(macp->hwDecrypErr_UNI+macp->hwDecrypErr_Mul);// macp->DriverDiscardedFrm            pLocalTally->rxDiscardedCnt_L = cpu_to_le32(macp->invalid_frame_good_crc);            pLocalTally->rxMulticastFrames_L = cpu_to_le32(macp->rxMulticastFrm);            pLocalTally->rxMultiOctets_L = cpu_to_le32(macp->rxMulticastOctets);            pLocalTally->rxPLCPCRCErrCnt_L = cpu_to_le32(macp->hwCRC16Cnt);//(macp->rxMulticastFrm+macp->rxUnicastFrm)            pLocalTally->rxTotalCnt_L = cpu_to_le32(macp->rxMulticastFrm+macp->rxUnicastFrm);//macp->rxUnicastFrm            pLocalTally->rxUnicastFrames_L = cpu_to_le32(macp->rxUnicastFrm);// macp->rxUnicastOctets            pLocalTally->rxUniOctets_L = cpu_to_le32(macp->rxUnicastOctets);//pLocalTally->txMulticastFrames = 0; // macp->txMulticastFrm//pLocalTally->txMultiOctets = 0; // macp->txMulticastOctets            pLocalTally->txMultipleRetriesFrames_L = cpu_to_le32(macp->hwRetryCnt);            pLocalTally->txRetryLimitExceeded_L = cpu_to_le32(macp->retryFailCnt);//pLocalTally->txUnicastFrames = 0; // macp->txUnicastFrm//pLocalTally->txUniOctets = 0; // macp->txUnicastOctets            *BytesWritten = sizeof(LOCAL_TALLY_STRUCT);            break;        default:            ZDPRODUCTDBG("%s Unknown OID = 0x%08x\r\n", "ZD1205EM_Custom_QueryInfo", Oid);            Status = NDIS_STATUS_NOT_SUPPORTED;            break;    }    return Status;}NDIS_STATUS ZD1205EM_Custom_SetInformation(PVOID NDIS_HANDLE,NDIS_OID Oid,PVOID InformationBuffer,ULONG InformationBufferLength,PULONG BytesRead,PULONG BytesNeeded){    NDIS_STATUS Status;    ULONG GenericUlong;    ULONG IoAddress;    ULONG IoValue;    U8 SSIDLen;    zd1205_private_t *macp = (zd1205_private_t *) NDIS_HANDLE;    void *reg = macp->regp;    NDIS_802_11_CONFIGURATION *pConfiguration;    NDIS_802_11_SSID *pSSID;    ZD_CUSTOM_STRUCT *pZDCustom;    ZD_RD_STRUCT *pZDRD;    RID_STRUCT *rid_p;//int flags;    Status = NDIS_STATUS_SUCCESS;    ZDPRODUCTDBG("***** ZD1205EM_Custom_SetInformation ******\r\n");    switch(Oid)    {        case OID_802_11_DESIRED_RATES:            ZDPRODUCTDBG("OID_802_11_DESIRED_RATES\r\n");/* Fixed the Tx rate */            GenericUlong = le32_to_cpu(*((ULONG*) InformationBuffer));            macp->cardSetting.FixedRate = Rate_Convert((GenericUlong & 0x7f));            macp->bFixedRate = 1;            ZDPRODUCTDBG("Rate: 0x%08x\r\n", macp->cardSetting.FixedRate);            Status = NDIS_STATUS_SUCCESS;            break;        case OID_802_11_CONFIGURATION:        case OID_ZDX_802_11_CONFIGURATION:            ZDPRODUCTDBG("OID_802_11_CONFIGURATION\r\n");            if (InformationBuffer == NULL ||                (InformationBufferLength < sizeof(NDIS_802_11_CONFIGURATION)))            {                Status = NDIS_STATUS_INVALID_LENGTH;                break;            }            pConfiguration = (PNDIS_802_11_CONFIGURATION) InformationBuffer;/* Update Beacon */            {//U16 p = (U16) le32_to_cpu(pConfiguration->BeaconPeriod);//U8 BcnInterval[2];//U16 *p = (U16 *)&BcnInterval;//BcnInterval[0] = (U8)(pConfiguration->BeaconPeriod);//BcnInterval[1] = (U8)(pConfiguration->BeaconPeriod >> 8);//HW_UpdateBcnInterval(&dot11Obj, *p);            }/* Update ATIMWindow */            {//U16 p = (U16) le32_to_cpu(pConfiguration->ATIMWindow);//U8 ATIMWindow[2];//U16 *p = (U16 *)&ATIMWindow;//ATIMWindow[0] = (U8)(pConfiguration->ATIMWindow);//ATIMWindow[1] = (U8)(pConfiguration->ATIMWindow >> 8);//HW_UpdateATIMWindow(&dot11Obj, *p);            }/* Update Channel */            {                ULONG ChannelNo=0;                UCHAR IntValue = 0xFF;#ifdef ZDCONF_80211A_SUPPORT                ChannelNo = Freq_11A_to_channel(pConfiguration->DSConfig/1000);#endif                if(!ChannelNo)                    ChannelNo=(le32_to_cpu(pConfiguration->DSConfig)/1000-2412)/5+1;/* If the desired channel is 14 */                if (le32_to_cpu(pConfiguration->DSConfig) == 2484000)                {//macp->SaveChannel = 14;//Set_RF_Channel(Adapter, 14, (U8)dot11Obj.rfMode, 1);                    ChannelNo = 14;

⌨️ 快捷键说明

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