rate.h 2.9 KB

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