qcacld-2.0: Add support to use generic netlink sockets for userspace apps
Currently user space communication functions[cnss diag, PTT socket app] in host driver uses netlink user sockets which is a security concern from Linux Android SE policies. Add support for to use netlink family cld80211 which uses generic netlink sockets. Change-Id: I4ea49ac6d7c9381212c93567fdc40f90e04dfba4 CRs-Fixed: 1112784 Bug: 32775496 Signed-off-by: Srinivas Girigowda <sgirigow@codeaurora.org>
This commit is contained in:
parent
1b8116f91b
commit
e1eb41fef5
|
@ -136,6 +136,10 @@ void hdd_ch_avoid_cb(void *hdd_context,void *indi_param);
|
|||
#include "tl_shim.h"
|
||||
#include "wlan_hdd_oemdata.h"
|
||||
|
||||
#ifdef CNSS_GENL
|
||||
#include <net/cnss_nl.h>
|
||||
#endif
|
||||
|
||||
#if defined(LINUX_QCMBR)
|
||||
#define SIOCIOCTLTX99 (SIOCDEVPRIVATE+13)
|
||||
#endif
|
||||
|
@ -17044,6 +17048,23 @@ void wlan_hdd_enable_roaming(hdd_adapter_t *pAdapter)
|
|||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* nl_srv_bcast_svc() - Wrapper function to send bcast msgs to SVC mcast group
|
||||
* @skb: sk buffer pointer
|
||||
*
|
||||
* Sends the bcast message to SVC multicast group with generic nl socket
|
||||
* if CNSS_GENL is enabled. Else, use the legacy netlink socket to send.
|
||||
*
|
||||
* Return: None
|
||||
*/
|
||||
static void nl_srv_bcast_svc(struct sk_buff *skb)
|
||||
{
|
||||
#ifdef CNSS_GENL
|
||||
nl_srv_bcast(skb, CLD80211_MCGRP_SVC_MSGS, WLAN_NL_MSG_SVC);
|
||||
#else
|
||||
nl_srv_bcast(skb);
|
||||
#endif
|
||||
}
|
||||
|
||||
void wlan_hdd_send_svc_nlink_msg(int type, void *data, int len)
|
||||
{
|
||||
|
@ -17106,7 +17127,7 @@ void wlan_hdd_send_svc_nlink_msg(int type, void *data, int len)
|
|||
return;
|
||||
}
|
||||
|
||||
nl_srv_bcast(skb);
|
||||
nl_srv_bcast_svc(skb);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -17343,7 +17364,6 @@ void hdd_stop_bus_bw_compute_timer(hdd_adapter_t *pAdapter)
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
|
||||
void wlan_hdd_check_sta_ap_concurrent_ch_intf(void *data)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Previously licensed under the ISC license by Qualcomm Atheros, Inc.
|
||||
*
|
||||
|
@ -48,6 +48,9 @@
|
|||
#include "vos_utils.h"
|
||||
#include "wma.h"
|
||||
#include "wlan_hdd_oemdata.h"
|
||||
#ifdef CNSS_GENL
|
||||
#include <net/cnss_nl.h>
|
||||
#endif
|
||||
|
||||
static struct hdd_context_s *pHddCtx;
|
||||
|
||||
|
@ -158,6 +161,26 @@ int iw_get_oem_data_cap(
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* nl_srv_ucast_oem() - Wrapper function to send ucast msgs to OEM
|
||||
* @skb: sk buffer pointer
|
||||
* @dst_pid: Destination PID
|
||||
* @flag: flags
|
||||
*
|
||||
* Sends the ucast message to OEM with generic nl socket if CNSS_GENL
|
||||
* is enabled. Else, use the legacy netlink socket to send.
|
||||
*
|
||||
* Return: None
|
||||
*/
|
||||
static void nl_srv_ucast_oem(struct sk_buff *skb, int dst_pid, int flag)
|
||||
{
|
||||
#ifdef CNSS_GENL
|
||||
nl_srv_ucast(skb, dst_pid, flag, WLAN_NL_MSG_OEM,
|
||||
CLD80211_MCGRP_OEM_MSGS);
|
||||
#else
|
||||
nl_srv_ucast(skb, dst_pid, flag);
|
||||
#endif
|
||||
}
|
||||
/**---------------------------------------------------------------------------
|
||||
|
||||
\brief send_oem_reg_rsp_nlink_msg() - send oem registration response
|
||||
|
@ -247,7 +270,7 @@ static void send_oem_reg_rsp_nlink_msg(void)
|
|||
"%s: sending App Reg Response length (%d) to process pid (%d)",
|
||||
__func__, aniHdr->length, pHddCtx->oem_pid);
|
||||
|
||||
(void)nl_srv_ucast(skb, pHddCtx->oem_pid, MSG_DONTWAIT);
|
||||
(void)nl_srv_ucast_oem(skb, pHddCtx->oem_pid, MSG_DONTWAIT);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -299,7 +322,7 @@ static void send_oem_err_rsp_nlink_msg(v_SINT_t app_pid, tANI_U8 error_code)
|
|||
"%s: sending oem error response to process pid (%d)",
|
||||
__func__, app_pid);
|
||||
|
||||
(void)nl_srv_ucast(skb, app_pid, MSG_DONTWAIT);
|
||||
(void)nl_srv_ucast_oem(skb, app_pid, MSG_DONTWAIT);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -367,7 +390,7 @@ void send_oem_data_rsp_msg(int length, tANI_U8 *oemDataRsp)
|
|||
"%s: sending Oem Data Response of len (%d) to process pid (%d)",
|
||||
__func__, length, pHddCtx->oem_pid);
|
||||
|
||||
(void)nl_srv_ucast(skb, pHddCtx->oem_pid, MSG_DONTWAIT);
|
||||
(void)nl_srv_ucast_oem(skb, pHddCtx->oem_pid, MSG_DONTWAIT);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -601,7 +624,7 @@ static int oem_process_channel_info_req_msg(int numOfChannels, char *chanList)
|
|||
"%s: sending channel info resp for num channels (%d) to pid (%d)",
|
||||
__func__, numOfChannels, pHddCtx->oem_pid);
|
||||
|
||||
(void)nl_srv_ucast(skb, pHddCtx->oem_pid, MSG_DONTWAIT);
|
||||
(void)nl_srv_ucast_oem(skb, pHddCtx->oem_pid, MSG_DONTWAIT);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -720,11 +743,202 @@ void hdd_SendPeerStatusIndToOemApp(v_MACADDR_t *peerMac,
|
|||
pPeerInfo->peer_chan_info.reg_info_2,
|
||||
pPeerInfo->reserved0);
|
||||
|
||||
(void)nl_srv_ucast(skb, pHddCtx->oem_pid, MSG_DONTWAIT);
|
||||
(void)nl_srv_ucast_oem(skb, pHddCtx->oem_pid, MSG_DONTWAIT);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef CNSS_GENL
|
||||
/*
|
||||
* Callback function invoked by Netlink service for all netlink
|
||||
* messages (from user space) addressed to WLAN_NL_MSG_OEM
|
||||
*/
|
||||
|
||||
/**
|
||||
* oem_msg_callback() - callback invoked by netlink service
|
||||
* @skb: skb with netlink message
|
||||
*
|
||||
* This function gets invoked by netlink service when a message
|
||||
* is received from user space addressed to WLAN_NL_MSG_OEM
|
||||
*
|
||||
* Return: zero on success
|
||||
* On error, error number will be returned.
|
||||
*/
|
||||
static int oem_msg_callback(tAniMsgHdr *msg_hdr, int len, int pid)
|
||||
{
|
||||
int ret;
|
||||
char *sign_str = NULL;
|
||||
|
||||
ret = wlan_hdd_validate_context(pHddCtx);
|
||||
if (0 != ret)
|
||||
return ret;
|
||||
|
||||
if (!msg_hdr) {
|
||||
hddLog(LOGE, FL("Message header null"));
|
||||
send_oem_err_rsp_nlink_msg(pid, OEM_ERR_NULL_MESSAGE_HEADER);
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
if (len < sizeof(tAniMsgHdr) + msg_hdr->length) {
|
||||
hddLog(LOGE, FL("Invalid msg len, len (%d), msg_hdr->len (%d)"),
|
||||
len, msg_hdr->length);
|
||||
send_oem_err_rsp_nlink_msg(pid,
|
||||
OEM_ERR_INVALID_MESSAGE_LENGTH);
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
switch (msg_hdr->type) {
|
||||
case ANI_MSG_APP_REG_REQ:
|
||||
/* Registration request is only allowed for Qualcomm Application */
|
||||
hddLog(LOG1, FL("Received App Req Req from App process pid(%d), len(%d)"),
|
||||
pid, msg_hdr->length);
|
||||
|
||||
sign_str = (char *)((char *)msg_hdr + sizeof(tAniMsgHdr));
|
||||
if ((OEM_APP_SIGNATURE_LEN == msg_hdr->length) &&
|
||||
(0 == strncmp(sign_str, OEM_APP_SIGNATURE_STR,
|
||||
OEM_APP_SIGNATURE_LEN))) {
|
||||
hddLog(LOG1, FL("Valid App Req Req from oem app process pid(%d)"),
|
||||
pid);
|
||||
|
||||
pHddCtx->oem_app_registered = TRUE;
|
||||
pHddCtx->oem_pid = pid;
|
||||
send_oem_reg_rsp_nlink_msg();
|
||||
} else {
|
||||
hddLog(LOGE, FL("Invalid signature in App Reg Request from pid(%d)"),
|
||||
pid);
|
||||
send_oem_err_rsp_nlink_msg(pid,
|
||||
OEM_ERR_INVALID_SIGNATURE);
|
||||
return -EPERM;
|
||||
}
|
||||
break;
|
||||
|
||||
case ANI_MSG_OEM_DATA_REQ:
|
||||
hddLog(LOG1, FL("Received Oem Data Request length(%d) from pid: %d"),
|
||||
msg_hdr->length, pid);
|
||||
|
||||
if ((!pHddCtx->oem_app_registered) ||
|
||||
(pid != pHddCtx->oem_pid)) {
|
||||
/* either oem app is not registered yet or pid is different */
|
||||
hddLog(LOGE, FL("OEM DataReq: app not registered(%d) or incorrect pid(%d)"),
|
||||
pHddCtx->oem_app_registered, pid);
|
||||
send_oem_err_rsp_nlink_msg(pid,
|
||||
OEM_ERR_APP_NOT_REGISTERED);
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
if ((!msg_hdr->length) || (OEM_DATA_REQ_SIZE < msg_hdr->length)) {
|
||||
hddLog(LOGE, FL("Invalid length (%d) in Oem Data Request"),
|
||||
msg_hdr->length);
|
||||
send_oem_err_rsp_nlink_msg(pid,
|
||||
OEM_ERR_INVALID_MESSAGE_LENGTH);
|
||||
return -EPERM;
|
||||
}
|
||||
oem_process_data_req_msg(msg_hdr->length,
|
||||
(char *) ((char *)msg_hdr +
|
||||
sizeof(tAniMsgHdr)));
|
||||
break;
|
||||
|
||||
case ANI_MSG_CHANNEL_INFO_REQ:
|
||||
hddLog(LOG1,
|
||||
FL("Received channel info request, num channel(%d) from pid: %d"),
|
||||
msg_hdr->length, pid);
|
||||
|
||||
if ((!pHddCtx->oem_app_registered) ||
|
||||
(pid != pHddCtx->oem_pid)) {
|
||||
/* either oem app is not registered yet or pid is different */
|
||||
hddLog(LOGE,
|
||||
FL("Chan InfoReq: app not registered(%d) or incorrect pid(%d)"),
|
||||
pHddCtx->oem_app_registered, pid);
|
||||
send_oem_err_rsp_nlink_msg(pid,
|
||||
OEM_ERR_APP_NOT_REGISTERED);
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
/* message length contains list of channel ids */
|
||||
if ((!msg_hdr->length) ||
|
||||
(WNI_CFG_VALID_CHANNEL_LIST_LEN < msg_hdr->length)) {
|
||||
hddLog(LOGE,
|
||||
FL("Invalid length (%d) in channel info request"),
|
||||
msg_hdr->length);
|
||||
send_oem_err_rsp_nlink_msg(pid,
|
||||
OEM_ERR_INVALID_MESSAGE_LENGTH);
|
||||
return -EPERM;
|
||||
}
|
||||
oem_process_channel_info_req_msg(msg_hdr->length,
|
||||
(char *)((char*)msg_hdr + sizeof(tAniMsgHdr)));
|
||||
break;
|
||||
|
||||
default:
|
||||
hddLog(LOGE,
|
||||
FL("Received Invalid message type (%d), length (%d)"),
|
||||
msg_hdr->type, msg_hdr->length);
|
||||
send_oem_err_rsp_nlink_msg(pid,
|
||||
OEM_ERR_INVALID_MESSAGE_TYPE);
|
||||
return -EPERM;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* oem_cmd_handler() - API to handle OEM commands
|
||||
* @data: Pointer to data
|
||||
* @data_len: length of the received data
|
||||
* @ctx: Pointer to the context
|
||||
* @pid: Process id
|
||||
*
|
||||
* This API handles the command from OEM application from user space and
|
||||
* send back event to user space if necessary.
|
||||
*
|
||||
* Return: None
|
||||
*/
|
||||
static void oem_cmd_handler(const void *data, int data_len, void *ctx, int pid)
|
||||
{
|
||||
tAniMsgHdr *msg_hdr;
|
||||
int ret;
|
||||
struct nlattr *tb[CLD80211_ATTR_MAX + 1];
|
||||
|
||||
ret = wlan_hdd_validate_context(pHddCtx);
|
||||
if (ret) {
|
||||
hddLog(LOGE, FL("hdd ctx validate fails"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (nla_parse(tb, CLD80211_ATTR_MAX, data, data_len, NULL)) {
|
||||
hddLog(LOGE, FL("Invalid ATTR"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!tb[CLD80211_ATTR_DATA]) {
|
||||
hddLog(LOGE, FL("attr ATTR_DATA failed"));
|
||||
return;
|
||||
}
|
||||
|
||||
msg_hdr = (tAniMsgHdr *)nla_data(tb[CLD80211_ATTR_DATA]);
|
||||
if (!msg_hdr) {
|
||||
hddLog(LOGE, FL("msg_hdr null"));
|
||||
send_oem_err_rsp_nlink_msg(pid, OEM_ERR_NULL_MESSAGE_HEADER);
|
||||
return;
|
||||
}
|
||||
oem_msg_callback(msg_hdr, nla_len(tb[CLD80211_ATTR_DATA]), pid);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* oem_activate_service() - API to register the oem command handler
|
||||
* @hdd_ctx: Pointer to HDD Context
|
||||
*
|
||||
* This API is used to register the oem app command handler. Argument
|
||||
* @pAdapter is given for prototype compatibility with legacy code.
|
||||
*
|
||||
* Return: 0
|
||||
*/
|
||||
int oem_activate_service(void *hdd_ctx)
|
||||
{
|
||||
pHddCtx = (struct hdd_context_s *) hdd_ctx;
|
||||
register_cld_cmd_cb(WLAN_NL_MSG_OEM, oem_cmd_handler, NULL);
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
/*
|
||||
* Callback function invoked by Netlink service for all netlink
|
||||
* messages (from user space) addressed to WLAN_NL_MSG_OEM
|
||||
|
@ -744,10 +958,10 @@ static int oem_msg_callback(struct sk_buff *skb)
|
|||
{
|
||||
struct nlmsghdr *nlh;
|
||||
tAniMsgHdr *msg_hdr;
|
||||
int ret;
|
||||
char *sign_str = NULL;
|
||||
nlh = (struct nlmsghdr *)skb->data;
|
||||
int ret;
|
||||
|
||||
nlh = (struct nlmsghdr *)skb->data;
|
||||
if (!nlh) {
|
||||
hddLog(LOGE, FL("Netlink header null"));
|
||||
return -EPERM;
|
||||
|
@ -886,20 +1100,18 @@ static int __oem_msg_callback(struct sk_buff *skb)
|
|||
an OEM application process.
|
||||
|
||||
\param -
|
||||
- pAdapter - pointer to HDD adapter
|
||||
- hdd_ctx: Pointer to HDD context
|
||||
|
||||
\return - 0 for success, non zero for failure
|
||||
|
||||
--------------------------------------------------------------------------*/
|
||||
int oem_activate_service(void *pAdapter)
|
||||
int oem_activate_service(void *hdd_ctx)
|
||||
{
|
||||
pHddCtx = (struct hdd_context_s*) pAdapter;
|
||||
pHddCtx = (struct hdd_context_s *) hdd_ctx;
|
||||
|
||||
/* Register the msg handler for msgs addressed to WLAN_NL_MSG_OEM */
|
||||
nl_srv_register(WLAN_NL_MSG_OEM, __oem_msg_callback);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Previously licensed under the ISC license by Qualcomm Atheros, Inc.
|
||||
*
|
||||
|
@ -66,8 +66,15 @@ void nl_srv_exit(void);
|
|||
#endif /* WLAN_KD_READY_NOTIFIER */
|
||||
int nl_srv_register(tWlanNlModTypes msg_type, nl_srv_msg_callback msg_handler);
|
||||
int nl_srv_unregister(tWlanNlModTypes msg_type, nl_srv_msg_callback msg_handler);
|
||||
int nl_srv_ucast(struct sk_buff * skb, int dst_pid, int flag);
|
||||
int nl_srv_bcast(struct sk_buff * skb);
|
||||
|
||||
#ifdef CNSS_GENL
|
||||
int nl_srv_ucast(struct sk_buff *skb, int dst_pid, int flag,
|
||||
int app_id, int mcgroup_id);
|
||||
int nl_srv_bcast(struct sk_buff *skb, int mcgroup_id, int app_id);
|
||||
#else
|
||||
int nl_srv_ucast(struct sk_buff *skb, int dst_pid, int flag);
|
||||
int nl_srv_bcast(struct sk_buff *skb);
|
||||
#endif
|
||||
int nl_srv_is_initialized(void);
|
||||
|
||||
#else
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Previously licensed under the ISC license by Qualcomm Atheros, Inc.
|
||||
*
|
||||
|
@ -93,7 +93,7 @@
|
|||
* Length : 4 bytes [LEN_PAYLOAD]
|
||||
* Payload : LEN_PAYLOAD bytes
|
||||
*/
|
||||
int ptt_sock_activate_svc(void *pAdapter);
|
||||
int ptt_sock_activate_svc(void *hdd_ctx);
|
||||
int ptt_sock_send_msg_to_app(tAniHdr *wmsg, int radio, int src_mod, int pid);
|
||||
|
||||
/*
|
||||
|
@ -110,6 +110,19 @@ typedef struct sAniAppRegReq {
|
|||
tAniNlModTypes type; // module id
|
||||
int pid; // process id
|
||||
} tAniNlAppRegReq;
|
||||
|
||||
/**
|
||||
* struct sptt_app_reg_req - PTT register request structure
|
||||
* @radio: Radio ID
|
||||
* @wmsg: ANI header
|
||||
*
|
||||
* payload structure received as nl data from PTT app/user space
|
||||
*/
|
||||
typedef struct sptt_app_reg_req {
|
||||
int radio;
|
||||
tAniHdr wmsg;
|
||||
} ptt_app_reg_req;
|
||||
|
||||
typedef struct sAniNlAppRegRsp {
|
||||
tAniHdr wniHdr; // Generic WNI msg header
|
||||
tAniNlAppRegReq regReq; // The original request msg
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2014-2016 The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2014-2017 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Previously licensed under the ISC license by Qualcomm Atheros, Inc.
|
||||
*
|
||||
|
@ -45,6 +45,9 @@
|
|||
#include <linux/rtc.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <vos_diag_core_log.h>
|
||||
#ifdef CNSS_GENL
|
||||
#include <net/cnss_nl.h>
|
||||
#endif
|
||||
#define LOGGING_TRACE(level, args...) \
|
||||
VOS_TRACE(VOS_MODULE_ID_HDD, level, ## args)
|
||||
|
||||
|
@ -52,7 +55,8 @@
|
|||
|
||||
#define ANI_NL_MSG_LOG_TYPE 89
|
||||
#define ANI_NL_MSG_READY_IND_TYPE 90
|
||||
#define MAX_LOGMSG_LENGTH 4096
|
||||
#define MAX_LOGMSG_LENGTH 2048
|
||||
#define MAX_SKBMSG_LENGTH 4096
|
||||
#define MAX_PKTSTATS_LENGTH 2048
|
||||
#define MAX_PKTSTATS_BUFF 16
|
||||
|
||||
|
@ -146,6 +150,7 @@ static struct pkt_stats_msg *gpkt_stats_buffers;
|
|||
/* PID of the APP to log the message */
|
||||
static int gapp_pid = INVALID_PID;
|
||||
|
||||
#ifndef CNSS_GENL
|
||||
/* Utility function to send a netlink message to an application
|
||||
* in user space
|
||||
*/
|
||||
|
@ -199,6 +204,7 @@ static int wlan_send_sock_msg_to_app(tAniHdr *wmsg, int radio,
|
|||
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* is_data_path_module() - To check for a Datapath module
|
||||
|
@ -466,6 +472,42 @@ static int pkt_stats_fill_headers(struct sk_buff *skb)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* nl_srv_bcast_diag() - Wrapper to send bcast msgs to diag events mcast grp
|
||||
* @skb: sk buffer pointer
|
||||
*
|
||||
* Sends the bcast message to diag events multicast group with generic nl socket
|
||||
* if CNSS_GENL is enabled. Else, use the legacy netlink socket to send.
|
||||
*
|
||||
* Return: zero on success, error code otherwise
|
||||
*/
|
||||
static int nl_srv_bcast_diag(struct sk_buff *skb)
|
||||
{
|
||||
#ifdef CNSS_GENL
|
||||
return nl_srv_bcast(skb, CLD80211_MCGRP_DIAG_EVENTS, ANI_NL_MSG_PUMAC);
|
||||
#else
|
||||
return nl_srv_bcast(skb);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* nl_srv_bcast_host_logs() - Wrapper to send bcast msgs to host logs mcast grp
|
||||
* @skb: sk buffer pointer
|
||||
*
|
||||
* Sends the bcast message to host logs multicast group with generic nl socket
|
||||
* if CNSS_GENL is enabled. Else, use the legacy netlink socket to send.
|
||||
*
|
||||
* Return: zero on success, error code otherwise
|
||||
*/
|
||||
static int nl_srv_bcast_host_logs(struct sk_buff *skb)
|
||||
{
|
||||
#ifdef CNSS_GENL
|
||||
return nl_srv_bcast(skb, CLD80211_MCGRP_HOST_LOGS, ANI_NL_MSG_LOG);
|
||||
#else
|
||||
return nl_srv_bcast(skb);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* pktlog_send_per_pkt_stats_to_user() - This function is used to send the per
|
||||
* packet statistics to the user
|
||||
|
@ -486,11 +528,11 @@ int pktlog_send_per_pkt_stats_to_user(void)
|
|||
|
||||
while (!list_empty(&gwlan_logging.pkt_stat_filled_list)
|
||||
&& !gwlan_logging.exit) {
|
||||
skb_new = dev_alloc_skb(MAX_PKTSTATS_LENGTH);
|
||||
skb_new = dev_alloc_skb(MAX_SKBMSG_LENGTH);
|
||||
if (skb_new == NULL) {
|
||||
if (!rate_limit) {
|
||||
pr_err("%s: dev_alloc_skb() failed for msg size[%d] drop count = %u\n",
|
||||
__func__, MAX_LOGMSG_LENGTH,
|
||||
__func__, MAX_SKBMSG_LENGTH,
|
||||
gwlan_logging.drop_count);
|
||||
}
|
||||
rate_limit = 1;
|
||||
|
@ -511,7 +553,8 @@ int pktlog_send_per_pkt_stats_to_user(void)
|
|||
free_old_skb = true;
|
||||
goto err;
|
||||
}
|
||||
ret = nl_srv_bcast(pstats_msg->skb);
|
||||
|
||||
ret = nl_srv_bcast_diag(pstats_msg->skb);
|
||||
if ((ret < 0) && (ret != -ESRCH)) {
|
||||
pr_info("%s: Send Failed %d drop_count = %u\n",
|
||||
__func__, ret,
|
||||
|
@ -609,7 +652,7 @@ static int send_filled_buffers_to_user(void)
|
|||
&gwlan_logging.free_list);
|
||||
spin_unlock_irqrestore(&gwlan_logging.spin_lock, flags);
|
||||
|
||||
ret = nl_srv_bcast(skb);
|
||||
ret = nl_srv_bcast_host_logs(skb);
|
||||
/* print every 64th drop count */
|
||||
if (ret < 0 && (!(gwlan_logging.drop_count % 0x40))) {
|
||||
pr_err("%s: Send Failed %d drop_count = %u\n",
|
||||
|
@ -755,6 +798,30 @@ static int wlan_logging_thread(void *Arg)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CNSS_GENL
|
||||
/**
|
||||
* register_logging_sock_handler() - Logging sock handler registration
|
||||
*
|
||||
* Dummy API to register the command handler for logger socket app.
|
||||
*
|
||||
* Return: None
|
||||
*/
|
||||
static void register_logging_sock_handler(void)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* unregister_logging_sock_handler() - Logging sock handler unregistration
|
||||
*
|
||||
* Dummy API to unregister the command handler for logger socket app.
|
||||
*
|
||||
* Return: None
|
||||
*/
|
||||
static void unregister_logging_sock_handler(void)
|
||||
{
|
||||
}
|
||||
|
||||
#else
|
||||
/*
|
||||
* Process all the Netlink messages from Logger Socket app in user space
|
||||
*/
|
||||
|
@ -813,6 +880,33 @@ static int wlan_logging_proc_sock_rx_msg(struct sk_buff *skb)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* register_logging_sock_handler() - Logging sock handler registration
|
||||
*
|
||||
* API to register the command handler for logger socket app. Registers
|
||||
* legacy handler
|
||||
*
|
||||
* Return: None
|
||||
*/
|
||||
static void register_logging_sock_handler(void)
|
||||
{
|
||||
nl_srv_register(ANI_NL_MSG_LOG, wlan_logging_proc_sock_rx_msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* unregister_logging_sock_handler() - Logging sock handler unregistration
|
||||
*
|
||||
* API to unregister the command handler for logger socket app. Unregisters
|
||||
* legacy handler
|
||||
*
|
||||
* Return: None
|
||||
*/
|
||||
static void unregister_logging_sock_handler(void)
|
||||
{
|
||||
nl_srv_unregister(ANI_NL_MSG_LOG, wlan_logging_proc_sock_rx_msg);
|
||||
}
|
||||
#endif
|
||||
|
||||
int wlan_logging_sock_activate_svc(int log_fe_to_console, int num_buf)
|
||||
{
|
||||
int i, j, pkt_stats_size;
|
||||
|
@ -903,7 +997,7 @@ int wlan_logging_sock_activate_svc(int log_fe_to_console, int num_buf)
|
|||
gwlan_logging.is_active = true;
|
||||
gwlan_logging.is_flush_complete = false;
|
||||
|
||||
nl_srv_register(ANI_NL_MSG_LOG, wlan_logging_proc_sock_rx_msg);
|
||||
register_logging_sock_handler();
|
||||
|
||||
return 0;
|
||||
|
||||
|
@ -934,7 +1028,7 @@ int wlan_logging_sock_deactivate_svc(void)
|
|||
if (!gplog_msg)
|
||||
return 0;
|
||||
|
||||
nl_srv_unregister(ANI_NL_MSG_LOG, wlan_logging_proc_sock_rx_msg);
|
||||
unregister_logging_sock_handler();
|
||||
clear_default_logtoapp_log_level();
|
||||
gapp_pid = INVALID_PID;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Previously licensed under the ISC license by Qualcomm Atheros, Inc.
|
||||
*
|
||||
|
@ -52,6 +52,13 @@
|
|||
#include <wlan_nlink_srv.h>
|
||||
#include <vos_trace.h>
|
||||
|
||||
#ifdef CNSS_GENL
|
||||
#include <vos_memory.h>
|
||||
#include <wlan_nlink_common.h>
|
||||
#include <net/genetlink.h>
|
||||
#include <net/cnss_nl.h>
|
||||
#endif
|
||||
|
||||
/* Global variables */
|
||||
static DEFINE_MUTEX(nl_srv_sem);
|
||||
static struct sock *nl_srv_sock;
|
||||
|
@ -155,6 +162,195 @@ int nl_srv_unregister(tWlanNlModTypes msg_type, nl_srv_msg_callback msg_handler)
|
|||
return retcode;
|
||||
}
|
||||
|
||||
#ifdef CNSS_GENL
|
||||
|
||||
/**
|
||||
* nl80211hdr_put() - API to fill genlmsg header
|
||||
* @skb: Sk buffer
|
||||
* @portid: Port ID
|
||||
* @seq: Sequence number
|
||||
* @flags: Flags
|
||||
* @cmd: Command id
|
||||
*
|
||||
* API to fill genl message header for brodcast events to user space
|
||||
*
|
||||
* Return: Pointer to user specific header/payload
|
||||
*/
|
||||
static inline void *nl80211hdr_put(struct sk_buff *skb, uint32_t portid,
|
||||
uint32_t seq, int flags, uint8_t cmd)
|
||||
{
|
||||
struct genl_family *cld80211_fam = cld80211_get_genl_family();
|
||||
|
||||
return genlmsg_put(skb, portid, seq, cld80211_fam, flags, cmd);
|
||||
}
|
||||
|
||||
/**
|
||||
* cld80211_fill_data() - API to fill payload to nl message
|
||||
* @msg: Sk buffer
|
||||
* @portid: Port ID
|
||||
* @seq: Sequence number
|
||||
* @flags: Flags
|
||||
* @cmd: Command ID
|
||||
* @buf: data buffer/payload to be filled
|
||||
* @len: length of the payload ie. @buf
|
||||
*
|
||||
* API to fill the payload/data of the nl message to be sent
|
||||
*
|
||||
* Return: zero on success
|
||||
*/
|
||||
static int cld80211_fill_data(struct sk_buff *msg, uint32_t portid,
|
||||
uint32_t seq, int flags, uint8_t cmd,
|
||||
uint8_t *buf, int len)
|
||||
{
|
||||
void *hdr;
|
||||
struct nlattr *nest;
|
||||
|
||||
hdr = nl80211hdr_put(msg, portid, seq, flags, cmd);
|
||||
if (!hdr) {
|
||||
VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
|
||||
"nl80211 hdr put failed");
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
nest = nla_nest_start(msg, CLD80211_ATTR_VENDOR_DATA);
|
||||
if (!nest) {
|
||||
VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
|
||||
"nla_nest_start failed");
|
||||
goto nla_put_failure;
|
||||
}
|
||||
|
||||
if (nla_put(msg, CLD80211_ATTR_DATA, len, buf)) {
|
||||
VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
|
||||
"nla_put failed");
|
||||
goto nla_put_failure;
|
||||
}
|
||||
|
||||
nla_nest_end(msg, nest);
|
||||
genlmsg_end(msg, hdr);
|
||||
|
||||
return 0;
|
||||
nla_put_failure:
|
||||
genlmsg_cancel(msg, hdr);
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
/**
|
||||
* send_msg_to_cld80211() - API to send message to user space Application
|
||||
* @cld_mcgroup_id: Multicast group ID
|
||||
* @pid: Port ID
|
||||
* @app_id: Application ID
|
||||
* @buf: Data/payload buffer to be sent
|
||||
* @len: Length of the data ie. @buf
|
||||
*
|
||||
* API to send the nl message to user space application.
|
||||
*
|
||||
* Return: zero on success
|
||||
*/
|
||||
static int send_msg_to_cld80211(enum cld80211_multicast_groups cld_mcgroup_id,
|
||||
int pid, int app_id, uint8_t *buf, int len)
|
||||
{
|
||||
struct sk_buff *msg;
|
||||
int status;
|
||||
int flags = GFP_KERNEL;
|
||||
int mcgroup_id;
|
||||
|
||||
if (in_interrupt() || irqs_disabled() || in_atomic())
|
||||
flags = GFP_ATOMIC;
|
||||
|
||||
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, flags);
|
||||
if (!msg) {
|
||||
VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
|
||||
"nlmsg malloc fails");
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
status = cld80211_fill_data(msg, pid, 0, 0, app_id, buf, len);
|
||||
if (status) {
|
||||
nlmsg_free(msg);
|
||||
return -EPERM;
|
||||
}
|
||||
mcgroup_id = cld80211_get_mcgrp_id(cld_mcgroup_id);
|
||||
if (mcgroup_id == -1) {
|
||||
nlmsg_free(msg);
|
||||
return -EINVAL;
|
||||
}
|
||||
genlmsg_multicast_netns(&init_net, msg, 0, mcgroup_id, flags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* nl_srv_bcast() - wrapper function to do broadcast events to user space apps
|
||||
* @skb: the socket buffer to send
|
||||
* @mcgroup_id: multicast group id
|
||||
* @app_id: application id
|
||||
*
|
||||
* This function is common wrapper to send broadcast events to different
|
||||
* user space applications.
|
||||
*
|
||||
* return: none
|
||||
*/
|
||||
int nl_srv_bcast(struct sk_buff *skb, int mcgroup_id, int app_id)
|
||||
{
|
||||
struct nlmsghdr *nlh = (struct nlmsghdr *)skb->data;
|
||||
void *msg = NLMSG_DATA(nlh);
|
||||
uint32_t msg_len = nlmsg_len(nlh);
|
||||
uint8_t *tempbuf;
|
||||
int status;
|
||||
|
||||
tempbuf = (uint8_t *)vos_mem_malloc(msg_len);
|
||||
vos_mem_copy(tempbuf, msg, msg_len);
|
||||
status = send_msg_to_cld80211(mcgroup_id, 0, app_id, tempbuf, msg_len);
|
||||
if (status) {
|
||||
VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
|
||||
"send msg to cld80211 fails for app id %d", app_id);
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
dev_kfree_skb(skb);
|
||||
vos_mem_free(tempbuf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* nl_srv_ucast() - wrapper function to do unicast events to user space apps
|
||||
* @skb: the socket buffer to send
|
||||
* @dst_pid: destination process IF
|
||||
* @flag: flags
|
||||
* @app_id: application id
|
||||
* @mcgroup_id: Multicast group ID
|
||||
*
|
||||
* This function is common wrapper to send unicast events to different
|
||||
* user space applications. This internally used broadcast API with multicast
|
||||
* group mcgrp_id. This wrapper serves as a common API in both
|
||||
* new generic netlink infra and legacy implementation.
|
||||
*
|
||||
* return: zero on success, error code otherwise
|
||||
*/
|
||||
int nl_srv_ucast(struct sk_buff *skb, int dst_pid, int flag,
|
||||
int app_id, int mcgroup_id)
|
||||
{
|
||||
struct nlmsghdr *nlh = (struct nlmsghdr *)skb->data;
|
||||
void *msg = NLMSG_DATA(nlh);
|
||||
uint32_t msg_len = nlmsg_len(nlh);
|
||||
uint8_t *tempbuf;
|
||||
int status;
|
||||
|
||||
tempbuf = (uint8_t *)vos_mem_malloc(msg_len);
|
||||
vos_mem_copy(tempbuf, msg, msg_len);
|
||||
status = send_msg_to_cld80211(mcgroup_id, dst_pid, app_id,
|
||||
tempbuf, msg_len);
|
||||
if (status) {
|
||||
VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
|
||||
"send msg to cld80211 fails for app id %d", app_id);
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
dev_kfree_skb(skb);
|
||||
vos_mem_free(tempbuf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
/*
|
||||
* Unicast the message to the process in user space identfied
|
||||
* by the dst-pid
|
||||
|
@ -183,10 +379,6 @@ int nl_srv_ucast(struct sk_buff *skb, int dst_pid, int flag)
|
|||
return err;
|
||||
}
|
||||
|
||||
/*
|
||||
* Broadcast the message. Broadcast will return an error if
|
||||
* there are no listeners
|
||||
*/
|
||||
int nl_srv_bcast(struct sk_buff *skb)
|
||||
{
|
||||
int err = 0;
|
||||
|
@ -215,6 +407,8 @@ int nl_srv_bcast(struct sk_buff *skb)
|
|||
return err;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Processes the Netlink socket input queue.
|
||||
* Dequeue skb's from the socket input queue and process
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Previously licensed under the ISC license by Qualcomm Atheros, Inc.
|
||||
*
|
||||
|
@ -40,6 +40,12 @@
|
|||
#include <vos_types.h>
|
||||
#include <vos_trace.h>
|
||||
#include <wlan_hdd_ftm.h>
|
||||
#ifdef CNSS_GENL
|
||||
#include <net/cnss_nl.h>
|
||||
#else
|
||||
|
||||
static struct hdd_context_s *hdd_ctx_handle;
|
||||
#endif
|
||||
|
||||
#define PTT_SOCK_DEBUG
|
||||
#ifdef PTT_SOCK_DEBUG
|
||||
|
@ -48,7 +54,6 @@
|
|||
#define PTT_TRACE(level, args...)
|
||||
#endif
|
||||
// Global variables
|
||||
static struct hdd_context_s *pAdapterHandle;
|
||||
|
||||
#ifdef PTT_SOCK_DEBUG_VERBOSE
|
||||
//Utility function to perform a hex dump
|
||||
|
@ -64,6 +69,46 @@ static void ptt_sock_dump_buf(const unsigned char * pbuf, int cnt)
|
|||
VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* nl_srv_ucast_ptt() - Wrapper function to send ucast msgs to PTT
|
||||
* @skb: sk buffer pointer
|
||||
* @dst_pid: Destination PID
|
||||
* @flag: flags
|
||||
*
|
||||
* Sends the ucast message to PTT with generic nl socket if CNSS_GENL
|
||||
* is enabled. Else, use the legacy netlink socket to send.
|
||||
*
|
||||
* Return: zero on success, error code otherwise
|
||||
*/
|
||||
static int nl_srv_ucast_ptt(struct sk_buff *skb, int dst_pid, int flag)
|
||||
{
|
||||
#ifdef CNSS_GENL
|
||||
return nl_srv_ucast(skb, dst_pid, flag, ANI_NL_MSG_PUMAC,
|
||||
CLD80211_MCGRP_DIAG_EVENTS);
|
||||
#else
|
||||
return nl_srv_ucast(skb, dst_pid, flag);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* nl_srv_bcast_ptt() - Wrapper function to send bcast msgs to DIAG mcast group
|
||||
* @skb: sk buffer pointer
|
||||
*
|
||||
* Sends the bcast message to DIAG multicast group with generic nl socket
|
||||
* if CNSS_GENL is enabled. Else, use the legacy netlink socket to send.
|
||||
*
|
||||
* Return: zero on success, error code otherwise
|
||||
*/
|
||||
static int nl_srv_bcast_ptt(struct sk_buff *skb)
|
||||
{
|
||||
#ifdef CNSS_GENL
|
||||
return nl_srv_bcast(skb, CLD80211_MCGRP_DIAG_EVENTS, ANI_NL_MSG_PUMAC);
|
||||
#else
|
||||
return nl_srv_bcast(skb);
|
||||
#endif
|
||||
}
|
||||
|
||||
//Utility function to send a netlink message to an application in user space
|
||||
int ptt_sock_send_msg_to_app(tAniHdr *wmsg, int radio, int src_mod, int pid)
|
||||
{
|
||||
|
@ -102,9 +147,9 @@ int ptt_sock_send_msg_to_app(tAniHdr *wmsg, int radio, int src_mod, int pid)
|
|||
#endif
|
||||
|
||||
if (pid != -1) {
|
||||
err = nl_srv_ucast(skb, pid, MSG_DONTWAIT);
|
||||
err = nl_srv_ucast_ptt(skb, pid, MSG_DONTWAIT);
|
||||
} else {
|
||||
err = nl_srv_bcast(skb);
|
||||
err = nl_srv_bcast_ptt(skb);
|
||||
}
|
||||
if (err) {
|
||||
PTT_TRACE(VOS_TRACE_LEVEL_INFO,
|
||||
|
@ -113,6 +158,8 @@ int ptt_sock_send_msg_to_app(tAniHdr *wmsg, int radio, int src_mod, int pid)
|
|||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
#ifndef CNSS_GENL
|
||||
/*
|
||||
* Process tregisteration request and send registration response messages
|
||||
* to the PTT Socket App in user space
|
||||
|
@ -128,7 +175,7 @@ static void ptt_sock_proc_reg_req(tAniHdr *wmsg, int radio)
|
|||
rspmsg.regReq.type = reg_req->type;
|
||||
|
||||
/* Save the pid */
|
||||
pAdapterHandle->ptt_pid = reg_req->pid;
|
||||
hdd_ctx_handle->ptt_pid = reg_req->pid;
|
||||
rspmsg.regReq.pid= reg_req->pid;
|
||||
rspmsg.wniHdr.type = cpu_to_be16(ANI_MSG_APP_REG_RSP);
|
||||
rspmsg.wniHdr.length = cpu_to_be16(sizeof(rspmsg.wniHdr));
|
||||
|
@ -139,6 +186,7 @@ static void ptt_sock_proc_reg_req(tAniHdr *wmsg, int radio)
|
|||
__func__, reg_req->pid);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Process all the messages from the PTT Socket App in user space
|
||||
*/
|
||||
|
@ -181,12 +229,72 @@ static int ptt_sock_rx_nlink_msg (struct sk_buff * skb)
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
int ptt_sock_activate_svc(void *pAdapter)
|
||||
#endif
|
||||
|
||||
#ifdef CNSS_GENL
|
||||
/**
|
||||
* ptt_cmd_handler() - Handler function for PTT commands
|
||||
* @data: Data to be parsed
|
||||
* @data_len: Length of the data received
|
||||
* @ctx: Registered context reference
|
||||
* @pid: Process id of the user space application
|
||||
*
|
||||
* This function handles the command from PTT user space application
|
||||
*
|
||||
* Return: None
|
||||
*/
|
||||
static void ptt_cmd_handler(const void *data, int data_len, void *ctx, int pid)
|
||||
{
|
||||
pAdapterHandle = (struct hdd_context_s*)pAdapter;
|
||||
pAdapterHandle->ptt_pid = INVALID_PID;
|
||||
ptt_app_reg_req *payload;
|
||||
struct nlattr *tb[CLD80211_ATTR_MAX + 1];
|
||||
|
||||
if (nla_parse(tb, CLD80211_ATTR_MAX, data, data_len, NULL)) {
|
||||
PTT_TRACE(VOS_TRACE_LEVEL_ERROR, "Invalid ATTR");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!tb[CLD80211_ATTR_DATA]) {
|
||||
PTT_TRACE(VOS_TRACE_LEVEL_ERROR, "attr ATTR_DATA failed");
|
||||
return;
|
||||
}
|
||||
|
||||
payload = (ptt_app_reg_req *)(nla_data(tb[CLD80211_ATTR_DATA]));
|
||||
switch (payload->wmsg.type) {
|
||||
case ANI_MSG_APP_REG_REQ:
|
||||
ptt_sock_send_msg_to_app(&payload->wmsg, payload->radio,
|
||||
ANI_NL_MSG_PUMAC, pid);
|
||||
break;
|
||||
default:
|
||||
PTT_TRACE(VOS_TRACE_LEVEL_ERROR, "Unknown msg type %d",
|
||||
payload->wmsg.type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ptt_sock_activate_svc() - API to register PTT/PUMAC command handler
|
||||
* @pAdapter: Pointer to adapter
|
||||
*
|
||||
* API to register the PTT/PUMAC command handlers. Argument @pAdapter
|
||||
* is sent for prototype compatibility between new genl and legacy
|
||||
* implementation
|
||||
*
|
||||
* Return: 0
|
||||
*/
|
||||
int ptt_sock_activate_svc(void *hdd_ctx)
|
||||
{
|
||||
register_cld_cmd_cb(ANI_NL_MSG_PUMAC, ptt_cmd_handler, NULL);
|
||||
register_cld_cmd_cb(ANI_NL_MSG_PTT, ptt_cmd_handler, NULL);
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
int ptt_sock_activate_svc(void *hdd_ctx)
|
||||
{
|
||||
hdd_ctx_handle = (struct hdd_context_s *)hdd_ctx;
|
||||
hdd_ctx_handle->ptt_pid = INVALID_PID;
|
||||
nl_srv_register(ANI_NL_MSG_PUMAC, ptt_sock_rx_nlink_msg);
|
||||
nl_srv_register(ANI_NL_MSG_PTT, ptt_sock_rx_nlink_msg);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#endif // PTT_SOCK_SVC_ENABLE
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2016, 2018 The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2013-2017, 2018 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Previously licensed under the ISC license by Qualcomm Atheros, Inc.
|
||||
*
|
||||
|
@ -42,6 +42,9 @@
|
|||
#include <wlan_hdd_wext.h>
|
||||
#include <net/sock.h>
|
||||
#include <linux/netlink.h>
|
||||
#ifdef CNSS_GENL
|
||||
#include <net/cnss_nl.h>
|
||||
#endif
|
||||
|
||||
#ifdef WLAN_OPEN_SOURCE
|
||||
#include <linux/debugfs.h>
|
||||
|
@ -1638,6 +1641,24 @@ dbglog_debugfs_raw_data(wmi_unified_t wmi_handle, const u_int8_t *buf, A_UINT32
|
|||
}
|
||||
#endif /* WLAN_OPEN_SOURCE */
|
||||
|
||||
/**
|
||||
* nl_srv_bcast_fw_logs() - Wrapper func to send bcast msgs to FW logs mcast grp
|
||||
* @skb: sk buffer pointer
|
||||
*
|
||||
* Sends the bcast message to FW logs multicast group with generic nl socket
|
||||
* if CNSS_GENL is enabled. Else, use the legacy netlink socket to send.
|
||||
*
|
||||
* Return: zero on success, error code otherwise
|
||||
*/
|
||||
static int nl_srv_bcast_fw_logs(struct sk_buff *skb)
|
||||
{
|
||||
#ifdef CNSS_GENL
|
||||
return nl_srv_bcast(skb, CLD80211_MCGRP_FW_LOGS, WLAN_NL_MSG_CNSS_DIAG);
|
||||
#else
|
||||
return nl_srv_bcast(skb);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Package the data from the fw diag WMI event handler.
|
||||
* Pass this data to cnss-diag service
|
||||
|
@ -1667,11 +1688,11 @@ send_fw_diag_nl_data(const u_int8_t *buffer,
|
|||
nlh = nlmsg_put(skb_out, 0, 0, WLAN_NL_MSG_CNSS_DIAG, len, 0);
|
||||
memcpy(nlmsg_data(nlh), buffer, len);
|
||||
|
||||
res = nl_srv_bcast(skb_out);
|
||||
res = nl_srv_bcast_fw_logs(skb_out);
|
||||
if ((res < 0) && (res != -ESRCH))
|
||||
{
|
||||
AR_DEBUG_PRINTF(ATH_DEBUG_RSVD1,
|
||||
("%s: nl_srv_bcast failed 0x%x \n", __func__, res));
|
||||
("%s: nl_srv_bcast_fw_logs failed 0x%x \n", __func__, res));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
@ -1716,10 +1737,10 @@ send_diag_netlink_data(const u_int8_t *buffer,
|
|||
/* Need to pad each record to fixed length ATH6KL_FWLOG_PAYLOAD_SIZE */
|
||||
memset(slot->payload + len, 0, ATH6KL_FWLOG_PAYLOAD_SIZE - len);
|
||||
|
||||
res = nl_srv_bcast(skb_out);
|
||||
res = nl_srv_bcast_fw_logs(skb_out);
|
||||
if ((res < 0) && (res != -ESRCH)) {
|
||||
AR_DEBUG_PRINTF(ATH_DEBUG_RSVD1,
|
||||
("%s: nl_srv_bcast failed 0x%x \n", __func__, res));
|
||||
("%s: nl_srv_bcast_fw_logs failed 0x%x \n", __func__, res));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
@ -1765,11 +1786,11 @@ dbglog_process_netlink_data(wmi_unified_t wmi_handle, const u_int8_t *buffer,
|
|||
/* Need to pad each record to fixed length ATH6KL_FWLOG_PAYLOAD_SIZE */
|
||||
memset(slot->payload + len, 0, ATH6KL_FWLOG_PAYLOAD_SIZE - len);
|
||||
|
||||
res = nl_srv_bcast(skb_out);
|
||||
res = nl_srv_bcast_fw_logs(skb_out);
|
||||
if ((res < 0) && (res != -ESRCH))
|
||||
{
|
||||
AR_DEBUG_PRINTF(ATH_DEBUG_RSVD1,
|
||||
("%s: nl_srv_bcast failed 0x%x \n", __func__, res));
|
||||
("%s: nl_srv_bcast_fw_logs failed 0x%x \n", __func__, res));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
@ -3949,6 +3970,41 @@ int dbglog_debugfs_remove(wmi_unified_t wmi_handle)
|
|||
}
|
||||
#endif /* WLAN_OPEN_SOURCE */
|
||||
|
||||
/**
|
||||
* cnss_diag_handle_crash_inject() - API to handle crash inject command
|
||||
* @slot: pointer to struct dbglog_slot
|
||||
*
|
||||
* API to handle CNSS diag crash inject command
|
||||
*
|
||||
* Return: None
|
||||
*/
|
||||
static void cnss_diag_handle_crash_inject(struct dbglog_slot *slot)
|
||||
{
|
||||
switch (slot->diag_type) {
|
||||
case DIAG_TYPE_CRASH_INJECT:
|
||||
if (slot->length == 2) {
|
||||
AR_DEBUG_PRINTF(ATH_DEBUG_INFO,
|
||||
("%s : DIAG_TYPE_CRASH_INJECT: %d %d\n", __func__,
|
||||
slot->payload[0], slot->payload[1]));
|
||||
if (!tgt_assert_enable) {
|
||||
AR_DEBUG_PRINTF(ATH_DEBUG_INFO,
|
||||
("%s: tgt Assert Disabled\n", __func__));
|
||||
return;
|
||||
}
|
||||
process_wma_set_command_twoargs(0,
|
||||
(int)GEN_PARAM_CRASH_INJECT,
|
||||
slot->payload[0],
|
||||
slot->payload[1], GEN_CMD);
|
||||
}
|
||||
else
|
||||
AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("crash_inject cmd error\n"));
|
||||
break;
|
||||
default:
|
||||
AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown cmd error\n"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**---------------------------------------------------------------------------
|
||||
\brief cnss_diag_msg_callback() - Call back invoked by netlink service
|
||||
|
||||
|
@ -3962,46 +4018,77 @@ int dbglog_debugfs_remove(wmi_unified_t wmi_handle)
|
|||
--------------------------------------------------------------------------*/
|
||||
int cnss_diag_msg_callback(struct sk_buff *skb)
|
||||
{
|
||||
struct nlmsghdr *nlh;
|
||||
struct dbglog_slot *slot;
|
||||
A_UINT8 *msg;
|
||||
struct nlmsghdr *nlh;
|
||||
A_UINT8 *msg;
|
||||
|
||||
nlh = (struct nlmsghdr *)skb->data;
|
||||
if (!nlh)
|
||||
{
|
||||
AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Netlink header null \n", __func__));
|
||||
return -1;
|
||||
}
|
||||
nlh = (struct nlmsghdr *)skb->data;
|
||||
if (!nlh) {
|
||||
AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Netlink header null \n", __func__));
|
||||
return -1;
|
||||
}
|
||||
|
||||
msg = NLMSG_DATA(nlh);
|
||||
|
||||
slot = (struct dbglog_slot *)msg;
|
||||
switch (slot->diag_type) {
|
||||
case DIAG_TYPE_CRASH_INJECT:
|
||||
if (slot->length == 2) {
|
||||
AR_DEBUG_PRINTF(ATH_DEBUG_INFO,
|
||||
("%s : DIAG_TYPE_CRASH_INJECT: %d %d\n", __func__,
|
||||
slot->payload[0], slot->payload[1]));
|
||||
if (!tgt_assert_enable) {
|
||||
AR_DEBUG_PRINTF(ATH_DEBUG_INFO,
|
||||
("%s: tgt Assert Disabled\n", __func__));
|
||||
return 0;
|
||||
}
|
||||
process_wma_set_command_twoargs(0,
|
||||
(int)GEN_PARAM_CRASH_INJECT,
|
||||
slot->payload[0],
|
||||
slot->payload[1], GEN_CMD);
|
||||
}
|
||||
else
|
||||
AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("crash_inject cmd error\n"));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
msg = NLMSG_DATA(nlh);
|
||||
cnss_diag_handle_crash_inject((struct dbglog_slot *)msg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CNSS_GENL
|
||||
|
||||
/**
|
||||
* cnss_diag_cmd_handler() - API to handle CNSS diag command
|
||||
* @data: Data received
|
||||
* @data_len: length of the data received
|
||||
* @ctx: Pointer to stored context
|
||||
* @pid: Process ID
|
||||
*
|
||||
* API to handle CNSS diag commands from user space
|
||||
*
|
||||
* Return: None
|
||||
*/
|
||||
static void cnss_diag_cmd_handler(const void *data, int data_len,
|
||||
void *ctx, int pid)
|
||||
{
|
||||
struct dbglog_slot *slot = NULL;
|
||||
struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
|
||||
|
||||
if (nla_parse(tb, CLD80211_ATTR_MAX, data, data_len, NULL)) {
|
||||
AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: nla parse fails \n",
|
||||
__func__));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!tb[CLD80211_ATTR_DATA]) {
|
||||
AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: attr VENDOR_DATA fails \n",
|
||||
__func__));
|
||||
return;
|
||||
}
|
||||
slot = (struct dbglog_slot *)nla_data(tb[CLD80211_ATTR_DATA]);
|
||||
|
||||
if (!slot) {
|
||||
AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: data NULL \n", __func__));
|
||||
return;
|
||||
}
|
||||
|
||||
cnss_diag_handle_crash_inject(slot);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* cnss_diag_activate_service() - API to register CNSS diag cmd handler
|
||||
*
|
||||
* API to register the CNSS diag command handler using new genl infra.
|
||||
* Return type is zero to match with legacy prototype
|
||||
*
|
||||
* Return: 0
|
||||
*/
|
||||
int cnss_diag_activate_service(void)
|
||||
{
|
||||
register_cld_cmd_cb(WLAN_NL_MSG_CNSS_DIAG, cnss_diag_cmd_handler, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
/**---------------------------------------------------------------------------
|
||||
\brief cnss_diag_activate_service() - Activate cnss_diag message handler
|
||||
|
||||
|
@ -4013,7 +4100,7 @@ int cnss_diag_msg_callback(struct sk_buff *skb)
|
|||
|
||||
\return - 0 for success, non zero for failure
|
||||
--------------------------------------------------------------------------*/
|
||||
int cnss_diag_activate_service()
|
||||
int cnss_diag_activate_service(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
|
@ -4027,6 +4114,7 @@ int cnss_diag_activate_service()
|
|||
kd_nl_init = TRUE;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
A_BOOL
|
||||
dbglog_wow_print_handler(
|
||||
|
|
|
@ -1071,6 +1071,10 @@ ifeq ($(CONFIG_QCACLD_WLAN_LFR3),y)
|
|||
CDEFINES += -DWLAN_FEATURE_ROAM_OFFLOAD
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CNSS_GENL), y)
|
||||
CDEFINES += -DCNSS_GENL
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_PRIMA_WLAN_OKC),y)
|
||||
CDEFINES += -DFEATURE_WLAN_OKC
|
||||
endif
|
||||
|
|
Loading…
Reference in New Issue