prism2sta.c

来自「Linux的无线局域网方案是一个Linux设备驱动程序和子系统 一揽子方案的用」· C语言 代码 · 共 2,232 行 · 第 1/5 页

C
2,232
字号
		break;	case DIDmsg_dot11req_reassociate :		WLAN_LOG_DEBUG0(2,"Received mlme reassociate request\n");		result = prism2mgmt_reassociate(wlandev, msg);		break;	case DIDmsg_dot11req_disassociate :		WLAN_LOG_DEBUG0(2,"Received mlme disassociate request\n");		result = prism2mgmt_disassociate(wlandev, msg);		break;	case DIDmsg_dot11req_reset :		WLAN_LOG_DEBUG0(2,"Received mlme reset request\n");		result = prism2mgmt_reset(wlandev, msg);		break;	case DIDmsg_dot11req_start :		WLAN_LOG_DEBUG0(2,"Received mlme start request\n");		result = prism2mgmt_start(wlandev, msg);		break;	/*	 * Prism2 specific messages	 */       	case DIDmsg_p2req_readpda :		WLAN_LOG_DEBUG0(2,"Received mlme readpda request\n");		result = prism2mgmt_readpda(wlandev, msg);		break;	case DIDmsg_p2req_readcis :		WLAN_LOG_DEBUG0(2,"Received mlme readcis request\n");		result = prism2mgmt_readcis(wlandev, msg);		break;	case DIDmsg_p2req_auxport_state :		WLAN_LOG_DEBUG0(2,"Received mlme auxport_state request\n");		result = prism2mgmt_auxport_state(wlandev, msg);		break;	case DIDmsg_p2req_auxport_read :		WLAN_LOG_DEBUG0(2,"Received mlme auxport_read request\n");		result = prism2mgmt_auxport_read(wlandev, msg);		break;	case DIDmsg_p2req_auxport_write :		WLAN_LOG_DEBUG0(2,"Received mlme auxport_write request\n");		result = prism2mgmt_auxport_write(wlandev, msg);		break;	case DIDmsg_p2req_low_level :		WLAN_LOG_DEBUG0(2,"Received mlme low_level request\n");		result = prism2mgmt_low_level(wlandev, msg);		break;        case DIDmsg_p2req_test_command :                WLAN_LOG_DEBUG0(2,"Received mlme test_command request\n");                result = prism2mgmt_test_command(wlandev, msg);                break;        case DIDmsg_p2req_mmi_read :                WLAN_LOG_DEBUG0(2,"Received mlme mmi_read request\n");                result = prism2mgmt_mmi_read(wlandev, msg);                break;        case DIDmsg_p2req_mmi_write :                WLAN_LOG_DEBUG0(2,"Received mlme mmi_write request\n");                result = prism2mgmt_mmi_write(wlandev, msg);                break;	case DIDmsg_p2req_ramdl_state :		WLAN_LOG_DEBUG0(2,"Received mlme ramdl_state request\n");		result = prism2mgmt_ramdl_state(wlandev, msg);		break;	case DIDmsg_p2req_ramdl_write :		WLAN_LOG_DEBUG0(2,"Received mlme ramdl_write request\n");		result = prism2mgmt_ramdl_write(wlandev, msg);		break;	case DIDmsg_p2req_flashdl_state :		WLAN_LOG_DEBUG0(2,"Received mlme flashdl_state request\n");		result = prism2mgmt_flashdl_state(wlandev, msg);		break;	case DIDmsg_p2req_flashdl_write :		WLAN_LOG_DEBUG0(2,"Received mlme flashdl_write request\n");		result = prism2mgmt_flashdl_write(wlandev, msg);		break;	case DIDmsg_p2req_dump_state :		WLAN_LOG_DEBUG0(2,"Received mlme dump_state request\n");		result = prism2mgmt_dump_state(wlandev, msg);		break;	case DIDmsg_p2req_channel_info :		WLAN_LOG_DEBUG0(2,"Received mlme channel_info request\n");		result = prism2mgmt_channel_info(wlandev, msg);		break;	case DIDmsg_p2req_channel_info_results :		WLAN_LOG_DEBUG0(2,"Received mlme channel_info_results request\n");		result = prism2mgmt_channel_info_results(wlandev, msg);		break;	/*	 * Linux specific messages	 */        case DIDmsg_lnxreq_ifstate :		{		p80211msg_lnxreq_ifstate_t	*ifstatemsg;                WLAN_LOG_DEBUG0(2,"Received mlme ifstate request\n");		ifstatemsg = (p80211msg_lnxreq_ifstate_t*)msg;                result = prism2sta_ifstate(wlandev, ifstatemsg->ifstate.data);		ifstatemsg->resultcode.status = 			P80211ENUM_msgitem_status_data_ok;		ifstatemsg->resultcode.data = result;		result = 0;		}                break;        case DIDmsg_lnxreq_wlansniff :                WLAN_LOG_DEBUG0(2,"Received mlme wlansniff request\n");                result = prism2mgmt_wlansniff(wlandev, msg);                break;	case DIDmsg_lnxreq_autojoin :		WLAN_LOG_DEBUG0(2,"Received mlme autojoin request\n");		result = prism2mgmt_autojoin(wlandev, msg);		break;	case DIDmsg_p2req_enable :		WLAN_LOG_DEBUG0(2,"Received mlme enable request\n");		result = prism2mgmt_enable(wlandev, msg);		break;	default:		WLAN_LOG_WARNING1("Unknown mgmt request message 0x%08lx", msg->msgcode);		break;	}	DBFEXIT;	return result;}/*----------------------------------------------------------------* prism2sta_ifstate** Interface state.  This is the primary WLAN interface enable/disable* handler.  Following the driver/load/deviceprobe sequence, this* function must be called with a state of "enable" before any other* 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){	prism2sta_priv_t	*priv;	prism2sta_priv_t	tmppriv;	hfa384x_t		*hw;	UINT32 			result;	DBFENTER;	priv = (prism2sta_priv_t*)wlandev->priv;	hw = priv->hw;	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)			if ((result=hfa384x_cmd_initialize(hw))) {				WLAN_LOG_ERROR1(					"hfa384x_cmd_initialize() failed,"					"result=%d\n", (int)result);				result = 				P80211ENUM_resultcode_implementation_failure;				wlandev->msdstate = WLAN_MSD_HWPRESENT;				break;			}#else			if ((result=hfa384x_drvr_start(hw))) {				WLAN_LOG_ERROR1(					"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:			/* Do nothing, we're already in this state.*/			result = P80211ENUM_resultcode_success;			break;		case WLAN_MSD_RUNNING:			WLAN_LOG_WARNING0(				"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_ERROR1(					"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_ERROR1(					"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_ERROR1(					"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;			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.			 */			hfa384x_drvr_stop(hw);			memcpy(&tmppriv, priv, sizeof(tmppriv));			memset(priv, 0, sizeof(*priv));#if (WLAN_HOSTIF == WLAN_PCMCIA)			memcpy(&priv->node, &tmppriv.node, sizeof(priv->node));			priv->cs_link = tmppriv.cs_link;#elif (WLAN_HOSTIF==WLAN_PLX || WLAN_HOSTIF==WLAN_PCI || WLAN_HOSTIF==WLAN_USB)			memcpy(priv->name, tmppriv.name, sizeof(priv->name));#endif			priv->hw = tmppriv.hw;			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;	prism2sta_priv_t	*priv = (prism2sta_priv_t*)wlandev->priv;	hfa384x_t		*hw = priv->hw;	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,			&priv->ident_nic, sizeof(hfa384x_compident_t));	if ( result ) {		WLAN_LOG_ERROR0("Failed to retrieve NICIDENTITY\n");		goto failed;	}	/* get all the nic id fields in host byte order */	priv->ident_nic.id = hfa384x2host_16(priv->ident_nic.id);	priv->ident_nic.variant = hfa384x2host_16(priv->ident_nic.variant);	priv->ident_nic.major = hfa384x2host_16(priv->ident_nic.major);	priv->ident_nic.minor = hfa384x2host_16(priv->ident_nic.minor);	WLAN_LOG_INFO4( "ident: nic h/w: id=0x%02x %d.%d.%d\n",			priv->ident_nic.id, priv->ident_nic.major,			priv->ident_nic.minor, priv->ident_nic.variant);	/* Primary f/w identity */	result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRIIDENTITY,			&priv->ident_pri_fw, sizeof(hfa384x_compident_t));	if ( result ) {		WLAN_LOG_ERROR0("Failed to retrieve PRIIDENTITY\n");		goto failed;	}	/* get all the private fw id fields in host byte order */	priv->ident_pri_fw.id = hfa384x2host_16(priv->ident_pri_fw.id);	priv->ident_pri_fw.variant = hfa384x2host_16(priv->ident_pri_fw.variant);	priv->ident_pri_fw.major = hfa384x2host_16(priv->ident_pri_fw.major);	priv->ident_pri_fw.minor = hfa384x2host_16(priv->ident_pri_fw.minor);	WLAN_LOG_INFO4( "ident: pri f/w: id=0x%02x %d.%d.%d\n",			priv->ident_pri_fw.id, priv->ident_pri_fw.major,			priv->ident_pri_fw.minor, priv->ident_pri_fw.variant);	/* Station (Secondary?) f/w identity */	result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STAIDENTITY,			&priv->ident_sta_fw, sizeof(hfa384x_compident_t));	if ( result ) {		WLAN_LOG_ERROR0("Failed to retrieve STAIDENTITY\n");		goto failed;	}	/* get all the station fw id fields in host byte order */	priv->ident_sta_fw.id = hfa384x2host_16(priv->ident_sta_fw.id);	priv->ident_sta_fw.variant = hfa384x2host_16(priv->ident_sta_fw.variant);	priv->ident_sta_fw.major = hfa384x2host_16(priv->ident_sta_fw.major);	priv->ident_sta_fw.minor = hfa384x2host_16(priv->ident_sta_fw.minor);	/* strip out the 'special' variant bits */	priv->mm_mods = priv->ident_sta_fw.variant & (BIT14 | BIT15);	priv->ident_sta_fw.variant &= ~((UINT16)(BIT14 | BIT15));	if  ( priv->ident_sta_fw.id == 0x1f ) {		priv->ap = 0;		WLAN_LOG_INFO4( 			"ident: sta f/w: id=0x%02x %d.%d.%d\n",			priv->ident_sta_fw.id, priv->ident_sta_fw.major,			priv->ident_sta_fw.minor, priv->ident_sta_fw.variant);	} else {		priv->ap = 1;		WLAN_LOG_INFO4(			"ident:  ap f/w: id=0x%02x %d.%d.%d\n",			priv->ident_sta_fw.id, priv->ident_sta_fw.major,			priv->ident_sta_fw.minor, priv->ident_sta_fw.variant);	}	/* Compatibility range, Modem supplier */	result = hfa384x_drvr_getconfig(hw, HFA384x_RID_MFISUPRANGE,			&priv->cap_sup_mfi, sizeof(hfa384x_caplevel_t));	if ( result ) {		WLAN_LOG_ERROR0("Failed to retrieve MFISUPRANGE\n");		goto failed;	}	/* get all the Compatibility range, modem interface supplier	fields in byte order */	priv->cap_sup_mfi.role = hfa384x2host_16(priv->cap_sup_mfi.role);	priv->cap_sup_mfi.id = hfa384x2host_16(priv->cap_sup_mfi.id);	priv->cap_sup_mfi.variant = hfa384x2host_16(priv->cap_sup_mfi.variant);	priv->cap_sup_mfi.bottom = hfa384x2host_16(priv->cap_sup_mfi.bottom);	priv->cap_sup_mfi.top = hfa384x2host_16(priv->cap_sup_mfi.top);	WLAN_LOG_INFO5(		"MFI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",		priv->cap_sup_mfi.role, priv->cap_sup_mfi.id,		priv->cap_sup_mfi.variant, priv->cap_sup_mfi.bottom,		priv->cap_sup_mfi.top);	/* Compatibility range, Controller supplier */	result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CFISUPRANGE,			&priv->cap_sup_cfi, sizeof(hfa384x_caplevel_t));	if ( result ) {		WLAN_LOG_ERROR0("Failed to retrieve CFISUPRANGE\n");		goto failed;	}	/* get all the Compatibility range, controller interface supplier

⌨️ 快捷键说明

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