Re: Searching new home for ath[59]k-devel mailing lists

2017-01-13 Thread Michael Renzmann
Hi Kalle.

Thanks for your response.

Kalle Valo wrote:
> So feel free to close both of the lists and thanks for the heads up.

Ok. I will send a shutdown notice to both lists during the next few days,
then unsubscribe all subscribers, and close the lists for new
subscriptions. I intend to keep the mailing list archives online, for
reference purpose.

> Are you planning to update the MAINTAINERS file or should I?

It would be great if you could take care of that.

Someone should also update the "Mailing list" section of [1] accordingly.
I guess one needs to have a valid user account for that to do, and I don't
have one atm.

[1] https://wireless.wiki.kernel.org/en/users/Drivers/ath9k

Bye, Mike



[PATCH] mwifiex: don't complain about 'unknown event id: 0x63'

2017-01-13 Thread Brian Norris
Marvell folks tell me this is a debugging event that the driver doesn't
need to handle, but on 8997 w/ firmware 16.68.1.p97, I see several of
these sorts of messages at (for instance) boot time:

[   13.825848] mwifiex_pcie :01:00.0: event: unknown event id: 0x63
[   14.838561] mwifiex_pcie :01:00.0: event: unknown event id: 0x63
[   14.850397] mwifiex_pcie :01:00.0: event: unknown event id: 0x63
[   32.529923] mwifiex_pcie :01:00.0: event: unknown event id: 0x63

Let's handle this "event" with a much lower verbosity.

Signed-off-by: Brian Norris 
---
 drivers/net/wireless/marvell/mwifiex/fw.h| 1 +
 drivers/net/wireless/marvell/mwifiex/sta_event.c | 4 
 2 files changed, 5 insertions(+)

diff --git a/drivers/net/wireless/marvell/mwifiex/fw.h 
b/drivers/net/wireless/marvell/mwifiex/fw.h
index 55db158fd156..cb6a1a81d44e 100644
--- a/drivers/net/wireless/marvell/mwifiex/fw.h
+++ b/drivers/net/wireless/marvell/mwifiex/fw.h
@@ -550,6 +550,7 @@ enum mwifiex_channel_flags {
 #define EVENT_TX_DATA_PAUSE 0x0055
 #define EVENT_EXT_SCAN_REPORT   0x0058
 #define EVENT_RXBA_SYNC 0x0059
+#define EVENT_UNKNOWN_DEBUG 0x0063
 #define EVENT_BG_SCAN_STOPPED   0x0065
 #define EVENT_REMAIN_ON_CHAN_EXPIRED0x005f
 #define EVENT_MULTI_CHAN_INFO   0x006a
diff --git a/drivers/net/wireless/marvell/mwifiex/sta_event.c 
b/drivers/net/wireless/marvell/mwifiex/sta_event.c
index 9df0c4dc06ed..96503d3d053f 100644
--- a/drivers/net/wireless/marvell/mwifiex/sta_event.c
+++ b/drivers/net/wireless/marvell/mwifiex/sta_event.c
@@ -1009,6 +1009,10 @@ int mwifiex_process_sta_event(struct mwifiex_private 
*priv)
adapter->event_skb->len -
sizeof(eventcause));
break;
+   /* Debugging event; not used, but let's not print an ERROR for it. */
+   case EVENT_UNKNOWN_DEBUG:
+   mwifiex_dbg(adapter, EVENT, "event: debug\n");
+   break;
default:
mwifiex_dbg(adapter, ERROR, "event: unknown event id: %#x\n",
eventcause);
-- 
2.11.0.483.g087da7b7c-goog



[PATCH v2 1/3] mwifiex: pcie: use posted write to wake up firmware

2017-01-13 Thread Brian Norris
Depending on system factors (e.g., the PCIe link PM state), the first
read to wake up the Wifi firmware can take a long time. There is no
reason to use a (blocking, non-posted) read at this point, so let's just
use a write instead. Write vs. read doesn't matter functionality-wise --
it's just a dummy operation. But let's make sure to re-write with the
correct "ready" signature, since we check for that in other parts of the
driver.

This has been shown to decrease the time spent blocking in this function
on RK3399.

Signed-off-by: Brian Norris 
---
v2:
 * write FIRMWARE_READY_PCIE instead of 0
---
 drivers/net/wireless/marvell/mwifiex/pcie.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c 
b/drivers/net/wireless/marvell/mwifiex/pcie.c
index 66226c615be0..3f4cda2d3b61 100644
--- a/drivers/net/wireless/marvell/mwifiex/pcie.c
+++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
@@ -458,7 +458,6 @@ static void mwifiex_delay_for_sleep_cookie(struct 
mwifiex_adapter *adapter,
 /* This function wakes up the card by reading fw_status register. */
 static int mwifiex_pm_wakeup_card(struct mwifiex_adapter *adapter)
 {
-   u32 fw_status;
struct pcie_service_card *card = adapter->card;
const struct mwifiex_pcie_card_reg *reg = card->pcie.reg;
 
@@ -468,10 +467,10 @@ static int mwifiex_pm_wakeup_card(struct mwifiex_adapter 
*adapter)
if (reg->sleep_cookie)
mwifiex_pcie_dev_wakeup_delay(adapter);
 
-   /* Reading fw_status register will wakeup device */
-   if (mwifiex_read_reg(adapter, reg->fw_status, _status)) {
+   /* Accessing fw_status register will wakeup device */
+   if (mwifiex_write_reg(adapter, reg->fw_status, FIRMWARE_READY_PCIE)) {
mwifiex_dbg(adapter, ERROR,
-   "Reading fw_status register failed\n");
+   "Writing fw_status register failed\n");
return -1;
}
 
-- 
2.11.0.483.g087da7b7c-goog



[PATCH v2 3/3] mwifiex: pcie: read FROMDEVICE DMA-able memory with READ_ONCE()

2017-01-13 Thread Brian Norris
In mwifiex_delay_for_sleep_cookie(), we're looping and waiting for the
PCIe endpoint to write a magic value back to memory, to signal that it
has finished going to sleep. We're not letting the compiler know that
this might change underneath our feet though. Let's do that, for good
hygiene.

I'm not aware of this fixing any concrete problems. I also give no
guarantee that this loop is actually correct in any other way, but at
least this looks like an improvement to me.

Signed-off-by: Brian Norris 
---
v2: new in v2
---
 drivers/net/wireless/marvell/mwifiex/pcie.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c 
b/drivers/net/wireless/marvell/mwifiex/pcie.c
index 194e0e04c3b1..c2511f212502 100644
--- a/drivers/net/wireless/marvell/mwifiex/pcie.c
+++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
@@ -440,7 +440,7 @@ static void mwifiex_delay_for_sleep_cookie(struct 
mwifiex_adapter *adapter,
 
for (count = 0; count < max_delay_loop_cnt; count++) {
buffer = card->cmdrsp_buf->data - INTF_HEADER_LEN;
-   sleep_cookie = *(u32 *)buffer;
+   sleep_cookie = READ_ONCE(*(u32 *)buffer);
 
if (sleep_cookie == MWIFIEX_DEF_SLEEP_COOKIE) {
mwifiex_dbg(adapter, INFO,
-- 
2.11.0.483.g087da7b7c-goog



[PATCH v2 2/3] mwifiex: pcie: don't loop/retry interrupt status checks

2017-01-13 Thread Brian Norris
The following sequence occurs when using IEEE power-save on 8997:
(a) driver sees SLEEP event
(b) driver issues SLEEP CONFIRM
(c) driver recevies CMD interrupt; within the interrupt processing loop,
we do (d) and (e):
(d) wait for FW sleep cookie (and often time out; it takes a while), FW
is putting card into low power mode
(e) re-check PCIE_HOST_INT_STATUS register; quit loop with 0 value

But at (e), no one actually signaled an interrupt (i.e., we didn't check
adapter->int_status). And what's more, because the card is going to
sleep, this register read appears to take a very long time in some cases
-- 3 milliseconds in my case!

Now, I propose that (e) is completely unnecessary. If there were any
additional interrupts signaled after the start of this loop, then the
interrupt handler would have set adapter->int_status to non-zero and
queued more work for the main loop -- and we'd catch it on the next
iteration of the main loop.

So this patch drops all the looping/re-reading of PCIE_HOST_INT_STATUS,
which avoids the problematic (and slow) register read in step (e).

Incidentally, this is a very similar issue to the one fixed in commit
ec815dd2a5f1 ("mwifiex: prevent register accesses after host is
sleeping"), except that the register read is just very slow instead of
fatal in this case.

Tested on 8997 in both MSI and (though not technically supported at the
moment) MSI-X mode.

Signed-off-by: Brian Norris 
---
v2:
 * new in v2, replacing an attempt to mess with step (d) above
---
 drivers/net/wireless/marvell/mwifiex/pcie.c | 102 +---
 1 file changed, 32 insertions(+), 70 deletions(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c 
b/drivers/net/wireless/marvell/mwifiex/pcie.c
index 3f4cda2d3b61..194e0e04c3b1 100644
--- a/drivers/net/wireless/marvell/mwifiex/pcie.c
+++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
@@ -2332,79 +2332,41 @@ static int mwifiex_process_pcie_int(struct 
mwifiex_adapter *adapter)
}
}
}
-   while (pcie_ireg & HOST_INTR_MASK) {
-   if (pcie_ireg & HOST_INTR_DNLD_DONE) {
-   pcie_ireg &= ~HOST_INTR_DNLD_DONE;
-   mwifiex_dbg(adapter, INTR,
-   "info: TX DNLD Done\n");
-   ret = mwifiex_pcie_send_data_complete(adapter);
-   if (ret)
-   return ret;
-   }
-   if (pcie_ireg & HOST_INTR_UPLD_RDY) {
-   pcie_ireg &= ~HOST_INTR_UPLD_RDY;
-   mwifiex_dbg(adapter, INTR,
-   "info: Rx DATA\n");
-   ret = mwifiex_pcie_process_recv_data(adapter);
-   if (ret)
-   return ret;
-   }
-   if (pcie_ireg & HOST_INTR_EVENT_RDY) {
-   pcie_ireg &= ~HOST_INTR_EVENT_RDY;
-   mwifiex_dbg(adapter, INTR,
-   "info: Rx EVENT\n");
-   ret = mwifiex_pcie_process_event_ready(adapter);
-   if (ret)
-   return ret;
-   }
-
-   if (pcie_ireg & HOST_INTR_CMD_DONE) {
-   pcie_ireg &= ~HOST_INTR_CMD_DONE;
-   if (adapter->cmd_sent) {
-   mwifiex_dbg(adapter, INTR,
-   "info: CMD sent Interrupt\n");
-   adapter->cmd_sent = false;
-   }
-   /* Handle command response */
-   ret = mwifiex_pcie_process_cmd_complete(adapter);
-   if (ret)
-   return ret;
-   if (adapter->hs_activated)
-   return ret;
-   }
-
-   if (card->msi_enable) {
-   spin_lock_irqsave(>int_lock, flags);
-   adapter->int_status = 0;
-   spin_unlock_irqrestore(>int_lock, flags);
-   }
-
-   if (mwifiex_pcie_ok_to_access_hw(adapter)) {
-   if (mwifiex_read_reg(adapter, PCIE_HOST_INT_STATUS,
-_ireg)) {
-   mwifiex_dbg(adapter, ERROR,
-   "Read register failed\n");
-   return -1;
-   }
 
-   if ((pcie_ireg != 0x) && (pcie_ireg)) {
-   if (mwifiex_write_reg(adapter,
- PCIE_HOST_INT_STATUS,
- ~pcie_ireg)) {
-   mwifiex_dbg(adapter, ERROR,
-

Re: [PATCH 2/2] mwifiex: pcie: don't delay for sleep cookie when not required

2017-01-13 Thread Brian Norris
On Thu, Jan 12, 2017 at 01:02:32PM -0800, Brian Norris wrote:
> Wifi modules like 8997 don't support the "sleep cookie", and so most of
> the time, we just time out in the mwifiex_delay_for_sleep_cookie()
> function ("max count reached while accessing sleep cookie"). This is a
> waste of time, and we should skip it for modules without the sleep
> cookie flag.
> 
> Additionally, this delay is sometimes counterproductive. For instance,
> when PCIe ASPM is enabled, this extra delay can leave the link idle for
> long enough to re-enter a low-power state even while we are trying to
> wake the module, compounding an additional delay when it comes time to
> read the next register (e.g., the interrupt status). On some systems,
> this is detrimental to overall system latency.
> 
> Signed-off-by: Brian Norris 
> ---
> Tested on Marvell 8997, but would be good to get confirmation from Marvell.

It would still be good to get comment from Marvell here, but elsewhere,
they've told me that this breaks the expected handshake procedure. I'm
still not quite sure how that is true, considering that we time out in
the mwifiex_delay_for_sleep_cookie() all the time anyway (so what's the
point of waiting then?)...

But anyway I think I have discovered a proper root cause [1] that is
causing my latency problems above. I'll post a v2 which replaces the
current patch with something else.

Brian

[1] The short version: re-reading the interrupt status register from the
card after we've sent it to sleep takes a long time. We shouldn't do
that.

>  drivers/net/wireless/marvell/mwifiex/pcie.c | 12 +++-
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c 
> b/drivers/net/wireless/marvell/mwifiex/pcie.c
> index 435ba879ef29..11e0673617c7 100644
> --- a/drivers/net/wireless/marvell/mwifiex/pcie.c
> +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
> @@ -1712,11 +1712,13 @@ static int mwifiex_pcie_process_cmd_complete(struct 
> mwifiex_adapter *adapter)
>   "Write register failed\n");
>   return -1;
>   }
> - mwifiex_delay_for_sleep_cookie(adapter,
> -MWIFIEX_MAX_DELAY_COUNT);
> - while (reg->sleep_cookie && (count++ < 10) &&
> -mwifiex_pcie_ok_to_access_hw(adapter))
> - usleep_range(50, 60);
> + if (reg->sleep_cookie) {
> + mwifiex_delay_for_sleep_cookie(adapter,
> +
> MWIFIEX_MAX_DELAY_COUNT);
> + while ((count++ < 10) &&
> +mwifiex_pcie_ok_to_access_hw(adapter))
> + usleep_range(50, 60);
> + }
>   mwifiex_pcie_enable_host_int(adapter);
>   mwifiex_process_sleep_confirm_resp(adapter, skb->data,
>  skb->len);
> -- 
> 2.11.0.390.gc69c2f50cf-goog
> 


Re: [PATCH 1/2] mwifiex: pcie: use posted write to wake up firmware

2017-01-13 Thread Brian Norris
On Thu, Jan 12, 2017 at 01:02:31PM -0800, Brian Norris wrote:
> Depending on system factors (e.g., the PCIe link PM state), the first
> read to wake up the Wifi firmware can take a long time. There is no
> reason to use a (blocking, non-posted) read at this point, so let's just
> use a write instead. Write vs. read doesn't matter functionality-wise --
> it's just a dummy operation.
> 
> This has been shown to decrease the time spent blocking in this function
> on a Rockchip RK3399 SoC.
> 
> Signed-off-by: Brian Norris 
> ---
>  drivers/net/wireless/marvell/mwifiex/pcie.c | 7 +++
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c 
> b/drivers/net/wireless/marvell/mwifiex/pcie.c
> index 66226c615be0..435ba879ef29 100644
> --- a/drivers/net/wireless/marvell/mwifiex/pcie.c
> +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
> @@ -458,7 +458,6 @@ static void mwifiex_delay_for_sleep_cookie(struct 
> mwifiex_adapter *adapter,
>  /* This function wakes up the card by reading fw_status register. */
>  static int mwifiex_pm_wakeup_card(struct mwifiex_adapter *adapter)
>  {
> - u32 fw_status;
>   struct pcie_service_card *card = adapter->card;
>   const struct mwifiex_pcie_card_reg *reg = card->pcie.reg;
>  
> @@ -468,10 +467,10 @@ static int mwifiex_pm_wakeup_card(struct 
> mwifiex_adapter *adapter)
>   if (reg->sleep_cookie)
>   mwifiex_pcie_dev_wakeup_delay(adapter);
>  
> - /* Reading fw_status register will wakeup device */
> - if (mwifiex_read_reg(adapter, reg->fw_status, _status)) {
> + /* Accessing fw_status register will wakeup device */
> + if (mwifiex_write_reg(adapter, reg->fw_status, 0)) {

As Amit noted to me elsewhere, the firmware only writes this status once
at FW init time to FIRMWARE_READY_PCIE, and we later check it in a few
places. So I noticed that this actually breaks re-probing the adapter
(e.g., 'rmmod mwifiex_pcie; modprobe mwifiex_pcie'); the second time,
we'll fail to find the FIRMWARE_READY_PCIE signature, and so we'll
abort.

I'll resend this patch with s/0/FIRMWARE_READY_PCIE/ instead.

Brian

>   mwifiex_dbg(adapter, ERROR,
> - "Reading fw_status register failed\n");
> + "Writing fw_status register failed\n");
>   return -1;
>   }
>  
> -- 
> 2.11.0.390.gc69c2f50cf-goog
> 


Re: [OpenWrt-Devel] [RFC] [PULL REQUEST] rt2x00 patches from OpenWrt.org

2017-01-13 Thread Daniel Golle
On Fri, Jan 13, 2017 at 05:17:23PM +0100, Daniel Golle wrote:
> On Fri, Jan 13, 2017 at 04:59:59PM +0100, Johannes Berg wrote:
> > 
> > > The advantage of pull requests is that author information can be
> > > preserved more easily. Running git format-patch results in most
> > > patches
> > > having wrong SMTP sender information due to the assumption that the
> > > patch author is the same person also submitting the patch.
> > > So in practise, this would either require changing the From: (and
> > > thus
> > > Author) to myself or having most mails eaten by anti-spam measures
> > > due
> > > to non-matching SPF which prohibits my SMTP to send mail on behalf of
> > > the original authors of the patches.
> > > 
> > 
> > This is completely untrue. If the first line of the *body* of the email
> > is "From: ..." then this is preserved as the author information by git
> > am, and doing so is also the default in git format-patch/send-email
> > when the author doesn't match the email configuration.
> 
> Thanks for the clarification, I'll then submit the patches via
> git format-patch.

I posted all patches on the mailing list and bundled them up on
patchwork.
https://patchwork.kernel.org/bundle/dangole/rt2x00-from-openwrt/

Cheers


Daniel


[PATCH 12/40] rt2x00: rt2800lib: add channel configuration function for RF3853

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

Signed-off-by: Gabor Juhos 
[dan...@makrotopia.org: replaced udelay with usleep_range]
---
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 208 +
 1 file changed, 208 insertions(+)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index 15bcad1156d9..eda886648daf 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -2661,6 +2661,211 @@ static void rt2800_config_channel_rf3053(struct 
rt2x00_dev *rt2x00dev,
}
 }
 
+static void rt2800_config_channel_rf3853(struct rt2x00_dev *rt2x00dev,
+struct ieee80211_conf *conf,
+struct rf_channel *rf,
+struct channel_info *info)
+{
+   u8 rfcsr;
+   u8 bbp;
+   u8 pwr1, pwr2, pwr3;
+
+   const bool txbf_enabled = false; /* TODO */
+
+   /* TODO: add band selection */
+
+   if (rf->channel <= 14)
+   rt2800_rfcsr_write(rt2x00dev, 6, 0x40);
+   else if (rf->channel < 132)
+   rt2800_rfcsr_write(rt2x00dev, 6, 0x80);
+   else
+   rt2800_rfcsr_write(rt2x00dev, 6, 0x40);
+
+   rt2800_rfcsr_write(rt2x00dev, 8, rf->rf1);
+   rt2800_rfcsr_write(rt2x00dev, 9, rf->rf3);
+
+   if (rf->channel <= 14)
+   rt2800_rfcsr_write(rt2x00dev, 11, 0x46);
+   else
+   rt2800_rfcsr_write(rt2x00dev, 11, 0x48);
+
+   if (rf->channel <= 14)
+   rt2800_rfcsr_write(rt2x00dev, 12, 0x1a);
+   else
+   rt2800_rfcsr_write(rt2x00dev, 12, 0x52);
+
+   rt2800_rfcsr_write(rt2x00dev, 13, 0x12);
+
+   rt2800_rfcsr_read(rt2x00dev, 1, );
+   rt2x00_set_field8(, RFCSR1_RX0_PD, 0);
+   rt2x00_set_field8(, RFCSR1_TX0_PD, 0);
+   rt2x00_set_field8(, RFCSR1_RX1_PD, 0);
+   rt2x00_set_field8(, RFCSR1_TX1_PD, 0);
+   rt2x00_set_field8(, RFCSR1_RX2_PD, 0);
+   rt2x00_set_field8(, RFCSR1_TX2_PD, 0);
+   rt2x00_set_field8(, RFCSR1_RF_BLOCK_EN, 1);
+   rt2x00_set_field8(, RFCSR1_PLL_PD, 1);
+
+   switch (rt2x00dev->default_ant.tx_chain_num) {
+   case 3:
+   rt2x00_set_field8(, RFCSR1_TX2_PD, 1);
+   /* fallthrough */
+   case 2:
+   rt2x00_set_field8(, RFCSR1_TX1_PD, 1);
+   /* fallthrough */
+   case 1:
+   rt2x00_set_field8(, RFCSR1_TX0_PD, 1);
+   break;
+   }
+
+   switch (rt2x00dev->default_ant.rx_chain_num) {
+   case 3:
+   rt2x00_set_field8(, RFCSR1_RX2_PD, 1);
+   /* fallthrough */
+   case 2:
+   rt2x00_set_field8(, RFCSR1_RX1_PD, 1);
+   /* fallthrough */
+   case 1:
+   rt2x00_set_field8(, RFCSR1_RX0_PD, 1);
+   break;
+   }
+   rt2800_rfcsr_write(rt2x00dev, 1, rfcsr);
+
+   rt2800_adjust_freq_offset(rt2x00dev);
+
+   rt2800_rfcsr_read(rt2x00dev, 30, );
+   if (!conf_is_ht40(conf))
+   rfcsr &= ~(0x06);
+   else
+   rfcsr |= 0x06;
+   rt2800_rfcsr_write(rt2x00dev, 30, rfcsr);
+
+   if (rf->channel <= 14)
+   rt2800_rfcsr_write(rt2x00dev, 31, 0xa0);
+   else
+   rt2800_rfcsr_write(rt2x00dev, 31, 0x80);
+
+   if (conf_is_ht40(conf))
+   rt2800_rfcsr_write(rt2x00dev, 32, 0x80);
+   else
+   rt2800_rfcsr_write(rt2x00dev, 32, 0xd8);
+
+   if (rf->channel <= 14)
+   rt2800_rfcsr_write(rt2x00dev, 34, 0x3c);
+   else
+   rt2800_rfcsr_write(rt2x00dev, 34, 0x20);
+
+   /* loopback RF_BS */
+   rt2800_rfcsr_read(rt2x00dev, 36, );
+   if (rf->channel <= 14)
+   rt2x00_set_field8(, RFCSR36_RF_BS, 1);
+   else
+   rt2x00_set_field8(, RFCSR36_RF_BS, 0);
+   rt2800_rfcsr_write(rt2x00dev, 36, rfcsr);
+
+   if (rf->channel <= 14)
+   rfcsr = 0x23;
+   else if (rf->channel < 100)
+   rfcsr = 0x36;
+   else if (rf->channel < 132)
+   rfcsr = 0x32;
+   else
+   rfcsr = 0x30;
+
+   if (txbf_enabled)
+   rfcsr |= 0x40;
+
+   rt2800_rfcsr_write(rt2x00dev, 39, rfcsr);
+
+   if (rf->channel <= 14)
+   rt2800_rfcsr_write(rt2x00dev, 44, 0x93);
+   else
+   rt2800_rfcsr_write(rt2x00dev, 44, 0x9b);
+
+   if (rf->channel <= 14)
+   rfcsr = 0xbb;
+   else if (rf->channel < 100)
+   rfcsr = 0xeb;
+   else if (rf->channel < 132)
+   rfcsr = 0xb3;
+   else
+   rfcsr = 0x9b;
+   rt2800_rfcsr_write(rt2x00dev, 45, rfcsr);
+
+   if (rf->channel <= 14)
+   rfcsr = 0x8e;
+   else
+   rfcsr = 0x8a;
+
+   if (txbf_enabled)
+   rfcsr |= 0x20;
+
+   

[PATCH 13/40] rt2x00: rt2800lib: enable RF3853 support

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

Signed-off-by: Gabor Juhos 
---
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index eda886648daf..7c5061d5328d 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -7447,6 +7447,7 @@ static int rt2800_init_eeprom(struct rt2x00_dev 
*rt2x00dev)
case RF3290:
case RF3320:
case RF3322:
+   case RF3853:
case RF5360:
case RF5362:
case RF5370:
-- 
2.11.0



[PATCH 14/40] rt2x00: rt2800lib: add MAC register initialization for RT3883

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

Signed-off-by: Gabor Juhos 
---
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index 7c5061d5328d..cf9a8cfd4fbc 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -5020,6 +5020,12 @@ static int rt2800_init_registers(struct rt2x00_dev 
*rt2x00dev)
rt2800_register_write(rt2x00dev, TX_SW_CFG2,
  0x);
}
+   } else if (rt2x00_rt(rt2x00dev, RT3883)) {
+   rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x0402);
+   rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x);
+   rt2800_register_write(rt2x00dev, TX_SW_CFG2, 0x0004);
+   rt2800_register_write(rt2x00dev, TX_TXBF_CFG_0, 0x8000fc21);
+   rt2800_register_write(rt2x00dev, TX_TXBF_CFG_3, 0x9c40);
} else if (rt2x00_rt(rt2x00dev, RT5390) ||
   rt2x00_rt(rt2x00dev, RT5392)) {
rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x0404);
@@ -5053,7 +5059,10 @@ static int rt2800_init_registers(struct rt2x00_dev 
*rt2x00dev)
 
rt2800_register_read(rt2x00dev, MAX_LEN_CFG, );
rt2x00_set_field32(, MAX_LEN_CFG_MAX_MPDU, AGGREGATION_SIZE);
-   if (rt2x00_rt_rev_gte(rt2x00dev, RT2872, REV_RT2872E) ||
+   if (rt2x00_rt(rt2x00dev, RT3883)) {
+   drv_data->max_psdu = 3;
+   rt2x00_set_field32(, MAX_LEN_CFG_MAX_PSDU, 3);
+   } else if (rt2x00_rt_rev_gte(rt2x00dev, RT2872, REV_RT2872E) ||
rt2x00_rt(rt2x00dev, RT2883) ||
rt2x00_rt_rev_lt(rt2x00dev, RT3070, REV_RT3070E)) {
drv_data->max_psdu = 2;
@@ -5211,6 +5220,11 @@ static int rt2800_init_registers(struct rt2x00_dev 
*rt2x00dev)
reg = rt2x00_rt(rt2x00dev, RT5592) ? 0x0082 : 0x0002;
rt2800_register_write(rt2x00dev, TXOP_HLDR_ET, reg);
 
+   if (rt2x00_rt(rt2x00dev, RT3883)) {
+   rt2800_register_write(rt2x00dev, TX_FBK_CFG_3S_0, 0x12111008);
+   rt2800_register_write(rt2x00dev, TX_FBK_CFG_3S_1, 0x16151413);
+   }
+
rt2800_register_read(rt2x00dev, TX_RTS_CFG, );
rt2x00_set_field32(, TX_RTS_CFG_AUTO_RTS_RETRY_LIMIT, 32);
rt2x00_set_field32(, TX_RTS_CFG_RTS_THRES,
-- 
2.11.0



[RFC 04/10] ath10k: new fw fetch functionality

2017-01-13 Thread Erik Stromdahl
A new function for creating the fw file name dynamically.

Since both SDIO and USB based chipsets will use different
firmware from the PCIe and AHB chipsets, the fw file name
is created dynamically.

The new firmware names are:

For PCIe and AHB:
firmware-.bin (same as before)

For SDIO:
firmware-sdio-.bin

For USB:
firmware-usb-.bin

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/core.c | 56 --
 drivers/net/wireless/ath/ath10k/hw.h   |  4 +++
 2 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index e985316..c275a52 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -1284,44 +1284,40 @@ int ath10k_core_fetch_firmware_api_n(struct ath10k *ar, 
const char *name,
return ret;
 }
 
+static void ath10k_core_get_fw_name(struct ath10k *ar, char *fw_name,
+   int fw_api)
+{
+   if ((ar->hif.bus != ATH10K_BUS_PCI) && (ar->hif.bus != ATH10K_BUS_AHB))
+   snprintf(fw_name, ATH10K_FW_FILE_NAME_MAX_LEN, "%s-%s-%d.bin",
+ATH10K_FW_FILE_BASE, ath10k_bus_str(ar->hif.bus),
+fw_api);
+   else
+   snprintf(fw_name, ATH10K_FW_FILE_NAME_MAX_LEN, "%s-%d.bin",
+ATH10K_FW_FILE_BASE, fw_api);
+}
+
 static int ath10k_core_fetch_firmware_files(struct ath10k *ar)
 {
-   int ret;
+   int ret, i;
+   char fw_name[ATH10K_FW_FILE_NAME_MAX_LEN];
 
/* calibration file is optional, don't check for any errors */
ath10k_fetch_cal_file(ar);
 
-   ar->fw_api = 5;
-   ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api);
-
-   ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API5_FILE,
-  >normal_mode_fw.fw_file);
-   if (ret == 0)
-   goto success;
-
-   ar->fw_api = 4;
-   ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api);
-
-   ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API4_FILE,
-  >normal_mode_fw.fw_file);
-   if (ret == 0)
-   goto success;
-
-   ar->fw_api = 3;
-   ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api);
-
-   ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API3_FILE,
-  >normal_mode_fw.fw_file);
-   if (ret == 0)
-   goto success;
+   for (i = 5; i >= 2; i--) {
+   ar->fw_api = i;
+   ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n",
+  ar->fw_api);
 
-   ar->fw_api = 2;
-   ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api);
+   ath10k_core_get_fw_name(ar, fw_name, ar->fw_api);
+   ret = ath10k_core_fetch_firmware_api_n(ar, fw_name,
+  
>normal_mode_fw.fw_file);
+   if (!ret)
+   goto success;
+   }
 
-   ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API2_FILE,
-  >normal_mode_fw.fw_file);
-   if (ret)
-   return ret;
+   /* We end up here if we couldn't fetch any firmware */
+   return ret;
 
 success:
ath10k_dbg(ar, ATH10K_DBG_BOOT, "using fw api %d\n", ar->fw_api);
diff --git a/drivers/net/wireless/ath/ath10k/hw.h 
b/drivers/net/wireless/ath/ath10k/hw.h
index 6bdea86..9f4cd76 100644
--- a/drivers/net/wireless/ath/ath10k/hw.h
+++ b/drivers/net/wireless/ath/ath10k/hw.h
@@ -128,6 +128,10 @@ enum qca9377_chip_id_rev {
 #define QCA4019_HW_1_0_BOARD_DATA_FILE "board.bin"
 #define QCA4019_HW_1_0_PATCH_LOAD_ADDR  0x1234
 
+#define ATH10K_FW_FILE_NAME_MAX_LEN100
+
+#define ATH10K_FW_FILE_BASE"firmware"
+
 #define ATH10K_FW_API2_FILE"firmware-2.bin"
 #define ATH10K_FW_API3_FILE"firmware-3.bin"
 
-- 
2.7.4



[RFC 07/10] ath10k: per target configurablity of various items

2017-01-13 Thread Erik Stromdahl
Added ability to set bus type and configure the max number of
peers in the ath10k_hw_params struct.

With this functionality it is possible to have a different
hw configuration depending on bus type for the same radio
chipset.

E.g. SDIO and USB devices using the same chipset as PCIe
devices will potentially use different board files and perhaps
other configuration parameters.

One such parameter is the max number of peers.
Instead of using a default value (suitable for PCIe devices)
derived from the WMI op version, a per target value can be
used instead.

This is needed by the QCA9377 USB device in order to prevent
the target fw to crash after HTT RX ring cfg is issued.

Apparently, the QCA9377 HL device does not seem to handle the
same amount of peers as the LL devices.

A new struct ath10k_hw_params item for QCA9377 USB devices was
also added to ath10k_hw_params_list.

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/core.c| 55 ++-
 drivers/net/wireless/ath/ath10k/core.h|  7 
 drivers/net/wireless/ath/ath10k/hw.h  | 23 +
 drivers/net/wireless/ath/ath10k/wmi-tlv.c |  4 +--
 4 files changed, 72 insertions(+), 17 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index 573e772..31a9471 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -282,6 +282,28 @@ static const struct ath10k_hw_params 
ath10k_hw_params_list[] = {
.decap_align_bytes = 4,
},
{
+   .id = QCA9377_HW_1_1_DEV_VERSION,
+   .dev_id = QCA9377_1_0_DEVICE_ID,
+   .name = "qca9377 hw1.1 usb",
+   .patch_load_addr = QCA9377_HW_1_0_PATCH_LOAD_ADDR,
+   .uart_pin = 6,
+   .otp_exe_param = 0,
+   .channel_counters_freq_hz = 88000,
+   .max_probe_resp_desc_thres = 0,
+   .cal_data_len = 8124,
+   .fw = {
+   .dir = QCA9377_HW_1_0_FW_DIR,
+   .board = QCA9377_HW_1_0_BOARD_DATA_FILE_USB,
+   .board_size = QCA9377_BOARD_DATA_SZ,
+   .board_ext_size = QCA9377_BOARD_EXT_DATA_SZ,
+   },
+   .hw_ops = _ops,
+   .decap_align_bytes = 4,
+   .max_num_peers = TARGET_QCA9377_HL_NUM_PEERS,
+   .is_high_latency = true,
+   .bus = ATH10K_BUS_USB,
+   },
+   {
.id = QCA4019_HW_1_0_DEV_VERSION,
.dev_id = 0,
.name = "qca4019 hw1.0",
@@ -1487,9 +1509,19 @@ static int ath10k_init_hw_params(struct ath10k *ar)
for (i = 0; i < ARRAY_SIZE(ath10k_hw_params_list); i++) {
hw_params = _hw_params_list[i];
 
-   if (hw_params->id == ar->target_version &&
-   hw_params->dev_id == ar->dev_id)
-   break;
+   if (ar->is_high_latency) {
+   /* High latency devices will use different fw depending
+* on if it is a USB or SDIO device.
+*/
+   if (hw_params->bus == ar->hif.bus &&
+   hw_params->id == ar->target_version &&
+   hw_params->dev_id == ar->dev_id)
+   break;
+   } else {
+   if (hw_params->id == ar->target_version &&
+   hw_params->dev_id == ar->dev_id)
+   break;
+   }
}
 
if (i == ARRAY_SIZE(ath10k_hw_params_list)) {
@@ -1580,6 +1612,7 @@ static void ath10k_core_set_coverage_class_work(struct 
work_struct *work)
 static int ath10k_core_init_firmware_features(struct ath10k *ar)
 {
struct ath10k_fw_file *fw_file = >normal_mode_fw.fw_file;
+   int max_num_peers;
 
if (test_bit(ATH10K_FW_FEATURE_WMI_10_2, fw_file->fw_features) &&
!test_bit(ATH10K_FW_FEATURE_WMI_10X, fw_file->fw_features)) {
@@ -1664,7 +1697,7 @@ static int ath10k_core_init_firmware_features(struct 
ath10k *ar)
 
switch (fw_file->wmi_op_version) {
case ATH10K_FW_WMI_OP_VERSION_MAIN:
-   ar->max_num_peers = TARGET_NUM_PEERS;
+   max_num_peers = TARGET_NUM_PEERS;
ar->max_num_stations = TARGET_NUM_STATIONS;
ar->max_num_vdevs = TARGET_NUM_VDEVS;
ar->htt.max_num_pending_tx = TARGET_NUM_MSDU_DESC;
@@ -1676,10 +1709,10 @@ static int ath10k_core_init_firmware_features(struct 
ath10k *ar)
case ATH10K_FW_WMI_OP_VERSION_10_2:
case ATH10K_FW_WMI_OP_VERSION_10_2_4:
if (ath10k_peer_stats_enabled(ar)) {
-   ar->max_num_peers = TARGET_10X_TX_STATS_NUM_PEERS;
+   max_num_peers = TARGET_10X_TX_STATS_NUM_PEERS;

[RFC 05/10] ath10k: htt: RX ring config HL support

2017-01-13 Thread Erik Stromdahl
Special HTT RX ring config message used by high latency
devices.

The main difference between HL and LL is that HL devices
do not use shared memory between device and host and thus,
no host paddr's are added to the RX config message.

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/htt.c|  5 +++-
 drivers/net/wireless/ath/ath10k/htt.h|  1 +
 drivers/net/wireless/ath/ath10k/htt_tx.c | 51 
 3 files changed, 56 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/htt.c 
b/drivers/net/wireless/ath/ath10k/htt.c
index cd160b1..29ed4af 100644
--- a/drivers/net/wireless/ath/ath10k/htt.c
+++ b/drivers/net/wireless/ath/ath10k/htt.c
@@ -258,7 +258,10 @@ int ath10k_htt_setup(struct ath10k_htt *htt)
if (status)
return status;
 
-   status = ath10k_htt_send_rx_ring_cfg_ll(htt);
+   if (ar->is_high_latency)
+   status = ath10k_htt_send_rx_ring_cfg_hl(htt);
+   else
+   status = ath10k_htt_send_rx_ring_cfg_ll(htt);
if (status) {
ath10k_warn(ar, "failed to setup rx ring: %d\n",
status);
diff --git a/drivers/net/wireless/ath/ath10k/htt.h 
b/drivers/net/wireless/ath/ath10k/htt.h
index 44b25cf..3d1bd6f 100644
--- a/drivers/net/wireless/ath/ath10k/htt.h
+++ b/drivers/net/wireless/ath/ath10k/htt.h
@@ -1797,6 +1797,7 @@ int ath10k_htt_h2t_ver_req_msg(struct ath10k_htt *htt);
 int ath10k_htt_h2t_stats_req(struct ath10k_htt *htt, u8 mask, u64 cookie);
 int ath10k_htt_send_frag_desc_bank_cfg(struct ath10k_htt *htt);
 int ath10k_htt_send_rx_ring_cfg_ll(struct ath10k_htt *htt);
+int ath10k_htt_send_rx_ring_cfg_hl(struct ath10k_htt *htt);
 int ath10k_htt_h2t_aggr_cfg_msg(struct ath10k_htt *htt,
u8 max_subfrms_ampdu,
u8 max_subfrms_amsdu);
diff --git a/drivers/net/wireless/ath/ath10k/htt_tx.c 
b/drivers/net/wireless/ath/ath10k/htt_tx.c
index 86b427f..505d3ed 100644
--- a/drivers/net/wireless/ath/ath10k/htt_tx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_tx.c
@@ -692,6 +692,57 @@ int ath10k_htt_send_rx_ring_cfg_ll(struct ath10k_htt *htt)
return 0;
 }
 
+int ath10k_htt_send_rx_ring_cfg_hl(struct ath10k_htt *htt)
+{
+   struct ath10k *ar = htt->ar;
+   struct sk_buff *skb;
+   struct htt_cmd *cmd;
+   struct htt_rx_ring_setup_ring *ring;
+   const int num_rx_ring = 1;
+   u16 flags;
+   int len;
+   int ret;
+
+   /*
+* the HW expects the buffer to be an integral number of 4-byte
+* "words"
+*/
+   BUILD_BUG_ON(!IS_ALIGNED(HTT_RX_BUF_SIZE, 4));
+   BUILD_BUG_ON((HTT_RX_BUF_SIZE & HTT_MAX_CACHE_LINE_SIZE_MASK) != 0);
+
+   len = sizeof(cmd->hdr) + sizeof(cmd->rx_setup.hdr)
+   + (sizeof(*ring) * num_rx_ring);
+   skb = ath10k_htc_alloc_skb(ar, len);
+   if (!skb)
+   return -ENOMEM;
+
+   skb_put(skb, len);
+
+   cmd = (struct htt_cmd *)skb->data;
+   ring = >rx_setup.rings[0];
+
+   cmd->hdr.msg_type = HTT_H2T_MSG_TYPE_RX_RING_CFG;
+   cmd->rx_setup.hdr.num_rings = 1;
+
+   flags = 0;
+   flags |= HTT_RX_RING_FLAGS_MSDU_PAYLOAD;
+   flags |= HTT_RX_RING_FLAGS_UNICAST_RX;
+   flags |= HTT_RX_RING_FLAGS_MULTICAST_RX;
+
+   memset(ring, 0, sizeof(*ring));
+   ring->rx_ring_len = __cpu_to_le32(HTT_RX_RING_SIZE_MIN);
+   ring->rx_ring_bufsize = __cpu_to_le32(HTT_RX_BUF_SIZE);
+   ring->flags = __cpu_to_le16(flags);
+
+   ret = ath10k_htc_send(>ar->htc, htt->eid, skb);
+   if (ret) {
+   dev_kfree_skb_any(skb);
+   return ret;
+   }
+
+   return 0;
+}
+
 int ath10k_htt_h2t_aggr_cfg_msg(struct ath10k_htt *htt,
u8 max_subfrms_ampdu,
u8 max_subfrms_amsdu)
-- 
2.7.4



[RFC 00/10] ath10k usb support

2017-01-13 Thread Erik Stromdahl
This patch series adds usb support to ath10k.

The target device used during development was a Linksys WUSB6100M
based on QCA9377.

I have tried to verify that the patches have not broken the existing
PCIe support since some of the patches affect the generic code as well.
To this end I have used a QCA9880 PCIe device operating in STA mode.

This patch series is depending on my previous sdio RFC (currently
version 3) since both these implementations share a lot of common
code. Hence, the sdio patches must be applied before these patches
can be applied!

* overview of patches *

patch 1 adds some usb definitions needed by the HIF layer.

patch 2 contains the actual usb HIF implementation.

patch 3 adds a is_high_latency check functionality

patch 4 introduces a new mechanism for fw fetch where the bus name is
used to determine which files to fetch (so we can have different fw for
usb and sdio).

patch 5 adds a HL version of the RX ring config.
This patch is applicable for sdio as well.

patch 6 sets the AMPDU and AMSDU limit to 1 for HL interfaces.
I believe this is the same thing as disabling frame aggregation but
I am not entirely sure (perhaps it just disables aggregation from
target to host). The reason for this patch is to have a simple setup
as possible. I have tried without this patch and the behavior is
identical so perhaps it should be removed from the series.

patch 7 adds more members to the ath10k_hw_params structure. These is
done in order to make it easier to separate HL config from LL config.
Some of stuff in here could potentially be added as elements in the
firmware file.

patch 8 adds "start once" functionality. It is used to leave the target
running after the BMI init phase in ath10k_core_probe_fw.
Could potentially be added as an element in the firmware file.

The last two patches (9 and 10) adds high latency RX and TX support.
These patches are applicable for sdio as well.

* testing *

The following functionality have been tested:

- connection to an 802.11ac AP with WPA2 PSK security.
- dhcp lease of ipv4 address
- pinging of access point and a few other devices on my home network
- TX/RX of TCP and UDP messages using netcat

UDP and TCP RX/TX is unfortunately not stable.
Currently I am only capable of receiving ~2.7 Mbytes over TCP before
the device stops receiving.

My RX/TX test looks like this:

Computer A (receiver):
nc -l -p 12345 > /tmp/random-out

Computer B (transmitter):
time nc -w 3 192.168.1.233 12345 < random-test-file

192.168.1.233 was the IPv4 address the WUSB6100M was assigned on my
home network.

The TCP RX data is identical to the TX data (no data is lost) but the
receiver stops receiving after ~2.7 Mbytes, so the RX data (/tmp/random-out
in my example) will be a truncated version of the TX file (random-test-file)

Adding a "-u" flag to netcat will do the same with UDP instead of TCP.

IMPORTANT:
It is possible to make the fw crash if an unsupported command or a
command with an unsupported setting is issued. This was the initial
problem I had with a crashing firmware after the RX ring config.
In this particular case the problem was related to an invalid init
message (containing an invalid maximum number of peers setting). There
could be more of this stuff in there that has not yet been fixed.
Depending on how wpa_supplicant etc. is configured there is a possibility
that the usb device will receive an unsupported command and crash.
It this happens, please enable logging and post the logs on the ath10k
mailing list.

* usb firmware *

Special firmware for usb is needed.
Linksys provide firmware for the QCA9377 version here:

http://www.linksys.com/us/support-article?articleNum=198580

The firmware must be converted into ath10k firmware using the below
command:

ath10k-fwencoder --create \
--otp=otp_AR6320.bin \
--firmware=athwlan_AR6320.bin \
--set-wmi-op-version=tlv \
--set-htt-op-version=tlv \
--set-fw-api=5 \
--features=ignore-otp-result

The firmware should be named firmware-usb-5.bin and should be placed
in /lib/firmware/ath10k/QCA9377/hw1.0

A board file is also needed:

cd /lib/firmware/ath10k/QCA9377/hw1.0
ln -s eeprom_qca9377_7_1p1_Robin_clpc_XXX.bin board-usb.bin

Pre-converted firmware can be obtained from my github fork of
ath10k-firmware:

https://github.com/erstrom/ath10k-firmware.git
branch: usb

Erik Stromdahl (10):
  ath10k: various usb related definitions
  ath10k: usb support
  ath10k: high_latency detection
  ath10k: new fw fetch functionality
  ath10k: htt: RX ring config HL support
  ath10k: disable frame aggregation for high latency
  ath10k: per target configurablity of various items
  ath10k: add start_once support
  ath10k: htt: High latency TX support
  ath10k: htt: High latency RX support

 drivers/net/wireless/ath/ath10k/Kconfig   |6 +
 drivers/net/wireless/ath/ath10k/Makefile  |3 +
 drivers/net/wireless/ath/ath10k/core.c|  179 +++--
 drivers/net/wireless/ath/ath10k/core.h|   17 +-
 drivers/net/wireless/ath/ath10k/debug.h   

[RFC 01/10] ath10k: various usb related definitions

2017-01-13 Thread Erik Stromdahl
Definitions for USB based chipsets

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/core.h  | 3 +++
 drivers/net/wireless/ath/ath10k/debug.h | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/core.h 
b/drivers/net/wireless/ath/ath10k/core.h
index 1ffef90..3f865c0 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -75,6 +75,7 @@ enum ath10k_bus {
ATH10K_BUS_PCI,
ATH10K_BUS_AHB,
ATH10K_BUS_SDIO,
+   ATH10K_BUS_USB,
 };
 
 static inline const char *ath10k_bus_str(enum ath10k_bus bus)
@@ -86,6 +87,8 @@ static inline const char *ath10k_bus_str(enum ath10k_bus bus)
return "ahb";
case ATH10K_BUS_SDIO:
return "sdio";
+   case ATH10K_BUS_USB:
+   return "usb";
}
 
return "unknown";
diff --git a/drivers/net/wireless/ath/ath10k/debug.h 
b/drivers/net/wireless/ath/ath10k/debug.h
index 257d109..548ad54 100644
--- a/drivers/net/wireless/ath/ath10k/debug.h
+++ b/drivers/net/wireless/ath/ath10k/debug.h
@@ -40,6 +40,8 @@ enum ath10k_debug_mask {
ATH10K_DBG_AHB  = 0x8000,
ATH10K_DBG_SDIO = 0x0001,
ATH10K_DBG_SDIO_DUMP= 0x0002,
+   ATH10K_DBG_USB  = 0x0004,
+   ATH10K_DBG_USB_BULK = 0x0008,
ATH10K_DBG_ANY  = 0x,
 };
 
-- 
2.7.4



[RFC 10/10] ath10k: htt: High latency RX support

2017-01-13 Thread Erik Stromdahl
Special HTT RX handling for high latency interfaces.

Since no DMA physical addresses are used in the RX ring
config message (this is not supported by the high latency
devices), no RX ring is allocated.
All RX skb's are allocated by the driver and passed directly
to mac80211 in the HTT RX indication handler.

A nice side effect of this is that no huge buffer will be
allocated with dma_alloc_coherent. On embedded systems with
limited memory resources, the allocation of the RX ring is
prone to fail.

Some tweaks made to "make it work":

Removal of protected bit in 802.11 header frame control field.
The chipset seems to do hw decryption but the frame_control
protected bit is still set.

This is necessary for mac80211 not to drop the frame.

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/core.c| 38 -
 drivers/net/wireless/ath/ath10k/htt.h | 47 +++
 drivers/net/wireless/ath/ath10k/htt_rx.c  | 95 ++-
 drivers/net/wireless/ath/ath10k/rx_desc.h | 15 +
 4 files changed, 177 insertions(+), 18 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index 250e32b..41a1ca6 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -1917,10 +1917,12 @@ int ath10k_core_start(struct ath10k *ar, enum 
ath10k_firmware_mode mode,
goto err_wmi_detach;
}
 
-   status = ath10k_htt_rx_alloc(>htt);
-   if (status) {
-   ath10k_err(ar, "failed to alloc htt rx: %d\n", status);
-   goto err_htt_tx_detach;
+   if (!ar->is_high_latency) {
+   status = ath10k_htt_rx_alloc(>htt);
+   if (status) {
+   ath10k_err(ar, "failed to alloc htt rx: %d\n", status);
+   goto err_htt_tx_detach;
+   }
}
 
status = ath10k_hif_start(ar);
@@ -2025,16 +2027,20 @@ int ath10k_core_start(struct ath10k *ar, enum 
ath10k_firmware_mode mode,
goto err_hif_stop;
}
 
-   /* If firmware indicates Full Rx Reorder support it must be used in a
-* slightly different manner. Let HTT code know.
-*/
-   ar->htt.rx_ring.in_ord_rx = !!(test_bit(WMI_SERVICE_RX_FULL_REORDER,
-   ar->wmi.svc_map));
+   if (!ar->is_high_latency) {
+   /* If firmware indicates Full Rx Reorder support it must be
+* used in a slightly different manner. Let HTT code know.
+*/
+   ar->htt.rx_ring.in_ord_rx =
+   !!(test_bit(WMI_SERVICE_RX_FULL_REORDER,
+   ar->wmi.svc_map));
 
-   status = ath10k_htt_rx_ring_refill(ar);
-   if (status) {
-   ath10k_err(ar, "failed to refill htt rx ring: %d\n", status);
-   goto err_hif_stop;
+   status = ath10k_htt_rx_ring_refill(ar);
+   if (status) {
+   ath10k_err(ar, "failed to refill htt rx ring: %d\n",
+  status);
+   goto err_hif_stop;
+   }
}
 
if (ar->max_num_vdevs >= 64)
@@ -2063,7 +2069,8 @@ int ath10k_core_start(struct ath10k *ar, enum 
ath10k_firmware_mode mode,
 err_hif_stop:
ath10k_hif_stop(ar);
 err_htt_rx_detach:
-   ath10k_htt_rx_free(>htt);
+   if (!ar->is_high_latency)
+   ath10k_htt_rx_free(>htt);
 err_htt_tx_detach:
ath10k_htt_tx_free(>htt);
 err_wmi_detach:
@@ -2108,7 +2115,8 @@ void ath10k_core_stop(struct ath10k *ar)
 
ath10k_hif_stop(ar);
ath10k_htt_tx_stop(>htt);
-   ath10k_htt_rx_free(>htt);
+   if (!ar->is_high_latency)
+   ath10k_htt_rx_free(>htt);
ath10k_wmi_detach(ar);
ar->is_started = false;
 }
diff --git a/drivers/net/wireless/ath/ath10k/htt.h 
b/drivers/net/wireless/ath/ath10k/htt.h
index d40b3a0..a51bf57 100644
--- a/drivers/net/wireless/ath/ath10k/htt.h
+++ b/drivers/net/wireless/ath/ath10k/htt.h
@@ -645,6 +645,15 @@ struct htt_rx_indication {
struct htt_rx_indication_mpdu_range mpdu_ranges[0];
 } __packed;
 
+/* High latency version of the RX indication */
+struct htt_rx_indication_hl {
+   struct htt_rx_indication_hdr hdr;
+   struct htt_rx_indication_ppdu ppdu;
+   struct htt_rx_indication_prefix prefix;
+   struct fw_rx_desc_hl fw_desc;
+   struct htt_rx_indication_mpdu_range mpdu_ranges[0];
+} __packed;
+
 static inline struct htt_rx_indication_mpdu_range *
htt_rx_ind_get_mpdu_ranges(struct htt_rx_indication *rx_ind)
 {
@@ -657,6 +666,18 @@ static inline struct htt_rx_indication_mpdu_range *
return ptr;
 }
 
+static inline struct htt_rx_indication_mpdu_range *
+   htt_rx_ind_get_mpdu_ranges_hl(struct htt_rx_indication_hl *rx_ind)
+{
+   void *ptr = rx_ind;
+
+   ptr += 

[RFC 02/10] ath10k: usb support

2017-01-13 Thread Erik Stromdahl
usb HIF implementation

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/Kconfig  |6 +
 drivers/net/wireless/ath/ath10k/Makefile |3 +
 drivers/net/wireless/ath/ath10k/usb.c| 1125 ++
 drivers/net/wireless/ath/ath10k/usb.h|  128 
 4 files changed, 1262 insertions(+)
 create mode 100644 drivers/net/wireless/ath/ath10k/usb.c
 create mode 100644 drivers/net/wireless/ath/ath10k/usb.h

diff --git a/drivers/net/wireless/ath/ath10k/Kconfig 
b/drivers/net/wireless/ath/ath10k/Kconfig
index 9a03178..c8b95e0 100644
--- a/drivers/net/wireless/ath/ath10k/Kconfig
+++ b/drivers/net/wireless/ath/ath10k/Kconfig
@@ -27,6 +27,12 @@ config ATH10K_SDIO
---help---
  This module adds support for SDIO/MMC bus
 
+config ATH10K_USB
+   tristate "Atheros ath10k USB support (EXPERIMENTAL)"
+   depends on ATH10K && USB
+   ---help---
+ This module adds support for USB bus
+
 config ATH10K_DEBUG
bool "Atheros ath10k debugging"
depends on ATH10K
diff --git a/drivers/net/wireless/ath/ath10k/Makefile 
b/drivers/net/wireless/ath/ath10k/Makefile
index b0b19a7..899b9b7 100644
--- a/drivers/net/wireless/ath/ath10k/Makefile
+++ b/drivers/net/wireless/ath/ath10k/Makefile
@@ -30,5 +30,8 @@ ath10k_pci-$(CONFIG_ATH10K_AHB) += ahb.o
 obj-$(CONFIG_ATH10K_SDIO) += ath10k_sdio.o
 ath10k_sdio-y += sdio.o
 
+obj-$(CONFIG_ATH10K_USB) += ath10k_usb.o
+ath10k_usb-y += usb.o
+
 # for tracing framework to find trace.h
 CFLAGS_trace.o := -I$(src)
diff --git a/drivers/net/wireless/ath/ath10k/usb.c 
b/drivers/net/wireless/ath/ath10k/usb.c
new file mode 100644
index 000..4ccf36a
--- /dev/null
+++ b/drivers/net/wireless/ath/ath10k/usb.c
@@ -0,0 +1,1125 @@
+/*
+ * Copyright (c) 2007-2011 Atheros Communications Inc.
+ * Copyright (c) 2011-2012 Qualcomm Atheros, Inc.
+ * Copyright (c) 2016 Erik Stromdahl.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include 
+#include 
+
+#include "debug.h"
+#include "core.h"
+#include "bmi.h"
+#include "hif.h"
+#include "htc.h"
+#include "usb.h"
+
+static void ath10k_usb_post_recv_transfers(struct ath10k *ar,
+  struct ath10k_usb_pipe *recv_pipe);
+
+/* inlined helper functions */
+
+static inline enum ath10k_htc_ep_id
+eid_from_htc_hdr(struct ath10k_htc_hdr *htc_hdr)
+{
+   return (enum ath10k_htc_ep_id)htc_hdr->eid;
+}
+
+static inline bool is_trailer_only_msg(struct ath10k_htc_hdr *htc_hdr)
+{
+   bool trailer_only = false;
+   u16 len = __le16_to_cpu(htc_hdr->len);
+
+   if (len == htc_hdr->trailer_len)
+   trailer_only = true;
+
+   return trailer_only;
+}
+
+/* pipe/urb operations */
+static struct ath10k_urb_context *
+ath10k_usb_alloc_urb_from_pipe(struct ath10k_usb_pipe *pipe)
+{
+   struct ath10k_urb_context *urb_context = NULL;
+   unsigned long flags;
+
+   spin_lock_irqsave(>ar_usb->cs_lock, flags);
+   if (!list_empty(>urb_list_head)) {
+   urb_context =
+   list_first_entry(>urb_list_head,
+struct ath10k_urb_context, link);
+   list_del(_context->link);
+   pipe->urb_cnt--;
+   }
+   spin_unlock_irqrestore(>ar_usb->cs_lock, flags);
+
+   return urb_context;
+}
+
+static void ath10k_usb_free_urb_to_pipe(struct ath10k_usb_pipe *pipe,
+   struct ath10k_urb_context *urb_context)
+{
+   unsigned long flags;
+
+   spin_lock_irqsave(>ar_usb->cs_lock, flags);
+   pipe->urb_cnt++;
+
+   list_add(_context->link, >urb_list_head);
+   spin_unlock_irqrestore(>ar_usb->cs_lock, flags);
+}
+
+static void ath10k_usb_cleanup_recv_urb(struct ath10k_urb_context *urb_context)
+{
+   dev_kfree_skb(urb_context->skb);
+   urb_context->skb = NULL;
+
+   ath10k_usb_free_urb_to_pipe(urb_context->pipe, urb_context);
+}
+
+static void ath10k_usb_free_pipe_resources(struct ath10k *ar,
+  struct ath10k_usb_pipe *pipe)
+{
+   if (!pipe->ar_usb) {
+   /* nothing allocated for this pipe */
+   return;
+   }
+
+   ath10k_dbg(ar, ATH10K_DBG_USB,
+  "free resources 

[RFC 03/10] ath10k: high_latency detection

2017-01-13 Thread Erik Stromdahl
The setup of high latency chips (USB and SDIO) is
sometimes different than for chips using low latency
interfaces.

The bus type is used to determine if the interface is
a high latency interface.

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/core.c | 1 +
 drivers/net/wireless/ath/ath10k/core.h | 7 +++
 2 files changed, 8 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index e34c734..e985316 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -2294,6 +2294,7 @@ struct ath10k *ath10k_core_create(size_t priv_size, 
struct device *dev,
ar->hw_rev = hw_rev;
ar->hif.ops = hif_ops;
ar->hif.bus = bus;
+   ar->is_high_latency = ath10k_is_high_latency(bus);
 
switch (hw_rev) {
case ATH10K_HW_QCA988X:
diff --git a/drivers/net/wireless/ath/ath10k/core.h 
b/drivers/net/wireless/ath/ath10k/core.h
index 3f865c0..c58250c 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -751,6 +751,8 @@ struct ath10k {
 
bool p2p;
 
+   bool is_high_latency;
+
struct {
enum ath10k_bus bus;
const struct ath10k_hif_ops *ops;
@@ -967,6 +969,11 @@ static inline bool ath10k_peer_stats_enabled(struct ath10k 
*ar)
return false;
 }
 
+static inline bool ath10k_is_high_latency(enum ath10k_bus bus)
+{
+   return ((bus == ATH10K_BUS_SDIO) || (bus == ATH10K_BUS_USB));
+}
+
 struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
  enum ath10k_bus bus,
  enum ath10k_hw_rev hw_rev,
-- 
2.7.4



[RFC 08/10] ath10k: add start_once support

2017-01-13 Thread Erik Stromdahl
Add possibility to configure the driver to only start target once.
This can reduce startup time of SDIO devices significantly since
loading the firmware can take a substantial amount of time.

The patch is also necessary for high latency devices in general
since it does not seem to be possible to rerun the BMI phase
(fw upload) without power-cycling the device.

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/core.c | 20 
 drivers/net/wireless/ath/ath10k/core.h |  2 ++
 drivers/net/wireless/ath/ath10k/hw.h   |  6 ++
 3 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index 31a9471..250e32b 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -302,6 +302,7 @@ static const struct ath10k_hw_params 
ath10k_hw_params_list[] = {
.max_num_peers = TARGET_QCA9377_HL_NUM_PEERS,
.is_high_latency = true,
.bus = ATH10K_BUS_USB,
+   .start_once = true,
},
{
.id = QCA4019_HW_1_0_DEV_VERSION,
@@ -1841,6 +1842,9 @@ int ath10k_core_start(struct ath10k *ar, enum 
ath10k_firmware_mode mode,
int status;
u32 val;
 
+   if (ar->is_started && ar->hw_params.start_once)
+   return 0;
+
lockdep_assert_held(>conf_mutex);
 
clear_bit(ATH10K_FLAG_CRASH_FLUSH, >dev_flags);
@@ -2053,6 +2057,7 @@ int ath10k_core_start(struct ath10k *ar, enum 
ath10k_firmware_mode mode,
if (status)
goto err_hif_stop;
 
+   ar->is_started = true;
return 0;
 
 err_hif_stop:
@@ -2105,6 +2110,7 @@ void ath10k_core_stop(struct ath10k *ar)
ath10k_htt_tx_stop(>htt);
ath10k_htt_rx_free(>htt);
ath10k_wmi_detach(ar);
+   ar->is_started = false;
 }
 EXPORT_SYMBOL(ath10k_core_stop);
 
@@ -2202,12 +2208,18 @@ static int ath10k_core_probe_fw(struct ath10k *ar)
goto err_unlock;
}
 
-   ath10k_debug_print_boot_info(ar);
-   ath10k_core_stop(ar);
+   /* Leave target running if hw_params.start_once is set */
+   if (ar->hw_params.start_once) {
+   mutex_unlock(>conf_mutex);
+   } else {
+   ath10k_debug_print_boot_info(ar);
+   ath10k_core_stop(ar);
 
-   mutex_unlock(>conf_mutex);
+   mutex_unlock(>conf_mutex);
+
+   ath10k_hif_power_down(ar);
+   }
 
-   ath10k_hif_power_down(ar);
return 0;
 
 err_unlock:
diff --git a/drivers/net/wireless/ath/ath10k/core.h 
b/drivers/net/wireless/ath/ath10k/core.h
index d9d7805..800f058 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -746,6 +746,8 @@ struct ath10k {
 
bool is_high_latency;
 
+   bool is_started;
+
struct {
enum ath10k_bus bus;
const struct ath10k_hif_ops *ops;
diff --git a/drivers/net/wireless/ath/ath10k/hw.h 
b/drivers/net/wireless/ath/ath10k/hw.h
index 33186be..04ae66d 100644
--- a/drivers/net/wireless/ath/ath10k/hw.h
+++ b/drivers/net/wireless/ath/ath10k/hw.h
@@ -436,6 +436,12 @@ struct ath10k_hw_params {
bool is_high_latency;
 
enum ath10k_bus bus;
+
+   /* Specifies whether or not the device should be started once.
+* If set, the device will be started once by the early fw probe
+* and it will not be terminated afterwards.
+*/
+   bool start_once;
 };
 
 struct htt_rx_desc;
-- 
2.7.4



[PATCH 40/40] rt2x00: correctly set HT20/HT40 filter

2017-01-13 Thread Daniel Golle
From: Serge Vasilugin 

Simple patch to correct HT20/HT40 switching.
Tested with Rt3290, Rt3352 and Rt5350

Signed-off-by: Serge Vasilugin 
[dan...@makrotopia.org: fixed code and commit message formatting]
---
 drivers/net/wireless/ralink/rt2x00/rt2800.h|  2 ++
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 13 +++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800.h 
b/drivers/net/wireless/ralink/rt2x00/rt2800.h
index f49babf2fbee..2fcb3eef65e6 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800.h
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h
@@ -2319,6 +2319,8 @@ struct mac_iveiv_entry {
 #define RFCSR30_RX_H20MFIELD8(0x04)
 #define RFCSR30_RX_VCM FIELD8(0x18)
 #define RFCSR30_RF_CALIBRATION FIELD8(0x80)
+#define RF3322_RFCSR30_TX_H20M FIELD8(0x01)
+#define RF3322_RFCSR30_RX_H20M FIELD8(0x02)
 
 /*
  * RFCSR 31:
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index 823bdc1b0322..c4e022edf119 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -3562,8 +3562,17 @@ static void rt2800_config_channel(struct rt2x00_dev 
*rt2x00dev,
rt2x00_rf(rt2x00dev, RF5390) ||
rt2x00_rf(rt2x00dev, RF5392)) {
rt2800_rfcsr_read(rt2x00dev, 30, );
-   rt2x00_set_field8(, RFCSR30_TX_H20M, 0);
-   rt2x00_set_field8(, RFCSR30_RX_H20M, 0);
+   if (rt2x00_rf(rt2x00dev, RF3322)) {
+   rt2x00_set_field8(, RF3322_RFCSR30_TX_H20M,
+ conf_is_ht40(conf));
+   rt2x00_set_field8(, RF3322_RFCSR30_RX_H20M,
+ conf_is_ht40(conf));
+   } else {
+   rt2x00_set_field8(, RFCSR30_TX_H20M,
+ conf_is_ht40(conf));
+   rt2x00_set_field8(, RFCSR30_RX_H20M,
+ conf_is_ht40(conf));
+   }
rt2800_rfcsr_write(rt2x00dev, 30, rfcsr);
 
rt2800_rfcsr_read(rt2x00dev, 3, );
-- 
2.11.0



[RFC 09/10] ath10k: htt: High latency TX support

2017-01-13 Thread Erik Stromdahl
Add HTT TX function for HL interfaces.
Intended for SDIO and USB.

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/htt.h|  9 ++--
 drivers/net/wireless/ath/ath10k/htt_tx.c | 72 +++-
 drivers/net/wireless/ath/ath10k/mac.c|  5 ++-
 3 files changed, 80 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/htt.h 
b/drivers/net/wireless/ath/ath10k/htt.h
index dd9e582..d40b3a0 100644
--- a/drivers/net/wireless/ath/ath10k/htt.h
+++ b/drivers/net/wireless/ath/ath10k/htt.h
@@ -1826,9 +1826,12 @@ int ath10k_htt_tx_mgmt_inc_pending(struct ath10k_htt 
*htt, bool is_mgmt,
 int ath10k_htt_tx_alloc_msdu_id(struct ath10k_htt *htt, struct sk_buff *skb);
 void ath10k_htt_tx_free_msdu_id(struct ath10k_htt *htt, u16 msdu_id);
 int ath10k_htt_mgmt_tx(struct ath10k_htt *htt, struct sk_buff *);
-int ath10k_htt_tx(struct ath10k_htt *htt,
- enum ath10k_hw_txrx_mode txmode,
- struct sk_buff *msdu);
+int ath10k_htt_tx_ll(struct ath10k_htt *htt,
+enum ath10k_hw_txrx_mode txmode,
+struct sk_buff *msdu);
+int ath10k_htt_tx_hl(struct ath10k_htt *htt,
+enum ath10k_hw_txrx_mode txmode,
+struct sk_buff *msdu);
 void ath10k_htt_rx_pktlog_completion_handler(struct ath10k *ar,
 struct sk_buff *skb);
 int ath10k_htt_txrx_compl_task(struct ath10k *ar, int budget);
diff --git a/drivers/net/wireless/ath/ath10k/htt_tx.c 
b/drivers/net/wireless/ath/ath10k/htt_tx.c
index 505d3ed..e64c249 100644
--- a/drivers/net/wireless/ath/ath10k/htt_tx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_tx.c
@@ -945,8 +945,76 @@ int ath10k_htt_mgmt_tx(struct ath10k_htt *htt, struct 
sk_buff *msdu)
return res;
 }
 
-int ath10k_htt_tx(struct ath10k_htt *htt, enum ath10k_hw_txrx_mode txmode,
- struct sk_buff *msdu)
+#define HTT_TX_HL_NEEDED_HEADROOM \
+   (unsigned int)(sizeof(struct htt_cmd_hdr) + \
+   sizeof(struct htt_data_tx_desc) + \
+   sizeof(struct ath10k_htc_hdr))
+
+int ath10k_htt_tx_hl(struct ath10k_htt *htt, enum ath10k_hw_txrx_mode txmode,
+struct sk_buff *msdu)
+{
+   struct ath10k *ar = htt->ar;
+   int res, data_len;
+   struct htt_cmd_hdr *cmd_hdr;
+   struct htt_data_tx_desc *tx_desc;
+   struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(msdu);
+   u8 flags0;
+   u16 flags1 = 0;
+
+   data_len = msdu->len;
+   flags0 = SM(txmode, HTT_DATA_TX_DESC_FLAGS0_PKT_TYPE);
+
+   if (skb_cb->flags & ATH10K_SKB_F_NO_HWCRYPT)
+   flags0 |= HTT_DATA_TX_DESC_FLAGS0_NO_ENCRYPT;
+
+   if (msdu->ip_summed == CHECKSUM_PARTIAL &&
+   !test_bit(ATH10K_FLAG_RAW_MODE, >dev_flags)) {
+   flags1 |= HTT_DATA_TX_DESC_FLAGS1_CKSUM_L3_OFFLOAD;
+   flags1 |= HTT_DATA_TX_DESC_FLAGS1_CKSUM_L4_OFFLOAD;
+   }
+
+   /* Prepend the HTT header and TX desc struct to the data message
+* and realloc the skb if it does not have enough headroom.
+*/
+   if (skb_headroom(msdu) < HTT_TX_HL_NEEDED_HEADROOM) {
+   struct sk_buff *tmp_skb = msdu;
+
+   ath10k_dbg(htt->ar, ATH10K_DBG_HTT,
+  "Not enough headroom in skb. Current headroom: %u, 
needed: %u. Reallocating...\n",
+  skb_headroom(msdu), HTT_TX_HL_NEEDED_HEADROOM);
+   msdu = skb_realloc_headroom(msdu, HTT_TX_HL_NEEDED_HEADROOM);
+   kfree_skb(tmp_skb);
+   if (!msdu) {
+   ath10k_warn(htt->ar, "htt hl tx: Unable to realloc 
skb!\n");
+   res = -ENOMEM;
+   goto out;
+   }
+   }
+
+   skb_push(msdu, sizeof(*cmd_hdr));
+   skb_push(msdu, sizeof(*tx_desc));
+   cmd_hdr = (struct htt_cmd_hdr *)msdu->data;
+   tx_desc = (struct htt_data_tx_desc *)(msdu->data + sizeof(*cmd_hdr));
+
+   cmd_hdr->msg_type = HTT_H2T_MSG_TYPE_TX_FRM;
+   tx_desc->flags0 = flags0;
+   tx_desc->flags1 = __cpu_to_le16(flags1);
+   tx_desc->len = __cpu_to_le16(data_len);
+   tx_desc->id = 0;
+   tx_desc->frags_paddr = 0; /* always zero */
+   /* Initialize peer_id to INVALID_PEER because this is NOT
+* Reinjection path
+*/
+   tx_desc->peerid = __cpu_to_le16(HTT_INVALID_PEERID);
+
+   res = ath10k_htc_send(>ar->htc, htt->eid, msdu);
+
+out:
+   return res;
+}
+
+int ath10k_htt_tx_ll(struct ath10k_htt *htt, enum ath10k_hw_txrx_mode txmode,
+struct sk_buff *msdu)
 {
struct ath10k *ar = htt->ar;
struct device *dev = ar->dev;
diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index 28bf199..477e170 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -3531,7 +3531,10 @@ static int 

[RFC 06/10] ath10k: disable frame aggregation for high latency

2017-01-13 Thread Erik Stromdahl
This patch disables frame aggregation for HL interfaces.
It is safest to do so until a mechanism for setting the limits
from fw etc. has been implemented.

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/core.c | 9 +++--
 drivers/net/wireless/ath/ath10k/htt.h  | 4 
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index c275a52..573e772 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -1615,8 +1615,13 @@ static int ath10k_core_init_firmware_features(struct 
ath10k *ar)
return -EINVAL;
}
 
-   ar->htt.max_num_amsdu = ATH10K_HTT_MAX_NUM_AMSDU_DEFAULT;
-   ar->htt.max_num_ampdu = ATH10K_HTT_MAX_NUM_AMPDU_DEFAULT;
+   if (ar->is_high_latency) {
+   ar->htt.max_num_amsdu = ATH10K_HTT_MAX_NUM_AMSDU_HL;
+   ar->htt.max_num_ampdu = ATH10K_HTT_MAX_NUM_AMPDU_HL;
+   } else {
+   ar->htt.max_num_amsdu = ATH10K_HTT_MAX_NUM_AMSDU_DEFAULT;
+   ar->htt.max_num_ampdu = ATH10K_HTT_MAX_NUM_AMPDU_DEFAULT;
+   }
 
if (rawmode) {
if (!test_bit(ATH10K_FW_FEATURE_RAW_MODE_SUPPORT,
diff --git a/drivers/net/wireless/ath/ath10k/htt.h 
b/drivers/net/wireless/ath/ath10k/htt.h
index 3d1bd6f..dd9e582 100644
--- a/drivers/net/wireless/ath/ath10k/htt.h
+++ b/drivers/net/wireless/ath/ath10k/htt.h
@@ -1777,6 +1777,10 @@ struct htt_rx_desc {
 #define ATH10K_HTT_MAX_NUM_AMSDU_DEFAULT 3
 #define ATH10K_HTT_MAX_NUM_AMPDU_DEFAULT 64
 
+/* Disable frame aggregation for high latency devices */
+#define ATH10K_HTT_MAX_NUM_AMSDU_HL 1
+#define ATH10K_HTT_MAX_NUM_AMPDU_HL 1
+
 int ath10k_htt_connect(struct ath10k_htt *htt);
 int ath10k_htt_init(struct ath10k *ar);
 int ath10k_htt_setup(struct ath10k_htt *htt);
-- 
2.7.4



[PATCH 38/40] rt2x00: add support for RT5350 WiSoC

2017-01-13 Thread Daniel Golle
From: Michel Stempin 

Support for the RT5350 WiSoC was added to OpenWrt after having a
lengthy debate about the legality of the original submission, see
https://lists.openwrt.org/pipermail/openwrt-devel/2013-January/018224.html
MTK/Ralink Acked replied and says we can merge this patch under the GPL.
https://dev.openwrt.org/changeset/36177

Signed-off-by: Serge Vasilugin 
Tested-by: Michel Stempin 
Acked-by: John Crispin 
[dan...@makrotopia.org: added commit message, fixed code formatting]
---
 drivers/net/wireless/ralink/rt2x00/rt2800.h|   1 +
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 131 +++--
 drivers/net/wireless/ralink/rt2x00/rt2x00.h|   1 +
 3 files changed, 126 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800.h 
b/drivers/net/wireless/ralink/rt2x00/rt2800.h
index 14c94034a707..f49babf2fbee 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800.h
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h
@@ -74,6 +74,7 @@
 #define RF3070 0x3070
 #define RF3290 0x3290
 #define RF3853 0x3853
+#define RF5350 0x5350
 #define RF5360 0x5360
 #define RF5362 0x5362
 #define RF5370 0x5370
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index 6a24892476c3..5f49117b9035 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -3050,6 +3050,13 @@ static void rt2800_config_channel_rf53xx(struct 
rt2x00_dev *rt2x00dev,
 
rt2800_rfcsr_write(rt2x00dev, 59,
   r59_non_bt[idx]);
+   } else if (rt2x00_rt(rt2x00dev, RT5350)) {
+   static const char r59_non_bt[] = {0x0b, 0x0b,
+   0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0a,
+   0x0a, 0x09, 0x08, 0x07, 0x07, 0x06};
+
+   rt2800_rfcsr_write(rt2x00dev, 59,
+  r59_non_bt[idx]);
}
}
}
@@ -3528,6 +3535,7 @@ static void rt2800_config_channel(struct rt2x00_dev 
*rt2x00dev,
rt2800_config_channel_rf3853(rt2x00dev, conf, rf, info);
break;
case RF3070:
+   case RF5350:
case RF5360:
case RF5362:
case RF5370:
@@ -3546,6 +3554,7 @@ static void rt2800_config_channel(struct rt2x00_dev 
*rt2x00dev,
if (rt2x00_rf(rt2x00dev, RF3070) ||
rt2x00_rf(rt2x00dev, RF3290) ||
rt2x00_rf(rt2x00dev, RF3322) ||
+   rt2x00_rf(rt2x00dev, RF5350) ||
rt2x00_rf(rt2x00dev, RF5360) ||
rt2x00_rf(rt2x00dev, RF5362) ||
rt2x00_rf(rt2x00dev, RF5370) ||
@@ -3824,7 +3833,8 @@ static void rt2800_config_channel(struct rt2x00_dev 
*rt2x00dev,
/*
 * Clear update flag
 */
-   if (rt2x00_rt(rt2x00dev, RT3352)) {
+   if (rt2x00_rt(rt2x00dev, RT3352) ||
+   rt2x00_rt(rt2x00dev, RT5350)) {
rt2800_bbp_read(rt2x00dev, 49, );
rt2x00_set_field8(, BBP49_UPDATE_FLAG, 0);
rt2800_bbp_write(rt2x00dev, 49, bbp);
@@ -4710,6 +4720,7 @@ void rt2800_vco_calibration(struct rt2x00_dev *rt2x00dev)
case RF3070:
case RF3290:
case RF3853:
+   case RF5350:
case RF5360:
case RF5362:
case RF5370:
@@ -5129,6 +5140,8 @@ static int rt2800_init_registers(struct rt2x00_dev 
*rt2x00dev)
rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x0404);
rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x);
rt2800_register_write(rt2x00dev, TX_SW_CFG2, 0x);
+   } else if (rt2x00_rt(rt2x00dev, RT5350)) {
+   rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x0404);
} else {
rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x);
rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x00080606);
@@ -5788,9 +5801,13 @@ static void rt2800_init_bbp_3352(struct rt2x00_dev 
*rt2x00dev)
 
rt2800_bbp_write(rt2x00dev, 82, 0x62);
 
-   rt2800_bbp_write(rt2x00dev, 83, 0x6a);
-
-   rt2800_bbp_write(rt2x00dev, 84, 0x99);
+   if (rt2x00_rt(rt2x00dev, RT5350)) {
+   rt2800_bbp_write(rt2x00dev, 83, 0x7a);
+   rt2800_bbp_write(rt2x00dev, 84, 0x9a);
+   } else {
+   rt2800_bbp_write(rt2x00dev, 83, 0x6a);
+   rt2800_bbp_write(rt2x00dev, 84, 0x99);
+   }
 
rt2800_bbp_write(rt2x00dev, 86, 0x38);
 
@@ -5804,9 +5821,13 @@ static void rt2800_init_bbp_3352(struct rt2x00_dev 

[PATCH 39/40] rt2x00: fix rf id for RT3352

2017-01-13 Thread Daniel Golle
From: Felix Fietkau 

Signed-off-by: Felix Fietkau 
---
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index 5f49117b9035..823bdc1b0322 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -7861,10 +7861,11 @@ static int rt2800_init_eeprom(struct rt2x00_dev 
*rt2x00dev)
 * RT53xx: defined in "EEPROM_CHIP_ID" field
 */
if (rt2x00_rt(rt2x00dev, RT3290) ||
-   rt2x00_rt(rt2x00dev, RT3352) ||
rt2x00_rt(rt2x00dev, RT5390) ||
rt2x00_rt(rt2x00dev, RT5392))
rt2800_eeprom_read(rt2x00dev, EEPROM_CHIP_ID, );
+   else if (rt2x00_rt(rt2x00dev, RT3352))
+   rf = RF3322;
else if (rt2x00_rt(rt2x00dev, RT3883))
rf = RF3853;
else if (rt2x00_rt(rt2x00dev, RT5350))
-- 
2.11.0



[PATCH 37/40] rt2x00: add support for RT3352 with 20MHz crystal

2017-01-13 Thread Daniel Golle
Signed-off-by: Gabor Juhos 
Signed-off-by: Mathias Kresin 
Signed-off-by: Daniel Golle 
---
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 50 +-
 drivers/net/wireless/ralink/rt2x00/rt2x00.h|  2 ++
 2 files changed, 51 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index 320fdb90be84..6a24892476c3 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -36,6 +36,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "rt2x00.h"
 #include "rt2800lib.h"
@@ -8227,6 +8228,27 @@ static const struct rf_channel rf_vals_5592_xtal40[] = {
{196, 83, 0, 12, 1},
 };
 
+/*
+ * RF value list for rt3xxx with Xtal20MHz
+ * Supports: 2.4 GHz (all) (RF3322)
+ */
+static const struct rf_channel rf_vals_xtal20mhz_3x[] = {
+   {1,0xE2, 2,  0x14},
+   {2,0xE3, 2,  0x14},
+   {3,0xE4, 2,  0x14},
+   {4,0xE5, 2,  0x14},
+   {5,0xE6, 2,  0x14},
+   {6,0xE7, 2,  0x14},
+   {7,0xE8, 2,  0x14},
+   {8,0xE9, 2,  0x14},
+   {9,0xEA, 2,  0x14},
+   {10,   0xEB, 2,  0x14},
+   {11,   0xEC, 2,  0x14},
+   {12,   0xED, 2,  0x14},
+   {13,   0xEE, 2,  0x14},
+   {14,   0xF0, 2,  0x18},
+};
+
 static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
 {
struct hw_mode_spec *spec = >spec;
@@ -8316,7 +8338,10 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev 
*rt2x00dev)
case RF5390:
case RF5392:
spec->num_channels = 14;
-   spec->channels = rf_vals_3x;
+   if (spec->clk_is_20mhz)
+   spec->channels = rf_vals_xtal20mhz_3x;
+   else
+   spec->channels = rf_vals_3x;
break;
 
case RF3052:
@@ -8504,6 +8529,20 @@ static int rt2800_probe_rt(struct rt2x00_dev *rt2x00dev)
return 0;
 }
 
+int rt2800_probe_clk(struct rt2x00_dev *rt2x00dev)
+{
+   struct hw_mode_spec *spec = >spec;
+   struct clk *clk = clk_get(rt2x00dev->dev, NULL);
+
+   if (IS_ERR(clk))
+   return PTR_ERR(clk);
+
+   if (clk_get_rate(clk) == 2000)
+   spec->clk_is_20mhz = 1;
+
+   return 0;
+}
+
 int rt2800_probe_hw(struct rt2x00_dev *rt2x00dev)
 {
struct rt2800_drv_data *drv_data = rt2x00dev->drv_data;
@@ -8546,6 +8585,15 @@ int rt2800_probe_hw(struct rt2x00_dev *rt2x00dev)
rt2800_register_write(rt2x00dev, GPIO_CTRL, reg);
 
/*
+* Probe SoC clock.
+*/
+   if (rt2x00_is_soc(rt2x00dev)) {
+   retval = rt2800_probe_clk(rt2x00dev);
+   if (retval)
+   return retval;
+   }
+
+   /*
 * Initialize hw specifications.
 */
retval = rt2800_probe_hw_mode(rt2x00dev);
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00.h 
b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
index cfbf414c2627..b1eec49b0dac 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
@@ -400,6 +400,7 @@ static inline struct rt2x00_intf* vif_to_intf(struct 
ieee80211_vif *vif)
  * @channels: Device/chipset specific channel values (See  rf_channel).
  * @channels_info: Additional information for channels (See  
channel_info).
  * @ht: Driver HT Capabilities (See _sta_ht_cap).
+ * @clk_is_20mhz: External crystal of WiSoC is 20MHz instead of 40MHz
  */
 struct hw_mode_spec {
unsigned int supported_bands;
@@ -415,6 +416,7 @@ struct hw_mode_spec {
const struct channel_info *channels_info;
 
struct ieee80211_sta_ht_cap ht;
+   int clk_is_20mhz;
 };
 
 /*
-- 
2.11.0



[PATCH 36/40] rt2x00: support for for RT3352 with external PA

2017-01-13 Thread Daniel Golle
This is needed for WiFi to work e.g. on DIR-615 rev.H1 which got
external RF power amplifiers connected to the WiSoC.

Signed-off-by: Daniel Golle 
Signed-off-by: Gabor Juhos 
---
 drivers/net/wireless/ralink/rt2x00/rt2800.h| 24 
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 77 +-
 drivers/net/wireless/ralink/rt2x00/rt2x00.h|  2 +
 3 files changed, 90 insertions(+), 13 deletions(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800.h 
b/drivers/net/wireless/ralink/rt2x00/rt2800.h
index 33a3b33c9a0b..14c94034a707 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800.h
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h
@@ -2333,6 +2333,12 @@ struct mac_iveiv_entry {
 #define RFCSR36_RF_BS  FIELD8(0x80)
 
 /*
+ * RFCSR 34:
+ */
+#define RFCSR34_TX0_EXT_PA FIELD8(0x04)
+#define RFCSR34_TX1_EXT_PA FIELD8(0x08)
+
+/*
  * RFCSR 38:
  */
 #define RFCSR38_RX_LO1_EN  FIELD8(0x20)
@@ -2344,6 +2350,18 @@ struct mac_iveiv_entry {
 #define RFCSR39_RX_LO2_EN  FIELD8(0x80)
 
 /*
+ * RFCSR 41:
+ */
+#define RFCSR41_BIT1   FIELD8(0x01)
+#define RFCSR41_BIT4   FIELD8(0x08)
+
+/*
+ * RFCSR 42:
+ */
+#define RFCSR42_BIT1   FIELD8(0x01)
+#define RFCSR42_BIT4   FIELD8(0x08)
+
+/*
  * RFCSR 49:
  */
 #define RFCSR49_TX FIELD8(0x3f)
@@ -2356,6 +2374,8 @@ struct mac_iveiv_entry {
  * RFCSR 50:
  */
 #define RFCSR50_TX FIELD8(0x3f)
+#define RFCSR50_TX0_EXT_PA FIELD8(0x02)
+#define RFCSR50_TX1_EXT_PA FIELD8(0x10)
 #define RFCSR50_EP FIELD8(0xc0)
 /* bits for RT3593 */
 #define RFCSR50_TX_LO1_EN  FIELD8(0x20)
@@ -2503,6 +2523,8 @@ enum rt2800_eeprom_word {
  * INTERNAL_TX_ALC: 0: disable, 1: enable
  * BT_COEXIST: 0: disable, 1: enable
  * DAC_TEST: 0: disable, 1: enable
+ * EXTERNAL_TX0_PA: 0: disable, 1: enable (only on RT3352)
+ * EXTERNAL_TX1_PA: 0: disable, 1: enable (only on RT3352)
  */
 #define EEPROM_NIC_CONF1_HW_RADIO  FIELD16(0x0001)
 #define EEPROM_NIC_CONF1_EXTERNAL_TX_ALC   FIELD16(0x0002)
@@ -2519,6 +2541,8 @@ enum rt2800_eeprom_word {
 #define EEPROM_NIC_CONF1_INTERNAL_TX_ALC   FIELD16(0x2000)
 #define EEPROM_NIC_CONF1_BT_COEXISTFIELD16(0x4000)
 #define EEPROM_NIC_CONF1_DAC_TEST  FIELD16(0x8000)
+#define EEPROM_NIC_CONF1_EXTERNAL_TX0_PA_3352  FIELD16(0x4000)
+#define EEPROM_NIC_CONF1_EXTERNAL_TX1_PA_3352  FIELD16(0x8000)
 
 /*
  * EEPROM frequency
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index 51c9d5e8b888..320fdb90be84 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -3564,11 +3564,18 @@ static void rt2800_config_channel(struct rt2x00_dev 
*rt2x00dev,
/*
 * Change BBP settings
 */
+
if (rt2x00_rt(rt2x00dev, RT3352)) {
+   rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain);
+   rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain);
+   rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain);
+
rt2800_bbp_write(rt2x00dev, 27, 0x0);
rt2800_bbp_write(rt2x00dev, 66, 0x26 + rt2x00dev->lna_gain);
rt2800_bbp_write(rt2x00dev, 27, 0x20);
rt2800_bbp_write(rt2x00dev, 66, 0x26 + rt2x00dev->lna_gain);
+   rt2800_bbp_write(rt2x00dev, 86, 0x38);
+   rt2800_bbp_write(rt2x00dev, 83, 0x6a);
} else if (rt2x00_rt(rt2x00dev, RT3593)) {
if (rf->channel > 14) {
/* Disable CCK Packet detection on 5GHz */
@@ -6640,6 +6647,12 @@ static void rt2800_init_rfcsr_3290(struct rt2x00_dev 
*rt2x00dev)
 
 static void rt2800_init_rfcsr_3352(struct rt2x00_dev *rt2x00dev)
 {
+   int tx0_int_pa = test_bit(CAPABILITY_INTERNAL_PA_TX0,
+ >cap_flags);
+   int tx1_int_pa = test_bit(CAPABILITY_INTERNAL_PA_TX1,
+ >cap_flags);
+   u8 rfcsr;
+
rt2800_rf_init_calibration(rt2x00dev, 30);
 
rt2800_rfcsr_write(rt2x00dev, 0, 0xf0);
@@ -6675,15 +6688,30 @@ static void rt2800_init_rfcsr_3352(struct rt2x00_dev 
*rt2x00dev)
rt2800_rfcsr_write(rt2x00dev, 31, 0x80);
rt2800_rfcsr_write(rt2x00dev, 32, 0x80);
rt2800_rfcsr_write(rt2x00dev, 33, 0x00);
-   rt2800_rfcsr_write(rt2x00dev, 34, 0x01);
+   rfcsr = 0x01;
+   if (!tx0_int_pa)
+   rt2x00_set_field8(, RFCSR34_TX0_EXT_PA, 1);
+   if (!tx1_int_pa)
+   rt2x00_set_field8(, RFCSR34_TX1_EXT_PA, 1);
+   rt2800_rfcsr_write(rt2x00dev, 34, rfcsr);
rt2800_rfcsr_write(rt2x00dev, 35, 0x03);
rt2800_rfcsr_write(rt2x00dev, 36, 0xbd);

[PATCH 35/40] rt2x00: rt2x00pci: set PCI MWI only if supported

2017-01-13 Thread Daniel Golle
From: Claudio Mignanti 

This is needed for devices without support for PCI MWI. See also
https://dev.openwrt.org/changeset/21850

Signed-off-by: Daniel Golle 
---
 drivers/net/wireless/ralink/rt2x00/rt2x00pci.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00pci.c 
b/drivers/net/wireless/ralink/rt2x00/rt2x00pci.c
index eb6dbcd4fddf..4becfeb75ba8 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00pci.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00pci.c
@@ -94,8 +94,10 @@ int rt2x00pci_probe(struct pci_dev *pci_dev, const struct 
rt2x00_ops *ops)
 
pci_set_master(pci_dev);
 
+#ifdef CONFIG_PCI_SET_MWI
if (pci_set_mwi(pci_dev))
rt2x00_probe_err("MWI not available\n");
+#endif
 
if (dma_set_mask(_dev->dev, DMA_BIT_MASK(32))) {
rt2x00_probe_err("PCI DMA not supported\n");
-- 
2.11.0



[PATCH 34/40] rt2x00: rt2800mmio: add a workaround for spurious TX_FIFO_STATUS interrupts

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

Signed-off-by: Gabor Juhos 
[dan...@makrotopia.org: fixed indention]
---
 drivers/net/wireless/ralink/rt2x00/rt2800mmio.c | 72 -
 drivers/net/wireless/ralink/rt2x00/rt2x00.h |  5 ++
 2 files changed, 65 insertions(+), 12 deletions(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c
index 5f1936aa8fa7..750a9425b5be 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c
@@ -415,9 +415,9 @@ void rt2800mmio_autowake_tasklet(unsigned long data)
 }
 EXPORT_SYMBOL_GPL(rt2800mmio_autowake_tasklet);
 
-static void rt2800mmio_txstatus_interrupt(struct rt2x00_dev *rt2x00dev)
+static void rt2800mmio_txstatus_interrupt(struct rt2x00_dev *rt2x00dev,
+ u32 status)
 {
-   u32 status;
int i;
 
/*
@@ -438,29 +438,77 @@ static void rt2800mmio_txstatus_interrupt(struct 
rt2x00_dev *rt2x00dev)
 * Since we have only one producer and one consumer we don't
 * need to lock the kfifo.
 */
-   for (i = 0; i < rt2x00dev->tx->limit; i++) {
-   rt2x00mmio_register_read(rt2x00dev, TX_STA_FIFO, );
-
-   if (!rt2x00_get_field32(status, TX_STA_FIFO_VALID))
-   break;
-
+   i = 0;
+   do {
if (!kfifo_put(>txstatus_fifo, status)) {
-   rt2x00_warn(rt2x00dev, "TX status FIFO overrun, drop tx 
status report\n");
+   rt2x00_warn(rt2x00dev,
+   "TX status FIFO overrun, drop TX status 
report\n");
break;
}
-   }
+
+   if (++i >= rt2x00dev->tx->limit)
+   break;
+
+   rt2x00mmio_register_read(rt2x00dev, TX_STA_FIFO, );
+   } while (rt2x00_get_field32(status, TX_STA_FIFO_VALID));
 
/* Schedule the tasklet for processing the tx status. */
tasklet_schedule(>txstatus_tasklet);
 }
 
+#define RT2800MMIO_TXSTATUS_IRQ_MAX_RETRIES4
+
+static bool rt2800mmio_txstatus_is_spurious(struct rt2x00_dev *rt2x00dev,
+   u32 txstatus)
+{
+   if (likely(rt2x00_get_field32(txstatus, TX_STA_FIFO_VALID))) {
+   rt2x00dev->txstatus_irq_retries = 0;
+   return false;
+   }
+
+   rt2x00dev->txstatus_irq_retries++;
+
+   /* Ensure that we don't go into an infinite IRQ loop. */
+   if (rt2x00dev->txstatus_irq_retries >=
+   RT2800MMIO_TXSTATUS_IRQ_MAX_RETRIES) {
+   rt2x00_warn(rt2x00dev,
+   "%u spurious TX_FIFO_STATUS interrupt(s)\n",
+   rt2x00dev->txstatus_irq_retries);
+   rt2x00dev->txstatus_irq_retries = 0;
+   return false;
+   }
+
+   return true;
+}
+
 irqreturn_t rt2800mmio_interrupt(int irq, void *dev_instance)
 {
struct rt2x00_dev *rt2x00dev = dev_instance;
u32 reg, mask;
+   u32 txstatus = 0;
 
-   /* Read status and ACK all interrupts */
+   /* Read status */
rt2x00mmio_register_read(rt2x00dev, INT_SOURCE_CSR, );
+
+   if (rt2x00_get_field32(reg, INT_SOURCE_CSR_TX_FIFO_STATUS)) {
+   /* Due to unknown reason the hardware generates a
+* TX_FIFO_STATUS interrupt before the TX_STA_FIFO
+* register contain valid data. Read the TX status
+* here to see if we have to process the actual
+* request.
+*/
+   rt2x00mmio_register_read(rt2x00dev, TX_STA_FIFO, );
+   if (rt2800mmio_txstatus_is_spurious(rt2x00dev, txstatus)) {
+   /* Remove the TX_FIFO_STATUS bit so it won't be
+* processed in this turn. The hardware will
+* generate another IRQ for us.
+*/
+   rt2x00_set_field32(,
+  INT_SOURCE_CSR_TX_FIFO_STATUS, 0);
+   }
+   }
+
+   /* ACK interrupts */
rt2x00mmio_register_write(rt2x00dev, INT_SOURCE_CSR, reg);
 
if (!reg)
@@ -477,7 +525,7 @@ irqreturn_t rt2800mmio_interrupt(int irq, void 
*dev_instance)
mask = ~reg;
 
if (rt2x00_get_field32(reg, INT_SOURCE_CSR_TX_FIFO_STATUS)) {
-   rt2800mmio_txstatus_interrupt(rt2x00dev);
+   rt2800mmio_txstatus_interrupt(rt2x00dev, txstatus);
/*
 * Never disable the TX_FIFO_STATUS interrupt.
 */
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00.h 
b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
index 034a07273038..c27408b494ef 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
@@ -995,6 +995,11 @@ struct rt2x00_dev {
int 

[PATCH 33/40] rt2x00: rt2800lib: use high memory for beacons on RT3883

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

Signed-off-by: Gabor Juhos 
Signed-off-by: Daniel Golle 
---
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index 55fc3ec4597b..51c9d5e8b888 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -97,7 +97,8 @@ static inline void rt2800_shared_mem_select(struct rt2x00_dev 
*rt2x00dev,
 
 static inline bool rt2800_beacon_uses_high_mem(struct rt2x00_dev *rt2x00dev)
 {
-   if (rt2x00_rt(rt2x00dev, RT3593))
+   if (rt2x00_rt(rt2x00dev, RT3593) ||
+   rt2x00_rt(rt2x00dev, RT3883))
return true;
 
return false;
-- 
2.11.0



[PATCH 32/40] rt2x00: rt2800lib: enable RT2800_HAS_HIGH_SHARED_MEM for RT3883

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

Signed-off-by: Gabor Juhos 
---
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index c8a14eaafd22..55fc3ec4597b 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -8464,7 +8464,8 @@ int rt2800_probe_hw(struct rt2x00_dev *rt2x00dev)
if (retval)
return retval;
 
-   if (rt2x00_rt(rt2x00dev, RT3593))
+   if (rt2x00_rt(rt2x00dev, RT3593) ||
+   rt2x00_rt(rt2x00dev, RT3883))
__set_bit(RT2800_HAS_HIGH_SHARED_MEM, _data->rt2800_flags);
 
if (rt2x00_rt(rt2x00dev, RT3593) ||
-- 
2.11.0



[PATCH 31/40] rt2x00: rt2800lib: fix txpower compensation for RT3883

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

Signed-off-by: Gabor Juhos 
---
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index 81368cee6e38..c8a14eaafd22 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -4017,6 +4017,9 @@ static u8 rt2800_compensate_txpower(struct rt2x00_dev 
*rt2x00dev, int is_rate_b,
if (rt2x00_rt(rt2x00dev, RT3593))
return min_t(u8, txpower, 0xc);
 
+   if (rt2x00_rt(rt2x00dev, RT3883))
+   return min_t(u8, txpower, 0xf);
+
if (rt2x00_has_cap_power_limit(rt2x00dev)) {
/*
 * Check if eirp txpower exceed txpower_limit.
-- 
2.11.0



Re: [RFC] [PULL REQUEST] rt2x00 patches from OpenWrt.org

2017-01-13 Thread Christian Lamparter
On Friday, January 13, 2017 4:46:30 PM CET Daniel Golle wrote:
> On Fri, Jan 13, 2017 at 12:46:56PM +0200, Kalle Valo wrote:
> > Daniel Golle  writes:
> > > ...
> > > Please review and comment, so we can get those patches merged!
> > 
> > No pull requests, please. Instead send these as patches, easier to
> > review and actually also easier for me to merge.
> 
> The advantage of pull requests is that author information can be
> preserved more easily. Running git format-patch results in most patches
> having wrong SMTP sender information due to the assumption that the
> patch author is the same person also submitting the patch.
> So in practise, this would either require changing the From: (and thus
> Author) to myself or having most mails eaten by anti-spam measures due
> to non-matching SPF which prohibits my SMTP to send mail on behalf of
> the original authors of the patches.
> 
> How do you suggest to handle this situation?
> 
>From what I know, git format-patch and send-email [0] will add a second
FROM: in the email's body with the author of the commit automatically
(if author isn't you). This is what it did, when I posted the apm821xx
patches on lede-dev [1] (Look at the additional "FROM: Chris Blake ..."
line in these patches. Whereas the mail came from my address).

The MTA (MDA, ...) will use the first FROM: (your address) whereas git will
use the FROM in the mail body (so the patch will be correctly attributed to
the original patch author). If you don't want to bother the original
authors, you can look at the --suppress-cc=author option and enable --dry-run
on git send-email.

I would say, just give it a "dry".
(Sadly, I didn't find any documentation for this feature.
But I know it worked back then and it should be fine with SPF.)

Regards,
Christian

[0] 
[1] 


[PATCH 30/40] rt2x00: rt2800lib: fix EEPROM LNA validation for RT3883

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

Signed-off-by: Gabor Juhos 
---
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index e79714b898b9..81368cee6e38 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -7648,7 +7648,8 @@ static int rt2800_validate_eeprom(struct rt2x00_dev 
*rt2x00dev)
rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, );
if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG2_OFFSET2)) > 10)
rt2x00_set_field16(, EEPROM_RSSI_BG2_OFFSET2, 0);
-   if (!rt2x00_rt(rt2x00dev, RT3593)) {
+   if (!rt2x00_rt(rt2x00dev, RT3593) &&
+   !rt2x00_rt(rt2x00dev, RT3883)) {
if (rt2x00_get_field16(word, EEPROM_RSSI_BG2_LNA_A1) == 0x00 ||
rt2x00_get_field16(word, EEPROM_RSSI_BG2_LNA_A1) == 0xff)
rt2x00_set_field16(, EEPROM_RSSI_BG2_LNA_A1,
@@ -7668,7 +7669,8 @@ static int rt2800_validate_eeprom(struct rt2x00_dev 
*rt2x00dev)
rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, );
if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A2_OFFSET2)) > 10)
rt2x00_set_field16(, EEPROM_RSSI_A2_OFFSET2, 0);
-   if (!rt2x00_rt(rt2x00dev, RT3593)) {
+   if (!rt2x00_rt(rt2x00dev, RT3593) &&
+   !rt2x00_rt(rt2x00dev, RT3883)) {
if (rt2x00_get_field16(word, EEPROM_RSSI_A2_LNA_A2) == 0x00 ||
rt2x00_get_field16(word, EEPROM_RSSI_A2_LNA_A2) == 0xff)
rt2x00_set_field16(, EEPROM_RSSI_A2_LNA_A2,
@@ -7676,7 +7678,8 @@ static int rt2800_validate_eeprom(struct rt2x00_dev 
*rt2x00dev)
}
rt2800_eeprom_write(rt2x00dev, EEPROM_RSSI_A2, word);
 
-   if (rt2x00_rt(rt2x00dev, RT3593)) {
+   if (rt2x00_rt(rt2x00dev, RT3593) ||
+   rt2x00_rt(rt2x00dev, RT3883)) {
rt2800_eeprom_read(rt2x00dev, EEPROM_EXT_LNA2, );
if (rt2x00_get_field16(word, EEPROM_EXT_LNA2_A1) == 0x00 ||
rt2x00_get_field16(word, EEPROM_EXT_LNA2_A1) == 0xff)
-- 
2.11.0



[PATCH 28/40] rt2x00: rt2800lib: fix LNA gain configuration for RT3883

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

Signed-off-by: Gabor Juhos 
---
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index bde8177c30c4..da430e304d1f 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -1994,7 +1994,8 @@ static void rt2800_config_lna_gain(struct rt2x00_dev 
*rt2x00dev,
rt2800_eeprom_read(rt2x00dev, EEPROM_LNA, );
lna_gain = rt2x00_get_field16(eeprom, EEPROM_LNA_A0);
} else if (libconf->rf.channel <= 128) {
-   if (rt2x00_rt(rt2x00dev, RT3593)) {
+   if (rt2x00_rt(rt2x00dev, RT3593) ||
+   rt2x00_rt(rt2x00dev, RT3883)) {
rt2800_eeprom_read(rt2x00dev, EEPROM_EXT_LNA2, );
lna_gain = rt2x00_get_field16(eeprom,
  EEPROM_EXT_LNA2_A1);
@@ -2004,7 +2005,8 @@ static void rt2800_config_lna_gain(struct rt2x00_dev 
*rt2x00dev,
  EEPROM_RSSI_BG2_LNA_A1);
}
} else {
-   if (rt2x00_rt(rt2x00dev, RT3593)) {
+   if (rt2x00_rt(rt2x00dev, RT3593) ||
+   rt2x00_rt(rt2x00dev, RT3883)) {
rt2800_eeprom_read(rt2x00dev, EEPROM_EXT_LNA2, );
lna_gain = rt2x00_get_field16(eeprom,
  EEPROM_EXT_LNA2_A2);
-- 
2.11.0



[PATCH 29/40] rt2x00: rt2800lib: fix VGC setup for RT3883

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

Signed-off-by: Gabor Juhos 
---
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index da430e304d1f..e79714b898b9 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -4850,7 +4850,8 @@ static u8 rt2800_get_default_vgc(struct rt2x00_dev 
*rt2x00dev)
else
vgc = 0x2e + rt2x00dev->lna_gain;
} else { /* 5GHZ band */
-   if (rt2x00_rt(rt2x00dev, RT3593))
+   if (rt2x00_rt(rt2x00dev, RT3593) ||
+   rt2x00_rt(rt2x00dev, RT3883))
vgc = 0x20 + (rt2x00dev->lna_gain * 5) / 3;
else if (rt2x00_rt(rt2x00dev, RT5592))
vgc = 0x24 + (2 * rt2x00dev->lna_gain);
@@ -4870,7 +4871,8 @@ static inline void rt2800_set_vgc(struct rt2x00_dev 
*rt2x00dev,
 {
if (qual->vgc_level != vgc_level) {
if (rt2x00_rt(rt2x00dev, RT3572) ||
-   rt2x00_rt(rt2x00dev, RT3593)) {
+   rt2x00_rt(rt2x00dev, RT3593) ||
+   rt2x00_rt(rt2x00dev, RT3883)) {
rt2800_bbp_write_with_rx_chain(rt2x00dev, 66,
   vgc_level);
} else if (rt2x00_rt(rt2x00dev, RT5592)) {
@@ -4917,6 +4919,11 @@ void rt2800_link_tuner(struct rt2x00_dev *rt2x00dev, 
struct link_qual *qual,
}
break;
 
+   case RT3883:
+   if (qual->rssi > -65)
+   vgc += 0x10;
+   break;
+
case RT5592:
if (qual->rssi > -65)
vgc += 0x20;
-- 
2.11.0



[PATCH 27/40] rt2x00: rt2800lib: fix antenna configuration for RT3883

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

Signed-off-by: Gabor Juhos 
---
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index ba73be7101b7..bde8177c30c4 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -1971,7 +1971,8 @@ void rt2800_config_ant(struct rt2x00_dev *rt2x00dev, 
struct antenna_setup *ant)
rt2800_bbp_write(rt2x00dev, 3, r3);
rt2800_bbp_write(rt2x00dev, 1, r1);
 
-   if (rt2x00_rt(rt2x00dev, RT3593)) {
+   if (rt2x00_rt(rt2x00dev, RT3593) ||
+   rt2x00_rt(rt2x00dev, RT3883)) {
if (ant->rx_chain_num == 1)
rt2800_bbp_write(rt2x00dev, 86, 0x00);
else
-- 
2.11.0



[PATCH 26/40] rt2x00: rt2800lib: use correct beacon count for RT3883

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

Signed-off-by: Gabor Juhos 
---
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index 8f036090f320..ba73be7101b7 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -8451,7 +8451,8 @@ int rt2800_probe_hw(struct rt2x00_dev *rt2x00dev)
if (rt2x00_rt(rt2x00dev, RT3593))
__set_bit(RT2800_HAS_HIGH_SHARED_MEM, _data->rt2800_flags);
 
-   if (rt2x00_rt(rt2x00dev, RT3593))
+   if (rt2x00_rt(rt2x00dev, RT3593) ||
+   rt2x00_rt(rt2x00dev, RT3883))
drv_data->hw_beacon_count = 16;
else
drv_data->hw_beacon_count = 8;
-- 
2.11.0



[PATCH 23/40] rt2x00: rt2800lib: hardcode txmixer gain values to zero for RT3883

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

Signed-off-by: Gabor Juhos 
---
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index 797c60875ac6..e406885a5cc3 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -7514,7 +7514,8 @@ static u8 rt2800_get_txmixer_gain_24g(struct rt2x00_dev 
*rt2x00dev)
 {
u16 word;
 
-   if (rt2x00_rt(rt2x00dev, RT3593))
+   if (rt2x00_rt(rt2x00dev, RT3593) ||
+   rt2x00_rt(rt2x00dev, RT3883))
return 0;
 
rt2800_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_BG, );
@@ -7528,7 +7529,8 @@ static u8 rt2800_get_txmixer_gain_5g(struct rt2x00_dev 
*rt2x00dev)
 {
u16 word;
 
-   if (rt2x00_rt(rt2x00dev, RT3593))
+   if (rt2x00_rt(rt2x00dev, RT3593) ||
+   rt2x00_rt(rt2x00dev, RT3883))
return 0;
 
rt2800_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_A, );
-- 
2.11.0



[PATCH 24/40] rt2x00: rt2800lib: use correct [RT]XWI size for RT3883

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

Signed-off-by: Gabor Juhos 
---
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index e406885a5cc3..1933dc22f1c4 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -558,6 +558,7 @@ void rt2800_get_txwi_rxwi_size(struct rt2x00_dev *rt2x00dev,
 {
switch (rt2x00dev->chip.rt) {
case RT3593:
+   case RT3883:
*txwi_size = TXWI_DESC_SIZE_4WORDS;
*rxwi_size = RXWI_DESC_SIZE_5WORDS;
break;
-- 
2.11.0



[PATCH 25/40] rt2x00: rt2800lib: use correct beacon base for RT3883

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

Signed-off-by: Gabor Juhos 
---
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index 1933dc22f1c4..8f036090f320 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -983,7 +983,8 @@ EXPORT_SYMBOL_GPL(rt2800_txdone_entry);
 static unsigned int rt2800_hw_beacon_base(struct rt2x00_dev *rt2x00dev,
  unsigned int index)
 {
-   if (rt2x00_rt(rt2x00dev, RT3593))
+   if (rt2x00_rt(rt2x00dev, RT3593) ||
+   rt2x00_rt(rt2x00dev, RT3883))
return HW_BEACON_BASE_HIGH(index);
 
return HW_BEACON_BASE(index);
-- 
2.11.0



[PATCH 15/40] rt2x00: rt2800soc: fix rt2800soc_disable_radio for RT3883

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

Signed-off-by: Gabor Juhos 
---
 drivers/net/wireless/ralink/rt2x00/rt2800soc.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800soc.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800soc.c
index 871d9d331046..85575004a784 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800soc.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800soc.c
@@ -51,9 +51,16 @@ static bool rt2800soc_hwcrypt_disabled(struct rt2x00_dev 
*rt2x00dev)
 
 static void rt2800soc_disable_radio(struct rt2x00_dev *rt2x00dev)
 {
+   u32 reg;
+
rt2800_disable_radio(rt2x00dev);
rt2x00mmio_register_write(rt2x00dev, PWR_PIN_CFG, 0);
-   rt2x00mmio_register_write(rt2x00dev, TX_PIN_CFG, 0);
+
+   reg = 0;
+   if (rt2x00_rt(rt2x00dev, RT3883))
+   rt2x00_set_field32(, TX_PIN_CFG_RFTR_EN, 1);
+
+   rt2x00mmio_register_write(rt2x00dev, TX_PIN_CFG, reg);
 }
 
 static int rt2800soc_set_device_state(struct rt2x00_dev *rt2x00dev,
-- 
2.11.0



[PATCH 22/40] rt2x00: rt2800lib: use correct txpower calculation function for RT3883

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

Signed-off-by: Gabor Juhos 
---
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index 6df2c240d756..797c60875ac6 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -4647,7 +4647,8 @@ static void rt2800_config_txpower(struct rt2x00_dev 
*rt2x00dev,
  struct ieee80211_channel *chan,
  int power_level)
 {
-   if (rt2x00_rt(rt2x00dev, RT3593))
+   if (rt2x00_rt(rt2x00dev, RT3593) ||
+   rt2x00_rt(rt2x00dev, RT3883))
rt2800_config_txpower_rt3593(rt2x00dev, chan, power_level);
else
rt2800_config_txpower_rt28xx(rt2x00dev, chan, power_level);
-- 
2.11.0



[PATCH 21/40] rt2x00: rt2800lib: fix txpower_to_dev function for RT3883

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

Signed-off-by: Gabor Juhos 
---
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index 62ac5aa0f016..6df2c240d756 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -3428,13 +3428,15 @@ static char rt2800_txpower_to_dev(struct rt2x00_dev 
*rt2x00dev,
  unsigned int channel,
  char txpower)
 {
-   if (rt2x00_rt(rt2x00dev, RT3593))
+   if (rt2x00_rt(rt2x00dev, RT3593) ||
+   rt2x00_rt(rt2x00dev, RT3883))
txpower = rt2x00_get_field8(txpower, EEPROM_TXPOWER_ALC);
 
if (channel <= 14)
return clamp_t(char, txpower, MIN_G_TXPOWER, MAX_G_TXPOWER);
 
-   if (rt2x00_rt(rt2x00dev, RT3593))
+   if (rt2x00_rt(rt2x00dev, RT3593) ||
+   rt2x00_rt(rt2x00dev, RT3883))
return clamp_t(char, txpower, MIN_A_TXPOWER_3593,
   MAX_A_TXPOWER_3593);
else
-- 
2.11.0



[RFC v3 0/8] ath10k sdio support

2017-01-13 Thread Erik Stromdahl
This is the third version of the sdio RFC patch series.
The actual sdio code (patch 6) has been subject to a massive overhaul,
mainly as a result of Kalle's review comments.
It no longer has any strong resemblance of the original ath6kl code from
which it was originally based upon.

Previous pathes 6 to 10 have been merged into one single patch.

The previous series had a rework of the "HTC fake service" connect
(ep 0 connect) that introduced a race between the actual endpoint
connect and the HTC ready message. This issue has been addressed,
and the current patches (3 and 4) has been rewritten accordingly.

* overview of patches *

Patches 1 to 4 are more or less identical to the previous RFC, with an
exception for patch 3 that changes the "HTC fake service" connect
(mentioned above).

Patch 5 is a squashed version of previous patches 6 to 10.

Patch 6 is the actual sdio patch

Patches 7 to 8 are new and adds special sdio versions of BMI get
target info and HTC ready.

The new version was built and tested against:
tag: ath-201701121109

Erik Stromdahl (8):
  ath10k: htc: made static function public
  ath10k: htc: rx trailer lookahead support
  ath10k: htc: move htc ctrl ep connect to htc_init
  ath10k: htc: refactorization
  ath10k: various sdio related definitions
  ath10k: sdio support
  ath10k: sdio get target info
  ath10k: htc: ready_ext msg support

 drivers/net/wireless/ath/ath10k/Kconfig |6 +
 drivers/net/wireless/ath/ath10k/Makefile|3 +
 drivers/net/wireless/ath/ath10k/bmi.c   |   70 +
 drivers/net/wireless/ath/ath10k/bmi.h   |2 +
 drivers/net/wireless/ath/ath10k/core.c  |5 +-
 drivers/net/wireless/ath/ath10k/core.h  |3 +
 drivers/net/wireless/ath/ath10k/debug.h |2 +
 drivers/net/wireless/ath/ath10k/htc.c   |  241 ++-
 drivers/net/wireless/ath/ath10k/htc.h   |   39 +-
 drivers/net/wireless/ath/ath10k/hw.h|   53 +
 drivers/net/wireless/ath/ath10k/sdio.c  | 2105 +++
 drivers/net/wireless/ath/ath10k/sdio.h  |  259 
 drivers/net/wireless/ath/ath10k/targaddrs.h |   24 +
 13 files changed, 2737 insertions(+), 75 deletions(-)
 create mode 100644 drivers/net/wireless/ath/ath10k/sdio.c
 create mode 100644 drivers/net/wireless/ath/ath10k/sdio.h

-- 
2.7.4



[RFC v3 3/8] ath10k: htc: move htc ctrl ep connect to htc_init

2017-01-13 Thread Erik Stromdahl
This patch moves the HTC ctrl service connect from
htc_wait_target to htc_init.

This is done in order to make sure the htc ctrl service
is setup properly before hif_start is called.

The reason for this is that we want the HTC ctrl service
callback to be initialized before the target sends the
HTC ready message.

The ready message will always be transmitted on endpoint 0
(which is always assigned to the HTC control service) so it
makes more sense if HTC control has been connected before the
ready message is received.

Since the service to pipe mapping is done as a part of
the service connect, the get_default_pipe call is redundant
and was removed.

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/htc.c | 39 +++
 1 file changed, 17 insertions(+), 22 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/htc.c 
b/drivers/net/wireless/ath/ath10k/htc.c
index e72f385..f39eef6 100644
--- a/drivers/net/wireless/ath/ath10k/htc.c
+++ b/drivers/net/wireless/ath/ath10k/htc.c
@@ -584,8 +584,6 @@ int ath10k_htc_wait_target(struct ath10k_htc *htc)
struct ath10k *ar = htc->ar;
int i, status = 0;
unsigned long time_left;
-   struct ath10k_htc_svc_conn_req conn_req;
-   struct ath10k_htc_svc_conn_resp conn_resp;
struct ath10k_htc_msg *msg;
u16 message_id;
u16 credit_count;
@@ -648,22 +646,6 @@ int ath10k_htc_wait_target(struct ath10k_htc *htc)
return -ECOMM;
}
 
-   /* setup our pseudo HTC control endpoint connection */
-   memset(_req, 0, sizeof(conn_req));
-   memset(_resp, 0, sizeof(conn_resp));
-   conn_req.ep_ops.ep_tx_complete = ath10k_htc_control_tx_complete;
-   conn_req.ep_ops.ep_rx_complete = ath10k_htc_control_rx_complete;
-   conn_req.max_send_queue_depth = ATH10K_NUM_CONTROL_TX_BUFFERS;
-   conn_req.service_id = ATH10K_HTC_SVC_ID_RSVD_CTRL;
-
-   /* connect fake service */
-   status = ath10k_htc_connect_service(htc, _req, _resp);
-   if (status) {
-   ath10k_err(ar, "could not connect to htc service (%d)\n",
-  status);
-   return status;
-   }
-
return 0;
 }
 
@@ -873,8 +855,10 @@ int ath10k_htc_start(struct ath10k_htc *htc)
 /* registered target arrival callback from the HIF layer */
 int ath10k_htc_init(struct ath10k *ar)
 {
-   struct ath10k_htc_ep *ep = NULL;
+   int status;
struct ath10k_htc *htc = >htc;
+   struct ath10k_htc_svc_conn_req conn_req;
+   struct ath10k_htc_svc_conn_resp conn_resp;
 
spin_lock_init(>tx_lock);
 
@@ -882,10 +866,21 @@ int ath10k_htc_init(struct ath10k *ar)
 
htc->ar = ar;
 
-   /* Get HIF default pipe for HTC message exchange */
-   ep = >endpoint[ATH10K_HTC_EP_0];
+   /* setup our pseudo HTC control endpoint connection */
+   memset(_req, 0, sizeof(conn_req));
+   memset(_resp, 0, sizeof(conn_resp));
+   conn_req.ep_ops.ep_tx_complete = ath10k_htc_control_tx_complete;
+   conn_req.ep_ops.ep_rx_complete = ath10k_htc_control_rx_complete;
+   conn_req.max_send_queue_depth = ATH10K_NUM_CONTROL_TX_BUFFERS;
+   conn_req.service_id = ATH10K_HTC_SVC_ID_RSVD_CTRL;
 
-   ath10k_hif_get_default_pipe(ar, >ul_pipe_id, >dl_pipe_id);
+   /* connect fake service */
+   status = ath10k_htc_connect_service(htc, _req, _resp);
+   if (status) {
+   ath10k_err(ar, "could not connect to htc service (%d)\n",
+  status);
+   return status;
+   }
 
init_completion(>ctl_resp);
 
-- 
2.7.4



[PATCH 20/40] rt2x00: rt2800lib: add channel configuration code for RT3883

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

Signed-off-by: Gabor Juhos 
---
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 72 --
 1 file changed, 69 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index 005fd02c0226..62ac5aa0f016 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -3441,6 +3441,36 @@ static char rt2800_txpower_to_dev(struct rt2x00_dev 
*rt2x00dev,
return clamp_t(char, txpower, MIN_A_TXPOWER, MAX_A_TXPOWER);
 }
 
+static void rt3883_bbp_adjust(struct rt2x00_dev *rt2x00dev,
+ struct rf_channel *rf)
+{
+   u8 bbp;
+
+   bbp = (rf->channel > 14) ? 0x48 : 0x38;
+   rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, bbp);
+
+   rt2800_bbp_write(rt2x00dev, 69, 0x12);
+
+   if (rf->channel <= 14) {
+   rt2800_bbp_write(rt2x00dev, 70, 0x0a);
+   } else {
+   /* Disable CCK packet detection */
+   rt2800_bbp_write(rt2x00dev, 70, 0x00);
+   }
+
+   rt2800_bbp_write(rt2x00dev, 73, 0x10);
+
+   if (rf->channel > 14) {
+   rt2800_bbp_write(rt2x00dev, 62, 0x1d);
+   rt2800_bbp_write(rt2x00dev, 63, 0x1d);
+   rt2800_bbp_write(rt2x00dev, 64, 0x1d);
+   } else {
+   rt2800_bbp_write(rt2x00dev, 62, 0x2d);
+   rt2800_bbp_write(rt2x00dev, 63, 0x2d);
+   rt2800_bbp_write(rt2x00dev, 64, 0x2d);
+   }
+}
+
 static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev,
  struct ieee80211_conf *conf,
  struct rf_channel *rf,
@@ -3459,6 +3489,12 @@ static void rt2800_config_channel(struct rt2x00_dev 
*rt2x00dev,
rt2800_txpower_to_dev(rt2x00dev, rf->channel,
  info->default_power3);
 
+   switch (rt2x00dev->chip.rt) {
+   case RT3883:
+   rt3883_bbp_adjust(rt2x00dev, rf);
+   break;
+   }
+
switch (rt2x00dev->chip.rf) {
case RF2020:
case RF3020:
@@ -3542,6 +3578,15 @@ static void rt2800_config_channel(struct rt2x00_dev 
*rt2x00dev,
rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain);
rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain);
rt2800_bbp_write(rt2x00dev, 77, 0x98);
+   } else if (rt2x00_rt(rt2x00dev, RT3883)) {
+   rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain);
+   rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain);
+   rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain);
+
+   if (rt2x00dev->default_ant.rx_chain_num > 1)
+   rt2800_bbp_write(rt2x00dev, 86, 0x46);
+   else
+   rt2800_bbp_write(rt2x00dev, 86, 0);
} else {
rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain);
rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain);
@@ -3554,6 +3599,7 @@ static void rt2800_config_channel(struct rt2x00_dev 
*rt2x00dev,
!rt2x00_rt(rt2x00dev, RT5392)) {
if (rt2x00_has_cap_external_lna_bg(rt2x00dev)) {
rt2800_bbp_write(rt2x00dev, 82, 0x62);
+   rt2800_bbp_write(rt2x00dev, 82, 0x62);
rt2800_bbp_write(rt2x00dev, 75, 0x46);
} else {
if (rt2x00_rt(rt2x00dev, RT3593))
@@ -3562,19 +3608,22 @@ static void rt2800_config_channel(struct rt2x00_dev 
*rt2x00dev,
rt2800_bbp_write(rt2x00dev, 82, 0x84);
rt2800_bbp_write(rt2x00dev, 75, 0x50);
}
-   if (rt2x00_rt(rt2x00dev, RT3593))
+   if (rt2x00_rt(rt2x00dev, RT3593) ||
+   rt2x00_rt(rt2x00dev, RT3883))
rt2800_bbp_write(rt2x00dev, 83, 0x8a);
}
 
} else {
if (rt2x00_rt(rt2x00dev, RT3572))
rt2800_bbp_write(rt2x00dev, 82, 0x94);
-   else if (rt2x00_rt(rt2x00dev, RT3593))
+   else if (rt2x00_rt(rt2x00dev, RT3593) ||
+rt2x00_rt(rt2x00dev, RT3883))
rt2800_bbp_write(rt2x00dev, 82, 0x82);
else
rt2800_bbp_write(rt2x00dev, 82, 0xf2);
 
-   if (rt2x00_rt(rt2x00dev, RT3593))
+   if (rt2x00_rt(rt2x00dev, RT3593) ||
+   rt2x00_rt(rt2x00dev, RT3883))
rt2800_bbp_write(rt2x00dev, 83, 0x9a);
 
if (rt2x00_has_cap_external_lna_a(rt2x00dev))
@@ -3699,6 

[PATCH 19/40] rt2x00: rt2800lib: force rf type to RF3853 on RT3883

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

Signed-off-by: Gabor Juhos 
---
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index e3b9a97b1fc2..005fd02c0226 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -7629,6 +7629,8 @@ static int rt2800_init_eeprom(struct rt2x00_dev 
*rt2x00dev)
rt2x00_rt(rt2x00dev, RT5390) ||
rt2x00_rt(rt2x00dev, RT5392))
rt2800_eeprom_read(rt2x00dev, EEPROM_CHIP_ID, );
+   else if (rt2x00_rt(rt2x00dev, RT3883))
+   rf = RF3853;
else
rf = rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RF_TYPE);
 
-- 
2.11.0



[RFC v3 2/8] ath10k: htc: rx trailer lookahead support

2017-01-13 Thread Erik Stromdahl
The RX trailer parsing is now capable of parsing lookahead reports.
A lookahead contains the first 4 bytes of the next HTC message
(that will be read in the next SDIO read operation).
Lookaheads are used by the SDIO/mbox HIF layer to determine if
the next message is part of a bundle, which endpoint it belongs
to and how long it is.

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/htc.c | 93 ++-
 drivers/net/wireless/ath/ath10k/htc.h | 30 +--
 2 files changed, 118 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/htc.c 
b/drivers/net/wireless/ath/ath10k/htc.c
index 35e67c4..e72f385 100644
--- a/drivers/net/wireless/ath/ath10k/htc.c
+++ b/drivers/net/wireless/ath/ath10k/htc.c
@@ -228,10 +228,76 @@ ath10k_htc_process_credit_report(struct ath10k_htc *htc,
spin_unlock_bh(>tx_lock);
 }
 
+static int
+ath10k_htc_process_lookahead(struct ath10k_htc *htc,
+const struct ath10k_htc_lookahead_report *report,
+int len,
+enum ath10k_htc_ep_id eid,
+void *next_lookaheads,
+int *next_lookaheads_len)
+{
+   struct ath10k *ar = htc->ar;
+
+   /* Invalid lookahead flags are actually transmitted by
+* the target in the HTC control message.
+* Since this will happen at every boot we silently ignore
+* the lookahead in this case
+*/
+   if (report->pre_valid != ((~report->post_valid) & 0xFF))
+   return 0;
+
+   if (next_lookaheads && next_lookaheads_len) {
+   ath10k_dbg(ar, ATH10K_DBG_HTC,
+  "htc rx lookahead found pre_valid 0x%x post_valid 
0x%x\n",
+  report->pre_valid, report->post_valid);
+
+   /* look ahead bytes are valid, copy them over */
+   memcpy((u8 *)next_lookaheads, report->lookahead, 4);
+
+   *next_lookaheads_len = 1;
+   }
+
+   return 0;
+}
+
+static int
+ath10k_htc_process_lookahead_bundle(struct ath10k_htc *htc,
+   const struct 
ath10k_htc_lookahead_report_bundle *report,
+   int len,
+   enum ath10k_htc_ep_id eid,
+   void *next_lookaheads,
+   int *next_lookaheads_len)
+{
+   struct ath10k *ar = htc->ar;
+   int bundle_cnt = len / sizeof(*report);
+
+   if (!bundle_cnt || (bundle_cnt > HTC_HOST_MAX_MSG_PER_BUNDLE)) {
+   ath10k_warn(ar, "Invalid lookahead bundle count: %d\n",
+   bundle_cnt);
+   return -EINVAL;
+   }
+
+   if (next_lookaheads && next_lookaheads_len) {
+   int i;
+
+   for (i = 0; i < bundle_cnt; i++) {
+   memcpy(((u8 *)next_lookaheads) + 4 * i,
+  report->lookahead, 4);
+   report++;
+   }
+
+   *next_lookaheads_len = bundle_cnt;
+   }
+
+   return 0;
+}
+
 int ath10k_htc_process_trailer(struct ath10k_htc *htc,
   u8 *buffer,
   int length,
-  enum ath10k_htc_ep_id src_eid)
+  enum ath10k_htc_ep_id src_eid,
+  void *next_lookaheads,
+  int *next_lookaheads_len)
 {
struct ath10k *ar = htc->ar;
int status = 0;
@@ -272,6 +338,28 @@ int ath10k_htc_process_trailer(struct ath10k_htc *htc,
 record->hdr.len,
 src_eid);
break;
+   case ATH10K_HTC_RECORD_LOOKAHEAD:
+   len = sizeof(struct ath10k_htc_lookahead_report);
+   if (record->hdr.len < len) {
+   ath10k_warn(ar, "Lookahead report too long\n");
+   status = -EINVAL;
+   break;
+   }
+   status = ath10k_htc_process_lookahead(htc,
+ 
record->lookahead_report,
+ record->hdr.len,
+ src_eid,
+ next_lookaheads,
+ 
next_lookaheads_len);
+   break;
+   case ATH10K_HTC_RECORD_LOOKAHEAD_BUNDLE:
+   status = ath10k_htc_process_lookahead_bundle(htc,
+
record->lookahead_bundle,
+   

[RFC v3 8/8] ath10k: htc: ready_ext msg support

2017-01-13 Thread Erik Stromdahl
Added support for extended ready message.
The extended ready message contains the maximum bundle
count supported by SDIO chipsets.

It is transmitted by SDIO chipset only and replaces the
"standard" ready message in this case.

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/htc.c | 28 ++--
 drivers/net/wireless/ath/ath10k/htc.h |  5 +
 2 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/htc.c 
b/drivers/net/wireless/ath/ath10k/htc.c
index eb036b3..3eaa9a8 100644
--- a/drivers/net/wireless/ath/ath10k/htc.c
+++ b/drivers/net/wireless/ath/ath10k/htc.c
@@ -581,8 +581,6 @@ int ath10k_htc_wait_target(struct ath10k_htc *htc)
unsigned long time_left;
struct ath10k_htc_msg *msg;
u16 message_id;
-   u16 credit_count;
-   u16 credit_size;
 
time_left = wait_for_completion_timeout(>ctl_resp,
ATH10K_HTC_WAIT_TIMEOUT_HZ);
@@ -619,16 +617,14 @@ int ath10k_htc_wait_target(struct ath10k_htc *htc)
 
msg = (struct ath10k_htc_msg *)htc->control_resp_buffer;
message_id   = __le16_to_cpu(msg->hdr.message_id);
-   credit_count = __le16_to_cpu(msg->ready.credit_count);
-   credit_size  = __le16_to_cpu(msg->ready.credit_size);
 
if (message_id != ATH10K_HTC_MSG_READY_ID) {
ath10k_err(ar, "Invalid HTC ready msg: 0x%x\n", message_id);
return -ECOMM;
}
 
-   htc->total_transmit_credits = credit_count;
-   htc->target_credit_size = credit_size;
+   htc->total_transmit_credits = __le16_to_cpu(msg->ready.credit_count);
+   htc->target_credit_size = __le16_to_cpu(msg->ready.credit_size);
 
ath10k_dbg(ar, ATH10K_DBG_HTC,
   "Target ready! transmit resources: %d size:%d\n",
@@ -641,6 +637,19 @@ int ath10k_htc_wait_target(struct ath10k_htc *htc)
return -ECOMM;
}
 
+   /* The only way to determine if the ready message is an extended
+* message is from the size.
+*/
+   if (htc->control_resp_len >=
+   sizeof(msg->hdr) + sizeof(msg->ready_ext)) {
+   htc->max_msgs_per_htc_bundle =
+   min_t(u8, msg->ready_ext.max_msgs_per_htc_bundle,
+ HTC_HOST_MAX_MSG_PER_BUNDLE);
+   ath10k_dbg(ar, ATH10K_DBG_HTC,
+  "Extended ready message. RX bundle size: %d\n",
+  htc->max_msgs_per_htc_bundle);
+   }
+
return 0;
 }
 
@@ -836,6 +845,13 @@ int ath10k_htc_start(struct ath10k_htc *htc)
msg->hdr.message_id =
__cpu_to_le16(ATH10K_HTC_MSG_SETUP_COMPLETE_EX_ID);
 
+   if (ar->hif.bus == ATH10K_BUS_SDIO) {
+   /* Extra setup params used by SDIO */
+   msg->setup_complete_ext.flags =
+   
__cpu_to_le32(ATH10K_HTC_SETUP_COMPLETE_FLAGS_RX_BNDL_EN);
+   msg->setup_complete_ext.max_msgs_per_bundled_recv =
+   htc->max_msgs_per_htc_bundle;
+   }
ath10k_dbg(ar, ATH10K_DBG_HTC, "HTC is using TX credit flow control\n");
 
status = ath10k_htc_send(htc, ATH10K_HTC_EP_0, skb);
diff --git a/drivers/net/wireless/ath/ath10k/htc.h 
b/drivers/net/wireless/ath/ath10k/htc.h
index 9a1db90..566e437 100644
--- a/drivers/net/wireless/ath/ath10k/htc.h
+++ b/drivers/net/wireless/ath/ath10k/htc.h
@@ -112,6 +112,10 @@ enum ath10k_htc_conn_svc_status {
ATH10K_HTC_CONN_SVC_STATUS_NO_MORE_EP   = 4
 };
 
+enum ath10k_htc_setup_complete_flags {
+   ATH10K_HTC_SETUP_COMPLETE_FLAGS_RX_BNDL_EN = 1
+};
+
 struct ath10k_ath10k_htc_msg_hdr {
__le16 message_id; /* @enum htc_message_id */
 } __packed;
@@ -360,6 +364,7 @@ struct ath10k_htc {
 
int total_transmit_credits;
int target_credit_size;
+   u8 max_msgs_per_htc_bundle;
 };
 
 int ath10k_htc_init(struct ath10k *ar);
-- 
2.7.4



[RFC v3 1/8] ath10k: htc: made static function public

2017-01-13 Thread Erik Stromdahl
Changed ath10k_htc_notify_tx_completion and
ath10k_htc_process_trailer from static to non static.

These functions are needed by SDIO/mbox.

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/htc.c | 14 --
 drivers/net/wireless/ath/ath10k/htc.h |  6 ++
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/htc.c 
b/drivers/net/wireless/ath/ath10k/htc.c
index 9f6a915..35e67c4 100644
--- a/drivers/net/wireless/ath/ath10k/htc.c
+++ b/drivers/net/wireless/ath/ath10k/htc.c
@@ -57,8 +57,8 @@ static inline void ath10k_htc_restore_tx_skb(struct 
ath10k_htc *htc,
skb_pull(skb, sizeof(struct ath10k_htc_hdr));
 }
 
-static void ath10k_htc_notify_tx_completion(struct ath10k_htc_ep *ep,
-   struct sk_buff *skb)
+void ath10k_htc_notify_tx_completion(struct ath10k_htc_ep *ep,
+struct sk_buff *skb)
 {
struct ath10k *ar = ep->htc->ar;
 
@@ -75,6 +75,7 @@ static void ath10k_htc_notify_tx_completion(struct 
ath10k_htc_ep *ep,
 
ep->ep_ops.ep_tx_complete(ep->htc->ar, skb);
 }
+EXPORT_SYMBOL(ath10k_htc_notify_tx_completion);
 
 static void ath10k_htc_prepare_tx_skb(struct ath10k_htc_ep *ep,
  struct sk_buff *skb)
@@ -227,10 +228,10 @@ ath10k_htc_process_credit_report(struct ath10k_htc *htc,
spin_unlock_bh(>tx_lock);
 }
 
-static int ath10k_htc_process_trailer(struct ath10k_htc *htc,
- u8 *buffer,
- int length,
- enum ath10k_htc_ep_id src_eid)
+int ath10k_htc_process_trailer(struct ath10k_htc *htc,
+  u8 *buffer,
+  int length,
+  enum ath10k_htc_ep_id src_eid)
 {
struct ath10k *ar = htc->ar;
int status = 0;
@@ -291,6 +292,7 @@ static int ath10k_htc_process_trailer(struct ath10k_htc 
*htc,
 
return status;
 }
+EXPORT_SYMBOL(ath10k_htc_process_trailer);
 
 void ath10k_htc_rx_completion_handler(struct ath10k *ar, struct sk_buff *skb)
 {
diff --git a/drivers/net/wireless/ath/ath10k/htc.h 
b/drivers/net/wireless/ath/ath10k/htc.h
index 6ababa3..f728ce7 100644
--- a/drivers/net/wireless/ath/ath10k/htc.h
+++ b/drivers/net/wireless/ath/ath10k/htc.h
@@ -351,5 +351,11 @@ int ath10k_htc_send(struct ath10k_htc *htc, enum 
ath10k_htc_ep_id eid,
 struct sk_buff *ath10k_htc_alloc_skb(struct ath10k *ar, int size);
 void ath10k_htc_tx_completion_handler(struct ath10k *ar, struct sk_buff *skb);
 void ath10k_htc_rx_completion_handler(struct ath10k *ar, struct sk_buff *skb);
+void ath10k_htc_notify_tx_completion(struct ath10k_htc_ep *ep,
+struct sk_buff *skb);
+int ath10k_htc_process_trailer(struct ath10k_htc *htc,
+  u8 *buffer,
+  int length,
+  enum ath10k_htc_ep_id src_eid);
 
 #endif
-- 
2.7.4



[PATCH 18/40] rt2x00: rt2800lib: use the extended EEPROM map for RT3883

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

Signed-off-by: Gabor Juhos 
---
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index 870e2da20d47..e3b9a97b1fc2 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -342,7 +342,8 @@ static unsigned int rt2800_eeprom_word_index(struct 
rt2x00_dev *rt2x00dev,
  wiphy_name(rt2x00dev->hw->wiphy), word))
return 0;
 
-   if (rt2x00_rt(rt2x00dev, RT3593))
+   if (rt2x00_rt(rt2x00dev, RT3593) ||
+   rt2x00_rt(rt2x00dev, RT3883))
map = rt2800_eeprom_map_ext;
else
map = rt2800_eeprom_map;
-- 
2.11.0



[RFC v3 7/8] ath10k: sdio get target info

2017-01-13 Thread Erik Stromdahl
Special BMI get target info function for SDIO.

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/bmi.c  | 70 ++
 drivers/net/wireless/ath/ath10k/bmi.h  |  2 +
 drivers/net/wireless/ath/ath10k/core.c |  5 ++-
 3 files changed, 76 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/bmi.c 
b/drivers/net/wireless/ath/ath10k/bmi.c
index 2872d34..d9db153 100644
--- a/drivers/net/wireless/ath/ath10k/bmi.c
+++ b/drivers/net/wireless/ath/ath10k/bmi.c
@@ -88,6 +88,76 @@ int ath10k_bmi_get_target_info(struct ath10k *ar,
return 0;
 }
 
+#define TARGET_VERSION_SENTINAL 0xu
+
+int ath10k_bmi_get_target_info_sdio(struct ath10k *ar,
+   struct bmi_target_info *target_info)
+{
+   struct bmi_cmd cmd;
+   union bmi_resp resp;
+   u32 cmdlen = sizeof(cmd.id) + sizeof(cmd.get_target_info);
+   u32 resplen, tmp, ver_len;
+   int ret;
+
+   ath10k_dbg(ar, ATH10K_DBG_BMI, "bmi get target info SDIO\n");
+
+   if (ar->bmi.done_sent) {
+   ath10k_warn(ar, "BMI Get Target Info Command disallowed\n");
+   return -EBUSY;
+   }
+
+   cmd.id = __cpu_to_le32(BMI_GET_TARGET_INFO);
+
+   /* Step 1: Read 4 bytes of the target info and check if it is
+* the special sentinal version word or the first word in the
+* version response.
+*/
+   resplen = sizeof(u32);
+   ret = ath10k_hif_exchange_bmi_msg(ar, , cmdlen, , );
+   if (ret) {
+   ath10k_warn(ar, "unable to read from device\n");
+   return ret;
+   }
+
+   /* Some SDIO boards have a special sentinal byte before the real
+* version response.
+*/
+   if (tmp == TARGET_VERSION_SENTINAL) {
+   /* Step 1b: Read the version length */
+   resplen = sizeof(u32);
+   ret = ath10k_hif_exchange_bmi_msg(ar, NULL, 0, ,
+ );
+   if (ret) {
+   ath10k_warn(ar, "unable to read from device\n");
+   return ret;
+   }
+   }
+
+   ver_len = __le32_to_cpu(tmp);
+
+   /* Step 2: Check the target info length */
+   if (ver_len != sizeof(resp.get_target_info)) {
+   ath10k_warn(ar, "Unexpected target info len: %u. Expected: 
%lu\n",
+   ver_len, sizeof(resp.get_target_info));
+   return -EINVAL;
+   }
+
+   /* Step 3: Read the rest of the version response */
+   resplen = sizeof(resp.get_target_info) - sizeof(u32);
+   ret = ath10k_hif_exchange_bmi_msg(ar, NULL, 0,
+ _target_info.version,
+ );
+   if (ret) {
+   ath10k_warn(ar, "unable to read from device\n");
+   return ret;
+   }
+
+   target_info->version = __le32_to_cpu(resp.get_target_info.version);
+   target_info->type= __le32_to_cpu(resp.get_target_info.type);
+
+   return 0;
+}
+
 int ath10k_bmi_read_memory(struct ath10k *ar,
   u32 address, void *buffer, u32 length)
 {
diff --git a/drivers/net/wireless/ath/ath10k/bmi.h 
b/drivers/net/wireless/ath/ath10k/bmi.h
index 7d3231a..8a5ef1b 100644
--- a/drivers/net/wireless/ath/ath10k/bmi.h
+++ b/drivers/net/wireless/ath/ath10k/bmi.h
@@ -197,6 +197,8 @@ void ath10k_bmi_start(struct ath10k *ar);
 int ath10k_bmi_done(struct ath10k *ar);
 int ath10k_bmi_get_target_info(struct ath10k *ar,
   struct bmi_target_info *target_info);
+int ath10k_bmi_get_target_info_sdio(struct ath10k *ar,
+   struct bmi_target_info *target_info);
 int ath10k_bmi_read_memory(struct ath10k *ar, u32 address,
   void *buffer, u32 length);
 int ath10k_bmi_write_memory(struct ath10k *ar, u32 address,
diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index 874c2a7..e34c734 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -2084,7 +2084,10 @@ static int ath10k_core_probe_fw(struct ath10k *ar)
}
 
memset(_info, 0, sizeof(target_info));
-   ret = ath10k_bmi_get_target_info(ar, _info);
+   if (ar->hif.bus == ATH10K_BUS_SDIO)
+   ret = ath10k_bmi_get_target_info_sdio(ar, _info);
+   else
+   ret = ath10k_bmi_get_target_info(ar, _info);
if (ret) {
ath10k_err(ar, "could not get target info (%d)\n", ret);
goto err_power_down;
-- 
2.7.4



[RFC v3 5/8] ath10k: various sdio related definitions

2017-01-13 Thread Erik Stromdahl
Debug masks for SDIO HIF layer.
Address definitions for SDIO/mbox based chipsets.
Augmented struct host_interest with more members.

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/core.h  |  3 ++
 drivers/net/wireless/ath/ath10k/debug.h |  2 ++
 drivers/net/wireless/ath/ath10k/hw.h| 53 +
 drivers/net/wireless/ath/ath10k/targaddrs.h | 24 +
 4 files changed, 82 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/core.h 
b/drivers/net/wireless/ath/ath10k/core.h
index c7664d6..1ffef90 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -74,6 +74,7 @@ struct ath10k;
 enum ath10k_bus {
ATH10K_BUS_PCI,
ATH10K_BUS_AHB,
+   ATH10K_BUS_SDIO,
 };
 
 static inline const char *ath10k_bus_str(enum ath10k_bus bus)
@@ -83,6 +84,8 @@ static inline const char *ath10k_bus_str(enum ath10k_bus bus)
return "pci";
case ATH10K_BUS_AHB:
return "ahb";
+   case ATH10K_BUS_SDIO:
+   return "sdio";
}
 
return "unknown";
diff --git a/drivers/net/wireless/ath/ath10k/debug.h 
b/drivers/net/wireless/ath/ath10k/debug.h
index 2368f47..257d109 100644
--- a/drivers/net/wireless/ath/ath10k/debug.h
+++ b/drivers/net/wireless/ath/ath10k/debug.h
@@ -38,6 +38,8 @@ enum ath10k_debug_mask {
ATH10K_DBG_WMI_PRINT= 0x2000,
ATH10K_DBG_PCI_PS   = 0x4000,
ATH10K_DBG_AHB  = 0x8000,
+   ATH10K_DBG_SDIO = 0x0001,
+   ATH10K_DBG_SDIO_DUMP= 0x0002,
ATH10K_DBG_ANY  = 0x,
 };
 
diff --git a/drivers/net/wireless/ath/ath10k/hw.h 
b/drivers/net/wireless/ath/ath10k/hw.h
index 7feffec..6bdea86 100644
--- a/drivers/net/wireless/ath/ath10k/hw.h
+++ b/drivers/net/wireless/ath/ath10k/hw.h
@@ -814,6 +814,59 @@ ath10k_rx_desc_get_l3_pad_bytes(struct ath10k_hw_params 
*hw,
 #define QCA9887_EEPROM_ADDR_LO_MASK0x00ff
 #define QCA9887_EEPROM_ADDR_LO_LSB 16
 
+#define MBOX_RESET_CONTROL_ADDRESS 0x
+#define MBOX_HOST_INT_STATUS_ADDRESS   0x0800
+#define MBOX_HOST_INT_STATUS_ERROR_LSB 7
+#define MBOX_HOST_INT_STATUS_ERROR_MASK0x0080
+#define MBOX_HOST_INT_STATUS_CPU_LSB   6
+#define MBOX_HOST_INT_STATUS_CPU_MASK  0x0040
+#define MBOX_HOST_INT_STATUS_COUNTER_LSB   4
+#define MBOX_HOST_INT_STATUS_COUNTER_MASK  0x0010
+#define MBOX_CPU_INT_STATUS_ADDRESS0x0801
+#define MBOX_ERROR_INT_STATUS_ADDRESS  0x0802
+#define MBOX_ERROR_INT_STATUS_WAKEUP_LSB   2
+#define MBOX_ERROR_INT_STATUS_WAKEUP_MASK  0x0004
+#define MBOX_ERROR_INT_STATUS_RX_UNDERFLOW_LSB 1
+#define MBOX_ERROR_INT_STATUS_RX_UNDERFLOW_MASK0x0002
+#define MBOX_ERROR_INT_STATUS_TX_OVERFLOW_LSB  0
+#define MBOX_ERROR_INT_STATUS_TX_OVERFLOW_MASK 0x0001
+#define MBOX_COUNTER_INT_STATUS_ADDRESS0x0803
+#define MBOX_COUNTER_INT_STATUS_COUNTER_LSB0
+#define MBOX_COUNTER_INT_STATUS_COUNTER_MASK   0x00ff
+#define MBOX_RX_LOOKAHEAD_VALID_ADDRESS0x0805
+#define MBOX_INT_STATUS_ENABLE_ADDRESS 0x0828
+#define MBOX_INT_STATUS_ENABLE_ERROR_LSB   7
+#define MBOX_INT_STATUS_ENABLE_ERROR_MASK  0x0080
+#define MBOX_INT_STATUS_ENABLE_CPU_LSB 6
+#define MBOX_INT_STATUS_ENABLE_CPU_MASK0x0040
+#define MBOX_INT_STATUS_ENABLE_INT_LSB 5
+#define MBOX_INT_STATUS_ENABLE_INT_MASK0x0020
+#define MBOX_INT_STATUS_ENABLE_COUNTER_LSB 4
+#define MBOX_INT_STATUS_ENABLE_COUNTER_MASK0x0010
+#define MBOX_INT_STATUS_ENABLE_MBOX_DATA_LSB   0
+#define MBOX_INT_STATUS_ENABLE_MBOX_DATA_MASK  0x000f
+#define MBOX_CPU_INT_STATUS_ENABLE_ADDRESS 0x0819
+#define MBOX_CPU_INT_STATUS_ENABLE_BIT_LSB 0
+#define MBOX_CPU_INT_STATUS_ENABLE_BIT_MASK0x00ff
+#define MBOX_ERROR_STATUS_ENABLE_ADDRESS   0x081a
+#define MBOX_ERROR_STATUS_ENABLE_RX_UNDERFLOW_LSB  1
+#define MBOX_ERROR_STATUS_ENABLE_RX_UNDERFLOW_MASK 0x0002
+#define MBOX_ERROR_STATUS_ENABLE_TX_OVERFLOW_LSB   0
+#define MBOX_ERROR_STATUS_ENABLE_TX_OVERFLOW_MASK  0x0001
+#define MBOX_COUNTER_INT_STATUS_ENABLE_ADDRESS 0x081b
+#define MBOX_COUNTER_INT_STATUS_ENABLE_BIT_LSB 0
+#define MBOX_COUNTER_INT_STATUS_ENABLE_BIT_MASK0x00ff
+#define MBOX_COUNT_ADDRESS 0x0820
+#define MBOX_COUNT_DEC_ADDRESS 0x0840
+#define MBOX_WINDOW_DATA_ADDRESS   0x0874
+#define MBOX_WINDOW_WRITE_ADDR_ADDRESS 0x0878
+#define MBOX_WINDOW_READ_ADDR_ADDRESS  0x087c
+#define MBOX_CPU_DBG_SEL_ADDRESS   0x0883
+#define MBOX_CPU_DBG_ADDRESS   0x0884
+#define MBOX_RTC_BASE_ADDRESS  0x
+#define 

[RFC v3 4/8] ath10k: htc: refactorization

2017-01-13 Thread Erik Stromdahl
Code refactorization:

Moved the code for ep 0 in ath10k_htc_rx_completion_handler
to ath10k_htc_control_rx_complete.

This eases the implementation of SDIO/mbox significantly since
the ep_rx_complete cb is invoked directly from the SDIO/mbox
hif layer.

Since the ath10k_htc_control_rx_complete already is present
(only containing a warning message) there is no reason for not
using it (instead of having a special case for ep 0 in
ath10k_htc_rx_completion_handler).

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/htc.c | 73 ---
 1 file changed, 34 insertions(+), 39 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/htc.c 
b/drivers/net/wireless/ath/ath10k/htc.c
index f39eef6..eb036b3 100644
--- a/drivers/net/wireless/ath/ath10k/htc.c
+++ b/drivers/net/wireless/ath/ath10k/htc.c
@@ -459,42 +459,6 @@ void ath10k_htc_rx_completion_handler(struct ath10k *ar, 
struct sk_buff *skb)
/* zero length packet with trailer data, just drop these */
goto out;
 
-   if (eid == ATH10K_HTC_EP_0) {
-   struct ath10k_htc_msg *msg = (struct ath10k_htc_msg *)skb->data;
-
-   switch (__le16_to_cpu(msg->hdr.message_id)) {
-   case ATH10K_HTC_MSG_READY_ID:
-   case ATH10K_HTC_MSG_CONNECT_SERVICE_RESP_ID:
-   /* handle HTC control message */
-   if (completion_done(>ctl_resp)) {
-   /*
-* this is a fatal error, target should not be
-* sending unsolicited messages on the ep 0
-*/
-   ath10k_warn(ar, "HTC rx ctrl still 
processing\n");
-   complete(>ctl_resp);
-   goto out;
-   }
-
-   htc->control_resp_len =
-   min_t(int, skb->len,
- ATH10K_HTC_MAX_CTRL_MSG_LEN);
-
-   memcpy(htc->control_resp_buffer, skb->data,
-  htc->control_resp_len);
-
-   complete(>ctl_resp);
-   break;
-   case ATH10K_HTC_MSG_SEND_SUSPEND_COMPLETE:
-   htc->htc_ops.target_send_suspend_complete(ar);
-   break;
-   default:
-   ath10k_warn(ar, "ignoring unsolicited htc ep0 event\n");
-   break;
-   }
-   goto out;
-   }
-
ath10k_dbg(ar, ATH10K_DBG_HTC, "htc rx completion ep %d skb %pK\n",
   eid, skb);
ep->ep_ops.ep_rx_complete(ar, skb);
@@ -509,9 +473,40 @@ EXPORT_SYMBOL(ath10k_htc_rx_completion_handler);
 static void ath10k_htc_control_rx_complete(struct ath10k *ar,
   struct sk_buff *skb)
 {
-   /* This is unexpected. FW is not supposed to send regular rx on this
-* endpoint. */
-   ath10k_warn(ar, "unexpected htc rx\n");
+   struct ath10k_htc *htc = >htc;
+   struct ath10k_htc_msg *msg = (struct ath10k_htc_msg *)skb->data;
+
+   switch (__le16_to_cpu(msg->hdr.message_id)) {
+   case ATH10K_HTC_MSG_READY_ID:
+   case ATH10K_HTC_MSG_CONNECT_SERVICE_RESP_ID:
+   /* handle HTC control message */
+   if (completion_done(>ctl_resp)) {
+   /* this is a fatal error, target should not be
+* sending unsolicited messages on the ep 0
+*/
+   ath10k_warn(ar, "HTC rx ctrl still processing\n");
+   complete(>ctl_resp);
+   goto out;
+   }
+
+   htc->control_resp_len =
+   min_t(int, skb->len,
+ ATH10K_HTC_MAX_CTRL_MSG_LEN);
+
+   memcpy(htc->control_resp_buffer, skb->data,
+  htc->control_resp_len);
+
+   complete(>ctl_resp);
+   break;
+   case ATH10K_HTC_MSG_SEND_SUSPEND_COMPLETE:
+   htc->htc_ops.target_send_suspend_complete(ar);
+   break;
+   default:
+   ath10k_warn(ar, "ignoring unsolicited htc ep0 event\n");
+   break;
+   }
+
+out:
kfree_skb(skb);
 }
 
-- 
2.7.4



[RFC v3 6/8] ath10k: sdio support

2017-01-13 Thread Erik Stromdahl
sdio/mailbox HIF implementation.

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/Kconfig  |6 +
 drivers/net/wireless/ath/ath10k/Makefile |3 +
 drivers/net/wireless/ath/ath10k/sdio.c   | 2105 ++
 drivers/net/wireless/ath/ath10k/sdio.h   |  259 
 4 files changed, 2373 insertions(+)
 create mode 100644 drivers/net/wireless/ath/ath10k/sdio.c
 create mode 100644 drivers/net/wireless/ath/ath10k/sdio.h

diff --git a/drivers/net/wireless/ath/ath10k/Kconfig 
b/drivers/net/wireless/ath/ath10k/Kconfig
index db1ca62..9a03178 100644
--- a/drivers/net/wireless/ath/ath10k/Kconfig
+++ b/drivers/net/wireless/ath/ath10k/Kconfig
@@ -21,6 +21,12 @@ config ATH10K_AHB
---help---
  This module adds support for AHB bus
 
+config ATH10K_SDIO
+   tristate "Atheros ath10k SDIO support (EXPERIMENTAL)"
+   depends on ATH10K && MMC
+   ---help---
+ This module adds support for SDIO/MMC bus
+
 config ATH10K_DEBUG
bool "Atheros ath10k debugging"
depends on ATH10K
diff --git a/drivers/net/wireless/ath/ath10k/Makefile 
b/drivers/net/wireless/ath/ath10k/Makefile
index 930fadd..b0b19a7 100644
--- a/drivers/net/wireless/ath/ath10k/Makefile
+++ b/drivers/net/wireless/ath/ath10k/Makefile
@@ -27,5 +27,8 @@ ath10k_pci-y += pci.o \
 
 ath10k_pci-$(CONFIG_ATH10K_AHB) += ahb.o
 
+obj-$(CONFIG_ATH10K_SDIO) += ath10k_sdio.o
+ath10k_sdio-y += sdio.o
+
 # for tracing framework to find trace.h
 CFLAGS_trace.o := -I$(src)
diff --git a/drivers/net/wireless/ath/ath10k/sdio.c 
b/drivers/net/wireless/ath/ath10k/sdio.c
new file mode 100644
index 000..cf911f3
--- /dev/null
+++ b/drivers/net/wireless/ath/ath10k/sdio.c
@@ -0,0 +1,2105 @@
+/*
+ * Copyright (c) 2004-2011 Atheros Communications Inc.
+ * Copyright (c) 2011-2012 Qualcomm Atheros, Inc.
+ * Copyright (c) 2016 Erik Stromdahl
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "core.h"
+#include "bmi.h"
+#include "debug.h"
+#include "hif.h"
+#include "htc.h"
+#include "targaddrs.h"
+#include "trace.h"
+#include "sdio.h"
+
+/* inlined helper functions */
+
+static inline int ath10k_sdio_calc_txrx_padded_len(struct ath10k_sdio *ar_sdio,
+  size_t len)
+{
+   return __ALIGN_MASK((len), ar_sdio->mbox_info.block_mask);
+}
+
+static inline enum ath10k_htc_ep_id pipe_id_to_eid(u8 pipe_id)
+{
+   return (enum ath10k_htc_ep_id)pipe_id;
+}
+
+static inline void ath10k_sdio_mbox_free_rx_pkt(struct ath10k_sdio_rx_data 
*pkt)
+{
+   dev_kfree_skb(pkt->skb);
+   pkt->skb = NULL;
+   pkt->alloc_len = 0;
+   pkt->act_len = 0;
+   pkt->trailer_only = false;
+}
+
+static inline int ath10k_sdio_mbox_alloc_rx_pkt(struct ath10k_sdio_rx_data 
*pkt,
+   size_t act_len, size_t full_len,
+   bool part_of_bundle,
+   bool last_in_bundle)
+{
+   pkt->skb = dev_alloc_skb(full_len);
+   if (!pkt->skb)
+   return -ENOMEM;
+
+   pkt->act_len = act_len;
+   pkt->alloc_len = full_len;
+   pkt->part_of_bundle = part_of_bundle;
+   pkt->last_in_bundle = last_in_bundle;
+   pkt->trailer_only = false;
+
+   return 0;
+}
+
+static inline bool is_trailer_only_msg(struct ath10k_sdio_rx_data *pkt)
+{
+   bool trailer_only = false;
+   struct ath10k_htc_hdr *htc_hdr =
+   (struct ath10k_htc_hdr *)pkt->skb->data;
+   u16 len = __le16_to_cpu(htc_hdr->len);
+
+   if (len == htc_hdr->trailer_len)
+   trailer_only = true;
+
+   return trailer_only;
+}
+
+/* sdio/mmc functions */
+
+static inline void ath10k_sdio_set_cmd52_arg(u32 *arg, u8 write, u8 raw,
+unsigned int address,
+unsigned char val)
+{
+   *arg = FIELD_PREP(BIT(31), write) |
+  FIELD_PREP(BIT(27), raw) |
+  FIELD_PREP(BIT(26), 1) |
+  FIELD_PREP(GENMASK(25, 9), address) |
+  FIELD_PREP(BIT(8), 1) |
+  

[PATCH 16/40] rt2x00: rt2800lib: add BBP register initialization for RT3883

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

Signed-off-by: Gabor Juhos 
---
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 44 ++
 1 file changed, 44 insertions(+)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index cf9a8cfd4fbc..df0c6dd90735 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -5830,6 +5830,47 @@ static void rt2800_init_bbp_3593(struct rt2x00_dev 
*rt2x00dev)
rt2800_bbp_write(rt2x00dev, 103, 0xc0);
 }
 
+static void rt2800_init_bbp_3883(struct rt2x00_dev *rt2x00dev)
+{
+   rt2800_init_bbp_early(rt2x00dev);
+
+   rt2800_bbp_write(rt2x00dev, 4, 0x50);
+   rt2800_bbp_write(rt2x00dev, 47, 0x48);
+
+   rt2800_bbp_write(rt2x00dev, 86, 0x46);
+   rt2800_bbp_write(rt2x00dev, 88, 0x90);
+
+   rt2800_bbp_write(rt2x00dev, 92, 0x02);
+
+   rt2800_bbp_write(rt2x00dev, 103, 0xc0);
+   rt2800_bbp_write(rt2x00dev, 104, 0x92);
+   rt2800_bbp_write(rt2x00dev, 105, 0x34);
+   rt2800_bbp_write(rt2x00dev, 106, 0x12);
+   rt2800_bbp_write(rt2x00dev, 120, 0x50);
+   rt2800_bbp_write(rt2x00dev, 137, 0x0f);
+   rt2800_bbp_write(rt2x00dev, 163, 0x9d);
+
+   /* Set ITxBF timeout to 0x9C40=1000msec */
+   rt2800_bbp_write(rt2x00dev, 179, 0x02);
+   rt2800_bbp_write(rt2x00dev, 180, 0x00);
+   rt2800_bbp_write(rt2x00dev, 182, 0x40);
+   rt2800_bbp_write(rt2x00dev, 180, 0x01);
+   rt2800_bbp_write(rt2x00dev, 182, 0x9c);
+
+   rt2800_bbp_write(rt2x00dev, 179, 0x00);
+
+   /* Reprogram the inband interface to put right values in RXWI */
+   rt2800_bbp_write(rt2x00dev, 142, 0x04);
+   rt2800_bbp_write(rt2x00dev, 143, 0x3b);
+   rt2800_bbp_write(rt2x00dev, 142, 0x06);
+   rt2800_bbp_write(rt2x00dev, 143, 0xa0);
+   rt2800_bbp_write(rt2x00dev, 142, 0x07);
+   rt2800_bbp_write(rt2x00dev, 143, 0xa1);
+   rt2800_bbp_write(rt2x00dev, 142, 0x08);
+   rt2800_bbp_write(rt2x00dev, 143, 0xa2);
+   rt2800_bbp_write(rt2x00dev, 148, 0xc8);
+}
+
 static void rt2800_init_bbp_53xx(struct rt2x00_dev *rt2x00dev)
 {
int ant, div_mode;
@@ -6048,6 +6089,9 @@ static void rt2800_init_bbp(struct rt2x00_dev *rt2x00dev)
case RT3593:
rt2800_init_bbp_3593(rt2x00dev);
return;
+   case RT3883:
+   rt2800_init_bbp_3883(rt2x00dev);
+   return;
case RT5390:
case RT5392:
rt2800_init_bbp_53xx(rt2x00dev);
-- 
2.11.0



[PATCH 17/40] rt2x00: rt2800lib: add RFCSR initialization for RT3883

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

Signed-off-by: Gabor Juhos 
[dan...@makrotopia.org: use usleep_range instead of msleep, fixed comment]
---
 drivers/net/wireless/ralink/rt2x00/rt2800.h|  13 +++
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 141 +
 2 files changed, 154 insertions(+)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800.h 
b/drivers/net/wireless/ralink/rt2x00/rt2800.h
index 2190bf07d004..33a3b33c9a0b 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800.h
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h
@@ -1588,6 +1588,18 @@
 #define TX_PWR_CFG_9_STBC7_CH2 FIELD32(0x0f00)
 
 /*
+ * TX_TXBF_CFG:
+ */
+#define TX_TXBF_CFG_0  0x138c
+#define TX_TXBF_CFG_1  0x13a4
+#define TX_TXBF_CFG_2  0x13a8
+#define TX_TXBF_CFG_3  0x13ac
+
+/* TX_FBK_CFG_3S */
+#define TX_FBK_CFG_3S_00x13c4
+#define TX_FBK_CFG_3S_10x13c8
+
+/*
  * RX_FILTER_CFG: RX configuration register.
  */
 #define RX_FILTER_CFG  0x1400
@@ -2157,6 +2169,7 @@ struct mac_iveiv_entry {
 /*
  * RFCSR 2:
  */
+#define RFCSR2_RESCAL_BP   FIELD8(0x40)
 #define RFCSR2_RESCAL_EN   FIELD8(0x80)
 
 /*
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index df0c6dd90735..870e2da20d47 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -6865,6 +6865,144 @@ static void rt2800_init_rfcsr_3593(struct rt2x00_dev 
*rt2x00dev)
/* TODO: enable stream mode support */
 }
 
+static void rt2800_init_rfcsr_3883(struct rt2x00_dev *rt2x00dev)
+{
+   u8 rfcsr;
+
+   /* TODO: get the actual ECO value from the SoC */
+   const unsigned int eco = 5;
+
+   rt2800_rf_init_calibration(rt2x00dev, 2);
+
+   rt2800_rfcsr_write(rt2x00dev, 0, 0xe0);
+   rt2800_rfcsr_write(rt2x00dev, 1, 0x03);
+   rt2800_rfcsr_write(rt2x00dev, 2, 0x50);
+   rt2800_rfcsr_write(rt2x00dev, 3, 0x20);
+   rt2800_rfcsr_write(rt2x00dev, 4, 0x00);
+   rt2800_rfcsr_write(rt2x00dev, 5, 0x00);
+   rt2800_rfcsr_write(rt2x00dev, 6, 0x40);
+   rt2800_rfcsr_write(rt2x00dev, 7, 0x00);
+   rt2800_rfcsr_write(rt2x00dev, 8, 0x5b);
+   rt2800_rfcsr_write(rt2x00dev, 9, 0x08);
+   rt2800_rfcsr_write(rt2x00dev, 10, 0xd3);
+   rt2800_rfcsr_write(rt2x00dev, 11, 0x48);
+   rt2800_rfcsr_write(rt2x00dev, 12, 0x1a);
+   rt2800_rfcsr_write(rt2x00dev, 13, 0x12);
+   rt2800_rfcsr_write(rt2x00dev, 14, 0x00);
+   rt2800_rfcsr_write(rt2x00dev, 15, 0x00);
+   rt2800_rfcsr_write(rt2x00dev, 16, 0x00);
+
+   /* RFCSR 17 will be initialized later based on the
+* frequency offset stored in the EEPROM
+*/
+
+   rt2800_rfcsr_write(rt2x00dev, 18, 0x40);
+   rt2800_rfcsr_write(rt2x00dev, 19, 0x00);
+   rt2800_rfcsr_write(rt2x00dev, 20, 0x00);
+   rt2800_rfcsr_write(rt2x00dev, 21, 0x00);
+   rt2800_rfcsr_write(rt2x00dev, 22, 0x20);
+   rt2800_rfcsr_write(rt2x00dev, 23, 0xc0);
+   rt2800_rfcsr_write(rt2x00dev, 24, 0x00);
+   rt2800_rfcsr_write(rt2x00dev, 25, 0x00);
+   rt2800_rfcsr_write(rt2x00dev, 26, 0x00);
+   rt2800_rfcsr_write(rt2x00dev, 27, 0x00);
+   rt2800_rfcsr_write(rt2x00dev, 28, 0x00);
+   rt2800_rfcsr_write(rt2x00dev, 29, 0x00);
+   rt2800_rfcsr_write(rt2x00dev, 30, 0x10);
+   rt2800_rfcsr_write(rt2x00dev, 31, 0x80);
+   rt2800_rfcsr_write(rt2x00dev, 32, 0x80);
+   rt2800_rfcsr_write(rt2x00dev, 33, 0x00);
+   rt2800_rfcsr_write(rt2x00dev, 34, 0x20);
+   rt2800_rfcsr_write(rt2x00dev, 35, 0x00);
+   rt2800_rfcsr_write(rt2x00dev, 36, 0x00);
+   rt2800_rfcsr_write(rt2x00dev, 37, 0x00);
+   rt2800_rfcsr_write(rt2x00dev, 38, 0x86);
+   rt2800_rfcsr_write(rt2x00dev, 39, 0x23);
+   rt2800_rfcsr_write(rt2x00dev, 40, 0x00);
+   rt2800_rfcsr_write(rt2x00dev, 41, 0x00);
+   rt2800_rfcsr_write(rt2x00dev, 42, 0x00);
+   rt2800_rfcsr_write(rt2x00dev, 43, 0x00);
+   rt2800_rfcsr_write(rt2x00dev, 44, 0x93);
+   rt2800_rfcsr_write(rt2x00dev, 45, 0xbb);
+   rt2800_rfcsr_write(rt2x00dev, 46, 0x60);
+   rt2800_rfcsr_write(rt2x00dev, 47, 0x00);
+   rt2800_rfcsr_write(rt2x00dev, 48, 0x00);
+   rt2800_rfcsr_write(rt2x00dev, 49, 0x8e);
+   rt2800_rfcsr_write(rt2x00dev, 50, 0x86);
+   rt2800_rfcsr_write(rt2x00dev, 51, 0x51);
+   rt2800_rfcsr_write(rt2x00dev, 52, 0x05);
+   rt2800_rfcsr_write(rt2x00dev, 53, 0x76);
+   rt2800_rfcsr_write(rt2x00dev, 54, 0x76);
+   rt2800_rfcsr_write(rt2x00dev, 55, 0x76);
+   rt2800_rfcsr_write(rt2x00dev, 56, 0xdb);
+   rt2800_rfcsr_write(rt2x00dev, 57, 0x3e);
+   rt2800_rfcsr_write(rt2x00dev, 58, 0x00);
+   rt2800_rfcsr_write(rt2x00dev, 59, 0x00);
+   rt2800_rfcsr_write(rt2x00dev, 60, 0x00);
+  

[PATCH 11/40] rt2x00: rt2800lib: enable VCO calibration for RF3853

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

Signed-off-by: Gabor Juhos 
---
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index a1f8ca9a788b..15bcad1156d9 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -4414,6 +4414,7 @@ void rt2800_vco_calibration(struct rt2x00_dev *rt2x00dev)
case RF3053:
case RF3070:
case RF3290:
+   case RF3853:
case RF5360:
case RF5362:
case RF5370:
@@ -7894,6 +7895,7 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev 
*rt2x00dev)
case RF3053:
case RF3070:
case RF3290:
+   case RF3853:
case RF5360:
case RF5362:
case RF5370:
-- 
2.11.0



[PATCH 09/40] rt2x00: rt2800lib: enable support for RT3883

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

Signed-off-by: Gabor Juhos 
---
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index ff653f0d43d2..efac8a320054 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -7869,6 +7869,7 @@ static int rt2800_probe_rt(struct rt2x00_dev *rt2x00dev)
case RT3390:
case RT3572:
case RT3593:
+   case RT3883:
case RT5390:
case RT5392:
case RT5592:
-- 
2.11.0



[PATCH 10/40] rt2x00: rt2800lib: add rf_vals for RF3853

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

Signed-off-by: Gabor Juhos 
---
 drivers/net/wireless/ralink/rt2x00/rt2800.h|  4 +-
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 65 ++
 2 files changed, 68 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800.h 
b/drivers/net/wireless/ralink/rt2x00/rt2800.h
index 02ed0d512734..2190bf07d004 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800.h
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h
@@ -48,7 +48,8 @@
  * RF2853 2.4G/5G 3T3R
  * RF3320 2.4G 1T1R(RT3350/RT3370/RT3390)
  * RF3322 2.4G 2T2R(RT3352/RT3371/RT3372/RT3391/RT3392)
- * RF3053 2.4G/5G 3T3R(RT3883/RT3563/RT3573/RT3593/RT3662)
+ * RF3053 2.4G/5G 3T3R(RT3563/RT3573/RT3593)
+ * RF3853 2.4G/5G 3T3R(RT3883/RT3662)
  * RF5592 2.4G/5G 2T2R
  * RF3070 2.4G 1T1R
  * RF5360 2.4G 1T1R
@@ -72,6 +73,7 @@
 #define RF5592 0x000f
 #define RF3070 0x3070
 #define RF3290 0x3290
+#define RF3853 0x3853
 #define RF5360 0x5360
 #define RF5362 0x5362
 #define RF5370 0x5370
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index efac8a320054..a1f8ca9a788b 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -7482,6 +7482,66 @@ static const struct rf_channel rf_vals_3x[] = {
{173, 0x61, 0, 9},
 };
 
+static const struct rf_channel rf_vals_3853[] = {
+   {1,  241, 6, 2},
+   {2,  241, 6, 7},
+   {3,  242, 6, 2},
+   {4,  242, 6, 7},
+   {5,  243, 6, 2},
+   {6,  243, 6, 7},
+   {7,  244, 6, 2},
+   {8,  244, 6, 7},
+   {9,  245, 6, 2},
+   {10, 245, 6, 7},
+   {11, 246, 6, 2},
+   {12, 246, 6, 7},
+   {13, 247, 6, 2},
+   {14, 248, 6, 4},
+
+   {36, 0x56, 8, 4},
+   {38, 0x56, 8, 6},
+   {40, 0x56, 8, 8},
+   {44, 0x57, 8, 0},
+   {46, 0x57, 8, 2},
+   {48, 0x57, 8, 4},
+   {52, 0x57, 8, 8},
+   {54, 0x57, 8, 10},
+   {56, 0x58, 8, 0},
+   {60, 0x58, 8, 4},
+   {62, 0x58, 8, 6},
+   {64, 0x58, 8, 8},
+
+   {100, 0x5b, 8, 8},
+   {102, 0x5b, 8, 10},
+   {104, 0x5c, 8, 0},
+   {108, 0x5c, 8, 4},
+   {110, 0x5c, 8, 6},
+   {112, 0x5c, 8, 8},
+   {114, 0x5c, 8, 10},
+   {116, 0x5d, 8, 0},
+   {118, 0x5d, 8, 2},
+   {120, 0x5d, 8, 4},
+   {124, 0x5d, 8, 8},
+   {126, 0x5d, 8, 10},
+   {128, 0x5e, 8, 0},
+   {132, 0x5e, 8, 4},
+   {134, 0x5e, 8, 6},
+   {136, 0x5e, 8, 8},
+   {140, 0x5f, 8, 0},
+
+   {149, 0x5f, 8, 9},
+   {151, 0x5f, 8, 11},
+   {153, 0x60, 8, 1},
+   {157, 0x60, 8, 5},
+   {159, 0x60, 8, 7},
+   {161, 0x60, 8, 9},
+   {165, 0x61, 8, 1},
+   {167, 0x61, 8, 3},
+   {169, 0x61, 8, 5},
+   {171, 0x61, 8, 7},
+   {173, 0x61, 8, 9},
+};
+
 static const struct rf_channel rf_vals_5592_xtal20[] = {
/* Channel, N, K, mod, R */
{1, 482, 4, 10, 3},
@@ -7712,6 +7772,11 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev 
*rt2x00dev)
spec->channels = rf_vals_3x;
break;
 
+   case RF3853:
+   spec->num_channels = ARRAY_SIZE(rf_vals_3853);
+   spec->channels = rf_vals_3853;
+   break;
+
case RF5592:
rt2800_register_read(rt2x00dev, MAC_DEBUG_INDEX, );
if (rt2x00_get_field32(reg, MAC_DEBUG_INDEX_XTAL)) {
-- 
2.11.0



[PATCH 08/40] rt2x00: allow to build rt2800soc module for RT3883

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

Signed-off-by: Gabor Juhos 
---
 drivers/net/wireless/ralink/rt2x00/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/Kconfig 
b/drivers/net/wireless/ralink/rt2x00/Kconfig
index de62f5dcb62f..3f2651dcbf37 100644
--- a/drivers/net/wireless/ralink/rt2x00/Kconfig
+++ b/drivers/net/wireless/ralink/rt2x00/Kconfig
@@ -201,7 +201,7 @@ endif
 
 config RT2800SOC
tristate "Ralink WiSoC support"
-   depends on SOC_RT288X || SOC_RT305X
+   depends on SOC_RT288X || SOC_RT305X || SOC_RT3883
select RT2X00_LIB_SOC
select RT2X00_LIB_MMIO
select RT2X00_LIB_CRYPTO
-- 
2.11.0



[PATCH 07/40] rt2x00: rt2800lib: fix max supported beacon count for RT3593

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

Signed-off-by: Gabor Juhos 
---
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index 5058494d6c27..ff653f0d43d2 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -7899,7 +7899,10 @@ int rt2800_probe_hw(struct rt2x00_dev *rt2x00dev)
if (rt2x00_rt(rt2x00dev, RT3593))
__set_bit(RT2800_HAS_HIGH_SHARED_MEM, _data->rt2800_flags);
 
-   drv_data->hw_beacon_count = 8;
+   if (rt2x00_rt(rt2x00dev, RT3593))
+   drv_data->hw_beacon_count = 16;
+   else
+   drv_data->hw_beacon_count = 8;
 
/*
 * Allocate eeprom data.
-- 
2.11.0



[PATCH 06/40] rt2x00: rt2800lib: init additional beacon offset registers

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

Signed-off-by: Gabor Juhos 
---
 drivers/net/wireless/ralink/rt2x00/rt2800.h| 14 ++
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 24 
 2 files changed, 38 insertions(+)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800.h 
b/drivers/net/wireless/ralink/rt2x00/rt2800.h
index a81852cfb4f9..02ed0d512734 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800.h
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h
@@ -629,6 +629,20 @@
  */
 #define PBF_DBG0x043c
 
+/* BCN_OFFSET2 */
+#define BCN_OFFSET20x0444
+#define BCN_OFFSET2_BCN8   FIELD32(0x00ff)
+#define BCN_OFFSET2_BCN9   FIELD32(0xff00)
+#define BCN_OFFSET2_BCN10  FIELD32(0x00ff)
+#define BCN_OFFSET2_BCN11  FIELD32(0xff00)
+
+/* BCN_OFFSET3 */
+#define BCN_OFFSET30x0448
+#define BCN_OFFSET3_BCN12  FIELD32(0x00ff)
+#define BCN_OFFSET3_BCN13  FIELD32(0xff00)
+#define BCN_OFFSET3_BCN14  FIELD32(0x00ff)
+#define BCN_OFFSET3_BCN15  FIELD32(0xff00)
+
 /*
  * RF registers
  */
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index 0893d9147af9..5058494d6c27 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -4665,6 +4665,30 @@ static int rt2800_init_registers(struct rt2x00_dev 
*rt2x00dev)
if (ret)
return ret;
 
+   if (drv_data->hw_beacon_count == 16) {
+   rt2800_register_read(rt2x00dev, BCN_OFFSET2, );
+   rt2x00_set_field32(, BCN_OFFSET2_BCN8,
+  rt2800_get_beacon_offset(rt2x00dev, 8));
+   rt2x00_set_field32(, BCN_OFFSET2_BCN9,
+  rt2800_get_beacon_offset(rt2x00dev, 9));
+   rt2x00_set_field32(, BCN_OFFSET2_BCN10,
+  rt2800_get_beacon_offset(rt2x00dev, 10));
+   rt2x00_set_field32(, BCN_OFFSET2_BCN11,
+  rt2800_get_beacon_offset(rt2x00dev, 11));
+   rt2800_register_write(rt2x00dev, BCN_OFFSET2, reg);
+
+   rt2800_register_read(rt2x00dev, BCN_OFFSET3, );
+   rt2x00_set_field32(, BCN_OFFSET3_BCN12,
+  rt2800_get_beacon_offset(rt2x00dev, 12));
+   rt2x00_set_field32(, BCN_OFFSET3_BCN13,
+  rt2800_get_beacon_offset(rt2x00dev, 13));
+   rt2x00_set_field32(, BCN_OFFSET3_BCN14,
+  rt2800_get_beacon_offset(rt2x00dev, 14));
+   rt2x00_set_field32(, BCN_OFFSET3_BCN15,
+  rt2800_get_beacon_offset(rt2x00dev, 15));
+   rt2800_register_write(rt2x00dev, BCN_OFFSET3, reg);
+   }
+
rt2800_register_write(rt2x00dev, LEGACY_BASIC_RATE, 0x013f);
rt2800_register_write(rt2x00dev, HT_BASIC_RATE, 0x8003);
 
-- 
2.11.0



[PATCH 05/40] rt2x00: rt2800lib: add hw_beacon_count field to struct rt2800_drv_data

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

Some chipsets can handle more than 8 beacons at once.
Add a new field to the rt2800_drv_data structure which
will hold the number of supported beacons of the given
chipset.

Update the rt2x00_init_registers function to get the
beacon count from the new field instead of using a
hardcoded value.

In order to keep the current behaviour, initialize the
new field with the actually used value.

Signed-off-by: Gabor Juhos 
---
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 4 +++-
 drivers/net/wireless/ralink/rt2x00/rt2800lib.h | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index dcacfa54b3d6..0893d9147af9 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -5025,7 +5025,7 @@ static int rt2800_init_registers(struct rt2x00_dev 
*rt2x00dev)
/*
 * Clear all beacons
 */
-   for (i = 0; i < 8; i++)
+   for (i = 0; i < drv_data->hw_beacon_count; i++)
rt2800_clear_beacon_register(rt2x00dev, i);
 
if (rt2x00_is_usb(rt2x00dev)) {
@@ -7875,6 +7875,8 @@ int rt2800_probe_hw(struct rt2x00_dev *rt2x00dev)
if (rt2x00_rt(rt2x00dev, RT3593))
__set_bit(RT2800_HAS_HIGH_SHARED_MEM, _data->rt2800_flags);
 
+   drv_data->hw_beacon_count = 8;
+
/*
 * Allocate eeprom data.
 */
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.h 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.h
index ccfa8cf1f5ac..ab49e6feeeb9 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.h
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.h
@@ -37,6 +37,7 @@ struct rt2800_drv_data {
u8 max_psdu;
unsigned int tbtt_tick;
unsigned int ampdu_factor_cnt[4];
+   unsigned int hw_beacon_count;
DECLARE_BITMAP(sta_ids, STA_IDS_SIZE);
 
unsigned long rt2800_flags;
-- 
2.11.0



[PATCH 03/40] rt2x00: rt2800: serialize shared memory access

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

The shared memory of the rt2800 devices is accessible
through the register offset range between 0x4000 and
0x8000. The size of this range is 16KB only and on
devices which have more than 16KB of shared memory either
the low or the high part of the memory is accessible at a
time.

Serialize all accesses to the shared memory by a mutex,
in order to avoid concurrent use of that.

Signed-off-by: Gabor Juhos 
[dan...@makrotopia.org: added comments for added mutex/spinlock]
---
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c  | 55 -
 drivers/net/wireless/ralink/rt2x00/rt2800lib.h  | 35 
 drivers/net/wireless/ralink/rt2x00/rt2800mmio.c | 26 
 drivers/net/wireless/ralink/rt2x00/rt2800mmio.h |  4 ++
 drivers/net/wireless/ralink/rt2x00/rt2800pci.c  | 14 +++
 drivers/net/wireless/ralink/rt2x00/rt2800soc.c  |  3 ++
 drivers/net/wireless/ralink/rt2x00/rt2800usb.c  | 31 ++
 7 files changed, 167 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index 5045af1b0dc9..0fd67026f806 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -451,11 +451,13 @@ void rt2800_mcu_request(struct rt2x00_dev *rt2x00dev,
rt2x00_set_field32(, H2M_MAILBOX_CSR_CMD_TOKEN, token);
rt2x00_set_field32(, H2M_MAILBOX_CSR_ARG0, arg0);
rt2x00_set_field32(, H2M_MAILBOX_CSR_ARG1, arg1);
+   rt2800_shared_mem_lock(rt2x00dev);
rt2800_register_write_lock(rt2x00dev, H2M_MAILBOX_CSR, reg);
 
reg = 0;
rt2x00_set_field32(, HOST_CMD_CSR_HOST_COMMAND, command);
rt2800_register_write_lock(rt2x00dev, HOST_CMD_CSR, reg);
+   rt2800_shared_mem_unlock(rt2x00dev);
}
 
mutex_unlock(>csr_mutex);
@@ -674,7 +676,9 @@ int rt2800_load_firmware(struct rt2x00_dev *rt2x00dev,
 * Wait for device to stabilize.
 */
for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
+   rt2800_shared_mem_lock(rt2x00dev);
rt2800_register_read(rt2x00dev, PBF_SYS_CTRL, );
+   rt2800_shared_mem_unlock(rt2x00dev);
if (rt2x00_get_field32(reg, PBF_SYS_CTRL_READY))
break;
msleep(1);
@@ -694,10 +698,16 @@ int rt2800_load_firmware(struct rt2x00_dev *rt2x00dev,
/*
 * Initialize firmware.
 */
+   rt2800_shared_mem_lock(rt2x00dev);
rt2800_register_write(rt2x00dev, H2M_BBP_AGENT, 0);
rt2800_register_write(rt2x00dev, H2M_MAILBOX_CSR, 0);
+   rt2800_shared_mem_unlock(rt2x00dev);
+
if (rt2x00_is_usb(rt2x00dev)) {
+   rt2800_shared_mem_lock(rt2x00dev);
rt2800_register_write(rt2x00dev, H2M_INT_SRC, 0);
+   rt2800_shared_mem_unlock(rt2x00dev);
+
rt2800_mcu_request(rt2x00dev, MCU_BOOT_SIGNAL, 0, 0, 0);
}
msleep(1);
@@ -1035,8 +1045,10 @@ void rt2800_write_beacon(struct queue_entry *entry, 
struct txentry_desc *txdesc)
 
beacon_base = rt2800_hw_beacon_base(rt2x00dev, entry->entry_idx);
 
+   rt2800_shared_mem_lock(rt2x00dev);
rt2800_register_multiwrite(rt2x00dev, beacon_base, entry->skb->data,
   entry->skb->len + padding_len);
+   rt2800_shared_mem_unlock(rt2x00dev);
__set_bit(ENTRY_BCN_ENABLED, >flags);
 
/*
@@ -1066,6 +1078,8 @@ static inline void rt2800_clear_beacon_register(struct 
rt2x00_dev *rt2x00dev,
 
beacon_base = rt2800_hw_beacon_base(rt2x00dev, index);
 
+   rt2800_shared_mem_lock(rt2x00dev);
+
/*
 * For the Beacon base registers we only need to clear
 * the whole TXWI which (when set to 0) will invalidate
@@ -1073,6 +1087,8 @@ static inline void rt2800_clear_beacon_register(struct 
rt2x00_dev *rt2x00dev,
 */
for (i = 0; i < txwi_desc_size; i += sizeof(__le32))
rt2800_register_write(rt2x00dev, beacon_base + i, 0);
+
+   rt2800_shared_mem_unlock(rt2x00dev);
 }
 
 void rt2800_clear_beacon(struct queue_entry *entry)
@@ -1261,7 +1277,9 @@ static void rt2800_delete_wcid_attr(struct rt2x00_dev 
*rt2x00dev, int wcid)
 {
u32 offset;
offset = MAC_WCID_ATTR_ENTRY(wcid);
+   rt2800_shared_mem_lock(rt2x00dev);
rt2800_register_write(rt2x00dev, offset, 0);
+   rt2800_shared_mem_unlock(rt2x00dev);
 }
 
 static void rt2800_config_wcid_attr_bssidx(struct rt2x00_dev *rt2x00dev,
@@ -1274,11 +1292,13 @@ static void rt2800_config_wcid_attr_bssidx(struct 
rt2x00_dev *rt2x00dev,
 * The BSS Idx numbers is split in a main value of 3 bits,
 * and a extended field for adding one additional bit to the value.
 */
+   rt2800_shared_mem_lock(rt2x00dev);

[PATCH 04/40] rt2x00: rt2800lib: fix beacon generation on RT3593

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

On the RT3593 chipset, the beacon registers are located
in the high 8KB part of the shared memory.

The high part of the shared memory is only accessible
if it is explicitly selected. Add a helper function
in order to be able to control the SHR_MSEL bit in
the PBF_SYS_CTRL register. Also add a few more helper
functions and use those to select the correct part of
the shared memory before and after accessing the beacon
registers.

The base addresses of the beacon registers are also
different from the actually used values, so fix the
'rt2800_hw_beacon_base' function to return the correct
values.

Signed-off-by: Gabor Juhos 
---
 drivers/net/wireless/ralink/rt2x00/rt2800.h|  3 ++
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 44 ++
 2 files changed, 47 insertions(+)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800.h 
b/drivers/net/wireless/ralink/rt2x00/rt2800.h
index 2371896c1e99..a81852cfb4f9 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800.h
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h
@@ -574,6 +574,7 @@
 #define PBF_SYS_CTRL   0x0400
 #define PBF_SYS_CTRL_READY FIELD32(0x0080)
 #define PBF_SYS_CTRL_HOST_RAM_WRITEFIELD32(0x0001)
+#define PBF_SYS_CTRL_SHR_MSEL  FIELD32(0x0008)
 
 /*
  * HOST-MCU shared memory
@@ -2026,6 +2027,8 @@ struct mac_iveiv_entry {
  (((__index) < 6) ? (HW_BEACON_BASE4 + ((__index - 4) * 0x0200)) : \
  (HW_BEACON_BASE6 - ((__index - 6) * 0x0200
 
+#define HW_BEACON_BASE_HIGH(__index)   (0x4000 + (__index) * 512)
+
 #define BEACON_BASE_TO_OFFSET(_base)   (((_base) - 0x4000) / 64)
 
 /*
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index 0fd67026f806..dcacfa54b3d6 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -82,6 +82,39 @@ static inline bool rt2800_is_305x_soc(struct rt2x00_dev 
*rt2x00dev)
return false;
 }
 
+static inline void rt2800_shared_mem_select(struct rt2x00_dev *rt2x00dev,
+   bool high)
+{
+   u32 reg;
+
+   if (WARN_ON_ONCE(!rt2800_has_high_shared_mem(rt2x00dev)))
+   return;
+
+   rt2800_register_read(rt2x00dev, PBF_SYS_CTRL, );
+   rt2x00_set_field32(, PBF_SYS_CTRL_SHR_MSEL, high);
+   rt2800_register_write(rt2x00dev, PBF_SYS_CTRL, reg);
+}
+
+static inline bool rt2800_beacon_uses_high_mem(struct rt2x00_dev *rt2x00dev)
+{
+   if (rt2x00_rt(rt2x00dev, RT3593))
+   return true;
+
+   return false;
+}
+
+static inline void rt2800_select_beacon_mem(struct rt2x00_dev *rt2x00dev)
+{
+   if (rt2800_beacon_uses_high_mem(rt2x00dev))
+   rt2800_shared_mem_select(rt2x00dev, true);
+}
+
+static inline void rt2800_deselect_beacon_mem(struct rt2x00_dev *rt2x00dev)
+{
+   if (rt2800_beacon_uses_high_mem(rt2x00dev))
+   rt2800_shared_mem_select(rt2x00dev, false);
+}
+
 static void rt2800_bbp_write(struct rt2x00_dev *rt2x00dev,
 const unsigned int word, const u8 value)
 {
@@ -948,6 +981,9 @@ EXPORT_SYMBOL_GPL(rt2800_txdone_entry);
 static unsigned int rt2800_hw_beacon_base(struct rt2x00_dev *rt2x00dev,
  unsigned int index)
 {
+   if (rt2x00_rt(rt2x00dev, RT3593))
+   return HW_BEACON_BASE_HIGH(index);
+
return HW_BEACON_BASE(index);
 }
 
@@ -1046,8 +1082,12 @@ void rt2800_write_beacon(struct queue_entry *entry, 
struct txentry_desc *txdesc)
beacon_base = rt2800_hw_beacon_base(rt2x00dev, entry->entry_idx);
 
rt2800_shared_mem_lock(rt2x00dev);
+
+   rt2800_select_beacon_mem(rt2x00dev);
rt2800_register_multiwrite(rt2x00dev, beacon_base, entry->skb->data,
   entry->skb->len + padding_len);
+   rt2800_deselect_beacon_mem(rt2x00dev);
+
rt2800_shared_mem_unlock(rt2x00dev);
__set_bit(ENTRY_BCN_ENABLED, >flags);
 
@@ -1080,6 +1120,8 @@ static inline void rt2800_clear_beacon_register(struct 
rt2x00_dev *rt2x00dev,
 
rt2800_shared_mem_lock(rt2x00dev);
 
+   rt2800_select_beacon_mem(rt2x00dev);
+
/*
 * For the Beacon base registers we only need to clear
 * the whole TXWI which (when set to 0) will invalidate
@@ -1088,6 +1130,8 @@ static inline void rt2800_clear_beacon_register(struct 
rt2x00_dev *rt2x00dev,
for (i = 0; i < txwi_desc_size; i += sizeof(__le32))
rt2800_register_write(rt2x00dev, beacon_base + i, 0);
 
+   rt2800_deselect_beacon_mem(rt2x00dev);
+
rt2800_shared_mem_unlock(rt2x00dev);
 }
 
-- 
2.11.0



[PATCH 02/40] rt2x00: rt2800lib: introduce RT2800_HAS_HIGH_SHARED_MEM flag

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

Some chipsets have more than 16KB of shared memory.
Introduce a new rt2800 specific flag to indicate that
and add a helper function which helps to check the
presence of the new flag.

Also enable the new flag for the RT3593 chipset which
has 24KB of shared memory. The flag can also be used
for other chipsets, but none of those has been tested
yet.

Signed-off-by: Gabor Juhos 
Signed-off-by: Daniel Golle 
---
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c |  4 
 drivers/net/wireless/ralink/rt2x00/rt2800lib.h | 13 +
 2 files changed, 17 insertions(+)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index 5436cdb07937..5045af1b0dc9 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -7770,6 +7770,7 @@ static int rt2800_probe_rt(struct rt2x00_dev *rt2x00dev)
 
 int rt2800_probe_hw(struct rt2x00_dev *rt2x00dev)
 {
+   struct rt2800_drv_data *drv_data = rt2x00dev->drv_data;
int retval;
u32 reg;
 
@@ -,6 +7778,9 @@ int rt2800_probe_hw(struct rt2x00_dev *rt2x00dev)
if (retval)
return retval;
 
+   if (rt2x00_rt(rt2x00dev, RT3593))
+   __set_bit(RT2800_HAS_HIGH_SHARED_MEM, _data->rt2800_flags);
+
/*
 * Allocate eeprom data.
 */
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.h 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.h
index 256928f0ea6a..4ee424dfe23f 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.h
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.h
@@ -22,6 +22,10 @@
 
 #include "rt2800.h"
 
+enum rt2800_flag {
+   RT2800_HAS_HIGH_SHARED_MEM,
+};
+
 /* RT2800 driver data structure */
 struct rt2800_drv_data {
u8 calibration_bw20;
@@ -34,6 +38,8 @@ struct rt2800_drv_data {
unsigned int tbtt_tick;
unsigned int ampdu_factor_cnt[4];
DECLARE_BITMAP(sta_ids, STA_IDS_SIZE);
+
+   unsigned long rt2800_flags;
 };
 
 struct rt2800_ops {
@@ -66,6 +72,13 @@ struct rt2800_ops {
__le32 *(*drv_get_txwi)(struct queue_entry *entry);
 };
 
+static inline bool rt2800_has_high_shared_mem(struct rt2x00_dev *rt2x00dev)
+{
+   struct rt2800_drv_data *drv_data = rt2x00dev->drv_data;
+
+   return test_bit(RT2800_HAS_HIGH_SHARED_MEM, _data->rt2800_flags);
+}
+
 static inline void rt2800_register_read(struct rt2x00_dev *rt2x00dev,
const unsigned int offset,
u32 *value)
-- 
2.11.0



[PATCH 01/40] rt2x00: rt2800lib: move rt2800_drv_data declaration into rt2800lib.h

2017-01-13 Thread Daniel Golle
From: Gabor Juhos 

The rt2800_drv_data structure contains driver specific
information. Move the declaration into the rt2800lib.h
header which is a more logical place for it. Also fix
the comment style to avoid checkpatch warning.

The patch contains no functional changes, it is in
preparation for the next patch.

Signed-off-by: Gabor Juhos 
[dan...@makrotopia.org: removed stray newline]
---
 drivers/net/wireless/ralink/rt2x00/rt2800.h| 16 
 drivers/net/wireless/ralink/rt2x00/rt2800lib.h | 16 
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800.h 
b/drivers/net/wireless/ralink/rt2x00/rt2800.h
index ec622a08a486..2371896c1e99 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800.h
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h
@@ -2969,20 +2969,4 @@ enum rt2800_eeprom_word {
 #define WCID_END   222
 #define STA_IDS_SIZE   (WCID_END - WCID_START + 2)
 
-/*
- * RT2800 driver data structure
- */
-struct rt2800_drv_data {
-   u8 calibration_bw20;
-   u8 calibration_bw40;
-   u8 bbp25;
-   u8 bbp26;
-   u8 txmixer_gain_24g;
-   u8 txmixer_gain_5g;
-   u8 max_psdu;
-   unsigned int tbtt_tick;
-   unsigned int ampdu_factor_cnt[4];
-   DECLARE_BITMAP(sta_ids, STA_IDS_SIZE);
-};
-
 #endif /* RT2800_H */
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.h 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.h
index 0a8b4df665fe..256928f0ea6a 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.h
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.h
@@ -20,6 +20,22 @@
 #ifndef RT2800LIB_H
 #define RT2800LIB_H
 
+#include "rt2800.h"
+
+/* RT2800 driver data structure */
+struct rt2800_drv_data {
+   u8 calibration_bw20;
+   u8 calibration_bw40;
+   u8 bbp25;
+   u8 bbp26;
+   u8 txmixer_gain_24g;
+   u8 txmixer_gain_5g;
+   u8 max_psdu;
+   unsigned int tbtt_tick;
+   unsigned int ampdu_factor_cnt[4];
+   DECLARE_BITMAP(sta_ids, STA_IDS_SIZE);
+};
+
 struct rt2800_ops {
void (*register_read)(struct rt2x00_dev *rt2x00dev,
  const unsigned int offset, u32 *value);
-- 
2.11.0



[PATCH 00/40] rt2x00 patches form OpenWrt.org

2017-01-13 Thread Daniel Golle
Some of these are fixes, most importantly Serge Vasilugin fixed setting
the HT20/HT40 filter which got us much closer to the expected
performance when using HT40 modes.

There is also a lot of new hardware support added:
Gabor Juhos wrote code for the Rt3883 WiSoC.
Daniel Golle implemented support for Rt3352 boards with external PA as
well as for boards using a 20MHz crystal instead of the usual 40MHz.
Serge Vasilugin contributed support for the Rt5350 WiSoC.
Michel Stempin, Felix Fietkau and John Crispin have been helping with
cleaning up things and putting away legal doubts.


Claudio Mignanti (1):
  rt2x00: rt2x00pci: set PCI MWI only if supported

Daniel Golle (2):
  rt2x00: support for for RT3352 with external PA
  rt2x00: add support for RT3352 with 20MHz crystal

Felix Fietkau (1):
  rt2x00: fix rf id for RT3352

Gabor Juhos (34):
  rt2x00: rt2800lib: move rt2800_drv_data declaration into rt2800lib.h
  rt2x00: rt2800lib: introduce RT2800_HAS_HIGH_SHARED_MEM flag
  rt2x00: rt2800: serialize shared memory access
  rt2x00: rt2800lib: fix beacon generation on RT3593
  rt2x00: rt2800lib: add hw_beacon_count field to struct rt2800_drv_data
  rt2x00: rt2800lib: init additional beacon offset registers
  rt2x00: rt2800lib: fix max supported beacon count for RT3593
  rt2x00: allow to build rt2800soc module for RT3883
  rt2x00: rt2800lib: enable support for RT3883
  rt2x00: rt2800lib: add rf_vals for RF3853
  rt2x00: rt2800lib: enable VCO calibration for RF3853
  rt2x00: rt2800lib: add channel configuration function for RF3853
  rt2x00: rt2800lib: enable RF3853 support
  rt2x00: rt2800lib: add MAC register initialization for RT3883
  rt2x00: rt2800soc: fix rt2800soc_disable_radio for RT3883
  rt2x00: rt2800lib: add BBP register initialization for RT3883
  rt2x00: rt2800lib: add RFCSR initialization for RT3883
  rt2x00: rt2800lib: use the extended EEPROM map for RT3883
  rt2x00: rt2800lib: force rf type to RF3853 on RT3883
  rt2x00: rt2800lib: add channel configuration code for RT3883
  rt2x00: rt2800lib: fix txpower_to_dev function for RT3883
  rt2x00: rt2800lib: use correct txpower calculation function for RT3883
  rt2x00: rt2800lib: hardcode txmixer gain values to zero for RT3883
  rt2x00: rt2800lib: use correct [RT]XWI size for RT3883
  rt2x00: rt2800lib: use correct beacon base for RT3883
  rt2x00: rt2800lib: use correct beacon count for RT3883
  rt2x00: rt2800lib: fix antenna configuration for RT3883
  rt2x00: rt2800lib: fix LNA gain configuration for RT3883
  rt2x00: rt2800lib: fix VGC setup for RT3883
  rt2x00: rt2800lib: fix EEPROM LNA validation for RT3883
  rt2x00: rt2800lib: fix txpower compensation for RT3883
  rt2x00: rt2800lib: enable RT2800_HAS_HIGH_SHARED_MEM for RT3883
  rt2x00: rt2800lib: use high memory for beacons on RT3883
  rt2x00: rt2800mmio: add a workaround for spurious TX_FIFO_STATUS
interrupts

Michel Stempin (1):
  rt2x00: add support for RT5350 WiSoC

Serge Vasilugin (1):
  rt2x00: correctly set HT20/HT40 filter

 drivers/net/wireless/ralink/rt2x00/Kconfig  |2 +-
 drivers/net/wireless/ralink/rt2x00/rt2800.h |   77 +-
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c  | 1013 ++-
 drivers/net/wireless/ralink/rt2x00/rt2800lib.h  |   65 ++
 drivers/net/wireless/ralink/rt2x00/rt2800mmio.c |   98 ++-
 drivers/net/wireless/ralink/rt2x00/rt2800mmio.h |4 +
 drivers/net/wireless/ralink/rt2x00/rt2800pci.c  |   14 +
 drivers/net/wireless/ralink/rt2x00/rt2800soc.c  |   12 +-
 drivers/net/wireless/ralink/rt2x00/rt2800usb.c  |   31 +
 drivers/net/wireless/ralink/rt2x00/rt2x00.h |   10 +
 drivers/net/wireless/ralink/rt2x00/rt2x00pci.c  |2 +
 11 files changed, 1254 insertions(+), 74 deletions(-)

-- 
2.11.0


ANNOUNCE: Netdev 2.1 in Montreal

2017-01-13 Thread Jamal Hadi Salim


Folks,

We are pleased to announce Netdev 2.1 (year 2, conference 1)
in the beautiful city of Montreal, Canada on the 6th to 8th of April.
The website is now online: http://www.netdevconf.org/2.1/
Netdev 2.1 will be held back to back with netconf2017.1
(http://vger.kernel.org/netconf2017.html)

Netdev 2.1 is a  community-driven conference geared towards Linux
netheads. Linux kernel networking and user space utilization of the
interfaces to the Linux kernel networking subsystem are the central
theme.
If you are using Linux as a boot system for proprietary networking,
then this conference _may not be for you_.

Registration costs
--
Very Cheap.
$CAN 300 if you register before Feb 27. $360 after.
$CAN 150 if you are a student. $180 after Feb 27

Why you should register
---
If you yearn for the old community tech driven conferences where
you mingle with fellow geeks (only these would be Linux networking
geeks) then this would be it. There will be no marketing flashing
light openings or loud bad music. Just a pure feed of Linux
networking. Gurus and magicians of all sorts will be there mingling,
juggling and giving talks.

While there will be heavy Linux kernel influence we expect a lot
of user space presence as well.

Exact Location:
-
Tentative: LE WESTIN MONTRÉAL

Sponsorship


If you can help us organize this event by sponsoring, please drop us a 
line to: spon...@netdevconf.org and we'll send you our sponsorship policy.


Important dates

January 18, 2017 Call for proposals open
January 23, 2017 Registration opens
February 20, 2017 Call for proposals close
February 27, 2017 Early Registration close
March 13, 2017 Conference schedule announced
March 27, 2017 Paper submission
March 31, 2017 Online Registration close
April 3, 2017 Slides submission
April 6-8, 2017 Conference days
May 1, 2017 Slides release
June 1, 2017 Paper release

cheers,
jamal


Re: [RFC] [PULL REQUEST] rt2x00 patches from OpenWrt.org

2017-01-13 Thread Daniel Golle
On Fri, Jan 13, 2017 at 04:59:59PM +0100, Johannes Berg wrote:
> 
> > The advantage of pull requests is that author information can be
> > preserved more easily. Running git format-patch results in most
> > patches
> > having wrong SMTP sender information due to the assumption that the
> > patch author is the same person also submitting the patch.
> > So in practise, this would either require changing the From: (and
> > thus
> > Author) to myself or having most mails eaten by anti-spam measures
> > due
> > to non-matching SPF which prohibits my SMTP to send mail on behalf of
> > the original authors of the patches.
> > 
> 
> This is completely untrue. If the first line of the *body* of the email
> is "From: ..." then this is preserved as the author information by git
> am, and doing so is also the default in git format-patch/send-email
> when the author doesn't match the email configuration.

Thanks for the clarification, I'll then submit the patches via
git format-patch.

Cheers

Daniel


Re: [RFC] [PULL REQUEST] rt2x00 patches from OpenWrt.org

2017-01-13 Thread Johannes Berg

> The advantage of pull requests is that author information can be
> preserved more easily. Running git format-patch results in most
> patches
> having wrong SMTP sender information due to the assumption that the
> patch author is the same person also submitting the patch.
> So in practise, this would either require changing the From: (and
> thus
> Author) to myself or having most mails eaten by anti-spam measures
> due
> to non-matching SPF which prohibits my SMTP to send mail on behalf of
> the original authors of the patches.
> 

This is completely untrue. If the first line of the *body* of the email
is "From: ..." then this is preserved as the author information by git
am, and doing so is also the default in git format-patch/send-email
when the author doesn't match the email configuration.

johannes


Re: [PATCH] rtlwifi: rtl8192ee: New firmware from Realtek

2017-01-13 Thread Larry Finger

On 01/13/2017 09:03 AM, Kyle McMartin wrote:

On Sat, Dec 17, 2016 at 12:50:54PM -0600, Larry Finger wrote:

-Info: Taken from Realtek version 
rtl_92ce_92se_92de_8723ae_88ee_8723be_92ee_linux_mac80211_0017.1224.2013
+Info: Initial version taken from Realtek version
+  rtl_92ce_92se_92de_8723ae_88ee_8723be_92ee_linux_mac80211_0017.1224.2013
+  Updated Jan. 14, 2015 with file added by Realtek to
+  http://github.com/lwfinger/rtlwifi_new.git.
 File: rtlwifi/rtl8192eefw.bin



Uh, did something weird happen here? This patch was applied in 2015. ;-)

cheers, Kyle


Realtek fixed some bugs in the firmware. This is a new version.

Larry




Re: [RFC] [PULL REQUEST] rt2x00 patches from OpenWrt.org

2017-01-13 Thread Daniel Golle
Hi Kalle,

On Fri, Jan 13, 2017 at 12:46:56PM +0200, Kalle Valo wrote:
> Daniel Golle  writes:
> > ...
> > Please review and comment, so we can get those patches merged!
> 
> No pull requests, please. Instead send these as patches, easier to
> review and actually also easier for me to merge.

The advantage of pull requests is that author information can be
preserved more easily. Running git format-patch results in most patches
having wrong SMTP sender information due to the assumption that the
patch author is the same person also submitting the patch.
So in practise, this would either require changing the From: (and thus
Author) to myself or having most mails eaten by anti-spam measures due
to non-matching SPF which prohibits my SMTP to send mail on behalf of
the original authors of the patches.

How do you suggest to handle this situation?


Cheers


Daniel


[PATCH] mwifiex: fix uninitialized variable access in pcie_remove

2017-01-13 Thread Arnd Bergmann
Checking the firmware status from PCIe register only works
if the register is available, otherwise we end up with
random behavior:

drivers/net/wireless/marvell/mwifiex/pcie.c: In function 'mwifiex_pcie_remove':
drivers/net/wireless/marvell/mwifiex/pcie.c:585:5: error: 'fw_status' may be 
used uninitialized in this function [-Werror=maybe-uninitialized]

This makes sure we treat the absence of the register as a failure.

Fixes: 045f0c1b5e26 ("mwifiex: get rid of global user_rmmod flag")
Signed-off-by: Arnd Bergmann 
---
 drivers/net/wireless/marvell/mwifiex/pcie.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c 
b/drivers/net/wireless/marvell/mwifiex/pcie.c
index 031141663fc0..eebc68caecdd 100644
--- a/drivers/net/wireless/marvell/mwifiex/pcie.c
+++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
@@ -581,6 +581,8 @@ static void mwifiex_pcie_remove(struct pci_dev *pdev)
reg = card->pcie.reg;
if (reg)
ret = mwifiex_read_reg(adapter, reg->fw_status, _status);
+   else
+   fw_status = -1;
 
if (fw_status == FIRMWARE_READY_PCIE && !adapter->mfg_mode) {
mwifiex_deauthenticate_all(adapter);
-- 
2.9.0



Re: [PATCH] linux-firmware: mwlwifi: update 88W8864 firmware.

2017-01-13 Thread Kyle McMartin
On Wed, Dec 21, 2016 at 06:53:19AM +, David Lin wrote:
> Release Version: 7.2.9.26.
> 
> Signed-off-by: David Lin 
> ---
>  mwlwifi/88W8864.bin | Bin 116356 -> 118776 bytes
>  1 file changed, 0 insertions(+), 0 deletions(-)
> 

Please include an update for WHENCE.

regards, Kyle


Re: [PATCH] rtlwifi: rtl8192ee: New firmware from Realtek

2017-01-13 Thread Kyle McMartin
On Sat, Dec 17, 2016 at 12:50:54PM -0600, Larry Finger wrote:
> -Info: Taken from Realtek version 
> rtl_92ce_92se_92de_8723ae_88ee_8723be_92ee_linux_mac80211_0017.1224.2013
> +Info: Initial version taken from Realtek version
> +  
> rtl_92ce_92se_92de_8723ae_88ee_8723be_92ee_linux_mac80211_0017.1224.2013
> +  Updated Jan. 14, 2015 with file added by Realtek to
> +  http://github.com/lwfinger/rtlwifi_new.git.
>  File: rtlwifi/rtl8192eefw.bin
>  

Uh, did something weird happen here? This patch was applied in 2015. ;-)

cheers, Kyle


[PATCH] rt2800: remove warning on bcn_num != rt2x00dev->intf_beaconing

2017-01-13 Thread Stanislaw Gruszka
Since rt2800pci update beacon settings asynchronously from
tbtt tasklet, without beacon_skb_mutex protection, number of
currently active beacons entries can be different than
number pointed by rt2x00dev->intf_beaconing. Remove warning
about that inconsistency.

Reported-by: evax...@qq.com
Signed-off-by: Stanislaw Gruszka 
---
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c 
b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index 4fb79e0..1abe38f 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -967,8 +967,6 @@ static void rt2800_update_beacons_setup(struct rt2x00_dev 
*rt2x00dev)
bcn_num++;
}
 
-   WARN_ON_ONCE(bcn_num != rt2x00dev->intf_beaconing);
-
rt2800_register_write(rt2x00dev, BCN_OFFSET0, (u32) reg);
rt2800_register_write(rt2x00dev, BCN_OFFSET1, (u32) (reg >> 32));
 
-- 
1.8.3.1



Re: [PATCH 1/2] brcm: add firmware for the BCM4356 SDIO device

2017-01-13 Thread Kyle McMartin
On Sun, Dec 18, 2016 at 08:16:35PM +, Arend van Spriel wrote:
> This patch adds firmware for the BCM4356 2x2 11ac SDIO device.
> 
> Reviewed-by: Hante Meuleman 
> Reviewed-by: Pieter-Paul Giesberts 
> Reviewed-by: Franky Lin 
> Signed-off-by: Arend van Spriel 
> Change-Id: I73131f77986c9fc0faf58d316640846897725a14
> Reviewed-on: http://hnd-swgit.sj.broadcom.com:8080/8117

Applied both, thanks Arend.

--Kyle


Google Summer of Code 2017 - Project ideas page for the Linux Foundation online

2017-01-13 Thread Till Kamppeter

Hi,

I have set up a page for project ideas for the Linux Foundation's
participation in the Google Summer of Code 2017:

https://wiki.linuxfoundation.org/gsoc/google-summer-code-2017

Please add your ideas to the sub-page of your work group. If you have
problems mail me with your project idea.

From this year on the ideas list is in the Linux Foundation Wiki. AFAIK 
it is enough to have a Linux Foundation web site account to be able to 
edit and there is no requirement of a special group membership.


Please also take into account that the deadline for our application as 
mentoring organization is Feb 9 and after that Google will evaluate the 
applications. So have your ideas (at least most of them, ideas can be 
posted up to the student application deadline) in by then to raise our 
chances to get accepted.


   Till



Re: [RFC] [PULL REQUEST] rt2x00 patches from OpenWrt.org

2017-01-13 Thread Stanislaw Gruszka
Hi

On Fri, Jan 13, 2017 at 04:50:32AM +0100, Daniel Golle wrote:
> Please review and comment, so we can get those patches merged!

As already pointed by Kalle posting patches to mailing list is better
way for review. Posing patches is easy with git-format-patch and
git-send-email. Ideally patch series should not be long, let say no more
than 30 patches - I suggest to split this into two series: second one
for RT3853 support and first one for other patches.

> evaxige (1):
>   rt2x00: fix WARN_ON_ONCE() caused by inbalanced set/clear of beacon 
> enable bit

I think I would prefer to remove:

WARN_ON_ONCE(bcn_num != rt2x00dev->intf_beaconing);

line instead of this patch. Other patches looks ok after quick glance.
I think you can post them as normal PATCH in the topic (not as RFC).

Thanks
Stanislaw


Re: [PATCH 1/6] iwlwifi: mvm: don't restart HW if suspend fails with unified image

2017-01-13 Thread Coelho, Luciano
On Fri, 2017-01-13 at 16:13 +0200, Kalle Valo wrote:
> Luca Coelho  writes:
> 
> > From: Luca Coelho 
> > 
> > For unified images, we shouldn't restart the HW if suspend fails.  The
> > only reason for restarting the HW with non-unified images is to go
> > back to the D0 image.
> > 
> > Fixes: commit 23ae61282b88 ("iwlwifi: mvm: Do not switch to D3 image on 
> > suspend")
> 
> s/commit // :)

Argh, did I do it again? I was specifically trying to remember this, but
I guess it was not enough...

--
Luca.

Re: [PATCH 1/6] iwlwifi: mvm: don't restart HW if suspend fails with unified image

2017-01-13 Thread Kalle Valo
Luca Coelho  writes:

> From: Luca Coelho 
>
> For unified images, we shouldn't restart the HW if suspend fails.  The
> only reason for restarting the HW with non-unified images is to go
> back to the D0 image.
>
> Fixes: commit 23ae61282b88 ("iwlwifi: mvm: Do not switch to D3 image on 
> suspend")

s/commit // :)

-- 
Kalle Valo


Re: [3/5] ath10k: Remove unused wmi_p2p_noa_descriptor 'noa' in wmi-tlv

2017-01-13 Thread Kalle Valo
Kirtika Ruchandani  wrote:
> Commit ca996ec56608 (ath10k: implement wmi-tlv backend)
> introduced ath10k_wmi_tlv_op_gen_vdev_start() where
> 'struct wmi_p2p_noa_descriptor *noa' is defined and set but not used.
> Compiling with W=1 gives the following warning, fix it.
> drivers/net/wireless/ath/ath10k/wmi-tlv.c: In function 
> ‘ath10k_wmi_tlv_op_gen_vdev_start’:
> drivers/net/wireless/ath/ath10k/wmi-tlv.c:1647:33: warning: variable ‘noa’ 
> set but not used [-Wunused-but-set-variable]
> 
> Fixes: ca996ec56608 ("ath10k: implement wmi-tlv backend")
> Cc: Michal Kazior 
> Cc: Kalle Valo 
> Signed-off-by: Kirtika Ruchandani 

No response to Michal's comment by the author

Patch set to Changes Requested.

-- 
https://patchwork.kernel.org/patch/9444937/

Documentation about submitting wireless patches and checking status
from patchwork:

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches



Re: [PATCH v2] mac80211: prevent skb/txq mismatch

2017-01-13 Thread Johannes Berg
On Fri, 2017-01-13 at 13:32 +0100, Michal Kazior wrote:
> Station structure is considered as not uploaded
> (to driver) until drv_sta_state() finishes. This
> call is however done after the structure is
> attached to mac80211 internal lists and hashes.
> This means mac80211 can lookup (and use) station
> structure before it is uploaded to a driver.
> 
[...]

Applied, thanks.

johannes


pull-request: mac80211 2017-01-13

2017-01-13 Thread Johannes Berg
Hi Dave,

Here's another update for the current cycle. Some of those
patches have been sitting in our tree and I haven't been
pulling them out quickly enough - will try to do better...

Please pull and let me know if there's any problem.

Thanks,
johannes



The following changes since commit 03430fa10b99e95e3a15eb7c00978fb1652f3b24:

  Merge branch 'bcm_sf2-fixes' (2017-01-08 22:01:22 -0500)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211.git 
tags/mac80211-for-davem-2017-01-13

for you to fetch changes up to dbef53621116474bb883f76f0ba6b7640bc42332:

  mac80211: prevent skb/txq mismatch (2017-01-13 14:47:21 +0100)


We have a number of fixes, in part because I was late
in actually sending them out - will try to do better in
the future:
 * handle VHT opmode properly when hostapd is controlling
   full station state
 * two fixes for minimum channel width in mac80211
 * don't leave SMPS set to junk in HT capabilities
 * fix headroom when forwarding mesh packets, recently
   broken by another fix that failed to take into account
   frame encryption
 * fix the TID in null-data packets indicating EOSP (end
   of service period) in U-APSD
 * prevent attempting to use (and then failing which
   results in crashes) TXQs on stations that aren't added
   to the driver yet


Beni Lev (1):
  cfg80211: consider VHT opmode on station update

Cedric Izoard (1):
  mac80211: Fix headroom allocation when forwarding mesh pkt

Emmanuel Grumbach (1):
  mac80211: fix the TID on NDPs sent as EOSP carrier

Felix Fietkau (1):
  mac80211: initialize SMPS field in HT capabilities

Johannes Berg (3):
  mac80211: implement multicast forwarding on fast-RX path
  mac80211: calculate min channel width correctly
  mac80211: recalculate min channel width on VHT opmode changes

Michal Kazior (1):
  mac80211: prevent skb/txq mismatch

 include/uapi/linux/nl80211.h |  4 +++-
 net/mac80211/chan.c  |  3 ---
 net/mac80211/iface.c | 21 +
 net/mac80211/main.c  | 13 +
 net/mac80211/rate.c  |  2 ++
 net/mac80211/rx.c| 38 +-
 net/mac80211/sta_info.c  |  4 ++--
 net/mac80211/tx.c| 17 +++--
 net/mac80211/vht.c   |  4 +++-
 net/wireless/nl80211.c   | 15 +++
 10 files changed, 83 insertions(+), 38 deletions(-)


Re: linux-next: build warning after merge of the wireless-drivers-next tree

2017-01-13 Thread Kalle Valo
Stephen Rothwell  writes:

> Hi all,
>
> After merging the wireless-drivers-next tree, today's linux-next build
> (x86_64 allmodconfig) produced this warning:
>
> drivers/net/wireless/marvell/mwifiex/pcie.c: In function 
> 'mwifiex_pcie_remove':
> drivers/net/wireless/marvell/mwifiex/pcie.c:303:5: warning: 'fw_status' may 
> be used uninitialized in this function [-Wmaybe-uninitialized]
>   if (fw_status == FIRMWARE_READY_PCIE && !adapter->mfg_mode) {
>  ^
>
> Introduced by commit
>
>   045f0c1b5e26 ("mwifiex: get rid of global user_rmmod flag")
>
> This is not a false positive since "reg" could be NULL just above
> (otherwise it would be tested for).

Thanks, I noticed this myself yesterday (after I had applied the patch)
and I have asked Marvell to send a fix.

-- 
Kalle Valo


Re: ath10k: Fix Tx legacy rate reporting

2017-01-13 Thread Kalle Valo
Mohammed Shafi Shajakhan  wrote:
> From: Mohammed Shafi Shajakhan 
> 
> Tx legacy rate is reported 10 fold, as below
> 
> iw dev wlan#N station dump | grep "tx bitrate"
> tx bitrate: 240.0 MBit/s
> 
> This is because by mistake we muliply by the hardware reported
> rate twice by 10, fix this.
> 
> Fixes: cec17c382140 ("ath10k: add per peer htt tx stats support for 10.4")
> Signed-off-by: Mohammed Shafi Shajakhan 

Patch applied to ath-next branch of ath.git, thanks.

cd59102779ac ath10k: fix tx legacy rate reporting

-- 
https://patchwork.kernel.org/patch/9508075/

Documentation about submitting wireless patches and checking status
from patchwork:

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches



Re: ath10k: Fix wifi connectivity and warning in Rx with channel 169

2017-01-13 Thread Kalle Valo
Mohammed Shafi Shajakhan  wrote:
> From: Mohammed Shafi Shajakhan 
> 
> In countries where basic operation of channel 169 is allowed,
> this fixes the below WARN_ON_ONCE in Rx and fixes the station
> connectivity failure in channel 169 as the packet is dropped
> in the driver as the current check limits to channel 165. As of
> now all the packets beyond channel 165 is dropped, fix this
> by extending the range to channel 169.
> 
> Call trace:
> 
> drivers/net/wireless/ath/ath10k/wmi.c:1505
> ath10k_wmi_event_mgmt_rx+0x278/0x440 [ath10k_core]()
> Call Trace:
>  [] ? printk+0x2d/0x2f
>  [] warn_slowpath_common+0x72/0xa0
>  [] ? ath10k_wmi_event_mgmt_rx+0x278/0x440
> 
>  [] ? ath10k_wmi_event_mgmt_rx+0x278/0x440
> 
>  [] warn_slowpath_null+0x22/0x30
>  [] ath10k_wmi_event_mgmt_rx+0x278/0x440
> 
>  [] ? ath10k_pci_sleep+0x8b/0xb0 [ath10k_pci]
>  [] ath10k_wmi_10_2_op_rx+0xf3/0x3b0
> 
>  [] ath10k_wmi_process_rx+0x1e/0x60
> 
>  [] ath10k_htc_rx_completion_handler+0x347/0x4d0 [ath10k_core]
>  [] ? ath10k_ce_completed_recv_next+0x53/0x70 [ath10k_pci]
>  [] ath10k_pci_ce_recv_data+0x171/0x1d0 [ath10k_pci]
>  [] ? ath10k_pci_write32+0x39/0x80 [ath10k_pci]
>  [] ath10k_ce_per_engine_service+0x5c/0xa0 [ath10k_pci]
>  [] ath10k_ce_per_engine_service_any+0x5f/0x70 [ath10k_pci]
>  [] ? local_bh_enable_ip+0x90/0x90
>  [] ath10k_pci_tasklet+0x1b/0x50 [ath10k_pci]
> 
> Fixes: 34c30b0a5e97 ("ath10k: enable advertising support for channel 169, 
> 5Ghz")
> Signed-off-by: Mohammed Shafi Shajakhan 

Patch applied to ath-next branch of ath.git, thanks.

c486dc571a37 ath10k: fix wifi connectivity and warning in rx with channel 169

-- 
https://patchwork.kernel.org/patch/9508031/

Documentation about submitting wireless patches and checking status
from patchwork:

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches



Re: ath9k: move RELAY and DEBUG_FS to ATH9K[_HTC]_DEBUGFS

2017-01-13 Thread Kalle Valo
Christian Lamparter  wrote:
> Currently, the common ath9k_common module needs to have a
> dependency on RELAY and DEBUG_FS in order to built. This
> is usually not a problem. But for RAM and FLASH starved
> AR71XX devices, every little bit counts.
> 
> This patch adds a new symbol CONFIG_ATH9K_COMMON_DEBUG
> which makes it possible to drop the RELAY and DEBUG_FS
> dependency there and move it to ATH_(HTC)_DEBUGFS.
> 
> Note: The shared FFT/spectral code (which is the only user
> of the relayfs in ath9k*) needs DEBUG_FS to export the relayfs
> interface to dump the data to userspace. So it makes no sense
> to have the functions compiled in, if DEBUG_FS is not there.
> 
> Signed-off-by: Christian Lamparter 

Patch applied to ath-next branch of ath.git, thanks.

1077ec472df4 ath9k: move RELAY and DEBUG_FS to ATH9K[_HTC]_DEBUGFS

-- 
https://patchwork.kernel.org/patch/9505653/

Documentation about submitting wireless patches and checking status
from patchwork:

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches



Re: [1/2] ath10k: add accounting for the extended peer statistics

2017-01-13 Thread Kalle Valo
Christian Lamparter  wrote:
> The 10.4 firmware adds extended peer information to the
> firmware's statistics payload. This additional info is
> stored as a separate data field and the elements are
> stored in their own "peers_extd" list.
> 
> These elements can pile up in the same way as the peer
> information elements. This is because the
> ath10k_wmi_10_4_op_pull_fw_stats() function tries to
> pull the same amount (num_peer_stats) for every statistic
> data unit.
> 
> Fixes: 4a49ae94a448faa ("ath10k: fix 10.4 extended peer stats update")
> Signed-off-by: Christian Lamparter 

Patch applied to ath-next branch of ath.git, thanks.

c1e3330f22bc ath10k: add accounting for the extended peer statistics

-- 
https://patchwork.kernel.org/patch/9461631/

Documentation about submitting wireless patches and checking status
from patchwork:

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches



Re: [v2,1/2] ath10k: refactor ath10k_peer_assoc_h_phymode()

2017-01-13 Thread Kalle Valo
Kalle Valo  wrote:
> When adding VHT160 support to ath10k_peer_assoc_h_phymode() the VHT mode
> selection code becomes too complex. Simplify it by refactoring the vht part to
> a separate function.
> 
> Signed-off-by: Kalle Valo 

2 patches applied to ath-next branch of ath.git, thanks.

06efdbe70f9c ath10k: refactor ath10k_peer_assoc_h_phymode()
bc1efd739b61 ath10k: add VHT160 support

-- 
https://patchwork.kernel.org/patch/9376371/

Documentation about submitting wireless patches and checking status
from patchwork:

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches



Re: [PATCH] mac80211: fix documentation warnings

2017-01-13 Thread Johannes Berg
On Fri, 2017-01-13 at 13:43 +0100, Markus Heiser wrote:

> does it make live easier when we use in-line member comments:
> 
>  https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html#in-
> line-member-documentation-comments
> 
> and place the entire list in a literalblock? 

Ah yes, I forgot about that. I should convert everything to that, but
that's probably better done separately.

johannes


Re: [RFC 4/5] cfg80211: add request id to cfg80211_sched_scan_results() api

2017-01-13 Thread Arend Van Spriel
On 13-1-2017 13:47, Arend van Spriel wrote:
> Have proper request id filled in the SCHED_SCAN_RESULTS notification
> toward user-space by having the driver provide it through the api.
> 
> Reviewed-by: Hante Meuleman 
> Reviewed-by: Pieter-Paul Giesberts 
> Reviewed-by: Franky Lin 
> Signed-off-by: Arend van Spriel 
> ---
>  drivers/net/wireless/ath/ath6kl/wmi.c  |  2 +-
>  .../broadcom/brcm80211/brcmfmac/cfg80211.c |  2 +-
>  drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c |  2 +-
>  include/net/cfg80211.h |  4 ++-
>  net/mac80211/scan.c|  2 +-
>  net/wireless/core.c|  1 -
>  net/wireless/core.h|  1 -
>  net/wireless/nl80211.c |  2 ++
>  net/wireless/scan.c| 30 
> +++---
>  net/wireless/trace.h   | 17 +---
>  10 files changed, 37 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c 
> b/drivers/net/wireless/ath/ath6kl/wmi.c
> index 84a6d12..04df853 100644
> --- a/drivers/net/wireless/ath/ath6kl/wmi.c
> +++ b/drivers/net/wireless/ath/ath6kl/wmi.c
> @@ -1082,7 +1082,7 @@ void ath6kl_wmi_sscan_timer(unsigned long ptr)
>  {
>   struct ath6kl_vif *vif = (struct ath6kl_vif *) ptr;
>  
> - cfg80211_sched_scan_results(vif->ar->wiphy);
> + cfg80211_sched_scan_results(vif->ar->wiphy, 0);
>  }
>  
>  static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len,
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c 
> b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
> index 8280f19..34d318e 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
> @@ -766,7 +766,7 @@ s32 brcmf_notify_escan_complete(struct 
> brcmf_cfg80211_info *cfg,
>   brcmf_dbg(SCAN, "scheduled scan completed\n");
>   cfg->internal_escan = false;
>   if (!aborted)
> - cfg80211_sched_scan_results(cfg_to_wiphy(cfg));
> + cfg80211_sched_scan_results(cfg_to_wiphy(cfg), 0);
>   } else if (scan_request) {
>   struct cfg80211_scan_info info = {
>   .aborted = aborted,
> diff --git a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c 
> b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
> index 8548027..12b471f 100644
> --- a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
> +++ b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
> @@ -1201,7 +1201,7 @@ int mwifiex_process_sta_cmdresp(struct mwifiex_private 
> *priv, u16 cmdresp_no,
>   break;
>   case HostCmd_CMD_802_11_BG_SCAN_QUERY:
>   ret = mwifiex_ret_802_11_scan(priv, resp);
> - cfg80211_sched_scan_results(priv->wdev.wiphy);
> + cfg80211_sched_scan_results(priv->wdev.wiphy, 0);
>   mwifiex_dbg(adapter, CMD,
>   "info: CMD_RESP: BG_SCAN result is ready!\n");
>   break;
> diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
> index 880a57a..17c78c4 100644
> --- a/include/net/cfg80211.h
> +++ b/include/net/cfg80211.h
> @@ -1677,6 +1677,7 @@ struct cfg80211_sched_scan_request {
>   u8 mac_addr_mask[ETH_ALEN] __aligned(2);
>  
>   /* internal */
> + struct work_struct results_wk;

When this worker is queued I suppose we should avoid the scheduled scan
request to be freed. Probable need cancel_work_sync() in
cfg80211_del_sched_scan_req().

Regards,
Arend


Re: [PATCH] mac80211: fix documentation warnings

2017-01-13 Thread Markus Heiser

Am 13.01.2017 um 11:12 schrieb Johannes Berg :

> From: Johannes Berg 
> 
> For a few restructured text warnings in mac80211, making the
> documentation warning-free (for now). Again, this required
> adding trailing whitespace to keep multiple paragraphs in a
> parameter description together.
> 
> Signed-off-by: Johannes Berg 
> ---
> include/net/mac80211.h | 28 ++--
> 1 file changed, 18 insertions(+), 10 deletions(-)
> 
> diff --git a/include/net/mac80211.h b/include/net/mac80211.h
> index 86967b85dfd0..228c72617916 100644
> --- a/include/net/mac80211.h
> +++ b/include/net/mac80211.h
> @@ -1771,10 +1771,12 @@ struct ieee80211_sta_rates {
> * @max_amsdu_len: indicates the maximal length of an A-MSDU in bytes. This
> * field is always valid for packets with a VHT preamble. For packets
> * with a HT preamble, additional limits apply:
> - *   + If the skb is transmitted as part of a BA agreement, the
> - * A-MSDU maximal size is min(max_amsdu_len, 4065) bytes.
> - *   + If the skb is not part of a BA aggreement, the A-MSDU maximal
> - * size is min(max_amsdu_len, 7935) bytes.
> + *   
> + *   * If the skb is transmitted as part of a BA agreement, the
> + * A-MSDU maximal size is min(max_amsdu_len, 4065) bytes.
> + *   * If the skb is not part of a BA aggreement, the A-MSDU maximal
> + * size is min(max_amsdu_len, 7935) bytes.
> + *   
> * Both additional HT limits must be enforced by the low level driver.
> * This is defined by the spec (IEEE 802.11-2012 section 8.3.2.2 NOTE 2).
> * @support_p2p_ps: indicates whether the STA supports P2P PS mechanism or not.
> @@ -3212,14 +3214,20 @@ enum ieee80211_reconfig_type {
> * nor send aggregates in a way that lost frames would exceed the
> * buffer size. If just limiting the aggregate size, this would be
> * possible with a buf_size of 8:
> - *- TX: 1.7
> - *- RX:  27 (lost frame #1)
> - *- TX:8..1...
> + *   
> + *   - ``TX: 1.7``
> + *   - ``RX:  27`` (lost frame #1)
> + *   - ``TX:8..1...``
> + *   

Hi Johannes!

does it make live easier when we use in-line member comments:

 
https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html#in-line-member-documentation-comments

and place the entire list in a literalblock? 

This is what I (sloppy) tested :


  void (*reset_tsf)(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
   int (*tx_last_beacon)(struct ieee80211_hw *hw);

   /**
* @ampdu_action: Perform a certain A-MPDU action
*
* The RA/TID combination determines the destination and TID we want
* the ampdu action to be performed for. The action is defined through
* ieee80211_ampdu_mlme_action.
* When the action is set to %IEEE80211_AMPDU_TX_OPERATIONAL the driver
* may neither send aggregates containing more subframes than @buf_size
* nor send aggregates in a way that lost frames would exceed the
* buffer size. If just limiting the aggregate size, this would be
* possible with a buf_size of 8::
*
*   - TX: 1.7
*   - RX:  27 (lost frame #1)
*   - TX:8..1...
*
* which is invalid since #1 was now re-transmitted well past the
* buffer size of 8. Correct ways to retransmit #1 would be::
*
*   - TX:   1 or 18 or 81
*
* Even "189" would be wrong since 1 could be lost again.
*
* Returns a negative error code on failure.
* The callback can sleep.
*/

   int (*ampdu_action)(struct ieee80211_hw *hw,
   struct ieee80211_vif *vif,
   struct ieee80211_ampdu_params *params);

just my 2cent.

-- Markus --



[RFC 1/5] nl80211: allow multiple active scheduled scan requests

2017-01-13 Thread Arend van Spriel
This patch implements the idea to have multiple scheduled scan requests
running concurrently. It mainly illustrates how to deal with the incoming
request from user-space in terms of backward compatibility. In order to
use multiple scheduled scans user-space needs to provide a flag attribute
NL80211_ATTR_SCHED_SCAN_MULTI to indicate support. If not the request is
treated as a legacy scan.

Reviewed-by: Hante Meuleman 
Reviewed-by: Pieter-Paul Giesberts 
Reviewed-by: Franky Lin 
Signed-off-by: Arend van Spriel 
---
 include/net/cfg80211.h   |  7 
 include/uapi/linux/nl80211.h | 12 +-
 net/wireless/core.c  | 30 +-
 net/wireless/core.h  | 10 -
 net/wireless/nl80211.c   | 37 +++--
 net/wireless/rdev-ops.h  |  2 +-
 net/wireless/scan.c  | 96 
 net/wireless/trace.h | 18 ++---
 8 files changed, 173 insertions(+), 39 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index cb13789..4c77c82 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1622,6 +1622,7 @@ struct cfg80211_sched_scan_plan {
 /**
  * struct cfg80211_sched_scan_request - scheduled scan request description
  *
+ * @reqid: identifies this request.
  * @ssids: SSIDs to scan for (passed in the probe_reqs in active scans)
  * @n_ssids: number of SSIDs
  * @n_channels: total number of channels to scan
@@ -1650,12 +1651,14 @@ struct cfg80211_sched_scan_plan {
  * @rcu_head: RCU callback used to free the struct
  * @owner_nlportid: netlink portid of owner (if this should is a request
  * owned by a particular socket)
+ * @list: for keeping list of requests.
  * @delay: delay in seconds to use before starting the first scan
  * cycle.  The driver may ignore this parameter and start
  * immediately (or at any other time), if this feature is not
  * supported.
  */
 struct cfg80211_sched_scan_request {
+   u64 reqid;
struct cfg80211_ssid *ssids;
int n_ssids;
u32 n_channels;
@@ -1679,6 +1682,7 @@ struct cfg80211_sched_scan_request {
unsigned long scan_start;
struct rcu_head rcu_head;
u32 owner_nlportid;
+   struct list_head list;
 
/* keep last */
struct ieee80211_channel *channels[0];
@@ -3443,6 +3447,8 @@ struct wiphy_iftype_ext_capab {
  * this variable determines its size
  * @max_scan_ssids: maximum number of SSIDs the device can scan for in
  * any given scan
+ * @max_sched_scan_reqs: maximum number of scheduled scan requests that
+ * the device can run concurrently.
  * @max_sched_scan_ssids: maximum number of SSIDs the device can scan
  * for in any given scheduled scan
  * @max_match_sets: maximum number of match sets the device can handle
@@ -3575,6 +3581,7 @@ struct wiphy {
 
int bss_priv_size;
u8 max_scan_ssids;
+   u8 max_sched_scan_reqs;
u8 max_sched_scan_ssids;
u8 max_match_sets;
u16 max_scan_ie_len;
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 174f4b3..70dc5a6 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -351,7 +351,9 @@
  * are used.  Extra IEs can also be passed from the userspace by
  * using the %NL80211_ATTR_IE attribute.  The first cycle of the
  * scheduled scan can be delayed by %NL80211_ATTR_SCHED_SCAN_DELAY
- * is supplied.
+ * is supplied. If the device supports multiple concurrent scheduled
+ * scans, it will allow such when the caller provides the flag attribute
+ * %NL80211_ATTR_SCHED_SCAN_MULTI to indicate user-space support for it.
  * @NL80211_CMD_STOP_SCHED_SCAN: stop a scheduled scan. Returns -ENOENT if
  * scheduled scan is not running. The caller may assume that as soon
  * as the call returns, it is safe to start a new scheduled scan again.
@@ -1982,6 +1984,11 @@ enum nl80211_commands {
  * @NL80211_ATTR_BSSID: The BSSID of the AP. Note that %NL80211_ATTR_MAC is 
also
  * used in various commands/events for specifying the BSSID.
  *
+ * @NL80211_ATTR_SCHED_SCAN_MULTI: flag attribute which user-space shall use to
+ * indicate that it supports multiple active scheduled scan requests.
+ * @NL80211_ATTR_SCHED_SCAN_MAX_REQS: indicates maximum number of scheduled
+ * scan request that may be active for the device (u8).
+ *
  * @NUM_NL80211_ATTR: total number of nl80211_attrs available
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -2388,6 +2395,9 @@ enum nl80211_attrs {
 
NL80211_ATTR_BSSID,
 
+   NL80211_ATTR_SCHED_SCAN_MULTI,
+   NL80211_ATTR_SCHED_SCAN_MAX_REQS,
+
/* add attributes here, update the policy in nl80211.c */
 
__NL80211_ATTR_AFTER_LAST,
diff --git a/net/wireless/core.c 

[RFC 4/5] cfg80211: add request id to cfg80211_sched_scan_results() api

2017-01-13 Thread Arend van Spriel
Have proper request id filled in the SCHED_SCAN_RESULTS notification
toward user-space by having the driver provide it through the api.

Reviewed-by: Hante Meuleman 
Reviewed-by: Pieter-Paul Giesberts 
Reviewed-by: Franky Lin 
Signed-off-by: Arend van Spriel 
---
 drivers/net/wireless/ath/ath6kl/wmi.c  |  2 +-
 .../broadcom/brcm80211/brcmfmac/cfg80211.c |  2 +-
 drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c |  2 +-
 include/net/cfg80211.h |  4 ++-
 net/mac80211/scan.c|  2 +-
 net/wireless/core.c|  1 -
 net/wireless/core.h|  1 -
 net/wireless/nl80211.c |  2 ++
 net/wireless/scan.c| 30 +++---
 net/wireless/trace.h   | 17 +---
 10 files changed, 37 insertions(+), 26 deletions(-)

diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c 
b/drivers/net/wireless/ath/ath6kl/wmi.c
index 84a6d12..04df853 100644
--- a/drivers/net/wireless/ath/ath6kl/wmi.c
+++ b/drivers/net/wireless/ath/ath6kl/wmi.c
@@ -1082,7 +1082,7 @@ void ath6kl_wmi_sscan_timer(unsigned long ptr)
 {
struct ath6kl_vif *vif = (struct ath6kl_vif *) ptr;
 
-   cfg80211_sched_scan_results(vif->ar->wiphy);
+   cfg80211_sched_scan_results(vif->ar->wiphy, 0);
 }
 
 static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len,
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index 8280f19..34d318e 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -766,7 +766,7 @@ s32 brcmf_notify_escan_complete(struct brcmf_cfg80211_info 
*cfg,
brcmf_dbg(SCAN, "scheduled scan completed\n");
cfg->internal_escan = false;
if (!aborted)
-   cfg80211_sched_scan_results(cfg_to_wiphy(cfg));
+   cfg80211_sched_scan_results(cfg_to_wiphy(cfg), 0);
} else if (scan_request) {
struct cfg80211_scan_info info = {
.aborted = aborted,
diff --git a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c 
b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
index 8548027..12b471f 100644
--- a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
+++ b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
@@ -1201,7 +1201,7 @@ int mwifiex_process_sta_cmdresp(struct mwifiex_private 
*priv, u16 cmdresp_no,
break;
case HostCmd_CMD_802_11_BG_SCAN_QUERY:
ret = mwifiex_ret_802_11_scan(priv, resp);
-   cfg80211_sched_scan_results(priv->wdev.wiphy);
+   cfg80211_sched_scan_results(priv->wdev.wiphy, 0);
mwifiex_dbg(adapter, CMD,
"info: CMD_RESP: BG_SCAN result is ready!\n");
break;
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 880a57a..17c78c4 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1677,6 +1677,7 @@ struct cfg80211_sched_scan_request {
u8 mac_addr_mask[ETH_ALEN] __aligned(2);
 
/* internal */
+   struct work_struct results_wk;
struct wiphy *wiphy;
struct net_device *dev;
unsigned long scan_start;
@@ -4441,8 +4442,9 @@ void cfg80211_scan_done(struct cfg80211_scan_request 
*request,
  * cfg80211_sched_scan_results - notify that new scan results are available
  *
  * @wiphy: the wiphy which got scheduled scan results
+ * @reqid: identifier for the related scheduled scan request
  */
-void cfg80211_sched_scan_results(struct wiphy *wiphy);
+void cfg80211_sched_scan_results(struct wiphy *wiphy, u64 reqid);
 
 /**
  * cfg80211_sched_scan_stopped - notify that the scheduled scan has stopped
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index faab3c4..3fd8757 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -1219,7 +1219,7 @@ void ieee80211_sched_scan_results(struct ieee80211_hw *hw)
 
trace_api_sched_scan_results(local);
 
-   cfg80211_sched_scan_results(hw->wiphy);
+   cfg80211_sched_scan_results(hw->wiphy, 0);
 }
 EXPORT_SYMBOL(ieee80211_sched_scan_results);
 
diff --git a/net/wireless/core.c b/net/wireless/core.c
index 1f91e85..3ac0f91 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -442,7 +442,6 @@ struct wiphy *wiphy_new_nm(const struct cfg80211_ops *ops, 
int sizeof_priv,
INIT_LIST_HEAD(>bss_list);
INIT_LIST_HEAD(>sched_scan_req_list);
INIT_WORK(>scan_done_wk, __cfg80211_scan_done);
-   INIT_WORK(>sched_scan_results_wk, __cfg80211_sched_scan_results);
INIT_LIST_HEAD(>mlme_unreg);

[RFC 3/5] cfg80211: add request id parameter to .sched_scan_stop() signature

2017-01-13 Thread Arend van Spriel
For multiple scheduled scan support the driver needs to know which
scheduled scan request is being stopped. Pass the request id in the
.sched_scan_stop() callback.

Reviewed-by: Hante Meuleman 
Reviewed-by: Pieter-Paul Giesberts 
Reviewed-by: Franky Lin 
Signed-off-by: Arend van Spriel 
---
 drivers/net/wireless/ath/ath6kl/cfg80211.c|  2 +-
 .../net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c   |  6 +++---
 drivers/net/wireless/marvell/mwifiex/cfg80211.c   |  2 +-
 include/net/cfg80211.h| 15 ---
 net/mac80211/cfg.c|  3 ++-
 net/wireless/rdev-ops.h   |  6 +++---
 net/wireless/scan.c   |  2 +-
 net/wireless/trace.h  | 10 +-
 8 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c 
b/drivers/net/wireless/ath/ath6kl/cfg80211.c
index b7fe0af..1509286 100644
--- a/drivers/net/wireless/ath/ath6kl/cfg80211.c
+++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c
@@ -3354,7 +3354,7 @@ static int ath6kl_cfg80211_sscan_start(struct wiphy 
*wiphy,
 }
 
 static int ath6kl_cfg80211_sscan_stop(struct wiphy *wiphy,
- struct net_device *dev)
+ struct net_device *dev, u64 reqid)
 {
struct ath6kl_vif *vif = netdev_priv(dev);
bool stopped;
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index ccae3bb..8280f19 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -3392,7 +3392,7 @@ static int brcmf_start_internal_escan(struct brcmf_if 
*ifp,
 }
 
 static int brcmf_cfg80211_sched_scan_stop(struct wiphy *wiphy,
- struct net_device *ndev)
+ struct net_device *ndev, u64 reqid)
 {
struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
struct brcmf_if *ifp = netdev_priv(ndev);
@@ -3595,7 +3595,7 @@ static s32 brcmf_cfg80211_resume(struct wiphy *wiphy)
  cfg->wowl.pre_pmmode);
cfg->wowl.active = false;
if (cfg->wowl.nd_enabled) {
-   brcmf_cfg80211_sched_scan_stop(cfg->wiphy, ifp->ndev);
+   brcmf_cfg80211_sched_scan_stop(cfg->wiphy, ifp->ndev, 
0);
brcmf_fweh_unregister(cfg->pub, BRCMF_E_PFN_NET_FOUND);
brcmf_fweh_register(cfg->pub, BRCMF_E_PFN_NET_FOUND,
brcmf_notify_sched_scan_results);
@@ -3679,7 +3679,7 @@ static s32 brcmf_cfg80211_suspend(struct wiphy *wiphy,
 
/* Stop scheduled scan */
if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_PNO))
-   brcmf_cfg80211_sched_scan_stop(wiphy, ndev);
+   brcmf_cfg80211_sched_scan_stop(wiphy, ndev, 0);
 
/* end any scanning */
if (test_bit(BRCMF_SCAN_STATUS_BUSY, >scan_status))
diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c 
b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
index 1e3bd43..243349476 100644
--- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
@@ -2701,7 +2701,7 @@ static int mwifiex_set_ibss_params(struct mwifiex_private 
*priv,
  * previous bgscan configuration in the firmware
  */
 static int mwifiex_cfg80211_sched_scan_stop(struct wiphy *wiphy,
-   struct net_device *dev)
+   struct net_device *dev, u64 reqid)
 {
struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
 
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 4c77c82..880a57a 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -2695,12 +2695,12 @@ struct cfg80211_nan_func {
  * @set_cqm_txe_config: Configure connection quality monitor TX error
  * thresholds.
  * @sched_scan_start: Tell the driver to start a scheduled scan.
- * @sched_scan_stop: Tell the driver to stop an ongoing scheduled scan. This
- * call must stop the scheduled scan and be ready for starting a new one
- * before it returns, i.e. @sched_scan_start may be called immediately
- * after that again and should not fail in that case. The driver should
- * not call cfg80211_sched_scan_stopped() for a requested stop (when this
- * method returns 0.)
+ * @sched_scan_stop: Tell the driver to stop an ongoing scheduled scan with
+ * given request id. This call must stop the scheduled scan and be ready
+ * for starting a new one before it returns, 

[RFC 0/5] cfg80211: support multiple scheduled scans

2017-01-13 Thread Arend van Spriel
After sending out the initial RFC for multiple scheduled scan support [1]
here a series that deal with it all (I hope) so including events and the
driver function call apis.

It is applies to the master branch of the mac80211-next repository.

Arend van Spriel (5):
  nl80211: allow multiple active scheduled scan requests
  nl80211: include request id in scheduled scan event messages
  cfg80211: add request id parameter to .sched_scan_stop() signature
  cfg80211: add request id to cfg80211_sched_scan_results() api
  cfg80211: add request id in cfg80211_sched_scan_stopped{,_rtnl}() api

 drivers/net/wireless/ath/ath6kl/cfg80211.c |   4 +-
 drivers/net/wireless/ath/ath6kl/wmi.c  |   2 +-
 .../broadcom/brcm80211/brcmfmac/cfg80211.c |  10 +-
 drivers/net/wireless/marvell/mwifiex/cfg80211.c|   8 +-
 drivers/net/wireless/marvell/mwifiex/main.c|   2 +-
 drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c |   2 +-
 drivers/net/wireless/marvell/mwifiex/sta_event.c   |   2 +-
 drivers/net/wireless/marvell/mwifiex/sta_ioctl.c   |   2 +-
 include/net/cfg80211.h |  32 +++--
 include/uapi/linux/nl80211.h   |  12 +-
 net/mac80211/cfg.c |   3 +-
 net/mac80211/pm.c  |   2 +-
 net/mac80211/scan.c|   4 +-
 net/mac80211/util.c|   2 +-
 net/wireless/core.c|  31 +++--
 net/wireless/core.h|  11 +-
 net/wireless/nl80211.c |  62 +++---
 net/wireless/nl80211.h |   3 +-
 net/wireless/rdev-ops.h|   8 +-
 net/wireless/scan.c| 135 +++--
 net/wireless/trace.h   |  54 ++---
 21 files changed, 271 insertions(+), 120 deletions(-)

--
1.9.1



  1   2   >