qcacld-3.0: Add support for packet capture mode
Add support for packet capture mode to monitor packets on WLAN interface. Change-Id: I8409479ef7855d51e303028d7e18e6bf89055407 CRs-Fixed: 2611293
This commit is contained in:

committato da
nshrivas

parent
2ce0391573
commit
9331f42f3e
78
components/pkt_capture/core/inc/wlan_pkt_capture_main.h
Normal file
78
components/pkt_capture/core/inc/wlan_pkt_capture_main.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 2020 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* DOC: Declare private API which shall be used internally only
|
||||
* in pkt_capture component. This file shall include prototypes of
|
||||
* various notification handlers and logging functions.
|
||||
*
|
||||
* Note: This API should be never accessed out of pkt_capture component.
|
||||
*/
|
||||
|
||||
#ifndef _WLAN_PKT_CAPTURE_MAIN_H_
|
||||
#define _WLAN_PKT_CAPTURE_MAIN_H_
|
||||
|
||||
#include <qdf_types.h>
|
||||
#include "wlan_pkt_capture_priv.h"
|
||||
#include "wlan_pkt_capture_objmgr.h"
|
||||
|
||||
#define pkt_capture_log(level, args...) \
|
||||
QDF_TRACE(QDF_MODULE_ID_PKT_CAPTURE, level, ## args)
|
||||
|
||||
#define pkt_capture_logfl(level, format, args...) \
|
||||
pkt_capture_log(level, FL(format), ## args)
|
||||
|
||||
#define pkt_capture_fatal(format, args...) \
|
||||
pkt_capture_logfl(QDF_TRACE_LEVEL_FATAL, format, ## args)
|
||||
#define pkt_capture_err(format, args...) \
|
||||
pkt_capture_logfl(QDF_TRACE_LEVEL_ERROR, format, ## args)
|
||||
#define pkt_capture_warn(format, args...) \
|
||||
pkt_capture_logfl(QDF_TRACE_LEVEL_WARN, format, ## args)
|
||||
#define pkt_capture_info(format, args...) \
|
||||
pkt_capture_logfl(QDF_TRACE_LEVEL_INFO, format, ## args)
|
||||
#define pkt_capture_debug(format, args...) \
|
||||
pkt_capture_logfl(QDF_TRACE_LEVEL_DEBUG, format, ## args)
|
||||
|
||||
#define PKT_CAPTURE_ENTER() pkt_capture_debug("enter")
|
||||
#define PKT_CAPTURE_EXIT() pkt_capture_debug("exit")
|
||||
|
||||
/**
|
||||
* pkt_capture_vdev_create_notification() - Handler for vdev create notify.
|
||||
* @vdev: vdev which is going to be created by objmgr
|
||||
* @arg: argument for notification handler.
|
||||
*
|
||||
* Allocate and attach vdev private object.
|
||||
*
|
||||
* Return: QDF_STATUS status in case of success else return error.
|
||||
*/
|
||||
QDF_STATUS
|
||||
pkt_capture_vdev_create_notification(struct wlan_objmgr_vdev *vdev, void *arg);
|
||||
|
||||
/**
|
||||
* pkt_capture_vdev_destroy_notification() - Handler for vdev destroy notify.
|
||||
* @vdev: vdev which is going to be destroyed by objmgr
|
||||
* @arg: argument for notification handler.
|
||||
*
|
||||
* Deallocate and detach vdev private object.
|
||||
*
|
||||
* Return QDF_STATUS status in case of success else return error
|
||||
*/
|
||||
QDF_STATUS
|
||||
pkt_capture_vdev_destroy_notification(struct wlan_objmgr_vdev *vdev, void *arg);
|
||||
|
||||
#endif /* end of _WLAN_PKT_CAPTURE_MAIN_H_ */
|
81
components/pkt_capture/core/inc/wlan_pkt_capture_objmgr.h
Normal file
81
components/pkt_capture/core/inc/wlan_pkt_capture_objmgr.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) 2020 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* DOC: This file contains various object manager related wrappers and helpers
|
||||
*/
|
||||
|
||||
#ifndef _WLAN_PKT_CAPTURE_OBJMGR_H
|
||||
#define _WLAN_PKT_CAPTURE_OBJMGR_H
|
||||
|
||||
#include "wlan_cmn.h"
|
||||
#include "wlan_objmgr_cmn.h"
|
||||
#include "wlan_objmgr_vdev_obj.h"
|
||||
#include "wlan_objmgr_global_obj.h"
|
||||
|
||||
/**
|
||||
* pkt_capture_vdev_get_ref() - Wrapper to increment pkt_capture ref count
|
||||
* @vdev: vdev object
|
||||
*
|
||||
* Wrapper for pkt_capture to increment ref count after checking valid
|
||||
* object state.
|
||||
*
|
||||
* Return: SUCCESS/FAILURE
|
||||
*/
|
||||
static inline
|
||||
QDF_STATUS pkt_capture_vdev_get_ref(struct wlan_objmgr_vdev *vdev)
|
||||
{
|
||||
return wlan_objmgr_vdev_try_get_ref(vdev, WLAN_PKT_CAPTURE_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* pkt_capture_vdev_put_ref() - Wrapper to decrement pkt_capture ref count
|
||||
* @vdev: vdev object
|
||||
*
|
||||
* Wrapper for pkt_capture to decrement ref count of vdev.
|
||||
*
|
||||
* Return: SUCCESS/FAILURE
|
||||
*/
|
||||
static inline
|
||||
void pkt_capture_vdev_put_ref(struct wlan_objmgr_vdev *vdev)
|
||||
{
|
||||
return wlan_objmgr_vdev_release_ref(vdev, WLAN_PKT_CAPTURE_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* pkt_capture_vdev_get_priv() - Wrapper to retrieve vdev priv obj
|
||||
* @vdev: vdev pointer
|
||||
*
|
||||
* Wrapper for pkt_capture to get vdev private object pointer.
|
||||
*
|
||||
* Return: Private object of vdev
|
||||
*/
|
||||
static inline struct pkt_capture_vdev_priv *
|
||||
pkt_capture_vdev_get_priv(struct wlan_objmgr_vdev *vdev)
|
||||
{
|
||||
struct pkt_capture_vdev_priv *vdev_priv;
|
||||
|
||||
vdev_priv = wlan_objmgr_vdev_get_comp_private_obj(
|
||||
vdev,
|
||||
WLAN_UMAC_COMP_PKT_CAPTURE);
|
||||
QDF_BUG(vdev_priv);
|
||||
|
||||
return vdev_priv;
|
||||
}
|
||||
|
||||
#endif /* _WLAN_PKT_CAPTURE_OBJMGR_H */
|
39
components/pkt_capture/core/inc/wlan_pkt_capture_priv.h
Normal file
39
components/pkt_capture/core/inc/wlan_pkt_capture_priv.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2020 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* DOC: Declare private API which shall be used internally only
|
||||
* in pkt_capture component. This file shall include prototypes of
|
||||
* pkt_capture parsing and send logic.
|
||||
*
|
||||
* Note: This API should be never accessed out of pkt_capture component.
|
||||
*/
|
||||
|
||||
#ifndef _WLAN_PKT_CAPTURE_PRIV_STRUCT_H_
|
||||
#define _WLAN_PKT_CAPTURE_PRIV_STRUCT_H_
|
||||
|
||||
#include "wlan_pkt_capture_objmgr.h"
|
||||
|
||||
/**
|
||||
* struct pkt_capture_vdev_priv - Private object to be stored in vdev
|
||||
* @vdev: pointer to vdev object
|
||||
*/
|
||||
struct pkt_capture_vdev_priv {
|
||||
struct wlan_objmgr_vdev *vdev;
|
||||
};
|
||||
#endif /* End of _WLAN_PKT_CAPTURE_PRIV_STRUCT_H_ */
|
97
components/pkt_capture/core/src/wlan_pkt_capture_main.c
Normal file
97
components/pkt_capture/core/src/wlan_pkt_capture_main.c
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 2020 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* DOC: Implement various notification handlers which are accessed
|
||||
* internally in pkt_capture component only.
|
||||
*/
|
||||
|
||||
#include "wlan_pkt_capture_main.h"
|
||||
|
||||
/**
|
||||
* pkt_capture_vdev_create_notification() - Handler for vdev create notify.
|
||||
* @vdev: vdev which is going to be created by objmgr
|
||||
* @arg: argument for notification handler.
|
||||
*
|
||||
* Allocate and attach vdev private object.
|
||||
*
|
||||
* Return: QDF_STATUS status in case of success else return error.
|
||||
*/
|
||||
QDF_STATUS
|
||||
pkt_capture_vdev_create_notification(struct wlan_objmgr_vdev *vdev, void *arg)
|
||||
{
|
||||
struct pkt_capture_vdev_priv *vdev_priv;
|
||||
QDF_STATUS status;
|
||||
|
||||
vdev_priv = qdf_mem_malloc(sizeof(*vdev_priv));
|
||||
if (!vdev_priv) {
|
||||
status = QDF_STATUS_E_NOMEM;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
status = wlan_objmgr_vdev_component_obj_attach(
|
||||
vdev,
|
||||
WLAN_UMAC_COMP_PKT_CAPTURE,
|
||||
(void *)vdev_priv, QDF_STATUS_SUCCESS);
|
||||
if (!QDF_IS_STATUS_SUCCESS(status)) {
|
||||
pkt_capture_err("Failed to attach priv with vdev");
|
||||
goto free_vdev_priv;
|
||||
}
|
||||
|
||||
vdev_priv->vdev = vdev;
|
||||
goto exit;
|
||||
|
||||
free_vdev_priv:
|
||||
qdf_mem_free(vdev_priv);
|
||||
status = QDF_STATUS_E_INVAL;
|
||||
exit:
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* pkt_capture_vdev_destroy_notification() - Handler for vdev destroy notify.
|
||||
* @vdev: vdev which is going to be destroyed by objmgr
|
||||
* @arg: argument for notification handler.
|
||||
*
|
||||
* Deallocate and detach vdev private object.
|
||||
*
|
||||
* Return QDF_STATUS status in case of success else return error
|
||||
*/
|
||||
QDF_STATUS
|
||||
pkt_capture_vdev_destroy_notification(struct wlan_objmgr_vdev *vdev, void *arg)
|
||||
{
|
||||
struct pkt_capture_vdev_priv *vdev_priv = NULL;
|
||||
QDF_STATUS status = QDF_STATUS_E_FAILURE;
|
||||
|
||||
vdev_priv = pkt_capture_vdev_get_priv(vdev);
|
||||
if (!vdev_priv) {
|
||||
pkt_capture_err("vdev priv is NULL");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
status = wlan_objmgr_vdev_component_obj_detach(
|
||||
vdev,
|
||||
WLAN_UMAC_COMP_PKT_CAPTURE,
|
||||
(void *)vdev_priv);
|
||||
if (!QDF_IS_STATUS_SUCCESS(status))
|
||||
pkt_capture_err("Failed to detach priv with psoc");
|
||||
|
||||
qdf_mem_free(vdev_priv);
|
||||
exit:
|
||||
return status;
|
||||
}
|
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2020 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* DOC: Declare public API related to the pkt_capture called by north bound
|
||||
* HDD/OSIF/LIM
|
||||
*/
|
||||
|
||||
#ifndef _WLAN_PKT_CAPTURE_UCFG_API_H_
|
||||
#define _WLAN_PKT_CAPTURE_UCFG_API_H_
|
||||
|
||||
#include <qdf_status.h>
|
||||
#include <qdf_types.h>
|
||||
#include "wlan_pkt_capture_objmgr.h"
|
||||
|
||||
#ifdef WLAN_FEATURE_PKT_CAPTURE
|
||||
/**
|
||||
* ucfg_pkt_capture_init() - Packet capture component initialization.
|
||||
*
|
||||
* This function gets called when packet capture initializing.
|
||||
*
|
||||
* Return: QDF_STATUS_SUCCESS - in case of success.
|
||||
*/
|
||||
QDF_STATUS ucfg_pkt_capture_init(void);
|
||||
|
||||
/**
|
||||
* ucfg_pkt_capture_deinit() - Packet capture component de-init.
|
||||
*
|
||||
* This function gets called when packet capture de-init.
|
||||
*
|
||||
* Return: None
|
||||
*/
|
||||
void ucfg_pkt_capture_deinit(void);
|
||||
#else
|
||||
static inline
|
||||
QDF_STATUS ucfg_pkt_capture_init(void)
|
||||
{
|
||||
return QDF_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static inline
|
||||
void ucfg_pkt_capture_deinit(void)
|
||||
{
|
||||
}
|
||||
#endif /* WLAN_FEATURE_PKT_CAPTURE */
|
||||
#endif /* _WLAN_PKT_CAPTURE_UCFG_API_H_ */
|
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (c) 2020 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* DOC: Public API implementation of pkt_capture called by north bound HDD/OSIF.
|
||||
*/
|
||||
|
||||
#include "wlan_pkt_capture_objmgr.h"
|
||||
#include "wlan_pkt_capture_main.h"
|
||||
#include "wlan_pkt_capture_ucfg_api.h"
|
||||
|
||||
/**
|
||||
* ucfg_pkt_capture_init() - Packet capture component initialization.
|
||||
*
|
||||
* This function gets called when packet capture initializing.
|
||||
*
|
||||
* Return: QDF_STATUS_SUCCESS - in case of success.
|
||||
*/
|
||||
QDF_STATUS ucfg_pkt_capture_init(void)
|
||||
{
|
||||
QDF_STATUS status;
|
||||
|
||||
status = wlan_objmgr_register_vdev_create_handler(
|
||||
WLAN_UMAC_COMP_PKT_CAPTURE,
|
||||
pkt_capture_vdev_create_notification, NULL);
|
||||
if (!QDF_IS_STATUS_SUCCESS(status)) {
|
||||
pkt_capture_err("Failed to register vdev create handler");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
status = wlan_objmgr_register_vdev_destroy_handler(
|
||||
WLAN_UMAC_COMP_PKT_CAPTURE,
|
||||
pkt_capture_vdev_destroy_notification, NULL);
|
||||
if (QDF_IS_STATUS_SUCCESS(status)) {
|
||||
pkt_capture_debug("vdev create/del notifications registered");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
pkt_capture_err("Failed to register vdev delete handler");
|
||||
wlan_objmgr_unregister_vdev_create_handler(
|
||||
WLAN_UMAC_COMP_PKT_CAPTURE,
|
||||
pkt_capture_vdev_create_notification,
|
||||
NULL);
|
||||
exit:
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* ucfg_pkt_capture_deinit() - Packet capture component de-init.
|
||||
*
|
||||
* This function gets called when packet capture de-init.
|
||||
*
|
||||
* Return: None
|
||||
*/
|
||||
void ucfg_pkt_capture_deinit(void)
|
||||
{
|
||||
QDF_STATUS status;
|
||||
|
||||
status = wlan_objmgr_unregister_vdev_create_handler(
|
||||
WLAN_UMAC_COMP_PKT_CAPTURE,
|
||||
pkt_capture_vdev_create_notification, NULL);
|
||||
if (!QDF_IS_STATUS_SUCCESS(status))
|
||||
pkt_capture_err("Failed to unregister vdev create handler");
|
||||
|
||||
status = wlan_objmgr_unregister_vdev_destroy_handler(
|
||||
WLAN_UMAC_COMP_PKT_CAPTURE,
|
||||
pkt_capture_vdev_destroy_notification,
|
||||
NULL);
|
||||
if (!QDF_IS_STATUS_SUCCESS(status))
|
||||
pkt_capture_err("Failed to unregister vdev delete handler");
|
||||
}
|
Fai riferimento in un nuovo problema
Block a user