فهرست منبع

qcacld-3.0: Add radio_index info to get_wifi_info command

qcacld-2.0 to qcacld-3.0 propagation

Add the radio_index information to get_wifi_info command.
This change allows user space to know which radio it is
talking to.

Also refactor the get_wifi_info command to support to query
multiple attributes in one command.

Change-Id: Ic3a3aabd9111e655ace3869771ae439aaec45dc4
CRs-fixed: 997545
Ryan Hsu 9 سال پیش
والد
کامیت
7ac8885a0d
2فایلهای تغییر یافته به همراه53 افزوده شده و 23 حذف شده
  1. 51 23
      core/hdd/src/wlan_hdd_cfg80211.c
  2. 2 0
      core/hdd/src/wlan_hdd_cfg80211.h

+ 51 - 23
core/hdd/src/wlan_hdd_cfg80211.c

@@ -2973,6 +2973,7 @@ static const struct nla_policy qca_wlan_vendor_get_wifi_info_policy[
 			QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX + 1] = {
 	[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION] = {.type = NLA_U8 },
 	[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION] = {.type = NLA_U8 },
+	[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_RADIO_INDEX] = {.type = NLA_U32 },
 };
 
 /**
@@ -2994,12 +2995,12 @@ __wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy,
 {
 	hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
 	struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX + 1];
-	tSirVersionString version;
-	uint32_t version_len;
+	tSirVersionString driver_version;
+	tSirVersionString firmware_version;
 	uint32_t major_spid = 0, minor_spid = 0, siid = 0, crmid = 0;
-	uint8_t attr;
 	int status;
-	struct sk_buff *reply_skb = NULL;
+	struct sk_buff *reply_skb;
+	uint32_t skb_len = 0, count = 0;
 
 	ENTER_DEV(wdev->netdev);
 
@@ -3014,41 +3015,68 @@ __wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy,
 
 	if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX, data,
 		      data_len, qca_wlan_vendor_get_wifi_info_policy)) {
-		hddLog(LOGE, FL("WIFI_INFO_GET NL CMD parsing failed"));
+		hdd_err("WIFI_INFO_GET NL CMD parsing failed");
 		return -EINVAL;
 	}
 
 	if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION]) {
-		hddLog(LOG1, FL("Rcvd req for Driver version"));
-		strlcpy(version, QWLAN_VERSIONSTR, sizeof(version));
-		attr = QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION;
-	} else if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION]) {
-		hddLog(LOG1, FL("Rcvd req for FW version"));
+		hdd_err("Rcvd req for Driver version");
+		strlcpy(driver_version, QWLAN_VERSIONSTR,
+			sizeof(driver_version));
+		skb_len += strlen(driver_version) + 1;
+		count++;
+	}
+
+	if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION]) {
+		hdd_info("Rcvd req for FW version");
 		hdd_get_fw_version(hdd_ctx, &major_spid, &minor_spid, &siid,
 				   &crmid);
-		snprintf(version, sizeof(version), "%d:%d:%d:%d",
-			 major_spid, minor_spid, siid, crmid);
-		attr = QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION;
-	} else {
-		hddLog(LOGE, FL("Invalid attribute in get wifi info request"));
+		snprintf(firmware_version, sizeof(firmware_version),
+			 "%d:%d:%d:%d", major_spid, minor_spid, siid, crmid);
+		skb_len += strlen(firmware_version) + 1;
+		count++;
+	}
+
+	if (count == 0) {
+		hdd_err("unknown attribute in get_wifi_info request");
 		return -EINVAL;
 	}
 
-	version_len = strlen(version);
-	reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
-			version_len + NLA_HDRLEN + NLMSG_HDRLEN);
+	skb_len += (NLA_HDRLEN * count) + NLMSG_HDRLEN;
+	reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, skb_len);
+
 	if (!reply_skb) {
-		hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
+		hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed");
 		return -ENOMEM;
 	}
 
-	if (nla_put(reply_skb, attr, version_len, version)) {
-		hddLog(LOGE, FL("nla put fail"));
-		kfree_skb(reply_skb);
-		return -EINVAL;
+	if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION]) {
+		if (nla_put_string(reply_skb,
+			    QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION,
+			    driver_version))
+			goto error_nla_fail;
+	}
+
+	if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION]) {
+		if (nla_put_string(reply_skb,
+			    QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION,
+			    firmware_version))
+			goto error_nla_fail;
+	}
+
+	if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_RADIO_INDEX]) {
+		if (nla_put_u32(reply_skb,
+				QCA_WLAN_VENDOR_ATTR_WIFI_INFO_RADIO_INDEX,
+				hdd_ctx->radio_index))
+			goto error_nla_fail;
 	}
 
 	return cfg80211_vendor_cmd_reply(reply_skb);
+
+error_nla_fail:
+	hdd_err("nla put fail");
+	kfree_skb(reply_skb);
+	return -EINVAL;
 }
 
 /**

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

@@ -1824,6 +1824,7 @@ enum qca_wlan_vendor_attr_roam_subcmd {
  * @QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_INVALID: Invalid initial value
  * @QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION: get host driver version
  * @QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION: ger firmware version
+ * @QCA_WLAN_VENDOR_ATTR_WIFI_INFO_RADIO_INDEX - get radio index
  * @QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_AFTER_LAST: after last
  * @QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX: subcmd max
  */
@@ -1831,6 +1832,7 @@ enum qca_wlan_vendor_attr_get_wifi_info {
 	QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_INVALID = 0,
 	QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION     = 1,
 	QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION   = 2,
+	QCA_WLAN_VENDOR_ATTR_WIFI_INFO_RADIO_INDEX        = 3,
 
 	/* KEEP LAST */
 	QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_AFTER_LAST,