1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
/*
* Copyright (C) 2022 Intel Corporation
*/
#include "mvm.h"
static int iwl_mvm_link_cmd_send(struct iwl_mvm *mvm,
struct iwl_link_config_cmd *cmd,
enum iwl_ctxt_action action)
{
int ret;
cmd->action = cpu_to_le32(action);
ret = iwl_mvm_send_cmd_pdu(mvm,
WIDE_ID(MAC_CONF_GROUP, LINK_CONFIG_CMD), 0,
sizeof(*cmd), cmd);
if (ret)
IWL_ERR(mvm, "Failed to send LINK_CONFIG_CMD (action:%d): %d\n",
action, ret);
return ret;
}
int iwl_mvm_add_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
{
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
struct iwl_link_config_cmd cmd = {};
if (WARN_ON_ONCE(!mvmvif->phy_ctxt))
return -EINVAL;
/* Update SF - Disable if needed. if this fails, SF might still be on
* while many macs are bound, which is forbidden - so fail the binding.
*/
if (iwl_mvm_sf_update(mvm, vif, false))
return -EINVAL;
cmd.link_id = cpu_to_le32(mvmvif->phy_ctxt->id);
cmd.mac_id = cpu_to_le32(mvmvif->id);
cmd.phy_id = cpu_to_le32(mvmvif->phy_ctxt->id);
memcpy(cmd.local_link_addr, vif->addr, ETH_ALEN);
return iwl_mvm_link_cmd_send(mvm, &cmd, FW_CTXT_ACTION_ADD);
}
int iwl_mvm_link_changed(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
u32 changes, bool active)
{
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
struct iwl_mvm_phy_ctxt *phyctxt = mvmvif->phy_ctxt;
struct iwl_link_config_cmd cmd = {};
u32 ht_flag, flags = 0, flags_mask = 0;
if (!phyctxt)
return -EINVAL;
cmd.link_id = cpu_to_le32(phyctxt->id);
/* The phy_id, link address and listen_lmac can be modified only until
* the link becomes active, otherwise they will be ignored.
*/
cmd.phy_id = cpu_to_le32(phyctxt->id);
cmd.mac_id = cpu_to_le32(mvmvif->id);
memcpy(cmd.local_link_addr, vif->addr, ETH_ALEN);
cmd.active = cpu_to_le32(active);
/* TODO: set a value to cmd.listen_lmac when system requiremens
* will define it
*/
iwl_mvm_set_fw_basic_rates(mvm, vif, &cmd.cck_rates, &cmd.ofdm_rates);
cmd.cck_short_preamble = cpu_to_le32(vif->bss_conf.use_short_preamble);
cmd.short_slot = cpu_to_le32(vif->bss_conf.use_short_slot);
/* The fw does not distinguish between ht and fat */
ht_flag = LINK_PROT_FLG_HT_PROT | LINK_PROT_FLG_FAT_PROT;
iwl_mvm_set_fw_protection_flags(mvm, vif, &cmd.protection_flags,
ht_flag, LINK_PROT_FLG_TGG_PROTECT);
iwl_mvm_set_fw_qos_params(mvm, vif, &cmd.ac[0], &cmd.qos_flags);
/* We need the dtim_period to set the MAC as associated */
if (vif->cfg.assoc && vif->bss_conf.dtim_period)
iwl_mvm_set_fw_dtim_tbtt(mvm, vif, &cmd.dtim_tsf,
&cmd.dtim_time,
&cmd.assoc_beacon_arrive_time);
else
changes &= ~LINK_CONTEXT_MODIFY_BEACON_TIMING;
cmd.bi = cpu_to_le32(vif->bss_conf.beacon_int);
cmd.dtim_interval = cpu_to_le32(vif->bss_conf.beacon_int *
vif->bss_conf.dtim_period);
/* TODO: Assumes that the beacon id == mac context id */
cmd.beacon_template = cpu_to_le32(mvmvif->id);
if (!vif->bss_conf.he_support || iwlwifi_mod_params.disable_11ax ||
!vif->cfg.assoc) {
changes &= ~LINK_CONTEXT_MODIFY_HE_PARAMS;
goto send_cmd;
}
cmd.htc_trig_based_pkt_ext = vif->bss_conf.htc_trig_based_pkt_ext;
if (vif->bss_conf.uora_exists) {
cmd.rand_alloc_ecwmin =
vif->bss_conf.uora_ocw_range & 0x7;
cmd.rand_alloc_ecwmax =
(vif->bss_conf.uora_ocw_range >> 3) & 0x7;
}
/* TODO how to set ndp_fdbk_buff_th_exp? */
if (iwl_mvm_set_fw_mu_edca_params(mvm, mvmvif,
&cmd.trig_based_txf[0])) {
flags |= LINK_FLG_MU_EDCA_CW;
flags_mask |= LINK_FLG_MU_EDCA_CW;
}
if (vif->bss_conf.eht_puncturing && !iwlwifi_mod_params.disable_11be)
cmd.puncture_mask = cpu_to_le16(vif->bss_conf.eht_puncturing);
else
/* This flag can be set only if the MAC has eht support */
changes &= ~LINK_CONTEXT_MODIFY_EHT_PARAMS;
cmd.bss_color = vif->bss_conf.he_bss_color.color;
if (!vif->bss_conf.he_bss_color.enabled) {
flags |= LINK_FLG_BSS_COLOR_DIS;
flags_mask |= LINK_FLG_BSS_COLOR_DIS;
}
cmd.frame_time_rts_th = cpu_to_le16(vif->bss_conf.frame_time_rts_th);
/* Block 26-tone RU OFDMA transmissions */
if (mvmvif->he_ru_2mhz_block) {
flags |= LINK_FLG_RU_2MHZ_BLOCK;
flags_mask |= LINK_FLG_RU_2MHZ_BLOCK;
}
if (vif->bss_conf.nontransmitted) {
ether_addr_copy(cmd.ref_bssid_addr,
vif->bss_conf.transmitter_bssid);
cmd.bssid_index = vif->bss_conf.bssid_index;
}
send_cmd:
cmd.modify_mask = cpu_to_le32(changes);
cmd.flags = cpu_to_le32(flags);
cmd.flags_mask = cpu_to_le32(flags_mask);
return iwl_mvm_link_cmd_send(mvm, &cmd, FW_CTXT_ACTION_MODIFY);
}
int iwl_mvm_remove_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
{
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
struct iwl_link_config_cmd cmd = {};
int ret;
if (WARN_ON_ONCE(!mvmvif->phy_ctxt))
return -EINVAL;
cmd.link_id = cpu_to_le32(mvmvif->phy_ctxt->id);
ret = iwl_mvm_link_cmd_send(mvm, &cmd, FW_CTXT_ACTION_REMOVE);
if (!ret)
if (iwl_mvm_sf_update(mvm, vif, true))
IWL_ERR(mvm, "Failed to update SF state\n");
return ret;
}
|