303-rt2x00-fix-monitor-mode-regression.patch 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. From: Eli Cooper <elicooper@gmx.com>
  2. Date: Thu, 14 Jan 2016 00:07:12 +0800
  3. Subject: [PATCH] rt2x00: fix monitor mode regression
  4. Since commit df1404650ccbfeb76a84f301f22316be0d00a864 monitor mode for rt2x00
  5. has been made effectively useless because the hardware filter is configured to
  6. drop packets whose intended recipient is not the device, regardless of the
  7. presence of monitor mode interfaces.
  8. This patch fixes this regression by adding explicit monitor mode support, and
  9. configuring the hardware filter accordingly.
  10. Signed-off-by: Eli Cooper <elicooper@gmx.com>
  11. ---
  12. --- a/drivers/net/wireless/ralink/rt2x00/rt2400pci.c
  13. +++ b/drivers/net/wireless/ralink/rt2x00/rt2400pci.c
  14. @@ -273,8 +273,10 @@ static void rt2400pci_config_filter(stru
  15. !(filter_flags & FIF_PLCPFAIL));
  16. rt2x00_set_field32(&reg, RXCSR0_DROP_CONTROL,
  17. !(filter_flags & FIF_CONTROL));
  18. - rt2x00_set_field32(&reg, RXCSR0_DROP_NOT_TO_ME, 1);
  19. + rt2x00_set_field32(&reg, RXCSR0_DROP_NOT_TO_ME,
  20. + !rt2x00dev->is_monitoring);
  21. rt2x00_set_field32(&reg, RXCSR0_DROP_TODS,
  22. + !rt2x00dev->is_monitoring &&
  23. !rt2x00dev->intf_ap_count);
  24. rt2x00_set_field32(&reg, RXCSR0_DROP_VERSION_ERROR, 1);
  25. rt2x00mmio_register_write(rt2x00dev, RXCSR0, reg);
  26. --- a/drivers/net/wireless/ralink/rt2x00/rt2500pci.c
  27. +++ b/drivers/net/wireless/ralink/rt2x00/rt2500pci.c
  28. @@ -274,8 +274,10 @@ static void rt2500pci_config_filter(stru
  29. !(filter_flags & FIF_PLCPFAIL));
  30. rt2x00_set_field32(&reg, RXCSR0_DROP_CONTROL,
  31. !(filter_flags & FIF_CONTROL));
  32. - rt2x00_set_field32(&reg, RXCSR0_DROP_NOT_TO_ME, 1);
  33. + rt2x00_set_field32(&reg, RXCSR0_DROP_NOT_TO_ME,
  34. + !rt2x00dev->is_monitoring);
  35. rt2x00_set_field32(&reg, RXCSR0_DROP_TODS,
  36. + !rt2x00dev->is_monitoring &&
  37. !rt2x00dev->intf_ap_count);
  38. rt2x00_set_field32(&reg, RXCSR0_DROP_VERSION_ERROR, 1);
  39. rt2x00_set_field32(&reg, RXCSR0_DROP_MCAST,
  40. --- a/drivers/net/wireless/ralink/rt2x00/rt2500usb.c
  41. +++ b/drivers/net/wireless/ralink/rt2x00/rt2500usb.c
  42. @@ -437,8 +437,10 @@ static void rt2500usb_config_filter(stru
  43. !(filter_flags & FIF_PLCPFAIL));
  44. rt2x00_set_field16(&reg, TXRX_CSR2_DROP_CONTROL,
  45. !(filter_flags & FIF_CONTROL));
  46. - rt2x00_set_field16(&reg, TXRX_CSR2_DROP_NOT_TO_ME, 1);
  47. + rt2x00_set_field16(&reg, TXRX_CSR2_DROP_NOT_TO_ME,
  48. + !rt2x00dev->is_monitoring);
  49. rt2x00_set_field16(&reg, TXRX_CSR2_DROP_TODS,
  50. + !rt2x00dev->is_monitoring &&
  51. !rt2x00dev->intf_ap_count);
  52. rt2x00_set_field16(&reg, TXRX_CSR2_DROP_VERSION_ERROR, 1);
  53. rt2x00_set_field16(&reg, TXRX_CSR2_DROP_MULTICAST,
  54. --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
  55. +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
  56. @@ -1490,7 +1490,8 @@ void rt2800_config_filter(struct rt2x00_
  57. !(filter_flags & FIF_FCSFAIL));
  58. rt2x00_set_field32(&reg, RX_FILTER_CFG_DROP_PHY_ERROR,
  59. !(filter_flags & FIF_PLCPFAIL));
  60. - rt2x00_set_field32(&reg, RX_FILTER_CFG_DROP_NOT_TO_ME, 1);
  61. + rt2x00_set_field32(&reg, RX_FILTER_CFG_DROP_NOT_TO_ME,
  62. + !rt2x00dev->is_monitoring);
  63. rt2x00_set_field32(&reg, RX_FILTER_CFG_DROP_NOT_MY_BSSD, 0);
  64. rt2x00_set_field32(&reg, RX_FILTER_CFG_DROP_VER_ERROR, 1);
  65. rt2x00_set_field32(&reg, RX_FILTER_CFG_DROP_MULTICAST,
  66. --- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
  67. +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
  68. @@ -844,11 +844,13 @@ struct rt2x00_dev {
  69. * - Open sta interface count.
  70. * - Association count.
  71. * - Beaconing enabled count.
  72. + * - Whether the device is monitoring.
  73. */
  74. unsigned int intf_ap_count;
  75. unsigned int intf_sta_count;
  76. unsigned int intf_associated;
  77. unsigned int intf_beaconing;
  78. + bool is_monitoring;
  79. /*
  80. * Interface combinations
  81. --- a/drivers/net/wireless/ralink/rt2x00/rt2x00config.c
  82. +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00config.c
  83. @@ -244,6 +244,16 @@ void rt2x00lib_config(struct rt2x00_dev
  84. (ieee80211_flags & IEEE80211_CONF_CHANGE_PS))
  85. cancel_delayed_work_sync(&rt2x00dev->autowakeup_work);
  86. + if (ieee80211_flags & IEEE80211_CONF_CHANGE_MONITOR) {
  87. + if (conf->flags & IEEE80211_CONF_MONITOR) {
  88. + rt2x00_dbg(rt2x00dev, "Monitor mode is enabled\n");
  89. + rt2x00dev->is_monitoring = true;
  90. + } else {
  91. + rt2x00_dbg(rt2x00dev, "Monitor mode is disabled\n");
  92. + rt2x00dev->is_monitoring = false;
  93. + }
  94. + }
  95. +
  96. /*
  97. * Start configuration.
  98. */
  99. --- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
  100. +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
  101. @@ -1204,6 +1204,7 @@ int rt2x00lib_start(struct rt2x00_dev *r
  102. rt2x00dev->intf_ap_count = 0;
  103. rt2x00dev->intf_sta_count = 0;
  104. rt2x00dev->intf_associated = 0;
  105. + rt2x00dev->is_monitoring = false;
  106. /* Enable the radio */
  107. retval = rt2x00lib_enable_radio(rt2x00dev);
  108. --- a/drivers/net/wireless/ralink/rt2x00/rt2x00mac.c
  109. +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00mac.c
  110. @@ -385,11 +385,6 @@ void rt2x00mac_configure_filter(struct i
  111. *total_flags |= FIF_PSPOLL;
  112. }
  113. - /*
  114. - * Check if there is any work left for us.
  115. - */
  116. - if (rt2x00dev->packet_filter == *total_flags)
  117. - return;
  118. rt2x00dev->packet_filter = *total_flags;
  119. rt2x00dev->ops->lib->config_filter(rt2x00dev, *total_flags);
  120. --- a/drivers/net/wireless/ralink/rt2x00/rt61pci.c
  121. +++ b/drivers/net/wireless/ralink/rt2x00/rt61pci.c
  122. @@ -530,8 +530,10 @@ static void rt61pci_config_filter(struct
  123. !(filter_flags & FIF_PLCPFAIL));
  124. rt2x00_set_field32(&reg, TXRX_CSR0_DROP_CONTROL,
  125. !(filter_flags & (FIF_CONTROL | FIF_PSPOLL)));
  126. - rt2x00_set_field32(&reg, TXRX_CSR0_DROP_NOT_TO_ME, 1);
  127. + rt2x00_set_field32(&reg, TXRX_CSR0_DROP_NOT_TO_ME,
  128. + !rt2x00dev->is_monitoring);
  129. rt2x00_set_field32(&reg, TXRX_CSR0_DROP_TO_DS,
  130. + !rt2x00dev->is_monitoring &&
  131. !rt2x00dev->intf_ap_count);
  132. rt2x00_set_field32(&reg, TXRX_CSR0_DROP_VERSION_ERROR, 1);
  133. rt2x00_set_field32(&reg, TXRX_CSR0_DROP_MULTICAST,
  134. --- a/drivers/net/wireless/ralink/rt2x00/rt73usb.c
  135. +++ b/drivers/net/wireless/ralink/rt2x00/rt73usb.c
  136. @@ -480,8 +480,10 @@ static void rt73usb_config_filter(struct
  137. !(filter_flags & FIF_PLCPFAIL));
  138. rt2x00_set_field32(&reg, TXRX_CSR0_DROP_CONTROL,
  139. !(filter_flags & (FIF_CONTROL | FIF_PSPOLL)));
  140. - rt2x00_set_field32(&reg, TXRX_CSR0_DROP_NOT_TO_ME, 1);
  141. + rt2x00_set_field32(&reg, TXRX_CSR0_DROP_NOT_TO_ME,
  142. + !rt2x00dev->is_monitoring);
  143. rt2x00_set_field32(&reg, TXRX_CSR0_DROP_TO_DS,
  144. + !rt2x00dev->is_monitoring &&
  145. !rt2x00dev->intf_ap_count);
  146. rt2x00_set_field32(&reg, TXRX_CSR0_DROP_VERSION_ERROR, 1);
  147. rt2x00_set_field32(&reg, TXRX_CSR0_DROP_MULTICAST,