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