diff --git a/components/pkt_capture/core/inc/wlan_pkt_capture_main.h b/components/pkt_capture/core/inc/wlan_pkt_capture_main.h index b6b328338247..9561217bc6ab 100644 --- a/components/pkt_capture/core/inc/wlan_pkt_capture_main.h +++ b/components/pkt_capture/core/inc/wlan_pkt_capture_main.h @@ -201,6 +201,16 @@ void pkt_capture_record_channel(struct wlan_objmgr_vdev *vdev); void pkt_capture_mon(struct pkt_capture_cb_context *cb_ctx, qdf_nbuf_t msdu, struct wlan_objmgr_vdev *vdev, uint16_t ch_freq); +/** + * pkt_capture_set_filter - Set packet capture frame filter + * @frame_filter: pkt capture frame filter data + * @vdev: pointer to vdev + * + * Return: QDF_STATUS + */ +QDF_STATUS pkt_capture_set_filter(struct pkt_capture_frame_filter frame_filter, + struct wlan_objmgr_vdev *vdev); + #ifdef WLAN_FEATURE_PKT_CAPTURE_V2 /** * pkt_capture_get_pktcap_mode_v2 - Get packet capture mode diff --git a/components/pkt_capture/core/inc/wlan_pkt_capture_priv.h b/components/pkt_capture/core/inc/wlan_pkt_capture_priv.h index 26e3bd4c4031..8f375535b464 100644 --- a/components/pkt_capture/core/inc/wlan_pkt_capture_priv.h +++ b/components/pkt_capture/core/inc/wlan_pkt_capture_priv.h @@ -58,6 +58,7 @@ struct pkt_capture_cb_context { * @cb_ctx: pointer to packet capture mon callback context * @rx_ops: rx ops * @tx_ops: tx ops + * @frame_filter: config filter set by vendor command * @rx_avg_rssi: avg rssi of rx data packets * @ppdu_stats_q: list used for storing smu related ppdu stats * @lock_q: spinlock for ppdu_stats q @@ -69,6 +70,7 @@ struct pkt_capture_vdev_priv { struct pkt_capture_cb_context *cb_ctx; struct wlan_pkt_capture_rx_ops rx_ops; struct wlan_pkt_capture_tx_ops tx_ops; + struct pkt_capture_frame_filter frame_filter; int32_t rx_avg_rssi; qdf_list_t ppdu_stats_q; qdf_spinlock_t lock_q; diff --git a/components/pkt_capture/core/src/wlan_pkt_capture_main.c b/components/pkt_capture/core/src/wlan_pkt_capture_main.c index 3e2703e2043d..c896686c9056 100644 --- a/components/pkt_capture/core/src/wlan_pkt_capture_main.c +++ b/components/pkt_capture/core/src/wlan_pkt_capture_main.c @@ -977,3 +977,57 @@ void pkt_capture_record_channel(struct wlan_objmgr_vdev *vdev) cdp_txrx_set_pdev_param(soc, wlan_objmgr_pdev_get_pdev_id(pdev), CDP_MONITOR_FREQUENCY, val); } + +QDF_STATUS pkt_capture_set_filter(struct pkt_capture_frame_filter frame_filter, + struct wlan_objmgr_vdev *vdev) +{ + struct pkt_capture_vdev_priv *vdev_priv; + + if (!vdev) { + pkt_capture_err("vdev is NULL"); + return QDF_STATUS_E_FAILURE; + } + + vdev_priv = pkt_capture_vdev_get_priv(vdev); + if (!vdev_priv) { + pkt_capture_err("vdev_priv is NULL"); + return QDF_STATUS_E_FAILURE; + } + + if (frame_filter.vendor_attr_to_set & + BIT(PKT_CAPTURE_ATTR_SET_MONITOR_MODE_DATA_TX_FRAME_TYPE)) + vdev_priv->frame_filter.data_tx_frame_filter = + frame_filter.data_tx_frame_filter; + + if (frame_filter.vendor_attr_to_set & + BIT(PKT_CAPTURE_ATTR_SET_MONITOR_MODE_DATA_RX_FRAME_TYPE)) + vdev_priv->frame_filter.data_rx_frame_filter = + frame_filter.data_rx_frame_filter; + + if (frame_filter.vendor_attr_to_set & + BIT(PKT_CAPTURE_ATTR_SET_MONITOR_MODE_MGMT_TX_FRAME_TYPE)) + vdev_priv->frame_filter.mgmt_tx_frame_filter = + frame_filter.mgmt_tx_frame_filter; + + if (frame_filter.vendor_attr_to_set & + BIT(PKT_CAPTURE_ATTR_SET_MONITOR_MODE_MGMT_RX_FRAME_TYPE)) + vdev_priv->frame_filter.mgmt_rx_frame_filter = + frame_filter.mgmt_rx_frame_filter; + + if (frame_filter.vendor_attr_to_set & + BIT(PKT_CAPTURE_ATTR_SET_MONITOR_MODE_CTRL_TX_FRAME_TYPE)) + vdev_priv->frame_filter.ctrl_tx_frame_filter = + frame_filter.ctrl_tx_frame_filter; + + if (frame_filter.vendor_attr_to_set & + BIT(PKT_CAPTURE_ATTR_SET_MONITOR_MODE_CTRL_RX_FRAME_TYPE)) + vdev_priv->frame_filter.ctrl_rx_frame_filter = + frame_filter.ctrl_rx_frame_filter; + + if (frame_filter.vendor_attr_to_set & + BIT(PKT_CAPTURE_ATTR_SET_MONITOR_MODE_CONNECTED_BEACON_INTERVAL)) + vdev_priv->frame_filter.connected_beacon_interval = + frame_filter.connected_beacon_interval; + + return QDF_STATUS_SUCCESS; +} diff --git a/components/pkt_capture/dispatcher/inc/wlan_pkt_capture_public_structs.h b/components/pkt_capture/dispatcher/inc/wlan_pkt_capture_public_structs.h index 4fdad87bd43f..acc1656b7877 100644 --- a/components/pkt_capture/dispatcher/inc/wlan_pkt_capture_public_structs.h +++ b/components/pkt_capture/dispatcher/inc/wlan_pkt_capture_public_structs.h @@ -19,6 +19,10 @@ #ifndef _WLAN_PKT_CAPTURE_PUBLIC_STRUCTS_H_ #define _WLAN_PKT_CAPTURE_PUBLIC_STRUCTS_H_ +#define PACKET_CAPTURE_DATA_MAX_FILTER BIT(18) +#define PACKET_CAPTURE_MGMT_MAX_FILTER BIT(5) +#define PACKET_CAPTURE_CTRL_MAX_FILTER BIT(3) + /** * enum pkt_capture_mode - packet capture modes * @PACKET_CAPTURE_MODE_DISABLE: packet capture mode disable @@ -124,4 +128,124 @@ struct wlan_pkt_capture_rx_ops { (struct wlan_objmgr_psoc *psoc); }; +/** + * pkt_capture_data_frame_type - Represent the various + * data types to be filtered in packet capture. + */ +enum pkt_capture_data_frame_type { + PKT_CAPTURE_DATA_FRAME_TYPE_ALL = BIT(0), + /* valid only if PKT_CAPTURE_DATA_DATA_FRAME_TYPE_ALL is not set */ + PKT_CAPTURE_DATA_FRAME_TYPE_ARP = BIT(1), + PKT_CAPTURE_DATA_FRAME_TYPE_DHCPV4 = BIT(2), + PKT_CAPTURE_DATA_FRAME_TYPE_DHCPV6 = BIT(3), + PKT_CAPTURE_DATA_FRAME_TYPE_EAPOL = BIT(4), + PKT_CAPTURE_DATA_FRAME_TYPE_DNSV4 = BIT(5), + PKT_CAPTURE_DATA_FRAME_TYPE_DNSV6 = BIT(6), + PKT_CAPTURE_DATA_FRAME_TYPE_TCP_SYN = BIT(7), + PKT_CAPTURE_DATA_FRAME_TYPE_TCP_SYNACK = BIT(8), + PKT_CAPTURE_DATA_FRAME_TYPE_TCP_FIN = BIT(9), + PKT_CAPTURE_DATA_FRAME_TYPE_TCP_FINACK = BIT(10), + PKT_CAPTURE_DATA_FRAME_TYPE_TCP_ACK = BIT(11), + PKT_CAPTURE_DATA_FRAME_TYPE_TCP_RST = BIT(12), + PKT_CAPTURE_DATA_FRAME_TYPE_ICMPV4 = BIT(13), + PKT_CAPTURE_DATA_FRAME_TYPE_ICMPV6 = BIT(14), + PKT_CAPTURE_DATA_FRAME_TYPE_RTP = BIT(15), + PKT_CAPTURE_DATA_FRAME_TYPE_SIP = BIT(16), + PKT_CAPTURE_DATA_FRAME_QOS_NULL = BIT(17), +}; + +/** + * pkt_capture_mgmt_frame_type - Represent the various + * mgmt types to be sent over the monitor interface. + * @PKT_CAPTURE_MGMT_FRAME_TYPE_ALL: All the MGMT Frames. + * @PKT_CAPTURE_MGMT_CONNECT_NO_BEACON: All the MGMT Frames + * except the Beacons. Valid only in the Connect state. + * @PKT_CAPTURE_MGMT_CONNECT_BEACON: Only the connected + * BSSID Beacons. Valid only in the Connect state. + * @PKT_CAPTURE_MONITOR_MGMT_CONNECT_SCAN_BEACON: Represents + * the Beacons obtained during the scan (off channel and connected channel) + * when in connected state. + */ + +enum pkt_capture_mgmt_frame_type { + PKT_CAPTURE_MGMT_FRAME_TYPE_ALL = BIT(0), + /* valid only if PKT_CAPTURE_MGMT_FRAME_TYPE_ALL is not set */ + PKT_CAPTURE_MGMT_CONNECT_NO_BEACON = BIT(1), + PKT_CAPTURE_MGMT_CONNECT_BEACON = BIT(2), + PKT_CAPTURE_MGMT_CONNECT_SCAN_BEACON = BIT(3), +}; + +/** + * pkt_capture_ctrl_frame_type - Represent the various + * ctrl types to be sent over the monitor interface. + * @PKT_CAPTURE_CTRL_FRAME_TYPE_ALL: All the ctrl Frames. + * @PKT_CAPTURE_CTRL_TRIGGER_FRAME: Trigger Frame. + */ +enum pkt_capture_ctrl_frame_type { + PKT_CAPTURE_CTRL_FRAME_TYPE_ALL = BIT(0), + /* valid only if PKT_CAPTURE_CTRL_FRAME_TYPE_ALL is not set */ + PKT_CAPTURE_CTRL_TRIGGER_FRAME = BIT(1), +}; + +/** + * enum pkt_capture_attr_set_monitor_mode - Used by the + * vendor command QCA_NL80211_VENDOR_SUBCMD_SET_MONITOR_MODE to set the + * monitor mode. + * + * @PKT_CAPTURE_ATTR_SET_MONITOR_MODE_DATA_TX_FRAME_TYPE: u32 attribute, + * Represents the tx data packet type to be monitored (u32). These data packets + * are represented by enum pkt_capture_data_frame_type. + * + * @PKT_CAPTURE_ATTR_SET_MONITOR_MODE_DATA_RX_FRAME_TYPE: u32 attribute, + * Represents the tx data packet type to be monitored (u32). These data packets + * are represented by enum pkt_capture_data_frame_type. + * + * @PKT_CAPTURE_ATTR_SET_MONITOR_MODE_MGMT_TX_FRAME_TYPE: u32 attribute, + * Represents the tx data packet type to be monitored (u32). These mgmt packets + * are represented by enum pkt_capture_mgmt_frame_type. + * + * @PKT_CAPTURE_ATTR_SET_MONITOR_MODE_MGMT_RX_FRAME_TYPE: u32 attribute, + * Represents the tx data packet type to be monitored (u32). These mgmt packets + * are represented by enum pkt_capture_mgmt_frame_type. + * + * @PKT_CAPTURE_ATTR_SET_MONITOR_MODE_CTRL_TX_FRAME_TYPE: u32 attribute, + * Represents the tx data packet type to be monitored (u32). These ctrl packets + * are represented by enum pkt_capture_ctrl_frame_type. + * + * @PKT_CAPTURE_ATTR_SET_MONITOR_MODE_CTRL_RX_FRAME_TYPE: u32 attribute, + * Represents the tx data packet type to be monitored (u32). These ctrl packets + * are represented by enum pkt_capture_ctrl_frame_type. + * + * @PKT_CAPTURE_ATTR_SET_MONITOR_MODE_CONNECTED_BEACON_INTERVAL: u32 attribute, + * An interval only for the connected beacon interval, which expects that the + * connected BSSID's beacons shall be sent on the monitor interface only on this + * specific interval. + */ +enum pkt_capture_attr_set_monitor_mode { + PKT_CAPTURE_ATTR_SET_MONITOR_MODE_INVALID = 0, + PKT_CAPTURE_ATTR_SET_MONITOR_MODE_DATA_TX_FRAME_TYPE = 1, + PKT_CAPTURE_ATTR_SET_MONITOR_MODE_DATA_RX_FRAME_TYPE = 2, + PKT_CAPTURE_ATTR_SET_MONITOR_MODE_MGMT_TX_FRAME_TYPE = 3, + PKT_CAPTURE_ATTR_SET_MONITOR_MODE_MGMT_RX_FRAME_TYPE = 4, + PKT_CAPTURE_ATTR_SET_MONITOR_MODE_CTRL_TX_FRAME_TYPE = 5, + PKT_CAPTURE_ATTR_SET_MONITOR_MODE_CTRL_RX_FRAME_TYPE = 6, + PKT_CAPTURE_ATTR_SET_MONITOR_MODE_CONNECTED_BEACON_INTERVAL = 7, + + /* keep last */ + PKT_CAPTURE_ATTR_SET_MONITOR_MODE_AFTER_LAST, + PKT_CAPTURE_ATTR_SET_MONITOR_MODE_MAX = + PKT_CAPTURE_ATTR_SET_MONITOR_MODE_AFTER_LAST - 1, + +}; + +struct pkt_capture_frame_filter { + enum pkt_capture_data_frame_type data_tx_frame_filter; + enum pkt_capture_data_frame_type data_rx_frame_filter; + enum pkt_capture_mgmt_frame_type mgmt_tx_frame_filter; + enum pkt_capture_mgmt_frame_type mgmt_rx_frame_filter; + enum pkt_capture_ctrl_frame_type ctrl_tx_frame_filter; + enum pkt_capture_ctrl_frame_type ctrl_rx_frame_filter; + uint32_t connected_beacon_interval; + uint8_t vendor_attr_to_set; +}; #endif /* _WLAN_PKT_CAPTURE_PUBLIC_STRUCTS_H_ */ diff --git a/components/pkt_capture/dispatcher/inc/wlan_pkt_capture_ucfg_api.h b/components/pkt_capture/dispatcher/inc/wlan_pkt_capture_ucfg_api.h index 10147b580332..768b3ac00fad 100644 --- a/components/pkt_capture/dispatcher/inc/wlan_pkt_capture_ucfg_api.h +++ b/components/pkt_capture/dispatcher/inc/wlan_pkt_capture_ucfg_api.h @@ -267,6 +267,17 @@ int ucfg_pkt_capture_register_wma_callbacks(struct wlan_objmgr_psoc *psoc, struct pkt_capture_callbacks *cb_obj); +/** + * ucfg_pkt_capture_set_filter ucfg API to set frame filter + * @frame_filter: pkt capture frame filter data + * @vdev: pointer to vdev + * + * Return: QDF_STATUS + */ +QDF_STATUS +ucfg_pkt_capture_set_filter(struct pkt_capture_frame_filter frame_filter, + struct wlan_objmgr_vdev *vdev); + #ifdef WLAN_FEATURE_PKT_CAPTURE_V2 /** * ucfg_pkt_capture_send_config - send packet capture config @@ -425,5 +436,13 @@ QDF_STATUS ucfg_pkt_capture_send_config { return QDF_STATUS_SUCCESS; } + +static inline QDF_STATUS +ucfg_pkt_capture_set_filter(struct pkt_capture_frame_filter frame_filter, + struct wlan_objmgr_vdev *vdev) +{ + return QDF_STATUS_SUCCESS; +} + #endif /* WLAN_FEATURE_PKT_CAPTURE */ #endif /* _WLAN_PKT_CAPTURE_UCFG_API_H_ */ diff --git a/components/pkt_capture/dispatcher/src/wlan_pkt_capture_ucfg_api.c b/components/pkt_capture/dispatcher/src/wlan_pkt_capture_ucfg_api.c index 97179fceeaa0..626ef47572a4 100644 --- a/components/pkt_capture/dispatcher/src/wlan_pkt_capture_ucfg_api.c +++ b/components/pkt_capture/dispatcher/src/wlan_pkt_capture_ucfg_api.c @@ -309,6 +309,13 @@ ucfg_pkt_capture_register_wma_callbacks(struct wlan_objmgr_psoc *psoc, return 0; } +QDF_STATUS +ucfg_pkt_capture_set_filter(struct pkt_capture_frame_filter frame_filter, + struct wlan_objmgr_vdev *vdev) +{ + return pkt_capture_set_filter(frame_filter, vdev); +} + #ifdef WLAN_FEATURE_PKT_CAPTURE_V2 QDF_STATUS ucfg_pkt_capture_send_config (struct wlan_objmgr_vdev *vdev,