qcacmn: Make RX path changes for Agile Spectral

Change Spectral report processing logic to handle
Agile Spectral reports. 160 MHz state machine is not
affected by Agile Spectral reports.

CRs-Fixed: 2458359
Change-Id: Iead6427f57edddd61f7d64a961cc6d936d54ab9e
此提交包含在:
Edayilliam Jayadev
2019-06-18 19:20:11 +05:30
提交者 nshrivas
父節點 cff882eb52
當前提交 cd6f190963
共有 8 個檔案被更改,包括 367 行新增291 行删除

查看文件

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2017-2018 The Linux Foundation. All rights reserved.
* Copyright (c) 2011, 2017-2019 The Linux Foundation. All rights reserved.
*
*
* Permission to use, copy, modify, and/or distribute this software for
@@ -56,12 +56,16 @@ void os_if_spectral_netlink_init(struct wlan_objmgr_pdev *pdev);
/**
* os_if_spectral_prep_skb() - Prepare socket buffer
* @pdev : Pointer to pdev
* @smsg_type: Spectral scan message type
* @buf_type: Spectral report buffer type
*
* 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);
void *os_if_spectral_prep_skb(struct wlan_objmgr_pdev *pdev,
enum spectral_msg_type smsg_type,
enum spectral_msg_buf_type buf_type);
/**
* os_if_spectral_netlink_deinit() - De-initialize Spectral Netlink data

查看文件

@@ -26,6 +26,7 @@
#ifdef CNSS_GENL
#include <net/cnss_nl.h>
#endif
#include <wlan_cfg80211.h>
/**
* os_if_spectral_remove_nbuf_debug_entry() - Remove nbuf from nbuf debug table
@@ -161,14 +162,14 @@ os_if_spectral_init_nl(struct wlan_objmgr_pdev *pdev)
memset(&cfg, 0, sizeof(cfg));
if (!pdev) {
spectral_err("PDEV is NULL!");
osif_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!");
osif_err("PDEV SPECTRAL object is NULL!");
return -EINVAL;
}
os_if_spectral_init_nl_cfg(&cfg);
@@ -177,14 +178,14 @@ os_if_spectral_init_nl(struct wlan_objmgr_pdev *pdev)
os_if_spectral_create_nl_sock(&cfg);
if (!os_if_spectral_nl_sock) {
spectral_err("NETLINK_KERNEL_CREATE FAILED");
osif_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");
osif_err("ps->spectral_sock is NULL");
return -ENODEV;
}
atomic_inc(&spectral_nl_users);
@@ -205,14 +206,14 @@ os_if_spectral_destroy_netlink(struct wlan_objmgr_pdev *pdev)
struct pdev_spectral *ps = NULL;
if (!pdev) {
spectral_err("PDEV is NULL!");
osif_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!");
osif_err("PDEV SPECTRAL object is NULL!");
return -EINVAL;
}
ps->spectral_sock = NULL;
@@ -238,48 +239,79 @@ os_if_spectral_destroy_netlink(struct wlan_objmgr_pdev *pdev)
#endif
void *
os_if_spectral_prep_skb(struct wlan_objmgr_pdev *pdev)
os_if_spectral_prep_skb(struct wlan_objmgr_pdev *pdev,
enum spectral_msg_type smsg_type,
enum spectral_msg_buf_type buf_type)
{
struct pdev_spectral *ps = NULL;
struct nlmsghdr *spectral_nlh = NULL;
void *buf = NULL;
if (!pdev) {
spectral_err("PDEV is NULL!");
osif_err("PDEV is NULL!");
return NULL;
}
if (smsg_type >= SPECTRAL_MSG_TYPE_MAX) {
osif_err("Invalid Spectral message type %u", smsg_type);
return NULL;
}
if (buf_type >= SPECTRAL_MSG_BUF_TYPE_MAX) {
osif_err("Invalid Spectral message buffer type %u",
buf_type);
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 = qdf_nbuf_alloc(NULL, MAX_SPECTRAL_PAYLOAD, 0, 0, false);
if (!ps->skb) {
spectral_err("allocate skb (len=%u) failed",
MAX_SPECTRAL_PAYLOAD);
osif_err("PDEV SPECTRAL object is NULL!");
return NULL;
}
qdf_nbuf_put_tail(ps->skb, MAX_SPECTRAL_PAYLOAD);
spectral_nlh = (struct nlmsghdr *)ps->skb->data;
if (buf_type == SPECTRAL_MSG_BUF_NEW) {
QDF_ASSERT(!ps->skb[smsg_type]);
ps->skb[smsg_type] =
qdf_nbuf_alloc(NULL, MAX_SPECTRAL_PAYLOAD,
0, 0, false);
qdf_mem_zero(spectral_nlh, sizeof(*spectral_nlh));
if (!ps->skb[smsg_type]) {
osif_err("alloc skb (len=%u, msg_type=%u) failed",
MAX_SPECTRAL_PAYLOAD, smsg_type);
return NULL;
}
/*
* Possible bug that size of struct spectral_samp_msg and
* SPECTRAL_MSG differ by 3 bytes so we miss 3 bytes
*/
qdf_nbuf_put_tail(ps->skb[smsg_type], MAX_SPECTRAL_PAYLOAD);
spectral_nlh = (struct nlmsghdr *)ps->skb[smsg_type]->data;
spectral_nlh->nlmsg_len = NLMSG_SPACE(sizeof(struct spectral_samp_msg));
spectral_nlh->nlmsg_pid = 0;
spectral_nlh->nlmsg_flags = 0;
spectral_nlh->nlmsg_type = WLAN_NL_MSG_SPECTRAL_SCAN;
qdf_mem_zero(spectral_nlh, sizeof(*spectral_nlh));
qdf_mem_zero(NLMSG_DATA(spectral_nlh),
sizeof(struct spectral_samp_msg));
return NLMSG_DATA(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;
spectral_nlh->nlmsg_type = WLAN_NL_MSG_SPECTRAL_SCAN;
qdf_mem_zero(NLMSG_DATA(spectral_nlh),
sizeof(struct spectral_samp_msg));
buf = NLMSG_DATA(spectral_nlh);
} else if (buf_type == SPECTRAL_MSG_BUF_SAVED) {
QDF_ASSERT(ps->skb[smsg_type]);
spectral_nlh = (struct nlmsghdr *)ps->skb[smsg_type]->data;
buf = NLMSG_DATA(spectral_nlh);
} else {
osif_err("Failed to get spectral report buffer");
buf = NULL;
}
return buf;
}
#if (KERNEL_VERSION(2, 6, 31) > LINUX_VERSION_CODE)
@@ -319,91 +351,108 @@ os_if_init_spectral_skb_pid_portid(struct sk_buff *skb)
* os_if_spectral_nl_unicast_msg() - Sends unicast Spectral message to user
* space
* @pdev : Pointer to pdev
* @smsg_type: Spectral message type
*
* Return: void
*/
#ifndef CNSS_GENL
static int
os_if_spectral_nl_unicast_msg(struct wlan_objmgr_pdev *pdev)
os_if_spectral_nl_unicast_msg(struct wlan_objmgr_pdev *pdev,
enum spectral_msg_type smsg_type)
{
struct pdev_spectral *ps = NULL;
int status;
if (!pdev) {
spectral_err("PDEV is NULL!");
osif_err("PDEV is NULL!");
return -EINVAL;
}
if (smsg_type >= SPECTRAL_MSG_TYPE_MAX) {
osif_err("Invalid Spectral message type %u", smsg_type);
return -EINVAL;
}
ps = wlan_objmgr_pdev_get_comp_private_obj(pdev,
WLAN_UMAC_COMP_SPECTRAL);
if (!ps) {
spectral_err("PDEV SPECTRAL object is NULL!");
osif_err("PDEV SPECTRAL object is NULL!");
return -EINVAL;
}
if (!ps->skb) {
spectral_err("Socket buffer is null");
if (!ps->skb[smsg_type]) {
osif_err("Socket buffer is null, msg_type= %u", smsg_type);
return -EINVAL;
}
if (!ps->spectral_sock) {
spectral_err("Spectral Socket is invalid");
qdf_nbuf_free(ps->skb);
osif_err("Spectral Socket is invalid, msg_type= %u",
smsg_type);
qdf_nbuf_free(ps->skb[smsg_type]);
ps->skb[smsg_type] = NULL;
return -EINVAL;
}
os_if_init_spectral_skb_dst_pid(ps->skb, ps);
os_if_init_spectral_skb_dst_pid(ps->skb[smsg_type], ps);
os_if_init_spectral_skb_pid_portid(ps->skb);
os_if_init_spectral_skb_pid_portid(ps->skb[smsg_type]);
/* to mcast group 1<<0 */
NETLINK_CB(ps->skb).dst_group = 0;
NETLINK_CB(ps->skb[smsg_type]).dst_group = 0;
os_if_spectral_remove_nbuf_debug_entry(ps->skb);
os_if_spectral_remove_nbuf_debug_entry(ps->skb[smsg_type]);
status = netlink_unicast(ps->spectral_sock,
ps->skb,
ps->skb[smsg_type],
ps->spectral_pid, MSG_DONTWAIT);
/* clear the local copy */
ps->skb = NULL;
/* clear the local copy, free would be done by netlink layer */
ps->skb[smsg_type] = NULL;
return status;
}
#else
static int
os_if_spectral_nl_unicast_msg(struct wlan_objmgr_pdev *pdev)
os_if_spectral_nl_unicast_msg(struct wlan_objmgr_pdev *pdev,
enum spectral_msg_type smsg_type)
{
struct pdev_spectral *ps = NULL;
int status;
if (!pdev) {
spectral_err("PDEV is NULL!");
osif_err("PDEV is NULL!");
return -EINVAL;
}
if (smsg_type >= SPECTRAL_MSG_TYPE_MAX) {
osif_err("Invalid Spectral message type %u", smsg_type);
return -EINVAL;
}
ps = wlan_objmgr_pdev_get_comp_private_obj(pdev,
WLAN_UMAC_COMP_SPECTRAL);
if (!ps) {
spectral_err("PDEV SPECTRAL object is NULL!");
osif_err("PDEV SPECTRAL object is NULL!");
return -EINVAL;
}
if (!ps->skb) {
spectral_err("Socket buffer is null");
if (!ps->skb[smsg_type]) {
osif_err("Socket buffer is null, msg_type= %u", smsg_type);
return -EINVAL;
}
os_if_init_spectral_skb_pid_portid(ps->skb);
os_if_init_spectral_skb_pid_portid(ps->skb[smsg_type]);
os_if_spectral_remove_nbuf_debug_entry(ps->skb);
status = nl_srv_ucast(ps->skb, ps->spectral_pid, MSG_DONTWAIT,
WLAN_NL_MSG_SPECTRAL_SCAN, CLD80211_MCGRP_OEM_MSGS);
os_if_spectral_remove_nbuf_debug_entry(ps->skb[smsg_type]);
status = nl_srv_ucast(ps->skb[smsg_type], ps->spectral_pid,
MSG_DONTWAIT, WLAN_NL_MSG_SPECTRAL_SCAN,
CLD80211_MCGRP_OEM_MSGS);
if (status < 0)
spectral_err("failed to send to spectral scan app");
osif_err("failed to send to spectral scan app");
/* clear the local copy */
ps->skb = NULL;
/* clear the local copy, free would be done by netlink layer */
ps->skb[smsg_type] = NULL;
return status;
}
@@ -414,11 +463,13 @@ os_if_spectral_nl_unicast_msg(struct wlan_objmgr_pdev *pdev)
* os_if_spectral_nl_bcast_msg() - Sends broadcast Spectral message to user
* space
* @pdev : Pointer to pdev
* @smsg_type: Spectral message type
*
* Return: void
*/
static int
os_if_spectral_nl_bcast_msg(struct wlan_objmgr_pdev *pdev)
os_if_spectral_nl_bcast_msg(struct wlan_objmgr_pdev *pdev,
enum spectral_msg_type smsg_type)
{
#if (KERNEL_VERSION(2, 6, 31) >= LINUX_VERSION_CODE)
fd_set write_set;
@@ -431,34 +482,42 @@ os_if_spectral_nl_bcast_msg(struct wlan_objmgr_pdev *pdev)
#endif
if (!pdev) {
spectral_err("PDEV is NULL!");
osif_err("PDEV is NULL!");
return -EINVAL;
}
if (smsg_type >= SPECTRAL_MSG_TYPE_MAX) {
osif_err("Invalid Spectral message type %u", smsg_type);
return -EINVAL;
}
ps = wlan_objmgr_pdev_get_comp_private_obj(pdev,
WLAN_UMAC_COMP_SPECTRAL);
if (!ps) {
spectral_err("PDEV SPECTRAL object is NULL!");
osif_err("PDEV SPECTRAL object is NULL!");
return -EINVAL;
}
if (!ps->skb) {
spectral_err("Socket buffer is null");
if (!ps->skb[smsg_type]) {
osif_err("Socket buffer is null, msg_type= %u", smsg_type);
return -EINVAL;
}
if (!ps->spectral_sock) {
qdf_nbuf_free(ps->skb);
qdf_nbuf_free(ps->skb[smsg_type]);
ps->skb[smsg_type] = NULL;
return -EINVAL;
}
os_if_spectral_remove_nbuf_debug_entry(ps->skb);
os_if_spectral_remove_nbuf_debug_entry(ps->skb[smsg_type]);
status = netlink_broadcast(ps->spectral_sock,
ps->skb,
ps->skb[smsg_type],
0, 1, GFP_ATOMIC);
/* clear the local copy */
ps->skb = NULL;
/* clear the local copy, free would be done by netlink layer */
ps->skb[smsg_type] = NULL;
return status;
}
@@ -467,36 +526,44 @@ os_if_spectral_nl_bcast_msg(struct wlan_objmgr_pdev *pdev)
* os_if_spectral_free_skb() - Free spectral SAMP message skb
*
* @pdev : Pointer to pdev
* @smsg_type: Spectral message type
*
* Return: void
*/
static void
os_if_spectral_free_skb(struct wlan_objmgr_pdev *pdev)
os_if_spectral_free_skb(struct wlan_objmgr_pdev *pdev,
enum spectral_msg_type smsg_type)
{
struct pdev_spectral *ps = NULL;
if (!pdev) {
spectral_err("PDEV is NULL!");
osif_err("PDEV is NULL!");
return;
}
if (smsg_type >= SPECTRAL_MSG_TYPE_MAX) {
osif_err("Invalid Spectral message type %u", smsg_type);
return;
}
ps = wlan_objmgr_pdev_get_comp_private_obj(pdev,
WLAN_UMAC_COMP_SPECTRAL);
if (!ps) {
spectral_err("PDEV SPECTRAL object is NULL!");
osif_err("PDEV SPECTRAL object is NULL!");
return;
}
if (!ps->skb) {
spectral_err("Socket buffer is null");
if (!ps->skb[smsg_type]) {
osif_info("Socket buffer is null, msg_type= %u", smsg_type);
return;
}
/* Free buffer */
qdf_nbuf_free(ps->skb);
qdf_nbuf_free(ps->skb[smsg_type]);
/* clear the local copy */
ps->skb = NULL;
ps->skb[smsg_type] = NULL;
}
qdf_export_symbol(os_if_spectral_free_skb);
@@ -508,24 +575,24 @@ os_if_spectral_netlink_init(struct wlan_objmgr_pdev *pdev)
struct spectral_context *sptrl_ctx;
if (!pdev) {
spectral_err("PDEV is NULL!");
osif_err("PDEV is NULL!");
return;
}
sptrl_ctx = spectral_get_spectral_ctx_from_pdev(pdev);
if (!sptrl_ctx) {
spectral_err("Spectral context is NULL!");
osif_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.get_sbuff = 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.free_nbuff = os_if_spectral_free_skb;
nl_cb.free_sbuff = os_if_spectral_free_skb;
if (sptrl_ctx->sptrlc_register_netlink_cb)
sptrl_ctx->sptrlc_register_netlink_cb(pdev, &nl_cb);
@@ -535,20 +602,22 @@ qdf_export_symbol(os_if_spectral_netlink_init);
void os_if_spectral_netlink_deinit(struct wlan_objmgr_pdev *pdev)
{
struct spectral_context *sptrl_ctx;
enum spectral_msg_type msg_type = SPECTRAL_MSG_NORMAL_MODE;
if (!pdev) {
spectral_err("PDEV is NULL!");
osif_err("PDEV is NULL!");
return;
}
sptrl_ctx = spectral_get_spectral_ctx_from_pdev(pdev);
if (!sptrl_ctx) {
spectral_err("Spectral context is NULL!");
osif_err("Spectral context is NULL!");
return;
}
os_if_spectral_free_skb(pdev);
for (; msg_type < SPECTRAL_MSG_TYPE_MAX; msg_type++)
os_if_spectral_free_skb(pdev, msg_type);
if (sptrl_ctx->sptrlc_deregister_netlink_cb)
sptrl_ctx->sptrlc_deregister_netlink_cb(pdev);