Browse Source

qcacld-3.0: Update cfg80211_vendor_event_alloc for Kernel upgrade

Commit: 6c09e79 ("cfg80211: Allow NL80211_ATTR_IFINDEX to be added
to vendor events")

This commit add parameter wdev to cfg80211_vendor_event_alloc(), that would
be used to check at __cfg80211_alloc_vendor_skb() to assign ifindex to
the skb and is merged in Kernel 4.1, so add a kernel version macro to
support this

Also merge the hdd_vendor_put_ifindex into cfg80211_vendor_event_alloc
to assign the ifindex when wdev is given, that way we can unify the interface.

Change-Id: I321e12bfe3f9160a8a0fcfeb2408f6336d50e2c5
CRs-fixed: 964291
Ryan Hsu 9 years ago
parent
commit
9206a4ef77

+ 1 - 8
core/hdd/src/wlan_hdd_cfg80211.c

@@ -1658,7 +1658,7 @@ void wlan_hdd_cfg80211_acs_ch_select_evt(hdd_adapter_t *adapter)
 	uint16_t ch_width;
 
 	vendor_event = cfg80211_vendor_event_alloc(hdd_ctx->wiphy,
-			NULL,
+			&(adapter->wdev),
 			4 * sizeof(u8) + 1 * sizeof(u16) + 4 + NLMSG_HDRLEN,
 			QCA_NL80211_VENDOR_SUBCMD_DO_ACS_INDEX,
 			GFP_KERNEL);
@@ -1668,13 +1668,6 @@ void wlan_hdd_cfg80211_acs_ch_select_evt(hdd_adapter_t *adapter)
 		return;
 	}
 
-	ret_val = hdd_vendor_put_ifindex(vendor_event, adapter->dev->ifindex);
-	if (ret_val) {
-		hddLog(LOGE, FL("NL80211_ATTR_IFINDEX put fail"));
-		kfree_skb(vendor_event);
-		return;
-	}
-
 	ret_val = nla_put_u8(vendor_event,
 				QCA_WLAN_VENDOR_ATTR_ACS_PRIMARY_CHANNEL,
 				sap_cfg->acs_cfg.pri_ch);

+ 25 - 2
core/hdd/src/wlan_hdd_cfg80211.h

@@ -2390,14 +2390,37 @@ static inline int wlan_hdd_send_roam_auth_event(hdd_context_t *hdd_ctx_ptr,
 
 int wlan_hdd_cfg80211_update_apies(hdd_adapter_t *adapter);
 
-#if !(defined (SUPPORT_WDEV_CFG80211_VENDOR_EVENT_ALLOC))
+#if !(defined (SUPPORT_WDEV_CFG80211_VENDOR_EVENT_ALLOC)) &&	\
+	(LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) && 	\
+	!(defined(WITH_BACKPORTS))
+
 static inline struct sk_buff *
 backported_cfg80211_vendor_event_alloc(struct wiphy *wiphy,
 					struct wireless_dev *wdev,
 					int approxlen,
 					int event_idx, gfp_t gfp)
 {
-	return cfg80211_vendor_event_alloc(wiphy, approxlen, event_idx, gfp);
+	struct sk_buff *skb;
+
+	skb = cfg80211_vendor_event_alloc(wiphy, approxlen, event_idx, gfp);
+
+	if (skb && wdev) {
+		struct nlattr *attr;
+		u32 ifindex = wdev->netdev->ifindex;
+
+		nla_nest_cancel(skb, ((void **)skb->cb)[2]);
+		if (nla_put_u32(skb, NL80211_ATTR_IFINDEX, ifindex))
+			goto nla_fail;
+
+		attr = nla_nest_start(skb, NL80211_ATTR_VENDOR_DATA);
+		((void **)skb->cb)[2] = attr;
+	}
+
+	return skb;
+
+nla_fail:
+	kfree_skb(skb);
+	return NULL;
 }
 #define cfg80211_vendor_event_alloc backported_cfg80211_vendor_event_alloc
 #endif

+ 1 - 33
core/hdd/src/wlan_hdd_scan.c

@@ -1017,7 +1017,7 @@ static void hdd_vendor_scan_callback(hdd_adapter_t *adapter,
 		qdf_mem_free(req);
 		return;
 	}
-	skb = cfg80211_vendor_event_alloc(hddctx->wiphy, NULL,
+	skb = cfg80211_vendor_event_alloc(hddctx->wiphy, &(adapter->wdev),
 			SCAN_DONE_EVENT_BUF_SIZE + 4 + NLMSG_HDRLEN,
 			QCA_NL80211_VENDOR_SUBCMD_SCAN_DONE_INDEX,
 			GFP_KERNEL);
@@ -1028,9 +1028,6 @@ static void hdd_vendor_scan_callback(hdd_adapter_t *adapter,
 		return;
 	}
 
-	if (0 != hdd_vendor_put_ifindex(skb, adapter->dev->ifindex))
-		goto nla_put_failure;
-
 	cookie = (uintptr_t)req;
 
 	attr = nla_nest_start(skb, QCA_WLAN_VENDOR_ATTR_SCAN_SSIDS);
@@ -1678,12 +1675,6 @@ static int wlan_hdd_send_scan_start_event(struct wiphy *wiphy,
 		return -ENOMEM;
 	}
 
-	ret = hdd_vendor_put_ifindex(skb, wdev->netdev->ifindex);
-	if (ret) {
-		kfree_skb(skb);
-		return -EINVAL;
-	}
-
 	if (nla_put_u64(skb, QCA_WLAN_VENDOR_ATTR_SCAN_COOKIE, cookie)) {
 		kfree_skb(skb);
 		return -EINVAL;
@@ -2410,29 +2401,6 @@ int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
 }
 #endif /*FEATURE_WLAN_SCAN_PNO */
 
-/**
- * hdd_vendor_put_ifindex() -send interface index
- * @skb: buffer pointer
- * @ifindex: interface index
- *
- * Send the IF index to differentiate the events on each interface
- * Return: 0 for success, non zero for failure
- */
-int hdd_vendor_put_ifindex(struct sk_buff *skb, int ifindex)
-{
-	struct nlattr *attr;
-
-	nla_nest_cancel(skb, ((void **)skb->cb)[2]);
-	if (nla_put_u32(skb, NL80211_ATTR_IFINDEX, ifindex))
-		return -EINVAL;
-
-	attr = nla_nest_start(skb, NL80211_ATTR_VENDOR_DATA);
-	((void **)skb->cb)[2] = attr;
-
-	return 0;
-}
-
-
 /**
  * hdd_cleanup_scan_queue() - remove entries in scan queue
  *

+ 0 - 2
core/hdd/src/wlan_hdd_scan.h

@@ -67,8 +67,6 @@ int wlan_hdd_cfg80211_vendor_scan(struct wiphy *wiphy,
 		struct wireless_dev *wdev, const void *data,
 		int data_len);
 
-int hdd_vendor_put_ifindex(struct sk_buff *skb, int ifindex);
 void hdd_cleanup_scan_queue(hdd_context_t *hdd_ctx);
-
 #endif /* end #if !defined(WLAN_HDD_SCAN_H) */