Re: [PATCH v3] PCI: Add PCI_DEVICE_DATA() macro to fully describe device ID entry

2018-07-27 Thread Bjorn Helgaas
On Fri, Jul 27, 2018 at 11:49:44PM +0300, Andy Shevchenko wrote:
> There are a lot of examples in the kernel where PCI_VDEVICE() is used and 
> still
> looks not so convenient due to additional driver_data field attached.
> 
> Introduce PCI_DEVICE_DATA() macro to fully describe device ID entry in 
> shortest
> possible form. For example,
> 
>   before:
> 
> { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MRFLD),
>   (kernel_ulong_t) _pci_mrfld_properties, },
> 
>   after:
> 
> { PCI_DEVICE_DATA(INTEL, INTEL_MRFLD, _pci_mrfld_properties) },

Most device IDs include the vendor ID; did you consider pasting the
vendor ID string into the device ID, so you would end up with this?

{ PCI_DEVICE_DATA(INTEL, MRFLD, _pci_mrfld_properties) },

I don't absolutely love either PCI_VDEVICE or PCI_DEVICE_DATA because
grep doesn't work as well to find uses of the symbol, but the existing
2300 uses of PCI_VDEVICE are telling me pretty loudly to just get over
it :)

Bjorn


Re: [PATCH PATCH net-next 15/18] sunrpc: whitespace fixes

2018-07-27 Thread Anna Schumaker
On 07/24/2018 03:29 PM, Stephen Hemminger wrote:
> Remove trailing whitespace and blank line at EOF

Looks good to me, I've applied it to my tree.

Thanks!
Anna

> 
> Signed-off-by: Stephen Hemminger 
> ---
>  net/sunrpc/auth_gss/auth_gss.c  | 2 +-
>  net/sunrpc/auth_gss/gss_generic_token.c | 1 -
>  net/sunrpc/auth_gss/gss_krb5_crypto.c   | 1 -
>  net/sunrpc/auth_gss/gss_krb5_keys.c | 1 -
>  net/sunrpc/auth_gss/gss_krb5_seal.c | 1 -
>  net/sunrpc/auth_gss/gss_krb5_unseal.c   | 1 -
>  net/sunrpc/auth_gss/gss_krb5_wrap.c | 1 -
>  net/sunrpc/auth_gss/svcauth_gss.c   | 2 +-
>  net/sunrpc/backchannel_rqst.c   | 1 -
>  net/sunrpc/clnt.c   | 2 +-
>  net/sunrpc/rpcb_clnt.c  | 2 +-
>  net/sunrpc/stats.c  | 1 -
>  net/sunrpc/sunrpc.h | 1 -
>  net/sunrpc/xprt.c   | 2 +-
>  net/sunrpc/xprtsock.c   | 1 -
>  15 files changed, 5 insertions(+), 15 deletions(-)
> 
> diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
> index be8f103d22fd..b67ad98a36a6 100644
> --- a/net/sunrpc/auth_gss/auth_gss.c
> +++ b/net/sunrpc/auth_gss/auth_gss.c
> @@ -1571,7 +1571,7 @@ static int gss_cred_is_negative_entry(struct rpc_cred 
> *cred)
>   if (test_bit(RPCAUTH_CRED_NEGATIVE, >cr_flags)) {
>   unsigned long now = jiffies;
>   unsigned long begin, expire;
> - struct gss_cred *gss_cred; 
> + struct gss_cred *gss_cred;
>  
>   gss_cred = container_of(cred, struct gss_cred, gc_base);
>   begin = gss_cred->gc_upcall_timestamp;
> diff --git a/net/sunrpc/auth_gss/gss_generic_token.c 
> b/net/sunrpc/auth_gss/gss_generic_token.c
> index 254defe446a7..fe97f3106536 100644
> --- a/net/sunrpc/auth_gss/gss_generic_token.c
> +++ b/net/sunrpc/auth_gss/gss_generic_token.c
> @@ -231,4 +231,3 @@ g_verify_token_header(struct xdr_netobj *mech, int 
> *body_size,
>  }
>  
>  EXPORT_SYMBOL_GPL(g_verify_token_header);
> -
> diff --git a/net/sunrpc/auth_gss/gss_krb5_crypto.c 
> b/net/sunrpc/auth_gss/gss_krb5_crypto.c
> index 8654494b4d0a..a1acee106faa 100644
> --- a/net/sunrpc/auth_gss/gss_krb5_crypto.c
> +++ b/net/sunrpc/auth_gss/gss_krb5_crypto.c
> @@ -1077,4 +1077,3 @@ krb5_rc4_setup_enc_key(struct krb5_ctx *kctx, struct 
> crypto_skcipher *cipher,
>   dprintk("%s: returning %d\n", __func__, err);
>   return err;
>  }
> -
> diff --git a/net/sunrpc/auth_gss/gss_krb5_keys.c 
> b/net/sunrpc/auth_gss/gss_krb5_keys.c
> index 870133146026..f7fe2d2b851f 100644
> --- a/net/sunrpc/auth_gss/gss_krb5_keys.c
> +++ b/net/sunrpc/auth_gss/gss_krb5_keys.c
> @@ -324,4 +324,3 @@ u32 gss_krb5_aes_make_key(const struct gss_krb5_enctype 
> *gk5e,
>  err_out:
>   return ret;
>  }
> -
> diff --git a/net/sunrpc/auth_gss/gss_krb5_seal.c 
> b/net/sunrpc/auth_gss/gss_krb5_seal.c
> index 94a2b3f082a8..eaad9bc7a0bd 100644
> --- a/net/sunrpc/auth_gss/gss_krb5_seal.c
> +++ b/net/sunrpc/auth_gss/gss_krb5_seal.c
> @@ -229,4 +229,3 @@ gss_get_mic_kerberos(struct gss_ctx *gss_ctx, struct 
> xdr_buf *text,
>   return gss_get_mic_v2(ctx, text, token);
>   }
>  }
> -
> diff --git a/net/sunrpc/auth_gss/gss_krb5_unseal.c 
> b/net/sunrpc/auth_gss/gss_krb5_unseal.c
> index b601a73cc9db..ef2b25b86d2f 100644
> --- a/net/sunrpc/auth_gss/gss_krb5_unseal.c
> +++ b/net/sunrpc/auth_gss/gss_krb5_unseal.c
> @@ -225,4 +225,3 @@ gss_verify_mic_kerberos(struct gss_ctx *gss_ctx,
>   return gss_verify_mic_v2(ctx, message_buffer, read_token);
>   }
>  }
> -
> diff --git a/net/sunrpc/auth_gss/gss_krb5_wrap.c 
> b/net/sunrpc/auth_gss/gss_krb5_wrap.c
> index a737c2da0837..286fd22404f2 100644
> --- a/net/sunrpc/auth_gss/gss_krb5_wrap.c
> +++ b/net/sunrpc/auth_gss/gss_krb5_wrap.c
> @@ -623,4 +623,3 @@ gss_unwrap_kerberos(struct gss_ctx *gctx, int offset, 
> struct xdr_buf *buf)
>   return gss_unwrap_kerberos_v2(kctx, offset, buf);
>   }
>  }
> -
> diff --git a/net/sunrpc/auth_gss/svcauth_gss.c 
> b/net/sunrpc/auth_gss/svcauth_gss.c
> index 5089dbb96d58..860f2a1bbb67 100644
> --- a/net/sunrpc/auth_gss/svcauth_gss.c
> +++ b/net/sunrpc/auth_gss/svcauth_gss.c
> @@ -1389,7 +1389,7 @@ static void destroy_use_gss_proxy_proc_entry(struct net 
> *net)
>   struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
>  
>   if (sn->use_gssp_proc) {
> - remove_proc_entry("use-gss-proxy", sn->proc_net_rpc); 
> + remove_proc_entry("use-gss-proxy", sn->proc_net_rpc);
>   clear_gssp_clnt(sn);
>   }
>  }
> diff --git a/net/sunrpc/backchannel_rqst.c b/net/sunrpc/backchannel_rqst.c
> index c2c68a15b59d..3c15a99b9700 100644
> --- a/net/sunrpc/backchannel_rqst.c
> +++ b/net/sunrpc/backchannel_rqst.c
> @@ -362,4 +362,3 @@ void xprt_complete_bc_request(struct rpc_rqst *req, 
> uint32_t copied)
>   wake_up(_serv->sv_cb_waitq);
>   spin_unlock(_serv->sv_cb_lock);
>  }
> -
> diff --git 

[PATCH v3] PCI: Add PCI_DEVICE_DATA() macro to fully describe device ID entry

2018-07-27 Thread Andy Shevchenko
There are a lot of examples in the kernel where PCI_VDEVICE() is used and still
looks not so convenient due to additional driver_data field attached.

Introduce PCI_DEVICE_DATA() macro to fully describe device ID entry in shortest
possible form. For example,

  before:

{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MRFLD),
  (kernel_ulong_t) _pci_mrfld_properties, },

  after:

{ PCI_DEVICE_DATA(INTEL, INTEL_MRFLD, _pci_mrfld_properties) },

Drivers can be converted later on in independent way.

While here, remove the unused macro with the same name
from Ralink wireless driver.

Signed-off-by: Andy Shevchenko 
---

- fix commit message (Randy)

 drivers/net/wireless/ralink/rt2x00/rt2x00pci.h |  6 --
 include/linux/pci.h| 15 +++
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h 
b/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h
index bc0ca5f58f38..283e2e607bba 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h
@@ -27,12 +27,6 @@
 #include 
 #include 
 
-/*
- * This variable should be used with the
- * pci_driver structure initialization.
- */
-#define PCI_DEVICE_DATA(__ops) .driver_data = (kernel_ulong_t)(__ops)
-
 /*
  * PCI driver handlers.
  */
diff --git a/include/linux/pci.h b/include/linux/pci.h
index d0961aefdbae..754da6f9adb3 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -825,6 +825,21 @@ struct pci_driver {
.vendor = PCI_VENDOR_ID_##vend, .device = (dev), \
.subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 0, 0
 
+/**
+ * PCI_DEVICE_DATA - macro used to describe a specific PCI device in very 
short form
+ * @vend: the vendor name (without PCI_VENDOR_ID_ prefix)
+ * @dev: the device name (without PCI_DEVICE_ID_ prefix)
+ * @data: the driver data to be filled
+ *
+ * This macro is used to create a struct pci_device_id that matches a
+ * specific PCI device.  The subvendor, and subdevice fields will be set
+ * to PCI_ANY_ID.
+ */
+#define PCI_DEVICE_DATA(vend, dev, data) \
+   .vendor = PCI_VENDOR_ID_##vend, .device = PCI_DEVICE_ID_##dev, \
+   .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 0, 0, \
+   .driver_data = (kernel_ulong_t)(data)
+
 enum {
PCI_REASSIGN_ALL_RSRC   = 0x0001,   /* Ignore firmware setup */
PCI_REASSIGN_ALL_BUS= 0x0002,   /* Reassign all bus numbers */
-- 
2.18.0



Re: [PATCH v2] PCI: Add PCI_DEVICE_DATA() macro to fully describe device ID entry

2018-07-27 Thread Randy Dunlap
On 07/27/2018 01:43 PM, Andy Shevchenko wrote:
> There are a lot of examples in the kernel where PCI_VDEVICE() is used and 
> still
> looks not so convenient due to additional driver_data field attached.
> 
> Introduce PCI_DEVICE_DATA() macro to fully describe device ID entry in 
> shortest
> possible form. For example,
> 
>   before:
> 
> { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MRFLD),
>   (kernel_ulong_t) _pci_mrfld_properties, },
> 
>   after:
> 
> { PCI_VDEVICE(INTEL, INTEL_MRFLD, _pci_mrfld_properties },

  { PCI_DEVICE_DATA(   ies) },

I guess.  or what?

> 
> Drivers can be converted later on in independent way.
> 
> While here, remove the unused macro with the same name
> from Ralink wireless driver.
> 
> Signed-off-by: Andy Shevchenko 
> ---
>  drivers/net/wireless/ralink/rt2x00/rt2x00pci.h |  6 --
>  include/linux/pci.h| 15 +++
>  2 files changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h 
> b/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h
> index bc0ca5f58f38..283e2e607bba 100644
> --- a/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h
> +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h
> @@ -27,12 +27,6 @@
>  #include 
>  #include 
>  
> -/*
> - * This variable should be used with the
> - * pci_driver structure initialization.
> - */
> -#define PCI_DEVICE_DATA(__ops)   .driver_data = (kernel_ulong_t)(__ops)
> -
>  /*
>   * PCI driver handlers.
>   */
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index d0961aefdbae..754da6f9adb3 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -825,6 +825,21 @@ struct pci_driver {
>   .vendor = PCI_VENDOR_ID_##vend, .device = (dev), \
>   .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 0, 0
>  
> +/**
> + * PCI_DEVICE_DATA - macro used to describe a specific PCI device in very 
> short form
> + * @vend: the vendor name (without PCI_VENDOR_ID_ prefix)
> + * @dev: the device name (without PCI_DEVICE_ID_ prefix)
> + * @data: the driver data to be filled
> + *
> + * This macro is used to create a struct pci_device_id that matches a
> + * specific PCI device.  The subvendor, and subdevice fields will be set
> + * to PCI_ANY_ID.
> + */
> +#define PCI_DEVICE_DATA(vend, dev, data) \
> + .vendor = PCI_VENDOR_ID_##vend, .device = PCI_DEVICE_ID_##dev, \
> + .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 0, 0, \
> + .driver_data = (kernel_ulong_t)(data)
> +
>  enum {
>   PCI_REASSIGN_ALL_RSRC   = 0x0001,   /* Ignore firmware setup */
>   PCI_REASSIGN_ALL_BUS= 0x0002,   /* Reassign all bus numbers */
> 


-- 
~Randy


Re: [PATCH v1] PCI: Add PCI_DEVICE_DATA() macro to fully describe device ID entry

2018-07-27 Thread Andy Shevchenko
On Fri, 2018-07-27 at 13:42 -0700, Randy Dunlap wrote:
> On 07/27/2018 01:41 PM, Andy Shevchenko wrote:
> > On Fri, 2018-07-27 at 23:39 +0300, Andy Shevchenko wrote:
> > > There are a lot of examples in the kernel where PCI_VDEVICE() is
> > > used
> > > and still
> > > looks not so convenient due to additional driver_data field
> > > attached.
> > > 
> > > Introduce PCI_DEVICE_DATA() macro to fully describe device ID
> > > entry in
> > > shortest
> > > possible form. For example,
> > > 
> > >   before:
> > > 
> > > { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MRFLD),
> > >   (kernel_ulong_t) _pci_mrfld_properties, },
> > > 
> > >   after:
> > > 
> > > { PCI_VDEVICE(INTEL, INTEL_MRFLD, _pci_mrfld_properties
> > > },
> > > 
> > > Drivers can be converted later on in independent way.
> > > 
> > > While here, remove the unused macro with the same name
> > > from Ralink wireless driver.
> > 
> > Skip this, it missed one comma.
> 
> s/comma/right paren/ ??

comma in the code and you are right about commit message. Btw, it missed
rename as well there.

Thanks for spotting this!

-- 
Andy Shevchenko 
Intel Finland Oy


[PATCH v2] PCI: Add PCI_DEVICE_DATA() macro to fully describe device ID entry

2018-07-27 Thread Andy Shevchenko
There are a lot of examples in the kernel where PCI_VDEVICE() is used and still
looks not so convenient due to additional driver_data field attached.

Introduce PCI_DEVICE_DATA() macro to fully describe device ID entry in shortest
possible form. For example,

  before:

{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MRFLD),
  (kernel_ulong_t) _pci_mrfld_properties, },

  after:

{ PCI_VDEVICE(INTEL, INTEL_MRFLD, _pci_mrfld_properties },

Drivers can be converted later on in independent way.

While here, remove the unused macro with the same name
from Ralink wireless driver.

Signed-off-by: Andy Shevchenko 
---
 drivers/net/wireless/ralink/rt2x00/rt2x00pci.h |  6 --
 include/linux/pci.h| 15 +++
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h 
b/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h
index bc0ca5f58f38..283e2e607bba 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h
@@ -27,12 +27,6 @@
 #include 
 #include 
 
-/*
- * This variable should be used with the
- * pci_driver structure initialization.
- */
-#define PCI_DEVICE_DATA(__ops) .driver_data = (kernel_ulong_t)(__ops)
-
 /*
  * PCI driver handlers.
  */
diff --git a/include/linux/pci.h b/include/linux/pci.h
index d0961aefdbae..754da6f9adb3 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -825,6 +825,21 @@ struct pci_driver {
.vendor = PCI_VENDOR_ID_##vend, .device = (dev), \
.subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 0, 0
 
+/**
+ * PCI_DEVICE_DATA - macro used to describe a specific PCI device in very 
short form
+ * @vend: the vendor name (without PCI_VENDOR_ID_ prefix)
+ * @dev: the device name (without PCI_DEVICE_ID_ prefix)
+ * @data: the driver data to be filled
+ *
+ * This macro is used to create a struct pci_device_id that matches a
+ * specific PCI device.  The subvendor, and subdevice fields will be set
+ * to PCI_ANY_ID.
+ */
+#define PCI_DEVICE_DATA(vend, dev, data) \
+   .vendor = PCI_VENDOR_ID_##vend, .device = PCI_DEVICE_ID_##dev, \
+   .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 0, 0, \
+   .driver_data = (kernel_ulong_t)(data)
+
 enum {
PCI_REASSIGN_ALL_RSRC   = 0x0001,   /* Ignore firmware setup */
PCI_REASSIGN_ALL_BUS= 0x0002,   /* Reassign all bus numbers */
-- 
2.18.0



Re: [PATCH v1] PCI: Add PCI_DEVICE_DATA() macro to fully describe device ID entry

2018-07-27 Thread Randy Dunlap
On 07/27/2018 01:41 PM, Andy Shevchenko wrote:
> On Fri, 2018-07-27 at 23:39 +0300, Andy Shevchenko wrote:
>> There are a lot of examples in the kernel where PCI_VDEVICE() is used
>> and still
>> looks not so convenient due to additional driver_data field attached.
>>
>> Introduce PCI_DEVICE_DATA() macro to fully describe device ID entry in
>> shortest
>> possible form. For example,
>>
>>   before:
>>
>> { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MRFLD),
>>   (kernel_ulong_t) _pci_mrfld_properties, },
>>
>>   after:
>>
>> { PCI_VDEVICE(INTEL, INTEL_MRFLD, _pci_mrfld_properties },
>>
>> Drivers can be converted later on in independent way.
>>
>> While here, remove the unused macro with the same name
>> from Ralink wireless driver.
> 
> Skip this, it missed one comma.

s/comma/right paren/ ??

> Will send v2 soon.
> 
>>
>> Signed-off-by: Andy Shevchenko 
>> ---
>>  drivers/net/wireless/ralink/rt2x00/rt2x00pci.h |  6 --
>>  include/linux/pci.h| 15 +++
>>  2 files changed, 15 insertions(+), 6 deletions(-)

-- 
~Randy


Re: [PATCH v1] PCI: Add PCI_DEVICE_DATA() macro to fully describe device ID entry

2018-07-27 Thread Andy Shevchenko
On Fri, 2018-07-27 at 23:39 +0300, Andy Shevchenko wrote:
> There are a lot of examples in the kernel where PCI_VDEVICE() is used
> and still
> looks not so convenient due to additional driver_data field attached.
> 
> Introduce PCI_DEVICE_DATA() macro to fully describe device ID entry in
> shortest
> possible form. For example,
> 
>   before:
> 
> { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MRFLD),
>   (kernel_ulong_t) _pci_mrfld_properties, },
> 
>   after:
> 
> { PCI_VDEVICE(INTEL, INTEL_MRFLD, _pci_mrfld_properties },
> 
> Drivers can be converted later on in independent way.
> 
> While here, remove the unused macro with the same name
> from Ralink wireless driver.

Skip this, it missed one comma.
Will send v2 soon.

> 
> Signed-off-by: Andy Shevchenko 
> ---
>  drivers/net/wireless/ralink/rt2x00/rt2x00pci.h |  6 --
>  include/linux/pci.h| 15 +++
>  2 files changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h
> b/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h
> index bc0ca5f58f38..283e2e607bba 100644
> --- a/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h
> +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h
> @@ -27,12 +27,6 @@
>  #include 
>  #include 
>  
> -/*
> - * This variable should be used with the
> - * pci_driver structure initialization.
> - */
> -#define PCI_DEVICE_DATA(__ops)   .driver_data =
> (kernel_ulong_t)(__ops)
> -
>  /*
>   * PCI driver handlers.
>   */
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index d0961aefdbae..af29a32865c5 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -825,6 +825,21 @@ struct pci_driver {
>   .vendor = PCI_VENDOR_ID_##vend, .device = (dev), \
>   .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 0, 0
>  
> +/**
> + * PCI_DEVICE_DATA - macro used to describe a specific PCI device in
> very short form
> + * @vend: the vendor name
> + * @dev: the device name (without PCI_DEVICE_ID_ prefix)
> + * @data: the driver data to be filled
> + *
> + * This macro is used to create a struct pci_device_id that matches a
> + * specific PCI device.  The subvendor, and subdevice fields will be
> set
> + * to PCI_ANY_ID.
> + */
> +#define PCI_DEVICE_DATA(vend, dev, data) \
> + .vendor = PCI_VENDOR_ID_##vend, .device =
> PCI_DEVICE_ID_##dev, \
> + .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 0, 0 \
> + .driver_data = (kernel_ulong_t)(data)
> +
>  enum {
>   PCI_REASSIGN_ALL_RSRC   = 0x0001,   /* Ignore
> firmware setup */
>   PCI_REASSIGN_ALL_BUS= 0x0002,   /* Reassign
> all bus numbers */

-- 
Andy Shevchenko 
Intel Finland Oy


[PATCH v1] PCI: Add PCI_DEVICE_DATA() macro to fully describe device ID entry

2018-07-27 Thread Andy Shevchenko
There are a lot of examples in the kernel where PCI_VDEVICE() is used and still
looks not so convenient due to additional driver_data field attached.

Introduce PCI_DEVICE_DATA() macro to fully describe device ID entry in shortest
possible form. For example,

  before:

{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MRFLD),
  (kernel_ulong_t) _pci_mrfld_properties, },

  after:

{ PCI_VDEVICE(INTEL, INTEL_MRFLD, _pci_mrfld_properties },

Drivers can be converted later on in independent way.

While here, remove the unused macro with the same name
from Ralink wireless driver.

Signed-off-by: Andy Shevchenko 
---
 drivers/net/wireless/ralink/rt2x00/rt2x00pci.h |  6 --
 include/linux/pci.h| 15 +++
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h 
b/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h
index bc0ca5f58f38..283e2e607bba 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h
@@ -27,12 +27,6 @@
 #include 
 #include 
 
-/*
- * This variable should be used with the
- * pci_driver structure initialization.
- */
-#define PCI_DEVICE_DATA(__ops) .driver_data = (kernel_ulong_t)(__ops)
-
 /*
  * PCI driver handlers.
  */
diff --git a/include/linux/pci.h b/include/linux/pci.h
index d0961aefdbae..af29a32865c5 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -825,6 +825,21 @@ struct pci_driver {
.vendor = PCI_VENDOR_ID_##vend, .device = (dev), \
.subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 0, 0
 
+/**
+ * PCI_DEVICE_DATA - macro used to describe a specific PCI device in very 
short form
+ * @vend: the vendor name
+ * @dev: the device name (without PCI_DEVICE_ID_ prefix)
+ * @data: the driver data to be filled
+ *
+ * This macro is used to create a struct pci_device_id that matches a
+ * specific PCI device.  The subvendor, and subdevice fields will be set
+ * to PCI_ANY_ID.
+ */
+#define PCI_DEVICE_DATA(vend, dev, data) \
+   .vendor = PCI_VENDOR_ID_##vend, .device = PCI_DEVICE_ID_##dev, \
+   .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 0, 0 \
+   .driver_data = (kernel_ulong_t)(data)
+
 enum {
PCI_REASSIGN_ALL_RSRC   = 0x0001,   /* Ignore firmware setup */
PCI_REASSIGN_ALL_BUS= 0x0002,   /* Reassign all bus numbers */
-- 
2.18.0



[PATCH net-next] Implement a rtnetlink device which simulates wifi.

2018-07-27 Thread Cody Schuffelen
The device added here is used through "ip link add ... type virt_wifi"
The intention is to take over an existing network device and produce a
new one that appears like a wireless connection, returning enough canned
responses to nl80211 to satisfy a standard network manager. If
necessary, it can also be set up one step removed from an existing
network device, such as through a vlan/80211Q or macvlan connection to
not disrupt the existing network interface.

This is being used for Google's Remote Android Virtual Device project,
which runs Android devices in virtual machines. The standard network
interfaces provided inside the virtual machines are all ethernet.
However, Android is not interested in ethernet devices and would rather
connect to a wireless interface. This patch allows the virtual machine
guest to treat one of its network connections as wireless rather than
ethernet, satisfying Android's network connection requirements.

We believe this is a generally useful driver for simulating wireless
network connections in other environments where a wireless connection is
desired by some userspace process but is not available. Future work can
also include exporting the wireless control plane to userspace, so the
device can configure the behavior of the simulated wireless network
itself.

This is distinct from other testing efforts such as mac80211_hwsim by
being a cfg80211 device instead of mac80211 device, allowing straight
pass-through on the data plane instead of forcing packaging of ethernet
data into mac80211 frames.

Signed-off-by: A. Cody Schuffelen 
Acked-by: Alistair Strachan 
Acked-by: Greg Hartman 
---
 drivers/net/wireless/Kconfig |   7 +
 drivers/net/wireless/Makefile|   2 +
 drivers/net/wireless/virt_wifi.c | 544 +++
 3 files changed, 553 insertions(+)
 create mode 100644 drivers/net/wireless/virt_wifi.c

diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig
index 166920ae23f8..1781d8a7f05a 100644
--- a/drivers/net/wireless/Kconfig
+++ b/drivers/net/wireless/Kconfig
@@ -114,4 +114,11 @@ config USB_NET_RNDIS_WLAN
 
  If you choose to build a module, it'll be called rndis_wlan.
 
+config VIRT_WIFI
+   tristate "Wifi wrapper for ethernet drivers"
+   default n
+   ---help---
+ This option adds support for ethernet connections to appear as if they
+ are wifi connections through a special rtnetlink device.
+
 endif # WLAN
diff --git a/drivers/net/wireless/Makefile b/drivers/net/wireless/Makefile
index 7fc96306712a..6cfe74515c95 100644
--- a/drivers/net/wireless/Makefile
+++ b/drivers/net/wireless/Makefile
@@ -27,3 +27,5 @@ obj-$(CONFIG_PCMCIA_WL3501)   += wl3501_cs.o
 obj-$(CONFIG_USB_NET_RNDIS_WLAN)   += rndis_wlan.o
 
 obj-$(CONFIG_MAC80211_HWSIM)   += mac80211_hwsim.o
+
+obj-$(CONFIG_VIRT_WIFI)+= virt_wifi.o
diff --git a/drivers/net/wireless/virt_wifi.c b/drivers/net/wireless/virt_wifi.c
new file mode 100644
index ..602bf462b444
--- /dev/null
+++ b/drivers/net/wireless/virt_wifi.c
@@ -0,0 +1,544 @@
+// SPDX-License-Identifier: GPL-2.0
+/* drivers/net/wireless/virt_wifi.c
+ *
+ * A fake implementation of cfg80211_ops that can be tacked on to an ethernet
+ * net_device to make it appear as a wireless connection.
+ *
+ * Copyright (C) 2018 Google, Inc.
+ *
+ * Author: schuffe...@google.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+struct virt_wifi_priv {
+   bool being_deleted;
+   struct cfg80211_scan_request *scan_request;
+   struct delayed_work scan_result;
+   struct delayed_work scan_complete;
+};
+
+static struct ieee80211_channel channel = {
+   .band = NL80211_BAND_5GHZ,
+   .center_freq = 5500,
+   .hw_value = 5500,
+
+   .flags = 0, /* ieee80211_channel_flags */
+   .max_antenna_gain = 20,
+   .max_power = 5500,
+   .max_reg_power = ,
+};
+
+static struct ieee80211_rate bitrate = {
+   .flags = IEEE80211_RATE_SHORT_PREAMBLE, /* ieee80211_rate_flags */
+   .bitrate = 1000,
+};
+
+static struct ieee80211_supported_band band_5ghz = {
+   .channels = ,
+   .bitrates = ,
+   .band = NL80211_BAND_5GHZ,
+   .n_channels = 1,
+   .n_bitrates = 1,
+};
+
+static struct cfg80211_inform_bss mock_inform_bss = {
+   /* ieee80211_channel* */ .chan = ,
+   /* nl80211_bss_scan_width */ .scan_width = NL80211_BSS_CHAN_WIDTH_20,
+   /* s32 */ .signal = 99,
+};
+
+static u8 fake_router_bssid[] = {4, 4, 4, 4, 4, 4};
+
+static int virt_wifi_scan(struct wiphy *wiphy,
+ struct cfg80211_scan_request *request)
+{
+   struct virt_wifi_priv *priv = wiphy_priv(wiphy);
+
+   wiphy_debug(wiphy, "scan\n");
+
+   if (priv->scan_request || priv->being_deleted)
+   return -EBUSY;
+
+   if (request->ie_len > 0)
+   wiphy_debug(wiphy, "scan: first ie: %d\n", (int)request->ie[0]);
+
+   if (request->n_ssids > 0) {
+   int i;
+

Re: [RFC] ath10k: Support configuring firmware tx-retry counter.

2018-07-27 Thread Ben Greear

On 07/16/2018 05:48 PM, gree...@candelatech.com wrote:

From: Ben Greear 

Firmware already supports this, so just enable the path
to configure the vdev parameter.

One potential issue:  The firmware (10.1 at least) defaults to 2,
and the mac80211 stack defaults to 4.  So applying this patch would
change the firmware behaviour regardless of user settings.

I verified this tweaked the proper firmware setting when I
ran this command:


So, please don't apply this.  At least wave-1 10.1 firmware is going to
crash and/or corrupt its rate-ctrl memory, because it has some logic that
is just full of bugs when there can be more than 2 retries.

I plan to fix this in my firmware, but I doubt upstream FW is fixed
or will be fixed (a quick code inspection of 10.2 fw src makes me think
the problem exists there as well).

Thanks,
Ben



iw phy wiphy0 set retry short 2 long 2

Signed-off-by: Ben Greear 
---
 drivers/net/wireless/ath/ath10k/mac.c | 31 +++
 drivers/net/wireless/ath/ath10k/wmi.c |  2 +-
 drivers/net/wireless/ath/ath10k/wmi.h |  2 ++
 3 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index c90c8bb..b458e5b 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -2027,6 +2027,16 @@ static int ath10k_mac_vif_setup_ps(struct ath10k_vif 
*arvif)
return 0;
 }

+static int ath10k_mac_vif_config_retry_limit(struct ath10k_vif *arvif, int 
limit)
+{
+   struct ath10k *ar = arvif->ar;
+   int vdev_param = ar->wmi.vdev_param->rc_num_retries;
+
+   lockdep_assert_held(>ar->conf_mutex);
+
+   return ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, vdev_param, limit);
+}
+
 static int ath10k_mac_vif_disable_keepalive(struct ath10k_vif *arvif)
 {
struct ath10k *ar = arvif->ar;
@@ -5516,6 +5526,24 @@ static int ath10k_config_ps(struct ath10k *ar)
return ret;
 }

+static int ath10k_config_retry_limit(struct ath10k *ar, int limit)
+{
+   struct ath10k_vif *arvif;
+   int ret = 0;
+
+   lockdep_assert_held(>conf_mutex);
+
+   list_for_each_entry(arvif, >arvifs, list) {
+   ret = ath10k_mac_vif_config_retry_limit(arvif, limit);
+   if (ret) {
+   ath10k_warn(ar, "failed to setup retry-limit: %d\n", 
ret);
+   break;
+   }
+   }
+
+   return ret;
+}
+
 static int ath10k_mac_txpower_setup(struct ath10k *ar, int txpower)
 {
int ret;
@@ -5592,6 +5620,9 @@ static int ath10k_config(struct ieee80211_hw *hw, u32 
changed)
ath10k_warn(ar, "failed to recalc monitor: %d\n", ret);
}

+   if (changed & IEEE80211_CONF_CHANGE_RETRY_LIMITS)
+   ret = ath10k_config_retry_limit(ar, 
conf->long_frame_max_tx_count);
+
mutex_unlock(>conf_mutex);
return ret;
 }
diff --git a/drivers/net/wireless/ath/ath10k/wmi.c 
b/drivers/net/wireless/ath/ath10k/wmi.c
index 6aaa439..816883d 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.c
+++ b/drivers/net/wireless/ath/ath10k/wmi.c
@@ -874,7 +874,7 @@ static struct wmi_vdev_param_map wmi_10x_vdev_param_map = {
.tx_encap_type = WMI_VDEV_PARAM_UNSUPPORTED,
.ap_detect_out_of_sync_sleeping_sta_time_secs =
WMI_10X_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS,
-   .rc_num_retries = WMI_VDEV_PARAM_UNSUPPORTED,
+   .rc_num_retries = WMI_10X_VDEV_PARAM_RC_NUM_RETRIES,
.cabq_maxdur = WMI_VDEV_PARAM_UNSUPPORTED,
.mfptest_set = WMI_VDEV_PARAM_UNSUPPORTED,
.rts_fixed_rate = WMI_VDEV_PARAM_UNSUPPORTED,
diff --git a/drivers/net/wireless/ath/ath10k/wmi.h 
b/drivers/net/wireless/ath/ath10k/wmi.h
index 95ff280..b01778e 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.h
+++ b/drivers/net/wireless/ath/ath10k/wmi.h
@@ -5369,6 +5369,8 @@ enum wmi_10x_vdev_param {
WMI_10X_VDEV_PARAM_MCAST2UCAST_SET,
/* Enable/Disable RTS-CTS */
WMI_10X_VDEV_PARAM_ENABLE_RTSCTS,
+   /** Total number of HW retries */
+   WMI_10X_VDEV_PARAM_RC_NUM_RETRIES,

WMI_10X_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS,





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



[PATCH] wlcore: Set rx_status boottime_ns field on rx

2018-07-27 Thread Loic Poulain
When receiving a beacon or probe response, we should update the
boottime_ns field which is the timestamp the frame was received at.
(cf mac80211.h)

This fixes a scanning issue with Android since it relies on this
timestamp to determine when the AP has been seen for the last time
(via the nl80211 BSS_LAST_SEEN_BOOTTIME parameter).

Signed-off-by: Loic Poulain 
---
 drivers/net/wireless/ti/wlcore/rx.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ti/wlcore/rx.c 
b/drivers/net/wireless/ti/wlcore/rx.c
index 0f15696..078a494 100644
--- a/drivers/net/wireless/ti/wlcore/rx.c
+++ b/drivers/net/wireless/ti/wlcore/rx.c
@@ -59,7 +59,7 @@ static u32 wlcore_rx_get_align_buf_size(struct wl1271 *wl, 
u32 pkt_len)
 static void wl1271_rx_status(struct wl1271 *wl,
 struct wl1271_rx_descriptor *desc,
 struct ieee80211_rx_status *status,
-u8 beacon)
+u8 beacon, u8 probe_rsp)
 {
memset(status, 0, sizeof(struct ieee80211_rx_status));
 
@@ -106,6 +106,9 @@ static void wl1271_rx_status(struct wl1271 *wl,
}
}
 
+   if (beacon || probe_rsp)
+   status->boottime_ns = ktime_get_boot_ns();
+
if (beacon)
wlcore_set_pending_regdomain_ch(wl, (u16)desc->channel,
status->band);
@@ -191,7 +194,8 @@ static int wl1271_rx_handle_data(struct wl1271 *wl, u8 
*data, u32 length,
if (ieee80211_is_data_present(hdr->frame_control))
is_data = 1;
 
-   wl1271_rx_status(wl, desc, IEEE80211_SKB_RXCB(skb), beacon);
+   wl1271_rx_status(wl, desc, IEEE80211_SKB_RXCB(skb), beacon,
+ieee80211_is_probe_resp(hdr->frame_control));
wlcore_hw_set_rx_csum(wl, desc, skb);
 
seq_num = (le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_SEQ) >> 4;
-- 
2.7.4



Re: pull-request mwifiex-firmware 2018-07-20

2018-07-27 Thread Josh Boyer
On Fri, Jul 20, 2018 at 1:42 AM Ganapathi Bhat  wrote:
>
> The following changes since commit e1abab618308110789a4c27db543d132fd62e89f:
>
>   linux-firmware: update Marvell USB8997 firmware image to add WPA2 
> vulnerability fix (2018-05-07 17:54:42 +0530)
>
> are available in the git repository at:
>
>   git://git.marvell.com/mwifiex-firmware.git
>
> for you to fetch changes up to 0ced724f6ed564a5e1602808163db7cfa4697f39:
>
>   linux-firmware: update Marvell USB8801 B0 firmware image (2018-07-20 
> 11:00:29 +0530)
>
> 
> Ganapathi Bhat (1):
>   linux-firmware: update Marvell USB8801 B0 firmware image
>
>  WHENCE  |   2 +-
>  mrvl/usb8801_uapsta.bin | Bin 255948 -> 250940 bytes
>  2 files changed, 1 insertion(+), 1 deletion(-)

Pulled and pushed out.  Thanks.

josh


ath9k and 16 VAP interfaces?

2018-07-27 Thread Ben Greear

Hello,

Has anyone tried making ath9k able to support 16 vAP interfaces on a single
radio?  I seem to recall that there were limitations regarding beacon
timers and such, and that is why the current limit is 8?

Thanks,
Ben

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


[PATCH 16/16] iwlwifi: pcie: split tx to amsdu and non amsdu

2018-07-27 Thread Luca Coelho
From: Sara Sharon 

The code is different enough to justify a split.

Signed-off-by: Sara Sharon 
Signed-off-by: Luca Coelho 
---
 .../net/wireless/intel/iwlwifi/pcie/tx-gen2.c | 149 --
 1 file changed, 100 insertions(+), 49 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c
index 64db540ad605..b99f33ff9123 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c
@@ -365,58 +365,89 @@ static int iwl_pcie_gen2_build_amsdu(struct iwl_trans 
*trans,
return -EINVAL;
 }
 
-static
-struct iwl_tfh_tfd *iwl_pcie_gen2_build_tfd(struct iwl_trans *trans,
-   struct iwl_txq *txq,
-   struct iwl_device_cmd *dev_cmd,
-   struct sk_buff *skb,
-   struct iwl_cmd_meta *out_meta)
+static struct
+iwl_tfh_tfd *iwl_pcie_gen2_build_tx_amsdu(struct iwl_trans *trans,
+ struct iwl_txq *txq,
+ struct iwl_device_cmd *dev_cmd,
+ struct sk_buff *skb,
+ struct iwl_cmd_meta *out_meta,
+ int hdr_len,
+ int tx_cmd_len)
 {
-   struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
int idx = iwl_pcie_get_cmd_index(txq, txq->write_ptr);
struct iwl_tfh_tfd *tfd = iwl_pcie_get_tfd(trans, txq, idx);
dma_addr_t tb_phys;
-   bool amsdu;
-   int i, len, tb1_len, tb2_len, hdr_len;
+   int len;
void *tb1_addr;
 
-   memset(tfd, 0, sizeof(*tfd));
+   tb_phys = iwl_pcie_get_first_tb_dma(txq, idx);
 
-   amsdu = ieee80211_is_data_qos(hdr->frame_control) &&
-   (*ieee80211_get_qos_ctl(hdr) &
-IEEE80211_QOS_CTL_A_MSDU_PRESENT);
+   iwl_pcie_gen2_set_tb(trans, tfd, tb_phys, IWL_FIRST_TB_SIZE);
+
+   /*
+* The second TB (tb1) points to the remainder of the TX command
+* and the 802.11 header - dword aligned size
+* (This calculation modifies the TX command, so do it before the
+* setup of the first TB)
+*/
+   len = tx_cmd_len + sizeof(struct iwl_cmd_header) + hdr_len -
+ IWL_FIRST_TB_SIZE;
+
+   /* do not align A-MSDU to dword as the subframe header aligns it */
+
+   /* map the data for TB1 */
+   tb1_addr = ((u8 *)_cmd->hdr) + IWL_FIRST_TB_SIZE;
+   tb_phys = dma_map_single(trans->dev, tb1_addr, len, DMA_TO_DEVICE);
+   if (unlikely(dma_mapping_error(trans->dev, tb_phys)))
+   goto out_err;
+   iwl_pcie_gen2_set_tb(trans, tfd, tb_phys, len);
+
+   if (iwl_pcie_gen2_build_amsdu(trans, skb, tfd,
+ len + IWL_FIRST_TB_SIZE,
+ hdr_len, dev_cmd))
+   goto out_err;
+
+   /* building the A-MSDU might have changed this data, memcpy it now */
+   memcpy(>first_tb_bufs[idx], _cmd->hdr, IWL_FIRST_TB_SIZE);
+   return tfd;
+
+out_err:
+   iwl_pcie_gen2_tfd_unmap(trans, out_meta, tfd);
+   return NULL;
+}
+
+static struct
+iwl_tfh_tfd *iwl_pcie_gen2_build_tx(struct iwl_trans *trans,
+   struct iwl_txq *txq,
+   struct iwl_device_cmd *dev_cmd,
+   struct sk_buff *skb,
+   struct iwl_cmd_meta *out_meta,
+   int hdr_len,
+   int tx_cmd_len)
+{
+   int idx = iwl_pcie_get_cmd_index(txq, txq->write_ptr);
+   struct iwl_tfh_tfd *tfd = iwl_pcie_get_tfd(trans, txq, idx);
+   dma_addr_t tb_phys;
+   int i, len, tb1_len, tb2_len;
+   void *tb1_addr;
 
tb_phys = iwl_pcie_get_first_tb_dma(txq, idx);
+
/* The first TB points to bi-directional DMA data */
-   if (!amsdu)
-   memcpy(>first_tb_bufs[idx], _cmd->hdr,
-  IWL_FIRST_TB_SIZE);
+   memcpy(>first_tb_bufs[idx], _cmd->hdr, IWL_FIRST_TB_SIZE);
 
iwl_pcie_gen2_set_tb(trans, tfd, tb_phys, IWL_FIRST_TB_SIZE);
 
-   /* there must be data left over for TB1 or this code must be changed */
-   BUILD_BUG_ON(sizeof(struct iwl_tx_cmd_gen2) < IWL_FIRST_TB_SIZE);
-
/*
 * The second TB (tb1) points to the remainder of the TX command
 * and the 802.11 header - dword aligned size
 * (This calculation modifies the TX command, so do it before the
 * setup of the first TB)
 */
-   if (trans->cfg->device_family < IWL_DEVICE_FAMILY_22560)
-   len = sizeof(struct iwl_tx_cmd_gen2);
-   else
-   len = sizeof(struct iwl_tx_cmd_gen3);
+   

[PATCH 15/16] iwlwifi: move some msix and rx functions to a common place

2018-07-27 Thread Luca Coelho
From: Golan Ben Ami 

We would like to allow other utlities to init msix and rx.
Put their declarations in a place accessible to other utilities.

Signed-off-by: Golan Ben Ami 
Signed-off-by: Luca Coelho 
---
 .../wireless/intel/iwlwifi/pcie/internal.h| 43 +++
 drivers/net/wireless/intel/iwlwifi/pcie/rx.c  | 24 +++
 .../net/wireless/intel/iwlwifi/pcie/trans.c   | 23 --
 3 files changed, 48 insertions(+), 42 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/internal.h 
b/drivers/net/wireless/intel/iwlwifi/pcie/internal.h
index f6726ccef819..b63d44b7cd7c 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/internal.h
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/internal.h
@@ -45,6 +45,7 @@
 #include "iwl-debug.h"
 #include "iwl-io.h"
 #include "iwl-op-mode.h"
+#include "iwl-drv.h"
 
 /* We need 2 entries for the TX command and header, and another one might
  * be needed for potential data in the SKB's head. The remaining ones can
@@ -639,6 +640,20 @@ IWL_TRANS_GET_PCIE_TRANS(struct iwl_trans *trans)
return (void *)trans->trans_specific;
 }
 
+static inline void iwl_pcie_clear_irq(struct iwl_trans *trans,
+ struct msix_entry *entry)
+{
+   /*
+* Before sending the interrupt the HW disables it to prevent
+* a nested interrupt. This is done by writing 1 to the corresponding
+* bit in the mask register. After handling the interrupt, it should be
+* re-enabled by clearing this bit. This register is defined as
+* write 1 clear (W1C) register, meaning that it's being clear
+* by writing 1 to the bit.
+*/
+   iwl_write32(trans, CSR_MSIX_AUTOMASK_ST_AD, BIT(entry->entry));
+}
+
 static inline struct iwl_trans *
 iwl_trans_pcie_get_trans(struct iwl_trans_pcie *trans_pcie)
 {
@@ -666,6 +681,11 @@ irqreturn_t iwl_pcie_irq_msix_handler(int irq, void 
*dev_id);
 irqreturn_t iwl_pcie_irq_rx_msix_handler(int irq, void *dev_id);
 int iwl_pcie_rx_stop(struct iwl_trans *trans);
 void iwl_pcie_rx_free(struct iwl_trans *trans);
+void iwl_pcie_free_rbs_pool(struct iwl_trans *trans);
+void iwl_pcie_rx_init_rxb_lists(struct iwl_rxq *rxq);
+int iwl_pcie_dummy_napi_poll(struct napi_struct *napi, int budget);
+void iwl_pcie_rxq_alloc_rbs(struct iwl_trans *trans, gfp_t priority,
+   struct iwl_rxq *rxq);
 
 /*
 * ICT - interrupt handling
@@ -892,6 +912,29 @@ static inline void *iwl_pcie_get_tfd(struct iwl_trans 
*trans,
return txq->tfds + trans_pcie->tfd_size * idx;
 }
 
+static inline const char *queue_name(struct device *dev,
+struct iwl_trans_pcie *trans_p, int i)
+{
+   if (trans_p->shared_vec_mask) {
+   int vec = trans_p->shared_vec_mask &
+ IWL_SHARED_IRQ_FIRST_RSS ? 1 : 0;
+
+   if (i == 0)
+   return DRV_NAME ": shared IRQ";
+
+   return devm_kasprintf(dev, GFP_KERNEL,
+ DRV_NAME ": queue %d", i + vec);
+   }
+   if (i == 0)
+   return DRV_NAME ": default queue";
+
+   if (i == trans_p->alloc_vecs - 1)
+   return DRV_NAME ": exception";
+
+   return devm_kasprintf(dev, GFP_KERNEL,
+ DRV_NAME  ": queue %d", i);
+}
+
 static inline void iwl_enable_rfkill_int(struct iwl_trans *trans)
 {
struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
index 59bedb461a8c..d017aa2a0a8b 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
@@ -417,8 +417,8 @@ static struct page *iwl_pcie_rx_alloc_page(struct iwl_trans 
*trans,
  * iwl_pcie_rxq_restock. The latter function will update the HW to use the 
newly
  * allocated buffers.
  */
-static void iwl_pcie_rxq_alloc_rbs(struct iwl_trans *trans, gfp_t priority,
-  struct iwl_rxq *rxq)
+void iwl_pcie_rxq_alloc_rbs(struct iwl_trans *trans, gfp_t priority,
+   struct iwl_rxq *rxq)
 {
struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
struct iwl_rx_mem_buffer *rxb;
@@ -474,7 +474,7 @@ static void iwl_pcie_rxq_alloc_rbs(struct iwl_trans *trans, 
gfp_t priority,
}
 }
 
-static void iwl_pcie_free_rbs_pool(struct iwl_trans *trans)
+void iwl_pcie_free_rbs_pool(struct iwl_trans *trans)
 {
struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
int i;
@@ -986,7 +986,7 @@ static void iwl_pcie_rx_mq_hw_init(struct iwl_trans *trans)
iwl_pcie_enable_rx_wake(trans, true);
 }
 
-static void iwl_pcie_rx_init_rxb_lists(struct iwl_rxq *rxq)
+void iwl_pcie_rx_init_rxb_lists(struct iwl_rxq *rxq)
 {
lockdep_assert_held(>lock);
 
@@ 

[PATCH 14/16] iwlwifi: pcie: include tcp.h implicitly

2018-07-27 Thread Luca Coelho
From: Luca Coelho 

If CONFIG_IPV6 is not enabled in the kernel, tcp.h is not included
implicitly from other header files, causing compilation errors.  To
solve that, explicitly include it in tx-gen2.c.

Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c
index e3ae7f91206b..64db540ad605 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c
@@ -52,6 +52,7 @@
  */
 #include 
 #include 
+#include 
 
 #include "iwl-debug.h"
 #include "iwl-csr.h"
-- 
2.18.0



[PATCH 10/16] iwlwifi: pcie: don't access periphery registers when not available

2018-07-27 Thread Luca Coelho
From: Emmanuel Grumbach 

The periphery can't be accessed before we set the
INIT_DONE bit which initializes the device.

A previous patch added a reconfiguration of the MSI-X
tables upon resume, but at that point in the flow,
INIT_DONE wasn't set. Since the reconfiguration of the
MSI-X tables require periphery access, it failed.

The difference between WoWLAN and without WoWLAN is that
in WoWLAN, iwl_trans_pcie_d3_suspend clears the INIT_DONE
without clearing the STATUS_DEVICE_ENABLED bit in the
software status. Because of that, the resume code thinks
that the device is enabled, but the INIT_DONE bit has been
cleared.

To fix this, don't reconfigure the MSI-X tables in case
WoWLAN is enabled. It will be done in
iwl_trans_pcie_d3_resume anyway.

Fixes: 52848a79b9d2 ("iwlwifi: pcie: reconfigure MSI-X HW on resume")
Signed-off-by: Emmanuel Grumbach 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/pcie/drv.c |  4 
 .../net/wireless/intel/iwlwifi/pcie/trans.c   | 24 +--
 2 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
index 651975bc159b..51a2e2deea9c 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
@@ -994,6 +994,10 @@ static int iwl_pci_resume(struct device *device)
if (!trans->op_mode)
return 0;
 
+   /* In WOWLAN, let iwl_trans_pcie_d3_resume do the rest of the work */
+   if (test_bit(STATUS_DEVICE_ENABLED, >status))
+   return 0;
+
/* reconfigure the MSI-X mapping to get the correct IRQ for rfkill */
iwl_pcie_conf_msix_hw(trans_pcie);
 
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
index 7928e8089f42..a54c2bc985ad 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
@@ -1563,18 +1563,6 @@ static int iwl_trans_pcie_d3_resume(struct iwl_trans 
*trans,
 
iwl_pcie_enable_rx_wake(trans, true);
 
-   /*
-* Reconfigure IVAR table in case of MSIX or reset ict table in
-* MSI mode since HW reset erased it.
-* Also enables interrupts - none will happen as
-* the device doesn't know we're waking it up, only when
-* the opmode actually tells it after this call.
-*/
-   iwl_pcie_conf_msix_hw(trans_pcie);
-   if (!trans_pcie->msix_enabled)
-   iwl_pcie_reset_ict(trans);
-   iwl_enable_interrupts(trans);
-
iwl_set_bit(trans, CSR_GP_CNTRL,
BIT(trans->cfg->csr->flag_mac_access_req));
iwl_set_bit(trans, CSR_GP_CNTRL,
@@ -1592,6 +1580,18 @@ static int iwl_trans_pcie_d3_resume(struct iwl_trans 
*trans,
return ret;
}
 
+   /*
+* Reconfigure IVAR table in case of MSIX or reset ict table in
+* MSI mode since HW reset erased it.
+* Also enables interrupts - none will happen as
+* the device doesn't know we're waking it up, only when
+* the opmode actually tells it after this call.
+*/
+   iwl_pcie_conf_msix_hw(trans_pcie);
+   if (!trans_pcie->msix_enabled)
+   iwl_pcie_reset_ict(trans);
+   iwl_enable_interrupts(trans);
+
iwl_pcie_set_pwr(trans, false);
 
if (!reset) {
-- 
2.18.0



[PATCH 08/16] iwlwifi: d3: disable dbg recording before entering D3

2018-07-27 Thread Luca Coelho
From: Luca Coelho 

Currently the firmware does not stop recording debugging data when
entering D3 and this causes trouble (e.g. sporadic wake ups).

Fix that by stopping dbg recording when suspending.

Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/d3.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/d3.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/d3.c
index 3fcf489f3120..79bdae994822 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/d3.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/d3.c
@@ -1037,6 +1037,13 @@ static int __iwl_mvm_suspend(struct ieee80211_hw *hw,
cpu_to_le32(IWL_WAKEUP_D3_CONFIG_FW_ERROR);
 #endif
 
+   /*
+* TODO: this is needed because the firmware is not stopping
+* the recording automatically before entering D3.  This can
+* be removed once the FW starts doing that.
+*/
+   iwl_fw_dbg_stop_recording(>fwrt);
+
/* must be last -- this switches firmware state */
ret = iwl_mvm_send_cmd(mvm, _cfg_cmd);
if (ret)
-- 
2.18.0



[PATCH 11/16] Revert "iwlwifi: implement fseq version mismatch warning"

2018-07-27 Thread Luca Coelho
From: Sara Sharon 

This reverts commit f2e66c8df0d0f10c70ed7f5e14a939714e9ee6a9.

The firmware never implemented this, and they do not plan to.

Signed-off-by: Sara Sharon 
Signed-off-by: Luca Coelho 
---
 .../net/wireless/intel/iwlwifi/fw/api/alive.h | 18 +---
 .../wireless/intel/iwlwifi/fw/api/commands.h  |  7 --
 .../net/wireless/intel/iwlwifi/fw/common_rx.c | 88 ---
 .../net/wireless/intel/iwlwifi/fw/runtime.h   |  3 -
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c  |  4 +-
 5 files changed, 3 insertions(+), 117 deletions(-)
 delete mode 100644 drivers/net/wireless/intel/iwlwifi/fw/common_rx.c

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/alive.h 
b/drivers/net/wireless/intel/iwlwifi/fw/api/alive.h
index 007bfe7656a4..08d3d8a190f6 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/alive.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/alive.h
@@ -8,6 +8,7 @@
  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
  * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
+ * Copyright (C) 2018 Intel Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of version 2 of the GNU General Public License as
@@ -30,6 +31,7 @@
  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
  * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
+ * Copyright (C) 2018 Intel Corporation
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -187,20 +189,4 @@ struct iwl_card_state_notif {
__le32 flags;
 } __packed; /* CARD_STATE_NTFY_API_S_VER_1 */
 
-/**
- * struct iwl_fseq_ver_mismatch_nty - Notification about version
- *
- * This notification does not have a direct impact on the init flow.
- * It means that another core (not WiFi) has initiated the FSEQ flow
- * and updated the FSEQ version.  The driver only prints an error when
- * this occurs.
- *
- * @aux_read_fseq_ver: auxiliary read FSEQ version
- * @wifi_fseq_ver: FSEQ version (embedded in WiFi)
- */
-struct iwl_fseq_ver_mismatch_ntf {
-   __le32 aux_read_fseq_ver;
-   __le32 wifi_fseq_ver;
-} __packed; /* FSEQ_VER_MISMATCH_NTFY_API_S_VER_1 */
-
 #endif /* __iwl_fw_api_alive_h__ */
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/commands.h 
b/drivers/net/wireless/intel/iwlwifi/fw/api/commands.h
index d71a6a837ec5..6dad748e5cdc 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/commands.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/commands.h
@@ -647,13 +647,6 @@ enum iwl_system_subcmd_ids {
 * @INIT_EXTENDED_CFG_CMD:  iwl_init_extended_cfg_cmd
 */
INIT_EXTENDED_CFG_CMD = 0x03,
-
-   /**
-* @FSEQ_VER_MISMATCH_NTF: Notification about fseq version
-*  mismatch during init.  The format is specified in
-*   iwl_fseq_ver_mismatch_ntf.
-*/
-   FSEQ_VER_MISMATCH_NTF = 0xFF,
 };
 
 #endif /* __iwl_fw_api_commands_h__ */
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/common_rx.c 
b/drivers/net/wireless/intel/iwlwifi/fw/common_rx.c
deleted file mode 100644
index 6f75985eea66..
--- a/drivers/net/wireless/intel/iwlwifi/fw/common_rx.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- *
- * This file is provided under a dual BSD/GPLv2 license.  When using or
- * redistributing this file, you may do so under either license.
- *
- * GPL LICENSE SUMMARY
- *
- * Copyright(c) 2017 Intel Deutschland GmbH
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * The full GNU General Public License is included in this distribution
- * in the file called COPYING.
- *
- * Contact Information:
- *  Intel Linux Wireless 
- * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
- *
- * BSD LICENSE
- *
- * Copyright(c) 2017 Intel Deutschland GmbH
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *  * Redistributions of source code must retain the above copyright
- *notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *notice, this list of conditions and the following disclaimer in
- *the documentation and/or other materials provided with the
- *distribution.
- *  * Neither the name Intel 

[PATCH 09/16] iwlwifi: mvm: configure multi RX queue

2018-07-27 Thread Luca Coelho
From: Sara Sharon 

Currently multi-queue is disabled for 22000 devices.

This was since driver isn't supposed to write to prph
registers anymore, and FW needs to configure the RFH.

Now that FW added support for the API - use it and remove
the 22000 multi RX queue disablement.

Bump min API version to avoid compatibility issues.

Signed-off-by: Sara Sharon 
Signed-off-by: Luca Coelho 
---
 .../net/wireless/intel/iwlwifi/cfg/22000.c|  2 +-
 .../wireless/intel/iwlwifi/fw/api/datapath.h  |  7 +++
 .../net/wireless/intel/iwlwifi/fw/api/rx.h| 32 +
 drivers/net/wireless/intel/iwlwifi/mvm/fw.c   | 48 +--
 .../net/wireless/intel/iwlwifi/mvm/mac80211.c |  7 ---
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c  |  1 +
 6 files changed, 86 insertions(+), 11 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/cfg/22000.c 
b/drivers/net/wireless/intel/iwlwifi/cfg/22000.c
index e5d5578f8b92..91ca77c7571c 100644
--- a/drivers/net/wireless/intel/iwlwifi/cfg/22000.c
+++ b/drivers/net/wireless/intel/iwlwifi/cfg/22000.c
@@ -59,7 +59,7 @@
 #define IWL_22000_UCODE_API_MAX38
 
 /* Lowest firmware API version supported */
-#define IWL_22000_UCODE_API_MIN24
+#define IWL_22000_UCODE_API_MIN39
 
 /* NVM versions */
 #define IWL_22000_NVM_VERSION  0x0a1d
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/datapath.h 
b/drivers/net/wireless/intel/iwlwifi/fw/api/datapath.h
index c1bf3898f8b6..59b3c6e8f37b 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/datapath.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/datapath.h
@@ -8,6 +8,7 @@
  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
  * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
+ * Copyright (C) 2018 Intel Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of version 2 of the GNU General Public License as
@@ -30,6 +31,7 @@
  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
  * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
+ * Copyright (C) 2018 Intel Corporation
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -87,6 +89,11 @@ enum iwl_data_path_subcmd_ids {
 */
STA_HE_CTXT_CMD = 0x7,
 
+   /**
+* @RFH_QUEUE_CONFIG_CMD:  iwl_rfh_queue_config
+*/
+   RFH_QUEUE_CONFIG_CMD = 0xD,
+
/**
 * @TLC_MNG_CONFIG_CMD:  iwl_tlc_config_cmd
 */
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h 
b/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h
index 565343f7e61f..2f599353c885 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h
@@ -715,4 +715,36 @@ struct iwl_ba_window_status_notif {
__le16 mpdu_rx_count[BA_WINDOW_STREAMS_MAX];
 } __packed; /* BA_WINDOW_STATUS_NTFY_API_S_VER_1 */
 
+/**
+ * struct iwl_rfh_queue_config - RX queue configuration
+ * @q_num: Q num
+ * @enable: enable queue
+ * @reserved: alignment
+ * @urbd_stts_wrptr: DMA address of urbd_stts_wrptr
+ * @fr_bd_cb: DMA address of freeRB table
+ * @ur_bd_cb: DMA address of used RB table
+ * @fr_bd_wid: Initial index of the free table
+ */
+struct iwl_rfh_queue_data {
+   u8 q_num;
+   u8 enable;
+   __le16 reserved;
+   __le64 urbd_stts_wrptr;
+   __le64 fr_bd_cb;
+   __le64 ur_bd_cb;
+   __le32 fr_bd_wid;
+} __packed; /* RFH_QUEUE_CONFIG_S_VER_1 */
+
+/**
+ * struct iwl_rfh_queue_config - RX queue configuration
+ * @num_queues: number of queues configured
+ * @reserved: alignment
+ * @data: DMA addresses per-queue
+ */
+struct iwl_rfh_queue_config {
+   u8 num_queues;
+   u8 reserved[3];
+   struct iwl_rfh_queue_data data[];
+} __packed; /* RFH_QUEUE_CONFIG_API_S_VER_1 */
+
 #endif /* __iwl_fw_api_rx_h__ */
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
index 5fe2b460234b..6bb1a99a197a 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
@@ -130,6 +130,41 @@ static int iwl_send_rss_cfg_cmd(struct iwl_mvm *mvm)
return iwl_mvm_send_cmd_pdu(mvm, RSS_CONFIG_CMD, 0, sizeof(cmd), );
 }
 
+static int iwl_configure_rxq(struct iwl_mvm *mvm)
+{
+   int i, num_queues, size;
+   struct iwl_rfh_queue_config *cmd;
+
+   /* Do not configure default queue, it is configured via context info */
+   num_queues = mvm->trans->num_rx_queues - 1;
+
+   size = sizeof(*cmd) + num_queues * sizeof(struct iwl_rfh_queue_data);
+
+   cmd = kzalloc(size, GFP_KERNEL);
+   if (!cmd)
+   return -ENOMEM;
+
+   cmd->num_queues = num_queues;
+
+   for (i = 0; i < num_queues; i++) {
+   struct iwl_trans_rxq_dma_data data;
+
+   

[PATCH 13/16] iwlwifi: mvm: remove dead gscan code

2018-07-27 Thread Luca Coelho
From: Luca Coelho 

There was a bunch of code to support gscan which has never been used.
Remove it all to cleanup and get rid of a lot of dead code.

Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/Makefile  |  1 -
 drivers/net/wireless/intel/iwlwifi/fw/file.h | 37 +-
 drivers/net/wireless/intel/iwlwifi/fw/img.h  | 36 -
 drivers/net/wireless/intel/iwlwifi/iwl-drv.c | 54 +---
 4 files changed, 2 insertions(+), 126 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/Makefile 
b/drivers/net/wireless/intel/iwlwifi/Makefile
index d619995b8bc2..04e376cc898c 100644
--- a/drivers/net/wireless/intel/iwlwifi/Makefile
+++ b/drivers/net/wireless/intel/iwlwifi/Makefile
@@ -14,7 +14,6 @@ iwlwifi-$(CONFIG_IWLMVM) += cfg/7000.o cfg/8000.o cfg/9000.o 
cfg/22000.o
 iwlwifi-objs   += iwl-trans.o
 iwlwifi-objs   += fw/notif-wait.o
 iwlwifi-$(CONFIG_IWLMVM) += fw/paging.o fw/smem.o fw/init.o fw/dbg.o
-iwlwifi-$(CONFIG_IWLMVM) += fw/common_rx.o
 iwlwifi-$(CONFIG_ACPI) += fw/acpi.o
 iwlwifi-$(CONFIG_IWLWIFI_DEBUGFS) += fw/debugfs.o
 
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/file.h 
b/drivers/net/wireless/intel/iwlwifi/fw/file.h
index c967dfbeacaf..bbf2b265a06a 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/file.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/file.h
@@ -321,7 +321,7 @@ typedef unsigned int __bitwise iwl_ucode_tlv_capa_t;
  * IWL_UCODE_TLV_API_WIFI_MCC_UPDATE. When either is set, multi-source LAR
  * is supported.
  * @IWL_UCODE_TLV_CAPA_BT_COEX_RRC: supports BT Coex RRC
- * @IWL_UCODE_TLV_CAPA_GSCAN_SUPPORT: supports gscan
+ * @IWL_UCODE_TLV_CAPA_GSCAN_SUPPORT: supports gscan (no longer used)
  * @IWL_UCODE_TLV_CAPA_STA_PM_NOTIF: firmware will send STA PM notification
  * @IWL_UCODE_TLV_CAPA_TLC_OFFLOAD: firmware implements rate scaling algorithm
  * @IWL_UCODE_TLV_CAPA_DYNAMIC_QUOTA: firmware implements quota related
@@ -892,39 +892,4 @@ struct iwl_fw_dbg_conf_tlv {
struct iwl_fw_dbg_conf_hcmd hcmd;
 } __packed;
 
-/**
- * struct iwl_fw_gscan_capabilities - gscan capabilities supported by FW
- * @max_scan_cache_size: total space allocated for scan results (in bytes).
- * @max_scan_buckets: maximum number of channel buckets.
- * @max_ap_cache_per_scan: maximum number of APs that can be stored per scan.
- * @max_rssi_sample_size: number of RSSI samples used for averaging RSSI.
- * @max_scan_reporting_threshold: max possible report threshold. in percentage.
- * @max_hotlist_aps: maximum number of entries for hotlist APs.
- * @max_significant_change_aps: maximum number of entries for significant
- * change APs.
- * @max_bssid_history_entries: number of BSSID/RSSI entries that the device can
- * hold.
- * @max_hotlist_ssids: maximum number of entries for hotlist SSIDs.
- * @max_number_epno_networks: max number of epno entries.
- * @max_number_epno_networks_by_ssid: max number of epno entries if ssid is
- * specified.
- * @max_number_of_white_listed_ssid: max number of white listed SSIDs.
- * @max_number_of_black_listed_ssid: max number of black listed SSIDs.
- */
-struct iwl_fw_gscan_capabilities {
-   __le32 max_scan_cache_size;
-   __le32 max_scan_buckets;
-   __le32 max_ap_cache_per_scan;
-   __le32 max_rssi_sample_size;
-   __le32 max_scan_reporting_threshold;
-   __le32 max_hotlist_aps;
-   __le32 max_significant_change_aps;
-   __le32 max_bssid_history_entries;
-   __le32 max_hotlist_ssids;
-   __le32 max_number_epno_networks;
-   __le32 max_number_epno_networks_by_ssid;
-   __le32 max_number_of_white_listed_ssid;
-   __le32 max_number_of_black_listed_ssid;
-} __packed;
-
 #endif  /* __iwl_fw_file_h__ */
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/img.h 
b/drivers/net/wireless/intel/iwlwifi/fw/img.h
index 6c5de68b5244..0861b97c4233 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/img.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/img.h
@@ -192,41 +192,6 @@ struct iwl_fw_cscheme_list {
struct iwl_fw_cipher_scheme cs[];
 } __packed;
 
-/**
- * struct iwl_gscan_capabilities - gscan capabilities supported by FW
- * @max_scan_cache_size: total space allocated for scan results (in bytes).
- * @max_scan_buckets: maximum number of channel buckets.
- * @max_ap_cache_per_scan: maximum number of APs that can be stored per scan.
- * @max_rssi_sample_size: number of RSSI samples used for averaging RSSI.
- * @max_scan_reporting_threshold: max possible report threshold. in percentage.
- * @max_hotlist_aps: maximum number of entries for hotlist APs.
- * @max_significant_change_aps: maximum number of entries for significant
- * change APs.
- * @max_bssid_history_entries: number of BSSID/RSSI entries that the device can
- * hold.
- * @max_hotlist_ssids: maximum number of entries for hotlist SSIDs.
- * @max_number_epno_networks: max number of epno entries.
- * @max_number_epno_networks_by_ssid: max number of epno entries if ssid 

[PATCH 00/16] iwlwifi: updates intended for v4.19 2018-07-27

2018-07-27 Thread Luca Coelho
From: Luca Coelho 

Hi,

Here's one more set of patches intended for v4.19.  It contains some
bugfixes, cleanups and more work on supporting the 22560 family of
devices.

The changes are:

* New PCI IDs for 22000 and 22560;
* Some fixes and an improvement in debug dumps and recording;
* Remove some old dead code;
* Fix compilation when only IPv6 is not enabled;
* Continued work on 22560 devices;

As usual, I'm pushing this to a pending branch, for kbuild bot, and
will send a pull-request later.

Please review.

Cheers,
Luca.


Emmanuel Grumbach (1):
  iwlwifi: pcie: don't access periphery registers when not available

Golan Ben Ami (4):
  iwlwifi: pcie: support rx structures for 22560 devices
  iwlwifi: support new rx_mpdu_desc api
  iwlwifi: hard code power save mode to CAM for 22560 devices
  iwlwifi: move some msix and rx functions to a common place

Luca Coelho (4):
  iwlwifi: pcie: add a bunch of PCI IDs for 22000 and 22560
  iwlwifi: d3: disable dbg recording before entering D3
  iwlwifi: mvm: remove dead gscan code
  iwlwifi: pcie: include tcp.h implicitly

Sara Sharon (6):
  iwlwifi: pcie: unionize used bd and completion descriptor
  iwlwifi: pcie: move rxb retrieval to a helper function
  iwlwifi: trans: add a new op for getting DMA data
  iwlwifi: mvm: configure multi RX queue
  Revert "iwlwifi: implement fseq version mismatch warning"
  iwlwifi: pcie: split tx to amsdu and non amsdu

Shahar S Matityahu (1):
  iwlwifi: allow masking out memory areas from the fw dump

 drivers/net/wireless/intel/iwlwifi/Makefile   |   1 -
 .../net/wireless/intel/iwlwifi/cfg/22000.c|   2 +-
 .../net/wireless/intel/iwlwifi/fw/api/alive.h |  18 +-
 .../wireless/intel/iwlwifi/fw/api/commands.h  |   7 -
 .../wireless/intel/iwlwifi/fw/api/datapath.h  |   7 +
 .../net/wireless/intel/iwlwifi/fw/api/rx.h| 211 ++---
 .../net/wireless/intel/iwlwifi/fw/common_rx.c |  88 --
 drivers/net/wireless/intel/iwlwifi/fw/dbg.c   | 284 ++
 drivers/net/wireless/intel/iwlwifi/fw/file.h  |  40 +--
 drivers/net/wireless/intel/iwlwifi/fw/img.h   |  37 +--
 .../net/wireless/intel/iwlwifi/fw/runtime.h   |   3 -
 drivers/net/wireless/intel/iwlwifi/iwl-drv.c  |  67 +
 .../net/wireless/intel/iwlwifi/iwl-trans.h|  27 ++
 drivers/net/wireless/intel/iwlwifi/mvm/d3.c   |   7 +
 .../net/wireless/intel/iwlwifi/mvm/debugfs.c  |   8 +-
 drivers/net/wireless/intel/iwlwifi/mvm/fw.c   |  48 ++-
 .../net/wireless/intel/iwlwifi/mvm/mac80211.c |   7 -
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c  |  20 +-
 drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c |  95 --
 drivers/net/wireless/intel/iwlwifi/pcie/drv.c |  25 +-
 .../wireless/intel/iwlwifi/pcie/internal.h|  78 -
 drivers/net/wireless/intel/iwlwifi/pcie/rx.c  | 170 +++
 .../net/wireless/intel/iwlwifi/pcie/trans.c   | 174 ++-
 .../net/wireless/intel/iwlwifi/pcie/tx-gen2.c | 150 ++---
 24 files changed, 936 insertions(+), 638 deletions(-)
 delete mode 100644 drivers/net/wireless/intel/iwlwifi/fw/common_rx.c

-- 
2.18.0



[PATCH 04/16] iwlwifi: pcie: unionize used bd and completion descriptor

2018-07-27 Thread Luca Coelho
From: Sara Sharon 

This allows less "dummy" declarations and casting.

Signed-off-by: Sara Sharon 
Signed-off-by: Luca Coelho 
---
 .../wireless/intel/iwlwifi/pcie/internal.h|  6 +++-
 drivers/net/wireless/intel/iwlwifi/pcie/rx.c  | 32 +--
 2 files changed, 13 insertions(+), 25 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/internal.h 
b/drivers/net/wireless/intel/iwlwifi/pcie/internal.h
index 90e8a47c8bda..f6726ccef819 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/internal.h
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/internal.h
@@ -235,7 +235,11 @@ struct iwl_rxq {
int id;
void *bd;
dma_addr_t bd_dma;
-   void *used_bd;
+   union {
+   void *used_bd;
+   __le32 *bd_32;
+   struct iwl_rx_completion_desc *cd;
+   };
dma_addr_t used_bd_dma;
__le16 *tr_tail;
dma_addr_t tr_tail_dma;
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
index 78e7e2d5d290..284946653e27 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
@@ -649,7 +649,6 @@ static void iwl_pcie_free_rxq_dma(struct iwl_trans *trans,
  struct iwl_rxq *rxq)
 {
struct device *dev = trans->dev;
-   struct iwl_rx_completion_desc *rx_cd;
bool use_rx_td = (trans->cfg->device_family >=
  IWL_DEVICE_FAMILY_22560);
int free_size = iwl_pcie_free_bd_size(trans, use_rx_td);
@@ -671,7 +670,7 @@ static void iwl_pcie_free_rxq_dma(struct iwl_trans *trans,
 
if (rxq->used_bd)
dma_free_coherent(trans->dev,
- (use_rx_td ? sizeof(*rx_cd) :
+ (use_rx_td ? sizeof(*rxq->cd) :
   sizeof(__le32)) * rxq->queue_size,
  rxq->used_bd, rxq->used_bd_dma);
rxq->used_bd_dma = 0;
@@ -698,7 +697,6 @@ static int iwl_pcie_alloc_rxq_dma(struct iwl_trans *trans,
 {
struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
struct device *dev = trans->dev;
-   struct iwl_rx_completion_desc *rx_cd;
int i;
int free_size;
bool use_rx_td = (trans->cfg->device_family >=
@@ -725,7 +723,7 @@ static int iwl_pcie_alloc_rxq_dma(struct iwl_trans *trans,
if (trans->cfg->mq_rx_supported) {
rxq->used_bd = dma_zalloc_coherent(dev,
   (use_rx_td ?
-  sizeof(*rx_cd) :
+  sizeof(*rxq->cd) :
   sizeof(__le32)) *
   rxq->queue_size,
   >used_bd_dma,
@@ -1371,18 +1369,10 @@ static void iwl_pcie_rx_handle(struct iwl_trans *trans, 
int queue)
 * to retrieve the vid
 */
if (trans->cfg->device_family >=
-   IWL_DEVICE_FAMILY_22560) {
-   struct iwl_rx_completion_desc *rx_cd =
-   &((struct iwl_rx_completion_desc *)
- rxq->used_bd)[i];
-
-   vid = le16_to_cpu(rx_cd->rbid) & 0x0FFF;
-   } else {
-   __le32 *used =
-   &((__le32 *)rxq->used_bd)[i];
-
-   vid = le32_to_cpu(*used) & 0x0FFF;
-   }
+   IWL_DEVICE_FAMILY_22560)
+   vid = le16_to_cpu(rxq->cd[i].rbid) & 0x0FFF;
+   else
+   vid = le32_to_cpu(rxq->bd_32[i]) & 0x0FFF;
 
if (WARN(!vid ||
 vid > ARRAY_SIZE(trans_pcie->global_table),
@@ -1397,15 +1387,9 @@ static void iwl_pcie_rx_handle(struct iwl_trans *trans, 
int queue)
goto out;
}
if (trans->cfg->device_family >=
-   IWL_DEVICE_FAMILY_22560) {
-   struct iwl_rx_completion_desc *rx_cd =
-   &((struct iwl_rx_completion_desc *)
- rxq->used_bd)[i];
-
-   rxb->size = le32_to_cpu(rx_cd->size) &
+   IWL_DEVICE_FAMILY_22560)
+   rxb->size = le32_to_cpu(rxq->cd[i].size) &
IWL_RX_CD_SIZE;
-   }
-
rxb->invalid = true;
} else {
rxb = rxq->queue[i];
-- 

[PATCH 02/16] iwlwifi: pcie: support rx structures for 22560 devices

2018-07-27 Thread Luca Coelho
From: Golan Ben Ami 

The rfh for 22560 devices has changed so it supports now
the same arch of using used and free lists, but different
structures to support the last.
Use the new structures, hw dependent, to manage the lists.

bd, the free list, uses the iwl_rx_transfer_desc,
in which the vid is stored in the structs' rbid
field, and the page address in the addr field.

used_bd, the used list, uses the iwl_rx_completion_desc
struct, in which the vid is stored in the structs' rbid
field.

rb_stts, the hw "write" pointer of rx is stored in a
__le16 array, in which each entry represents the write
pointer per queue.

Signed-off-by: Golan Ben Ami 
Signed-off-by: Luca Coelho 
---
 .../wireless/intel/iwlwifi/pcie/internal.h|  31 -
 drivers/net/wireless/intel/iwlwifi/pcie/rx.c  | 111 +++---
 .../net/wireless/intel/iwlwifi/pcie/trans.c   |  12 +-
 3 files changed, 128 insertions(+), 26 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/internal.h 
b/drivers/net/wireless/intel/iwlwifi/pcie/internal.h
index 11687dc4039d..90e8a47c8bda 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/internal.h
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/internal.h
@@ -72,6 +72,7 @@ struct iwl_host_cmd;
  * @page: driver's pointer to the rxb page
  * @invalid: rxb is in driver ownership - not owned by HW
  * @vid: index of this rxb in the global table
+ * @size: size used from the buffer
  */
 struct iwl_rx_mem_buffer {
dma_addr_t page_dma;
@@ -79,6 +80,7 @@ struct iwl_rx_mem_buffer {
u16 vid;
bool invalid;
struct list_head list;
+   u32 size;
 };
 
 /**
@@ -159,8 +161,10 @@ enum iwl_completion_desc_wifi_status {
IWL_CD_STTS_REPLAY_ERR,
 };
 
-#define IWL_RX_TD_TYPE 0xff00
-#define IWL_RX_TD_SIZE 0x00ff
+#define IWL_RX_TD_TYPE_MSK 0xff00
+#define IWL_RX_TD_SIZE_MSK 0x00ff
+#define IWL_RX_TD_SIZE_2K  BIT(11)
+#define IWL_RX_TD_TYPE 0
 
 /**
  * struct iwl_rx_transfer_desc - transfer descriptor
@@ -204,6 +208,7 @@ struct iwl_rx_completion_desc {
  * @id: queue index
  * @bd: driver's pointer to buffer of receive buffer descriptors (rbd).
  * Address size is 32 bit in pre-9000 devices and 64 bit in 9000 devices.
+ * In 22560 devices it is a pointer to a list of iwl_rx_transfer_desc's
  * @bd_dma: bus address of buffer of receive buffer descriptors (rbd)
  * @ubd: driver's pointer to buffer of used receive buffer descriptors (rbd)
  * @ubd_dma: physical address of buffer of used receive buffer descriptors 
(rbd)
@@ -230,7 +235,7 @@ struct iwl_rxq {
int id;
void *bd;
dma_addr_t bd_dma;
-   __le32 *used_bd;
+   void *used_bd;
dma_addr_t used_bd_dma;
__le16 *tr_tail;
dma_addr_t tr_tail_dma;
@@ -245,7 +250,7 @@ struct iwl_rxq {
struct list_head rx_free;
struct list_head rx_used;
bool need_update;
-   struct iwl_rb_status *rb_stts;
+   void *rb_stts;
dma_addr_t rb_stts_dma;
spinlock_t lock;
struct napi_struct napi;
@@ -289,6 +294,24 @@ static inline int iwl_queue_inc_wrap(struct iwl_trans 
*trans, int index)
return ++index & (trans->cfg->base_params->max_tfd_queue_size - 1);
 }
 
+/**
+ * iwl_get_closed_rb_stts - get closed rb stts from different structs
+ * @rxq - the rxq to get the rb stts from
+ */
+static inline __le16 iwl_get_closed_rb_stts(struct iwl_trans *trans,
+   struct iwl_rxq *rxq)
+{
+   if (trans->cfg->device_family >= IWL_DEVICE_FAMILY_22560) {
+   __le16 *rb_stts = rxq->rb_stts;
+
+   return READ_ONCE(*rb_stts);
+   } else {
+   struct iwl_rb_status *rb_stts = rxq->rb_stts;
+
+   return READ_ONCE(rb_stts->closed_rb_num);
+   }
+}
+
 /**
  * iwl_queue_dec_wrap - decrement queue index, wrap back to end
  * @index -- current index
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
index f509e55f27b1..78e7e2d5d290 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
@@ -242,6 +242,25 @@ static void iwl_pcie_rxq_check_wrptr(struct iwl_trans 
*trans)
}
 }
 
+static void iwl_pcie_restock_bd(struct iwl_trans *trans,
+   struct iwl_rxq *rxq,
+   struct iwl_rx_mem_buffer *rxb)
+{
+   if (trans->cfg->device_family >= IWL_DEVICE_FAMILY_22560) {
+   struct iwl_rx_transfer_desc *bd = rxq->bd;
+
+   bd[rxq->write].type_n_size =
+   cpu_to_le32((IWL_RX_TD_TYPE & IWL_RX_TD_TYPE_MSK) |
+   ((IWL_RX_TD_SIZE_2K >> 8) & IWL_RX_TD_SIZE_MSK));
+   bd[rxq->write].addr = cpu_to_le64(rxb->page_dma);
+   bd[rxq->write].rbid = cpu_to_le16(rxb->vid);
+   } else {
+   __le64 *bd = rxq->bd;
+
+   

[PATCH 03/16] iwlwifi: support new rx_mpdu_desc api

2018-07-27 Thread Luca Coelho
From: Golan Ben Ami 

22560 devices use a new rx_mpdu_desc api.
Update the code to use the new api.

Signed-off-by: Golan Ben Ami 
Signed-off-by: Luca Coelho 
---
 .../net/wireless/intel/iwlwifi/fw/api/rx.h| 179 +-
 .../net/wireless/intel/iwlwifi/mvm/debugfs.c  |   8 +-
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c  |   9 +-
 drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c |  95 +++---
 4 files changed, 218 insertions(+), 73 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h 
b/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h
index 0daa09c94b0f..565343f7e61f 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h
@@ -377,78 +377,94 @@ enum iwl_rx_he_phy {
 };
 
 /**
- * struct iwl_rx_mpdu_desc - RX MPDU descriptor
+ * struct iwl_rx_mpdu_desc_v1 - RX MPDU descriptor
  */
-struct iwl_rx_mpdu_desc {
-   /* DW2 */
-   /**
-* @mpdu_len: MPDU length
-*/
-   __le16 mpdu_len;
-   /**
-* @mac_flags1:  iwl_rx_mpdu_mac_flags1
-*/
-   u8 mac_flags1;
-   /**
-* @mac_flags2:  iwl_rx_mpdu_mac_flags2
-*/
-   u8 mac_flags2;
-   /* DW3 */
+struct iwl_rx_mpdu_desc_v1 {
+   /* DW7 - carries rss_hash only when rpa_en == 1 */
/**
-* @amsdu_info:  iwl_rx_mpdu_amsdu_info
+* @rss_hash: RSS hash value
 */
-   u8 amsdu_info;
+   __le32 rss_hash;
+   /* DW8 - carries filter_match only when rpa_en == 1 */
/**
-* @phy_info:  iwl_rx_mpdu_phy_info
+* @filter_match: filter match value
 */
-   __le16 phy_info;
+   __le32 filter_match;
+   /* DW9 */
/**
-* @mac_phy_idx: MAC/PHY index
+* @rate_n_flags: RX rate/flags encoding
 */
-   u8 mac_phy_idx;
-   /* DW4 - carries csum data only when rpa_en == 1 */
+   __le32 rate_n_flags;
+   /* DW10 */
/**
-* @raw_csum: raw checksum (alledgedly unreliable)
+* @energy_a: energy chain A
 */
-   __le16 raw_csum;
+   u8 energy_a;
/**
-* @l3l4_flags:  iwl_rx_l3l4_flags
+* @energy_b: energy chain B
 */
-   __le16 l3l4_flags;
-   /* DW5 */
+   u8 energy_b;
/**
-* @status:  iwl_rx_mpdu_status
+* @channel: channel number
 */
-   __le16 status;
+   u8 channel;
/**
-* @hash_filter: hash filter value
+* @mac_context: MAC context mask
 */
-   u8 hash_filter;
+   u8 mac_context;
+   /* DW11 */
/**
-* @sta_id_flags:  iwl_rx_mpdu_sta_id_flags
+* @gp2_on_air_rise: GP2 timer value on air rise (INA)
 */
-   u8 sta_id_flags;
-   /* DW6 */
+   __le32 gp2_on_air_rise;
+   /* DW12 & DW13 */
+   union {
+   /**
+* @tsf_on_air_rise:
+* TSF value on air rise (INA), only valid if
+* %IWL_RX_MPDU_PHY_TSF_OVERLOAD isn't set
+*/
+   __le64 tsf_on_air_rise;
+   /**
+* @he_phy_data:
+* HE PHY data, see  iwl_rx_he_phy, valid
+* only if %IWL_RX_MPDU_PHY_TSF_OVERLOAD is set
+*/
+   __le64 he_phy_data;
+   };
+} __packed;
+
+/**
+ * struct iwl_rx_mpdu_desc_v3 - RX MPDU descriptor
+ */
+struct iwl_rx_mpdu_desc_v3 {
+   /* DW7 - carries filter_match only when rpa_en == 1 */
/**
-* @reorder_data:  iwl_rx_mpdu_reorder_data
+* @filter_match: filter match value
 */
-   __le32 reorder_data;
-   /* DW7 - carries rss_hash only when rpa_en == 1 */
+   __le32 filter_match;
+   /* DW8 - carries rss_hash only when rpa_en == 1 */
/**
 * @rss_hash: RSS hash value
 */
__le32 rss_hash;
-   /* DW8 - carries filter_match only when rpa_en == 1 */
+   /* DW9 */
/**
-* @filter_match: filter match value
+* @partial_hash: 31:0 ip/tcp header hash
+*  w/o some fields (such as IP SRC addr)
 */
-   __le32 filter_match;
-   /* DW9 */
+   __le32 partial_hash;
+   /* DW10 */
+   /**
+* @raw_xsum: raw xsum value
+*/
+   __le32 raw_xsum;
+   /* DW11 */
/**
 * @rate_n_flags: RX rate/flags encoding
 */
__le32 rate_n_flags;
-   /* DW10 */
+   /* DW12 */
/**
 * @energy_a: energy chain A
 */
@@ -465,12 +481,12 @@ struct iwl_rx_mpdu_desc {
 * @mac_context: MAC context mask
 */
u8 mac_context;
-   /* DW11 */
+   /* DW13 */
/**
 * @gp2_on_air_rise: GP2 timer value on air rise (INA)
 */
__le32 gp2_on_air_rise;
-   /* DW12 & DW13 */
+   /* DW14 & DW15 */
union {
/**
 * @tsf_on_air_rise:
@@ -485,7 +501,78 @@ struct 

[PATCH 12/16] iwlwifi: hard code power save mode to CAM for 22560 devices

2018-07-27 Thread Luca Coelho
From: Golan Ben Ami 

Balanced power save mode isn't supported in the fw for 22560 devices
yet.  Configure the power save mode to CAM until it gets implemented.

Signed-off-by: Golan Ben Ami 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
index 0efd2a36e6c4..0e26619fb330 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
@@ -709,10 +709,13 @@ iwl_op_mode_mvm_start(struct iwl_trans *trans, const 
struct iwl_cfg *cfg,
}
 
/* the hardware splits the A-MSDU */
-   if (mvm->trans->cfg->device_family >= IWL_DEVICE_FAMILY_22560)
+   if (mvm->trans->cfg->device_family >= IWL_DEVICE_FAMILY_22560) {
trans_cfg.rx_buf_size = IWL_AMSDU_2K;
-   else if (mvm->cfg->mq_rx_supported)
+   /* TODO: remove when balanced power mode is fw supported */
+   iwlmvm_mod_params.power_scheme = IWL_POWER_SCHEME_CAM;
+   } else if (mvm->cfg->mq_rx_supported) {
trans_cfg.rx_buf_size = IWL_AMSDU_4K;
+   }
 
trans->wide_cmd_header = true;
trans_cfg.bc_table_dword =
-- 
2.18.0



[PATCH 05/16] iwlwifi: pcie: move rxb retrieval to a helper function

2018-07-27 Thread Luca Coelho
From: Sara Sharon 

This makes code less indented and more readable.

Signed-off-by: Sara Sharon 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/pcie/rx.c | 75 +++-
 1 file changed, 42 insertions(+), 33 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
index 284946653e27..59bedb461a8c 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
@@ -1332,6 +1332,45 @@ static void iwl_pcie_rx_handle_rb(struct iwl_trans 
*trans,
iwl_pcie_rx_reuse_rbd(trans, rxb, rxq, emergency);
 }
 
+static struct iwl_rx_mem_buffer *iwl_pcie_get_rxb(struct iwl_trans *trans,
+ struct iwl_rxq *rxq, int i)
+{
+   struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
+   struct iwl_rx_mem_buffer *rxb;
+   u16 vid;
+
+   if (!trans->cfg->mq_rx_supported) {
+   rxb = rxq->queue[i];
+   rxq->queue[i] = NULL;
+   return rxb;
+   }
+
+   /* used_bd is a 32/16 bit but only 12 are used to retrieve the vid */
+   if (trans->cfg->device_family >= IWL_DEVICE_FAMILY_22560)
+   vid = le16_to_cpu(rxq->cd[i].rbid) & 0x0FFF;
+   else
+   vid = le32_to_cpu(rxq->bd_32[i]) & 0x0FFF;
+
+   if (!vid || vid > ARRAY_SIZE(trans_pcie->global_table))
+   goto out_err;
+
+   rxb = trans_pcie->global_table[vid - 1];
+   if (rxb->invalid)
+   goto out_err;
+
+   if (trans->cfg->device_family >= IWL_DEVICE_FAMILY_22560)
+   rxb->size = le32_to_cpu(rxq->cd[i].size) & IWL_RX_CD_SIZE;
+
+   rxb->invalid = true;
+
+   return rxb;
+
+out_err:
+   WARN(1, "Invalid rxb from HW %u\n", (u32)vid);
+   iwl_force_nmi(trans);
+   return NULL;
+}
+
 /*
  * iwl_pcie_rx_handle - Main entry function for receiving responses from fw
  */
@@ -1362,39 +1401,9 @@ static void iwl_pcie_rx_handle(struct iwl_trans *trans, 
int queue)
if (unlikely(rxq->used_count == rxq->queue_size / 2))
emergency = true;
 
-   if (trans->cfg->mq_rx_supported) {
-   u16 vid;
-   /*
-* used_bd is a 32/16 bit but only 12 are used
-* to retrieve the vid
-*/
-   if (trans->cfg->device_family >=
-   IWL_DEVICE_FAMILY_22560)
-   vid = le16_to_cpu(rxq->cd[i].rbid) & 0x0FFF;
-   else
-   vid = le32_to_cpu(rxq->bd_32[i]) & 0x0FFF;
-
-   if (WARN(!vid ||
-vid > ARRAY_SIZE(trans_pcie->global_table),
-"Invalid rxb index from HW %u\n", (u32)vid)) {
-   iwl_force_nmi(trans);
-   goto out;
-   }
-   rxb = trans_pcie->global_table[vid - 1];
-   if (WARN(rxb->invalid,
-"Invalid rxb from HW %u\n", (u32)vid)) {
-   iwl_force_nmi(trans);
-   goto out;
-   }
-   if (trans->cfg->device_family >=
-   IWL_DEVICE_FAMILY_22560)
-   rxb->size = le32_to_cpu(rxq->cd[i].size) &
-   IWL_RX_CD_SIZE;
-   rxb->invalid = true;
-   } else {
-   rxb = rxq->queue[i];
-   rxq->queue[i] = NULL;
-   }
+   rxb = iwl_pcie_get_rxb(trans, rxq, i);
+   if (!rxb)
+   goto out;
 
IWL_DEBUG_RX(trans, "Q %d: HW = %d, SW = %d\n", rxq->id, r, i);
iwl_pcie_rx_handle_rb(trans, rxq, rxb, emergency);
-- 
2.18.0



[PATCH 01/16] iwlwifi: pcie: add a bunch of PCI IDs for 22000 and 22560

2018-07-27 Thread Luca Coelho
From: Luca Coelho 

Add some missing PCI IDs for 22000 and 22560 devices.

Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/pcie/drv.c | 21 ---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
index 0358b406be81..651975bc159b 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
@@ -806,17 +806,32 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
{IWL_PCI_DEVICE(0xA370, 0x42A4, iwl9462_2ac_cfg_soc)},
 
 /* 22000 Series */
-   {IWL_PCI_DEVICE(0x2720, 0x0A10, iwl22000_2ac_cfg_hr_cdb)},
-   {IWL_PCI_DEVICE(0x34F0, 0x0310, iwl22000_2ac_cfg_jf)},
{IWL_PCI_DEVICE(0x2720, 0x, iwl22000_2ax_cfg_hr)},
-   {IWL_PCI_DEVICE(0x34F0, 0x0070, iwl22000_2ax_cfg_hr)},
+   {IWL_PCI_DEVICE(0x2720, 0x0040, iwl22000_2ax_cfg_hr)},
{IWL_PCI_DEVICE(0x2720, 0x0078, iwl22000_2ax_cfg_hr)},
{IWL_PCI_DEVICE(0x2720, 0x0070, iwl22000_2ac_cfg_hr_cdb)},
{IWL_PCI_DEVICE(0x2720, 0x0030, iwl22000_2ac_cfg_hr_cdb)},
{IWL_PCI_DEVICE(0x2720, 0x1080, iwl22000_2ax_cfg_hr)},
{IWL_PCI_DEVICE(0x2720, 0x0090, iwl22000_2ac_cfg_hr_cdb)},
{IWL_PCI_DEVICE(0x2720, 0x0310, iwl22000_2ac_cfg_hr_cdb)},
+   {IWL_PCI_DEVICE(0x34F0, 0x0040, iwl22000_2ax_cfg_hr)},
+   {IWL_PCI_DEVICE(0x34F0, 0x0070, iwl22000_2ax_cfg_hr)},
+   {IWL_PCI_DEVICE(0x34F0, 0x0078, iwl22000_2ax_cfg_hr)},
+   {IWL_PCI_DEVICE(0x34F0, 0x0310, iwl22000_2ac_cfg_jf)},
+   {IWL_PCI_DEVICE(0x40C0, 0x, iwl22560_2ax_cfg_su_cdb)},
+   {IWL_PCI_DEVICE(0x40C0, 0x0010, iwl22560_2ax_cfg_su_cdb)},
+   {IWL_PCI_DEVICE(0x40c0, 0x0090, iwl22560_2ax_cfg_su_cdb)},
+   {IWL_PCI_DEVICE(0x40C0, 0x0310, iwl22560_2ax_cfg_su_cdb)},
+   {IWL_PCI_DEVICE(0x40C0, 0x0A10, iwl22560_2ax_cfg_su_cdb)},
+   {IWL_PCI_DEVICE(0x43F0, 0x0040, iwl22000_2ax_cfg_hr)},
+   {IWL_PCI_DEVICE(0x43F0, 0x0070, iwl22000_2ax_cfg_hr)},
+   {IWL_PCI_DEVICE(0x43F0, 0x0078, iwl22000_2ax_cfg_hr)},
{IWL_PCI_DEVICE(0xA0F0, 0x, iwl22000_2ax_cfg_hr)},
+   {IWL_PCI_DEVICE(0xA0F0, 0x0040, iwl22000_2ax_cfg_hr)},
+   {IWL_PCI_DEVICE(0xA0F0, 0x0070, iwl22000_2ax_cfg_hr)},
+   {IWL_PCI_DEVICE(0xA0F0, 0x0078, iwl22000_2ax_cfg_hr)},
+   {IWL_PCI_DEVICE(0xA0F0, 0x00B0, iwl22000_2ax_cfg_hr)},
+   {IWL_PCI_DEVICE(0xA0F0, 0x0A10, iwl22000_2ax_cfg_hr)},
 
 #endif /* CONFIG_IWLMVM */
 
-- 
2.18.0



[PATCH 06/16] iwlwifi: trans: add a new op for getting DMA data

2018-07-27 Thread Luca Coelho
From: Sara Sharon 

Op mode will need this data in order to feed FW with it.

Signed-off-by: Sara Sharon 
Signed-off-by: Luca Coelho 
---
 .../net/wireless/intel/iwlwifi/iwl-trans.h| 26 +++
 .../net/wireless/intel/iwlwifi/pcie/trans.c   | 17 
 2 files changed, 43 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-trans.h 
b/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
index 4229992073b6..9483f76476de 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
@@ -439,6 +439,20 @@ struct iwl_trans_txq_scd_cfg {
int frame_limit;
 };
 
+/**
+ * struct iwl_trans_rxq_dma_data - RX queue DMA data
+ * @fr_bd_cb: DMA address of free BD cyclic buffer
+ * @fr_bd_wid: Initial write index of the free BD cyclic buffer
+ * @urbd_stts_wrptr: DMA address of urbd_stts_wrptr
+ * @ur_bd_cb: DMA address of used BD cyclic buffer
+ */
+struct iwl_trans_rxq_dma_data {
+   u64 fr_bd_cb;
+   u32 fr_bd_wid;
+   u64 urbd_stts_wrptr;
+   u64 ur_bd_cb;
+};
+
 /**
  * struct iwl_trans_ops - transport specific operations
  *
@@ -559,6 +573,8 @@ struct iwl_trans_ops {
 int cmd_id, int size,
 unsigned int queue_wdg_timeout);
void (*txq_free)(struct iwl_trans *trans, int queue);
+   int (*rxq_dma_data)(struct iwl_trans *trans, int queue,
+   struct iwl_trans_rxq_dma_data *data);
 
void (*txq_set_shared_mode)(struct iwl_trans *trans, u32 txq_id,
bool shared);
@@ -947,6 +963,16 @@ iwl_trans_txq_enable_cfg(struct iwl_trans *trans, int 
queue, u16 ssn,
  cfg, queue_wdg_timeout);
 }
 
+static inline int
+iwl_trans_get_rxq_dma_data(struct iwl_trans *trans, int queue,
+  struct iwl_trans_rxq_dma_data *data)
+{
+   if (WARN_ON_ONCE(!trans->ops->rxq_dma_data))
+   return -ENOTSUPP;
+
+   return trans->ops->rxq_dma_data(trans, queue, data);
+}
+
 static inline void
 iwl_trans_txq_free(struct iwl_trans *trans, int queue)
 {
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
index 64c781eab6a5..603458aa2923 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
@@ -2265,6 +2265,22 @@ void iwl_trans_pcie_log_scd_error(struct iwl_trans 
*trans, struct iwl_txq *txq)
iwl_read_direct32(trans, FH_TX_TRB_REG(fifo)));
 }
 
+static int iwl_trans_pcie_rxq_dma_data(struct iwl_trans *trans, int queue,
+  struct iwl_trans_rxq_dma_data *data)
+{
+   struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
+
+   if (queue >= trans->num_rx_queues || !trans_pcie->rxq)
+   return -EINVAL;
+
+   data->fr_bd_cb = trans_pcie->rxq[queue].bd_dma;
+   data->urbd_stts_wrptr = trans_pcie->rxq[queue].rb_stts_dma;
+   data->ur_bd_cb = trans_pcie->rxq[queue].used_bd_dma;
+   data->fr_bd_wid = 0;
+
+   return 0;
+}
+
 static int iwl_trans_pcie_wait_txq_empty(struct iwl_trans *trans, int txq_idx)
 {
struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
@@ -3212,6 +3228,7 @@ static const struct iwl_trans_ops trans_ops_pcie_gen2 = {
.txq_alloc = iwl_trans_pcie_dyn_txq_alloc,
.txq_free = iwl_trans_pcie_dyn_txq_free,
.wait_txq_empty = iwl_trans_pcie_wait_txq_empty,
+   .rxq_dma_data = iwl_trans_pcie_rxq_dma_data,
 };
 
 struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
-- 
2.18.0



[PATCH 07/16] iwlwifi: allow masking out memory areas from the fw dump

2018-07-27 Thread Luca Coelho
From: Shahar S Matityahu 

Reading and dumping memory areas takes time, and sometimes
dumping all of the areas isn't necessary.

Allow choosing the memory areas which should be dumped.

Signed-off-by: Shahar S Matityahu 
Signed-off-by: Golan Ben Ami 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/fw/dbg.c   | 284 ++
 drivers/net/wireless/intel/iwlwifi/fw/file.h  |   3 +
 drivers/net/wireless/intel/iwlwifi/fw/img.h   |   1 +
 drivers/net/wireless/intel/iwlwifi/iwl-drv.c  |  13 +
 .../net/wireless/intel/iwlwifi/iwl-trans.h|   1 +
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c  |   1 +
 .../net/wireless/intel/iwlwifi/pcie/trans.c   |  98 +++---
 7 files changed, 244 insertions(+), 157 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c 
b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
index fa283285fcbe..a31a42e673c4 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
@@ -243,39 +243,47 @@ static void iwl_fw_dump_fifos(struct iwl_fw_runtime *fwrt,
if (!iwl_trans_grab_nic_access(fwrt->trans, ))
return;
 
-   /* Pull RXF1 */
-   iwl_fwrt_dump_rxf(fwrt, dump_data, cfg->lmac[0].rxfifo1_size, 0, 0);
-   /* Pull RXF2 */
-   iwl_fwrt_dump_rxf(fwrt, dump_data, cfg->rxfifo2_size,
- RXF_DIFF_FROM_PREV, 1);
-   /* Pull LMAC2 RXF1 */
-   if (fwrt->smem_cfg.num_lmacs > 1)
-   iwl_fwrt_dump_rxf(fwrt, dump_data, cfg->lmac[1].rxfifo1_size,
- LMAC2_PRPH_OFFSET, 2);
-
-   /* Pull TXF data from LMAC1 */
-   for (i = 0; i < fwrt->smem_cfg.num_txfifo_entries; i++) {
-   /* Mark the number of TXF we're pulling now */
-   iwl_trans_write_prph(fwrt->trans, TXF_LARC_NUM, i);
-   iwl_fwrt_dump_txf(fwrt, dump_data, cfg->lmac[0].txfifo_size[i],
- 0, i);
+   if (fwrt->fw->dbg_dump_mask & BIT(IWL_FW_ERROR_DUMP_RXF)) {
+   /* Pull RXF1 */
+   iwl_fwrt_dump_rxf(fwrt, dump_data,
+ cfg->lmac[0].rxfifo1_size, 0, 0);
+   /* Pull RXF2 */
+   iwl_fwrt_dump_rxf(fwrt, dump_data, cfg->rxfifo2_size,
+ RXF_DIFF_FROM_PREV, 1);
+   /* Pull LMAC2 RXF1 */
+   if (fwrt->smem_cfg.num_lmacs > 1)
+   iwl_fwrt_dump_rxf(fwrt, dump_data,
+ cfg->lmac[1].rxfifo1_size,
+ LMAC2_PRPH_OFFSET, 2);
}
 
-   /* Pull TXF data from LMAC2 */
-   if (fwrt->smem_cfg.num_lmacs > 1) {
+   if (fwrt->fw->dbg_dump_mask & BIT(IWL_FW_ERROR_DUMP_TXF)) {
+   /* Pull TXF data from LMAC1 */
for (i = 0; i < fwrt->smem_cfg.num_txfifo_entries; i++) {
/* Mark the number of TXF we're pulling now */
-   iwl_trans_write_prph(fwrt->trans,
-TXF_LARC_NUM + LMAC2_PRPH_OFFSET,
-i);
+   iwl_trans_write_prph(fwrt->trans, TXF_LARC_NUM, i);
iwl_fwrt_dump_txf(fwrt, dump_data,
- cfg->lmac[1].txfifo_size[i],
- LMAC2_PRPH_OFFSET,
- i + cfg->num_txfifo_entries);
+ cfg->lmac[0].txfifo_size[i], 0, i);
+   }
+
+   /* Pull TXF data from LMAC2 */
+   if (fwrt->smem_cfg.num_lmacs > 1) {
+   for (i = 0; i < fwrt->smem_cfg.num_txfifo_entries;
+i++) {
+   /* Mark the number of TXF we're pulling now */
+   iwl_trans_write_prph(fwrt->trans,
+TXF_LARC_NUM +
+LMAC2_PRPH_OFFSET, i);
+   iwl_fwrt_dump_txf(fwrt, dump_data,
+ cfg->lmac[1].txfifo_size[i],
+ LMAC2_PRPH_OFFSET,
+ i + cfg->num_txfifo_entries);
+   }
}
}
 
-   if (fw_has_capa(>fw->ucode_capa,
+   if (fwrt->fw->dbg_dump_mask & BIT(IWL_FW_ERROR_DUMP_INTERNAL_TXF) &&
+   fw_has_capa(>fw->ucode_capa,
IWL_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG)) {
/* Pull UMAC internal TXF data from all TXFs */
for (i = 0;
@@ -600,42 +608,54 @@ void iwl_fw_error_dump(struct iwl_fw_runtime *fwrt)
if (test_bit(STATUS_FW_ERROR, >trans->status)) {
fifo_data_len = 0;
 
-   /* Count RXF2 size */
-   if