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

📄 zdreq.c

📁 zd1211b芯片的无线网卡的驱动,移植到s3c2410平台
💻 C
📖 第 1 页 / 共 5 页
字号:
/* src/zdreq.c * * * * Copyright (C) 2004 ZyDAS Inc.  All Rights Reserved. * -------------------------------------------------------------------- * * * *   The contents of this file are subject to the Mozilla Public *   License Version 1.1 (the "License"); you may not use this file *   except in compliance with the License. You may obtain a copy of *   the License at http://www.mozilla.org/MPL/ * *   Software distributed under the License is distributed on an "AS *   IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or *   implied. See the License for the specific language governing *   rights and limitations under the License. * *   Alternatively, the contents of this file may be used under the *   terms of the GNU Public License version 2 (the "GPL"), in which *   case the provisions of the GPL are applicable instead of the *   above.  If you wish to allow the use of your version of this file *   only under the terms of the GPL and not to allow others to use *   your version of this file under the MPL, indicate your decision *   by deleting the provisions above and replace them with the notice *   and other provisions required by the GPL.  If you do not delete *   the provisions above, a recipient may use your version of this *   file under either the MPL or the GPL. * * -------------------------------------------------------------------- */#include "zd1205.h"#include "zdhw.h"#include "zdhci.h"#include "zddebug.h"#include "zdreq.h"#include "zdsm.h"#include "zdbuf.h"#ifdef PRODUCTIONextern zd_80211Obj_t dot11Obj;extern U8 mMacMode;extern void zd1205_CollectHwTally(struct zd1205_private *macp);//extern void zd1205_SoftwareReset(struct zd1205_private *macp);/* In fact, these global variables should be avoided. The should be * removed to the context of adapter. *///extern U8 IntValue[14];int zdproduction_ioctl(struct zd1205_private *macp, struct zd_point *p){    NDIS_STATUS status;    oid_wrap_t *param;    int ret = 0;    printk(KERN_ERR "zdproduction_ioctl, length: %d\n", p->length);    if (p->length < sizeof(oid_wrap_t) || !p->pointer)    {        printk(KERN_ERR "Something Wrong,%d,%d\n",p->length,sizeof(oid_wrap_t));        return -EINVAL;    }    param = (oid_wrap_t *) kmalloc(p->length, GFP_ATOMIC);    if (param == NULL)    {        printk(KERN_ERR "Buf is NULL\n");        return -ENOMEM;    }    if (copy_from_user(param, p->pointer, p->length))    {        printk(KERN_ERR "copy_from_user error\n");        ret = -EFAULT;        goto out;    }/* Dump the content */#if 0    ZDPRODUCTDBG("\r\n");    {        int ii;        u8 *pp = (u8 *) param;        for(ii = 0; ii < p->length;)        {            ZDPRODUCTDBG("0x%02x ", pp[ii]);            if((++ii % 16) == 0)                ZDPRODUCTDBG("\r\n");        }        ZDPRODUCTDBG("\r\n");    }#endif/* Dump the data structure of UDP request. */    ZDPRODUCTDBG("request: 0x%04x\n", le16_to_cpu(param->request));    ZDPRODUCTDBG("seq: 0x%04x\n", le16_to_cpu(param->seq));    ZDPRODUCTDBG("oid: 0x%08x\n", le32_to_cpu(param->u.info.oid));    ZDPRODUCTDBG("status: 0x%08x\n", le32_to_cpu(param->u.info.status));    ZDPRODUCTDBG("length: 0x%08x\n", le32_to_cpu(param->u.info.length));/* Query command */    if (le16_to_cpu(param->request) == CMD_QUERY_INFORMATION)    {        NDIS_OID Oid = le32_to_cpu(param->u.info.oid);        PVOID InformationBuffer = param->u.info.data;        ULONG InformationBufferLength = le32_to_cpu(param->u.info.length);        ULONG BytesWritten;        ULONG BytesNeeded;        status = ZD1205EM_Custom_QueryInformation((PVOID) macp,            Oid,            InformationBuffer,            InformationBufferLength,            &BytesWritten,            &BytesNeeded);        param->u.info.status = cpu_to_le32(status);        if (status == NDIS_STATUS_SUCCESS)        {/* Update information */            param->u.info.length = cpu_to_le32(BytesWritten);            p->length = ZD_GENERIC_OID_HDR_LEN + BytesWritten;            ret = 1;        }        else        {/* If the status is not NDIS_STATUS_SUCCESS,   we don't change the length field. */            p->length = ZD_GENERIC_OID_HDR_LEN + sizeof(ZD_RD_STRUCT);            ret = 1;        }    }    else if (le16_to_cpu(param->request) == CMD_SET_INFORMATION)    {        NDIS_OID Oid = le32_to_cpu(param->u.info.oid);        PVOID InformationBuffer = param->u.info.data;        ULONG InformationBufferLength = le32_to_cpu(param->u.info.length);        ULONG BytesWritten;        ULONG BytesNeeded;        status = ZD1205EM_Custom_SetInformation((PVOID) macp,            Oid,            InformationBuffer,            InformationBufferLength,            &BytesWritten,            &BytesNeeded);        param->u.info.status = cpu_to_le32(status);/* Update information */        p->length = ZD_GENERIC_OID_HDR_LEN;        ret = 1;    }    if (ret == 1)    {        if (copy_to_user(p->pointer, param, p->length))        {            ret = -EFAULT;            goto out;        }        else            ret = 0;    }    out:    kfree(param);    return ret;}#if 0 //Replace by SoftwareReset in zdmain.cvoid SoftwareReset(zd1205_private_t *macp){    void *reg = macp->regp;    U32 tmpvalue;    acquire_ctrl_of_phy_req(reg);    dot11Obj.SetReg(reg,ZD1205_PHY_END, 0x8);    release_ctrl_of_phy_req(reg);    tmpvalue = dot11Obj.GetReg(reg, PS_Ctrl);    dot11Obj.SetReg(reg, PS_Ctrl, (tmpvalue | BIT_5));    acquire_ctrl_of_phy_req(reg);    dot11Obj.SetReg(reg, ZD1205_PHY_END, 0x0);    release_ctrl_of_phy_req(reg);/* Recycle Tx process */    ZD1205_recycle_tx(macp);/* Recycle Rx process */    ZD1205_recycle_rx(macp);}#endifUCHAR Rate_Convert_to_MS(UCHAR rate_in_drv){    UCHAR rate;    switch (rate_in_drv)    {        case RATE_1M:            rate = 2;                             // 1M            break;        case RATE_2M:            rate = 4;                             // 2M            break;        case RATE_5M:            rate = 11;                            // 5.5M            break;        case RATE_11M:            rate = 22;                            // 11M            break;        case RATE_6M:            rate = 12;                            // 6M            break;        case RATE_9M:            rate = 18;                            // 9M            break;        case RATE_12M:            rate = 24;                            // 12M            break;        case RATE_18M:            rate = 36;                            // 18M            break;        case RATE_24M:            rate = 48;                            // 24M            break;        case RATE_36M:            rate = 72;                            // 36M            break;        case RATE_48M:            rate = 96;                            // 48M            break;        case RATE_54M:            rate = 108;                           // 54M            break;        default:            rate = 108;                           // 54M            break;    }    return rate;}UCHAR Rate_Convert(UCHAR rate){    switch(rate)    {        case 2:     return 0;                     // 1M        case 4:     return 1;                     // 2M        case 11:    return 2;                     // 5.5M        case 22:    return 3;                     // 11M        case 12:    return 4;                     // 6M        case 18:    return 5;                     // 9M        case 24:    return 6;                     // 12M        case 36:    return 7;                     // 18M        case 48:    return 8;                     // 24M        case 72:    return 9;                     // 36M        case 96:    return 0xa;                   // 48M        case 108:   return 0xb;                   // 54M        default:    return 0xb;                   // 54M    }}void Reset_Tally(zd1205_private_t *macp){    void *reg = macp->regp;    macp->txUnicastFrm = 0;    macp->txMulticastFrm = 0;    macp->txUnicastOctets = 0;    macp->txMulticastOctets = 0;    macp->retryFailCnt = 0;    macp->hwTotalTxFrm = 0;    macp->hwRetryCnt = 0;    macp->hwUnderrunCnt = 0;    macp->DriverRxFrmCnt = 0;    macp->rxUnicastFrm = 0;    macp->rxMulticastFrm = 0;    macp->rxCnt = 0;    macp->rxUnicastOctets = 0;    macp->rxMulticastOctets = 0;    macp->invalid_frame_good_crc = 0;    macp->ErrShortFrmCnt = 0;    macp->ErrLongFrmCnt = 0;    macp->rxBroadcastFrm = 0;    macp->rxBroadcastOctets = 0;    macp->rx11bDataFrame = 0;    macp->rxOFDMDataFrame = 0;    macp->rxNeedFrag = 0;    macp->rxMgtFrm = 0;    macp->hwTotalRxFrm = 0;    macp->hwCRC16Cnt = 0;    macp->hwCRC32Cnt = 0;    macp->hwDecrypErr_UNI = 0;    macp->hwDecrypErr_Mul = 0;    macp->hwRxFIFOOverrun = 0;/* Debug counter */    macp->rxDiscardByNotPIBSS = 0;    macp->rxDiscardByAllocateBuf = 0;/* Read clear those hardware counters */    dot11Obj.GetReg(reg, TotalRxFrm);    dot11Obj.GetReg(reg, CRC32Cnt);    dot11Obj.GetReg(reg, CRC16Cnt);    dot11Obj.GetReg(reg, DecrypErr_UNI);    dot11Obj.GetReg(reg, DecrypErr_Mul);    dot11Obj.GetReg(reg, RxFIFOOverrun);    dot11Obj.GetReg(reg, TotalTxFrm);    dot11Obj.GetReg(reg, UnderrunCnt);    dot11Obj.GetReg(reg, RetryCnt);}NDIS_STATUS ZD1205EM_Custom_QueryInformation(PVOID NDIS_HANDLE,NDIS_OID Oid,PVOID InformationBuffer,ULONG InformationBufferLength,PULONG BytesWritten,PULONG BytesNeeded){    NDIS_STATUS Status;    ULONG GenericUlong;    ULONG IoAddress;//ULONG IoValue;//PVOID MoveSource = (PVOID) (&GenericUlong);//ULONG MoveBytes = sizeof(GenericUlong);    zd1205_private_t *macp = (zd1205_private_t *) NDIS_HANDLE;    void *reg = macp->regp;    NDIS_802_11_CONFIGURATION  *pConfiguration;    ZD_CUSTOM_STRUCT *pZDCustom;    ZD_RD_STRUCT *pZDRD;    RID_STRUCT *rid_p;    LOCAL_TALLY_STRUCT *pLocalTally;

⌨️ 快捷键说明

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