Skip to content

Commit

Permalink
Merge tag 'mac80211-next-for-net-next-2020-10-02' of git://git.kernel…
Browse files Browse the repository at this point in the history
….org/pub/scm/linux/kernel/git/jberg/mac80211-next

Johannes Berg says:

====================
Another set of changes, this time with:
 * lots more S1G band support
 * 6 GHz scanning, finally
 * kernel-doc fixes
 * non-split wiphy dump fixes in nl80211
 * various other small cleanups/features
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Oct 2, 2020
2 parents 4f359b6 + 75f87ea commit 26d0a8e
Show file tree
Hide file tree
Showing 27 changed files with 1,423 additions and 199 deletions.
100 changes: 90 additions & 10 deletions drivers/net/wireless/mac80211_hwsim.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ MODULE_PARM_DESC(support_p2p_device, "Support P2P-Device interface type");
* domain requests. The first radio will adhere to the first custom world
* regulatory domain, the second one to the second custom world regulatory
* domain. All other devices will world roam.
* @HWSIM_REGTEST_STRICT_FOLLOW_: Used for testing strict regulatory domain
* @HWSIM_REGTEST_STRICT_FOLLOW: Used for testing strict regulatory domain
* settings, only the first radio will send a regulatory domain request
* and use strict settings. The rest of the radios are expected to follow.
* @HWSIM_REGTEST_STRICT_ALL: Used for testing strict regulatory domain
Expand Down Expand Up @@ -377,6 +377,49 @@ static const struct ieee80211_channel hwsim_channels_5ghz[] = {
CHAN5G(5925), /* Channel 185 */
};

#define NUM_S1G_CHANS_US 51
static struct ieee80211_channel hwsim_channels_s1g[NUM_S1G_CHANS_US];

static const struct ieee80211_sta_s1g_cap hwsim_s1g_cap = {
.s1g = true,
.cap = { S1G_CAP0_SGI_1MHZ | S1G_CAP0_SGI_2MHZ,
0,
0,
S1G_CAP3_MAX_MPDU_LEN,
0,
S1G_CAP5_AMPDU,
0,
S1G_CAP7_DUP_1MHZ,
S1G_CAP8_TWT_RESPOND | S1G_CAP8_TWT_REQUEST,
0},
.nss_mcs = { 0xfc | 1, /* MCS 7 for 1 SS */
/* RX Highest Supported Long GI Data Rate 0:7 */
0,
/* RX Highest Supported Long GI Data Rate 0:7 */
/* TX S1G MCS Map 0:6 */
0xfa,
/* TX S1G MCS Map :7 */
/* TX Highest Supported Long GI Data Rate 0:6 */
0x80,
/* TX Highest Supported Long GI Data Rate 7:8 */
/* Rx Single spatial stream and S1G-MCS Map for 1MHz */
/* Tx Single spatial stream and S1G-MCS Map for 1MHz */
0 },
};

static void hwsim_init_s1g_channels(struct ieee80211_channel *channels)
{
int ch, freq;

for (ch = 0; ch < NUM_S1G_CHANS_US; ch++) {
freq = 902000 + (ch + 1) * 500;
channels[ch].band = NL80211_BAND_S1GHZ;
channels[ch].center_freq = KHZ_TO_MHZ(freq);
channels[ch].freq_offset = freq % 1000;
channels[ch].hw_value = ch + 1;
}
}

static const struct ieee80211_rate hwsim_rates[] = {
{ .bitrate = 10 },
{ .bitrate = 20, .flags = IEEE80211_RATE_SHORT_PREAMBLE },
Expand Down Expand Up @@ -505,6 +548,7 @@ struct mac80211_hwsim_data {
struct ieee80211_supported_band bands[NUM_NL80211_BANDS];
struct ieee80211_channel channels_2ghz[ARRAY_SIZE(hwsim_channels_2ghz)];
struct ieee80211_channel channels_5ghz[ARRAY_SIZE(hwsim_channels_5ghz)];
struct ieee80211_channel channels_s1g[ARRAY_SIZE(hwsim_channels_s1g)];
struct ieee80211_rate rates[ARRAY_SIZE(hwsim_rates)];
struct ieee80211_iface_combination if_combination;
struct ieee80211_iface_limit if_limits[3];
Expand Down Expand Up @@ -900,12 +944,14 @@ static void mac80211_hwsim_monitor_rx(struct ieee80211_hw *hw,
struct mac80211_hwsim_data *data = hw->priv;
struct sk_buff *skb;
struct hwsim_radiotap_hdr *hdr;
u16 flags;
u16 flags, bitrate;
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx_skb);
struct ieee80211_rate *txrate = ieee80211_get_tx_rate(hw, info);

if (WARN_ON(!txrate))
return;
if (!txrate)
bitrate = 0;
else
bitrate = txrate->bitrate;

if (!netif_running(hwsim_mon))
return;
Expand All @@ -924,10 +970,10 @@ static void mac80211_hwsim_monitor_rx(struct ieee80211_hw *hw,
(1 << IEEE80211_RADIOTAP_CHANNEL));
hdr->rt_tsft = __mac80211_hwsim_get_tsf(data);
hdr->rt_flags = 0;
hdr->rt_rate = txrate->bitrate / 5;
hdr->rt_rate = bitrate / 5;
hdr->rt_channel = cpu_to_le16(chan->center_freq);
flags = IEEE80211_CHAN_2GHZ;
if (txrate->flags & IEEE80211_RATE_ERP_G)
if (txrate && txrate->flags & IEEE80211_RATE_ERP_G)
flags |= IEEE80211_CHAN_OFDM;
else
flags |= IEEE80211_CHAN_CCK;
Expand Down Expand Up @@ -1341,6 +1387,7 @@ static bool mac80211_hwsim_tx_frame_no_nl(struct ieee80211_hw *hw,
memset(&rx_status, 0, sizeof(rx_status));
rx_status.flag |= RX_FLAG_MACTIME_START;
rx_status.freq = chan->center_freq;
rx_status.freq_offset = chan->freq_offset ? 1 : 0;
rx_status.band = chan->band;
if (info->control.rates[0].flags & IEEE80211_TX_RC_VHT_MCS) {
rx_status.rate_idx =
Expand Down Expand Up @@ -1522,14 +1569,18 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw,
/* fake header transmission time */
struct ieee80211_mgmt *mgmt;
struct ieee80211_rate *txrate;
/* TODO: get MCS */
int bitrate = 100;
u64 ts;

mgmt = (struct ieee80211_mgmt *)skb->data;
txrate = ieee80211_get_tx_rate(hw, txi);
if (txrate)
bitrate = txrate->bitrate;
ts = mac80211_hwsim_get_tsf_raw();
mgmt->u.probe_resp.timestamp =
cpu_to_le64(ts + data->tsf_offset +
24 * 8 * 10 / txrate->bitrate);
24 * 8 * 10 / bitrate);
}

mac80211_hwsim_monitor_rx(hw, skb, channel);
Expand Down Expand Up @@ -1664,6 +1715,8 @@ static void mac80211_hwsim_beacon_tx(void *arg, u8 *mac,
struct ieee80211_rate *txrate;
struct ieee80211_mgmt *mgmt;
struct sk_buff *skb;
/* TODO: get MCS */
int bitrate = 100;

hwsim_check_magic(vif);

Expand All @@ -1683,13 +1736,25 @@ static void mac80211_hwsim_beacon_tx(void *arg, u8 *mac,
ARRAY_SIZE(info->control.rates));

txrate = ieee80211_get_tx_rate(hw, info);
if (txrate)
bitrate = txrate->bitrate;

mgmt = (struct ieee80211_mgmt *) skb->data;
/* fake header transmission time */
data->abs_bcn_ts = mac80211_hwsim_get_tsf_raw();
mgmt->u.beacon.timestamp = cpu_to_le64(data->abs_bcn_ts +
data->tsf_offset +
24 * 8 * 10 / txrate->bitrate);
if (ieee80211_is_s1g_beacon(mgmt->frame_control)) {
struct ieee80211_ext *ext = (void *) mgmt;

ext->u.s1g_beacon.timestamp = cpu_to_le32(data->abs_bcn_ts +
data->tsf_offset +
10 * 8 * 10 /
bitrate);
} else {
mgmt->u.beacon.timestamp = cpu_to_le64(data->abs_bcn_ts +
data->tsf_offset +
24 * 8 * 10 /
bitrate);
}

mac80211_hwsim_tx_frame(hw, skb,
rcu_dereference(vif->chanctx_conf)->def.chan);
Expand Down Expand Up @@ -1737,6 +1802,11 @@ static const char * const hwsim_chanwidths[] = {
[NL80211_CHAN_WIDTH_80] = "vht80",
[NL80211_CHAN_WIDTH_80P80] = "vht80p80",
[NL80211_CHAN_WIDTH_160] = "vht160",
[NL80211_CHAN_WIDTH_1] = "1MHz",
[NL80211_CHAN_WIDTH_2] = "2MHz",
[NL80211_CHAN_WIDTH_4] = "4MHz",
[NL80211_CHAN_WIDTH_8] = "8MHz",
[NL80211_CHAN_WIDTH_16] = "16MHz",
};

static int mac80211_hwsim_config(struct ieee80211_hw *hw, u32 changed)
Expand Down Expand Up @@ -3079,6 +3149,8 @@ static int mac80211_hwsim_new_radio(struct genl_info *info,
sizeof(hwsim_channels_2ghz));
memcpy(data->channels_5ghz, hwsim_channels_5ghz,
sizeof(hwsim_channels_5ghz));
memcpy(data->channels_s1g, hwsim_channels_s1g,
sizeof(hwsim_channels_s1g));
memcpy(data->rates, hwsim_rates, sizeof(hwsim_rates));

for (band = NL80211_BAND_2GHZ; band < NUM_NL80211_BANDS; band++) {
Expand Down Expand Up @@ -3121,6 +3193,12 @@ static int mac80211_hwsim_new_radio(struct genl_info *info,
sband->vht_cap.vht_mcs.tx_mcs_map =
sband->vht_cap.vht_mcs.rx_mcs_map;
break;
case NL80211_BAND_S1GHZ:
memcpy(&sband->s1g_cap, &hwsim_s1g_cap,
sizeof(sband->s1g_cap));
sband->channels = data->channels_s1g;
sband->n_channels = ARRAY_SIZE(hwsim_channels_s1g);
break;
default:
continue;
}
Expand Down Expand Up @@ -4318,6 +4396,8 @@ static int __init init_mac80211_hwsim(void)
goto out_exit_virtio;
}

hwsim_init_s1g_channels(hwsim_channels_s1g);

for (i = 0; i < radios; i++) {
struct hwsim_new_radio_params param = { 0 };

Expand Down
74 changes: 72 additions & 2 deletions include/linux/ieee80211.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@

#define IEEE80211_ANO_NETTYPE_WILD 15

/* bits unique to S1G beacon */
#define IEEE80211_S1G_BCN_NEXT_TBTT 0x100

/* control extension - for IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTL_EXT */
#define IEEE80211_CTL_EXT_POLL 0x2000
#define IEEE80211_CTL_EXT_SPR 0x3000
Expand Down Expand Up @@ -553,6 +556,28 @@ static inline bool ieee80211_is_s1g_beacon(__le16 fc)
cpu_to_le16(IEEE80211_FTYPE_EXT | IEEE80211_STYPE_S1G_BEACON);
}

/**
* ieee80211_next_tbtt_present - check if IEEE80211_FTYPE_EXT &&
* IEEE80211_STYPE_S1G_BEACON && IEEE80211_S1G_BCN_NEXT_TBTT
* @fc: frame control bytes in little-endian byteorder
*/
static inline bool ieee80211_next_tbtt_present(__le16 fc)
{
return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
cpu_to_le16(IEEE80211_FTYPE_EXT | IEEE80211_STYPE_S1G_BEACON) &&
fc & cpu_to_le16(IEEE80211_S1G_BCN_NEXT_TBTT);
}

/**
* ieee80211_is_s1g_short_beacon - check if next tbtt present bit is set. Only
* true for S1G beacons when they're short.
* @fc: frame control bytes in little-endian byteorder
*/
static inline bool ieee80211_is_s1g_short_beacon(__le16 fc)
{
return ieee80211_is_s1g_beacon(fc) && ieee80211_next_tbtt_present(fc);
}

/**
* ieee80211_is_atim - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ATIM
* @fc: frame control bytes in little-endian byteorder
Expand Down Expand Up @@ -962,6 +987,25 @@ enum ieee80211_vht_opmode_bits {
IEEE80211_OPMODE_NOTIF_RX_NSS_TYPE_BF = 0x80,
};

/**
* enum ieee80211_s1g_chanwidth
* These are defined in IEEE802.11-2016ah Table 10-20
* as BSS Channel Width
*
* @IEEE80211_S1G_CHANWIDTH_1MHZ: 1MHz operating channel
* @IEEE80211_S1G_CHANWIDTH_2MHZ: 2MHz operating channel
* @IEEE80211_S1G_CHANWIDTH_4MHZ: 4MHz operating channel
* @IEEE80211_S1G_CHANWIDTH_8MHZ: 8MHz operating channel
* @IEEE80211_S1G_CHANWIDTH_16MHZ: 16MHz operating channel
*/
enum ieee80211_s1g_chanwidth {
IEEE80211_S1G_CHANWIDTH_1MHZ = 0,
IEEE80211_S1G_CHANWIDTH_2MHZ = 1,
IEEE80211_S1G_CHANWIDTH_4MHZ = 3,
IEEE80211_S1G_CHANWIDTH_8MHZ = 7,
IEEE80211_S1G_CHANWIDTH_16MHZ = 15,
};

#define WLAN_SA_QUERY_TR_ID_LEN 2
#define WLAN_MEMBERSHIP_LEN 8
#define WLAN_USER_POSITION_LEN 16
Expand Down Expand Up @@ -1034,6 +1078,13 @@ struct ieee80211_ext {
u8 change_seq;
u8 variable[0];
} __packed s1g_beacon;
struct {
u8 sa[ETH_ALEN];
__le32 timestamp;
u8 change_seq;
u8 next_tbtt[3];
u8 variable[0];
} __packed s1g_short_beacon;
} u;
} __packed __aligned(2);

Expand Down Expand Up @@ -1068,6 +1119,11 @@ struct ieee80211_mgmt {
/* followed by Supported rates */
u8 variable[0];
} __packed assoc_resp, reassoc_resp;
struct {
__le16 capab_info;
__le16 status_code;
u8 variable[0];
} __packed s1g_assoc_resp, s1g_reassoc_resp;
struct {
__le16 capab_info;
__le16 listen_interval;
Expand Down Expand Up @@ -2294,8 +2350,11 @@ ieee80211_he_6ghz_oper(const struct ieee80211_he_operation *he_oper)
}

/* HE Spatial Reuse defines */
#define IEEE80211_HE_SPR_NON_SRG_OFFSET_PRESENT 0x4
#define IEEE80211_HE_SPR_SRG_INFORMATION_PRESENT 0x8
#define IEEE80211_HE_SPR_PSR_DISALLOWED BIT(0)
#define IEEE80211_HE_SPR_NON_SRG_OBSS_PD_SR_DISALLOWED BIT(1)
#define IEEE80211_HE_SPR_NON_SRG_OFFSET_PRESENT BIT(2)
#define IEEE80211_HE_SPR_SRG_INFORMATION_PRESENT BIT(3)
#define IEEE80211_HE_SPR_HESIGA_SR_VAL15_ALLOWED BIT(4)

/*
* ieee80211_he_spr_size - calculate 802.11ax HE Spatial Reuse IE size
Expand Down Expand Up @@ -2330,6 +2389,8 @@ ieee80211_he_spr_size(const u8 *he_spr_ie)
}

/* S1G Capabilities Information field */
#define IEEE80211_S1G_CAPABILITY_LEN 15

#define S1G_CAP0_S1G_LONG BIT(0)
#define S1G_CAP0_SGI_1MHZ BIT(1)
#define S1G_CAP0_SGI_2MHZ BIT(2)
Expand Down Expand Up @@ -2409,6 +2470,13 @@ ieee80211_he_spr_size(const u8 *he_spr_ie)
#define S1G_OPER_CH_WIDTH_PRIMARY_1MHZ BIT(0)
#define S1G_OPER_CH_WIDTH_OPER GENMASK(4, 1)


#define LISTEN_INT_USF GENMASK(15, 14)
#define LISTEN_INT_UI GENMASK(13, 0)

#define IEEE80211_MAX_USF FIELD_MAX(LISTEN_INT_USF)
#define IEEE80211_MAX_UI FIELD_MAX(LISTEN_INT_UI)

/* Authentication algorithms */
#define WLAN_AUTH_OPEN 0
#define WLAN_AUTH_SHARED_KEY 1
Expand Down Expand Up @@ -2808,6 +2876,8 @@ enum ieee80211_eid {

WLAN_EID_REDUCED_NEIGHBOR_REPORT = 201,

WLAN_EID_AID_REQUEST = 210,
WLAN_EID_AID_RESPONSE = 211,
WLAN_EID_S1G_BCN_COMPAT = 213,
WLAN_EID_S1G_SHORT_BCN_INTERVAL = 214,
WLAN_EID_S1G_CAPABILITIES = 217,
Expand Down
Loading

0 comments on commit 26d0a8e

Please sign in to comment.