Skip to content

Commit 6ca33f8

Browse files
haimdreyfusslucacoelho
authored andcommitted
iwlwifi: mvm: support new beacon template command
Support a new version of the beacon template command. This replaces v8 of the command, which was missing the rate code. Also, export rate decision logic to a separate function. Signed-off-by: Haim Dreyfuss <[email protected]> Signed-off-by: Luca Coelho <[email protected]>
1 parent 944eafc commit 6ca33f8

File tree

3 files changed

+47
-18
lines changed

3 files changed

+47
-18
lines changed

drivers/net/wireless/intel/iwlwifi/fw/api/tx.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -786,13 +786,20 @@ struct iwl_mac_beacon_cmd_v7 {
786786
struct ieee80211_hdr frame[0];
787787
} __packed; /* BEACON_TEMPLATE_CMD_API_S_VER_7 */
788788

789+
enum iwl_mac_beacon_flags {
790+
IWL_MAC_BEACON_CCK = BIT(8),
791+
IWL_MAC_BEACON_ANT_A = BIT(9),
792+
IWL_MAC_BEACON_ANT_B = BIT(10),
793+
IWL_MAC_BEACON_ANT_C = BIT(11),
794+
};
795+
789796
/**
790797
* struct iwl_mac_beacon_cmd - beacon template command with offloaded CSA
791-
* @byte_cnt: byte count of the beacon frame
792-
* @flags: for future use
798+
* @byte_cnt: byte count of the beacon frame.
799+
* @flags: least significant byte for rate code. The most significant byte
800+
* is &enum iwl_mac_beacon_flags.
793801
* @reserved: reserved
794-
* @template_id: currently equal to the mac context id of the coresponding
795-
* mac.
802+
* @template_id: currently equal to the mac context id of the coresponding mac.
796803
* @tim_idx: the offset of the tim IE in the beacon
797804
* @tim_size: the length of the tim IE
798805
* @ecsa_offset: offset to the ECSA IE if present
@@ -809,7 +816,7 @@ struct iwl_mac_beacon_cmd {
809816
__le32 ecsa_offset;
810817
__le32 csa_offset;
811818
struct ieee80211_hdr frame[0];
812-
} __packed; /* BEACON_TEMPLATE_CMD_API_S_VER_8 */
819+
} __packed; /* BEACON_TEMPLATE_CMD_API_S_VER_9 */
813820

814821
struct iwl_beacon_notif {
815822
struct iwl_mvm_tx_resp beacon_notify_hdr;

drivers/net/wireless/intel/iwlwifi/fw/file.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ enum iwl_ucode_tlv_api {
260260
IWL_UCODE_TLV_API_STA_TYPE = (__force iwl_ucode_tlv_api_t)30,
261261
IWL_UCODE_TLV_API_NAN2_VER2 = (__force iwl_ucode_tlv_api_t)31,
262262
/* API Set 1 */
263+
IWL_UCODE_TLV_API_NEW_BEACON_TEMPLATE = (__force iwl_ucode_tlv_api_t)34,
263264
IWL_UCODE_TLV_API_NEW_RX_STATS = (__force iwl_ucode_tlv_api_t)35,
264265

265266
NUM_IWL_UCODE_TLV_API

drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -923,14 +923,28 @@ static u32 iwl_mvm_find_ie_offset(u8 *beacon, u8 eid, u32 frame_size)
923923
return ie - beacon;
924924
}
925925

926+
static u8 iwl_mvm_mac_ctxt_get_lowest_rate(struct ieee80211_tx_info *info,
927+
struct ieee80211_vif *vif)
928+
{
929+
u8 rate;
930+
931+
if (info->band == NL80211_BAND_5GHZ || vif->p2p)
932+
rate = IWL_FIRST_OFDM_RATE;
933+
else
934+
rate = IWL_FIRST_CCK_RATE;
935+
936+
return rate;
937+
}
938+
926939
static void iwl_mvm_mac_ctxt_set_tx(struct iwl_mvm *mvm,
927940
struct ieee80211_vif *vif,
928941
struct sk_buff *beacon,
929942
struct iwl_tx_cmd *tx)
930943
{
931944
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
932945
struct ieee80211_tx_info *info;
933-
u32 rate, tx_flags;
946+
u8 rate;
947+
u32 tx_flags;
934948

935949
info = IEEE80211_SKB_CB(beacon);
936950

@@ -955,14 +969,12 @@ static void iwl_mvm_mac_ctxt_set_tx(struct iwl_mvm *mvm,
955969
cpu_to_le32(BIT(mvm->mgmt_last_antenna_idx) <<
956970
RATE_MCS_ANT_POS);
957971

958-
if (info->band == NL80211_BAND_5GHZ || vif->p2p) {
959-
rate = IWL_FIRST_OFDM_RATE;
960-
} else {
961-
rate = IWL_FIRST_CCK_RATE;
962-
tx->rate_n_flags |= cpu_to_le32(RATE_MCS_CCK_MSK);
963-
}
972+
rate = iwl_mvm_mac_ctxt_get_lowest_rate(info, vif);
964973

965974
tx->rate_n_flags |= cpu_to_le32(iwl_mvm_mac80211_idx_to_hwrate(rate));
975+
if (rate == IWL_FIRST_CCK_RATE)
976+
tx->rate_n_flags |= cpu_to_le32(RATE_MCS_CCK_MSK);
977+
966978
}
967979

968980
static int iwl_mvm_mac_ctxt_send_beacon_cmd(struct iwl_mvm *mvm,
@@ -1033,19 +1045,27 @@ static int iwl_mvm_mac_ctxt_send_beacon_v7(struct iwl_mvm *mvm,
10331045
sizeof(beacon_cmd));
10341046
}
10351047

1036-
static int iwl_mvm_mac_ctxt_send_beacon_v8(struct iwl_mvm *mvm,
1048+
static int iwl_mvm_mac_ctxt_send_beacon_v9(struct iwl_mvm *mvm,
10371049
struct ieee80211_vif *vif,
10381050
struct sk_buff *beacon)
10391051
{
10401052
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1053+
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(beacon);
10411054
struct iwl_mac_beacon_cmd beacon_cmd = {};
1055+
u8 rate = iwl_mvm_mac_ctxt_get_lowest_rate(info, vif);
1056+
u16 flags;
1057+
1058+
flags = iwl_mvm_mac80211_idx_to_hwrate(rate);
10421059

1060+
if (rate == IWL_FIRST_CCK_RATE)
1061+
flags |= IWL_MAC_BEACON_CCK;
1062+
1063+
beacon_cmd.flags = cpu_to_le16(flags);
10431064
beacon_cmd.byte_cnt = cpu_to_le16((u16)beacon->len);
10441065
beacon_cmd.template_id = cpu_to_le32((u32)mvmvif->id);
10451066

10461067
if (vif->type == NL80211_IFTYPE_AP)
1047-
iwl_mvm_mac_ctxt_set_tim(mvm,
1048-
&beacon_cmd.tim_idx,
1068+
iwl_mvm_mac_ctxt_set_tim(mvm, &beacon_cmd.tim_idx,
10491069
&beacon_cmd.tim_size,
10501070
beacon->data, beacon->len);
10511071

@@ -1073,10 +1093,11 @@ static int iwl_mvm_mac_ctxt_send_beacon(struct iwl_mvm *mvm,
10731093
IWL_UCODE_TLV_CAPA_CSA_AND_TBTT_OFFLOAD))
10741094
return iwl_mvm_mac_ctxt_send_beacon_v6(mvm, vif, beacon);
10751095

1076-
if (!iwl_mvm_has_new_tx_api(mvm))
1077-
return iwl_mvm_mac_ctxt_send_beacon_v7(mvm, vif, beacon);
1096+
if (fw_has_api(&mvm->fw->ucode_capa,
1097+
IWL_UCODE_TLV_API_NEW_BEACON_TEMPLATE))
1098+
return iwl_mvm_mac_ctxt_send_beacon_v9(mvm, vif, beacon);
10781099

1079-
return iwl_mvm_mac_ctxt_send_beacon_v8(mvm, vif, beacon);
1100+
return iwl_mvm_mac_ctxt_send_beacon_v7(mvm, vif, beacon);
10801101
}
10811102

10821103
/* The beacon template for the AP/GO/IBSS has changed and needs update */

0 commit comments

Comments
 (0)