[PATCH v4 4/4] wcn36xx: Implement print_reg indication

2016-09-06 Thread Bjorn Andersson
Some firmware versions sends a "print register indication", handle this
by printing out the content.

Cc: Nicolas Dechesne 
Signed-off-by: Bjorn Andersson 
---

Changes since v3:
- Rebased separate patch onto this series

 drivers/net/wireless/ath/wcn36xx/hal.h | 16 
 drivers/net/wireless/ath/wcn36xx/smd.c | 30 ++
 2 files changed, 46 insertions(+)

diff --git a/drivers/net/wireless/ath/wcn36xx/hal.h 
b/drivers/net/wireless/ath/wcn36xx/hal.h
index 4f87ef1e1eb8..b765c647319d 100644
--- a/drivers/net/wireless/ath/wcn36xx/hal.h
+++ b/drivers/net/wireless/ath/wcn36xx/hal.h
@@ -350,6 +350,8 @@ enum wcn36xx_hal_host_msg_type {
 
WCN36XX_HAL_AVOID_FREQ_RANGE_IND = 233,
 
+   WCN36XX_HAL_PRINT_REG_INFO_IND = 259,
+
WCN36XX_HAL_MSG_MAX = WCN36XX_HAL_MSG_TYPE_MAX_ENUM_SIZE
 };
 
@@ -4703,4 +4705,18 @@ struct stats_class_b_ind {
u32 rx_time_total;
 };
 
+/* WCN36XX_HAL_PRINT_REG_INFO_IND */
+struct wcn36xx_hal_print_reg_info_ind {
+   struct wcn36xx_hal_msg_header header;
+
+   u32 count;
+   u32 scenario;
+   u32 reason;
+
+   struct {
+   u32 addr;
+   u32 value;
+   } regs[];
+} __packed;
+
 #endif /* _HAL_H_ */
diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c 
b/drivers/net/wireless/ath/wcn36xx/smd.c
index be5e5ea1e5c3..1c2966f7db7a 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.c
+++ b/drivers/net/wireless/ath/wcn36xx/smd.c
@@ -2109,6 +2109,30 @@ static int wcn36xx_smd_delete_sta_context_ind(struct 
wcn36xx *wcn,
return -ENOENT;
 }
 
+static int wcn36xx_smd_print_reg_info_ind(struct wcn36xx *wcn,
+ void *buf,
+ size_t len)
+{
+   struct wcn36xx_hal_print_reg_info_ind *rsp = buf;
+   int i;
+
+   if (len < sizeof(*rsp)) {
+   wcn36xx_warn("Corrupted print reg info indication\n");
+   return -EIO;
+   }
+
+   wcn36xx_dbg(WCN36XX_DBG_HAL,
+   "reginfo indication, scenario: 0x%x reason: 0x%x\n",
+   rsp->scenario, rsp->reason);
+
+   for (i = 0; i < rsp->count; i++) {
+   wcn36xx_dbg(WCN36XX_DBG_HAL, "\t0x%x: 0x%x\n",
+   rsp->regs[i].addr, rsp->regs[i].value);
+   }
+
+   return 0;
+}
+
 int wcn36xx_smd_update_cfg(struct wcn36xx *wcn, u32 cfg_id, u32 value)
 {
struct wcn36xx_hal_update_cfg_req_msg msg_body, *body;
@@ -2237,6 +2261,7 @@ int wcn36xx_smd_rsp_process(struct qcom_smd_channel 
*channel,
case WCN36XX_HAL_OTA_TX_COMPL_IND:
case WCN36XX_HAL_MISSED_BEACON_IND:
case WCN36XX_HAL_DELETE_STA_CONTEXT_IND:
+   case WCN36XX_HAL_PRINT_REG_INFO_IND:
msg_ind = kmalloc(sizeof(*msg_ind) + len, GFP_ATOMIC);
if (!msg_ind) {
wcn36xx_err("Run out of memory while handling SMD_EVENT 
(%d)\n",
@@ -2296,6 +2321,11 @@ static void wcn36xx_ind_smd_work(struct work_struct 
*work)
   hal_ind_msg->msg,
   hal_ind_msg->msg_len);
break;
+   case WCN36XX_HAL_PRINT_REG_INFO_IND:
+   wcn36xx_smd_print_reg_info_ind(wcn,
+  hal_ind_msg->msg,
+  hal_ind_msg->msg_len);
+   break;
default:
wcn36xx_err("SMD_EVENT (%d) not supported\n",
  msg_header->msg_type);
-- 
2.5.0



[PATCH v4 2/4] wcn36xx: Transition driver to SMD client

2016-09-06 Thread Bjorn Andersson
The wcn36xx wifi driver follows the life cycle of the WLAN_CTRL SMD
channel, as such it should be a SMD client. This patch makes this
transition, now that we have the necessary frameworks available.

Signed-off-by: Bjorn Andersson 
---

Changes since v3:
- Made msg_header const in wcn36xx_smd_rsp_process()

Changes since v2:
- Correct the call to the new ieee80211_scan_completed()

 drivers/net/wireless/ath/wcn36xx/dxe.c | 16 +++---
 drivers/net/wireless/ath/wcn36xx/main.c| 79 --
 drivers/net/wireless/ath/wcn36xx/smd.c | 31 +---
 drivers/net/wireless/ath/wcn36xx/smd.h |  5 ++
 drivers/net/wireless/ath/wcn36xx/wcn36xx.h | 21 +++-
 5 files changed, 86 insertions(+), 66 deletions(-)

diff --git a/drivers/net/wireless/ath/wcn36xx/dxe.c 
b/drivers/net/wireless/ath/wcn36xx/dxe.c
index 231fd022f0f5..87dfdaf9044c 100644
--- a/drivers/net/wireless/ath/wcn36xx/dxe.c
+++ b/drivers/net/wireless/ath/wcn36xx/dxe.c
@@ -23,6 +23,7 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include 
+#include 
 #include "wcn36xx.h"
 #include "txrx.h"
 
@@ -151,9 +152,12 @@ int wcn36xx_dxe_alloc_ctl_blks(struct wcn36xx *wcn)
goto out_err;
 
/* Initialize SMSM state  Clear TX Enable RING EMPTY STATE */
-   ret = wcn->ctrl_ops->smsm_change_state(
-   WCN36XX_SMSM_WLAN_TX_ENABLE,
-   WCN36XX_SMSM_WLAN_TX_RINGS_EMPTY);
+   ret = qcom_smem_state_update_bits(wcn->tx_enable_state,
+ WCN36XX_SMSM_WLAN_TX_ENABLE |
+ WCN36XX_SMSM_WLAN_TX_RINGS_EMPTY,
+ WCN36XX_SMSM_WLAN_TX_RINGS_EMPTY);
+   if (ret)
+   goto out_err;
 
return 0;
 
@@ -678,9 +682,9 @@ int wcn36xx_dxe_tx_frame(struct wcn36xx *wcn,
 * notify chip about new frame through SMSM bus.
 */
if (is_low &&  vif_priv->pw_state == WCN36XX_BMPS) {
-   wcn->ctrl_ops->smsm_change_state(
- 0,
- WCN36XX_SMSM_WLAN_TX_ENABLE);
+   qcom_smem_state_update_bits(wcn->tx_rings_empty_state,
+   WCN36XX_SMSM_WLAN_TX_ENABLE,
+   WCN36XX_SMSM_WLAN_TX_ENABLE);
} else {
/* indicate End Of Packet and generate interrupt on descriptor
 * done.
diff --git a/drivers/net/wireless/ath/wcn36xx/main.c 
b/drivers/net/wireless/ath/wcn36xx/main.c
index e1d59da2ad20..3c2522b07c90 100644
--- a/drivers/net/wireless/ath/wcn36xx/main.c
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
@@ -21,6 +21,10 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
 #include "wcn36xx.h"
 
 unsigned int wcn36xx_dbg_mask;
@@ -1058,8 +1062,7 @@ static int wcn36xx_platform_get_resources(struct wcn36xx 
*wcn,
int ret;
 
/* Set TX IRQ */
-   res = platform_get_resource_byname(pdev, IORESOURCE_IRQ,
-  "wcnss_wlantx_irq");
+   res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "tx");
if (!res) {
wcn36xx_err("failed to get tx_irq\n");
return -ENOENT;
@@ -1067,14 +1070,29 @@ static int wcn36xx_platform_get_resources(struct 
wcn36xx *wcn,
wcn->tx_irq = res->start;
 
/* Set RX IRQ */
-   res = platform_get_resource_byname(pdev, IORESOURCE_IRQ,
-  "wcnss_wlanrx_irq");
+   res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "rx");
if (!res) {
wcn36xx_err("failed to get rx_irq\n");
return -ENOENT;
}
wcn->rx_irq = res->start;
 
+   /* Acquire SMSM tx enable handle */
+   wcn->tx_enable_state = qcom_smem_state_get(>dev,
+   "tx-enable", >tx_enable_state_bit);
+   if (IS_ERR(wcn->tx_enable_state)) {
+   wcn36xx_err("failed to get tx-enable state\n");
+   return PTR_ERR(wcn->tx_enable_state);
+   }
+
+   /* Acquire SMSM tx rings empty handle */
+   wcn->tx_rings_empty_state = qcom_smem_state_get(>dev,
+   "tx-rings-empty", >tx_rings_empty_state_bit);
+   if (IS_ERR(wcn->tx_rings_empty_state)) {
+   wcn36xx_err("failed to get tx-rings-empty state\n");
+   return PTR_ERR(wcn->tx_rings_empty_state);
+   }
+
mmio_node = of_parse_phandle(pdev->dev.parent->of_node, "qcom,mmio", 0);
if (!mmio_node) {
wcn36xx_err("failed to acquire qcom,mmio reference\n");
@@ -1115,11 +1133,14 @@ static int wcn36xx_probe(struct platform_device *pdev)
 {
struct ieee80211_hw *hw;
struct wcn36xx *wcn;
+   void *wcnss;
int ret;
-   u8 addr[ETH_ALEN];
+   const u8 *addr;
 
wcn36xx_dbg(WCN36XX_DBG_MAC, "platform probe\n");
 
+   

[PATCH v4 1/4] soc: qcom: wcnss_ctrl: Stub wcnss_ctrl API

2016-09-06 Thread Bjorn Andersson
Stub the wcnss_ctrl API to allow compile testing wcnss function drivers.

Cc: Marcel Holtmann 
Signed-off-by: Bjorn Andersson 
---

There are no other pending changes colliding with this, so if Andy is okay with
this it could be merged through Kalle's tree - together with the other patches.

Marcel, with this applied we can drop the depends on QCOM_SMD from the
btqcomsmd driver as well.

Changes since v3:
- Added this patch to allow compile testing without SMD support after patch 2

 include/linux/soc/qcom/wcnss_ctrl.h | 13 +
 1 file changed, 13 insertions(+)

diff --git a/include/linux/soc/qcom/wcnss_ctrl.h 
b/include/linux/soc/qcom/wcnss_ctrl.h
index a37bc5538f19..eab64976a73b 100644
--- a/include/linux/soc/qcom/wcnss_ctrl.h
+++ b/include/linux/soc/qcom/wcnss_ctrl.h
@@ -3,6 +3,19 @@
 
 #include 
 
+#if IS_ENABLED(CONFIG_QCOM_WCNSS_CTRL)
+
 struct qcom_smd_channel *qcom_wcnss_open_channel(void *wcnss, const char 
*name, qcom_smd_cb_t cb);
 
+#else
+
+static inline struct qcom_smd_channel*
+qcom_wcnss_open_channel(void *wcnss, const char *name, qcom_smd_cb_t cb)
+{
+   WARN_ON(1);
+   return ERR_PTR(-ENXIO);
+}
+
+#endif
+
 #endif
-- 
2.5.0



[PATCH v4 3/4] wcn36xx: Implement firmware assisted scan

2016-09-06 Thread Bjorn Andersson
Using the software based channel scan mechanism from mac80211 keeps us
offline for 10-15 second, we should instead issue a start_scan/end_scan
on each channel reducing this time.

Signed-off-by: Bjorn Andersson 
---

Changes since v3:
- None
Changes since v2:
- Match prototype change of ieee80211_scan_completed()

 drivers/net/wireless/ath/wcn36xx/main.c| 64 +-
 drivers/net/wireless/ath/wcn36xx/smd.c |  8 ++--
 drivers/net/wireless/ath/wcn36xx/smd.h |  4 +-
 drivers/net/wireless/ath/wcn36xx/txrx.c| 19 ++---
 drivers/net/wireless/ath/wcn36xx/wcn36xx.h |  9 +
 5 files changed, 81 insertions(+), 23 deletions(-)

diff --git a/drivers/net/wireless/ath/wcn36xx/main.c 
b/drivers/net/wireless/ath/wcn36xx/main.c
index 3c2522b07c90..96a9584edcbb 100644
--- a/drivers/net/wireless/ath/wcn36xx/main.c
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
@@ -568,23 +568,59 @@ out:
return ret;
 }
 
-static void wcn36xx_sw_scan_start(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif,
- const u8 *mac_addr)
+static void wcn36xx_hw_scan_worker(struct work_struct *work)
 {
-   struct wcn36xx *wcn = hw->priv;
+   struct wcn36xx *wcn = container_of(work, struct wcn36xx, scan_work);
+   struct cfg80211_scan_request *req = wcn->scan_req;
+   u8 channels[WCN36XX_HAL_PNO_MAX_NETW_CHANNELS_EX];
+   struct cfg80211_scan_info scan_info = {};
+   int i;
+
+   wcn36xx_dbg(WCN36XX_DBG_MAC, "mac80211 scan %d channels worker\n", 
req->n_channels);
+
+   for (i = 0; i < req->n_channels; i++)
+   channels[i] = req->channels[i]->hw_value;
+
+   wcn36xx_smd_update_scan_params(wcn, channels, req->n_channels);
 
wcn36xx_smd_init_scan(wcn, HAL_SYS_MODE_SCAN);
-   wcn36xx_smd_start_scan(wcn);
+   for (i = 0; i < req->n_channels; i++) {
+   wcn->scan_freq = req->channels[i]->center_freq;
+   wcn->scan_band = req->channels[i]->band;
+
+   wcn36xx_smd_start_scan(wcn, req->channels[i]->hw_value);
+   msleep(30);
+   wcn36xx_smd_end_scan(wcn, req->channels[i]->hw_value);
+
+   wcn->scan_freq = 0;
+   }
+   wcn36xx_smd_finish_scan(wcn, HAL_SYS_MODE_SCAN);
+
+   scan_info.aborted = false;
+   ieee80211_scan_completed(wcn->hw, _info);
+
+   mutex_lock(>scan_lock);
+   wcn->scan_req = NULL;
+   mutex_unlock(>scan_lock);
 }
 
-static void wcn36xx_sw_scan_complete(struct ieee80211_hw *hw,
-struct ieee80211_vif *vif)
+static int wcn36xx_hw_scan(struct ieee80211_hw *hw,
+  struct ieee80211_vif *vif,
+  struct ieee80211_scan_request *hw_req)
 {
struct wcn36xx *wcn = hw->priv;
 
-   wcn36xx_smd_end_scan(wcn);
-   wcn36xx_smd_finish_scan(wcn, HAL_SYS_MODE_SCAN);
+   mutex_lock(>scan_lock);
+   if (wcn->scan_req) {
+   mutex_unlock(>scan_lock);
+   return -EBUSY;
+   }
+   wcn->scan_req = _req->req;
+   mutex_unlock(>scan_lock);
+
+   schedule_work(>scan_work);
+
+   return 0;
 }
 
 static void wcn36xx_update_allowed_rates(struct ieee80211_sta *sta,
@@ -997,8 +1033,7 @@ static const struct ieee80211_ops wcn36xx_ops = {
.configure_filter   = wcn36xx_configure_filter,
.tx = wcn36xx_tx,
.set_key= wcn36xx_set_key,
-   .sw_scan_start  = wcn36xx_sw_scan_start,
-   .sw_scan_complete   = wcn36xx_sw_scan_complete,
+   .hw_scan= wcn36xx_hw_scan,
.bss_info_changed   = wcn36xx_bss_info_changed,
.set_rts_threshold  = wcn36xx_set_rts_threshold,
.sta_add= wcn36xx_sta_add,
@@ -1023,6 +1058,7 @@ static int wcn36xx_init_ieee80211(struct wcn36xx *wcn)
ieee80211_hw_set(wcn->hw, SUPPORTS_PS);
ieee80211_hw_set(wcn->hw, SIGNAL_DBM);
ieee80211_hw_set(wcn->hw, HAS_RATE_CONTROL);
+   ieee80211_hw_set(wcn->hw, SINGLE_SCAN_ON_ALL_BANDS);
 
wcn->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
BIT(NL80211_IFTYPE_AP) |
@@ -1032,6 +1068,9 @@ static int wcn36xx_init_ieee80211(struct wcn36xx *wcn)
wcn->hw->wiphy->bands[NL80211_BAND_2GHZ] = _band_2ghz;
wcn->hw->wiphy->bands[NL80211_BAND_5GHZ] = _band_5ghz;
 
+   wcn->hw->wiphy->max_scan_ssids = WCN36XX_MAX_SCAN_SSIDS;
+   wcn->hw->wiphy->max_scan_ie_len = WCN36XX_MAX_SCAN_IE_LEN;
+
wcn->hw->wiphy->cipher_suites = cipher_suites;
wcn->hw->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites);
 
@@ -1152,6 +1191,9 @@ static int wcn36xx_probe(struct platform_device *pdev)
wcn->hw = hw;
wcn->dev = >dev;
mutex_init(>hal_mutex);
+   mutex_init(>scan_lock);
+
+   INIT_WORK(>scan_work, wcn36xx_hw_scan_worker);
 

Re: [PATCH v8] mac80211: Move reorder-sensitive TX handlers to after TXQ dequeue.

2016-09-06 Thread Felix Fietkau
On 2016-09-06 13:44, Toke Høiland-Jørgensen wrote:
> The TXQ intermediate queues can cause packet reordering when more than
> one flow is active to a single station. Since some of the wifi-specific
> packet handling (notably sequence number and encryption handling) is
> sensitive to re-ordering, things break if they are applied before the
> TXQ.
> 
> This splits up the TX handlers and fast_xmit logic into two parts: An
> early part and a late part. The former is applied before TXQ enqueue,
> and the latter after dequeue. The non-TXQ path just applies both parts
> at once.
> 
> Because fragments shouldn't be split up or reordered, the fragmentation
> handler is run after dequeue. Any fragments are then kept in the TXQ and
> on subsequent dequeues they take precedence over dequeueing from the FQ
> structure.
> 
> This approach avoids having to scatter special cases for when TXQ is
> enabled, at the cost of making the fast_xmit and TX handler code
> slightly more complex.
> 
> Signed-off-by: Toke Høiland-Jørgensen 
Acked-by: Felix Fietkau 



[PATCH v6 3/3] ath9k: parse the device configuration from an OF node

2016-09-06 Thread Martin Blumenstingl
This allows configuring ath9k based PCI devices using devicetree.
There is some out-of-tree code to "convert devicetree to
ath9k_platform_data" (for example in OpenWrt and LEDE) which becomes
obsolete with this patch.

Signed-off-by: Martin Blumenstingl 
---
 drivers/net/wireless/ath/ath9k/init.c | 51 +++
 1 file changed, 51 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/init.c 
b/drivers/net/wireless/ath/ath9k/init.c
index cfa3fe8..c123145 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -20,6 +20,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 
@@ -555,6 +557,51 @@ static int ath9k_init_platform(struct ath_softc *sc)
return 0;
 }
 
+static int ath9k_of_init(struct ath_softc *sc)
+{
+   struct device_node *np = sc->dev->of_node;
+   struct ath_hw *ah = sc->sc_ah;
+   struct ath_common *common = ath9k_hw_common(ah);
+   enum ath_bus_type bus_type = common->bus_ops->ath_bus_type;
+   const char *mac;
+   char eeprom_name[100];
+   int ret;
+
+   if (!of_device_is_available(np))
+   return 0;
+
+   ath_dbg(common, CONFIG, "parsing configuration from OF node\n");
+
+   if (of_property_read_bool(np, "qca,clk-25mhz"))
+   ah->is_clk_25mhz = true;
+
+   if (of_property_read_bool(np, "qca,disable-2ghz"))
+   ah->disable_2ghz = true;
+
+   if (of_property_read_bool(np, "qca,disable-5ghz"))
+   ah->disable_5ghz = true;
+
+   if (of_property_read_bool(np, "qca,no-eeprom")) {
+   /* ath9k-eeprom--.bin */
+   scnprintf(eeprom_name, sizeof(eeprom_name),
+ "ath9k-eeprom-%s-%s.bin",
+ ath_bus_type_to_string(bus_type), dev_name(ah->dev));
+
+   ret = ath9k_eeprom_request(sc, eeprom_name);
+   if (ret)
+   return ret;
+   }
+
+   mac = of_get_mac_address(np);
+   if (mac)
+   ether_addr_copy(common->macaddr, mac);
+
+   ah->ah_flags &= ~AH_USE_EEPROM;
+   ah->ah_flags |= AH_NO_EEP_SWAP;
+
+   return 0;
+}
+
 static int ath9k_init_softc(u16 devid, struct ath_softc *sc,
const struct ath_bus_ops *bus_ops)
 {
@@ -611,6 +658,10 @@ static int ath9k_init_softc(u16 devid, struct ath_softc 
*sc,
if (ret)
return ret;
 
+   ret = ath9k_of_init(sc);
+   if (ret)
+   return ret;
+
if (ath9k_led_active_high != -1)
ah->config.led_active_high = ath9k_led_active_high == 1;
 
-- 
2.9.3



[PATCH v6 1/3] Documentation: dt: net: add ath9k wireless device binding

2016-09-06 Thread Martin Blumenstingl
Add documentation how devicetree can be used to configure ath9k based
devices.

Signed-off-by: Martin Blumenstingl 
---
 .../devicetree/bindings/net/wireless/qca,ath9k.txt | 39 ++
 1 file changed, 39 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/wireless/qca,ath9k.txt

diff --git a/Documentation/devicetree/bindings/net/wireless/qca,ath9k.txt 
b/Documentation/devicetree/bindings/net/wireless/qca,ath9k.txt
new file mode 100644
index 000..77b9202
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/wireless/qca,ath9k.txt
@@ -0,0 +1,39 @@
+* Qualcomm Atheros ath9k wireless devices
+
+This node provides properties for configuring the ath9k wireless device. The
+node is expected to be specified as a child node of the PCI controller to
+which the wireless chip is connected.
+
+Required properties:
+- compatible: For PCI and PCIe devices this should be an identifier following
+   the format as defined in "PCI Bus Binding to Open Firmware"
+   Revision 2.1. One of the possible formats is "pci,"
+   where  is the PCI vendor ID and  is PCI device ID.
+
+Optional properties:
+- reg: Address and length of the register set for the device.
+- qca,clk-25mhz: Defines that a 25MHz clock is used
+- qca,no-eeprom: Indicates that there is no physical EEPROM connected to the
+   ath9k wireless chip (in this case the calibration /
+   EEPROM data will be loaded from userspace using the
+   kernel firmware loader).
+- qca,disable-2ghz: Overrides the settings from the EEPROM and disables the
+   2.4GHz band. Setting this property is only needed
+   when the RF circuit does not support the 2.4GHz band
+   while it is enabled nevertheless in the EEPROM.
+- qca,disable-5ghz: Overrides the settings from the EEPROM and disables the
+   5GHz band. Setting this property is only needed when
+   the RF circuit does not support the 5GHz band while
+   it is enabled nevertheless in the EEPROM.
+- mac-address: See ethernet.txt in the parent directory
+- local-mac-address: See ethernet.txt in the parent directory
+
+
+In this example, the node is defined as child node of the PCI controller:
+ {
+   ath9k@168c,002d {
+   compatible = "pci168c,002d";
+   reg = <0x7000 0 0 0 0x1000>;
+   qca,disable-5ghz;
+   };
+};
-- 
2.9.3



[PATCH v6 0/3] add devicetree support to ath9k

2016-09-06 Thread Martin Blumenstingl
This series adds support for configuring ath9k based devices via
devicetree. This was tested on PCI(e) based devices. This should work
for AHB based devices as well as soon as the ath79 platform is ready
to populate the ath9k wmac via devicetree.

Changes since v5:
- updated the example in the documentation (keeping it at a bare
  minimum: removed the PCI bridge, use a better real-world example with
  less-confusing device/fn numbers, added the actual size of the config
  space to the reg property)


Martin Blumenstingl (3):
  Documentation: dt: net: add ath9k wireless device binding
  ath9k: add a helper to get the string representation of ath_bus_type
  ath9k: parse the device configuration from an OF node

 .../devicetree/bindings/net/wireless/qca,ath9k.txt | 39 +
 drivers/net/wireless/ath/ath.h |  6 +++
 drivers/net/wireless/ath/ath9k/init.c  | 51 ++
 drivers/net/wireless/ath/main.c|  7 +++
 4 files changed, 103 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/wireless/qca,ath9k.txt

-- 
2.9.3



[PATCH v6 2/3] ath9k: add a helper to get the string representation of ath_bus_type

2016-09-06 Thread Martin Blumenstingl
This can be used when the ath_bus_type has to be presented in a log
message or firmware filename.

Signed-off-by: Martin Blumenstingl 
---
 drivers/net/wireless/ath/ath.h  | 6 ++
 drivers/net/wireless/ath/main.c | 7 +++
 2 files changed, 13 insertions(+)

diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h
index da7a7c8..f3f2784 100644
--- a/drivers/net/wireless/ath/ath.h
+++ b/drivers/net/wireless/ath/ath.h
@@ -327,4 +327,10 @@ static inline const char *ath_opmode_to_string(enum 
nl80211_iftype opmode)
 }
 #endif
 
+extern const char *ath_bus_type_strings[];
+static inline const char *ath_bus_type_to_string(enum ath_bus_type bustype)
+{
+   return ath_bus_type_strings[bustype];
+}
+
 #endif /* ATH_H */
diff --git a/drivers/net/wireless/ath/main.c b/drivers/net/wireless/ath/main.c
index 338d723..89f4b05 100644
--- a/drivers/net/wireless/ath/main.c
+++ b/drivers/net/wireless/ath/main.c
@@ -90,3 +90,10 @@ void ath_printk(const char *level, const struct ath_common* 
common,
va_end(args);
 }
 EXPORT_SYMBOL(ath_printk);
+
+const char *ath_bus_type_strings[] = {
+   [ATH_PCI] = "pci",
+   [ATH_AHB] = "ahb",
+   [ATH_USB] = "usb",
+};
+EXPORT_SYMBOL(ath_bus_type_strings);
-- 
2.9.3



Re: [PATCH] cfg80211: cap 20MHz VHT bitrate at MCS 8

2016-09-06 Thread Ben Greear

On 09/06/2016 12:00 PM, Thomas Pedersen wrote:

Some drivers (ath10k) report MCS 9 @ 20MHz, which
technically isn't allowed. To get more meaningful value
than 0 out of this however, just cap the bitrate for 20MHz
to MCS 8.


If it is actually reporting MCS9, why lie about it?  Report it up
the stack as a proper value instead of hiding the issue?

Thanks,
Ben




Signed-off-by: Thomas Pedersen 
---
 net/wireless/util.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/wireless/util.c b/net/wireless/util.c
index 0675f51..5fb0249 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -1157,7 +1157,9 @@ static u32 cfg80211_calculate_bitrate_vht(struct 
rate_info *rate)
   5850,
   6500,
   7800,
-  0,
+  /* some drivers report MCS 9 for 20MHz anyway. Clip to MCS 8
+   * bitrate as it's closer than 0 */
+  7800,
},
{  1350,
   2700,




--
Ben Greear 
Candela Technologies Inc  http://www.candelatech.com



[PATCH] ath10k: enable peer stats by default

2016-09-06 Thread Thomas Pedersen
IFTYPE_MESH_POINT need to rely on these for accurate path
selection metrics. Other modes will probably also find
them useful. Enabling peer stats has the side effect of
reducing max number of STAs from 128 to 118. There should
be negligible performance impact.

If users really need 128 STAs and don't mind losing out on
peer stats, they can still disable them:

echo 0 > debugfs/ieee80211/phyn/ath10k/peer_stats

Signed-off-by: Thomas Pedersen 
---
 drivers/net/wireless/ath/ath10k/core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index c9d163e..c0ab4f4 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -2145,6 +2145,9 @@ static void ath10k_core_register_work(struct work_struct 
*work)
struct ath10k *ar = container_of(work, struct ath10k, register_work);
int status;
 
+   /* peer stats are enabled by default */
+   set_bit(ATH10K_FLAG_PEER_STATS, >dev_flags);
+
status = ath10k_core_probe_fw(ar);
if (status) {
ath10k_err(ar, "could not probe fw (%d)\n", status);
-- 
2.1.4



[PATCH] cfg80211: cap 20MHz VHT bitrate at MCS 8

2016-09-06 Thread Thomas Pedersen
Some drivers (ath10k) report MCS 9 @ 20MHz, which
technically isn't allowed. To get more meaningful value
than 0 out of this however, just cap the bitrate for 20MHz
to MCS 8.

Signed-off-by: Thomas Pedersen 
---
 net/wireless/util.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/wireless/util.c b/net/wireless/util.c
index 0675f51..5fb0249 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -1157,7 +1157,9 @@ static u32 cfg80211_calculate_bitrate_vht(struct 
rate_info *rate)
   5850,
   6500,
   7800,
-  0,
+  /* some drivers report MCS 9 for 20MHz anyway. Clip to MCS 8
+   * bitrate as it's closer than 0 */
+  7800,
},
{  1350,
   2700,
-- 
2.1.4



[PATCH] mac80211: make mpath path fixing more robust

2016-09-06 Thread Thomas Pedersen
A fixed mpath was not quite being treated as such:

1) if a PERR frame was received, a fixed mpath was
   deactivated.

2) queued path discovery for fixed mpath was potentially
   being considered, changing mpath state.

3) other mpath flags were potentially being inherited when
   fixing the mpath. Just assign PATH_FIXED and SN_VALID.

This solves several issues when fixing a mesh path in one
direction. The reverse direction mpath should probably
also be fixed, or root announcements at least be enabled.

Signed-off-by: Thomas Pedersen 
---
 net/mac80211/mesh_hwmp.c| 3 ++-
 net/mac80211/mesh_pathtbl.c | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c
index fa7d37c..b747c96 100644
--- a/net/mac80211/mesh_hwmp.c
+++ b/net/mac80211/mesh_hwmp.c
@@ -757,6 +757,7 @@ static void hwmp_perr_frame_process(struct 
ieee80211_sub_if_data *sdata,
sta = next_hop_deref_protected(mpath);
if (mpath->flags & MESH_PATH_ACTIVE &&
ether_addr_equal(ta, sta->sta.addr) &&
+   !(mpath->flags & MESH_PATH_FIXED) &&
(!(mpath->flags & MESH_PATH_SN_VALID) ||
SN_GT(target_sn, mpath->sn)  || target_sn == 0)) {
mpath->flags &= ~MESH_PATH_ACTIVE;
@@ -1023,7 +1024,7 @@ void mesh_path_start_discovery(struct 
ieee80211_sub_if_data *sdata)
goto enddiscovery;
 
spin_lock_bh(>state_lock);
-   if (mpath->flags & MESH_PATH_DELETED) {
+   if (mpath->flags & (MESH_PATH_DELETED | MESH_PATH_FIXED)) {
spin_unlock_bh(>state_lock);
goto enddiscovery;
}
diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c
index 6db2ddf..8e3d2d1 100644
--- a/net/mac80211/mesh_pathtbl.c
+++ b/net/mac80211/mesh_pathtbl.c
@@ -826,7 +826,7 @@ void mesh_path_fix_nexthop(struct mesh_path *mpath, struct 
sta_info *next_hop)
mpath->metric = 0;
mpath->hop_count = 0;
mpath->exp_time = 0;
-   mpath->flags |= MESH_PATH_FIXED;
+   mpath->flags = (MESH_PATH_FIXED | MESH_PATH_SN_VALID);
mesh_path_activate(mpath);
spin_unlock_bh(>state_lock);
mesh_path_tx_pending(mpath);
-- 
2.1.4



Re: [PATCH] ath10k: ensure pdev sta kickout threshold is set.

2016-09-06 Thread Ben Greear

On 09/06/2016 10:16 AM, Rajkumar Manoharan wrote:

On 2016-09-06 18:42, Ben Greear wrote:

On 09/06/2016 12:39 AM, Manoharan, Rajkumar wrote:

[...]


+int ath10k_mac_set_pdev_kickout(struct ath10k *ar)
+{
+   u32 param = ar->wmi.pdev_param->sta_kickout_th;
+   int rv;
+
+   rv = ath10k_wmi_pdev_set_param(ar, param,
+  ar->sta_xretry_kickout_thresh);
+   if (rv) {
+   ath10k_warn(ar, "failed to set sta kickout threshold to %d: 
%d\n",
+   ar->sta_xretry_kickout_thresh, rv);
+   }
+   return rv;
+}


Ben,

I plan to get rid of setting station kickout threshold from host. Each firmware 
revision (i.e qca988x, qca99x0, ipq4019)  follows different logic based on hw
capability for station kickout and follows different default paramters. So 
configuring common threshold will affect firmware logic. Better to get rid of
these configuration from host driver and let firmware to work with default 
parameters.

Also I could not find out sta_xretry_kickout_thresh definition in upstream 
driver. Have you posted any changes for the same?


Hmm, maybe that last bit is something I added in another patch.  Probably my
patch to enable firmware config on a per radio basis (fwcfg in my
tree).  Those patches are
larger and probably will never make it upstream.

I need a way to configure this kickout, since firmware is kicking out
stations when it should
not.



Could you please explain the scenario?


A customer reported issues when having a bunch of android tablets connected to
a QCA9880 NIC running my 10.1 CT firmware in AP mode.

It is not clear exactly why the peers suddenly cannot ack packets,
but disabling the logic that kicks out stations due to low acks appears
to resolve the issue.

To turn the question around:  Is there any benefit to having the
firmware handle this keep-alive stuff?

I can see maybe it is useful in station only mode for power-saving reasons,
but not in AP mode.


Instead of removing the capability, you should instead make it configurable
through debugfs or something like my fwcfg patches, and/or disable the
kickout entirely.
Since mac80211 can deal with kicking out stations already, the stuff
in the firmware just makes
things less stable in poor RF environments and/or with stations with
flaky power-save and
off-channel roaming.


I plan to get rid of hardcoded value and fix this through proper netlink 
interface instead of debugfs. While ago, I posted a change for configuring low 
ack
threshold. It is still pending in my TODO list.

http://comments.gmane.org/gmane.linux.kernel.wireless.general/137645


That sounds nice.  I would hope that setting the value to 0 would
disable as much firmware keep-alive logic as possible.

Thanks,
Ben

--
Ben Greear 
Candela Technologies Inc  http://www.candelatech.com



Re: [PATCH] ath10k: ensure pdev sta kickout threshold is set.

2016-09-06 Thread Rajkumar Manoharan

On 2016-09-06 18:42, Ben Greear wrote:

On 09/06/2016 12:39 AM, Manoharan, Rajkumar wrote:

[...]


+int ath10k_mac_set_pdev_kickout(struct ath10k *ar)
+{
+   u32 param = ar->wmi.pdev_param->sta_kickout_th;
+   int rv;
+
+   rv = ath10k_wmi_pdev_set_param(ar, param,
+  
ar->sta_xretry_kickout_thresh);

+   if (rv) {
+   ath10k_warn(ar, "failed to set sta kickout threshold 
to %d: %d\n",

+   ar->sta_xretry_kickout_thresh, rv);
+   }
+   return rv;
+}


Ben,

I plan to get rid of setting station kickout threshold from host. Each 
firmware revision (i.e qca988x, qca99x0, ipq4019)  follows different 
logic based on hw capability for station kickout and follows different 
default paramters. So configuring common threshold will affect 
firmware logic. Better to get rid of these configuration from host 
driver and let firmware to work with default parameters.


Also I could not find out sta_xretry_kickout_thresh definition in 
upstream driver. Have you posted any changes for the same?


Hmm, maybe that last bit is something I added in another patch.  
Probably my

patch to enable firmware config on a per radio basis (fwcfg in my
tree).  Those patches are
larger and probably will never make it upstream.

I need a way to configure this kickout, since firmware is kicking out
stations when it should
not.



Could you please explain the scenario?

Instead of removing the capability, you should instead make it 
configurable

through debugfs or something like my fwcfg patches, and/or disable the
kickout entirely.
Since mac80211 can deal with kicking out stations already, the stuff
in the firmware just makes
things less stable in poor RF environments and/or with stations with
flaky power-save and
off-channel roaming.

I plan to get rid of hardcoded value and fix this through proper netlink 
interface instead of debugfs. While ago, I posted a change for 
configuring low ack threshold. It is still pending in my TODO list.


http://comments.gmane.org/gmane.linux.kernel.wireless.general/137645

-Rajkumar


[PATCH v3 1/6] staging: rtl8723au: remove unimplemented functions declaration

2016-09-06 Thread Luca Ceresoli
These functions have been declared without any implementation since
the first commit (364e30ebd2dbaccba430c603da03e68746eb932a) and there
has been no mention of them in following commits.

Signed-off-by: Luca Ceresoli 
Cc: Larry Finger 
Cc: Jes Sorensen 
Cc: Greg Kroah-Hartman 
Cc: linux-wireless@vger.kernel.org
Cc: de...@driverdev.osuosl.org
Cc: linux-ker...@vger.kernel.org

---

Changes v2 -> v3:
- add "staging: " prefix to commit message title.

Changes v1 -> v2:
- improve the commit message.
---
 drivers/staging/rtl8723au/include/recv_osdep.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/rtl8723au/include/recv_osdep.h 
b/drivers/staging/rtl8723au/include/recv_osdep.h
index c2d3f1b..c159dbc 100644
--- a/drivers/staging/rtl8723au/include/recv_osdep.h
+++ b/drivers/staging/rtl8723au/include/recv_osdep.h
@@ -26,9 +26,6 @@ int rtw_recv_indicatepkt23a(struct rtw_adapter *adapter, 
struct recv_frame *prec
 
 void rtw_handle_tkip_mic_err23a(struct rtw_adapter *padapter, u8 bgroup);
 
-intrtw_init_recv_priv(struct recv_priv *precvpriv, struct rtw_adapter 
*padapter);
-void rtw_free_recv_priv (struct recv_priv *precvpriv);
-
 int rtw_os_recv_resource_init(struct recv_priv *precvpriv, struct rtw_adapter 
*padapter);
 
 void rtw_init_recv_timer23a(struct recv_reorder_ctrl *preorder_ctrl);
-- 
2.7.4



Re: [PATCH 0/5] Some cleanup patches for drivers/staging/rtl8723au/core/rtw_mlme.c

2016-09-06 Thread Jes Sorensen
Joe Perches  writes:
> On Tue, 2016-09-06 at 12:00 -0400, Jes Sorensen wrote:
>
>> Nothing wrong with these patches, however I intend to post a patch to
>> remove this driver soon, so it's kind of a waste of your time to spend
>> too many cycles on it.
>
> It might be useful to mark any drivers you're
> planning on removing as "Obsolete" in MAINTAINERS.
>
> checkpatch will then emit a "don't waste your time"
> message if anyone scans an obsolete driver/file.

I see, wasn't aware of that. I did add a printk to it for 4.6 notifying
users that the driver was going to go away.

Jes


Re: [PATCH 0/5] Some cleanup patches for drivers/staging/rtl8723au/core/rtw_mlme.c

2016-09-06 Thread Joe Perches
On Tue, 2016-09-06 at 12:00 -0400, Jes Sorensen wrote:

> Nothing wrong with these patches, however I intend to post a patch to
> remove this driver soon, so it's kind of a waste of your time to spend
> too many cycles on it.

It might be useful to mark any drivers you're
planning on removing as "Obsolete" in MAINTAINERS.

checkpatch will then emit a "don't waste your time"
message if anyone scans an obsolete driver/file.



Re: [PATCH 0/5] Some cleanup patches for drivers/staging/rtl8723au/core/rtw_mlme.c

2016-09-06 Thread Jes Sorensen
Matthias Beyer  writes:
> This patchset fixes some errors and warnings reported by checkpatch.pl.
>
> Matthias Beyer (5):
>   drivers: staging: rtl8723au: core: Fix checkpatch.pl errors
>   drivers: staging: rtl8723au: core: simplify if-break-else
>   drivers: staging: rtl8723au: core: Refactor pointless branching
>   drivers: staging: rtl8723au: core: Fix "space prohibited" warning
>   drivers: staging: rtl8723au: core: Fix indentation
>
>  drivers/staging/rtl8723au/core/rtw_mlme.c | 72 
> ++-
>  1 file changed, 33 insertions(+), 39 deletions(-)

Nothing wrong with these patches, however I intend to post a patch to
remove this driver soon, so it's kind of a waste of your time to spend
too many cycles on it.

Best regards,
Jes


Re: Debugging RTL8192CU firmware loading on 3.12 powerpc

2016-09-06 Thread Larry Finger

On 09/06/2016 08:09 AM, Sven Eckelmann wrote:

On Dienstag, 6. September 2016 09:40:41 CEST Sven Eckelmann wrote:

On Freitag, 2. September 2016 12:53:28 CEST Larry Finger wrote:
[...]


The patch I included in my previous E-mail, and attached here,  does get
the firmware loaded correctly. There is still a problem that prevents
authentication. I'm still looking for that issue.


Thanks for the fast update. I am currently testing your patch. It looks like
the initial error is now gone. The hostapd also starts but beaconing
doesn't seem to work at all (no error from the kernel/hostapd but the
device is not sending anything). I am currently checking how beaconing is
supposed to work in your driver. Maybe I will spot something useful.


Yes, found something similar in the checksumming algorithm. See the attached
patch for details.


Just for the record, this is not "my" driver. It was provided by Realtek. My 
contribution has only been to clean it up.


Thanks for the patch. I too had found that checksum code, but I had not sent it 
as there are still problems on BE machines. These difficulties are running the 
NIC in STA mode. I have not tried AP mode. Scan data seem to be read OK, but it 
never authenticates. I do not know if there are further errors in setting up the 
transmit buffer, or if the problem is in the encryption/decryption code. I'm 
still looking.


Larry




Re: [PATCH] ath10k: ensure pdev sta kickout threshold is set.

2016-09-06 Thread Ben Greear



On 09/06/2016 12:39 AM, Manoharan, Rajkumar wrote:

[...]


+int ath10k_mac_set_pdev_kickout(struct ath10k *ar)
+{
+   u32 param = ar->wmi.pdev_param->sta_kickout_th;
+   int rv;
+
+   rv = ath10k_wmi_pdev_set_param(ar, param,
+  ar->sta_xretry_kickout_thresh);
+   if (rv) {
+   ath10k_warn(ar, "failed to set sta kickout threshold to %d: 
%d\n",
+   ar->sta_xretry_kickout_thresh, rv);
+   }
+   return rv;
+}


Ben,

I plan to get rid of setting station kickout threshold from host. Each firmware 
revision (i.e qca988x, qca99x0, ipq4019)  follows different logic based on hw 
capability for station kickout and follows different default paramters. So 
configuring common threshold will affect firmware logic. Better to get rid of 
these configuration from host driver and let firmware to work with default 
parameters.

Also I could not find out sta_xretry_kickout_thresh definition in upstream 
driver. Have you posted any changes for the same?


Hmm, maybe that last bit is something I added in another patch.  Probably my
patch to enable firmware config on a per radio basis (fwcfg in my tree).  Those 
patches are
larger and probably will never make it upstream.

I need a way to configure this kickout, since firmware is kicking out stations 
when it should
not.

Instead of removing the capability, you should instead make it configurable
through debugfs or something like my fwcfg patches, and/or disable the kickout 
entirely.
Since mac80211 can deal with kicking out stations already, the stuff in the 
firmware just makes
things less stable in poor RF environments and/or with stations with flaky 
power-save and
off-channel roaming.

Thanks,
Ben


--
Ben Greear 
Candela Technologies Inc  http://www.candelatech.com


Re: Debugging RTL8192CU firmware loading on 3.12 powerpc

2016-09-06 Thread Sven Eckelmann
On Dienstag, 6. September 2016 09:40:41 CEST Sven Eckelmann wrote:
> On Freitag, 2. September 2016 12:53:28 CEST Larry Finger wrote:
> [...]
> 
> > The patch I included in my previous E-mail, and attached here,  does get
> > the firmware loaded correctly. There is still a problem that prevents
> > authentication. I'm still looking for that issue.
> 
> Thanks for the fast update. I am currently testing your patch. It looks like
> the initial error is now gone. The hostapd also starts but beaconing
> doesn't seem to work at all (no error from the kernel/hostapd but the
> device is not sending anything). I am currently checking how beaconing is
> supposed to work in your driver. Maybe I will spot something useful.

Yes, found something similar in the checksumming algorithm. See the attached 
patch for details.

Kind regards,
SvenFrom: Larry Finger 
Date: Mon, 5 Sep 2016 11:03:44 +0200
Subject: [PATCH] rtl8192c: Fix byteorder of loaded firmware

The firmware is read in as an array of bytes, thus it is effectively in
little-endian order. When it is written back to the device in routine
_rtl92c_fw_block_write(), the data output uses 32-bit writes. Of course,
all data supplied in all 2- and 4-byte writes is assumed to be in CPU
order. As the device needs the data to be little-endian, it will be byte
swapped on BE machines. As a result, the firmware is written out in the
wrong byte order
---
 drivers/net/wireless/realtek/rtlwifi/rtl8192c/fw_common.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192c/fw_common.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192c/fw_common.c
index 43fcb25..7c5fc85 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192c/fw_common.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192c/fw_common.c
@@ -74,16 +74,18 @@ static void _rtl92c_fw_block_write(struct ieee80211_hw *hw,
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	u32 blocksize = sizeof(u32);
 	u8 *bufferptr = (u8 *)buffer;
-	u32 *pu4byteptr = (u32 *)buffer;
+	__le32 *pu4byteptr = (__le32 *)buffer;
 	u32 i, offset, blockcount, remainsize;
+	u32 data;
 
 	blockcount = size / blocksize;
 	remainsize = size % blocksize;
 
 	for (i = 0; i < blockcount; i++) {
 		offset = i * blocksize;
+		data = le32_to_cpu(*(pu4byteptr + i));
 		rtl_write_dword(rtlpriv, (FW_8192C_START_ADDRESS + offset),
-*(pu4byteptr + i));
+data);
 	}
 
 	if (remainsize) {
From: Sven Eckelmann 
Date: Tue, 6 Sep 2016 15:00:27 +0200
Subject: [PATCH] Fix TX checksum on big endian systems
---
 drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
index 95880fe..6cb46ba 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
@@ -481,14 +481,14 @@ static void _rtl_fill_usb_tx_desc(u8 *txdesc)
  */
 static void _rtl_tx_desc_checksum(u8 *txdesc)
 {
-	u16 *ptr = (u16 *)txdesc;
+	__le16 *ptr = (__le16 *)txdesc;
 	u16	checksum = 0;
 	u32 index;
 
 	/* Clear first */
 	SET_TX_DESC_TX_DESC_CHECKSUM(txdesc, 0);
 	for (index = 0; index < 16; index++)
-		checksum = checksum ^ (*(ptr + index));
+		checksum = checksum ^ le16_to_cpu(*(ptr + index));
 	SET_TX_DESC_TX_DESC_CHECKSUM(txdesc, checksum);
 }
 


signature.asc
Description: This is a digitally signed message part.


[PATCH 2/3] ath10k: use devm_reset_control_get() instead of reset_control_get()

2016-09-06 Thread Masahiro Yamada
Use the managed variant of reset_control_get() to simplify the
failure path and the .remove callback.

Signed-off-by: Masahiro Yamada 
---

 drivers/net/wireless/ath/ath10k/ahb.c | 56 +++
 1 file changed, 10 insertions(+), 46 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/ahb.c 
b/drivers/net/wireless/ath/ath10k/ahb.c
index 8a55c0c..6b355ee 100644
--- a/drivers/net/wireless/ath/ath10k/ahb.c
+++ b/drivers/net/wireless/ath/ath10k/ahb.c
@@ -191,92 +191,56 @@ static int ath10k_ahb_rst_ctrl_init(struct ath10k *ar)
 {
struct ath10k_ahb *ar_ahb = ath10k_ahb_priv(ar);
struct device *dev;
-   int ret;
 
dev = _ahb->pdev->dev;
 
-   ar_ahb->core_cold_rst = reset_control_get(dev, "wifi_core_cold");
+   ar_ahb->core_cold_rst = devm_reset_control_get(dev, "wifi_core_cold");
if (IS_ERR_OR_NULL(ar_ahb->core_cold_rst)) {
ath10k_err(ar, "failed to get core cold rst ctrl: %ld\n",
   PTR_ERR(ar_ahb->core_cold_rst));
-   ret = ar_ahb->core_cold_rst ?
+   return ar_ahb->core_cold_rst ?
PTR_ERR(ar_ahb->core_cold_rst) : -ENODEV;
-   goto out;
}
 
-   ar_ahb->radio_cold_rst = reset_control_get(dev, "wifi_radio_cold");
+   ar_ahb->radio_cold_rst = devm_reset_control_get(dev, "wifi_radio_cold");
if (IS_ERR_OR_NULL(ar_ahb->radio_cold_rst)) {
ath10k_err(ar, "failed to get radio cold rst ctrl: %ld\n",
   PTR_ERR(ar_ahb->radio_cold_rst));
-   ret = ar_ahb->radio_cold_rst ?
+   return ar_ahb->radio_cold_rst ?
PTR_ERR(ar_ahb->radio_cold_rst) : -ENODEV;
-   goto err_core_cold_rst_put;
}
 
-   ar_ahb->radio_warm_rst = reset_control_get(dev, "wifi_radio_warm");
+   ar_ahb->radio_warm_rst = devm_reset_control_get(dev, "wifi_radio_warm");
if (IS_ERR_OR_NULL(ar_ahb->radio_warm_rst)) {
ath10k_err(ar, "failed to get radio warm rst ctrl: %ld\n",
   PTR_ERR(ar_ahb->radio_warm_rst));
-   ret = ar_ahb->radio_warm_rst ?
+   return ar_ahb->radio_warm_rst ?
PTR_ERR(ar_ahb->radio_warm_rst) : -ENODEV;
-   goto err_radio_cold_rst_put;
}
 
-   ar_ahb->radio_srif_rst = reset_control_get(dev, "wifi_radio_srif");
+   ar_ahb->radio_srif_rst = devm_reset_control_get(dev, "wifi_radio_srif");
if (IS_ERR_OR_NULL(ar_ahb->radio_srif_rst)) {
ath10k_err(ar, "failed to get radio srif rst ctrl: %ld\n",
   PTR_ERR(ar_ahb->radio_srif_rst));
-   ret = ar_ahb->radio_srif_rst ?
+   return ar_ahb->radio_srif_rst ?
PTR_ERR(ar_ahb->radio_srif_rst) : -ENODEV;
-   goto err_radio_warm_rst_put;
}
 
-   ar_ahb->cpu_init_rst = reset_control_get(dev, "wifi_cpu_init");
+   ar_ahb->cpu_init_rst = devm_reset_control_get(dev, "wifi_cpu_init");
if (IS_ERR_OR_NULL(ar_ahb->cpu_init_rst)) {
ath10k_err(ar, "failed to get cpu init rst ctrl: %ld\n",
   PTR_ERR(ar_ahb->cpu_init_rst));
-   ret = ar_ahb->cpu_init_rst ?
+   return ar_ahb->cpu_init_rst ?
PTR_ERR(ar_ahb->cpu_init_rst) : -ENODEV;
-   goto err_radio_srif_rst_put;
}
 
return 0;
-
-err_radio_srif_rst_put:
-   reset_control_put(ar_ahb->radio_srif_rst);
-
-err_radio_warm_rst_put:
-   reset_control_put(ar_ahb->radio_warm_rst);
-
-err_radio_cold_rst_put:
-   reset_control_put(ar_ahb->radio_cold_rst);
-
-err_core_cold_rst_put:
-   reset_control_put(ar_ahb->core_cold_rst);
-
-out:
-   return ret;
 }
 
 static void ath10k_ahb_rst_ctrl_deinit(struct ath10k *ar)
 {
struct ath10k_ahb *ar_ahb = ath10k_ahb_priv(ar);
 
-   if (!IS_ERR_OR_NULL(ar_ahb->core_cold_rst))
-   reset_control_put(ar_ahb->core_cold_rst);
-
-   if (!IS_ERR_OR_NULL(ar_ahb->radio_cold_rst))
-   reset_control_put(ar_ahb->radio_cold_rst);
-
-   if (!IS_ERR_OR_NULL(ar_ahb->radio_warm_rst))
-   reset_control_put(ar_ahb->radio_warm_rst);
-
-   if (!IS_ERR_OR_NULL(ar_ahb->radio_srif_rst))
-   reset_control_put(ar_ahb->radio_srif_rst);
-
-   if (!IS_ERR_OR_NULL(ar_ahb->cpu_init_rst))
-   reset_control_put(ar_ahb->cpu_init_rst);
-
ar_ahb->core_cold_rst = NULL;
ar_ahb->radio_cold_rst = NULL;
ar_ahb->radio_warm_rst = NULL;
-- 
1.9.1



[PATCH 3/3] ath10k: do not check if reset is NULL

2016-09-06 Thread Masahiro Yamada
Since reset_control_get() never returns NULL, we can use IS_ERR()
instead of IS_ERR_OR_NULL().  The return statements can be simpler
as well.

Signed-off-by: Masahiro Yamada 
---

 drivers/net/wireless/ath/ath10k/ahb.c | 25 ++---
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/ahb.c 
b/drivers/net/wireless/ath/ath10k/ahb.c
index 6b355ee..b29dc4d 100644
--- a/drivers/net/wireless/ath/ath10k/ahb.c
+++ b/drivers/net/wireless/ath/ath10k/ahb.c
@@ -195,43 +195,38 @@ static int ath10k_ahb_rst_ctrl_init(struct ath10k *ar)
dev = _ahb->pdev->dev;
 
ar_ahb->core_cold_rst = devm_reset_control_get(dev, "wifi_core_cold");
-   if (IS_ERR_OR_NULL(ar_ahb->core_cold_rst)) {
+   if (IS_ERR(ar_ahb->core_cold_rst)) {
ath10k_err(ar, "failed to get core cold rst ctrl: %ld\n",
   PTR_ERR(ar_ahb->core_cold_rst));
-   return ar_ahb->core_cold_rst ?
-   PTR_ERR(ar_ahb->core_cold_rst) : -ENODEV;
+   return PTR_ERR(ar_ahb->core_cold_rst);
}
 
ar_ahb->radio_cold_rst = devm_reset_control_get(dev, "wifi_radio_cold");
-   if (IS_ERR_OR_NULL(ar_ahb->radio_cold_rst)) {
+   if (IS_ERR(ar_ahb->radio_cold_rst)) {
ath10k_err(ar, "failed to get radio cold rst ctrl: %ld\n",
   PTR_ERR(ar_ahb->radio_cold_rst));
-   return ar_ahb->radio_cold_rst ?
-   PTR_ERR(ar_ahb->radio_cold_rst) : -ENODEV;
+   return PTR_ERR(ar_ahb->radio_cold_rst);
}
 
ar_ahb->radio_warm_rst = devm_reset_control_get(dev, "wifi_radio_warm");
-   if (IS_ERR_OR_NULL(ar_ahb->radio_warm_rst)) {
+   if (IS_ERR(ar_ahb->radio_warm_rst)) {
ath10k_err(ar, "failed to get radio warm rst ctrl: %ld\n",
   PTR_ERR(ar_ahb->radio_warm_rst));
-   return ar_ahb->radio_warm_rst ?
-   PTR_ERR(ar_ahb->radio_warm_rst) : -ENODEV;
+   return PTR_ERR(ar_ahb->radio_warm_rst);
}
 
ar_ahb->radio_srif_rst = devm_reset_control_get(dev, "wifi_radio_srif");
-   if (IS_ERR_OR_NULL(ar_ahb->radio_srif_rst)) {
+   if (IS_ERR(ar_ahb->radio_srif_rst)) {
ath10k_err(ar, "failed to get radio srif rst ctrl: %ld\n",
   PTR_ERR(ar_ahb->radio_srif_rst));
-   return ar_ahb->radio_srif_rst ?
-   PTR_ERR(ar_ahb->radio_srif_rst) : -ENODEV;
+   return PTR_ERR(ar_ahb->radio_srif_rst);
}
 
ar_ahb->cpu_init_rst = devm_reset_control_get(dev, "wifi_cpu_init");
-   if (IS_ERR_OR_NULL(ar_ahb->cpu_init_rst)) {
+   if (IS_ERR(ar_ahb->cpu_init_rst)) {
ath10k_err(ar, "failed to get cpu init rst ctrl: %ld\n",
   PTR_ERR(ar_ahb->cpu_init_rst));
-   return ar_ahb->cpu_init_rst ?
-   PTR_ERR(ar_ahb->cpu_init_rst) : -ENODEV;
+   return PTR_ERR(ar_ahb->cpu_init_rst);
}
 
return 0;
-- 
1.9.1



[PATCH 1/3] ath10k: use devm_clk_get() instead of clk_get()

2016-09-06 Thread Masahiro Yamada
Use the managed variant of clk_get() to simplify the failure path
and the .remove callback.

Signed-off-by: Masahiro Yamada 
---

 drivers/net/wireless/ath/ath10k/ahb.c | 34 ++
 1 file changed, 6 insertions(+), 28 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/ahb.c 
b/drivers/net/wireless/ath/ath10k/ahb.c
index acec16b..8a55c0c 100644
--- a/drivers/net/wireless/ath/ath10k/ahb.c
+++ b/drivers/net/wireless/ath/ath10k/ahb.c
@@ -91,59 +91,37 @@ static int ath10k_ahb_clock_init(struct ath10k *ar)
 {
struct ath10k_ahb *ar_ahb = ath10k_ahb_priv(ar);
struct device *dev;
-   int ret;
 
dev = _ahb->pdev->dev;
 
-   ar_ahb->cmd_clk = clk_get(dev, "wifi_wcss_cmd");
+   ar_ahb->cmd_clk = devm_clk_get(dev, "wifi_wcss_cmd");
if (IS_ERR_OR_NULL(ar_ahb->cmd_clk)) {
ath10k_err(ar, "failed to get cmd clk: %ld\n",
   PTR_ERR(ar_ahb->cmd_clk));
-   ret = ar_ahb->cmd_clk ? PTR_ERR(ar_ahb->cmd_clk) : -ENODEV;
-   goto out;
+   return ar_ahb->cmd_clk ? PTR_ERR(ar_ahb->cmd_clk) : -ENODEV;
}
 
-   ar_ahb->ref_clk = clk_get(dev, "wifi_wcss_ref");
+   ar_ahb->ref_clk = devm_clk_get(dev, "wifi_wcss_ref");
if (IS_ERR_OR_NULL(ar_ahb->ref_clk)) {
ath10k_err(ar, "failed to get ref clk: %ld\n",
   PTR_ERR(ar_ahb->ref_clk));
-   ret = ar_ahb->ref_clk ? PTR_ERR(ar_ahb->ref_clk) : -ENODEV;
-   goto err_cmd_clk_put;
+   return ar_ahb->ref_clk ? PTR_ERR(ar_ahb->ref_clk) : -ENODEV;
}
 
-   ar_ahb->rtc_clk = clk_get(dev, "wifi_wcss_rtc");
+   ar_ahb->rtc_clk = devm_clk_get(dev, "wifi_wcss_rtc");
if (IS_ERR_OR_NULL(ar_ahb->rtc_clk)) {
ath10k_err(ar, "failed to get rtc clk: %ld\n",
   PTR_ERR(ar_ahb->rtc_clk));
-   ret = ar_ahb->rtc_clk ? PTR_ERR(ar_ahb->rtc_clk) : -ENODEV;
-   goto err_ref_clk_put;
+   return ar_ahb->rtc_clk ? PTR_ERR(ar_ahb->rtc_clk) : -ENODEV;
}
 
return 0;
-
-err_ref_clk_put:
-   clk_put(ar_ahb->ref_clk);
-
-err_cmd_clk_put:
-   clk_put(ar_ahb->cmd_clk);
-
-out:
-   return ret;
 }
 
 static void ath10k_ahb_clock_deinit(struct ath10k *ar)
 {
struct ath10k_ahb *ar_ahb = ath10k_ahb_priv(ar);
 
-   if (!IS_ERR_OR_NULL(ar_ahb->cmd_clk))
-   clk_put(ar_ahb->cmd_clk);
-
-   if (!IS_ERR_OR_NULL(ar_ahb->ref_clk))
-   clk_put(ar_ahb->ref_clk);
-
-   if (!IS_ERR_OR_NULL(ar_ahb->rtc_clk))
-   clk_put(ar_ahb->rtc_clk);
-
ar_ahb->cmd_clk = NULL;
ar_ahb->ref_clk = NULL;
ar_ahb->rtc_clk = NULL;
-- 
1.9.1



[PATCH 0/3] ath10k: a little bit clean-up of ATH10K driver

2016-09-06 Thread Masahiro Yamada

Clean-up code with devm_clk_get() and devm_reset_control_get().

I know devm_reset_control_get() should be replaced with
either devm_reset_control_get_exclusive() or
devm_reset_control_get_shared().

My best guess is devm_reset_control_get_shared() for this case,
but I am not 100% sure, so I am leaving it to other developers.



Masahiro Yamada (3):
  ath10k: use devm_clk_get() instead of clk_get()
  ath10k: use devm_reset_control_get() instead of reset_control_get()
  ath10k: do not check if reset is NULL

 drivers/net/wireless/ath/ath10k/ahb.c | 105 +++---
 1 file changed, 21 insertions(+), 84 deletions(-)

-- 
1.9.1



Re: mwifiex: propagate error if IRQ request fails in mwifiex_sdio_of()

2016-09-06 Thread Javier Martinez Canillas
Hello Kalle,

On 09/03/2016 12:35 PM, Kalle Valo wrote:
> Javier Martinez Canillas  wrote:
>> If request_irq() fails in mwifiex_sdio_probe_of(), only an error message
>> is printed but the actual error is not propagated to the caller function.
>>
>> Signed-off-by: Javier Martinez Canillas 
> 
> What's the conclusion with this patch? Should I drop it or take it?
> 
> (The discussion is available from the patchwork link in the signature.)
> 

My understanding is that Arend agrees with the patch and that the question
raised was caused by looking at an older kernel version. IOW, the patch is
OK and should be picked.

I'm adding Arend to cc, so can comment in case I misunderstood him though.

Best regards,
-- 
Javier Martinez Canillas
Open Source Group
Samsung Research America


Re: [PATCH v7] mac80211: Move reorder-sensitive TX handlers to after TXQ dequeue.

2016-09-06 Thread Toke Høiland-Jørgensen
Toke Høiland-Jørgensen  writes:

> The TXQ intermediate queues can cause packet reordering when more than
> one flow is active to a single station. Since some of the wifi-specific
> packet handling (notably sequence number and encryption handling) is
> sensitive to re-ordering, things break if they are applied before the
> TXQ.
>
> This splits up the TX handlers and fast_xmit logic into two parts: An
> early part and a late part. The former is applied before TXQ enqueue,
> and the latter after dequeue. The non-TXQ path just applies both parts
> at once.
>
> Because fragments shouldn't be split up or reordered, the fragmentation
> handler is run after dequeue. Any fragments are then kept in the TXQ and
> on subsequent dequeues they take precedence over dequeueing from the FQ
> structure.
>
> This approach avoids having to scatter special cases for when TXQ is
> enabled, at the cost of making the fast_xmit and TX handler code
> slightly more complex.
>
> Signed-off-by: Toke Høiland-Jørgensen 

Sorry for sending this again; meant to send v8. :/

-Toke


[PATCH v8] mac80211: Move reorder-sensitive TX handlers to after TXQ dequeue.

2016-09-06 Thread Toke Høiland-Jørgensen
The TXQ intermediate queues can cause packet reordering when more than
one flow is active to a single station. Since some of the wifi-specific
packet handling (notably sequence number and encryption handling) is
sensitive to re-ordering, things break if they are applied before the
TXQ.

This splits up the TX handlers and fast_xmit logic into two parts: An
early part and a late part. The former is applied before TXQ enqueue,
and the latter after dequeue. The non-TXQ path just applies both parts
at once.

Because fragments shouldn't be split up or reordered, the fragmentation
handler is run after dequeue. Any fragments are then kept in the TXQ and
on subsequent dequeues they take precedence over dequeueing from the FQ
structure.

This approach avoids having to scatter special cases for when TXQ is
enabled, at the cost of making the fast_xmit and TX handler code
slightly more complex.

Signed-off-by: Toke Høiland-Jørgensen 
---
Changes since v8:
- Don't rely on the fast_tx pointer on TXQ dequeue; it can go away while
  the packet was queued, and we don't actually need it, since we can get
  the key configuration and offset from the packet info.

 include/net/mac80211.h |   2 +
 net/mac80211/ieee80211_i.h |   2 +
 net/mac80211/tx.c  | 255 +
 3 files changed, 195 insertions(+), 64 deletions(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index cca510a..9a6a3e9 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -715,6 +715,7 @@ enum mac80211_tx_info_flags {
  * frame (PS-Poll or uAPSD).
  * @IEEE80211_TX_CTRL_RATE_INJECT: This frame is injected with rate information
  * @IEEE80211_TX_CTRL_AMSDU: This frame is an A-MSDU frame
+ * @IEEE80211_TX_CTRL_FAST_XMIT: This frame is going through the fast_xmit path
  *
  * These flags are used in tx_info->control.flags.
  */
@@ -723,6 +724,7 @@ enum mac80211_tx_control_flags {
IEEE80211_TX_CTRL_PS_RESPONSE   = BIT(1),
IEEE80211_TX_CTRL_RATE_INJECT   = BIT(2),
IEEE80211_TX_CTRL_AMSDU = BIT(3),
+   IEEE80211_TX_CTRL_FAST_XMIT = BIT(4),
 };
 
 /*
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 9211cce..d36f3b1 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -813,11 +813,13 @@ enum txq_info_flags {
  * @def_flow: used as a fallback flow when a packet destined to @tin hashes to
  * a fq_flow which is already owned by a different tin
  * @def_cvars: codel vars for @def_flow
+ * @frags: used to keep fragments created after dequeue
  */
 struct txq_info {
struct fq_tin tin;
struct fq_flow def_flow;
struct codel_vars def_cvars;
+   struct sk_buff_head frags;
unsigned long flags;
 
/* keep last! */
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index efc38e7..f8eec60 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -38,6 +38,12 @@
 #include "wme.h"
 #include "rate.h"
 
+static int invoke_tx_handlers_late(struct ieee80211_tx_data *tx);
+static bool ieee80211_xmit_fast_finish(struct ieee80211_sub_if_data *sdata,
+  struct sta_info *sta, u8 pn_offs,
+  struct ieee80211_key_conf *key_conf,
+  struct sk_buff *skb);
+
 /* misc utils */
 
 static inline void ieee80211_tx_stats(struct net_device *dev, u32 len)
@@ -853,8 +859,7 @@ ieee80211_tx_h_sequence(struct ieee80211_tx_data *tx)
tid = *qc & IEEE80211_QOS_CTL_TID_MASK;
tx->sta->tx_stats.msdu[tid]++;
 
-   if (!tx->sta->sta.txq[0])
-   hdr->seq_ctrl = ieee80211_tx_next_seq(tx->sta, tid);
+   hdr->seq_ctrl = ieee80211_tx_next_seq(tx->sta, tid);
 
return TX_CONTINUE;
 }
@@ -1403,6 +1408,7 @@ void ieee80211_txq_init(struct ieee80211_sub_if_data 
*sdata,
fq_tin_init(>tin);
fq_flow_init(>def_flow);
codel_vars_init(>def_cvars);
+   __skb_queue_head_init(>frags);
 
txqi->txq.vif = >vif;
 
@@ -1425,6 +1431,7 @@ void ieee80211_txq_purge(struct ieee80211_local *local,
struct fq_tin *tin = >tin;
 
fq_tin_reset(fq, tin, fq_skb_free_func);
+   ieee80211_purge_tx_queue(>hw, >frags);
 }
 
 int ieee80211_txq_setup_flows(struct ieee80211_local *local)
@@ -1485,12 +1492,19 @@ struct sk_buff *ieee80211_tx_dequeue(struct 
ieee80211_hw *hw,
struct sk_buff *skb = NULL;
struct fq *fq = >fq;
struct fq_tin *tin = >tin;
+   struct ieee80211_tx_info *info;
 
spin_lock_bh(>lock);
 
if (test_bit(IEEE80211_TXQ_STOP, >flags))
goto out;
 
+   /* Make sure fragments stay together. */
+   skb = __skb_dequeue(>frags);
+   if (skb)
+   goto out;
+
+begin:
skb = fq_tin_dequeue(fq, tin, fq_tin_dequeue_func);
if (!skb)
goto out;
@@ -1498,16 +1512,37 @@ struct sk_buff 

[PATCH v7] mac80211: Move reorder-sensitive TX handlers to after TXQ dequeue.

2016-09-06 Thread Toke Høiland-Jørgensen
The TXQ intermediate queues can cause packet reordering when more than
one flow is active to a single station. Since some of the wifi-specific
packet handling (notably sequence number and encryption handling) is
sensitive to re-ordering, things break if they are applied before the
TXQ.

This splits up the TX handlers and fast_xmit logic into two parts: An
early part and a late part. The former is applied before TXQ enqueue,
and the latter after dequeue. The non-TXQ path just applies both parts
at once.

Because fragments shouldn't be split up or reordered, the fragmentation
handler is run after dequeue. Any fragments are then kept in the TXQ and
on subsequent dequeues they take precedence over dequeueing from the FQ
structure.

This approach avoids having to scatter special cases for when TXQ is
enabled, at the cost of making the fast_xmit and TX handler code
slightly more complex.

Signed-off-by: Toke Høiland-Jørgensen 
---
Changes since v6:
  - Invoking the rate control handler can cause packets to be generated
(for establishing a BA session). This can cause a deadlock because
dequeue can happen while sta->lock is held. So this version moves
the rate control handler back before the intermediate queue step.
  - Fix sequence number allocation on the slow path.
  
 include/net/mac80211.h |   2 +
 net/mac80211/ieee80211_i.h |   2 +
 net/mac80211/tx.c  | 250 ++---
 3 files changed, 192 insertions(+), 62 deletions(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index cca510a..9a6a3e9 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -715,6 +715,7 @@ enum mac80211_tx_info_flags {
  * frame (PS-Poll or uAPSD).
  * @IEEE80211_TX_CTRL_RATE_INJECT: This frame is injected with rate information
  * @IEEE80211_TX_CTRL_AMSDU: This frame is an A-MSDU frame
+ * @IEEE80211_TX_CTRL_FAST_XMIT: This frame is going through the fast_xmit path
  *
  * These flags are used in tx_info->control.flags.
  */
@@ -723,6 +724,7 @@ enum mac80211_tx_control_flags {
IEEE80211_TX_CTRL_PS_RESPONSE   = BIT(1),
IEEE80211_TX_CTRL_RATE_INJECT   = BIT(2),
IEEE80211_TX_CTRL_AMSDU = BIT(3),
+   IEEE80211_TX_CTRL_FAST_XMIT = BIT(4),
 };
 
 /*
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 9211cce..d36f3b1 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -813,11 +813,13 @@ enum txq_info_flags {
  * @def_flow: used as a fallback flow when a packet destined to @tin hashes to
  * a fq_flow which is already owned by a different tin
  * @def_cvars: codel vars for @def_flow
+ * @frags: used to keep fragments created after dequeue
  */
 struct txq_info {
struct fq_tin tin;
struct fq_flow def_flow;
struct codel_vars def_cvars;
+   struct sk_buff_head frags;
unsigned long flags;
 
/* keep last! */
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index efc38e7..94f38cc 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -38,6 +38,12 @@
 #include "wme.h"
 #include "rate.h"
 
+static int invoke_tx_handlers_late(struct ieee80211_tx_data *tx);
+static bool ieee80211_xmit_fast_finish(struct ieee80211_sub_if_data *sdata,
+  struct sta_info *sta,
+  struct ieee80211_fast_tx *fast_tx,
+  struct sk_buff *skb);
+
 /* misc utils */
 
 static inline void ieee80211_tx_stats(struct net_device *dev, u32 len)
@@ -853,8 +859,7 @@ ieee80211_tx_h_sequence(struct ieee80211_tx_data *tx)
tid = *qc & IEEE80211_QOS_CTL_TID_MASK;
tx->sta->tx_stats.msdu[tid]++;
 
-   if (!tx->sta->sta.txq[0])
-   hdr->seq_ctrl = ieee80211_tx_next_seq(tx->sta, tid);
+   hdr->seq_ctrl = ieee80211_tx_next_seq(tx->sta, tid);
 
return TX_CONTINUE;
 }
@@ -1403,6 +1408,7 @@ void ieee80211_txq_init(struct ieee80211_sub_if_data 
*sdata,
fq_tin_init(>tin);
fq_flow_init(>def_flow);
codel_vars_init(>def_cvars);
+   __skb_queue_head_init(>frags);
 
txqi->txq.vif = >vif;
 
@@ -1425,6 +1431,7 @@ void ieee80211_txq_purge(struct ieee80211_local *local,
struct fq_tin *tin = >tin;
 
fq_tin_reset(fq, tin, fq_skb_free_func);
+   ieee80211_purge_tx_queue(>hw, >frags);
 }
 
 int ieee80211_txq_setup_flows(struct ieee80211_local *local)
@@ -1481,33 +1488,61 @@ struct sk_buff *ieee80211_tx_dequeue(struct 
ieee80211_hw *hw,
 {
struct ieee80211_local *local = hw_to_local(hw);
struct txq_info *txqi = container_of(txq, struct txq_info, txq);
-   struct ieee80211_hdr *hdr;
struct sk_buff *skb = NULL;
struct fq *fq = >fq;
struct fq_tin *tin = >tin;
+   struct ieee80211_tx_info *info;
 
spin_lock_bh(>lock);
 
if (test_bit(IEEE80211_TXQ_STOP, >flags))
goto 

Re: [PATCH v2] bcma: use of_dma_configure() to set initial dma mask

2016-09-06 Thread Arnd Bergmann
On Monday, September 5, 2016 11:34:14 PM CEST Rafał Miłecki wrote:
> On 17 March 2016 at 10:39, Arnd Bergmann  wrote:
> > While fixing another bug, I noticed that bcma manually sets up
> > a dma_mask pointer for its child devices. We have a generic
> > helper for that now, which should be able to cope better with
> > any variations that might be needed to deal with cache coherency,
> > unusual DMA address offsets, iommus, or limited DMA masks, none
> > of which are currently handled here.
> >
> > This changes the core to use the of_dma_configure(), like
> > we do for platform devices that are probed directly from
> > DT.
> >
> > Signed-off-by: Arnd Bergmann 
> 
> I applied this patch and tested on BCM47081 based device. I still got
> bgmac working which surely uses DMA.

Thanks!

> There is only 1 ARM wireless SoC
> using bcma (BCM47198) but its WiFi core isn't supported by b43.
> 
> Any tips what else to test? SPI core/driver doesn't use DMA. Maybe
> NAND core does, but we don't use it.
> 

If there is nothing else using this, then the patch won't cause
a regression ;-)

Arnd


Re: [PATCH] ath10k: advertize hardware packet loss mechanism

2016-09-06 Thread kbuild test robot
Hi Rajkumar,

[auto build test ERROR on ath6kl/ath-next]
[also build test ERROR on v4.8-rc5 next-20160906]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]
[Suggest to use git(>=2.9.0) format-patch --base= (or --base=auto for 
convenience) to record what (public, well-known) commit your patch series was 
built on]
[Check https://git-scm.com/docs/git-format-patch for more information]

url:
https://github.com/0day-ci/linux/commits/Rajkumar-Manoharan/ath10k-advertize-hardware-packet-loss-mechanism/20160906-151148
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git ath-next
config: i386-randconfig-x008-201636 (attached as .config)
compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All error/warnings (new ones prefixed by >>):

   In file included from drivers/net/wireless/ath/ath10k/mac.h:21:0,
from drivers/net/wireless/ath/ath10k/mac.c:18:
   drivers/net/wireless/ath/ath10k/mac.c: In function 'ath10k_mac_register':
>> include/net/mac80211.h:2206:57: error: 'IEEE80211_HW_REPORTS_LOW_ACK' 
>> undeclared (first use in this function)
#define ieee80211_hw_set(hw, flg) _ieee80211_hw_set(hw, IEEE80211_HW_##flg)
^
>> drivers/net/wireless/ath/ath10k/mac.c:7884:2: note: in expansion of macro 
>> 'ieee80211_hw_set'
 ieee80211_hw_set(ar->hw, REPORTS_LOW_ACK);
 ^~~~
   include/net/mac80211.h:2206:57: note: each undeclared identifier is reported 
only once for each function it appears in
#define ieee80211_hw_set(hw, flg) _ieee80211_hw_set(hw, IEEE80211_HW_##flg)
^
>> drivers/net/wireless/ath/ath10k/mac.c:7884:2: note: in expansion of macro 
>> 'ieee80211_hw_set'
 ieee80211_hw_set(ar->hw, REPORTS_LOW_ACK);
 ^~~~

vim +/ieee80211_hw_set +7884 drivers/net/wireless/ath/ath10k/mac.c

  7868  BIT(NL80211_IFTYPE_P2P_GO);
  7869  
  7870  ieee80211_hw_set(ar->hw, SIGNAL_DBM);
  7871  ieee80211_hw_set(ar->hw, SUPPORTS_PS);
  7872  ieee80211_hw_set(ar->hw, SUPPORTS_DYNAMIC_PS);
  7873  ieee80211_hw_set(ar->hw, MFP_CAPABLE);
  7874  ieee80211_hw_set(ar->hw, REPORTS_TX_ACK_STATUS);
  7875  ieee80211_hw_set(ar->hw, HAS_RATE_CONTROL);
  7876  ieee80211_hw_set(ar->hw, AP_LINK_PS);
  7877  ieee80211_hw_set(ar->hw, SPECTRUM_MGMT);
  7878  ieee80211_hw_set(ar->hw, SUPPORT_FAST_XMIT);
  7879  ieee80211_hw_set(ar->hw, CONNECTION_MONITOR);
  7880  ieee80211_hw_set(ar->hw, SUPPORTS_PER_STA_GTK);
  7881  ieee80211_hw_set(ar->hw, WANT_MONITOR_VIF);
  7882  ieee80211_hw_set(ar->hw, CHANCTX_STA_CSA);
  7883  ieee80211_hw_set(ar->hw, QUEUE_CONTROL);
> 7884  ieee80211_hw_set(ar->hw, REPORTS_LOW_ACK);
  7885  
  7886  if (!test_bit(ATH10K_FLAG_RAW_MODE, >dev_flags))
  7887  ieee80211_hw_set(ar->hw, SW_CRYPTO_CONTROL);
  7888  
  7889  ar->hw->wiphy->features |= NL80211_FEATURE_STATIC_SMPS;
  7890  ar->hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
  7891  
  7892  if (ar->ht_cap_info & WMI_HT_CAP_DYNAMIC_SMPS)

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


Re: [v2] bcma: use of_dma_configure() to set initial dma mask

2016-09-06 Thread Kalle Valo
Arnd Bergmann  writes:

> On Saturday, September 3, 2016 2:08:19 PM CEST Kalle Valo wrote:
>> Arnd Bergmann  wrote:
>> > While fixing another bug, I noticed that bcma manually sets up
>> > a dma_mask pointer for its child devices. We have a generic
>> > helper for that now, which should be able to cope better with
>> > any variations that might be needed to deal with cache coherency,
>> > unusual DMA address offsets, iommus, or limited DMA masks, none
>> > of which are currently handled here.
>> > 
>> > This changes the core to use the of_dma_configure(), like
>> > we do for platform devices that are probed directly from
>> > DT.
>> > 
>> > Signed-off-by: Arnd Bergmann 
>> 
>> Nobody tested this, so I'll drop the patch.
>
> Should I resend it? I think it's still required.

Sorry, I misunderstood your comments then. No need to resend, I readded
this to my queue:

https://patchwork.kernel.org/patch/8608751/

-- 
Kalle Valo


Re: Debugging RTL8192CU firmware loading on 3.12 powerpc

2016-09-06 Thread Sven Eckelmann
On Freitag, 2. September 2016 12:53:28 CEST Larry Finger wrote:
[...]
> The patch I included in my previous E-mail, and attached here,  does get the
> firmware loaded correctly. There is still a problem that prevents
> authentication. I'm still looking for that issue.

Thanks for the fast update. I am currently testing your patch. It looks like 
the initial error is now gone. The hostapd also starts but beaconing doesn't 
seem to work at all (no error from the kernel/hostapd but the device is not 
sending anything). I am currently checking how beaconing is supposed to work 
in your driver. Maybe I will spot something useful.

Kind regards,
Sven

signature.asc
Description: This is a digitally signed message part.


Re: [PATCH] ath10k: ensure pdev sta kickout threshold is set.

2016-09-06 Thread Manoharan, Rajkumar
[...]

> +int ath10k_mac_set_pdev_kickout(struct ath10k *ar)
> +{
> +   u32 param = ar->wmi.pdev_param->sta_kickout_th;
> +   int rv;
> +
> +   rv = ath10k_wmi_pdev_set_param(ar, param,
> +  ar->sta_xretry_kickout_thresh);
> +   if (rv) {
> +   ath10k_warn(ar, "failed to set sta kickout threshold to %d: 
> %d\n",
> +   ar->sta_xretry_kickout_thresh, rv);
> +   }
> +   return rv;
> +}
>
Ben,

I plan to get rid of setting station kickout threshold from host. Each firmware 
revision (i.e qca988x, qca99x0, ipq4019)  follows different logic based on hw 
capability for station kickout and follows different default paramters. So 
configuring common threshold will affect firmware logic. Better to get rid of 
these configuration from host driver and let firmware to work with default 
parameters.

Also I could not find out sta_xretry_kickout_thresh definition in upstream 
driver. Have you posted any changes for the same?

-Rajkumar

[NetDev] [ANNOUNCE] Netdev 1.2 weekly updates (6th September, 2016)

2016-09-06 Thread Hajime Tazaki

Hello folks,

Tokyo is still being in a hot weather but it'll start
comfortable autumn very soon.

Here is an weekly update of Netdev 1.2 Tokyo.

We again extended the deadline of early bird registration.
Please don't miss the discount ticket - and your early
registration will be definitely helpful to prepare the
conference.

http://netdevconf.org/1.2/registration.html


== Newly accepted sessions ==

Here is newly accepted sessions in the last week.  We're
going to announce keynote talks once we confirmed so, stay
tune for a while.

Full list of accepted sessions is available here.

http://netdevconf.org/1.2/accepted-sessions.html

* Workshop

- nftables workshop
  by Pablo Neira Ayuso

* Talk

- Data center networking stack
  by Tom Herbert

- Single Virtual function driver for current and future Intel Network devices
  by Anjali Singhai Jain, Mitch Williams, Jesse Brandeburg

- Stacked Vlan: Performance Improvement and Challenges
  by Toshiaki Makita

- eBPF/XDP hardware offload to SmartNICs
  by Jakub Kicinski, Nic Viljoen

- Using SR-IOV offload with application like openVswitch
  by Rony Efraim, Or Gerlitz

* BoF

- Accelerating container network with channel based IO
  by Rony Efraim, Or Gerlitz


== Our sponsors ==

- Platinum
Verizon, Facebook, Cumulus Networks
- Gold
Mojatatu Networks, VMWare, Google, NTT, LinkedIn
- Silver
NetApp, IIJ, Netronome, SolarFlare, Mellanox, Sophos
- Bronze
Zen Load Balancer

Twitter: https://twitter.com/netdev01
Web: http://netdevconf.org/1.2/

== Others ==

Be prepared for your travel ! Hotel and travel information
are available on the web pages.

http://netdevconf.org/1.2/travel.html
http://netdevconf.org/1.2/hotel.html


Looking forward to seeing you in Tokyo very soon.

-- Hajime




[PATCH] ath10k: advertize hardware packet loss mechanism

2016-09-06 Thread Rajkumar Manoharan
Indicate hardware (or firmware) supports that CQM packet-loss report
will be generated based on station kickout algorithm. As of now mac80211
tracks connection loss by missing msdu counts (50) whereas ath10k
firmware tracks them by missing ppdus (+ BAR tries). While firmware is
trying to adapt its rate table, mac80211 might send out low_ack event to
hostapd. This is causing frequent connect and disconnect iteration under
noisy environment or when station is roaming around.

Signed-off-by: Rajkumar Manoharan 
---
 drivers/net/wireless/ath/ath10k/mac.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index 79525f769db6..bae7662e7207 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -7865,6 +7865,7 @@ int ath10k_mac_register(struct ath10k *ar)
ieee80211_hw_set(ar->hw, WANT_MONITOR_VIF);
ieee80211_hw_set(ar->hw, CHANCTX_STA_CSA);
ieee80211_hw_set(ar->hw, QUEUE_CONTROL);
+   ieee80211_hw_set(ar->hw, REPORTS_LOW_ACK);
 
if (!test_bit(ATH10K_FLAG_RAW_MODE, >dev_flags))
ieee80211_hw_set(ar->hw, SW_CRYPTO_CONTROL);
-- 
2.9.3



[PATCH] mac80211: allow driver to handle packet-loss mechanism

2016-09-06 Thread Rajkumar Manoharan
mac80211 keeps track of missing acks and triggers CQM packet-loss
mechanism whenever consecutive msdu failure reaches threshold limit
(STA_LOST_PKT_THRESHOLD). Drivers like ath10k offlaoded rate countrol
and aggregation to firmware. Such drivers have its own connection
monitoring algorithm that is offloaded to firmware for triggering
station kickout due to excessive tries. In VHT mode, single PPDU can have
more than 50 msdus at higher rates. Under noisy environment, single ppdu
failure can cause station kickout by current mac80211 lost_packet mechanism
while firmware is trying to adapt its rate table. This is causing frequent
connect and disconnect iteration when station is roaming around.

In such scenario, driver (or firmware) is not given enough chance to
tune its rate control. So for devices that report low ack events, add a
hardware flag to rely on their mechnism.

Signed-off-by: Rajkumar Manoharan 
---
 include/net/mac80211.h | 5 +
 net/mac80211/debugfs.c | 1 +
 net/mac80211/status.c  | 6 ++
 3 files changed, 12 insertions(+)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index cca510a585c3..6619fa1ccd01 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -2014,6 +2014,10 @@ struct ieee80211_txq {
  * @IEEE80211_HW_TX_FRAG_LIST: Hardware (or driver) supports sending frag_list
  * skbs, needed for zero-copy software A-MSDU.
  *
+ * @IEEE80211_HW_REPORTS_LOW_ACK: The driver (or firmware) reports low ack 
event
+ * based on its own algorithm. For such devices, mac80211 does not report
+ * low ack event based on lost packets.
+ *
  * @NUM_IEEE80211_HW_FLAGS: number of hardware flags, used for sizing arrays
  */
 enum ieee80211_hw_flags {
@@ -2054,6 +2058,7 @@ enum ieee80211_hw_flags {
IEEE80211_HW_USES_RSS,
IEEE80211_HW_TX_AMSDU,
IEEE80211_HW_TX_FRAG_LIST,
+   IEEE80211_HW_REPORTS_LOW_ACK,
 
/* keep last, obviously */
NUM_IEEE80211_HW_FLAGS
diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c
index 2906c1004e1a..e433319a67f1 100644
--- a/net/mac80211/debugfs.c
+++ b/net/mac80211/debugfs.c
@@ -302,6 +302,7 @@ static const char *hw_flag_names[] = {
FLAG(USES_RSS),
FLAG(TX_AMSDU),
FLAG(TX_FRAG_LIST),
+   FLAG(REPORTS_LOW_ACK),
 #undef FLAG
 };
 
diff --git a/net/mac80211/status.c b/net/mac80211/status.c
index fabd9ff710d9..6121ed196630 100644
--- a/net/mac80211/status.c
+++ b/net/mac80211/status.c
@@ -557,6 +557,12 @@ static void ieee80211_report_used_skb(struct 
ieee80211_local *local,
 static void ieee80211_lost_packet(struct sta_info *sta,
  struct ieee80211_tx_info *info)
 {
+   /* Driver supports its own algorithm for triggering CQM packet-loss
+* mechanism.
+*/
+   if (ieee80211_hw_check(>local->hw, REPORTS_LOW_ACK))
+   return;
+
/* This packet was aggregated but doesn't carry status info */
if ((info->flags & IEEE80211_TX_CTL_AMPDU) &&
!(info->flags & IEEE80211_TX_STAT_AMPDU))
-- 
2.9.3