在设备进行pci总线注册之后,进入pci驱动的probe函数,该函数中最为重要的就是开启wlan的主机设备驱动,即hdd_wlan_startup()
函数:
/**---------------------------------------------------------------------------
\brief hdd_wlan_startup() - HDD init function
This is the driver startup code executed once a WLAN device has been detected
\param - dev - Pointer to the underlying device
\return - 0 for success, < 0 for failure
--------------------------------------------------------------------------*/
int hdd_wlan_startup(struct device *dev, v_VOID_t *hif_sc)
{
VOS_STATUS status;
hdd_adapter_t *pAdapter = NULL;
#ifdef WLAN_OPEN_P2P_INTERFACE
hdd_adapter_t *pP2pAdapter = NULL;
#endif
hdd_context_t *pHddCtx = NULL;
v_CONTEXT_t pVosContext= NULL;
#ifdef WLAN_BTAMP_FEATURE
VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
WLANBAP_ConfigType btAmpConfig;
hdd_config_t *pConfig;
#endif
eHalStatus hal_status;
int ret;
int i;
struct wiphy *wiphy;
unsigned long rc;
tSmeThermalParams thermalParam;
tSirTxPowerLimit *hddtxlimit;
#ifdef FEATURE_WLAN_CH_AVOID
int unsafeChannelIndex;
#endif
ENTER();
.......
pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_INFRA_STATION, "wlan%d",
wlan_hdd_get_intf_addr(pHddCtx), FALSE );
......
success:
EXIT();
return 0;
}
该函数初始化内容繁多,主要集中的有两部分,一个是vos_open
打开开虚拟接口,另外是hdd_open_adapter
函数,提供了网络接口并建立了无线网络适配器。
hdd_wlan_startup
中通过wlan_hdd_cfg80211_wiphy_alloc
为无线设备分配一个wiphy结构体,再通过hdd_open_adapter
函数中hdd_register_interface
实现无线网络设备注册,
/*
* FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
* This function is called by hdd_wlan_startup()
* during initialization.
* This function is used to allocate wiphy structure.
*/
struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
{
struct wiphy *wiphy;
ENTER();
/*
* Create wiphy device
*/
wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
if (!wiphy)
{
/* Print error and jump into err label and free the memory */
hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
return NULL;
}
return wiphy;
}
在分配新的wiphy时,关联了wlan_hdd_cfg80211_ops
结构体,该结构体是cfg80211提供的操作结构体,即struct cfg80211_ops
hdd_adapter_t* hdd_open_adapter( hdd_context_t *pHddCtx, tANI_U8 session_type,
const char *iface_name, tSirMacAddr macAddr,
tANI_U8 rtnl_held )
{
hdd_adapter_t *pAdapter = NULL;
hdd_adapter_list_node_t *pHddAdapterNode = NULL;
VOS_STATUS status = VOS_STATUS_E_FAILURE;
VOS_STATUS exitbmpsStatus = VOS_STATUS_E_FAILURE;
hdd_cfg80211_state_t *cfgState;
int ret;
hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: iface =%s type = %d\n", __func__,