/* * For the high priority TE use a time event type that has similar priority to * the FW's action scan priority.
*/ #define IWL_MVM_ROC_TE_TYPE_NORMAL TE_P2P_DEVICE_DISCOVERABLE #define IWL_MVM_ROC_TE_TYPE_MGMT_TX TE_P2P_CLIENT_ASSOC
/* * Clear the ROC_P2P_RUNNING status bit. * This will cause the TX path to drop offchannel transmissions. * That would also be done by mac80211, but it is racy, in particular * in the case that the time event actually completed in the firmware. * * Also flush the offchannel queue -- this is called when the time * event finishes or is canceled, so that frames queued for it * won't get stuck on the queue and be transmitted in the next * time event.
*/ if (test_and_clear_bit(IWL_MVM_STATUS_ROC_P2P_RUNNING, &mvm->status)) { struct iwl_mvm_vif *mvmvif;
synchronize_net();
/* * NB: access to this pointer would be racy, but the flush bit * can only be set when we had a P2P-Device VIF, and we have a * flush of this work in iwl_mvm_prepare_mac_removal() so it's * not really racy.
*/
if (!WARN_ON(!vif)) {
mvmvif = iwl_mvm_vif_from_mac80211(vif);
iwl_mvm_flush_sta(mvm, mvmvif->deflink.bcast_sta.sta_id,
mvmvif->deflink.bcast_sta.tfd_queue_msk);
if (mvm->mld_api_is_used) {
iwl_mvm_mld_rm_bcast_sta(mvm, vif,
&vif->bss_conf);
/* Do not remove the PHY context as removing and adding * a PHY context has timing overheads. Leaving it * configured in FW would be useful in case the next ROC * is with the same channel.
*/
}
}
/* * P2P AUX ROC and HS2.0 ROC do not run simultaneously. * Clear the ROC_AUX_RUNNING status bit. * This will cause the TX path to drop offchannel transmissions. * That would also be done by mac80211, but it is racy, in particular * in the case that the time event actually completed in the firmware * (which is handled in iwl_mvm_te_handle_notif).
*/ if (test_and_clear_bit(IWL_MVM_STATUS_ROC_AUX_RUNNING, &mvm->status)) {
synchronize_net();
/* In newer version of this command an aux station is added only * in cases of dedicated tx queue and need to be removed in end * of use. For the even newer mld api, use the appropriate * function.
*/ if (mvm->mld_api_is_used)
iwl_mvm_mld_rm_aux_sta(mvm); elseif (iwl_mvm_has_new_station_api(mvm->fw))
iwl_mvm_rm_aux_sta(mvm);
}
if (!IS_ERR_OR_NULL(bss_vif))
iwl_mvm_unblock_esr(mvm, bss_vif, IWL_MVM_ESR_BLOCKED_ROC);
mutex_unlock(&mvm->mutex);
}
mutex_lock(&mvm->mutex); /* Mutex is released inside */
iwl_mvm_cleanup_roc(mvm);
}
staticvoid iwl_mvm_roc_finished(struct iwl_mvm *mvm)
{ /* * Of course, our status bit is just as racy as mac80211, so in * addition, fire off the work struct which will drop all frames * from the hardware queues that made it through the race. First * it will of course synchronize the TX path to make sure that * any *new* TX will be rejected.
*/
schedule_work(&mvm->roc_done_wk);
}
csa_vif = rcu_dereference(mvm->csa_vif); if (!csa_vif || !csa_vif->bss_conf.csa_active) goto out_unlock;
IWL_DEBUG_TE(mvm, "CSA NOA started\n");
/* * CSA NoA is started but we still have beacons to * transmit on the current channel. * So we just do nothing here and the switch * will be performed on the last TBTT.
*/ if (!ieee80211_beacon_cntdwn_is_complete(csa_vif, 0)) {
IWL_WARN(mvm, "CSA NOA started too early\n"); goto out_unlock;
}
if (vif->cfg.assoc) { /* * When not associated, this will be called from * iwl_mvm_event_mlme_callback_ini()
*/
iwl_dbg_tlv_time_point(&mvm->fwrt,
IWL_FW_INI_TIME_POINT_ASSOC_FAILED,
NULL);
/* * Handles a FW notification for an event that is known to the driver. * * @mvm: the mvm component * @te_data: the time event data * @notif: the notification data corresponding the time event data.
*/ staticvoid iwl_mvm_te_handle_notif(struct iwl_mvm *mvm, struct iwl_mvm_time_event_data *te_data, struct iwl_time_event_notif *notif)
{
lockdep_assert_held(&mvm->time_event_lock);
/* * The FW sends the start/end time event notifications even for events * that it fails to schedule. This is indicated in the status field of * the notification. This happens in cases that the scheduler cannot * find a schedule that can handle the event (for example requesting a * P2P Device discoveribility, while there are other higher priority * events in the system).
*/ if (!le32_to_cpu(notif->status)) { constchar *msg;
if (notif->action & cpu_to_le32(TE_V2_NOTIF_HOST_EVENT_START))
msg = "Time Event start notification failure"; else
msg = "Time Event end notification failure";
IWL_DEBUG_TE(mvm, "%s\n", msg);
if (iwl_mvm_te_check_disconnect(mvm, te_data->vif, msg)) {
iwl_mvm_te_clear_data(mvm, te_data); return;
}
}
if (le32_to_cpu(notif->action) & TE_V2_NOTIF_HOST_EVENT_END) {
IWL_DEBUG_TE(mvm, "TE ended - current time %lu, estimated end %lu\n",
jiffies, te_data->end_jiffies);
switch (te_data->vif->type) { case NL80211_IFTYPE_P2P_DEVICE:
ieee80211_remain_on_channel_expired(mvm->hw);
iwl_mvm_roc_finished(mvm); break; case NL80211_IFTYPE_STATION: /* * If we are switching channel, don't disconnect * if the time event is already done. Beacons can * be delayed a bit after the switch.
*/ if (te_data->id == TE_CHANNEL_SWITCH_PERIOD) {
IWL_DEBUG_TE(mvm, "No beacon heard and the CS time event is over, don't disconnect\n"); break;
}
/* * By now, we should have finished association * and know the dtim period.
*/
iwl_mvm_te_check_disconnect(mvm, te_data->vif,
!te_data->vif->cfg.assoc ? "Not associated and the time event is over already..." : "No beacon heard and the time event is over already..."); break; default: break;
}
/* Clear vif roc_activity if done (set to ROC_NUM_ACTIVITIES) */
ieee80211_iterate_active_interfaces_atomic(mvm->hw,
IEEE80211_IFACE_ITER_NORMAL,
iwl_mvm_rx_roc_iterator,
&data); /* * It is possible that the ROC was canceled * but the notification was already fired.
*/ if (!data.found) return;
/* * Handle A Aux ROC time event
*/ staticint iwl_mvm_aux_roc_te_handle_notif(struct iwl_mvm *mvm, struct iwl_time_event_notif *notif)
{ struct iwl_mvm_time_event_data *aux_roc_te = NULL, *te_data;
list_for_each_entry(te_data, &mvm->aux_roc_te_list, list) { if (le32_to_cpu(notif->unique_id) == te_data->uid) {
aux_roc_te = te_data; break;
}
} if (!aux_roc_te) /* Not a Aux ROC time event */ return -EINVAL;
spin_lock_bh(&mvm->time_event_lock); /* This time event is triggered for Aux ROC request */ if (!iwl_mvm_aux_roc_te_handle_notif(mvm, notif)) goto unlock;
/* te_data->uid is already set in the TIME_EVENT_CMD response */ if (le32_to_cpu(resp->unique_id) != te_data->uid) returnfalse;
IWL_DEBUG_TE(mvm, "TIME_EVENT_NOTIFICATION response - UID = 0x%x\n",
te_data->uid); if (!resp->status)
IWL_ERR(mvm, "TIME_EVENT_NOTIFICATION received but not executed\n");
/* * Use a notification wait, which really just processes the * command response and doesn't wait for anything, in order * to be able to process the response and get the UID inside * the RX path. Using CMD_WANT_SKB doesn't work because it * stores the buffer and then wakes up this thread, by which * time another notification (that the time event started) * might already be processed unsuccessfully.
*/
iwl_init_notification_wait(&mvm->notif_wait, &wait_time_event,
time_event_response,
ARRAY_SIZE(time_event_response),
iwl_mvm_time_event_response, te_data);
/* No need to wait for anything, so just pass 1 (0 isn't valid) */
ret = iwl_wait_notification(&mvm->notif_wait, &wait_time_event, 1); /* should never fail */
WARN_ON_ONCE(ret);
if (te_data->running &&
time_after(te_data->end_jiffies, TU_TO_EXP_TIME(min_duration))) {
IWL_DEBUG_TE(mvm, "We have enough time in the current TE: %u\n",
jiffies_to_msecs(te_data->end_jiffies - jiffies)); return;
}
if (te_data->running) {
IWL_DEBUG_TE(mvm, "extend 0x%x: only %u ms left\n",
te_data->uid,
jiffies_to_msecs(te_data->end_jiffies - jiffies)); /* * we don't have enough time * cancel the current TE and issue a new one * Of course it would be better to remove the old one only * when the new one is added, but we don't care if we are off * channel for a bit. All we need to do, is not to return * before we actually begin to be on the channel.
*/
iwl_mvm_stop_session_protection(mvm, vif);
}
time_cmd.max_frags = TE_V2_FRAG_NONE;
time_cmd.max_delay = cpu_to_le32(max_delay); /* TODO: why do we need to interval = bi if it is not periodic? */
time_cmd.interval = cpu_to_le32(1);
time_cmd.duration = cpu_to_le32(duration);
time_cmd.repeat = 1;
time_cmd.policy = cpu_to_le16(TE_V2_NOTIF_HOST_EVENT_START |
TE_V2_NOTIF_HOST_EVENT_END |
TE_V2_START_IMMEDIATELY);
if (!wait_for_notif) {
iwl_mvm_time_event_send_add(mvm, vif, te_data, &time_cmd); return;
}
/* * Create notification_wait for the TIME_EVENT_NOTIFICATION to use * right after we send the time event
*/
iwl_init_notification_wait(&mvm->notif_wait, &wait_te_notif,
te_notif_response,
ARRAY_SIZE(te_notif_response),
iwl_mvm_te_notif, te_data);
/* If TE was sent OK - wait for the notification that started */ if (iwl_mvm_time_event_send_add(mvm, vif, te_data, &time_cmd)) {
IWL_ERR(mvm, "Failed to add TE to protect session\n");
iwl_remove_notification(&mvm->notif_wait, &wait_te_notif);
} elseif (iwl_wait_notification(&mvm->notif_wait, &wait_te_notif,
TU_TO_JIFFIES(max_delay))) {
IWL_ERR(mvm, "Failed to protect session until TE\n");
}
}
/* Determine whether mac or link id should be used, and validate the link id */ staticint iwl_mvm_get_session_prot_id(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
s8 link_id)
{ struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); int ver = iwl_fw_lookup_cmd_ver(mvm->fw,
WIDE_ID(MAC_CONF_GROUP,
SESSION_PROTECTION_CMD), 1);
if (ver < 2) return mvmvif->id;
if (WARN(link_id < 0 || !mvmvif->link[link_id], "Invalid link ID for session protection: %u\n", link_id)) return -EINVAL;
if (WARN(!mvmvif->link[link_id]->active, "Session Protection on an inactive link: %u\n", link_id)) return -EINVAL;
/* * It is possible that by the time we got to this point the time * event was already removed.
*/
spin_lock_bh(&mvm->time_event_lock);
/* Save time event uid before clearing its data */
*uid = te_data->uid;
id = te_data->id;
link_id = te_data->link_id;
/* * The clear_data function handles time events that were already removed
*/
iwl_mvm_te_clear_data(mvm, te_data);
spin_unlock_bh(&mvm->time_event_lock);
if ((p2p_aux && iftype == NL80211_IFTYPE_P2P_DEVICE) ||
(roc_ver >= 3 && mvmvif->roc_activity == ROC_ACTIVITY_HOTSPOT)) { if (mvmvif->roc_activity < ROC_NUM_ACTIVITIES) {
iwl_mvm_roc_rm_cmd(mvm, mvmvif->roc_activity);
mvmvif->roc_activity = ROC_NUM_ACTIVITIES;
iwl_mvm_roc_finished(mvm);
} returnfalse;
} elseif (fw_has_capa(&mvm->fw->ucode_capa,
IWL_UCODE_TLV_CAPA_SESSION_PROT_CMD) &&
id != HOT_SPOT_CMD) { /* When session protection is used, the te_data->id field * is reused to save session protection's configuration. * For AUX ROC, HOT_SPOT_CMD is used and the te_data->id * field is set to HOT_SPOT_CMD.
*/ if (mvmvif && id < SESSION_PROTECT_CONF_MAX_ID) { /* Session protection is still ongoing. Cancel it */
iwl_mvm_cancel_session_protection(mvm, vif, id,
link_id); if (iftype == NL80211_IFTYPE_P2P_DEVICE) {
iwl_mvm_roc_finished(mvm);
}
} returnfalse;
} else { /* It is possible that by the time we try to remove it, the * time event has already ended and removed. In such a case * there is no need to send a removal command.
*/ if (id == TE_MAX) {
IWL_DEBUG_TE(mvm, "TE 0x%x has already ended\n", *uid); returnfalse;
}
}
returntrue;
}
/* * Explicit request to remove a aux roc time event. The removal of a time * event needs to be synchronized with the flow of a time event's end * notification, which also removes the time event from the op mode * data structures.
*/ staticvoid iwl_mvm_remove_aux_roc_te(struct iwl_mvm *mvm, struct iwl_mvm_vif *mvmvif, struct iwl_mvm_time_event_data *te_data)
{ struct iwl_hs20_roc_req aux_cmd = {};
u16 len = sizeof(aux_cmd) - iwl_mvm_chan_info_padding(mvm);
u32 uid; int ret;
if (!__iwl_mvm_remove_time_event(mvm, te_data, &uid)) return;
aux_cmd.event_unique_id = cpu_to_le32(uid);
aux_cmd.action = cpu_to_le32(FW_CTXT_ACTION_REMOVE);
aux_cmd.id_and_color =
cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, mvmvif->color));
IWL_DEBUG_TE(mvm, "Removing BSS AUX ROC TE 0x%x\n",
le32_to_cpu(aux_cmd.event_unique_id));
ret = iwl_mvm_send_cmd_pdu(mvm, HOT_SPOT_CMD, 0,
len, &aux_cmd);
if (WARN_ON(ret)) return;
}
/* * Explicit request to remove a time event. The removal of a time event needs to * be synchronized with the flow of a time event's end notification, which also * removes the time event from the op mode data structures.
*/ void iwl_mvm_remove_time_event(struct iwl_mvm *mvm, struct iwl_mvm_vif *mvmvif, struct iwl_mvm_time_event_data *te_data)
{ struct iwl_time_event_cmd time_cmd = {};
u32 uid; int ret;
if (!__iwl_mvm_remove_time_event(mvm, te_data, &uid)) return;
/* When we remove a TE, the UID is to be set in the id field */
time_cmd.id = cpu_to_le32(uid);
time_cmd.action = cpu_to_le32(FW_CTXT_ACTION_REMOVE);
time_cmd.id_and_color =
cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, mvmvif->color));
IWL_DEBUG_TE(mvm, "Removing TE 0x%x\n", le32_to_cpu(time_cmd.id));
ret = iwl_mvm_send_cmd_pdu(mvm, TIME_EVENT_CMD, 0, sizeof(time_cmd), &time_cmd); if (ret)
IWL_ERR(mvm, "Couldn't remove the time event\n");
}
/* note we use link ID == MAC ID */
vif = iwl_mvm_rcu_dereference_vif_id(mvm, id, true); if (!vif) goto out_unlock;
mvmvif = iwl_mvm_vif_from_mac80211(vif);
/* The vif is not a P2P_DEVICE, maintain its time_event_data */ if (vif->type != NL80211_IFTYPE_P2P_DEVICE) { struct iwl_mvm_time_event_data *te_data =
&mvmvif->time_event_data;
if (le32_to_cpu(notif->start)) {
spin_lock_bh(&mvm->time_event_lock);
te_data->running = le32_to_cpu(notif->start);
te_data->end_jiffies =
TU_TO_EXP_TIME(te_data->duration);
spin_unlock_bh(&mvm->time_event_lock);
} else { /* * By now, we should have finished association * and know the dtim period.
*/
iwl_mvm_te_check_disconnect(mvm, vif,
!vif->cfg.assoc ? "Not associated and the session protection is over already..." : "No beacon heard and the session protection is over already...");
spin_lock_bh(&mvm->time_event_lock);
iwl_mvm_te_clear_data(mvm, te_data);
spin_unlock_bh(&mvm->time_event_lock);
}
goto out_unlock;
}
if (!le32_to_cpu(notif->status) || !le32_to_cpu(notif->start)) { /* End TE, notify mac80211 */
mvmvif->time_event_data.id = SESSION_PROTECT_CONF_MAX_ID;
mvmvif->time_event_data.link_id = -1; /* set the bit so the ROC cleanup will actually clean up */
set_bit(IWL_MVM_STATUS_ROC_P2P_RUNNING, &mvm->status);
iwl_mvm_roc_finished(mvm);
ieee80211_remain_on_channel_expired(mvm->hw);
} elseif (le32_to_cpu(notif->start)) { if (WARN_ON(mvmvif->time_event_data.id !=
le32_to_cpu(notif->conf_id))) goto out_unlock;
set_bit(IWL_MVM_STATUS_ROC_P2P_RUNNING, &mvm->status);
ieee80211_ready_on_channel(mvm->hw); /* Start TE */
}
/* * If we are associated we want the delay time to be at least one * dtim interval so that the FW can wait until after the DTIM and * then start the time event, this will potentially allow us to * remain off-channel for the max duration. * Since we want to use almost a whole dtim interval we would also * like the delay to be for 2-3 dtim intervals, in case there are * other time events with higher priority. * dtim_interval should never be 0, it can be 1 if we don't know it * (we haven't heard any beacon yet).
*/ if (vif->cfg.assoc && !WARN_ON(!dtim_interval)) {
*delay = min_t(u32, dtim_interval * 3, AUX_ROC_MAX_DELAY); /* We cannot remain off-channel longer than the DTIM interval */ if (dtim_interval <= *duration_tu) {
*duration_tu = dtim_interval - AUX_ROC_SAFETY_BUFFER; if (*duration_tu <= AUX_ROC_MIN_DURATION)
*duration_tu = dtim_interval -
AUX_ROC_MIN_SAFETY_BUFFER;
}
}
}
if (WARN_ON(mvmvif->roc_activity != ROC_NUM_ACTIVITIES)) return -EBUSY;
/* Set the channel info data */
iwl_mvm_set_chan_info(mvm, &roc_req.channel_info,
channel->hw_value,
iwl_mvm_phy_band_from_nl80211(channel->band),
IWL_PHY_CHANNEL_MODE20, 0);
/* * The P2P Device TEs can have lower priority than other events * that are being scheduled by the driver/fw, and thus it might not be * scheduled. To improve the chances of it being scheduled, allow them * to be fragmented, and in addition allow them to be delayed.
*/
time_cmd.max_frags = min(MSEC_TO_TU(duration)/50, TE_V2_FRAG_ENDLESS);
time_cmd.max_delay = cpu_to_le32(MSEC_TO_TU(duration/2));
time_cmd.duration = cpu_to_le32(MSEC_TO_TU(duration));
time_cmd.repeat = 1;
time_cmd.policy = cpu_to_le16(TE_V2_NOTIF_HOST_EVENT_START |
TE_V2_NOTIF_HOST_EVENT_END |
TE_V2_START_IMMEDIATELY);
/* * Iterate over the list of time events and find the time event that is * associated with a P2P_DEVICE interface. * This assumes that a P2P_DEVICE interface can have only a single time * event at any given time and this time event coresponds to a ROC * request
*/
list_for_each_entry(te_data, &mvm->time_event_list, list) { if (te_data->vif->type == NL80211_IFTYPE_P2P_DEVICE) goto out;
}
/* There can only be at most one AUX ROC time event, we just use the * list to simplify/unify code. Remove it if it exists.
*/
te_data = list_first_entry_or_null(&mvm->aux_roc_te_list, struct iwl_mvm_time_event_data,
list);
out:
spin_unlock_bh(&mvm->time_event_lock); return te_data;
}
cleanup_roc: /* * In case we get here before the ROC event started, * (so the status bit isn't set) set it here so iwl_mvm_cleanup_roc will * cleanup things properly
*/ if (p2p_aux || iftype != NL80211_IFTYPE_P2P_DEVICE)
set_bit(IWL_MVM_STATUS_ROC_AUX_RUNNING, &mvm->status); else
set_bit(IWL_MVM_STATUS_ROC_P2P_RUNNING, &mvm->status);
/* Mutex is released inside this function */
iwl_mvm_cleanup_roc(mvm);
}
spin_lock_bh(&mvm->time_event_lock);
id = te_data->id;
spin_unlock_bh(&mvm->time_event_lock);
if (id == TE_CHANNEL_SWITCH_PERIOD) {
IWL_DEBUG_TE(mvm, "CS period is already scheduled\n"); return -EBUSY;
}
/* * Remove the session protection time event to allow the * channel switch. If we got here, we just heard a beacon so * the session protection is not needed anymore anyway.
*/
iwl_mvm_remove_time_event(mvm, mvmvif, te_data);
}
spin_lock_bh(&mvm->time_event_lock); if (te_data->running && te_data->link_id == link_id &&
time_after(te_data->end_jiffies, TU_TO_EXP_TIME(min_duration))) {
IWL_DEBUG_TE(mvm, "We have enough time in the current TE: %u\n",
jiffies_to_msecs(te_data->end_jiffies - jiffies));
spin_unlock_bh(&mvm->time_event_lock);
return;
}
iwl_mvm_te_clear_data(mvm, te_data); /* * The time_event_data.id field is reused to save session * protection's configuration.
*/
te_data->id = le32_to_cpu(cmd.conf_id);
te_data->duration = le32_to_cpu(cmd.duration_tu);
te_data->vif = vif;
te_data->link_id = link_id;
spin_unlock_bh(&mvm->time_event_lock);
IWL_DEBUG_TE(mvm, "Add new session protection, duration %d TU\n",
le32_to_cpu(cmd.duration_tu));
if (!wait_for_notif) { if (iwl_mvm_send_cmd_pdu(mvm,
WIDE_ID(MAC_CONF_GROUP, SESSION_PROTECTION_CMD),
0, sizeof(cmd), &cmd)) { goto send_cmd_err;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.