Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 98fb8129 authored by Jes Sorensen's avatar Jes Sorensen Committed by Greg Kroah-Hartman
Browse files

staging: rtl8723au: Remove P2P/WiFiDirect/WiFiDisplay code



Discussing with Johannes Berg and Larry Finger, we have concluded that
this code really should be handled through wpa_supplicant, and not in
the kernel.

Signed-off-by: default avatarJes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 91624933
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -19,14 +19,6 @@ config 8723AU_AP_MODE
	will never be used as an AP, or the target system has limited memory,
	"Y" should be selected.

config 8723AU_P2P
	bool "Realtek RTL8723AU Peer-to-peer mode"
	default y
	---help---
	This option enables peer-to-peer mode for the r8723au driver. Unless you
	know that peer-to-peer (P2P) mode will never be used, or the target system has
	limited memory, "Y" should be selected.

config 8723AU_BT_COEXIST
	bool "Realtek RTL8723AU BlueTooth Coexistence"
	default y
+0 −1
Original line number Diff line number Diff line
@@ -8,7 +8,6 @@ r8723au-y := \
		core/rtw_led.o		\
		core/rtw_mlme.o		\
		core/rtw_mlme_ext.o	\
		core/rtw_p2p.o		\
		core/rtw_pwrctrl.o	\
		core/rtw_recv.o		\
		core/rtw_security.o	\
+0 −9
Original line number Diff line number Diff line
@@ -659,9 +659,6 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf)
	struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
	struct wlan_bssid_ex *pnetwork_mlmeext = &pmlmeinfo->network;
	struct HT_info_element *pht_info = NULL;
#ifdef CONFIG_8723AU_P2P
	struct wifidirect_info *pwdinfo = &padapter->wdinfo;
#endif /* CONFIG_8723AU_P2P */

	bcn_interval = (u16)pnetwork->Configuration.BeaconPeriod;
	cur_channel = pnetwork->Configuration.DSConfig;
@@ -773,12 +770,6 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf)
	/* let pnetwork_mlmeext == pnetwork_mlme. */
	memcpy(pnetwork_mlmeext, pnetwork, pnetwork->Length);

#ifdef CONFIG_8723AU_P2P
	memcpy(pwdinfo->p2p_group_ssid, pnetwork->Ssid.ssid,
	       pnetwork->Ssid.ssid_len);
	pwdinfo->p2p_group_ssid_len = pnetwork->Ssid.ssid_len;
#endif /* CONFIG_8723AU_P2P */

	if (pmlmeext->bstart_bss) {
		update_beacon23a(padapter, WLAN_EID_TIM, NULL, false);

+0 −58
Original line number Diff line number Diff line
@@ -527,12 +527,6 @@ u8 rtw_sitesurvey_cmd23a(struct rtw_adapter *padapter,
	if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
		rtw_lps_ctrl_wk_cmd23a(padapter, LPS_CTRL_SCAN, 1);

#ifdef CONFIG_8723AU_P2P
	if (check_fwstate(pmlmepriv, _FW_LINKED) == true) {
		p2p_ps_wk_cmd23a(padapter, P2P_PS_SCAN, 1);
	}
#endif /* CONFIG_8723AU_P2P */

	ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
	if (!ph2c)
		return _FAIL;
@@ -1354,48 +1348,6 @@ static void power_saving_wk_hdl(struct rtw_adapter *padapter, u8 *pbuf, int sz)
	 rtw_ps_processor23a(padapter);
}

#ifdef CONFIG_8723AU_P2P
u8 p2p_protocol_wk_cmd23a(struct rtw_adapter*padapter, int intCmdType)
{
	struct cmd_obj *ph2c;
	struct drvextra_cmd_parm *pdrvextra_cmd_parm;
	struct wifidirect_info *pwdinfo = &padapter->wdinfo;
	struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
	u8 res = _SUCCESS;

	if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
	{
		return res;
	}

	ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
	if (!ph2c) {
		res = _FAIL;
		goto exit;
	}

	pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm),
				     GFP_ATOMIC);
	if (!pdrvextra_cmd_parm) {
		kfree(ph2c);
		res = _FAIL;
		goto exit;
	}

	pdrvextra_cmd_parm->ec_id = P2P_PROTO_WK_CID;
	pdrvextra_cmd_parm->type_size = intCmdType; /* As the command tppe. */
	pdrvextra_cmd_parm->pbuf = NULL;	    /* Must be NULL here */

	init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm,
				   GEN_CMD_CODE(_Set_Drv_Extra));

	res = rtw_enqueue_cmd23a(pcmdpriv, ph2c);
exit:

	return res;
}
#endif /* CONFIG_8723AU_P2P */

u8 rtw_ps_cmd23a(struct rtw_adapter*padapter)
{
	struct cmd_obj *ppscmd;
@@ -1634,16 +1586,6 @@ u8 rtw_drvextra_cmd_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf)
	case LPS_CTRL_WK_CID:
		lps_ctrl_wk_hdl(padapter, (u8)pdrvextra_cmd->type_size);
		break;
#ifdef CONFIG_8723AU_P2P
	case P2P_PS_WK_CID:
		p2p_ps_wk_hdl23a(padapter, pdrvextra_cmd->type_size);
		break;
	case P2P_PROTO_WK_CID:
		/*	Commented by Albert 2011/07/01 */
		/*	I used the type_size as the type command */
		p2p_protocol_wk_hdl23a(padapter, pdrvextra_cmd->type_size);
		break;
#endif /*  CONFIG_8723AU_P2P */
#ifdef CONFIG_8723AU_AP_MODE
	case CHECK_HIQ_WK_CID:
		rtw_chk_hi_queue_hdl(padapter);
+0 −311
Original line number Diff line number Diff line
@@ -1227,9 +1227,6 @@ void dump_ies23a(u8 *buf, u32 buf_len) {
		len = *(pos + 1);

		DBG_8723A("%s ID:%u, LEN:%u\n", __func__, id, len);
#ifdef CONFIG_8723AU_P2P
		dump_p2p_ie23a(pos, len);
#endif
		dump_wps_ie23a(pos, len);

		pos += (2 + len);
@@ -1259,314 +1256,6 @@ void dump_wps_ie23a(u8 *ie, u32 ie_len) {
	}
}

#ifdef CONFIG_8723AU_P2P
void dump_p2p_ie23a(u8 *ie, u32 ie_len) {
	u8* pos = (u8*)ie;
	u8 id;
	u16 len;

	u8 *p2p_ie;
	uint p2p_ielen;

	p2p_ie = rtw_get_p2p_ie23a(ie, ie_len, NULL, &p2p_ielen);
	if (p2p_ie != ie || p2p_ielen == 0)
		return;

	pos += 6;
	while (pos-ie < ie_len) {
		id = *pos;
		len = get_unaligned_le16(pos+1);

		DBG_8723A("%s ID:%u, LEN:%u\n", __func__, id, len);

		pos+= (3+len);
	}
}

/**
 * rtw_get_p2p_ie23a - Search P2P IE from a series of IEs
 * @in_ie: Address of IEs to search
 * @in_len: Length limit from in_ie
 * @p2p_ie: If not NULL and P2P IE is found, P2P IE will be copied to the
 *          buf starting from p2p_ie
 * @p2p_ielen: If not NULL and P2P IE is found, will set to the length of
 *             the entire P2P IE
 *
 * Returns: The address of the P2P IE found, or NULL
 */
u8 *rtw_get_p2p_ie23a(u8 *in_ie, int in_len, u8 *p2p_ie, uint *p2p_ielen)
{
	uint cnt = 0;
	u8 *p2p_ie_ptr;
	u8 eid, p2p_oui[4]={0x50, 0x6F, 0x9A, 0x09};

	if (p2p_ielen)
		*p2p_ielen = 0;

	while (cnt<in_len) {
		eid = in_ie[cnt];
		if ((in_len < 0) || (cnt > MAX_IE_SZ)) {
			dump_stack();
			return NULL;
		}
		if ((eid == WLAN_EID_VENDOR_SPECIFIC) &&
		    !memcmp(&in_ie[cnt + 2], p2p_oui, 4)) {
			p2p_ie_ptr = in_ie + cnt;

			if (p2p_ie != NULL) {
				memcpy(p2p_ie, &in_ie[cnt],
				       in_ie[cnt + 1] + 2);
			}

			if (p2p_ielen != NULL) {
				*p2p_ielen = in_ie[cnt + 1] + 2;
			}

			return p2p_ie_ptr;

			break;
		} else {
			cnt += in_ie[cnt + 1] + 2; /* goto next */
		}
	}

	return NULL;
}

/**
 * rtw_get_p2p_attr23a - Search a specific P2P attribute from a given P2P IE
 * @p2p_ie: Address of P2P IE to search
 * @p2p_ielen: Length limit from p2p_ie
 * @target_attr_id: The attribute ID of P2P attribute to search
 * @buf_attr: If not NULL and the P2P attribute is found, P2P attribute will
 *            be copied to the buf starting from buf_attr
 * @len_attr: If not NULL and the P2P attribute is found, will set to the
 *            length of the entire P2P attribute
 *
 * Returns: the address of the specific WPS attribute found, or NULL
 */
u8 *rtw_get_p2p_attr23a(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id,
		     u8 *buf_attr, u32 *len_attr)
{
	u8 *attr_ptr = NULL;
	u8 *target_attr_ptr = NULL;
	u8 p2p_oui[4]={0x50, 0x6F, 0x9A, 0x09};

	if (len_attr)
		*len_attr = 0;

	if (!p2p_ie || (p2p_ie[0] != WLAN_EID_VENDOR_SPECIFIC) ||
	    memcmp(p2p_ie + 2, p2p_oui, 4)) {
		return attr_ptr;
	}

	/*  6 = 1(Element ID) + 1(Length) + 3 (OUI) + 1(OUI Type) */
	attr_ptr = p2p_ie + 6; /* goto first attr */

	while (attr_ptr - p2p_ie < p2p_ielen) {
		/*  3 = 1(Attribute ID) + 2(Length) */
		u8 attr_id = *attr_ptr;
		u16 attr_data_len = get_unaligned_le16(attr_ptr + 1);
		u16 attr_len = attr_data_len + 3;

		/* DBG_8723A("%s attr_ptr:%p, id:%u, length:%u\n", __func__, attr_ptr, attr_id, attr_data_len); */
		if (attr_id == target_attr_id) {
			target_attr_ptr = attr_ptr;

			if (buf_attr)
				memcpy(buf_attr, attr_ptr, attr_len);

			if (len_attr)
				*len_attr = attr_len;

			break;
		} else {
			attr_ptr += attr_len; /* goto next */
		}
	}

	return target_attr_ptr;
}

/**
 * rtw_get_p2p_attr23a_content - Search a specific P2P attribute content from
 * a given P2P IE
 * @p2p_ie: Address of P2P IE to search
 * @p2p_ielen: Length limit from p2p_ie
 * @target_attr_id: The attribute ID of P2P attribute to search
 * @buf_content: If not NULL and the P2P attribute is found, P2P attribute
 *               content will be copied to the buf starting from buf_content
 * @len_content: If not NULL and the P2P attribute is found, will set to the
 *               length of the P2P attribute content
 *
 * Returns: the address of the specific P2P attribute content found, or NULL
 */
u8 *rtw_get_p2p_attr23a_content(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id,
			     u8 *buf_content, uint *len_content)
{
	u8 *attr_ptr;
	u32 attr_len;

	if (len_content)
		*len_content = 0;

	attr_ptr = rtw_get_p2p_attr23a(p2p_ie, p2p_ielen, target_attr_id,
				    NULL, &attr_len);

	if (attr_ptr && attr_len) {
		if (buf_content)
			memcpy(buf_content, attr_ptr + 3, attr_len - 3);

		if (len_content)
			*len_content = attr_len - 3;

		return attr_ptr+3;
	}

	return NULL;
}

u32 rtw_set_p2p_attr_content23a(u8 *pbuf, u8 attr_id, u16 attr_len, u8 *pdata_attr)
{
	u32 a_len;

	*pbuf = attr_id;

	/* u16*)(pbuf + 1) = cpu_to_le16(attr_len); */
	put_unaligned_le16(attr_len, pbuf + 1);

	if (pdata_attr)
		memcpy(pbuf + 3, pdata_attr, attr_len);

	a_len = attr_len + 3;

	return a_len;
}

static uint rtw_p2p_attr_remove(u8 *ie, uint ielen_ori, u8 attr_id)
{
	u8 *target_attr;
	u32 target_attr_len;
	uint ielen = ielen_ori;

	while(1) {
		target_attr = rtw_get_p2p_attr23a(ie, ielen, attr_id, NULL,
					     &target_attr_len);
		if (target_attr && target_attr_len) {
			u8 *next_attr = target_attr+target_attr_len;
			uint remain_len = ielen-(next_attr-ie);
			/* dump_ies23a(ie, ielen); */

			memset(target_attr, 0, target_attr_len);
			memcpy(target_attr, next_attr, remain_len);
			memset(target_attr+remain_len, 0, target_attr_len);
			*(ie + 1) -= target_attr_len;
			ielen -= target_attr_len;
		} else {
			/* if (index>0) */
			/*	dump_ies23a(ie, ielen); */
			break;
		}
	}

	return ielen;
}

void rtw_wlan_bssid_ex_remove_p2p_attr23a(struct wlan_bssid_ex *bss_ex, u8 attr_id)
{
	u8 *p2p_ie;
	uint p2p_ielen, p2p_ielen_ori;

	if ((p2p_ie = rtw_get_p2p_ie23a(bss_ex->IEs + _FIXED_IE_LENGTH_,
				     bss_ex->IELength - _FIXED_IE_LENGTH_,
				     NULL, &p2p_ielen_ori))) {
		p2p_ielen = rtw_p2p_attr_remove(p2p_ie, p2p_ielen_ori, attr_id);
		if (p2p_ielen != p2p_ielen_ori) {
			u8 *next_ie_ori = p2p_ie+p2p_ielen_ori;
			u8 *next_ie = p2p_ie+p2p_ielen;
			uint remain_len;
			remain_len = bss_ex->IELength-(next_ie_ori-bss_ex->IEs);

			memcpy(next_ie, next_ie_ori, remain_len);
			memset(next_ie+remain_len, 0, p2p_ielen_ori-p2p_ielen);
			bss_ex->IELength -= p2p_ielen_ori-p2p_ielen;
		}
	}
}

#endif /* CONFIG_8723AU_P2P */

#ifdef CONFIG_8723AU_P2P
int rtw_get_wfd_ie(u8 *in_ie, int in_len, u8 *wfd_ie, uint *wfd_ielen)
{
	int match;
	const u8 *ie;

	match = 0;

	if (in_len < 0)
		return match;

	ie = cfg80211_find_vendor_ie(0x506F9A, 0x0A, in_ie, in_len);
	if (ie && (ie[1] <= (MAX_WFD_IE_LEN - 2))) {
		if (wfd_ie) {
			*wfd_ielen = ie[1] + 2;
			memcpy(wfd_ie, ie, ie[1] + 2);
		} else
			if (wfd_ielen)
				*wfd_ielen = 0;

		match = 1;
	}

	return match;
}

/*	attr_content: The output buffer, contains the "body field" of
	WFD attribute. */
/*	attr_contentlen: The data length of the "body field" of WFD
	attribute. */
int rtw_get_wfd_attr_content(u8 *wfd_ie, uint wfd_ielen, u8 target_attr_id,
			     u8 *attr_content, uint *attr_contentlen)
{
	int match;
	uint cnt = 0;
	u8 attr_id, wfd_oui[4] = {0x50, 0x6F, 0x9A, 0x0A};

	match = false;

	if ((wfd_ie[0] != WLAN_EID_VENDOR_SPECIFIC) ||
	    memcmp(wfd_ie + 2, wfd_oui, 4)) {
		return match;
	}

	/*	1 (WFD IE) + 1 (Length) + 3 (OUI) + 1 (OUI Type) */
	cnt = 6;
	while (cnt < wfd_ielen) {
		u16 attrlen = get_unaligned_be16(wfd_ie + cnt + 1);

		attr_id = wfd_ie[cnt];
		if (attr_id == target_attr_id) {
			/*	3 -> 1 byte for attribute ID field, 2
				bytes for length field */
			if (attr_content)
				memcpy(attr_content, &wfd_ie[cnt + 3], attrlen);

			if (attr_contentlen)
				*attr_contentlen = attrlen;

			cnt += attrlen + 3;

			match = true;
			break;
		} else {
			cnt += attrlen + 3; /* goto next */
		}
	}

	return match;
}
#endif /*  CONFIG_8723AU_P2P */

/* Baron adds to avoid FreeBSD warning */
int ieee80211_is_empty_essid23a(const char *essid, int essid_len)
Loading