qcacmn: Move Spectral Netlink APIs to os_if layer
Spectral Netlink related APIs are currently present in
target_if layer, move them to os_if layer.
Change-Id: I86a5495f6ec8aa85a2e9639902503a522b023f8e
CRs-Fixed: 2151548
diff --git a/os_if/linux/spectral/inc/os_if_spectral_netlink.h b/os_if/linux/spectral/inc/os_if_spectral_netlink.h
new file mode 100644
index 0000000..95db6e2
--- /dev/null
+++ b/os_if/linux/spectral/inc/os_if_spectral_netlink.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2011, 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
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _OS_IF_SPECTRAL_NETLINK_H
+#define _OS_IF_SPECTRAL_NETLINK_H
+
+#include <net/netlink.h>
+#include <wlan_objmgr_pdev_obj.h>
+
+/* NETLINK related declarations */
+#if (KERNEL_VERSION(2, 6, 31) > LINUX_VERSION_CODE)
+void os_if_spectral_nl_data_ready(struct sock *sk, int len);
+#else
+void os_if_spectral_nl_data_ready(struct sk_buff *skb);
+#endif /* VERSION CHECK */
+
+#ifndef NETLINK_ATHEROS
+#define NETLINK_ATHEROS (NETLINK_GENERIC + 1)
+#endif
+#define MAX_SPECTRAL_PAYLOAD 1500
+
+/* Init's network namespace */
+extern struct net init_net;
+
+/**
+ * os_if_spectral_netlink_init() - Initialize Spectral Netlink data structures
+ * and register the NL handlers with Spectral target_if
+ * @pdev: Pointer to pdev
+ *
+ * Sending Netlink messages to application layer and de-initialization of
+ * netlink related data structures are defined in os_if layer,
+ * they need to be registered with Spectral target_if
+ *
+ * Return: None
+ */
+void os_if_spectral_netlink_init(struct wlan_objmgr_pdev *pdev);
+
+#endif /* _OS_IF_SPECTRAL_NETLINK_H */
diff --git a/os_if/linux/spectral/src/os_if_spectral_netlink.c b/os_if/linux/spectral/src/os_if_spectral_netlink.c
new file mode 100644
index 0000000..ca1f73c
--- /dev/null
+++ b/os_if/linux/spectral/src/os_if_spectral_netlink.c
@@ -0,0 +1,416 @@
+/*
+ * Copyright (c) 2011, 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
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <os_if_spectral_netlink.h>
+#include <spectral_cmn_api_i.h>
+#include <spectral_defs_i.h>
+
+struct sock *os_if_spectral_nl_sock;
+static atomic_t spectral_nl_users = ATOMIC_INIT(0);
+
+#if (KERNEL_VERSION(2, 6, 31) > LINUX_VERSION_CODE)
+void
+os_if_spectral_nl_data_ready(struct sock *sk, int len)
+{
+ spectral_debug("%d", __LINE__);
+}
+
+#else
+void
+os_if_spectral_nl_data_ready(struct sk_buff *skb)
+{
+ spectral_debug("%d", __LINE__);
+}
+#endif /* VERSION */
+
+/**
+ * os_if_spectral_init_nl_cfg() - Initialize netlink kernel
+ * configuration parameters
+ * @cfg : Pointer to netlink_kernel_cfg
+ *
+ * Initialize netlink kernel configuration parameters required
+ * for spectral module
+ *
+ * Return: None
+ */
+#if KERNEL_VERSION(3, 6, 0) <= LINUX_VERSION_CODE
+static void
+os_if_spectral_init_nl_cfg(struct netlink_kernel_cfg *cfg)
+{
+ cfg->groups = 1;
+ cfg->input = os_if_spectral_nl_data_ready;
+}
+#else
+static void
+os_if_spectral_init_nl_cfg(struct netlink_kernel_cfg *cfg)
+{
+}
+#endif
+
+/**
+ * os_if_spectral_create_nl_sock() - Create Netlink socket
+ * @cfg : Pointer to netlink_kernel_cfg
+ *
+ * Create Netlink socket required for spectral module
+ *
+ * Return: None
+ */
+#if KERNEL_VERSION(3, 7, 0) <= LINUX_VERSION_CODE
+static void
+os_if_spectral_create_nl_sock(struct netlink_kernel_cfg *cfg)
+{
+ os_if_spectral_nl_sock =
+ (struct sock *)netlink_kernel_create(&init_net,
+ NETLINK_ATHEROS, cfg);
+}
+#elif KERNEL_VERSION(3, 6, 0) <= LINUX_VERSION_CODE
+static void
+os_if_spectral_create_nl_sock(struct netlink_kernel_cfg *cfg)
+{
+ os_if_spectral_nl_sock =
+ (struct sock *)netlink_kernel_create(&init_net,
+ NETLINK_ATHEROS,
+ THIS_MODULE, cfg);
+}
+#elif (KERNEL_VERSION(2, 6, 31) > LINUX_VERSION_CODE)
+static void
+os_if_spectral_create_nl_sock(struct netlink_kernel_cfg *cfg)
+{
+ os_if_spectral_nl_sock =
+ (struct sock *)netlink_kernel_create(
+ NETLINK_ATHEROS, 1,
+ &os_if_spectral_nl_data_ready,
+ THIS_MODULE);
+}
+#else
+#if (KERNEL_VERSION(3, 10, 0) <= LINUX_VERSION_CODE)
+static void
+os_if_spectral_create_nl_sock(struct netlink_kernel_cfg *cfg)
+{
+ memset(cfg, 0, sizeof(*cfg));
+ cfg->groups = 1;
+ cfg->input = &os_if_spectral_nl_data_ready;
+ os_if_spectral_nl_sock =
+ (struct sock *)netlink_kernel_create(&init_net,
+ NETLINK_ATHEROS, cfg);
+}
+#else
+static void
+os_if_spectral_create_nl_sock(struct netlink_kernel_cfg *cfg)
+{
+ os_if_spectral_nl_sock =
+ (struct sock *)netlink_kernel_create(
+ &init_net,
+ NETLINK_ATHEROS, 1,
+ &os_if_spectral_nl_data_ready,
+ NULL, THIS_MODULE);
+}
+#endif
+#endif
+
+/**
+ * os_if_spectral_init_nl() - Initialize netlink data structures for
+ * spectral module
+ * @pdev : Pointer to pdev
+ *
+ * Return: 0 on success else failure
+ */
+static int
+os_if_spectral_init_nl(struct wlan_objmgr_pdev *pdev)
+{
+ struct pdev_spectral *ps = NULL;
+ struct netlink_kernel_cfg cfg;
+
+ memset(&cfg, 0, sizeof(cfg));
+ if (!pdev) {
+ spectral_err("PDEV is NULL!");
+ return -EINVAL;
+ }
+ ps = wlan_objmgr_pdev_get_comp_private_obj(pdev,
+ WLAN_UMAC_COMP_SPECTRAL);
+
+ if (!ps) {
+ spectral_err("PDEV SPECTRAL object is NULL!");
+ return -EINVAL;
+ }
+ os_if_spectral_init_nl_cfg(&cfg);
+
+ if (!os_if_spectral_nl_sock) {
+ os_if_spectral_create_nl_sock(&cfg);
+
+ if (!os_if_spectral_nl_sock) {
+ spectral_err("NETLINK_KERNEL_CREATE FAILED");
+ return -ENODEV;
+ }
+ }
+ ps->spectral_sock = os_if_spectral_nl_sock;
+
+ if (!ps->spectral_sock) {
+ spectral_err("ps->spectral_sock is NULL");
+ return -ENODEV;
+ }
+ atomic_inc(&spectral_nl_users);
+
+ return 0;
+}
+
+/**
+ * os_if_spectral_destroy_netlink() - De-initialize netlink data structures for
+ * spectral module
+ * @pdev : Pointer to pdev
+ *
+ * Return: Success/Failure
+ */
+static int
+os_if_spectral_destroy_netlink(struct wlan_objmgr_pdev *pdev)
+{
+ struct pdev_spectral *ps = NULL;
+
+ if (!pdev) {
+ spectral_err("PDEV is NULL!");
+ return -EINVAL;
+ }
+ ps = wlan_objmgr_pdev_get_comp_private_obj(pdev,
+ WLAN_UMAC_COMP_SPECTRAL);
+
+ if (!ps) {
+ spectral_err("PDEV SPECTRAL object is NULL!");
+ return -EINVAL;
+ }
+ ps->spectral_sock = NULL;
+ if (atomic_dec_and_test(&spectral_nl_users)) {
+ sock_release(os_if_spectral_nl_sock->sk_socket);
+ os_if_spectral_nl_sock = NULL;
+ }
+ return 0;
+}
+
+/**
+ * os_if_spectral_prep_skb() - Prepare socket buffer
+ * @pdev : Pointer to pdev
+ *
+ * Prepare socket buffer to send the data to application layer
+ *
+ * Return: NLMSG_DATA of the created skb or NULL if no memory
+ */
+void *
+os_if_spectral_prep_skb(struct wlan_objmgr_pdev *pdev)
+{
+ struct pdev_spectral *ps = NULL;
+ struct nlmsghdr *spectral_nlh = NULL;
+
+ if (!pdev) {
+ spectral_err("PDEV is NULL!");
+ return NULL;
+ }
+ ps = wlan_objmgr_pdev_get_comp_private_obj(pdev,
+ WLAN_UMAC_COMP_SPECTRAL);
+
+ if (!ps) {
+ spectral_err("PDEV SPECTRAL object is NULL!");
+ return NULL;
+ }
+ ps->skb = dev_alloc_skb(MAX_SPECTRAL_PAYLOAD);
+
+ if (!ps->skb) {
+ spectral_err("allocate skb (len=%u) failed",
+ MAX_SPECTRAL_PAYLOAD);
+ return NULL;
+ }
+
+ skb_put(ps->skb, MAX_SPECTRAL_PAYLOAD);
+ spectral_nlh = (struct nlmsghdr *)ps->skb->data;
+
+ OS_MEMZERO(spectral_nlh,
+ sizeof(*spectral_nlh));
+
+ /*
+ * Possible bug that size of struct spectral_samp_msg and
+ * SPECTRAL_MSG differ by 3 bytes so we miss 3 bytes
+ */
+
+ spectral_nlh->nlmsg_len =
+ NLMSG_SPACE(sizeof(struct spectral_samp_msg));
+ spectral_nlh->nlmsg_pid = 0;
+ spectral_nlh->nlmsg_flags = 0;
+
+ return NLMSG_DATA(spectral_nlh);
+}
+
+#if (KERNEL_VERSION(2, 6, 31) > LINUX_VERSION_CODE)
+static inline void
+os_if_init_spectral_skb_dst_pid(
+ struct sk_buff *skb,
+ struct pdev_spectral *ps)
+{
+ NETLINK_CB(skb).dst_pid =
+ ps->spectral_pid;
+}
+#else
+static inline void
+os_if_init_spectral_skb_dst_pid(
+ struct sk_buff *skb,
+ struct pdev_spectral *ps)
+{
+}
+#endif /* VERSION - field deprecated by newer kernels */
+
+#if KERNEL_VERSION(3, 7, 0) > LINUX_VERSION_CODE
+static inline void
+os_if_init_spectral_skb_pid_portid(struct sk_buff *skb)
+{
+ NETLINK_CB(skb).pid = 0; /* from kernel */
+}
+#else
+static inline void
+os_if_init_spectral_skb_pid_portid(struct sk_buff *skb)
+{
+ NETLINK_CB(skb).portid = 0; /* from kernel */
+}
+#endif
+
+/**
+ * os_if_spectral_nl_unicast_msg() - Sends unicast Spectral message to user
+ * space
+ * @pdev : Pointer to pdev
+ *
+ * Return: void
+ */
+static int
+os_if_spectral_nl_unicast_msg(struct wlan_objmgr_pdev *pdev)
+{
+ struct pdev_spectral *ps = NULL;
+ int status;
+
+ if (!pdev) {
+ spectral_err("PDEV is NULL!");
+ return -EINVAL;
+ }
+
+ ps = wlan_objmgr_pdev_get_comp_private_obj(pdev,
+ WLAN_UMAC_COMP_SPECTRAL);
+ if (!ps) {
+ spectral_err("PDEV SPECTRAL object is NULL!");
+ return -EINVAL;
+ }
+
+ if (!ps->skb) {
+ spectral_err("Socket buffer is null");
+ return -EINVAL;
+ }
+
+ if (!ps->spectral_sock) {
+ spectral_err("Spectral Socket is invalid");
+ dev_kfree_skb(ps->skb);
+ return -EINVAL;
+ }
+
+ os_if_init_spectral_skb_dst_pid(ps->skb, ps);
+
+ os_if_init_spectral_skb_pid_portid(ps->skb);
+
+ /* to mcast group 1<<0 */
+ NETLINK_CB(ps->skb).dst_group = 0;
+
+ status = netlink_unicast(ps->spectral_sock,
+ ps->skb,
+ ps->spectral_pid, MSG_DONTWAIT);
+
+ return status;
+}
+
+/**
+ * os_if_spectral_nl_bcast_msg() - Sends broadcast Spectral message to user
+ * space
+ * @pdev : Pointer to pdev
+ *
+ * Return: void
+ */
+static int
+os_if_spectral_nl_bcast_msg(struct wlan_objmgr_pdev *pdev)
+{
+#if (KERNEL_VERSION(2, 6, 31) >= LINUX_VERSION_CODE)
+ fd_set write_set;
+#endif
+ int status;
+ struct pdev_spectral *ps = NULL;
+
+#if (KERNEL_VERSION(2, 6, 31) >= LINUX_VERSION_CODE)
+ FD_ZERO(&write_set);
+#endif
+
+ if (!pdev) {
+ spectral_err("PDEV is NULL!");
+ return -EINVAL;
+ }
+ ps = wlan_objmgr_pdev_get_comp_private_obj(pdev,
+ WLAN_UMAC_COMP_SPECTRAL);
+
+ if (!ps) {
+ spectral_err("PDEV SPECTRAL object is NULL!");
+ return -EINVAL;
+ }
+
+ if (!ps->skb) {
+ spectral_err("Socket buffer is null");
+ return -EINVAL;
+ }
+
+ if (!ps->spectral_sock) {
+ dev_kfree_skb(ps->skb);
+ return -EINVAL;
+ }
+
+ status = netlink_broadcast(ps->spectral_sock,
+ ps->skb,
+ 0, 1, GFP_ATOMIC);
+
+ return status;
+}
+
+void
+os_if_spectral_netlink_init(struct wlan_objmgr_pdev *pdev)
+{
+ struct spectral_nl_cb nl_cb = {0};
+ struct spectral_context *sptrl_ctx;
+
+ if (!pdev) {
+ spectral_err("PDEV is NULL!");
+ return;
+ }
+
+ sptrl_ctx = spectral_get_spectral_ctx_from_pdev(pdev);
+
+ if (!sptrl_ctx) {
+ spectral_err("Spectral context is NULL!");
+ return;
+ }
+
+ os_if_spectral_init_nl(pdev);
+
+ /* Register Netlink handlers */
+ nl_cb.get_nbuff = os_if_spectral_prep_skb;
+ nl_cb.send_nl_bcast = os_if_spectral_nl_bcast_msg;
+ nl_cb.send_nl_unicast = os_if_spectral_nl_unicast_msg;
+ nl_cb.destroy_netlink = os_if_spectral_destroy_netlink;
+
+ if (sptrl_ctx->sptrlc_register_netlink_cb)
+ sptrl_ctx->sptrlc_register_netlink_cb(pdev, &nl_cb);
+}
+EXPORT_SYMBOL(os_if_spectral_netlink_init);
diff --git a/spectral/Kbuild b/spectral/Kbuild
index 4fbd8d4..ce58416 100644
--- a/spectral/Kbuild
+++ b/spectral/Kbuild
@@ -25,6 +25,7 @@
INCS += -I$(obj)/$(DEPTH)/cmn_dev/umac/dfs/dispatcher/inc
INCS += -I$(obj)/$(DEPTH)/cmn_dev/os_if/linux/spectral/inc
INCS += -I$(obj)/$(DEPTH)/cmn_dev/os_if/linux/scan/inc
+INCS += -I$(obj)/$(DEPTH)/cmn_dev/spectral/core
ifeq ($(WLAN_CONV_CRYPTO_SUPPORTED), 1)
INCS += -I$(obj)/$(DEPTH)/cmn_dev/umac/cmn_services/crypto/inc
@@ -188,7 +189,8 @@
dispatcher/src/wlan_spectral_ucfg_api.o \
dispatcher/src/wlan_spectral_tgt_api.o \
core/spectral_module.o \
- $(DEPTH)/cmn_dev/os_if/linux/spectral/src/wlan_cfg80211_spectral.o
+ $(DEPTH)/cmn_dev/os_if/linux/spectral/src/wlan_cfg80211_spectral.o \
+ $(DEPTH)/cmn_dev/os_if/linux/spectral/src/os_if_spectral_netlink.o
qca_spectral-objs += ${SPECTRAL_CMN_OBJS} \
${SPECTRAL_TIF_OBJS} \
diff --git a/spectral/core/spectral_defs_i.h b/spectral/core/spectral_defs_i.h
index 54b5190..510f502 100644
--- a/spectral/core/spectral_defs_i.h
+++ b/spectral/core/spectral_defs_i.h
@@ -55,14 +55,18 @@
/**
* struct pdev_spectral - Radio specific spectral object
* @psptrl_pdev: Back-pointer to struct wlan_objmgr_pdev
- * @psptrl_nl_sock: Spectral Netlink socket for sending samples to
+ * @spectral_sock: Spectral Netlink socket for sending samples to
* applications
* @psptrl_target_handle: reference to spectral lmac object
+ * @skb: Socket buffer for sending samples to applications
+ * @spectral_pid : Spectral port ID
*/
struct pdev_spectral {
struct wlan_objmgr_pdev *psptrl_pdev;
- struct sock *psptrl_nl_sock;
+ struct sock *spectral_sock;
void *psptrl_target_handle;
+ struct sk_buff *skb;
+ uint32_t spectral_pid;
};
struct wmi_spectral_cmd_ops;
@@ -86,6 +90,8 @@
* @sptrlc_get_spectral_capinfo: Get spectral capability info
* @sptrlc_get_spectral_diagstats: Get spectral diag status
* @sptrlc_register_wmi_spectral_cmd_ops: Register wmi_spectral_cmd operations
+ * @sptrlc_register_netlink_cb: Register Netlink callbacks
+ * @sptrlc_use_nl_bcast: Check whether to use Netlink broadcast/unicast
*/
struct spectral_context {
struct wlan_objmgr_psoc *psoc_obj;
@@ -118,6 +124,10 @@
void (*sptrlc_register_wmi_spectral_cmd_ops)(
struct wlan_objmgr_pdev *pdev,
struct wmi_spectral_cmd_ops *cmd_ops);
+ void (*sptrlc_register_netlink_cb)(
+ struct wlan_objmgr_pdev *pdev,
+ struct spectral_nl_cb *nl_cb);
+ bool (*sptrlc_use_nl_bcast)(struct wlan_objmgr_pdev *pdev);
};
#endif /* _SPECTRAL_DEFS_I_H_ */
diff --git a/spectral/core/spectral_direct_attach.c b/spectral/core/spectral_direct_attach.c
index ae011aa..c532503 100644
--- a/spectral/core/spectral_direct_attach.c
+++ b/spectral/core/spectral_direct_attach.c
@@ -42,4 +42,6 @@
sc->sptrlc_get_spectral_diagstats = tgt_get_spectral_diagstats;
sc->sptrlc_register_wmi_spectral_cmd_ops =
tgt_register_wmi_spectral_cmd_ops;
+ sc->sptrlc_register_netlink_cb = tgt_spectral_register_nl_cb;
+ sc->sptrlc_use_nl_bcast = tgt_spectral_use_nl_bcast;
}
diff --git a/spectral/core/spectral_offload.c b/spectral/core/spectral_offload.c
index b4b6068..dd09c78 100644
--- a/spectral/core/spectral_offload.c
+++ b/spectral/core/spectral_offload.c
@@ -43,4 +43,6 @@
sc->sptrlc_get_spectral_diagstats = tgt_get_spectral_diagstats;
sc->sptrlc_register_wmi_spectral_cmd_ops =
tgt_register_wmi_spectral_cmd_ops;
+ sc->sptrlc_register_netlink_cb = tgt_spectral_register_nl_cb;
+ sc->sptrlc_use_nl_bcast = tgt_spectral_use_nl_bcast;
}
diff --git a/spectral/dispatcher/inc/wlan_spectral_public_structs.h b/spectral/dispatcher/inc/wlan_spectral_public_structs.h
index 5c7106b..f65611a 100644
--- a/spectral/dispatcher/inc/wlan_spectral_public_structs.h
+++ b/spectral/dispatcher/inc/wlan_spectral_public_structs.h
@@ -502,6 +502,22 @@
struct spectral_samp_data samp_data;
} __ATTRIB_PACKED;
+/* Forward declarations */
+struct wlan_objmgr_pdev;
+
+/**
+ * struct spectral_nl_cb - Spectral Netlink callbacks
+ * @get_nbuff: Get the socket buffer to send the data to the application
+ * @send_nl_bcast: Send data to the application using netlink broadcast
+ * @send_nl_unicast: Send data to the application using netlink unicast
+ * @destroy_netlink: De-initialize Netlink data structures
+ */
+struct spectral_nl_cb {
+ void *(*get_nbuff)(struct wlan_objmgr_pdev *pdev);
+ int (*send_nl_bcast)(struct wlan_objmgr_pdev *pdev);
+ int (*send_nl_unicast)(struct wlan_objmgr_pdev *pdev);
+ int (*destroy_netlink)(struct wlan_objmgr_pdev *pdev);
+};
#ifdef WIN32
#pragma pack(pop, spectral)
#endif
diff --git a/spectral/dispatcher/inc/wlan_spectral_tgt_api.h b/spectral/dispatcher/inc/wlan_spectral_tgt_api.h
index 5221d8a..f3f574f 100644
--- a/spectral/dispatcher/inc/wlan_spectral_tgt_api.h
+++ b/spectral/dispatcher/inc/wlan_spectral_tgt_api.h
@@ -25,19 +25,6 @@
#include "../../core/spectral_cmn_api_i.h"
/**
- * tgt_send_phydata() - Send Spectral PHY data
- * @pdev: Pointer to pdev
- * @sock: Netlink socket to use
- * @nbuf: Network buffer containing PHY data to send
- *
- * Send spectral PHY data over netlink
- *
- * Return: 0 on success, negative value on failure
- */
-int tgt_send_phydata(struct wlan_objmgr_pdev *pdev,
- struct sock *sock, qdf_nbuf_t nbuf);
-
-/**
* tgt_get_target_handle() - Get target_if handle
* @pdev: Pointer to pdev
*
@@ -62,12 +49,9 @@
*
* Return: 0 success else failure
*/
-int
-tgt_spectral_control(
- struct wlan_objmgr_pdev *pdev,
- u_int id,
- void *indata,
- u_int32_t insize, void *outdata, u_int32_t *outsize);
+int tgt_spectral_control(struct wlan_objmgr_pdev *pdev,
+ u_int id, void *indata, u_int32_t insize,
+ void *outdata, u_int32_t *outsize);
/**
* tgt_pdev_spectral_init() - implementation for spectral init
@@ -76,8 +60,7 @@
* Return: On success, pointer to Spectral target_if internal private data, on
* failure, NULL
*/
-void *
-tgt_pdev_spectral_init(struct wlan_objmgr_pdev *pdev);
+void *tgt_pdev_spectral_init(struct wlan_objmgr_pdev *pdev);
/**
* tgt_pdev_spectral_deinit() - implementation for spectral de-init
@@ -85,8 +68,7 @@
*
* Return: None
*/
-void
-tgt_pdev_spectral_deinit(struct wlan_objmgr_pdev *pdev);
+void tgt_pdev_spectral_deinit(struct wlan_objmgr_pdev *pdev);
/**
* tgt_set_spectral_config() - Set spectral config
@@ -98,10 +80,9 @@
*
* Return: 0 on success else failure
*/
-int
-tgt_set_spectral_config(
- struct wlan_objmgr_pdev *pdev,
- const u_int32_t threshtype, const u_int32_t value);
+int tgt_set_spectral_config(struct wlan_objmgr_pdev *pdev,
+ const u_int32_t threshtype,
+ const u_int32_t value);
/**
* tgt_get_spectral_config() - Get spectral configuration
@@ -113,10 +94,8 @@
*
* Return: None
*/
-void
-tgt_get_spectral_config(
- struct wlan_objmgr_pdev *pdev,
- struct spectral_config *sptrl_config);
+void tgt_get_spectral_config(struct wlan_objmgr_pdev *pdev,
+ struct spectral_config *sptrl_config);
/**
* tgt_start_spectral_scan() - Start spectral scan
@@ -126,8 +105,7 @@
*
* Return: 0 in case of success, -1 on failure
*/
-int
-tgt_start_spectral_scan(struct wlan_objmgr_pdev *pdev);
+int tgt_start_spectral_scan(struct wlan_objmgr_pdev *pdev);
/**
* tgt_stop_spectral_scan() - Stop spectral scan
@@ -137,8 +115,7 @@
*
* Return: None
*/
-void
-tgt_stop_spectral_scan(struct wlan_objmgr_pdev *pdev);
+void tgt_stop_spectral_scan(struct wlan_objmgr_pdev *pdev);
/**
* tgt_is_spectral_active() - Get whether Spectral is active
@@ -148,8 +125,7 @@
*
* Return: True if Spectral is active, false if Spectral is not active
*/
-bool
-tgt_is_spectral_active(struct wlan_objmgr_pdev *pdev);
+bool tgt_is_spectral_active(struct wlan_objmgr_pdev *pdev);
/**
* tgt_is_spectral_enabled() - Get whether Spectral is active
@@ -159,8 +135,7 @@
*
* Return: True if Spectral is active, false if Spectral is not active
*/
-bool
-tgt_is_spectral_enabled(struct wlan_objmgr_pdev *pdev);
+bool tgt_is_spectral_enabled(struct wlan_objmgr_pdev *pdev);
/**
* tgt_set_debug_level() - Set debug level for Spectral
@@ -171,8 +146,7 @@
*
* Return: 0 in case of success
*/
-int
-tgt_set_debug_level(struct wlan_objmgr_pdev *pdev, u_int32_t debug_level);
+int tgt_set_debug_level(struct wlan_objmgr_pdev *pdev, u_int32_t debug_level);
/**
* tgt_get_debug_level() - Get debug level for Spectral
@@ -182,8 +156,7 @@
*
* Return: Current debug level
*/
-u_int32_t
-tgt_get_debug_level(struct wlan_objmgr_pdev *pdev);
+uint32_t tgt_get_debug_level(struct wlan_objmgr_pdev *pdev);
/**
* tgt_get_spectral_capinfo() - Get Spectral capability information
@@ -194,8 +167,7 @@
*
* Return: void
*/
-void
-tgt_get_spectral_capinfo(struct wlan_objmgr_pdev *pdev, void *outdata);
+void tgt_get_spectral_capinfo(struct wlan_objmgr_pdev *pdev, void *outdata);
/**
* tgt_get_spectral_diagstats() - Get Spectral diagnostic statistics
@@ -206,8 +178,7 @@
*
* Return: void
*/
-void
-tgt_get_spectral_diagstats(struct wlan_objmgr_pdev *pdev, void *outdata);
+void tgt_get_spectral_diagstats(struct wlan_objmgr_pdev *pdev, void *outdata);
/**
* tgt_register_wmi_spectral_cmd_ops() - Register wmi_spectral_cmd_ops
@@ -219,8 +190,25 @@
*
* Return: void
*/
-void
-tgt_register_wmi_spectral_cmd_ops(
- struct wlan_objmgr_pdev *pdev,
- struct wmi_spectral_cmd_ops *cmd_ops);
+void tgt_register_wmi_spectral_cmd_ops(struct wlan_objmgr_pdev *pdev,
+ struct wmi_spectral_cmd_ops *cmd_ops);
+
+/**
+ * tgt_spectral_register_nl_cb() - Register Netlink callbacks
+ * @pdev: Pointer to pdev object
+ * @nl_cb: Netlink callbacks to register
+ *
+ * Return: void
+ */
+void tgt_spectral_register_nl_cb(struct wlan_objmgr_pdev *pdev,
+ struct spectral_nl_cb *nl_cb);
+
+/**
+ * tgt_spectral_use_nl_bcast() - Get whether to use broadcast/unicast while
+ * sending Netlink messages to the application layer
+ * @pdev: Pointer to pdev object
+ *
+ * Return: true for broadcast, false for unicast
+ */
+bool tgt_spectral_use_nl_bcast(struct wlan_objmgr_pdev *pdev);
#endif /* _WLAN_SPECTRAL_TGT_API_H_ */
diff --git a/spectral/dispatcher/src/wlan_spectral_tgt_api.c b/spectral/dispatcher/src/wlan_spectral_tgt_api.c
index 0952bc8..63b666b 100644
--- a/spectral/dispatcher/src/wlan_spectral_tgt_api.c
+++ b/spectral/dispatcher/src/wlan_spectral_tgt_api.c
@@ -19,13 +19,6 @@
#include <wlan_spectral_tgt_api.h>
-int
-tgt_send_phydata(struct wlan_objmgr_pdev *pdev,
- struct sock *sock, qdf_nbuf_t nbuf)
-{
- return netlink_broadcast(sock, nbuf, 0, 1, GFP_ATOMIC);
-}
-
void *
tgt_get_target_handle(struct wlan_objmgr_pdev *pdev)
{
@@ -203,3 +196,32 @@
return psptrl_tx_ops->sptrlto_register_wmi_spectral_cmd_ops(pdev,
cmd_ops);
}
+
+void
+tgt_spectral_register_nl_cb(
+ struct wlan_objmgr_pdev *pdev,
+ struct spectral_nl_cb *nl_cb)
+{
+ struct wlan_objmgr_psoc *psoc = NULL;
+ struct wlan_lmac_if_sptrl_tx_ops *psptrl_tx_ops = NULL;
+
+ psoc = wlan_pdev_get_psoc(pdev);
+
+ psptrl_tx_ops = &psoc->soc_cb.tx_ops.sptrl_tx_ops;
+
+ return psptrl_tx_ops->sptrlto_register_netlink_cb(pdev,
+ nl_cb);
+}
+
+bool
+tgt_spectral_use_nl_bcast(struct wlan_objmgr_pdev *pdev)
+{
+ struct wlan_objmgr_psoc *psoc = NULL;
+ struct wlan_lmac_if_sptrl_tx_ops *psptrl_tx_ops = NULL;
+
+ psoc = wlan_pdev_get_psoc(pdev);
+
+ psptrl_tx_ops = &psoc->soc_cb.tx_ops.sptrl_tx_ops;
+
+ return psptrl_tx_ops->sptrlto_use_nl_bcast(pdev);
+}
diff --git a/spectral/dispatcher/src/wlan_spectral_utils_api.c b/spectral/dispatcher/src/wlan_spectral_utils_api.c
index 9ae3be9..37234f1 100644
--- a/spectral/dispatcher/src/wlan_spectral_utils_api.c
+++ b/spectral/dispatcher/src/wlan_spectral_utils_api.c
@@ -149,7 +149,6 @@
struct wlan_lmac_if_sptrl_rx_ops *sptrl_rx_ops = &rx_ops->sptrl_rx_ops;
/* Spectral rx ops */
- sptrl_rx_ops->sptrlro_send_phydata = tgt_send_phydata;
sptrl_rx_ops->sptrlro_get_target_handle = tgt_get_target_handle;
sptrl_rx_ops->sptrlro_vdev_get_chan_freq = spectral_vdev_get_chan_freq;
sptrl_rx_ops->sptrlro_vdev_get_ch_width = spectral_vdev_get_ch_width;
diff --git a/target_if/spectral/target_if_spectral.c b/target_if/spectral/target_if_spectral.c
index ebd1224..663953e 100644
--- a/target_if/spectral/target_if_spectral.c
+++ b/target_if/spectral/target_if_spectral.c
@@ -1839,9 +1839,7 @@
target_if_spectral_detach_simulation(spectral);
-#ifdef SPECTRAL_USE_NETLINK_SOCKETS
- target_if_spectral_destroy_netlink(spectral);
-#endif
+ spectral->nl_cb.destroy_netlink(spectral->pdev_obj);
qdf_spinlock_destroy(&spectral->spectral_lock);
qdf_spinlock_destroy(&spectral->noise_pwr_reports_lock);
@@ -1945,11 +1943,11 @@
if (p_sops->get_capability(spectral, SPECTRAL_CAP_PHYDIAG))
spectral_info("HAL_CAP_PHYDIAG : Capable");
- SPECTRAL_TODO("Need to fix the capablity check for RADAR");
+ /* TODO: Need to fix the capablity check for RADAR */
if (p_sops->get_capability(spectral, SPECTRAL_CAP_RADAR))
spectral_info("HAL_CAP_RADAR : Capable");
- SPECTRAL_TODO("Need to fix the capablity check for SPECTRAL\n");
+ /* TODO : Need to fix the capablity check for SPECTRAL */
/* TODO : Should this be called here of after ath_attach ? */
if (p_sops->get_capability(spectral, SPECTRAL_CAP_SPECTRAL_SCAN))
spectral_info("HAL_CAP_SPECTRAL_SCAN : Capable");
@@ -1958,13 +1956,6 @@
qdf_spinlock_create(&spectral->noise_pwr_reports_lock);
target_if_spectral_clear_stats(spectral);
- qdf_spinlock_create(&spectral->spectral_skbqlock);
- STAILQ_INIT(&spectral->spectral_skbq);
-
-#ifdef SPECTRAL_USE_NETLINK_SOCKETS
- target_if_spectral_init_netlink(spectral);
-#endif
-
/* Set the default values for spectral parameters */
target_if_spectral_init_param_defaults(spectral);
#ifdef CONFIG_WIN
@@ -2029,10 +2020,12 @@
if (target_type == TARGET_TYPE_QCA9984 ||
target_type == TARGET_TYPE_QCA9888)
spectral->is_sec80_rssi_war_required = true;
+ spectral->use_nl_bcast = true;
#else
spectral->is_160_format = true;
spectral->is_lb_edge_extrabins_format = true;
spectral->is_rb_edge_extrabins_format = true;
+ spectral->use_nl_bcast = false;
#endif
}
@@ -2607,7 +2600,7 @@
qdf_spin_lock(&spectral->spectral_lock);
p_sops->stop_spectral_scan(spectral);
if (spectral->classify_scan) {
- SPECTRAL_TODO("Check if this logic is necessary");
+ /* TODO : Check if this logic is necessary */
spectral->detects_control_channel = 0;
spectral->detects_extension_channel = 0;
spectral->detects_above_dc = 0;
@@ -2757,6 +2750,45 @@
cmd_ops->wmi_spectral_enable_cmd_send;
}
+/**
+ * target_if_register_netlink_cb() - Register Netlink callbacks
+ * @pdev: Pointer to pdev object
+ * @nl_cb: Netlink callbacks to register
+ *
+ * Return: void
+ */
+static void
+target_if_register_netlink_cb(
+ struct wlan_objmgr_pdev *pdev,
+ struct spectral_nl_cb *nl_cb)
+{
+ struct target_if_spectral *spectral = NULL;
+
+ spectral = get_target_if_spectral_handle_from_pdev(pdev);
+ qdf_mem_copy(&spectral->nl_cb, nl_cb, sizeof(struct spectral_nl_cb));
+
+ if (spectral->use_nl_bcast)
+ spectral->send_phy_data = spectral->nl_cb.send_nl_bcast;
+ else
+ spectral->send_phy_data = spectral->nl_cb.send_nl_unicast;
+}
+
+/**
+ * target_if_use_nl_bcast() - Get whether to use broadcast/unicast while sending
+ * Netlink messages to the application layer
+ * @pdev: Pointer to pdev object
+ *
+ * Return: true for broadcast, false for unicast
+ */
+static bool
+target_if_use_nl_bcast(struct wlan_objmgr_pdev *pdev)
+{
+ struct target_if_spectral *spectral = NULL;
+
+ spectral = get_target_if_spectral_handle_from_pdev(pdev);
+ return spectral->use_nl_bcast;
+}
+
void
target_if_sptrl_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
{
@@ -2786,6 +2818,10 @@
target_if_get_spectral_diagstats;
tx_ops->sptrl_tx_ops.sptrlto_register_wmi_spectral_cmd_ops =
target_if_register_wmi_spectral_cmd_ops;
+ tx_ops->sptrl_tx_ops.sptrlto_register_netlink_cb =
+ target_if_register_netlink_cb;
+ tx_ops->sptrl_tx_ops.sptrlto_use_nl_bcast =
+ target_if_use_nl_bcast;
}
EXPORT_SYMBOL(target_if_sptrl_register_tx_ops);
@@ -2793,26 +2829,23 @@
target_if_spectral_send_intf_found_msg(struct wlan_objmgr_pdev *pdev,
uint16_t cw_int, uint32_t dcs_enabled)
{
-#ifdef SPECTRAL_USE_NETLINK_SOCKETS
struct spectral_samp_msg *msg = NULL;
struct target_if_spectral_ops *p_sops = NULL;
struct target_if_spectral *spectral = NULL;
spectral = get_target_if_spectral_handle_from_pdev(pdev);
- p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral);
- target_if_spectral_prep_skb(spectral);
- if (spectral->spectral_skb) {
- spectral->spectral_nlh =
- (struct nlmsghdr *)spectral->spectral_skb->data;
- msg = (struct spectral_samp_msg *)NLMSG_DATA(
- spectral->spectral_nlh);
+ msg = (struct spectral_samp_msg *)spectral->nl_cb.get_nbuff(
+ spectral->pdev_obj);
+
+ if (msg) {
msg->int_type = cw_int ?
SPECTRAL_DCS_INT_CW : SPECTRAL_DCS_INT_WIFI;
msg->dcs_enabled = dcs_enabled;
msg->signature = SPECTRAL_SIGNATURE;
+ p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral);
p_sops->get_mac_address(spectral, msg->macaddr);
- target_if_spectral_bcast_msg(spectral);
+ if (spectral->send_phy_data(pdev) == 0)
+ spectral->spectral_sent_msg++;
}
-#endif
}
EXPORT_SYMBOL(target_if_spectral_send_intf_found_msg);
diff --git a/target_if/spectral/target_if_spectral.h b/target_if/spectral/target_if_spectral.h
index acbe158..a5b8873 100644
--- a/target_if/spectral/target_if_spectral.h
+++ b/target_if/spectral/target_if_spectral.h
@@ -59,10 +59,7 @@
#undef spectral_dbg_line
#define spectral_dbg_line() \
spectral_debug("----------------------------------------------------\n")
-#undef SPECTRAL_TODO
-#define SPECTRAL_TODO(str) \
- spectral_info("SPECTRAL : %s (%s : %d)\n", \
- (str), __func__, __LINE__)
+
#undef spectral_ops_not_registered
#define spectral_ops_not_registered(str) \
spectral_info("SPECTRAL : %s not registered\n", (str))
@@ -112,10 +109,6 @@
/* Mask for time stamp from descriptor */
#define SPECTRAL_TSMASK 0xFFFFFFFF
#define SPECTRAL_SIGNATURE 0xdeadbeef
-#define MAX_SPECTRAL_PAYLOAD 1500
-#ifndef NETLINK_ATHEROS
-#define NETLINK_ATHEROS (NETLINK_GENERIC + 1)
-#endif
/* START of spectral GEN II HW specific details */
#define SPECTRAL_PHYERR_SIGNATURE_GEN2 0xbb
@@ -677,6 +670,9 @@
* header, for the given hardware generation
* @tlvhdr_size: Expected PHYERR TLV header size, for the given hardware
* generation
+ * @nl_cb: Netlink callbacks
+ * @use_nl_bcast: Whether to use Netlink broadcast/unicast
+ * @send_phy_data: Send data to the applicaton layer
*/
struct target_if_spectral {
struct wlan_objmgr_pdev *pdev_obj;
@@ -700,13 +696,6 @@
int lower_is_control;
int lower_is_extension;
uint8_t sc_spectraltest_ieeechan;
- struct sock *spectral_sock;
- struct sk_buff *spectral_skb;
- struct nlmsghdr *spectral_nlh;
- uint32_t spectral_pid;
-
- STAILQ_HEAD(, target_if_spectral_skb_event) spectral_skbq;
- qdf_spinlock_t spectral_skbqlock;
int spectral_numbins;
int spectral_fft_len;
int spectral_data_len;
@@ -781,20 +770,9 @@
uint8_t tag_sscan_fft_exp;
uint8_t tlvhdr_size;
struct wmi_spectral_cmd_ops param_wmi_cmd_ops;
-};
-
-/**
- * struct target_if_spectral_skb_event - Used to broadcast FFT report to
- * applications
- * @sp_skb: Pointer to skb
- * @sp_nlh: Pointer to nl message header
- * @spectral_skb_list: Linked list to manipulate the reports
- */
-struct target_if_spectral_skb_event {
- struct sk_buff *sp_skb;
- struct nlmsghdr *sp_nlh;
-
- STAILQ_ENTRY(target_if_spectral_skb_event) spectral_skb_list;
+ struct spectral_nl_cb nl_cb;
+ bool use_nl_bcast;
+ int (*send_phy_data)(struct wlan_objmgr_pdev *pdev);
};
/**
@@ -872,15 +850,6 @@
struct ath_softc *sc;
};
-/* NETLINK related declarations */
-#ifdef SPECTRAL_USE_NETLINK_SOCKETS
-#if (KERNEL_VERSION(2, 6, 31) > LINUX_VERSION_CODE)
-void target_if_spectral_nl_data_ready(struct sock *sk, int len);
-#else
-void target_if_spectral_nl_data_ready(struct sk_buff *skb);
-#endif /* VERSION CHECK */
-#endif /* SPECTRAL_USE_NETLINK_SOCKETS defined */
-
/**
* target_if_spectral_dump_fft() - Dump Spectral FFT
* @pfft: Pointer to Spectral Phyerr FFT
@@ -915,66 +884,6 @@
*/
void target_if_sptrl_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops);
-/* Init's network namespace */
-extern struct net init_net;
-
-/**
- * target_if_spectral_init_netlink() - Initialize netlink data structures for
- * spectral module
- * @spectral : Pointer to spectral internal structure
- *
- * Return: Success/Failure
- */
-int target_if_spectral_init_netlink(struct target_if_spectral *spectral);
-
-/**
- * target_if_spectral_init_netlink() - De-initialize netlink data structures for
- * spectral module
- * @spectral : Pointer to spectral internal structure
- *
- * Return: Success/Failure
- */
-int target_if_spectral_destroy_netlink(struct target_if_spectral *spectral);
-
-/**
- * target_if_spectral_unicast_msg() - Passes unicast spectral message to host
- * @spectral : Pointer to spectral internal structure
- *
- * Return: void
- */
-void target_if_spectral_unicast_msg(struct target_if_spectral *spectral);
-
-/**
- * target_if_spectral_bcast_msg() - Passes broadcast spectral message to host
- * @spectral : Pointer to spectral internal structure
- *
- * Return: void
- */
-void target_if_spectral_bcast_msg(struct target_if_spectral *spectral);
-
-/**
- * target_if_spectral_prep_skb() - Prepare socket buffer
- * @spectral : Pointer to spectral internal structure
- *
- * Prepare socket buffer to send the data to application layer
- *
- * Return: void
- */
-void target_if_spectral_prep_skb(struct target_if_spectral *spectral);
-
-/**
- * target_if_spectral_skb_dequeue() - Dequeue all the spectral queued socket
- * buffers
- * @data : unsigned long pointer to spectral internal structure.
- * Have to be typecasted to struct target_if_spectral pointer type.
- *
- * Dequeue all the spectral queued socket buffers queued.
- * Broadcasts spectral data after dequeing each sk_buff.
- *
- * Return: void
- */
-void target_if_spectral_skb_dequeue(void *data);
-
/**
* target_if_spectral_create_samp_msg() - Create the spectral samp message
* @spectral : Pointer to spectral internal structure
@@ -1164,25 +1073,6 @@
struct spectral_search_fft_info_gen3 *p_fft_info);
/**
- * target_if_send_phydata() - Send Spectral PHY data over netlink
- * @pdev: Pointer to pdev
- * @sock: Netlink socket to use
- * @nbuf: Network buffer containing PHY data to send
- *
- * Return: 0 on success, negative value on failure
- */
-static inline uint32_t target_if_send_phydata(
- struct wlan_objmgr_pdev *pdev,
- struct sock *sock, qdf_nbuf_t nbuf)
-{
- struct wlan_objmgr_psoc *psoc = NULL;
-
- psoc = wlan_pdev_get_psoc(pdev);
- return psoc->soc_cb.rx_ops.sptrl_rx_ops.sptrlro_send_phydata(pdev,
- sock, nbuf);
-}
-
-/**
* get_target_if_spectral_handle_from_pdev() - Get handle to target_if internal
* Spectral data
* @pdev: Pointer to pdev
diff --git a/target_if/spectral/target_if_spectral_netlink.c b/target_if/spectral/target_if_spectral_netlink.c
index c4a5484..4fea8dd 100644
--- a/target_if/spectral/target_if_spectral_netlink.c
+++ b/target_if/spectral/target_if_spectral_netlink.c
@@ -27,162 +27,6 @@
#include <wlan_osif_priv.h>
#include <reg_services_public_struct.h>
-#ifdef SPECTRAL_USE_NETLINK_SOCKETS
-struct sock *target_if_spectral_nl_sock;
-static atomic_t spectral_nl_users = ATOMIC_INIT(0);
-
-#if (KERNEL_VERSION(2, 6, 31) > LINUX_VERSION_CODE)
-void
-target_if_spectral_nl_data_ready(struct sock *sk, int len)
-{
- spectral_debug("%d", __LINE__);
-}
-
-#else
-void
-target_if_spectral_nl_data_ready(struct sk_buff *skb)
-{
- spectral_debug("%d", __LINE__);
-}
-#endif /* VERSION */
-
-/**
- * target_if_spectral_init_nl_cfg() - Initialize netlink kernel
- * configuration parameters
- * @spectral : Pointer to netlink_kernel_cfg
- *
- * Initialize netlink kernel configuration parameters required
- * for spectral module
- *
- * Return: None
- */
-#if KERNEL_VERSION(3, 6, 0) <= LINUX_VERSION_CODE
-static void
-target_if_spectral_init_nl_cfg(struct netlink_kernel_cfg *cfg)
-{
- cfg->groups = 1;
- cfg->input = target_if_spectral_nl_data_ready;
-}
-#else
-static void
-target_if_spectral_init_nl_cfg(struct netlink_kernel_cfg *cfg)
-{
-}
-#endif
-
-/**
- * target_if_spectral_create_nl_sock() - Create Netlink socket
- * @spectral : Pointer to netlink_kernel_cfg
- *
- * Create Netlink socket required for spectral module
- *
- * Return: None
- */
-#if KERNEL_VERSION(3, 7, 0) <= LINUX_VERSION_CODE
-static void
-target_if_spectral_create_nl_sock(struct netlink_kernel_cfg *cfg)
-{
- target_if_spectral_nl_sock =
- (struct sock *)netlink_kernel_create(&init_net,
- NETLINK_ATHEROS, cfg);
-}
-#elif KERNEL_VERSION(3, 6, 0) <= LINUX_VERSION_CODE
-static void
-target_if_spectral_create_nl_sock(struct netlink_kernel_cfg *cfg)
-{
- target_if_spectral_nl_sock =
- (struct sock *)netlink_kernel_create(&init_net,
- NETLINK_ATHEROS,
- THIS_MODULE, cfg);
-}
-#elif (KERNEL_VERSION(2, 6, 31) > LINUX_VERSION_CODE)
-static void
-target_if_spectral_create_nl_sock(struct netlink_kernel_cfg *cfg)
-{
- target_if_spectral_nl_sock =
- (struct sock *)netlink_kernel_create(
- NETLINK_ATHEROS, 1,
- &target_if_spectral_nl_data_ready,
- THIS_MODULE);
-}
-#else
-#if (KERNEL_VERSION(3, 10, 0) <= LINUX_VERSION_CODE)
-static void
-target_if_spectral_create_nl_sock(struct netlink_kernel_cfg *cfg)
-{
- memset(cfg, 0, sizeof(*cfg));
- cfg->groups = 1;
- cfg->input = &target_if_spectral_nl_data_ready;
- target_if_spectral_nl_sock =
- (struct sock *)netlink_kernel_create(&init_net,
- NETLINK_ATHEROS, cfg);
-}
-#else
-static void
-target_if_spectral_create_nl_sock(struct netlink_kernel_cfg *cfg)
-{
- target_if_spectral_nl_sock =
- (struct sock *)netlink_kernel_create(
- &init_net,
- NETLINK_ATHEROS, 1,
- &target_if_spectral_nl_data_ready,
- NULL, THIS_MODULE);
-}
-#endif
-#endif
-
-int
-target_if_spectral_init_netlink(struct target_if_spectral *spectral)
-{
- struct netlink_kernel_cfg cfg;
-
- memset(&cfg, 0, sizeof(cfg));
-
- target_if_spectral_init_nl_cfg(&cfg);
-
- if (!spectral) {
- spectral_err("sc_spectral is NULL");
- return -EIO;
- }
-
- spectral->spectral_sent_msg = 0;
-
- if (!target_if_spectral_nl_sock) {
- target_if_spectral_create_nl_sock(&cfg);
-
- if (!target_if_spectral_nl_sock) {
- spectral_err("NETLINK_KERNEL_CREATE FAILED");
- return -ENODEV;
- }
- }
- atomic_inc(&spectral_nl_users);
- spectral->spectral_sock = target_if_spectral_nl_sock;
-
- if ((!spectral) || (!spectral->spectral_sock)) {
- spectral_err("NULL pointers (spectral=%d) (sock=%d)",
- (!spectral),
- (!spectral->spectral_sock));
- return -ENODEV;
- }
- if (!spectral->spectral_skb)
- spectral_err("%d NULL SKB", __LINE__);
-
- return 0;
-}
-
-int
-target_if_spectral_destroy_netlink(struct target_if_spectral *spectral)
-{
- spectral->spectral_sock = NULL;
- if (atomic_dec_and_test(&spectral_nl_users)) {
- sock_release(target_if_spectral_nl_sock->sk_socket);
- target_if_spectral_nl_sock = NULL;
- }
- return 0;
-}
-
-#endif /* SPECTRAL_USE_NETLINK_SOCKETS */
-
static void
target_if_spectral_process_noise_pwr_report(
struct target_if_spectral *spectral,
@@ -277,22 +121,21 @@
int temp_samp_msg_len = 0;
- static struct spectral_samp_msg spec_samp_msg;
+ struct spectral_samp_msg *spec_samp_msg;
- struct spectral_samp_msg *msg = NULL;
struct spectral_samp_data *data = NULL;
uint8_t *bin_pwr_data = NULL;
struct spectral_classifier_params *cp = NULL;
struct spectral_classifier_params *pcp = NULL;
struct target_if_spectral_ops *p_sops = NULL;
- struct target_if_spectral_skb_event *sp_skb_event = NULL;
-
-#ifdef SPECTRAL_USE_NETLINK_SOCKETS
static int samp_msg_index;
-#endif
+
+ spec_samp_msg = (struct spectral_samp_msg *)spectral->nl_cb.get_nbuff(
+ spectral->pdev_obj);
+ if (!spec_samp_msg)
+ return;
p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral);
-
temp_samp_msg_len = sizeof(struct spectral_samp_msg) -
(MAX_NUM_BINS * sizeof(uint8_t));
temp_samp_msg_len += (params->pwr_count * sizeof(uint8_t));
@@ -301,47 +144,45 @@
(params->pwr_count_sec80 * sizeof(uint8_t));
bin_pwr_data = params->bin_pwr_data;
- memset(&spec_samp_msg, 0, sizeof(struct spectral_samp_msg));
+ data = &spec_samp_msg->samp_data;
- data = &spec_samp_msg.samp_data;
+ spec_samp_msg->signature = SPECTRAL_SIGNATURE;
+ spec_samp_msg->freq = params->freq;
+ spec_samp_msg->freq_loading = params->freq_loading;
+ spec_samp_msg->samp_data.spectral_data_len = params->datalen;
+ spec_samp_msg->samp_data.spectral_rssi = params->rssi;
+ spec_samp_msg->samp_data.ch_width = spectral->ch_width;
- spec_samp_msg.signature = SPECTRAL_SIGNATURE;
- spec_samp_msg.freq = params->freq;
- spec_samp_msg.freq_loading = params->freq_loading;
- spec_samp_msg.samp_data.spectral_data_len = params->datalen;
- spec_samp_msg.samp_data.spectral_rssi = params->rssi;
- spec_samp_msg.samp_data.ch_width = spectral->ch_width;
-
- spec_samp_msg.samp_data.spectral_combined_rssi =
+ spec_samp_msg->samp_data.spectral_combined_rssi =
(uint8_t)params->rssi;
- spec_samp_msg.samp_data.spectral_upper_rssi = params->upper_rssi;
- spec_samp_msg.samp_data.spectral_lower_rssi = params->lower_rssi;
+ spec_samp_msg->samp_data.spectral_upper_rssi = params->upper_rssi;
+ spec_samp_msg->samp_data.spectral_lower_rssi = params->lower_rssi;
- OS_MEMCPY(spec_samp_msg.samp_data.spectral_chain_ctl_rssi,
+ OS_MEMCPY(spec_samp_msg->samp_data.spectral_chain_ctl_rssi,
params->chain_ctl_rssi, sizeof(params->chain_ctl_rssi));
- OS_MEMCPY(spec_samp_msg.samp_data.spectral_chain_ext_rssi,
+ OS_MEMCPY(spec_samp_msg->samp_data.spectral_chain_ext_rssi,
params->chain_ext_rssi, sizeof(params->chain_ext_rssi));
- spec_samp_msg.samp_data.spectral_bwinfo = params->bwinfo;
- spec_samp_msg.samp_data.spectral_tstamp = params->tstamp;
- spec_samp_msg.samp_data.spectral_max_index = params->max_index;
+ spec_samp_msg->samp_data.spectral_bwinfo = params->bwinfo;
+ spec_samp_msg->samp_data.spectral_tstamp = params->tstamp;
+ spec_samp_msg->samp_data.spectral_max_index = params->max_index;
/* Classifier in user space needs access to these */
- spec_samp_msg.samp_data.spectral_lower_max_index =
+ spec_samp_msg->samp_data.spectral_lower_max_index =
params->max_lower_index;
- spec_samp_msg.samp_data.spectral_upper_max_index =
+ spec_samp_msg->samp_data.spectral_upper_max_index =
params->max_upper_index;
- spec_samp_msg.samp_data.spectral_nb_lower = params->nb_lower;
- spec_samp_msg.samp_data.spectral_nb_upper = params->nb_upper;
- spec_samp_msg.samp_data.spectral_last_tstamp = params->last_tstamp;
- spec_samp_msg.samp_data.spectral_max_mag = params->max_mag;
- spec_samp_msg.samp_data.bin_pwr_count = params->pwr_count;
- spec_samp_msg.samp_data.lb_edge_extrabins = spectral->lb_edge_extrabins;
- spec_samp_msg.samp_data.rb_edge_extrabins = spectral->rb_edge_extrabins;
- spec_samp_msg.samp_data.spectral_combined_rssi = params->rssi;
- spec_samp_msg.samp_data.spectral_max_scale = params->max_exp;
-
-#ifdef SPECTRAL_USE_NETLINK_SOCKETS
+ spec_samp_msg->samp_data.spectral_nb_lower = params->nb_lower;
+ spec_samp_msg->samp_data.spectral_nb_upper = params->nb_upper;
+ spec_samp_msg->samp_data.spectral_last_tstamp = params->last_tstamp;
+ spec_samp_msg->samp_data.spectral_max_mag = params->max_mag;
+ spec_samp_msg->samp_data.bin_pwr_count = params->pwr_count;
+ spec_samp_msg->samp_data.lb_edge_extrabins =
+ spectral->lb_edge_extrabins;
+ spec_samp_msg->samp_data.rb_edge_extrabins =
+ spectral->rb_edge_extrabins;
+ spec_samp_msg->samp_data.spectral_combined_rssi = params->rssi;
+ spec_samp_msg->samp_data.spectral_max_scale = params->max_exp;
/*
* This is a dirty hack to get the Windows build pass.
@@ -357,11 +198,10 @@
*
*/
- spec_samp_msg.samp_data.noise_floor = params->noise_floor;
-#endif /* SPECTRAL_USE_NETLINK_SOCKETS */
+ spec_samp_msg->samp_data.noise_floor = params->noise_floor;
/* Classifier in user space needs access to these */
- cp = &spec_samp_msg.samp_data.classifier_params;
+ cp = &spec_samp_msg->samp_data.classifier_params;
pcp = ¶ms->classifier_params;
OS_MEMCPY(cp, pcp, sizeof(struct spectral_classifier_params));
@@ -369,23 +209,22 @@
SPECTRAL_MESSAGE_COPY_CHAR_ARRAY(&data->bin_pwr[0],
bin_pwr_data, params->pwr_count);
-#ifdef SPECTRAL_USE_NETLINK_SOCKETS
- spec_samp_msg.vhtop_ch_freq_seg1 = params->vhtop_ch_freq_seg1;
- spec_samp_msg.vhtop_ch_freq_seg2 = params->vhtop_ch_freq_seg2;
+ spec_samp_msg->vhtop_ch_freq_seg1 = params->vhtop_ch_freq_seg1;
+ spec_samp_msg->vhtop_ch_freq_seg2 = params->vhtop_ch_freq_seg2;
if (spectral->ch_width == CH_WIDTH_160MHZ) {
- spec_samp_msg.samp_data.spectral_rssi_sec80 =
+ spec_samp_msg->samp_data.spectral_rssi_sec80 =
params->rssi_sec80;
- spec_samp_msg.samp_data.noise_floor_sec80 =
+ spec_samp_msg->samp_data.noise_floor_sec80 =
params->noise_floor_sec80;
- spec_samp_msg.samp_data.spectral_data_len_sec80 =
+ spec_samp_msg->samp_data.spectral_data_len_sec80 =
params->datalen_sec80;
- spec_samp_msg.samp_data.spectral_max_index_sec80 =
+ spec_samp_msg->samp_data.spectral_max_index_sec80 =
params->max_index_sec80;
- spec_samp_msg.samp_data.spectral_max_mag_sec80 =
+ spec_samp_msg->samp_data.spectral_max_mag_sec80 =
params->max_mag_sec80;
- spec_samp_msg.samp_data.bin_pwr_count_sec80 =
+ spec_samp_msg->samp_data.bin_pwr_count_sec80 =
params->pwr_count_sec80;
SPECTRAL_MESSAGE_COPY_CHAR_ARRAY(&data->bin_pwr_sec80[0],
(params->bin_pwr_data_sec80),
@@ -396,238 +235,16 @@
* secondary 80 data at this point.
*/
}
-#endif /* SPECTRAL_USE_NETLINK_SOCKETS */
target_if_spectral_init_interf_list(data, params);
-
-#ifdef SPECTRAL_USE_NETLINK_SOCKETS
- target_if_spectral_prep_skb(spectral);
- if (spectral->spectral_skb) {
- p_sops->get_mac_address(spectral, spec_samp_msg.macaddr);
- spectral->spectral_nlh =
- (struct nlmsghdr *)spectral->spectral_skb->data;
- memcpy(NLMSG_DATA(spectral->spectral_nlh),
- &spec_samp_msg, sizeof(struct spectral_samp_msg));
- msg = (struct spectral_samp_msg *)NLMSG_DATA(
- spectral->spectral_nlh);
- /*
- * Broadcast spectral data only
- * if it is a edma supported device
- */
- if (!spectral->sc_spectral_non_edma)
- target_if_spectral_bcast_msg(spectral);
- samp_msg_index++;
- }
-
- /*
- * Check if the device is non-edma and follow the required broadcast
- * path if true
- */
- if (spectral->sc_spectral_non_edma) {
- /*
- * Allocating memory for the queue entity to
- * hold the spectral socket buffer
- */
- sp_skb_event = (struct target_if_spectral_skb_event
- *)qdf_mem_malloc(
- sizeof(
- struct target_if_spectral_skb_event));
-
- if (sp_skb_event) {
- OS_MEMZERO(sp_skb_event,
- sizeof(struct target_if_spectral_skb_event));
- sp_skb_event->sp_skb = spectral->spectral_skb;
- sp_skb_event->sp_nlh = spectral->spectral_nlh;
- spectral->spectral_skb = NULL;
- spectral->spectral_nlh = NULL;
-
- /*
- * Queue spectral socket buffers to be broadcasted
- * outside irq lock
- */
- qdf_spin_lock(&spectral->spectral_skbqlock);
- STAILQ_INSERT_TAIL(&spectral->spectral_skbq,
- sp_skb_event, spectral_skb_list);
- qdf_spin_unlock(&spectral->spectral_skbqlock);
- }
- }
-#else
- /*
- * call the indicate function to pass the data to the net layer
- * Windows will pass to a spectral WIN32 service
- */
- msg = (struct spectral_samp_msg *)qdf_mem_malloc(
- sizeof(struct spectral_samp_msg));
- if (msg) {
- OS_MEMCPY(msg, &spec_samp_msg,
- sizeof(struct spectral_samp_msg));
- ath_spectral_indicate(params->sc, (void *)msg,
- sizeof(struct spectral_samp_msg));
- OS_FREE(msg);
- msg = NULL;
- } else {
- spectral_err("No buffer");
- }
-#endif /* SPECTRAL_USE_NETLINK_SOCKETS */
+ p_sops->get_mac_address(spectral, spec_samp_msg->macaddr);
if (spectral->sc_spectral_noise_pwr_cal)
target_if_spectral_process_noise_pwr_report(
- spectral, &spec_samp_msg);
-}
+ spectral, spec_samp_msg);
-#ifdef SPECTRAL_USE_NETLINK_SOCKETS
-
-void
-target_if_spectral_prep_skb(struct target_if_spectral *spectral)
-{
- spectral->spectral_skb = dev_alloc_skb(MAX_SPECTRAL_PAYLOAD);
-
- if (spectral->spectral_skb) {
- skb_put(spectral->spectral_skb, MAX_SPECTRAL_PAYLOAD);
- spectral->spectral_nlh =
- (struct nlmsghdr *)spectral->spectral_skb->data;
-
- OS_MEMZERO(spectral->spectral_nlh,
- sizeof(*spectral->spectral_nlh));
-
- /*
- * Possible bug that size of struct spectral_samp_msg and
- * SPECTRAL_MSG differ by 3 bytes so we miss 3 bytes
- */
-
- spectral->spectral_nlh->nlmsg_len =
- NLMSG_SPACE(sizeof(struct spectral_samp_msg));
- spectral->spectral_nlh->nlmsg_pid = 0;
- spectral->spectral_nlh->nlmsg_flags = 0;
- } else {
- spectral->spectral_skb = NULL;
- spectral->spectral_nlh = NULL;
- }
-}
-
-#if (KERNEL_VERSION(2, 6, 31) > LINUX_VERSION_CODE)
-static inline void
-target_if_init_spectral_skb_dst_pid(
- struct target_if_spectral *spectral)
-{
- NETLINK_CB(spectral->spectral_skb).dst_pid =
- spectral->spectral_pid;
-}
-#else
-static inline void
-target_if_init_spectral_skb_dst_pid(
- struct target_if_spectral *spectral)
-{
-}
-#endif /* VERSION - field depracated by newer kernel */
-
-#if KERNEL_VERSION(3, 7, 0) > LINUX_VERSION_CODE
-static inline void
-target_if_init_spectral_skb_pid_portid(
- struct target_if_spectral *spectral)
-{
- NETLINK_CB(spectral->spectral_skb).pid = 0; /* from kernel */
-}
-#else
-static inline void
-target_if_init_spectral_skb_pid_portid(
- struct target_if_spectral *spectral)
-{
- NETLINK_CB(spectral->spectral_skb).portid = 0; /* from kernel */
-}
-#endif
-
-void
-target_if_spectral_unicast_msg(struct target_if_spectral *spectral)
-{
- if (!spectral) {
- spectral_err("Spectral is NULL");
- return;
- }
-
- if (!spectral->spectral_sock) {
- spectral_err("Spectral Socket is invalid");
- dev_kfree_skb(spectral->spectral_skb);
- spectral->spectral_skb = NULL;
- return;
- }
-
- if (spectral->spectral_skb) {
- target_if_init_spectral_skb_dst_pid(spectral);
-
- target_if_init_spectral_skb_pid_portid(spectral);
-
- /* to mcast group 1<<0 */
- NETLINK_CB(spectral->spectral_skb).dst_group = 0;
-
- netlink_unicast(spectral->spectral_sock,
- spectral->spectral_skb,
- spectral->spectral_pid, MSG_DONTWAIT);
- }
-}
-
-void
-target_if_spectral_bcast_msg(struct target_if_spectral *spectral)
-{
-#if (KERNEL_VERSION(2, 6, 31) >= LINUX_VERSION_CODE)
- fd_set write_set;
-#endif
- struct spectral_samp_msg *msg = NULL;
- struct nlmsghdr *nlh = NULL;
- int status;
-
-#if (KERNEL_VERSION(2, 6, 31) >= LINUX_VERSION_CODE)
- FD_ZERO(&write_set);
-#endif
-
- if (!spectral)
- return;
-
- if (!spectral->spectral_sock) {
- dev_kfree_skb(spectral->spectral_skb);
- spectral->spectral_skb = NULL;
- return;
- }
-
- if (!spectral->spectral_skb)
- return;
-
- nlh = (struct nlmsghdr *)spectral->spectral_skb->data;
- msg = (struct spectral_samp_msg *)NLMSG_DATA(spectral->spectral_nlh);
- status = target_if_send_phydata(spectral->pdev_obj,
- spectral->spectral_sock,
- spectral->spectral_skb);
- if (status == 0)
+ if (spectral->send_phy_data(spectral->pdev_obj) == 0)
spectral->spectral_sent_msg++;
- /* netlink will have freed the skb */
- if (spectral->spectral_skb)
- spectral->spectral_skb = NULL;
+ samp_msg_index++;
}
-
-void
-target_if_spectral_skb_dequeue(void *data)
-{
- struct target_if_spectral *spectral = (struct target_if_spectral *)data;
- struct target_if_spectral_skb_event *sp_skb_event = NULL;
-
- qdf_spin_lock(&spectral->spectral_skbqlock);
- /* Deque all the spectral socket buffers queued */
- while (!STAILQ_EMPTY(&spectral->spectral_skbq)) {
- sp_skb_event = STAILQ_FIRST(&spectral->spectral_skbq);
- if (sp_skb_event) {
- spectral->spectral_skb = sp_skb_event->sp_skb;
- spectral->spectral_nlh = sp_skb_event->sp_nlh;
- STAILQ_REMOVE_HEAD(&spectral->spectral_skbq,
- spectral_skb_list);
- qdf_spin_unlock(&spectral->spectral_skbqlock);
- OS_FREE(sp_skb_event);
- /* Broadcast spectral data after dequeing */
- target_if_spectral_bcast_msg(spectral);
- qdf_spin_lock(&spectral->spectral_skbqlock);
- }
- }
- qdf_spin_unlock(&spectral->spectral_skbqlock);
-}
-
-#endif /* SPECTRAL_USE_NETLINK_SOCKETS */
diff --git a/target_if/spectral/target_if_spectral_phyerr.c b/target_if/spectral/target_if_spectral_phyerr.c
index 21b1443..05a36f7 100644
--- a/target_if/spectral/target_if_spectral_phyerr.c
+++ b/target_if/spectral/target_if_spectral_phyerr.c
@@ -88,13 +88,12 @@
uint8_t *data, uint32_t datalen)
{
int status = true;
+ void *nl_data = spectral->nl_cb.get_nbuff(spectral->pdev_obj);
- target_if_spectral_prep_skb(spectral);
- if (spectral->spectral_skb) {
- spectral->spectral_nlh =
- (struct nlmsghdr *)spectral->spectral_skb->data;
- memcpy(NLMSG_DATA(spectral->spectral_nlh), data, datalen);
- target_if_spectral_bcast_msg(spectral);
+ if (nl_data) {
+ memcpy(nl_data, data, datalen);
+ if (spectral->send_phy_data(spectral->pdev_obj) == 0)
+ spectral->spectral_sent_msg++;
} else {
status = false;
}
@@ -1110,7 +1109,7 @@
ptlv->length;
if (curr_tlv_complete_size > bytes_remaining) {
- spectral_err("Current indicated complete TLV size %u greater than number of bytes remaining to be processed %u",
+ spectral_err("TLV size %d greater than number of bytes remaining %d",
curr_tlv_complete_size, bytes_remaining);
return -EPERM;
}
diff --git a/umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h b/umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h
index 6104409..8f04bf5 100644
--- a/umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h
+++ b/umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h
@@ -334,6 +334,8 @@
* @sptrlto_clear_chaninfo: Clear channel information
* @sptrlto_get_spectral_capinfo: Get Spectral capability information
* @sptrlto_get_spectral_diagstats: Get Spectral diagnostic statistics
+ * @sptrlto_register_netlink_cb: Register Spectral Netlink callbacks
+ * @sptrlto_use_nl_bcast: Get whether to use Netlink broadcast/unicast
**/
struct wlan_lmac_if_sptrl_tx_ops {
void *(*sptrlto_pdev_spectral_init)(struct wlan_objmgr_pdev *pdev);
@@ -358,6 +360,10 @@
void (*sptrlto_register_wmi_spectral_cmd_ops)(
struct wlan_objmgr_pdev *pdev,
struct wmi_spectral_cmd_ops *cmd_ops);
+ void (*sptrlto_register_netlink_cb)(
+ struct wlan_objmgr_pdev *pdev,
+ struct spectral_nl_cb *nl_cb);
+ bool (*sptrlto_use_nl_bcast)(struct wlan_objmgr_pdev *pdev);
};
#endif /* WLAN_CONV_SPECTRAL_ENABLE */
@@ -920,12 +926,9 @@
/**
* struct wlan_lmac_if_sptrl_rx_ops - Spectral south bound Rx operations
*
- * @sptrl_send_phydata: Send Spectral PHY Data
* @sptrlro_get_target_handle: Get Spectral handle for target/LMAC private data
*/
struct wlan_lmac_if_sptrl_rx_ops {
- int (*sptrlro_send_phydata)(struct wlan_objmgr_pdev *pdev,
- struct sock *sock, qdf_nbuf_t nbuf);
void * (*sptrlro_get_target_handle)(struct wlan_objmgr_pdev *pdev);
int16_t (*sptrlro_vdev_get_chan_freq)(struct wlan_objmgr_vdev *vdev);
enum phy_ch_width (*sptrlro_vdev_get_ch_width)(