octeontx2-pf: Fix error return code in otx2_probe()
[linux/fpc-iii.git] / net / mac80211 / rate.h
blob79b44d3db171e9ddbc1d6e2de041d88e350696ac
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Copyright 2002-2005, Instant802 Networks, Inc.
4 * Copyright 2005, Devicescape Software, Inc.
5 * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz>
6 */
8 #ifndef IEEE80211_RATE_H
9 #define IEEE80211_RATE_H
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"
17 #include "driver-ops.h"
19 struct rate_control_ref {
20 const struct rate_control_ops *ops;
21 void *priv;
24 void rate_control_get_rate(struct ieee80211_sub_if_data *sdata,
25 struct sta_info *sta,
26 struct ieee80211_tx_rate_control *txrc);
28 void rate_control_tx_status(struct ieee80211_local *local,
29 struct ieee80211_supported_band *sband,
30 struct ieee80211_tx_status *st);
32 void rate_control_rate_init(struct sta_info *sta);
33 void rate_control_rate_update(struct ieee80211_local *local,
34 struct ieee80211_supported_band *sband,
35 struct sta_info *sta, u32 changed);
37 static inline void *rate_control_alloc_sta(struct rate_control_ref *ref,
38 struct sta_info *sta, gfp_t gfp)
40 spin_lock_init(&sta->rate_ctrl_lock);
41 return ref->ops->alloc_sta(ref->priv, &sta->sta, gfp);
44 static inline void rate_control_free_sta(struct sta_info *sta)
46 struct rate_control_ref *ref = sta->rate_ctrl;
47 struct ieee80211_sta *ista = &sta->sta;
48 void *priv_sta = sta->rate_ctrl_priv;
50 ref->ops->free_sta(ref->priv, ista, priv_sta);
53 static inline void rate_control_add_sta_debugfs(struct sta_info *sta)
55 #ifdef CONFIG_MAC80211_DEBUGFS
56 struct rate_control_ref *ref = sta->rate_ctrl;
57 if (ref && sta->debugfs_dir && ref->ops->add_sta_debugfs)
58 ref->ops->add_sta_debugfs(ref->priv, sta->rate_ctrl_priv,
59 sta->debugfs_dir);
60 #endif
63 extern const struct file_operations rcname_ops;
65 static inline void rate_control_add_debugfs(struct ieee80211_local *local)
67 #ifdef CONFIG_MAC80211_DEBUGFS
68 struct dentry *debugfsdir;
70 if (!local->rate_ctrl)
71 return;
73 if (!local->rate_ctrl->ops->add_debugfs)
74 return;
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);
81 local->rate_ctrl->ops->add_debugfs(&local->hw, local->rate_ctrl->priv,
82 debugfsdir);
83 #endif
86 void ieee80211_check_rate_mask(struct ieee80211_sub_if_data *sdata);
88 /* Get a reference to the rate control algorithm. If `name' is NULL, get the
89 * first available algorithm. */
90 int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
91 const char *name);
92 void rate_control_deinitialize(struct ieee80211_local *local);
95 /* Rate control algorithms */
96 #ifdef CONFIG_MAC80211_RC_MINSTREL
97 int rc80211_minstrel_init(void);
98 void rc80211_minstrel_exit(void);
99 #else
100 static inline int rc80211_minstrel_init(void)
102 return 0;
104 static inline void rc80211_minstrel_exit(void)
107 #endif
110 #endif /* IEEE80211_RATE_H */