prism2sta.c
来自「Linux的无线局域网方案是一个Linux设备驱动程序和子系统 一揽子方案的用」· C语言 代码 · 共 2,232 行 · 第 1/5 页
C
2,232 行
fields in byte order */ priv->cap_sup_cfi.role = hfa384x2host_16(priv->cap_sup_cfi.role); priv->cap_sup_cfi.id = hfa384x2host_16(priv->cap_sup_cfi.id); priv->cap_sup_cfi.variant = hfa384x2host_16(priv->cap_sup_cfi.variant); priv->cap_sup_cfi.bottom = hfa384x2host_16(priv->cap_sup_cfi.bottom); priv->cap_sup_cfi.top = hfa384x2host_16(priv->cap_sup_cfi.top); WLAN_LOG_INFO5( "CFI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", priv->cap_sup_cfi.role, priv->cap_sup_cfi.id, priv->cap_sup_cfi.variant, priv->cap_sup_cfi.bottom, priv->cap_sup_cfi.top); /* Compatibility range, Primary f/w supplier */ result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRISUPRANGE, &priv->cap_sup_pri, sizeof(hfa384x_caplevel_t)); if ( result ) { WLAN_LOG_ERROR0("Failed to retrieve PRISUPRANGE\n"); goto failed; } /* get all the Compatibility range, primary firmware supplier fields in byte order */ priv->cap_sup_pri.role = hfa384x2host_16(priv->cap_sup_pri.role); priv->cap_sup_pri.id = hfa384x2host_16(priv->cap_sup_pri.id); priv->cap_sup_pri.variant = hfa384x2host_16(priv->cap_sup_pri.variant); priv->cap_sup_pri.bottom = hfa384x2host_16(priv->cap_sup_pri.bottom); priv->cap_sup_pri.top = hfa384x2host_16(priv->cap_sup_pri.top); WLAN_LOG_INFO5( "PRI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", priv->cap_sup_pri.role, priv->cap_sup_pri.id, priv->cap_sup_pri.variant, priv->cap_sup_pri.bottom, priv->cap_sup_pri.top); /* Compatibility range, Station f/w supplier */ result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STASUPRANGE, &priv->cap_sup_sta, sizeof(hfa384x_caplevel_t)); if ( result ) { WLAN_LOG_ERROR0("Failed to retrieve STASUPRANGE\n"); goto failed; } /* get all the Compatibility range, station firmware supplier fields in byte order */ priv->cap_sup_sta.role = hfa384x2host_16(priv->cap_sup_sta.role); priv->cap_sup_sta.id = hfa384x2host_16(priv->cap_sup_sta.id); priv->cap_sup_sta.variant = hfa384x2host_16(priv->cap_sup_sta.variant); priv->cap_sup_sta.bottom = hfa384x2host_16(priv->cap_sup_sta.bottom); priv->cap_sup_sta.top = hfa384x2host_16(priv->cap_sup_sta.top); if ( priv->cap_sup_sta.id == 0x04 ) { WLAN_LOG_INFO5( "STA:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", priv->cap_sup_sta.role, priv->cap_sup_sta.id, priv->cap_sup_sta.variant, priv->cap_sup_sta.bottom, priv->cap_sup_sta.top); } else { WLAN_LOG_INFO5( "AP:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", priv->cap_sup_sta.role, priv->cap_sup_sta.id, priv->cap_sup_sta.variant, priv->cap_sup_sta.bottom, priv->cap_sup_sta.top); } /* Compatibility range, primary f/w actor, CFI supplier */ result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRI_CFIACTRANGES, &priv->cap_act_pri_cfi, sizeof(hfa384x_caplevel_t)); if ( result ) { WLAN_LOG_ERROR0("Failed to retrieve PRI_CFIACTRANGES\n"); goto failed; } /* get all the Compatibility range, primary f/w actor, CFI supplier fields in byte order */ priv->cap_act_pri_cfi.role = hfa384x2host_16(priv->cap_act_pri_cfi.role); priv->cap_act_pri_cfi.id = hfa384x2host_16(priv->cap_act_pri_cfi.id); priv->cap_act_pri_cfi.variant = hfa384x2host_16(priv->cap_act_pri_cfi.variant); priv->cap_act_pri_cfi.bottom = hfa384x2host_16(priv->cap_act_pri_cfi.bottom); priv->cap_act_pri_cfi.top = hfa384x2host_16(priv->cap_act_pri_cfi.top); WLAN_LOG_INFO5( "PRI-CFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", priv->cap_act_pri_cfi.role, priv->cap_act_pri_cfi.id, priv->cap_act_pri_cfi.variant, priv->cap_act_pri_cfi.bottom, priv->cap_act_pri_cfi.top); /* Compatibility range, sta f/w actor, CFI supplier */ result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STA_CFIACTRANGES, &priv->cap_act_sta_cfi, sizeof(hfa384x_caplevel_t)); if ( result ) { WLAN_LOG_ERROR0("Failed to retrieve STA_CFIACTRANGES\n"); goto failed; } /* get all the Compatibility range, station f/w actor, CFI supplier fields in byte order */ priv->cap_act_sta_cfi.role = hfa384x2host_16(priv->cap_act_sta_cfi.role); priv->cap_act_sta_cfi.id = hfa384x2host_16(priv->cap_act_sta_cfi.id); priv->cap_act_sta_cfi.variant = hfa384x2host_16(priv->cap_act_sta_cfi.variant); priv->cap_act_sta_cfi.bottom = hfa384x2host_16(priv->cap_act_sta_cfi.bottom); priv->cap_act_sta_cfi.top = hfa384x2host_16(priv->cap_act_sta_cfi.top); WLAN_LOG_INFO5( "STA-CFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", priv->cap_act_sta_cfi.role, priv->cap_act_sta_cfi.id, priv->cap_act_sta_cfi.variant, priv->cap_act_sta_cfi.bottom, priv->cap_act_sta_cfi.top); /* Compatibility range, sta f/w actor, MFI supplier */ result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STA_MFIACTRANGES, &priv->cap_act_sta_mfi, sizeof(hfa384x_caplevel_t)); if ( result ) { WLAN_LOG_ERROR0("Failed to retrieve STA_MFIACTRANGES\n"); goto failed; } /* get all the Compatibility range, station f/w actor, MFI supplier fields in byte order */ priv->cap_act_sta_mfi.role = hfa384x2host_16(priv->cap_act_sta_mfi.role); priv->cap_act_sta_mfi.id = hfa384x2host_16(priv->cap_act_sta_mfi.id); priv->cap_act_sta_mfi.variant = hfa384x2host_16(priv->cap_act_sta_mfi.variant); priv->cap_act_sta_mfi.bottom = hfa384x2host_16(priv->cap_act_sta_mfi.bottom); priv->cap_act_sta_mfi.top = hfa384x2host_16(priv->cap_act_sta_mfi.top); WLAN_LOG_INFO5( "STA-MFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", priv->cap_act_sta_mfi.role, priv->cap_act_sta_mfi.id, priv->cap_act_sta_mfi.variant, priv->cap_act_sta_mfi.bottom, priv->cap_act_sta_mfi.top); /* Serial Number */ result = hfa384x_drvr_getconfig(hw, HFA384x_RID_NICSERIALNUMBER, snum, HFA384x_RID_NICSERIALNUMBER_LEN); if ( !result ) { wlan_mkprintstr(snum, HFA384x_RID_NICSERIALNUMBER_LEN, pstr, sizeof(pstr)); WLAN_LOG_INFO1("Prism2 card SN: %s\n", pstr); } else { WLAN_LOG_ERROR0("Failed to retrieve Prism2 Card SN\n"); goto failed; } /* Collect the MAC address */ result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CNFOWNMACADDR, wlandev->netdev->dev_addr, WLAN_ADDR_LEN); if ( result != 0 ) { WLAN_LOG_ERROR0("Failed to retrieve mac address\n"); goto failed; } /* TODO: Set any internally managed config items */ goto done;failed: WLAN_LOG_ERROR1("Failed, result=%d\n", result);done: DBFEXIT; return result;}/*----------------------------------------------------------------* prism2sta_globalsetup** Set any global RIDs that we want to set at device activation.** Arguments:* wlandev wlan device structure** Returns: * 0 success* >0 f/w reported error* <0 driver reported error** Side effects:** Call context:* process thread----------------------------------------------------------------*/int prism2sta_globalsetup(wlandevice_t *wlandev){ prism2sta_priv_t *priv = (prism2sta_priv_t*)wlandev->priv; hfa384x_t *hw = priv->hw; UINT16 reg; DBFENTER; /* Set the maximum frame size */ reg=WLAN_DATA_MAXLEN; hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFMAXDATALEN, ®); return 0; DBFENTER;}/*----------------------------------------------------------------* prism2sta_inf_handover** Handles the receipt of a Handover info frame. Should only be present* in APs only.** Arguments:* wlandev wlan device structure* inf ptr to info frame (contents in hfa384x order)** Returns: * nothing** Side effects:** Call context:* interrupt----------------------------------------------------------------*/void prism2sta_inf_handover(wlandevice_t *wlandev, hfa384x_InfFrame_t *inf){ DBFENTER; WLAN_LOG_DEBUG0(2,"received infoframe:HANDOVER (unhandled)\n"); DBFEXIT; return;}/*----------------------------------------------------------------* prism2sta_inf_tallies** Handles the receipt of a CommTallies info frame. ** Arguments:* wlandev wlan device structure* inf ptr to info frame (contents in hfa384x order)** Returns: * nothing** Side effects:** Call context:* interrupt----------------------------------------------------------------*/void prism2sta_inf_tallies(wlandevice_t *wlandev, hfa384x_InfFrame_t *inf){ prism2sta_priv_t *priv = wlandev->priv; UINT16 *src16; UINT32 *dst; UINT32 *src32; int i; int cnt; DBFENTER; /* ** Determine if these are 16-bit or 32-bit tallies, based on the ** record length of the info record. */ cnt = sizeof(hfa384x_CommTallies32_t) / sizeof(UINT32); if (inf->framelen > 22) { dst = (UINT32 *) &priv->tallies; src32 = (UINT32 *) &inf->info.commtallies32; for (i = 0; i < cnt; i++, dst++, src32++) *dst += hfa384x2host_32(*src32); } else { dst = (UINT32 *) &priv->tallies; src16 = (UINT16 *) &inf->info.commtallies16; for (i = 0; i < cnt; i++, dst++, src16++) *dst += hfa384x2host_16(*src16); } DBFEXIT; return;}/*----------------------------------------------------------------* prism2sta_inf_scanresults** Handles the receipt of a Scan Results info frame.** Arguments:* wlandev wlan device structure* inf ptr to info frame (contents in hfa384x order)** Returns: * nothing** Side effects:** Call context:* interrupt----------------------------------------------------------------*/void prism2sta_inf_scanresults(wlandevice_t *wlandev, hfa384x_InfFrame_t *inf){ prism2sta_priv_t *priv = wlandev->priv; hfa384x_t *hw = priv->hw; int nbss; hfa384x_ScanResult_t *sr = &(inf->info.scanresult); int i; hfa384x_JoinRequest_data_t joinreq; int result; DBFENTER; /* Get the number of results, first in bytes, then in results */ nbss = (inf->framelen * sizeof(UINT16)) - sizeof(inf->infotype) - sizeof(inf->info.scanresult.scanreason); nbss /= sizeof(hfa384x_ScanResultSub_t); /* Print em */ WLAN_LOG_DEBUG2(1,"rx scanresults, reason=%d, nbss=%d:\n", inf->info.scanresult.scanreason, nbss); for ( i = 0; i < nbss; i++) { WLAN_LOG_DEBUG4(1, "chid=%d anl=%d sl=%d bcnint=%d\n", sr->result[i].chid, sr->result[i].anl, sr->result[i].sl, sr->result[i].bcnint); WLAN_LOG_DEBUG2(1, " capinfo=0x%04x proberesp_rate=%d\n", sr->result[i].capinfo, sr->result[i].proberesp_rate); } /* issue a join request */ joinreq.channel = sr->result[0].chid; memcpy( joinreq.bssid, sr->result[0].bssid, WLAN_BSSID_LEN); result = hfa384x_drvr_setconfig( hw, HFA384x_RID_JOINREQUEST, &joinreq, HFA384x_RID_JOINREQUEST_LEN); if (result) { WLAN_LOG_ERROR1("setconfig(joinreq) failed, result=%d\n", result); } DBFEXIT; return;}/*----------------------------------------------------------------* prism2sta_inf_chinforesults** Handles the receipt of a Channel Info Results info frame.** Arguments:* wlandev wlan device structure* inf ptr to info frame (contents in hfa384x order)** Returns: * nothing** Side effects:** Call context:* interrupt----------------------------------------------------------------*/void prism2sta_inf_chinforesults(wlandevice_t *wlandev, hfa384x_InfFrame_t *inf){ prism2sta_priv_t *priv = wlandev->priv; unsigned int i, n; DBFENTER; priv->channel_info.results.scanchannels = hfa384x2host_16(inf->info.chinforesult.scanchannels);#if 0 memcpy(&inf->info.chinforesult, &priv->channel_info.results, sizeof(hfa384x_ChInfoResult_t));#endif for (i=0, n=0; i<HFA384x_CHINFORESULT_MAX; i++) { if (priv->channel_info.results.scanchannels & (1<<i)) { int channel=hfa384x2host_16(inf->info.chinforesult.result[n].chid)-1; hfa384x_ChInfoResultSub_t *chinforesult=&priv->channel_info.results.result[channel]; chinforesult->chid = channel; chinforesult->anl = hfa384x2host_16(inf->info.chinforesult.result[n].anl); chinforesult->pnl = hfa384x2host_16(inf->info.chinforesult.result[n].pnl); chinforesult->active = hfa384x2host_16(inf->info.chinforesult.result[n].active); WLAN_LOG_DEBUG5(2, "chinfo: channel %d, %s level (avg/peak)=%d/%d dB, pcf %d\n", channel+1, chinforesult->active & HFA384x_CHINFORESULT_BSSACTIVE ? "signal" : "noise", chinforesult->anl, chinforesult->pnl, chinforesult->active & HFA384x_CHINFORESULT_PCFACTIVE ? 1 : 0 ); n++; } } atomic_set(&priv->channel_info.done, 2); priv->channel_info.count = n; DBFEXIT; return;}/*----------------------------------------------------------------* prism2sta_inf_linkstatus** Handles the receipt of a Link Status info frame.** Arguments:* wlandev wlan device structure* inf ptr to info frame (contents in hfa384x order)** Returns: * nothing** Side effects:** Call context:* interrupt----------------------------------------------------------------*/void prism2sta_inf_linkstatus(wlandevice_t *wlandev, hfa384x_InfFrame_t *inf){ prism2sta_priv_t *priv = wlandev->priv; hfa384x_t *hw = priv->hw; DBFENTER; /* Convert */ inf->info.linkstatus.linkstatus = hfa384x2host_16(inf->info.linkstatus.linkstatus); /* Handle */ switch (inf->info.linkstatus.linkstatus) { case HFA384x_LINK_NOTCONNECTED: /* I'm currently assuming that this is the initial link * state. It should only be possible immediately * following an Enable command. * Response: * Block Transmits, Ignore receives of data frames */ WLAN_LOG_DEBUG0(1,"linkstatus=NOTCONNECTED (unhandled)\n"); break; case HFA384x_LINK_CONNECTED: /* This one indicates a successful scan/join/auth/assoc. * When we have the full MLME complement, this event will * signify successful completion of both mlme_authenticate * and mlme_associate. State management will get a little * ugly here. * Response: * Indicate authentication and/or association * Enable Transmits, Receives and pass up data frames */ WLAN_LOG_DEBUG0(1,"linkstatus=CONNECTED\n");#if (WLAN_HOSTIF == WLAN_USB) /* For USB devices, all the [get|set]config calls that * occur in an 'event (i.e. interrupt) context must * use the async version. */ /* Collect the BSSID, and set state to allow tx */ hfa384x_drvr_getconfig_async(hw,
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?