]> git.ipfire.org Git - thirdparty/linux.git/blame - net/mac80211/rate.h
Merge tag 'drm/tegra/for-5.7-fixes' of git://anongit.freedesktop.org/tegra/linux...
[thirdparty/linux.git] / net / mac80211 / rate.h
CommitLineData
d2912cb1 1/* SPDX-License-Identifier: GPL-2.0-only */
f0706e82
JB
2/*
3 * Copyright 2002-2005, Instant802 Networks, Inc.
4 * Copyright 2005, Devicescape Software, Inc.
5 * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz>
f0706e82
JB
6 */
7
8#ifndef IEEE80211_RATE_H
9#define IEEE80211_RATE_H
10
11#include <linux/netdevice.h>
12#include <linux/skbuff.h>
13#include <linux/types.h>
14#include <net/mac80211.h>
15#include "ieee80211_i.h"
16#include "sta_info.h"
8f727ef3 17#include "driver-ops.h"
f0706e82 18
f0706e82 19struct rate_control_ref {
631ad703 20 const struct rate_control_ops *ops;
f0706e82 21 void *priv;
f0706e82
JB
22};
23
4b7679a5 24void rate_control_get_rate(struct ieee80211_sub_if_data *sdata,
e6a9854b
JB
25 struct sta_info *sta,
26 struct ieee80211_tx_rate_control *txrc);
f0706e82 27
18fb84d9
FF
28void rate_control_tx_status(struct ieee80211_local *local,
29 struct ieee80211_supported_band *sband,
30 struct ieee80211_tx_status *st);
f0706e82 31
eb6d9293
DV
32void rate_control_rate_init(struct sta_info *sta);
33void rate_control_rate_update(struct ieee80211_local *local,
81cb7623 34 struct ieee80211_supported_band *sband,
eb6d9293 35 struct sta_info *sta, u32 changed);
f0706e82 36
f0706e82 37static inline void *rate_control_alloc_sta(struct rate_control_ref *ref,
35c347ac 38 struct sta_info *sta, gfp_t gfp)
f0706e82 39{
35c347ac
JB
40 spin_lock_init(&sta->rate_ctrl_lock);
41 return ref->ops->alloc_sta(ref->priv, &sta->sta, gfp);
f0706e82
JB
42}
43
4b7679a5 44static inline void rate_control_free_sta(struct sta_info *sta)
f0706e82 45{
4b7679a5
JB
46 struct rate_control_ref *ref = sta->rate_ctrl;
47 struct ieee80211_sta *ista = &sta->sta;
48 void *priv_sta = sta->rate_ctrl_priv;
49
50 ref->ops->free_sta(ref->priv, ista, priv_sta);
f0706e82
JB
51}
52
e9f207f0
JB
53static inline void rate_control_add_sta_debugfs(struct sta_info *sta)
54{
55#ifdef CONFIG_MAC80211_DEBUGFS
56 struct rate_control_ref *ref = sta->rate_ctrl;
fc4a25c5 57 if (ref && sta->debugfs_dir && ref->ops->add_sta_debugfs)
e9f207f0 58 ref->ops->add_sta_debugfs(ref->priv, sta->rate_ctrl_priv,
fc4a25c5 59 sta->debugfs_dir);
e9f207f0
JB
60#endif
61}
62
6cb5f3ea
JB
63extern const struct file_operations rcname_ops;
64
65static inline void rate_control_add_debugfs(struct ieee80211_local *local)
66{
67#ifdef CONFIG_MAC80211_DEBUGFS
68 struct dentry *debugfsdir;
69
70 if (!local->rate_ctrl)
71 return;
72
73 if (!local->rate_ctrl->ops->add_debugfs)
74 return;
75
76 debugfsdir = debugfs_create_dir("rc", local->hw.wiphy->debugfsdir);
77 local->debugfs.rcdir = debugfsdir;
78 debugfs_create_file("name", 0400, debugfsdir,
79 local->rate_ctrl, &rcname_ops);
80
81 local->rate_ctrl->ops->add_debugfs(&local->hw, local->rate_ctrl->priv,
82 debugfsdir);
83#endif
84}
85
e8e4f528
JB
86void ieee80211_check_rate_mask(struct ieee80211_sub_if_data *sdata);
87
209c671d
AS
88/* Get a reference to the rate control algorithm. If `name' is NULL, get the
89 * first available algorithm. */
ff688089
JB
90int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
91 const char *name);
92void rate_control_deinitialize(struct ieee80211_local *local);
93
4b475898
JB
94
95/* Rate control algorithms */
cccf129f 96#ifdef CONFIG_MAC80211_RC_MINSTREL
c1b1203d
JP
97int rc80211_minstrel_init(void);
98void rc80211_minstrel_exit(void);
cccf129f
FF
99#else
100static inline int rc80211_minstrel_init(void)
101{
102 return 0;
103}
104static inline void rc80211_minstrel_exit(void)
105{
106}
107#endif
108
109
f0706e82 110#endif /* IEEE80211_RATE_H */