rate.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. #include "driver-ops.h"
  19. struct rate_control_ref {
  20. const 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. void rate_control_tx_status(struct ieee80211_local *local,
  27. struct ieee80211_supported_band *sband,
  28. struct ieee80211_tx_status *st);
  29. void rate_control_rate_init(struct sta_info *sta);
  30. void rate_control_rate_update(struct ieee80211_local *local,
  31. struct ieee80211_supported_band *sband,
  32. struct sta_info *sta, u32 changed);
  33. static inline void *rate_control_alloc_sta(struct rate_control_ref *ref,
  34. struct sta_info *sta, gfp_t gfp)
  35. {
  36. spin_lock_init(&sta->rate_ctrl_lock);
  37. return ref->ops->alloc_sta(ref->priv, &sta->sta, gfp);
  38. }
  39. static inline void rate_control_free_sta(struct sta_info *sta)
  40. {
  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. ref->ops->free_sta(ref->priv, ista, priv_sta);
  45. }
  46. static inline void rate_control_add_sta_debugfs(struct sta_info *sta)
  47. {
  48. #ifdef CONFIG_MAC80211_DEBUGFS
  49. struct rate_control_ref *ref = sta->rate_ctrl;
  50. if (ref && sta->debugfs_dir && ref->ops->add_sta_debugfs)
  51. ref->ops->add_sta_debugfs(ref->priv, sta->rate_ctrl_priv,
  52. sta->debugfs_dir);
  53. #endif
  54. }
  55. static inline void rate_control_remove_sta_debugfs(struct sta_info *sta)
  56. {
  57. #ifdef CONFIG_MAC80211_DEBUGFS
  58. struct rate_control_ref *ref = sta->rate_ctrl;
  59. if (ref && ref->ops->remove_sta_debugfs)
  60. ref->ops->remove_sta_debugfs(ref->priv, sta->rate_ctrl_priv);
  61. #endif
  62. }
  63. void ieee80211_check_rate_mask(struct ieee80211_sub_if_data *sdata);
  64. /* Get a reference to the rate control algorithm. If `name' is NULL, get the
  65. * first available algorithm. */
  66. int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
  67. const char *name);
  68. void rate_control_deinitialize(struct ieee80211_local *local);
  69. /* Rate control algorithms */
  70. #ifdef CONFIG_MAC80211_RC_MINSTREL
  71. int rc80211_minstrel_init(void);
  72. void rc80211_minstrel_exit(void);
  73. #else
  74. static inline int rc80211_minstrel_init(void)
  75. {
  76. return 0;
  77. }
  78. static inline void rc80211_minstrel_exit(void)
  79. {
  80. }
  81. #endif
  82. #ifdef CONFIG_MAC80211_RC_MINSTREL_HT
  83. int rc80211_minstrel_ht_init(void);
  84. void rc80211_minstrel_ht_exit(void);
  85. #else
  86. static inline int rc80211_minstrel_ht_init(void)
  87. {
  88. return 0;
  89. }
  90. static inline void rc80211_minstrel_ht_exit(void)
  91. {
  92. }
  93. #endif
  94. #endif /* IEEE80211_RATE_H */