📄 prism2sta.c
字号:
* commands will be accepted.** Arguments:* wlandev wlan device structure* msgp ptr to msg buffer** Returns: * A p80211 message resultcode value.** Side effects:** Call context:* process thread (usually)* interrupt----------------------------------------------------------------*/UINT32 prism2sta_ifstate(wlandevice_t *wlandev, UINT32 ifstate){ hfa384x_t *hw = (hfa384x_t *)wlandev->priv; UINT32 result; DBFENTER; result = P80211ENUM_resultcode_implementation_failure; switch (ifstate) { case P80211ENUM_ifstate_fwload: switch (wlandev->msdstate) { case WLAN_MSD_HWPRESENT: wlandev->msdstate = WLAN_MSD_FWLOAD_PENDING; /* * Initialize the device+driver sufficiently * for firmware loading. */#if (WLAN_HOSTIF != WLAN_USB) result=hfa384x_cmd_initialize(hw);#else if ((result=hfa384x_drvr_start(hw))) { WLAN_LOG_ERROR( "hfa384x_drvr_start() failed," "result=%d\n", (int)result); result = P80211ENUM_resultcode_implementation_failure; wlandev->msdstate = WLAN_MSD_HWPRESENT; break; }#endif wlandev->msdstate = WLAN_MSD_FWLOAD; result = P80211ENUM_resultcode_success; break; case WLAN_MSD_FWLOAD: hfa384x_cmd_initialize(hw); result = P80211ENUM_resultcode_success; break; case WLAN_MSD_RUNNING: WLAN_LOG_WARNING( "Cannot enter fwload state from enable state," "you must disable first.\n"); result = P80211ENUM_resultcode_invalid_parameters; break; case WLAN_MSD_HWFAIL: default: /* probe() had a problem or the msdstate contains * an unrecognized value, there's nothing we can do. */ result = P80211ENUM_resultcode_implementation_failure; break; } break; case P80211ENUM_ifstate_enable: switch (wlandev->msdstate) { case WLAN_MSD_HWPRESENT: case WLAN_MSD_FWLOAD: wlandev->msdstate = WLAN_MSD_RUNNING_PENDING; /* Initialize the device+driver for full * operation. Note that this might me an FWLOAD to * to RUNNING transition so we must not do a chip * or board level reset. Note that on failure, * the MSD state is set to HWPRESENT because we * can't make any assumptions about the state * of the hardware or a previous firmware load. */ if ((result=hfa384x_drvr_start(hw))) { WLAN_LOG_ERROR( "hfa384x_drvr_start() failed," "result=%d\n", (int)result); result = P80211ENUM_resultcode_implementation_failure; wlandev->msdstate = WLAN_MSD_HWPRESENT; break; } if ((result=prism2sta_getcardinfo(wlandev))) { WLAN_LOG_ERROR( "prism2sta_getcardinfo() failed," "result=%d\n", (int)result); result = P80211ENUM_resultcode_implementation_failure; hfa384x_drvr_stop(hw); wlandev->msdstate = WLAN_MSD_HWPRESENT; break; } if ((result=prism2sta_globalsetup(wlandev))) { WLAN_LOG_ERROR( "prism2sta_globalsetup() failed," "result=%d\n", (int)result); result = P80211ENUM_resultcode_implementation_failure; hfa384x_drvr_stop(hw); wlandev->msdstate = WLAN_MSD_HWPRESENT; break; } wlandev->msdstate = WLAN_MSD_RUNNING; hw->join_ap = 0; hw->join_retries = 60; result = P80211ENUM_resultcode_success; break; case WLAN_MSD_RUNNING: /* Do nothing, we're already in this state.*/ result = P80211ENUM_resultcode_success; break; case WLAN_MSD_HWFAIL: default: /* probe() had a problem or the msdstate contains * an unrecognized value, there's nothing we can do. */ result = P80211ENUM_resultcode_implementation_failure; break; } break; case P80211ENUM_ifstate_disable: switch (wlandev->msdstate) { case WLAN_MSD_HWPRESENT: /* Do nothing, we're already in this state.*/ result = P80211ENUM_resultcode_success; break; case WLAN_MSD_FWLOAD: case WLAN_MSD_RUNNING: wlandev->msdstate = WLAN_MSD_HWPRESENT_PENDING; /* * TODO: Shut down the MAC completely. Here a chip * or board level reset is probably called for. * After a "disable" _all_ results are lost, even * those from a fwload. Note the memset of priv, * if priv ever gets any pointers in it, we'll * need to do a deep copy. */ if (wlandev->netdev) netif_stop_queue(wlandev->netdev); hfa384x_drvr_stop(hw); // XXX possibly Clean out hw->stuff. wlandev->macmode = WLAN_MACMODE_NONE; wlandev->msdstate = WLAN_MSD_HWPRESENT; result = P80211ENUM_resultcode_success; break; case WLAN_MSD_HWFAIL: default: /* probe() had a problem or the msdstate contains * an unrecognized value, there's nothing we can do. */ result = P80211ENUM_resultcode_implementation_failure; break; } break; default: result = P80211ENUM_resultcode_invalid_parameters; break; } DBFEXIT; return result;}/*----------------------------------------------------------------* prism2sta_getcardinfo** Collect the NICID, firmware version and any other identifiers* we'd like to have in host-side data structures.** Arguments:* wlandev wlan device structure** Returns: * 0 success* >0 f/w reported error* <0 driver reported error** Side effects:** Call context:* Either.----------------------------------------------------------------*/int prism2sta_getcardinfo(wlandevice_t *wlandev){ int result = 0; hfa384x_t *hw = (hfa384x_t *)wlandev->priv; UINT16 temp; UINT8 snum[HFA384x_RID_NICSERIALNUMBER_LEN]; char pstr[(HFA384x_RID_NICSERIALNUMBER_LEN * 4) + 1]; DBFENTER; /* Collect version and compatibility info */ /* Some are critical, some are not */ /* NIC identity */ result = hfa384x_drvr_getconfig(hw, HFA384x_RID_NICIDENTITY, &hw->ident_nic, sizeof(hfa384x_compident_t)); if ( result ) { WLAN_LOG_ERROR("Failed to retrieve NICIDENTITY\n"); goto failed; } /* get all the nic id fields in host byte order */ hw->ident_nic.id = hfa384x2host_16(hw->ident_nic.id); hw->ident_nic.variant = hfa384x2host_16(hw->ident_nic.variant); hw->ident_nic.major = hfa384x2host_16(hw->ident_nic.major); hw->ident_nic.minor = hfa384x2host_16(hw->ident_nic.minor); WLAN_LOG_INFO( "ident: nic h/w: id=0x%02x %d.%d.%d\n", hw->ident_nic.id, hw->ident_nic.major, hw->ident_nic.minor, hw->ident_nic.variant); /* Primary f/w identity */ result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRIIDENTITY, &hw->ident_pri_fw, sizeof(hfa384x_compident_t)); if ( result ) { WLAN_LOG_ERROR("Failed to retrieve PRIIDENTITY\n"); goto failed; } /* get all the private fw id fields in host byte order */ hw->ident_pri_fw.id = hfa384x2host_16(hw->ident_pri_fw.id); hw->ident_pri_fw.variant = hfa384x2host_16(hw->ident_pri_fw.variant); hw->ident_pri_fw.major = hfa384x2host_16(hw->ident_pri_fw.major); hw->ident_pri_fw.minor = hfa384x2host_16(hw->ident_pri_fw.minor); WLAN_LOG_INFO( "ident: pri f/w: id=0x%02x %d.%d.%d\n", hw->ident_pri_fw.id, hw->ident_pri_fw.major, hw->ident_pri_fw.minor, hw->ident_pri_fw.variant); /* Station (Secondary?) f/w identity */ result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STAIDENTITY, &hw->ident_sta_fw, sizeof(hfa384x_compident_t)); if ( result ) { WLAN_LOG_ERROR("Failed to retrieve STAIDENTITY\n"); goto failed; } if (hw->ident_nic.id < 0x8000) { WLAN_LOG_ERROR("FATAL: Card is not an Intersil Prism2/2.5/3\n"); result = -1; goto failed; } /* get all the station fw id fields in host byte order */ hw->ident_sta_fw.id = hfa384x2host_16(hw->ident_sta_fw.id); hw->ident_sta_fw.variant = hfa384x2host_16(hw->ident_sta_fw.variant); hw->ident_sta_fw.major = hfa384x2host_16(hw->ident_sta_fw.major); hw->ident_sta_fw.minor = hfa384x2host_16(hw->ident_sta_fw.minor); /* strip out the 'special' variant bits */ hw->mm_mods = hw->ident_sta_fw.variant & (BIT14 | BIT15); hw->ident_sta_fw.variant &= ~((UINT16)(BIT14 | BIT15)); if ( hw->ident_sta_fw.id == 0x1f ) { hw->ap = 0; WLAN_LOG_INFO( "ident: sta f/w: id=0x%02x %d.%d.%d\n", hw->ident_sta_fw.id, hw->ident_sta_fw.major, hw->ident_sta_fw.minor, hw->ident_sta_fw.variant); } else { hw->ap = 1; WLAN_LOG_INFO( "ident: ap f/w: id=0x%02x %d.%d.%d\n", hw->ident_sta_fw.id, hw->ident_sta_fw.major, hw->ident_sta_fw.minor, hw->ident_sta_fw.variant); } /* Compatibility range, Modem supplier */ result = hfa384x_drvr_getconfig(hw, HFA384x_RID_MFISUPRANGE, &hw->cap_sup_mfi, sizeof(hfa384x_caplevel_t)); if ( result ) { WLAN_LOG_ERROR("Failed to retrieve MFISUPRANGE\n"); goto failed; } /* get all the Compatibility range, modem interface supplier fields in byte order */ hw->cap_sup_mfi.role = hfa384x2host_16(hw->cap_sup_mfi.role); hw->cap_sup_mfi.id = hfa384x2host_16(hw->cap_sup_mfi.id); hw->cap_sup_mfi.variant = hfa384x2host_16(hw->cap_sup_mfi.variant); hw->cap_sup_mfi.bottom = hfa384x2host_16(hw->cap_sup_mfi.bottom); hw->cap_sup_mfi.top = hfa384x2host_16(hw->cap_sup_mfi.top); WLAN_LOG_INFO( "MFI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", hw->cap_sup_mfi.role, hw->cap_sup_mfi.id, hw->cap_sup_mfi.variant, hw->cap_sup_mfi.bottom, hw->cap_sup_mfi.top); /* Compatibility range, Controller supplier */ result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CFISUPRANGE, &hw->cap_sup_cfi, sizeof(hfa384x_caplevel_t)); if ( result ) { WLAN_LOG_ERROR("Failed to retrieve CFISUPRANGE\n"); goto failed; } /* get all the Compatibility range, controller interface supplier fields in byte order */ hw->cap_sup_cfi.role = hfa384x2host_16(hw->cap_sup_cfi.role); hw->cap_sup_cfi.id = hfa384x2host_16(hw->cap_sup_cfi.id); hw->cap_sup_cfi.variant = hfa384x2host_16(hw->cap_sup_cfi.variant); hw->cap_sup_cfi.bottom = hfa384x2host_16(hw->cap_sup_cfi.bottom); hw->cap_sup_cfi.top = hfa384x2host_16(hw->cap_sup_cfi.top); WLAN_LOG_INFO( "CFI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", hw->cap_sup_cfi.role, hw->cap_sup_cfi.id, hw->cap_sup_cfi.variant, hw->cap_sup_cfi.bottom, hw->cap_sup_cfi.top); /* Compatibility range, Primary f/w supplier */ result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRISUPRANGE, &hw->cap_sup_pri, sizeof(hfa384x_caplevel_t)); if ( result ) { WLAN_LOG_ERROR("Failed to retrieve PRISUPRANGE\n"); goto failed; } /* get all the Compatibility range, primary firmware supplier fields in byte order */ hw->cap_sup_pri.role = hfa384x2host_16(hw->cap_sup_pri.role); hw->cap_sup_pri.id = hfa384x2host_16(hw->cap_sup_pri.id); hw->cap_sup_pri.variant = hfa384x2host_16(hw->cap_sup_pri.variant); hw->cap_sup_pri.bottom = hfa384x2host_16(hw->cap_sup_pri.bottom); hw->cap_sup_pri.top = hfa384x2host_16(hw->cap_sup_pri.top); WLAN_LOG_INFO( "PRI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", hw->cap_sup_pri.role, hw->cap_sup_pri.id, hw->cap_sup_pri.variant, hw->cap_sup_pri.bottom, hw->cap_sup_pri.top); /* Compatibility range, Station f/w supplier */ result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STASUPRANGE, &hw->cap_sup_sta, sizeof(hfa384x_caplevel_t)); if ( result ) { WLAN_LOG_ERROR("Failed to retrieve STASUPRANGE\n"); goto failed; } /* get all the Compatibility range, station firmware supplier fields in byte order */ hw->cap_sup_sta.role = hfa384x2host_16(hw->cap_sup_sta.role); hw->cap_sup_sta.id = hfa384x2host_16(hw->cap_sup_sta.id); hw->cap_sup_sta.variant = hfa384x2host_16(hw->cap_sup_sta.variant); hw->cap_sup_sta.bottom = hfa384x2host_16(hw->cap_sup_sta.bottom); hw->cap_sup_sta.top = hfa384x2host_16(hw->cap_sup_sta.top); if ( hw->cap_sup_sta.id == 0x04 ) { WLAN_LOG_INFO( "STA:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", hw->cap_sup_sta.role, hw->cap_sup_sta.id, hw->cap_sup_sta.variant, hw->cap_sup_sta.bottom, hw->cap_sup_sta.top); } else { WLAN_LOG_INFO( "AP:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", hw->cap_sup_sta.role, hw->cap_sup_sta.id, hw->cap_sup_sta.variant, hw->cap_sup_sta.bottom, hw->cap_sup_sta.top); } /* Compatibility range, primary f/w actor, CFI supplier */ result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRI_CFIACTRANGES, &hw->cap_act_pri_cfi, sizeof(hfa384x_caplevel_t)); if ( result ) { WLAN_LOG_ERROR("Failed to retrieve PRI_CFIACTRANGES\n"); goto failed; } /* get all the Compatibility range, primary f/w actor, CFI supplier fields in byte order */ hw->cap_act_pri_cfi.role = hfa384x2host_16(hw->cap_act_pri_cfi.role); hw->cap_act_pri_cfi.id = hfa384x2host_16(hw->cap_act_pri_cfi.id); hw->cap_act_pri_cfi.variant = hfa384x2host_16(hw->cap_act_pri_cfi.variant); hw->cap_act_pri_cfi.bottom = hfa384x2host_16(hw->cap_act_pri_cfi.bottom); hw->cap_act_pri_cfi.top = hfa384x2host_16(hw->cap_act_pri_cfi.top); WLAN_LOG_INFO( "PRI-CFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", hw->cap_act_pri_cfi.role, hw->cap_act_pri_cfi.id, hw->cap_act_pri_cfi.variant, hw->cap_act_pri_cfi.bottom, hw->cap_act_pri_cfi.top); /* Compatibility range, sta f/w actor, CFI supplier */ result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STA_CFIACTRANGES, &hw->cap_act_sta_cfi, sizeof(hfa384x_caplevel_t)); if ( result ) { WLAN_LOG_ERROR("Failed to retrieve STA_CFIACTRANGES\n"); goto failed; } /* get all the Compatibility range, station f/w actor, CFI supplier fields in byte order */ hw->cap_act_sta_cfi.role = hfa384x2host_16(hw->cap_act_sta_cfi.role); hw->cap_act_sta_cfi.id = hfa384x2host_16(hw->cap_act_sta_cfi.id); hw->cap_act_sta_cfi.variant = hfa384x2host_16(hw->cap_act_sta_cfi.variant); hw->cap_act_sta_cfi.bottom = hfa384x2host_16(hw->cap_act_sta_cfi.bottom); hw->cap_act_sta_cfi.top = hfa384x2host_16(hw->cap_act_sta_cfi.top); WLAN_LOG_INFO( "STA-CFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", hw->cap_act_sta_cfi.role, hw->cap_act_sta_cfi.id, hw->cap_act_sta_cfi.variant, hw->cap_act_sta_cfi.bottom, hw->cap_act_sta_cfi.top); /* Compatibility range, sta f/w actor, MFI supplier */ result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STA_MFIACTRANGES, &hw->cap_act_sta_mfi, sizeof(hfa384x_caplevel_t)); if ( result ) { WLAN_LOG_ERROR("Failed to retrieve STA_MFIACTRANGES\n"); goto failed; } /* get all the Compatibility range, station f/w actor, MFI supplier fields in byte order */ hw->cap_act_sta_mfi.role = hfa384x2host_16(hw->cap_act_sta_mfi.role); hw->cap_act_sta_mfi.id = hfa384x2host_16(hw->cap_act_sta_mfi.id); hw->cap_act_sta_mfi.variant = hfa384x2host_16(hw->cap_act_sta_mfi.variant); hw->cap_act_sta_mfi.bottom = hfa384x2host_16(hw->cap_act_sta_mfi.bottom); hw->cap_act_sta_mfi.top = hfa384x2host_16(hw->cap_act_sta_mfi.top); WLAN_LOG_INFO( "STA-MFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", hw->cap_act_sta_mfi.role, hw->cap_act_sta_mfi.id, hw->cap_act_sta_mfi.variant, hw->cap_act_sta_mfi.bottom, hw->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_INFO("Prism2 card SN: %s\n", pstr);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -