rate.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. */
  7. #ifndef IEEE80211_RATE_H
  8. #define IEEE80211_RATE_H
  9. #include <linux/netdevice.h>
  10. #include <linux/skbuff.h>
  11. #include <linux/types.h>
  12. #include <net/mac80211.h>
  13. #include "ieee80211_i.h"
  14. #include "sta_info.h"
  15. #include "driver-ops.h"
  16. struct rate_control_ref {
  17. const struct rate_control_ops *ops;
  18. void *priv;
  19. };
  20. void rate_control_get_rate(struct ieee80211_sub_if_data *sdata,
  21. struct sta_info *sta,
  22. struct ieee80211_tx_rate_control *txrc);
  23. void rate_control_tx_status(struct ieee80211_local *local,
  24. struct ieee80211_supported_band *sband,
  25. struct ieee80211_tx_status *st);
  26. void rate_control_rate_init(struct sta_info *sta);
  27. void rate_control_rate_update(struct ieee80211_local *local,
  28. struct ieee80211_supported_band *sband,
  29. struct sta_info *sta, u32 changed);
  30. static inline void *rate_control_alloc_sta(struct rate_control_ref *ref,
  31. struct sta_info *sta, gfp_t gfp)
  32. {
  33. spin_lock_init(&sta->rate_ctrl_lock);
  34. return ref->ops->alloc_sta(ref->priv, &sta->sta, gfp);
  35. }
  36. static inline void rate_control_free_sta(struct sta_info *sta)
  37. {
  38. struct rate_control_ref *ref = sta->rate_ctrl;
  39. struct ieee80211_sta *ista = &sta->sta;
  40. void *priv_sta = sta->rate_ctrl_priv;
  41. ref->ops->free_sta(ref->priv, ista, priv_sta);
  42. }
  43. static inline void rate_control_add_sta_debugfs(struct sta_info *sta)
  44. {
  45. #ifdef CONFIG_MAC80211_DEBUGFS
  46. struct rate_control_ref *ref = sta->rate_ctrl;
  47. if (ref && sta->debugfs_dir && ref->ops->add_sta_debugfs)
  48. ref->ops->add_sta_debugfs(ref->priv, sta->rate_ctrl_priv,
  49. sta->debugfs_dir);
  50. #endif
  51. }
  52. extern const struct file_operations rcname_ops;
  53. static inline void rate_control_add_debugfs(struct ieee80211_local *local)
  54. {
  55. #ifdef CONFIG_MAC80211_DEBUGFS
  56. struct dentry *debugfsdir;
  57. if (!local->rate_ctrl)
  58. return;
  59. if (!local->rate_ctrl->ops->add_debugfs)
  60. return;
  61. debugfsdir = debugfs_create_dir("rc", local->hw.wiphy->debugfsdir);
  62. local->debugfs.rcdir = debugfsdir;
  63. debugfs_create_file("name", 0400, debugfsdir,
  64. local->rate_ctrl, &rcname_ops);
  65. local->rate_ctrl->ops->add_debugfs(&local->hw, local->rate_ctrl->priv,
  66. debugfsdir);
  67. #endif
  68. }
  69. void ieee80211_check_rate_mask(struct ieee80211_sub_if_data *sdata);
  70. /* Get a reference to the rate control algorithm. If `name' is NULL, get the
  71. * first available algorithm. */
  72. int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
  73. const char *name);
  74. void rate_control_deinitialize(struct ieee80211_local *local);
  75. /* Rate control algorithms */
  76. #ifdef CONFIG_MAC80211_RC_MINSTREL
  77. int rc80211_minstrel_init(void);
  78. void rc80211_minstrel_exit(void);
  79. #else
  80. static inline int rc80211_minstrel_init(void)
  81. {
  82. return 0;
  83. }
  84. static inline void rc80211_minstrel_exit(void)
  85. {
  86. }
  87. #endif
  88. #endif /* IEEE80211_RATE_H */