dynack.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * Copyright (c) 2014, Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef DYNACK_H
  17. #define DYNACK_H
  18. #define ATH_DYN_BUF 64
  19. struct ath_hw;
  20. struct ath_node;
  21. /**
  22. * struct ath_dyn_rxbuf - ACK frame ring buffer
  23. * @h_rb: ring buffer head
  24. * @t_rb: ring buffer tail
  25. * @tstamp: ACK RX timestamp buffer
  26. */
  27. struct ath_dyn_rxbuf {
  28. u16 h_rb, t_rb;
  29. u32 tstamp[ATH_DYN_BUF];
  30. };
  31. struct ts_info {
  32. u32 tstamp;
  33. u32 dur;
  34. };
  35. struct haddr_pair {
  36. u8 h_dest[ETH_ALEN];
  37. u8 h_src[ETH_ALEN];
  38. };
  39. /**
  40. * struct ath_dyn_txbuf - tx frame ring buffer
  41. * @h_rb: ring buffer head
  42. * @t_rb: ring buffer tail
  43. * @addr: dest/src address pair for a given TX frame
  44. * @ts: TX frame timestamp buffer
  45. */
  46. struct ath_dyn_txbuf {
  47. u16 h_rb, t_rb;
  48. struct haddr_pair addr[ATH_DYN_BUF];
  49. struct ts_info ts[ATH_DYN_BUF];
  50. };
  51. /**
  52. * struct ath_dynack - dynack processing info
  53. * @enabled: enable dyn ack processing
  54. * @ackto: current ACK timeout
  55. * @lto: last ACK timeout computation
  56. * @nodes: ath_node linked list
  57. * @qlock: ts queue spinlock
  58. * @ack_rbf: ACK ts ring buffer
  59. * @st_rbf: status ts ring buffer
  60. */
  61. struct ath_dynack {
  62. bool enabled;
  63. int ackto;
  64. unsigned long lto;
  65. struct list_head nodes;
  66. /* protect timestamp queue access */
  67. spinlock_t qlock;
  68. struct ath_dyn_rxbuf ack_rbf;
  69. struct ath_dyn_txbuf st_rbf;
  70. };
  71. #if defined(CONFIG_ATH9K_DYNACK)
  72. void ath_dynack_reset(struct ath_hw *ah);
  73. void ath_dynack_node_init(struct ath_hw *ah, struct ath_node *an);
  74. void ath_dynack_node_deinit(struct ath_hw *ah, struct ath_node *an);
  75. void ath_dynack_init(struct ath_hw *ah);
  76. void ath_dynack_sample_ack_ts(struct ath_hw *ah, struct sk_buff *skb, u32 ts);
  77. void ath_dynack_sample_tx_ts(struct ath_hw *ah, struct sk_buff *skb,
  78. struct ath_tx_status *ts);
  79. #else
  80. static inline void ath_dynack_init(struct ath_hw *ah) {}
  81. static inline void ath_dynack_node_init(struct ath_hw *ah,
  82. struct ath_node *an) {}
  83. static inline void ath_dynack_node_deinit(struct ath_hw *ah,
  84. struct ath_node *an) {}
  85. static inline void ath_dynack_sample_ack_ts(struct ath_hw *ah,
  86. struct sk_buff *skb, u32 ts) {}
  87. static inline void ath_dynack_sample_tx_ts(struct ath_hw *ah,
  88. struct sk_buff *skb,
  89. struct ath_tx_status *ts) {}
  90. #endif
  91. #endif /* DYNACK_H */