RT2860V2 Source Analysis Three

Source: Internet
Author: User
Tags bssid

The rtmpphynetdevinit is invoked in the Rt2860_probe function to initialize the wireless network device, essentially allocating the pnetdevhook structure:

Pnet_dev rtmpphynetdevinit (in VOID *pad, in Rtmp_os_netdev_op_hook *pnetdevhook) {Stru
CT Net_device *net_dev = NULL; /* Ndis_status STATUS;

    * * ULONG InfID, Opmode;

Rtmp_driver_main_inf_get (PAd, &infid); /* Net_dev = Rtmposnetdevcreate (pAd, int_main, 0, sizeof (prtmp_adapter), inf_main_dev_name);
    * * Rtmp_driver_main_inf_create (pAd, &net_dev);
        if (Net_dev = = NULL) {PRINTK ("rtmpphynetdevinit (): Creation failed for main physical net device!\n");
    return NULL;
    } ndiszeromemory ((unsigned char *) pnetdevhook, sizeof (Rtmp_os_netdev_op_hook));
    Pnetdevhook->open = Mainvirtualif_open;
    Pnetdevhook->stop = Mainvirtualif_close;
Pnetdevhook->xmit = rt28xx_send_packets;
#ifdef ikanos_vx_1x0 pnetdevhook->xmit = ikanos_dataframestx;
    #endif/* ikanos_vx_1x0 * * pnetdevhook->ioctl = RT28XX_IOCTL; Pnetdevhook->priv_flags = InfID; /*int_main; * * Pnetdevhook->get_stATS = rt28xx_get_ether_stats;

pnetdevhook->needprotcted = FALSE;
#if (Wireless_ext <) && (Wireless_ext >=) pnetdevhook->get_wstats = rt28xx_get_wireless_stats;

#endif rtmp_driver_op_mode_get (PAd, &opmode);  #ifdef config_sta_support #if wireless_ext >= (opmode = = Opmode_sta) {Pnetdevhook->iw_handler
    = (void *) &rt28xx_iw_handler_def; #endif/*wireless_ext >=/#endif/* Config_sta_support/#ifdef config_apsta_mixed_support #if wireless_ext &G
    t;= if (Opmode = = Opmode_ap) {Pnetdevhook->iw_handler = &rt28xx_ap_iw_handler_def; #endif/*wireless_ext >=/#endif/* config_apsta_mixed_support/* Put private data structure/* * RTMP

    _os_netdev_set_priv (Net_dev, pAd); /* Double-check if pAd is associated with the Net_dev/if (Rtmp_os_netdev_get_priv (net_dev) = NULL) {R
        Tmposnetdevfree (Net_dev);
    return NULL; }/* PAD-&GT;net_dev = Net_dev;

* * Rtmp_driver_net_dev_set (pAd, Net_dev);
#if Linux_version_code < Kernel_version (2,6,24) Set_module_owner (Net_dev);

#endif return Net_dev; }

The

Pnetdevhook is the rtmp_os_netdev_op_hook structure, which is rtmp_os the hook that operates on the network device and is assigned to the Rtmposnetdevattach function net_ The device structural body Pnetdev is associated. Then the network operation Open function is Mainvirtualif_open, and the other operations correspond to each other, and the Mainvirtualif_open contents are as follows:

/* ======================================================================== routine Description:open RaxX interface

. Arguments: *net_dev The RaxX interface pointer ===========================================================

    ============= */int mainvirtualif_open (in struct Net_device *net_dev) {VOID *pad = NULL; 

    Get_pad_from_net_dev (PAD, Net_dev); /* Sanity check for pad */if (pad = NULL) return 0; /* Close OK */#ifdef config_ap_support/* pad->apcfg.mbssid[main_mbssid].bbcnsntreq = TRUE;
* * Rtmp_driver_ap_main_open (PAD); #endif/* Config_ap_support/#ifdef Ifup_in_probe while Rtmp_driver_ioctl_sanity_check (PAd, NULL)!= Ndis_stat
        us_success) {os_wait (10);
    Dbgprint (Rt_debug_trace, ("Card not Ready, ndis_status_success!\n"));
#else if (virtual_if_up (pAd)!= 0) return-1;

    #endif/* ifup_in_probe/* Increase MODULE Use count */Rt_mod_inc_use_count (); Netif_staRt_queue (Net_dev);
    NETIF_CARRIER_ON (Net_dev);

    Netif_wake_queue (Net_dev);
return 0;
 }

In functions prefixed with RTMP_DRIVD, such as Rtmp_driver_main_inf_get and rtmp_driver_main_inf_create, these functions define the port IOCTL operation in Rtmp, and the unified invocation of the RTMP_ Com_ioctlhandle, and select different operation tasks according to the parameter cmd.

The Rtmp_com_ioctlhandle function reads as follows:

int Rtmp_com_ioctlhandle (in VOID *padsrc, in Rtmp_ioctl_input_struct *WRQ, in int                   CMD, in USHORT subcmd, in VOID *pdata, in ULONG
    Data) {Prtmp_adapter pAd = (prtmp_adapter) padsrc;
    Pos_cookie pobj = (Pos_cookie) pad->os_cookie;
    INT Status = ndis_status_success, I;
    Uchar Permanentaddress[mac_addr_len];


    USHORT Addr01, Addr23, Addr45; Pobj = Pobj; /* Avoid compile warning/switch (cmd) {case Cmd_rtpriv_ioctl_netdev_get:/* Get main Net_dev *
            /{void **ppnetdev = (void * * *) PData;
        *ppnetdev = (VOID *) (Pad->net_dev);

        } break;

Case Cmd_rtpriv_ioctl_netdev_set:/* SET main Net_dev * * Pad->net_dev = PData; #ifdef Config_ap_support Pad->apcfg.mbssid[main_mbssid].
Mssiddev = PData;
         #endif/* Config_ap_support * *   Break
            Case Cmd_rtpriv_ioctl_opmode_get:/* Get Operation Mode * * (ULONG *) PData = pad->opmode;


        Break Case Cmd_rtpriv_ioctl_task_list_get:/* Get all Tasks/{rt_cmd_wait_queue_list *plist = (RT

            _cmd_wait_queue_list *) PData;
Plist->pmlmetask = &pAd->mlmeTask;
#ifdef Rtmp_timer_task_support plist->ptimertask = &pAd->timerTask;
#endif/* Rtmp_timer_task_support * plist->pcmdqtask = &pAd->cmdQTask;
#ifdef wsc_included plist->pwsctask = &pAd->wscTask;

        #endif/* wsc_included/} break;
            Case CMD_RTPRIV_IOCTL_IRQ_INIT:/* INIT IRQ/rtmp_irq_init (PAD);

        Break
            Case Cmd_rtpriv_ioctl_irq_release:/* Release IRQ */Rtmp_os_irq_release (pAd, Pad->net_dev);

Break #ifdef RTMP_MAC_PCI Case Cmd_rtpriv_ioctl_msi_eNable: * Enable MSI */rtmp_msi_enable (PAD);
            * (ULONG * *) PData = (ULONG *) (Pobj->pci_dev);
Break #endif/* Rtmp_mac_pci/Case cmd_rtpriv_ioctl_nic_not_exist:/* Set driver state to Frtmp_adapter_nic_n
            Ot_exist * * Rtmp_set_flag (pAd, frtmp_adapter_nic_not_exist);

Break
            #ifdef config_apsta_mixed_support Case cmd_rtpriv_ioctl_max_in_bit:/* Set max_in_bit for WMM * *
            Cw_max_in_bits = Data;
Break
                #endif/* Config_apsta_mixed_support * * #ifdef config_sta_support #ifdef config_pm #ifdef usb_support_selective_suspend
                        Case Cmd_rtpriv_ioctl_usb_dev_get:/* Get USB DEV/*
                        void **ppusb_dev = (void * * *) PData;
                *ppusb_dev = (VOID *) (Pobj->pusb_dev);

                } break; Case Cmd_rtpriv_ioctl_usb_intf_get:/*Get USB intf */{void **ppintf = (void * * *) PData;
                *ppintf = (VOID *) (pobj->intf);

        } break; Case Cmd_rtpriv_ioctl_adapter_suspend_set:/* SET driver State to Frtmp_adapter_suspend * * RTMP_SET_FL
            AG (Pad,frtmp_adapter_suspend);

        Break Case Cmd_rtpriv_ioctl_adapter_suspend_clear:/* Clear driver State to Frtmp_adapter_suspend * * RTMP_CL
            Ear_flag (Pad,frtmp_adapter_suspend);

        Break  Case Cmd_rtpriv_ioctl_adapter_send_dissassociate:/* Clear driver State to frtmp_adapter_suspend */IF (infra_on (PAD) && (!
                Rtmp_test_flag (PAd, frtmp_adapter_nic_not_exist))) {mlme_disassoc_req_struct disreq;
                Mlme_queue_elem *msgelem;/* = (Mlme_queue_elem *) kmalloc (sizeof (Mlme_queue_elem), Mem_alloc_flag); Os_alloc_meM (NULL, (UCHAR * *) &msgelem, sizeof (Mlme_queue_elem));
                    if (Msgelem) {copy_mac_addr (disreq.addr, Pad->commoncfg.bssid);
                    Disreq.reason = reason_deauth_sta_leaving;
                    Msgelem->machine = Assoc_state_machine;
                    Msgelem->msgtype = Mt2_mlme_disassoc_req;
                    Msgelem->msglen = sizeof (mlme_disassoc_req_struct);
                    Ndismovememory (msgelem->msg, &disreq, sizeof (mlme_disassoc_req_struct));
                    /* Prevent to connect AP again in stamlmeperiodicexec*/pad->mlmeaux.autoreconnectssidlen= 32;
                    Ndiszeromemory (Pad->mlmeaux.autoreconnectssid, Pad->mlmeaux.autoreconnectssidlen);
                    Pad->mlme.cntlmachine.currstate = CNTL_WAIT_OID_DISASSOC; Mlmedisassocreqaction (PAd, Msgelem);/* Kfree (Msgelem); * * OS_FREE_MEM (NULL, Msgelem); }/* Rtmpusecdelay (1000); * * Rtmposwrielesseventsend (Pad->net_dev, Rt_wlan_
            Event_cgiwap,-1, NULL, NULL, 0);

        } break; Case Cmd_rtpriv_ioctl_adapter_suspend_test:/* TEST driver State to Frtmp_adapter_suspend * * (UCHAR *
            ) PData = Rtmp_test_flag (pad,frtmp_adapter_suspend);

        Break
            Case Cmd_rtpriv_ioctl_adapter_idle_radio_off_test:/* TEST driver State to Frtmp_adapter_idle_radio_off * *
            * (UCHAR *) PData = Rtmp_test_flag (Pad,frtmp_adapter_idle_radio_off);

        Break Case Cmd_rtpriv_ioctl_adapter_rt28xx_usb_asicradio_off:/* rt28xxusbasicradiooff * * Rt28xxusbasicradio
            Off (PAD);

        Break Case CMD_RTPRIV_IOCTL_ADAPTER_RT28XX_USB_ASICRADIO_ON:/* rt28xxusbasicradioon * * Rt28xxusbasicradioon
            (PAD);

Break #ifdef wow_support #endif/* wow_support* * #endif/* Usb_support_selective_suspend/#endif/* config_pm/Case Cmd_rtpriv_ioctl_ap_bssid_get: if (pad->stacfg.portsecured = = wpa_802_1x_port_not_secured) ndiscopymemory (PData, Pad->mlmeau
            X.bssid, 6);
            else return ndis_status_failure;
Break
            #endif/* Config_sta_support/Case Cmd_rtpriv_ioctl_sanity_check:/* Sanity CHECK before IOCTL * * if (! Rtmp_test_flag (PAd, Frtmp_adapter_interrupt_in_use)) #ifdef Ifup_in_probe | | (Rtmp_test_flag (PAd, frtmp_adapter_reset_in_progress)) | | (Rtmp_test_flag (PAd, frtmp_adapter_halt_in_progress)) | |
                (Rtmp_test_flag (PAd, frtmp_adapter_nic_not_exist)) #endif/* Ifup_in_probe/*) { if (PData = NULL | |
            Rt_islegalcmdbeforeinfup ((pstring) pData) = = FALSE) return ndis_status_failure;

        } break; Case CMD_RTPRIV_IOCTL_siocgiwfreq:/* Get channel number * * (ULONG *) PData = pad->commoncfg.channel;

Break
            #ifdef Mesh_support Case Cmd_rtpriv_ioctl_mesh_init:meshinit (pAd, pData);

        Break
            Case Cmd_rtpriv_ioctl_mesh_remove:mesh_remove (PAD);

        Break 
            Case Cmd_rtpriv_ioctl_mesh_open_pre:if (Mesh_openpre (pData)!= 0) return ndis_status_failure;

        Break Case Cmd_rtpriv_ioctl_mesh_open_post:if (Mesh_openpost (pData)!= 0) return Ndis_status_failur
            E

        Break
            Case cmd_rtpriv_ioctl_mesh_is_valid: * (BOOLEAN *) PData = Meshvalid (&pad->meshtab);

        Break
            Case Cmd_rtpriv_ioctl_mesh_close:mesh_close (PData);
Break
            #endif/* Mesh_support/#ifdef p2p_support case Cmd_rtpriv_ioctl_p2p_init:p2pinit (pAd, pData);

  Break      Case Cmd_rtpriv_ioctl_p2p_remove:p2p_remove (PAD);

        Break
            Case Cmd_rtpriv_ioctl_p2p_open_pre:if (P2p_openpre (pData)!= 0) return ndis_status_failure;

        Break 
            Case Cmd_rtpriv_ioctl_p2p_open_post:if (P2p_openpost (pData)!= 0) return ndis_status_failure;

        Break
            Case Cmd_rtpriv_ioctl_p2p_close:p2p_close (PData);
Break #endif/* P2p_support/Case cmd_rtpriv_ioctl_beacon_update:/* UPDATE all BEACON contents/#ifdef CON
            Fig_ap_support Apmakeallbssbeacon (pAd);
Apupdateallbeaconframe (PAD);
            #endif/* Config_ap_support/#ifdef mesh_support Meshmakebeacon (pAd, PAD-&GT;MESHTAB.BCNBUFIDX);
Meshupdatebeaconframe (PAd, PAD-&GT;MESHTAB.BCNBUFIDX);

        #endif/* mesh_support * * BREAK;
Case Cmd_rtpriv_ioctl_rxpath_get:/* Get the number of RX path * *            * (ULONG *) PData = pad->antenna.field.rxpath;

        Break
            Case Cmd_rtpriv_ioctl_chan_list_num_get: * (ULONG *) PData = pad->channellistnum;

        Break
            Case Cmd_rtpriv_ioctl_chan_list_get: {UINT32 i;

            Uchar *pchannel = (Uchar *) PData; for (i = 1; I <= pad->channellistnum; i++) {*pchannel = pad->channellist[i-1].
                Channel;
            Pchannel + +;

        }} break;
            Case Cmd_rtpriv_ioctl_freq_list_get: {UINT32 i;
            UINT32 *pfreq = (UINT32 *) PData;

            UINT32 m;
                for (i = 1; I <= pad->channellistnum; i++) {m = 2412000; Map_channel_id_to_khz (Pad->channellist[i-1].
                Channel, M);
                (*pfreq) = m;
            Pfreq + +;

}} break; #ifdef ext_build_channel_list CASE Cmd_rtpriv_set_preconfig_value:/* SET some preconfigured VALUE before interface up*/Pad->common
           Cfg.dfstype = max_rd_region;
Break #endif/* ext_build_channel_list * * #ifdef rtmp_pci_support case cmd_rtpriv_ioctl_pci_suspend:rtmp
            _set_flag (PAd, frtmp_adapter_halt_in_progress);
            Rtmp_set_flag (PAd, Frtmp_adapter_radio_off);

        Break
            Case Cmd_rtpriv_ioctl_pci_resume:rtmp_clear_flag (PAd, frtmp_adapter_halt_in_progress);
            Rtmp_clear_flag (PAd, Frtmp_adapter_radio_off);

        Break
            Case cmd_rtpriv_ioctl_pci_csr_set:pad->csrbaseaddress = (Puchar) Data; Dbgprint (Rt_debug_error, ("Pad->csrbaseaddress =0x%lx, csr_addr=0x%lx!\n", (ULONG) pad->csrbaseaddress, (ULONG
            ) (Data));

        Break
            Case Cmd_rtpriv_ioctl_pcie_init:rtmpinitpciedevice (PData, pAd);
Break #endif/* Rtmp_pci_support * * #ifdef RT_CFG80211_support case Cmd_rtpriv_ioctl_cfg80211_cfg_start:rt_cfg80211_reinit (pAd);
            Rt_cfg80211_crda_reg_rule_apply (PAD);
Break #endif/* Rt_cfg80211_support * * #ifdef inf_ppa_support case CMD_RTPRIV_IOCTL_INF_PPA_INIT:OS_ALLOC_
            Mem (NULL, (UCHAR * *) & (PAD-&GT;PDIRECTPATHCB), sizeof (PPA_DIRECTPATH_CB));

        Break Case Cmd_rtpriv_ioctl_inf_ppa_exit:if (PPA_HOOK_DIRECTPATH_REGISTER_DEV_FN && pad->ppaenable==true
                ) {UINT status;
                STATUS=PPA_HOOK_DIRECTPATH_REGISTER_DEV_FN (&pad->g_if_id, Pad->net_dev, NULL, 0);
            Dbgprint (Rt_debug_trace, ("Unregister ppa:g_if_id=%d status=%d\n", pad->g_if_id,status));
            } os_free_mem (NULL, PAD-&GT;PDIRECTPATHCB);
Break
            #endif/* inf_ppa_support*/case CMD_RTPRIV_IOCTL_VIRTUAL_INF_UP:/* Interface up/* { Rt_cmd_inf_up_down *pinfconf = (Rt_cmd_inf_up_down *) PData;
                if (Virtual_if_num (pAd) = = 0) {if (Pinfconf->rt28xx_open (Pad->net_dev)!= 0)
                    {Dbgprint (Rt_debug_trace, ("Rt28xx_open return fail!\n"));
                return ndis_status_failure; } else {#ifdef config_ap_support extern VOID Apmakeallbssbeacon (in
                Prtmp_adapter pAd);
                extern VOID Apupdateallbeaconframe (in Prtmp_adapter pAd);
                Apmakeallbssbeacon (PAD);
Apupdateallbeaconframe (PAD); #endif/* Config_ap_support */#ifdef mesh_support {extern VOID Meshmakebeacon (in PRT
                    Mp_adapter pAd, in Uchar idx);
                    extern VOID Meshupdatebeaconframe (in Prtmp_adapter pAd, in Uchar idx);
                    Meshmakebeacon (PAd, PAD-&GT;MESHTAB.BCNBUFIDX); Meshupdatebeaconframe (PAd, PAD-&GT;MESHTAB.BCNBUFIDX);
        #endif/* Mesh_support/} virtual_if_inc (PAd);

        } break; Case Cmd_rtpriv_ioctl_virtual_inf_down:/* Interface Down * * * rt_cmd_inf_up_down *pinfconf =

            (Rt_cmd_inf_up_down *) PData;
            Virtual_if_dec (PAD);
        if (Virtual_if_num (pAd) = = 0) pinfconf->rt28xx_close (pad->net_dev);

        } break; Case Cmd_rtpriv_ioctl_virtual_inf_get:/* Get VIRTUAL Interface number * * (ULONG *) PData = virtual_if
            _num (PAD);

        Break Case Cmd_rtpriv_ioctl_inf_type_get:/* Get Current interface TYPE * * (ULONG *) PData = Pad->inftype
            ;

        Break Case Cmd_rtpriv_ioctl_inf_stats_get:/* Get statistics * * Rt_cmd_stat
                S *pstats = (rt_cmd_stats *) PData; Pstats->pstats = Pad->staTs if (Pad->opmode = = Opmode_sta) {pstats->rx_packets = Pad->wlancounters.receiv
                    Edfragmentcount.quadpart;
                    Pstats->tx_packets = pad->wlancounters.transmittedfragmentcount.quadpart;
                    Pstats->rx_bytes = pad->ralinkcounters.receivedbytecount;
                    Pstats->tx_bytes = pad->ralinkcounters.transmittedbytecount;
                    Pstats->rx_errors = pad->counters8023.rxerrors;
                    Pstats->tx_errors = pad->counters8023.txerrors;   Pstats->multicast = pad->wlancounters.multicastreceivedframecount.quadpart; /* Multicast packets received*/pstats->collisions = pad->counters8023.onecollision + Pad->co unters8023.  Morecollisions;                   /* Collision packets*/pstats->rx_over_errors = pad->counters8023.rxnobuffer;
    /* Receiver Ring buff overflow*/                Pstats->rx_crc_errors = 0;/*pad->wlancounters.fcserrorcount;          Recved PKT with CRC error*/Pstats->rx_frame_errors = pad->counters8023.rcvalignmenterrors;                   /* recv ' d frame alignment error*/pstats->rx_fifo_errors = pad->counters8023.rxnobuffer; /* recv ' r FIFO overrun*/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.