530-ath9k_paprd_thermal.patch 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. --- a/drivers/net/wireless/ath/ath9k/main.c
  2. +++ b/drivers/net/wireless/ath/ath9k/main.c
  3. @@ -320,6 +320,42 @@ static void ath_paprd_activate(struct at
  4. ath9k_ps_restore(sc);
  5. }
  6. +static bool ath_paprd_send_frame(struct ath_softc *sc, struct sk_buff *skb, int chain)
  7. +{
  8. + struct ieee80211_hw *hw = sc->hw;
  9. + struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
  10. + struct ath_tx_control txctl;
  11. + int time_left;
  12. +
  13. + memset(&txctl, 0, sizeof(txctl));
  14. + txctl.txq = sc->tx.txq_map[WME_AC_BE];
  15. +
  16. + memset(tx_info, 0, sizeof(*tx_info));
  17. + tx_info->band = hw->conf.channel->band;
  18. + tx_info->flags |= IEEE80211_TX_CTL_NO_ACK;
  19. + tx_info->control.rates[0].idx = 0;
  20. + tx_info->control.rates[0].count = 1;
  21. + tx_info->control.rates[0].flags = IEEE80211_TX_RC_MCS;
  22. + tx_info->control.rates[1].idx = -1;
  23. +
  24. + init_completion(&sc->paprd_complete);
  25. + sc->paprd_pending = true;
  26. + txctl.paprd = BIT(chain);
  27. + if (ath_tx_start(hw, skb, &txctl) != 0)
  28. + return false;
  29. +
  30. + time_left = wait_for_completion_timeout(&sc->paprd_complete,
  31. + msecs_to_jiffies(ATH_PAPRD_TIMEOUT));
  32. + sc->paprd_pending = false;
  33. +
  34. + if (!time_left)
  35. + ath_dbg(ath9k_hw_common(sc->sc_ah), ATH_DBG_CALIBRATE,
  36. + "Timeout waiting for paprd training on TX chain %d\n",
  37. + chain);
  38. +
  39. + return !!time_left;
  40. +}
  41. +
  42. void ath_paprd_calibrate(struct work_struct *work)
  43. {
  44. struct ath_softc *sc = container_of(work, struct ath_softc, paprd_work);
  45. @@ -327,18 +363,12 @@ void ath_paprd_calibrate(struct work_str
  46. struct ath_hw *ah = sc->sc_ah;
  47. struct ieee80211_hdr *hdr;
  48. struct sk_buff *skb = NULL;
  49. - struct ieee80211_tx_info *tx_info;
  50. - int band = hw->conf.channel->band;
  51. - struct ieee80211_supported_band *sband = &sc->sbands[band];
  52. - struct ath_tx_control txctl;
  53. struct ath9k_hw_cal_data *caldata = ah->caldata;
  54. struct ath_common *common = ath9k_hw_common(ah);
  55. int ftype;
  56. int chain_ok = 0;
  57. int chain;
  58. int len = 1800;
  59. - int time_left;
  60. - int i;
  61. if (!caldata)
  62. return;
  63. @@ -347,8 +377,6 @@ void ath_paprd_calibrate(struct work_str
  64. if (!skb)
  65. return;
  66. - tx_info = IEEE80211_SKB_CB(skb);
  67. -
  68. skb_put(skb, len);
  69. memset(skb->data, 0, len);
  70. hdr = (struct ieee80211_hdr *)skb->data;
  71. @@ -359,9 +387,6 @@ void ath_paprd_calibrate(struct work_str
  72. memcpy(hdr->addr2, hw->wiphy->perm_addr, ETH_ALEN);
  73. memcpy(hdr->addr3, hw->wiphy->perm_addr, ETH_ALEN);
  74. - memset(&txctl, 0, sizeof(txctl));
  75. - txctl.txq = sc->tx.txq_map[WME_AC_BE];
  76. -
  77. ath9k_ps_wakeup(sc);
  78. ar9003_paprd_init_table(ah);
  79. for (chain = 0; chain < AR9300_MAX_CHAINS; chain++) {
  80. @@ -369,30 +394,19 @@ void ath_paprd_calibrate(struct work_str
  81. continue;
  82. chain_ok = 0;
  83. - memset(tx_info, 0, sizeof(*tx_info));
  84. - tx_info->band = band;
  85. - for (i = 0; i < 4; i++) {
  86. - tx_info->control.rates[i].idx = sband->n_bitrates - 1;
  87. - tx_info->control.rates[i].count = 6;
  88. - }
  89. + ath_dbg(common, ATH_DBG_CALIBRATE,
  90. + "Sending PAPRD frame for thermal measurement "
  91. + "on chain %d\n", chain);
  92. + if (!ath_paprd_send_frame(sc, skb, chain))
  93. + goto fail_paprd;
  94. - init_completion(&sc->paprd_complete);
  95. - sc->paprd_pending = true;
  96. ar9003_paprd_setup_gain_table(ah, chain);
  97. - txctl.paprd = BIT(chain);
  98. - if (ath_tx_start(hw, skb, &txctl) != 0)
  99. - break;
  100. - time_left = wait_for_completion_timeout(&sc->paprd_complete,
  101. - msecs_to_jiffies(ATH_PAPRD_TIMEOUT));
  102. - sc->paprd_pending = false;
  103. - if (!time_left) {
  104. - ath_dbg(ath9k_hw_common(ah), ATH_DBG_CALIBRATE,
  105. - "Timeout waiting for paprd training on TX chain %d\n",
  106. - chain);
  107. + ath_dbg(common, ATH_DBG_CALIBRATE,
  108. + "Sending PAPRD training frame on chain %d\n", chain);
  109. + if (!ath_paprd_send_frame(sc, skb, chain))
  110. goto fail_paprd;
  111. - }
  112. if (!ar9003_paprd_is_done(ah))
  113. break;