qcacmn: Implement WIFI_POS commands
Implement following commands for WIFI_POS: 1) ANI_MSG_APP_REG_REQ 2) ANI_MSG_CHANNEL_INFO_REQ 3) ANI_MSG_SET_OEM_CAP_REQ 4) ANI_MSG_GET_OEM_CAP_REQ 5) ANI_MSG_OEM_DATA_REQ 6) ANI_MSG_PEER_STATUS_IND Change-Id: I7e3b502660b169f4cdb654cb5f433446a24d2421 CRs-Fixed: 2003488
This commit is contained in:

committed by
Sandeep Puligilla

parent
18ceca16b7
commit
922724f2db
@@ -37,10 +37,126 @@
|
||||
#include "os_if_wifi_pos.h"
|
||||
#include "wifi_pos_api.h"
|
||||
#include "wlan_cfg80211.h"
|
||||
#include "wlan_objmgr_psoc_obj.h"
|
||||
#ifdef CNSS_GENL
|
||||
#include <net/cnss_nl.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* os_if_wifi_pos_send_rsp() - send oem registration response
|
||||
*
|
||||
* This function sends oem message to registered application process
|
||||
*
|
||||
* Return: none
|
||||
*/
|
||||
static void os_if_wifi_pos_send_rsp(uint32_t pid, uint32_t rsp_msg_type,
|
||||
uint32_t buf_len, uint8_t *buf)
|
||||
{
|
||||
tAniMsgHdr *aniHdr;
|
||||
struct sk_buff *skb;
|
||||
struct nlmsghdr *nlh;
|
||||
|
||||
/* OEM msg is always to a specific process and cannot be a broadcast */
|
||||
if (pid == 0) {
|
||||
cfg80211_err("invalid dest pid");
|
||||
return;
|
||||
}
|
||||
|
||||
skb = alloc_skb(NLMSG_SPACE(sizeof(tAniMsgHdr) + buf_len), GFP_ATOMIC);
|
||||
if (skb == NULL) {
|
||||
cfg80211_alert("alloc_skb failed");
|
||||
return;
|
||||
}
|
||||
|
||||
nlh = (struct nlmsghdr *)skb->data;
|
||||
nlh->nlmsg_pid = 0; /* from kernel */
|
||||
nlh->nlmsg_flags = 0;
|
||||
nlh->nlmsg_seq = 0;
|
||||
nlh->nlmsg_type = WLAN_NL_MSG_OEM;
|
||||
nlh->nlmsg_len = NLMSG_LENGTH(sizeof(tAniMsgHdr) + buf_len);
|
||||
|
||||
aniHdr = NLMSG_DATA(nlh);
|
||||
aniHdr->type = rsp_msg_type;
|
||||
qdf_mem_copy(&aniHdr[1], buf, buf_len);
|
||||
aniHdr->length = buf_len;
|
||||
|
||||
skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + buf_len));
|
||||
cfg80211_debug("sending oem rsp: type: %d len(%d) to pid (%d)",
|
||||
rsp_msg_type, buf_len, pid);
|
||||
nl_srv_ucast_oem(skb, pid, MSG_DONTWAIT);
|
||||
}
|
||||
|
||||
#ifdef CNSS_GENL
|
||||
static int wifi_pos_parse_req(const void *data, int len, int pid,
|
||||
struct wifi_pos_req_msg *req)
|
||||
{
|
||||
tAniMsgHdr *msg_hdr;
|
||||
struct nlattr *tb[CLD80211_ATTR_MAX + 1];
|
||||
|
||||
if (nla_parse(tb, CLD80211_ATTR_MAX, data, len, NULL)) {
|
||||
cfg80211_err("invalid data in request");
|
||||
return OEM_ERR_INVALID_MESSAGE_TYPE;
|
||||
}
|
||||
|
||||
if (!tb[CLD80211_ATTR_DATA]) {
|
||||
cfg80211_err("CLD80211_ATTR_DATA not present");
|
||||
return OEM_ERR_INVALID_MESSAGE_TYPE;
|
||||
}
|
||||
|
||||
msg_hdr = (tAniMsgHdr *)nla_data(tb[CLD80211_ATTR_DATA]);
|
||||
if (!msg_hdr) {
|
||||
cfg80211_err("msg_hdr null");
|
||||
return OEM_ERR_NULL_MESSAGE_HEADER;
|
||||
}
|
||||
|
||||
req->msg_type = msg_hdr->type;
|
||||
req->buf_len = msg_hdr->length;
|
||||
req->buf = (uint8_t *)&msg_hdr[1];
|
||||
req->pid = pid;
|
||||
|
||||
if (tb[CLD80211_ATTR_META_DATA]) {
|
||||
req->field_info_buf = (struct wifi_pos_field_info *)
|
||||
nla_data(tb[CLD80211_ATTR_META_DATA]);
|
||||
req->field_info_buf_len = nla_len(tb[CLD80211_ATTR_META_DATA]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
static int wifi_pos_parse_req(struct sk_buff *skb, struct wifi_pos_req_msg *req)
|
||||
{
|
||||
/* SKB->data contains NL msg */
|
||||
/* NLMSG_DATA(nlh) contains ANI msg */
|
||||
struct nlmsghdr *nlh;
|
||||
tAniMsgHdr *msg_hdr;
|
||||
|
||||
nlh = (struct nlmsghdr *)skb->data;
|
||||
if (!nlh) {
|
||||
cfg80211_err("Netlink header null");
|
||||
return OEM_ERR_NULL_MESSAGE_HEADER;
|
||||
}
|
||||
|
||||
msg_hdr = NLMSG_DATA(nlh);
|
||||
if (!msg_hdr) {
|
||||
cfg80211_err("Message header null");
|
||||
return OEM_ERR_NULL_MESSAGE_HEADER;
|
||||
}
|
||||
|
||||
if (nlh->nlmsg_len < NLMSG_LENGTH(sizeof(*msg_hdr) + msg_hdr->length)) {
|
||||
cfg80211_err("nlmsg_len(%d) and animsg_len(%d) mis-match",
|
||||
nlh->nlmsg_len, msg_hdr->length);
|
||||
return OEM_ERR_INVALID_MESSAGE_LENGTH;
|
||||
}
|
||||
|
||||
req->msg_type = msg_hdr->type;
|
||||
req->buf_len = msg_hdr->length;
|
||||
req->buf = (uint8_t *)&msg_hdr[1];
|
||||
req->pid = nlh->nlmsg_pid;
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* os_if_wifi_pos_callback() - callback registered with NL service socket to
|
||||
* process wifi pos request
|
||||
@@ -52,26 +168,70 @@
|
||||
static void os_if_wifi_pos_callback(const void *data, int data_len,
|
||||
void *ctx, int pid)
|
||||
{
|
||||
uint8_t err;
|
||||
QDF_STATUS status;
|
||||
struct wifi_pos_req_msg req = {0};
|
||||
struct wlan_objmgr_psoc *psoc = wifi_pos_get_psoc();
|
||||
|
||||
cfg80211_debug("enter: pid %d", pid);
|
||||
if (!psoc) {
|
||||
cfg80211_err("global psoc object not registered yet.");
|
||||
return;
|
||||
}
|
||||
|
||||
wlan_objmgr_psoc_get_ref(psoc, WLAN_WIFI_POS_ID);
|
||||
err = wifi_pos_parse_req(data, data_len, pid, &req);
|
||||
if (err) {
|
||||
os_if_wifi_pos_send_rsp(wifi_pos_get_app_pid(psoc),
|
||||
ANI_MSG_OEM_ERROR, sizeof(err), &err);
|
||||
status = QDF_STATUS_E_INVAL;
|
||||
goto release_psoc_ref;
|
||||
}
|
||||
|
||||
/* implemention is TBD */
|
||||
status = ucfg_wifi_pos_process_req(psoc, &req, NULL);
|
||||
status = ucfg_wifi_pos_process_req(psoc, &req, os_if_wifi_pos_send_rsp);
|
||||
if (QDF_IS_STATUS_ERROR(status))
|
||||
cfg80211_err("ucfg_wifi_pos_process_req failed. status: %d",
|
||||
status);
|
||||
|
||||
release_psoc_ref:
|
||||
wlan_objmgr_psoc_release_ref(psoc, WLAN_WIFI_POS_ID);
|
||||
}
|
||||
#else
|
||||
static int os_if_wifi_pos_callback(struct sk_buff *skb)
|
||||
{
|
||||
uint8_t err;
|
||||
QDF_STATUS status;
|
||||
struct wifi_pos_req_msg req = {0};
|
||||
struct wlan_objmgr_psoc *psoc = wifi_pos_get_psoc();
|
||||
|
||||
cfg80211_debug("enter");
|
||||
if (!psoc) {
|
||||
cfg80211_err("global psoc object not registered yet.");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
wlan_objmgr_psoc_get_ref(psoc, WLAN_WIFI_POS_ID);
|
||||
err = wifi_pos_parse_req(skb, &req);
|
||||
if (err) {
|
||||
os_if_wifi_pos_send_rsp(wifi_pos_get_app_pid(psoc),
|
||||
ANI_MSG_OEM_ERROR, sizeof(err), &err);
|
||||
status = QDF_STATUS_E_INVAL;
|
||||
goto release_psoc_ref;
|
||||
}
|
||||
|
||||
status = ucfg_wifi_pos_process_req(psoc, &req, os_if_wifi_pos_send_rsp);
|
||||
if (QDF_IS_STATUS_ERROR(status))
|
||||
cfg80211_err("ucfg_wifi_pos_process_req failed. status: %d",
|
||||
status);
|
||||
|
||||
release_psoc_ref:
|
||||
wlan_objmgr_psoc_release_ref(psoc, WLAN_WIFI_POS_ID);
|
||||
|
||||
return qdf_status_to_os_return(status);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CNSS_GENL
|
||||
int os_if_wifi_pos_register_nl(void)
|
||||
{
|
||||
int ret = register_cld_cmd_cb(WLAN_NL_MSG_OEM,
|
||||
@@ -81,7 +241,14 @@ int os_if_wifi_pos_register_nl(void)
|
||||
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
int os_if_wifi_pos_register_nl(void)
|
||||
{
|
||||
return nl_srv_register(WLAN_NL_MSG_OEM, os_if_wifi_pos_callback);
|
||||
}
|
||||
#endif /* CNSS_GENL */
|
||||
|
||||
#ifdef CNSS_GENL
|
||||
int os_if_wifi_pos_deregister_nl(void)
|
||||
{
|
||||
int ret = deregister_cld_cmd_cb(WLAN_NL_MSG_OEM);
|
||||
@@ -91,16 +258,11 @@ int os_if_wifi_pos_deregister_nl(void)
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
int os_if_wifi_pos_register_nl(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int os_if_wifi_pos_deregister_nl(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#endif /* CNSS_GENL */
|
||||
|
||||
void os_if_wifi_pos_send_peer_status(struct qdf_mac_addr *peer_mac,
|
||||
uint8_t peer_status,
|
||||
@@ -109,7 +271,62 @@ void os_if_wifi_pos_send_peer_status(struct qdf_mac_addr *peer_mac,
|
||||
struct wifi_pos_ch_info *chan_info,
|
||||
enum tQDF_ADAPTER_MODE dev_mode)
|
||||
{
|
||||
/* implemention TBD */
|
||||
struct wlan_objmgr_psoc *psoc = wifi_pos_get_psoc();
|
||||
struct wmi_pos_peer_status_info *peer_info;
|
||||
|
||||
if (!psoc) {
|
||||
cfg80211_err("global wifi_pos psoc object not registered");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!wifi_pos_is_app_registered(psoc) ||
|
||||
wifi_pos_get_app_pid(psoc) == 0) {
|
||||
cfg80211_err("app is not registered or pid is invalid");
|
||||
return;
|
||||
}
|
||||
|
||||
peer_info = qdf_mem_malloc(sizeof(*peer_info));
|
||||
if (!peer_info) {
|
||||
cfg80211_alert("malloc failed");
|
||||
return;
|
||||
}
|
||||
qdf_mem_copy(peer_info->peer_mac_addr, peer_mac->bytes,
|
||||
sizeof(peer_mac->bytes));
|
||||
peer_info->peer_status = peer_status;
|
||||
peer_info->vdev_id = session_id;
|
||||
peer_info->peer_capability = peer_timing_meas_cap;
|
||||
peer_info->reserved0 = 0;
|
||||
/* Set 0th bit of reserved0 for STA mode */
|
||||
if (QDF_STA_MODE == dev_mode)
|
||||
peer_info->reserved0 |= 0x01;
|
||||
|
||||
if (chan_info) {
|
||||
peer_info->peer_chan_info.chan_id = chan_info->chan_id;
|
||||
peer_info->peer_chan_info.reserved0 = 0;
|
||||
peer_info->peer_chan_info.mhz = chan_info->mhz;
|
||||
peer_info->peer_chan_info.band_center_freq1 =
|
||||
chan_info->band_center_freq1;
|
||||
peer_info->peer_chan_info.band_center_freq2 =
|
||||
chan_info->band_center_freq2;
|
||||
peer_info->peer_chan_info.info = chan_info->info;
|
||||
peer_info->peer_chan_info.reg_info_1 = chan_info->reg_info_1;
|
||||
peer_info->peer_chan_info.reg_info_2 = chan_info->reg_info_2;
|
||||
}
|
||||
|
||||
os_if_wifi_pos_send_rsp(wifi_pos_get_app_pid(psoc),
|
||||
ANI_MSG_PEER_STATUS_IND,
|
||||
sizeof(*peer_info), (uint8_t *)peer_info);
|
||||
return;
|
||||
}
|
||||
|
||||
void os_if_wifi_pos_set_ftm_cap(struct wlan_objmgr_psoc *psoc, uint32_t val)
|
||||
{
|
||||
if (!psoc) {
|
||||
cfg80211_err("psoc is null");
|
||||
return;
|
||||
}
|
||||
|
||||
wifi_pos_set_ftm_cap(psoc, val);
|
||||
}
|
||||
|
||||
int os_if_wifi_pos_populate_caps(struct wlan_objmgr_psoc *psoc,
|
||||
|
Reference in New Issue
Block a user