qcacmn: Reorganize protocol and flow tagging changes to wifi-host component

Reorganize protocol and flow tagging changes to wifi-host component.

CRs-Fixed: 2501573
Change-Id: Ic6bc9548fd8bb66c2f8bae4740a4dcad4002f720
Cette révision appartient à :
Sumeet Rao
2019-08-09 15:29:43 -07:00
révisé par nshrivas
Parent 3e31e2babd
révision 2b730bbc76
3 fichiers modifiés avec 19 ajouts et 1171 suppressions

Voir le fichier

@@ -833,77 +833,13 @@ static inline bool check_qwrap_multicast_loopback(struct dp_vdev *vdev,
}
#endif
#if defined(WLAN_SUPPORT_RX_TAG_STATISTICS) && \
defined(WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG)
/**
* dp_rx_update_rx_protocol_tag_stats() - Increments the protocol tag stats
* for the given protocol type
* @soc: core txrx main context
* @pdev: TXRX pdev context for which stats should be incremented
* @protocol_index: Protocol index for which the stats should be incremented
* @ring_index: REO ring number from which this tag was received.
*
* Since HKv2 is a SMP, two or more cores may simultaneously receive packets
* of same type, and hence attempt to increment counters for the same protocol
* type at the same time. This creates the possibility of missing stats.
*
* For example, when two or more CPUs have each read the old tag value, V,
* for protocol type, P and each increment the value to V+1. Instead, the
* operations should have been sequenced to achieve a final value of V+2.
*
* In order to avoid this scenario, we can either use locks or store stats
* on a per-CPU basis. Since tagging happens in the core data path, locks
* are not preferred. Instead, we use a per-ring counter, since each CPU
* operates on a REO ring.
*
* Return: void
*/
static inline void dp_rx_update_rx_protocol_tag_stats(struct dp_pdev *pdev,
uint16_t protocol_index,
uint16_t ring_index)
{
if (ring_index >= MAX_REO_DEST_RINGS)
return;
pdev->reo_proto_tag_stats[ring_index][protocol_index].tag_ctr++;
}
#else
static inline void dp_rx_update_rx_protocol_tag_stats(struct dp_pdev *pdev,
uint16_t protocol_index,
uint16_t ring_index)
{
}
#endif /* WLAN_SUPPORT_RX_TAG_STATISTICS */
#if defined(WLAN_SUPPORT_RX_TAG_STATISTICS) && \
defined(WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG)
/**
* dp_rx_update_rx_err_protocol_tag_stats() - Increments the protocol tag stats
* for the given protocol type
* received from exception ring
* @soc: core txrx main context
* @pdev: TXRX pdev context for which stats should be incremented
* @protocol_index: Protocol index for which the stats should be incremented
*
* In HKv2, all exception packets are received on Ring-0 (along with normal
* Rx). Hence tags are maintained separately for exception ring as well.
*
* Return: void
*/
static inline
void dp_rx_update_rx_err_protocol_tag_stats(struct dp_pdev *pdev,
uint16_t protocol_index)
{
pdev->rx_err_proto_tag_stats[protocol_index].tag_ctr++;
}
#else
static inline
void dp_rx_update_rx_err_protocol_tag_stats(struct dp_pdev *pdev,
uint16_t protocol_index)
{
}
#endif /* WLAN_SUPPORT_RX_TAG_STATISTICS */
#if defined(WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG) ||\
defined(WLAN_SUPPORT_RX_TAG_STATISTICS) ||\
defined(WLAN_SUPPORT_RX_FLOW_TAG)
#include "dp_rx_tag.h"
#endif
#ifndef WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG
/**
* dp_rx_update_protocol_tag() - Reads CCE metadata from the RX MSDU end TLV
* and set the corresponding tag in QDF packet
@@ -916,121 +852,16 @@ void dp_rx_update_rx_err_protocol_tag_stats(struct dp_pdev *pdev,
* @is_update_stats: flag to indicate whether to update stats or not
* Return: void
*/
#ifdef WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG
static inline void
dp_rx_update_protocol_tag(struct dp_soc *soc, struct dp_vdev *vdev,
qdf_nbuf_t nbuf, uint8_t *rx_tlv_hdr,
uint16_t ring_index,
bool is_reo_exception, bool is_update_stats)
{
uint16_t cce_metadata = RX_PROTOCOL_TAG_START_OFFSET;
bool cce_match = false;
struct dp_pdev *pdev;
uint16_t protocol_tag = 0;
if (qdf_unlikely(!vdev))
return;
pdev = vdev->pdev;
if (qdf_likely(!pdev->is_rx_protocol_tagging_enabled))
return;
/*
* In case of raw frames, rx_attention and rx_msdu_end tlv
* may be stale or invalid. Do not tag such frames.
* Default decap_type is set to ethernet for monitor vdev,
* therefore, cannot check decap_type for monitor mode.
* We will call this only for eth frames from dp_rx_mon_dest.c.
*/
if (qdf_likely(!(pdev->monitor_vdev && pdev->monitor_vdev == vdev) &&
(vdev->rx_decap_type != htt_cmn_pkt_type_ethernet)))
return;
/*
* Check whether HW has filled in the CCE metadata in
* this packet, if not filled, just return
*/
if (qdf_likely(!hal_rx_msdu_cce_match_get(rx_tlv_hdr)))
return;
cce_match = true;
/* Get the cce_metadata from RX MSDU TLV */
cce_metadata = (hal_rx_msdu_cce_metadata_get(rx_tlv_hdr) &
RX_MSDU_END_16_CCE_METADATA_MASK);
/*
* Received CCE metadata should be within the
* valid limits
*/
qdf_assert_always((cce_metadata >= RX_PROTOCOL_TAG_START_OFFSET) &&
(cce_metadata < (RX_PROTOCOL_TAG_START_OFFSET +
RX_PROTOCOL_TAG_MAX)));
/*
* The CCE metadata received is just the
* packet_type + RX_PROTOCOL_TAG_START_OFFSET
*/
cce_metadata -= RX_PROTOCOL_TAG_START_OFFSET;
/*
* Update the QDF packet with the user-specified
* tag/metadata by looking up tag value for
* received protocol type.
*/
protocol_tag = pdev->rx_proto_tag_map[cce_metadata].tag;
qdf_nbuf_set_rx_protocol_tag(nbuf, protocol_tag);
QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_LOW,
"Seq:%u dcap:%u CCE Match:%u ProtoID:%u Tag:%u stats:%u",
hal_rx_get_rx_sequence(rx_tlv_hdr),
vdev->rx_decap_type, cce_match, cce_metadata,
protocol_tag, is_update_stats);
if (qdf_likely(!is_update_stats))
return;
if (qdf_unlikely(is_reo_exception)) {
dp_rx_update_rx_err_protocol_tag_stats(pdev,
cce_metadata);
} else {
dp_rx_update_rx_protocol_tag_stats(pdev,
cce_metadata,
ring_index);
}
}
#else
static inline void
dp_rx_update_protocol_tag(struct dp_soc *soc, struct dp_vdev *vdev,
qdf_nbuf_t nbuf, uint8_t *rx_tlv_hdr,
uint16_t ring_index,
bool is_reo_exception, bool is_update_stats)
{
/* Stub API */
}
#endif /* WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG */
/**
* dp_rx_update_rx_flow_tag_stats() - Update stats for given flow index
* @pdev: TXRX pdev context for which stats should be incremented
* @flow_index: flow index for which the stats should be incremented
*
* Return: void
*/
#ifdef WLAN_SUPPORT_RX_FLOW_TAG
QDF_STATUS dp_rx_flow_update_fse_stats(struct dp_pdev *pdev, uint32_t flow_id);
static inline void dp_rx_update_rx_flow_tag_stats(struct dp_pdev *pdev,
uint32_t flow_index)
{
dp_rx_flow_update_fse_stats(pdev, flow_index);
}
#else
static inline void dp_rx_update_rx_flow_tag_stats(struct dp_pdev *pdev,
uint32_t flow_index)
{
}
#endif /* WLAN_SUPPORT_RX_FLOW_TAG */
#ifndef WLAN_SUPPORT_RX_FLOW_TAG
/**
* dp_rx_update_flow_tag() - Reads FSE metadata from the RX MSDU end TLV
* and set the corresponding tag in QDF packet
@@ -1042,60 +873,6 @@ static inline void dp_rx_update_rx_flow_tag_stats(struct dp_pdev *pdev,
*
* Return: void
*/
#ifdef WLAN_SUPPORT_RX_FLOW_TAG
static inline void
dp_rx_update_flow_tag(struct dp_soc *soc, struct dp_vdev *vdev,
qdf_nbuf_t nbuf, uint8_t *rx_tlv_hdr, bool update_stats)
{
bool flow_idx_invalid, flow_idx_timeout;
uint32_t flow_idx, fse_metadata;
struct dp_pdev *pdev;
if (qdf_unlikely(!vdev))
return;
pdev = vdev->pdev;
if (qdf_likely(!wlan_cfg_is_rx_flow_tag_enabled(soc->wlan_cfg_ctx)))
return;
/**
* In case of raw frames, rx_msdu_end tlv may be stale or invalid.
* Do not tag such frames in normal REO path.
* Default decap_type is set to ethernet for monitor vdev currently,
* therefore, we will not check decap_type for monitor mode.
* We will call this only for eth frames from dp_rx_mon_dest.c.
*/
if (qdf_likely((vdev->rx_decap_type != htt_cmn_pkt_type_ethernet)))
return;
flow_idx_invalid = hal_rx_msdu_flow_idx_invalid(rx_tlv_hdr);
hal_rx_msdu_get_flow_params(rx_tlv_hdr, &flow_idx_invalid,
&flow_idx_timeout, &flow_idx);
if (qdf_unlikely(flow_idx_invalid))
return;
if (qdf_unlikely(flow_idx_timeout))
return;
/**
* Limit FSE metadata to 16 bit as we have allocated only
* 16 bits for flow_tag field in skb->cb
*/
fse_metadata = hal_rx_msdu_fse_metadata_get(rx_tlv_hdr) & 0xFFFF;
/* update the skb->cb with the user-specified tag/metadata */
qdf_nbuf_set_rx_flow_tag(nbuf, fse_metadata);
QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_LOW,
"Seq:%u dcap:%u invalid:%u timeout:%u flow:%u tag:%u stat:%u",
hal_rx_get_rx_sequence(rx_tlv_hdr),
vdev->rx_decap_type, flow_idx_invalid, flow_idx_timeout,
flow_idx, fse_metadata, update_stats);
if (qdf_likely(update_stats))
dp_rx_update_rx_flow_tag_stats(pdev, flow_idx);
}
#else
static inline void
dp_rx_update_flow_tag(struct dp_soc *soc, struct dp_vdev *vdev,
qdf_nbuf_t nbuf, uint8_t *rx_tlv_hdr, bool update_stats)
@@ -1103,6 +880,8 @@ dp_rx_update_flow_tag(struct dp_soc *soc, struct dp_vdev *vdev,
}
#endif /* WLAN_SUPPORT_RX_FLOW_TAG */
#if !defined(WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG) &&\
!defined(WLAN_SUPPORT_RX_FLOW_TAG)
/**
* dp_rx_mon_update_protocol_flow_tag() - Performs necessary checks for monitor
* mode and then tags appropriate packets
@@ -1112,65 +891,11 @@ dp_rx_update_flow_tag(struct dp_soc *soc, struct dp_vdev *vdev,
* @rx_desc: base address where the RX TLVs start
* Return: void
*/
#if defined(WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG) ||\
defined(WLAN_SUPPORT_RX_FLOW_TAG)
static inline
void dp_rx_mon_update_protocol_flow_tag(struct dp_soc *soc,
struct dp_pdev *dp_pdev,
qdf_nbuf_t msdu, void *rx_desc)
{
uint32_t msdu_ppdu_id = 0;
struct mon_rx_status *mon_recv_status;
bool is_mon_protocol_flow_tag_enabled =
wlan_cfg_is_rx_mon_protocol_flow_tag_enabled(soc->wlan_cfg_ctx);
if (qdf_likely(!is_mon_protocol_flow_tag_enabled))
return;
if (qdf_likely(!dp_pdev->monitor_vdev))
return;
if (qdf_likely(1 != dp_pdev->ppdu_info.rx_status.rxpcu_filter_pass))
return;
msdu_ppdu_id = HAL_RX_HW_DESC_GET_PPDUID_GET(rx_desc);
if (msdu_ppdu_id != dp_pdev->ppdu_info.com_info.ppdu_id) {
QDF_TRACE(QDF_MODULE_ID_DP,
QDF_TRACE_LEVEL_ERROR,
"msdu_ppdu_id=%x,com_info.ppdu_id=%x",
msdu_ppdu_id,
dp_pdev->ppdu_info.com_info.ppdu_id);
return;
}
mon_recv_status = &dp_pdev->ppdu_info.rx_status;
if (mon_recv_status->frame_control_info_valid &&
((mon_recv_status->frame_control & IEEE80211_FC0_TYPE_MASK) ==
IEEE80211_FC0_TYPE_DATA)) {
/*
* Update the protocol tag in SKB for packets received on BSS.
* Do not update tag stats since it would double actual
* received count.
*/
dp_rx_update_protocol_tag(soc,
dp_pdev->monitor_vdev,
msdu, rx_desc,
MAX_REO_DEST_RINGS,
false, false);
/* Update the flow tag in SKB based on FSE metadata */
dp_rx_update_flow_tag(soc, dp_pdev->monitor_vdev,
msdu, rx_desc, false);
}
}
#else
static inline
void dp_rx_mon_update_protocol_flow_tag(struct dp_soc *soc,
struct dp_pdev *dp_pdev,
qdf_nbuf_t msdu, void *rx_desc)
{
/* Stub API */
}
#endif /* WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG || WLAN_SUPPORT_RX_FLOW_TAG */