Merge branch 'for-next' of git://git.samba.org/sfrench/cifs-2.6
[firefly-linux-kernel-4.4.55.git] / net / mac80211 / driver-ops.c
index 1a720e890d4086d065accf65c62af04a534b454f..ca1fe5576103767c3a98b52e037c0034b949887f 100644 (file)
@@ -1,4 +1,6 @@
 /*
+ * Copyright 2015 Intel Deutschland GmbH
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
@@ -8,6 +10,48 @@
 #include "trace.h"
 #include "driver-ops.h"
 
+int drv_start(struct ieee80211_local *local)
+{
+       int ret;
+
+       might_sleep();
+
+       if (WARN_ON(local->started))
+               return -EALREADY;
+
+       trace_drv_start(local);
+       local->started = true;
+       /* allow rx frames */
+       smp_mb();
+       ret = local->ops->start(&local->hw);
+       trace_drv_return_int(local, ret);
+
+       if (ret)
+               local->started = false;
+
+       return ret;
+}
+
+void drv_stop(struct ieee80211_local *local)
+{
+       might_sleep();
+
+       if (WARN_ON(!local->started))
+               return;
+
+       trace_drv_stop(local);
+       local->ops->stop(&local->hw);
+       trace_drv_return_void(local);
+
+       /* sync away all work on the tasklet before clearing started */
+       tasklet_disable(&local->tasklet);
+       tasklet_enable(&local->tasklet);
+
+       barrier();
+
+       local->started = false;
+}
+
 int drv_add_interface(struct ieee80211_local *local,
                      struct ieee80211_sub_if_data *sdata)
 {
@@ -139,6 +183,52 @@ int drv_conf_tx(struct ieee80211_local *local,
        return ret;
 }
 
+u64 drv_get_tsf(struct ieee80211_local *local,
+               struct ieee80211_sub_if_data *sdata)
+{
+       u64 ret = -1ULL;
+
+       might_sleep();
+
+       if (!check_sdata_in_driver(sdata))
+               return ret;
+
+       trace_drv_get_tsf(local, sdata);
+       if (local->ops->get_tsf)
+               ret = local->ops->get_tsf(&local->hw, &sdata->vif);
+       trace_drv_return_u64(local, ret);
+       return ret;
+}
+
+void drv_set_tsf(struct ieee80211_local *local,
+                struct ieee80211_sub_if_data *sdata,
+                u64 tsf)
+{
+       might_sleep();
+
+       if (!check_sdata_in_driver(sdata))
+               return;
+
+       trace_drv_set_tsf(local, sdata, tsf);
+       if (local->ops->set_tsf)
+               local->ops->set_tsf(&local->hw, &sdata->vif, tsf);
+       trace_drv_return_void(local);
+}
+
+void drv_reset_tsf(struct ieee80211_local *local,
+                  struct ieee80211_sub_if_data *sdata)
+{
+       might_sleep();
+
+       if (!check_sdata_in_driver(sdata))
+               return;
+
+       trace_drv_reset_tsf(local, sdata);
+       if (local->ops->reset_tsf)
+               local->ops->reset_tsf(&local->hw, &sdata->vif);
+       trace_drv_return_void(local);
+}
+
 int drv_switch_vif_chanctx(struct ieee80211_local *local,
                           struct ieee80211_vif_chanctx_switch *vifs,
                           int n_vifs, enum ieee80211_chanctx_switch_mode mode)
@@ -146,6 +236,8 @@ int drv_switch_vif_chanctx(struct ieee80211_local *local,
        int ret = 0;
        int i;
 
+       might_sleep();
+
        if (!local->ops->switch_vif_chanctx)
                return -EOPNOTSUPP;
 
@@ -189,3 +281,29 @@ int drv_switch_vif_chanctx(struct ieee80211_local *local,
 
        return ret;
 }
+
+int drv_ampdu_action(struct ieee80211_local *local,
+                    struct ieee80211_sub_if_data *sdata,
+                    enum ieee80211_ampdu_mlme_action action,
+                    struct ieee80211_sta *sta, u16 tid,
+                    u16 *ssn, u8 buf_size, bool amsdu)
+{
+       int ret = -EOPNOTSUPP;
+
+       might_sleep();
+
+       sdata = get_bss_sdata(sdata);
+       if (!check_sdata_in_driver(sdata))
+               return -EIO;
+
+       trace_drv_ampdu_action(local, sdata, action, sta, tid,
+                              ssn, buf_size, amsdu);
+
+       if (local->ops->ampdu_action)
+               ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action,
+                                              sta, tid, ssn, buf_size, amsdu);
+
+       trace_drv_return_int(local, ret);
+
+       return ret;
+}