1 // SPDX-License-Identifier: GPL-2.0+
2 /* Copyright (c) 2015-2016 Quantenna Communications. All rights reserved. */
5 #include "qtn_hw_ids.h"
7 void qtnf_sta_list_init(struct qtnf_sta_list
*list
)
12 INIT_LIST_HEAD(&list
->head
);
13 atomic_set(&list
->size
, 0);
16 struct qtnf_sta_node
*qtnf_sta_list_lookup(struct qtnf_sta_list
*list
,
19 struct qtnf_sta_node
*node
;
24 list_for_each_entry(node
, &list
->head
, list
) {
25 if (ether_addr_equal(node
->mac_addr
, mac
))
32 struct qtnf_sta_node
*qtnf_sta_list_lookup_index(struct qtnf_sta_list
*list
,
35 struct qtnf_sta_node
*node
;
37 if (qtnf_sta_list_size(list
) <= index
)
40 list_for_each_entry(node
, &list
->head
, list
) {
48 struct qtnf_sta_node
*qtnf_sta_list_add(struct qtnf_vif
*vif
,
51 struct qtnf_sta_list
*list
= &vif
->sta_list
;
52 struct qtnf_sta_node
*node
;
57 node
= qtnf_sta_list_lookup(list
, mac
);
62 node
= kzalloc(sizeof(*node
), GFP_KERNEL
);
66 ether_addr_copy(node
->mac_addr
, mac
);
67 list_add_tail(&node
->list
, &list
->head
);
68 atomic_inc(&list
->size
);
75 bool qtnf_sta_list_del(struct qtnf_vif
*vif
, const u8
*mac
)
77 struct qtnf_sta_list
*list
= &vif
->sta_list
;
78 struct qtnf_sta_node
*node
;
81 node
= qtnf_sta_list_lookup(list
, mac
);
84 list_del(&node
->list
);
85 atomic_dec(&list
->size
);
94 void qtnf_sta_list_free(struct qtnf_sta_list
*list
)
96 struct qtnf_sta_node
*node
, *tmp
;
98 atomic_set(&list
->size
, 0);
100 list_for_each_entry_safe(node
, tmp
, &list
->head
, list
) {
101 list_del(&node
->list
);
105 INIT_LIST_HEAD(&list
->head
);
108 const char *qtnf_chipid_to_string(unsigned long chip_id
)
111 case QTN_CHIP_ID_TOPAZ
:
113 case QTN_CHIP_ID_PEARL
:
115 case QTN_CHIP_ID_PEARL_B
:
117 case QTN_CHIP_ID_PEARL_C
:
123 EXPORT_SYMBOL_GPL(qtnf_chipid_to_string
);