qtnfmac: keeping track of "generation" for STA info

Keep generation in per-VIF data structure and increment it whenever STA
list is changed. Use generation value to fill struct station_info when
required.

Signed-off-by: Igor Mitsyanko <igor.mitsyanko.os@quantenna.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
This commit is contained in:
Igor Mitsyanko 2017-12-19 14:28:55 +03:00 committed by Kalle Valo
parent 4d2a7a1cfa
commit 7a4d3a3bc8
5 changed files with 16 additions and 7 deletions

View File

@ -418,6 +418,7 @@ qtnf_get_station(struct wiphy *wiphy, struct net_device *dev,
{ {
struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); struct qtnf_vif *vif = qtnf_netdev_get_priv(dev);
sinfo->generation = vif->generation;
return qtnf_cmd_get_sta_info(vif, mac, sinfo); return qtnf_cmd_get_sta_info(vif, mac, sinfo);
} }
@ -439,11 +440,13 @@ qtnf_dump_station(struct wiphy *wiphy, struct net_device *dev,
ret = qtnf_cmd_get_sta_info(vif, sta_node->mac_addr, sinfo); ret = qtnf_cmd_get_sta_info(vif, sta_node->mac_addr, sinfo);
if (unlikely(ret == -ENOENT)) { if (unlikely(ret == -ENOENT)) {
qtnf_sta_list_del(&vif->sta_list, mac); qtnf_sta_list_del(vif, mac);
cfg80211_del_sta(vif->netdev, mac, GFP_KERNEL); cfg80211_del_sta(vif->netdev, mac, GFP_KERNEL);
sinfo->filled = 0; sinfo->filled = 0;
} }
sinfo->generation = vif->generation;
return ret; return ret;
} }

View File

@ -88,6 +88,7 @@ struct qtnf_vif {
struct work_struct reset_work; struct work_struct reset_work;
struct qtnf_sta_list sta_list; struct qtnf_sta_list sta_list;
unsigned long cons_tx_timeout_cnt; unsigned long cons_tx_timeout_cnt;
int generation;
}; };
struct qtnf_mac_info { struct qtnf_mac_info {

View File

@ -59,10 +59,11 @@ qtnf_event_handle_sta_assoc(struct qtnf_wmac *mac, struct qtnf_vif *vif,
pr_debug("VIF%u.%u: MAC:%pM FC:%x\n", mac->macid, vif->vifid, sta_addr, pr_debug("VIF%u.%u: MAC:%pM FC:%x\n", mac->macid, vif->vifid, sta_addr,
frame_control); frame_control);
qtnf_sta_list_add(&vif->sta_list, sta_addr); qtnf_sta_list_add(vif, sta_addr);
sinfo.assoc_req_ies = NULL; sinfo.assoc_req_ies = NULL;
sinfo.assoc_req_ies_len = 0; sinfo.assoc_req_ies_len = 0;
sinfo.generation = vif->generation;
payload_len = len - sizeof(*sta_assoc); payload_len = len - sizeof(*sta_assoc);
tlv = (const struct qlink_tlv_hdr *)sta_assoc->ies; tlv = (const struct qlink_tlv_hdr *)sta_assoc->ies;
@ -132,7 +133,7 @@ qtnf_event_handle_sta_deauth(struct qtnf_wmac *mac, struct qtnf_vif *vif,
pr_debug("VIF%u.%u: MAC:%pM reason:%x\n", mac->macid, vif->vifid, pr_debug("VIF%u.%u: MAC:%pM reason:%x\n", mac->macid, vif->vifid,
sta_addr, reason); sta_addr, reason);
if (qtnf_sta_list_del(&vif->sta_list, sta_addr)) if (qtnf_sta_list_del(vif, sta_addr))
cfg80211_del_sta(vif->netdev, sta_deauth->sta_addr, cfg80211_del_sta(vif->netdev, sta_deauth->sta_addr,
GFP_KERNEL); GFP_KERNEL);

View File

@ -57,9 +57,10 @@ struct qtnf_sta_node *qtnf_sta_list_lookup_index(struct qtnf_sta_list *list,
return NULL; return NULL;
} }
struct qtnf_sta_node *qtnf_sta_list_add(struct qtnf_sta_list *list, struct qtnf_sta_node *qtnf_sta_list_add(struct qtnf_vif *vif,
const u8 *mac) const u8 *mac)
{ {
struct qtnf_sta_list *list = &vif->sta_list;
struct qtnf_sta_node *node; struct qtnf_sta_node *node;
if (unlikely(!mac)) if (unlikely(!mac))
@ -77,13 +78,15 @@ struct qtnf_sta_node *qtnf_sta_list_add(struct qtnf_sta_list *list,
ether_addr_copy(node->mac_addr, mac); ether_addr_copy(node->mac_addr, mac);
list_add_tail(&node->list, &list->head); list_add_tail(&node->list, &list->head);
atomic_inc(&list->size); atomic_inc(&list->size);
++vif->generation;
done: done:
return node; return node;
} }
bool qtnf_sta_list_del(struct qtnf_sta_list *list, const u8 *mac) bool qtnf_sta_list_del(struct qtnf_vif *vif, const u8 *mac)
{ {
struct qtnf_sta_list *list = &vif->sta_list;
struct qtnf_sta_node *node; struct qtnf_sta_node *node;
bool ret = false; bool ret = false;
@ -93,6 +96,7 @@ bool qtnf_sta_list_del(struct qtnf_sta_list *list, const u8 *mac)
list_del(&node->list); list_del(&node->list);
atomic_dec(&list->size); atomic_dec(&list->size);
kfree(node); kfree(node);
++vif->generation;
ret = true; ret = true;
} }

View File

@ -26,9 +26,9 @@ struct qtnf_sta_node *qtnf_sta_list_lookup(struct qtnf_sta_list *list,
const u8 *mac); const u8 *mac);
struct qtnf_sta_node *qtnf_sta_list_lookup_index(struct qtnf_sta_list *list, struct qtnf_sta_node *qtnf_sta_list_lookup_index(struct qtnf_sta_list *list,
size_t index); size_t index);
struct qtnf_sta_node *qtnf_sta_list_add(struct qtnf_sta_list *list, struct qtnf_sta_node *qtnf_sta_list_add(struct qtnf_vif *vif,
const u8 *mac); const u8 *mac);
bool qtnf_sta_list_del(struct qtnf_sta_list *list, const u8 *mac); bool qtnf_sta_list_del(struct qtnf_vif *vif, const u8 *mac);
void qtnf_sta_list_free(struct qtnf_sta_list *list); void qtnf_sta_list_free(struct qtnf_sta_list *list);