2 ******************************************************************************
4 * @file ecrnx_mu_group.h
6 * Copyright (C) ESWIN 2015-2020
8 ******************************************************************************
10 #ifndef _ECRNX_MU_GROUP_H_
11 #define _ECRNX_MU_GROUP_H_
13 #include <linux/workqueue.h>
14 #include <linux/semaphore.h>
19 #ifdef CONFIG_ECRNX_MUMIMO_TX
22 * struct ecrnx_sta_group_info - Group Information for a STA
24 * @active: node for @mu->active_sta list
25 * @update: node for @mu->update_sta list
26 * @cnt: Number of groups the STA belongs to
27 * @map: Bitfield of groups the sta belongs to
28 * @traffic: Number of buffers sent since previous group selection
29 * @group: Id of the group selected by previous group selection
30 * (cf @ecrnx_mu_group_sta_select)
32 struct ecrnx_sta_group_info {
33 struct list_head active;
34 struct list_head update;
43 * struct mu_group_info - Information about the users of a group
45 * @list: node for mu->active_groups
46 * @group_id: Group identifier
47 * @user_cnt: Number of the users in the group
48 * @users: Pointer to the sta, ordered by user position
50 struct ecrnx_mu_group {
51 struct list_head list;
54 struct ecrnx_sta *users[CONFIG_USER_MAX];
58 * struct ecrnx_mu_info - Information about all MU group
60 * @active_groups: List of all possible groups. Ordered from the most recently
61 * used one to the least one (and possibly never used)
62 * @active_sta: List of MU beamformee sta that have been active (since previous
63 * group update). Ordered from the most recently active.
64 * @update_sta: List of sta whose group information has changed and need to be
66 * @groups: Table of all groups
67 * @group_work: Work item used to schedule group update
68 * @update_count: Counter used to identify the last group formation update.
69 * (cf ecrnx_sta_group_info.last_update)
70 * @lock: Lock taken during group update. If tx happens lock is taken, then tx
72 * @next_group_assign: Next time the group selection should be run
73 * (ref @ecrnx_mu_group_sta_select)
74 * @group_cnt: Number of group created
76 struct ecrnx_mu_info {
77 struct list_head active_groups;
78 struct list_head active_sta;
79 struct list_head update_sta;
80 struct ecrnx_mu_group groups[NX_MU_GROUP_MAX];
81 struct delayed_work group_work;
83 struct semaphore lock;
84 unsigned long next_group_select;
88 #define ECRNX_SU_GROUP BIT_ULL(0)
89 #define ECRNX_MU_GROUP_MASK 0x7ffffffffffffffeULL
90 #define ECRNX_MU_GROUP_INTERVAL 200 /* in ms */
91 #define ECRNX_MU_GROUP_SELECT_INTERVAL 100 /* in ms */
92 // minimum traffic in a ECRNX_MU_GROUP_SELECT_INTERVAL to consider the sta
93 #define ECRNX_MU_GROUP_MIN_TRAFFIC 50 /* in number of packet */
96 #define ECRNX_GET_FIRST_GROUP_ID(map) (fls64(map) - 1)
98 #define group_sta_for_each(sta, id, map) \
99 map = sta->group_info.map & ECRNX_MU_GROUP_MASK; \
100 for (id = (fls64(map) - 1) ; id > 0 ; \
101 map &= ~(u64)BIT_ULL(id), id = (fls64(map) - 1))
103 #define group_for_each(id, map) \
104 for (id = (fls64(map) - 1) ; id > 0 ; \
105 map &= ~(u64)BIT_ULL(id), id = (fls64(map) - 1))
107 #define ECRNX_MUMIMO_INFO_POS_ID(info) (((info) >> 6) & 0x3)
108 #define ECRNX_MUMIMO_INFO_GROUP_ID(info) ((info) & 0x3f)
111 struct ecrnx_mu_group *ecrnx_mu_group_from_id(struct ecrnx_mu_info *mu, int id)
113 if (id > NX_MU_GROUP_MAX)
116 return &mu->groups[id - 1];
120 void ecrnx_mu_group_sta_init(struct ecrnx_sta *sta,
121 const struct ieee80211_vht_cap *vht_cap);
122 void ecrnx_mu_group_sta_del(struct ecrnx_hw *ecrnx_hw, struct ecrnx_sta *sta);
123 u64 ecrnx_mu_group_sta_get_map(struct ecrnx_sta *sta);
124 int ecrnx_mu_group_sta_get_pos(struct ecrnx_hw *ecrnx_hw, struct ecrnx_sta *sta,
127 void ecrnx_mu_group_init(struct ecrnx_hw *ecrnx_hw);
129 void ecrnx_mu_set_active_sta(struct ecrnx_hw *ecrnx_hw, struct ecrnx_sta *sta,
131 void ecrnx_mu_set_active_group(struct ecrnx_hw *ecrnx_hw, int group_id);
132 void ecrnx_mu_group_sta_select(struct ecrnx_hw *ecrnx_hw);
135 #else /* ! CONFIG_ECRNX_MUMIMO_TX */
138 void ecrnx_mu_group_sta_init(struct ecrnx_sta *sta,
139 const struct ieee80211_vht_cap *vht_cap)
143 void ecrnx_mu_group_sta_del(struct ecrnx_hw *ecrnx_hw, struct ecrnx_sta *sta)
147 u64 ecrnx_mu_group_sta_get_map(struct ecrnx_sta *sta)
153 int ecrnx_mu_group_sta_get_pos(struct ecrnx_hw *ecrnx_hw, struct ecrnx_sta *sta,
160 void ecrnx_mu_group_init(struct ecrnx_hw *ecrnx_hw)
164 void ecrnx_mu_set_active_sta(struct ecrnx_hw *ecrnx_hw, struct ecrnx_sta *sta,
169 void ecrnx_mu_set_active_group(struct ecrnx_hw *ecrnx_hw, int group_id)
173 void ecrnx_mu_group_sta_select(struct ecrnx_hw *ecrnx_hw)
176 #endif /* CONFIG_ECRNX_MUMIMO_TX */
178 #endif /* _ECRNX_MU_GROUP_H_ */