wifi: mm81x: support v57 firmware
Lachlan Hodges
maintainerv2 cover wifi: mm81x: support v57 firmware
Hi,
Small set to support v57 firmware.
v1->v2:
- Resending now that -next has been ff'd
lachlan
Lachlan Hodges (4):
wifi: mm81x: use guard(rcu)() over scoped_guard()
wifi: mm81x: use the BCF size advertised by the firmware
wifi: mm81x: support v57 firmware
wifi: mm81x: drop probe requests received off channel
.../wireless/morsemicro/mm81x/command_defs.h | 38 +++++++++-- drivers/net/wireless/morsemicro/mm81x/core.h | 1 + drivers/net/wireless/morsemicro/mm81x/fw.c | 27 +++++--- drivers/net/wireless/morsemicro/mm81x/fw.h | 3 +- drivers/net/wireless/morsemicro/mm81x/hw.c | 2 + drivers/net/wireless/morsemicro/mm81x/mac.c | 64 +++++++++++++++---- drivers/net/wireless/morsemicro/mm81x/skbq.h | 22 ++++++- 7 files changed, 127 insertions(+), 30 deletions(-)
Signature · 1 line
2.43.0
Lachlan Hodges
maintainerPATCH v2 1/4 wifi: mm81x: use guard(rcu)() over scoped_guard()
use guard(rcu) over scoped_guard() to reduce a level of indentation. No functional change.
--- drivers/net/wireless/morsemicro/mm81x/mac.c | 27 ++++++++++----------- 1 file changed, 13 insertions(+), 14 deletions(-)
drivers/net/wireless/morsemicro/mm81x/mac.c +13 -14
@@ -2136,23 +2136,22 @@ void mm81x_mac_rx_skb(struct mm81x *mors, struct sk_buff *skb,mm81x_rx_h_fill_status (mors, hdr_rx_status, &rx_status, skb); -scoped_guard (rcu) { - vif =mm81x_rx_h_skb_get_vif (mors, skb, hdr_rx_status); -if (vif) { - sta =ieee80211_find_sta (vif, lookup); -if (sta) -mm81x_rx_h_update_sta (sta, &rx_status); - } +guard (rcu)(); + vif =mm81x_rx_h_skb_get_vif (mors, skb, hdr_rx_status); +if (vif) { + sta =ieee80211_find_sta (vif, lookup); +if (sta) +mm81x_rx_h_update_sta (sta, &rx_status); + } -if (mors->monitor_en) -mm81x_rx_h_add_rt_s1g_tlv (skb, hdr_rx_status, &rx_status); +if (mors->monitor_en) +mm81x_rx_h_add_rt_s1g_tlv (skb, hdr_rx_status, &rx_status); -memcpy (IEEE80211_SKB_RXCB (skb), &rx_status,sizeof (rx_status)); +memcpy (IEEE80211_SKB_RXCB (skb), &rx_status,sizeof (rx_status)); -local_bh_disable (); -ieee80211_rx_napi (hw, sta ? &sta->deflink :NULL , skb,NULL ); -local_bh_enable (); - } +local_bh_disable (); +ieee80211_rx_napi (hw, sta ? &sta->deflink :NULL , skb,NULL ); +local_bh_enable (); }static void mm81x_mac_flush_queues (struct mm81x *mors)
Signature · 1 line
2.43.0
Lachlan Hodges
maintainerPATCH v2 2/4 wifi: mm81x: use the BCF size advertised by the firmware
In reply to Lachlan HodgesThe BCF region in firmware memory grew from 1024 to 2048 bytes in v57 firmware, which now advertises the size of the region in its .fw_info section. Use the advertised size to limit the BCF written to the chip, falling back to the previous 1024 bytes for firmware that does not advertise it.
--- drivers/net/wireless/morsemicro/mm81x/core.h | 1 + drivers/net/wireless/morsemicro/mm81x/fw.c | 8 ++++++-- drivers/net/wireless/morsemicro/mm81x/fw.h | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-)
drivers/net/wireless/morsemicro/mm81x/core.h +1 -0
@@ -312,6 +312,7 @@ struct mm81x {/* Refer to @enum mm81x_bus_type */ u32 bus_type;u32 bcf_address; +u32 bcf_size;/* * Parsed from the release tag, which should be in the format
drivers/net/wireless/morsemicro/mm81x/fw.c +6 -2
@@ -62,6 +62,9 @@ static void mm81x_fw_parse_info(struct mm81x *mors, const u8 *data, int length)case MM81X_FW_INFO_TLV_BCF_ADDR : mors->bcf_address =get_unaligned_le32 (tlv->val);break ; +case MM81X_FW_INFO_TLV_BCF_SIZE : + mors->bcf_size =get_unaligned_le32 (tlv->val); +break ;default :break ; }
@@ -167,6 +170,7 @@ static int mm81x_fw_load_fw(struct mm81x *mors, const struct firmware *fw) } } + mors->bcf_size =BCF_DEFAULT_SIZE ;for (i =0 ; i < ehdr.e_shnum; i++) {if (mm81x_fw_get_section_header (fw->data, &ehdr, &shdr, i))continue ;
@@ -195,7 +199,7 @@ static int __mm81x_fw_load_bcf(struct mm81x *mors, unsigned int addr,if (rounded > scratch_cap)return -EINVAL ; -if (rounded >BCF_DATABASE_SIZE ) +if (rounded > mors->bcf_size)return -EFBIG ;memcpy (scratch, src, src_len);
@@ -286,7 +290,7 @@ static int mm81x_fw_load_bcf(struct mm81x *mors, const struct firmware *bcf, goto out_free; reg_len_rounded =ROUND_BYTES_TO_WORD (reg_len); -if ((cfg_len_rounded + reg_len_rounded) >BCF_DATABASE_SIZE ) { +if ((cfg_len_rounded + reg_len_rounded) > mors->bcf_size) { ret = -EFBIG ; goto out_free; }
drivers/net/wireless/morsemicro/mm81x/fw.h +2 -1
@@ -12,7 +12,7 @@#include "command_defs.h" #include "yaps_hw.h" -#define BCF_DATABASE_SIZE (1024) +#define BCF_DEFAULT_SIZE (1024)#define MM81X_FW_DIR "morsemicro/mm81x"#define MM81X_FW_EXT ".bin"
@@ -65,6 +65,7 @@ struct mm81x_elf32_phdr {enum mm81x_fw_info_tlv_type {MM81X_FW_INFO_TLV_BCF_ADDR =1 , +MM81X_FW_INFO_TLV_BCF_SIZE =3 , };struct mm81x_fw_info_tlv {
Signature · 1 line
2.43.0
Lachlan Hodges
maintainerPATCH v2 3/4 wifi: mm81x: support v57 firmware
In reply to Lachlan HodgesUpdate the type definitions to support the v57 firmware and advertise suppport for the new firmware.
--- .../wireless/morsemicro/mm81x/command_defs.h | 38 +++++++++++++++++-- drivers/net/wireless/morsemicro/mm81x/fw.c | 19 +++++++--- drivers/net/wireless/morsemicro/mm81x/hw.c | 2 + drivers/net/wireless/morsemicro/mm81x/mac.c | 16 ++++++++ drivers/net/wireless/morsemicro/mm81x/skbq.h | 22 +++++++++-- 5 files changed, 84 insertions(+), 13 deletions(-)
drivers/net/wireless/morsemicro/mm81x/command_defs.h +34 -4
@@ -11,8 +11,8 @@#define __sle32 __le32#define __sle64 __le64 -#define HOST_CMD_SEMVER_MAJOR 56 -#define HOST_CMD_SEMVER_MINOR 17 +#define HOST_CMD_SEMVER_MAJOR 57 +#define HOST_CMD_SEMVER_MINOR 20#define HOST_CMD_SEMVER_PATCH 0#define HOST_CMD_TYPE_REQ BIT(0)
@@ -149,6 +149,19 @@ enum host_cmd_ocs_subcmd { HOST_CMD_OCS_SUBCMD_STATUS = 2, }; +enum host_cmd_boot_code { +HOST_CMD_BOOT_CODE_NONE =0 , +HOST_CMD_BOOT_CODE_BCF_INIT =1 , +HOST_CMD_BOOT_CODE_VALID_BCF_NOT_FOUND =2 , +HOST_CMD_BOOT_CODE_BCF_LEN_INVALID =3 , +HOST_CMD_BOOT_CODE_BCF_CRC_INVALID =4 , +HOST_CMD_BOOT_CODE_BCF_UNSUPPORTED_VERSION =5 , +HOST_CMD_BOOT_CODE_BCF_REGDOM_LEN_INVALID =6 , +HOST_CMD_BOOT_CODE_BCF_REGDOM_CRC_INVALID =7 , +HOST_CMD_BOOT_CODE_BCF_PARSE_FAIL =8 , +HOST_CMD_BOOT_CODE_COMPLETE =255 , +}; +enum host_cmd_headless_cfg_option {HOST_CMD_HEADLESS_CFG_OPTION_KEEP_IFACES =BIT (0 ),HOST_CMD_HEADLESS_CFG_OPTION_BUFFER_RX =BIT (1 ),
@@ -1211,7 +1224,7 @@ struct host_cmd_req_mbssid {#define HOST_CMD_MESH_BEACONLESS_MODE_DISABLE 0#define HOST_CMD_MESH_BEACONLESS_MODE_ENABLE 1#define HOST_CMD_MESH_PEER_LINKS_MIN 0 -#define HOST_CMD_MESH_PEER_LINKS_MAX 10 +#define HOST_CMD_MESH_PEER_LINKS_MAX 20struct host_cmd_req_set_mesh_config {struct host_cmd_header hdr;
@@ -1587,9 +1600,18 @@ enum host_cmd_hart_id { HOST_CMD_HART_ID_LPHY = 3, }; +enum host_cmd_crash_type { +HOST_CMD_CRASH_TYPE_ASSERTION_FAILURE =0 , +HOST_CMD_CRASH_TYPE_NULL_DEREFERENCE =1 , +HOST_CMD_CRASH_TYPE_HANG =2 , +HOST_CMD_CRASH_TYPE_HANG_NOIRQ =3 , +}; +struct host_cmd_req_force_assert {struct host_cmd_header hdr;__le32 hart_id; +__le32 delay; +__le32 crash_type; } __packed;#define HOST_CMD_HOST_BLOCK_TX_FRAMES BIT(0)
@@ -1637,7 +1659,15 @@ enum host_cmd_param_id {HOST_CMD_PARAM_ID_DEFAULT_ACTIVE_SCAN_DWELL_MS =27 ,HOST_CMD_PARAM_ID_CTS_TO_SELF =28 ,HOST_CMD_PARAM_ID_CHANNELIZATION =29 , - HOST_CMD_PARAM_ID_LAST = 30, +HOST_CMD_PARAM_ID_CRYPTO_IN_HOST =30 , +HOST_CMD_PARAM_ID_AUTOCONNECT =31 , +HOST_CMD_PARAM_ID_HOST_PWR_OFF_GPIO =32 , +HOST_CMD_PARAM_ID_HOST_PWR_OFF_GPIO_PULSE_MS =33 , +HOST_CMD_PARAM_ID_ALLOW_PRE_ASSOC_OFF_CHAN_PS =34 , +HOST_CMD_PARAM_ID_SCAN_INTERVAL_BASE_S =35 , +HOST_CMD_PARAM_ID_SCAN_INTERVAL_LIMIT_S =36 , +HOST_CMD_PARAM_ID_AMPDU_FEEDBACK =37 , + HOST_CMD_PARAM_ID_LAST = 38, }; struct host_cmd_req_get_set_generic_param {
drivers/net/wireless/morsemicro/mm81x/fw.c +13 -6
@@ -384,7 +384,7 @@ static int mm81x_fw_get_flags(struct mm81x *mors)static int mm81x_fw_check_compatibility (struct mm81x *mors) { -int ret =0 ; +int ret;u32 fw_version;u32 major;u32 minor;
@@ -397,23 +397,30 @@ static int mm81x_fw_check_compatibility(struct mm81x *mors) fw_version_number), &fw_version);mm81x_release_bus (mors); +if (ret) +return ret; major =MM81X_SEMVER_GET_MAJOR (fw_version); minor =MM81X_SEMVER_GET_MINOR (fw_version); patch =MM81X_SEMVER_GET_PATCH (fw_version); +dev_info (mors->dev,"Firmware API version %u.%u.%u\n" , major, minor, + patch); +/* Firmware on device must match the firmware file we requested */ -if (ret ==0 && major != mors->fw_major) { +if (major != mors->fw_major) {dev_err (mors->dev,"Incompatible FW version: (Requested) v%u, (Chip) %d.%d.%d\n" , mors->fw_major, major, minor, patch); - ret = -EPERM ; - }else if (ret ==0 && major !=HOST_CMD_SEMVER_MAJOR ) { +return -EPERM ; + } + +if (major !=HOST_CMD_SEMVER_MAJOR ) {dev_warn ( mors->dev,"Running FW v%d.%d.%d, driver supports up to v%d, some features might not be supported" , major, minor, patch,HOST_CMD_SEMVER_MAJOR ); - }else if (ret ==0 && minor !=HOST_CMD_SEMVER_MINOR ) { + }else if (minor !=HOST_CMD_SEMVER_MINOR ) { dev_warn( mors->dev, "FW version mismatch, some features might not be supported: (Driver) %d.%d.%d, (Chip) %d.%d.%d",
@@ -421,7 +428,7 @@ static int mm81x_fw_check_compatibility(struct mm81x *mors) HOST_CMD_SEMVER_PATCH, major, minor, patch); } -return ret; +return 0 ; }static int mm81x_fw_invalidate_host_ptr (struct mm81x *mors)
drivers/net/wireless/morsemicro/mm81x/hw.c +2 -0
@@ -365,3 +365,5 @@ const struct mm81x_regs mm8108_regs = { MODULE_FIRMWARE(MM81X_FW_DIR "/v" __stringify(MM81X_FW_VER_MAX) "/"MM8108_FW_BASE MM81X_FW_EXT ); +MODULE_FIRMWARE(MM81X_FW_DIR "/v" __stringify(MM81X_FW_VER_MIN) "/" +MM8108_FW_BASE MM81X_FW_EXT );
drivers/net/wireless/morsemicro/mm81x/mac.c +16 -0
@@ -2009,6 +2009,22 @@ static void mm81x_rx_h_add_rt_s1g_tlv(struct sk_buff *skb,* This is a hack to workaround how our firmware reports frequencies. * For any 1MHz frames report them directly (i.e during scanning), else * report the 1MHz control channel we are tuned to. +* +* Unfortunately, the new channel_info field reported by the v57 +* is actually not what we are after. The part of the channel_info +* field reports the index of the _first_ 1MHz channel of the +* channel it was transmitted on. This is because the firmware is +* _really_ reporting the subband carrier offset, not the control +* channel the radio was tuned to during reception. +* +* For example, say an 8MHz operating on channel 44 with a 1MHz +* primary of 39. If a frame is transmitted on the 4MHz primary, +* the channel_info will convey the 1MHz index as 0, even though +* the primary 1MHz we were tuned was index 1. For a frame +* transmitted at 8MHz, the index is _always_ zero. +* +* This means we unfortunately need to keep using this for both +* v56 and v57 firmware in the meantime. */ static void mm81x_rx_h_fill_freq (struct mm81x *mors,u32 rx_khz,struct ieee80211_rx_status *rx_status)
drivers/net/wireless/morsemicro/mm81x/skbq.h +19 -3
@@ -104,7 +104,15 @@ struct mm81x_skb_tx_status {__le32 pkt_id;u8 tid;u8 channel; -__le16 ampdu_info; +union { +struct { +__le16 ampdu_info; + } __packed v56; +struct { +u8 per_attempt_ampdu_info; +u8 per_attempt_missing_block_ack; + } __packed v57; + };struct mm81x_skb_rate_info rates[MM81X_SKB_MAX_RATES ]; } __packed;
@@ -150,8 +158,16 @@ struct mm81x_skb_rx_status {__le16 freq_100khz;u8 bss_color;s8 noise_dbm; -/** Padding for word alignment */ -u8 padding[2 ]; +union { +struct { +/** Padding for word alignment */ +u8 padding[2 ]; + } __packed v56; +struct { +u8 channel_info; +u8 padding; + } __packed v57; + };__le64 rx_timestamp_us; } __packed;
Signature · 1 line
2.43.0
Lachlan Hodges
maintainerPATCH v2 4/4 wifi: mm81x: drop probe requests received off channel
In reply to Lachlan HodgesThe mm81x receiver picks up probe requests on channels adjacent to the tuned 1MHz control channel. These probe requests travel up the stack as they are assumed to be received on the control channel which leads to multiple probe responses being sent out on the control channel flooding airtime. This is especially noticable in mutli-sta scenarios at lower bandwidths where airtime is especially precious and leads to failed associations.
To fix, drop any probe requests that weren't received on our tuned control channel.
--- drivers/net/wireless/morsemicro/mm81x/mac.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
drivers/net/wireless/morsemicro/mm81x/mac.c +21 -0
@@ -2115,6 +2115,22 @@ static void mm81x_rx_h_update_sta(struct ieee80211_sta *sta, } } +/* +* The chip receives 1MHz PPDUs on any 1MHz channel within the operating +* channel. Probe requests sent outside the primary channel are from STAs +* that can't hear our response, so don't pass them up. +*/ +static bool mm81x_rx_h_is_off_chan_probe_req (struct mm81x *mors, +struct ieee80211_hdr *hdr, +struct ieee80211_rx_status *rx_status) +{ +if (mors->monitor_en || !ieee80211_is_probe_req (hdr->frame_control)) +return false; + +return ieee80211_rx_status_to_khz (rx_status) != +ieee80211_channel_to_khz (mors->chandef.chan); +} +static struct ieee80211_vif *mm81x_rx_h_skb_get_vif (struct mm81x *mors,struct sk_buff *skb,struct mm81x_skb_rx_status *hdr_rx_status)
@@ -2152,6 +2168,11 @@ void mm81x_mac_rx_skb(struct mm81x *mors, struct sk_buff *skb,mm81x_rx_h_fill_status (mors, hdr_rx_status, &rx_status, skb); +if (mm81x_rx_h_is_off_chan_probe_req (mors, hdr, &rx_status)) { +dev_kfree_skb_any (skb); +return ; + } +guard (rcu)(); vif =mm81x_rx_h_skb_get_vif (mors, skb, hdr_rx_status);if (vif) {
Signature · 1 line
2.43.0