1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright 2002-2005, Instant802 Networks, Inc.
4 * Copyright 2005, Devicescape Software, Inc.
5 * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz>
6 * Copyright (C) 2022 Intel Corporation
9 #ifndef IEEE80211_RATE_H
10 #define IEEE80211_RATE_H
12 #include <linux/netdevice.h>
13 #include <linux/skbuff.h>
14 #include <linux/types.h>
15 #include <net/mac80211.h>
16 #include "ieee80211_i.h"
18 #include "driver-ops.h"
20 struct rate_control_ref {
21 const struct rate_control_ops *ops;
25 void rate_control_get_rate(struct ieee80211_sub_if_data *sdata,
27 struct ieee80211_tx_rate_control *txrc);
29 void rate_control_tx_status(struct ieee80211_local *local,
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,
39 static inline void *rate_control_alloc_sta(struct rate_control_ref *ref,
40 struct sta_info *sta, gfp_t gfp)
42 spin_lock_init(&sta->rate_ctrl_lock);
43 return ref->ops->alloc_sta(ref->priv, &sta->sta, gfp);
46 static inline void rate_control_free_sta(struct sta_info *sta)
48 struct rate_control_ref *ref = sta->rate_ctrl;
49 struct ieee80211_sta *ista = &sta->sta;
50 void *priv_sta = sta->rate_ctrl_priv;
52 ref->ops->free_sta(ref->priv, ista, priv_sta);
55 static inline void rate_control_add_sta_debugfs(struct sta_info *sta)
57 #ifdef CONFIG_MAC80211_DEBUGFS
58 struct rate_control_ref *ref = sta->rate_ctrl;
59 if (ref && sta->debugfs_dir && ref->ops->add_sta_debugfs)
60 ref->ops->add_sta_debugfs(ref->priv, sta->rate_ctrl_priv,
65 extern const struct file_operations rcname_ops;
67 static inline void rate_control_add_debugfs(struct ieee80211_local *local)
69 #ifdef CONFIG_MAC80211_DEBUGFS
70 struct dentry *debugfsdir;
72 if (!local->rate_ctrl)
75 if (!local->rate_ctrl->ops->add_debugfs)
78 debugfsdir = debugfs_create_dir("rc", local->hw.wiphy->debugfsdir);
79 local->debugfs.rcdir = debugfsdir;
80 debugfs_create_file("name", 0400, debugfsdir,
81 local->rate_ctrl, &rcname_ops);
83 local->rate_ctrl->ops->add_debugfs(&local->hw, local->rate_ctrl->priv,
88 void ieee80211_check_rate_mask(struct ieee80211_link_data *link);
90 /* Get a reference to the rate control algorithm. If `name' is NULL, get the
91 * first available algorithm. */
92 int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
94 void rate_control_deinitialize(struct ieee80211_local *local);
97 /* Rate control algorithms */
98 #ifdef CONFIG_MAC80211_RC_MINSTREL
99 int rc80211_minstrel_init(void);
100 void rc80211_minstrel_exit(void);
102 static inline int rc80211_minstrel_init(void)
106 static inline void rc80211_minstrel_exit(void)
112 #endif /* IEEE80211_RATE_H */