From 574d9b4316d63fd4acd92b2c23e478525d60bc6e Mon Sep 17 00:00:00 2001 From: Naveen Rawat Date: Sun, 2 Apr 2017 18:25:54 -0700 Subject: [PATCH] qcacmn: Add framework for NDP cmd execution Add NDP command execution framework: 1) Define UCFG apis, that will be called from OS_IF layer 2) Define request proccessing functions to post to scheduler and callback. 3) Define request proccessing functions to post to serializer and callback. 4) Define functions handling activated, cancelled and timed out NDP req. Change-Id: Ibc6fe32c65f8de0c24e0537f2eb538f806cf5284 CRs-Fixed: 2014795 --- inc/os_if_nan.h | 29 +++++++++++++++ src/os_if_nan.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+) diff --git a/inc/os_if_nan.h b/inc/os_if_nan.h index 3843abacfa52..4e263d5ef6a4 100644 --- a/inc/os_if_nan.h +++ b/inc/os_if_nan.h @@ -23,6 +23,11 @@ #ifndef _OS_IF_NAN_H_ #define _OS_IF_NAN_H_ +#include "qdf_types.h" + +struct wlan_objmgr_psoc; +struct wlan_objmgr_vdev; + #ifdef WLAN_FEATURE_NAN_CONVERGENCE #define NDP_QOS_INFO_LEN 255 @@ -114,4 +119,28 @@ enum qca_wlan_vendor_attr_ndp_sub_cmd_value { #endif /* WLAN_FEATURE_NAN_CONVERGENCE */ +/** + * os_if_nan_process_ndp_cmd: os_if api to handle nan request message + * @psoc: pointer to psoc object + * @data: request data. contains vendor cmd tlvs + * @data_len: length of data + * + * Return: status of operation + */ +int os_if_nan_process_ndp_cmd(struct wlan_objmgr_psoc *psoc, + const void *data, int data_len); + +/** + * os_if_nan_event_handler: os_if handler api for nan response messages + * @psoc: pointer to psoc object + * @vdev: pointer to vdev object + * @type: message type + * @msg: msg buffer + * + * Return: None + */ +void os_if_nan_event_handler(struct wlan_objmgr_psoc *psoc, + struct wlan_objmgr_vdev *vdev, + uint32_t type, void *msg); + #endif diff --git a/src/os_if_nan.c b/src/os_if_nan.c index 3ee4c4706966..5d260ecc32a9 100644 --- a/src/os_if_nan.c +++ b/src/os_if_nan.c @@ -20,3 +20,99 @@ * DOC: defines nan component os interface APIs */ +#include "qdf_types.h" +#include "qdf_trace.h" +#include "os_if_nan.h" +#include "wlan_nlink_srv.h" +#include "nan_public_structs.h" +#include "wlan_cfg80211.h" + +/* NLA policy */ +static const struct nla_policy +vendor_attr_policy[QCA_WLAN_VENDOR_ATTR_NDP_PARAMS_MAX + 1] = { + [QCA_WLAN_VENDOR_ATTR_NDP_SUBCMD] = { .type = NLA_U32 }, + [QCA_WLAN_VENDOR_ATTR_NDP_TRANSACTION_ID] = { .type = NLA_U16 }, + [QCA_WLAN_VENDOR_ATTR_NDP_IFACE_STR] = { .type = NLA_STRING, + .len = IFNAMSIZ }, + [QCA_WLAN_VENDOR_ATTR_NDP_SERVICE_INSTANCE_ID] = { .type = NLA_U32 }, + [QCA_WLAN_VENDOR_ATTR_NDP_CHANNEL] = { .type = NLA_U32 }, + [QCA_WLAN_VENDOR_ATTR_NDP_PEER_DISCOVERY_MAC_ADDR] = { + .type = NLA_BINARY, + .len = QDF_MAC_ADDR_SIZE }, + [QCA_WLAN_VENDOR_ATTR_NDP_CONFIG_SECURITY] = { .type = NLA_U16 }, + [QCA_WLAN_VENDOR_ATTR_NDP_CONFIG_QOS] = { .type = NLA_BINARY, + .len = NDP_QOS_INFO_LEN }, + [QCA_WLAN_VENDOR_ATTR_NDP_APP_INFO] = { .type = NLA_BINARY, + .len = NDP_APP_INFO_LEN }, + [QCA_WLAN_VENDOR_ATTR_NDP_INSTANCE_ID] = { .type = NLA_U32 }, + [QCA_WLAN_VENDOR_ATTR_NDP_RESPONSE_CODE] = { .type = NLA_U16 }, + [QCA_WLAN_VENDOR_ATTR_NDP_NDI_MAC_ADDR] = { .type = NLA_BINARY, + .len = QDF_MAC_ADDR_SIZE }, + [QCA_WLAN_VENDOR_ATTR_NDP_INSTANCE_ID_ARRAY] = { .type = NLA_BINARY, + .len = NDP_NUM_INSTANCE_ID }, + [QCA_WLAN_VENDOR_ATTR_NDP_CHANNEL_CONFIG] = { .type = NLA_U32 }, + [QCA_WLAN_VENDOR_ATTR_NDP_NCS_SK_TYPE] = { .type = NLA_U32 }, + [QCA_WLAN_VENDOR_ATTR_NDP_PMK] = { .type = NLA_BINARY, + .len = NDP_PMK_LEN }, + [QCA_WLAN_VENDOR_ATTR_NDP_SCID] = { .type = NLA_BINARY, + .len = NDP_SCID_BUF_LEN }, + [QCA_WLAN_VENDOR_ATTR_NDP_DRV_RESPONSE_STATUS_TYPE] = { .type = + NLA_U32 }, + [QCA_WLAN_VENDOR_ATTR_NDP_DRV_RETURN_VALUE] = { .type = NLA_U32 }, +}; + +int os_if_nan_process_ndp_cmd(void *ctx, struct wlan_objmgr_psoc *psoc, + const void *data, int data_len) +{ + uint32_t ndp_cmd_type; + uint16_t transaction_id; + struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_NDP_PARAMS_MAX + 1]; + char *iface_name; + + if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_NDP_PARAMS_MAX, + data, data_len, vendor_attr_policy)) { + cfg80211_err("Invalid NDP vendor command attributes"); + return -EINVAL; + } + + /* Parse and fetch NDP Command Type*/ + if (!tb[QCA_WLAN_VENDOR_ATTR_NDP_SUBCMD]) { + cfg80211_err("NAN datapath cmd type failed"); + return -EINVAL; + } + ndp_cmd_type = nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_NDP_SUBCMD]); + + if (!tb[QCA_WLAN_VENDOR_ATTR_NDP_TRANSACTION_ID]) { + cfg80211_err("attr transaction id failed"); + return -EINVAL; + } + transaction_id = nla_get_u16( + tb[QCA_WLAN_VENDOR_ATTR_NDP_TRANSACTION_ID]); + + if (tb[QCA_WLAN_VENDOR_ATTR_NDP_IFACE_STR]) { + iface_name = nla_data(tb[QCA_WLAN_VENDOR_ATTR_NDP_IFACE_STR]); + cfg80211_err("Transaction Id: %d NDPCmd: %d iface_name: %s", + transaction_id, ndp_cmd_type, iface_name); + } else { + cfg80211_err("Transaction Id: %d NDPCmd: %d iface_name: unspecified", + transaction_id, ndp_cmd_type); + } + + switch (ndp_cmd_type) { + default: + cfg80211_err("Unrecognized NDP vendor cmd %d", ndp_cmd_type); + return -EINVAL; + } + + return -EINVAL; +} + +void os_if_nan_event_handler(struct wlan_objmgr_psoc *psoc, + struct wlan_objmgr_vdev *vdev, + uint32_t type, void *msg) +{ + switch (type) { + default: + break; + } +}