rate.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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 ieee80211_supported_band *sband,
  31. struct sta_info *sta, struct sk_buff *skb,
  32. struct rate_selection *sel);
  33. struct rate_control_ref *rate_control_get(struct rate_control_ref *ref);
  34. void rate_control_put(struct rate_control_ref *ref);
  35. static inline void rate_control_tx_status(struct ieee80211_local *local,
  36. struct ieee80211_supported_band *sband,
  37. struct sta_info *sta,
  38. struct sk_buff *skb)
  39. {
  40. struct rate_control_ref *ref = local->rate_ctrl;
  41. struct ieee80211_sta *ista = &sta->sta;
  42. void *priv_sta = sta->rate_ctrl_priv;
  43. ref->ops->tx_status(ref->priv, sband, ista, priv_sta, skb);
  44. }
  45. static inline void rate_control_rate_init(struct sta_info *sta)
  46. {
  47. struct ieee80211_local *local = sta->sdata->local;
  48. struct rate_control_ref *ref = sta->rate_ctrl;
  49. struct ieee80211_sta *ista = &sta->sta;
  50. void *priv_sta = sta->rate_ctrl_priv;
  51. struct ieee80211_supported_band *sband;
  52. sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
  53. ref->ops->rate_init(ref->priv, sband, ista, priv_sta);
  54. }
  55. static inline void rate_control_clear(struct ieee80211_local *local)
  56. {
  57. struct rate_control_ref *ref = local->rate_ctrl;
  58. ref->ops->clear(ref->priv);
  59. }
  60. static inline void *rate_control_alloc_sta(struct rate_control_ref *ref,
  61. struct ieee80211_sta *sta,
  62. gfp_t gfp)
  63. {
  64. return ref->ops->alloc_sta(ref->priv, sta, gfp);
  65. }
  66. static inline void rate_control_free_sta(struct sta_info *sta)
  67. {
  68. struct rate_control_ref *ref = sta->rate_ctrl;
  69. struct ieee80211_sta *ista = &sta->sta;
  70. void *priv_sta = sta->rate_ctrl_priv;
  71. ref->ops->free_sta(ref->priv, ista, priv_sta);
  72. }
  73. static inline void rate_control_add_sta_debugfs(struct sta_info *sta)
  74. {
  75. #ifdef CONFIG_MAC80211_DEBUGFS
  76. struct rate_control_ref *ref = sta->rate_ctrl;
  77. if (sta->debugfs.dir && ref->ops->add_sta_debugfs)
  78. ref->ops->add_sta_debugfs(ref->priv, sta->rate_ctrl_priv,
  79. sta->debugfs.dir);
  80. #endif
  81. }
  82. static inline void rate_control_remove_sta_debugfs(struct sta_info *sta)
  83. {
  84. #ifdef CONFIG_MAC80211_DEBUGFS
  85. struct rate_control_ref *ref = sta->rate_ctrl;
  86. if (ref->ops->remove_sta_debugfs)
  87. ref->ops->remove_sta_debugfs(ref->priv, sta->rate_ctrl_priv);
  88. #endif
  89. }
  90. /* functions for rate control related to a device */
  91. int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
  92. const char *name);
  93. void rate_control_deinitialize(struct ieee80211_local *local);
  94. /* Rate control algorithms */
  95. #ifdef CONFIG_MAC80211_RC_PID
  96. extern int rc80211_pid_init(void);
  97. extern void rc80211_pid_exit(void);
  98. #else
  99. static inline int rc80211_pid_init(void)
  100. {
  101. return 0;
  102. }
  103. static inline void rc80211_pid_exit(void)
  104. {
  105. }
  106. #endif
  107. #ifdef CONFIG_MAC80211_RC_MINSTREL
  108. extern int rc80211_minstrel_init(void);
  109. extern void rc80211_minstrel_exit(void);
  110. #else
  111. static inline int rc80211_minstrel_init(void)
  112. {
  113. return 0;
  114. }
  115. static inline void rc80211_minstrel_exit(void)
  116. {
  117. }
  118. #endif
  119. #endif /* IEEE80211_RATE_H */