qca-wifi: Componentize QWRAP code

Remove dependency of qwrap on VAP layer and radio(ic) layer data
structures and move QWRAP DP code from OSIF to Component DEV.

Change-Id: I0fc975ef4cbac52e1e7fd8a87db3de8f97056ac0

CRs-Fixed: 2832334
This commit is contained in:
Rathees kumar Chinannan
2020-12-30 13:49:59 +05:30
parent 0179c38036
commit 8d8c8e710a
4 changed files with 1906 additions and 0 deletions

392
dp_wrap/inc/dp_wrap.h Normal file
View File

@@ -0,0 +1,392 @@
/*
* Copyright (c) 2020-2021 The Linux Foundation. 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.
*/
#ifndef _DP_WRAP_H_
#define _DP_WRAP_H__
#if ATH_SUPPORT_WRAP
#if !WLAN_QWRAP_LEGACY
#include "dp_wrap_struct.h"
#include <dp_txrx.h>
#include <cdp_txrx_cmn.h>
#include <wlan_osif_priv.h>
/**
* dp_wrap_get_pdev_handle() - get wrap handle from pdev handle
*
* @pdev: handle to the objmgr pdev
* Return: handle to wrap_pdev
*/
static inline
dp_pdev_wrap_t *dp_wrap_get_pdev_handle(struct wlan_objmgr_pdev *pdev)
{
ol_txrx_soc_handle soc;
dp_txrx_pdev_handle_t *dp_hdl;
soc = wlan_psoc_get_dp_handle(wlan_pdev_get_psoc(pdev));
if (qdf_unlikely(!soc)) {
qwrap_err(" soc handle is NULL");
return NULL;
}
dp_hdl = (dp_txrx_pdev_handle_t *)cdp_pdev_get_dp_txrx_handle(soc,
wlan_objmgr_pdev_get_pdev_id(pdev));
if (qdf_unlikely(!dp_hdl)) {
qwrap_err(" dp txrx handle is NULL");
return NULL;
}
return &dp_hdl->wrap_pdev_hdl;
}
/**
* dp_wrap_get_vdev_handle() - get wrap handle from vdev handle
*
* @vdev: handle to the objmgr vdev
* Return: handle to wrap_vdev
*/
static inline
dp_vdev_wrap_t *dp_wrap_get_vdev_handle(struct wlan_objmgr_vdev *vdev)
{
ol_txrx_soc_handle soc;
dp_vdev_txrx_handle_t *dp_hdl;
soc = wlan_psoc_get_dp_handle(
wlan_pdev_get_psoc(wlan_vdev_get_pdev(vdev)));
if (qdf_unlikely(!soc)) {
qwrap_err(" soc handle is NULL");
return NULL;
}
dp_hdl = (dp_vdev_txrx_handle_t *)cdp_vdev_get_dp_ext_txrx_handle(soc,
wlan_vdev_get_id(vdev));
if (qdf_unlikely(!dp_hdl)) {
qwrap_err(" dp txrx handle is NULL");
return NULL;
}
return &dp_hdl->wrap_vdev_hdl;
}
/**
* dp_wrap_get_mpsta_vdev() - get mpsta vdev
*
* @pdev: handle to pdev obj mgr
* Return: mpsta vdev object
*/
static
struct wlan_objmgr_vdev *dp_wrap_get_mpsta_vdev(struct wlan_objmgr_pdev *pdev)
{
struct dp_wrap_pdev *wrap_pdev;
if (!pdev)
return NULL;
wrap_pdev = dp_wrap_get_pdev_handle(pdev);
if (!wrap_pdev)
return NULL;
return wrap_pdev->mpsta_vdev;
}
/**
* dp_wrap_get_vdev() - get mpsta vdev
*
* @pdev: handle to pdev obj mgr
* Return: wrap vdev object
*/
static
struct wlan_objmgr_vdev *dp_wrap_get_vdev(struct wlan_objmgr_pdev *pdev)
{
struct dp_wrap_pdev *wrap_pdev;
if (!pdev)
return NULL;
wrap_pdev = dp_wrap_get_pdev_handle(pdev);
if (!wrap_pdev)
return NULL;
return wrap_pdev->wrap_vdev;
}
/**
* dp_wrap_vdev_is_mat_set() - Indicates whether mat translation is set
*
* @vdev: handle to the objmgr vdev.
* Return: true if mat is set, false otherwise
*/
static inline bool dp_wrap_vdev_is_mat_set(struct wlan_objmgr_vdev *vdev)
{
if (vdev && wlan_vdev_mlme_feat_ext_cap_get(vdev, WLAN_VDEV_FEXT_MAT))
return true;
else
return false;
}
/**
* dp_wrap_vdev_is_wired_psta() - Indicates whether vdev is wired psta.
*
* @vdev: handle to the objmgr vdev.
* Return: true if wired psta, false otherwise.
*/
static inline bool dp_wrap_vdev_is_wired_psta(struct wlan_objmgr_vdev *vdev)
{
if (vdev && wlan_vdev_mlme_feat_ext_cap_get(
vdev, WLAN_VDEV_FEXT_WIRED_PSTA))
return true;
else
return false;
}
/**
* dp_wrap_vdev_is_psta() - Indicates whether vdev is of type PSTA.
*
* @vdev: handle to the objmgr vdev.
* Return: True if psta, false otherwise
*/
static inline bool dp_wrap_vdev_is_psta(struct wlan_objmgr_vdev *vdev)
{
if (vdev && wlan_vdev_mlme_feat_ext_cap_get(vdev, WLAN_VDEV_FEXT_PSTA))
return true;
else
return false;
}
/**
* dp_wrap_vdev_is_mpsta() - Indicates whether vdev is of type MPSTA.
*
* @vdev: handle to the objmgr vdev.
* Return: True if mpsta, false otherwise.
*/
static inline bool dp_wrap_vdev_is_mpsta(struct wlan_objmgr_vdev *vdev)
{
if (vdev && wlan_vdev_mlme_feat_ext_cap_get(
vdev, WLAN_VDEV_FEXT_MPSTA))
return true;
else
return false;
}
/**
* dp_wrap_vdev_is_wrap() - Indicates whether vdev is of type WRAP.
*
* @vdev: handle to the objmgr vdev.
* Return: True if wrap, false otherwise.
*/
static bool dp_wrap_vdev_is_wrap(struct wlan_objmgr_vdev *vdev)
{
if (vdev && wlan_vdev_mlme_feat_ext_cap_get(vdev, WLAN_VDEV_FEXT_WRAP))
return true;
else
return false;
}
/**
* dp_wrap_vdev_get_nwrapvaps() - Get number of wrap vaps
*
* @pdev: handle to the objmgr pdev.
* Return: wrap vaps count
*/
static int dp_wrap_vdev_get_nwrapvaps(struct wlan_objmgr_pdev *pdev)
{
struct dp_wrap_pdev *wpdev;
if (pdev) {
wpdev = dp_wrap_get_pdev_handle(pdev);
if (!wpdev) {
qwrap_err(" wpdev is NULL");
return 0;
}
return wpdev->nwrapvaps;
}
return 0;
}
/**
* dp_wrap_vdev_get_npstavaps() - Get number of psta vaps
*
* @pdev: handle to the objmgr pdev.
* Return: psta vaps count
*/
static int dp_wrap_vdev_get_npstavaps(struct wlan_objmgr_pdev *pdev)
{
struct dp_wrap_pdev *wpdev;
if (pdev) {
wpdev = dp_wrap_get_pdev_handle(pdev);
if (!wpdev) {
qwrap_err(" wpdev is NULL");
return 0;
}
return wpdev->npstavaps;
}
return 0;
}
/**
* dp_wrap_pdev_set_isolation() - set isolation
*
* @pdev: handle to the objmgr pdev.
* @isolation: handle to set isolation param
* Return: void
*/
static void
dp_wrap_pdev_set_isolation(struct wlan_objmgr_pdev *pdev, int isolation)
{
struct dp_wrap_pdev *wpdev;
if (pdev) {
wpdev = dp_wrap_get_pdev_handle(pdev);
if (!wpdev) {
qwrap_err(" wpdev is NULL");
return;
}
wpdev->wp_isolation = isolation;
}
}
/**
* dp_wrap_pdev_get_isolation() - Indicates whether isolation is set
*
* @pdev: handle to the objmgr pdev.
* Return: isolation value
*/
static int dp_wrap_pdev_get_isolation(struct wlan_objmgr_pdev *pdev)
{
struct dp_wrap_pdev *wpdev;
if (pdev) {
wpdev = dp_wrap_get_pdev_handle(pdev);
if (!wpdev) {
qwrap_err(" wpdev is NULL");
return 0;
}
return wpdev->wp_isolation;
}
return 0;
}
/**
* dp_wrap_vdev_get_oma() - Get OMA address of PSTA
*
* @pdev: handle to the objmgr vdev.
* Return: PSTA OMA address
*/
static u_int8_t *dp_wrap_vdev_get_oma(struct wlan_objmgr_vdev *vdev)
{
struct dp_wrap_vdev *wvdev;
if (vdev) {
wvdev = dp_wrap_get_vdev_handle(vdev);
if (!wvdev) {
qwrap_err(" wvdev is NULL");
return NULL;
}
return &wvdev->wrap_dev_oma[0];
}
return NULL;
}
/**
* dp_wrap_vdev_get_vma() - Get VMA address of PSTA
*
* @pdev: handle to the objmgr vdev.
* Return: PSTA VMA address
*/
static u_int8_t *dp_wrap_vdev_get_vma(struct wlan_objmgr_vdev *vdev)
{
struct dp_wrap_vdev *wvdev;
if (vdev) {
wvdev = dp_wrap_get_vdev_handle(vdev);
if (!wvdev) {
qwrap_err(" wvdev is NULL");
return NULL;
}
return &wvdev->wrap_dev_vma[0];
}
return NULL;
}
/**
* @brief Find vdev object based on MAC address.
*
* @param pdev Ptr to pdev obj mgr.
* @param mac MAC address to look up.
*
* @return vdev objmgr on success
* @return NULL on failure
*/
static inline struct wlan_objmgr_vdev *dp_wrap_vdev_vma_find(
struct wlan_objmgr_pdev *pdev, unsigned char *mac)
{
dp_vdev_wrap_t *wrap_vdev;
int hash;
rwlock_state_t lock_state;
struct dp_wrap_pdev *wrap_pdev;
struct dp_wrap_devt *wdt;
if (!pdev)
return NULL;
wrap_pdev = dp_wrap_get_pdev_handle(pdev);
if (!wrap_pdev)
return NULL;
wdt = &wrap_pdev->wp_devt;
hash = WRAP_DEV_HASH(mac);
OS_RWLOCK_READ_LOCK(&wdt->wdt_lock, &lock_state);
LIST_FOREACH(wrap_vdev, &wdt->wdt_hash_vma[hash], wrap_dev_hash_vma) {
if (qdf_is_macaddr_equal((struct qdf_mac_addr *)
wrap_vdev->wrap_dev_vma, (struct qdf_mac_addr *)mac)) {
OS_RWLOCK_READ_UNLOCK(&wdt->wdt_lock, &lock_state);
return wrap_vdev->vdev;
}
}
OS_RWLOCK_READ_UNLOCK(&wdt->wdt_lock, &lock_state);
return NULL;
}
int dp_wrap_attach(struct wlan_objmgr_pdev *pdev);
int dp_wrap_detach(struct wlan_objmgr_pdev *pdev);
void dp_wrap_vdev_attach(struct wlan_objmgr_vdev *vdev);
void dp_wrap_vdev_detach(struct wlan_objmgr_vdev *vdev);
int dp_wrap_dev_add(struct wlan_objmgr_vdev *vdev);
void dp_wrap_vdev_set_psta(struct wlan_objmgr_vdev *vdev);
void dp_wrap_vdev_set_mpsta(struct wlan_objmgr_vdev *vdev);
void dp_wrap_vdev_clear_psta(struct wlan_objmgr_vdev *vdev);
void dp_wrap_vdev_set_wrap(struct wlan_objmgr_vdev *vdev);
void dp_wrap_vdev_clear_wrap(struct wlan_objmgr_vdev *vdev);
void dp_wrap_dev_remove(struct wlan_objmgr_vdev *vdev);
void dp_wrap_dev_remove_vma(struct wlan_objmgr_vdev *vdev);
int dp_wrap_rx_process(struct net_device **dev, struct wlan_objmgr_vdev *vdev,
struct sk_buff *skb, int *nwifi);
int dp_wrap_tx_process(struct net_device **dev, struct wlan_objmgr_vdev *vdev,
struct sk_buff **skb);
int dp_wrap_mat_tx(struct dp_wrap_vdev *wvdev, wbuf_t buf);
int dp_wrap_mat_rx(struct dp_wrap_vdev *wvdev, wbuf_t buf);
void dp_wrap_vdev_set_netdev(struct wlan_objmgr_vdev *vdev,
struct net_device *dev);
void dp_wrap_register_xmit_handler(struct wlan_objmgr_vdev *vdev,
void (*wlan_vdev_xmit_queue)
(struct net_device *dev, wbuf_t wbuf));
#endif
#endif
#endif

View File

@@ -0,0 +1,87 @@
/*
* Copyright (c) 2020-2021 The Linux Foundation. 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.
*/
#ifndef _DP_WRAP_STRUCT_H_
#define _DP_WRAP_STRUCT_H_
#if ATH_SUPPORT_WRAP
#if !WLAN_QWRAP_LEGACY
#include <wbuf.h>
#define WRAP_DEV_HASHSIZE 32 /*dev hash table size*/
/*device table simple hash function*/
#define WRAP_DEV_HASH(addr) \
(((const u_int8_t *)(addr))[QDF_MAC_ADDR_SIZE - 1] % WRAP_DEV_HASHSIZE)
#define qwrap_err(params...) QDF_TRACE_ERROR(QDF_MODULE_ID_WRAP, ## params)
#define qwrap_warn(params...) QDF_TRACE_WARN(QDF_MODULE_ID_WRAP, ## params)
#define qwrap_info(params...) QDF_TRACE_INFO(QDF_MODULE_ID_WRAP, ## params)
#define qwrap_debug(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_WRAP, ## params)
#define qwrap_trace(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_WRAP, ## params)
#define WRAP_ISOLATION_DEFVAL 0
typedef rwlock_t wrap_devt_lock_t;
/*wrap device table*/
typedef struct dp_wrap_devt {
struct dp_wrap_pdev *wrap_pdev;
/*back ptr to wrap pdev*/
wrap_devt_lock_t wdt_lock;
/*lock for dev table*/
TAILQ_HEAD(, dp_wrap_vdev) wdt_dev; /*head for device list*/
ATH_LIST_HEAD(, dp_wrap_vdev) wdt_hash[WRAP_DEV_HASHSIZE];
/*head for device hash*/
TAILQ_HEAD(, dp_wrap_vdev) wdt_dev_vma; /*head for device list*/
ATH_LIST_HEAD(, dp_wrap_vdev) wdt_hash_vma[WRAP_DEV_HASHSIZE];
/*head for device hash*/
} dp_wrap_devt_t;
/*wrap pdev struct*/
typedef struct dp_wrap_pdev {
struct dp_wrap_devt wp_devt; /*wrap device table*/
u_int8_t wp_isolation;
int wp_use_cnt; /*wrap pdev use cnt*/
struct wlan_objmgr_vdev *mpsta_vdev;
struct wlan_objmgr_vdev *wrap_vdev;
struct net_device *mpsta_dev;
u_int8_t nwrapvaps; /* Number of active WRAP APs */
u_int8_t npstavaps;
} dp_pdev_wrap_t;
/*wrap vdev struct*/
typedef struct dp_wrap_vdev {
struct dp_wrap_pdev *wrap_pdev; /*back ptr to wrap pdev*/
struct net_device *dev;
struct wlan_objmgr_vdev *vdev;
bool is_wrap;
bool is_mpsta;
bool is_psta;
bool is_wired_psta;
bool mat_enabled;
unsigned char wrap_dev_oma[ETH_ALEN]; /* dev oma mac address */
unsigned char wrap_dev_vma[ETH_ALEN]; /* dev vma mac address */
TAILQ_ENTRY(dp_wrap_vdev) wrap_dev_list; /*wrap oma dev list entry*/
LIST_ENTRY(dp_wrap_vdev) wrap_dev_hash; /*wrap oma hash list entry*/
TAILQ_ENTRY(dp_wrap_vdev) wrap_dev_list_vma; /*wrap vma dev list*/
LIST_ENTRY(dp_wrap_vdev) wrap_dev_hash_vma; /*wrap vma hash list */
void (*wlan_vdev_xmit_queue)(struct net_device *dev, wbuf_t wbuf);
} dp_vdev_wrap_t;
#endif
#endif
#endif