rate.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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 <linux/kref.h>
  16. #include <net/mac80211.h>
  17. #include "ieee80211_i.h"
  18. #include "sta_info.h"
  19. struct rate_control_ref {
  20. struct ieee80211_local *local;
  21. struct rate_control_ops *ops;
  22. void *priv;
  23. struct kref kref;
  24. };
  25. /* Get a reference to the rate control algorithm. If `name' is NULL, get the
  26. * first available algorithm. */
  27. struct rate_control_ref *rate_control_alloc(const char *name,
  28. struct ieee80211_local *local);
  29. void rate_control_get_rate(struct ieee80211_sub_if_data *sdata,
  30. struct sta_info *sta,
  31. struct ieee80211_tx_rate_control *txrc);
  32. struct rate_control_ref *rate_control_get(struct rate_control_ref *ref);
  33. void rate_control_put(struct rate_control_ref *ref);
  34. static inline void rate_control_tx_status(struct ieee80211_local *local,
  35. struct ieee80211_supported_band *sband,
  36. struct sta_info *sta,
  37. struct sk_buff *skb)
  38. {
  39. struct rate_control_ref *ref = local->rate_ctrl;
  40. struct ieee80211_sta *ista = &sta->sta;
  41. void *priv_sta = sta->rate_ctrl_priv;
  42. ref->ops->tx_status(ref->priv, sband, ista, priv_sta, skb);
  43. }
  44. static inline void rate_control_rate_init(struct sta_info *sta)
  45. {
  46. struct ieee80211_local *local = sta->sdata->local;
  47. struct rate_control_ref *ref = sta->rate_ctrl;
  48. struct ieee80211_sta *ista = &sta->sta;
  49. void *priv_sta = sta->rate_ctrl_priv;
  50. struct ieee80211_supported_band *sband;
  51. sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
  52. ref->ops->rate_init(ref->priv, sband, ista, priv_sta);
  53. }
  54. static inline void *rate_control_alloc_sta(struct rate_control_ref *ref,
  55. struct ieee80211_sta *sta,
  56. gfp_t gfp)
  57. {
  58. return ref->ops->alloc_sta(ref->priv, sta, gfp);
  59. }
  60. static inline void rate_control_free_sta(struct sta_info *sta)
  61. {
  62. struct rate_control_ref *ref = sta->rate_ctrl;
  63. struct ieee80211_sta *ista = &sta->sta;
  64. void *priv_sta = sta->rate_ctrl_priv;
  65. ref->ops->free_sta(ref->priv, ista, priv_sta);
  66. }
  67. static inline void rate_control_add_sta_debugfs(struct sta_info *sta)
  68. {
  69. #ifdef CONFIG_MAC80211_DEBUGFS
  70. struct rate_control_ref *ref = sta->rate_ctrl;
  71. if (sta->debugfs.dir && ref->ops->add_sta_debugfs)
  72. ref->ops->add_sta_debugfs(ref->priv, sta->rate_ctrl_priv,
  73. sta->debugfs.dir);
  74. #endif
  75. }
  76. static inline void rate_control_remove_sta_debugfs(struct sta_info *sta)
  77. {
  78. #ifdef CONFIG_MAC80211_DEBUGFS
  79. struct rate_control_ref *ref = sta->rate_ctrl;
  80. if (ref->ops->remove_sta_debugfs)
  81. ref->ops->remove_sta_debugfs(ref->priv, sta->rate_ctrl_priv);
  82. #endif
  83. }
  84. /* functions for rate control related to a device */
  85. int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
  86. const char *name);
  87. void rate_control_deinitialize(struct ieee80211_local *local);
  88. /* Rate control algorithms */
  89. #ifdef CONFIG_MAC80211_RC_PID
  90. extern int rc80211_pid_init(void);
  91. extern void rc80211_pid_exit(void);
  92. #else
  93. static inline int rc80211_pid_init(void)
  94. {
  95. return 0;
  96. }
  97. static inline void rc80211_pid_exit(void)
  98. {
  99. }
  100. #endif
  101. #ifdef CONFIG_MAC80211_RC_MINSTREL
  102. extern int rc80211_minstrel_init(void);
  103. extern void rc80211_minstrel_exit(void);
  104. #else
  105. static inline int rc80211_minstrel_init(void)
  106. {
  107. return 0;
  108. }
  109. static inline void rc80211_minstrel_exit(void)
  110. {
  111. }
  112. #endif
  113. #endif /* IEEE80211_RATE_H */