From e10f87bd410f9bf9bd2c6857b7afe2ae02edc438 Mon Sep 17 00:00:00 2001 From: Chaithanya Garrepalli Date: Thu, 18 Oct 2018 00:14:11 +0530 Subject: [PATCH] qcacmn: add a flag in AST entry to indicate AST map Add a flag for AST entry to indicate if AST entry is mapped to AST table and use this flag while dereferncing ast table with ast_index in ast_entry Change-Id: I8c90f3c40116e24303aac8a7bd53e8f5b67e22bf --- dp/wifi3.0/dp_peer.c | 22 ++++++++++++++-------- dp/wifi3.0/dp_rx.h | 4 ++-- dp/wifi3.0/dp_rx_err.c | 1 + dp/wifi3.0/dp_types.h | 4 +++- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/dp/wifi3.0/dp_peer.c b/dp/wifi3.0/dp_peer.c index a958405e2434..52e49c867966 100644 --- a/dp/wifi3.0/dp_peer.c +++ b/dp/wifi3.0/dp_peer.c @@ -466,6 +466,7 @@ static inline void dp_peer_map_ast(struct dp_soc *soc, ast_entry->is_active = TRUE; peer_type = ast_entry->type; ast_entry->ast_hash_value = ast_hash; + ast_entry->is_mapped = TRUE; } if (ast_entry || (peer->vdev && peer->vdev->proxysta_vdev)) { @@ -574,7 +575,7 @@ add_ast_entry: ast_entry->peer = peer; ast_entry->pdev_id = vdev->pdev->pdev_id; ast_entry->vdev_id = vdev->vdev_id; - ast_entry->ast_idx = DP_INVALID_AST_IDX; + ast_entry->is_mapped = false; switch (type) { case CDP_TXRX_AST_TYPE_STATIC: @@ -649,10 +650,10 @@ void dp_peer_del_ast(struct dp_soc *soc, struct dp_ast_entry *ast_entry) dp_peer_ast_send_wds_del(soc, ast_entry); } else { /* - * For TYPE_SELF (STA mode), no T2H_PEER_MAP message to map - * the peer, hence no need to clear ast_table here. + * release the reference only if it is mapped + * to ast_table */ - if (ast_entry->type != CDP_TXRX_AST_TYPE_SELF) + if (ast_entry->is_mapped) soc->ast_table[ast_entry->ast_idx] = NULL; TAILQ_REMOVE(&peer->ast_entry_list, ast_entry, ase_list_elem); @@ -686,10 +687,10 @@ void dp_peer_del_ast(struct dp_soc *soc, struct dp_ast_entry *ast_entry) ast_entry->mac_addr.raw); /* - * For TYPE_SELF (STA mode), no T2H_PEER_MAP message to map the peer, - * hence no need to clear ast_table here. + * release the reference only if it is mapped + * to ast_table */ - if (ast_entry->type != CDP_TXRX_AST_TYPE_SELF) + if (ast_entry->is_mapped) soc->ast_table[ast_entry->ast_idx] = NULL; TAILQ_REMOVE(&peer->ast_entry_list, ast_entry, ase_list_elem); @@ -903,7 +904,12 @@ void dp_peer_ast_free_entry(struct dp_soc *soc, { struct dp_peer *peer = ast_entry->peer; - soc->ast_table[ast_entry->ast_idx] = NULL; + /* + * release the reference only if it is mapped + * to ast_table + */ + if (ast_entry->is_mapped) + soc->ast_table[ast_entry->ast_idx] = NULL; TAILQ_REMOVE(&peer->ast_entry_list, ast_entry, ase_list_elem); DP_STATS_INC(soc, ast.deleted, 1); dp_peer_ast_hash_remove(soc, ast_entry); diff --git a/dp/wifi3.0/dp_rx.h b/dp/wifi3.0/dp_rx.h index cf1d64858a40..f6a266ee68ac 100644 --- a/dp/wifi3.0/dp_rx.h +++ b/dp/wifi3.0/dp_rx.h @@ -479,7 +479,7 @@ dp_rx_wds_srcport_learn(struct dp_soc *soc, * There is a possibility we might arrive here without * AST MAP event , so this check is mandatory */ - if (ast->ast_idx == sa_idx) + if (ast->is_mapped && (ast->ast_idx == sa_idx)) ast->is_active = TRUE; if (sa_sw_peer_id != ta_peer->peer_ids[0]) { @@ -743,7 +743,7 @@ static inline QDF_STATUS dp_rx_ast_set_active(struct dp_soc *soc, uint16_t sa_id * There is a possibility we might arrive here without * AST MAP event , so this check is mandatory */ - if (ast && (ast->ast_idx == sa_idx)) { + if (ast && ast->is_mapped && (ast->ast_idx == sa_idx)) { ast->is_active = is_active; qdf_spin_unlock_bh(&soc->ast_lock); return QDF_STATUS_SUCCESS; diff --git a/dp/wifi3.0/dp_rx_err.c b/dp/wifi3.0/dp_rx_err.c index 492434db4e21..701e75cb4868 100644 --- a/dp/wifi3.0/dp_rx_err.c +++ b/dp/wifi3.0/dp_rx_err.c @@ -132,6 +132,7 @@ static inline bool dp_rx_mcast_echo_check(struct dp_soc *soc, if (ase) { ase->ast_idx = sa_idx; soc->ast_table[sa_idx] = ase; + ase->is_mapped = TRUE; } } } else diff --git a/dp/wifi3.0/dp_types.h b/dp/wifi3.0/dp_types.h index e9571365329d..e6d788293d4a 100644 --- a/dp/wifi3.0/dp_types.h +++ b/dp/wifi3.0/dp_types.h @@ -636,7 +636,6 @@ union dp_align_mac_addr { } align4_2; }; -#define DP_INVALID_AST_IDX 0xFFFF /* * dp_ast_entry * @@ -649,6 +648,8 @@ union dp_align_mac_addr { * (used for aging out/expiry) * @ase_list_elem: node in peer AST list * @is_bss: flag to indicate if entry corresponds to bss peer + * @is_mapped: flag to indicate that we have mapped the AST entry + * in ast_table * @pdev_id: pdev ID * @vdev_id: vdev ID * @ast_hash_value: hast value in HW @@ -666,6 +667,7 @@ struct dp_ast_entry { bool next_hop; bool is_active; bool is_bss; + bool is_mapped; uint8_t pdev_id; uint8_t vdev_id; uint16_t ast_hash_value;