^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright 2015 Intel Deutschland GmbH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <net/mac80211.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include "ieee80211_i.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include "trace.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include "driver-ops.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) int drv_start(struct ieee80211_local *local)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) might_sleep();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) if (WARN_ON(local->started))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) return -EALREADY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) trace_drv_start(local);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) local->started = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) /* allow rx frames */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) smp_mb();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) ret = local->ops->start(&local->hw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) trace_drv_return_int(local, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) local->started = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) void drv_stop(struct ieee80211_local *local)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) might_sleep();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) if (WARN_ON(!local->started))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) trace_drv_stop(local);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) local->ops->stop(&local->hw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) trace_drv_return_void(local);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) /* sync away all work on the tasklet before clearing started */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) tasklet_disable(&local->tasklet);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) tasklet_enable(&local->tasklet);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) barrier();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) local->started = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) int drv_add_interface(struct ieee80211_local *local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) might_sleep();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) if (WARN_ON(sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) (sdata->vif.type == NL80211_IFTYPE_MONITOR &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) !ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) !(sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE))))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) trace_drv_add_interface(local, sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) ret = local->ops->add_interface(&local->hw, &sdata->vif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) trace_drv_return_int(local, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) if (ret == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) sdata->flags |= IEEE80211_SDATA_IN_DRIVER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) int drv_change_interface(struct ieee80211_local *local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) enum nl80211_iftype type, bool p2p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) might_sleep();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) if (!check_sdata_in_driver(sdata))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) trace_drv_change_interface(local, sdata, type, p2p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) ret = local->ops->change_interface(&local->hw, &sdata->vif, type, p2p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) trace_drv_return_int(local, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) void drv_remove_interface(struct ieee80211_local *local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) might_sleep();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) if (!check_sdata_in_driver(sdata))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) trace_drv_remove_interface(local, sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) local->ops->remove_interface(&local->hw, &sdata->vif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) sdata->flags &= ~IEEE80211_SDATA_IN_DRIVER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) trace_drv_return_void(local);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) __must_check
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) int drv_sta_state(struct ieee80211_local *local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) struct sta_info *sta,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) enum ieee80211_sta_state old_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) enum ieee80211_sta_state new_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) might_sleep();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) sdata = get_bss_sdata(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) if (!check_sdata_in_driver(sdata))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) trace_drv_sta_state(local, sdata, &sta->sta, old_state, new_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) if (local->ops->sta_state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) ret = local->ops->sta_state(&local->hw, &sdata->vif, &sta->sta,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) old_state, new_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) } else if (old_state == IEEE80211_STA_AUTH &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) new_state == IEEE80211_STA_ASSOC) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) ret = drv_sta_add(local, sdata, &sta->sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) if (ret == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) sta->uploaded = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) if (rcu_access_pointer(sta->sta.rates))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) drv_sta_rate_tbl_update(local, sdata, &sta->sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) } else if (old_state == IEEE80211_STA_ASSOC &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) new_state == IEEE80211_STA_AUTH) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) drv_sta_remove(local, sdata, &sta->sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) trace_drv_return_int(local, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) __must_check
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) int drv_sta_set_txpwr(struct ieee80211_local *local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) struct sta_info *sta)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) int ret = -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) might_sleep();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) sdata = get_bss_sdata(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) if (!check_sdata_in_driver(sdata))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) trace_drv_sta_set_txpwr(local, sdata, &sta->sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) if (local->ops->sta_set_txpwr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) ret = local->ops->sta_set_txpwr(&local->hw, &sdata->vif,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) &sta->sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) trace_drv_return_int(local, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) void drv_sta_rc_update(struct ieee80211_local *local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) struct ieee80211_sta *sta, u32 changed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) sdata = get_bss_sdata(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) if (!check_sdata_in_driver(sdata))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) WARN_ON(changed & IEEE80211_RC_SUPP_RATES_CHANGED &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) (sdata->vif.type != NL80211_IFTYPE_ADHOC &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) sdata->vif.type != NL80211_IFTYPE_MESH_POINT));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) trace_drv_sta_rc_update(local, sdata, sta, changed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) if (local->ops->sta_rc_update)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) local->ops->sta_rc_update(&local->hw, &sdata->vif,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) sta, changed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) trace_drv_return_void(local);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) int drv_conf_tx(struct ieee80211_local *local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) struct ieee80211_sub_if_data *sdata, u16 ac,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) const struct ieee80211_tx_queue_params *params)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) int ret = -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) might_sleep();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) if (!check_sdata_in_driver(sdata))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) if (params->cw_min == 0 || params->cw_min > params->cw_max) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) * If we can't configure hardware anyway, don't warn. We may
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) * never have initialized the CW parameters.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) WARN_ONCE(local->ops->conf_tx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) "%s: invalid CW_min/CW_max: %d/%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) sdata->name, params->cw_min, params->cw_max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) trace_drv_conf_tx(local, sdata, ac, params);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) if (local->ops->conf_tx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) ret = local->ops->conf_tx(&local->hw, &sdata->vif,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) ac, params);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) trace_drv_return_int(local, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) u64 drv_get_tsf(struct ieee80211_local *local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) u64 ret = -1ULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) might_sleep();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) if (!check_sdata_in_driver(sdata))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) trace_drv_get_tsf(local, sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) if (local->ops->get_tsf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) ret = local->ops->get_tsf(&local->hw, &sdata->vif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) trace_drv_return_u64(local, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) void drv_set_tsf(struct ieee80211_local *local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) u64 tsf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) might_sleep();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) if (!check_sdata_in_driver(sdata))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) trace_drv_set_tsf(local, sdata, tsf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) if (local->ops->set_tsf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) local->ops->set_tsf(&local->hw, &sdata->vif, tsf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) trace_drv_return_void(local);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) void drv_offset_tsf(struct ieee80211_local *local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) s64 offset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) might_sleep();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) if (!check_sdata_in_driver(sdata))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) trace_drv_offset_tsf(local, sdata, offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) if (local->ops->offset_tsf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) local->ops->offset_tsf(&local->hw, &sdata->vif, offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) trace_drv_return_void(local);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) void drv_reset_tsf(struct ieee80211_local *local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) might_sleep();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) if (!check_sdata_in_driver(sdata))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) trace_drv_reset_tsf(local, sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) if (local->ops->reset_tsf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) local->ops->reset_tsf(&local->hw, &sdata->vif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) trace_drv_return_void(local);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) int drv_switch_vif_chanctx(struct ieee80211_local *local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) struct ieee80211_vif_chanctx_switch *vifs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) int n_vifs, enum ieee80211_chanctx_switch_mode mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) might_sleep();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) if (!local->ops->switch_vif_chanctx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) for (i = 0; i < n_vifs; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) struct ieee80211_chanctx *new_ctx =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) container_of(vifs[i].new_ctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) struct ieee80211_chanctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) conf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) struct ieee80211_chanctx *old_ctx =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) container_of(vifs[i].old_ctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) struct ieee80211_chanctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) conf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) WARN_ON_ONCE(!old_ctx->driver_present);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) WARN_ON_ONCE((mode == CHANCTX_SWMODE_SWAP_CONTEXTS &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) new_ctx->driver_present) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) (mode == CHANCTX_SWMODE_REASSIGN_VIF &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) !new_ctx->driver_present));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) trace_drv_switch_vif_chanctx(local, vifs, n_vifs, mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) ret = local->ops->switch_vif_chanctx(&local->hw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) vifs, n_vifs, mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) trace_drv_return_int(local, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) if (!ret && mode == CHANCTX_SWMODE_SWAP_CONTEXTS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) for (i = 0; i < n_vifs; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) struct ieee80211_chanctx *new_ctx =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) container_of(vifs[i].new_ctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) struct ieee80211_chanctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) conf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) struct ieee80211_chanctx *old_ctx =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) container_of(vifs[i].old_ctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) struct ieee80211_chanctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) conf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) new_ctx->driver_present = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) old_ctx->driver_present = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) int drv_ampdu_action(struct ieee80211_local *local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) struct ieee80211_ampdu_params *params)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) int ret = -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) might_sleep();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) sdata = get_bss_sdata(sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) if (!check_sdata_in_driver(sdata))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) trace_drv_ampdu_action(local, sdata, params);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) if (local->ops->ampdu_action)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) ret = local->ops->ampdu_action(&local->hw, &sdata->vif, params);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) trace_drv_return_int(local, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) }