Преглед на файлове

qcacld-3.0: changes to support spectral genl

HDD changes to support general netlink sockets for
spectral scan feature.

Change-Id: Ie8f262ef77b42c69ac5e25e9a2d0cc099b66b1dd
CRs-Fixed: 2183863
Sandeep Puligilla преди 7 години
родител
ревизия
019a1bd120
променени са 6 файла, в които са добавени 171 реда и са изтрити 4 реда
  1. 4 1
      Kbuild
  2. 1 0
      core/hdd/inc/wlan_hdd_main.h
  3. 30 1
      core/hdd/inc/wlan_hdd_spectralscan.h
  4. 7 1
      core/hdd/src/wlan_hdd_main.c
  5. 2 0
      core/hdd/src/wlan_hdd_object_manager.c
  6. 127 1
      core/hdd/src/wlan_hdd_spectralscan.c

+ 4 - 1
Kbuild

@@ -872,13 +872,16 @@ UMAC_SPECTRAL_CORE_DIR := $(WLAN_COMMON_ROOT)/$(UMAC_SPECTRAL_DIR)/core
 UMAC_SPECTRAL_DISP_DIR := $(WLAN_COMMON_ROOT)/$(UMAC_SPECTRAL_DIR)/dispatcher/src
 UMAC_TARGET_SPECTRAL_INC := -I$(WLAN_COMMON_INC)/target_if/spectral
 
-UMAC_SPECTRAL_INC := -I$(WLAN_COMMON_INC)/$(UMAC_SPECTRAL_DISP_INC_DIR)
+UMAC_SPECTRAL_INC := -I$(WLAN_COMMON_INC)/$(UMAC_SPECTRAL_DISP_INC_DIR) \
+			-I$(WLAN_COMMON_INC)/$(UMAC_SPECTRAL_CORE_INC_DIR) \
+			-I$(WLAN_COMMON_INC)/target_if/direct_buf_rx/inc
 UMAC_SPECTRAL_OBJS := $(UMAC_SPECTRAL_CORE_DIR)/spectral_offload.o \
 		$(UMAC_SPECTRAL_CORE_DIR)/spectral_common.o \
 		$(UMAC_SPECTRAL_DISP_DIR)/wlan_spectral_ucfg_api.o \
 		$(UMAC_SPECTRAL_DISP_DIR)/wlan_spectral_utils_api.o \
 		$(UMAC_SPECTRAL_DISP_DIR)/wlan_spectral_tgt_api.o \
 		$(WLAN_COMMON_ROOT)/os_if/linux/spectral/src/wlan_cfg80211_spectral.o \
+		$(WLAN_COMMON_ROOT)/os_if/linux/spectral/src/os_if_spectral_netlink.o \
 		$(WLAN_COMMON_ROOT)/target_if/spectral/target_if_spectral_netlink.o \
 		$(WLAN_COMMON_ROOT)/target_if/spectral/target_if_spectral_phyerr.o \
 		$(WLAN_COMMON_ROOT)/target_if/spectral/target_if_spectral.o \

+ 1 - 0
core/hdd/inc/wlan_hdd_main.h

@@ -1710,6 +1710,7 @@ struct hdd_context {
 	bool force_rsne_override;
 	qdf_wake_lock_t monitor_mode_wakelock;
 	bool lte_coex_ant_share;
+	int sscan_pid;
 };
 
 /**

+ 30 - 1
core/hdd/inc/wlan_hdd_spectralscan.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -26,6 +26,26 @@
 #if !defined(WLAN_HDD_SPECTRALSCAN_H)
 #define WLAN_HDD_SPECTRALSCAN_H
 
+/*
+ * enum spectral_scan_msg_type - spectral scan registration
+ * @SPECTRAL_SCAN_REGISTER_REQ: spectral scan app register request
+ * @SPECTRAL_SCAN_REGISTER_RSP: spectral scan app register response
+ */
+enum spectral_scan_msg_type {
+	SPECTRAL_SCAN_REGISTER_REQ,
+	SPECTRAL_SCAN_REGISTER_RSP,
+};
+
+/*
+ * struct spectral_scan_msg - spectral scan request message
+ * @msg_type: message type
+ * @pid: process id
+ */
+struct spectral_scan_msg {
+	uint32_t msg_type;
+	uint32_t pid;
+};
+
 #define FEATURE_SPECTRAL_SCAN_VENDOR_COMMANDS \
 { \
 	.info.vendor_id = QCA_NL80211_VENDOR_ID, \
@@ -166,5 +186,14 @@ int wlan_hdd_cfg80211_spectral_scan_get_status(struct wiphy *wiphy,
 						const void *data,
 						int data_len);
 
+/**
+ * spectral_scan_activate_service() - Activate spectral scan  message handler
+ *
+ *  This function registers a handler to receive netlink message from
+ *  the spectral scan application process.
+ *
+ * Return - 0 for success, non zero for failure
+ */
+int spectral_scan_activate_service(void);
 
 #endif

+ 7 - 1
core/hdd/src/wlan_hdd_main.c

@@ -139,7 +139,7 @@
 #include "wlan_ocb_ucfg_api.h"
 
 #include <wlan_green_ap_ucfg_api.h>
-
+#include <wlan_hdd_spectralscan.h>
 #ifdef MODULE
 #define WLAN_MODULE_NAME  module_name(THIS_MODULE)
 #else
@@ -6215,6 +6215,12 @@ static int hdd_init_netlink_services(struct hdd_context *hdd_ctx)
 		goto err_close_cesium;
 	}
 
+	ret = spectral_scan_activate_service();
+	if (ret) {
+		hdd_alert("spectral_scan_activate_service failed: %d", ret);
+		goto err_close_cesium;
+	}
+
 	return 0;
 
 err_close_cesium:

+ 2 - 0
core/hdd/src/wlan_hdd_object_manager.c

@@ -34,6 +34,7 @@
 #include <wlan_osif_priv.h>
 #include <wlan_reg_ucfg_api.h>
 #include <target_if.h>
+#include <os_if_spectral_netlink.h>
 
 #define LOW_2GHZ_FREQ 2312
 #define HIGH_2GHZ_FREQ 2732
@@ -47,6 +48,7 @@ static void hdd_init_pdev_os_priv(struct hdd_context *hdd_ctx,
 	os_priv->wiphy = hdd_ctx->wiphy;
 	os_priv->legacy_osif_priv = hdd_ctx;
 	wlan_cfg80211_scan_priv_init(hdd_ctx->hdd_pdev);
+	os_if_spectral_netlink_init(hdd_ctx->hdd_pdev);
 }
 
 static void hdd_deinit_pdev_os_priv(struct wlan_objmgr_pdev *pdev)

+ 127 - 1
core/hdd/src/wlan_hdd_spectralscan.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2017, 2018 The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -31,6 +31,10 @@
 #include "ani_global.h"
 #include "wlan_cfg80211_spectral.h"
 #include "wlan_hdd_spectralscan.h"
+#include <wlan_spectral_ucfg_api.h>
+#ifdef CNSS_GENL
+#include <net/cnss_nl.h>
+#endif
 
 /**
  * __wlan_hdd_cfg80211_spectral_scan_start() - start spectral scan
@@ -354,3 +358,125 @@ int wlan_hdd_cfg80211_spectral_scan_get_status(struct wiphy *wiphy,
 
 	return ret;
 }
+
+#ifdef CNSS_GENL
+static void send_spectral_scan_reg_rsp_msg(struct hdd_context *hdd_ctx)
+{
+	struct sk_buff *skb;
+	struct nlmsghdr *nlh;
+	struct spectral_scan_msg *rsp_msg;
+	int err;
+
+	skb = alloc_skb(NLMSG_SPACE(sizeof(struct spectral_scan_msg)),
+				GFP_KERNEL);
+	if (skb == NULL) {
+		hdd_err("Skb allocation failed");
+		return;
+	}
+
+	nlh = (struct nlmsghdr *)skb->data;
+	nlh->nlmsg_pid = 0;
+	nlh->nlmsg_flags = 0;
+	nlh->nlmsg_seq = 0;
+	nlh->nlmsg_type = WLAN_NL_MSG_SPECTRAL_SCAN;
+
+	rsp_msg = NLMSG_DATA(nlh);
+	rsp_msg->msg_type = SPECTRAL_SCAN_REGISTER_RSP;
+	rsp_msg->pid = hdd_ctx->sscan_pid;
+
+	nlh->nlmsg_len = NLMSG_LENGTH(sizeof(struct spectral_scan_msg));
+	skb_put(skb, NLMSG_SPACE(sizeof(struct spectral_scan_msg)));
+
+	hdd_info("sending App Reg Response to process pid %d",
+			hdd_ctx->sscan_pid);
+
+	err = nl_srv_ucast(skb, hdd_ctx->sscan_pid, MSG_DONTWAIT,
+			WLAN_NL_MSG_SPECTRAL_SCAN, CLD80211_MCGRP_OEM_MSGS);
+
+	if (err < 0)
+		hdd_err("SPECTRAL: failed to send to spectral scan reg"
+			" response");
+}
+
+/**
+ * __spectral_scan_msg_handler() - API to handle spectral scan
+ * command
+ * @data: Data received
+ * @data_len: length of the data received
+ * @ctx: Pointer to stored context
+ * @pid: Process ID
+ *
+ * API to handle spectral scan commands from user space
+ *
+ * Return: None
+ */
+static void __spectral_scan_msg_handler(const void *data, int data_len,
+					void *ctx, int pid)
+{
+	struct spectral_scan_msg *ss_msg = NULL;
+	struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
+	struct hdd_context *hdd_ctx;
+	int ret;
+
+	hdd_ctx = (struct hdd_context *)cds_get_context(QDF_MODULE_ID_HDD);
+	ret = wlan_hdd_validate_context(hdd_ctx);
+	if (0 != ret)
+		return;
+
+	if (wlan_cfg80211_nla_parse(tb, CLD80211_ATTR_MAX, data,
+				    data_len, NULL)) {
+		hdd_err("nla parse fails");
+		return;
+	}
+
+	if (!tb[CLD80211_ATTR_DATA]) {
+		hdd_err("attr VENDOR_DATA fails");
+		return;
+	}
+	ss_msg = (struct spectral_scan_msg *)nla_data(tb[CLD80211_ATTR_DATA]);
+
+	if (!ss_msg) {
+		hdd_err("data NULL");
+		return;
+	}
+
+	switch (ss_msg->msg_type) {
+	case SPECTRAL_SCAN_REGISTER_REQ:
+		hdd_ctx->sscan_pid = ss_msg->pid;
+		hdd_debug("spectral scan application registered, pid=%d",
+				 hdd_ctx->sscan_pid);
+		send_spectral_scan_reg_rsp_msg(hdd_ctx);
+		ucfg_spectral_scan_set_ppid(hdd_ctx->hdd_pdev,
+						hdd_ctx->sscan_pid);
+		break;
+	default:
+		hdd_warn("invalid message type %d", ss_msg->msg_type);
+		break;
+	}
+}
+
+static void spectral_scan_msg_handler(const void *data, int data_len,
+					void *ctx, int pid)
+{
+	cds_ssr_protect(__func__);
+	__spectral_scan_msg_handler(data, data_len, ctx, pid);
+	cds_ssr_unprotect(__func__);
+}
+
+/**
+ * spectral_scan_activate_service() - API to register spectral
+ * scan cmd handler
+ *
+ * API to register the spectral scan command handler using new
+ * genl infra. Return type is zero to match with legacy
+ * prototype
+ *
+ * Return: 0
+ */
+int spectral_scan_activate_service(void)
+{
+	register_cld_cmd_cb(WLAN_NL_MSG_SPECTRAL_SCAN,
+				spectral_scan_msg_handler, NULL);
+	return 0;
+}
+#endif