All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

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

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
......@@ -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,8 +41,8 @@ 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,
&sta->sta, tid, NULL))
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,9 +278,8 @@ 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,
&sta->sta, tid, &start_seq_num);
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);
#endif /* CONFIG_MAC80211_HT_DEBUG */
......
......@@ -16,6 +16,7 @@
#include <linux/ieee80211.h>
#include <net/mac80211.h>
#include "ieee80211_i.h"
#include "driver-ops.h"
#include "wme.h"
/**
......@@ -134,8 +135,8 @@ 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,
&sta->sta, tid, NULL);
ret = drv_ampdu_action(local, IEEE80211_AMPDU_TX_STOP,
&sta->sta, tid, NULL);
/* HW shall not deny going back to legacy */
if (WARN_ON(ret)) {
......@@ -306,8 +307,8 @@ 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,
&sta->sta, tid, &start_seq_num);
ret = drv_ampdu_action(local, IEEE80211_AMPDU_TX_START,
&sta->sta, tid, &start_seq_num);
if (ret) {
#ifdef CONFIG_MAC80211_HT_DEBUG
......@@ -418,8 +419,8 @@ 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,
&sta->sta, tid, NULL);
drv_ampdu_action(local, IEEE80211_AMPDU_TX_OPERATIONAL,
&sta->sta, tid, NULL);
}
void ieee80211_start_tx_ba_cb(struct ieee80211_hw *hw, u8 *ra, u16 tid)
......
......@@ -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,12 +246,10 @@ 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),
key->conf.hw_key_idx,
&iv32, &iv16);
if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)
drv_get_tkip_seq(sdata->local,
key->conf.hw_key_idx,
&iv32, &iv16);
seq[0] = iv16 & 0xff;
seq[1] = (iv16 >> 8) & 0xff;
......@@ -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,16 +1295,13 @@ 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 (err)
return err;
}
if (changed & WIPHY_PARAM_RETRY_SHORT)
......
......@@ -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,14 +150,12 @@ 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)
res = printvalue(&stats, buf, sizeof(buf));
if (res)
return res;
res = printvalue(&stats, buf, sizeof(buf));
return simple_read_from_buffer(userbuf, count, ppos, buf, res);
}
......
#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 */
......@@ -22,6 +22,7 @@
#include <asm/unaligned.h>
#include "ieee80211_i.h"
#include "driver-ops.h"
#include "rate.h"
#define IEEE80211_SCAN_INTERVAL (2 * HZ)
......@@ -75,10 +76,9 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
struct ieee80211_supported_band *sband;
u32 bss_change;
if (local->ops->reset_tsf) {
/* Reset own TSF to allow time synchronization work. */
local->ops->reset_tsf(local_to_hw(local));
}
/* Reset own TSF to allow time synchronization work. */
drv_reset_tsf(local);
skb = ifibss->skb;
rcu_assign_pointer(ifibss->presp, NULL);
......@@ -315,12 +315,13 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
bitrates[rx_status->rate_idx].bitrate;
rx_timestamp = rx_status->mactime + (24 * 8 * 10 / rate);
} else if (local && local->ops && local->ops->get_tsf)
/* second best option: get current TSF */
rx_timestamp = local->ops->get_tsf(local_to_hw(local));
else
/* can't merge without knowing the TSF */
rx_timestamp = -1LLU;
} else {
/*
* second best option: get current TSF
* (will return -1 if not supported)
*/
rx_timestamp = drv_get_tsf(local);
}
#ifdef CONFIG_MAC80211_IBSS_DEBUG
printk(KERN_DEBUG "RX beacon SA=%pM BSSID="
......@@ -591,10 +592,7 @@ static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata,
len < 24 + 2 || !ifibss->presp)
return;
if (local->ops->tx_last_beacon)
tx_last_beacon = local->ops->tx_last_beacon(local_to_hw(local));
else
tx_last_beacon = 1;
tx_last_beacon = drv_tx_last_beacon(local);
#ifdef CONFIG_MAC80211_IBSS_DEBUG
printk(KERN_DEBUG "%s: RX ProbeReq SA=%pM DA=%pM BSSID=%pM"
......
......@@ -20,6 +20,7 @@
#include "debugfs_netdev.h"
#include "mesh.h"
#include "led.h"
#include "driver-ops.h"
/**
* DOC: Interface list locking
......@@ -164,9 +165,7 @@ static int ieee80211_open(struct net_device *dev)
}
if (local->open_count == 0) {
res = 0;
if (local->ops->start)
res = local->ops->start(local_to_hw(local));
res = drv_start(local);
if (res)
goto err_del_bss;
/* we're brought up, everything changes */
......@@ -199,8 +198,8 @@ static int ieee80211_open(struct net_device *dev)
* Validate the MAC address for this device.
*/
if (!is_valid_ether_addr(dev->dev_addr)) {
if (!local->open_count && local->ops->stop)
local->ops->stop(local_to_hw(local));
if (!local->open_count)
drv_stop(local);
return -EADDRNOTAVAIL;
}
......@@ -241,7 +240,7 @@ static int ieee80211_open(struct net_device *dev)
conf.vif = &sdata->vif;
conf.type = sdata->vif.type;
conf.mac_addr = dev->dev_addr;
res = local->ops->add_interface(local_to_hw(local), &conf);
res = drv_add_interface(local, &conf);
if (res)
goto err_stop;
......@@ -328,10 +327,10 @@ static int ieee80211_open(struct net_device *dev)
return 0;
err_del_interface:
local->ops->remove_interface(local_to_hw(local), &conf);
drv_remove_interface(local, &conf);
err_stop:
if (!local->open_count && local->ops->stop)
local->ops->stop(local_to_hw(local));
if (!local->open_count)
drv_stop(local);
err_del_bss:
sdata->bss = NULL;
if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
......@@ -544,7 +543,7 @@ static int ieee80211_stop(struct net_device *dev)
conf.mac_addr = dev->dev_addr;
/* disable all keys for as long as this netdev is down */
ieee80211_disable_keys(sdata);
local->ops->remove_interface(local_to_hw(local), &conf);
drv_remove_interface(local, &conf);
}
sdata->bss = NULL;
......@@ -553,8 +552,7 @@ static int ieee80211_stop(struct net_device *dev)
if (netif_running(local->mdev))
dev_close(local->mdev);
if (local->ops->stop)
local->ops->stop(local_to_hw(local));
drv_stop(local);
ieee80211_led_radio(local, 0);
......
......@@ -16,6 +16,7 @@
#include <linux/rtnetlink.h>
#include <net/mac80211.h>
#include "ieee80211_i.h"
#include "driver-ops.h"
#include "debugfs_key.h"
#include "aes_ccm.h"
#include "aes_cmac.h"
......@@ -136,8 +137,7 @@ static void ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
struct ieee80211_sub_if_data,
u.ap);
ret = key->local->ops->set_key(local_to_hw(key->local), SET_KEY,
&sdata->vif, sta, &key->conf);
ret = drv_set_key(key->local, SET_KEY, &sdata->vif, sta, &key->conf);
if (!ret) {
spin_lock(&todo_lock);
......@@ -179,8 +179,8 @@ static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key)
struct ieee80211_sub_if_data,
u.ap);
ret = key->local->ops->set_key(local_to_hw(key->local), DISABLE_KEY,
&sdata->vif, sta, &key->conf);
ret = drv_set_key(key->local, DISABLE_KEY, &sdata->vif,
sta, &key->conf);
if (ret)
printk(KERN_ERR "mac80211-%s: failed to remove key "
......
......@@ -26,6 +26,7 @@
#include <net/cfg80211.h>
#include "ieee80211_i.h"
#include "driver-ops.h"
#include "rate.h"
#include "mesh.h"
#include "wep.h"
......@@ -81,10 +82,9 @@ void ieee80211_configure_filter(struct ieee80211_local *local)
/* be a bit nasty */
new_flags |= (1<<31);
local->ops->configure_filter(local_to_hw(local),
changed_flags, &new_flags,
local->mdev->mc_count,
local->mdev->mc_list);
drv_configure_filter(local, changed_flags, &new_flags,
local->mdev->mc_count,
local->mdev->mc_list);
WARN_ON(new_flags & (1<<31));
......@@ -192,7 +192,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
}
if (changed && local->open_count) {
ret = local->ops->config(local_to_hw(local), changed);
ret = drv_config(local, changed);
/*
* Goal:
* HW reconfiguration should never fail, the driver has told
......@@ -276,11 +276,8 @@ void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
}
}
if (local->ops->bss_info_changed)
local->ops->bss_info_changed(local_to_hw(local),
&sdata->vif,
&sdata->vif.bss_conf,
changed);
drv_bss_info_changed(local, &sdata->vif,
&sdata->vif.bss_conf, changed);
/*
* DEPRECATED
......
......@@ -23,6 +23,7 @@
#include <asm/unaligned.h>
#include "ieee80211_i.h"
#include "driver-ops.h"
#include "rate.h"
#include "led.h"
......@@ -683,11 +684,10 @@ static void ieee80211_sta_wmm_params(struct ieee80211_local *local,
local->mdev->name, queue, aci, acm, params.aifs, params.cw_min,
params.cw_max, params.txop);
#endif
if (local->ops->conf_tx &&
local->ops->conf_tx(local_to_hw(local), queue, &params)) {
if (drv_conf_tx(local, queue, &params) && local->ops->conf_tx)
printk(KERN_DEBUG "%s: failed to set TX queue "
"parameters for queue %d\n", local->mdev->name, queue);
}
"parameters for queue %d\n", local->mdev->name,
queue);
}
}
......@@ -1982,10 +1982,8 @@ static void ieee80211_sta_reset_auth(struct ieee80211_sub_if_data *sdata)
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
struct ieee80211_local *local = sdata->local;
if (local->ops->reset_tsf) {
/* Reset own TSF to allow time synchronization work. */
local->ops->reset_tsf(local_to_hw(local));
}
/* Reset own TSF to allow time synchronization work. */
drv_reset_tsf(local);
ifmgd->wmm_last_param_set = -1; /* allow any WMM update */
......
......@@ -2,6 +2,7 @@
#include <net/rtnetlink.h>
#include "ieee80211_i.h"
#include "driver-ops.h"
#include "led.h"
int __ieee80211_suspend(struct ieee80211_hw *hw)
......@@ -43,8 +44,8 @@ int __ieee80211_suspend(struct ieee80211_hw *hw)
struct ieee80211_sub_if_data,
u.ap);
local->ops->sta_notify(hw, &sdata->vif,
STA_NOTIFY_REMOVE, &sta->sta);
drv_sta_notify(local, &sdata->vif, STA_NOTIFY_REMOVE,
&sta->sta);
}
spin_unlock_irqrestore(&local->sta_lock, flags);
}
......@@ -57,7 +58,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw)
conf.vif = &sdata->vif;
conf.type = sdata->vif.type;
conf.mac_addr = sdata->dev->dev_addr;
local->ops->remove_interface(hw, &conf);
drv_remove_interface(local, &conf);
}
}
......@@ -67,7 +68,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw)
/* stop hardware */
if (local->open_count) {
ieee80211_led_radio(local, false);
local->ops->stop(hw);
drv_stop(local);
}
return 0;
}
......
......@@ -19,6 +19,7 @@
#include <net/ieee80211_radiotap.h>