Commit 24487981 authored by Johannes Berg's avatar Johannes Berg Committed by John W. Linville
Browse files

mac80211: add driver ops wrappers



In order to later add tracing or verifications to the driver
calls mac80211 makes, this patch adds static inline wrappers
for all operations.

All calls are now written as

	drv_<op>(local, ...);

instead of

	local->ops-><op>(&local->hw, ...);

Where necessary, the wrappers also do existence checking and
return default values as appropriate.

Signed-off-by: default avatarJohannes Berg <johannes@sipsolutions.net>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 2d0ddec5
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -16,12 +16,12 @@
#include <linux/ieee80211.h>
#include <net/mac80211.h>
#include "ieee80211_i.h"
#include "driver-ops.h"

void __ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid,
				    u16 initiator, u16 reason)
{
	struct ieee80211_local *local = sta->local;
	struct ieee80211_hw *hw = &local->hw;
	int i;

	/* check if TID is in operational state */
@@ -41,7 +41,7 @@ void __ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid,
	       sta->sta.addr, tid);
#endif /* CONFIG_MAC80211_HT_DEBUG */

	if (local->ops->ampdu_action(hw, IEEE80211_AMPDU_RX_STOP,
	if (drv_ampdu_action(local, IEEE80211_AMPDU_RX_STOP,
			     &sta->sta, tid, NULL))
		printk(KERN_DEBUG "HW problem - can not stop rx "
				"aggregation for tid %d\n", tid);
@@ -278,8 +278,7 @@ void ieee80211_process_addba_request(struct ieee80211_local *local,
		goto end;
	}

	if (local->ops->ampdu_action)
		ret = local->ops->ampdu_action(hw, IEEE80211_AMPDU_RX_START,
	ret = drv_ampdu_action(local, IEEE80211_AMPDU_RX_START,
			       &sta->sta, tid, &start_seq_num);
#ifdef CONFIG_MAC80211_HT_DEBUG
	printk(KERN_DEBUG "Rx A-MPDU request on tid %d result %d\n", tid, ret);
+7 −6
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
#include <linux/ieee80211.h>
#include <net/mac80211.h>
#include "ieee80211_i.h"
#include "driver-ops.h"
#include "wme.h"

/**
@@ -134,7 +135,7 @@ static int ___ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid,
	*state = HT_AGG_STATE_REQ_STOP_BA_MSK |
		(initiator << HT_AGG_STATE_INITIATOR_SHIFT);

	ret = local->ops->ampdu_action(&local->hw, IEEE80211_AMPDU_TX_STOP,
	ret = drv_ampdu_action(local, IEEE80211_AMPDU_TX_STOP,
			       &sta->sta, tid, NULL);

	/* HW shall not deny going back to legacy */
@@ -306,7 +307,7 @@ int ieee80211_start_tx_ba_session(struct ieee80211_hw *hw, u8 *ra, u16 tid)

	start_seq_num = sta->tid_seq[tid];

	ret = local->ops->ampdu_action(hw, IEEE80211_AMPDU_TX_START,
	ret = drv_ampdu_action(local, IEEE80211_AMPDU_TX_START,
			       &sta->sta, tid, &start_seq_num);

	if (ret) {
@@ -418,7 +419,7 @@ static void ieee80211_agg_tx_operational(struct ieee80211_local *local,
	ieee80211_agg_splice_finish(local, sta, tid);
	spin_unlock(&local->ampdu_lock);

	local->ops->ampdu_action(&local->hw, IEEE80211_AMPDU_TX_OPERATIONAL,
	drv_ampdu_action(local, IEEE80211_AMPDU_TX_OPERATIONAL,
			 &sta->sta, tid, NULL);
}

+10 −14
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@
#include <linux/rcupdate.h>
#include <net/cfg80211.h>
#include "ieee80211_i.h"
#include "driver-ops.h"
#include "cfg.h"
#include "rate.h"
#include "mesh.h"
@@ -245,10 +246,8 @@ static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
		iv32 = key->u.tkip.tx.iv32;
		iv16 = key->u.tkip.tx.iv16;

		if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE &&
		    sdata->local->ops->get_tkip_seq)
			sdata->local->ops->get_tkip_seq(
				local_to_hw(sdata->local),
		if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)
			drv_get_tkip_seq(sdata->local,
					 key->conf.hw_key_idx,
					 &iv32, &iv16);

@@ -1115,7 +1114,7 @@ static int ieee80211_set_txq_params(struct wiphy *wiphy,
	p.cw_max = params->cwmax;
	p.cw_min = params->cwmin;
	p.txop = params->txop;
	if (local->ops->conf_tx(local_to_hw(local), params->queue, &p)) {
	if (drv_conf_tx(local, params->queue, &p)) {
		printk(KERN_DEBUG "%s: failed to set TX queue "
		       "parameters for queue %d\n", local->mdev->name,
		       params->queue);
@@ -1296,17 +1295,14 @@ static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
{
	struct ieee80211_local *local = wiphy_priv(wiphy);
	int err;

	if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
		int err;
		err = drv_set_rts_threshold(local, wiphy->rts_threshold);

		if (local->ops->set_rts_threshold) {
			err = local->ops->set_rts_threshold(
				local_to_hw(local), wiphy->rts_threshold);
		if (err)
			return err;
	}
	}

	if (changed & WIPHY_PARAM_RETRY_SHORT)
		local->hw.conf.short_frame_max_tx_count = wiphy->retry_short;
+9 −11
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@
#include <linux/debugfs.h>
#include <linux/rtnetlink.h>
#include "ieee80211_i.h"
#include "driver-ops.h"
#include "rate.h"
#include "debugfs.h"

@@ -70,11 +71,10 @@ static ssize_t tsf_read(struct file *file, char __user *user_buf,
			     size_t count, loff_t *ppos)
{
	struct ieee80211_local *local = file->private_data;
	u64 tsf = 0;
	u64 tsf;
	char buf[100];

	if (local->ops->get_tsf)
		tsf = local->ops->get_tsf(local_to_hw(local));
	tsf = drv_get_tsf(local);

	snprintf(buf, sizeof(buf), "0x%016llx\n", (unsigned long long) tsf);

@@ -97,13 +97,13 @@ static ssize_t tsf_write(struct file *file,

	if (strncmp(buf, "reset", 5) == 0) {
		if (local->ops->reset_tsf) {
			local->ops->reset_tsf(local_to_hw(local));
			drv_reset_tsf(local);
			printk(KERN_INFO "%s: debugfs reset TSF\n", wiphy_name(local->hw.wiphy));
		}
	} else {
		tsf = simple_strtoul(buf, NULL, 0);
		if (local->ops->set_tsf) {
			local->ops->set_tsf(local_to_hw(local), tsf);
			drv_set_tsf(local, tsf);
			printk(KERN_INFO "%s: debugfs set TSF to %#018llx\n", wiphy_name(local->hw.wiphy), tsf);
		}
	}
@@ -150,13 +150,11 @@ static ssize_t format_devstat_counter(struct ieee80211_local *local,
	char buf[20];
	int res;

	if (!local->ops->get_stats)
		return -EOPNOTSUPP;

	rtnl_lock();
	res = local->ops->get_stats(local_to_hw(local), &stats);
	res = drv_get_stats(local, &stats);
	rtnl_unlock();
	if (!res)
	if (res)
		return res;
	res = printvalue(&stats, buf, sizeof(buf));
	return simple_read_from_buffer(userbuf, count, ppos, buf, res);
}
+184 −0
Original line number Diff line number Diff line
#ifndef __MAC80211_DRIVER_OPS
#define __MAC80211_DRIVER_OPS

#include <net/mac80211.h>
#include "ieee80211_i.h"

static inline int drv_tx(struct ieee80211_local *local, struct sk_buff *skb)
{
	return local->ops->tx(&local->hw, skb);
}

static inline int drv_start(struct ieee80211_local *local)
{
	return local->ops->start(&local->hw);
}

static inline void drv_stop(struct ieee80211_local *local)
{
	local->ops->stop(&local->hw);
}

static inline int drv_add_interface(struct ieee80211_local *local,
				    struct ieee80211_if_init_conf *conf)
{
	return local->ops->add_interface(&local->hw, conf);
}

static inline void drv_remove_interface(struct ieee80211_local *local,
					struct ieee80211_if_init_conf *conf)
{
	local->ops->remove_interface(&local->hw, conf);
}

static inline int drv_config(struct ieee80211_local *local, u32 changed)
{
	return local->ops->config(&local->hw, changed);
}

static inline void drv_bss_info_changed(struct ieee80211_local *local,
					struct ieee80211_vif *vif,
					struct ieee80211_bss_conf *info,
					u32 changed)
{
	if (local->ops->bss_info_changed)
		local->ops->bss_info_changed(&local->hw, vif, info, changed);
}

static inline void drv_configure_filter(struct ieee80211_local *local,
					unsigned int changed_flags,
					unsigned int *total_flags,
					int mc_count,
					struct dev_addr_list *mc_list)
{
	local->ops->configure_filter(&local->hw, changed_flags, total_flags,
				     mc_count, mc_list);
}

static inline int drv_set_tim(struct ieee80211_local *local,
			      struct ieee80211_sta *sta, bool set)
{
	if (local->ops->set_tim)
		return local->ops->set_tim(&local->hw, sta, set);
	return 0;
}

static inline int drv_set_key(struct ieee80211_local *local,
			      enum set_key_cmd cmd, struct ieee80211_vif *vif,
			      struct ieee80211_sta *sta,
			      struct ieee80211_key_conf *key)
{
	return local->ops->set_key(&local->hw, cmd, vif, sta, key);
}

static inline void drv_update_tkip_key(struct ieee80211_local *local,
				       struct ieee80211_key_conf *conf,
				       const u8 *address, u32 iv32,
				       u16 *phase1key)
{
	if (local->ops->update_tkip_key)
		local->ops->update_tkip_key(&local->hw, conf, address,
					    iv32, phase1key);
}

static inline int drv_hw_scan(struct ieee80211_local *local,
			      struct cfg80211_scan_request *req)
{
	return local->ops->hw_scan(&local->hw, req);
}

static inline void drv_sw_scan_start(struct ieee80211_local *local)
{
	if (local->ops->sw_scan_start)
		local->ops->sw_scan_start(&local->hw);
}

static inline void drv_sw_scan_complete(struct ieee80211_local *local)
{
	if (local->ops->sw_scan_complete)
		local->ops->sw_scan_complete(&local->hw);
}

static inline int drv_get_stats(struct ieee80211_local *local,
				struct ieee80211_low_level_stats *stats)
{
	if (!local->ops->get_stats)
		return -EOPNOTSUPP;
	return local->ops->get_stats(&local->hw, stats);
}

static inline void drv_get_tkip_seq(struct ieee80211_local *local,
				    u8 hw_key_idx, u32 *iv32, u16 *iv16)
{
	if (local->ops->get_tkip_seq)
		local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16);
}

static inline int drv_set_rts_threshold(struct ieee80211_local *local,
					u32 value)
{
	if (local->ops->set_rts_threshold)
		return local->ops->set_rts_threshold(&local->hw, value);
	return 0;
}

static inline void drv_sta_notify(struct ieee80211_local *local,
				  struct ieee80211_vif *vif,
				  enum sta_notify_cmd cmd,
				  struct ieee80211_sta *sta)
{
	if (local->ops->sta_notify)
		local->ops->sta_notify(&local->hw, vif, cmd, sta);
}

static inline int drv_conf_tx(struct ieee80211_local *local, u16 queue,
			      const struct ieee80211_tx_queue_params *params)
{
	if (local->ops->conf_tx)
		return local->ops->conf_tx(&local->hw, queue, params);
	return -EOPNOTSUPP;
}

static inline int drv_get_tx_stats(struct ieee80211_local *local,
				   struct ieee80211_tx_queue_stats *stats)
{
	return local->ops->get_tx_stats(&local->hw, stats);
}

static inline u64 drv_get_tsf(struct ieee80211_local *local)
{
	if (local->ops->get_tsf)
		return local->ops->get_tsf(&local->hw);
	return -1ULL;
}

static inline void drv_set_tsf(struct ieee80211_local *local, u64 tsf)
{
	if (local->ops->set_tsf)
		local->ops->set_tsf(&local->hw, tsf);
}

static inline void drv_reset_tsf(struct ieee80211_local *local)
{
	if (local->ops->reset_tsf)
		local->ops->reset_tsf(&local->hw);
}

static inline int drv_tx_last_beacon(struct ieee80211_local *local)
{
	if (local->ops->tx_last_beacon)
		return local->ops->tx_last_beacon(&local->hw);
	return 1;
}

static inline int drv_ampdu_action(struct ieee80211_local *local,
				   enum ieee80211_ampdu_mlme_action action,
				   struct ieee80211_sta *sta, u16 tid,
				   u16 *ssn)
{
	if (local->ops->ampdu_action)
		return local->ops->ampdu_action(&local->hw, action,
						sta, tid, ssn);
	return -EOPNOTSUPP;
}
#endif /* __MAC80211_DRIVER_OPS */
Loading