qcacmn: Add support to initiate PASN authentication request

Register OSIF callbacks with Wifi_pos module to initiate PASN
authentication request.

Call cfg80211_pasn_auth_request() to initiate PASN authentication
from wpa_supplicant for the list of secure peers.

Change-Id: I52b9518526f1b04ad520f2f19c7a4caa9b62b6b0
CRs-Fixed: 3149968
This commit is contained in:
Pragaspathi Thilagaraj
2022-06-15 18:35:54 +05:30
committed by Madan Koyyalamudi
parent debe4c7ecf
commit 957b6d2307
8 changed files with 353 additions and 19 deletions

View File

@@ -1,5 +1,6 @@
/*
* Copyright (c) 2012-2017, 2020 The Linux Foundation. All rights reserved.
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
@@ -25,7 +26,8 @@
#include "qdf_types.h"
#include "qdf_status.h"
#include <wlan_objmgr_cmn.h>
#include "wifi_pos_public_struct.h"
/* forward declaration */
struct wifi_pos_ch_info;
@@ -283,4 +285,30 @@ enum cld80211_sub_attr_peer_info {
CLD80211_SUB_ATTR_PEER_AFTER_LAST - 1
};
#endif
#if defined(WIFI_POS_CONVERGED) && defined(WLAN_FEATURE_RTT_11AZ_SUPPORT)
/**
* os_if_wifi_pos_initiate_pasn_auth() - Initiate PASN authentication from
* userspace
* @vdev: Vdev object pointer
* @pasn_peer: PASN Peer list
* @num_pasn_peers: number of PASN peers
* @is_initiate_pasn: Initiate pasn or initiate flush keys
*
* Return: QDF_STATUS
*/
QDF_STATUS os_if_wifi_pos_initiate_pasn_auth(struct wlan_objmgr_vdev *vdev,
struct wlan_pasn_request *pasn_peer,
uint8_t num_pasn_peers,
bool is_initiate_pasn);
#else
static inline
QDF_STATUS os_if_wifi_pos_initiate_pasn_auth(struct wlan_objmgr_vdev *vdev,
struct wlan_pasn_request *pasn_peer,
uint8_t num_pasn_peers,
bool is_initiate_pasn)
{
return QDF_STATUS_E_NOSUPPORT;
}
#endif /* WLAN_FEATURE_RTT_11AZ_SUPPORT */
#endif /* _OS_IF_WIFI_POS_H_ */

View File

@@ -0,0 +1,72 @@
/*
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/**
* DOC: os_if_wifi_pos_utils.h
* This file provide declaration of wifi_pos's os_if APIs
*/
#ifndef _OS_IF_WIFI_POS_UTILS_H_
#define _OS_IF_WIFI_POS_UTILS_H_
#include "qdf_types.h"
#include "qdf_status.h"
#include <wlan_objmgr_cmn.h>
#if defined(WIFI_POS_CONVERGED) && defined(WLAN_FEATURE_RTT_11AZ_SUPPORT)
/**
* struct wifi_pos_osif_ops - Wifi POS osif callbacks
* @osif_initiate_pasn_cb: Callback to initiate PASN authentication
*/
struct wifi_pos_osif_ops {
QDF_STATUS (*osif_initiate_pasn_cb)(struct wlan_objmgr_vdev *vdev,
struct wlan_pasn_request *pasn_peer,
uint8_t num_pasn_peers,
bool is_initiate_pasn);
};
#endif
#if defined(WIFI_POS_CONVERGED) && defined(WLAN_FEATURE_RTT_11AZ_SUPPORT)
/**
* osif_wifi_pos_register_ops() - Register Wifi-Pos module OS_IF callbacks
* @psoc: Pointer to PSOC obj
*
* Return: QDF_STATUS
*/
QDF_STATUS
osif_wifi_pos_register_ops(struct wlan_objmgr_psoc *psoc);
/**
* osif_wifi_pos_deregister_ops - Deregister the wifi pos OS_IF callbacks
* @psoc: Pointer to PSOC obj
*
* Return: QDF_STATUS
*/
QDF_STATUS
osif_wifi_pos_deregister_ops(struct wlan_objmgr_psoc *psoc);
#else
static inline QDF_STATUS
osif_wifi_pos_register_ops(struct wlan_objmgr_psoc *psoc)
{
return QDF_STATUS_SUCCESS;
}
static inline QDF_STATUS
osif_wifi_pos_deregister_ops(struct wlan_objmgr_psoc *psoc)
{
return QDF_STATUS_SUCCESS;
}
#endif /* WIFI_POS_CONVERGED */
#endif /* _OS_IF_WIFI_POS_UTILS_H_ */

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2012-2021 The Linux Foundation. All rights reserved.
* Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
@@ -33,6 +33,7 @@
#include "wifi_pos_api.h"
#include "wlan_cfg80211.h"
#include "wlan_objmgr_psoc_obj.h"
#include "wlan_osif_priv.h"
#ifdef CNSS_GENL
#ifdef CONFIG_CNSS_OUT_OF_TREE
#include "cnss_nl.h"
@@ -1083,3 +1084,66 @@ int os_if_wifi_pos_populate_caps(struct wlan_objmgr_psoc *psoc,
return qdf_status_to_os_return(wifi_pos_populate_caps(psoc, caps));
}
#if defined(WIFI_POS_CONVERGED) && defined(WLAN_FEATURE_RTT_11AZ_SUPPORT)
QDF_STATUS
os_if_wifi_pos_initiate_pasn_auth(struct wlan_objmgr_vdev *vdev,
struct wlan_pasn_request *pasn_peer,
uint8_t num_pasn_peers,
bool is_initiate_pasn)
{
struct net_device *netdev;
struct cfg80211_pasn_params *pasn_params;
struct vdev_osif_priv *osif_priv;
int i, ret;
QDF_STATUS status = QDF_STATUS_SUCCESS;
osif_priv = wlan_vdev_get_ospriv(vdev);
if (!osif_priv) {
osif_err("OSIF priv is NULL");
return QDF_STATUS_E_FAILURE;
}
netdev = osif_priv->wdev->netdev;
pasn_params = qdf_mem_malloc(sizeof(*pasn_params) +
(num_pasn_peers *
sizeof(struct pasn_peer)));
if (!pasn_params)
return QDF_STATUS_E_NOMEM;
pasn_params->action = (is_initiate_pasn ?
NL80211_PASN_ACTION_AUTH : NL80211_PASN_ACTION_DEAUTH);
pasn_params->num_pasn_peers = num_pasn_peers;
for (i = 0; i < num_pasn_peers; i++) {
qdf_mem_copy(pasn_params->peer[i].peer_addr,
pasn_peer[i].peer_mac.bytes,
QDF_MAC_ADDR_SIZE);
qdf_mem_copy(pasn_params->peer[i].src_addr,
pasn_peer[i].self_mac.bytes,
QDF_MAC_ADDR_SIZE);
if (pasn_peer[i].force_self_mac_usage)
pasn_params->peer[i].flags = PASN_PEER_USE_SRC_MAC;
osif_debug("PASN peer_mac[%d]:" QDF_MAC_ADDR_FMT " src_mac:" QDF_MAC_ADDR_FMT,
i,
QDF_MAC_ADDR_REF(pasn_params->peer[i].peer_addr),
QDF_MAC_ADDR_REF(pasn_params->peer[i].src_addr));
}
osif_debug("action:%d num_pasn_peers:%d", pasn_params->action,
pasn_params->num_pasn_peers);
ret = cfg80211_pasn_auth_request(netdev, pasn_params,
qdf_mem_malloc_flags());
if (ret) {
status = qdf_status_from_os_return(ret);
osif_err("PASN Auth request failed");
}
qdf_mem_free(pasn_params);
return status;
}
#endif /* WIFI_POS_CONVERGED && WLAN_FEATURE_RTT_11AZ_SUPPORT */

View File

@@ -0,0 +1,44 @@
/*
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/**
* DOC: os_if_wifi_pos_utils.c
* This file defines the important functions pertinent to wifi positioning
* component's os_if layer.
*/
#include "wlan_objmgr_psoc_obj.h"
#include "os_if_wifi_pos_utils.h"
#include "wifi_pos_ucfg_i.h"
#include "os_if_wifi_pos.h"
#if defined(WIFI_POS_CONVERGED) && defined(WLAN_FEATURE_RTT_11AZ_SUPPORT)
static struct wifi_pos_osif_ops osif_ops = {
.osif_initiate_pasn_cb = os_if_wifi_pos_initiate_pasn_auth,
};
QDF_STATUS
osif_wifi_pos_register_ops(struct wlan_objmgr_psoc *psoc)
{
return ucfg_wifi_pos_register_osif_callbacks(psoc, &osif_ops);
}
QDF_STATUS
osif_wifi_pos_deregister_ops(struct wlan_objmgr_psoc *psoc)
{
return ucfg_wifi_pos_deregister_osif_callbacks(psoc);
}
#endif

View File

@@ -638,4 +638,26 @@ QDF_STATUS wifi_pos_send_report_resp(struct wlan_objmgr_psoc *psoc,
QDF_STATUS wifi_pos_convert_host_pdev_id_to_target(
struct wlan_objmgr_psoc *psoc, uint32_t host_pdev_id,
uint32_t *target_pdev_id);
#endif
#ifdef WIFI_POS_CONVERGED
/**
* wifi_pos_register_osif_callbacks() - Register OSIF callbacks
* @psoc: Pointer to psoc object
* @ops: Osif callbacks pointer
*
* Return: QDF_STATUS
*/
QDF_STATUS
wifi_pos_register_osif_callbacks(struct wlan_objmgr_psoc *psoc,
struct wifi_pos_osif_ops *ops);
/**
* wifi_pos_get_osif_callbacks() - Get OS IF callbacks
* @psoc: Pointer to PSOC object
*
* Return: struct wifi_pos_osif_ops pointer
*/
struct wifi_pos_osif_ops *
wifi_pos_get_osif_callbacks(struct wlan_objmgr_psoc *psoc);
#endif /* WIFI_POS_CONVERGED */
#endif /* _WIFI_POS_API_H_ */

View File

@@ -253,6 +253,7 @@ struct wifi_pos_legacy_ops {
* @dma_cfg: DMA ring cfg to be programmed to firmware
* @dma_buf_pool: DMA buffer pools maintained at host: this will be 2-D array
* where with num_rows = number of rings num_elements in each row = ring depth
* @osif_cb: Callbacks to OS_IF
* @wifi_pos_lock: lock to access wifi pos priv object
* @oem_6g_support_disable: oem target 6ghz support is disabled if set
* @wifi_pos_req_handler: function pointer to handle TLV or non-TLV
@@ -305,6 +306,8 @@ struct wifi_pos_psoc_priv_obj {
struct wifi_pos_dma_rings_cfg *dma_cfg;
struct wifi_pos_dma_buf_info **dma_buf_pool;
struct wifi_pos_osif_ops *osif_cb;
qdf_spinlock_t wifi_pos_lock;
bool oem_6g_support_disable;
struct wifi_pos_legacy_ops *legacy_ops;

View File

@@ -30,6 +30,7 @@
#include "wlan_objmgr_cmn.h"
#include "wlan_objmgr_global_obj.h"
#include "wlan_objmgr_psoc_obj.h"
#include "wlan_objmgr_peer_obj.h"
#include "wlan_lmac_if_def.h"
struct wlan_lmac_if_wifi_pos_rx_ops *
@@ -612,3 +613,34 @@ QDF_STATUS wifi_pos_register_send_action(
return QDF_STATUS_SUCCESS;
}
QDF_STATUS
wifi_pos_register_osif_callbacks(struct wlan_objmgr_psoc *psoc,
struct wifi_pos_osif_ops *ops)
{
struct wifi_pos_psoc_priv_obj *wifi_pos_obj =
wifi_pos_get_psoc_priv_obj(psoc);
if (!wifi_pos_obj) {
wifi_pos_err("wifi_pos priv obj is null");
return QDF_STATUS_E_NULL_VALUE;
}
wifi_pos_obj->osif_cb = ops;
return QDF_STATUS_SUCCESS;
}
struct wifi_pos_osif_ops *
wifi_pos_get_osif_callbacks(struct wlan_objmgr_psoc *psoc)
{
struct wifi_pos_psoc_priv_obj *wifi_pos_obj =
wifi_pos_get_psoc_priv_obj(psoc);
if (!wifi_pos_obj) {
wifi_pos_err("wifi_pos priv obj is null");
return NULL;
}
return wifi_pos_obj->osif_cb;
}

View File

@@ -118,7 +118,7 @@ void wifi_pos_add_peer_to_list(struct wlan_objmgr_vdev *vdev,
wifi_pos_debug("Added %s peer: " QDF_MAC_ADDR_FMT " at idx[%d]",
(req->peer_type == WLAN_WIFI_POS_PASN_SECURE_PEER) ? "secure" : "unsecure",
QDF_MAC_ADDR_REF(mac_addr), i);
QDF_MAC_ADDR_REF(dst_entry->peer_mac.bytes), i);
break;
}
@@ -211,11 +211,12 @@ void wifi_pos_move_peers_to_fail_list(struct wlan_objmgr_vdev *vdev,
static QDF_STATUS
wifi_pos_request_external_pasn_auth(struct wlan_objmgr_psoc *psoc,
struct wlan_objmgr_vdev *vdev)
struct wlan_objmgr_vdev *vdev,
struct wlan_pasn_request *peer_list,
uint8_t num_peers)
{
struct wifi_pos_vdev_priv_obj *vdev_pos_obj;
struct wifi_pos_osif_ops *osif_cb;
struct wifi_pos_11az_context *pasn_context;
QDF_STATUS status;
if (wlan_vdev_mlme_get_opmode(vdev) != QDF_STA_MODE)
@@ -234,12 +235,39 @@ wifi_pos_request_external_pasn_auth(struct wlan_objmgr_psoc *psoc,
return QDF_STATUS_E_FAILURE;
}
pasn_context = &vdev_pos_obj->pasn_context;
status = osif_cb->osif_initiate_pasn_cb(vdev, peer_list,
num_peers, true);
if (QDF_IS_STATUS_ERROR(status))
wifi_pos_err("Initiate PASN auth failed");
status = osif_cb->osif_initiate_pasn_cb(vdev,
pasn_context->secure_peer_list,
pasn_context->num_secure_peers,
true);
return status;
}
static QDF_STATUS
wifi_pos_request_flush_pasn_keys(struct wlan_objmgr_psoc *psoc,
struct wlan_objmgr_vdev *vdev,
struct wlan_pasn_request *peer_list,
uint8_t num_peers)
{
struct wifi_pos_vdev_priv_obj *vdev_pos_obj;
struct wifi_pos_osif_ops *osif_cb;
QDF_STATUS status;
osif_cb = wifi_pos_get_osif_callbacks(psoc);
if (!osif_cb || !osif_cb->osif_initiate_pasn_cb) {
wifi_pos_err("OSIF %s cb is NULL",
!osif_cb ? "" : "PASN");
return QDF_STATUS_E_FAILURE;
}
vdev_pos_obj = wifi_pos_get_vdev_priv_obj(vdev);
if (!vdev_pos_obj) {
wifi_pos_err("Wifi pos vdev priv obj is null");
return QDF_STATUS_E_FAILURE;
}
status = osif_cb->osif_initiate_pasn_cb(vdev, peer_list, num_peers,
false);
return status;
}
@@ -252,10 +280,13 @@ wifi_pos_check_and_initiate_pasn_authentication(struct wlan_objmgr_psoc *psoc,
struct qdf_mac_addr bcast_mac = QDF_MAC_ADDR_BCAST_INIT;
QDF_STATUS status;
if (pasn_ctx->num_pending_peer_creation)
if (pasn_ctx->num_pending_peer_creation ||
!pasn_ctx->num_secure_peers)
return QDF_STATUS_SUCCESS;
status = wifi_pos_request_external_pasn_auth(psoc, vdev);
status = wifi_pos_request_external_pasn_auth(psoc, vdev,
pasn_ctx->secure_peer_list,
pasn_ctx->num_secure_peers);
if (QDF_IS_STATUS_ERROR(status)) {
wifi_pos_err("Initiate Pasn Authentication failed");
wifi_pos_move_peers_to_fail_list(vdev, &bcast_mac,
@@ -342,8 +373,11 @@ QDF_STATUS wifi_pos_handle_ranging_peer_create(struct wlan_objmgr_psoc *psoc,
}
/*
* This condition occurs when firmware requests for PASN peer
* create with all PASN peers which are already created.
* If peer already exists for all the entries provided in the request,
* then fw peer create will not be sent again. Just the secure list
* will be updated and num_pending_peer_creation will be 0.
* In this case initiate the PASN auth directly without waiting for
* peer create response.
*/
pasn_context = &vdev_pos_obj->pasn_context;
status = wifi_pos_check_and_initiate_pasn_authentication(psoc, vdev,
@@ -383,7 +417,7 @@ wifi_pos_handle_ranging_peer_create_rsp(struct wlan_objmgr_psoc *psoc,
pasn_context->num_pending_peer_creation--;
wifi_pos_debug("Received peer create response for " QDF_MAC_ADDR_FMT " status:%d pending_count:%d",
QDF_MAC_ADDR_REF(peer_mac.bytes), peer_create_status,
QDF_MAC_ADDR_REF(peer_mac->bytes), peer_create_status,
pasn_context->num_pending_peer_creation);
if (peer_create_status)
wifi_pos_move_peers_to_fail_list(vdev, peer_mac,
@@ -403,7 +437,10 @@ QDF_STATUS wifi_pos_handle_ranging_peer_delete(struct wlan_objmgr_psoc *psoc,
{
struct wifi_pos_legacy_ops *legacy_cb;
struct wlan_objmgr_peer *peer;
struct wlan_pasn_request *del_peer_list;
struct wlan_objmgr_vdev *vdev;
bool no_fw_peer_delete;
uint8_t peer_count = 0, i;
QDF_STATUS status = QDF_STATUS_SUCCESS;
legacy_cb = wifi_pos_get_legacy_ops(psoc);
@@ -412,6 +449,10 @@ QDF_STATUS wifi_pos_handle_ranging_peer_delete(struct wlan_objmgr_psoc *psoc,
return QDF_STATUS_E_FAILURE;
}
del_peer_list = qdf_mem_malloc(sizeof(*del_peer_list) * total_entries);
if (!del_peer_list)
return QDF_STATUS_E_NOMEM;
for (i = 0; i < total_entries; i++) {
peer = wlan_objmgr_get_peer_by_mac(psoc, req[i].peer_mac.bytes,
WLAN_WIFI_POS_CORE_ID);
@@ -421,6 +462,10 @@ QDF_STATUS wifi_pos_handle_ranging_peer_delete(struct wlan_objmgr_psoc *psoc,
req[i].control_flags);
wifi_pos_debug("Delete PASN Peer: " QDF_MAC_ADDR_FMT,
QDF_MAC_ADDR_REF(req[i].peer_mac.bytes));
del_peer_list[peer_count] = req[i];
peer_count++;
status = legacy_cb->pasn_peer_delete_cb(
psoc, &req[i].peer_mac,
vdev_id, no_fw_peer_delete);
@@ -439,5 +484,29 @@ QDF_STATUS wifi_pos_handle_ranging_peer_delete(struct wlan_objmgr_psoc *psoc,
}
}
return QDF_STATUS_SUCCESS;
if (!peer_count) {
wifi_pos_debug("No Peers to delete ");
goto no_peer;
}
vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, vdev_id,
WLAN_WIFI_POS_CORE_ID);
if (!vdev) {
wifi_pos_err("Vdev object is null");
qdf_mem_free(del_peer_list);
return QDF_STATUS_E_FAILURE;
}
status = wifi_pos_request_flush_pasn_keys(psoc, vdev,
del_peer_list,
peer_count);
if (QDF_IS_STATUS_ERROR(status))
wifi_pos_err("Failed to indicate peer deauth to userspace");
wlan_objmgr_vdev_release_ref(vdev, WLAN_WIFI_POS_CORE_ID);
no_peer:
qdf_mem_free(del_peer_list);
return status;
}