Lines Matching +full:combined +full:- +full:power +full:- +full:req
1 // SPDX-License-Identifier: GPL-2.0-only
3 * mac80211_hwsim - software simulator of 802.11 radio(s) for mac80211
6 * Copyright (c) 2016 - 2017 Intel Deutschland GmbH
7 * Copyright (C) 2018 - 2022 Intel Corporation
12 * - Add TSF sync and fix IBSS beacon transmission by adding
14 * - RX filtering based on filter configuration (data->rx_filter)
66 MODULE_PARM_DESC(support_p2p_device, "Support P2P-Device interface type");
73 * enum hwsim_regtest - the type of regulatory tests we offer
97 * this by using a custom beacon-capable regulatory domain for the first
112 * domain settings, combined with secondary driver regulatory domain
115 * non-strict settings using the second driver regulatory request. All
120 * 1 - driver custom world regulatory domain
121 * 2 - second custom world regulatory domain
122 * 3 - first driver regulatory domain request
123 * 4 - second driver regulatory domain request
124 * 5 - strict regulatory domain settings using the third driver regulatory
126 * 6 and on - should follow the intersection of the 3rd, 4rth and 5th radio
161 REG_RULE(2412-10, 2462+10, 40, 0, 20, 0),
162 REG_RULE(2484-10, 2484+10, 40, 0, 20, 0),
163 REG_RULE(5150-10, 5240+10, 40, 0, 30, 0),
164 REG_RULE(5745-10, 5825+10, 40, 0, 30, 0),
165 REG_RULE(5855-10, 5925+10, 40, 0, 33, 0),
173 REG_RULE(2412-10, 2462+10, 40, 0, 20, 0),
174 REG_RULE(5725-10, 5850+10, 40, 0, 30,
176 REG_RULE(5855-10, 5925+10, 40, 0, 33, 0),
184 REG_RULE(2412 - 10, 2462 + 10, 40, 0, 20, 0),
185 REG_RULE(2484 - 10, 2484 + 10, 40, 0, 20, 0),
186 REG_RULE(5150 - 10, 5240 + 10, 40, 0, 30, 0),
187 REG_RULE(5745 - 10, 5825 + 10, 40, 0, 30, 0),
188 REG_RULE(5855 - 10, 5925 + 10, 40, 0, 33, 0),
189 REG_RULE(5955 - 10, 7125 + 10, 320, 0, 33, 0),
211 struct hwsim_vif_priv *vp = (void *)vif->drv_priv; in hwsim_check_magic()
212 WARN(vp->magic != HWSIM_VIF_MAGIC, in hwsim_check_magic()
214 vif, vp->magic, vif->addr, vif->type, vif->p2p); in hwsim_check_magic()
219 struct hwsim_vif_priv *vp = (void *)vif->drv_priv; in hwsim_set_magic()
220 vp->magic = HWSIM_VIF_MAGIC; in hwsim_set_magic()
225 struct hwsim_vif_priv *vp = (void *)vif->drv_priv; in hwsim_clear_magic()
226 vp->magic = 0; in hwsim_clear_magic()
239 struct hwsim_sta_priv *sp = (void *)sta->drv_priv; in hwsim_check_sta_magic()
240 WARN_ON(sp->magic != HWSIM_STA_MAGIC); in hwsim_check_sta_magic()
245 struct hwsim_sta_priv *sp = (void *)sta->drv_priv; in hwsim_set_sta_magic()
246 sp->magic = HWSIM_STA_MAGIC; in hwsim_set_sta_magic()
251 struct hwsim_sta_priv *sp = (void *)sta->drv_priv; in hwsim_clear_sta_magic()
252 sp->magic = 0; in hwsim_clear_sta_magic()
263 struct hwsim_chanctx_priv *cp = (void *)c->drv_priv; in hwsim_check_chanctx_magic()
264 WARN_ON(cp->magic != HWSIM_CHANCTX_MAGIC); in hwsim_check_chanctx_magic()
269 struct hwsim_chanctx_priv *cp = (void *)c->drv_priv; in hwsim_set_chanctx_magic()
270 cp->magic = HWSIM_CHANCTX_MAGIC; in hwsim_set_chanctx_magic()
275 struct hwsim_chanctx_priv *cp = (void *)c->drv_priv; in hwsim_clear_chanctx_magic()
276 cp->magic = 0; in hwsim_clear_chanctx_magic()
292 return hwsim_net->netgroup; in hwsim_net_get_netgroup()
299 hwsim_net->netgroup = ida_alloc(&hwsim_netgroup_ida, GFP_KERNEL); in hwsim_net_set_netgroup()
300 return hwsim_net->netgroup >= 0 ? 0 : -ENOMEM; in hwsim_net_set_netgroup()
307 return hwsim_net->wmediumd; in hwsim_net_get_wmediumd()
314 hwsim_net->wmediumd = portid; in hwsim_net_set_wmediumd()
492 /* Rx Single spatial stream and S1G-MCS Map for 1MHz */
493 /* Tx Single spatial stream and S1G-MCS Map for 1MHz */
525 #define DEFAULT_RX_RSSI -50
567 return -EINVAL; in mac80211_hwsim_vendor_cmd_test()
587 /* Send the event - this will call nla_nest_end() */ in mac80211_hwsim_vendor_cmd_test()
594 return -ENOMEM; in mac80211_hwsim_vendor_cmd_test()
812 err = -ENODEV; in hwsim_tx_virtio()
816 sg_init_one(sg, skb->head, skb_end_offset(skb)); in hwsim_tx_virtio()
879 struct hwsim_vif_priv *vp = (void *)vif->drv_priv; in hwsim_send_ps_poll()
883 if (!vp->assoc) in hwsim_send_ps_poll()
886 wiphy_dbg(data->hw->wiphy, in hwsim_send_ps_poll()
887 "%s: send PS-Poll to %pM for aid %d\n", in hwsim_send_ps_poll()
888 __func__, vp->bssid, vp->aid); in hwsim_send_ps_poll()
894 pspoll->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | in hwsim_send_ps_poll()
897 pspoll->aid = cpu_to_le16(0xc000 | vp->aid); in hwsim_send_ps_poll()
898 memcpy(pspoll->bssid, vp->bssid, ETH_ALEN); in hwsim_send_ps_poll()
899 memcpy(pspoll->ta, mac, ETH_ALEN); in hwsim_send_ps_poll()
902 mac80211_hwsim_tx_frame(data->hw, skb, in hwsim_send_ps_poll()
903 rcu_dereference(vif->bss_conf.chanctx_conf)->def.chan); in hwsim_send_ps_poll()
910 struct hwsim_vif_priv *vp = (void *)vif->drv_priv; in hwsim_send_nullfunc()
915 if (!vp->assoc) in hwsim_send_nullfunc()
918 wiphy_dbg(data->hw->wiphy, in hwsim_send_nullfunc()
920 __func__, vp->bssid, ps); in hwsim_send_nullfunc()
925 hdr = skb_put(skb, sizeof(*hdr) - ETH_ALEN); in hwsim_send_nullfunc()
926 hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | in hwsim_send_nullfunc()
930 hdr->duration_id = cpu_to_le16(0); in hwsim_send_nullfunc()
931 memcpy(hdr->addr1, vp->bssid, ETH_ALEN); in hwsim_send_nullfunc()
932 memcpy(hdr->addr2, mac, ETH_ALEN); in hwsim_send_nullfunc()
933 memcpy(hdr->addr3, vp->bssid, ETH_ALEN); in hwsim_send_nullfunc()
936 cb->control.rates[0].count = 1; in hwsim_send_nullfunc()
937 cb->control.rates[1].idx = -1; in hwsim_send_nullfunc()
940 mac80211_hwsim_tx_frame(data->hw, skb, in hwsim_send_nullfunc()
941 rcu_dereference(vif->bss_conf.chanctx_conf)->def.chan); in hwsim_send_nullfunc()
963 *val = data->ps; in hwsim_fops_ps_read()
974 return -EINVAL; in hwsim_fops_ps_write()
977 if (data->ps != PS_ENABLED) in hwsim_fops_ps_write()
978 return -EINVAL; in hwsim_fops_ps_write()
981 data->hw, IEEE80211_IFACE_ITER_NORMAL, in hwsim_fops_ps_write()
986 old_ps = data->ps; in hwsim_fops_ps_write()
987 data->ps = val; in hwsim_fops_ps_write()
992 data->hw, IEEE80211_IFACE_ITER_NORMAL, in hwsim_fops_ps_write()
996 data->hw, IEEE80211_IFACE_ITER_NORMAL, in hwsim_fops_ps_write()
1011 ieee80211_radar_detected(data->hw); in hwsim_write_simulate_radar()
1022 *val = data->group; in hwsim_fops_group_read()
1029 data->group = val; in hwsim_fops_group_write()
1040 *val = data->rx_rssi; in hwsim_fops_rx_rssi_read()
1049 if (rssi >= 0 || rssi < -100) in hwsim_fops_rx_rssi_write()
1050 return -EINVAL; in hwsim_fops_rx_rssi_write()
1052 data->rx_rssi = rssi; in hwsim_fops_rx_rssi_write()
1076 return cpu_to_le64(now + data->tsf_offset); in __mac80211_hwsim_get_tsf()
1082 struct mac80211_hwsim_data *data = hw->priv; in mac80211_hwsim_get_tsf()
1089 struct mac80211_hwsim_data *data = hw->priv; in mac80211_hwsim_set_tsf()
1092 u32 bcn_int = data->link_data[0].beacon_int; in mac80211_hwsim_set_tsf()
1093 u64 delta = abs(tsf - now); in mac80211_hwsim_set_tsf()
1097 data->tsf_offset += delta; in mac80211_hwsim_set_tsf()
1098 data->bcn_delta = do_div(delta, bcn_int); in mac80211_hwsim_set_tsf()
1100 data->tsf_offset -= delta; in mac80211_hwsim_set_tsf()
1101 data->bcn_delta = -(s64)do_div(delta, bcn_int); in mac80211_hwsim_set_tsf()
1109 struct mac80211_hwsim_data *data = hw->priv; in mac80211_hwsim_monitor_rx()
1119 bitrate = txrate->bitrate; in mac80211_hwsim_monitor_rx()
1129 hdr->hdr.it_version = PKTHDR_RADIOTAP_VERSION; in mac80211_hwsim_monitor_rx()
1130 hdr->hdr.it_pad = 0; in mac80211_hwsim_monitor_rx()
1131 hdr->hdr.it_len = cpu_to_le16(sizeof(*hdr)); in mac80211_hwsim_monitor_rx()
1132 hdr->hdr.it_present = cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) | in mac80211_hwsim_monitor_rx()
1136 hdr->rt_tsft = __mac80211_hwsim_get_tsf(data); in mac80211_hwsim_monitor_rx()
1137 hdr->rt_flags = 0; in mac80211_hwsim_monitor_rx()
1138 hdr->rt_rate = bitrate / 5; in mac80211_hwsim_monitor_rx()
1139 hdr->rt_channel = cpu_to_le16(chan->center_freq); in mac80211_hwsim_monitor_rx()
1141 if (txrate && txrate->flags & IEEE80211_RATE_ERP_G) in mac80211_hwsim_monitor_rx()
1145 hdr->rt_chbitmask = cpu_to_le16(flags); in mac80211_hwsim_monitor_rx()
1147 skb->dev = hwsim_mon; in mac80211_hwsim_monitor_rx()
1149 skb->ip_summed = CHECKSUM_UNNECESSARY; in mac80211_hwsim_monitor_rx()
1150 skb->pkt_type = PACKET_OTHERHOST; in mac80211_hwsim_monitor_rx()
1151 skb->protocol = htons(ETH_P_802_2); in mac80211_hwsim_monitor_rx()
1152 memset(skb->cb, 0, sizeof(skb->cb)); in mac80211_hwsim_monitor_rx()
1173 hdr->hdr.it_version = PKTHDR_RADIOTAP_VERSION; in mac80211_hwsim_monitor_ack()
1174 hdr->hdr.it_pad = 0; in mac80211_hwsim_monitor_ack()
1175 hdr->hdr.it_len = cpu_to_le16(sizeof(*hdr)); in mac80211_hwsim_monitor_ack()
1176 hdr->hdr.it_present = cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) | in mac80211_hwsim_monitor_ack()
1178 hdr->rt_flags = 0; in mac80211_hwsim_monitor_ack()
1179 hdr->pad = 0; in mac80211_hwsim_monitor_ack()
1180 hdr->rt_channel = cpu_to_le16(chan->center_freq); in mac80211_hwsim_monitor_ack()
1182 hdr->rt_chbitmask = cpu_to_le16(flags); in mac80211_hwsim_monitor_ack()
1185 hdr11->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | in mac80211_hwsim_monitor_ack()
1187 hdr11->duration_id = cpu_to_le16(0); in mac80211_hwsim_monitor_ack()
1188 memcpy(hdr11->addr1, addr, ETH_ALEN); in mac80211_hwsim_monitor_ack()
1190 skb->dev = hwsim_mon; in mac80211_hwsim_monitor_ack()
1192 skb->ip_summed = CHECKSUM_UNNECESSARY; in mac80211_hwsim_monitor_ack()
1193 skb->pkt_type = PACKET_OTHERHOST; in mac80211_hwsim_monitor_ack()
1194 skb->protocol = htons(ETH_P_802_2); in mac80211_hwsim_monitor_ack()
1195 memset(skb->cb, 0, sizeof(skb->cb)); in mac80211_hwsim_monitor_ack()
1210 if (memcmp(mac, md->addr, ETH_ALEN) == 0) { in mac80211_hwsim_addr_iter()
1211 md->ret = true; in mac80211_hwsim_addr_iter()
1216 for (i = 0; i < ARRAY_SIZE(vif->link_conf); i++) { in mac80211_hwsim_addr_iter()
1219 conf = rcu_dereference(vif->link_conf[i]); in mac80211_hwsim_addr_iter()
1223 if (memcmp(conf->addr, md->addr, ETH_ALEN) == 0) { in mac80211_hwsim_addr_iter()
1224 md->ret = true; in mac80211_hwsim_addr_iter()
1237 if (data->scanning && memcmp(addr, data->scan_addr, ETH_ALEN) == 0) in mac80211_hwsim_addr_match()
1242 ieee80211_iterate_active_interfaces_atomic(data->hw, in mac80211_hwsim_addr_match()
1253 switch (data->ps) { in hwsim_ps_rx_ok()
1260 * if pending PS-Poll has been sent */ in hwsim_ps_rx_ok()
1264 * PS-Poll */ in hwsim_ps_rx_ok()
1265 if (data->ps_poll_pending && in hwsim_ps_rx_ok()
1266 mac80211_hwsim_addr_match(data, skb->data + 4)) { in hwsim_ps_rx_ok()
1267 data->ps_poll_pending = false; in hwsim_ps_rx_ok()
1281 int res = -ENOENT; in hwsim_unicast_netgroup()
1285 if (data->netgroup == hwsim_net_get_netgroup(net)) { in hwsim_unicast_netgroup()
1302 struct mac80211_hwsim_data *data = hw->priv; in mac80211_hwsim_config_mac_nl()
1303 u32 _portid = READ_ONCE(data->wmediumd); in mac80211_hwsim_config_mac_nl()
1325 ETH_ALEN, data->addresses[1].addr)) in mac80211_hwsim_config_mac_nl()
1346 if (rate->flags & IEEE80211_TX_RC_USE_RTS_CTS) in trans_tx_rate_flags_ieee2hwsim()
1348 if (rate->flags & IEEE80211_TX_RC_USE_CTS_PROTECT) in trans_tx_rate_flags_ieee2hwsim()
1350 if (rate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE) in trans_tx_rate_flags_ieee2hwsim()
1352 if (rate->flags & IEEE80211_TX_RC_MCS) in trans_tx_rate_flags_ieee2hwsim()
1354 if (rate->flags & IEEE80211_TX_RC_GREEN_FIELD) in trans_tx_rate_flags_ieee2hwsim()
1356 if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) in trans_tx_rate_flags_ieee2hwsim()
1358 if (rate->flags & IEEE80211_TX_RC_DUP_DATA) in trans_tx_rate_flags_ieee2hwsim()
1360 if (rate->flags & IEEE80211_TX_RC_SHORT_GI) in trans_tx_rate_flags_ieee2hwsim()
1362 if (rate->flags & IEEE80211_TX_RC_VHT_MCS) in trans_tx_rate_flags_ieee2hwsim()
1364 if (rate->flags & IEEE80211_TX_RC_80_MHZ_WIDTH) in trans_tx_rate_flags_ieee2hwsim()
1366 if (rate->flags & IEEE80211_TX_RC_160_MHZ_WIDTH) in trans_tx_rate_flags_ieee2hwsim()
1378 struct mac80211_hwsim_data *data = hw->priv; in mac80211_hwsim_tx_frame_nl()
1379 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) my_skb->data; in mac80211_hwsim_tx_frame_nl()
1388 if (data->ps != PS_DISABLED) in mac80211_hwsim_tx_frame_nl()
1389 hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); in mac80211_hwsim_tx_frame_nl()
1391 if (skb_queue_len(&data->pending) >= MAX_QUEUE) { in mac80211_hwsim_tx_frame_nl()
1393 while (skb_queue_len(&data->pending) >= WARN_QUEUE) { in mac80211_hwsim_tx_frame_nl()
1394 ieee80211_free_txskb(hw, skb_dequeue(&data->pending)); in mac80211_hwsim_tx_frame_nl()
1395 data->tx_dropped++; in mac80211_hwsim_tx_frame_nl()
1411 ETH_ALEN, data->addresses[1].addr)) in mac80211_hwsim_tx_frame_nl()
1414 /* We get the skb->data */ in mac80211_hwsim_tx_frame_nl()
1415 if (nla_put(skb, HWSIM_ATTR_FRAME, my_skb->len, my_skb->data)) in mac80211_hwsim_tx_frame_nl()
1421 if (info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS) in mac80211_hwsim_tx_frame_nl()
1424 if (info->flags & IEEE80211_TX_CTL_NO_ACK) in mac80211_hwsim_tx_frame_nl()
1430 if (nla_put_u32(skb, HWSIM_ATTR_FREQ, channel->center_freq)) in mac80211_hwsim_tx_frame_nl()
1436 tx_attempts[i].idx = info->status.rates[i].idx; in mac80211_hwsim_tx_frame_nl()
1437 tx_attempts_flags[i].idx = info->status.rates[i].idx; in mac80211_hwsim_tx_frame_nl()
1438 tx_attempts[i].count = info->status.rates[i].count; in mac80211_hwsim_tx_frame_nl()
1441 &info->status.rates[i]); in mac80211_hwsim_tx_frame_nl()
1455 cookie = atomic_inc_return(&data->pending_cookie); in mac80211_hwsim_tx_frame_nl()
1456 info->rate_driver_data[0] = (void *)cookie; in mac80211_hwsim_tx_frame_nl()
1471 skb_queue_tail(&data->pending, my_skb); in mac80211_hwsim_tx_frame_nl()
1472 data->tx_pkts++; in mac80211_hwsim_tx_frame_nl()
1473 data->tx_bytes += my_skb->len; in mac80211_hwsim_tx_frame_nl()
1481 data->tx_failed++; in mac80211_hwsim_tx_frame_nl()
1490 return c1->center_freq == c2->center_freq; in hwsim_chans_compat()
1504 for (i = 0; i < ARRAY_SIZE(vif->link_conf); i++) { in mac80211_hwsim_tx_iter()
1508 conf = rcu_dereference(vif->link_conf[i]); in mac80211_hwsim_tx_iter()
1512 chanctx = rcu_dereference(conf->chanctx_conf); in mac80211_hwsim_tx_iter()
1516 if (!hwsim_chans_compat(data->channel, chanctx->def.chan)) in mac80211_hwsim_tx_iter()
1519 data->receive = true; in mac80211_hwsim_tx_iter()
1544 rtap->oui[0] = HWSIM_RADIOTAP_OUI[0]; in mac80211_hwsim_add_vendor_rtap()
1545 rtap->oui[1] = HWSIM_RADIOTAP_OUI[1]; in mac80211_hwsim_add_vendor_rtap()
1546 rtap->oui[2] = HWSIM_RADIOTAP_OUI[2]; in mac80211_hwsim_add_vendor_rtap()
1547 rtap->subns = 127; in mac80211_hwsim_add_vendor_rtap()
1555 rtap->present = BIT(0); in mac80211_hwsim_add_vendor_rtap()
1557 rtap->len = 8; in mac80211_hwsim_add_vendor_rtap()
1559 rtap->align = 8; in mac80211_hwsim_add_vendor_rtap()
1561 rtap->pad = 4; in mac80211_hwsim_add_vendor_rtap()
1563 memcpy(rtap->data, "ABCDEFGH", 8); in mac80211_hwsim_add_vendor_rtap()
1565 memset(rtap->data + 8, 0, 4); in mac80211_hwsim_add_vendor_rtap()
1567 IEEE80211_SKB_RXCB(skb)->flag |= RX_FLAG_RADIOTAP_VENDOR_DATA; in mac80211_hwsim_add_vendor_rtap()
1575 struct ieee80211_hdr *hdr = (void *)skb->data; in mac80211_hwsim_rx()
1577 if (!ieee80211_has_morefrags(hdr->frame_control) && in mac80211_hwsim_rx()
1578 !is_multicast_ether_addr(hdr->addr1) && in mac80211_hwsim_rx()
1579 (ieee80211_is_mgmt(hdr->frame_control) || in mac80211_hwsim_rx()
1580 ieee80211_is_data(hdr->frame_control))) { in mac80211_hwsim_rx()
1585 sta = ieee80211_find_sta_by_link_addrs(data->hw, hdr->addr2, in mac80211_hwsim_rx()
1586 hdr->addr1, &link_id); in mac80211_hwsim_rx()
1588 struct hwsim_sta_priv *sp = (void *)sta->drv_priv; in mac80211_hwsim_rx()
1590 if (ieee80211_has_pm(hdr->frame_control)) in mac80211_hwsim_rx()
1591 sp->active_links_rx &= ~BIT(link_id); in mac80211_hwsim_rx()
1593 sp->active_links_rx |= BIT(link_id); in mac80211_hwsim_rx()
1602 data->rx_pkts++; in mac80211_hwsim_rx()
1603 data->rx_bytes += skb->len; in mac80211_hwsim_rx()
1604 ieee80211_rx_irqsafe(data->hw, skb); in mac80211_hwsim_rx()
1611 struct mac80211_hwsim_data *data = hw->priv, *data2; in mac80211_hwsim_tx_frame_no_nl()
1613 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; in mac80211_hwsim_tx_frame_no_nl()
1620 rx_status.freq = chan->center_freq; in mac80211_hwsim_tx_frame_no_nl()
1621 rx_status.freq_offset = chan->freq_offset ? 1 : 0; in mac80211_hwsim_tx_frame_no_nl()
1622 rx_status.band = chan->band; in mac80211_hwsim_tx_frame_no_nl()
1623 if (info->control.rates[0].flags & IEEE80211_TX_RC_VHT_MCS) { in mac80211_hwsim_tx_frame_no_nl()
1625 ieee80211_rate_get_vht_mcs(&info->control.rates[0]); in mac80211_hwsim_tx_frame_no_nl()
1627 ieee80211_rate_get_vht_nss(&info->control.rates[0]); in mac80211_hwsim_tx_frame_no_nl()
1630 rx_status.rate_idx = info->control.rates[0].idx; in mac80211_hwsim_tx_frame_no_nl()
1631 if (info->control.rates[0].flags & IEEE80211_TX_RC_MCS) in mac80211_hwsim_tx_frame_no_nl()
1634 if (info->control.rates[0].flags & IEEE80211_TX_RC_40_MHZ_WIDTH) in mac80211_hwsim_tx_frame_no_nl()
1636 else if (info->control.rates[0].flags & IEEE80211_TX_RC_80_MHZ_WIDTH) in mac80211_hwsim_tx_frame_no_nl()
1638 else if (info->control.rates[0].flags & IEEE80211_TX_RC_160_MHZ_WIDTH) in mac80211_hwsim_tx_frame_no_nl()
1642 if (info->control.rates[0].flags & IEEE80211_TX_RC_SHORT_GI) in mac80211_hwsim_tx_frame_no_nl()
1645 rx_status.signal = data->rx_rssi; in mac80211_hwsim_tx_frame_no_nl()
1646 if (info->control.vif) in mac80211_hwsim_tx_frame_no_nl()
1647 rx_status.signal += info->control.vif->bss_conf.txpower; in mac80211_hwsim_tx_frame_no_nl()
1649 if (data->ps != PS_DISABLED) in mac80211_hwsim_tx_frame_no_nl()
1650 hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); in mac80211_hwsim_tx_frame_no_nl()
1655 skb->mark = 0; in mac80211_hwsim_tx_frame_no_nl()
1662 * Giving beacons a different mactime than non-beacons looks messy, but in mac80211_hwsim_tx_frame_no_nl()
1666 if (ieee80211_is_beacon(hdr->frame_control) || in mac80211_hwsim_tx_frame_no_nl()
1667 ieee80211_is_probe_resp(hdr->frame_control)) { in mac80211_hwsim_tx_frame_no_nl()
1669 now = data->abs_bcn_ts; in mac80211_hwsim_tx_frame_no_nl()
1686 if (!data2->started || (data2->idle && !data2->tmp_chan) || in mac80211_hwsim_tx_frame_no_nl()
1690 if (!(data->group & data2->group)) in mac80211_hwsim_tx_frame_no_nl()
1693 if (data->netgroup != data2->netgroup) in mac80211_hwsim_tx_frame_no_nl()
1696 if (!hwsim_chans_compat(chan, data2->tmp_chan) && in mac80211_hwsim_tx_frame_no_nl()
1697 !hwsim_chans_compat(chan, data2->channel)) { in mac80211_hwsim_tx_frame_no_nl()
1699 data2->hw, IEEE80211_IFACE_ITER_NORMAL, in mac80211_hwsim_tx_frame_no_nl()
1709 if (skb->len < PAGE_SIZE && paged_rx) { in mac80211_hwsim_tx_frame_no_nl()
1721 memcpy(page_address(page), skb->data, skb->len); in mac80211_hwsim_tx_frame_no_nl()
1722 skb_add_rx_frag(nskb, 0, page, 0, skb->len, skb->len); in mac80211_hwsim_tx_frame_no_nl()
1729 if (mac80211_hwsim_addr_match(data2, hdr->addr1)) in mac80211_hwsim_tx_frame_no_nl()
1732 rx_status.mactime = now + data2->tsf_offset; in mac80211_hwsim_tx_frame_no_nl()
1748 struct hwsim_sta_priv *sp = (void *)sta->drv_priv; in mac80211_hwsim_select_tx_link()
1751 if (!vif->valid_links) in mac80211_hwsim_select_tx_link()
1752 return &vif->bss_conf; in mac80211_hwsim_select_tx_link()
1754 WARN_ON(is_multicast_ether_addr(hdr->addr1)); in mac80211_hwsim_select_tx_link()
1756 if (WARN_ON_ONCE(!sta->valid_links)) in mac80211_hwsim_select_tx_link()
1757 return &vif->bss_conf; in mac80211_hwsim_select_tx_link()
1759 for (i = 0; i < ARRAY_SIZE(vif->link_conf); i++) { in mac80211_hwsim_select_tx_link()
1763 /* round-robin the available link IDs */ in mac80211_hwsim_select_tx_link()
1764 link_id = (sp->last_link + i + 1) % ARRAY_SIZE(vif->link_conf); in mac80211_hwsim_select_tx_link()
1766 if (!(vif->active_links & BIT(link_id))) in mac80211_hwsim_select_tx_link()
1769 if (!(sp->active_links_rx & BIT(link_id))) in mac80211_hwsim_select_tx_link()
1772 *link_sta = rcu_dereference(sta->link[link_id]); in mac80211_hwsim_select_tx_link()
1776 bss_conf = rcu_dereference(vif->link_conf[link_id]); in mac80211_hwsim_select_tx_link()
1781 if (!rcu_access_pointer(bss_conf->chanctx_conf)) in mac80211_hwsim_select_tx_link()
1784 sp->last_link = link_id; in mac80211_hwsim_select_tx_link()
1795 struct mac80211_hwsim_data *data = hw->priv; in mac80211_hwsim_tx()
1797 struct ieee80211_hdr *hdr = (void *)skb->data; in mac80211_hwsim_tx()
1804 if (WARN_ON(skb->len < 10)) { in mac80211_hwsim_tx()
1810 if (!data->use_chanctx) { in mac80211_hwsim_tx()
1811 channel = data->channel; in mac80211_hwsim_tx()
1812 confbw = data->bw; in mac80211_hwsim_tx()
1813 } else if (txi->hw_queue == 4) { in mac80211_hwsim_tx()
1814 channel = data->tmp_chan; in mac80211_hwsim_tx()
1816 u8 link = u32_get_bits(IEEE80211_SKB_CB(skb)->control.flags, in mac80211_hwsim_tx()
1818 struct ieee80211_vif *vif = txi->control.vif; in mac80211_hwsim_tx()
1820 struct ieee80211_sta *sta = control->sta; in mac80211_hwsim_tx()
1824 bss_conf = rcu_dereference(txi->control.vif->link_conf[link]); in mac80211_hwsim_tx()
1826 link_sta = rcu_dereference(sta->link[link]); in mac80211_hwsim_tx()
1837 if (sta && sta->mlo) { in mac80211_hwsim_tx()
1843 ether_addr_copy(hdr->addr1, link_sta->addr); in mac80211_hwsim_tx()
1844 ether_addr_copy(hdr->addr2, bss_conf->addr); in mac80211_hwsim_tx()
1846 if (!ieee80211_has_tods(hdr->frame_control) && in mac80211_hwsim_tx()
1847 !ieee80211_has_fromds(hdr->frame_control)) { in mac80211_hwsim_tx()
1848 if (ether_addr_equal(hdr->addr3, sta->addr)) in mac80211_hwsim_tx()
1849 ether_addr_copy(hdr->addr3, link_sta->addr); in mac80211_hwsim_tx()
1850 else if (ether_addr_equal(hdr->addr3, vif->addr)) in mac80211_hwsim_tx()
1851 ether_addr_copy(hdr->addr3, bss_conf->addr); in mac80211_hwsim_tx()
1856 chanctx_conf = rcu_dereference(bss_conf->chanctx_conf); in mac80211_hwsim_tx()
1858 channel = chanctx_conf->def.chan; in mac80211_hwsim_tx()
1859 confbw = chanctx_conf->def.width; in mac80211_hwsim_tx()
1865 if (WARN(!channel, "TX w/o channel - queue = %d\n", txi->hw_queue)) { in mac80211_hwsim_tx()
1870 if (data->idle && !data->tmp_chan) { in mac80211_hwsim_tx()
1871 wiphy_dbg(hw->wiphy, "Trying to TX when idle - reject\n"); in mac80211_hwsim_tx()
1876 if (txi->control.vif) in mac80211_hwsim_tx()
1877 hwsim_check_magic(txi->control.vif); in mac80211_hwsim_tx()
1878 if (control->sta) in mac80211_hwsim_tx()
1879 hwsim_check_sta_magic(control->sta); in mac80211_hwsim_tx()
1882 ieee80211_get_tx_rates(txi->control.vif, control->sta, skb, in mac80211_hwsim_tx()
1883 txi->control.rates, in mac80211_hwsim_tx()
1884 ARRAY_SIZE(txi->control.rates)); in mac80211_hwsim_tx()
1886 for (i = 0; i < ARRAY_SIZE(txi->control.rates); i++) { in mac80211_hwsim_tx()
1887 u16 rflags = txi->control.rates[i].flags; in mac80211_hwsim_tx()
1888 /* initialize to data->bw for 5/10 MHz handling */ in mac80211_hwsim_tx()
1889 enum nl80211_chan_width bw = data->bw; in mac80211_hwsim_tx()
1891 if (txi->control.rates[i].idx == -1) in mac80211_hwsim_tx()
1905 if (skb->len >= 24 + 8 && in mac80211_hwsim_tx()
1906 ieee80211_is_probe_resp(hdr->frame_control)) { in mac80211_hwsim_tx()
1914 mgmt = (struct ieee80211_mgmt *)skb->data; in mac80211_hwsim_tx()
1917 bitrate = txrate->bitrate; in mac80211_hwsim_tx()
1919 mgmt->u.probe_resp.timestamp = in mac80211_hwsim_tx()
1920 cpu_to_le64(ts + data->tsf_offset + in mac80211_hwsim_tx()
1927 _portid = READ_ONCE(data->wmediumd); in mac80211_hwsim_tx()
1933 data->tx_pkts++; in mac80211_hwsim_tx()
1934 data->tx_bytes += skb->len; in mac80211_hwsim_tx()
1937 if (ack && skb->len >= 16) in mac80211_hwsim_tx()
1938 mac80211_hwsim_monitor_ack(channel, hdr->addr2); in mac80211_hwsim_tx()
1943 txi->control.rates[0].count = 1; in mac80211_hwsim_tx()
1944 txi->control.rates[1].idx = -1; in mac80211_hwsim_tx()
1946 if (!(txi->flags & IEEE80211_TX_CTL_NO_ACK) && ack) in mac80211_hwsim_tx()
1947 txi->flags |= IEEE80211_TX_STAT_ACK; in mac80211_hwsim_tx()
1954 struct mac80211_hwsim_data *data = hw->priv; in mac80211_hwsim_start()
1955 wiphy_dbg(hw->wiphy, "%s\n", __func__); in mac80211_hwsim_start()
1956 data->started = true; in mac80211_hwsim_start()
1963 struct mac80211_hwsim_data *data = hw->priv; in mac80211_hwsim_stop()
1966 data->started = false; in mac80211_hwsim_stop()
1968 for (i = 0; i < ARRAY_SIZE(data->link_data); i++) in mac80211_hwsim_stop()
1969 hrtimer_cancel(&data->link_data[i].beacon_timer); in mac80211_hwsim_stop()
1971 while (!skb_queue_empty(&data->pending)) in mac80211_hwsim_stop()
1972 ieee80211_free_txskb(hw, skb_dequeue(&data->pending)); in mac80211_hwsim_stop()
1974 wiphy_dbg(hw->wiphy, "%s\n", __func__); in mac80211_hwsim_stop()
1981 wiphy_dbg(hw->wiphy, "%s (type=%d mac_addr=%pM)\n", in mac80211_hwsim_add_interface()
1983 vif->addr); in mac80211_hwsim_add_interface()
1986 if (vif->type != NL80211_IFTYPE_MONITOR) in mac80211_hwsim_add_interface()
1987 mac80211_hwsim_config_mac_nl(hw, vif->addr, true); in mac80211_hwsim_add_interface()
1989 vif->cab_queue = 0; in mac80211_hwsim_add_interface()
1990 vif->hw_queue[IEEE80211_AC_VO] = 0; in mac80211_hwsim_add_interface()
1991 vif->hw_queue[IEEE80211_AC_VI] = 1; in mac80211_hwsim_add_interface()
1992 vif->hw_queue[IEEE80211_AC_BE] = 2; in mac80211_hwsim_add_interface()
1993 vif->hw_queue[IEEE80211_AC_BK] = 3; in mac80211_hwsim_add_interface()
2005 wiphy_dbg(hw->wiphy, in mac80211_hwsim_change_interface()
2008 newtype, vif->addr); in mac80211_hwsim_change_interface()
2012 * interface may change from non-AP to AP in in mac80211_hwsim_change_interface()
2015 vif->cab_queue = 0; in mac80211_hwsim_change_interface()
2023 wiphy_dbg(hw->wiphy, "%s (type=%d mac_addr=%pM)\n", in mac80211_hwsim_remove_interface()
2025 vif->addr); in mac80211_hwsim_remove_interface()
2028 if (vif->type != NL80211_IFTYPE_MONITOR) in mac80211_hwsim_remove_interface()
2029 mac80211_hwsim_config_mac_nl(hw, vif->addr, false); in mac80211_hwsim_remove_interface()
2036 struct mac80211_hwsim_data *data = hw->priv; in mac80211_hwsim_tx_frame()
2037 u32 _pid = READ_ONCE(data->wmediumd); in mac80211_hwsim_tx_frame()
2041 ieee80211_get_tx_rates(txi->control.vif, NULL, skb, in mac80211_hwsim_tx_frame()
2042 txi->control.rates, in mac80211_hwsim_tx_frame()
2043 ARRAY_SIZE(txi->control.rates)); in mac80211_hwsim_tx_frame()
2051 data->tx_pkts++; in mac80211_hwsim_tx_frame()
2052 data->tx_bytes += skb->len; in mac80211_hwsim_tx_frame()
2061 u32 link_id = link_data->link_id; in mac80211_hwsim_beacon_tx()
2066 struct ieee80211_hw *hw = data->hw; in mac80211_hwsim_beacon_tx()
2076 link_conf = rcu_dereference(vif->link_conf[link_id]); in mac80211_hwsim_beacon_tx()
2080 if (vif->type != NL80211_IFTYPE_AP && in mac80211_hwsim_beacon_tx()
2081 vif->type != NL80211_IFTYPE_MESH_POINT && in mac80211_hwsim_beacon_tx()
2082 vif->type != NL80211_IFTYPE_ADHOC && in mac80211_hwsim_beacon_tx()
2083 vif->type != NL80211_IFTYPE_OCB) in mac80211_hwsim_beacon_tx()
2086 skb = ieee80211_beacon_get(hw, vif, link_data->link_id); in mac80211_hwsim_beacon_tx()
2092 info->control.rates, in mac80211_hwsim_beacon_tx()
2093 ARRAY_SIZE(info->control.rates)); in mac80211_hwsim_beacon_tx()
2097 bitrate = txrate->bitrate; in mac80211_hwsim_beacon_tx()
2099 mgmt = (struct ieee80211_mgmt *) skb->data; in mac80211_hwsim_beacon_tx()
2101 data->abs_bcn_ts = mac80211_hwsim_get_tsf_raw(); in mac80211_hwsim_beacon_tx()
2102 if (ieee80211_is_s1g_beacon(mgmt->frame_control)) { in mac80211_hwsim_beacon_tx()
2105 ext->u.s1g_beacon.timestamp = cpu_to_le32(data->abs_bcn_ts + in mac80211_hwsim_beacon_tx()
2106 data->tsf_offset + in mac80211_hwsim_beacon_tx()
2110 mgmt->u.beacon.timestamp = cpu_to_le64(data->abs_bcn_ts + in mac80211_hwsim_beacon_tx()
2111 data->tsf_offset + in mac80211_hwsim_beacon_tx()
2117 rcu_dereference(link_conf->chanctx_conf)->def.chan); in mac80211_hwsim_beacon_tx()
2121 rcu_dereference(link_conf->chanctx_conf)->def.chan); in mac80211_hwsim_beacon_tx()
2124 if (link_conf->csa_active && ieee80211_beacon_cntdwn_is_complete(vif)) in mac80211_hwsim_beacon_tx()
2135 link_data[link_data->link_id]); in mac80211_hwsim_beacon()
2136 struct ieee80211_hw *hw = data->hw; in mac80211_hwsim_beacon()
2137 u64 bcn_int = link_data->beacon_int; in mac80211_hwsim_beacon()
2139 if (!data->started) in mac80211_hwsim_beacon()
2147 if (data->bcn_delta) { in mac80211_hwsim_beacon()
2148 bcn_int -= data->bcn_delta; in mac80211_hwsim_beacon()
2149 data->bcn_delta = 0; in mac80211_hwsim_beacon()
2151 hrtimer_forward_now(&link_data->beacon_timer, in mac80211_hwsim_beacon()
2174 struct mac80211_hwsim_data *data = hw->priv; in mac80211_hwsim_config()
2175 struct ieee80211_conf *conf = &hw->conf; in mac80211_hwsim_config()
2184 if (conf->chandef.chan) in mac80211_hwsim_config()
2185 wiphy_dbg(hw->wiphy, in mac80211_hwsim_config()
2186 "%s (freq=%d(%d - %d)/%s idle=%d ps=%d smps=%s)\n", in mac80211_hwsim_config()
2188 conf->chandef.chan->center_freq, in mac80211_hwsim_config()
2189 conf->chandef.center_freq1, in mac80211_hwsim_config()
2190 conf->chandef.center_freq2, in mac80211_hwsim_config()
2191 hwsim_chanwidths[conf->chandef.width], in mac80211_hwsim_config()
2192 !!(conf->flags & IEEE80211_CONF_IDLE), in mac80211_hwsim_config()
2193 !!(conf->flags & IEEE80211_CONF_PS), in mac80211_hwsim_config()
2194 smps_modes[conf->smps_mode]); in mac80211_hwsim_config()
2196 wiphy_dbg(hw->wiphy, in mac80211_hwsim_config()
2199 !!(conf->flags & IEEE80211_CONF_IDLE), in mac80211_hwsim_config()
2200 !!(conf->flags & IEEE80211_CONF_PS), in mac80211_hwsim_config()
2201 smps_modes[conf->smps_mode]); in mac80211_hwsim_config()
2203 data->idle = !!(conf->flags & IEEE80211_CONF_IDLE); in mac80211_hwsim_config()
2205 WARN_ON(conf->chandef.chan && data->use_chanctx); in mac80211_hwsim_config()
2207 mutex_lock(&data->mutex); in mac80211_hwsim_config()
2208 if (data->scanning && conf->chandef.chan) { in mac80211_hwsim_config()
2209 for (idx = 0; idx < ARRAY_SIZE(data->survey_data); idx++) { in mac80211_hwsim_config()
2210 if (data->survey_data[idx].channel == data->channel) { in mac80211_hwsim_config()
2211 data->survey_data[idx].start = in mac80211_hwsim_config()
2212 data->survey_data[idx].next_start; in mac80211_hwsim_config()
2213 data->survey_data[idx].end = jiffies; in mac80211_hwsim_config()
2218 data->channel = conf->chandef.chan; in mac80211_hwsim_config()
2219 data->bw = conf->chandef.width; in mac80211_hwsim_config()
2221 for (idx = 0; idx < ARRAY_SIZE(data->survey_data); idx++) { in mac80211_hwsim_config()
2222 if (data->survey_data[idx].channel && in mac80211_hwsim_config()
2223 data->survey_data[idx].channel != data->channel) in mac80211_hwsim_config()
2225 data->survey_data[idx].channel = data->channel; in mac80211_hwsim_config()
2226 data->survey_data[idx].next_start = jiffies; in mac80211_hwsim_config()
2230 data->channel = conf->chandef.chan; in mac80211_hwsim_config()
2231 data->bw = conf->chandef.width; in mac80211_hwsim_config()
2233 mutex_unlock(&data->mutex); in mac80211_hwsim_config()
2235 for (idx = 0; idx < ARRAY_SIZE(data->link_data); idx++) { in mac80211_hwsim_config()
2237 &data->link_data[idx]; in mac80211_hwsim_config()
2239 if (!data->started || !link_data->beacon_int) { in mac80211_hwsim_config()
2240 hrtimer_cancel(&link_data->beacon_timer); in mac80211_hwsim_config()
2241 } else if (!hrtimer_is_queued(&link_data->beacon_timer)) { in mac80211_hwsim_config()
2243 u32 bcn_int = link_data->beacon_int; in mac80211_hwsim_config()
2244 u64 until_tbtt = bcn_int - do_div(tsf, bcn_int); in mac80211_hwsim_config()
2246 hrtimer_start(&link_data->beacon_timer, in mac80211_hwsim_config()
2260 struct mac80211_hwsim_data *data = hw->priv; in mac80211_hwsim_configure_filter()
2262 wiphy_dbg(hw->wiphy, "%s\n", __func__); in mac80211_hwsim_configure_filter()
2264 data->rx_filter = 0; in mac80211_hwsim_configure_filter()
2266 data->rx_filter |= FIF_ALLMULTI; in mac80211_hwsim_configure_filter()
2268 data->rx_filter |= FIF_MCAST_ACTION; in mac80211_hwsim_configure_filter()
2270 *total_flags = data->rx_filter; in mac80211_hwsim_configure_filter()
2277 struct hwsim_vif_priv *vp = (void *)vif->drv_priv; in mac80211_hwsim_bcn_en_iter()
2279 if (vp->bcn_en) in mac80211_hwsim_bcn_en_iter()
2287 struct hwsim_vif_priv *vp = (void *)vif->drv_priv; in mac80211_hwsim_vif_info_changed()
2291 wiphy_dbg(hw->wiphy, "%s(changed=0x%llx vif->addr=%pM)\n", in mac80211_hwsim_vif_info_changed()
2292 __func__, changed, vif->addr); in mac80211_hwsim_vif_info_changed()
2295 wiphy_dbg(hw->wiphy, " ASSOC: assoc=%d aid=%d\n", in mac80211_hwsim_vif_info_changed()
2296 vif->cfg.assoc, vif->cfg.aid); in mac80211_hwsim_vif_info_changed()
2297 vp->assoc = vif->cfg.assoc; in mac80211_hwsim_vif_info_changed()
2298 vp->aid = vif->cfg.aid; in mac80211_hwsim_vif_info_changed()
2307 struct hwsim_vif_priv *vp = (void *)vif->drv_priv; in mac80211_hwsim_link_info_changed()
2308 struct mac80211_hwsim_data *data = hw->priv; in mac80211_hwsim_link_info_changed()
2309 unsigned int link_id = info->link_id; in mac80211_hwsim_link_info_changed()
2310 struct mac80211_hwsim_link_data *link_data = &data->link_data[link_id]; in mac80211_hwsim_link_info_changed()
2314 wiphy_dbg(hw->wiphy, "%s(changed=0x%llx vif->addr=%pM, link id %u)\n", in mac80211_hwsim_link_info_changed()
2315 __func__, (unsigned long long)changed, vif->addr, link_id); in mac80211_hwsim_link_info_changed()
2318 wiphy_dbg(hw->wiphy, "%s: BSSID changed: %pM\n", in mac80211_hwsim_link_info_changed()
2319 __func__, info->bssid); in mac80211_hwsim_link_info_changed()
2320 memcpy(vp->bssid, info->bssid, ETH_ALEN); in mac80211_hwsim_link_info_changed()
2324 wiphy_dbg(hw->wiphy, " BCN EN: %d (BI=%u)\n", in mac80211_hwsim_link_info_changed()
2325 info->enable_beacon, info->beacon_int); in mac80211_hwsim_link_info_changed()
2326 vp->bcn_en = info->enable_beacon; in mac80211_hwsim_link_info_changed()
2327 if (data->started && in mac80211_hwsim_link_info_changed()
2328 !hrtimer_is_queued(&link_data->beacon_timer) && in mac80211_hwsim_link_info_changed()
2329 info->enable_beacon) { in mac80211_hwsim_link_info_changed()
2332 link_data->beacon_int = info->beacon_int * 1024; in mac80211_hwsim_link_info_changed()
2334 bcn_int = link_data->beacon_int; in mac80211_hwsim_link_info_changed()
2335 until_tbtt = bcn_int - do_div(tsf, bcn_int); in mac80211_hwsim_link_info_changed()
2337 hrtimer_start(&link_data->beacon_timer, in mac80211_hwsim_link_info_changed()
2340 } else if (!info->enable_beacon) { in mac80211_hwsim_link_info_changed()
2343 data->hw, IEEE80211_IFACE_ITER_NORMAL, in mac80211_hwsim_link_info_changed()
2345 wiphy_dbg(hw->wiphy, " beaconing vifs remaining: %u", in mac80211_hwsim_link_info_changed()
2348 hrtimer_cancel(&link_data->beacon_timer); in mac80211_hwsim_link_info_changed()
2349 link_data->beacon_int = 0; in mac80211_hwsim_link_info_changed()
2355 wiphy_dbg(hw->wiphy, " ERP_CTS_PROT: %d\n", in mac80211_hwsim_link_info_changed()
2356 info->use_cts_prot); in mac80211_hwsim_link_info_changed()
2360 wiphy_dbg(hw->wiphy, " ERP_PREAMBLE: %d\n", in mac80211_hwsim_link_info_changed()
2361 info->use_short_preamble); in mac80211_hwsim_link_info_changed()
2365 wiphy_dbg(hw->wiphy, " ERP_SLOT: %d\n", info->use_short_slot); in mac80211_hwsim_link_info_changed()
2369 wiphy_dbg(hw->wiphy, " HT: op_mode=0x%x\n", in mac80211_hwsim_link_info_changed()
2370 info->ht_operation_mode); in mac80211_hwsim_link_info_changed()
2374 wiphy_dbg(hw->wiphy, " BASIC_RATES: 0x%llx\n", in mac80211_hwsim_link_info_changed()
2375 (unsigned long long) info->basic_rates); in mac80211_hwsim_link_info_changed()
2379 wiphy_dbg(hw->wiphy, " TX Power: %d dBm\n", info->txpower); in mac80211_hwsim_link_info_changed()
2388 struct mac80211_hwsim_data *data = hw->priv; in mac80211_hwsim_sta_rc_update()
2394 link_id < ARRAY_SIZE(vif->link_conf); in mac80211_hwsim_sta_rc_update()
2400 link_sta = rcu_dereference(sta->link[link_id]); in mac80211_hwsim_sta_rc_update()
2405 switch (link_sta->bandwidth) { in mac80211_hwsim_sta_rc_update()
2415 if (!data->use_chanctx) { in mac80211_hwsim_sta_rc_update()
2416 confbw = data->bw; in mac80211_hwsim_sta_rc_update()
2420 vif_conf = rcu_dereference(vif->link_conf[link_id]); in mac80211_hwsim_sta_rc_update()
2424 chanctx_conf = rcu_dereference(vif_conf->chanctx_conf); in mac80211_hwsim_sta_rc_update()
2427 confbw = chanctx_conf->def.width; in mac80211_hwsim_sta_rc_update()
2432 vif->addr, link_id, sta->addr, bw, sta->deflink.bandwidth, in mac80211_hwsim_sta_rc_update()
2433 hwsim_get_chanwidth(data->bw), data->bw); in mac80211_hwsim_sta_rc_update()
2446 struct hwsim_sta_priv *sp = (void *)sta->drv_priv; in mac80211_hwsim_sta_add()
2452 if (sta->valid_links) { in mac80211_hwsim_sta_add()
2453 WARN(hweight16(sta->valid_links) > 1, in mac80211_hwsim_sta_add()
2455 sta->valid_links); in mac80211_hwsim_sta_add()
2456 sp->active_links_rx = sta->valid_links; in mac80211_hwsim_sta_add()
2488 if (vif->type == NL80211_IFTYPE_STATION && in mac80211_hwsim_sta_state()
2489 new_state == IEEE80211_STA_AUTHORIZED && !sta->tdls) in mac80211_hwsim_sta_state()
2490 ieee80211_set_active_links_async(vif, vif->valid_links); in mac80211_hwsim_sta_state()
2526 wiphy_dbg(hw->wiphy, in mac80211_hwsim_conf_tx()
2529 params->txop, params->cw_min, in mac80211_hwsim_conf_tx()
2530 params->cw_max, params->aifs); in mac80211_hwsim_conf_tx()
2537 struct mac80211_hwsim_data *hwsim = hw->priv; in mac80211_hwsim_get_survey()
2539 if (idx < 0 || idx >= ARRAY_SIZE(hwsim->survey_data)) in mac80211_hwsim_get_survey()
2540 return -ENOENT; in mac80211_hwsim_get_survey()
2542 mutex_lock(&hwsim->mutex); in mac80211_hwsim_get_survey()
2543 survey->channel = hwsim->survey_data[idx].channel; in mac80211_hwsim_get_survey()
2544 if (!survey->channel) { in mac80211_hwsim_get_survey()
2545 mutex_unlock(&hwsim->mutex); in mac80211_hwsim_get_survey()
2546 return -ENOENT; in mac80211_hwsim_get_survey()
2550 * Magically conjured dummy values --- this is only ok for simulated hardware. in mac80211_hwsim_get_survey()
2553 * report any, especially not a magically conjured ones :-) in mac80211_hwsim_get_survey()
2555 survey->filled = SURVEY_INFO_NOISE_DBM | in mac80211_hwsim_get_survey()
2558 survey->noise = -92; in mac80211_hwsim_get_survey()
2559 survey->time = in mac80211_hwsim_get_survey()
2560 jiffies_to_msecs(hwsim->survey_data[idx].end - in mac80211_hwsim_get_survey()
2561 hwsim->survey_data[idx].start); in mac80211_hwsim_get_survey()
2563 survey->time_busy = survey->time/8; in mac80211_hwsim_get_survey()
2564 mutex_unlock(&hwsim->mutex); in mac80211_hwsim_get_survey()
2583 HWSIM_TM_ATTR_MAX = __HWSIM_TM_ATTR_AFTER_LAST - 1
2602 struct mac80211_hwsim_data *hwsim = hw->priv; in mac80211_hwsim_testmode_cmd()
2613 return -EINVAL; in mac80211_hwsim_testmode_cmd()
2618 return -EINVAL; in mac80211_hwsim_testmode_cmd()
2622 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, in mac80211_hwsim_testmode_cmd()
2625 return -ENOMEM; in mac80211_hwsim_testmode_cmd()
2626 if (nla_put_u32(skb, HWSIM_TM_ATTR_PS, hwsim->ps)) in mac80211_hwsim_testmode_cmd()
2636 return -EOPNOTSUPP; in mac80211_hwsim_testmode_cmd()
2641 return -ENOBUFS; in mac80211_hwsim_testmode_cmd()
2649 struct ieee80211_sta *sta = params->sta; in mac80211_hwsim_ampdu_action()
2650 enum ieee80211_ampdu_mlme_action action = params->action; in mac80211_hwsim_ampdu_action()
2651 u16 tid = params->tid; in mac80211_hwsim_ampdu_action()
2659 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); in mac80211_hwsim_ampdu_action()
2667 return -EOPNOTSUPP; in mac80211_hwsim_ampdu_action()
2684 struct cfg80211_scan_request *req = hwsim->hw_scan_request; in hw_scan_work() local
2687 mutex_lock(&hwsim->mutex); in hw_scan_work()
2688 if (hwsim->scan_chan_idx >= req->n_channels) { in hw_scan_work()
2693 wiphy_dbg(hwsim->hw->wiphy, "hw scan complete\n"); in hw_scan_work()
2694 ieee80211_scan_completed(hwsim->hw, &info); in hw_scan_work()
2695 hwsim->hw_scan_request = NULL; in hw_scan_work()
2696 hwsim->hw_scan_vif = NULL; in hw_scan_work()
2697 hwsim->tmp_chan = NULL; in hw_scan_work()
2698 mutex_unlock(&hwsim->mutex); in hw_scan_work()
2699 mac80211_hwsim_config_mac_nl(hwsim->hw, hwsim->scan_addr, in hw_scan_work()
2704 wiphy_dbg(hwsim->hw->wiphy, "hw scan %d MHz\n", in hw_scan_work()
2705 req->channels[hwsim->scan_chan_idx]->center_freq); in hw_scan_work()
2707 hwsim->tmp_chan = req->channels[hwsim->scan_chan_idx]; in hw_scan_work()
2708 if (hwsim->tmp_chan->flags & (IEEE80211_CHAN_NO_IR | in hw_scan_work()
2710 !req->n_ssids) { in hw_scan_work()
2715 for (i = 0; i < req->n_ssids; i++) { in hw_scan_work()
2719 probe = ieee80211_probereq_get(hwsim->hw, in hw_scan_work()
2720 hwsim->scan_addr, in hw_scan_work()
2721 req->ssids[i].ssid, in hw_scan_work()
2722 req->ssids[i].ssid_len, in hw_scan_work()
2723 req->ie_len); in hw_scan_work()
2727 mgmt = (struct ieee80211_mgmt *) probe->data; in hw_scan_work()
2728 memcpy(mgmt->da, req->bssid, ETH_ALEN); in hw_scan_work()
2729 memcpy(mgmt->bssid, req->bssid, ETH_ALEN); in hw_scan_work()
2731 if (req->ie_len) in hw_scan_work()
2732 skb_put_data(probe, req->ie, req->ie_len); in hw_scan_work()
2735 if (!ieee80211_tx_prepare_skb(hwsim->hw, in hw_scan_work()
2736 hwsim->hw_scan_vif, in hw_scan_work()
2738 hwsim->tmp_chan->band, in hw_scan_work()
2746 mac80211_hwsim_tx_frame(hwsim->hw, probe, in hw_scan_work()
2747 hwsim->tmp_chan); in hw_scan_work()
2752 ieee80211_queue_delayed_work(hwsim->hw, &hwsim->hw_scan, in hw_scan_work()
2754 hwsim->survey_data[hwsim->scan_chan_idx].channel = hwsim->tmp_chan; in hw_scan_work()
2755 hwsim->survey_data[hwsim->scan_chan_idx].start = jiffies; in hw_scan_work()
2756 hwsim->survey_data[hwsim->scan_chan_idx].end = in hw_scan_work()
2758 hwsim->scan_chan_idx++; in hw_scan_work()
2759 mutex_unlock(&hwsim->mutex); in hw_scan_work()
2766 struct mac80211_hwsim_data *hwsim = hw->priv; in mac80211_hwsim_hw_scan()
2767 struct cfg80211_scan_request *req = &hw_req->req; in mac80211_hwsim_hw_scan() local
2769 mutex_lock(&hwsim->mutex); in mac80211_hwsim_hw_scan()
2770 if (WARN_ON(hwsim->tmp_chan || hwsim->hw_scan_request)) { in mac80211_hwsim_hw_scan()
2771 mutex_unlock(&hwsim->mutex); in mac80211_hwsim_hw_scan()
2772 return -EBUSY; in mac80211_hwsim_hw_scan()
2774 hwsim->hw_scan_request = req; in mac80211_hwsim_hw_scan()
2775 hwsim->hw_scan_vif = vif; in mac80211_hwsim_hw_scan()
2776 hwsim->scan_chan_idx = 0; in mac80211_hwsim_hw_scan()
2777 if (req->flags & NL80211_SCAN_FLAG_RANDOM_ADDR) in mac80211_hwsim_hw_scan()
2778 get_random_mask_addr(hwsim->scan_addr, in mac80211_hwsim_hw_scan()
2779 hw_req->req.mac_addr, in mac80211_hwsim_hw_scan()
2780 hw_req->req.mac_addr_mask); in mac80211_hwsim_hw_scan()
2782 memcpy(hwsim->scan_addr, vif->addr, ETH_ALEN); in mac80211_hwsim_hw_scan()
2783 memset(hwsim->survey_data, 0, sizeof(hwsim->survey_data)); in mac80211_hwsim_hw_scan()
2784 mutex_unlock(&hwsim->mutex); in mac80211_hwsim_hw_scan()
2786 mac80211_hwsim_config_mac_nl(hw, hwsim->scan_addr, true); in mac80211_hwsim_hw_scan()
2787 wiphy_dbg(hw->wiphy, "hwsim hw_scan request\n"); in mac80211_hwsim_hw_scan()
2789 ieee80211_queue_delayed_work(hwsim->hw, &hwsim->hw_scan, 0); in mac80211_hwsim_hw_scan()
2797 struct mac80211_hwsim_data *hwsim = hw->priv; in mac80211_hwsim_cancel_hw_scan()
2802 wiphy_dbg(hw->wiphy, "hwsim cancel_hw_scan\n"); in mac80211_hwsim_cancel_hw_scan()
2804 cancel_delayed_work_sync(&hwsim->hw_scan); in mac80211_hwsim_cancel_hw_scan()
2806 mutex_lock(&hwsim->mutex); in mac80211_hwsim_cancel_hw_scan()
2807 ieee80211_scan_completed(hwsim->hw, &info); in mac80211_hwsim_cancel_hw_scan()
2808 hwsim->tmp_chan = NULL; in mac80211_hwsim_cancel_hw_scan()
2809 hwsim->hw_scan_request = NULL; in mac80211_hwsim_cancel_hw_scan()
2810 hwsim->hw_scan_vif = NULL; in mac80211_hwsim_cancel_hw_scan()
2811 mutex_unlock(&hwsim->mutex); in mac80211_hwsim_cancel_hw_scan()
2818 struct mac80211_hwsim_data *hwsim = hw->priv; in mac80211_hwsim_sw_scan()
2820 mutex_lock(&hwsim->mutex); in mac80211_hwsim_sw_scan()
2822 if (hwsim->scanning) { in mac80211_hwsim_sw_scan()
2829 memcpy(hwsim->scan_addr, mac_addr, ETH_ALEN); in mac80211_hwsim_sw_scan()
2830 mac80211_hwsim_config_mac_nl(hw, hwsim->scan_addr, true); in mac80211_hwsim_sw_scan()
2831 hwsim->scanning = true; in mac80211_hwsim_sw_scan()
2832 memset(hwsim->survey_data, 0, sizeof(hwsim->survey_data)); in mac80211_hwsim_sw_scan()
2835 mutex_unlock(&hwsim->mutex); in mac80211_hwsim_sw_scan()
2841 struct mac80211_hwsim_data *hwsim = hw->priv; in mac80211_hwsim_sw_scan_complete()
2843 mutex_lock(&hwsim->mutex); in mac80211_hwsim_sw_scan_complete()
2846 hwsim->scanning = false; in mac80211_hwsim_sw_scan_complete()
2847 mac80211_hwsim_config_mac_nl(hw, hwsim->scan_addr, false); in mac80211_hwsim_sw_scan_complete()
2848 eth_zero_addr(hwsim->scan_addr); in mac80211_hwsim_sw_scan_complete()
2850 mutex_unlock(&hwsim->mutex); in mac80211_hwsim_sw_scan_complete()
2858 mutex_lock(&hwsim->mutex); in hw_roc_start()
2860 wiphy_dbg(hwsim->hw->wiphy, "hwsim ROC begins\n"); in hw_roc_start()
2861 hwsim->tmp_chan = hwsim->roc_chan; in hw_roc_start()
2862 ieee80211_ready_on_channel(hwsim->hw); in hw_roc_start()
2864 ieee80211_queue_delayed_work(hwsim->hw, &hwsim->roc_done, in hw_roc_start()
2865 msecs_to_jiffies(hwsim->roc_duration)); in hw_roc_start()
2867 mutex_unlock(&hwsim->mutex); in hw_roc_start()
2875 mutex_lock(&hwsim->mutex); in hw_roc_done()
2876 ieee80211_remain_on_channel_expired(hwsim->hw); in hw_roc_done()
2877 hwsim->tmp_chan = NULL; in hw_roc_done()
2878 mutex_unlock(&hwsim->mutex); in hw_roc_done()
2880 wiphy_dbg(hwsim->hw->wiphy, "hwsim ROC expired\n"); in hw_roc_done()
2889 struct mac80211_hwsim_data *hwsim = hw->priv; in mac80211_hwsim_roc()
2891 mutex_lock(&hwsim->mutex); in mac80211_hwsim_roc()
2892 if (WARN_ON(hwsim->tmp_chan || hwsim->hw_scan_request)) { in mac80211_hwsim_roc()
2893 mutex_unlock(&hwsim->mutex); in mac80211_hwsim_roc()
2894 return -EBUSY; in mac80211_hwsim_roc()
2897 hwsim->roc_chan = chan; in mac80211_hwsim_roc()
2898 hwsim->roc_duration = duration; in mac80211_hwsim_roc()
2899 mutex_unlock(&hwsim->mutex); in mac80211_hwsim_roc()
2901 wiphy_dbg(hw->wiphy, "hwsim ROC (%d MHz, %d ms)\n", in mac80211_hwsim_roc()
2902 chan->center_freq, duration); in mac80211_hwsim_roc()
2903 ieee80211_queue_delayed_work(hw, &hwsim->roc_start, HZ/50); in mac80211_hwsim_roc()
2911 struct mac80211_hwsim_data *hwsim = hw->priv; in mac80211_hwsim_croc()
2913 cancel_delayed_work_sync(&hwsim->roc_start); in mac80211_hwsim_croc()
2914 cancel_delayed_work_sync(&hwsim->roc_done); in mac80211_hwsim_croc()
2916 mutex_lock(&hwsim->mutex); in mac80211_hwsim_croc()
2917 hwsim->tmp_chan = NULL; in mac80211_hwsim_croc()
2918 mutex_unlock(&hwsim->mutex); in mac80211_hwsim_croc()
2920 wiphy_dbg(hw->wiphy, "hwsim ROC canceled\n"); in mac80211_hwsim_croc()
2929 wiphy_dbg(hw->wiphy, in mac80211_hwsim_add_chanctx()
2931 ctx->def.chan->center_freq, ctx->def.width, in mac80211_hwsim_add_chanctx()
2932 ctx->def.center_freq1, ctx->def.center_freq2); in mac80211_hwsim_add_chanctx()
2939 wiphy_dbg(hw->wiphy, in mac80211_hwsim_remove_chanctx()
2941 ctx->def.chan->center_freq, ctx->def.width, in mac80211_hwsim_remove_chanctx()
2942 ctx->def.center_freq1, ctx->def.center_freq2); in mac80211_hwsim_remove_chanctx()
2952 wiphy_dbg(hw->wiphy, in mac80211_hwsim_change_chanctx()
2954 ctx->def.chan->center_freq, ctx->def.width, in mac80211_hwsim_change_chanctx()
2955 ctx->def.center_freq1, ctx->def.center_freq2); in mac80211_hwsim_change_chanctx()
2967 if (vif->type == NL80211_IFTYPE_STATION && vif->cfg.assoc) { in mac80211_hwsim_assign_vif_chanctx()
2970 skb = ieee80211_nullfunc_get(hw, vif, link_conf->link_id, true); in mac80211_hwsim_assign_vif_chanctx()
2973 mac80211_hwsim_tx_frame(hw, skb, ctx->def.chan); in mac80211_hwsim_assign_vif_chanctx()
2990 if (vif->type == NL80211_IFTYPE_STATION && vif->cfg.assoc) { in mac80211_hwsim_unassign_vif_chanctx()
2993 skb = ieee80211_nullfunc_get(hw, vif, link_conf->link_id, true); in mac80211_hwsim_unassign_vif_chanctx()
2995 struct ieee80211_hdr *hdr = (void *)skb->data; in mac80211_hwsim_unassign_vif_chanctx()
2997 hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); in mac80211_hwsim_unassign_vif_chanctx()
3000 mac80211_hwsim_tx_frame(hw, skb, ctx->def.chan); in mac80211_hwsim_unassign_vif_chanctx()
3040 struct mac80211_hwsim_data *ar = hw->priv; in mac80211_hwsim_get_et_stats()
3043 data[i++] = ar->tx_pkts; in mac80211_hwsim_get_et_stats()
3044 data[i++] = ar->tx_bytes; in mac80211_hwsim_get_et_stats()
3045 data[i++] = ar->rx_pkts; in mac80211_hwsim_get_et_stats()
3046 data[i++] = ar->rx_bytes; in mac80211_hwsim_get_et_stats()
3047 data[i++] = ar->tx_dropped; in mac80211_hwsim_get_et_stats()
3048 data[i++] = ar->tx_failed; in mac80211_hwsim_get_et_stats()
3049 data[i++] = ar->ps; in mac80211_hwsim_get_et_stats()
3050 data[i++] = ar->group; in mac80211_hwsim_get_et_stats()
3062 return -EOPNOTSUPP; in mac80211_hwsim_set_rts_threshold()
3080 mac80211_hwsim_config_mac_nl(hw, old[i]->addr, false); in mac80211_hwsim_change_vif_links()
3089 mac80211_hwsim_config_mac_nl(hw, link_conf->addr, true); in mac80211_hwsim_change_vif_links()
3100 struct hwsim_sta_priv *sp = (void *)sta->drv_priv; in mac80211_hwsim_change_sta_links()
3104 if (vif->type == NL80211_IFTYPE_STATION) in mac80211_hwsim_change_sta_links()
3105 sp->active_links_rx = new_links; in mac80211_hwsim_change_sta_links()
3210 if (param->channels) { in append_radio_msg()
3211 ret = nla_put_u32(skb, HWSIM_ATTR_CHANNELS, param->channels); in append_radio_msg()
3216 if (param->reg_alpha2) { in append_radio_msg()
3218 param->reg_alpha2); in append_radio_msg()
3223 if (param->regd) { in append_radio_msg()
3227 if (hwsim_world_regdom_custom[i] != param->regd) in append_radio_msg()
3237 if (param->reg_strict) { in append_radio_msg()
3243 if (param->p2p_device) { in append_radio_msg()
3249 if (param->use_chanctx) { in append_radio_msg()
3255 if (param->hwname) { in append_radio_msg()
3257 strlen(param->hwname), param->hwname); in append_radio_msg()
4191 if (sband->band == NL80211_BAND_2GHZ) { in mac80211_hwsim_sband_capab()
4193 sband->iftype_data = in mac80211_hwsim_sband_capab()
4195 } else if (sband->band == NL80211_BAND_5GHZ) { in mac80211_hwsim_sband_capab()
4197 sband->iftype_data = in mac80211_hwsim_sband_capab()
4199 } else if (sband->band == NL80211_BAND_6GHZ) { in mac80211_hwsim_sband_capab()
4201 sband->iftype_data = in mac80211_hwsim_sband_capab()
4207 sband->n_iftype_data = n_iftype_data; in mac80211_hwsim_sband_capab()
4245 if (WARN_ON(param->channels > 1 && !param->use_chanctx)) in mac80211_hwsim_new_radio()
4246 return -EINVAL; in mac80211_hwsim_new_radio()
4252 if (param->mlo) in mac80211_hwsim_new_radio()
4254 else if (param->use_chanctx) in mac80211_hwsim_new_radio()
4256 hw = ieee80211_alloc_hw_nm(sizeof(*data), ops, param->hwname); in mac80211_hwsim_new_radio()
4259 err = -ENOMEM; in mac80211_hwsim_new_radio()
4264 param->hwname = wiphy_name(hw->wiphy); in mac80211_hwsim_new_radio()
4270 wiphy_net_set(hw->wiphy, net); in mac80211_hwsim_new_radio()
4272 data = hw->priv; in mac80211_hwsim_new_radio()
4273 data->hw = hw; in mac80211_hwsim_new_radio()
4275 data->dev = device_create(hwsim_class, NULL, 0, hw, "hwsim%d", idx); in mac80211_hwsim_new_radio()
4276 if (IS_ERR(data->dev)) { in mac80211_hwsim_new_radio()
4279 PTR_ERR(data->dev)); in mac80211_hwsim_new_radio()
4280 err = -ENOMEM; in mac80211_hwsim_new_radio()
4283 data->dev->driver = &mac80211_hwsim_driver.driver; in mac80211_hwsim_new_radio()
4284 err = device_bind_driver(data->dev); in mac80211_hwsim_new_radio()
4291 skb_queue_head_init(&data->pending); in mac80211_hwsim_new_radio()
4293 SET_IEEE80211_DEV(hw, data->dev); in mac80211_hwsim_new_radio()
4294 if (!param->perm_addr) { in mac80211_hwsim_new_radio()
4299 memcpy(data->addresses[0].addr, addr, ETH_ALEN); in mac80211_hwsim_new_radio()
4301 memcpy(data->addresses[1].addr, addr, ETH_ALEN); in mac80211_hwsim_new_radio()
4302 data->addresses[1].addr[0] |= 0x40; in mac80211_hwsim_new_radio()
4303 hw->wiphy->n_addresses = 2; in mac80211_hwsim_new_radio()
4304 hw->wiphy->addresses = data->addresses; in mac80211_hwsim_new_radio()
4307 memcpy(data->addresses[0].addr, param->perm_addr, ETH_ALEN); in mac80211_hwsim_new_radio()
4309 memcpy(data->addresses[1].addr, param->perm_addr, ETH_ALEN); in mac80211_hwsim_new_radio()
4310 hw->wiphy->n_addresses = 2; in mac80211_hwsim_new_radio()
4311 hw->wiphy->addresses = data->addresses; in mac80211_hwsim_new_radio()
4314 data->channels = param->channels; in mac80211_hwsim_new_radio()
4315 data->use_chanctx = param->use_chanctx; in mac80211_hwsim_new_radio()
4316 data->idx = idx; in mac80211_hwsim_new_radio()
4317 data->destroy_on_close = param->destroy_on_close; in mac80211_hwsim_new_radio()
4319 data->portid = info->snd_portid; in mac80211_hwsim_new_radio()
4322 if (param->iftypes & BIT(NL80211_IFTYPE_ADHOC)) { in mac80211_hwsim_new_radio()
4323 data->if_limits[n_limits].max = 1; in mac80211_hwsim_new_radio()
4324 data->if_limits[n_limits].types = BIT(NL80211_IFTYPE_ADHOC); in mac80211_hwsim_new_radio()
4328 if (param->iftypes & HWSIM_DEFAULT_IF_LIMIT) { in mac80211_hwsim_new_radio()
4329 data->if_limits[n_limits].max = 2048; in mac80211_hwsim_new_radio()
4333 * bits that both param->iftype & HWSIM_DEFAULT_IF_LIMIT have. in mac80211_hwsim_new_radio()
4335 data->if_limits[n_limits].types = in mac80211_hwsim_new_radio()
4336 HWSIM_DEFAULT_IF_LIMIT & param->iftypes; in mac80211_hwsim_new_radio()
4340 if (param->iftypes & BIT(NL80211_IFTYPE_P2P_DEVICE)) { in mac80211_hwsim_new_radio()
4341 data->if_limits[n_limits].max = 1; in mac80211_hwsim_new_radio()
4342 data->if_limits[n_limits].types = in mac80211_hwsim_new_radio()
4347 if (data->use_chanctx) { in mac80211_hwsim_new_radio()
4348 hw->wiphy->max_scan_ssids = 255; in mac80211_hwsim_new_radio()
4349 hw->wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN; in mac80211_hwsim_new_radio()
4350 hw->wiphy->max_remain_on_channel_duration = 1000; in mac80211_hwsim_new_radio()
4351 data->if_combination.radar_detect_widths = 0; in mac80211_hwsim_new_radio()
4352 data->if_combination.num_different_channels = data->channels; in mac80211_hwsim_new_radio()
4354 data->if_combination.num_different_channels = 1; in mac80211_hwsim_new_radio()
4355 data->if_combination.radar_detect_widths = in mac80211_hwsim_new_radio()
4366 err = -EINVAL; in mac80211_hwsim_new_radio()
4370 data->if_combination.max_interfaces = 0; in mac80211_hwsim_new_radio()
4372 data->if_combination.max_interfaces += in mac80211_hwsim_new_radio()
4373 data->if_limits[i].max; in mac80211_hwsim_new_radio()
4375 data->if_combination.n_limits = n_limits; in mac80211_hwsim_new_radio()
4376 data->if_combination.limits = data->if_limits; in mac80211_hwsim_new_radio()
4380 * advertise them - if there's only a single thing like in mac80211_hwsim_new_radio()
4383 if (data->if_combination.max_interfaces > 1) { in mac80211_hwsim_new_radio()
4384 hw->wiphy->iface_combinations = &data->if_combination; in mac80211_hwsim_new_radio()
4385 hw->wiphy->n_iface_combinations = 1; in mac80211_hwsim_new_radio()
4388 if (param->ciphers) { in mac80211_hwsim_new_radio()
4389 memcpy(data->ciphers, param->ciphers, in mac80211_hwsim_new_radio()
4390 param->n_ciphers * sizeof(u32)); in mac80211_hwsim_new_radio()
4391 hw->wiphy->cipher_suites = data->ciphers; in mac80211_hwsim_new_radio()
4392 hw->wiphy->n_cipher_suites = param->n_ciphers; in mac80211_hwsim_new_radio()
4395 data->rx_rssi = DEFAULT_RX_RSSI; in mac80211_hwsim_new_radio()
4397 INIT_DELAYED_WORK(&data->roc_start, hw_roc_start); in mac80211_hwsim_new_radio()
4398 INIT_DELAYED_WORK(&data->roc_done, hw_roc_done); in mac80211_hwsim_new_radio()
4399 INIT_DELAYED_WORK(&data->hw_scan, hw_scan_work); in mac80211_hwsim_new_radio()
4401 hw->queues = 5; in mac80211_hwsim_new_radio()
4402 hw->offchannel_tx_hw_queue = 4; in mac80211_hwsim_new_radio()
4417 if (param->mlo) { in mac80211_hwsim_new_radio()
4418 hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_MLO; in mac80211_hwsim_new_radio()
4430 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; in mac80211_hwsim_new_radio()
4431 hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS | in mac80211_hwsim_new_radio()
4436 hw->wiphy->features |= NL80211_FEATURE_ACTIVE_MONITOR | in mac80211_hwsim_new_radio()
4441 wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_VHT_IBSS); in mac80211_hwsim_new_radio()
4442 wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_BEACON_PROTECTION); in mac80211_hwsim_new_radio()
4443 wiphy_ext_feature_set(hw->wiphy, in mac80211_hwsim_new_radio()
4445 wiphy_ext_feature_set(hw->wiphy, in mac80211_hwsim_new_radio()
4448 hw->wiphy->interface_modes = param->iftypes; in mac80211_hwsim_new_radio()
4451 hw->vif_data_size = sizeof(struct hwsim_vif_priv); in mac80211_hwsim_new_radio()
4452 hw->sta_data_size = sizeof(struct hwsim_sta_priv); in mac80211_hwsim_new_radio()
4453 hw->chanctx_data_size = sizeof(struct hwsim_chanctx_priv); in mac80211_hwsim_new_radio()
4455 memcpy(data->channels_2ghz, hwsim_channels_2ghz, in mac80211_hwsim_new_radio()
4457 memcpy(data->channels_5ghz, hwsim_channels_5ghz, in mac80211_hwsim_new_radio()
4459 memcpy(data->channels_6ghz, hwsim_channels_6ghz, in mac80211_hwsim_new_radio()
4461 memcpy(data->channels_s1g, hwsim_channels_s1g, in mac80211_hwsim_new_radio()
4463 memcpy(data->rates, hwsim_rates, sizeof(hwsim_rates)); in mac80211_hwsim_new_radio()
4466 struct ieee80211_supported_band *sband = &data->bands[band]; in mac80211_hwsim_new_radio()
4468 sband->band = band; in mac80211_hwsim_new_radio()
4472 sband->channels = data->channels_2ghz; in mac80211_hwsim_new_radio()
4473 sband->n_channels = ARRAY_SIZE(hwsim_channels_2ghz); in mac80211_hwsim_new_radio()
4474 sband->bitrates = data->rates; in mac80211_hwsim_new_radio()
4475 sband->n_bitrates = ARRAY_SIZE(hwsim_rates); in mac80211_hwsim_new_radio()
4478 sband->channels = data->channels_5ghz; in mac80211_hwsim_new_radio()
4479 sband->n_channels = ARRAY_SIZE(hwsim_channels_5ghz); in mac80211_hwsim_new_radio()
4480 sband->bitrates = data->rates + 4; in mac80211_hwsim_new_radio()
4481 sband->n_bitrates = ARRAY_SIZE(hwsim_rates) - 4; in mac80211_hwsim_new_radio()
4483 sband->vht_cap.vht_supported = true; in mac80211_hwsim_new_radio()
4484 sband->vht_cap.cap = in mac80211_hwsim_new_radio()
4493 sband->vht_cap.vht_mcs.rx_mcs_map = in mac80211_hwsim_new_radio()
4502 sband->vht_cap.vht_mcs.tx_mcs_map = in mac80211_hwsim_new_radio()
4503 sband->vht_cap.vht_mcs.rx_mcs_map; in mac80211_hwsim_new_radio()
4506 sband->channels = data->channels_6ghz; in mac80211_hwsim_new_radio()
4507 sband->n_channels = ARRAY_SIZE(hwsim_channels_6ghz); in mac80211_hwsim_new_radio()
4508 sband->bitrates = data->rates + 4; in mac80211_hwsim_new_radio()
4509 sband->n_bitrates = ARRAY_SIZE(hwsim_rates) - 4; in mac80211_hwsim_new_radio()
4512 memcpy(&sband->s1g_cap, &hwsim_s1g_cap, in mac80211_hwsim_new_radio()
4513 sizeof(sband->s1g_cap)); in mac80211_hwsim_new_radio()
4514 sband->channels = data->channels_s1g; in mac80211_hwsim_new_radio()
4515 sband->n_channels = ARRAY_SIZE(hwsim_channels_s1g); in mac80211_hwsim_new_radio()
4522 sband->ht_cap.ht_supported = true; in mac80211_hwsim_new_radio()
4523 sband->ht_cap.cap = IEEE80211_HT_CAP_SUP_WIDTH_20_40 | in mac80211_hwsim_new_radio()
4528 sband->ht_cap.ampdu_factor = 0x3; in mac80211_hwsim_new_radio()
4529 sband->ht_cap.ampdu_density = 0x6; in mac80211_hwsim_new_radio()
4530 memset(&sband->ht_cap.mcs, 0, in mac80211_hwsim_new_radio()
4531 sizeof(sband->ht_cap.mcs)); in mac80211_hwsim_new_radio()
4532 sband->ht_cap.mcs.rx_mask[0] = 0xff; in mac80211_hwsim_new_radio()
4533 sband->ht_cap.mcs.rx_mask[1] = 0xff; in mac80211_hwsim_new_radio()
4534 sband->ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; in mac80211_hwsim_new_radio()
4539 hw->wiphy->bands[band] = sband; in mac80211_hwsim_new_radio()
4543 data->group = 1; in mac80211_hwsim_new_radio()
4544 mutex_init(&data->mutex); in mac80211_hwsim_new_radio()
4546 data->netgroup = hwsim_net_get_netgroup(net); in mac80211_hwsim_new_radio()
4547 data->wmediumd = hwsim_net_get_wmediumd(net); in mac80211_hwsim_new_radio()
4550 hw->max_rates = 4; in mac80211_hwsim_new_radio()
4551 hw->max_rate_tries = 11; in mac80211_hwsim_new_radio()
4553 hw->wiphy->vendor_commands = mac80211_hwsim_vendor_commands; in mac80211_hwsim_new_radio()
4554 hw->wiphy->n_vendor_commands = in mac80211_hwsim_new_radio()
4556 hw->wiphy->vendor_events = mac80211_hwsim_vendor_events; in mac80211_hwsim_new_radio()
4557 hw->wiphy->n_vendor_events = ARRAY_SIZE(mac80211_hwsim_vendor_events); in mac80211_hwsim_new_radio()
4559 if (param->reg_strict) in mac80211_hwsim_new_radio()
4560 hw->wiphy->regulatory_flags |= REGULATORY_STRICT_REG; in mac80211_hwsim_new_radio()
4561 if (param->regd) { in mac80211_hwsim_new_radio()
4562 data->regd = param->regd; in mac80211_hwsim_new_radio()
4563 hw->wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG; in mac80211_hwsim_new_radio()
4564 wiphy_apply_custom_regulatory(hw->wiphy, param->regd); in mac80211_hwsim_new_radio()
4569 if (param->no_vif) in mac80211_hwsim_new_radio()
4572 wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_CQM_RSSI_LIST); in mac80211_hwsim_new_radio()
4574 for (i = 0; i < ARRAY_SIZE(data->link_data); i++) { in mac80211_hwsim_new_radio()
4575 hrtimer_init(&data->link_data[i].beacon_timer, CLOCK_MONOTONIC, in mac80211_hwsim_new_radio()
4577 data->link_data[i].beacon_timer.function = in mac80211_hwsim_new_radio()
4579 data->link_data[i].link_id = i; in mac80211_hwsim_new_radio()
4589 wiphy_dbg(hw->wiphy, "hwaddr %pM registered\n", hw->wiphy->perm_addr); in mac80211_hwsim_new_radio()
4591 if (param->reg_alpha2) { in mac80211_hwsim_new_radio()
4592 data->alpha2[0] = param->reg_alpha2[0]; in mac80211_hwsim_new_radio()
4593 data->alpha2[1] = param->reg_alpha2[1]; in mac80211_hwsim_new_radio()
4594 regulatory_hint(hw->wiphy, param->reg_alpha2); in mac80211_hwsim_new_radio()
4597 data->debugfs = debugfs_create_dir("hwsim", hw->wiphy->debugfsdir); in mac80211_hwsim_new_radio()
4598 debugfs_create_file("ps", 0666, data->debugfs, data, &hwsim_fops_ps); in mac80211_hwsim_new_radio()
4599 debugfs_create_file("group", 0666, data->debugfs, data, in mac80211_hwsim_new_radio()
4601 debugfs_create_file("rx_rssi", 0666, data->debugfs, data, in mac80211_hwsim_new_radio()
4603 if (!data->use_chanctx) in mac80211_hwsim_new_radio()
4605 data->debugfs, in mac80211_hwsim_new_radio()
4609 err = rhashtable_insert_fast(&hwsim_radios_rht, &data->rht, in mac80211_hwsim_new_radio()
4614 NL_SET_BAD_ATTR(info->extack, in mac80211_hwsim_new_radio()
4615 info->attrs[HWSIM_ATTR_PERM_ADDR]); in mac80211_hwsim_new_radio()
4621 list_add_tail(&data->list, &hwsim_radios); in mac80211_hwsim_new_radio()
4630 debugfs_remove_recursive(data->debugfs); in mac80211_hwsim_new_radio()
4631 ieee80211_unregister_hw(data->hw); in mac80211_hwsim_new_radio()
4633 device_release_driver(data->dev); in mac80211_hwsim_new_radio()
4635 device_unregister(data->dev); in mac80211_hwsim_new_radio()
4681 hwsim_mcast_del_radio(data->idx, hwname, info); in mac80211_hwsim_del_radio()
4682 debugfs_remove_recursive(data->debugfs); in mac80211_hwsim_del_radio()
4683 ieee80211_unregister_hw(data->hw); in mac80211_hwsim_del_radio()
4684 device_release_driver(data->dev); in mac80211_hwsim_del_radio()
4685 device_unregister(data->dev); in mac80211_hwsim_del_radio()
4686 ieee80211_free_hw(data->hw); in mac80211_hwsim_del_radio()
4696 int res = -EMSGSIZE; in mac80211_hwsim_get_radio()
4701 return -EMSGSIZE; in mac80211_hwsim_get_radio()
4706 if (data->alpha2[0] && data->alpha2[1]) in mac80211_hwsim_get_radio()
4707 param.reg_alpha2 = data->alpha2; in mac80211_hwsim_get_radio()
4709 param.reg_strict = !!(data->hw->wiphy->regulatory_flags & in mac80211_hwsim_get_radio()
4711 param.p2p_device = !!(data->hw->wiphy->interface_modes & in mac80211_hwsim_get_radio()
4713 param.use_chanctx = data->use_chanctx; in mac80211_hwsim_get_radio()
4714 param.regd = data->regd; in mac80211_hwsim_get_radio()
4715 param.channels = data->channels; in mac80211_hwsim_get_radio()
4716 param.hwname = wiphy_name(data->hw->wiphy); in mac80211_hwsim_get_radio()
4718 res = append_radio_msg(skb, data->idx, ¶m); in mac80211_hwsim_get_radio()
4738 list_del(&data->list); in mac80211_hwsim_free()
4740 mac80211_hwsim_del_radio(data, wiphy_name(data->hw->wiphy), in mac80211_hwsim_free()
4758 dev->netdev_ops = &hwsim_netdev_ops; in hwsim_mon_setup()
4759 dev->needs_free_netdev = true; in hwsim_mon_setup()
4761 dev->priv_flags |= IFF_NO_QUEUE; in hwsim_mon_setup()
4762 dev->type = ARPHRD_IEEE80211_RADIOTAP; in hwsim_mon_setup()
4783 if (data->netgroup == hwsim_net_get_netgroup(net)) in hwsim_register_wmediumd()
4784 data->wmediumd = portid; in hwsim_register_wmediumd()
4805 if (!info->attrs[HWSIM_ATTR_ADDR_TRANSMITTER] || in hwsim_tx_info_frame_received_nl()
4806 !info->attrs[HWSIM_ATTR_FLAGS] || in hwsim_tx_info_frame_received_nl()
4807 !info->attrs[HWSIM_ATTR_COOKIE] || in hwsim_tx_info_frame_received_nl()
4808 !info->attrs[HWSIM_ATTR_SIGNAL] || in hwsim_tx_info_frame_received_nl()
4809 !info->attrs[HWSIM_ATTR_TX_INFO]) in hwsim_tx_info_frame_received_nl()
4812 src = (void *)nla_data(info->attrs[HWSIM_ATTR_ADDR_TRANSMITTER]); in hwsim_tx_info_frame_received_nl()
4813 hwsim_flags = nla_get_u32(info->attrs[HWSIM_ATTR_FLAGS]); in hwsim_tx_info_frame_received_nl()
4814 ret_skb_cookie = nla_get_u64(info->attrs[HWSIM_ATTR_COOKIE]); in hwsim_tx_info_frame_received_nl()
4822 data2->netgroup) in hwsim_tx_info_frame_received_nl()
4825 if (info->snd_portid != data2->wmediumd) in hwsim_tx_info_frame_received_nl()
4830 spin_lock_irqsave(&data2->pending.lock, flags); in hwsim_tx_info_frame_received_nl()
4831 skb_queue_walk_safe(&data2->pending, skb, tmp) { in hwsim_tx_info_frame_received_nl()
4835 skb_cookie = (uintptr_t)txi->rate_driver_data[0]; in hwsim_tx_info_frame_received_nl()
4838 __skb_unlink(skb, &data2->pending); in hwsim_tx_info_frame_received_nl()
4843 spin_unlock_irqrestore(&data2->pending.lock, flags); in hwsim_tx_info_frame_received_nl()
4853 info->attrs[HWSIM_ATTR_TX_INFO]); in hwsim_tx_info_frame_received_nl()
4861 txi->status.rates[i].idx = tx_attempts[i].idx; in hwsim_tx_info_frame_received_nl()
4862 txi->status.rates[i].count = tx_attempts[i].count; in hwsim_tx_info_frame_received_nl()
4865 txi->status.ack_signal = nla_get_u32(info->attrs[HWSIM_ATTR_SIGNAL]); in hwsim_tx_info_frame_received_nl()
4869 if (skb->len >= 16) { in hwsim_tx_info_frame_received_nl()
4870 hdr = (struct ieee80211_hdr *) skb->data; in hwsim_tx_info_frame_received_nl()
4871 mac80211_hwsim_monitor_ack(data2->channel, in hwsim_tx_info_frame_received_nl()
4872 hdr->addr2); in hwsim_tx_info_frame_received_nl()
4874 txi->flags |= IEEE80211_TX_STAT_ACK; in hwsim_tx_info_frame_received_nl()
4878 txi->flags |= IEEE80211_TX_STAT_NOACK_TRANSMITTED; in hwsim_tx_info_frame_received_nl()
4880 ieee80211_tx_status_irqsafe(data2->hw, skb); in hwsim_tx_info_frame_received_nl()
4883 return -EINVAL; in hwsim_tx_info_frame_received_nl()
4899 if (!info->attrs[HWSIM_ATTR_ADDR_RECEIVER] || in hwsim_cloned_frame_received_nl()
4900 !info->attrs[HWSIM_ATTR_FRAME] || in hwsim_cloned_frame_received_nl()
4901 !info->attrs[HWSIM_ATTR_RX_RATE] || in hwsim_cloned_frame_received_nl()
4902 !info->attrs[HWSIM_ATTR_SIGNAL]) in hwsim_cloned_frame_received_nl()
4905 dst = (void *)nla_data(info->attrs[HWSIM_ATTR_ADDR_RECEIVER]); in hwsim_cloned_frame_received_nl()
4906 frame_data_len = nla_len(info->attrs[HWSIM_ATTR_FRAME]); in hwsim_cloned_frame_received_nl()
4907 frame_data = (void *)nla_data(info->attrs[HWSIM_ATTR_FRAME]); in hwsim_cloned_frame_received_nl()
4924 if (data2->use_chanctx) { in hwsim_cloned_frame_received_nl()
4925 if (data2->tmp_chan) in hwsim_cloned_frame_received_nl()
4926 channel = data2->tmp_chan; in hwsim_cloned_frame_received_nl()
4928 channel = data2->channel; in hwsim_cloned_frame_received_nl()
4933 data2->netgroup) in hwsim_cloned_frame_received_nl()
4936 if (info->snd_portid != data2->wmediumd) in hwsim_cloned_frame_received_nl()
4942 if ((data2->idle && !data2->tmp_chan) || !data2->started) in hwsim_cloned_frame_received_nl()
4947 if (info->attrs[HWSIM_ATTR_FREQ]) { in hwsim_cloned_frame_received_nl()
4950 /* throw away off-channel packets, but allow both the temporary in hwsim_cloned_frame_received_nl()
4951 * ("hw" scan/remain-on-channel), regular channels and links, in hwsim_cloned_frame_received_nl()
4954 rx_status.freq = nla_get_u32(info->attrs[HWSIM_ATTR_FREQ]); in hwsim_cloned_frame_received_nl()
4956 iter_data.channel = ieee80211_get_channel(data2->hw->wiphy, in hwsim_cloned_frame_received_nl()
4960 rx_status.band = iter_data.channel->band; in hwsim_cloned_frame_received_nl()
4962 mutex_lock(&data2->mutex); in hwsim_cloned_frame_received_nl()
4965 data2->hw, IEEE80211_IFACE_ITER_NORMAL, in hwsim_cloned_frame_received_nl()
4968 mutex_unlock(&data2->mutex); in hwsim_cloned_frame_received_nl()
4972 mutex_unlock(&data2->mutex); in hwsim_cloned_frame_received_nl()
4976 rx_status.freq = channel->center_freq; in hwsim_cloned_frame_received_nl()
4977 rx_status.band = channel->band; in hwsim_cloned_frame_received_nl()
4980 rx_status.rate_idx = nla_get_u32(info->attrs[HWSIM_ATTR_RX_RATE]); in hwsim_cloned_frame_received_nl()
4981 if (rx_status.rate_idx >= data2->hw->wiphy->bands[rx_status.band]->n_bitrates) in hwsim_cloned_frame_received_nl()
4983 rx_status.signal = nla_get_u32(info->attrs[HWSIM_ATTR_SIGNAL]); in hwsim_cloned_frame_received_nl()
4985 hdr = (void *)skb->data; in hwsim_cloned_frame_received_nl()
4987 if (ieee80211_is_beacon(hdr->frame_control) || in hwsim_cloned_frame_received_nl()
4988 ieee80211_is_probe_resp(hdr->frame_control)) in hwsim_cloned_frame_received_nl()
4998 return -EINVAL; in hwsim_cloned_frame_received_nl()
5010 chans = max(chans, data->channels); in hwsim_register_received_nl()
5014 * to set a flag that it does support multi-channel, then we can in hwsim_register_received_nl()
5019 return -EOPNOTSUPP; in hwsim_register_received_nl()
5022 return -EBUSY; in hwsim_register_received_nl()
5024 hwsim_register_wmediumd(net, info->snd_portid); in hwsim_register_received_nl()
5027 "switching to wmediumd mode with pid %d\n", info->snd_portid); in hwsim_register_received_nl()
5061 param.reg_strict = info->attrs[HWSIM_ATTR_REG_STRICT_REG]; in hwsim_new_radio_nl()
5062 param.p2p_device = info->attrs[HWSIM_ATTR_SUPPORT_P2P_DEVICE]; in hwsim_new_radio_nl()
5065 info->attrs[HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE]; in hwsim_new_radio_nl()
5067 if (info->attrs[HWSIM_ATTR_CHANNELS]) in hwsim_new_radio_nl()
5068 param.channels = nla_get_u32(info->attrs[HWSIM_ATTR_CHANNELS]); in hwsim_new_radio_nl()
5072 return -EINVAL; in hwsim_new_radio_nl()
5075 if (info->attrs[HWSIM_ATTR_NO_VIF]) in hwsim_new_radio_nl()
5078 if (info->attrs[HWSIM_ATTR_USE_CHANCTX]) in hwsim_new_radio_nl()
5083 if (info->attrs[HWSIM_ATTR_REG_HINT_ALPHA2]) in hwsim_new_radio_nl()
5085 nla_data(info->attrs[HWSIM_ATTR_REG_HINT_ALPHA2]); in hwsim_new_radio_nl()
5087 if (info->attrs[HWSIM_ATTR_REG_CUSTOM_REG]) { in hwsim_new_radio_nl()
5088 u32 idx = nla_get_u32(info->attrs[HWSIM_ATTR_REG_CUSTOM_REG]); in hwsim_new_radio_nl()
5091 return -EINVAL; in hwsim_new_radio_nl()
5098 if (info->attrs[HWSIM_ATTR_PERM_ADDR]) { in hwsim_new_radio_nl()
5100 nla_data(info->attrs[HWSIM_ATTR_PERM_ADDR]))) { in hwsim_new_radio_nl()
5102 NL_SET_BAD_ATTR(info->extack, in hwsim_new_radio_nl()
5103 info->attrs[HWSIM_ATTR_PERM_ADDR]); in hwsim_new_radio_nl()
5104 return -EINVAL; in hwsim_new_radio_nl()
5107 param.perm_addr = nla_data(info->attrs[HWSIM_ATTR_PERM_ADDR]); in hwsim_new_radio_nl()
5110 if (info->attrs[HWSIM_ATTR_IFTYPE_SUPPORT]) { in hwsim_new_radio_nl()
5112 nla_get_u32(info->attrs[HWSIM_ATTR_IFTYPE_SUPPORT]); in hwsim_new_radio_nl()
5115 NL_SET_ERR_MSG_ATTR(info->extack, in hwsim_new_radio_nl()
5116 info->attrs[HWSIM_ATTR_IFTYPE_SUPPORT], in hwsim_new_radio_nl()
5118 return -EINVAL; in hwsim_new_radio_nl()
5131 if (info->attrs[HWSIM_ATTR_CIPHER_SUPPORT]) { in hwsim_new_radio_nl()
5132 u32 len = nla_len(info->attrs[HWSIM_ATTR_CIPHER_SUPPORT]); in hwsim_new_radio_nl()
5135 nla_data(info->attrs[HWSIM_ATTR_CIPHER_SUPPORT]); in hwsim_new_radio_nl()
5138 NL_SET_ERR_MSG_ATTR(info->extack, in hwsim_new_radio_nl()
5139 info->attrs[HWSIM_ATTR_CIPHER_SUPPORT], in hwsim_new_radio_nl()
5141 return -EINVAL; in hwsim_new_radio_nl()
5147 NL_SET_ERR_MSG_ATTR(info->extack, in hwsim_new_radio_nl()
5148 info->attrs[HWSIM_ATTR_CIPHER_SUPPORT], in hwsim_new_radio_nl()
5150 return -EINVAL; in hwsim_new_radio_nl()
5154 NL_SET_ERR_MSG_ATTR(info->extack, in hwsim_new_radio_nl()
5155 info->attrs[HWSIM_ATTR_CIPHER_SUPPORT], in hwsim_new_radio_nl()
5157 return -EINVAL; in hwsim_new_radio_nl()
5161 param.mlo = info->attrs[HWSIM_ATTR_MLO_SUPPORT]; in hwsim_new_radio_nl()
5166 if (info->attrs[HWSIM_ATTR_RADIO_NAME]) { in hwsim_new_radio_nl()
5167 hwname = kstrndup((char *)nla_data(info->attrs[HWSIM_ATTR_RADIO_NAME]), in hwsim_new_radio_nl()
5168 nla_len(info->attrs[HWSIM_ATTR_RADIO_NAME]), in hwsim_new_radio_nl()
5171 return -ENOMEM; in hwsim_new_radio_nl()
5183 s64 idx = -1; in hwsim_del_radio_nl()
5186 if (info->attrs[HWSIM_ATTR_RADIO_ID]) { in hwsim_del_radio_nl()
5187 idx = nla_get_u32(info->attrs[HWSIM_ATTR_RADIO_ID]); in hwsim_del_radio_nl()
5188 } else if (info->attrs[HWSIM_ATTR_RADIO_NAME]) { in hwsim_del_radio_nl()
5189 hwname = kstrndup((char *)nla_data(info->attrs[HWSIM_ATTR_RADIO_NAME]), in hwsim_del_radio_nl()
5190 nla_len(info->attrs[HWSIM_ATTR_RADIO_NAME]), in hwsim_del_radio_nl()
5193 return -ENOMEM; in hwsim_del_radio_nl()
5195 return -EINVAL; in hwsim_del_radio_nl()
5200 if (data->idx != idx) in hwsim_del_radio_nl()
5204 strcmp(hwname, wiphy_name(data->hw->wiphy))) in hwsim_del_radio_nl()
5208 if (!net_eq(wiphy_net(data->hw->wiphy), genl_info_net(info))) in hwsim_del_radio_nl()
5211 list_del(&data->list); in hwsim_del_radio_nl()
5212 rhashtable_remove_fast(&hwsim_radios_rht, &data->rht, in hwsim_del_radio_nl()
5216 mac80211_hwsim_del_radio(data, wiphy_name(data->hw->wiphy), in hwsim_del_radio_nl()
5224 return -ENODEV; in hwsim_del_radio_nl()
5231 int idx, res = -ENODEV; in hwsim_get_radio_nl()
5233 if (!info->attrs[HWSIM_ATTR_RADIO_ID]) in hwsim_get_radio_nl()
5234 return -EINVAL; in hwsim_get_radio_nl()
5235 idx = nla_get_u32(info->attrs[HWSIM_ATTR_RADIO_ID]); in hwsim_get_radio_nl()
5239 if (data->idx != idx) in hwsim_get_radio_nl()
5242 if (!net_eq(wiphy_net(data->hw->wiphy), genl_info_net(info))) in hwsim_get_radio_nl()
5247 res = -ENOMEM; in hwsim_get_radio_nl()
5251 res = mac80211_hwsim_get_radio(skb, data, info->snd_portid, in hwsim_get_radio_nl()
5252 info->snd_seq, NULL, 0); in hwsim_get_radio_nl()
5271 int last_idx = cb->args[0] - 1; in hwsim_dump_radio_nl()
5277 cb->seq = hwsim_radios_generation; in hwsim_dump_radio_nl()
5279 if (last_idx >= hwsim_radio_idx-1) in hwsim_dump_radio_nl()
5283 if (data->idx <= last_idx) in hwsim_dump_radio_nl()
5286 if (!net_eq(wiphy_net(data->hw->wiphy), sock_net(skb->sk))) in hwsim_dump_radio_nl()
5290 NETLINK_CB(cb->skb).portid, in hwsim_dump_radio_nl()
5291 cb->nlh->nlmsg_seq, cb, in hwsim_dump_radio_nl()
5296 last_idx = data->idx; in hwsim_dump_radio_nl()
5299 cb->args[0] = last_idx + 1; in hwsim_dump_radio_nl()
5302 if (skb->len == 0 && cb->prev_seq && cb->seq != cb->prev_seq) { in hwsim_dump_radio_nl()
5303 hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid, in hwsim_dump_radio_nl()
5304 cb->nlh->nlmsg_seq, &hwsim_genl_family, in hwsim_dump_radio_nl()
5310 res = -EMSGSIZE; in hwsim_dump_radio_nl()
5316 return res ?: skb->len; in hwsim_dump_radio_nl()
5378 if (entry->destroy_on_close && entry->portid == portid) { in remove_user_radios()
5379 list_move(&entry->list, &list); in remove_user_radios()
5380 rhashtable_remove_fast(&hwsim_radios_rht, &entry->rht, in remove_user_radios()
5388 list_del(&entry->list); in remove_user_radios()
5389 mac80211_hwsim_del_radio(entry, wiphy_name(entry->hw->wiphy), in remove_user_radios()
5403 remove_user_radios(notify->portid); in mac80211_hwsim_netlink_notify()
5405 if (notify->portid == hwsim_net_get_wmediumd(notify->net)) { in mac80211_hwsim_netlink_notify()
5408 hwsim_register_wmediumd(notify->net, 0); in mac80211_hwsim_netlink_notify()
5438 return -EINVAL; in hwsim_init_netlink()
5453 if (!net_eq(wiphy_net(data->hw->wiphy), net)) in hwsim_exit_net()
5457 if (data->netgroup == hwsim_net_get_netgroup(&init_net)) in hwsim_exit_net()
5460 list_move(&data->list, &list); in hwsim_exit_net()
5461 rhashtable_remove_fast(&hwsim_radios_rht, &data->rht, in hwsim_exit_net()
5468 list_del(&data->list); in hwsim_exit_net()
5470 wiphy_name(data->hw->wiphy), in hwsim_exit_net()
5516 if (skb->len < nlh->nlmsg_len) in hwsim_virtio_handle_cmd()
5517 return -EINVAL; in hwsim_virtio_handle_cmd()
5528 switch (gnlh->cmd) { in hwsim_virtio_handle_cmd()
5536 pr_err_ratelimited("hwsim: invalid cmd: %d\n", gnlh->cmd); in hwsim_virtio_handle_cmd()
5537 return -EPROTO; in hwsim_virtio_handle_cmd()
5560 skb->data = skb->head; in hwsim_virtio_rx_work()
5571 sg_init_one(sg, skb->head, skb_end_offset(skb)); in hwsim_virtio_rx_work()
5612 return -ENOMEM; in fill_vq()
5614 sg_init_one(sg, skb->head, skb_end_offset(skb)); in fill_vq()
5639 vdev->config->del_vqs(vdev); in remove_vqs()
5650 return -EEXIST; in hwsim_virtio_probe()
5725 return -EINVAL; in init_mac80211_hwsim()
5728 return -EINVAL; in init_mac80211_hwsim()
5844 err = -ENOMEM; in init_mac80211_hwsim()
5849 err = dev_alloc_name(hwsim_mon, hwsim_mon->name); in init_mac80211_hwsim()