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
这个提交包含在:
Shiva Krishna Pittala
2017-12-29 20:17:39 +05:30
提交者 snandini
父节点 82032dd2a4
当前提交 101778698b
修改 15 个文件,包含 696 行新增643 行删除

查看文件

@@ -1839,9 +1839,7 @@ target_if_spectral_detach(struct target_if_spectral *spectral)
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 @@ target_if_pdev_spectral_init(struct wlan_objmgr_pdev *pdev)
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 @@ target_if_pdev_spectral_init(struct wlan_objmgr_pdev *pdev)
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 @@ target_if_pdev_spectral_init(struct wlan_objmgr_pdev *pdev)
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 @@ target_if_stop_spectral_scan(struct wlan_objmgr_pdev *pdev)
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 @@ target_if_register_wmi_spectral_cmd_ops(struct wlan_objmgr_pdev *pdev,
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_sptrl_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
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 @@ void
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);

查看文件

@@ -59,10 +59,7 @@ QDF_PRINT_INFO(QDF_PRINT_IDX_SHARED, QDF_MODULE_ID_SPECTRAL, level, ## args)
#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 @@ QDF_PRINT_INFO(QDF_PRINT_IDX_SHARED, QDF_MODULE_ID_SPECTRAL, level, ## args)
/* 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 @@ struct wmi_spectral_cmd_ops {
* 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 @@ struct target_if_spectral {
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 @@ struct target_if_spectral {
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 target_if_samp_msg_params {
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 @@ uint32_t target_if_get_offset_swar_sec80(uint32_t channel_width);
*/
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
@@ -1163,25 +1072,6 @@ int target_if_process_sfft_report_gen3(
struct spectral_phyerr_fft_report_gen3 *p_fft_report,
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

查看文件

@@ -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 @@ target_if_spectral_create_samp_msg(struct target_if_spectral *spectral,
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 @@ target_if_spectral_create_samp_msg(struct target_if_spectral *spectral,
(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 @@ target_if_spectral_create_samp_msg(struct target_if_spectral *spectral,
*
*/
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 = &params->classifier_params;
OS_MEMCPY(cp, pcp, sizeof(struct spectral_classifier_params));
@@ -369,23 +209,22 @@ target_if_spectral_create_samp_msg(struct target_if_spectral *spectral,
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 @@ target_if_spectral_create_samp_msg(struct target_if_spectral *spectral,
* 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 */

查看文件

@@ -88,13 +88,12 @@ target_if_spectral_send_tlv_to_host(struct target_if_spectral *spectral,
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 @@ target_if_spectral_dump_phyerr_data_gen2(uint8_t *data, uint32_t datalen,
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;
}