rate.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*
  2. * Copyright 2002-2005, Instant802 Networks, Inc.
  3. * Copyright 2005, Devicescape Software, Inc.
  4. * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #ifndef IEEE80211_RATE_H
  11. #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"
  17. #include "sta_info.h"
  18. struct rate_control_ref {
  19. struct ieee80211_local *local;
  20. struct rate_control_ops *ops;
  21. void *priv;
  22. };
  23. void rate_control_get_rate(struct ieee80211_sub_if_data *sdata,
  24. struct sta_info *sta,
  25. struct ieee80211_tx_rate_control *txrc);
  26. static inline void rate_control_tx_status(struct ieee80211_local *local,
  27. struct ieee80211_supported_band *sband,
  28. struct sta_info *sta,
  29. struct sk_buff *skb)
  30. {
  31. struct rate_control_ref *ref = local->rate_ctrl;
  32. struct ieee80211_sta *ista = &sta->sta;
  33. void *priv_sta = sta->rate_ctrl_priv;
  34. if (!ref || !test_sta_flag(sta, WLAN_STA_RATE_CONTROL))
  35. return;
  36. ref->ops->tx_status(ref->priv, sband, ista, priv_sta, skb);
  37. }
  38. static inline void rate_control_rate_init(struct sta_info *sta)
  39. {
  40. struct ieee80211_local *local = sta->sdata->local;
  41. struct rate_control_ref *ref = sta->rate_ctrl;
  42. struct ieee80211_sta *ista = &sta->sta;
  43. void *priv_sta = sta->rate_ctrl_priv;
  44. struct ieee80211_supported_band *sband;
  45. if (!ref)
  46. return;
  47. sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
  48. ref->ops->rate_init(ref->priv, sband, ista, priv_sta);
  49. set_sta_flag(sta, WLAN_STA_RATE_CONTROL);
  50. }
  51. static inline void rate_control_rate_update(struct ieee80211_local *local,
  52. struct ieee80211_supported_band *sband,
  53. struct sta_info *sta, u32 changed,
  54. enum nl80211_channel_type oper_chan_type)
  55. {
  56. struct rate_control_ref *ref = local->rate_ctrl;
  57. struct ieee80211_sta *ista = &sta->sta;
  58. void *priv_sta = sta->rate_ctrl_priv;
  59. if (ref && ref->ops->rate_update)
  60. ref->ops->rate_update(ref->priv, sband, ista,
  61. priv_sta, changed, oper_chan_type);
  62. }
  63. static inline void *rate_control_alloc_sta(struct rate_control_ref *ref,
  64. struct ieee80211_sta *sta,
  65. gfp_t gfp)
  66. {
  67. return ref->ops->alloc_sta(ref->priv, sta, gfp);
  68. }
  69. static inline void rate_control_free_sta(struct sta_info *sta)
  70. {
  71. struct rate_control_ref *ref = sta->rate_ctrl;
  72. struct ieee80211_sta *ista = &sta->sta;
  73. void *priv_sta = sta->rate_ctrl_priv;
  74. ref->ops->free_sta(ref->priv, ista, priv_sta);
  75. }
  76. static inline void rate_control_add_sta_debugfs(struct sta_info *sta)
  77. {
  78. #ifdef CONFIG_MAC80211_DEBUGFS
  79. struct rate_control_ref *ref = sta->rate_ctrl;
  80. if (ref && sta->debugfs.dir && ref->ops->add_sta_debugfs)
  81. ref->ops->add_sta_debugfs(ref->priv, sta->rate_ctrl_priv,
  82. sta->debugfs.dir);
  83. #endif
  84. }
  85. static inline void rate_control_remove_sta_debugfs(struct sta_info *sta)
  86. {
  87. #ifdef CONFIG_MAC80211_DEBUGFS
  88. struct rate_control_ref *ref = sta->rate_ctrl;
  89. if (ref && ref->ops->remove_sta_debugfs)
  90. ref->ops->remove_sta_debugfs(ref->priv, sta->rate_ctrl_priv);
  91. #endif
  92. }
  93. /* Get a reference to the rate control algorithm. If `name' is NULL, get the
  94. * first available algorithm. */
  95. int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
  96. const char *name);
  97. void rate_control_deinitialize(struct ieee80211_local *local);
  98. /* Rate control algorithms */
  99. #ifdef CONFIG_MAC80211_RC_PID
  100. extern int rc80211_pid_init(void);
  101. extern void rc80211_pid_exit(void);
  102. #else
  103. static inline int rc80211_pid_init(void)
  104. {
  105. return 0;
  106. }
  107. static inline void rc80211_pid_exit(void)
  108. {
  109. }
  110. #endif
  111. #ifdef CONFIG_MAC80211_RC_MINSTREL
  112. extern int rc80211_minstrel_init(void);
  113. extern void rc80211_minstrel_exit(void);
  114. #else
  115. static inline int rc80211_minstrel_init(void)
  116. {
  117. return 0;
  118. }
  119. static inline void rc80211_minstrel_exit(void)
  120. {
  121. }
  122. #endif
  123. #ifdef CONFIG_MAC80211_RC_MINSTREL_HT
  124. extern int rc80211_minstrel_ht_init(void);
  125. extern void rc80211_minstrel_ht_exit(void);
  126. #else
  127. static inline int rc80211_minstrel_ht_init(void)
  128. {
  129. return 0;
  130. }
  131. static inline void rc80211_minstrel_ht_exit(void)
  132. {
  133. }
  134. #endif
  135. #endif /* IEEE80211_RATE_H */