Re: [PATCH] wilc1000: move wilc driver out of staging

2020-07-02 Thread Ajay.Kathat



On 02/07/20 12:30 pm, Kalle Valo wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the 
> content is safe
> 
>  writes:
> 
>> From: Ajay Singh 
>>
>> WILC1000 is an IEEE 802.11 b/g/n IoT link controller module. The
>> WILC1000 connects to Microchip AVR/SMART MCUs, SMART MPUs, and other
>> processors with minimal resource requirements with a simple
>> SPI/SDIO-to-Wi-Fi interface.
>>
>> WILC1000 driver has been part of staging for few years. With
>> contributions from the community, it has improved significantly. Full
>> driver review has helped in achieving the current state.
>> The details for those reviews are captured in 1 & 2.
>>
>> [1]. 
>> https://lore.kernel.org/linux-wireless/1537957525-11467-1-git-send-email-ajay.kat...@microchip.com/
>> [2]. 
>> https://lore.kernel.org/linux-wireless/1562896697-8002-1-git-send-email-ajay.kat...@microchip.com/
>>
>> Signed-off-by: Ajay Singh 
>> ---
>>
>> As suggested, keeping all the changes in single commit with file rename
>> so it's easy to move out of staging [3].
>>
>> Please choose whichever option you prefer between the git mv or patch series
>> sent last Tuesday. The resulting driver is the same as no patch has been
>> queued in between.
>>
>> [3]. 
>> https://lore.kernel.org/linux-wireless/2020062311.31559-1-ajay.kat...@microchip.com/
> 
> As discussed with Greg I created an immutable branch for this and merged
> the branch to wireless-drivers-next:

Thanks Kalle.


If my understanding is correct, we have to use 'wireless-driver-next'
master branch to submit new patches for wilc1000. right?

> 
> 5625f965d764 wilc1000: move wilc driver out of staging
> 
> Greg, here's the location of the immutable branch:
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git 
> wilc1000-move-out-of-staging
> 
> --
> https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] wilc1000: move wilc driver out of staging

2020-07-02 Thread Ajay.Kathat



On 02/07/20 12:45 pm, Greg KH wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the 
> content is safe
> 
> On Thu, Jul 02, 2020 at 10:00:40AM +0300, Kalle Valo wrote:
>>  writes:
>>
>>> From: Ajay Singh 
>>>
>>> WILC1000 is an IEEE 802.11 b/g/n IoT link controller module. The
>>> WILC1000 connects to Microchip AVR/SMART MCUs, SMART MPUs, and other
>>> processors with minimal resource requirements with a simple
>>> SPI/SDIO-to-Wi-Fi interface.
>>>
>>> WILC1000 driver has been part of staging for few years. With
>>> contributions from the community, it has improved significantly. Full
>>> driver review has helped in achieving the current state.
>>> The details for those reviews are captured in 1 & 2.
>>>
>>> [1]. 
>>> https://lore.kernel.org/linux-wireless/1537957525-11467-1-git-send-email-ajay.kat...@microchip.com/
>>> [2]. 
>>> https://lore.kernel.org/linux-wireless/1562896697-8002-1-git-send-email-ajay.kat...@microchip.com/
>>>
>>> Signed-off-by: Ajay Singh 
>>> ---
>>>
>>> As suggested, keeping all the changes in single commit with file rename
>>> so it's easy to move out of staging [3].
>>>
>>> Please choose whichever option you prefer between the git mv or patch series
>>> sent last Tuesday. The resulting driver is the same as no patch has been
>>> queued in between.
>>>
>>> [3]. 
>>> https://lore.kernel.org/linux-wireless/2020062311.31559-1-ajay.kat...@microchip.com/
>>
>> As discussed with Greg I created an immutable branch for this and merged
>> the branch to wireless-drivers-next:
>>
>> 5625f965d764 wilc1000: move wilc driver out of staging
>>
>> Greg, here's the location of the immutable branch:
>>
>> git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git
>>  wilc1000-move-out-of-staging
> 
> Looks good, I've pulled it into my staging tree as well, but there's
> still a TODO file left in drivers/staging/wilc1000, right?
> 
> I'll just add a patch to my tree to remove that last file.
> 

Yes, TODO file needs to be removed after the driver movement.
Thanks Greg for all your support to move driver out of staging.

Regards,
Ajay
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v7 00/17] wilc1000: move out of staging

2020-06-30 Thread Ajay.Kathat


On 29/06/20 6:56 pm, Pali Rohár wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the 
> content is safe
> 
> On Tuesday 23 June 2020 11:00:04 ajay.kat...@microchip.com wrote:
>> This patch series is to review and move wilc1000 driver out of staging.
>> Most of the review comments received in [1] & [2] are addressed in the
>> latest code.
>> Please review and provide your inputs.
> 
> Hello Ajay! Could you please move SDIO vendor/device ID definitions from
> driver code wilc1000/sdio.c to common file include/linux/mmc/sdio_ids.h?
> 

Currently, the wilc1000 driver movement changes are present in topic
branch and yet to be merged to master branch. Would it be okay to submit
the new patch once driver is merged to 'wireless-driver-next' master and
branch is pulled into Greg's staging repo.

Regards,
Ajay

> Similar cleanup was recently finished for all existing non-staging drivers:
> https://lore.kernel.org/linux-mmc/20200522144412.19712-1-p...@kernel.org/
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] wilc1000: move wilc driver out of staging

2020-06-26 Thread Ajay.Kathat



On 26/06/20 11:21 am, Kalle Valo wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the 
> content is safe
> 
>  writes:
> 
>> From: Ajay Singh 
>>
>> WILC1000 is an IEEE 802.11 b/g/n IoT link controller module. The
>> WILC1000 connects to Microchip AVR/SMART MCUs, SMART MPUs, and other
>> processors with minimal resource requirements with a simple
>> SPI/SDIO-to-Wi-Fi interface.
>>
>> WILC1000 driver has been part of staging for few years. With
>> contributions from the community, it has improved significantly. Full
>> driver review has helped in achieving the current state.
>> The details for those reviews are captured in 1 & 2.
>>
>> [1]. 
>> https://lore.kernel.org/linux-wireless/1537957525-11467-1-git-send-email-ajay.kat...@microchip.com/
>> [2]. 
>> https://lore.kernel.org/linux-wireless/1562896697-8002-1-git-send-email-ajay.kat...@microchip.com/
>>
>> Signed-off-by: Ajay Singh 
> 
> [...]
> 
>> --- a/drivers/net/wireless/Kconfig
>> +++ b/drivers/net/wireless/Kconfig
>> @@ -47,6 +47,7 @@ source "drivers/net/wireless/st/Kconfig"
>>  source "drivers/net/wireless/ti/Kconfig"
>>  source "drivers/net/wireless/zydas/Kconfig"
>>  source "drivers/net/wireless/quantenna/Kconfig"
>> +source "drivers/net/wireless/microchip/Kconfig"
> 
> This should be in alphabetical order.
> 
>> --- a/drivers/net/wireless/Makefile
>> +++ b/drivers/net/wireless/Makefile
>> @@ -19,6 +19,7 @@ obj-$(CONFIG_WLAN_VENDOR_ST) += st/
>>  obj-$(CONFIG_WLAN_VENDOR_TI) += ti/
>>  obj-$(CONFIG_WLAN_VENDOR_ZYDAS) += zydas/
>>  obj-$(CONFIG_WLAN_VENDOR_QUANTENNA) += quantenna/
>> +obj-$(CONFIG_WLAN_VENDOR_MICROCHIP) += microchip/
> 
> And this as well.
> 
> I fixed these in the topic branch, please double check:


Thanks Kalle.
I just checked the patch and it looks good.

Regards,
Ajay


> 
> https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git/commit/?h=wilc1000-move-out-of-staging=5625f965d7644b4dc6a71d74021cfe093ad34eea
> 
> I have not pulled that branch yet into master so we can make changes
> still.>
> --
> https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] wilc1000: move wilc driver out of staging

2020-06-25 Thread Ajay.Kathat
From: Ajay Singh 

WILC1000 is an IEEE 802.11 b/g/n IoT link controller module. The
WILC1000 connects to Microchip AVR/SMART MCUs, SMART MPUs, and other
processors with minimal resource requirements with a simple
SPI/SDIO-to-Wi-Fi interface.

WILC1000 driver has been part of staging for few years. With
contributions from the community, it has improved significantly. Full
driver review has helped in achieving the current state.
The details for those reviews are captured in 1 & 2.

[1]. 
https://lore.kernel.org/linux-wireless/1537957525-11467-1-git-send-email-ajay.kat...@microchip.com/
[2]. 
https://lore.kernel.org/linux-wireless/1562896697-8002-1-git-send-email-ajay.kat...@microchip.com/

Signed-off-by: Ajay Singh 
---

As suggested, keeping all the changes in single commit with file rename
so it's easy to move out of staging [3].

Please choose whichever option you prefer between the git mv or patch series
sent last Tuesday. The resulting driver is the same as no patch has been
queued in between.

[3]. 
https://lore.kernel.org/linux-wireless/2020062311.31559-1-ajay.kat...@microchip.com/

 .../net/wireless}/microchip,wilc1000.yaml |  0
 MAINTAINERS   | 14 +++---
 drivers/net/wireless/Kconfig  |  1 +
 drivers/net/wireless/Makefile |  1 +
 drivers/net/wireless/microchip/Kconfig| 15 +++
 drivers/net/wireless/microchip/Makefile   |  2 ++
 .../wireless/microchip}/wilc1000/Kconfig  |  0
 .../wireless/microchip}/wilc1000/Makefile |  0
 .../wireless/microchip}/wilc1000/cfg80211.c   |  0
 .../wireless/microchip}/wilc1000/cfg80211.h   |  0
 .../wireless/microchip}/wilc1000/fw.h |  0
 .../wireless/microchip}/wilc1000/hif.c|  0
 .../wireless/microchip}/wilc1000/hif.h|  0
 .../wireless/microchip}/wilc1000/mon.c|  0
 .../wireless/microchip}/wilc1000/netdev.c |  0
 .../wireless/microchip}/wilc1000/netdev.h |  0
 .../wireless/microchip}/wilc1000/sdio.c   |  0
 .../wireless/microchip}/wilc1000/spi.c|  0
 .../wireless/microchip}/wilc1000/wlan.c   |  0
 .../wireless/microchip}/wilc1000/wlan.h   |  0
 .../wireless/microchip}/wilc1000/wlan_cfg.c   |  0
 .../wireless/microchip}/wilc1000/wlan_cfg.h   |  0
 .../wireless/microchip}/wilc1000/wlan_if.h|  0
 drivers/staging/Kconfig   |  2 --
 drivers/staging/Makefile  |  1 -
 25 files changed, 26 insertions(+), 10 deletions(-)
 rename {drivers/staging/wilc1000 => 
Documentation/devicetree/bindings/net/wireless}/microchip,wilc1000.yaml (100%)
 create mode 100644 drivers/net/wireless/microchip/Kconfig
 create mode 100644 drivers/net/wireless/microchip/Makefile
 rename drivers/{staging => net/wireless/microchip}/wilc1000/Kconfig (100%)
 rename drivers/{staging => net/wireless/microchip}/wilc1000/Makefile (100%)
 rename drivers/{staging => net/wireless/microchip}/wilc1000/cfg80211.c (100%)
 rename drivers/{staging => net/wireless/microchip}/wilc1000/cfg80211.h (100%)
 rename drivers/{staging => net/wireless/microchip}/wilc1000/fw.h (100%)
 rename drivers/{staging => net/wireless/microchip}/wilc1000/hif.c (100%)
 rename drivers/{staging => net/wireless/microchip}/wilc1000/hif.h (100%)
 rename drivers/{staging => net/wireless/microchip}/wilc1000/mon.c (100%)
 rename drivers/{staging => net/wireless/microchip}/wilc1000/netdev.c (100%)
 rename drivers/{staging => net/wireless/microchip}/wilc1000/netdev.h (100%)
 rename drivers/{staging => net/wireless/microchip}/wilc1000/sdio.c (100%)
 rename drivers/{staging => net/wireless/microchip}/wilc1000/spi.c (100%)
 rename drivers/{staging => net/wireless/microchip}/wilc1000/wlan.c (100%)
 rename drivers/{staging => net/wireless/microchip}/wilc1000/wlan.h (100%)
 rename drivers/{staging => net/wireless/microchip}/wilc1000/wlan_cfg.c (100%)
 rename drivers/{staging => net/wireless/microchip}/wilc1000/wlan_cfg.h (100%)
 rename drivers/{staging => net/wireless/microchip}/wilc1000/wlan_if.h (100%)

diff --git a/drivers/staging/wilc1000/microchip,wilc1000.yaml 
b/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml
similarity index 100%
rename from drivers/staging/wilc1000/microchip,wilc1000.yaml
rename to Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml
diff --git a/MAINTAINERS b/MAINTAINERS
index 68f21d46614c..7dae51e32254 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11362,6 +11362,13 @@ L: linux-arm-ker...@lists.infradead.org (moderated 
for non-subscribers)
 S: Supported
 F: drivers/usb/gadget/udc/atmel_usba_udc.*
 
+MICROCHIP WILC1000 WIFI DRIVER
+M: Adham Abozaeid 
+M: Ajay Singh 
+L: linux-wirel...@vger.kernel.org
+S: Supported
+F: drivers/net/wireless/microchip/wilc1000/
+
 MICROCHIP XDMA DRIVER
 M: Ludovic Desroches 
 L: 

Re: [PATCH v7 17/17] wilc1000: add Makefile and Kconfig files for wilc1000 compilation

2020-06-24 Thread Ajay.Kathat



On 23/06/20 8:22 pm, kernel test robot wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the 
> content is safe
> 
> Hi,
> 
> I love your patch! Perhaps something to improve:
> 
> [auto build test WARNING on a15a20acc980342c97d804c5fae1cfc0cd7712a9]
> 
> url:
> https://github.com/0day-ci/linux/commits/Ajay-Kathat-microchip-com/wilc1000-move-out-of-staging/20200623-190333
> base:a15a20acc980342c97d804c5fae1cfc0cd7712a9
> config: ia64-allmodconfig (attached as .config)
> compiler: ia64-linux-gcc (GCC) 9.3.0
> reproduce (this is a W=1 build):
> wget 
> https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
> ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # save the attached .config to linux build tree
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross 
> ARCH=ia64
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot 
> 
> All warnings (new ones prefixed by >>):
> 
>drivers/net/wireless/microchip/wilc1000/mon.c: In function 
> 'wilc_wfi_init_mon_interface':
>>> drivers/net/wireless/microchip/wilc1000/mon.c:232:2: warning: 'strncpy' 
>>> specified bound 16 equals destination size [-Wstringop-truncation]
>  232 |  strncpy(wl->monitor_dev->name, name, IFNAMSIZ);
>  |  ^~

Though replacing 'strncpy' with 'strlcpy' will help to suppress this
warning but not sure if its true alarm because next line sets NULL
termination for string.
I agree 'strlcpy' is better candidate here and reduces one extra line.

> 
> vim +/strncpy +232 drivers/net/wireless/microchip/wilc1000/mon.c
> 
> daf8b5f14a7066 Ajay Singh 2020-06-23  216
> daf8b5f14a7066 Ajay Singh 2020-06-23  217  struct net_device 
> *wilc_wfi_init_mon_interface(struct wilc *wl,
> daf8b5f14a7066 Ajay Singh 2020-06-23  218 
>  const char *name,
> daf8b5f14a7066 Ajay Singh 2020-06-23  219 
>  struct net_device *real_dev)
> daf8b5f14a7066 Ajay Singh 2020-06-23  220  {
> daf8b5f14a7066 Ajay Singh 2020-06-23  221   struct wilc_wfi_mon_priv 
> *priv;
> daf8b5f14a7066 Ajay Singh 2020-06-23  222
> daf8b5f14a7066 Ajay Singh 2020-06-23  223   /* If monitor interface is 
> already initialized, return it */
> daf8b5f14a7066 Ajay Singh 2020-06-23  224   if (wl->monitor_dev)
> daf8b5f14a7066 Ajay Singh 2020-06-23  225   return 
> wl->monitor_dev;
> daf8b5f14a7066 Ajay Singh 2020-06-23  226
> daf8b5f14a7066 Ajay Singh 2020-06-23  227   wl->monitor_dev = 
> alloc_etherdev(sizeof(struct wilc_wfi_mon_priv));
> daf8b5f14a7066 Ajay Singh 2020-06-23  228   if (!wl->monitor_dev)
> daf8b5f14a7066 Ajay Singh 2020-06-23  229   return NULL;
> daf8b5f14a7066 Ajay Singh 2020-06-23  230
> daf8b5f14a7066 Ajay Singh 2020-06-23  231   wl->monitor_dev->type = 
> ARPHRD_IEEE80211_RADIOTAP;
> daf8b5f14a7066 Ajay Singh 2020-06-23 @232   
> strncpy(wl->monitor_dev->name, name, IFNAMSIZ);
> daf8b5f14a7066 Ajay Singh 2020-06-23  233   
> wl->monitor_dev->name[IFNAMSIZ - 1] = 0;
> daf8b5f14a7066 Ajay Singh 2020-06-23  234   wl->monitor_dev->netdev_ops = 
> _wfi_netdev_ops;
> daf8b5f14a7066 Ajay Singh 2020-06-23  235   
> wl->monitor_dev->needs_free_netdev = true;
> daf8b5f14a7066 Ajay Singh 2020-06-23  236
> daf8b5f14a7066 Ajay Singh 2020-06-23  237   if 
> (register_netdevice(wl->monitor_dev)) {
> daf8b5f14a7066 Ajay Singh 2020-06-23  238   netdev_err(real_dev, 
> "register_netdevice failed\n");
> daf8b5f14a7066 Ajay Singh 2020-06-23  239   return NULL;
> daf8b5f14a7066 Ajay Singh 2020-06-23  240   }
> daf8b5f14a7066 Ajay Singh 2020-06-23  241   priv = 
> netdev_priv(wl->monitor_dev);
> daf8b5f14a7066 Ajay Singh 2020-06-23  242   if (!priv)
> daf8b5f14a7066 Ajay Singh 2020-06-23  243   return NULL;
> daf8b5f14a7066 Ajay Singh 2020-06-23  244
> daf8b5f14a7066 Ajay Singh 2020-06-23  245   priv->real_ndev = real_dev;
> daf8b5f14a7066 Ajay Singh 2020-06-23  246
> daf8b5f14a7066 Ajay Singh 2020-06-23  247   return wl->monitor_dev;
> daf8b5f14a7066 Ajay Singh 2020-06-23  248  }
> daf8b5f14a7066 Ajay Singh 2020-06-23  249
> 
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v7 13/17] wilc1000: add wlan.c

2020-06-23 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/wlan.c' to
'drivers/net/wireless/microchip/wilc1000/wlan.c'.

Signed-off-by: Ajay Singh 
---
 .../net/wireless/microchip/wilc1000/wlan.c| 1238 +
 1 file changed, 1238 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/wlan.c

diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c 
b/drivers/net/wireless/microchip/wilc1000/wlan.c
new file mode 100644
index ..6a82fb2f283e
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/wlan.c
@@ -0,0 +1,1238 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#include 
+#include 
+#include "cfg80211.h"
+#include "wlan_cfg.h"
+
+static inline bool is_wilc1000(u32 id)
+{
+   return (id & (~WILC_CHIP_REV_FIELD)) == WILC_1000_BASE_ID;
+}
+
+static inline void acquire_bus(struct wilc *wilc, enum bus_acquire acquire)
+{
+   mutex_lock(>hif_cs);
+   if (acquire == WILC_BUS_ACQUIRE_AND_WAKEUP)
+   chip_wakeup(wilc);
+}
+
+static inline void release_bus(struct wilc *wilc, enum bus_release release)
+{
+   if (release == WILC_BUS_RELEASE_ALLOW_SLEEP)
+   chip_allow_sleep(wilc);
+   mutex_unlock(>hif_cs);
+}
+
+static void wilc_wlan_txq_remove(struct wilc *wilc, struct txq_entry_t *tqe)
+{
+   list_del(>list);
+   wilc->txq_entries -= 1;
+}
+
+static struct txq_entry_t *
+wilc_wlan_txq_remove_from_head(struct net_device *dev)
+{
+   struct txq_entry_t *tqe = NULL;
+   unsigned long flags;
+   struct wilc_vif *vif = netdev_priv(dev);
+   struct wilc *wilc = vif->wilc;
+
+   spin_lock_irqsave(>txq_spinlock, flags);
+
+   if (!list_empty(>txq_head.list)) {
+   tqe = list_first_entry(>txq_head.list, struct txq_entry_t,
+  list);
+   list_del(>list);
+   wilc->txq_entries -= 1;
+   }
+   spin_unlock_irqrestore(>txq_spinlock, flags);
+   return tqe;
+}
+
+static void wilc_wlan_txq_add_to_tail(struct net_device *dev,
+ struct txq_entry_t *tqe)
+{
+   unsigned long flags;
+   struct wilc_vif *vif = netdev_priv(dev);
+   struct wilc *wilc = vif->wilc;
+
+   spin_lock_irqsave(>txq_spinlock, flags);
+
+   list_add_tail(>list, >txq_head.list);
+   wilc->txq_entries += 1;
+
+   spin_unlock_irqrestore(>txq_spinlock, flags);
+
+   complete(>txq_event);
+}
+
+static void wilc_wlan_txq_add_to_head(struct wilc_vif *vif,
+ struct txq_entry_t *tqe)
+{
+   unsigned long flags;
+   struct wilc *wilc = vif->wilc;
+
+   mutex_lock(>txq_add_to_head_cs);
+
+   spin_lock_irqsave(>txq_spinlock, flags);
+
+   list_add(>list, >txq_head.list);
+   wilc->txq_entries += 1;
+
+   spin_unlock_irqrestore(>txq_spinlock, flags);
+   mutex_unlock(>txq_add_to_head_cs);
+   complete(>txq_event);
+}
+
+#define NOT_TCP_ACK(-1)
+
+static inline void add_tcp_session(struct wilc_vif *vif, u32 src_prt,
+  u32 dst_prt, u32 seq)
+{
+   struct tcp_ack_filter *f = >ack_filter;
+
+   if (f->tcp_session < 2 * MAX_TCP_SESSION) {
+   f->ack_session_info[f->tcp_session].seq_num = seq;
+   f->ack_session_info[f->tcp_session].bigger_ack_num = 0;
+   f->ack_session_info[f->tcp_session].src_port = src_prt;
+   f->ack_session_info[f->tcp_session].dst_port = dst_prt;
+   f->tcp_session++;
+   }
+}
+
+static inline void update_tcp_session(struct wilc_vif *vif, u32 index, u32 ack)
+{
+   struct tcp_ack_filter *f = >ack_filter;
+
+   if (index < 2 * MAX_TCP_SESSION &&
+   ack > f->ack_session_info[index].bigger_ack_num)
+   f->ack_session_info[index].bigger_ack_num = ack;
+}
+
+static inline void add_tcp_pending_ack(struct wilc_vif *vif, u32 ack,
+  u32 session_index,
+  struct txq_entry_t *txqe)
+{
+   struct tcp_ack_filter *f = >ack_filter;
+   u32 i = f->pending_base + f->pending_acks_idx;
+
+   if (i < MAX_PENDING_ACKS) {
+   f->pending_acks[i].ack_num = ack;
+   f->pending_acks[i].txqe = txqe;
+   f->pending_acks[i].session_index = session_index;
+   txqe->ack_idx = i;
+   f->pending_acks_idx++;
+   }
+}
+
+static inline void tcp_process(struct net_device *dev, struct txq_entry_t *tqe)
+{
+   void *buffer = tqe->buffer;
+   const struct ethhdr *eth_hdr_ptr = buffer;
+   int i;
+   unsigned long flags;
+   struct wilc_vif *vif = netdev_priv(dev);
+   struct wilc *wilc = vif->wilc;
+   struct tcp_ack_filter *f = >ack_filter;
+   const struct iphdr *ip_hdr_ptr;
+   const struct tcphdr *tcp_hdr_ptr;
+  

[PATCH v7 11/17] wilc1000: add spi.c

2020-06-23 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/spi.c' to
'drivers/net/wireless/microchip/wilc1000/spi.c'.

Signed-off-by: Ajay Singh 
---
 drivers/net/wireless/microchip/wilc1000/spi.c | 945 ++
 1 file changed, 945 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/spi.c

diff --git a/drivers/net/wireless/microchip/wilc1000/spi.c 
b/drivers/net/wireless/microchip/wilc1000/spi.c
new file mode 100644
index ..3f19e3f38a39
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/spi.c
@@ -0,0 +1,945 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+
+#include "netdev.h"
+#include "cfg80211.h"
+
+struct wilc_spi {
+   int crc_off;
+};
+
+static const struct wilc_hif_func wilc_hif_spi;
+
+/
+ *
+ *  Spi protocol Function
+ *
+ /
+
+#define CMD_DMA_WRITE  0xc1
+#define CMD_DMA_READ   0xc2
+#define CMD_INTERNAL_WRITE 0xc3
+#define CMD_INTERNAL_READ  0xc4
+#define CMD_TERMINATE  0xc5
+#define CMD_REPEAT 0xc6
+#define CMD_DMA_EXT_WRITE  0xc7
+#define CMD_DMA_EXT_READ   0xc8
+#define CMD_SINGLE_WRITE   0xc9
+#define CMD_SINGLE_READ0xca
+#define CMD_RESET  0xcf
+
+#define DATA_PKT_SZ_256256
+#define DATA_PKT_SZ_512512
+#define DATA_PKT_SZ_1K 1024
+#define DATA_PKT_SZ_4K (4 * 1024)
+#define DATA_PKT_SZ_8K (8 * 1024)
+#define DATA_PKT_SZDATA_PKT_SZ_8K
+
+#define USE_SPI_DMA0
+
+#define WILC_SPI_COMMAND_STAT_SUCCESS  0
+#define WILC_GET_RESP_HDR_START(h) (((h) >> 4) & 0xf)
+
+struct wilc_spi_cmd {
+   u8 cmd_type;
+   union {
+   struct {
+   u8 addr[3];
+   u8 crc[];
+   } __packed simple_cmd;
+   struct {
+   u8 addr[3];
+   u8 size[2];
+   u8 crc[];
+   } __packed dma_cmd;
+   struct {
+   u8 addr[3];
+   u8 size[3];
+   u8 crc[];
+   } __packed dma_cmd_ext;
+   struct {
+   u8 addr[2];
+   __be32 data;
+   u8 crc[];
+   } __packed internal_w_cmd;
+   struct {
+   u8 addr[3];
+   __be32 data;
+   u8 crc[];
+   } __packed w_cmd;
+   } u;
+} __packed;
+
+struct wilc_spi_read_rsp_data {
+   u8 rsp_cmd_type;
+   u8 status;
+   u8 resp_header;
+   u8 resp_data[4];
+   u8 crc[];
+} __packed;
+
+struct wilc_spi_rsp_data {
+   u8 rsp_cmd_type;
+   u8 status;
+} __packed;
+
+static int wilc_bus_probe(struct spi_device *spi)
+{
+   int ret;
+   struct wilc *wilc;
+   struct wilc_spi *spi_priv;
+
+   spi_priv = kzalloc(sizeof(*spi_priv), GFP_KERNEL);
+   if (!spi_priv)
+   return -ENOMEM;
+
+   ret = wilc_cfg80211_init(, >dev, WILC_HIF_SPI, _hif_spi);
+   if (ret) {
+   kfree(spi_priv);
+   return ret;
+   }
+
+   spi_set_drvdata(spi, wilc);
+   wilc->dev = >dev;
+   wilc->bus_data = spi_priv;
+   wilc->dev_irq_num = spi->irq;
+
+   wilc->rtc_clk = devm_clk_get(>dev, "rtc_clk");
+   if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER)
+   return -EPROBE_DEFER;
+   else if (!IS_ERR(wilc->rtc_clk))
+   clk_prepare_enable(wilc->rtc_clk);
+
+   return 0;
+}
+
+static int wilc_bus_remove(struct spi_device *spi)
+{
+   struct wilc *wilc = spi_get_drvdata(spi);
+
+   if (!IS_ERR(wilc->rtc_clk))
+   clk_disable_unprepare(wilc->rtc_clk);
+
+   wilc_netdev_cleanup(wilc);
+   return 0;
+}
+
+static const struct of_device_id wilc_of_match[] = {
+   { .compatible = "microchip,wilc1000", },
+   { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, wilc_of_match);
+
+static struct spi_driver wilc_spi_driver = {
+   .driver = {
+   .name = MODALIAS,
+   .of_match_table = wilc_of_match,
+   },
+   .probe =  wilc_bus_probe,
+   .remove = wilc_bus_remove,
+};
+module_spi_driver(wilc_spi_driver);
+MODULE_LICENSE("GPL");
+
+static int wilc_spi_tx(struct wilc *wilc, u8 *b, u32 len)
+{
+   struct spi_device *spi = to_spi_device(wilc->dev);
+   int ret;
+   struct 

[PATCH v7 12/17] wilc1000: add wlan.h

2020-06-23 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/wlan.h' to
'drivers/net/wireless/microchip/wilc1000/wlan.h'.

Signed-off-by: Ajay Singh 
---
 .../net/wireless/microchip/wilc1000/wlan.h| 397 ++
 1 file changed, 397 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/wlan.h

diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.h 
b/drivers/net/wireless/microchip/wilc1000/wlan.h
new file mode 100644
index ..7689569cd82f
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/wlan.h
@@ -0,0 +1,397 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#ifndef WILC_WLAN_H
+#define WILC_WLAN_H
+
+#include 
+#include 
+
+/
+ *
+ *  Mac eth header length
+ *
+ /
+#define MAX_MAC_HDR_LEN26 /* QOS_MAC_HDR_LEN */
+#define SUB_MSDU_HEADER_LENGTH 14
+#define SNAP_HDR_LEN   8
+#define ETHERNET_HDR_LEN   14
+#define WORD_ALIGNMENT_PAD 0
+
+#define ETH_ETHERNET_HDR_OFFSET(MAX_MAC_HDR_LEN + \
+SUB_MSDU_HEADER_LENGTH + \
+SNAP_HDR_LEN - \
+ETHERNET_HDR_LEN + \
+WORD_ALIGNMENT_PAD)
+
+#define HOST_HDR_OFFSET4
+#define ETHERNET_HDR_LEN   14
+#define IP_HDR_LEN 20
+#define IP_HDR_OFFSET  ETHERNET_HDR_LEN
+#define UDP_HDR_OFFSET (IP_HDR_LEN + IP_HDR_OFFSET)
+#define UDP_HDR_LEN8
+#define UDP_DATA_OFFSET(UDP_HDR_OFFSET + UDP_HDR_LEN)
+#define ETH_CONFIG_PKT_HDR_LEN UDP_DATA_OFFSET
+
+#define ETH_CONFIG_PKT_HDR_OFFSET  (ETH_ETHERNET_HDR_OFFSET + \
+ETH_CONFIG_PKT_HDR_LEN)
+
+/
+ *
+ *  Register Defines
+ *
+ /
+#define WILC_PERIPH_REG_BASE   0x1000
+#define WILC_CHANGING_VIR_IF   0x108c
+#define WILC_CHIPIDWILC_PERIPH_REG_BASE
+#define WILC_GLB_RESET_0   (WILC_PERIPH_REG_BASE + 0x400)
+#define WILC_PIN_MUX_0 (WILC_PERIPH_REG_BASE + 0x408)
+#define WILC_HOST_TX_CTRL  (WILC_PERIPH_REG_BASE + 0x6c)
+#define WILC_HOST_RX_CTRL_0(WILC_PERIPH_REG_BASE + 0x70)
+#define WILC_HOST_RX_CTRL_1(WILC_PERIPH_REG_BASE + 0x74)
+#define WILC_HOST_VMM_CTL  (WILC_PERIPH_REG_BASE + 0x78)
+#define WILC_HOST_RX_CTRL  (WILC_PERIPH_REG_BASE + 0x80)
+#define WILC_HOST_RX_EXTRA_SIZE(WILC_PERIPH_REG_BASE + 0x84)
+#define WILC_HOST_TX_CTRL_1(WILC_PERIPH_REG_BASE + 0x88)
+#define WILC_MISC  (WILC_PERIPH_REG_BASE + 0x428)
+#define WILC_INTR_REG_BASE (WILC_PERIPH_REG_BASE + 0xa00)
+#define WILC_INTR_ENABLE   WILC_INTR_REG_BASE
+#define WILC_INTR2_ENABLE  (WILC_INTR_REG_BASE + 4)
+
+#define WILC_INTR_POLARITY (WILC_INTR_REG_BASE + 0x10)
+#define WILC_INTR_TYPE (WILC_INTR_REG_BASE + 0x20)
+#define WILC_INTR_CLEAR(WILC_INTR_REG_BASE + 0x30)
+#define WILC_INTR_STATUS   (WILC_INTR_REG_BASE + 0x40)
+
+#define WILC_RF_REVISION_ID0x13f4
+
+#define WILC_VMM_TBL_SIZE  64
+#define WILC_VMM_TX_TBL_BASE   0x150400
+#define WILC_VMM_RX_TBL_BASE   0x150500
+
+#define WILC_VMM_BASE  0x15
+#define WILC_VMM_CORE_CTL  WILC_VMM_BASE
+#define WILC_VMM_TBL_CTL   (WILC_VMM_BASE + 0x4)
+#define WILC_VMM_TBL_ENTRY (WILC_VMM_BASE + 0x8)
+#define WILC_VMM_TBL0_SIZE (WILC_VMM_BASE + 0xc)
+#define WILC_VMM_TO_HOST_SIZE  (WILC_VMM_BASE + 0x10)
+#define WILC_VMM_CORE_CFG  (WILC_VMM_BASE + 0x14)
+#define WILC_VMM_TBL_ACTIVE(WILC_VMM_BASE + 040)
+#define WILC_VMM_TBL_STATUS(WILC_VMM_BASE + 0x44)
+
+#define WILC_SPI_REG_BASE  0xe800
+#define WILC_SPI_CTL   WILC_SPI_REG_BASE
+#define WILC_SPI_MASTER_DMA_ADDR   (WILC_SPI_REG_BASE + 0x4)
+#define WILC_SPI_MASTER_DMA_COUNT  (WILC_SPI_REG_BASE + 0x8)
+#define WILC_SPI_SLAVE_DMA_ADDR(WILC_SPI_REG_BASE + 0xc)
+#define WILC_SPI_SLAVE_DMA_COUNT   (WILC_SPI_REG_BASE + 0x10)
+#define WILC_SPI_TX_MODE   (WILC_SPI_REG_BASE + 0x20)
+#define WILC_SPI_PROTOCOL_CONFIG   (WILC_SPI_REG_BASE + 0x24)
+#define WILC_SPI_INTR_CTL  (WILC_SPI_REG_BASE + 0x2c)
+#define WILC_SPI_INT_STATUS(WILC_SPI_REG_BASE + 0x40)
+#define WILC_SPI_INT_CLEAR (WILC_SPI_REG_BASE + 0x44)
+
+#define 

[PATCH v7 08/17] wilc1000: add netdev.h

2020-06-23 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/netdev.h' to
'drivers/net/wireless/microchip/wilc1000/netdev.h'.

Signed-off-by: Ajay Singh 
---
 .../net/wireless/microchip/wilc1000/netdev.h  | 287 ++
 1 file changed, 287 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/netdev.h

diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.h 
b/drivers/net/wireless/microchip/wilc1000/netdev.h
new file mode 100644
index ..d0a006b68d08
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/netdev.h
@@ -0,0 +1,287 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#ifndef WILC_NETDEV_H
+#define WILC_NETDEV_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "hif.h"
+#include "wlan.h"
+#include "wlan_cfg.h"
+
+#define FLOW_CONTROL_LOWER_THRESHOLD   128
+#define FLOW_CONTROL_UPPER_THRESHOLD   256
+
+#define PMKID_FOUND1
+#define NUM_STA_ASSOCIATED 8
+
+#define TCP_ACK_FILTER_LINK_SPEED_THRESH   54
+#define DEFAULT_LINK_SPEED 72
+
+struct wilc_wfi_stats {
+   unsigned long rx_packets;
+   unsigned long tx_packets;
+   unsigned long rx_bytes;
+   unsigned long tx_bytes;
+   u64 rx_time;
+   u64 tx_time;
+
+};
+
+struct wilc_wfi_key {
+   u8 *key;
+   u8 *seq;
+   int key_len;
+   int seq_len;
+   u32 cipher;
+};
+
+struct wilc_wfi_wep_key {
+   u8 *key;
+   u8 key_len;
+   u8 key_idx;
+};
+
+struct sta_info {
+   u8 sta_associated_bss[WILC_MAX_NUM_STA][ETH_ALEN];
+};
+
+/* Parameters needed for host interface for remaining on channel */
+struct wilc_wfi_p2p_listen_params {
+   struct ieee80211_channel *listen_ch;
+   u32 listen_duration;
+   u64 listen_cookie;
+};
+
+static const u32 wilc_cipher_suites[] = {
+   WLAN_CIPHER_SUITE_WEP40,
+   WLAN_CIPHER_SUITE_WEP104,
+   WLAN_CIPHER_SUITE_TKIP,
+   WLAN_CIPHER_SUITE_CCMP,
+   WLAN_CIPHER_SUITE_AES_CMAC
+};
+
+#define CHAN2G(_channel, _freq, _flags) {   \
+   .band = NL80211_BAND_2GHZ, \
+   .center_freq  = (_freq), \
+   .hw_value = (_channel),  \
+   .flags= (_flags),\
+   .max_antenna_gain = 0,   \
+   .max_power= 30,  \
+}
+
+static const struct ieee80211_channel wilc_2ghz_channels[] = {
+   CHAN2G(1,  2412, 0),
+   CHAN2G(2,  2417, 0),
+   CHAN2G(3,  2422, 0),
+   CHAN2G(4,  2427, 0),
+   CHAN2G(5,  2432, 0),
+   CHAN2G(6,  2437, 0),
+   CHAN2G(7,  2442, 0),
+   CHAN2G(8,  2447, 0),
+   CHAN2G(9,  2452, 0),
+   CHAN2G(10, 2457, 0),
+   CHAN2G(11, 2462, 0),
+   CHAN2G(12, 2467, 0),
+   CHAN2G(13, 2472, 0),
+   CHAN2G(14, 2484, 0)
+};
+
+#define RATETAB_ENT(_rate, _hw_value, _flags) {\
+   .bitrate  = (_rate),\
+   .hw_value = (_hw_value),\
+   .flags= (_flags),   \
+}
+
+static struct ieee80211_rate wilc_bitrates[] = {
+   RATETAB_ENT(10,  0,  0),
+   RATETAB_ENT(20,  1,  0),
+   RATETAB_ENT(55,  2,  0),
+   RATETAB_ENT(110, 3,  0),
+   RATETAB_ENT(60,  9,  0),
+   RATETAB_ENT(90,  6,  0),
+   RATETAB_ENT(120, 7,  0),
+   RATETAB_ENT(180, 8,  0),
+   RATETAB_ENT(240, 9,  0),
+   RATETAB_ENT(360, 10, 0),
+   RATETAB_ENT(480, 11, 0),
+   RATETAB_ENT(540, 12, 0)
+};
+
+struct wilc_priv {
+   struct wireless_dev wdev;
+   struct cfg80211_scan_request *scan_req;
+
+   struct wilc_wfi_p2p_listen_params remain_on_ch_params;
+   u64 tx_cookie;
+
+   bool cfg_scanning;
+
+   u8 associated_bss[ETH_ALEN];
+   struct sta_info assoc_stainfo;
+   struct sk_buff *skb;
+   struct net_device *dev;
+   struct host_if_drv *hif_drv;
+   struct wilc_pmkid_attr pmkid_list;
+   u8 wep_key[4][WLAN_KEY_LEN_WEP104];
+   u8 wep_key_len[4];
+
+   /* The real interface that the monitor is on */
+   struct net_device *real_ndev;
+   struct wilc_wfi_key *wilc_gtk[WILC_MAX_NUM_STA];
+   struct wilc_wfi_key *wilc_ptk[WILC_MAX_NUM_STA];
+   u8 wilc_groupkey;
+
+   /* mutexes */
+   struct mutex scan_req_lock;
+   bool p2p_listen_state;
+   int scanned_cnt;
+
+   u64 inc_roc_cookie;
+};
+
+#define MAX_TCP_SESSION25
+#define MAX_PENDING_ACKS   256
+
+struct ack_session_info {
+   u32 seq_num;
+   u32 bigger_ack_num;
+   u16 src_port;
+   u16 dst_port;
+   u16 status;
+};
+
+struct pending_acks {
+   u32 ack_num;
+   u32 session_index;
+   struct txq_entry_t  *txqe;
+};
+
+struct tcp_ack_filter {
+   struct ack_session_info ack_session_info[2 * MAX_TCP_SESSION];

[PATCH v7 10/17] wilc1000: add mon.c

2020-06-23 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/mon.c' to
'drivers/net/wireless/microchip/wilc1000/mon.c'.

Signed-off-by: Ajay Singh 
---
 drivers/net/wireless/microchip/wilc1000/mon.c | 260 ++
 1 file changed, 260 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/mon.c

diff --git a/drivers/net/wireless/microchip/wilc1000/mon.c 
b/drivers/net/wireless/microchip/wilc1000/mon.c
new file mode 100644
index ..60331417bd98
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/mon.c
@@ -0,0 +1,260 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#include "cfg80211.h"
+
+struct wilc_wfi_radiotap_hdr {
+   struct ieee80211_radiotap_header hdr;
+   u8 rate;
+} __packed;
+
+struct wilc_wfi_radiotap_cb_hdr {
+   struct ieee80211_radiotap_header hdr;
+   u8 rate;
+   u8 dump;
+   u16 tx_flags;
+} __packed;
+
+#define TX_RADIOTAP_PRESENT ((1 << IEEE80211_RADIOTAP_RATE) |  \
+(1 << IEEE80211_RADIOTAP_TX_FLAGS))
+
+void wilc_wfi_monitor_rx(struct net_device *mon_dev, u8 *buff, u32 size)
+{
+   u32 header, pkt_offset;
+   struct sk_buff *skb = NULL;
+   struct wilc_wfi_radiotap_hdr *hdr;
+   struct wilc_wfi_radiotap_cb_hdr *cb_hdr;
+
+   if (!mon_dev)
+   return;
+
+   if (!netif_running(mon_dev))
+   return;
+
+   /* Get WILC header */
+   header = get_unaligned_le32(buff - HOST_HDR_OFFSET);
+   /*
+* The packet offset field contain info about what type of management
+* the frame we are dealing with and ack status
+*/
+   pkt_offset = FIELD_GET(WILC_PKT_HDR_OFFSET_FIELD, header);
+
+   if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {
+   /* hostapd callback mgmt frame */
+
+   skb = dev_alloc_skb(size + sizeof(*cb_hdr));
+   if (!skb)
+   return;
+
+   skb_put_data(skb, buff, size);
+
+   cb_hdr = skb_push(skb, sizeof(*cb_hdr));
+   memset(cb_hdr, 0, sizeof(*cb_hdr));
+
+   cb_hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */
+
+   cb_hdr->hdr.it_len = cpu_to_le16(sizeof(*cb_hdr));
+
+   cb_hdr->hdr.it_present = cpu_to_le32(TX_RADIOTAP_PRESENT);
+
+   cb_hdr->rate = 5;
+
+   if (pkt_offset & IS_MGMT_STATUS_SUCCES) {
+   /* success */
+   cb_hdr->tx_flags = IEEE80211_RADIOTAP_F_TX_RTS;
+   } else {
+   cb_hdr->tx_flags = IEEE80211_RADIOTAP_F_TX_FAIL;
+   }
+
+   } else {
+   skb = dev_alloc_skb(size + sizeof(*hdr));
+
+   if (!skb)
+   return;
+
+   skb_put_data(skb, buff, size);
+   hdr = skb_push(skb, sizeof(*hdr));
+   memset(hdr, 0, sizeof(struct wilc_wfi_radiotap_hdr));
+   hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */
+   hdr->hdr.it_len = cpu_to_le16(sizeof(*hdr));
+   hdr->hdr.it_present = cpu_to_le32
+   (1 << IEEE80211_RADIOTAP_RATE);
+   hdr->rate = 5;
+   }
+
+   skb->dev = mon_dev;
+   skb_reset_mac_header(skb);
+   skb->ip_summed = CHECKSUM_UNNECESSARY;
+   skb->pkt_type = PACKET_OTHERHOST;
+   skb->protocol = htons(ETH_P_802_2);
+   memset(skb->cb, 0, sizeof(skb->cb));
+
+   netif_rx(skb);
+}
+
+struct tx_complete_mon_data {
+   int size;
+   void *buff;
+};
+
+static void mgmt_tx_complete(void *priv, int status)
+{
+   struct tx_complete_mon_data *pv_data = priv;
+   /*
+* in case of fully hosting mode, the freeing will be done
+* in response to the cfg packet
+*/
+   kfree(pv_data->buff);
+
+   kfree(pv_data);
+}
+
+static int mon_mgmt_tx(struct net_device *dev, const u8 *buf, size_t len)
+{
+   struct tx_complete_mon_data *mgmt_tx = NULL;
+
+   if (!dev)
+   return -EFAULT;
+
+   netif_stop_queue(dev);
+   mgmt_tx = kmalloc(sizeof(*mgmt_tx), GFP_ATOMIC);
+   if (!mgmt_tx)
+   return -ENOMEM;
+
+   mgmt_tx->buff = kmemdup(buf, len, GFP_ATOMIC);
+   if (!mgmt_tx->buff) {
+   kfree(mgmt_tx);
+   return -ENOMEM;
+   }
+
+   mgmt_tx->size = len;
+
+   wilc_wlan_txq_add_mgmt_pkt(dev, mgmt_tx, mgmt_tx->buff, mgmt_tx->size,
+  mgmt_tx_complete);
+
+   netif_wake_queue(dev);
+   return 0;
+}
+
+static netdev_tx_t wilc_wfi_mon_xmit(struct sk_buff *skb,
+struct net_device *dev)
+{
+   u32 rtap_len, ret = 0;
+   struct wilc_wfi_mon_priv  *mon_priv;
+   struct sk_buff *skb2;
+   struct wilc_wfi_radiotap_cb_hdr *cb_hdr;
+   u8 srcadd[ETH_ALEN];
+   

[PATCH v7 09/17] wilc1000: add netdev.c

2020-06-23 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/netdev.c' to
'drivers/net/wireless/microchip/wilc1000/netdev.c'.

Signed-off-by: Ajay Singh 
---
 .../net/wireless/microchip/wilc1000/netdev.c  | 931 ++
 1 file changed, 931 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/netdev.c

diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.c 
b/drivers/net/wireless/microchip/wilc1000/netdev.c
new file mode 100644
index ..fda0ab97b02c
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/netdev.c
@@ -0,0 +1,931 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "cfg80211.h"
+#include "wlan_cfg.h"
+
+#define WILC_MULTICAST_TABLE_SIZE  8
+
+static irqreturn_t isr_uh_routine(int irq, void *user_data)
+{
+   struct net_device *dev = user_data;
+   struct wilc_vif *vif = netdev_priv(dev);
+   struct wilc *wilc = vif->wilc;
+
+   if (wilc->close) {
+   netdev_err(dev, "Can't handle UH interrupt\n");
+   return IRQ_HANDLED;
+   }
+   return IRQ_WAKE_THREAD;
+}
+
+static irqreturn_t isr_bh_routine(int irq, void *userdata)
+{
+   struct net_device *dev = userdata;
+   struct wilc_vif *vif = netdev_priv(userdata);
+   struct wilc *wilc = vif->wilc;
+
+   if (wilc->close) {
+   netdev_err(dev, "Can't handle BH interrupt\n");
+   return IRQ_HANDLED;
+   }
+
+   wilc_handle_isr(wilc);
+
+   return IRQ_HANDLED;
+}
+
+static int init_irq(struct net_device *dev)
+{
+   struct wilc_vif *vif = netdev_priv(dev);
+   struct wilc *wl = vif->wilc;
+   int ret;
+
+   ret = request_threaded_irq(wl->dev_irq_num, isr_uh_routine,
+  isr_bh_routine,
+  IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+  "WILC_IRQ", dev);
+   if (ret) {
+   netdev_err(dev, "Failed to request IRQ [%d]\n", ret);
+   return ret;
+   }
+   netdev_dbg(dev, "IRQ request succeeded IRQ-NUM= %d\n", wl->dev_irq_num);
+
+   return 0;
+}
+
+static void deinit_irq(struct net_device *dev)
+{
+   struct wilc_vif *vif = netdev_priv(dev);
+   struct wilc *wilc = vif->wilc;
+
+   /* Deinitialize IRQ */
+   if (wilc->dev_irq_num)
+   free_irq(wilc->dev_irq_num, wilc);
+}
+
+void wilc_mac_indicate(struct wilc *wilc)
+{
+   s8 status;
+
+   wilc_wlan_cfg_get_val(wilc, WID_STATUS, , 1);
+   if (wilc->mac_status == WILC_MAC_STATUS_INIT) {
+   wilc->mac_status = status;
+   complete(>sync_event);
+   } else {
+   wilc->mac_status = status;
+   }
+}
+
+static struct net_device *get_if_handler(struct wilc *wilc, u8 *mac_header)
+{
+   struct net_device *ndev = NULL;
+   struct wilc_vif *vif;
+   struct ieee80211_hdr *h = (struct ieee80211_hdr *)mac_header;
+
+   list_for_each_entry_rcu(vif, >vif_list, list) {
+   if (vif->mode == WILC_STATION_MODE)
+   if (ether_addr_equal_unaligned(h->addr2, vif->bssid)) {
+   ndev = vif->ndev;
+   goto out;
+   }
+   if (vif->mode == WILC_AP_MODE)
+   if (ether_addr_equal_unaligned(h->addr1, vif->bssid)) {
+   ndev = vif->ndev;
+   goto out;
+   }
+   }
+out:
+   return ndev;
+}
+
+void wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid, u8 mode)
+{
+   struct wilc_vif *vif = netdev_priv(wilc_netdev);
+
+   if (bssid)
+   ether_addr_copy(vif->bssid, bssid);
+   else
+   eth_zero_addr(vif->bssid);
+
+   vif->mode = mode;
+}
+
+int wilc_wlan_get_num_conn_ifcs(struct wilc *wilc)
+{
+   int srcu_idx;
+   u8 ret_val = 0;
+   struct wilc_vif *vif;
+
+   srcu_idx = srcu_read_lock(>srcu);
+   list_for_each_entry_rcu(vif, >vif_list, list) {
+   if (!is_zero_ether_addr(vif->bssid))
+   ret_val++;
+   }
+   srcu_read_unlock(>srcu, srcu_idx);
+   return ret_val;
+}
+
+static int wilc_txq_task(void *vp)
+{
+   int ret;
+   u32 txq_count;
+   struct wilc *wl = vp;
+
+   complete(>txq_thread_started);
+   while (1) {
+   wait_for_completion(>txq_event);
+
+   if (wl->close) {
+   complete(>txq_thread_started);
+
+   while (!kthread_should_stop())
+   schedule();
+   break;
+   }
+   do {
+   ret = wilc_wlan_handle_txq(wl, _count);
+   if (txq_count < 

[PATCH v7 06/17] wilc1000: add cfg80211.c

2020-06-23 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/cfg80211.c' to
'drivers/net/wireless/microchip/wilc1000/cfg80211.c'.

Signed-off-by: Ajay Singh 
---
 .../wireless/microchip/wilc1000/cfg80211.c| 1846 +
 1 file changed, 1846 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/cfg80211.c

diff --git a/drivers/net/wireless/microchip/wilc1000/cfg80211.c 
b/drivers/net/wireless/microchip/wilc1000/cfg80211.c
new file mode 100644
index ..bd91dd800531
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/cfg80211.c
@@ -0,0 +1,1846 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#include "cfg80211.h"
+
+#define GO_NEG_REQ 0x00
+#define GO_NEG_RSP 0x01
+#define GO_NEG_CONF0x02
+#define P2P_INV_REQ0x03
+#define P2P_INV_RSP0x04
+
+#define WILC_INVALID_CHANNEL   0
+
+/* Operation at 2.4 GHz with channels 1-13 */
+#define WILC_WLAN_OPERATING_CLASS_2_4GHZ   0x51
+
+static const struct ieee80211_txrx_stypes
+   wilc_wfi_cfg80211_mgmt_types[NUM_NL80211_IFTYPES] = {
+   [NL80211_IFTYPE_STATION] = {
+   .tx = 0x,
+   .rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
+   BIT(IEEE80211_STYPE_PROBE_REQ >> 4)
+   },
+   [NL80211_IFTYPE_AP] = {
+   .tx = 0x,
+   .rx = BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) |
+   BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) |
+   BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
+   BIT(IEEE80211_STYPE_DISASSOC >> 4) |
+   BIT(IEEE80211_STYPE_AUTH >> 4) |
+   BIT(IEEE80211_STYPE_DEAUTH >> 4) |
+   BIT(IEEE80211_STYPE_ACTION >> 4)
+   },
+   [NL80211_IFTYPE_P2P_CLIENT] = {
+   .tx = 0x,
+   .rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
+   BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
+   BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) |
+   BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) |
+   BIT(IEEE80211_STYPE_DISASSOC >> 4) |
+   BIT(IEEE80211_STYPE_AUTH >> 4) |
+   BIT(IEEE80211_STYPE_DEAUTH >> 4)
+   }
+};
+
+static const struct wiphy_wowlan_support wowlan_support = {
+   .flags = WIPHY_WOWLAN_ANY
+};
+
+struct wilc_p2p_mgmt_data {
+   int size;
+   u8 *buff;
+};
+
+struct wilc_p2p_pub_act_frame {
+   u8 category;
+   u8 action;
+   u8 oui[3];
+   u8 oui_type;
+   u8 oui_subtype;
+   u8 dialog_token;
+   u8 elem[];
+} __packed;
+
+struct wilc_vendor_specific_ie {
+   u8 tag_number;
+   u8 tag_len;
+   u8 oui[3];
+   u8 oui_type;
+   u8 attr[];
+} __packed;
+
+struct wilc_attr_entry {
+   u8  attr_type;
+   __le16 attr_len;
+   u8 val[];
+} __packed;
+
+struct wilc_attr_oper_ch {
+   u8 attr_type;
+   __le16 attr_len;
+   u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
+   u8 op_class;
+   u8 op_channel;
+} __packed;
+
+struct wilc_attr_ch_list {
+   u8 attr_type;
+   __le16 attr_len;
+   u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
+   u8 elem[];
+} __packed;
+
+struct wilc_ch_list_elem {
+   u8 op_class;
+   u8 no_of_channels;
+   u8 ch_list[];
+} __packed;
+
+static void cfg_scan_result(enum scan_event scan_event,
+   struct wilc_rcvd_net_info *info, void *user_void)
+{
+   struct wilc_priv *priv = user_void;
+
+   if (!priv->cfg_scanning)
+   return;
+
+   if (scan_event == SCAN_EVENT_NETWORK_FOUND) {
+   s32 freq;
+   struct ieee80211_channel *channel;
+   struct cfg80211_bss *bss;
+   struct wiphy *wiphy = priv->dev->ieee80211_ptr->wiphy;
+
+   if (!wiphy || !info)
+   return;
+
+   freq = ieee80211_channel_to_frequency((s32)info->ch,
+ NL80211_BAND_2GHZ);
+   channel = ieee80211_get_channel(wiphy, freq);
+   if (!channel)
+   return;
+
+   bss = cfg80211_inform_bss_frame(wiphy, channel, info->mgmt,
+   info->frame_len,
+   (s32)info->rssi * 100,
+   GFP_KERNEL);
+   if (!bss)
+   cfg80211_put_bss(wiphy, bss);
+   } else if (scan_event == SCAN_EVENT_DONE) {
+   mutex_lock(>scan_req_lock);
+
+   if (priv->scan_req) {
+   struct cfg80211_scan_info info = {
+   .aborted = false,
+   };
+

[PATCH v7 16/17] dt: bindings: net: add microchip,wilc1000.yaml

2020-06-23 Thread Ajay.Kathat
From: Ajay Singh 

This file describes the binding details to connect wilc1000 device. It's
moved from staging to 'Documentation/devicetree/bindings/net/wireless'
path.

Reviewed-by: Rob Herring 
Signed-off-by: Ajay Singh 
---
 This patch was reviewed earlier with previous version[v6] of series [1].

 [1]. https://lore.kernel.org/linux-wireless/20200405013235.GA24105@bogus

 .../net/wireless/microchip,wilc1000.yaml  | 71 +++
 1 file changed, 71 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml

diff --git 
a/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml 
b/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml
new file mode 100644
index ..2c320eb2a8c4
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml
@@ -0,0 +1,71 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/wireless/microchip,wilc1000.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Microchip WILC wireless devicetree bindings
+
+maintainers:
+  - Adham Abozaeid 
+  - Ajay Singh 
+
+description:
+  The wilc1000 chips can be connected via SPI or SDIO. This document
+  describes the binding to connect wilc devices.
+
+properties:
+  compatible:
+const: microchip,wilc1000
+
+  spi-max-frequency: true
+
+  interrupts:
+maxItems: 1
+
+  clocks:
+description: phandle to the clock connected on rtc clock line.
+maxItems: 1
+
+  clock-names:
+const: rtc
+
+required:
+  - compatible
+  - interrupts
+
+examples:
+  - |
+spi {
+  #address-cells = <1>;
+  #size-cells = <0>;
+  wifi@0 {
+compatible = "microchip,wilc1000";
+spi-max-frequency = <4800>;
+reg = <0>;
+interrupt-parent = <>;
+interrupts = <27 0>;
+clocks = <>;
+clock-names = "rtc";
+  };
+};
+
+  - |
+mmc {
+  #address-cells = <1>;
+  #size-cells = <0>;
+  pinctrl-names = "default";
+  pinctrl-0 = <_mmc1_clk_cmd_dat0 _mmc1_dat1_3>;
+  non-removable;
+  vmmc-supply = <_mmc1_reg>;
+  vqmmc-supply = <_3v3_reg>;
+  bus-width = <4>;
+  wifi@0 {
+compatible = "microchip,wilc1000";
+reg = <0>;
+interrupt-parent = <>;
+interrupts = <27 0>;
+clocks = <>;
+clock-names = "rtc";
+  };
+};
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v7 14/17] wilc1000: add sdio.c

2020-06-23 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/sdio.c' to
'drivers/net/wireless/microchip/wilc1000/sdio.c'.

Signed-off-by: Ajay Singh 
---
 .../net/wireless/microchip/wilc1000/sdio.c| 1023 +
 1 file changed, 1023 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/sdio.c

diff --git a/drivers/net/wireless/microchip/wilc1000/sdio.c 
b/drivers/net/wireless/microchip/wilc1000/sdio.c
new file mode 100644
index ..36eb589263bf
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/sdio.c
@@ -0,0 +1,1023 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "netdev.h"
+#include "cfg80211.h"
+
+#define SDIO_MODALIAS "wilc1000_sdio"
+
+#define SDIO_VENDOR_ID_WILC 0x0296
+#define SDIO_DEVICE_ID_WILC 0x5347
+
+static const struct sdio_device_id wilc_sdio_ids[] = {
+   { SDIO_DEVICE(SDIO_VENDOR_ID_WILC, SDIO_DEVICE_ID_WILC) },
+   { },
+};
+
+#define WILC_SDIO_BLOCK_SIZE 512
+
+struct wilc_sdio {
+   bool irq_gpio;
+   u32 block_size;
+   int has_thrpt_enh3;
+};
+
+struct sdio_cmd52 {
+   u32 read_write: 1;
+   u32 function:   3;
+   u32 raw:1;
+   u32 address:17;
+   u32 data:   8;
+};
+
+struct sdio_cmd53 {
+   u32 read_write: 1;
+   u32 function:   3;
+   u32 block_mode: 1;
+   u32 increment:  1;
+   u32 address:17;
+   u32 count:  9;
+   u8 *buffer;
+   u32 block_size;
+};
+
+static const struct wilc_hif_func wilc_hif_sdio;
+
+static void wilc_sdio_interrupt(struct sdio_func *func)
+{
+   sdio_release_host(func);
+   wilc_handle_isr(sdio_get_drvdata(func));
+   sdio_claim_host(func);
+}
+
+static int wilc_sdio_cmd52(struct wilc *wilc, struct sdio_cmd52 *cmd)
+{
+   struct sdio_func *func = container_of(wilc->dev, struct sdio_func, dev);
+   int ret;
+   u8 data;
+
+   sdio_claim_host(func);
+
+   func->num = cmd->function;
+   if (cmd->read_write) {  /* write */
+   if (cmd->raw) {
+   sdio_writeb(func, cmd->data, cmd->address, );
+   data = sdio_readb(func, cmd->address, );
+   cmd->data = data;
+   } else {
+   sdio_writeb(func, cmd->data, cmd->address, );
+   }
+   } else {/* read */
+   data = sdio_readb(func, cmd->address, );
+   cmd->data = data;
+   }
+
+   sdio_release_host(func);
+
+   if (ret)
+   dev_err(>dev, "%s..failed, err(%d)\n", __func__, ret);
+   return ret;
+}
+
+static int wilc_sdio_cmd53(struct wilc *wilc, struct sdio_cmd53 *cmd)
+{
+   struct sdio_func *func = container_of(wilc->dev, struct sdio_func, dev);
+   int size, ret;
+
+   sdio_claim_host(func);
+
+   func->num = cmd->function;
+   func->cur_blksize = cmd->block_size;
+   if (cmd->block_mode)
+   size = cmd->count * cmd->block_size;
+   else
+   size = cmd->count;
+
+   if (cmd->read_write) {  /* write */
+   ret = sdio_memcpy_toio(func, cmd->address,
+  (void *)cmd->buffer, size);
+   } else {/* read */
+   ret = sdio_memcpy_fromio(func, (void *)cmd->buffer,
+cmd->address,  size);
+   }
+
+   sdio_release_host(func);
+
+   if (ret)
+   dev_err(>dev, "%s..failed, err(%d)\n", __func__,  ret);
+
+   return ret;
+}
+
+static int wilc_sdio_probe(struct sdio_func *func,
+  const struct sdio_device_id *id)
+{
+   struct wilc *wilc;
+   int ret;
+   struct wilc_sdio *sdio_priv;
+
+   sdio_priv = kzalloc(sizeof(*sdio_priv), GFP_KERNEL);
+   if (!sdio_priv)
+   return -ENOMEM;
+
+   ret = wilc_cfg80211_init(, >dev, WILC_HIF_SDIO,
+_hif_sdio);
+   if (ret) {
+   kfree(sdio_priv);
+   return ret;
+   }
+
+   if (IS_ENABLED(CONFIG_WILC1000_HW_OOB_INTR)) {
+   struct device_node *np = func->card->dev.of_node;
+   int irq_num = of_irq_get(np, 0);
+
+   if (irq_num > 0) {
+   wilc->dev_irq_num = irq_num;
+   sdio_priv->irq_gpio = true;
+   }
+   }
+
+   sdio_set_drvdata(func, wilc);
+   wilc->bus_data = sdio_priv;
+   wilc->dev = >dev;
+
+   wilc->rtc_clk = devm_clk_get(>card->dev, "rtc");
+   if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER)
+   return -EPROBE_DEFER;
+   else if (!IS_ERR(wilc->rtc_clk))
+   clk_prepare_enable(wilc->rtc_clk);
+
+   dev_info(>dev, 

[PATCH v7 17/17] wilc1000: add Makefile and Kconfig files for wilc1000 compilation

2020-06-23 Thread Ajay.Kathat
From: Ajay Singh 

Added Makefile and Kconfig files for compiling wilc1000 module from
'drivers/net/wireless/microchip/'.

Signed-off-by: Ajay Singh 
---
 drivers/net/wireless/Kconfig  |  1 +
 drivers/net/wireless/Makefile |  1 +
 drivers/net/wireless/microchip/Kconfig| 15 ++
 drivers/net/wireless/microchip/Makefile   |  2 +
 .../net/wireless/microchip/wilc1000/Kconfig   | 47 +++
 .../net/wireless/microchip/wilc1000/Makefile  | 14 ++
 drivers/staging/Kconfig   |  2 -
 drivers/staging/Makefile  |  1 -
 8 files changed, 80 insertions(+), 3 deletions(-)
 create mode 100644 drivers/net/wireless/microchip/Kconfig
 create mode 100644 drivers/net/wireless/microchip/Makefile
 create mode 100644 drivers/net/wireless/microchip/wilc1000/Kconfig
 create mode 100644 drivers/net/wireless/microchip/wilc1000/Makefile

diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig
index 8ab62bb6b853..be0de242d8fd 100644
--- a/drivers/net/wireless/Kconfig
+++ b/drivers/net/wireless/Kconfig
@@ -47,6 +47,7 @@ source "drivers/net/wireless/st/Kconfig"
 source "drivers/net/wireless/ti/Kconfig"
 source "drivers/net/wireless/zydas/Kconfig"
 source "drivers/net/wireless/quantenna/Kconfig"
+source "drivers/net/wireless/microchip/Kconfig"
 
 config PCMCIA_RAYCS
tristate "Aviator/Raytheon 2.4GHz wireless support"
diff --git a/drivers/net/wireless/Makefile b/drivers/net/wireless/Makefile
index 6cfe74515c95..f9a51c2889ca 100644
--- a/drivers/net/wireless/Makefile
+++ b/drivers/net/wireless/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_WLAN_VENDOR_ST) += st/
 obj-$(CONFIG_WLAN_VENDOR_TI) += ti/
 obj-$(CONFIG_WLAN_VENDOR_ZYDAS) += zydas/
 obj-$(CONFIG_WLAN_VENDOR_QUANTENNA) += quantenna/
+obj-$(CONFIG_WLAN_VENDOR_MICROCHIP) += microchip/
 
 # 16-bit wireless PCMCIA client drivers
 obj-$(CONFIG_PCMCIA_RAYCS) += ray_cs.o
diff --git a/drivers/net/wireless/microchip/Kconfig 
b/drivers/net/wireless/microchip/Kconfig
new file mode 100644
index ..a6b46fb6b1ec
--- /dev/null
+++ b/drivers/net/wireless/microchip/Kconfig
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: GPL-2.0
+config WLAN_VENDOR_MICROCHIP
+   bool "Microchip devices"
+   default y
+   help
+   If you have a wireless card belonging to this class, say Y.
+
+   Note that the answer to this question doesn't directly affect the
+   kernel: saying N will just cause the configurator to skip all the
+   questions about these cards. If you say Y, you will be asked for
+   your specific card in the following questions.
+
+if WLAN_VENDOR_MICROCHIP
+source "drivers/net/wireless/microchip/wilc1000/Kconfig"
+endif # WLAN_VENDOR_MICROCHIP
diff --git a/drivers/net/wireless/microchip/Makefile 
b/drivers/net/wireless/microchip/Makefile
new file mode 100644
index ..73b763c7393e
--- /dev/null
+++ b/drivers/net/wireless/microchip/Makefile
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-$(CONFIG_WILC1000) += wilc1000/
diff --git a/drivers/net/wireless/microchip/wilc1000/Kconfig 
b/drivers/net/wireless/microchip/wilc1000/Kconfig
new file mode 100644
index ..80c92e8bf8a5
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/Kconfig
@@ -0,0 +1,47 @@
+# SPDX-License-Identifier: GPL-2.0
+config WILC1000
+   tristate
+   help
+ Add support for the Atmel WILC1000 802.11 b/g/n SoC.
+ This provides Wi-FI over an SDIO or SPI interface, and
+ is usually found in IoT devices.
+
+ This module only support IEEE 802.11n WiFi.
+
+config WILC1000_SDIO
+   tristate "Atmel WILC1000 SDIO (WiFi only)"
+   depends on CFG80211 && INET && MMC
+   select WILC1000
+   help
+ This module adds support for the SDIO interface of adapters using
+ WILC1000 chipset. The Atmel WILC1000 SDIO is a full speed interface.
+ It meets SDIO card specification version 2.0. The interface supports
+ the 1-bit/4-bit SD transfer mode at the clock range of 0-50 MHz.
+ The host can use this interface to read and write from any register
+ within the chip as well as configure the WILC1000 for data DMA.
+ To use this interface, pin9 (SDIO_SPI_CFG) must be grounded. Select
+ this if your platform is using the SDIO bus.
+
+config WILC1000_SPI
+   tristate "Atmel WILC1000 SPI (WiFi only)"
+   depends on CFG80211 && INET && SPI
+   select WILC1000
+   select CRC7
+   help
+ This module adds support for the SPI interface of adapters using
+ WILC1000 chipset. The Atmel WILC1000 has a Serial Peripheral
+ Interface (SPI) that operates as a SPI slave. This SPI interface can
+ be used for control and for serial I/O of 802.11 data. The SPI is a
+ full-duplex slave synchronous serial interface that is available
+ immediately following reset when pin 9 (SDIO_SPI_CFG) is tied 

[PATCH v7 02/17] wilc1000: add hif.c

2020-06-23 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/hif.c' to
'drivers/net/wireless/microchip/wilc1000/hif.c'.

Signed-off-by: Ajay Singh 
---
 drivers/net/wireless/microchip/wilc1000/hif.c | 1961 +
 1 file changed, 1961 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/hif.c

diff --git a/drivers/net/wireless/microchip/wilc1000/hif.c 
b/drivers/net/wireless/microchip/wilc1000/hif.c
new file mode 100644
index ..d025a3093015
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/hif.c
@@ -0,0 +1,1961 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#include "netdev.h"
+
+#define WILC_HIF_SCAN_TIMEOUT_MS5000
+#define WILC_HIF_CONNECT_TIMEOUT_MS 9500
+
+#define WILC_FALSE_FRMWR_CHANNEL   100
+
+#define WILC_SCAN_WID_LIST_SIZE6
+
+struct wilc_rcvd_mac_info {
+   u8 status;
+};
+
+struct wilc_set_multicast {
+   u32 enabled;
+   u32 cnt;
+   u8 *mc_list;
+};
+
+struct wilc_del_all_sta {
+   u8 assoc_sta;
+   u8 mac[WILC_MAX_NUM_STA][ETH_ALEN];
+};
+
+union wilc_message_body {
+   struct wilc_rcvd_net_info net_info;
+   struct wilc_rcvd_mac_info mac_info;
+   struct wilc_set_multicast mc_info;
+   struct wilc_remain_ch remain_on_ch;
+   char *data;
+};
+
+struct host_if_msg {
+   union wilc_message_body body;
+   struct wilc_vif *vif;
+   struct work_struct work;
+   void (*fn)(struct work_struct *ws);
+   struct completion work_comp;
+   bool is_sync;
+};
+
+/* 'msg' should be free by the caller for syc */
+static struct host_if_msg*
+wilc_alloc_work(struct wilc_vif *vif, void (*work_fun)(struct work_struct *),
+   bool is_sync)
+{
+   struct host_if_msg *msg;
+
+   if (!work_fun)
+   return ERR_PTR(-EINVAL);
+
+   msg = kzalloc(sizeof(*msg), GFP_ATOMIC);
+   if (!msg)
+   return ERR_PTR(-ENOMEM);
+   msg->fn = work_fun;
+   msg->vif = vif;
+   msg->is_sync = is_sync;
+   if (is_sync)
+   init_completion(>work_comp);
+
+   return msg;
+}
+
+static int wilc_enqueue_work(struct host_if_msg *msg)
+{
+   INIT_WORK(>work, msg->fn);
+
+   if (!msg->vif || !msg->vif->wilc || !msg->vif->wilc->hif_workqueue)
+   return -EINVAL;
+
+   if (!queue_work(msg->vif->wilc->hif_workqueue, >work))
+   return -EINVAL;
+
+   return 0;
+}
+
+/* The idx starts from 0 to (NUM_CONCURRENT_IFC - 1), but 0 index used as
+ * special purpose in wilc device, so we add 1 to the index to starts from 1.
+ * As a result, the returned index will be 1 to NUM_CONCURRENT_IFC.
+ */
+int wilc_get_vif_idx(struct wilc_vif *vif)
+{
+   return vif->idx + 1;
+}
+
+/* We need to minus 1 from idx which is from wilc device to get real index
+ * of wilc->vif[], because we add 1 when pass to wilc device in the function
+ * wilc_get_vif_idx.
+ * As a result, the index should be between 0 and (NUM_CONCURRENT_IFC - 1).
+ */
+static struct wilc_vif *wilc_get_vif_from_idx(struct wilc *wilc, int idx)
+{
+   int index = idx - 1;
+   struct wilc_vif *vif;
+
+   if (index < 0 || index >= WILC_NUM_CONCURRENT_IFC)
+   return NULL;
+
+   list_for_each_entry_rcu(vif, >vif_list, list) {
+   if (vif->idx == index)
+   return vif;
+   }
+
+   return NULL;
+}
+
+static int handle_scan_done(struct wilc_vif *vif, enum scan_event evt)
+{
+   int result = 0;
+   u8 abort_running_scan;
+   struct wid wid;
+   struct host_if_drv *hif_drv = vif->hif_drv;
+   struct wilc_user_scan_req *scan_req;
+
+   if (evt == SCAN_EVENT_ABORTED) {
+   abort_running_scan = 1;
+   wid.id = WID_ABORT_RUNNING_SCAN;
+   wid.type = WID_CHAR;
+   wid.val = (s8 *)_running_scan;
+   wid.size = sizeof(char);
+
+   result = wilc_send_config_pkt(vif, WILC_SET_CFG, , 1);
+   if (result) {
+   netdev_err(vif->ndev, "Failed to set abort running\n");
+   result = -EFAULT;
+   }
+   }
+
+   if (!hif_drv) {
+   netdev_err(vif->ndev, "%s: hif driver is NULL\n", __func__);
+   return result;
+   }
+
+   scan_req = _drv->usr_scan_req;
+   if (scan_req->scan_result) {
+   scan_req->scan_result(evt, NULL, scan_req->arg);
+   scan_req->scan_result = NULL;
+   }
+
+   return result;
+}
+
+int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
+ u8 *ch_freq_list, u8 ch_list_len,
+ void (*scan_result_fn)(enum scan_event,
+struct wilc_rcvd_net_info *, void *),
+ void *user_arg, struct cfg80211_scan_request *request)
+{
+   int result = 

[PATCH v7 01/17] wilc1000: add hif.h

2020-06-23 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/hif.h' to
'drivers/net/wireless/microchip/wilc1000/hif.h'.

Signed-off-by: Ajay Singh 
---
 drivers/net/wireless/microchip/wilc1000/hif.h | 214 ++
 1 file changed, 214 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/hif.h

diff --git a/drivers/net/wireless/microchip/wilc1000/hif.h 
b/drivers/net/wireless/microchip/wilc1000/hif.h
new file mode 100644
index ..db9179171f05
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/hif.h
@@ -0,0 +1,214 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries
+ * All rights reserved.
+ */
+
+#ifndef WILC_HIF_H
+#define WILC_HIF_H
+#include 
+#include "wlan_if.h"
+
+enum {
+   WILC_IDLE_MODE = 0x0,
+   WILC_AP_MODE = 0x1,
+   WILC_STATION_MODE = 0x2,
+   WILC_GO_MODE = 0x3,
+   WILC_CLIENT_MODE = 0x4
+};
+
+#define WILC_MAX_NUM_PROBED_SSID   10
+
+#define WILC_TX_MIC_KEY_LEN8
+#define WILC_RX_MIC_KEY_LEN8
+
+#define WILC_ADD_STA_LENGTH40
+#define WILC_NUM_CONCURRENT_IFC2
+
+enum {
+   WILC_SET_CFG = 0,
+   WILC_GET_CFG
+};
+
+#define WILC_MAX_ASSOC_RESP_FRAME_SIZE   256
+
+struct rf_info {
+   u8 link_speed;
+   s8 rssi;
+   u32 tx_cnt;
+   u32 rx_cnt;
+   u32 tx_fail_cnt;
+};
+
+enum host_if_state {
+   HOST_IF_IDLE= 0,
+   HOST_IF_SCANNING= 1,
+   HOST_IF_CONNECTING  = 2,
+   HOST_IF_WAITING_CONN_RESP   = 3,
+   HOST_IF_CONNECTED   = 4,
+   HOST_IF_P2P_LISTEN  = 5,
+   HOST_IF_FORCE_32BIT = 0x
+};
+
+struct cfg_param_attr {
+   u32 flag;
+   u16 short_retry_limit;
+   u16 long_retry_limit;
+   u16 frag_threshold;
+   u16 rts_threshold;
+};
+
+enum cfg_param {
+   WILC_CFG_PARAM_RETRY_SHORT = BIT(0),
+   WILC_CFG_PARAM_RETRY_LONG = BIT(1),
+   WILC_CFG_PARAM_FRAG_THRESHOLD = BIT(2),
+   WILC_CFG_PARAM_RTS_THRESHOLD = BIT(3)
+};
+
+enum scan_event {
+   SCAN_EVENT_NETWORK_FOUND= 0,
+   SCAN_EVENT_DONE = 1,
+   SCAN_EVENT_ABORTED  = 2,
+   SCAN_EVENT_FORCE_32BIT  = 0x
+};
+
+enum conn_event {
+   CONN_DISCONN_EVENT_CONN_RESP= 0,
+   CONN_DISCONN_EVENT_DISCONN_NOTIF= 1,
+   CONN_DISCONN_EVENT_FORCE_32BIT  = 0x
+};
+
+enum {
+   WILC_HIF_SDIO = 0,
+   WILC_HIF_SPI = BIT(0)
+};
+
+enum {
+   WILC_MAC_STATUS_INIT = -1,
+   WILC_MAC_STATUS_DISCONNECTED = 0,
+   WILC_MAC_STATUS_CONNECTED = 1
+};
+
+struct wilc_rcvd_net_info {
+   s8 rssi;
+   u8 ch;
+   u16 frame_len;
+   struct ieee80211_mgmt *mgmt;
+};
+
+struct wilc_user_scan_req {
+   void (*scan_result)(enum scan_event evt,
+   struct wilc_rcvd_net_info *info, void *priv);
+   void *arg;
+   u32 ch_cnt;
+};
+
+struct wilc_conn_info {
+   u8 bssid[ETH_ALEN];
+   u8 security;
+   enum authtype auth_type;
+   u8 ch;
+   u8 *req_ies;
+   size_t req_ies_len;
+   u8 *resp_ies;
+   u16 resp_ies_len;
+   u16 status;
+   void (*conn_result)(enum conn_event evt, u8 status, void *priv_data);
+   void *arg;
+   void *param;
+};
+
+struct wilc_remain_ch {
+   u16 ch;
+   u32 duration;
+   void (*expired)(void *priv, u64 cookie);
+   void *arg;
+   u32 cookie;
+};
+
+struct wilc;
+struct host_if_drv {
+   struct wilc_user_scan_req usr_scan_req;
+   struct wilc_conn_info conn_info;
+   struct wilc_remain_ch remain_on_ch;
+   u64 p2p_timeout;
+
+   enum host_if_state hif_state;
+
+   u8 assoc_bssid[ETH_ALEN];
+
+   struct timer_list scan_timer;
+   struct wilc_vif *scan_timer_vif;
+
+   struct timer_list connect_timer;
+   struct wilc_vif *connect_timer_vif;
+
+   struct timer_list remain_on_ch_timer;
+   struct wilc_vif *remain_on_ch_timer_vif;
+
+   bool ifc_up;
+   u8 assoc_resp[WILC_MAX_ASSOC_RESP_FRAME_SIZE];
+};
+
+struct wilc_vif;
+int wilc_remove_wep_key(struct wilc_vif *vif, u8 index);
+int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index);
+int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len,
+u8 index);
+int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len,
+   u8 index, u8 mode, enum authtype auth_type);
+int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len,
+const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic,
+u8 mode, u8 cipher_mode, u8 index);
+s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac,
+  u32 *out_val);
+int wilc_add_rx_gtk(struct wilc_vif 

[PATCH v7 15/17] wilc1000: add fw.h

2020-06-23 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/fw.h' to
'drivers/net/wireless/microchip/wilc1000/fw.h'.

Signed-off-by: Ajay Singh 
---
 drivers/net/wireless/microchip/wilc1000/fw.h | 119 +++
 1 file changed, 119 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/fw.h

diff --git a/drivers/net/wireless/microchip/wilc1000/fw.h 
b/drivers/net/wireless/microchip/wilc1000/fw.h
new file mode 100644
index ..a76e1dea4345
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/fw.h
@@ -0,0 +1,119 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#ifndef WILC_FW_H
+#define WILC_FW_H
+
+#include 
+
+#define WILC_MAX_NUM_STA   9
+#define WILC_MAX_RATES_SUPPORTED   12
+#define WILC_MAX_NUM_PMKIDS16
+#define WILC_MAX_NUM_SCANNED_CH14
+
+struct wilc_assoc_resp {
+   __le16 capab_info;
+   __le16 status_code;
+   __le16 aid;
+} __packed;
+
+struct wilc_pmkid {
+   u8 bssid[ETH_ALEN];
+   u8 pmkid[WLAN_PMKID_LEN];
+} __packed;
+
+struct wilc_pmkid_attr {
+   u8 numpmkid;
+   struct wilc_pmkid pmkidlist[WILC_MAX_NUM_PMKIDS];
+} __packed;
+
+struct wilc_reg_frame {
+   u8 reg;
+   u8 reg_id;
+   __le16 frame_type;
+} __packed;
+
+struct wilc_drv_handler {
+   __le32 handler;
+   u8 mode;
+} __packed;
+
+struct wilc_wep_key {
+   u8 index;
+   u8 key_len;
+   u8 key[0];
+} __packed;
+
+struct wilc_sta_wpa_ptk {
+   u8 mac_addr[ETH_ALEN];
+   u8 key_len;
+   u8 key[0];
+} __packed;
+
+struct wilc_ap_wpa_ptk {
+   u8 mac_addr[ETH_ALEN];
+   u8 index;
+   u8 key_len;
+   u8 key[0];
+} __packed;
+
+struct wilc_gtk_key {
+   u8 mac_addr[ETH_ALEN];
+   u8 rsc[8];
+   u8 index;
+   u8 key_len;
+   u8 key[0];
+} __packed;
+
+struct wilc_op_mode {
+   __le32 mode;
+} __packed;
+
+struct wilc_noa_opp_enable {
+   u8 ct_window;
+   u8 cnt;
+   __le32 duration;
+   __le32 interval;
+   __le32 start_time;
+} __packed;
+
+struct wilc_noa_opp_disable {
+   u8 cnt;
+   __le32 duration;
+   __le32 interval;
+   __le32 start_time;
+} __packed;
+
+struct wilc_join_bss_param {
+   char ssid[IEEE80211_MAX_SSID_LEN];
+   u8 ssid_terminator;
+   u8 bss_type;
+   u8 ch;
+   __le16 cap_info;
+   u8 sa[ETH_ALEN];
+   u8 bssid[ETH_ALEN];
+   __le16 beacon_period;
+   u8 dtim_period;
+   u8 supp_rates[WILC_MAX_RATES_SUPPORTED + 1];
+   u8 wmm_cap;
+   u8 uapsd_cap;
+   u8 ht_capable;
+   u8 rsn_found;
+   u8 rsn_grp_policy;
+   u8 mode_802_11i;
+   u8 p_suites[3];
+   u8 akm_suites[3];
+   u8 rsn_cap[2];
+   u8 noa_enabled;
+   __le32 tsf_lo;
+   u8 idx;
+   u8 opp_enabled;
+   union {
+   struct wilc_noa_opp_disable opp_dis;
+   struct wilc_noa_opp_enable opp_en;
+   };
+} __packed;
+#endif
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v7 00/17] wilc1000: move out of staging

2020-06-23 Thread Ajay.Kathat
From: Ajay Singh 

This patch series is to review and move wilc1000 driver out of staging.
Most of the review comments received in [1] & [2] are addressed in the
latest code.
Please review and provide your inputs.

[1]. 
https://lore.kernel.org/linux-wireless/1537957525-11467-1-git-send-email-ajay.kat...@microchip.com/
[2]. 
https://lore.kernel.org/linux-wireless/1562896697-8002-1-git-send-email-ajay.kat...@microchip.com/

Changes since v6:
 - added Reviewed-by tag received for DT binding document patch earlier.
   * https://lore.kernel.org/linux-wireless/20200405013235.GA24105@bogus
 - merged latest driver and included --base commit as suggested.

Changes since v5:
 - handle DT binding review comments suggested in below link:
  * https://lore.kernel.org/driverdev-devel/20200320175920.GA31641@bogus
 - merged latest driver from staging which contains few cleanup patches
   and changes to use crc7 from existing library instead of having
   private implementation.

Changes since v4:
  - merged wilc1000 SDIO and SPI DT binding into a single file.
  - handle DT binding review comments suggested in below links:
* https://lore.kernel.org/linux-wireless/20200303015558.GA6876@bogus
* 
https://lore.kernel.org/linux-wireless/20200306144400.4269-2-ajay.kat...@microchip.com

Changes since v3:
  - handle few Smatch static checker reported issues.
  - use flexible-array member instead of zero-length array.

Changes since v2:
  - use 'struct' to extract FW info from received commands.
  - make use of C style comments instead of C++.
  - remove use of bool type for firmware struct.
  - deleted unused code related to interrupt handling.
  - make use of RCU list to maintain interfaces list.
  - remove 'wilc_' prefix from file name.
  - added 'WILC_' prefix for header guard macro.
  - remove use of infinite loops(i.e. while(1)).
  - move firmware related struct to a separate file.
  - refactor SPI command handling by using 'struct'.
  - use different functions to handle different SPI commands.
  - cleanup spi.c and sdio.c by removing unused code.
  - remove use of vendor specific IE for p2p handling.
  - refactor p2p related code to avoid use of buf pointer operation.
  - make use of FIELD_GET/PREP macro.
  - use #define instead of magic values.
  - use YAML schemes for DT binding documentation.
  - deleted unused code from spi.c and sdio.c.
  - added changes for few issues reported by smatch static code analyzer.

Changes since v1:
  - remove use of shadow buffer to keep scan result.
  - remove internal messaging flow to handle cfg80211_ops.
  - make use of cfg80211 provide API.
  - use 'struct' for packing firmware commands.
  - make use of kernel API's and Macro.
  - remove unnecessary log messages
  - supported dynamically add/remove interfaces.
  - cleanup and deleted around 3.3k lines of code.

Ajay Singh (17):
  wilc1000: add hif.h
  wilc1000: add hif.c
  wilc1000: add wlan_if.h
  wilc1000: add wlan_cfg.h
  wilc1000: add wlan_cfg.c
  wilc1000: add cfg80211.c
  wilc1000: add cfg80211.h
  wilc1000: add netdev.h
  wilc1000: add netdev.c
  wilc1000: add mon.c
  wilc1000: add spi.c
  wilc1000: add wlan.h
  wilc1000: add wlan.c
  wilc1000: add sdio.c
  wilc1000: add fw.h
  dt: bindings: net: add microchip,wilc1000.yaml
  wilc1000: add Makefile and Kconfig files for wilc1000 compilation

 .../net/wireless/microchip,wilc1000.yaml  |   71 +
 drivers/net/wireless/Kconfig  |1 +
 drivers/net/wireless/Makefile |1 +
 drivers/net/wireless/microchip/Kconfig|   15 +
 drivers/net/wireless/microchip/Makefile   |2 +
 .../net/wireless/microchip/wilc1000/Kconfig   |   47 +
 .../net/wireless/microchip/wilc1000/Makefile  |   14 +
 .../wireless/microchip/wilc1000/cfg80211.c| 1846 
 .../wireless/microchip/wilc1000/cfg80211.h|   30 +
 drivers/net/wireless/microchip/wilc1000/fw.h  |  119 +
 drivers/net/wireless/microchip/wilc1000/hif.c | 1961 +
 drivers/net/wireless/microchip/wilc1000/hif.h |  214 ++
 drivers/net/wireless/microchip/wilc1000/mon.c |  260 +++
 .../net/wireless/microchip/wilc1000/netdev.c  |  931 
 .../net/wireless/microchip/wilc1000/netdev.h  |  287 +++
 .../net/wireless/microchip/wilc1000/sdio.c| 1023 +
 drivers/net/wireless/microchip/wilc1000/spi.c |  945 
 .../net/wireless/microchip/wilc1000/wlan.c| 1238 +++
 .../net/wireless/microchip/wilc1000/wlan.h|  397 
 .../wireless/microchip/wilc1000/wlan_cfg.c|  413 
 .../wireless/microchip/wilc1000/wlan_cfg.h|   54 +
 .../net/wireless/microchip/wilc1000/wlan_if.h |  803 +++
 drivers/staging/Kconfig   |2 -
 drivers/staging/Makefile  |1 -
 24 files changed, 10672 insertions(+), 3 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml
 create mode 100644 drivers/net/wireless/microchip/Kconfig
 create mode 100644 

[PATCH v7 07/17] wilc1000: add cfg80211.h

2020-06-23 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/cfg80211.h' to
'drivers/net/wireless/microchip/wilc1000/cfg80211.h'.

Signed-off-by: Ajay Singh 
---
 .../wireless/microchip/wilc1000/cfg80211.h| 30 +++
 1 file changed, 30 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/cfg80211.h

diff --git a/drivers/net/wireless/microchip/wilc1000/cfg80211.h 
b/drivers/net/wireless/microchip/wilc1000/cfg80211.h
new file mode 100644
index ..37b294cb3b37
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/cfg80211.h
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#ifndef WILC_CFG80211_H
+#define WILC_CFG80211_H
+#include "netdev.h"
+
+struct wiphy *wilc_cfg_alloc(void);
+int wilc_cfg80211_init(struct wilc **wilc, struct device *dev, int io_type,
+  const struct wilc_hif_func *ops);
+struct wilc *wilc_create_wiphy(struct device *dev);
+void wilc_deinit_host_int(struct net_device *net);
+int wilc_init_host_int(struct net_device *net);
+void wilc_wfi_monitor_rx(struct net_device *mon_dev, u8 *buff, u32 size);
+struct wilc_vif *wilc_netdev_interface(struct wilc *wl, const char *name,
+  enum nl80211_iftype type);
+void wilc_wfi_deinit_mon_interface(struct wilc *wl, bool rtnl_locked);
+struct net_device *wilc_wfi_init_mon_interface(struct wilc *wl,
+  const char *name,
+  struct net_device *real_dev);
+void wilc_update_mgmt_frame_registrations(struct wiphy *wiphy,
+ struct wireless_dev *wdev,
+ struct mgmt_frame_regs *upd);
+struct wilc_vif *wilc_get_interface(struct wilc *wl);
+struct wilc_vif *wilc_get_wl_to_vif(struct wilc *wl);
+void wlan_deinit_locks(struct wilc *wilc);
+#endif
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v7 04/17] wilc1000: add wlan_cfg.h

2020-06-23 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/wlan_cfg.h' to
'drivers/net/wireless/microchip/wilc1000/wlan_cfg.h'.

Signed-off-by: Ajay Singh 
---
 .../wireless/microchip/wilc1000/wlan_cfg.h| 54 +++
 1 file changed, 54 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/wlan_cfg.h

diff --git a/drivers/net/wireless/microchip/wilc1000/wlan_cfg.h 
b/drivers/net/wireless/microchip/wilc1000/wlan_cfg.h
new file mode 100644
index ..614c5673f232
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/wlan_cfg.h
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#ifndef WILC_WLAN_CFG_H
+#define WILC_WLAN_CFG_H
+
+struct wilc_cfg_byte {
+   u16 id;
+   u8 val;
+};
+
+struct wilc_cfg_hword {
+   u16 id;
+   u16 val;
+};
+
+struct wilc_cfg_word {
+   u16 id;
+   u32 val;
+};
+
+struct wilc_cfg_str {
+   u16 id;
+   u8 *str;
+};
+
+struct wilc_cfg_str_vals {
+   u8 mac_address[7];
+   u8 firmware_version[129];
+   u8 assoc_rsp[256];
+};
+
+struct wilc_cfg {
+   struct wilc_cfg_byte *b;
+   struct wilc_cfg_hword *hw;
+   struct wilc_cfg_word *w;
+   struct wilc_cfg_str *s;
+   struct wilc_cfg_str_vals *str_vals;
+};
+
+struct wilc;
+int wilc_wlan_cfg_set_wid(u8 *frame, u32 offset, u16 id, u8 *buf, int size);
+int wilc_wlan_cfg_get_wid(u8 *frame, u32 offset, u16 id);
+int wilc_wlan_cfg_get_val(struct wilc *wl, u16 wid, u8 *buffer,
+ u32 buffer_size);
+void wilc_wlan_cfg_indicate_rx(struct wilc *wilc, u8 *frame, int size,
+  struct wilc_cfg_rsp *rsp);
+int wilc_wlan_cfg_init(struct wilc *wl);
+void wilc_wlan_cfg_deinit(struct wilc *wl);
+
+#endif
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v7 03/17] wilc1000: add wlan_if.h

2020-06-23 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/wlan_if.h' to
'drivers/net/wireless/microchip/wilc1000/wlan_if.h'.

Signed-off-by: Ajay Singh 
---
 .../net/wireless/microchip/wilc1000/wlan_if.h | 803 ++
 1 file changed, 803 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/wlan_if.h

diff --git a/drivers/net/wireless/microchip/wilc1000/wlan_if.h 
b/drivers/net/wireless/microchip/wilc1000/wlan_if.h
new file mode 100644
index ..f85fd575136d
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/wlan_if.h
@@ -0,0 +1,803 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#ifndef WILC_WLAN_IF_H
+#define WILC_WLAN_IF_H
+
+#include 
+#include "fw.h"
+
+/
+ *
+ *  Wlan Configuration ID
+ *
+ /
+
+enum bss_types {
+   WILC_FW_BSS_TYPE_INFRA = 0,
+   WILC_FW_BSS_TYPE_INDEPENDENT,
+   WILC_FW_BSS_TYPE_AP,
+};
+
+enum {
+   WILC_FW_OPER_MODE_B_ONLY = 0,/* 1, 2 M, otherwise 5, 11 M */
+   WILC_FW_OPER_MODE_G_ONLY,/* 6,12,24 otherwise 9,18,36,48,54 */
+   WILC_FW_OPER_MODE_G_MIXED_11B_1, /* 1,2,5.5,11 otherwise all on */
+   WILC_FW_OPER_MODE_G_MIXED_11B_2, /* 1,2,5,11,6,12,24 otherwise all on */
+};
+
+enum {
+   WILC_FW_PREAMBLE_SHORT = 0, /* Short Preamble */
+   WILC_FW_PREAMBLE_LONG = 1,  /* Long Preamble */
+   WILC_FW_PREAMBLE_AUTO = 2,  /* Auto Preamble Selection */
+};
+
+enum {
+   WILC_FW_PASSIVE_SCAN = 0,
+   WILC_FW_ACTIVE_SCAN = 1,
+};
+
+enum {
+   WILC_FW_NO_POWERSAVE = 0,
+   WILC_FW_MIN_FAST_PS = 1,
+   WILC_FW_MAX_FAST_PS = 2,
+   WILC_FW_MIN_PSPOLL_PS = 3,
+   WILC_FW_MAX_PSPOLL_PS = 4
+};
+
+enum chip_ps_states {
+   WILC_CHIP_WAKEDUP = 0,
+   WILC_CHIP_SLEEPING_AUTO = 1,
+   WILC_CHIP_SLEEPING_MANUAL = 2
+};
+
+enum bus_acquire {
+   WILC_BUS_ACQUIRE_ONLY = 0,
+   WILC_BUS_ACQUIRE_AND_WAKEUP = 1,
+};
+
+enum bus_release {
+   WILC_BUS_RELEASE_ONLY = 0,
+   WILC_BUS_RELEASE_ALLOW_SLEEP = 1,
+};
+
+enum {
+   WILC_FW_NO_ENCRYPT = 0,
+   WILC_FW_ENCRYPT_ENABLED = BIT(0),
+   WILC_FW_WEP = BIT(1),
+   WILC_FW_WEP_EXTENDED = BIT(2),
+   WILC_FW_WPA = BIT(3),
+   WILC_FW_WPA2 = BIT(4),
+   WILC_FW_AES = BIT(5),
+   WILC_FW_TKIP = BIT(6)
+};
+
+enum {
+   WILC_FW_SEC_NO = WILC_FW_NO_ENCRYPT,
+   WILC_FW_SEC_WEP = WILC_FW_WEP | WILC_FW_ENCRYPT_ENABLED,
+   WILC_FW_SEC_WEP_EXTENDED = WILC_FW_WEP_EXTENDED | WILC_FW_SEC_WEP,
+   WILC_FW_SEC_WPA = WILC_FW_WPA | WILC_FW_ENCRYPT_ENABLED,
+   WILC_FW_SEC_WPA_AES = WILC_FW_AES | WILC_FW_SEC_WPA,
+   WILC_FW_SEC_WPA_TKIP = WILC_FW_TKIP | WILC_FW_SEC_WPA,
+   WILC_FW_SEC_WPA2 = WILC_FW_WPA2 | WILC_FW_ENCRYPT_ENABLED,
+   WILC_FW_SEC_WPA2_AES = WILC_FW_AES | WILC_FW_SEC_WPA2,
+   WILC_FW_SEC_WPA2_TKIP = WILC_FW_TKIP | WILC_FW_SEC_WPA2
+};
+
+enum authtype {
+   WILC_FW_AUTH_OPEN_SYSTEM = 1,
+   WILC_FW_AUTH_SHARED_KEY = 2,
+   WILC_FW_AUTH_ANY = 3,
+   WILC_FW_AUTH_IEEE8021 = 5
+};
+
+enum site_survey {
+   WILC_FW_SITE_SURVEY_1CH = 0,
+   WILC_FW_SITE_SURVEY_ALL_CH = 1,
+   WILC_FW_SITE_SURVEY_OFF = 2
+};
+
+enum {
+   WILC_FW_ACK_POLICY_NORMAL = 0,
+   WILC_FW_ACK_NO_POLICY,
+};
+
+enum {
+   WILC_FW_REKEY_POLICY_DISABLE = 1,
+   WILC_FW_REKEY_POLICY_TIME_BASE,
+   WILC_FW_REKEY_POLICY_PKT_BASE,
+   WILC_FW_REKEY_POLICY_TIME_PKT_BASE
+};
+
+enum {
+   WILC_FW_FILTER_NO = 0x00,
+   WILC_FW_FILTER_AP_ONLY = 0x01,
+   WILC_FW_FILTER_STA_ONLY = 0x02
+};
+
+enum {
+   WILC_FW_11N_PROT_AUTO = 0,  /* Auto */
+   WILC_FW_11N_NO_PROT,/* Do not use any protection */
+   WILC_FW_11N_PROT_ERP,   /* Protect all ERP frame exchanges */
+   WILC_FW_11N_PROT_HT,/* Protect all HT frame exchanges  */
+   WILC_FW_11N_PROT_GF /* Protect all GF frame exchanges  */
+};
+
+enum {
+   WILC_FW_ERP_PROT_SELF_CTS,
+   WILC_FW_ERP_PROT_RTS_CTS,
+};
+
+enum {
+   WILC_FW_11N_OP_MODE_HT_MIXED = 1,
+   WILC_FW_11N_OP_MODE_HT_ONLY_20MHZ,
+   WILC_FW_11N_OP_MODE_HT_ONLY_20_40MHZ,
+};
+
+enum {
+   WILC_FW_OBBS_NONHT_NO_DETECT = 0,
+   WILC_FW_OBBS_NONHT_DETECT_ONLY = 1,
+   WILC_FW_OBBS_NONHT_DETECT_PROTECT = 2,
+   WILC_FW_OBBS_NONHT_DETECT_PROTECT_REPORT = 3,
+};
+
+enum {
+   WILC_FW_HT_PROT_RTS_CTS_NONHT = 0,  /* RTS-CTS at non-HT rate */
+   WILC_FW_HT_PROT_FIRST_FRAME_NONHT,  /* First frame at non-HT rate */
+   WILC_FW_HT_PROT_LSIG_TXOP,  /* LSIG TXOP Protection */
+   WILC_FW_HT_PROT_FIRST_FRAME_MIXED,  /* First frame at Mixed format */
+};
+
+enum {
+   WILC_FW_SMPS_MODE_STATIC = 1,
+   WILC_FW_SMPS_MODE_DYNAMIC = 2,
+   WILC_FW_SMPS_MODE_MIMO = 3,  

[PATCH v7 05/17] wilc1000: add wlan_cfg.c

2020-06-23 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/wlan_cfg.c' to
'drivers/net/wireless/microchip/wilc1000/wlan_cfg.c'.

Signed-off-by: Ajay Singh 
---
 .../wireless/microchip/wilc1000/wlan_cfg.c| 413 ++
 1 file changed, 413 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/wlan_cfg.c

diff --git a/drivers/net/wireless/microchip/wilc1000/wlan_cfg.c 
b/drivers/net/wireless/microchip/wilc1000/wlan_cfg.c
new file mode 100644
index ..fe2a7ed8e5cd
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/wlan_cfg.c
@@ -0,0 +1,413 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#include 
+#include "wlan_if.h"
+#include "wlan.h"
+#include "wlan_cfg.h"
+#include "netdev.h"
+
+enum cfg_cmd_type {
+   CFG_BYTE_CMD= 0,
+   CFG_HWORD_CMD   = 1,
+   CFG_WORD_CMD= 2,
+   CFG_STR_CMD = 3,
+   CFG_BIN_CMD = 4
+};
+
+static const struct wilc_cfg_byte g_cfg_byte[] = {
+   {WID_STATUS, 0},
+   {WID_RSSI, 0},
+   {WID_LINKSPEED, 0},
+   {WID_NIL, 0}
+};
+
+static const struct wilc_cfg_hword g_cfg_hword[] = {
+   {WID_NIL, 0}
+};
+
+static const struct wilc_cfg_word g_cfg_word[] = {
+   {WID_FAILED_COUNT, 0},
+   {WID_RECEIVED_FRAGMENT_COUNT, 0},
+   {WID_SUCCESS_FRAME_COUNT, 0},
+   {WID_GET_INACTIVE_TIME, 0},
+   {WID_NIL, 0}
+
+};
+
+static const struct wilc_cfg_str g_cfg_str[] = {
+   {WID_FIRMWARE_VERSION, NULL},
+   {WID_MAC_ADDR, NULL},
+   {WID_ASSOC_RES_INFO, NULL},
+   {WID_NIL, NULL}
+};
+
+#define WILC_RESP_MSG_TYPE_CONFIG_REPLY'R'
+#define WILC_RESP_MSG_TYPE_STATUS_INFO 'I'
+#define WILC_RESP_MSG_TYPE_NETWORK_INFO'N'
+#define WILC_RESP_MSG_TYPE_SCAN_COMPLETE   'S'
+
+/
+ *
+ *  Configuration Functions
+ *
+ /
+
+static int wilc_wlan_cfg_set_byte(u8 *frame, u32 offset, u16 id, u8 val8)
+{
+   if ((offset + 4) >= WILC_MAX_CFG_FRAME_SIZE)
+   return 0;
+
+   put_unaligned_le16(id, [offset]);
+   put_unaligned_le16(1, [offset + 2]);
+   frame[offset + 4] = val8;
+   return 5;
+}
+
+static int wilc_wlan_cfg_set_hword(u8 *frame, u32 offset, u16 id, u16 val16)
+{
+   if ((offset + 5) >= WILC_MAX_CFG_FRAME_SIZE)
+   return 0;
+
+   put_unaligned_le16(id, [offset]);
+   put_unaligned_le16(2, [offset + 2]);
+   put_unaligned_le16(val16, [offset + 4]);
+
+   return 6;
+}
+
+static int wilc_wlan_cfg_set_word(u8 *frame, u32 offset, u16 id, u32 val32)
+{
+   if ((offset + 7) >= WILC_MAX_CFG_FRAME_SIZE)
+   return 0;
+
+   put_unaligned_le16(id, [offset]);
+   put_unaligned_le16(4, [offset + 2]);
+   put_unaligned_le32(val32, [offset + 4]);
+
+   return 8;
+}
+
+static int wilc_wlan_cfg_set_str(u8 *frame, u32 offset, u16 id, u8 *str,
+u32 size)
+{
+   if ((offset + size + 4) >= WILC_MAX_CFG_FRAME_SIZE)
+   return 0;
+
+   put_unaligned_le16(id, [offset]);
+   put_unaligned_le16(size, [offset + 2]);
+   if (str && size != 0)
+   memcpy([offset + 4], str, size);
+
+   return (size + 4);
+}
+
+static int wilc_wlan_cfg_set_bin(u8 *frame, u32 offset, u16 id, u8 *b, u32 
size)
+{
+   u32 i;
+   u8 checksum = 0;
+
+   if ((offset + size + 5) >= WILC_MAX_CFG_FRAME_SIZE)
+   return 0;
+
+   put_unaligned_le16(id, [offset]);
+   put_unaligned_le16(size, [offset + 2]);
+
+   if ((b) && size != 0) {
+   memcpy([offset + 4], b, size);
+   for (i = 0; i < size; i++)
+   checksum += frame[offset + i + 4];
+   }
+
+   frame[offset + size + 4] = checksum;
+
+   return (size + 5);
+}
+
+/
+ *
+ *  Configuration Response Functions
+ *
+ /
+
+static void wilc_wlan_parse_response_frame(struct wilc *wl, u8 *info, int size)
+{
+   u16 wid;
+   u32 len = 0, i = 0;
+   struct wilc_cfg *cfg = >cfg;
+
+   while (size > 0) {
+   i = 0;
+   wid = get_unaligned_le16(info);
+
+   switch (FIELD_GET(WILC_WID_TYPE, wid)) {
+   case WID_CHAR:
+   while (cfg->b[i].id != WID_NIL && cfg->b[i].id != wid)
+   i++;
+
+   if (cfg->b[i].id == wid)
+   cfg->b[i].val = info[4];
+
+   len = 3;
+   break;
+
+   case WID_SHORT:
+   while (cfg->hw[i].id != WID_NIL && cfg->hw[i].id != wid)
+   i++;
+
+   if (cfg->hw[i].id == wid)
+   

Re: [PATCH v2] staging: wilc1000: Increase the size of wid_list array

2020-05-03 Thread Ajay.Kathat



On 03/05/20 1:21 pm, Oscar Carter wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the 
> content is safe
> 
> Increase by one the size of wid_list array as index variable can reach a
> value of 5. If this happens, an out-of-bounds access is performed.
> 
> Addresses-Coverity-ID: 1451981 ("Out-of-bounds access")
> Fixes: f5a3cb90b802d ("staging: wilc1000: add passive scan support")
> Signed-off-by: Oscar Carter 


Thanks for making the changes.

Acked-by: Ajay Singh 


> ---
> Changelog v1 -> v2
> - Fix the commit for the "Fixes" tag as Ajay suggested.
> 
>  drivers/staging/wilc1000/hif.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/wilc1000/hif.c b/drivers/staging/wilc1000/hif.c
> index 6c7de2f8d3f2..128943c3be4f 100644
> --- a/drivers/staging/wilc1000/hif.c
> +++ b/drivers/staging/wilc1000/hif.c
> @@ -151,7 +151,7 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 
> scan_type,
>   void *user_arg, struct cfg80211_scan_request *request)
>  {
> int result = 0;
> -   struct wid wid_list[5];
> +   struct wid wid_list[6];
> u32 index = 0;
> u32 i, scan_timeout;
> u8 *buffer;
> --
> 2.20.1
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: wilc1000: Increase the size of wid_list array

2020-05-01 Thread Ajay.Kathat


On 01/05/20 10:32 pm, Oscar Carter wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the 
> content is safe
> 
> Increase by one the size of wid_list array as index variable can reach a
> value of 5. If this happens, an out-of-bounds access is performed.
> 
> Addresses-Coverity-ID: 1451981 ("Out-of-bounds access")
> Fixes: c5c77ba18ea66 ("staging: wilc1000: Add SDIO/SPI 802.11 driver")

The code changes are fine. But the correct commit for Fixes tag should be

Fixes: f5a3cb90b802d ("staging: wilc1000: add passive scan support")


Regards,
Ajay

> Signed-off-by: Oscar Carter 
> ---
>  drivers/staging/wilc1000/hif.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/wilc1000/hif.c b/drivers/staging/wilc1000/hif.c
> index 6c7de2f8d3f2..128943c3be4f 100644
> --- a/drivers/staging/wilc1000/hif.c
> +++ b/drivers/staging/wilc1000/hif.c
> @@ -151,7 +151,7 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 
> scan_type,
>   void *user_arg, struct cfg80211_scan_request *request)
>  {
> int result = 0;
> -   struct wid wid_list[5];
> +   struct wid wid_list[6];
> u32 index = 0;
> u32 i, scan_timeout;
> u8 *buffer;
> --
> 2.20.1
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/2] staging: wilc1000: adjust for management frame register API changes

2020-04-28 Thread Ajay.Kathat


On 28/04/20 1:44 pm, Johannes Berg wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the 
> content is safe
> 
> From: Johannes Berg 
> 
> Adjust to the API changes in cfg80211 for management frame registration.
> 
> Fixes: 6cd536fe62ef ("cfg80211: change internal management frame registration 
> API")
> Signed-off-by: Johannes Berg 


Acked-by: Ajay Singh 

This patch looks better to handle cfg80211 callback changes for frame
registration compared to [1].

[1].
https://lore.kernel.org/linux-wireless/20200424212454.230080-1-geoma...@gmail.com/

> ---
>  drivers/staging/wilc1000/cfg80211.c | 36 ++---
>  drivers/staging/wilc1000/cfg80211.h |  5 ++--
>  drivers/staging/wilc1000/netdev.c   | 21 -
>  drivers/staging/wilc1000/netdev.h   |  9 +---
>  4 files changed, 30 insertions(+), 41 deletions(-)
> 
> diff --git a/drivers/staging/wilc1000/cfg80211.c 
> b/drivers/staging/wilc1000/cfg80211.c
> index 4bdcbc5fd2fd..b6065a0d660f 100644
> --- a/drivers/staging/wilc1000/cfg80211.c
> +++ b/drivers/staging/wilc1000/cfg80211.c
> @@ -1217,33 +1217,31 @@ static int mgmt_tx_cancel_wait(struct wiphy *wiphy,
> return 0;
>  }
> 
> -void wilc_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev,
> - u16 frame_type, bool reg)
> +void wilc_update_mgmt_frame_registrations(struct wiphy *wiphy,
> + struct wireless_dev *wdev,
> + struct mgmt_frame_regs *upd)
>  {
> struct wilc *wl = wiphy_priv(wiphy);
> struct wilc_vif *vif = netdev_priv(wdev->netdev);
> +   u32 presp_bit = BIT(IEEE80211_STYPE_PROBE_REQ >> 4);
> +   u32 action_bit = BIT(IEEE80211_STYPE_ACTION >> 4);
> 
> -   if (!frame_type)
> -   return;
> +   if (wl->initialized) {
> +   bool prev = vif->mgmt_reg_stypes & presp_bit;
> +   bool now = upd->interface_stypes & presp_bit;
> 
> -   switch (frame_type) {
> -   case IEEE80211_STYPE_PROBE_REQ:
> -   vif->frame_reg[0].type = frame_type;
> -   vif->frame_reg[0].reg = reg;
> -   break;
> +   if (now != prev)
> +   wilc_frame_register(vif, IEEE80211_STYPE_PROBE_REQ, 
> now);
> 
> -   case IEEE80211_STYPE_ACTION:
> -   vif->frame_reg[1].type = frame_type;
> -   vif->frame_reg[1].reg = reg;
> -   break;
> +   prev = vif->mgmt_reg_stypes & action_bit;
> +   now = upd->interface_stypes & action_bit;
> 
> -   default:
> -   break;
> +   if (now != prev)
> +   wilc_frame_register(vif, IEEE80211_STYPE_ACTION, now);
> }
> 
> -   if (!wl->initialized)
> -   return;
> -   wilc_frame_register(vif, frame_type, reg);
> +   vif->mgmt_reg_stypes =
> +   upd->interface_stypes & (presp_bit | action_bit);
>  }
> 
>  static int set_cqm_rssi_config(struct wiphy *wiphy, struct net_device *dev,
> @@ -1665,7 +1663,7 @@ static const struct cfg80211_ops wilc_cfg80211_ops = {
> .cancel_remain_on_channel = cancel_remain_on_channel,
> .mgmt_tx_cancel_wait = mgmt_tx_cancel_wait,
> .mgmt_tx = mgmt_tx,
> -   .mgmt_frame_register = wilc_mgmt_frame_register,
> +   .update_mgmt_frame_registrations = 
> wilc_update_mgmt_frame_registrations,
> .set_power_mgmt = set_power_mgmt,
> .set_cqm_rssi_config = set_cqm_rssi_config,
> 
> diff --git a/drivers/staging/wilc1000/cfg80211.h 
> b/drivers/staging/wilc1000/cfg80211.h
> index 5e5d63f70df2..37b294cb3b37 100644
> --- a/drivers/staging/wilc1000/cfg80211.h
> +++ b/drivers/staging/wilc1000/cfg80211.h
> @@ -21,8 +21,9 @@ void wilc_wfi_deinit_mon_interface(struct wilc *wl, bool 
> rtnl_locked);
>  struct net_device *wilc_wfi_init_mon_interface(struct wilc *wl,
>const char *name,
>struct net_device *real_dev);
> -void wilc_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev,
> - u16 frame_type, bool reg);
> +void wilc_update_mgmt_frame_registrations(struct wiphy *wiphy,
> + struct wireless_dev *wdev,
> + struct mgmt_frame_regs *upd);
>  struct wilc_vif *wilc_get_interface(struct wilc *wl);
>  struct wilc_vif *wilc_get_wl_to_vif(struct wilc *wl);
>  void wlan_deinit_locks(struct wilc *wilc);
> diff --git a/drivers/staging/wilc1000/netdev.c 
> b/drivers/staging/wilc1000/netdev.c
> index f94a17babd12..fda0ab97b02c 100644
> --- a/drivers/staging/wilc1000/netdev.c
> +++ b/drivers/staging/wilc1000/netdev.c
> @@ -571,6 +571,7 @@ static int wilc_mac_open(struct net_device *ndev)
> struct wilc *wl = vif->wilc;
> unsigned char mac_add[ETH_ALEN] = {0};
> 

Re: [PATCH v3] staging: wilc1000: Use crc7 in lib/ rather than a private copy

2020-04-02 Thread Ajay.Kathat
Hi Dan,

On 02/04/20 1:57 pm, Dan Carpenter wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the 
> content is safe
> 
> On Thu, Mar 26, 2020 at 03:23:36PM +, ajay.kat...@microchip.com wrote:
>> From: George Spelvin 
>>
>> The code in lib/ is the desired polynomial, and even includes
>> the 1-bit left shift in the table rather than needing to code
>> it explicitly.
>>
>> While I'm in Kconfig, add a description of what a WILC1000 is.
>> Kconfig questions that require me to look up a data sheet to
>> find out that I probably don't have one are a pet peeve.
>>
> 
> I don't know how this patch made it through two versions without anyone
> complaining that this paragraph should be done as a separate patch...
> 

The first two version of patches were not submitted to devel@driverdev
mailing list. I too missed the point to keep the Kconfig changes in
separate patch.

>> Cc: Adham Abozaeid 
>> Cc: linux-wirel...@vger.kernel.org
>> Reviewed-by: Ajay Singh 
>> Signed-off-by: George Spelvin 
>> ---
> 
> This should have you Signed-off-by.  The Reviewed-by is kind of assumed
> so you can drop that bit.  But everyone who touches a patch needs to
> add their signed off by.
> 

Thanks, I will make a note of it.

Regards
Ajay
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v6 00/17] wilc1000: move out of staging

2020-03-27 Thread Ajay.Kathat
Hi Kalle,

On 27/03/20 4:46 pm, Kalle Valo wrote:
> 
>  writes:
> 
>> From: Ajay Singh 
>>
>> This patch series is to review and move wilc1000 driver out of staging.
>> Most of the review comments received in [1] & [2] are addressed in the
>> latest code. Please review and provide your inputs.
>>
>> [1]. 
>> https://lore.kernel.org/linux-wireless/1537957525-11467-1-git-send-email-ajay.kat...@microchip.com/
>> [2]. 
>> https://lore.kernel.org/linux-wireless/1562896697-8002-1-git-send-email-ajay.kat...@microchip.com/
>>
>> Changes since v5:
>>  - handle DT binding review comments suggested in below link:
>>   * https://lore.kernel.org/driverdev-devel/20200320175920.GA31641@bogus
>>  - merged latest driver from staging which contains few cleanup patches
>>and changes to use crc7 from existing library instead of having
>>private implementation.
> 
> This is already the third version this month, please avoid spamming the
> list unnecessarily. What you can do to speed up the acceptance is to get
> Reviewed-by tags from people, the more I see those the more confident I
> get about the driver. I will also review this again once I find some
> free time, but don't know when that will happen.
> 

Apology for sending the patch series multiple times. This series also
contains the DT binding documentation patch. We have received couple of
review comments for the file. In the latest series all those comments
are taken care and hope it cover all points. I wanted to atleast close
this and get Reviewed-by tag for the file.
Any suggestion on how to get only single file reviewed out of this
series in case further comments are received.

> But it would be good to document in the cover letter what commit id are
> you using as the baseline. That way it's easy to review rest of the
> changes Greg has applied separately and you don't need to resend the
> whole driver everytime.
> 

Sure, will capture the commit id details in the series cover letter.

Regards
Ajay
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v6 11/17] wilc1000: add spi.c

2020-03-27 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/spi.c' to
'drivers/net/wireless/microchip/wilc1000/spi.c'.

Signed-off-by: Ajay Singh 
---
 drivers/net/wireless/microchip/wilc1000/spi.c | 945 ++
 1 file changed, 945 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/spi.c

diff --git a/drivers/net/wireless/microchip/wilc1000/spi.c 
b/drivers/net/wireless/microchip/wilc1000/spi.c
new file mode 100644
index ..3f19e3f38a39
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/spi.c
@@ -0,0 +1,945 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+
+#include "netdev.h"
+#include "cfg80211.h"
+
+struct wilc_spi {
+   int crc_off;
+};
+
+static const struct wilc_hif_func wilc_hif_spi;
+
+/
+ *
+ *  Spi protocol Function
+ *
+ /
+
+#define CMD_DMA_WRITE  0xc1
+#define CMD_DMA_READ   0xc2
+#define CMD_INTERNAL_WRITE 0xc3
+#define CMD_INTERNAL_READ  0xc4
+#define CMD_TERMINATE  0xc5
+#define CMD_REPEAT 0xc6
+#define CMD_DMA_EXT_WRITE  0xc7
+#define CMD_DMA_EXT_READ   0xc8
+#define CMD_SINGLE_WRITE   0xc9
+#define CMD_SINGLE_READ0xca
+#define CMD_RESET  0xcf
+
+#define DATA_PKT_SZ_256256
+#define DATA_PKT_SZ_512512
+#define DATA_PKT_SZ_1K 1024
+#define DATA_PKT_SZ_4K (4 * 1024)
+#define DATA_PKT_SZ_8K (8 * 1024)
+#define DATA_PKT_SZDATA_PKT_SZ_8K
+
+#define USE_SPI_DMA0
+
+#define WILC_SPI_COMMAND_STAT_SUCCESS  0
+#define WILC_GET_RESP_HDR_START(h) (((h) >> 4) & 0xf)
+
+struct wilc_spi_cmd {
+   u8 cmd_type;
+   union {
+   struct {
+   u8 addr[3];
+   u8 crc[];
+   } __packed simple_cmd;
+   struct {
+   u8 addr[3];
+   u8 size[2];
+   u8 crc[];
+   } __packed dma_cmd;
+   struct {
+   u8 addr[3];
+   u8 size[3];
+   u8 crc[];
+   } __packed dma_cmd_ext;
+   struct {
+   u8 addr[2];
+   __be32 data;
+   u8 crc[];
+   } __packed internal_w_cmd;
+   struct {
+   u8 addr[3];
+   __be32 data;
+   u8 crc[];
+   } __packed w_cmd;
+   } u;
+} __packed;
+
+struct wilc_spi_read_rsp_data {
+   u8 rsp_cmd_type;
+   u8 status;
+   u8 resp_header;
+   u8 resp_data[4];
+   u8 crc[];
+} __packed;
+
+struct wilc_spi_rsp_data {
+   u8 rsp_cmd_type;
+   u8 status;
+} __packed;
+
+static int wilc_bus_probe(struct spi_device *spi)
+{
+   int ret;
+   struct wilc *wilc;
+   struct wilc_spi *spi_priv;
+
+   spi_priv = kzalloc(sizeof(*spi_priv), GFP_KERNEL);
+   if (!spi_priv)
+   return -ENOMEM;
+
+   ret = wilc_cfg80211_init(, >dev, WILC_HIF_SPI, _hif_spi);
+   if (ret) {
+   kfree(spi_priv);
+   return ret;
+   }
+
+   spi_set_drvdata(spi, wilc);
+   wilc->dev = >dev;
+   wilc->bus_data = spi_priv;
+   wilc->dev_irq_num = spi->irq;
+
+   wilc->rtc_clk = devm_clk_get(>dev, "rtc_clk");
+   if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER)
+   return -EPROBE_DEFER;
+   else if (!IS_ERR(wilc->rtc_clk))
+   clk_prepare_enable(wilc->rtc_clk);
+
+   return 0;
+}
+
+static int wilc_bus_remove(struct spi_device *spi)
+{
+   struct wilc *wilc = spi_get_drvdata(spi);
+
+   if (!IS_ERR(wilc->rtc_clk))
+   clk_disable_unprepare(wilc->rtc_clk);
+
+   wilc_netdev_cleanup(wilc);
+   return 0;
+}
+
+static const struct of_device_id wilc_of_match[] = {
+   { .compatible = "microchip,wilc1000", },
+   { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, wilc_of_match);
+
+static struct spi_driver wilc_spi_driver = {
+   .driver = {
+   .name = MODALIAS,
+   .of_match_table = wilc_of_match,
+   },
+   .probe =  wilc_bus_probe,
+   .remove = wilc_bus_remove,
+};
+module_spi_driver(wilc_spi_driver);
+MODULE_LICENSE("GPL");
+
+static int wilc_spi_tx(struct wilc *wilc, u8 *b, u32 len)
+{
+   struct spi_device *spi = to_spi_device(wilc->dev);
+   int ret;
+   struct 

[PATCH v6 17/17] wilc1000: add Makefile and Kconfig files for wilc1000 compilation

2020-03-27 Thread Ajay.Kathat
From: Ajay Singh 

Added Makefile and Kconfig files for compiling wilc1000 module from
'drivers/net/wireless/microchip/'.

Signed-off-by: Ajay Singh 
---
 drivers/net/wireless/Kconfig  |  1 +
 drivers/net/wireless/Makefile |  1 +
 drivers/net/wireless/microchip/Kconfig| 15 ++
 drivers/net/wireless/microchip/Makefile   |  2 +
 .../net/wireless/microchip/wilc1000/Kconfig   | 47 +++
 .../net/wireless/microchip/wilc1000/Makefile  | 14 ++
 drivers/staging/Kconfig   |  2 -
 drivers/staging/Makefile  |  1 -
 8 files changed, 80 insertions(+), 3 deletions(-)
 create mode 100644 drivers/net/wireless/microchip/Kconfig
 create mode 100644 drivers/net/wireless/microchip/Makefile
 create mode 100644 drivers/net/wireless/microchip/wilc1000/Kconfig
 create mode 100644 drivers/net/wireless/microchip/wilc1000/Makefile

diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig
index 1c98d781ae49..86faf8f3d9b0 100644
--- a/drivers/net/wireless/Kconfig
+++ b/drivers/net/wireless/Kconfig
@@ -47,6 +47,7 @@ source "drivers/net/wireless/st/Kconfig"
 source "drivers/net/wireless/ti/Kconfig"
 source "drivers/net/wireless/zydas/Kconfig"
 source "drivers/net/wireless/quantenna/Kconfig"
+source "drivers/net/wireless/microchip/Kconfig"
 
 config PCMCIA_RAYCS
tristate "Aviator/Raytheon 2.4GHz wireless support"
diff --git a/drivers/net/wireless/Makefile b/drivers/net/wireless/Makefile
index 6cfe74515c95..f9a51c2889ca 100644
--- a/drivers/net/wireless/Makefile
+++ b/drivers/net/wireless/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_WLAN_VENDOR_ST) += st/
 obj-$(CONFIG_WLAN_VENDOR_TI) += ti/
 obj-$(CONFIG_WLAN_VENDOR_ZYDAS) += zydas/
 obj-$(CONFIG_WLAN_VENDOR_QUANTENNA) += quantenna/
+obj-$(CONFIG_WLAN_VENDOR_MICROCHIP) += microchip/
 
 # 16-bit wireless PCMCIA client drivers
 obj-$(CONFIG_PCMCIA_RAYCS) += ray_cs.o
diff --git a/drivers/net/wireless/microchip/Kconfig 
b/drivers/net/wireless/microchip/Kconfig
new file mode 100644
index ..a6b46fb6b1ec
--- /dev/null
+++ b/drivers/net/wireless/microchip/Kconfig
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: GPL-2.0
+config WLAN_VENDOR_MICROCHIP
+   bool "Microchip devices"
+   default y
+   help
+   If you have a wireless card belonging to this class, say Y.
+
+   Note that the answer to this question doesn't directly affect the
+   kernel: saying N will just cause the configurator to skip all the
+   questions about these cards. If you say Y, you will be asked for
+   your specific card in the following questions.
+
+if WLAN_VENDOR_MICROCHIP
+source "drivers/net/wireless/microchip/wilc1000/Kconfig"
+endif # WLAN_VENDOR_MICROCHIP
diff --git a/drivers/net/wireless/microchip/Makefile 
b/drivers/net/wireless/microchip/Makefile
new file mode 100644
index ..73b763c7393e
--- /dev/null
+++ b/drivers/net/wireless/microchip/Makefile
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-$(CONFIG_WILC1000) += wilc1000/
diff --git a/drivers/net/wireless/microchip/wilc1000/Kconfig 
b/drivers/net/wireless/microchip/wilc1000/Kconfig
new file mode 100644
index ..80c92e8bf8a5
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/Kconfig
@@ -0,0 +1,47 @@
+# SPDX-License-Identifier: GPL-2.0
+config WILC1000
+   tristate
+   help
+ Add support for the Atmel WILC1000 802.11 b/g/n SoC.
+ This provides Wi-FI over an SDIO or SPI interface, and
+ is usually found in IoT devices.
+
+ This module only support IEEE 802.11n WiFi.
+
+config WILC1000_SDIO
+   tristate "Atmel WILC1000 SDIO (WiFi only)"
+   depends on CFG80211 && INET && MMC
+   select WILC1000
+   help
+ This module adds support for the SDIO interface of adapters using
+ WILC1000 chipset. The Atmel WILC1000 SDIO is a full speed interface.
+ It meets SDIO card specification version 2.0. The interface supports
+ the 1-bit/4-bit SD transfer mode at the clock range of 0-50 MHz.
+ The host can use this interface to read and write from any register
+ within the chip as well as configure the WILC1000 for data DMA.
+ To use this interface, pin9 (SDIO_SPI_CFG) must be grounded. Select
+ this if your platform is using the SDIO bus.
+
+config WILC1000_SPI
+   tristate "Atmel WILC1000 SPI (WiFi only)"
+   depends on CFG80211 && INET && SPI
+   select WILC1000
+   select CRC7
+   help
+ This module adds support for the SPI interface of adapters using
+ WILC1000 chipset. The Atmel WILC1000 has a Serial Peripheral
+ Interface (SPI) that operates as a SPI slave. This SPI interface can
+ be used for control and for serial I/O of 802.11 data. The SPI is a
+ full-duplex slave synchronous serial interface that is available
+ immediately following reset when pin 9 (SDIO_SPI_CFG) is tied 

[PATCH v6 14/17] wilc1000: add sdio.c

2020-03-27 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/sdio.c' to
'drivers/net/wireless/microchip/wilc1000/sdio.c'.

Signed-off-by: Ajay Singh 
---
 .../net/wireless/microchip/wilc1000/sdio.c| 1023 +
 1 file changed, 1023 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/sdio.c

diff --git a/drivers/net/wireless/microchip/wilc1000/sdio.c 
b/drivers/net/wireless/microchip/wilc1000/sdio.c
new file mode 100644
index ..36eb589263bf
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/sdio.c
@@ -0,0 +1,1023 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "netdev.h"
+#include "cfg80211.h"
+
+#define SDIO_MODALIAS "wilc1000_sdio"
+
+#define SDIO_VENDOR_ID_WILC 0x0296
+#define SDIO_DEVICE_ID_WILC 0x5347
+
+static const struct sdio_device_id wilc_sdio_ids[] = {
+   { SDIO_DEVICE(SDIO_VENDOR_ID_WILC, SDIO_DEVICE_ID_WILC) },
+   { },
+};
+
+#define WILC_SDIO_BLOCK_SIZE 512
+
+struct wilc_sdio {
+   bool irq_gpio;
+   u32 block_size;
+   int has_thrpt_enh3;
+};
+
+struct sdio_cmd52 {
+   u32 read_write: 1;
+   u32 function:   3;
+   u32 raw:1;
+   u32 address:17;
+   u32 data:   8;
+};
+
+struct sdio_cmd53 {
+   u32 read_write: 1;
+   u32 function:   3;
+   u32 block_mode: 1;
+   u32 increment:  1;
+   u32 address:17;
+   u32 count:  9;
+   u8 *buffer;
+   u32 block_size;
+};
+
+static const struct wilc_hif_func wilc_hif_sdio;
+
+static void wilc_sdio_interrupt(struct sdio_func *func)
+{
+   sdio_release_host(func);
+   wilc_handle_isr(sdio_get_drvdata(func));
+   sdio_claim_host(func);
+}
+
+static int wilc_sdio_cmd52(struct wilc *wilc, struct sdio_cmd52 *cmd)
+{
+   struct sdio_func *func = container_of(wilc->dev, struct sdio_func, dev);
+   int ret;
+   u8 data;
+
+   sdio_claim_host(func);
+
+   func->num = cmd->function;
+   if (cmd->read_write) {  /* write */
+   if (cmd->raw) {
+   sdio_writeb(func, cmd->data, cmd->address, );
+   data = sdio_readb(func, cmd->address, );
+   cmd->data = data;
+   } else {
+   sdio_writeb(func, cmd->data, cmd->address, );
+   }
+   } else {/* read */
+   data = sdio_readb(func, cmd->address, );
+   cmd->data = data;
+   }
+
+   sdio_release_host(func);
+
+   if (ret)
+   dev_err(>dev, "%s..failed, err(%d)\n", __func__, ret);
+   return ret;
+}
+
+static int wilc_sdio_cmd53(struct wilc *wilc, struct sdio_cmd53 *cmd)
+{
+   struct sdio_func *func = container_of(wilc->dev, struct sdio_func, dev);
+   int size, ret;
+
+   sdio_claim_host(func);
+
+   func->num = cmd->function;
+   func->cur_blksize = cmd->block_size;
+   if (cmd->block_mode)
+   size = cmd->count * cmd->block_size;
+   else
+   size = cmd->count;
+
+   if (cmd->read_write) {  /* write */
+   ret = sdio_memcpy_toio(func, cmd->address,
+  (void *)cmd->buffer, size);
+   } else {/* read */
+   ret = sdio_memcpy_fromio(func, (void *)cmd->buffer,
+cmd->address,  size);
+   }
+
+   sdio_release_host(func);
+
+   if (ret)
+   dev_err(>dev, "%s..failed, err(%d)\n", __func__,  ret);
+
+   return ret;
+}
+
+static int wilc_sdio_probe(struct sdio_func *func,
+  const struct sdio_device_id *id)
+{
+   struct wilc *wilc;
+   int ret;
+   struct wilc_sdio *sdio_priv;
+
+   sdio_priv = kzalloc(sizeof(*sdio_priv), GFP_KERNEL);
+   if (!sdio_priv)
+   return -ENOMEM;
+
+   ret = wilc_cfg80211_init(, >dev, WILC_HIF_SDIO,
+_hif_sdio);
+   if (ret) {
+   kfree(sdio_priv);
+   return ret;
+   }
+
+   if (IS_ENABLED(CONFIG_WILC1000_HW_OOB_INTR)) {
+   struct device_node *np = func->card->dev.of_node;
+   int irq_num = of_irq_get(np, 0);
+
+   if (irq_num > 0) {
+   wilc->dev_irq_num = irq_num;
+   sdio_priv->irq_gpio = true;
+   }
+   }
+
+   sdio_set_drvdata(func, wilc);
+   wilc->bus_data = sdio_priv;
+   wilc->dev = >dev;
+
+   wilc->rtc_clk = devm_clk_get(>card->dev, "rtc");
+   if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER)
+   return -EPROBE_DEFER;
+   else if (!IS_ERR(wilc->rtc_clk))
+   clk_prepare_enable(wilc->rtc_clk);
+
+   dev_info(>dev, 

[PATCH v6 02/17] wilc1000: add hif.c

2020-03-27 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/hif.c' to
'drivers/net/wireless/microchip/wilc1000/hif.c'.

Signed-off-by: Ajay Singh 
---
 drivers/net/wireless/microchip/wilc1000/hif.c | 1959 +
 1 file changed, 1959 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/hif.c

diff --git a/drivers/net/wireless/microchip/wilc1000/hif.c 
b/drivers/net/wireless/microchip/wilc1000/hif.c
new file mode 100644
index ..6c7de2f8d3f2
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/hif.c
@@ -0,0 +1,1959 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#include "netdev.h"
+
+#define WILC_HIF_SCAN_TIMEOUT_MS5000
+#define WILC_HIF_CONNECT_TIMEOUT_MS 9500
+
+#define WILC_FALSE_FRMWR_CHANNEL   100
+
+struct wilc_rcvd_mac_info {
+   u8 status;
+};
+
+struct wilc_set_multicast {
+   u32 enabled;
+   u32 cnt;
+   u8 *mc_list;
+};
+
+struct wilc_del_all_sta {
+   u8 assoc_sta;
+   u8 mac[WILC_MAX_NUM_STA][ETH_ALEN];
+};
+
+union wilc_message_body {
+   struct wilc_rcvd_net_info net_info;
+   struct wilc_rcvd_mac_info mac_info;
+   struct wilc_set_multicast mc_info;
+   struct wilc_remain_ch remain_on_ch;
+   char *data;
+};
+
+struct host_if_msg {
+   union wilc_message_body body;
+   struct wilc_vif *vif;
+   struct work_struct work;
+   void (*fn)(struct work_struct *ws);
+   struct completion work_comp;
+   bool is_sync;
+};
+
+/* 'msg' should be free by the caller for syc */
+static struct host_if_msg*
+wilc_alloc_work(struct wilc_vif *vif, void (*work_fun)(struct work_struct *),
+   bool is_sync)
+{
+   struct host_if_msg *msg;
+
+   if (!work_fun)
+   return ERR_PTR(-EINVAL);
+
+   msg = kzalloc(sizeof(*msg), GFP_ATOMIC);
+   if (!msg)
+   return ERR_PTR(-ENOMEM);
+   msg->fn = work_fun;
+   msg->vif = vif;
+   msg->is_sync = is_sync;
+   if (is_sync)
+   init_completion(>work_comp);
+
+   return msg;
+}
+
+static int wilc_enqueue_work(struct host_if_msg *msg)
+{
+   INIT_WORK(>work, msg->fn);
+
+   if (!msg->vif || !msg->vif->wilc || !msg->vif->wilc->hif_workqueue)
+   return -EINVAL;
+
+   if (!queue_work(msg->vif->wilc->hif_workqueue, >work))
+   return -EINVAL;
+
+   return 0;
+}
+
+/* The idx starts from 0 to (NUM_CONCURRENT_IFC - 1), but 0 index used as
+ * special purpose in wilc device, so we add 1 to the index to starts from 1.
+ * As a result, the returned index will be 1 to NUM_CONCURRENT_IFC.
+ */
+int wilc_get_vif_idx(struct wilc_vif *vif)
+{
+   return vif->idx + 1;
+}
+
+/* We need to minus 1 from idx which is from wilc device to get real index
+ * of wilc->vif[], because we add 1 when pass to wilc device in the function
+ * wilc_get_vif_idx.
+ * As a result, the index should be between 0 and (NUM_CONCURRENT_IFC - 1).
+ */
+static struct wilc_vif *wilc_get_vif_from_idx(struct wilc *wilc, int idx)
+{
+   int index = idx - 1;
+   struct wilc_vif *vif;
+
+   if (index < 0 || index >= WILC_NUM_CONCURRENT_IFC)
+   return NULL;
+
+   list_for_each_entry_rcu(vif, >vif_list, list) {
+   if (vif->idx == index)
+   return vif;
+   }
+
+   return NULL;
+}
+
+static int handle_scan_done(struct wilc_vif *vif, enum scan_event evt)
+{
+   int result = 0;
+   u8 abort_running_scan;
+   struct wid wid;
+   struct host_if_drv *hif_drv = vif->hif_drv;
+   struct wilc_user_scan_req *scan_req;
+
+   if (evt == SCAN_EVENT_ABORTED) {
+   abort_running_scan = 1;
+   wid.id = WID_ABORT_RUNNING_SCAN;
+   wid.type = WID_CHAR;
+   wid.val = (s8 *)_running_scan;
+   wid.size = sizeof(char);
+
+   result = wilc_send_config_pkt(vif, WILC_SET_CFG, , 1);
+   if (result) {
+   netdev_err(vif->ndev, "Failed to set abort running\n");
+   result = -EFAULT;
+   }
+   }
+
+   if (!hif_drv) {
+   netdev_err(vif->ndev, "%s: hif driver is NULL\n", __func__);
+   return result;
+   }
+
+   scan_req = _drv->usr_scan_req;
+   if (scan_req->scan_result) {
+   scan_req->scan_result(evt, NULL, scan_req->arg);
+   scan_req->scan_result = NULL;
+   }
+
+   return result;
+}
+
+int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
+ u8 *ch_freq_list, u8 ch_list_len,
+ void (*scan_result_fn)(enum scan_event,
+struct wilc_rcvd_net_info *, void *),
+ void *user_arg, struct cfg80211_scan_request *request)
+{
+   int result = 0;
+   struct wid wid_list[5];
+   u32 

[PATCH v6 07/17] wilc1000: add cfg80211.h

2020-03-27 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/cfg80211.h' to
'drivers/net/wireless/microchip/wilc1000/cfg80211.h'.

Signed-off-by: Ajay Singh 
---
 .../wireless/microchip/wilc1000/cfg80211.h| 29 +++
 1 file changed, 29 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/cfg80211.h

diff --git a/drivers/net/wireless/microchip/wilc1000/cfg80211.h 
b/drivers/net/wireless/microchip/wilc1000/cfg80211.h
new file mode 100644
index ..5e5d63f70df2
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/cfg80211.h
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#ifndef WILC_CFG80211_H
+#define WILC_CFG80211_H
+#include "netdev.h"
+
+struct wiphy *wilc_cfg_alloc(void);
+int wilc_cfg80211_init(struct wilc **wilc, struct device *dev, int io_type,
+  const struct wilc_hif_func *ops);
+struct wilc *wilc_create_wiphy(struct device *dev);
+void wilc_deinit_host_int(struct net_device *net);
+int wilc_init_host_int(struct net_device *net);
+void wilc_wfi_monitor_rx(struct net_device *mon_dev, u8 *buff, u32 size);
+struct wilc_vif *wilc_netdev_interface(struct wilc *wl, const char *name,
+  enum nl80211_iftype type);
+void wilc_wfi_deinit_mon_interface(struct wilc *wl, bool rtnl_locked);
+struct net_device *wilc_wfi_init_mon_interface(struct wilc *wl,
+  const char *name,
+  struct net_device *real_dev);
+void wilc_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev,
+ u16 frame_type, bool reg);
+struct wilc_vif *wilc_get_interface(struct wilc *wl);
+struct wilc_vif *wilc_get_wl_to_vif(struct wilc *wl);
+void wlan_deinit_locks(struct wilc *wilc);
+#endif
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v6 03/17] wilc1000: add wlan_if.h

2020-03-27 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/wlan_if.h' to
'drivers/net/wireless/microchip/wilc1000/wlan_if.h'.

Signed-off-by: Ajay Singh 
---
 .../net/wireless/microchip/wilc1000/wlan_if.h | 803 ++
 1 file changed, 803 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/wlan_if.h

diff --git a/drivers/net/wireless/microchip/wilc1000/wlan_if.h 
b/drivers/net/wireless/microchip/wilc1000/wlan_if.h
new file mode 100644
index ..f85fd575136d
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/wlan_if.h
@@ -0,0 +1,803 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#ifndef WILC_WLAN_IF_H
+#define WILC_WLAN_IF_H
+
+#include 
+#include "fw.h"
+
+/
+ *
+ *  Wlan Configuration ID
+ *
+ /
+
+enum bss_types {
+   WILC_FW_BSS_TYPE_INFRA = 0,
+   WILC_FW_BSS_TYPE_INDEPENDENT,
+   WILC_FW_BSS_TYPE_AP,
+};
+
+enum {
+   WILC_FW_OPER_MODE_B_ONLY = 0,/* 1, 2 M, otherwise 5, 11 M */
+   WILC_FW_OPER_MODE_G_ONLY,/* 6,12,24 otherwise 9,18,36,48,54 */
+   WILC_FW_OPER_MODE_G_MIXED_11B_1, /* 1,2,5.5,11 otherwise all on */
+   WILC_FW_OPER_MODE_G_MIXED_11B_2, /* 1,2,5,11,6,12,24 otherwise all on */
+};
+
+enum {
+   WILC_FW_PREAMBLE_SHORT = 0, /* Short Preamble */
+   WILC_FW_PREAMBLE_LONG = 1,  /* Long Preamble */
+   WILC_FW_PREAMBLE_AUTO = 2,  /* Auto Preamble Selection */
+};
+
+enum {
+   WILC_FW_PASSIVE_SCAN = 0,
+   WILC_FW_ACTIVE_SCAN = 1,
+};
+
+enum {
+   WILC_FW_NO_POWERSAVE = 0,
+   WILC_FW_MIN_FAST_PS = 1,
+   WILC_FW_MAX_FAST_PS = 2,
+   WILC_FW_MIN_PSPOLL_PS = 3,
+   WILC_FW_MAX_PSPOLL_PS = 4
+};
+
+enum chip_ps_states {
+   WILC_CHIP_WAKEDUP = 0,
+   WILC_CHIP_SLEEPING_AUTO = 1,
+   WILC_CHIP_SLEEPING_MANUAL = 2
+};
+
+enum bus_acquire {
+   WILC_BUS_ACQUIRE_ONLY = 0,
+   WILC_BUS_ACQUIRE_AND_WAKEUP = 1,
+};
+
+enum bus_release {
+   WILC_BUS_RELEASE_ONLY = 0,
+   WILC_BUS_RELEASE_ALLOW_SLEEP = 1,
+};
+
+enum {
+   WILC_FW_NO_ENCRYPT = 0,
+   WILC_FW_ENCRYPT_ENABLED = BIT(0),
+   WILC_FW_WEP = BIT(1),
+   WILC_FW_WEP_EXTENDED = BIT(2),
+   WILC_FW_WPA = BIT(3),
+   WILC_FW_WPA2 = BIT(4),
+   WILC_FW_AES = BIT(5),
+   WILC_FW_TKIP = BIT(6)
+};
+
+enum {
+   WILC_FW_SEC_NO = WILC_FW_NO_ENCRYPT,
+   WILC_FW_SEC_WEP = WILC_FW_WEP | WILC_FW_ENCRYPT_ENABLED,
+   WILC_FW_SEC_WEP_EXTENDED = WILC_FW_WEP_EXTENDED | WILC_FW_SEC_WEP,
+   WILC_FW_SEC_WPA = WILC_FW_WPA | WILC_FW_ENCRYPT_ENABLED,
+   WILC_FW_SEC_WPA_AES = WILC_FW_AES | WILC_FW_SEC_WPA,
+   WILC_FW_SEC_WPA_TKIP = WILC_FW_TKIP | WILC_FW_SEC_WPA,
+   WILC_FW_SEC_WPA2 = WILC_FW_WPA2 | WILC_FW_ENCRYPT_ENABLED,
+   WILC_FW_SEC_WPA2_AES = WILC_FW_AES | WILC_FW_SEC_WPA2,
+   WILC_FW_SEC_WPA2_TKIP = WILC_FW_TKIP | WILC_FW_SEC_WPA2
+};
+
+enum authtype {
+   WILC_FW_AUTH_OPEN_SYSTEM = 1,
+   WILC_FW_AUTH_SHARED_KEY = 2,
+   WILC_FW_AUTH_ANY = 3,
+   WILC_FW_AUTH_IEEE8021 = 5
+};
+
+enum site_survey {
+   WILC_FW_SITE_SURVEY_1CH = 0,
+   WILC_FW_SITE_SURVEY_ALL_CH = 1,
+   WILC_FW_SITE_SURVEY_OFF = 2
+};
+
+enum {
+   WILC_FW_ACK_POLICY_NORMAL = 0,
+   WILC_FW_ACK_NO_POLICY,
+};
+
+enum {
+   WILC_FW_REKEY_POLICY_DISABLE = 1,
+   WILC_FW_REKEY_POLICY_TIME_BASE,
+   WILC_FW_REKEY_POLICY_PKT_BASE,
+   WILC_FW_REKEY_POLICY_TIME_PKT_BASE
+};
+
+enum {
+   WILC_FW_FILTER_NO = 0x00,
+   WILC_FW_FILTER_AP_ONLY = 0x01,
+   WILC_FW_FILTER_STA_ONLY = 0x02
+};
+
+enum {
+   WILC_FW_11N_PROT_AUTO = 0,  /* Auto */
+   WILC_FW_11N_NO_PROT,/* Do not use any protection */
+   WILC_FW_11N_PROT_ERP,   /* Protect all ERP frame exchanges */
+   WILC_FW_11N_PROT_HT,/* Protect all HT frame exchanges  */
+   WILC_FW_11N_PROT_GF /* Protect all GF frame exchanges  */
+};
+
+enum {
+   WILC_FW_ERP_PROT_SELF_CTS,
+   WILC_FW_ERP_PROT_RTS_CTS,
+};
+
+enum {
+   WILC_FW_11N_OP_MODE_HT_MIXED = 1,
+   WILC_FW_11N_OP_MODE_HT_ONLY_20MHZ,
+   WILC_FW_11N_OP_MODE_HT_ONLY_20_40MHZ,
+};
+
+enum {
+   WILC_FW_OBBS_NONHT_NO_DETECT = 0,
+   WILC_FW_OBBS_NONHT_DETECT_ONLY = 1,
+   WILC_FW_OBBS_NONHT_DETECT_PROTECT = 2,
+   WILC_FW_OBBS_NONHT_DETECT_PROTECT_REPORT = 3,
+};
+
+enum {
+   WILC_FW_HT_PROT_RTS_CTS_NONHT = 0,  /* RTS-CTS at non-HT rate */
+   WILC_FW_HT_PROT_FIRST_FRAME_NONHT,  /* First frame at non-HT rate */
+   WILC_FW_HT_PROT_LSIG_TXOP,  /* LSIG TXOP Protection */
+   WILC_FW_HT_PROT_FIRST_FRAME_MIXED,  /* First frame at Mixed format */
+};
+
+enum {
+   WILC_FW_SMPS_MODE_STATIC = 1,
+   WILC_FW_SMPS_MODE_DYNAMIC = 2,
+   WILC_FW_SMPS_MODE_MIMO = 3,  

[PATCH v6 09/17] wilc1000: add netdev.c

2020-03-27 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/netdev.c' to
'drivers/net/wireless/microchip/wilc1000/netdev.c'.

Signed-off-by: Ajay Singh 
---
 .../net/wireless/microchip/wilc1000/netdev.c  | 934 ++
 1 file changed, 934 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/netdev.c

diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.c 
b/drivers/net/wireless/microchip/wilc1000/netdev.c
new file mode 100644
index ..f94a17babd12
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/netdev.c
@@ -0,0 +1,934 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "cfg80211.h"
+#include "wlan_cfg.h"
+
+#define WILC_MULTICAST_TABLE_SIZE  8
+
+static irqreturn_t isr_uh_routine(int irq, void *user_data)
+{
+   struct net_device *dev = user_data;
+   struct wilc_vif *vif = netdev_priv(dev);
+   struct wilc *wilc = vif->wilc;
+
+   if (wilc->close) {
+   netdev_err(dev, "Can't handle UH interrupt\n");
+   return IRQ_HANDLED;
+   }
+   return IRQ_WAKE_THREAD;
+}
+
+static irqreturn_t isr_bh_routine(int irq, void *userdata)
+{
+   struct net_device *dev = userdata;
+   struct wilc_vif *vif = netdev_priv(userdata);
+   struct wilc *wilc = vif->wilc;
+
+   if (wilc->close) {
+   netdev_err(dev, "Can't handle BH interrupt\n");
+   return IRQ_HANDLED;
+   }
+
+   wilc_handle_isr(wilc);
+
+   return IRQ_HANDLED;
+}
+
+static int init_irq(struct net_device *dev)
+{
+   struct wilc_vif *vif = netdev_priv(dev);
+   struct wilc *wl = vif->wilc;
+   int ret;
+
+   ret = request_threaded_irq(wl->dev_irq_num, isr_uh_routine,
+  isr_bh_routine,
+  IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+  "WILC_IRQ", dev);
+   if (ret) {
+   netdev_err(dev, "Failed to request IRQ [%d]\n", ret);
+   return ret;
+   }
+   netdev_dbg(dev, "IRQ request succeeded IRQ-NUM= %d\n", wl->dev_irq_num);
+
+   return 0;
+}
+
+static void deinit_irq(struct net_device *dev)
+{
+   struct wilc_vif *vif = netdev_priv(dev);
+   struct wilc *wilc = vif->wilc;
+
+   /* Deinitialize IRQ */
+   if (wilc->dev_irq_num)
+   free_irq(wilc->dev_irq_num, wilc);
+}
+
+void wilc_mac_indicate(struct wilc *wilc)
+{
+   s8 status;
+
+   wilc_wlan_cfg_get_val(wilc, WID_STATUS, , 1);
+   if (wilc->mac_status == WILC_MAC_STATUS_INIT) {
+   wilc->mac_status = status;
+   complete(>sync_event);
+   } else {
+   wilc->mac_status = status;
+   }
+}
+
+static struct net_device *get_if_handler(struct wilc *wilc, u8 *mac_header)
+{
+   struct net_device *ndev = NULL;
+   struct wilc_vif *vif;
+   struct ieee80211_hdr *h = (struct ieee80211_hdr *)mac_header;
+
+   list_for_each_entry_rcu(vif, >vif_list, list) {
+   if (vif->mode == WILC_STATION_MODE)
+   if (ether_addr_equal_unaligned(h->addr2, vif->bssid)) {
+   ndev = vif->ndev;
+   goto out;
+   }
+   if (vif->mode == WILC_AP_MODE)
+   if (ether_addr_equal_unaligned(h->addr1, vif->bssid)) {
+   ndev = vif->ndev;
+   goto out;
+   }
+   }
+out:
+   return ndev;
+}
+
+void wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid, u8 mode)
+{
+   struct wilc_vif *vif = netdev_priv(wilc_netdev);
+
+   if (bssid)
+   ether_addr_copy(vif->bssid, bssid);
+   else
+   eth_zero_addr(vif->bssid);
+
+   vif->mode = mode;
+}
+
+int wilc_wlan_get_num_conn_ifcs(struct wilc *wilc)
+{
+   int srcu_idx;
+   u8 ret_val = 0;
+   struct wilc_vif *vif;
+
+   srcu_idx = srcu_read_lock(>srcu);
+   list_for_each_entry_rcu(vif, >vif_list, list) {
+   if (!is_zero_ether_addr(vif->bssid))
+   ret_val++;
+   }
+   srcu_read_unlock(>srcu, srcu_idx);
+   return ret_val;
+}
+
+static int wilc_txq_task(void *vp)
+{
+   int ret;
+   u32 txq_count;
+   struct wilc *wl = vp;
+
+   complete(>txq_thread_started);
+   while (1) {
+   wait_for_completion(>txq_event);
+
+   if (wl->close) {
+   complete(>txq_thread_started);
+
+   while (!kthread_should_stop())
+   schedule();
+   break;
+   }
+   do {
+   ret = wilc_wlan_handle_txq(wl, _count);
+   if (txq_count < 

[PATCH v6 05/17] wilc1000: add wlan_cfg.c

2020-03-27 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/wlan_cfg.c' to
'drivers/net/wireless/microchip/wilc1000/wlan_cfg.c'.

Signed-off-by: Ajay Singh 
---
 .../wireless/microchip/wilc1000/wlan_cfg.c| 413 ++
 1 file changed, 413 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/wlan_cfg.c

diff --git a/drivers/net/wireless/microchip/wilc1000/wlan_cfg.c 
b/drivers/net/wireless/microchip/wilc1000/wlan_cfg.c
new file mode 100644
index ..fe2a7ed8e5cd
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/wlan_cfg.c
@@ -0,0 +1,413 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#include 
+#include "wlan_if.h"
+#include "wlan.h"
+#include "wlan_cfg.h"
+#include "netdev.h"
+
+enum cfg_cmd_type {
+   CFG_BYTE_CMD= 0,
+   CFG_HWORD_CMD   = 1,
+   CFG_WORD_CMD= 2,
+   CFG_STR_CMD = 3,
+   CFG_BIN_CMD = 4
+};
+
+static const struct wilc_cfg_byte g_cfg_byte[] = {
+   {WID_STATUS, 0},
+   {WID_RSSI, 0},
+   {WID_LINKSPEED, 0},
+   {WID_NIL, 0}
+};
+
+static const struct wilc_cfg_hword g_cfg_hword[] = {
+   {WID_NIL, 0}
+};
+
+static const struct wilc_cfg_word g_cfg_word[] = {
+   {WID_FAILED_COUNT, 0},
+   {WID_RECEIVED_FRAGMENT_COUNT, 0},
+   {WID_SUCCESS_FRAME_COUNT, 0},
+   {WID_GET_INACTIVE_TIME, 0},
+   {WID_NIL, 0}
+
+};
+
+static const struct wilc_cfg_str g_cfg_str[] = {
+   {WID_FIRMWARE_VERSION, NULL},
+   {WID_MAC_ADDR, NULL},
+   {WID_ASSOC_RES_INFO, NULL},
+   {WID_NIL, NULL}
+};
+
+#define WILC_RESP_MSG_TYPE_CONFIG_REPLY'R'
+#define WILC_RESP_MSG_TYPE_STATUS_INFO 'I'
+#define WILC_RESP_MSG_TYPE_NETWORK_INFO'N'
+#define WILC_RESP_MSG_TYPE_SCAN_COMPLETE   'S'
+
+/
+ *
+ *  Configuration Functions
+ *
+ /
+
+static int wilc_wlan_cfg_set_byte(u8 *frame, u32 offset, u16 id, u8 val8)
+{
+   if ((offset + 4) >= WILC_MAX_CFG_FRAME_SIZE)
+   return 0;
+
+   put_unaligned_le16(id, [offset]);
+   put_unaligned_le16(1, [offset + 2]);
+   frame[offset + 4] = val8;
+   return 5;
+}
+
+static int wilc_wlan_cfg_set_hword(u8 *frame, u32 offset, u16 id, u16 val16)
+{
+   if ((offset + 5) >= WILC_MAX_CFG_FRAME_SIZE)
+   return 0;
+
+   put_unaligned_le16(id, [offset]);
+   put_unaligned_le16(2, [offset + 2]);
+   put_unaligned_le16(val16, [offset + 4]);
+
+   return 6;
+}
+
+static int wilc_wlan_cfg_set_word(u8 *frame, u32 offset, u16 id, u32 val32)
+{
+   if ((offset + 7) >= WILC_MAX_CFG_FRAME_SIZE)
+   return 0;
+
+   put_unaligned_le16(id, [offset]);
+   put_unaligned_le16(4, [offset + 2]);
+   put_unaligned_le32(val32, [offset + 4]);
+
+   return 8;
+}
+
+static int wilc_wlan_cfg_set_str(u8 *frame, u32 offset, u16 id, u8 *str,
+u32 size)
+{
+   if ((offset + size + 4) >= WILC_MAX_CFG_FRAME_SIZE)
+   return 0;
+
+   put_unaligned_le16(id, [offset]);
+   put_unaligned_le16(size, [offset + 2]);
+   if (str && size != 0)
+   memcpy([offset + 4], str, size);
+
+   return (size + 4);
+}
+
+static int wilc_wlan_cfg_set_bin(u8 *frame, u32 offset, u16 id, u8 *b, u32 
size)
+{
+   u32 i;
+   u8 checksum = 0;
+
+   if ((offset + size + 5) >= WILC_MAX_CFG_FRAME_SIZE)
+   return 0;
+
+   put_unaligned_le16(id, [offset]);
+   put_unaligned_le16(size, [offset + 2]);
+
+   if ((b) && size != 0) {
+   memcpy([offset + 4], b, size);
+   for (i = 0; i < size; i++)
+   checksum += frame[offset + i + 4];
+   }
+
+   frame[offset + size + 4] = checksum;
+
+   return (size + 5);
+}
+
+/
+ *
+ *  Configuration Response Functions
+ *
+ /
+
+static void wilc_wlan_parse_response_frame(struct wilc *wl, u8 *info, int size)
+{
+   u16 wid;
+   u32 len = 0, i = 0;
+   struct wilc_cfg *cfg = >cfg;
+
+   while (size > 0) {
+   i = 0;
+   wid = get_unaligned_le16(info);
+
+   switch (FIELD_GET(WILC_WID_TYPE, wid)) {
+   case WID_CHAR:
+   while (cfg->b[i].id != WID_NIL && cfg->b[i].id != wid)
+   i++;
+
+   if (cfg->b[i].id == wid)
+   cfg->b[i].val = info[4];
+
+   len = 3;
+   break;
+
+   case WID_SHORT:
+   while (cfg->hw[i].id != WID_NIL && cfg->hw[i].id != wid)
+   i++;
+
+   if (cfg->hw[i].id == wid)
+   

[PATCH v6 10/17] wilc1000: add mon.c

2020-03-27 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/mon.c' to
'drivers/net/wireless/microchip/wilc1000/mon.c'.

Signed-off-by: Ajay Singh 
---
 drivers/net/wireless/microchip/wilc1000/mon.c | 260 ++
 1 file changed, 260 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/mon.c

diff --git a/drivers/net/wireless/microchip/wilc1000/mon.c 
b/drivers/net/wireless/microchip/wilc1000/mon.c
new file mode 100644
index ..60331417bd98
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/mon.c
@@ -0,0 +1,260 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#include "cfg80211.h"
+
+struct wilc_wfi_radiotap_hdr {
+   struct ieee80211_radiotap_header hdr;
+   u8 rate;
+} __packed;
+
+struct wilc_wfi_radiotap_cb_hdr {
+   struct ieee80211_radiotap_header hdr;
+   u8 rate;
+   u8 dump;
+   u16 tx_flags;
+} __packed;
+
+#define TX_RADIOTAP_PRESENT ((1 << IEEE80211_RADIOTAP_RATE) |  \
+(1 << IEEE80211_RADIOTAP_TX_FLAGS))
+
+void wilc_wfi_monitor_rx(struct net_device *mon_dev, u8 *buff, u32 size)
+{
+   u32 header, pkt_offset;
+   struct sk_buff *skb = NULL;
+   struct wilc_wfi_radiotap_hdr *hdr;
+   struct wilc_wfi_radiotap_cb_hdr *cb_hdr;
+
+   if (!mon_dev)
+   return;
+
+   if (!netif_running(mon_dev))
+   return;
+
+   /* Get WILC header */
+   header = get_unaligned_le32(buff - HOST_HDR_OFFSET);
+   /*
+* The packet offset field contain info about what type of management
+* the frame we are dealing with and ack status
+*/
+   pkt_offset = FIELD_GET(WILC_PKT_HDR_OFFSET_FIELD, header);
+
+   if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {
+   /* hostapd callback mgmt frame */
+
+   skb = dev_alloc_skb(size + sizeof(*cb_hdr));
+   if (!skb)
+   return;
+
+   skb_put_data(skb, buff, size);
+
+   cb_hdr = skb_push(skb, sizeof(*cb_hdr));
+   memset(cb_hdr, 0, sizeof(*cb_hdr));
+
+   cb_hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */
+
+   cb_hdr->hdr.it_len = cpu_to_le16(sizeof(*cb_hdr));
+
+   cb_hdr->hdr.it_present = cpu_to_le32(TX_RADIOTAP_PRESENT);
+
+   cb_hdr->rate = 5;
+
+   if (pkt_offset & IS_MGMT_STATUS_SUCCES) {
+   /* success */
+   cb_hdr->tx_flags = IEEE80211_RADIOTAP_F_TX_RTS;
+   } else {
+   cb_hdr->tx_flags = IEEE80211_RADIOTAP_F_TX_FAIL;
+   }
+
+   } else {
+   skb = dev_alloc_skb(size + sizeof(*hdr));
+
+   if (!skb)
+   return;
+
+   skb_put_data(skb, buff, size);
+   hdr = skb_push(skb, sizeof(*hdr));
+   memset(hdr, 0, sizeof(struct wilc_wfi_radiotap_hdr));
+   hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */
+   hdr->hdr.it_len = cpu_to_le16(sizeof(*hdr));
+   hdr->hdr.it_present = cpu_to_le32
+   (1 << IEEE80211_RADIOTAP_RATE);
+   hdr->rate = 5;
+   }
+
+   skb->dev = mon_dev;
+   skb_reset_mac_header(skb);
+   skb->ip_summed = CHECKSUM_UNNECESSARY;
+   skb->pkt_type = PACKET_OTHERHOST;
+   skb->protocol = htons(ETH_P_802_2);
+   memset(skb->cb, 0, sizeof(skb->cb));
+
+   netif_rx(skb);
+}
+
+struct tx_complete_mon_data {
+   int size;
+   void *buff;
+};
+
+static void mgmt_tx_complete(void *priv, int status)
+{
+   struct tx_complete_mon_data *pv_data = priv;
+   /*
+* in case of fully hosting mode, the freeing will be done
+* in response to the cfg packet
+*/
+   kfree(pv_data->buff);
+
+   kfree(pv_data);
+}
+
+static int mon_mgmt_tx(struct net_device *dev, const u8 *buf, size_t len)
+{
+   struct tx_complete_mon_data *mgmt_tx = NULL;
+
+   if (!dev)
+   return -EFAULT;
+
+   netif_stop_queue(dev);
+   mgmt_tx = kmalloc(sizeof(*mgmt_tx), GFP_ATOMIC);
+   if (!mgmt_tx)
+   return -ENOMEM;
+
+   mgmt_tx->buff = kmemdup(buf, len, GFP_ATOMIC);
+   if (!mgmt_tx->buff) {
+   kfree(mgmt_tx);
+   return -ENOMEM;
+   }
+
+   mgmt_tx->size = len;
+
+   wilc_wlan_txq_add_mgmt_pkt(dev, mgmt_tx, mgmt_tx->buff, mgmt_tx->size,
+  mgmt_tx_complete);
+
+   netif_wake_queue(dev);
+   return 0;
+}
+
+static netdev_tx_t wilc_wfi_mon_xmit(struct sk_buff *skb,
+struct net_device *dev)
+{
+   u32 rtap_len, ret = 0;
+   struct wilc_wfi_mon_priv  *mon_priv;
+   struct sk_buff *skb2;
+   struct wilc_wfi_radiotap_cb_hdr *cb_hdr;
+   u8 srcadd[ETH_ALEN];
+   

[PATCH v6 16/17] dt: bindings: net: add microchip,wilc1000.yaml

2020-03-27 Thread Ajay.Kathat
From: Ajay Singh 

This file describes the binding details to connect wilc1000 device. It's
moved from staging to 'Documentation/devicetree/bindings/net/wireless'
path.

Signed-off-by: Ajay Singh 
---
 .../net/wireless/microchip,wilc1000.yaml  | 71 +++
 1 file changed, 71 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml

diff --git 
a/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml 
b/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml
new file mode 100644
index ..2c320eb2a8c4
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml
@@ -0,0 +1,71 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/wireless/microchip,wilc1000.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Microchip WILC wireless devicetree bindings
+
+maintainers:
+  - Adham Abozaeid 
+  - Ajay Singh 
+
+description:
+  The wilc1000 chips can be connected via SPI or SDIO. This document
+  describes the binding to connect wilc devices.
+
+properties:
+  compatible:
+const: microchip,wilc1000
+
+  spi-max-frequency: true
+
+  interrupts:
+maxItems: 1
+
+  clocks:
+description: phandle to the clock connected on rtc clock line.
+maxItems: 1
+
+  clock-names:
+const: rtc
+
+required:
+  - compatible
+  - interrupts
+
+examples:
+  - |
+spi {
+  #address-cells = <1>;
+  #size-cells = <0>;
+  wifi@0 {
+compatible = "microchip,wilc1000";
+spi-max-frequency = <4800>;
+reg = <0>;
+interrupt-parent = <>;
+interrupts = <27 0>;
+clocks = <>;
+clock-names = "rtc";
+  };
+};
+
+  - |
+mmc {
+  #address-cells = <1>;
+  #size-cells = <0>;
+  pinctrl-names = "default";
+  pinctrl-0 = <_mmc1_clk_cmd_dat0 _mmc1_dat1_3>;
+  non-removable;
+  vmmc-supply = <_mmc1_reg>;
+  vqmmc-supply = <_3v3_reg>;
+  bus-width = <4>;
+  wifi@0 {
+compatible = "microchip,wilc1000";
+reg = <0>;
+interrupt-parent = <>;
+interrupts = <27 0>;
+clocks = <>;
+clock-names = "rtc";
+  };
+};
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v6 08/17] wilc1000: add netdev.h

2020-03-27 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/netdev.h' to
'drivers/net/wireless/microchip/wilc1000/netdev.h'.

Signed-off-by: Ajay Singh 
---
 .../net/wireless/microchip/wilc1000/netdev.h  | 294 ++
 1 file changed, 294 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/netdev.h

diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.h 
b/drivers/net/wireless/microchip/wilc1000/netdev.h
new file mode 100644
index ..61cbec674a62
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/netdev.h
@@ -0,0 +1,294 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#ifndef WILC_NETDEV_H
+#define WILC_NETDEV_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "hif.h"
+#include "wlan.h"
+#include "wlan_cfg.h"
+
+#define FLOW_CONTROL_LOWER_THRESHOLD   128
+#define FLOW_CONTROL_UPPER_THRESHOLD   256
+
+#define PMKID_FOUND1
+#define NUM_STA_ASSOCIATED 8
+
+#define NUM_REG_FRAME  2
+
+#define TCP_ACK_FILTER_LINK_SPEED_THRESH   54
+#define DEFAULT_LINK_SPEED 72
+
+struct wilc_wfi_stats {
+   unsigned long rx_packets;
+   unsigned long tx_packets;
+   unsigned long rx_bytes;
+   unsigned long tx_bytes;
+   u64 rx_time;
+   u64 tx_time;
+
+};
+
+struct wilc_wfi_key {
+   u8 *key;
+   u8 *seq;
+   int key_len;
+   int seq_len;
+   u32 cipher;
+};
+
+struct wilc_wfi_wep_key {
+   u8 *key;
+   u8 key_len;
+   u8 key_idx;
+};
+
+struct sta_info {
+   u8 sta_associated_bss[WILC_MAX_NUM_STA][ETH_ALEN];
+};
+
+/* Parameters needed for host interface for remaining on channel */
+struct wilc_wfi_p2p_listen_params {
+   struct ieee80211_channel *listen_ch;
+   u32 listen_duration;
+   u64 listen_cookie;
+};
+
+static const u32 wilc_cipher_suites[] = {
+   WLAN_CIPHER_SUITE_WEP40,
+   WLAN_CIPHER_SUITE_WEP104,
+   WLAN_CIPHER_SUITE_TKIP,
+   WLAN_CIPHER_SUITE_CCMP,
+   WLAN_CIPHER_SUITE_AES_CMAC
+};
+
+#define CHAN2G(_channel, _freq, _flags) {   \
+   .band = NL80211_BAND_2GHZ, \
+   .center_freq  = (_freq), \
+   .hw_value = (_channel),  \
+   .flags= (_flags),\
+   .max_antenna_gain = 0,   \
+   .max_power= 30,  \
+}
+
+static const struct ieee80211_channel wilc_2ghz_channels[] = {
+   CHAN2G(1,  2412, 0),
+   CHAN2G(2,  2417, 0),
+   CHAN2G(3,  2422, 0),
+   CHAN2G(4,  2427, 0),
+   CHAN2G(5,  2432, 0),
+   CHAN2G(6,  2437, 0),
+   CHAN2G(7,  2442, 0),
+   CHAN2G(8,  2447, 0),
+   CHAN2G(9,  2452, 0),
+   CHAN2G(10, 2457, 0),
+   CHAN2G(11, 2462, 0),
+   CHAN2G(12, 2467, 0),
+   CHAN2G(13, 2472, 0),
+   CHAN2G(14, 2484, 0)
+};
+
+#define RATETAB_ENT(_rate, _hw_value, _flags) {\
+   .bitrate  = (_rate),\
+   .hw_value = (_hw_value),\
+   .flags= (_flags),   \
+}
+
+static struct ieee80211_rate wilc_bitrates[] = {
+   RATETAB_ENT(10,  0,  0),
+   RATETAB_ENT(20,  1,  0),
+   RATETAB_ENT(55,  2,  0),
+   RATETAB_ENT(110, 3,  0),
+   RATETAB_ENT(60,  9,  0),
+   RATETAB_ENT(90,  6,  0),
+   RATETAB_ENT(120, 7,  0),
+   RATETAB_ENT(180, 8,  0),
+   RATETAB_ENT(240, 9,  0),
+   RATETAB_ENT(360, 10, 0),
+   RATETAB_ENT(480, 11, 0),
+   RATETAB_ENT(540, 12, 0)
+};
+
+struct wilc_priv {
+   struct wireless_dev wdev;
+   struct cfg80211_scan_request *scan_req;
+
+   struct wilc_wfi_p2p_listen_params remain_on_ch_params;
+   u64 tx_cookie;
+
+   bool cfg_scanning;
+
+   u8 associated_bss[ETH_ALEN];
+   struct sta_info assoc_stainfo;
+   struct sk_buff *skb;
+   struct net_device *dev;
+   struct host_if_drv *hif_drv;
+   struct wilc_pmkid_attr pmkid_list;
+   u8 wep_key[4][WLAN_KEY_LEN_WEP104];
+   u8 wep_key_len[4];
+
+   /* The real interface that the monitor is on */
+   struct net_device *real_ndev;
+   struct wilc_wfi_key *wilc_gtk[WILC_MAX_NUM_STA];
+   struct wilc_wfi_key *wilc_ptk[WILC_MAX_NUM_STA];
+   u8 wilc_groupkey;
+
+   /* mutexes */
+   struct mutex scan_req_lock;
+   bool p2p_listen_state;
+   int scanned_cnt;
+
+   u64 inc_roc_cookie;
+};
+
+struct frame_reg {
+   u16 type;
+   bool reg;
+};
+
+#define MAX_TCP_SESSION25
+#define MAX_PENDING_ACKS   256
+
+struct ack_session_info {
+   u32 seq_num;
+   u32 bigger_ack_num;
+   u16 src_port;
+   u16 dst_port;
+   u16 status;
+};
+
+struct pending_acks {
+   u32 ack_num;
+   u32 session_index;
+   struct 

[PATCH v6 04/17] wilc1000: add wlan_cfg.h

2020-03-27 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/wlan_cfg.h' to
'drivers/net/wireless/microchip/wilc1000/wlan_cfg.h'.

Signed-off-by: Ajay Singh 
---
 .../wireless/microchip/wilc1000/wlan_cfg.h| 54 +++
 1 file changed, 54 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/wlan_cfg.h

diff --git a/drivers/net/wireless/microchip/wilc1000/wlan_cfg.h 
b/drivers/net/wireless/microchip/wilc1000/wlan_cfg.h
new file mode 100644
index ..614c5673f232
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/wlan_cfg.h
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#ifndef WILC_WLAN_CFG_H
+#define WILC_WLAN_CFG_H
+
+struct wilc_cfg_byte {
+   u16 id;
+   u8 val;
+};
+
+struct wilc_cfg_hword {
+   u16 id;
+   u16 val;
+};
+
+struct wilc_cfg_word {
+   u16 id;
+   u32 val;
+};
+
+struct wilc_cfg_str {
+   u16 id;
+   u8 *str;
+};
+
+struct wilc_cfg_str_vals {
+   u8 mac_address[7];
+   u8 firmware_version[129];
+   u8 assoc_rsp[256];
+};
+
+struct wilc_cfg {
+   struct wilc_cfg_byte *b;
+   struct wilc_cfg_hword *hw;
+   struct wilc_cfg_word *w;
+   struct wilc_cfg_str *s;
+   struct wilc_cfg_str_vals *str_vals;
+};
+
+struct wilc;
+int wilc_wlan_cfg_set_wid(u8 *frame, u32 offset, u16 id, u8 *buf, int size);
+int wilc_wlan_cfg_get_wid(u8 *frame, u32 offset, u16 id);
+int wilc_wlan_cfg_get_val(struct wilc *wl, u16 wid, u8 *buffer,
+ u32 buffer_size);
+void wilc_wlan_cfg_indicate_rx(struct wilc *wilc, u8 *frame, int size,
+  struct wilc_cfg_rsp *rsp);
+int wilc_wlan_cfg_init(struct wilc *wl);
+void wilc_wlan_cfg_deinit(struct wilc *wl);
+
+#endif
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v6 15/17] wilc1000: add fw.h

2020-03-27 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/fw.h' to
'drivers/net/wireless/microchip/wilc1000/fw.h'.

Signed-off-by: Ajay Singh 
---
 drivers/net/wireless/microchip/wilc1000/fw.h | 119 +++
 1 file changed, 119 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/fw.h

diff --git a/drivers/net/wireless/microchip/wilc1000/fw.h 
b/drivers/net/wireless/microchip/wilc1000/fw.h
new file mode 100644
index ..a76e1dea4345
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/fw.h
@@ -0,0 +1,119 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#ifndef WILC_FW_H
+#define WILC_FW_H
+
+#include 
+
+#define WILC_MAX_NUM_STA   9
+#define WILC_MAX_RATES_SUPPORTED   12
+#define WILC_MAX_NUM_PMKIDS16
+#define WILC_MAX_NUM_SCANNED_CH14
+
+struct wilc_assoc_resp {
+   __le16 capab_info;
+   __le16 status_code;
+   __le16 aid;
+} __packed;
+
+struct wilc_pmkid {
+   u8 bssid[ETH_ALEN];
+   u8 pmkid[WLAN_PMKID_LEN];
+} __packed;
+
+struct wilc_pmkid_attr {
+   u8 numpmkid;
+   struct wilc_pmkid pmkidlist[WILC_MAX_NUM_PMKIDS];
+} __packed;
+
+struct wilc_reg_frame {
+   u8 reg;
+   u8 reg_id;
+   __le16 frame_type;
+} __packed;
+
+struct wilc_drv_handler {
+   __le32 handler;
+   u8 mode;
+} __packed;
+
+struct wilc_wep_key {
+   u8 index;
+   u8 key_len;
+   u8 key[0];
+} __packed;
+
+struct wilc_sta_wpa_ptk {
+   u8 mac_addr[ETH_ALEN];
+   u8 key_len;
+   u8 key[0];
+} __packed;
+
+struct wilc_ap_wpa_ptk {
+   u8 mac_addr[ETH_ALEN];
+   u8 index;
+   u8 key_len;
+   u8 key[0];
+} __packed;
+
+struct wilc_gtk_key {
+   u8 mac_addr[ETH_ALEN];
+   u8 rsc[8];
+   u8 index;
+   u8 key_len;
+   u8 key[0];
+} __packed;
+
+struct wilc_op_mode {
+   __le32 mode;
+} __packed;
+
+struct wilc_noa_opp_enable {
+   u8 ct_window;
+   u8 cnt;
+   __le32 duration;
+   __le32 interval;
+   __le32 start_time;
+} __packed;
+
+struct wilc_noa_opp_disable {
+   u8 cnt;
+   __le32 duration;
+   __le32 interval;
+   __le32 start_time;
+} __packed;
+
+struct wilc_join_bss_param {
+   char ssid[IEEE80211_MAX_SSID_LEN];
+   u8 ssid_terminator;
+   u8 bss_type;
+   u8 ch;
+   __le16 cap_info;
+   u8 sa[ETH_ALEN];
+   u8 bssid[ETH_ALEN];
+   __le16 beacon_period;
+   u8 dtim_period;
+   u8 supp_rates[WILC_MAX_RATES_SUPPORTED + 1];
+   u8 wmm_cap;
+   u8 uapsd_cap;
+   u8 ht_capable;
+   u8 rsn_found;
+   u8 rsn_grp_policy;
+   u8 mode_802_11i;
+   u8 p_suites[3];
+   u8 akm_suites[3];
+   u8 rsn_cap[2];
+   u8 noa_enabled;
+   __le32 tsf_lo;
+   u8 idx;
+   u8 opp_enabled;
+   union {
+   struct wilc_noa_opp_disable opp_dis;
+   struct wilc_noa_opp_enable opp_en;
+   };
+} __packed;
+#endif
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v6 12/17] wilc1000: add wlan.h

2020-03-27 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/wlan.h' to
'drivers/net/wireless/microchip/wilc1000/wlan.h'.

Signed-off-by: Ajay Singh 
---
 .../net/wireless/microchip/wilc1000/wlan.h| 397 ++
 1 file changed, 397 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/wlan.h

diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.h 
b/drivers/net/wireless/microchip/wilc1000/wlan.h
new file mode 100644
index ..7689569cd82f
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/wlan.h
@@ -0,0 +1,397 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#ifndef WILC_WLAN_H
+#define WILC_WLAN_H
+
+#include 
+#include 
+
+/
+ *
+ *  Mac eth header length
+ *
+ /
+#define MAX_MAC_HDR_LEN26 /* QOS_MAC_HDR_LEN */
+#define SUB_MSDU_HEADER_LENGTH 14
+#define SNAP_HDR_LEN   8
+#define ETHERNET_HDR_LEN   14
+#define WORD_ALIGNMENT_PAD 0
+
+#define ETH_ETHERNET_HDR_OFFSET(MAX_MAC_HDR_LEN + \
+SUB_MSDU_HEADER_LENGTH + \
+SNAP_HDR_LEN - \
+ETHERNET_HDR_LEN + \
+WORD_ALIGNMENT_PAD)
+
+#define HOST_HDR_OFFSET4
+#define ETHERNET_HDR_LEN   14
+#define IP_HDR_LEN 20
+#define IP_HDR_OFFSET  ETHERNET_HDR_LEN
+#define UDP_HDR_OFFSET (IP_HDR_LEN + IP_HDR_OFFSET)
+#define UDP_HDR_LEN8
+#define UDP_DATA_OFFSET(UDP_HDR_OFFSET + UDP_HDR_LEN)
+#define ETH_CONFIG_PKT_HDR_LEN UDP_DATA_OFFSET
+
+#define ETH_CONFIG_PKT_HDR_OFFSET  (ETH_ETHERNET_HDR_OFFSET + \
+ETH_CONFIG_PKT_HDR_LEN)
+
+/
+ *
+ *  Register Defines
+ *
+ /
+#define WILC_PERIPH_REG_BASE   0x1000
+#define WILC_CHANGING_VIR_IF   0x108c
+#define WILC_CHIPIDWILC_PERIPH_REG_BASE
+#define WILC_GLB_RESET_0   (WILC_PERIPH_REG_BASE + 0x400)
+#define WILC_PIN_MUX_0 (WILC_PERIPH_REG_BASE + 0x408)
+#define WILC_HOST_TX_CTRL  (WILC_PERIPH_REG_BASE + 0x6c)
+#define WILC_HOST_RX_CTRL_0(WILC_PERIPH_REG_BASE + 0x70)
+#define WILC_HOST_RX_CTRL_1(WILC_PERIPH_REG_BASE + 0x74)
+#define WILC_HOST_VMM_CTL  (WILC_PERIPH_REG_BASE + 0x78)
+#define WILC_HOST_RX_CTRL  (WILC_PERIPH_REG_BASE + 0x80)
+#define WILC_HOST_RX_EXTRA_SIZE(WILC_PERIPH_REG_BASE + 0x84)
+#define WILC_HOST_TX_CTRL_1(WILC_PERIPH_REG_BASE + 0x88)
+#define WILC_MISC  (WILC_PERIPH_REG_BASE + 0x428)
+#define WILC_INTR_REG_BASE (WILC_PERIPH_REG_BASE + 0xa00)
+#define WILC_INTR_ENABLE   WILC_INTR_REG_BASE
+#define WILC_INTR2_ENABLE  (WILC_INTR_REG_BASE + 4)
+
+#define WILC_INTR_POLARITY (WILC_INTR_REG_BASE + 0x10)
+#define WILC_INTR_TYPE (WILC_INTR_REG_BASE + 0x20)
+#define WILC_INTR_CLEAR(WILC_INTR_REG_BASE + 0x30)
+#define WILC_INTR_STATUS   (WILC_INTR_REG_BASE + 0x40)
+
+#define WILC_RF_REVISION_ID0x13f4
+
+#define WILC_VMM_TBL_SIZE  64
+#define WILC_VMM_TX_TBL_BASE   0x150400
+#define WILC_VMM_RX_TBL_BASE   0x150500
+
+#define WILC_VMM_BASE  0x15
+#define WILC_VMM_CORE_CTL  WILC_VMM_BASE
+#define WILC_VMM_TBL_CTL   (WILC_VMM_BASE + 0x4)
+#define WILC_VMM_TBL_ENTRY (WILC_VMM_BASE + 0x8)
+#define WILC_VMM_TBL0_SIZE (WILC_VMM_BASE + 0xc)
+#define WILC_VMM_TO_HOST_SIZE  (WILC_VMM_BASE + 0x10)
+#define WILC_VMM_CORE_CFG  (WILC_VMM_BASE + 0x14)
+#define WILC_VMM_TBL_ACTIVE(WILC_VMM_BASE + 040)
+#define WILC_VMM_TBL_STATUS(WILC_VMM_BASE + 0x44)
+
+#define WILC_SPI_REG_BASE  0xe800
+#define WILC_SPI_CTL   WILC_SPI_REG_BASE
+#define WILC_SPI_MASTER_DMA_ADDR   (WILC_SPI_REG_BASE + 0x4)
+#define WILC_SPI_MASTER_DMA_COUNT  (WILC_SPI_REG_BASE + 0x8)
+#define WILC_SPI_SLAVE_DMA_ADDR(WILC_SPI_REG_BASE + 0xc)
+#define WILC_SPI_SLAVE_DMA_COUNT   (WILC_SPI_REG_BASE + 0x10)
+#define WILC_SPI_TX_MODE   (WILC_SPI_REG_BASE + 0x20)
+#define WILC_SPI_PROTOCOL_CONFIG   (WILC_SPI_REG_BASE + 0x24)
+#define WILC_SPI_INTR_CTL  (WILC_SPI_REG_BASE + 0x2c)
+#define WILC_SPI_INT_STATUS(WILC_SPI_REG_BASE + 0x40)
+#define WILC_SPI_INT_CLEAR (WILC_SPI_REG_BASE + 0x44)
+
+#define 

[PATCH v6 13/17] wilc1000: add wlan.c

2020-03-27 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/wlan.c' to
'drivers/net/wireless/microchip/wilc1000/wlan.c'.

Signed-off-by: Ajay Singh 
---
 .../net/wireless/microchip/wilc1000/wlan.c| 1238 +
 1 file changed, 1238 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/wlan.c

diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c 
b/drivers/net/wireless/microchip/wilc1000/wlan.c
new file mode 100644
index ..6a82fb2f283e
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/wlan.c
@@ -0,0 +1,1238 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#include 
+#include 
+#include "cfg80211.h"
+#include "wlan_cfg.h"
+
+static inline bool is_wilc1000(u32 id)
+{
+   return (id & (~WILC_CHIP_REV_FIELD)) == WILC_1000_BASE_ID;
+}
+
+static inline void acquire_bus(struct wilc *wilc, enum bus_acquire acquire)
+{
+   mutex_lock(>hif_cs);
+   if (acquire == WILC_BUS_ACQUIRE_AND_WAKEUP)
+   chip_wakeup(wilc);
+}
+
+static inline void release_bus(struct wilc *wilc, enum bus_release release)
+{
+   if (release == WILC_BUS_RELEASE_ALLOW_SLEEP)
+   chip_allow_sleep(wilc);
+   mutex_unlock(>hif_cs);
+}
+
+static void wilc_wlan_txq_remove(struct wilc *wilc, struct txq_entry_t *tqe)
+{
+   list_del(>list);
+   wilc->txq_entries -= 1;
+}
+
+static struct txq_entry_t *
+wilc_wlan_txq_remove_from_head(struct net_device *dev)
+{
+   struct txq_entry_t *tqe = NULL;
+   unsigned long flags;
+   struct wilc_vif *vif = netdev_priv(dev);
+   struct wilc *wilc = vif->wilc;
+
+   spin_lock_irqsave(>txq_spinlock, flags);
+
+   if (!list_empty(>txq_head.list)) {
+   tqe = list_first_entry(>txq_head.list, struct txq_entry_t,
+  list);
+   list_del(>list);
+   wilc->txq_entries -= 1;
+   }
+   spin_unlock_irqrestore(>txq_spinlock, flags);
+   return tqe;
+}
+
+static void wilc_wlan_txq_add_to_tail(struct net_device *dev,
+ struct txq_entry_t *tqe)
+{
+   unsigned long flags;
+   struct wilc_vif *vif = netdev_priv(dev);
+   struct wilc *wilc = vif->wilc;
+
+   spin_lock_irqsave(>txq_spinlock, flags);
+
+   list_add_tail(>list, >txq_head.list);
+   wilc->txq_entries += 1;
+
+   spin_unlock_irqrestore(>txq_spinlock, flags);
+
+   complete(>txq_event);
+}
+
+static void wilc_wlan_txq_add_to_head(struct wilc_vif *vif,
+ struct txq_entry_t *tqe)
+{
+   unsigned long flags;
+   struct wilc *wilc = vif->wilc;
+
+   mutex_lock(>txq_add_to_head_cs);
+
+   spin_lock_irqsave(>txq_spinlock, flags);
+
+   list_add(>list, >txq_head.list);
+   wilc->txq_entries += 1;
+
+   spin_unlock_irqrestore(>txq_spinlock, flags);
+   mutex_unlock(>txq_add_to_head_cs);
+   complete(>txq_event);
+}
+
+#define NOT_TCP_ACK(-1)
+
+static inline void add_tcp_session(struct wilc_vif *vif, u32 src_prt,
+  u32 dst_prt, u32 seq)
+{
+   struct tcp_ack_filter *f = >ack_filter;
+
+   if (f->tcp_session < 2 * MAX_TCP_SESSION) {
+   f->ack_session_info[f->tcp_session].seq_num = seq;
+   f->ack_session_info[f->tcp_session].bigger_ack_num = 0;
+   f->ack_session_info[f->tcp_session].src_port = src_prt;
+   f->ack_session_info[f->tcp_session].dst_port = dst_prt;
+   f->tcp_session++;
+   }
+}
+
+static inline void update_tcp_session(struct wilc_vif *vif, u32 index, u32 ack)
+{
+   struct tcp_ack_filter *f = >ack_filter;
+
+   if (index < 2 * MAX_TCP_SESSION &&
+   ack > f->ack_session_info[index].bigger_ack_num)
+   f->ack_session_info[index].bigger_ack_num = ack;
+}
+
+static inline void add_tcp_pending_ack(struct wilc_vif *vif, u32 ack,
+  u32 session_index,
+  struct txq_entry_t *txqe)
+{
+   struct tcp_ack_filter *f = >ack_filter;
+   u32 i = f->pending_base + f->pending_acks_idx;
+
+   if (i < MAX_PENDING_ACKS) {
+   f->pending_acks[i].ack_num = ack;
+   f->pending_acks[i].txqe = txqe;
+   f->pending_acks[i].session_index = session_index;
+   txqe->ack_idx = i;
+   f->pending_acks_idx++;
+   }
+}
+
+static inline void tcp_process(struct net_device *dev, struct txq_entry_t *tqe)
+{
+   void *buffer = tqe->buffer;
+   const struct ethhdr *eth_hdr_ptr = buffer;
+   int i;
+   unsigned long flags;
+   struct wilc_vif *vif = netdev_priv(dev);
+   struct wilc *wilc = vif->wilc;
+   struct tcp_ack_filter *f = >ack_filter;
+   const struct iphdr *ip_hdr_ptr;
+   const struct tcphdr *tcp_hdr_ptr;
+  

[PATCH v6 01/17] wilc1000: add hif.h

2020-03-27 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/hif.h' to
'drivers/net/wireless/microchip/wilc1000/hif.h'.

Signed-off-by: Ajay Singh 
---
 drivers/net/wireless/microchip/wilc1000/hif.h | 214 ++
 1 file changed, 214 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/hif.h

diff --git a/drivers/net/wireless/microchip/wilc1000/hif.h 
b/drivers/net/wireless/microchip/wilc1000/hif.h
new file mode 100644
index ..db9179171f05
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/hif.h
@@ -0,0 +1,214 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries
+ * All rights reserved.
+ */
+
+#ifndef WILC_HIF_H
+#define WILC_HIF_H
+#include 
+#include "wlan_if.h"
+
+enum {
+   WILC_IDLE_MODE = 0x0,
+   WILC_AP_MODE = 0x1,
+   WILC_STATION_MODE = 0x2,
+   WILC_GO_MODE = 0x3,
+   WILC_CLIENT_MODE = 0x4
+};
+
+#define WILC_MAX_NUM_PROBED_SSID   10
+
+#define WILC_TX_MIC_KEY_LEN8
+#define WILC_RX_MIC_KEY_LEN8
+
+#define WILC_ADD_STA_LENGTH40
+#define WILC_NUM_CONCURRENT_IFC2
+
+enum {
+   WILC_SET_CFG = 0,
+   WILC_GET_CFG
+};
+
+#define WILC_MAX_ASSOC_RESP_FRAME_SIZE   256
+
+struct rf_info {
+   u8 link_speed;
+   s8 rssi;
+   u32 tx_cnt;
+   u32 rx_cnt;
+   u32 tx_fail_cnt;
+};
+
+enum host_if_state {
+   HOST_IF_IDLE= 0,
+   HOST_IF_SCANNING= 1,
+   HOST_IF_CONNECTING  = 2,
+   HOST_IF_WAITING_CONN_RESP   = 3,
+   HOST_IF_CONNECTED   = 4,
+   HOST_IF_P2P_LISTEN  = 5,
+   HOST_IF_FORCE_32BIT = 0x
+};
+
+struct cfg_param_attr {
+   u32 flag;
+   u16 short_retry_limit;
+   u16 long_retry_limit;
+   u16 frag_threshold;
+   u16 rts_threshold;
+};
+
+enum cfg_param {
+   WILC_CFG_PARAM_RETRY_SHORT = BIT(0),
+   WILC_CFG_PARAM_RETRY_LONG = BIT(1),
+   WILC_CFG_PARAM_FRAG_THRESHOLD = BIT(2),
+   WILC_CFG_PARAM_RTS_THRESHOLD = BIT(3)
+};
+
+enum scan_event {
+   SCAN_EVENT_NETWORK_FOUND= 0,
+   SCAN_EVENT_DONE = 1,
+   SCAN_EVENT_ABORTED  = 2,
+   SCAN_EVENT_FORCE_32BIT  = 0x
+};
+
+enum conn_event {
+   CONN_DISCONN_EVENT_CONN_RESP= 0,
+   CONN_DISCONN_EVENT_DISCONN_NOTIF= 1,
+   CONN_DISCONN_EVENT_FORCE_32BIT  = 0x
+};
+
+enum {
+   WILC_HIF_SDIO = 0,
+   WILC_HIF_SPI = BIT(0)
+};
+
+enum {
+   WILC_MAC_STATUS_INIT = -1,
+   WILC_MAC_STATUS_DISCONNECTED = 0,
+   WILC_MAC_STATUS_CONNECTED = 1
+};
+
+struct wilc_rcvd_net_info {
+   s8 rssi;
+   u8 ch;
+   u16 frame_len;
+   struct ieee80211_mgmt *mgmt;
+};
+
+struct wilc_user_scan_req {
+   void (*scan_result)(enum scan_event evt,
+   struct wilc_rcvd_net_info *info, void *priv);
+   void *arg;
+   u32 ch_cnt;
+};
+
+struct wilc_conn_info {
+   u8 bssid[ETH_ALEN];
+   u8 security;
+   enum authtype auth_type;
+   u8 ch;
+   u8 *req_ies;
+   size_t req_ies_len;
+   u8 *resp_ies;
+   u16 resp_ies_len;
+   u16 status;
+   void (*conn_result)(enum conn_event evt, u8 status, void *priv_data);
+   void *arg;
+   void *param;
+};
+
+struct wilc_remain_ch {
+   u16 ch;
+   u32 duration;
+   void (*expired)(void *priv, u64 cookie);
+   void *arg;
+   u32 cookie;
+};
+
+struct wilc;
+struct host_if_drv {
+   struct wilc_user_scan_req usr_scan_req;
+   struct wilc_conn_info conn_info;
+   struct wilc_remain_ch remain_on_ch;
+   u64 p2p_timeout;
+
+   enum host_if_state hif_state;
+
+   u8 assoc_bssid[ETH_ALEN];
+
+   struct timer_list scan_timer;
+   struct wilc_vif *scan_timer_vif;
+
+   struct timer_list connect_timer;
+   struct wilc_vif *connect_timer_vif;
+
+   struct timer_list remain_on_ch_timer;
+   struct wilc_vif *remain_on_ch_timer_vif;
+
+   bool ifc_up;
+   u8 assoc_resp[WILC_MAX_ASSOC_RESP_FRAME_SIZE];
+};
+
+struct wilc_vif;
+int wilc_remove_wep_key(struct wilc_vif *vif, u8 index);
+int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index);
+int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len,
+u8 index);
+int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len,
+   u8 index, u8 mode, enum authtype auth_type);
+int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len,
+const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic,
+u8 mode, u8 cipher_mode, u8 index);
+s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac,
+  u32 *out_val);
+int wilc_add_rx_gtk(struct wilc_vif 

[PATCH v6 00/17] wilc1000: move out of staging

2020-03-27 Thread Ajay.Kathat
From: Ajay Singh 

This patch series is to review and move wilc1000 driver out of staging.
Most of the review comments received in [1] & [2] are addressed in the
latest code. Please review and provide your inputs.

[1]. 
https://lore.kernel.org/linux-wireless/1537957525-11467-1-git-send-email-ajay.kat...@microchip.com/
[2]. 
https://lore.kernel.org/linux-wireless/1562896697-8002-1-git-send-email-ajay.kat...@microchip.com/

Changes since v5:
 - handle DT binding review comments suggested in below link:
  * https://lore.kernel.org/driverdev-devel/20200320175920.GA31641@bogus
 - merged latest driver from staging which contains few cleanup patches
   and changes to use crc7 from existing library instead of having
   private implementation.

Changes since v4:
  - merged wilc1000 SDIO and SPI DT binding into a single file.
  - handle DT binding review comments suggested in below links:
* https://lore.kernel.org/linux-wireless/20200303015558.GA6876@bogus
* 
https://lore.kernel.org/linux-wireless/20200306144400.4269-2-ajay.kat...@microchip.com

Changes since v3:
  - handle few Smatch static checker reported issues.
  - use flexible-array member instead of zero-length array.

Changes since v2:
  - use 'struct' to extract FW info from received commands.
  - make use of C style comments instead of C++.
  - remove use of bool type for firmware struct.
  - deleted unused code related to interrupt handling.
  - make use of RCU list to maintain interfaces list.
  - remove 'wilc_' prefix from file name.
  - added 'WILC_' prefix for header guard macro.
  - remove use of infinite loops(i.e. while(1)).
  - move firmware related struct to a separate file.
  - refactor SPI command handling by using 'struct'.
  - use different functions to handle different SPI commands.
  - cleanup spi.c and sdio.c by removing unused code.
  - remove use of vendor specific IE for p2p handling.
  - refactor p2p related code to avoid use of buf pointer operation.
  - make use of FIELD_GET/PREP macro.
  - use #define instead of magic values.
  - use YAML schemes for DT binding documentation.
  - deleted unused code from spi.c and sdio.c.
  - added changes for few issues reported by smatch static code analyzer.

Changes since v1:
  - remove use of shadow buffer to keep scan result.
  - remove internal messaging flow to handle cfg80211_ops.
  - make use of cfg80211 provide API.
  - use 'struct' for packing firmware commands.
  - make use of kernel API's and Macro.
  - remove unnecessary log messages
  - supported dynamically add/remove interfaces.
  - cleanup and deleted around 3.3k lines of code.

Ajay Singh (17):
  wilc1000: add hif.h
  wilc1000: add hif.c
  wilc1000: add wlan_if.h
  wilc1000: add wlan_cfg.h
  wilc1000: add wlan_cfg.c
  wilc1000: add cfg80211.c
  wilc1000: add cfg80211.h
  wilc1000: add netdev.h
  wilc1000: add netdev.c
  wilc1000: add mon.c
  wilc1000: add spi.c
  wilc1000: add wlan.h
  wilc1000: add wlan.c
  wilc1000: add sdio.c
  wilc1000: add fw.h
  dt: bindings: net: add microchip,wilc1000.yaml
  wilc1000: add Makefile and Kconfig files for wilc1000 compilation

 .../net/wireless/microchip,wilc1000.yaml  |   71 +
 drivers/net/wireless/Kconfig  |1 +
 drivers/net/wireless/Makefile |1 +
 drivers/net/wireless/microchip/Kconfig|   15 +
 drivers/net/wireless/microchip/Makefile   |2 +
 .../net/wireless/microchip/wilc1000/Kconfig   |   47 +
 .../net/wireless/microchip/wilc1000/Makefile  |   14 +
 .../wireless/microchip/wilc1000/cfg80211.c| 1849 
 .../wireless/microchip/wilc1000/cfg80211.h|   29 +
 drivers/net/wireless/microchip/wilc1000/fw.h  |  119 +
 drivers/net/wireless/microchip/wilc1000/hif.c | 1959 +
 drivers/net/wireless/microchip/wilc1000/hif.h |  214 ++
 drivers/net/wireless/microchip/wilc1000/mon.c |  260 +++
 .../net/wireless/microchip/wilc1000/netdev.c  |  934 
 .../net/wireless/microchip/wilc1000/netdev.h  |  294 +++
 .../net/wireless/microchip/wilc1000/sdio.c| 1023 +
 drivers/net/wireless/microchip/wilc1000/spi.c |  945 
 .../net/wireless/microchip/wilc1000/wlan.c| 1238 +++
 .../net/wireless/microchip/wilc1000/wlan.h|  397 
 .../wireless/microchip/wilc1000/wlan_cfg.c|  413 
 .../wireless/microchip/wilc1000/wlan_cfg.h|   54 +
 .../net/wireless/microchip/wilc1000/wlan_if.h |  803 +++
 drivers/staging/Kconfig   |2 -
 drivers/staging/Makefile  |1 -
 24 files changed, 10682 insertions(+), 3 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml
 create mode 100644 drivers/net/wireless/microchip/Kconfig
 create mode 100644 drivers/net/wireless/microchip/Makefile
 create mode 100644 drivers/net/wireless/microchip/wilc1000/Kconfig
 create mode 100644 drivers/net/wireless/microchip/wilc1000/Makefile
 create mode 100644 

[PATCH v6 06/17] wilc1000: add cfg80211.c

2020-03-27 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/cfg80211.c' to
'drivers/net/wireless/microchip/wilc1000/cfg80211.c'.

Signed-off-by: Ajay Singh 
---
 .../wireless/microchip/wilc1000/cfg80211.c| 1849 +
 1 file changed, 1849 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/cfg80211.c

diff --git a/drivers/net/wireless/microchip/wilc1000/cfg80211.c 
b/drivers/net/wireless/microchip/wilc1000/cfg80211.c
new file mode 100644
index ..4bdcbc5fd2fd
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/cfg80211.c
@@ -0,0 +1,1849 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#include "cfg80211.h"
+
+#define GO_NEG_REQ 0x00
+#define GO_NEG_RSP 0x01
+#define GO_NEG_CONF0x02
+#define P2P_INV_REQ0x03
+#define P2P_INV_RSP0x04
+
+#define WILC_INVALID_CHANNEL   0
+
+/* Operation at 2.4 GHz with channels 1-13 */
+#define WILC_WLAN_OPERATING_CLASS_2_4GHZ   0x51
+
+static const struct ieee80211_txrx_stypes
+   wilc_wfi_cfg80211_mgmt_types[NUM_NL80211_IFTYPES] = {
+   [NL80211_IFTYPE_STATION] = {
+   .tx = 0x,
+   .rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
+   BIT(IEEE80211_STYPE_PROBE_REQ >> 4)
+   },
+   [NL80211_IFTYPE_AP] = {
+   .tx = 0x,
+   .rx = BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) |
+   BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) |
+   BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
+   BIT(IEEE80211_STYPE_DISASSOC >> 4) |
+   BIT(IEEE80211_STYPE_AUTH >> 4) |
+   BIT(IEEE80211_STYPE_DEAUTH >> 4) |
+   BIT(IEEE80211_STYPE_ACTION >> 4)
+   },
+   [NL80211_IFTYPE_P2P_CLIENT] = {
+   .tx = 0x,
+   .rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
+   BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
+   BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) |
+   BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) |
+   BIT(IEEE80211_STYPE_DISASSOC >> 4) |
+   BIT(IEEE80211_STYPE_AUTH >> 4) |
+   BIT(IEEE80211_STYPE_DEAUTH >> 4)
+   }
+};
+
+static const struct wiphy_wowlan_support wowlan_support = {
+   .flags = WIPHY_WOWLAN_ANY
+};
+
+struct wilc_p2p_mgmt_data {
+   int size;
+   u8 *buff;
+};
+
+struct wilc_p2p_pub_act_frame {
+   u8 category;
+   u8 action;
+   u8 oui[3];
+   u8 oui_type;
+   u8 oui_subtype;
+   u8 dialog_token;
+   u8 elem[];
+} __packed;
+
+struct wilc_vendor_specific_ie {
+   u8 tag_number;
+   u8 tag_len;
+   u8 oui[3];
+   u8 oui_type;
+   u8 attr[];
+} __packed;
+
+struct wilc_attr_entry {
+   u8  attr_type;
+   __le16 attr_len;
+   u8 val[];
+} __packed;
+
+struct wilc_attr_oper_ch {
+   u8 attr_type;
+   __le16 attr_len;
+   u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
+   u8 op_class;
+   u8 op_channel;
+} __packed;
+
+struct wilc_attr_ch_list {
+   u8 attr_type;
+   __le16 attr_len;
+   u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
+   u8 elem[];
+} __packed;
+
+struct wilc_ch_list_elem {
+   u8 op_class;
+   u8 no_of_channels;
+   u8 ch_list[];
+} __packed;
+
+static void cfg_scan_result(enum scan_event scan_event,
+   struct wilc_rcvd_net_info *info, void *user_void)
+{
+   struct wilc_priv *priv = user_void;
+
+   if (!priv->cfg_scanning)
+   return;
+
+   if (scan_event == SCAN_EVENT_NETWORK_FOUND) {
+   s32 freq;
+   struct ieee80211_channel *channel;
+   struct cfg80211_bss *bss;
+   struct wiphy *wiphy = priv->dev->ieee80211_ptr->wiphy;
+
+   if (!wiphy || !info)
+   return;
+
+   freq = ieee80211_channel_to_frequency((s32)info->ch,
+ NL80211_BAND_2GHZ);
+   channel = ieee80211_get_channel(wiphy, freq);
+   if (!channel)
+   return;
+
+   bss = cfg80211_inform_bss_frame(wiphy, channel, info->mgmt,
+   info->frame_len,
+   (s32)info->rssi * 100,
+   GFP_KERNEL);
+   if (!bss)
+   cfg80211_put_bss(wiphy, bss);
+   } else if (scan_event == SCAN_EVENT_DONE) {
+   mutex_lock(>scan_req_lock);
+
+   if (priv->scan_req) {
+   struct cfg80211_scan_info info = {
+   .aborted = false,
+   };
+

[PATCH v3] staging: wilc1000: Use crc7 in lib/ rather than a private copy

2020-03-26 Thread Ajay.Kathat
From: George Spelvin 

The code in lib/ is the desired polynomial, and even includes
the 1-bit left shift in the table rather than needing to code
it explicitly.

While I'm in Kconfig, add a description of what a WILC1000 is.
Kconfig questions that require me to look up a data sheet to
find out that I probably don't have one are a pet peeve.

Cc: Adham Abozaeid 
Cc: linux-wirel...@vger.kernel.org
Reviewed-by: Ajay Singh 
Signed-off-by: George Spelvin 
---
v3: added 'staging' to subject and submit to de...@driverdev.osuosl.org

v2: Rebase on the staging-next tree

 drivers/staging/wilc1000/Kconfig |  5 +++
 drivers/staging/wilc1000/spi.c   | 64 +++-
 2 files changed, 11 insertions(+), 58 deletions(-)

diff --git a/drivers/staging/wilc1000/Kconfig b/drivers/staging/wilc1000/Kconfig
index 59e58550d139..80c92e8bf8a5 100644
--- a/drivers/staging/wilc1000/Kconfig
+++ b/drivers/staging/wilc1000/Kconfig
@@ -2,6 +2,10 @@
 config WILC1000
tristate
help
+ Add support for the Atmel WILC1000 802.11 b/g/n SoC.
+ This provides Wi-FI over an SDIO or SPI interface, and
+ is usually found in IoT devices.
+
  This module only support IEEE 802.11n WiFi.
 
 config WILC1000_SDIO
@@ -22,6 +26,7 @@ config WILC1000_SPI
tristate "Atmel WILC1000 SPI (WiFi only)"
depends on CFG80211 && INET && SPI
select WILC1000
+   select CRC7
help
  This module adds support for the SPI interface of adapters using
  WILC1000 chipset. The Atmel WILC1000 has a Serial Peripheral
diff --git a/drivers/staging/wilc1000/spi.c b/drivers/staging/wilc1000/spi.c
index 8d4b8c219c2f..3f19e3f38a39 100644
--- a/drivers/staging/wilc1000/spi.c
+++ b/drivers/staging/wilc1000/spi.c
@@ -6,6 +6,7 @@
 
 #include 
 #include 
+#include 
 
 #include "netdev.h"
 #include "cfg80211.h"
@@ -16,64 +17,6 @@ struct wilc_spi {
 
 static const struct wilc_hif_func wilc_hif_spi;
 
-/
- *
- *  Crc7
- *
- /
-
-static const u8 crc7_syndrome_table[256] = {
-   0x00, 0x09, 0x12, 0x1b, 0x24, 0x2d, 0x36, 0x3f,
-   0x48, 0x41, 0x5a, 0x53, 0x6c, 0x65, 0x7e, 0x77,
-   0x19, 0x10, 0x0b, 0x02, 0x3d, 0x34, 0x2f, 0x26,
-   0x51, 0x58, 0x43, 0x4a, 0x75, 0x7c, 0x67, 0x6e,
-   0x32, 0x3b, 0x20, 0x29, 0x16, 0x1f, 0x04, 0x0d,
-   0x7a, 0x73, 0x68, 0x61, 0x5e, 0x57, 0x4c, 0x45,
-   0x2b, 0x22, 0x39, 0x30, 0x0f, 0x06, 0x1d, 0x14,
-   0x63, 0x6a, 0x71, 0x78, 0x47, 0x4e, 0x55, 0x5c,
-   0x64, 0x6d, 0x76, 0x7f, 0x40, 0x49, 0x52, 0x5b,
-   0x2c, 0x25, 0x3e, 0x37, 0x08, 0x01, 0x1a, 0x13,
-   0x7d, 0x74, 0x6f, 0x66, 0x59, 0x50, 0x4b, 0x42,
-   0x35, 0x3c, 0x27, 0x2e, 0x11, 0x18, 0x03, 0x0a,
-   0x56, 0x5f, 0x44, 0x4d, 0x72, 0x7b, 0x60, 0x69,
-   0x1e, 0x17, 0x0c, 0x05, 0x3a, 0x33, 0x28, 0x21,
-   0x4f, 0x46, 0x5d, 0x54, 0x6b, 0x62, 0x79, 0x70,
-   0x07, 0x0e, 0x15, 0x1c, 0x23, 0x2a, 0x31, 0x38,
-   0x41, 0x48, 0x53, 0x5a, 0x65, 0x6c, 0x77, 0x7e,
-   0x09, 0x00, 0x1b, 0x12, 0x2d, 0x24, 0x3f, 0x36,
-   0x58, 0x51, 0x4a, 0x43, 0x7c, 0x75, 0x6e, 0x67,
-   0x10, 0x19, 0x02, 0x0b, 0x34, 0x3d, 0x26, 0x2f,
-   0x73, 0x7a, 0x61, 0x68, 0x57, 0x5e, 0x45, 0x4c,
-   0x3b, 0x32, 0x29, 0x20, 0x1f, 0x16, 0x0d, 0x04,
-   0x6a, 0x63, 0x78, 0x71, 0x4e, 0x47, 0x5c, 0x55,
-   0x22, 0x2b, 0x30, 0x39, 0x06, 0x0f, 0x14, 0x1d,
-   0x25, 0x2c, 0x37, 0x3e, 0x01, 0x08, 0x13, 0x1a,
-   0x6d, 0x64, 0x7f, 0x76, 0x49, 0x40, 0x5b, 0x52,
-   0x3c, 0x35, 0x2e, 0x27, 0x18, 0x11, 0x0a, 0x03,
-   0x74, 0x7d, 0x66, 0x6f, 0x50, 0x59, 0x42, 0x4b,
-   0x17, 0x1e, 0x05, 0x0c, 0x33, 0x3a, 0x21, 0x28,
-   0x5f, 0x56, 0x4d, 0x44, 0x7b, 0x72, 0x69, 0x60,
-   0x0e, 0x07, 0x1c, 0x15, 0x2a, 0x23, 0x38, 0x31,
-   0x46, 0x4f, 0x54, 0x5d, 0x62, 0x6b, 0x70, 0x79
-};
-
-static u8 crc7_byte(u8 crc, u8 data)
-{
-   return crc7_syndrome_table[(crc << 1) ^ data];
-}
-
-static u8 crc7(u8 crc, const u8 *buffer, u32 len)
-{
-   while (len--)
-   crc = crc7_byte(crc, *buffer++);
-   return crc;
-}
-
-static u8 wilc_get_crc7(u8 *buffer, u32 len)
-{
-   return crc7(0x7f, (const u8 *)buffer, len) << 1;
-}
-
 /
  *
  *  Spi protocol Function
@@ -403,6 +346,11 @@ static int spi_data_write(struct wilc *wilc, u8 *b, u32 sz)
  *  Spi Internal Read/Write Function
  *
  /
+static u8 wilc_get_crc7(u8 *buffer, u32 len)
+{
+   return crc7_be(0xfe, buffer, len);
+}
+
 static int wilc_spi_single_read(struct wilc *wilc, u8 cmd, u32 adr, void *b,
u8 clockless)
 {
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: wilc1000: remove label from examples in DT binding documentation

2020-03-26 Thread Ajay.Kathat
Hi Kalle,

On 26/03/20 1:15 pm, Kalle Valo wrote:
> 
>  writes:
> 
>> From: Ajay Singh 
>>
>> Remove labels and not relevant property from DT binding documentation
>> examples as suggested in [1].
>>
>> 1. https://patchwork.ozlabs.org/patch/1252837
> 
> Just a nitpick but patchwork links are not that reliable in the long
> run. Instead using a lore link is better as the message id is visible
> directly from the URL.
> 

Sure. I will make use of lore link for future patches as this patch is
already applied.


Regards,
Ajay
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: wilc1000: remove label from examples in DT binding documentation

2020-03-25 Thread Ajay.Kathat
From: Ajay Singh 

Remove labels and not relevant property from DT binding documentation
examples as suggested in [1].

1. https://patchwork.ozlabs.org/patch/1252837

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/microchip,wilc1000.yaml | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/wilc1000/microchip,wilc1000.yaml 
b/drivers/staging/wilc1000/microchip,wilc1000.yaml
index bc6cc5d3f347..2c320eb2a8c4 100644
--- a/drivers/staging/wilc1000/microchip,wilc1000.yaml
+++ b/drivers/staging/wilc1000/microchip,wilc1000.yaml
@@ -36,10 +36,9 @@ required:
 
 examples:
   - |
-spi1: spi@fc018000 {
+spi {
   #address-cells = <1>;
   #size-cells = <0>;
-  cs-gpios = < 21 0>;
   wifi@0 {
 compatible = "microchip,wilc1000";
 spi-max-frequency = <4800>;
@@ -52,7 +51,7 @@ examples:
 };
 
   - |
-mmc1: mmc@fc00 {
+mmc {
   #address-cells = <1>;
   #size-cells = <0>;
   pinctrl-names = "default";
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v5 16/17] dt: bindings: net: add microchip,wilc1000.yaml

2020-03-22 Thread Ajay.Kathat
Hi Rob,

On 20/03/20 11:29 pm, Rob Herring wrote:
> 
> On Wed, Mar 11, 2020 at 12:18:50PM +, ajay.kat...@microchip.com wrote:
>> From: Ajay Singh 
>>
>> This file describes the binding details to connect wilc1000 device. It's
>> moved from staging to 'Documentation/devicetree/bindings/net/wireless'
>> path.
>>
>> Signed-off-by: Ajay Singh 
>> ---
>>  .../net/wireless/microchip,wilc1000.yaml  | 72 +++
>>  1 file changed, 72 insertions(+)
>>  create mode 100644 
>> Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml
>>
>> diff --git 
>> a/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml 
>> b/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml
>> new file mode 100644
>> index ..bc6cc5d3f347
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml
>> @@ -0,0 +1,72 @@
>> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
>> +%YAML 1.2
>> +---
>> +$id: http://devicetree.org/schemas/net/wireless/microchip,wilc1000.yaml#
>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>> +
>> +title: Microchip WILC wireless devicetree bindings
>> +
>> +maintainers:
>> +  - Adham Abozaeid 
>> +  - Ajay Singh 
>> +
>> +description:
>> +  The wilc1000 chips can be connected via SPI or SDIO. This document
>> +  describes the binding to connect wilc devices.
>> +
>> +properties:
>> +  compatible:
>> +const: microchip,wilc1000
>> +
>> +  spi-max-frequency: true
>> +
>> +  interrupts:
>> +maxItems: 1
>> +
>> +  clocks:
>> +description: phandle to the clock connected on rtc clock line.
>> +maxItems: 1
>> +
>> +  clock-names:
>> +const: rtc
>> +
>> +required:
>> +  - compatible
>> +  - interrupts
>> +
>> +examples:
>> +  - |
>> +spi1: spi@fc018000 {
> 
> spi {
> 
>> +  #address-cells = <1>;
>> +  #size-cells = <0>;
>> +  cs-gpios = < 21 0>;
> 
> Drop this. Not relevant to the example.

Ok.

> 
>> +  wifi@0 {
>> +compatible = "microchip,wilc1000";
>> +spi-max-frequency = <4800>;
>> +reg = <0>;
>> +interrupt-parent = <>;
>> +interrupts = <27 0>;
>> +clocks = <>;
>> +clock-names = "rtc";
>> +  };
>> +};
>> +
>> +  - |
>> +mmc1: mmc@fc00 {
> 
> Drop the label. Either drop the unit address or add a 'reg' property to
> match.

Ok. I will drop the label and unit address in this.


Regards,
Ajay
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 10/17] wilc1000: add mon.c

2020-03-11 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/mon.c' to
'drivers/net/wireless/microchip/wilc1000/mon.c'.

Signed-off-by: Ajay Singh 
---
 drivers/net/wireless/microchip/wilc1000/mon.c | 260 ++
 1 file changed, 260 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/mon.c

diff --git a/drivers/net/wireless/microchip/wilc1000/mon.c 
b/drivers/net/wireless/microchip/wilc1000/mon.c
new file mode 100644
index ..60331417bd98
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/mon.c
@@ -0,0 +1,260 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#include "cfg80211.h"
+
+struct wilc_wfi_radiotap_hdr {
+   struct ieee80211_radiotap_header hdr;
+   u8 rate;
+} __packed;
+
+struct wilc_wfi_radiotap_cb_hdr {
+   struct ieee80211_radiotap_header hdr;
+   u8 rate;
+   u8 dump;
+   u16 tx_flags;
+} __packed;
+
+#define TX_RADIOTAP_PRESENT ((1 << IEEE80211_RADIOTAP_RATE) |  \
+(1 << IEEE80211_RADIOTAP_TX_FLAGS))
+
+void wilc_wfi_monitor_rx(struct net_device *mon_dev, u8 *buff, u32 size)
+{
+   u32 header, pkt_offset;
+   struct sk_buff *skb = NULL;
+   struct wilc_wfi_radiotap_hdr *hdr;
+   struct wilc_wfi_radiotap_cb_hdr *cb_hdr;
+
+   if (!mon_dev)
+   return;
+
+   if (!netif_running(mon_dev))
+   return;
+
+   /* Get WILC header */
+   header = get_unaligned_le32(buff - HOST_HDR_OFFSET);
+   /*
+* The packet offset field contain info about what type of management
+* the frame we are dealing with and ack status
+*/
+   pkt_offset = FIELD_GET(WILC_PKT_HDR_OFFSET_FIELD, header);
+
+   if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {
+   /* hostapd callback mgmt frame */
+
+   skb = dev_alloc_skb(size + sizeof(*cb_hdr));
+   if (!skb)
+   return;
+
+   skb_put_data(skb, buff, size);
+
+   cb_hdr = skb_push(skb, sizeof(*cb_hdr));
+   memset(cb_hdr, 0, sizeof(*cb_hdr));
+
+   cb_hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */
+
+   cb_hdr->hdr.it_len = cpu_to_le16(sizeof(*cb_hdr));
+
+   cb_hdr->hdr.it_present = cpu_to_le32(TX_RADIOTAP_PRESENT);
+
+   cb_hdr->rate = 5;
+
+   if (pkt_offset & IS_MGMT_STATUS_SUCCES) {
+   /* success */
+   cb_hdr->tx_flags = IEEE80211_RADIOTAP_F_TX_RTS;
+   } else {
+   cb_hdr->tx_flags = IEEE80211_RADIOTAP_F_TX_FAIL;
+   }
+
+   } else {
+   skb = dev_alloc_skb(size + sizeof(*hdr));
+
+   if (!skb)
+   return;
+
+   skb_put_data(skb, buff, size);
+   hdr = skb_push(skb, sizeof(*hdr));
+   memset(hdr, 0, sizeof(struct wilc_wfi_radiotap_hdr));
+   hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */
+   hdr->hdr.it_len = cpu_to_le16(sizeof(*hdr));
+   hdr->hdr.it_present = cpu_to_le32
+   (1 << IEEE80211_RADIOTAP_RATE);
+   hdr->rate = 5;
+   }
+
+   skb->dev = mon_dev;
+   skb_reset_mac_header(skb);
+   skb->ip_summed = CHECKSUM_UNNECESSARY;
+   skb->pkt_type = PACKET_OTHERHOST;
+   skb->protocol = htons(ETH_P_802_2);
+   memset(skb->cb, 0, sizeof(skb->cb));
+
+   netif_rx(skb);
+}
+
+struct tx_complete_mon_data {
+   int size;
+   void *buff;
+};
+
+static void mgmt_tx_complete(void *priv, int status)
+{
+   struct tx_complete_mon_data *pv_data = priv;
+   /*
+* in case of fully hosting mode, the freeing will be done
+* in response to the cfg packet
+*/
+   kfree(pv_data->buff);
+
+   kfree(pv_data);
+}
+
+static int mon_mgmt_tx(struct net_device *dev, const u8 *buf, size_t len)
+{
+   struct tx_complete_mon_data *mgmt_tx = NULL;
+
+   if (!dev)
+   return -EFAULT;
+
+   netif_stop_queue(dev);
+   mgmt_tx = kmalloc(sizeof(*mgmt_tx), GFP_ATOMIC);
+   if (!mgmt_tx)
+   return -ENOMEM;
+
+   mgmt_tx->buff = kmemdup(buf, len, GFP_ATOMIC);
+   if (!mgmt_tx->buff) {
+   kfree(mgmt_tx);
+   return -ENOMEM;
+   }
+
+   mgmt_tx->size = len;
+
+   wilc_wlan_txq_add_mgmt_pkt(dev, mgmt_tx, mgmt_tx->buff, mgmt_tx->size,
+  mgmt_tx_complete);
+
+   netif_wake_queue(dev);
+   return 0;
+}
+
+static netdev_tx_t wilc_wfi_mon_xmit(struct sk_buff *skb,
+struct net_device *dev)
+{
+   u32 rtap_len, ret = 0;
+   struct wilc_wfi_mon_priv  *mon_priv;
+   struct sk_buff *skb2;
+   struct wilc_wfi_radiotap_cb_hdr *cb_hdr;
+   u8 srcadd[ETH_ALEN];
+   

[PATCH v5 14/17] wilc1000: add sdio.c

2020-03-11 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/sdio.c' to
'drivers/net/wireless/microchip/wilc1000/sdio.c'.

Signed-off-by: Ajay Singh 
---
 .../net/wireless/microchip/wilc1000/sdio.c| 1023 +
 1 file changed, 1023 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/sdio.c

diff --git a/drivers/net/wireless/microchip/wilc1000/sdio.c 
b/drivers/net/wireless/microchip/wilc1000/sdio.c
new file mode 100644
index ..36eb589263bf
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/sdio.c
@@ -0,0 +1,1023 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "netdev.h"
+#include "cfg80211.h"
+
+#define SDIO_MODALIAS "wilc1000_sdio"
+
+#define SDIO_VENDOR_ID_WILC 0x0296
+#define SDIO_DEVICE_ID_WILC 0x5347
+
+static const struct sdio_device_id wilc_sdio_ids[] = {
+   { SDIO_DEVICE(SDIO_VENDOR_ID_WILC, SDIO_DEVICE_ID_WILC) },
+   { },
+};
+
+#define WILC_SDIO_BLOCK_SIZE 512
+
+struct wilc_sdio {
+   bool irq_gpio;
+   u32 block_size;
+   int has_thrpt_enh3;
+};
+
+struct sdio_cmd52 {
+   u32 read_write: 1;
+   u32 function:   3;
+   u32 raw:1;
+   u32 address:17;
+   u32 data:   8;
+};
+
+struct sdio_cmd53 {
+   u32 read_write: 1;
+   u32 function:   3;
+   u32 block_mode: 1;
+   u32 increment:  1;
+   u32 address:17;
+   u32 count:  9;
+   u8 *buffer;
+   u32 block_size;
+};
+
+static const struct wilc_hif_func wilc_hif_sdio;
+
+static void wilc_sdio_interrupt(struct sdio_func *func)
+{
+   sdio_release_host(func);
+   wilc_handle_isr(sdio_get_drvdata(func));
+   sdio_claim_host(func);
+}
+
+static int wilc_sdio_cmd52(struct wilc *wilc, struct sdio_cmd52 *cmd)
+{
+   struct sdio_func *func = container_of(wilc->dev, struct sdio_func, dev);
+   int ret;
+   u8 data;
+
+   sdio_claim_host(func);
+
+   func->num = cmd->function;
+   if (cmd->read_write) {  /* write */
+   if (cmd->raw) {
+   sdio_writeb(func, cmd->data, cmd->address, );
+   data = sdio_readb(func, cmd->address, );
+   cmd->data = data;
+   } else {
+   sdio_writeb(func, cmd->data, cmd->address, );
+   }
+   } else {/* read */
+   data = sdio_readb(func, cmd->address, );
+   cmd->data = data;
+   }
+
+   sdio_release_host(func);
+
+   if (ret)
+   dev_err(>dev, "%s..failed, err(%d)\n", __func__, ret);
+   return ret;
+}
+
+static int wilc_sdio_cmd53(struct wilc *wilc, struct sdio_cmd53 *cmd)
+{
+   struct sdio_func *func = container_of(wilc->dev, struct sdio_func, dev);
+   int size, ret;
+
+   sdio_claim_host(func);
+
+   func->num = cmd->function;
+   func->cur_blksize = cmd->block_size;
+   if (cmd->block_mode)
+   size = cmd->count * cmd->block_size;
+   else
+   size = cmd->count;
+
+   if (cmd->read_write) {  /* write */
+   ret = sdio_memcpy_toio(func, cmd->address,
+  (void *)cmd->buffer, size);
+   } else {/* read */
+   ret = sdio_memcpy_fromio(func, (void *)cmd->buffer,
+cmd->address,  size);
+   }
+
+   sdio_release_host(func);
+
+   if (ret)
+   dev_err(>dev, "%s..failed, err(%d)\n", __func__,  ret);
+
+   return ret;
+}
+
+static int wilc_sdio_probe(struct sdio_func *func,
+  const struct sdio_device_id *id)
+{
+   struct wilc *wilc;
+   int ret;
+   struct wilc_sdio *sdio_priv;
+
+   sdio_priv = kzalloc(sizeof(*sdio_priv), GFP_KERNEL);
+   if (!sdio_priv)
+   return -ENOMEM;
+
+   ret = wilc_cfg80211_init(, >dev, WILC_HIF_SDIO,
+_hif_sdio);
+   if (ret) {
+   kfree(sdio_priv);
+   return ret;
+   }
+
+   if (IS_ENABLED(CONFIG_WILC1000_HW_OOB_INTR)) {
+   struct device_node *np = func->card->dev.of_node;
+   int irq_num = of_irq_get(np, 0);
+
+   if (irq_num > 0) {
+   wilc->dev_irq_num = irq_num;
+   sdio_priv->irq_gpio = true;
+   }
+   }
+
+   sdio_set_drvdata(func, wilc);
+   wilc->bus_data = sdio_priv;
+   wilc->dev = >dev;
+
+   wilc->rtc_clk = devm_clk_get(>card->dev, "rtc");
+   if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER)
+   return -EPROBE_DEFER;
+   else if (!IS_ERR(wilc->rtc_clk))
+   clk_prepare_enable(wilc->rtc_clk);
+
+   dev_info(>dev, 

[PATCH v5 15/17] wilc1000: add fw.h

2020-03-11 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/fw.h' to
'drivers/net/wireless/microchip/wilc1000/fw.h'.

Signed-off-by: Ajay Singh 
---
 drivers/net/wireless/microchip/wilc1000/fw.h | 119 +++
 1 file changed, 119 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/fw.h

diff --git a/drivers/net/wireless/microchip/wilc1000/fw.h 
b/drivers/net/wireless/microchip/wilc1000/fw.h
new file mode 100644
index ..a76e1dea4345
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/fw.h
@@ -0,0 +1,119 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#ifndef WILC_FW_H
+#define WILC_FW_H
+
+#include 
+
+#define WILC_MAX_NUM_STA   9
+#define WILC_MAX_RATES_SUPPORTED   12
+#define WILC_MAX_NUM_PMKIDS16
+#define WILC_MAX_NUM_SCANNED_CH14
+
+struct wilc_assoc_resp {
+   __le16 capab_info;
+   __le16 status_code;
+   __le16 aid;
+} __packed;
+
+struct wilc_pmkid {
+   u8 bssid[ETH_ALEN];
+   u8 pmkid[WLAN_PMKID_LEN];
+} __packed;
+
+struct wilc_pmkid_attr {
+   u8 numpmkid;
+   struct wilc_pmkid pmkidlist[WILC_MAX_NUM_PMKIDS];
+} __packed;
+
+struct wilc_reg_frame {
+   u8 reg;
+   u8 reg_id;
+   __le16 frame_type;
+} __packed;
+
+struct wilc_drv_handler {
+   __le32 handler;
+   u8 mode;
+} __packed;
+
+struct wilc_wep_key {
+   u8 index;
+   u8 key_len;
+   u8 key[0];
+} __packed;
+
+struct wilc_sta_wpa_ptk {
+   u8 mac_addr[ETH_ALEN];
+   u8 key_len;
+   u8 key[0];
+} __packed;
+
+struct wilc_ap_wpa_ptk {
+   u8 mac_addr[ETH_ALEN];
+   u8 index;
+   u8 key_len;
+   u8 key[0];
+} __packed;
+
+struct wilc_gtk_key {
+   u8 mac_addr[ETH_ALEN];
+   u8 rsc[8];
+   u8 index;
+   u8 key_len;
+   u8 key[0];
+} __packed;
+
+struct wilc_op_mode {
+   __le32 mode;
+} __packed;
+
+struct wilc_noa_opp_enable {
+   u8 ct_window;
+   u8 cnt;
+   __le32 duration;
+   __le32 interval;
+   __le32 start_time;
+} __packed;
+
+struct wilc_noa_opp_disable {
+   u8 cnt;
+   __le32 duration;
+   __le32 interval;
+   __le32 start_time;
+} __packed;
+
+struct wilc_join_bss_param {
+   char ssid[IEEE80211_MAX_SSID_LEN];
+   u8 ssid_terminator;
+   u8 bss_type;
+   u8 ch;
+   __le16 cap_info;
+   u8 sa[ETH_ALEN];
+   u8 bssid[ETH_ALEN];
+   __le16 beacon_period;
+   u8 dtim_period;
+   u8 supp_rates[WILC_MAX_RATES_SUPPORTED + 1];
+   u8 wmm_cap;
+   u8 uapsd_cap;
+   u8 ht_capable;
+   u8 rsn_found;
+   u8 rsn_grp_policy;
+   u8 mode_802_11i;
+   u8 p_suites[3];
+   u8 akm_suites[3];
+   u8 rsn_cap[2];
+   u8 noa_enabled;
+   __le32 tsf_lo;
+   u8 idx;
+   u8 opp_enabled;
+   union {
+   struct wilc_noa_opp_disable opp_dis;
+   struct wilc_noa_opp_enable opp_en;
+   };
+} __packed;
+#endif
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 09/17] wilc1000: add netdev.c

2020-03-11 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/netdev.c' to
'drivers/net/wireless/microchip/wilc1000/netdev.c'.

Signed-off-by: Ajay Singh 
---
 .../net/wireless/microchip/wilc1000/netdev.c  | 932 ++
 1 file changed, 932 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/netdev.c

diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.c 
b/drivers/net/wireless/microchip/wilc1000/netdev.c
new file mode 100644
index ..a61c1a7aefa8
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/netdev.c
@@ -0,0 +1,932 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "cfg80211.h"
+#include "wlan_cfg.h"
+
+#define WILC_MULTICAST_TABLE_SIZE  8
+
+static irqreturn_t isr_uh_routine(int irq, void *user_data)
+{
+   struct net_device *dev = user_data;
+   struct wilc_vif *vif = netdev_priv(dev);
+   struct wilc *wilc = vif->wilc;
+
+   if (wilc->close) {
+   netdev_err(dev, "Can't handle UH interrupt\n");
+   return IRQ_HANDLED;
+   }
+   return IRQ_WAKE_THREAD;
+}
+
+static irqreturn_t isr_bh_routine(int irq, void *userdata)
+{
+   struct net_device *dev = userdata;
+   struct wilc_vif *vif = netdev_priv(userdata);
+   struct wilc *wilc = vif->wilc;
+
+   if (wilc->close) {
+   netdev_err(dev, "Can't handle BH interrupt\n");
+   return IRQ_HANDLED;
+   }
+
+   wilc_handle_isr(wilc);
+
+   return IRQ_HANDLED;
+}
+
+static int init_irq(struct net_device *dev)
+{
+   struct wilc_vif *vif = netdev_priv(dev);
+   struct wilc *wl = vif->wilc;
+   int ret;
+
+   ret = request_threaded_irq(wl->dev_irq_num, isr_uh_routine,
+  isr_bh_routine,
+  IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+  "WILC_IRQ", dev);
+   if (ret) {
+   netdev_err(dev, "Failed to request IRQ [%d]\n", ret);
+   return ret;
+   }
+   netdev_dbg(dev, "IRQ request succeeded IRQ-NUM= %d\n", wl->dev_irq_num);
+
+   return 0;
+}
+
+static void deinit_irq(struct net_device *dev)
+{
+   struct wilc_vif *vif = netdev_priv(dev);
+   struct wilc *wilc = vif->wilc;
+
+   /* Deinitialize IRQ */
+   if (wilc->dev_irq_num)
+   free_irq(wilc->dev_irq_num, wilc);
+}
+
+void wilc_mac_indicate(struct wilc *wilc)
+{
+   s8 status;
+
+   wilc_wlan_cfg_get_val(wilc, WID_STATUS, , 1);
+   if (wilc->mac_status == WILC_MAC_STATUS_INIT) {
+   wilc->mac_status = status;
+   complete(>sync_event);
+   } else {
+   wilc->mac_status = status;
+   }
+}
+
+static struct net_device *get_if_handler(struct wilc *wilc, u8 *mac_header)
+{
+   struct net_device *ndev = NULL;
+   struct wilc_vif *vif;
+   struct ieee80211_hdr *h = (struct ieee80211_hdr *)mac_header;
+
+   list_for_each_entry_rcu(vif, >vif_list, list) {
+   if (vif->mode == WILC_STATION_MODE)
+   if (ether_addr_equal_unaligned(h->addr2, vif->bssid)) {
+   ndev = vif->ndev;
+   goto out;
+   }
+   if (vif->mode == WILC_AP_MODE)
+   if (ether_addr_equal_unaligned(h->addr1, vif->bssid)) {
+   ndev = vif->ndev;
+   goto out;
+   }
+   }
+out:
+   return ndev;
+}
+
+void wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid, u8 mode)
+{
+   struct wilc_vif *vif = netdev_priv(wilc_netdev);
+
+   if (bssid)
+   ether_addr_copy(vif->bssid, bssid);
+   else
+   eth_zero_addr(vif->bssid);
+
+   vif->mode = mode;
+}
+
+int wilc_wlan_get_num_conn_ifcs(struct wilc *wilc)
+{
+   int srcu_idx;
+   u8 ret_val = 0;
+   struct wilc_vif *vif;
+
+   srcu_idx = srcu_read_lock(>srcu);
+   list_for_each_entry_rcu(vif, >vif_list, list) {
+   if (!is_zero_ether_addr(vif->bssid))
+   ret_val++;
+   }
+   srcu_read_unlock(>srcu, srcu_idx);
+   return ret_val;
+}
+
+static int wilc_txq_task(void *vp)
+{
+   int ret;
+   u32 txq_count;
+   struct wilc *wl = vp;
+
+   complete(>txq_thread_started);
+   while (1) {
+   wait_for_completion(>txq_event);
+
+   if (wl->close) {
+   complete(>txq_thread_started);
+
+   while (!kthread_should_stop())
+   schedule();
+   break;
+   }
+   do {
+   ret = wilc_wlan_handle_txq(wl, _count);
+   if (txq_count < 

[PATCH v5 05/17] wilc1000: add wlan_cfg.c

2020-03-11 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/wlan_cfg.c' to
'drivers/net/wireless/microchip/wilc1000/wlan_cfg.c'.

Signed-off-by: Ajay Singh 
---
 .../wireless/microchip/wilc1000/wlan_cfg.c| 413 ++
 1 file changed, 413 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/wlan_cfg.c

diff --git a/drivers/net/wireless/microchip/wilc1000/wlan_cfg.c 
b/drivers/net/wireless/microchip/wilc1000/wlan_cfg.c
new file mode 100644
index ..fe2a7ed8e5cd
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/wlan_cfg.c
@@ -0,0 +1,413 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#include 
+#include "wlan_if.h"
+#include "wlan.h"
+#include "wlan_cfg.h"
+#include "netdev.h"
+
+enum cfg_cmd_type {
+   CFG_BYTE_CMD= 0,
+   CFG_HWORD_CMD   = 1,
+   CFG_WORD_CMD= 2,
+   CFG_STR_CMD = 3,
+   CFG_BIN_CMD = 4
+};
+
+static const struct wilc_cfg_byte g_cfg_byte[] = {
+   {WID_STATUS, 0},
+   {WID_RSSI, 0},
+   {WID_LINKSPEED, 0},
+   {WID_NIL, 0}
+};
+
+static const struct wilc_cfg_hword g_cfg_hword[] = {
+   {WID_NIL, 0}
+};
+
+static const struct wilc_cfg_word g_cfg_word[] = {
+   {WID_FAILED_COUNT, 0},
+   {WID_RECEIVED_FRAGMENT_COUNT, 0},
+   {WID_SUCCESS_FRAME_COUNT, 0},
+   {WID_GET_INACTIVE_TIME, 0},
+   {WID_NIL, 0}
+
+};
+
+static const struct wilc_cfg_str g_cfg_str[] = {
+   {WID_FIRMWARE_VERSION, NULL},
+   {WID_MAC_ADDR, NULL},
+   {WID_ASSOC_RES_INFO, NULL},
+   {WID_NIL, NULL}
+};
+
+#define WILC_RESP_MSG_TYPE_CONFIG_REPLY'R'
+#define WILC_RESP_MSG_TYPE_STATUS_INFO 'I'
+#define WILC_RESP_MSG_TYPE_NETWORK_INFO'N'
+#define WILC_RESP_MSG_TYPE_SCAN_COMPLETE   'S'
+
+/
+ *
+ *  Configuration Functions
+ *
+ /
+
+static int wilc_wlan_cfg_set_byte(u8 *frame, u32 offset, u16 id, u8 val8)
+{
+   if ((offset + 4) >= WILC_MAX_CFG_FRAME_SIZE)
+   return 0;
+
+   put_unaligned_le16(id, [offset]);
+   put_unaligned_le16(1, [offset + 2]);
+   frame[offset + 4] = val8;
+   return 5;
+}
+
+static int wilc_wlan_cfg_set_hword(u8 *frame, u32 offset, u16 id, u16 val16)
+{
+   if ((offset + 5) >= WILC_MAX_CFG_FRAME_SIZE)
+   return 0;
+
+   put_unaligned_le16(id, [offset]);
+   put_unaligned_le16(2, [offset + 2]);
+   put_unaligned_le16(val16, [offset + 4]);
+
+   return 6;
+}
+
+static int wilc_wlan_cfg_set_word(u8 *frame, u32 offset, u16 id, u32 val32)
+{
+   if ((offset + 7) >= WILC_MAX_CFG_FRAME_SIZE)
+   return 0;
+
+   put_unaligned_le16(id, [offset]);
+   put_unaligned_le16(4, [offset + 2]);
+   put_unaligned_le32(val32, [offset + 4]);
+
+   return 8;
+}
+
+static int wilc_wlan_cfg_set_str(u8 *frame, u32 offset, u16 id, u8 *str,
+u32 size)
+{
+   if ((offset + size + 4) >= WILC_MAX_CFG_FRAME_SIZE)
+   return 0;
+
+   put_unaligned_le16(id, [offset]);
+   put_unaligned_le16(size, [offset + 2]);
+   if (str && size != 0)
+   memcpy([offset + 4], str, size);
+
+   return (size + 4);
+}
+
+static int wilc_wlan_cfg_set_bin(u8 *frame, u32 offset, u16 id, u8 *b, u32 
size)
+{
+   u32 i;
+   u8 checksum = 0;
+
+   if ((offset + size + 5) >= WILC_MAX_CFG_FRAME_SIZE)
+   return 0;
+
+   put_unaligned_le16(id, [offset]);
+   put_unaligned_le16(size, [offset + 2]);
+
+   if ((b) && size != 0) {
+   memcpy([offset + 4], b, size);
+   for (i = 0; i < size; i++)
+   checksum += frame[offset + i + 4];
+   }
+
+   frame[offset + size + 4] = checksum;
+
+   return (size + 5);
+}
+
+/
+ *
+ *  Configuration Response Functions
+ *
+ /
+
+static void wilc_wlan_parse_response_frame(struct wilc *wl, u8 *info, int size)
+{
+   u16 wid;
+   u32 len = 0, i = 0;
+   struct wilc_cfg *cfg = >cfg;
+
+   while (size > 0) {
+   i = 0;
+   wid = get_unaligned_le16(info);
+
+   switch (FIELD_GET(WILC_WID_TYPE, wid)) {
+   case WID_CHAR:
+   while (cfg->b[i].id != WID_NIL && cfg->b[i].id != wid)
+   i++;
+
+   if (cfg->b[i].id == wid)
+   cfg->b[i].val = info[4];
+
+   len = 3;
+   break;
+
+   case WID_SHORT:
+   while (cfg->hw[i].id != WID_NIL && cfg->hw[i].id != wid)
+   i++;
+
+   if (cfg->hw[i].id == wid)
+   

[PATCH v5 11/17] wilc1000: add spi.c

2020-03-11 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/spi.c' to
'drivers/net/wireless/microchip/wilc1000/spi.c'.

Signed-off-by: Ajay Singh 
---
 drivers/net/wireless/microchip/wilc1000/spi.c | 988 ++
 1 file changed, 988 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/spi.c

diff --git a/drivers/net/wireless/microchip/wilc1000/spi.c 
b/drivers/net/wireless/microchip/wilc1000/spi.c
new file mode 100644
index ..d77582c55326
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/spi.c
@@ -0,0 +1,988 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#include 
+#include 
+
+#include "netdev.h"
+#include "cfg80211.h"
+
+struct wilc_spi {
+   int crc_off;
+};
+
+static const struct wilc_hif_func wilc_hif_spi;
+
+/
+ *
+ *  Crc7
+ *
+ /
+
+static const u8 crc7_syndrome_table[256] = {
+   0x00, 0x09, 0x12, 0x1b, 0x24, 0x2d, 0x36, 0x3f,
+   0x48, 0x41, 0x5a, 0x53, 0x6c, 0x65, 0x7e, 0x77,
+   0x19, 0x10, 0x0b, 0x02, 0x3d, 0x34, 0x2f, 0x26,
+   0x51, 0x58, 0x43, 0x4a, 0x75, 0x7c, 0x67, 0x6e,
+   0x32, 0x3b, 0x20, 0x29, 0x16, 0x1f, 0x04, 0x0d,
+   0x7a, 0x73, 0x68, 0x61, 0x5e, 0x57, 0x4c, 0x45,
+   0x2b, 0x22, 0x39, 0x30, 0x0f, 0x06, 0x1d, 0x14,
+   0x63, 0x6a, 0x71, 0x78, 0x47, 0x4e, 0x55, 0x5c,
+   0x64, 0x6d, 0x76, 0x7f, 0x40, 0x49, 0x52, 0x5b,
+   0x2c, 0x25, 0x3e, 0x37, 0x08, 0x01, 0x1a, 0x13,
+   0x7d, 0x74, 0x6f, 0x66, 0x59, 0x50, 0x4b, 0x42,
+   0x35, 0x3c, 0x27, 0x2e, 0x11, 0x18, 0x03, 0x0a,
+   0x56, 0x5f, 0x44, 0x4d, 0x72, 0x7b, 0x60, 0x69,
+   0x1e, 0x17, 0x0c, 0x05, 0x3a, 0x33, 0x28, 0x21,
+   0x4f, 0x46, 0x5d, 0x54, 0x6b, 0x62, 0x79, 0x70,
+   0x07, 0x0e, 0x15, 0x1c, 0x23, 0x2a, 0x31, 0x38,
+   0x41, 0x48, 0x53, 0x5a, 0x65, 0x6c, 0x77, 0x7e,
+   0x09, 0x00, 0x1b, 0x12, 0x2d, 0x24, 0x3f, 0x36,
+   0x58, 0x51, 0x4a, 0x43, 0x7c, 0x75, 0x6e, 0x67,
+   0x10, 0x19, 0x02, 0x0b, 0x34, 0x3d, 0x26, 0x2f,
+   0x73, 0x7a, 0x61, 0x68, 0x57, 0x5e, 0x45, 0x4c,
+   0x3b, 0x32, 0x29, 0x20, 0x1f, 0x16, 0x0d, 0x04,
+   0x6a, 0x63, 0x78, 0x71, 0x4e, 0x47, 0x5c, 0x55,
+   0x22, 0x2b, 0x30, 0x39, 0x06, 0x0f, 0x14, 0x1d,
+   0x25, 0x2c, 0x37, 0x3e, 0x01, 0x08, 0x13, 0x1a,
+   0x6d, 0x64, 0x7f, 0x76, 0x49, 0x40, 0x5b, 0x52,
+   0x3c, 0x35, 0x2e, 0x27, 0x18, 0x11, 0x0a, 0x03,
+   0x74, 0x7d, 0x66, 0x6f, 0x50, 0x59, 0x42, 0x4b,
+   0x17, 0x1e, 0x05, 0x0c, 0x33, 0x3a, 0x21, 0x28,
+   0x5f, 0x56, 0x4d, 0x44, 0x7b, 0x72, 0x69, 0x60,
+   0x0e, 0x07, 0x1c, 0x15, 0x2a, 0x23, 0x38, 0x31,
+   0x46, 0x4f, 0x54, 0x5d, 0x62, 0x6b, 0x70, 0x79
+};
+
+static u8 crc7_byte(u8 crc, u8 data)
+{
+   return crc7_syndrome_table[(crc << 1) ^ data];
+}
+
+static u8 crc7(u8 crc, const u8 *buffer, u32 len)
+{
+   while (len--)
+   crc = crc7_byte(crc, *buffer++);
+   return crc;
+}
+
+static u8 wilc_get_crc7(u8 *buffer, u32 len)
+{
+   return crc7(0x7f, (const u8 *)buffer, len) << 1;
+}
+
+/
+ *
+ *  Spi protocol Function
+ *
+ /
+
+#define CMD_DMA_WRITE  0xc1
+#define CMD_DMA_READ   0xc2
+#define CMD_INTERNAL_WRITE 0xc3
+#define CMD_INTERNAL_READ  0xc4
+#define CMD_TERMINATE  0xc5
+#define CMD_REPEAT 0xc6
+#define CMD_DMA_EXT_WRITE  0xc7
+#define CMD_DMA_EXT_READ   0xc8
+#define CMD_SINGLE_WRITE   0xc9
+#define CMD_SINGLE_READ0xca
+#define CMD_RESET  0xcf
+
+#define DATA_PKT_SZ_256256
+#define DATA_PKT_SZ_512512
+#define DATA_PKT_SZ_1K 1024
+#define DATA_PKT_SZ_4K (4 * 1024)
+#define DATA_PKT_SZ_8K (8 * 1024)
+#define DATA_PKT_SZDATA_PKT_SZ_8K
+
+#define USE_SPI_DMA0
+
+#define WILC_SPI_COMMAND_STAT_SUCCESS  0
+#define WILC_GET_RESP_HDR_START(h) (((h) >> 4) & 0xf)
+
+struct wilc_spi_cmd {
+   u8 cmd_type;
+   union {
+   struct {
+   u8 addr[3];
+   u8 crc[];
+   } __packed simple_cmd;
+   struct {
+   u8 addr[3];
+   u8 size[2];
+   u8 crc[];
+   } __packed dma_cmd;
+   struct {
+   u8 addr[3];
+   u8 size[3];
+   u8 crc[];
+   } __packed dma_cmd_ext;
+ 

[PATCH v5 17/17] wilc1000: add Makefile and Kconfig files for wilc1000 compilation

2020-03-11 Thread Ajay.Kathat
From: Ajay Singh 

Added Makefile and Kconfig files for compiling wilc1000 module from
'drivers/net/wireless/microchip/'.

Signed-off-by: Ajay Singh 
---
 drivers/net/wireless/Kconfig  |  1 +
 drivers/net/wireless/Makefile |  1 +
 drivers/net/wireless/microchip/Kconfig| 15 +++
 drivers/net/wireless/microchip/Makefile   |  2 +
 .../net/wireless/microchip/wilc1000/Kconfig   | 42 +++
 .../net/wireless/microchip/wilc1000/Makefile  | 14 +++
 drivers/staging/Kconfig   |  2 -
 drivers/staging/Makefile  |  1 -
 8 files changed, 75 insertions(+), 3 deletions(-)
 create mode 100644 drivers/net/wireless/microchip/Kconfig
 create mode 100644 drivers/net/wireless/microchip/Makefile
 create mode 100644 drivers/net/wireless/microchip/wilc1000/Kconfig
 create mode 100644 drivers/net/wireless/microchip/wilc1000/Makefile

diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig
index 1c98d781ae49..86faf8f3d9b0 100644
--- a/drivers/net/wireless/Kconfig
+++ b/drivers/net/wireless/Kconfig
@@ -47,6 +47,7 @@ source "drivers/net/wireless/st/Kconfig"
 source "drivers/net/wireless/ti/Kconfig"
 source "drivers/net/wireless/zydas/Kconfig"
 source "drivers/net/wireless/quantenna/Kconfig"
+source "drivers/net/wireless/microchip/Kconfig"
 
 config PCMCIA_RAYCS
tristate "Aviator/Raytheon 2.4GHz wireless support"
diff --git a/drivers/net/wireless/Makefile b/drivers/net/wireless/Makefile
index 6cfe74515c95..f9a51c2889ca 100644
--- a/drivers/net/wireless/Makefile
+++ b/drivers/net/wireless/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_WLAN_VENDOR_ST) += st/
 obj-$(CONFIG_WLAN_VENDOR_TI) += ti/
 obj-$(CONFIG_WLAN_VENDOR_ZYDAS) += zydas/
 obj-$(CONFIG_WLAN_VENDOR_QUANTENNA) += quantenna/
+obj-$(CONFIG_WLAN_VENDOR_MICROCHIP) += microchip/
 
 # 16-bit wireless PCMCIA client drivers
 obj-$(CONFIG_PCMCIA_RAYCS) += ray_cs.o
diff --git a/drivers/net/wireless/microchip/Kconfig 
b/drivers/net/wireless/microchip/Kconfig
new file mode 100644
index ..a6b46fb6b1ec
--- /dev/null
+++ b/drivers/net/wireless/microchip/Kconfig
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: GPL-2.0
+config WLAN_VENDOR_MICROCHIP
+   bool "Microchip devices"
+   default y
+   help
+   If you have a wireless card belonging to this class, say Y.
+
+   Note that the answer to this question doesn't directly affect the
+   kernel: saying N will just cause the configurator to skip all the
+   questions about these cards. If you say Y, you will be asked for
+   your specific card in the following questions.
+
+if WLAN_VENDOR_MICROCHIP
+source "drivers/net/wireless/microchip/wilc1000/Kconfig"
+endif # WLAN_VENDOR_MICROCHIP
diff --git a/drivers/net/wireless/microchip/Makefile 
b/drivers/net/wireless/microchip/Makefile
new file mode 100644
index ..73b763c7393e
--- /dev/null
+++ b/drivers/net/wireless/microchip/Makefile
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-$(CONFIG_WILC1000) += wilc1000/
diff --git a/drivers/net/wireless/microchip/wilc1000/Kconfig 
b/drivers/net/wireless/microchip/wilc1000/Kconfig
new file mode 100644
index ..59e58550d139
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/Kconfig
@@ -0,0 +1,42 @@
+# SPDX-License-Identifier: GPL-2.0
+config WILC1000
+   tristate
+   help
+ This module only support IEEE 802.11n WiFi.
+
+config WILC1000_SDIO
+   tristate "Atmel WILC1000 SDIO (WiFi only)"
+   depends on CFG80211 && INET && MMC
+   select WILC1000
+   help
+ This module adds support for the SDIO interface of adapters using
+ WILC1000 chipset. The Atmel WILC1000 SDIO is a full speed interface.
+ It meets SDIO card specification version 2.0. The interface supports
+ the 1-bit/4-bit SD transfer mode at the clock range of 0-50 MHz.
+ The host can use this interface to read and write from any register
+ within the chip as well as configure the WILC1000 for data DMA.
+ To use this interface, pin9 (SDIO_SPI_CFG) must be grounded. Select
+ this if your platform is using the SDIO bus.
+
+config WILC1000_SPI
+   tristate "Atmel WILC1000 SPI (WiFi only)"
+   depends on CFG80211 && INET && SPI
+   select WILC1000
+   help
+ This module adds support for the SPI interface of adapters using
+ WILC1000 chipset. The Atmel WILC1000 has a Serial Peripheral
+ Interface (SPI) that operates as a SPI slave. This SPI interface can
+ be used for control and for serial I/O of 802.11 data. The SPI is a
+ full-duplex slave synchronous serial interface that is available
+ immediately following reset when pin 9 (SDIO_SPI_CFG) is tied to
+ VDDIO. Select this if your platform is using the SPI bus.
+
+config WILC1000_HW_OOB_INTR
+   bool "WILC1000 out of band interrupt"
+   depends on WILC1000_SDIO
+   

[PATCH v5 16/17] dt: bindings: net: add microchip,wilc1000.yaml

2020-03-11 Thread Ajay.Kathat
From: Ajay Singh 

This file describes the binding details to connect wilc1000 device. It's
moved from staging to 'Documentation/devicetree/bindings/net/wireless'
path.

Signed-off-by: Ajay Singh 
---
 .../net/wireless/microchip,wilc1000.yaml  | 72 +++
 1 file changed, 72 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml

diff --git 
a/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml 
b/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml
new file mode 100644
index ..bc6cc5d3f347
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml
@@ -0,0 +1,72 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/wireless/microchip,wilc1000.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Microchip WILC wireless devicetree bindings
+
+maintainers:
+  - Adham Abozaeid 
+  - Ajay Singh 
+
+description:
+  The wilc1000 chips can be connected via SPI or SDIO. This document
+  describes the binding to connect wilc devices.
+
+properties:
+  compatible:
+const: microchip,wilc1000
+
+  spi-max-frequency: true
+
+  interrupts:
+maxItems: 1
+
+  clocks:
+description: phandle to the clock connected on rtc clock line.
+maxItems: 1
+
+  clock-names:
+const: rtc
+
+required:
+  - compatible
+  - interrupts
+
+examples:
+  - |
+spi1: spi@fc018000 {
+  #address-cells = <1>;
+  #size-cells = <0>;
+  cs-gpios = < 21 0>;
+  wifi@0 {
+compatible = "microchip,wilc1000";
+spi-max-frequency = <4800>;
+reg = <0>;
+interrupt-parent = <>;
+interrupts = <27 0>;
+clocks = <>;
+clock-names = "rtc";
+  };
+};
+
+  - |
+mmc1: mmc@fc00 {
+  #address-cells = <1>;
+  #size-cells = <0>;
+  pinctrl-names = "default";
+  pinctrl-0 = <_mmc1_clk_cmd_dat0 _mmc1_dat1_3>;
+  non-removable;
+  vmmc-supply = <_mmc1_reg>;
+  vqmmc-supply = <_3v3_reg>;
+  bus-width = <4>;
+  wifi@0 {
+compatible = "microchip,wilc1000";
+reg = <0>;
+interrupt-parent = <>;
+interrupts = <27 0>;
+clocks = <>;
+clock-names = "rtc";
+  };
+};
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 06/17] wilc1000: add cfg80211.c

2020-03-11 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/cfg80211.c' to
'drivers/net/wireless/microchip/wilc1000/cfg80211.c'.

Signed-off-by: Ajay Singh 
---
 .../wireless/microchip/wilc1000/cfg80211.c| 1850 +
 1 file changed, 1850 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/cfg80211.c

diff --git a/drivers/net/wireless/microchip/wilc1000/cfg80211.c 
b/drivers/net/wireless/microchip/wilc1000/cfg80211.c
new file mode 100644
index ..54e02807cebf
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/cfg80211.c
@@ -0,0 +1,1850 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#include "cfg80211.h"
+
+#define GO_NEG_REQ 0x00
+#define GO_NEG_RSP 0x01
+#define GO_NEG_CONF0x02
+#define P2P_INV_REQ0x03
+#define P2P_INV_RSP0x04
+
+#define WILC_INVALID_CHANNEL   0
+
+/* Operation at 2.4 GHz with channels 1-13 */
+#define WILC_WLAN_OPERATING_CLASS_2_4GHZ   0x51
+
+static const struct ieee80211_txrx_stypes
+   wilc_wfi_cfg80211_mgmt_types[NUM_NL80211_IFTYPES] = {
+   [NL80211_IFTYPE_STATION] = {
+   .tx = 0x,
+   .rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
+   BIT(IEEE80211_STYPE_PROBE_REQ >> 4)
+   },
+   [NL80211_IFTYPE_AP] = {
+   .tx = 0x,
+   .rx = BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) |
+   BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) |
+   BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
+   BIT(IEEE80211_STYPE_DISASSOC >> 4) |
+   BIT(IEEE80211_STYPE_AUTH >> 4) |
+   BIT(IEEE80211_STYPE_DEAUTH >> 4) |
+   BIT(IEEE80211_STYPE_ACTION >> 4)
+   },
+   [NL80211_IFTYPE_P2P_CLIENT] = {
+   .tx = 0x,
+   .rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
+   BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
+   BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) |
+   BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) |
+   BIT(IEEE80211_STYPE_DISASSOC >> 4) |
+   BIT(IEEE80211_STYPE_AUTH >> 4) |
+   BIT(IEEE80211_STYPE_DEAUTH >> 4)
+   }
+};
+
+static const struct wiphy_wowlan_support wowlan_support = {
+   .flags = WIPHY_WOWLAN_ANY
+};
+
+struct wilc_p2p_mgmt_data {
+   int size;
+   u8 *buff;
+};
+
+struct wilc_p2p_pub_act_frame {
+   u8 category;
+   u8 action;
+   u8 oui[3];
+   u8 oui_type;
+   u8 oui_subtype;
+   u8 dialog_token;
+   u8 elem[];
+} __packed;
+
+struct wilc_vendor_specific_ie {
+   u8 tag_number;
+   u8 tag_len;
+   u8 oui[3];
+   u8 oui_type;
+   u8 attr[];
+} __packed;
+
+struct wilc_attr_entry {
+   u8  attr_type;
+   __le16 attr_len;
+   u8 val[];
+} __packed;
+
+struct wilc_attr_oper_ch {
+   u8 attr_type;
+   __le16 attr_len;
+   u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
+   u8 op_class;
+   u8 op_channel;
+} __packed;
+
+struct wilc_attr_ch_list {
+   u8 attr_type;
+   __le16 attr_len;
+   u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
+   u8 elem[];
+} __packed;
+
+struct wilc_ch_list_elem {
+   u8 op_class;
+   u8 no_of_channels;
+   u8 ch_list[];
+} __packed;
+
+static void cfg_scan_result(enum scan_event scan_event,
+   struct wilc_rcvd_net_info *info, void *user_void)
+{
+   struct wilc_priv *priv = user_void;
+
+   if (!priv->cfg_scanning)
+   return;
+
+   if (scan_event == SCAN_EVENT_NETWORK_FOUND) {
+   s32 freq;
+   struct ieee80211_channel *channel;
+   struct cfg80211_bss *bss;
+   struct wiphy *wiphy = priv->dev->ieee80211_ptr->wiphy;
+
+   if (!wiphy || !info)
+   return;
+
+   freq = ieee80211_channel_to_frequency((s32)info->ch,
+ NL80211_BAND_2GHZ);
+   channel = ieee80211_get_channel(wiphy, freq);
+   if (!channel)
+   return;
+
+   bss = cfg80211_inform_bss_frame(wiphy, channel, info->mgmt,
+   info->frame_len,
+   (s32)info->rssi * 100,
+   GFP_KERNEL);
+   if (!bss)
+   cfg80211_put_bss(wiphy, bss);
+   } else if (scan_event == SCAN_EVENT_DONE) {
+   mutex_lock(>scan_req_lock);
+
+   if (priv->scan_req) {
+   struct cfg80211_scan_info info = {
+   .aborted = false,
+   };
+

[PATCH v5 12/17] wilc1000: add wlan.h

2020-03-11 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/wlan.h' to
'drivers/net/wireless/microchip/wilc1000/wlan.h'.

Signed-off-by: Ajay Singh 
---
 .../net/wireless/microchip/wilc1000/wlan.h| 397 ++
 1 file changed, 397 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/wlan.h

diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.h 
b/drivers/net/wireless/microchip/wilc1000/wlan.h
new file mode 100644
index ..7689569cd82f
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/wlan.h
@@ -0,0 +1,397 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#ifndef WILC_WLAN_H
+#define WILC_WLAN_H
+
+#include 
+#include 
+
+/
+ *
+ *  Mac eth header length
+ *
+ /
+#define MAX_MAC_HDR_LEN26 /* QOS_MAC_HDR_LEN */
+#define SUB_MSDU_HEADER_LENGTH 14
+#define SNAP_HDR_LEN   8
+#define ETHERNET_HDR_LEN   14
+#define WORD_ALIGNMENT_PAD 0
+
+#define ETH_ETHERNET_HDR_OFFSET(MAX_MAC_HDR_LEN + \
+SUB_MSDU_HEADER_LENGTH + \
+SNAP_HDR_LEN - \
+ETHERNET_HDR_LEN + \
+WORD_ALIGNMENT_PAD)
+
+#define HOST_HDR_OFFSET4
+#define ETHERNET_HDR_LEN   14
+#define IP_HDR_LEN 20
+#define IP_HDR_OFFSET  ETHERNET_HDR_LEN
+#define UDP_HDR_OFFSET (IP_HDR_LEN + IP_HDR_OFFSET)
+#define UDP_HDR_LEN8
+#define UDP_DATA_OFFSET(UDP_HDR_OFFSET + UDP_HDR_LEN)
+#define ETH_CONFIG_PKT_HDR_LEN UDP_DATA_OFFSET
+
+#define ETH_CONFIG_PKT_HDR_OFFSET  (ETH_ETHERNET_HDR_OFFSET + \
+ETH_CONFIG_PKT_HDR_LEN)
+
+/
+ *
+ *  Register Defines
+ *
+ /
+#define WILC_PERIPH_REG_BASE   0x1000
+#define WILC_CHANGING_VIR_IF   0x108c
+#define WILC_CHIPIDWILC_PERIPH_REG_BASE
+#define WILC_GLB_RESET_0   (WILC_PERIPH_REG_BASE + 0x400)
+#define WILC_PIN_MUX_0 (WILC_PERIPH_REG_BASE + 0x408)
+#define WILC_HOST_TX_CTRL  (WILC_PERIPH_REG_BASE + 0x6c)
+#define WILC_HOST_RX_CTRL_0(WILC_PERIPH_REG_BASE + 0x70)
+#define WILC_HOST_RX_CTRL_1(WILC_PERIPH_REG_BASE + 0x74)
+#define WILC_HOST_VMM_CTL  (WILC_PERIPH_REG_BASE + 0x78)
+#define WILC_HOST_RX_CTRL  (WILC_PERIPH_REG_BASE + 0x80)
+#define WILC_HOST_RX_EXTRA_SIZE(WILC_PERIPH_REG_BASE + 0x84)
+#define WILC_HOST_TX_CTRL_1(WILC_PERIPH_REG_BASE + 0x88)
+#define WILC_MISC  (WILC_PERIPH_REG_BASE + 0x428)
+#define WILC_INTR_REG_BASE (WILC_PERIPH_REG_BASE + 0xa00)
+#define WILC_INTR_ENABLE   WILC_INTR_REG_BASE
+#define WILC_INTR2_ENABLE  (WILC_INTR_REG_BASE + 4)
+
+#define WILC_INTR_POLARITY (WILC_INTR_REG_BASE + 0x10)
+#define WILC_INTR_TYPE (WILC_INTR_REG_BASE + 0x20)
+#define WILC_INTR_CLEAR(WILC_INTR_REG_BASE + 0x30)
+#define WILC_INTR_STATUS   (WILC_INTR_REG_BASE + 0x40)
+
+#define WILC_RF_REVISION_ID0x13f4
+
+#define WILC_VMM_TBL_SIZE  64
+#define WILC_VMM_TX_TBL_BASE   0x150400
+#define WILC_VMM_RX_TBL_BASE   0x150500
+
+#define WILC_VMM_BASE  0x15
+#define WILC_VMM_CORE_CTL  WILC_VMM_BASE
+#define WILC_VMM_TBL_CTL   (WILC_VMM_BASE + 0x4)
+#define WILC_VMM_TBL_ENTRY (WILC_VMM_BASE + 0x8)
+#define WILC_VMM_TBL0_SIZE (WILC_VMM_BASE + 0xc)
+#define WILC_VMM_TO_HOST_SIZE  (WILC_VMM_BASE + 0x10)
+#define WILC_VMM_CORE_CFG  (WILC_VMM_BASE + 0x14)
+#define WILC_VMM_TBL_ACTIVE(WILC_VMM_BASE + 040)
+#define WILC_VMM_TBL_STATUS(WILC_VMM_BASE + 0x44)
+
+#define WILC_SPI_REG_BASE  0xe800
+#define WILC_SPI_CTL   WILC_SPI_REG_BASE
+#define WILC_SPI_MASTER_DMA_ADDR   (WILC_SPI_REG_BASE + 0x4)
+#define WILC_SPI_MASTER_DMA_COUNT  (WILC_SPI_REG_BASE + 0x8)
+#define WILC_SPI_SLAVE_DMA_ADDR(WILC_SPI_REG_BASE + 0xc)
+#define WILC_SPI_SLAVE_DMA_COUNT   (WILC_SPI_REG_BASE + 0x10)
+#define WILC_SPI_TX_MODE   (WILC_SPI_REG_BASE + 0x20)
+#define WILC_SPI_PROTOCOL_CONFIG   (WILC_SPI_REG_BASE + 0x24)
+#define WILC_SPI_INTR_CTL  (WILC_SPI_REG_BASE + 0x2c)
+#define WILC_SPI_INT_STATUS(WILC_SPI_REG_BASE + 0x40)
+#define WILC_SPI_INT_CLEAR (WILC_SPI_REG_BASE + 0x44)
+
+#define 

[PATCH v5 02/17] wilc1000: add hif.c

2020-03-11 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/hif.c' to
'drivers/net/wireless/microchip/wilc1000/hif.c'.

Signed-off-by: Ajay Singh 
---
 drivers/net/wireless/microchip/wilc1000/hif.c | 1959 +
 1 file changed, 1959 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/hif.c

diff --git a/drivers/net/wireless/microchip/wilc1000/hif.c 
b/drivers/net/wireless/microchip/wilc1000/hif.c
new file mode 100644
index ..6c7de2f8d3f2
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/hif.c
@@ -0,0 +1,1959 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#include "netdev.h"
+
+#define WILC_HIF_SCAN_TIMEOUT_MS5000
+#define WILC_HIF_CONNECT_TIMEOUT_MS 9500
+
+#define WILC_FALSE_FRMWR_CHANNEL   100
+
+struct wilc_rcvd_mac_info {
+   u8 status;
+};
+
+struct wilc_set_multicast {
+   u32 enabled;
+   u32 cnt;
+   u8 *mc_list;
+};
+
+struct wilc_del_all_sta {
+   u8 assoc_sta;
+   u8 mac[WILC_MAX_NUM_STA][ETH_ALEN];
+};
+
+union wilc_message_body {
+   struct wilc_rcvd_net_info net_info;
+   struct wilc_rcvd_mac_info mac_info;
+   struct wilc_set_multicast mc_info;
+   struct wilc_remain_ch remain_on_ch;
+   char *data;
+};
+
+struct host_if_msg {
+   union wilc_message_body body;
+   struct wilc_vif *vif;
+   struct work_struct work;
+   void (*fn)(struct work_struct *ws);
+   struct completion work_comp;
+   bool is_sync;
+};
+
+/* 'msg' should be free by the caller for syc */
+static struct host_if_msg*
+wilc_alloc_work(struct wilc_vif *vif, void (*work_fun)(struct work_struct *),
+   bool is_sync)
+{
+   struct host_if_msg *msg;
+
+   if (!work_fun)
+   return ERR_PTR(-EINVAL);
+
+   msg = kzalloc(sizeof(*msg), GFP_ATOMIC);
+   if (!msg)
+   return ERR_PTR(-ENOMEM);
+   msg->fn = work_fun;
+   msg->vif = vif;
+   msg->is_sync = is_sync;
+   if (is_sync)
+   init_completion(>work_comp);
+
+   return msg;
+}
+
+static int wilc_enqueue_work(struct host_if_msg *msg)
+{
+   INIT_WORK(>work, msg->fn);
+
+   if (!msg->vif || !msg->vif->wilc || !msg->vif->wilc->hif_workqueue)
+   return -EINVAL;
+
+   if (!queue_work(msg->vif->wilc->hif_workqueue, >work))
+   return -EINVAL;
+
+   return 0;
+}
+
+/* The idx starts from 0 to (NUM_CONCURRENT_IFC - 1), but 0 index used as
+ * special purpose in wilc device, so we add 1 to the index to starts from 1.
+ * As a result, the returned index will be 1 to NUM_CONCURRENT_IFC.
+ */
+int wilc_get_vif_idx(struct wilc_vif *vif)
+{
+   return vif->idx + 1;
+}
+
+/* We need to minus 1 from idx which is from wilc device to get real index
+ * of wilc->vif[], because we add 1 when pass to wilc device in the function
+ * wilc_get_vif_idx.
+ * As a result, the index should be between 0 and (NUM_CONCURRENT_IFC - 1).
+ */
+static struct wilc_vif *wilc_get_vif_from_idx(struct wilc *wilc, int idx)
+{
+   int index = idx - 1;
+   struct wilc_vif *vif;
+
+   if (index < 0 || index >= WILC_NUM_CONCURRENT_IFC)
+   return NULL;
+
+   list_for_each_entry_rcu(vif, >vif_list, list) {
+   if (vif->idx == index)
+   return vif;
+   }
+
+   return NULL;
+}
+
+static int handle_scan_done(struct wilc_vif *vif, enum scan_event evt)
+{
+   int result = 0;
+   u8 abort_running_scan;
+   struct wid wid;
+   struct host_if_drv *hif_drv = vif->hif_drv;
+   struct wilc_user_scan_req *scan_req;
+
+   if (evt == SCAN_EVENT_ABORTED) {
+   abort_running_scan = 1;
+   wid.id = WID_ABORT_RUNNING_SCAN;
+   wid.type = WID_CHAR;
+   wid.val = (s8 *)_running_scan;
+   wid.size = sizeof(char);
+
+   result = wilc_send_config_pkt(vif, WILC_SET_CFG, , 1);
+   if (result) {
+   netdev_err(vif->ndev, "Failed to set abort running\n");
+   result = -EFAULT;
+   }
+   }
+
+   if (!hif_drv) {
+   netdev_err(vif->ndev, "%s: hif driver is NULL\n", __func__);
+   return result;
+   }
+
+   scan_req = _drv->usr_scan_req;
+   if (scan_req->scan_result) {
+   scan_req->scan_result(evt, NULL, scan_req->arg);
+   scan_req->scan_result = NULL;
+   }
+
+   return result;
+}
+
+int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
+ u8 *ch_freq_list, u8 ch_list_len,
+ void (*scan_result_fn)(enum scan_event,
+struct wilc_rcvd_net_info *, void *),
+ void *user_arg, struct cfg80211_scan_request *request)
+{
+   int result = 0;
+   struct wid wid_list[5];
+   u32 

[PATCH v5 13/17] wilc1000: add wlan.c

2020-03-11 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/wlan.c' to
'drivers/net/wireless/microchip/wilc1000/wlan.c'.

Signed-off-by: Ajay Singh 
---
 .../net/wireless/microchip/wilc1000/wlan.c| 1238 +
 1 file changed, 1238 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/wlan.c

diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c 
b/drivers/net/wireless/microchip/wilc1000/wlan.c
new file mode 100644
index ..6a82fb2f283e
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/wlan.c
@@ -0,0 +1,1238 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#include 
+#include 
+#include "cfg80211.h"
+#include "wlan_cfg.h"
+
+static inline bool is_wilc1000(u32 id)
+{
+   return (id & (~WILC_CHIP_REV_FIELD)) == WILC_1000_BASE_ID;
+}
+
+static inline void acquire_bus(struct wilc *wilc, enum bus_acquire acquire)
+{
+   mutex_lock(>hif_cs);
+   if (acquire == WILC_BUS_ACQUIRE_AND_WAKEUP)
+   chip_wakeup(wilc);
+}
+
+static inline void release_bus(struct wilc *wilc, enum bus_release release)
+{
+   if (release == WILC_BUS_RELEASE_ALLOW_SLEEP)
+   chip_allow_sleep(wilc);
+   mutex_unlock(>hif_cs);
+}
+
+static void wilc_wlan_txq_remove(struct wilc *wilc, struct txq_entry_t *tqe)
+{
+   list_del(>list);
+   wilc->txq_entries -= 1;
+}
+
+static struct txq_entry_t *
+wilc_wlan_txq_remove_from_head(struct net_device *dev)
+{
+   struct txq_entry_t *tqe = NULL;
+   unsigned long flags;
+   struct wilc_vif *vif = netdev_priv(dev);
+   struct wilc *wilc = vif->wilc;
+
+   spin_lock_irqsave(>txq_spinlock, flags);
+
+   if (!list_empty(>txq_head.list)) {
+   tqe = list_first_entry(>txq_head.list, struct txq_entry_t,
+  list);
+   list_del(>list);
+   wilc->txq_entries -= 1;
+   }
+   spin_unlock_irqrestore(>txq_spinlock, flags);
+   return tqe;
+}
+
+static void wilc_wlan_txq_add_to_tail(struct net_device *dev,
+ struct txq_entry_t *tqe)
+{
+   unsigned long flags;
+   struct wilc_vif *vif = netdev_priv(dev);
+   struct wilc *wilc = vif->wilc;
+
+   spin_lock_irqsave(>txq_spinlock, flags);
+
+   list_add_tail(>list, >txq_head.list);
+   wilc->txq_entries += 1;
+
+   spin_unlock_irqrestore(>txq_spinlock, flags);
+
+   complete(>txq_event);
+}
+
+static void wilc_wlan_txq_add_to_head(struct wilc_vif *vif,
+ struct txq_entry_t *tqe)
+{
+   unsigned long flags;
+   struct wilc *wilc = vif->wilc;
+
+   mutex_lock(>txq_add_to_head_cs);
+
+   spin_lock_irqsave(>txq_spinlock, flags);
+
+   list_add(>list, >txq_head.list);
+   wilc->txq_entries += 1;
+
+   spin_unlock_irqrestore(>txq_spinlock, flags);
+   mutex_unlock(>txq_add_to_head_cs);
+   complete(>txq_event);
+}
+
+#define NOT_TCP_ACK(-1)
+
+static inline void add_tcp_session(struct wilc_vif *vif, u32 src_prt,
+  u32 dst_prt, u32 seq)
+{
+   struct tcp_ack_filter *f = >ack_filter;
+
+   if (f->tcp_session < 2 * MAX_TCP_SESSION) {
+   f->ack_session_info[f->tcp_session].seq_num = seq;
+   f->ack_session_info[f->tcp_session].bigger_ack_num = 0;
+   f->ack_session_info[f->tcp_session].src_port = src_prt;
+   f->ack_session_info[f->tcp_session].dst_port = dst_prt;
+   f->tcp_session++;
+   }
+}
+
+static inline void update_tcp_session(struct wilc_vif *vif, u32 index, u32 ack)
+{
+   struct tcp_ack_filter *f = >ack_filter;
+
+   if (index < 2 * MAX_TCP_SESSION &&
+   ack > f->ack_session_info[index].bigger_ack_num)
+   f->ack_session_info[index].bigger_ack_num = ack;
+}
+
+static inline void add_tcp_pending_ack(struct wilc_vif *vif, u32 ack,
+  u32 session_index,
+  struct txq_entry_t *txqe)
+{
+   struct tcp_ack_filter *f = >ack_filter;
+   u32 i = f->pending_base + f->pending_acks_idx;
+
+   if (i < MAX_PENDING_ACKS) {
+   f->pending_acks[i].ack_num = ack;
+   f->pending_acks[i].txqe = txqe;
+   f->pending_acks[i].session_index = session_index;
+   txqe->ack_idx = i;
+   f->pending_acks_idx++;
+   }
+}
+
+static inline void tcp_process(struct net_device *dev, struct txq_entry_t *tqe)
+{
+   void *buffer = tqe->buffer;
+   const struct ethhdr *eth_hdr_ptr = buffer;
+   int i;
+   unsigned long flags;
+   struct wilc_vif *vif = netdev_priv(dev);
+   struct wilc *wilc = vif->wilc;
+   struct tcp_ack_filter *f = >ack_filter;
+   const struct iphdr *ip_hdr_ptr;
+   const struct tcphdr *tcp_hdr_ptr;
+  

[PATCH v5 00/17] wilc1000: move out of staging

2020-03-11 Thread Ajay.Kathat
From: Ajay Singh 

This patch series is to review and move wilc1000 driver out of staging.
Most of the review comments received in [1] & [2] are addressed in the
latest code. Please review and provide your inputs.

[1]. 
https://lore.kernel.org/linux-wireless/1537957525-11467-1-git-send-email-ajay.kat...@microchip.com/
[2]. 
https://lore.kernel.org/linux-wireless/1562896697-8002-1-git-send-email-ajay.kat...@microchip.com/

Changes since v4:
  - merged wilc1000 SDIO and SPI DT binding into a single file.
  - handle DT binding review comments suggested in below links:
* https://lore.kernel.org/linux-wireless/20200303015558.GA6876@bogus
* 
https://lore.kernel.org/linux-wireless/20200306144400.4269-2-ajay.kat...@microchip.com

Changes since v3:
  - handle few Smatch static checker reported issues.
  - use flexible-array member instead of zero-length array.

Changes since v2:
  - use 'struct' to extract FW info from received commands.
  - make use of C style comments instead of C++.
  - remove use of bool type for firmware struct.
  - deleted unused code related to interrupt handling.
  - make use of RCU list to maintain interfaces list.
  - remove 'wilc_' prefix from file name.
  - added 'WILC_' prefix for header guard macro.
  - remove use of infinite loops(i.e. while(1)).
  - move firmware related struct to a separate file.
  - refactor SPI command handling by using 'struct'.
  - use different functions to handle different SPI commands.
  - cleanup spi.c and sdio.c by removing unused code.
  - remove use of vendor specific IE for p2p handling.
  - refactor p2p related code to avoid use of buf pointer operation.
  - make use of FIELD_GET/PREP macro.
  - use #define instead of magic values.
  - use YAML schemes for DT binding documentation.
  - deleted unused code from spi.c and sdio.c.
  - added changes for few issues reported by smatch static code analyzer.

Changes since v1:
  - remove use of shadow buffer to keep scan result.
  - remove internal messaging flow to handle cfg80211_ops.
  - make use of cfg80211 provide API.
  - use 'struct' for packing firmware commands.
  - make use of kernel API's and Macro.
  - remove unnecessary log messages
  - supported dynamically add/remove interfaces.
  - cleanup and deleted around 3.3k lines of code.

Ajay Singh (17):
  wilc1000: add hif.h
  wilc1000: add hif.c
  wilc1000: add wlan_if.h
  wilc1000: add wlan_cfg.h
  wilc1000: add wlan_cfg.c
  wilc1000: add cfg80211.c
  wilc1000: add cfg80211.h
  wilc1000: add netdev.h
  wilc1000: add netdev.c
  wilc1000: add mon.c
  wilc1000: add spi.c
  wilc1000: add wlan.h
  wilc1000: add wlan.c
  wilc1000: add sdio.c
  wilc1000: add fw.h
  dt: bindings: net: add microchip,wilc1000.yaml
  wilc1000: add Makefile and Kconfig files for wilc1000 compilation

 .../net/wireless/microchip,wilc1000.yaml  |   72 +
 drivers/net/wireless/Kconfig  |1 +
 drivers/net/wireless/Makefile |1 +
 drivers/net/wireless/microchip/Kconfig|   15 +
 drivers/net/wireless/microchip/Makefile   |2 +
 .../net/wireless/microchip/wilc1000/Kconfig   |   42 +
 .../net/wireless/microchip/wilc1000/Makefile  |   14 +
 .../wireless/microchip/wilc1000/cfg80211.c| 1850 
 .../wireless/microchip/wilc1000/cfg80211.h|   29 +
 drivers/net/wireless/microchip/wilc1000/fw.h  |  119 +
 drivers/net/wireless/microchip/wilc1000/hif.c | 1959 +
 drivers/net/wireless/microchip/wilc1000/hif.h |  214 ++
 drivers/net/wireless/microchip/wilc1000/mon.c |  260 +++
 .../net/wireless/microchip/wilc1000/netdev.c  |  932 
 .../net/wireless/microchip/wilc1000/netdev.h  |  294 +++
 .../net/wireless/microchip/wilc1000/sdio.c| 1023 +
 drivers/net/wireless/microchip/wilc1000/spi.c |  988 +
 .../net/wireless/microchip/wilc1000/wlan.c| 1238 +++
 .../net/wireless/microchip/wilc1000/wlan.h|  397 
 .../wireless/microchip/wilc1000/wlan_cfg.c|  413 
 .../wireless/microchip/wilc1000/wlan_cfg.h|   54 +
 .../net/wireless/microchip/wilc1000/wlan_if.h |  803 +++
 drivers/staging/Kconfig   |2 -
 drivers/staging/Makefile  |1 -
 24 files changed, 10720 insertions(+), 3 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml
 create mode 100644 drivers/net/wireless/microchip/Kconfig
 create mode 100644 drivers/net/wireless/microchip/Makefile
 create mode 100644 drivers/net/wireless/microchip/wilc1000/Kconfig
 create mode 100644 drivers/net/wireless/microchip/wilc1000/Makefile
 create mode 100644 drivers/net/wireless/microchip/wilc1000/cfg80211.c
 create mode 100644 drivers/net/wireless/microchip/wilc1000/cfg80211.h
 create mode 100644 drivers/net/wireless/microchip/wilc1000/fw.h
 create mode 100644 drivers/net/wireless/microchip/wilc1000/hif.c
 create mode 100644 drivers/net/wireless/microchip/wilc1000/hif.h
 create mode 100644 

[PATCH v5 07/17] wilc1000: add cfg80211.h

2020-03-11 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/cfg80211.h' to
'drivers/net/wireless/microchip/wilc1000/cfg80211.h'.

Signed-off-by: Ajay Singh 
---
 .../wireless/microchip/wilc1000/cfg80211.h| 29 +++
 1 file changed, 29 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/cfg80211.h

diff --git a/drivers/net/wireless/microchip/wilc1000/cfg80211.h 
b/drivers/net/wireless/microchip/wilc1000/cfg80211.h
new file mode 100644
index ..5e5d63f70df2
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/cfg80211.h
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#ifndef WILC_CFG80211_H
+#define WILC_CFG80211_H
+#include "netdev.h"
+
+struct wiphy *wilc_cfg_alloc(void);
+int wilc_cfg80211_init(struct wilc **wilc, struct device *dev, int io_type,
+  const struct wilc_hif_func *ops);
+struct wilc *wilc_create_wiphy(struct device *dev);
+void wilc_deinit_host_int(struct net_device *net);
+int wilc_init_host_int(struct net_device *net);
+void wilc_wfi_monitor_rx(struct net_device *mon_dev, u8 *buff, u32 size);
+struct wilc_vif *wilc_netdev_interface(struct wilc *wl, const char *name,
+  enum nl80211_iftype type);
+void wilc_wfi_deinit_mon_interface(struct wilc *wl, bool rtnl_locked);
+struct net_device *wilc_wfi_init_mon_interface(struct wilc *wl,
+  const char *name,
+  struct net_device *real_dev);
+void wilc_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev,
+ u16 frame_type, bool reg);
+struct wilc_vif *wilc_get_interface(struct wilc *wl);
+struct wilc_vif *wilc_get_wl_to_vif(struct wilc *wl);
+void wlan_deinit_locks(struct wilc *wilc);
+#endif
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 01/17] wilc1000: add hif.h

2020-03-11 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/hif.h' to
'drivers/net/wireless/microchip/wilc1000/hif.h'.

Signed-off-by: Ajay Singh 
---
 drivers/net/wireless/microchip/wilc1000/hif.h | 214 ++
 1 file changed, 214 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/hif.h

diff --git a/drivers/net/wireless/microchip/wilc1000/hif.h 
b/drivers/net/wireless/microchip/wilc1000/hif.h
new file mode 100644
index ..db9179171f05
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/hif.h
@@ -0,0 +1,214 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries
+ * All rights reserved.
+ */
+
+#ifndef WILC_HIF_H
+#define WILC_HIF_H
+#include 
+#include "wlan_if.h"
+
+enum {
+   WILC_IDLE_MODE = 0x0,
+   WILC_AP_MODE = 0x1,
+   WILC_STATION_MODE = 0x2,
+   WILC_GO_MODE = 0x3,
+   WILC_CLIENT_MODE = 0x4
+};
+
+#define WILC_MAX_NUM_PROBED_SSID   10
+
+#define WILC_TX_MIC_KEY_LEN8
+#define WILC_RX_MIC_KEY_LEN8
+
+#define WILC_ADD_STA_LENGTH40
+#define WILC_NUM_CONCURRENT_IFC2
+
+enum {
+   WILC_SET_CFG = 0,
+   WILC_GET_CFG
+};
+
+#define WILC_MAX_ASSOC_RESP_FRAME_SIZE   256
+
+struct rf_info {
+   u8 link_speed;
+   s8 rssi;
+   u32 tx_cnt;
+   u32 rx_cnt;
+   u32 tx_fail_cnt;
+};
+
+enum host_if_state {
+   HOST_IF_IDLE= 0,
+   HOST_IF_SCANNING= 1,
+   HOST_IF_CONNECTING  = 2,
+   HOST_IF_WAITING_CONN_RESP   = 3,
+   HOST_IF_CONNECTED   = 4,
+   HOST_IF_P2P_LISTEN  = 5,
+   HOST_IF_FORCE_32BIT = 0x
+};
+
+struct cfg_param_attr {
+   u32 flag;
+   u16 short_retry_limit;
+   u16 long_retry_limit;
+   u16 frag_threshold;
+   u16 rts_threshold;
+};
+
+enum cfg_param {
+   WILC_CFG_PARAM_RETRY_SHORT = BIT(0),
+   WILC_CFG_PARAM_RETRY_LONG = BIT(1),
+   WILC_CFG_PARAM_FRAG_THRESHOLD = BIT(2),
+   WILC_CFG_PARAM_RTS_THRESHOLD = BIT(3)
+};
+
+enum scan_event {
+   SCAN_EVENT_NETWORK_FOUND= 0,
+   SCAN_EVENT_DONE = 1,
+   SCAN_EVENT_ABORTED  = 2,
+   SCAN_EVENT_FORCE_32BIT  = 0x
+};
+
+enum conn_event {
+   CONN_DISCONN_EVENT_CONN_RESP= 0,
+   CONN_DISCONN_EVENT_DISCONN_NOTIF= 1,
+   CONN_DISCONN_EVENT_FORCE_32BIT  = 0x
+};
+
+enum {
+   WILC_HIF_SDIO = 0,
+   WILC_HIF_SPI = BIT(0)
+};
+
+enum {
+   WILC_MAC_STATUS_INIT = -1,
+   WILC_MAC_STATUS_DISCONNECTED = 0,
+   WILC_MAC_STATUS_CONNECTED = 1
+};
+
+struct wilc_rcvd_net_info {
+   s8 rssi;
+   u8 ch;
+   u16 frame_len;
+   struct ieee80211_mgmt *mgmt;
+};
+
+struct wilc_user_scan_req {
+   void (*scan_result)(enum scan_event evt,
+   struct wilc_rcvd_net_info *info, void *priv);
+   void *arg;
+   u32 ch_cnt;
+};
+
+struct wilc_conn_info {
+   u8 bssid[ETH_ALEN];
+   u8 security;
+   enum authtype auth_type;
+   u8 ch;
+   u8 *req_ies;
+   size_t req_ies_len;
+   u8 *resp_ies;
+   u16 resp_ies_len;
+   u16 status;
+   void (*conn_result)(enum conn_event evt, u8 status, void *priv_data);
+   void *arg;
+   void *param;
+};
+
+struct wilc_remain_ch {
+   u16 ch;
+   u32 duration;
+   void (*expired)(void *priv, u64 cookie);
+   void *arg;
+   u32 cookie;
+};
+
+struct wilc;
+struct host_if_drv {
+   struct wilc_user_scan_req usr_scan_req;
+   struct wilc_conn_info conn_info;
+   struct wilc_remain_ch remain_on_ch;
+   u64 p2p_timeout;
+
+   enum host_if_state hif_state;
+
+   u8 assoc_bssid[ETH_ALEN];
+
+   struct timer_list scan_timer;
+   struct wilc_vif *scan_timer_vif;
+
+   struct timer_list connect_timer;
+   struct wilc_vif *connect_timer_vif;
+
+   struct timer_list remain_on_ch_timer;
+   struct wilc_vif *remain_on_ch_timer_vif;
+
+   bool ifc_up;
+   u8 assoc_resp[WILC_MAX_ASSOC_RESP_FRAME_SIZE];
+};
+
+struct wilc_vif;
+int wilc_remove_wep_key(struct wilc_vif *vif, u8 index);
+int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index);
+int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len,
+u8 index);
+int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len,
+   u8 index, u8 mode, enum authtype auth_type);
+int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len,
+const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic,
+u8 mode, u8 cipher_mode, u8 index);
+s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac,
+  u32 *out_val);
+int wilc_add_rx_gtk(struct wilc_vif 

[PATCH v5 08/17] wilc1000: add netdev.h

2020-03-11 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/netdev.h' to
'drivers/net/wireless/microchip/wilc1000/netdev.h'.

Signed-off-by: Ajay Singh 
---
 .../net/wireless/microchip/wilc1000/netdev.h  | 294 ++
 1 file changed, 294 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/netdev.h

diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.h 
b/drivers/net/wireless/microchip/wilc1000/netdev.h
new file mode 100644
index ..61cbec674a62
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/netdev.h
@@ -0,0 +1,294 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#ifndef WILC_NETDEV_H
+#define WILC_NETDEV_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "hif.h"
+#include "wlan.h"
+#include "wlan_cfg.h"
+
+#define FLOW_CONTROL_LOWER_THRESHOLD   128
+#define FLOW_CONTROL_UPPER_THRESHOLD   256
+
+#define PMKID_FOUND1
+#define NUM_STA_ASSOCIATED 8
+
+#define NUM_REG_FRAME  2
+
+#define TCP_ACK_FILTER_LINK_SPEED_THRESH   54
+#define DEFAULT_LINK_SPEED 72
+
+struct wilc_wfi_stats {
+   unsigned long rx_packets;
+   unsigned long tx_packets;
+   unsigned long rx_bytes;
+   unsigned long tx_bytes;
+   u64 rx_time;
+   u64 tx_time;
+
+};
+
+struct wilc_wfi_key {
+   u8 *key;
+   u8 *seq;
+   int key_len;
+   int seq_len;
+   u32 cipher;
+};
+
+struct wilc_wfi_wep_key {
+   u8 *key;
+   u8 key_len;
+   u8 key_idx;
+};
+
+struct sta_info {
+   u8 sta_associated_bss[WILC_MAX_NUM_STA][ETH_ALEN];
+};
+
+/* Parameters needed for host interface for remaining on channel */
+struct wilc_wfi_p2p_listen_params {
+   struct ieee80211_channel *listen_ch;
+   u32 listen_duration;
+   u64 listen_cookie;
+};
+
+static const u32 wilc_cipher_suites[] = {
+   WLAN_CIPHER_SUITE_WEP40,
+   WLAN_CIPHER_SUITE_WEP104,
+   WLAN_CIPHER_SUITE_TKIP,
+   WLAN_CIPHER_SUITE_CCMP,
+   WLAN_CIPHER_SUITE_AES_CMAC
+};
+
+#define CHAN2G(_channel, _freq, _flags) {   \
+   .band = NL80211_BAND_2GHZ, \
+   .center_freq  = (_freq), \
+   .hw_value = (_channel),  \
+   .flags= (_flags),\
+   .max_antenna_gain = 0,   \
+   .max_power= 30,  \
+}
+
+static const struct ieee80211_channel wilc_2ghz_channels[] = {
+   CHAN2G(1,  2412, 0),
+   CHAN2G(2,  2417, 0),
+   CHAN2G(3,  2422, 0),
+   CHAN2G(4,  2427, 0),
+   CHAN2G(5,  2432, 0),
+   CHAN2G(6,  2437, 0),
+   CHAN2G(7,  2442, 0),
+   CHAN2G(8,  2447, 0),
+   CHAN2G(9,  2452, 0),
+   CHAN2G(10, 2457, 0),
+   CHAN2G(11, 2462, 0),
+   CHAN2G(12, 2467, 0),
+   CHAN2G(13, 2472, 0),
+   CHAN2G(14, 2484, 0)
+};
+
+#define RATETAB_ENT(_rate, _hw_value, _flags) {\
+   .bitrate  = (_rate),\
+   .hw_value = (_hw_value),\
+   .flags= (_flags),   \
+}
+
+static struct ieee80211_rate wilc_bitrates[] = {
+   RATETAB_ENT(10,  0,  0),
+   RATETAB_ENT(20,  1,  0),
+   RATETAB_ENT(55,  2,  0),
+   RATETAB_ENT(110, 3,  0),
+   RATETAB_ENT(60,  9,  0),
+   RATETAB_ENT(90,  6,  0),
+   RATETAB_ENT(120, 7,  0),
+   RATETAB_ENT(180, 8,  0),
+   RATETAB_ENT(240, 9,  0),
+   RATETAB_ENT(360, 10, 0),
+   RATETAB_ENT(480, 11, 0),
+   RATETAB_ENT(540, 12, 0)
+};
+
+struct wilc_priv {
+   struct wireless_dev wdev;
+   struct cfg80211_scan_request *scan_req;
+
+   struct wilc_wfi_p2p_listen_params remain_on_ch_params;
+   u64 tx_cookie;
+
+   bool cfg_scanning;
+
+   u8 associated_bss[ETH_ALEN];
+   struct sta_info assoc_stainfo;
+   struct sk_buff *skb;
+   struct net_device *dev;
+   struct host_if_drv *hif_drv;
+   struct wilc_pmkid_attr pmkid_list;
+   u8 wep_key[4][WLAN_KEY_LEN_WEP104];
+   u8 wep_key_len[4];
+
+   /* The real interface that the monitor is on */
+   struct net_device *real_ndev;
+   struct wilc_wfi_key *wilc_gtk[WILC_MAX_NUM_STA];
+   struct wilc_wfi_key *wilc_ptk[WILC_MAX_NUM_STA];
+   u8 wilc_groupkey;
+
+   /* mutexes */
+   struct mutex scan_req_lock;
+   bool p2p_listen_state;
+   int scanned_cnt;
+
+   u64 inc_roc_cookie;
+};
+
+struct frame_reg {
+   u16 type;
+   bool reg;
+};
+
+#define MAX_TCP_SESSION25
+#define MAX_PENDING_ACKS   256
+
+struct ack_session_info {
+   u32 seq_num;
+   u32 bigger_ack_num;
+   u16 src_port;
+   u16 dst_port;
+   u16 status;
+};
+
+struct pending_acks {
+   u32 ack_num;
+   u32 session_index;
+   struct 

[PATCH v5 03/17] wilc1000: add wlan_if.h

2020-03-11 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/wlan_if.h' to
'drivers/net/wireless/microchip/wilc1000/wlan_if.h'.

Signed-off-by: Ajay Singh 
---
 .../net/wireless/microchip/wilc1000/wlan_if.h | 803 ++
 1 file changed, 803 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/wlan_if.h

diff --git a/drivers/net/wireless/microchip/wilc1000/wlan_if.h 
b/drivers/net/wireless/microchip/wilc1000/wlan_if.h
new file mode 100644
index ..f85fd575136d
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/wlan_if.h
@@ -0,0 +1,803 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#ifndef WILC_WLAN_IF_H
+#define WILC_WLAN_IF_H
+
+#include 
+#include "fw.h"
+
+/
+ *
+ *  Wlan Configuration ID
+ *
+ /
+
+enum bss_types {
+   WILC_FW_BSS_TYPE_INFRA = 0,
+   WILC_FW_BSS_TYPE_INDEPENDENT,
+   WILC_FW_BSS_TYPE_AP,
+};
+
+enum {
+   WILC_FW_OPER_MODE_B_ONLY = 0,/* 1, 2 M, otherwise 5, 11 M */
+   WILC_FW_OPER_MODE_G_ONLY,/* 6,12,24 otherwise 9,18,36,48,54 */
+   WILC_FW_OPER_MODE_G_MIXED_11B_1, /* 1,2,5.5,11 otherwise all on */
+   WILC_FW_OPER_MODE_G_MIXED_11B_2, /* 1,2,5,11,6,12,24 otherwise all on */
+};
+
+enum {
+   WILC_FW_PREAMBLE_SHORT = 0, /* Short Preamble */
+   WILC_FW_PREAMBLE_LONG = 1,  /* Long Preamble */
+   WILC_FW_PREAMBLE_AUTO = 2,  /* Auto Preamble Selection */
+};
+
+enum {
+   WILC_FW_PASSIVE_SCAN = 0,
+   WILC_FW_ACTIVE_SCAN = 1,
+};
+
+enum {
+   WILC_FW_NO_POWERSAVE = 0,
+   WILC_FW_MIN_FAST_PS = 1,
+   WILC_FW_MAX_FAST_PS = 2,
+   WILC_FW_MIN_PSPOLL_PS = 3,
+   WILC_FW_MAX_PSPOLL_PS = 4
+};
+
+enum chip_ps_states {
+   WILC_CHIP_WAKEDUP = 0,
+   WILC_CHIP_SLEEPING_AUTO = 1,
+   WILC_CHIP_SLEEPING_MANUAL = 2
+};
+
+enum bus_acquire {
+   WILC_BUS_ACQUIRE_ONLY = 0,
+   WILC_BUS_ACQUIRE_AND_WAKEUP = 1,
+};
+
+enum bus_release {
+   WILC_BUS_RELEASE_ONLY = 0,
+   WILC_BUS_RELEASE_ALLOW_SLEEP = 1,
+};
+
+enum {
+   WILC_FW_NO_ENCRYPT = 0,
+   WILC_FW_ENCRYPT_ENABLED = BIT(0),
+   WILC_FW_WEP = BIT(1),
+   WILC_FW_WEP_EXTENDED = BIT(2),
+   WILC_FW_WPA = BIT(3),
+   WILC_FW_WPA2 = BIT(4),
+   WILC_FW_AES = BIT(5),
+   WILC_FW_TKIP = BIT(6)
+};
+
+enum {
+   WILC_FW_SEC_NO = WILC_FW_NO_ENCRYPT,
+   WILC_FW_SEC_WEP = WILC_FW_WEP | WILC_FW_ENCRYPT_ENABLED,
+   WILC_FW_SEC_WEP_EXTENDED = WILC_FW_WEP_EXTENDED | WILC_FW_SEC_WEP,
+   WILC_FW_SEC_WPA = WILC_FW_WPA | WILC_FW_ENCRYPT_ENABLED,
+   WILC_FW_SEC_WPA_AES = WILC_FW_AES | WILC_FW_SEC_WPA,
+   WILC_FW_SEC_WPA_TKIP = WILC_FW_TKIP | WILC_FW_SEC_WPA,
+   WILC_FW_SEC_WPA2 = WILC_FW_WPA2 | WILC_FW_ENCRYPT_ENABLED,
+   WILC_FW_SEC_WPA2_AES = WILC_FW_AES | WILC_FW_SEC_WPA2,
+   WILC_FW_SEC_WPA2_TKIP = WILC_FW_TKIP | WILC_FW_SEC_WPA2
+};
+
+enum authtype {
+   WILC_FW_AUTH_OPEN_SYSTEM = 1,
+   WILC_FW_AUTH_SHARED_KEY = 2,
+   WILC_FW_AUTH_ANY = 3,
+   WILC_FW_AUTH_IEEE8021 = 5
+};
+
+enum site_survey {
+   WILC_FW_SITE_SURVEY_1CH = 0,
+   WILC_FW_SITE_SURVEY_ALL_CH = 1,
+   WILC_FW_SITE_SURVEY_OFF = 2
+};
+
+enum {
+   WILC_FW_ACK_POLICY_NORMAL = 0,
+   WILC_FW_ACK_NO_POLICY,
+};
+
+enum {
+   WILC_FW_REKEY_POLICY_DISABLE = 1,
+   WILC_FW_REKEY_POLICY_TIME_BASE,
+   WILC_FW_REKEY_POLICY_PKT_BASE,
+   WILC_FW_REKEY_POLICY_TIME_PKT_BASE
+};
+
+enum {
+   WILC_FW_FILTER_NO = 0x00,
+   WILC_FW_FILTER_AP_ONLY = 0x01,
+   WILC_FW_FILTER_STA_ONLY = 0x02
+};
+
+enum {
+   WILC_FW_11N_PROT_AUTO = 0,  /* Auto */
+   WILC_FW_11N_NO_PROT,/* Do not use any protection */
+   WILC_FW_11N_PROT_ERP,   /* Protect all ERP frame exchanges */
+   WILC_FW_11N_PROT_HT,/* Protect all HT frame exchanges  */
+   WILC_FW_11N_PROT_GF /* Protect all GF frame exchanges  */
+};
+
+enum {
+   WILC_FW_ERP_PROT_SELF_CTS,
+   WILC_FW_ERP_PROT_RTS_CTS,
+};
+
+enum {
+   WILC_FW_11N_OP_MODE_HT_MIXED = 1,
+   WILC_FW_11N_OP_MODE_HT_ONLY_20MHZ,
+   WILC_FW_11N_OP_MODE_HT_ONLY_20_40MHZ,
+};
+
+enum {
+   WILC_FW_OBBS_NONHT_NO_DETECT = 0,
+   WILC_FW_OBBS_NONHT_DETECT_ONLY = 1,
+   WILC_FW_OBBS_NONHT_DETECT_PROTECT = 2,
+   WILC_FW_OBBS_NONHT_DETECT_PROTECT_REPORT = 3,
+};
+
+enum {
+   WILC_FW_HT_PROT_RTS_CTS_NONHT = 0,  /* RTS-CTS at non-HT rate */
+   WILC_FW_HT_PROT_FIRST_FRAME_NONHT,  /* First frame at non-HT rate */
+   WILC_FW_HT_PROT_LSIG_TXOP,  /* LSIG TXOP Protection */
+   WILC_FW_HT_PROT_FIRST_FRAME_MIXED,  /* First frame at Mixed format */
+};
+
+enum {
+   WILC_FW_SMPS_MODE_STATIC = 1,
+   WILC_FW_SMPS_MODE_DYNAMIC = 2,
+   WILC_FW_SMPS_MODE_MIMO = 3,  

[PATCH v5 04/17] wilc1000: add wlan_cfg.h

2020-03-11 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/wlan_cfg.h' to
'drivers/net/wireless/microchip/wilc1000/wlan_cfg.h'.

Signed-off-by: Ajay Singh 
---
 .../wireless/microchip/wilc1000/wlan_cfg.h| 54 +++
 1 file changed, 54 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/wlan_cfg.h

diff --git a/drivers/net/wireless/microchip/wilc1000/wlan_cfg.h 
b/drivers/net/wireless/microchip/wilc1000/wlan_cfg.h
new file mode 100644
index ..614c5673f232
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/wlan_cfg.h
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#ifndef WILC_WLAN_CFG_H
+#define WILC_WLAN_CFG_H
+
+struct wilc_cfg_byte {
+   u16 id;
+   u8 val;
+};
+
+struct wilc_cfg_hword {
+   u16 id;
+   u16 val;
+};
+
+struct wilc_cfg_word {
+   u16 id;
+   u32 val;
+};
+
+struct wilc_cfg_str {
+   u16 id;
+   u8 *str;
+};
+
+struct wilc_cfg_str_vals {
+   u8 mac_address[7];
+   u8 firmware_version[129];
+   u8 assoc_rsp[256];
+};
+
+struct wilc_cfg {
+   struct wilc_cfg_byte *b;
+   struct wilc_cfg_hword *hw;
+   struct wilc_cfg_word *w;
+   struct wilc_cfg_str *s;
+   struct wilc_cfg_str_vals *str_vals;
+};
+
+struct wilc;
+int wilc_wlan_cfg_set_wid(u8 *frame, u32 offset, u16 id, u8 *buf, int size);
+int wilc_wlan_cfg_get_wid(u8 *frame, u32 offset, u16 id);
+int wilc_wlan_cfg_get_val(struct wilc *wl, u16 wid, u8 *buffer,
+ u32 buffer_size);
+void wilc_wlan_cfg_indicate_rx(struct wilc *wilc, u8 *frame, int size,
+  struct wilc_cfg_rsp *rsp);
+int wilc_wlan_cfg_init(struct wilc *wl);
+void wilc_wlan_cfg_deinit(struct wilc *wl);
+
+#endif
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 2/3] staging: wilc1000: modified 'clock-names' and 'compatible' property

2020-03-07 Thread Ajay.Kathat
From: Ajay Singh 

Modified the 'clock-names' property by removing '_clk' from its name and
remove '_spi/sdio' from 'compatible' string.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/sdio.c | 4 ++--
 drivers/staging/wilc1000/spi.c  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/wilc1000/sdio.c b/drivers/staging/wilc1000/sdio.c
index 44b426874c1b..36eb589263bf 100644
--- a/drivers/staging/wilc1000/sdio.c
+++ b/drivers/staging/wilc1000/sdio.c
@@ -150,7 +150,7 @@ static int wilc_sdio_probe(struct sdio_func *func,
wilc->bus_data = sdio_priv;
wilc->dev = >dev;
 
-   wilc->rtc_clk = devm_clk_get(>card->dev, "rtc_clk");
+   wilc->rtc_clk = devm_clk_get(>card->dev, "rtc");
if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER)
return -EPROBE_DEFER;
else if (!IS_ERR(wilc->rtc_clk))
@@ -997,7 +997,7 @@ static int wilc_sdio_resume(struct device *dev)
 }
 
 static const struct of_device_id wilc_of_match[] = {
-   { .compatible = "microchip,wilc1000-sdio", },
+   { .compatible = "microchip,wilc1000", },
{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, wilc_of_match);
diff --git a/drivers/staging/wilc1000/spi.c b/drivers/staging/wilc1000/spi.c
index 852f318a86f0..d77582c55326 100644
--- a/drivers/staging/wilc1000/spi.c
+++ b/drivers/staging/wilc1000/spi.c
@@ -189,7 +189,7 @@ static int wilc_bus_remove(struct spi_device *spi)
 }
 
 static const struct of_device_id wilc_of_match[] = {
-   { .compatible = "microchip,wilc1000-spi", },
+   { .compatible = "microchip,wilc1000", },
{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, wilc_of_match);
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 1/3] staging: wilc1000: use 'interrupts' property instead of 'irq-gpio'

2020-03-07 Thread Ajay.Kathat
From: Ajay Singh 

Make use of 'interrupts' property instead of using gpio for handling
the interrupt as suggested in [1].

[1]. https://lore.kernel.org/linux-wireless/20200303015558.GA6876@bogus

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/netdev.c | 24 
 drivers/staging/wilc1000/netdev.h |  1 -
 drivers/staging/wilc1000/sdio.c   | 31 ---
 drivers/staging/wilc1000/spi.c| 15 +--
 drivers/staging/wilc1000/wlan.h   |  1 -
 5 files changed, 21 insertions(+), 51 deletions(-)

diff --git a/drivers/staging/wilc1000/netdev.c 
b/drivers/staging/wilc1000/netdev.c
index 045f5cdfdca0..a61c1a7aefa8 100644
--- a/drivers/staging/wilc1000/netdev.c
+++ b/drivers/staging/wilc1000/netdev.c
@@ -46,29 +46,21 @@ static irqreturn_t isr_bh_routine(int irq, void *userdata)
 
 static int init_irq(struct net_device *dev)
 {
-   int ret = 0;
struct wilc_vif *vif = netdev_priv(dev);
struct wilc *wl = vif->wilc;
-
-   ret = gpiod_direction_input(wl->gpio_irq);
-   if (ret) {
-   netdev_err(dev, "could not obtain gpio for WILC_INTR\n");
-   return ret;
-   }
-
-   wl->dev_irq_num = gpiod_to_irq(wl->gpio_irq);
+   int ret;
 
ret = request_threaded_irq(wl->dev_irq_num, isr_uh_routine,
   isr_bh_routine,
   IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
   "WILC_IRQ", dev);
-   if (ret < 0)
-   netdev_err(dev, "Failed to request IRQ\n");
-   else
-   netdev_dbg(dev, "IRQ request succeeded IRQ-NUM= %d\n",
-  wl->dev_irq_num);
+   if (ret) {
+   netdev_err(dev, "Failed to request IRQ [%d]\n", ret);
+   return ret;
+   }
+   netdev_dbg(dev, "IRQ request succeeded IRQ-NUM= %d\n", wl->dev_irq_num);
 
-   return ret;
+   return 0;
 }
 
 static void deinit_irq(struct net_device *dev)
@@ -501,7 +493,7 @@ static int wilc_wlan_initialize(struct net_device *dev, 
struct wilc_vif *vif)
if (ret)
goto fail_wilc_wlan;
 
-   if (wl->gpio_irq && init_irq(dev)) {
+   if (wl->dev_irq_num && init_irq(dev)) {
ret = -EIO;
goto fail_threads;
}
diff --git a/drivers/staging/wilc1000/netdev.h 
b/drivers/staging/wilc1000/netdev.h
index e3689e2a4abb..61cbec674a62 100644
--- a/drivers/staging/wilc1000/netdev.h
+++ b/drivers/staging/wilc1000/netdev.h
@@ -209,7 +209,6 @@ struct wilc {
const struct wilc_hif_func *hif_func;
int io_type;
s8 mac_status;
-   struct gpio_desc *gpio_irq;
struct clk *rtc_clk;
bool initialized;
int dev_irq_num;
diff --git a/drivers/staging/wilc1000/sdio.c b/drivers/staging/wilc1000/sdio.c
index 2301e90c21ca..44b426874c1b 100644
--- a/drivers/staging/wilc1000/sdio.c
+++ b/drivers/staging/wilc1000/sdio.c
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "netdev.h"
 #include "cfg80211.h"
@@ -122,33 +123,32 @@ static int wilc_sdio_probe(struct sdio_func *func,
 {
struct wilc *wilc;
int ret;
-   struct gpio_desc *gpio = NULL;
struct wilc_sdio *sdio_priv;
 
sdio_priv = kzalloc(sizeof(*sdio_priv), GFP_KERNEL);
if (!sdio_priv)
return -ENOMEM;
 
-   if (IS_ENABLED(CONFIG_WILC1000_HW_OOB_INTR)) {
-   gpio = gpiod_get(>dev, "irq", GPIOD_IN);
-   if (IS_ERR(gpio)) {
-   /* get the GPIO descriptor from hardcode GPIO number */
-   gpio = gpio_to_desc(GPIO_NUM);
-   if (!gpio)
-   dev_err(>dev, "failed to get irq gpio\n");
-   }
-   }
-
ret = wilc_cfg80211_init(, >dev, WILC_HIF_SDIO,
 _hif_sdio);
if (ret) {
kfree(sdio_priv);
return ret;
}
+
+   if (IS_ENABLED(CONFIG_WILC1000_HW_OOB_INTR)) {
+   struct device_node *np = func->card->dev.of_node;
+   int irq_num = of_irq_get(np, 0);
+
+   if (irq_num > 0) {
+   wilc->dev_irq_num = irq_num;
+   sdio_priv->irq_gpio = true;
+   }
+   }
+
sdio_set_drvdata(func, wilc);
wilc->bus_data = sdio_priv;
wilc->dev = >dev;
-   wilc->gpio_irq = gpio;
 
wilc->rtc_clk = devm_clk_get(>card->dev, "rtc_clk");
if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER)
@@ -164,10 +164,6 @@ static void wilc_sdio_remove(struct sdio_func *func)
 {
struct wilc *wilc = sdio_get_drvdata(func);
 
-   /* free the GPIO in module remove */
-   if (wilc->gpio_irq)
-   gpiod_put(wilc->gpio_irq);
-
if (!IS_ERR(wilc->rtc_clk))

[PATCH v2 3/3] staging: wilc1000: updated DT binding documentation

2020-03-07 Thread Ajay.Kathat
From: Ajay Singh 

Merged the DT binding documentation of SDIO and SPI into a single file.
Removed documentation for some of the properties which are not required
and handled review comments received in [1] & [2].

[1]. https://lore.kernel.org/linux-wireless/20200303020230.GA15543@bogus
[2]. https://lore.kernel.org/linux-wireless/20200303015558.GA6876@bogus

Signed-off-by: Ajay Singh 
---
 .../wilc1000/microchip,wilc1000,sdio.yaml | 68 --
 .../wilc1000/microchip,wilc1000,spi.yaml  | 61 
 .../staging/wilc1000/microchip,wilc1000.yaml  | 72 +++
 3 files changed, 72 insertions(+), 129 deletions(-)
 delete mode 100644 drivers/staging/wilc1000/microchip,wilc1000,sdio.yaml
 delete mode 100644 drivers/staging/wilc1000/microchip,wilc1000,spi.yaml
 create mode 100644 drivers/staging/wilc1000/microchip,wilc1000.yaml

diff --git a/drivers/staging/wilc1000/microchip,wilc1000,sdio.yaml 
b/drivers/staging/wilc1000/microchip,wilc1000,sdio.yaml
deleted file mode 100644
index b338f569f7e2..
--- a/drivers/staging/wilc1000/microchip,wilc1000,sdio.yaml
+++ /dev/null
@@ -1,68 +0,0 @@
-# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
-%YAML 1.2

-$id: http://devicetree.org/schemas/net/wireless/microchip,wilc1000,sdio.yaml#
-$schema: http://devicetree.org/meta-schemas/core.yaml#
-
-title: Microchip WILC wireless SDIO devicetree bindings
-
-maintainers:
-  - Adham Abozaeid 
-  - Ajay Singh 
-
-description:
-  The wilc1000 chips can be connected via SDIO. The node is used to
-  specify child node to the SDIO controller that connects the device
-  to the system.
-
-properties:
-  compatible:
-const: microchip,wilc1000-sdio
-
-  irq-gpios:
-description: The GPIO phandle connect to a host IRQ.
-maxItems: 1
-
-  reg:
-description: Slot ID used in the controller.
-maxItems: 1
-
-  clocks:
-description: phandle to the clock connected on rtc clock line.
-maxItems: 1
-
-  bus-width:
-description: The number of data lines wired up the slot.
-allOf:
-  - $ref: /schemas/types.yaml#/definitions/uint32
-  - enum: [1, 4, 8]
-  - default: 1
-
-required:
-  - compatible
-  - irq-gpios
-  - reg
-
-examples:
-  - |
-mmc1: mmc@fc00 {
-  #address-cells = <1>;
-  #size-cells = <0>;
-  pinctrl-names = "default";
-  pinctrl-0 = <_mmc1_clk_cmd_dat0 _mmc1_dat1_3>;
-  non-removable;
-  vmmc-supply = <_mmc1_reg>;
-  vqmmc-supply = <_3v3_reg>;
-  status = "okay";
-  wilc_sdio@0 {
-compatible = "microchip,wilc1000-sdio";
-  irq-gpios = < 27 0>;
-  reg = <0>;
-  clocks = <>;
-  clock-names = "rtc_clk";
-  assigned-clocks = <>;
-  assigned-clock-rates = <32768>;
-  status = "okay";
-  bus-width = <4>;
-};
-};
diff --git a/drivers/staging/wilc1000/microchip,wilc1000,spi.yaml 
b/drivers/staging/wilc1000/microchip,wilc1000,spi.yaml
deleted file mode 100644
index cc8ed64ce627..
--- a/drivers/staging/wilc1000/microchip,wilc1000,spi.yaml
+++ /dev/null
@@ -1,61 +0,0 @@
-# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
-%YAML 1.2

-$id: http://devicetree.org/schemas/net/wireless/microchip,wilc1000,spi.yaml#
-$schema: http://devicetree.org/meta-schemas/core.yaml#
-
-title: Microchip WILC wireless SPI devicetree bindings
-
-maintainers:
-  - Adham Abozaeid 
-  - Ajay Singh 
-
-description:
-  The wilc1000 chips can be connected via SPI. This document describes
-  the binding for the SPI connected module.
-
-properties:
-  compatible:
-const: microchip,wilc1000-spi
-
-  spi-max-frequency:
-description: Maximum SPI clocking speed of device in Hz.
-maxItems: 1
-
-  reg:
-description: Chip select address of device.
-maxItems: 1
-
-  irq-gpios:
-description: The GPIO phandle connect to a host IRQ.
-maxItems: 1
-
-  clocks:
-description: phandle to the clock connected on rtc clock line.
-maxItems: 1
-
-required:
-  - compatible
-  - spi-max-frequency
-  - reg
-  - irq-gpios
-
-examples:
-  - |
-spi1: spi@fc018000 {
-  #address-cells = <1>;
-  #size-cells = <0>;
-  cs-gpios = < 21 0>;
-  status = "okay";
-  wilc_spi@0 {
-compatible = "microchip,wilc1000-spi";
-spi-max-frequency = <4800>;
-reg = <0>;
-irq-gpios = < 27 0>;
-clocks = <>;
-clock-names = "rtc_clk";
-assigned-clocks = <>;
-assigned-clock-rates = <32768>;
-status = "okay";
-  };
-};
diff --git a/drivers/staging/wilc1000/microchip,wilc1000.yaml 
b/drivers/staging/wilc1000/microchip,wilc1000.yaml
new file mode 100644
index ..bc6cc5d3f347
--- /dev/null
+++ b/drivers/staging/wilc1000/microchip,wilc1000.yaml
@@ -0,0 +1,72 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/wireless/microchip,wilc1000.yaml#
+$schema: 

[PATCH v2 0/3] staging: wilc1000: handle DT binding documentation comments

2020-03-07 Thread Ajay.Kathat
From: Ajay Singh 

This patch series contains changes to handle DT binding documentation
related review comments. The changes were suggested during the full
driver review [1] & [2].
First submitting these patches to staging and later will include them
as part of the full driver review patch series.

Changes since v1:
 - keep the bindings changes separate from code.
 - only add binding to '/driver/staging/wilc1000'.
 - remove redefines for common property.

[1]. https://patchwork.kernel.org/patch/11415897
[2]. https://patchwork.kernel.org/patch/11415901

Ajay Singh (3):
  staging: wilc1000: use 'interrupts' property instead of 'irq-gpio'
  staging: wilc1000: modified 'clock-names' and 'compatible' property
  staging: wilc1000: updated DT binding documentation

 .../wilc1000/microchip,wilc1000,sdio.yaml | 68 --
 .../wilc1000/microchip,wilc1000,spi.yaml  | 61 
 .../staging/wilc1000/microchip,wilc1000.yaml  | 72 +++
 drivers/staging/wilc1000/netdev.c | 24 +++
 drivers/staging/wilc1000/netdev.h |  1 -
 drivers/staging/wilc1000/sdio.c   | 35 -
 drivers/staging/wilc1000/spi.c| 17 +
 drivers/staging/wilc1000/wlan.h   |  1 -
 8 files changed, 96 insertions(+), 183 deletions(-)
 delete mode 100644 drivers/staging/wilc1000/microchip,wilc1000,sdio.yaml
 delete mode 100644 drivers/staging/wilc1000/microchip,wilc1000,spi.yaml
 create mode 100644 drivers/staging/wilc1000/microchip,wilc1000.yaml

-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/2] staging: wilc1000: use 'interrupts' property instead of 'irq-gpio'

2020-03-07 Thread Ajay.Kathat
Hi Rob,

On 06/03/20 9:05 pm, Rob Herring wrote:
> 
> On Fri, Mar 6, 2020 at 8:44 AM  wrote:
>>
>> From: Ajay Singh 
>>
>> Make use of 'interrupts' property instead of using gpio for handling
>> the interrupt as suggested in [1].
>>
>> [1]. https://lore.kernel.org/linux-wireless/20200303015558.GA6876@bogus/
>>
>> Signed-off-by: Ajay Singh 
>> ---
>>  .../net/wireless/microchip,wilc1000.yaml  | 79 +++
>>  .../wilc1000/microchip,wilc1000,sdio.yaml |  8 +-
>>  .../wilc1000/microchip,wilc1000,spi.yaml  |  8 +-
> 
> Bindings should be a separate patch.
> 

Ok. I will add them in separate patch.

>>  drivers/staging/wilc1000/netdev.c | 24 ++
>>  drivers/staging/wilc1000/netdev.h |  1 -
>>  drivers/staging/wilc1000/sdio.c   | 31 +++-
>>  drivers/staging/wilc1000/spi.c| 15 +---
>>  drivers/staging/wilc1000/wlan.h   |  1 -
>>  8 files changed, 108 insertions(+), 59 deletions(-)
>>  create mode 100644 
>> Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml
>>
>> diff --git 
>> a/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml 
>> b/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml
>> new file mode 100644
>> index ..a1914449ad07
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml
>> @@ -0,0 +1,79 @@
>> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
>> +%YAML 1.2
>> +---
>> +$id: http://devicetree.org/schemas/net/wireless/microchip,wilc1000.yaml#
>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>> +
>> +title: Microchip WILC wireless devicetree bindings
>> +
>> +maintainers:
>> +  - Adham Abozaeid 
>> +  - Ajay Singh 
>> +
>> +description:
>> +  The wilc1000 chips can be connected via SPI or SDIO. This document
>> +  describes the binding to connect wilc devices.
>> +
>> +properties:
>> +  compatible:
>> +const: microchip,wilc1000
>> +
>> +  spi-max-frequency:
>> +description: Maximum SPI clocking speed of device in Hz.
>> +maxItems: 1
> 
> No need to redefine a common property. Just:
> 
> spi-max-frequency: true
> 
Ok. I will changes this.

>> +
>> +  reg:
>> +description: Chip select address of device.
> 
> Drop this.
>

Ok.

>> +maxItems: 1
>> +
>> +  interrupts:
>> +maxItems: 1
>> +
>> +  clocks:
>> +description: phandle to the clock connected on rtc clock line.
>> +maxItems: 1
>> +
>> +  clock-names:
>> +const: rtc
>> +
>> +required:
>> +  - compatible
>> +  - reg
>> +  - interrupts
>> +
>> +examples:
>> +  - |
>> +spi1: spi@fc018000 {
>> +  #address-cells = <1>;
>> +  #size-cells = <0>;
>> +  cs-gpios = < 21 0>;
>> +  wifi@0 {
>> +compatible = "microchip,wilc1000";
>> +spi-max-frequency = <4800>;
>> +reg = <0>;
>> +interrupt-parent = <>;
>> +interrupts = <27 0>;
>> +clocks = <>;
>> +clock-names = "rtc";
>> +  };
>> +};
>> +
>> +  - |
>> +mmc1: mmc@fc00 {
>> +  #address-cells = <1>;
>> +  #size-cells = <0>;
>> +  pinctrl-names = "default";
>> +  pinctrl-0 = <_mmc1_clk_cmd_dat0 _mmc1_dat1_3>;
>> +  non-removable;
>> +  vmmc-supply = <_mmc1_reg>;
>> +  vqmmc-supply = <_3v3_reg>;
>> +  bus-width = <4>;
>> +  wifi@0 {
>> +compatible = "microchip,wilc1000";
>> +reg = <0>;
>> +interrupt-parent = <>;
>> +interrupts = <27 0>;
>> +clocks = <>;
>> +clock-names = "rtc";
>> +  };
>> +};
>> diff --git a/drivers/staging/wilc1000/microchip,wilc1000,sdio.yaml 
>> b/drivers/staging/wilc1000/microchip,wilc1000,sdio.yaml
>> index b338f569f7e2..9df7327bc668 100644
>> --- a/drivers/staging/wilc1000/microchip,wilc1000,sdio.yaml
>> +++ b/drivers/staging/wilc1000/microchip,wilc1000,sdio.yaml
> 
> Why aren't you just removing this file and the spi one?


The binding file wrongly got added in this patch. It needs to be added
only to '/driver/staging/wilc1000'. I will update this and send v2
series by keeping binding patch separate from code changes.

Regards,
Ajay
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 0/2] staging: wilc1000: handle DT binding documentation comments

2020-03-06 Thread Ajay.Kathat
From: Ajay Singh 

This patch series contains changes to handle DT binding documentation
related review comments. The changes were suggested during the full
driver review [1] & [2].
First submitting these patches to staging and later will include them
as part of the full driver review patch series.

[1]. https://patchwork.kernel.org/patch/11415897
[2]. https://patchwork.kernel.org/patch/11415901

Ajay Singh (2):
  staging: wilc1000: use 'interrupts' property instead of 'irq-gpio'
  staging: wilc1000: use single DT binding documentation for SDIO and
SPI

 .../net/wireless/microchip,wilc1000.yaml  | 79 +++
 .../wilc1000/microchip,wilc1000,sdio.yaml | 68 
 .../wilc1000/microchip,wilc1000,spi.yaml  | 61 --
 .../staging/wilc1000/microchip,wilc1000.yaml  | 79 +++
 drivers/staging/wilc1000/netdev.c | 24 ++
 drivers/staging/wilc1000/netdev.h |  1 -
 drivers/staging/wilc1000/sdio.c   | 35 
 drivers/staging/wilc1000/spi.c| 17 +---
 drivers/staging/wilc1000/wlan.h   |  1 -
 9 files changed, 182 insertions(+), 183 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml
 delete mode 100644 drivers/staging/wilc1000/microchip,wilc1000,sdio.yaml
 delete mode 100644 drivers/staging/wilc1000/microchip,wilc1000,spi.yaml
 create mode 100644 drivers/staging/wilc1000/microchip,wilc1000.yaml

-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/2] staging: wilc1000: use 'interrupts' property instead of 'irq-gpio'

2020-03-06 Thread Ajay.Kathat
From: Ajay Singh 

Make use of 'interrupts' property instead of using gpio for handling
the interrupt as suggested in [1].

[1]. https://lore.kernel.org/linux-wireless/20200303015558.GA6876@bogus/

Signed-off-by: Ajay Singh 
---
 .../net/wireless/microchip,wilc1000.yaml  | 79 +++
 .../wilc1000/microchip,wilc1000,sdio.yaml |  8 +-
 .../wilc1000/microchip,wilc1000,spi.yaml  |  8 +-
 drivers/staging/wilc1000/netdev.c | 24 ++
 drivers/staging/wilc1000/netdev.h |  1 -
 drivers/staging/wilc1000/sdio.c   | 31 +++-
 drivers/staging/wilc1000/spi.c| 15 +---
 drivers/staging/wilc1000/wlan.h   |  1 -
 8 files changed, 108 insertions(+), 59 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml

diff --git 
a/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml 
b/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml
new file mode 100644
index ..a1914449ad07
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml
@@ -0,0 +1,79 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/wireless/microchip,wilc1000.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Microchip WILC wireless devicetree bindings
+
+maintainers:
+  - Adham Abozaeid 
+  - Ajay Singh 
+
+description:
+  The wilc1000 chips can be connected via SPI or SDIO. This document
+  describes the binding to connect wilc devices.
+
+properties:
+  compatible:
+const: microchip,wilc1000
+
+  spi-max-frequency:
+description: Maximum SPI clocking speed of device in Hz.
+maxItems: 1
+
+  reg:
+description: Chip select address of device.
+maxItems: 1
+
+  interrupts:
+maxItems: 1
+
+  clocks:
+description: phandle to the clock connected on rtc clock line.
+maxItems: 1
+
+  clock-names:
+const: rtc
+
+required:
+  - compatible
+  - reg
+  - interrupts
+
+examples:
+  - |
+spi1: spi@fc018000 {
+  #address-cells = <1>;
+  #size-cells = <0>;
+  cs-gpios = < 21 0>;
+  wifi@0 {
+compatible = "microchip,wilc1000";
+spi-max-frequency = <4800>;
+reg = <0>;
+interrupt-parent = <>;
+interrupts = <27 0>;
+clocks = <>;
+clock-names = "rtc";
+  };
+};
+
+  - |
+mmc1: mmc@fc00 {
+  #address-cells = <1>;
+  #size-cells = <0>;
+  pinctrl-names = "default";
+  pinctrl-0 = <_mmc1_clk_cmd_dat0 _mmc1_dat1_3>;
+  non-removable;
+  vmmc-supply = <_mmc1_reg>;
+  vqmmc-supply = <_3v3_reg>;
+  bus-width = <4>;
+  wifi@0 {
+compatible = "microchip,wilc1000";
+reg = <0>;
+interrupt-parent = <>;
+interrupts = <27 0>;
+clocks = <>;
+clock-names = "rtc";
+  };
+};
diff --git a/drivers/staging/wilc1000/microchip,wilc1000,sdio.yaml 
b/drivers/staging/wilc1000/microchip,wilc1000,sdio.yaml
index b338f569f7e2..9df7327bc668 100644
--- a/drivers/staging/wilc1000/microchip,wilc1000,sdio.yaml
+++ b/drivers/staging/wilc1000/microchip,wilc1000,sdio.yaml
@@ -19,8 +19,7 @@ properties:
   compatible:
 const: microchip,wilc1000-sdio
 
-  irq-gpios:
-description: The GPIO phandle connect to a host IRQ.
+  interrupts:
 maxItems: 1
 
   reg:
@@ -40,7 +39,7 @@ properties:
 
 required:
   - compatible
-  - irq-gpios
+  - interrupts
   - reg
 
 examples:
@@ -56,7 +55,8 @@ examples:
   status = "okay";
   wilc_sdio@0 {
 compatible = "microchip,wilc1000-sdio";
-  irq-gpios = < 27 0>;
+interrupt-parent = <>;
+interrupts = <27 0>;
   reg = <0>;
   clocks = <>;
   clock-names = "rtc_clk";
diff --git a/drivers/staging/wilc1000/microchip,wilc1000,spi.yaml 
b/drivers/staging/wilc1000/microchip,wilc1000,spi.yaml
index cc8ed64ce627..dd5e8da1f562 100644
--- a/drivers/staging/wilc1000/microchip,wilc1000,spi.yaml
+++ b/drivers/staging/wilc1000/microchip,wilc1000,spi.yaml
@@ -26,8 +26,7 @@ properties:
 description: Chip select address of device.
 maxItems: 1
 
-  irq-gpios:
-description: The GPIO phandle connect to a host IRQ.
+  interrupts:
 maxItems: 1
 
   clocks:
@@ -38,7 +37,7 @@ required:
   - compatible
   - spi-max-frequency
   - reg
-  - irq-gpios
+  - interrupts
 
 examples:
   - |
@@ -51,7 +50,8 @@ examples:
 compatible = "microchip,wilc1000-spi";
 spi-max-frequency = <4800>;
 reg = <0>;
-irq-gpios = < 27 0>;
+interrupt-parent = <>;
+interrupts = <27 0>;
 clocks = <>;
 clock-names = "rtc_clk";
 assigned-clocks = <>;
diff --git a/drivers/staging/wilc1000/netdev.c 
b/drivers/staging/wilc1000/netdev.c
index 045f5cdfdca0..a61c1a7aefa8 100644
--- a/drivers/staging/wilc1000/netdev.c
+++ b/drivers/staging/wilc1000/netdev.c
@@ 

[PATCH 2/2] staging: wilc1000: use single DT binding documentation for SDIO and SPI

2020-03-06 Thread Ajay.Kathat
From: Ajay Singh 

Merged the DT binding documentation of SDIO and SPI into a single file.
Removed documentation for some of the properties which are not required
and handled review comments received in [1] & [2].

[1]. https://lore.kernel.org/linux-wireless/20200303020230.GA15543@bogus
[2]. https://lore.kernel.org/linux-wireless/20200303015558.GA6876@bogus

Signed-off-by: Ajay Singh 
---
 .../wilc1000/microchip,wilc1000,sdio.yaml | 68 ---
 ...c1000,spi.yaml => microchip,wilc1000.yaml} | 44 
 drivers/staging/wilc1000/sdio.c   |  4 +-
 drivers/staging/wilc1000/spi.c|  2 +-
 4 files changed, 34 insertions(+), 84 deletions(-)
 delete mode 100644 drivers/staging/wilc1000/microchip,wilc1000,sdio.yaml
 rename drivers/staging/wilc1000/{microchip,wilc1000,spi.yaml => 
microchip,wilc1000.yaml} (53%)

diff --git a/drivers/staging/wilc1000/microchip,wilc1000,sdio.yaml 
b/drivers/staging/wilc1000/microchip,wilc1000,sdio.yaml
deleted file mode 100644
index 9df7327bc668..
--- a/drivers/staging/wilc1000/microchip,wilc1000,sdio.yaml
+++ /dev/null
@@ -1,68 +0,0 @@
-# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
-%YAML 1.2

-$id: http://devicetree.org/schemas/net/wireless/microchip,wilc1000,sdio.yaml#
-$schema: http://devicetree.org/meta-schemas/core.yaml#
-
-title: Microchip WILC wireless SDIO devicetree bindings
-
-maintainers:
-  - Adham Abozaeid 
-  - Ajay Singh 
-
-description:
-  The wilc1000 chips can be connected via SDIO. The node is used to
-  specify child node to the SDIO controller that connects the device
-  to the system.
-
-properties:
-  compatible:
-const: microchip,wilc1000-sdio
-
-  interrupts:
-maxItems: 1
-
-  reg:
-description: Slot ID used in the controller.
-maxItems: 1
-
-  clocks:
-description: phandle to the clock connected on rtc clock line.
-maxItems: 1
-
-  bus-width:
-description: The number of data lines wired up the slot.
-allOf:
-  - $ref: /schemas/types.yaml#/definitions/uint32
-  - enum: [1, 4, 8]
-  - default: 1
-
-required:
-  - compatible
-  - interrupts
-  - reg
-
-examples:
-  - |
-mmc1: mmc@fc00 {
-  #address-cells = <1>;
-  #size-cells = <0>;
-  pinctrl-names = "default";
-  pinctrl-0 = <_mmc1_clk_cmd_dat0 _mmc1_dat1_3>;
-  non-removable;
-  vmmc-supply = <_mmc1_reg>;
-  vqmmc-supply = <_3v3_reg>;
-  status = "okay";
-  wilc_sdio@0 {
-compatible = "microchip,wilc1000-sdio";
-interrupt-parent = <>;
-interrupts = <27 0>;
-  reg = <0>;
-  clocks = <>;
-  clock-names = "rtc_clk";
-  assigned-clocks = <>;
-  assigned-clock-rates = <32768>;
-  status = "okay";
-  bus-width = <4>;
-};
-};
diff --git a/drivers/staging/wilc1000/microchip,wilc1000,spi.yaml 
b/drivers/staging/wilc1000/microchip,wilc1000.yaml
similarity index 53%
rename from drivers/staging/wilc1000/microchip,wilc1000,spi.yaml
rename to drivers/staging/wilc1000/microchip,wilc1000.yaml
index dd5e8da1f562..a1914449ad07 100644
--- a/drivers/staging/wilc1000/microchip,wilc1000,spi.yaml
+++ b/drivers/staging/wilc1000/microchip,wilc1000.yaml
@@ -1,22 +1,22 @@
 # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
 %YAML 1.2
 ---
-$id: http://devicetree.org/schemas/net/wireless/microchip,wilc1000,spi.yaml#
+$id: http://devicetree.org/schemas/net/wireless/microchip,wilc1000.yaml#
 $schema: http://devicetree.org/meta-schemas/core.yaml#
 
-title: Microchip WILC wireless SPI devicetree bindings
+title: Microchip WILC wireless devicetree bindings
 
 maintainers:
   - Adham Abozaeid 
   - Ajay Singh 
 
 description:
-  The wilc1000 chips can be connected via SPI. This document describes
-  the binding for the SPI connected module.
+  The wilc1000 chips can be connected via SPI or SDIO. This document
+  describes the binding to connect wilc devices.
 
 properties:
   compatible:
-const: microchip,wilc1000-spi
+const: microchip,wilc1000
 
   spi-max-frequency:
 description: Maximum SPI clocking speed of device in Hz.
@@ -33,9 +33,11 @@ properties:
 description: phandle to the clock connected on rtc clock line.
 maxItems: 1
 
+  clock-names:
+const: rtc
+
 required:
   - compatible
-  - spi-max-frequency
   - reg
   - interrupts
 
@@ -45,17 +47,33 @@ examples:
   #address-cells = <1>;
   #size-cells = <0>;
   cs-gpios = < 21 0>;
-  status = "okay";
-  wilc_spi@0 {
-compatible = "microchip,wilc1000-spi";
+  wifi@0 {
+compatible = "microchip,wilc1000";
 spi-max-frequency = <4800>;
 reg = <0>;
 interrupt-parent = <>;
 interrupts = <27 0>;
 clocks = <>;
-clock-names = "rtc_clk";
-assigned-clocks = <>;
-assigned-clock-rates = <32768>;
-status = "okay";
+clock-names = "rtc";
+  };
+};
+
+  - |
+mmc1: mmc@fc00 {
+  

Re: [PATCH v4 17/18] dt: bindings: net: add microchip,wilc1000,spi.yaml

2020-03-03 Thread Ajay.Kathat



On 03/03/20 7:32 am, Rob Herring wrote:
> 
> On Mon, Mar 02, 2020 at 04:34:40PM +, ajay.kat...@microchip.com wrote:
>> From: Ajay Singh 
>>
>> Moved '/drivers/staging/wilc1000//microchip,wilc1000,spi.yaml' to
>> 'Documentation/devicetree/bindings/net/wireless/microchip,wilc1000,spi.yaml'.
> 
> Not a useful changelog.
> 

Sure. I will update the changelog.

> I think this should be combined with the SDIO version. Details below.
> 
>>
>> Signed-off-by: Ajay Singh 
>> ---
>>  .../net/wireless/microchip,wilc1000,spi.yaml  | 61 +++
>>  1 file changed, 61 insertions(+)
>>  create mode 100644 
>> Documentation/devicetree/bindings/net/wireless/microchip,wilc1000,spi.yaml
>>
>> diff --git 
>> a/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000,spi.yaml 
>> b/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000,spi.yaml
>> new file mode 100644
>> index ..cc8ed64ce627
>> --- /dev/null
>> +++ 
>> b/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000,spi.yaml
>> @@ -0,0 +1,61 @@
>> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
>> +%YAML 1.2
>> +---
>> +$id: http://devicetree.org/schemas/net/wireless/microchip,wilc1000,spi.yaml#
>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>> +
>> +title: Microchip WILC wireless SPI devicetree bindings
>> +
>> +maintainers:
>> +  - Adham Abozaeid 
>> +  - Ajay Singh 
>> +
>> +description:
>> +  The wilc1000 chips can be connected via SPI. This document describes
>> +  the binding for the SPI connected module.
>> +
>> +properties:
>> +  compatible:
>> +const: microchip,wilc1000-spi
> 
> You can drop '-spi' (and '-sdio'). They don't need to be different
> because they already sit on different buses.
> 

In that case, we should use only a single DT binding documentation and
keep both example inside the same file i.e We will have single
properties descriptions with 2 examples(sdio/spi) in a single DT binding
document. Is my understanding correct?

>> +
>> +  spi-max-frequency:
>> +description: Maximum SPI clocking speed of device in Hz.
>> +maxItems: 1
>> +
>> +  reg:
>> +description: Chip select address of device.
>> +maxItems: 1
>> +
>> +  irq-gpios:
>> +description: The GPIO phandle connect to a host IRQ.
>> +maxItems: 1
>> +
>> +  clocks:
>> +description: phandle to the clock connected on rtc clock line.
>> +maxItems: 1
>> +
>> +required:
>> +  - compatible
>> +  - spi-max-frequency
> 
> This should not be required.
> 

Ok. I will drop this.

>> +  - reg
>> +  - irq-gpios
>> +
>> +examples:
>> +  - |
>> +spi1: spi@fc018000 {
>> +  #address-cells = <1>;
>> +  #size-cells = <0>;
>> +  cs-gpios = < 21 0>;
>> +  status = "okay";
>> +  wilc_spi@0 {
>> +compatible = "microchip,wilc1000-spi";
>> +spi-max-frequency = <4800>;
>> +reg = <0>;
>> +irq-gpios = < 27 0>;
>> +clocks = <>;
>> +clock-names = "rtc_clk";
> 
> Not documented. '_clk' is redundant.
> 

Ok. I will update the clock-names and add the description.

>> +assigned-clocks = <>;
>> +assigned-clock-rates = <32768>;
> 
> Not documented.
> 

Ok. I will add the description.


Regards,
Ajay
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v4 16/18] dt: bindings: net: add microchip,wilc1000,sdio.yaml

2020-03-03 Thread Ajay.Kathat
Hi Rob,

Thanks for reviewing.

On 03/03/20 7:25 am, Rob Herring wrote:
> 
> On Mon, Mar 02, 2020 at 04:34:40PM +, ajay.kat...@microchip.com wrote:
>> From: Ajay Singh 
>>
>> Moved '/drivers/staging/wilc1000/microchip,wilc1000,sdio.yaml' to
>> 'Documentation/devicetree/bindings/net/wireless/microchip,wilc1000,sdio.yaml'.
>>
>> Signed-off-by: Ajay Singh 
>> ---
>>  .../net/wireless/microchip,wilc1000,sdio.yaml | 68 +++
>>  1 file changed, 68 insertions(+)
>>  create mode 100644 
>> Documentation/devicetree/bindings/net/wireless/microchip,wilc1000,sdio.yaml
>>
>> diff --git 
>> a/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000,sdio.yaml
>>  
>> b/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000,sdio.yaml
>> new file mode 100644
>> index ..b338f569f7e2
>> --- /dev/null
>> +++ 
>> b/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000,sdio.yaml
>> @@ -0,0 +1,68 @@
>> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
>> +%YAML 1.2
>> +---
>> +$id: 
>> http://devicetree.org/schemas/net/wireless/microchip,wilc1000,sdio.yaml#
>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>> +
>> +title: Microchip WILC wireless SDIO devicetree bindings
>> +
>> +maintainers:
>> +  - Adham Abozaeid 
>> +  - Ajay Singh 
>> +
>> +description:
>> +  The wilc1000 chips can be connected via SDIO. The node is used to
>> +  specify child node to the SDIO controller that connects the device
>> +  to the system.
>> +
>> +properties:
>> +  compatible:
>> +const: microchip,wilc1000-sdio
>> +
>> +  irq-gpios:
> 
> Unless you need GPIO control of the line, use 'interrupts' instead.

I will check this.

> 
>> +description: The GPIO phandle connect to a host IRQ.
>> +maxItems: 1
>> +
>> +  reg:
>> +description: Slot ID used in the controller.
> 
> No, it's the function number. But you can just drop this.
> 

Ok. I will drop this description.

>> +maxItems: 1
>> +
>> +  clocks:
>> +description: phandle to the clock connected on rtc clock line.
>> +maxItems: 1
>> +
>> +  bus-width:
> 
> I believe this is defined to go in the parent node.
> 

In that case, I think we can drop this description here by moving it to
parent node. right?

>> +description: The number of data lines wired up the slot.
>> +allOf:
>> +  - $ref: /schemas/types.yaml#/definitions/uint32
>> +  - enum: [1, 4, 8]
>> +  - default: 1
>> +
>> +required:
>> +  - compatible
>> +  - irq-gpios
>> +  - reg
>> +
>> +examples:
>> +  - |
>> +mmc1: mmc@fc00 {
>> +  #address-cells = <1>;
>> +  #size-cells = <0>;
>> +  pinctrl-names = "default";
>> +  pinctrl-0 = <_mmc1_clk_cmd_dat0 _mmc1_dat1_3>;
>> +  non-removable;
>> +  vmmc-supply = <_mmc1_reg>;
>> +  vqmmc-supply = <_3v3_reg>;
>> +  status = "okay";
> 
> Don't show 'status' in examples.
> 

OK. I will remove this.

>> +  wilc_sdio@0 {
> 
> wifi@0
> 
>> +compatible = "microchip,wilc1000-sdio";
>> +  irq-gpios = < 27 0>;
>> +  reg = <0>;
>> +  clocks = <>;
>> +  clock-names = "rtc_clk";
>> +  assigned-clocks = <>;
>> +  assigned-clock-rates = <32768>;
>> +  status = "okay";

I will remove 'status' here also.

>> +  bus-width = <4>;

I will move this property to parent node.

>> +};
>> +};
>> --
>> 2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3 00/18] wilc1000: move out of staging

2020-03-02 Thread Ajay.Kathat
Hi Dan,


On 02/03/20 2:53 pm, Dan Carpenter wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the 
> content is safe
> 
> There are a few static checker warnings from Friday's linux-next.  Only
> the first one is important.  (Not all these Smatch warnings have been
> published).

Thanks. I have submitted a patch series to address Smatch static checker
warnings in staging ml. I will send v4 for this series by including
those changes.

Regards
Ajay
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 11/18] wilc1000: add spi.c

2020-03-02 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/spi.c' to
'drivers/net/wireless/microchip/wilc1000/spi.c'.

Signed-off-by: Ajay Singh 
---
 drivers/net/wireless/microchip/wilc1000/spi.c | 1001 +
 1 file changed, 1001 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/spi.c

diff --git a/drivers/net/wireless/microchip/wilc1000/spi.c 
b/drivers/net/wireless/microchip/wilc1000/spi.c
new file mode 100644
index ..dfd25df75780
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/spi.c
@@ -0,0 +1,1001 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#include 
+#include 
+
+#include "netdev.h"
+#include "cfg80211.h"
+
+struct wilc_spi {
+   int crc_off;
+};
+
+static const struct wilc_hif_func wilc_hif_spi;
+
+/
+ *
+ *  Crc7
+ *
+ /
+
+static const u8 crc7_syndrome_table[256] = {
+   0x00, 0x09, 0x12, 0x1b, 0x24, 0x2d, 0x36, 0x3f,
+   0x48, 0x41, 0x5a, 0x53, 0x6c, 0x65, 0x7e, 0x77,
+   0x19, 0x10, 0x0b, 0x02, 0x3d, 0x34, 0x2f, 0x26,
+   0x51, 0x58, 0x43, 0x4a, 0x75, 0x7c, 0x67, 0x6e,
+   0x32, 0x3b, 0x20, 0x29, 0x16, 0x1f, 0x04, 0x0d,
+   0x7a, 0x73, 0x68, 0x61, 0x5e, 0x57, 0x4c, 0x45,
+   0x2b, 0x22, 0x39, 0x30, 0x0f, 0x06, 0x1d, 0x14,
+   0x63, 0x6a, 0x71, 0x78, 0x47, 0x4e, 0x55, 0x5c,
+   0x64, 0x6d, 0x76, 0x7f, 0x40, 0x49, 0x52, 0x5b,
+   0x2c, 0x25, 0x3e, 0x37, 0x08, 0x01, 0x1a, 0x13,
+   0x7d, 0x74, 0x6f, 0x66, 0x59, 0x50, 0x4b, 0x42,
+   0x35, 0x3c, 0x27, 0x2e, 0x11, 0x18, 0x03, 0x0a,
+   0x56, 0x5f, 0x44, 0x4d, 0x72, 0x7b, 0x60, 0x69,
+   0x1e, 0x17, 0x0c, 0x05, 0x3a, 0x33, 0x28, 0x21,
+   0x4f, 0x46, 0x5d, 0x54, 0x6b, 0x62, 0x79, 0x70,
+   0x07, 0x0e, 0x15, 0x1c, 0x23, 0x2a, 0x31, 0x38,
+   0x41, 0x48, 0x53, 0x5a, 0x65, 0x6c, 0x77, 0x7e,
+   0x09, 0x00, 0x1b, 0x12, 0x2d, 0x24, 0x3f, 0x36,
+   0x58, 0x51, 0x4a, 0x43, 0x7c, 0x75, 0x6e, 0x67,
+   0x10, 0x19, 0x02, 0x0b, 0x34, 0x3d, 0x26, 0x2f,
+   0x73, 0x7a, 0x61, 0x68, 0x57, 0x5e, 0x45, 0x4c,
+   0x3b, 0x32, 0x29, 0x20, 0x1f, 0x16, 0x0d, 0x04,
+   0x6a, 0x63, 0x78, 0x71, 0x4e, 0x47, 0x5c, 0x55,
+   0x22, 0x2b, 0x30, 0x39, 0x06, 0x0f, 0x14, 0x1d,
+   0x25, 0x2c, 0x37, 0x3e, 0x01, 0x08, 0x13, 0x1a,
+   0x6d, 0x64, 0x7f, 0x76, 0x49, 0x40, 0x5b, 0x52,
+   0x3c, 0x35, 0x2e, 0x27, 0x18, 0x11, 0x0a, 0x03,
+   0x74, 0x7d, 0x66, 0x6f, 0x50, 0x59, 0x42, 0x4b,
+   0x17, 0x1e, 0x05, 0x0c, 0x33, 0x3a, 0x21, 0x28,
+   0x5f, 0x56, 0x4d, 0x44, 0x7b, 0x72, 0x69, 0x60,
+   0x0e, 0x07, 0x1c, 0x15, 0x2a, 0x23, 0x38, 0x31,
+   0x46, 0x4f, 0x54, 0x5d, 0x62, 0x6b, 0x70, 0x79
+};
+
+static u8 crc7_byte(u8 crc, u8 data)
+{
+   return crc7_syndrome_table[(crc << 1) ^ data];
+}
+
+static u8 crc7(u8 crc, const u8 *buffer, u32 len)
+{
+   while (len--)
+   crc = crc7_byte(crc, *buffer++);
+   return crc;
+}
+
+static u8 wilc_get_crc7(u8 *buffer, u32 len)
+{
+   return crc7(0x7f, (const u8 *)buffer, len) << 1;
+}
+
+/
+ *
+ *  Spi protocol Function
+ *
+ /
+
+#define CMD_DMA_WRITE  0xc1
+#define CMD_DMA_READ   0xc2
+#define CMD_INTERNAL_WRITE 0xc3
+#define CMD_INTERNAL_READ  0xc4
+#define CMD_TERMINATE  0xc5
+#define CMD_REPEAT 0xc6
+#define CMD_DMA_EXT_WRITE  0xc7
+#define CMD_DMA_EXT_READ   0xc8
+#define CMD_SINGLE_WRITE   0xc9
+#define CMD_SINGLE_READ0xca
+#define CMD_RESET  0xcf
+
+#define DATA_PKT_SZ_256256
+#define DATA_PKT_SZ_512512
+#define DATA_PKT_SZ_1K 1024
+#define DATA_PKT_SZ_4K (4 * 1024)
+#define DATA_PKT_SZ_8K (8 * 1024)
+#define DATA_PKT_SZDATA_PKT_SZ_8K
+
+#define USE_SPI_DMA0
+
+#define WILC_SPI_COMMAND_STAT_SUCCESS  0
+#define WILC_GET_RESP_HDR_START(h) (((h) >> 4) & 0xf)
+
+struct wilc_spi_cmd {
+   u8 cmd_type;
+   union {
+   struct {
+   u8 addr[3];
+   u8 crc[];
+   } __packed simple_cmd;
+   struct {
+   u8 addr[3];
+   u8 size[2];
+   u8 crc[];
+   } __packed dma_cmd;
+   struct {
+   u8 addr[3];
+   u8 size[3];
+   u8 crc[];
+   } __packed dma_cmd_ext;
+   

[PATCH v4 06/18] wilc1000: add cfg80211.c

2020-03-02 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/cfg80211.c' to
'drivers/net/wireless/microchip/wilc1000/cfg80211.c'.

Signed-off-by: Ajay Singh 
---
 .../wireless/microchip/wilc1000/cfg80211.c| 1850 +
 1 file changed, 1850 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/cfg80211.c

diff --git a/drivers/net/wireless/microchip/wilc1000/cfg80211.c 
b/drivers/net/wireless/microchip/wilc1000/cfg80211.c
new file mode 100644
index ..54e02807cebf
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/cfg80211.c
@@ -0,0 +1,1850 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#include "cfg80211.h"
+
+#define GO_NEG_REQ 0x00
+#define GO_NEG_RSP 0x01
+#define GO_NEG_CONF0x02
+#define P2P_INV_REQ0x03
+#define P2P_INV_RSP0x04
+
+#define WILC_INVALID_CHANNEL   0
+
+/* Operation at 2.4 GHz with channels 1-13 */
+#define WILC_WLAN_OPERATING_CLASS_2_4GHZ   0x51
+
+static const struct ieee80211_txrx_stypes
+   wilc_wfi_cfg80211_mgmt_types[NUM_NL80211_IFTYPES] = {
+   [NL80211_IFTYPE_STATION] = {
+   .tx = 0x,
+   .rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
+   BIT(IEEE80211_STYPE_PROBE_REQ >> 4)
+   },
+   [NL80211_IFTYPE_AP] = {
+   .tx = 0x,
+   .rx = BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) |
+   BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) |
+   BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
+   BIT(IEEE80211_STYPE_DISASSOC >> 4) |
+   BIT(IEEE80211_STYPE_AUTH >> 4) |
+   BIT(IEEE80211_STYPE_DEAUTH >> 4) |
+   BIT(IEEE80211_STYPE_ACTION >> 4)
+   },
+   [NL80211_IFTYPE_P2P_CLIENT] = {
+   .tx = 0x,
+   .rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
+   BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
+   BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) |
+   BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) |
+   BIT(IEEE80211_STYPE_DISASSOC >> 4) |
+   BIT(IEEE80211_STYPE_AUTH >> 4) |
+   BIT(IEEE80211_STYPE_DEAUTH >> 4)
+   }
+};
+
+static const struct wiphy_wowlan_support wowlan_support = {
+   .flags = WIPHY_WOWLAN_ANY
+};
+
+struct wilc_p2p_mgmt_data {
+   int size;
+   u8 *buff;
+};
+
+struct wilc_p2p_pub_act_frame {
+   u8 category;
+   u8 action;
+   u8 oui[3];
+   u8 oui_type;
+   u8 oui_subtype;
+   u8 dialog_token;
+   u8 elem[];
+} __packed;
+
+struct wilc_vendor_specific_ie {
+   u8 tag_number;
+   u8 tag_len;
+   u8 oui[3];
+   u8 oui_type;
+   u8 attr[];
+} __packed;
+
+struct wilc_attr_entry {
+   u8  attr_type;
+   __le16 attr_len;
+   u8 val[];
+} __packed;
+
+struct wilc_attr_oper_ch {
+   u8 attr_type;
+   __le16 attr_len;
+   u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
+   u8 op_class;
+   u8 op_channel;
+} __packed;
+
+struct wilc_attr_ch_list {
+   u8 attr_type;
+   __le16 attr_len;
+   u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
+   u8 elem[];
+} __packed;
+
+struct wilc_ch_list_elem {
+   u8 op_class;
+   u8 no_of_channels;
+   u8 ch_list[];
+} __packed;
+
+static void cfg_scan_result(enum scan_event scan_event,
+   struct wilc_rcvd_net_info *info, void *user_void)
+{
+   struct wilc_priv *priv = user_void;
+
+   if (!priv->cfg_scanning)
+   return;
+
+   if (scan_event == SCAN_EVENT_NETWORK_FOUND) {
+   s32 freq;
+   struct ieee80211_channel *channel;
+   struct cfg80211_bss *bss;
+   struct wiphy *wiphy = priv->dev->ieee80211_ptr->wiphy;
+
+   if (!wiphy || !info)
+   return;
+
+   freq = ieee80211_channel_to_frequency((s32)info->ch,
+ NL80211_BAND_2GHZ);
+   channel = ieee80211_get_channel(wiphy, freq);
+   if (!channel)
+   return;
+
+   bss = cfg80211_inform_bss_frame(wiphy, channel, info->mgmt,
+   info->frame_len,
+   (s32)info->rssi * 100,
+   GFP_KERNEL);
+   if (!bss)
+   cfg80211_put_bss(wiphy, bss);
+   } else if (scan_event == SCAN_EVENT_DONE) {
+   mutex_lock(>scan_req_lock);
+
+   if (priv->scan_req) {
+   struct cfg80211_scan_info info = {
+   .aborted = false,
+   };
+

[PATCH v4 18/18] wilc1000: add Makefile and Kconfig files for wilc1000 compilation

2020-03-02 Thread Ajay.Kathat
From: Ajay Singh 

Added Makefile and Kconfig files for compiling wilc1000 module from
'drivers/net/wireless/microchip/'.

Signed-off-by: Ajay Singh 
---
 drivers/net/wireless/Kconfig  |  1 +
 drivers/net/wireless/Makefile |  1 +
 drivers/net/wireless/microchip/Kconfig| 15 +++
 drivers/net/wireless/microchip/Makefile   |  2 +
 .../net/wireless/microchip/wilc1000/Kconfig   | 42 +++
 .../net/wireless/microchip/wilc1000/Makefile  | 14 +++
 drivers/staging/Kconfig   |  2 -
 drivers/staging/Makefile  |  1 -
 8 files changed, 75 insertions(+), 3 deletions(-)
 create mode 100644 drivers/net/wireless/microchip/Kconfig
 create mode 100644 drivers/net/wireless/microchip/Makefile
 create mode 100644 drivers/net/wireless/microchip/wilc1000/Kconfig
 create mode 100644 drivers/net/wireless/microchip/wilc1000/Makefile

diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig
index 1c98d781ae49..86faf8f3d9b0 100644
--- a/drivers/net/wireless/Kconfig
+++ b/drivers/net/wireless/Kconfig
@@ -47,6 +47,7 @@ source "drivers/net/wireless/st/Kconfig"
 source "drivers/net/wireless/ti/Kconfig"
 source "drivers/net/wireless/zydas/Kconfig"
 source "drivers/net/wireless/quantenna/Kconfig"
+source "drivers/net/wireless/microchip/Kconfig"
 
 config PCMCIA_RAYCS
tristate "Aviator/Raytheon 2.4GHz wireless support"
diff --git a/drivers/net/wireless/Makefile b/drivers/net/wireless/Makefile
index 6cfe74515c95..f9a51c2889ca 100644
--- a/drivers/net/wireless/Makefile
+++ b/drivers/net/wireless/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_WLAN_VENDOR_ST) += st/
 obj-$(CONFIG_WLAN_VENDOR_TI) += ti/
 obj-$(CONFIG_WLAN_VENDOR_ZYDAS) += zydas/
 obj-$(CONFIG_WLAN_VENDOR_QUANTENNA) += quantenna/
+obj-$(CONFIG_WLAN_VENDOR_MICROCHIP) += microchip/
 
 # 16-bit wireless PCMCIA client drivers
 obj-$(CONFIG_PCMCIA_RAYCS) += ray_cs.o
diff --git a/drivers/net/wireless/microchip/Kconfig 
b/drivers/net/wireless/microchip/Kconfig
new file mode 100644
index ..a6b46fb6b1ec
--- /dev/null
+++ b/drivers/net/wireless/microchip/Kconfig
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: GPL-2.0
+config WLAN_VENDOR_MICROCHIP
+   bool "Microchip devices"
+   default y
+   help
+   If you have a wireless card belonging to this class, say Y.
+
+   Note that the answer to this question doesn't directly affect the
+   kernel: saying N will just cause the configurator to skip all the
+   questions about these cards. If you say Y, you will be asked for
+   your specific card in the following questions.
+
+if WLAN_VENDOR_MICROCHIP
+source "drivers/net/wireless/microchip/wilc1000/Kconfig"
+endif # WLAN_VENDOR_MICROCHIP
diff --git a/drivers/net/wireless/microchip/Makefile 
b/drivers/net/wireless/microchip/Makefile
new file mode 100644
index ..73b763c7393e
--- /dev/null
+++ b/drivers/net/wireless/microchip/Makefile
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-$(CONFIG_WILC1000) += wilc1000/
diff --git a/drivers/net/wireless/microchip/wilc1000/Kconfig 
b/drivers/net/wireless/microchip/wilc1000/Kconfig
new file mode 100644
index ..59e58550d139
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/Kconfig
@@ -0,0 +1,42 @@
+# SPDX-License-Identifier: GPL-2.0
+config WILC1000
+   tristate
+   help
+ This module only support IEEE 802.11n WiFi.
+
+config WILC1000_SDIO
+   tristate "Atmel WILC1000 SDIO (WiFi only)"
+   depends on CFG80211 && INET && MMC
+   select WILC1000
+   help
+ This module adds support for the SDIO interface of adapters using
+ WILC1000 chipset. The Atmel WILC1000 SDIO is a full speed interface.
+ It meets SDIO card specification version 2.0. The interface supports
+ the 1-bit/4-bit SD transfer mode at the clock range of 0-50 MHz.
+ The host can use this interface to read and write from any register
+ within the chip as well as configure the WILC1000 for data DMA.
+ To use this interface, pin9 (SDIO_SPI_CFG) must be grounded. Select
+ this if your platform is using the SDIO bus.
+
+config WILC1000_SPI
+   tristate "Atmel WILC1000 SPI (WiFi only)"
+   depends on CFG80211 && INET && SPI
+   select WILC1000
+   help
+ This module adds support for the SPI interface of adapters using
+ WILC1000 chipset. The Atmel WILC1000 has a Serial Peripheral
+ Interface (SPI) that operates as a SPI slave. This SPI interface can
+ be used for control and for serial I/O of 802.11 data. The SPI is a
+ full-duplex slave synchronous serial interface that is available
+ immediately following reset when pin 9 (SDIO_SPI_CFG) is tied to
+ VDDIO. Select this if your platform is using the SPI bus.
+
+config WILC1000_HW_OOB_INTR
+   bool "WILC1000 out of band interrupt"
+   depends on WILC1000_SDIO
+   

[PATCH v4 17/18] dt: bindings: net: add microchip,wilc1000,spi.yaml

2020-03-02 Thread Ajay.Kathat
From: Ajay Singh 

Moved '/drivers/staging/wilc1000//microchip,wilc1000,spi.yaml' to
'Documentation/devicetree/bindings/net/wireless/microchip,wilc1000,spi.yaml'.

Signed-off-by: Ajay Singh 
---
 .../net/wireless/microchip,wilc1000,spi.yaml  | 61 +++
 1 file changed, 61 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/net/wireless/microchip,wilc1000,spi.yaml

diff --git 
a/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000,spi.yaml 
b/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000,spi.yaml
new file mode 100644
index ..cc8ed64ce627
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000,spi.yaml
@@ -0,0 +1,61 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/wireless/microchip,wilc1000,spi.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Microchip WILC wireless SPI devicetree bindings
+
+maintainers:
+  - Adham Abozaeid 
+  - Ajay Singh 
+
+description:
+  The wilc1000 chips can be connected via SPI. This document describes
+  the binding for the SPI connected module.
+
+properties:
+  compatible:
+const: microchip,wilc1000-spi
+
+  spi-max-frequency:
+description: Maximum SPI clocking speed of device in Hz.
+maxItems: 1
+
+  reg:
+description: Chip select address of device.
+maxItems: 1
+
+  irq-gpios:
+description: The GPIO phandle connect to a host IRQ.
+maxItems: 1
+
+  clocks:
+description: phandle to the clock connected on rtc clock line.
+maxItems: 1
+
+required:
+  - compatible
+  - spi-max-frequency
+  - reg
+  - irq-gpios
+
+examples:
+  - |
+spi1: spi@fc018000 {
+  #address-cells = <1>;
+  #size-cells = <0>;
+  cs-gpios = < 21 0>;
+  status = "okay";
+  wilc_spi@0 {
+compatible = "microchip,wilc1000-spi";
+spi-max-frequency = <4800>;
+reg = <0>;
+irq-gpios = < 27 0>;
+clocks = <>;
+clock-names = "rtc_clk";
+assigned-clocks = <>;
+assigned-clock-rates = <32768>;
+status = "okay";
+  };
+};
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 13/18] wilc1000: add wlan.c

2020-03-02 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/wlan.c' to
'drivers/net/wireless/microchip/wilc1000/wlan.c'.

Signed-off-by: Ajay Singh 
---
 .../net/wireless/microchip/wilc1000/wlan.c| 1238 +
 1 file changed, 1238 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/wlan.c

diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c 
b/drivers/net/wireless/microchip/wilc1000/wlan.c
new file mode 100644
index ..6a82fb2f283e
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/wlan.c
@@ -0,0 +1,1238 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#include 
+#include 
+#include "cfg80211.h"
+#include "wlan_cfg.h"
+
+static inline bool is_wilc1000(u32 id)
+{
+   return (id & (~WILC_CHIP_REV_FIELD)) == WILC_1000_BASE_ID;
+}
+
+static inline void acquire_bus(struct wilc *wilc, enum bus_acquire acquire)
+{
+   mutex_lock(>hif_cs);
+   if (acquire == WILC_BUS_ACQUIRE_AND_WAKEUP)
+   chip_wakeup(wilc);
+}
+
+static inline void release_bus(struct wilc *wilc, enum bus_release release)
+{
+   if (release == WILC_BUS_RELEASE_ALLOW_SLEEP)
+   chip_allow_sleep(wilc);
+   mutex_unlock(>hif_cs);
+}
+
+static void wilc_wlan_txq_remove(struct wilc *wilc, struct txq_entry_t *tqe)
+{
+   list_del(>list);
+   wilc->txq_entries -= 1;
+}
+
+static struct txq_entry_t *
+wilc_wlan_txq_remove_from_head(struct net_device *dev)
+{
+   struct txq_entry_t *tqe = NULL;
+   unsigned long flags;
+   struct wilc_vif *vif = netdev_priv(dev);
+   struct wilc *wilc = vif->wilc;
+
+   spin_lock_irqsave(>txq_spinlock, flags);
+
+   if (!list_empty(>txq_head.list)) {
+   tqe = list_first_entry(>txq_head.list, struct txq_entry_t,
+  list);
+   list_del(>list);
+   wilc->txq_entries -= 1;
+   }
+   spin_unlock_irqrestore(>txq_spinlock, flags);
+   return tqe;
+}
+
+static void wilc_wlan_txq_add_to_tail(struct net_device *dev,
+ struct txq_entry_t *tqe)
+{
+   unsigned long flags;
+   struct wilc_vif *vif = netdev_priv(dev);
+   struct wilc *wilc = vif->wilc;
+
+   spin_lock_irqsave(>txq_spinlock, flags);
+
+   list_add_tail(>list, >txq_head.list);
+   wilc->txq_entries += 1;
+
+   spin_unlock_irqrestore(>txq_spinlock, flags);
+
+   complete(>txq_event);
+}
+
+static void wilc_wlan_txq_add_to_head(struct wilc_vif *vif,
+ struct txq_entry_t *tqe)
+{
+   unsigned long flags;
+   struct wilc *wilc = vif->wilc;
+
+   mutex_lock(>txq_add_to_head_cs);
+
+   spin_lock_irqsave(>txq_spinlock, flags);
+
+   list_add(>list, >txq_head.list);
+   wilc->txq_entries += 1;
+
+   spin_unlock_irqrestore(>txq_spinlock, flags);
+   mutex_unlock(>txq_add_to_head_cs);
+   complete(>txq_event);
+}
+
+#define NOT_TCP_ACK(-1)
+
+static inline void add_tcp_session(struct wilc_vif *vif, u32 src_prt,
+  u32 dst_prt, u32 seq)
+{
+   struct tcp_ack_filter *f = >ack_filter;
+
+   if (f->tcp_session < 2 * MAX_TCP_SESSION) {
+   f->ack_session_info[f->tcp_session].seq_num = seq;
+   f->ack_session_info[f->tcp_session].bigger_ack_num = 0;
+   f->ack_session_info[f->tcp_session].src_port = src_prt;
+   f->ack_session_info[f->tcp_session].dst_port = dst_prt;
+   f->tcp_session++;
+   }
+}
+
+static inline void update_tcp_session(struct wilc_vif *vif, u32 index, u32 ack)
+{
+   struct tcp_ack_filter *f = >ack_filter;
+
+   if (index < 2 * MAX_TCP_SESSION &&
+   ack > f->ack_session_info[index].bigger_ack_num)
+   f->ack_session_info[index].bigger_ack_num = ack;
+}
+
+static inline void add_tcp_pending_ack(struct wilc_vif *vif, u32 ack,
+  u32 session_index,
+  struct txq_entry_t *txqe)
+{
+   struct tcp_ack_filter *f = >ack_filter;
+   u32 i = f->pending_base + f->pending_acks_idx;
+
+   if (i < MAX_PENDING_ACKS) {
+   f->pending_acks[i].ack_num = ack;
+   f->pending_acks[i].txqe = txqe;
+   f->pending_acks[i].session_index = session_index;
+   txqe->ack_idx = i;
+   f->pending_acks_idx++;
+   }
+}
+
+static inline void tcp_process(struct net_device *dev, struct txq_entry_t *tqe)
+{
+   void *buffer = tqe->buffer;
+   const struct ethhdr *eth_hdr_ptr = buffer;
+   int i;
+   unsigned long flags;
+   struct wilc_vif *vif = netdev_priv(dev);
+   struct wilc *wilc = vif->wilc;
+   struct tcp_ack_filter *f = >ack_filter;
+   const struct iphdr *ip_hdr_ptr;
+   const struct tcphdr *tcp_hdr_ptr;
+  

[PATCH v4 08/18] wilc1000: add netdev.h

2020-03-02 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/netdev.h' to
'drivers/net/wireless/microchip/wilc1000/netdev.h'.

Signed-off-by: Ajay Singh 
---
 .../net/wireless/microchip/wilc1000/netdev.h  | 295 ++
 1 file changed, 295 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/netdev.h

diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.h 
b/drivers/net/wireless/microchip/wilc1000/netdev.h
new file mode 100644
index ..e3689e2a4abb
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/netdev.h
@@ -0,0 +1,295 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#ifndef WILC_NETDEV_H
+#define WILC_NETDEV_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "hif.h"
+#include "wlan.h"
+#include "wlan_cfg.h"
+
+#define FLOW_CONTROL_LOWER_THRESHOLD   128
+#define FLOW_CONTROL_UPPER_THRESHOLD   256
+
+#define PMKID_FOUND1
+#define NUM_STA_ASSOCIATED 8
+
+#define NUM_REG_FRAME  2
+
+#define TCP_ACK_FILTER_LINK_SPEED_THRESH   54
+#define DEFAULT_LINK_SPEED 72
+
+struct wilc_wfi_stats {
+   unsigned long rx_packets;
+   unsigned long tx_packets;
+   unsigned long rx_bytes;
+   unsigned long tx_bytes;
+   u64 rx_time;
+   u64 tx_time;
+
+};
+
+struct wilc_wfi_key {
+   u8 *key;
+   u8 *seq;
+   int key_len;
+   int seq_len;
+   u32 cipher;
+};
+
+struct wilc_wfi_wep_key {
+   u8 *key;
+   u8 key_len;
+   u8 key_idx;
+};
+
+struct sta_info {
+   u8 sta_associated_bss[WILC_MAX_NUM_STA][ETH_ALEN];
+};
+
+/* Parameters needed for host interface for remaining on channel */
+struct wilc_wfi_p2p_listen_params {
+   struct ieee80211_channel *listen_ch;
+   u32 listen_duration;
+   u64 listen_cookie;
+};
+
+static const u32 wilc_cipher_suites[] = {
+   WLAN_CIPHER_SUITE_WEP40,
+   WLAN_CIPHER_SUITE_WEP104,
+   WLAN_CIPHER_SUITE_TKIP,
+   WLAN_CIPHER_SUITE_CCMP,
+   WLAN_CIPHER_SUITE_AES_CMAC
+};
+
+#define CHAN2G(_channel, _freq, _flags) {   \
+   .band = NL80211_BAND_2GHZ, \
+   .center_freq  = (_freq), \
+   .hw_value = (_channel),  \
+   .flags= (_flags),\
+   .max_antenna_gain = 0,   \
+   .max_power= 30,  \
+}
+
+static const struct ieee80211_channel wilc_2ghz_channels[] = {
+   CHAN2G(1,  2412, 0),
+   CHAN2G(2,  2417, 0),
+   CHAN2G(3,  2422, 0),
+   CHAN2G(4,  2427, 0),
+   CHAN2G(5,  2432, 0),
+   CHAN2G(6,  2437, 0),
+   CHAN2G(7,  2442, 0),
+   CHAN2G(8,  2447, 0),
+   CHAN2G(9,  2452, 0),
+   CHAN2G(10, 2457, 0),
+   CHAN2G(11, 2462, 0),
+   CHAN2G(12, 2467, 0),
+   CHAN2G(13, 2472, 0),
+   CHAN2G(14, 2484, 0)
+};
+
+#define RATETAB_ENT(_rate, _hw_value, _flags) {\
+   .bitrate  = (_rate),\
+   .hw_value = (_hw_value),\
+   .flags= (_flags),   \
+}
+
+static struct ieee80211_rate wilc_bitrates[] = {
+   RATETAB_ENT(10,  0,  0),
+   RATETAB_ENT(20,  1,  0),
+   RATETAB_ENT(55,  2,  0),
+   RATETAB_ENT(110, 3,  0),
+   RATETAB_ENT(60,  9,  0),
+   RATETAB_ENT(90,  6,  0),
+   RATETAB_ENT(120, 7,  0),
+   RATETAB_ENT(180, 8,  0),
+   RATETAB_ENT(240, 9,  0),
+   RATETAB_ENT(360, 10, 0),
+   RATETAB_ENT(480, 11, 0),
+   RATETAB_ENT(540, 12, 0)
+};
+
+struct wilc_priv {
+   struct wireless_dev wdev;
+   struct cfg80211_scan_request *scan_req;
+
+   struct wilc_wfi_p2p_listen_params remain_on_ch_params;
+   u64 tx_cookie;
+
+   bool cfg_scanning;
+
+   u8 associated_bss[ETH_ALEN];
+   struct sta_info assoc_stainfo;
+   struct sk_buff *skb;
+   struct net_device *dev;
+   struct host_if_drv *hif_drv;
+   struct wilc_pmkid_attr pmkid_list;
+   u8 wep_key[4][WLAN_KEY_LEN_WEP104];
+   u8 wep_key_len[4];
+
+   /* The real interface that the monitor is on */
+   struct net_device *real_ndev;
+   struct wilc_wfi_key *wilc_gtk[WILC_MAX_NUM_STA];
+   struct wilc_wfi_key *wilc_ptk[WILC_MAX_NUM_STA];
+   u8 wilc_groupkey;
+
+   /* mutexes */
+   struct mutex scan_req_lock;
+   bool p2p_listen_state;
+   int scanned_cnt;
+
+   u64 inc_roc_cookie;
+};
+
+struct frame_reg {
+   u16 type;
+   bool reg;
+};
+
+#define MAX_TCP_SESSION25
+#define MAX_PENDING_ACKS   256
+
+struct ack_session_info {
+   u32 seq_num;
+   u32 bigger_ack_num;
+   u16 src_port;
+   u16 dst_port;
+   u16 status;
+};
+
+struct pending_acks {
+   u32 ack_num;
+   u32 session_index;
+   struct 

[PATCH v4 12/18] wilc1000: add wlan.h

2020-03-02 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/wlan.h' to
'drivers/net/wireless/microchip/wilc1000/wlan.h'.

Signed-off-by: Ajay Singh 
---
 .../net/wireless/microchip/wilc1000/wlan.h| 398 ++
 1 file changed, 398 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/wlan.h

diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.h 
b/drivers/net/wireless/microchip/wilc1000/wlan.h
new file mode 100644
index ..5999c5490ea5
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/wlan.h
@@ -0,0 +1,398 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#ifndef WILC_WLAN_H
+#define WILC_WLAN_H
+
+#include 
+#include 
+
+/
+ *
+ *  Mac eth header length
+ *
+ /
+#define MAX_MAC_HDR_LEN26 /* QOS_MAC_HDR_LEN */
+#define SUB_MSDU_HEADER_LENGTH 14
+#define SNAP_HDR_LEN   8
+#define ETHERNET_HDR_LEN   14
+#define WORD_ALIGNMENT_PAD 0
+
+#define ETH_ETHERNET_HDR_OFFSET(MAX_MAC_HDR_LEN + \
+SUB_MSDU_HEADER_LENGTH + \
+SNAP_HDR_LEN - \
+ETHERNET_HDR_LEN + \
+WORD_ALIGNMENT_PAD)
+
+#define HOST_HDR_OFFSET4
+#define ETHERNET_HDR_LEN   14
+#define IP_HDR_LEN 20
+#define IP_HDR_OFFSET  ETHERNET_HDR_LEN
+#define UDP_HDR_OFFSET (IP_HDR_LEN + IP_HDR_OFFSET)
+#define UDP_HDR_LEN8
+#define UDP_DATA_OFFSET(UDP_HDR_OFFSET + UDP_HDR_LEN)
+#define ETH_CONFIG_PKT_HDR_LEN UDP_DATA_OFFSET
+
+#define ETH_CONFIG_PKT_HDR_OFFSET  (ETH_ETHERNET_HDR_OFFSET + \
+ETH_CONFIG_PKT_HDR_LEN)
+
+/
+ *
+ *  Register Defines
+ *
+ /
+#define WILC_PERIPH_REG_BASE   0x1000
+#define WILC_CHANGING_VIR_IF   0x108c
+#define WILC_CHIPIDWILC_PERIPH_REG_BASE
+#define WILC_GLB_RESET_0   (WILC_PERIPH_REG_BASE + 0x400)
+#define WILC_PIN_MUX_0 (WILC_PERIPH_REG_BASE + 0x408)
+#define WILC_HOST_TX_CTRL  (WILC_PERIPH_REG_BASE + 0x6c)
+#define WILC_HOST_RX_CTRL_0(WILC_PERIPH_REG_BASE + 0x70)
+#define WILC_HOST_RX_CTRL_1(WILC_PERIPH_REG_BASE + 0x74)
+#define WILC_HOST_VMM_CTL  (WILC_PERIPH_REG_BASE + 0x78)
+#define WILC_HOST_RX_CTRL  (WILC_PERIPH_REG_BASE + 0x80)
+#define WILC_HOST_RX_EXTRA_SIZE(WILC_PERIPH_REG_BASE + 0x84)
+#define WILC_HOST_TX_CTRL_1(WILC_PERIPH_REG_BASE + 0x88)
+#define WILC_MISC  (WILC_PERIPH_REG_BASE + 0x428)
+#define WILC_INTR_REG_BASE (WILC_PERIPH_REG_BASE + 0xa00)
+#define WILC_INTR_ENABLE   WILC_INTR_REG_BASE
+#define WILC_INTR2_ENABLE  (WILC_INTR_REG_BASE + 4)
+
+#define WILC_INTR_POLARITY (WILC_INTR_REG_BASE + 0x10)
+#define WILC_INTR_TYPE (WILC_INTR_REG_BASE + 0x20)
+#define WILC_INTR_CLEAR(WILC_INTR_REG_BASE + 0x30)
+#define WILC_INTR_STATUS   (WILC_INTR_REG_BASE + 0x40)
+
+#define WILC_RF_REVISION_ID0x13f4
+
+#define WILC_VMM_TBL_SIZE  64
+#define WILC_VMM_TX_TBL_BASE   0x150400
+#define WILC_VMM_RX_TBL_BASE   0x150500
+
+#define WILC_VMM_BASE  0x15
+#define WILC_VMM_CORE_CTL  WILC_VMM_BASE
+#define WILC_VMM_TBL_CTL   (WILC_VMM_BASE + 0x4)
+#define WILC_VMM_TBL_ENTRY (WILC_VMM_BASE + 0x8)
+#define WILC_VMM_TBL0_SIZE (WILC_VMM_BASE + 0xc)
+#define WILC_VMM_TO_HOST_SIZE  (WILC_VMM_BASE + 0x10)
+#define WILC_VMM_CORE_CFG  (WILC_VMM_BASE + 0x14)
+#define WILC_VMM_TBL_ACTIVE(WILC_VMM_BASE + 040)
+#define WILC_VMM_TBL_STATUS(WILC_VMM_BASE + 0x44)
+
+#define WILC_SPI_REG_BASE  0xe800
+#define WILC_SPI_CTL   WILC_SPI_REG_BASE
+#define WILC_SPI_MASTER_DMA_ADDR   (WILC_SPI_REG_BASE + 0x4)
+#define WILC_SPI_MASTER_DMA_COUNT  (WILC_SPI_REG_BASE + 0x8)
+#define WILC_SPI_SLAVE_DMA_ADDR(WILC_SPI_REG_BASE + 0xc)
+#define WILC_SPI_SLAVE_DMA_COUNT   (WILC_SPI_REG_BASE + 0x10)
+#define WILC_SPI_TX_MODE   (WILC_SPI_REG_BASE + 0x20)
+#define WILC_SPI_PROTOCOL_CONFIG   (WILC_SPI_REG_BASE + 0x24)
+#define WILC_SPI_INTR_CTL  (WILC_SPI_REG_BASE + 0x2c)
+#define WILC_SPI_INT_STATUS(WILC_SPI_REG_BASE + 0x40)
+#define WILC_SPI_INT_CLEAR (WILC_SPI_REG_BASE + 0x44)
+
+#define 

[PATCH v4 14/18] wilc1000: add sdio.c

2020-03-02 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/sdio.c' to
'drivers/net/wireless/microchip/wilc1000/sdio.c'.

Signed-off-by: Ajay Singh 
---
 .../net/wireless/microchip/wilc1000/sdio.c| 1030 +
 1 file changed, 1030 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/sdio.c

diff --git a/drivers/net/wireless/microchip/wilc1000/sdio.c 
b/drivers/net/wireless/microchip/wilc1000/sdio.c
new file mode 100644
index ..2301e90c21ca
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/sdio.c
@@ -0,0 +1,1030 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include "netdev.h"
+#include "cfg80211.h"
+
+#define SDIO_MODALIAS "wilc1000_sdio"
+
+#define SDIO_VENDOR_ID_WILC 0x0296
+#define SDIO_DEVICE_ID_WILC 0x5347
+
+static const struct sdio_device_id wilc_sdio_ids[] = {
+   { SDIO_DEVICE(SDIO_VENDOR_ID_WILC, SDIO_DEVICE_ID_WILC) },
+   { },
+};
+
+#define WILC_SDIO_BLOCK_SIZE 512
+
+struct wilc_sdio {
+   bool irq_gpio;
+   u32 block_size;
+   int has_thrpt_enh3;
+};
+
+struct sdio_cmd52 {
+   u32 read_write: 1;
+   u32 function:   3;
+   u32 raw:1;
+   u32 address:17;
+   u32 data:   8;
+};
+
+struct sdio_cmd53 {
+   u32 read_write: 1;
+   u32 function:   3;
+   u32 block_mode: 1;
+   u32 increment:  1;
+   u32 address:17;
+   u32 count:  9;
+   u8 *buffer;
+   u32 block_size;
+};
+
+static const struct wilc_hif_func wilc_hif_sdio;
+
+static void wilc_sdio_interrupt(struct sdio_func *func)
+{
+   sdio_release_host(func);
+   wilc_handle_isr(sdio_get_drvdata(func));
+   sdio_claim_host(func);
+}
+
+static int wilc_sdio_cmd52(struct wilc *wilc, struct sdio_cmd52 *cmd)
+{
+   struct sdio_func *func = container_of(wilc->dev, struct sdio_func, dev);
+   int ret;
+   u8 data;
+
+   sdio_claim_host(func);
+
+   func->num = cmd->function;
+   if (cmd->read_write) {  /* write */
+   if (cmd->raw) {
+   sdio_writeb(func, cmd->data, cmd->address, );
+   data = sdio_readb(func, cmd->address, );
+   cmd->data = data;
+   } else {
+   sdio_writeb(func, cmd->data, cmd->address, );
+   }
+   } else {/* read */
+   data = sdio_readb(func, cmd->address, );
+   cmd->data = data;
+   }
+
+   sdio_release_host(func);
+
+   if (ret)
+   dev_err(>dev, "%s..failed, err(%d)\n", __func__, ret);
+   return ret;
+}
+
+static int wilc_sdio_cmd53(struct wilc *wilc, struct sdio_cmd53 *cmd)
+{
+   struct sdio_func *func = container_of(wilc->dev, struct sdio_func, dev);
+   int size, ret;
+
+   sdio_claim_host(func);
+
+   func->num = cmd->function;
+   func->cur_blksize = cmd->block_size;
+   if (cmd->block_mode)
+   size = cmd->count * cmd->block_size;
+   else
+   size = cmd->count;
+
+   if (cmd->read_write) {  /* write */
+   ret = sdio_memcpy_toio(func, cmd->address,
+  (void *)cmd->buffer, size);
+   } else {/* read */
+   ret = sdio_memcpy_fromio(func, (void *)cmd->buffer,
+cmd->address,  size);
+   }
+
+   sdio_release_host(func);
+
+   if (ret)
+   dev_err(>dev, "%s..failed, err(%d)\n", __func__,  ret);
+
+   return ret;
+}
+
+static int wilc_sdio_probe(struct sdio_func *func,
+  const struct sdio_device_id *id)
+{
+   struct wilc *wilc;
+   int ret;
+   struct gpio_desc *gpio = NULL;
+   struct wilc_sdio *sdio_priv;
+
+   sdio_priv = kzalloc(sizeof(*sdio_priv), GFP_KERNEL);
+   if (!sdio_priv)
+   return -ENOMEM;
+
+   if (IS_ENABLED(CONFIG_WILC1000_HW_OOB_INTR)) {
+   gpio = gpiod_get(>dev, "irq", GPIOD_IN);
+   if (IS_ERR(gpio)) {
+   /* get the GPIO descriptor from hardcode GPIO number */
+   gpio = gpio_to_desc(GPIO_NUM);
+   if (!gpio)
+   dev_err(>dev, "failed to get irq gpio\n");
+   }
+   }
+
+   ret = wilc_cfg80211_init(, >dev, WILC_HIF_SDIO,
+_hif_sdio);
+   if (ret) {
+   kfree(sdio_priv);
+   return ret;
+   }
+   sdio_set_drvdata(func, wilc);
+   wilc->bus_data = sdio_priv;
+   wilc->dev = >dev;
+   wilc->gpio_irq = gpio;
+
+   wilc->rtc_clk = devm_clk_get(>card->dev, "rtc_clk");
+   if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER)
+  

[PATCH v4 04/18] wilc1000: add wlan_cfg.h

2020-03-02 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/wlan_cfg.h' to
'drivers/net/wireless/microchip/wilc1000/wlan_cfg.h'.

Signed-off-by: Ajay Singh 
---
 .../wireless/microchip/wilc1000/wlan_cfg.h| 54 +++
 1 file changed, 54 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/wlan_cfg.h

diff --git a/drivers/net/wireless/microchip/wilc1000/wlan_cfg.h 
b/drivers/net/wireless/microchip/wilc1000/wlan_cfg.h
new file mode 100644
index ..614c5673f232
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/wlan_cfg.h
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#ifndef WILC_WLAN_CFG_H
+#define WILC_WLAN_CFG_H
+
+struct wilc_cfg_byte {
+   u16 id;
+   u8 val;
+};
+
+struct wilc_cfg_hword {
+   u16 id;
+   u16 val;
+};
+
+struct wilc_cfg_word {
+   u16 id;
+   u32 val;
+};
+
+struct wilc_cfg_str {
+   u16 id;
+   u8 *str;
+};
+
+struct wilc_cfg_str_vals {
+   u8 mac_address[7];
+   u8 firmware_version[129];
+   u8 assoc_rsp[256];
+};
+
+struct wilc_cfg {
+   struct wilc_cfg_byte *b;
+   struct wilc_cfg_hword *hw;
+   struct wilc_cfg_word *w;
+   struct wilc_cfg_str *s;
+   struct wilc_cfg_str_vals *str_vals;
+};
+
+struct wilc;
+int wilc_wlan_cfg_set_wid(u8 *frame, u32 offset, u16 id, u8 *buf, int size);
+int wilc_wlan_cfg_get_wid(u8 *frame, u32 offset, u16 id);
+int wilc_wlan_cfg_get_val(struct wilc *wl, u16 wid, u8 *buffer,
+ u32 buffer_size);
+void wilc_wlan_cfg_indicate_rx(struct wilc *wilc, u8 *frame, int size,
+  struct wilc_cfg_rsp *rsp);
+int wilc_wlan_cfg_init(struct wilc *wl);
+void wilc_wlan_cfg_deinit(struct wilc *wl);
+
+#endif
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 09/18] wilc1000: add netdev.c

2020-03-02 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/netdev.c' to
'drivers/net/wireless/microchip/wilc1000/netdev.c'.

Signed-off-by: Ajay Singh 
---
 .../net/wireless/microchip/wilc1000/netdev.c  | 940 ++
 1 file changed, 940 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/netdev.c

diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.c 
b/drivers/net/wireless/microchip/wilc1000/netdev.c
new file mode 100644
index ..045f5cdfdca0
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/netdev.c
@@ -0,0 +1,940 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "cfg80211.h"
+#include "wlan_cfg.h"
+
+#define WILC_MULTICAST_TABLE_SIZE  8
+
+static irqreturn_t isr_uh_routine(int irq, void *user_data)
+{
+   struct net_device *dev = user_data;
+   struct wilc_vif *vif = netdev_priv(dev);
+   struct wilc *wilc = vif->wilc;
+
+   if (wilc->close) {
+   netdev_err(dev, "Can't handle UH interrupt\n");
+   return IRQ_HANDLED;
+   }
+   return IRQ_WAKE_THREAD;
+}
+
+static irqreturn_t isr_bh_routine(int irq, void *userdata)
+{
+   struct net_device *dev = userdata;
+   struct wilc_vif *vif = netdev_priv(userdata);
+   struct wilc *wilc = vif->wilc;
+
+   if (wilc->close) {
+   netdev_err(dev, "Can't handle BH interrupt\n");
+   return IRQ_HANDLED;
+   }
+
+   wilc_handle_isr(wilc);
+
+   return IRQ_HANDLED;
+}
+
+static int init_irq(struct net_device *dev)
+{
+   int ret = 0;
+   struct wilc_vif *vif = netdev_priv(dev);
+   struct wilc *wl = vif->wilc;
+
+   ret = gpiod_direction_input(wl->gpio_irq);
+   if (ret) {
+   netdev_err(dev, "could not obtain gpio for WILC_INTR\n");
+   return ret;
+   }
+
+   wl->dev_irq_num = gpiod_to_irq(wl->gpio_irq);
+
+   ret = request_threaded_irq(wl->dev_irq_num, isr_uh_routine,
+  isr_bh_routine,
+  IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+  "WILC_IRQ", dev);
+   if (ret < 0)
+   netdev_err(dev, "Failed to request IRQ\n");
+   else
+   netdev_dbg(dev, "IRQ request succeeded IRQ-NUM= %d\n",
+  wl->dev_irq_num);
+
+   return ret;
+}
+
+static void deinit_irq(struct net_device *dev)
+{
+   struct wilc_vif *vif = netdev_priv(dev);
+   struct wilc *wilc = vif->wilc;
+
+   /* Deinitialize IRQ */
+   if (wilc->dev_irq_num)
+   free_irq(wilc->dev_irq_num, wilc);
+}
+
+void wilc_mac_indicate(struct wilc *wilc)
+{
+   s8 status;
+
+   wilc_wlan_cfg_get_val(wilc, WID_STATUS, , 1);
+   if (wilc->mac_status == WILC_MAC_STATUS_INIT) {
+   wilc->mac_status = status;
+   complete(>sync_event);
+   } else {
+   wilc->mac_status = status;
+   }
+}
+
+static struct net_device *get_if_handler(struct wilc *wilc, u8 *mac_header)
+{
+   struct net_device *ndev = NULL;
+   struct wilc_vif *vif;
+   struct ieee80211_hdr *h = (struct ieee80211_hdr *)mac_header;
+
+   list_for_each_entry_rcu(vif, >vif_list, list) {
+   if (vif->mode == WILC_STATION_MODE)
+   if (ether_addr_equal_unaligned(h->addr2, vif->bssid)) {
+   ndev = vif->ndev;
+   goto out;
+   }
+   if (vif->mode == WILC_AP_MODE)
+   if (ether_addr_equal_unaligned(h->addr1, vif->bssid)) {
+   ndev = vif->ndev;
+   goto out;
+   }
+   }
+out:
+   return ndev;
+}
+
+void wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid, u8 mode)
+{
+   struct wilc_vif *vif = netdev_priv(wilc_netdev);
+
+   if (bssid)
+   ether_addr_copy(vif->bssid, bssid);
+   else
+   eth_zero_addr(vif->bssid);
+
+   vif->mode = mode;
+}
+
+int wilc_wlan_get_num_conn_ifcs(struct wilc *wilc)
+{
+   int srcu_idx;
+   u8 ret_val = 0;
+   struct wilc_vif *vif;
+
+   srcu_idx = srcu_read_lock(>srcu);
+   list_for_each_entry_rcu(vif, >vif_list, list) {
+   if (!is_zero_ether_addr(vif->bssid))
+   ret_val++;
+   }
+   srcu_read_unlock(>srcu, srcu_idx);
+   return ret_val;
+}
+
+static int wilc_txq_task(void *vp)
+{
+   int ret;
+   u32 txq_count;
+   struct wilc *wl = vp;
+
+   complete(>txq_thread_started);
+   while (1) {
+   wait_for_completion(>txq_event);
+
+   if (wl->close) {
+   complete(>txq_thread_started);
+
+   while 

[PATCH v4 16/18] dt: bindings: net: add microchip,wilc1000,sdio.yaml

2020-03-02 Thread Ajay.Kathat
From: Ajay Singh 

Moved '/drivers/staging/wilc1000/microchip,wilc1000,sdio.yaml' to
'Documentation/devicetree/bindings/net/wireless/microchip,wilc1000,sdio.yaml'.

Signed-off-by: Ajay Singh 
---
 .../net/wireless/microchip,wilc1000,sdio.yaml | 68 +++
 1 file changed, 68 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/net/wireless/microchip,wilc1000,sdio.yaml

diff --git 
a/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000,sdio.yaml 
b/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000,sdio.yaml
new file mode 100644
index ..b338f569f7e2
--- /dev/null
+++ 
b/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000,sdio.yaml
@@ -0,0 +1,68 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/wireless/microchip,wilc1000,sdio.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Microchip WILC wireless SDIO devicetree bindings
+
+maintainers:
+  - Adham Abozaeid 
+  - Ajay Singh 
+
+description:
+  The wilc1000 chips can be connected via SDIO. The node is used to
+  specify child node to the SDIO controller that connects the device
+  to the system.
+
+properties:
+  compatible:
+const: microchip,wilc1000-sdio
+
+  irq-gpios:
+description: The GPIO phandle connect to a host IRQ.
+maxItems: 1
+
+  reg:
+description: Slot ID used in the controller.
+maxItems: 1
+
+  clocks:
+description: phandle to the clock connected on rtc clock line.
+maxItems: 1
+
+  bus-width:
+description: The number of data lines wired up the slot.
+allOf:
+  - $ref: /schemas/types.yaml#/definitions/uint32
+  - enum: [1, 4, 8]
+  - default: 1
+
+required:
+  - compatible
+  - irq-gpios
+  - reg
+
+examples:
+  - |
+mmc1: mmc@fc00 {
+  #address-cells = <1>;
+  #size-cells = <0>;
+  pinctrl-names = "default";
+  pinctrl-0 = <_mmc1_clk_cmd_dat0 _mmc1_dat1_3>;
+  non-removable;
+  vmmc-supply = <_mmc1_reg>;
+  vqmmc-supply = <_3v3_reg>;
+  status = "okay";
+  wilc_sdio@0 {
+compatible = "microchip,wilc1000-sdio";
+  irq-gpios = < 27 0>;
+  reg = <0>;
+  clocks = <>;
+  clock-names = "rtc_clk";
+  assigned-clocks = <>;
+  assigned-clock-rates = <32768>;
+  status = "okay";
+  bus-width = <4>;
+};
+};
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 01/18] wilc1000: add hif.h

2020-03-02 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/hif.h' to
'drivers/net/wireless/microchip/wilc1000/hif.h'.

Signed-off-by: Ajay Singh 
---
 drivers/net/wireless/microchip/wilc1000/hif.h | 214 ++
 1 file changed, 214 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/hif.h

diff --git a/drivers/net/wireless/microchip/wilc1000/hif.h 
b/drivers/net/wireless/microchip/wilc1000/hif.h
new file mode 100644
index ..db9179171f05
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/hif.h
@@ -0,0 +1,214 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries
+ * All rights reserved.
+ */
+
+#ifndef WILC_HIF_H
+#define WILC_HIF_H
+#include 
+#include "wlan_if.h"
+
+enum {
+   WILC_IDLE_MODE = 0x0,
+   WILC_AP_MODE = 0x1,
+   WILC_STATION_MODE = 0x2,
+   WILC_GO_MODE = 0x3,
+   WILC_CLIENT_MODE = 0x4
+};
+
+#define WILC_MAX_NUM_PROBED_SSID   10
+
+#define WILC_TX_MIC_KEY_LEN8
+#define WILC_RX_MIC_KEY_LEN8
+
+#define WILC_ADD_STA_LENGTH40
+#define WILC_NUM_CONCURRENT_IFC2
+
+enum {
+   WILC_SET_CFG = 0,
+   WILC_GET_CFG
+};
+
+#define WILC_MAX_ASSOC_RESP_FRAME_SIZE   256
+
+struct rf_info {
+   u8 link_speed;
+   s8 rssi;
+   u32 tx_cnt;
+   u32 rx_cnt;
+   u32 tx_fail_cnt;
+};
+
+enum host_if_state {
+   HOST_IF_IDLE= 0,
+   HOST_IF_SCANNING= 1,
+   HOST_IF_CONNECTING  = 2,
+   HOST_IF_WAITING_CONN_RESP   = 3,
+   HOST_IF_CONNECTED   = 4,
+   HOST_IF_P2P_LISTEN  = 5,
+   HOST_IF_FORCE_32BIT = 0x
+};
+
+struct cfg_param_attr {
+   u32 flag;
+   u16 short_retry_limit;
+   u16 long_retry_limit;
+   u16 frag_threshold;
+   u16 rts_threshold;
+};
+
+enum cfg_param {
+   WILC_CFG_PARAM_RETRY_SHORT = BIT(0),
+   WILC_CFG_PARAM_RETRY_LONG = BIT(1),
+   WILC_CFG_PARAM_FRAG_THRESHOLD = BIT(2),
+   WILC_CFG_PARAM_RTS_THRESHOLD = BIT(3)
+};
+
+enum scan_event {
+   SCAN_EVENT_NETWORK_FOUND= 0,
+   SCAN_EVENT_DONE = 1,
+   SCAN_EVENT_ABORTED  = 2,
+   SCAN_EVENT_FORCE_32BIT  = 0x
+};
+
+enum conn_event {
+   CONN_DISCONN_EVENT_CONN_RESP= 0,
+   CONN_DISCONN_EVENT_DISCONN_NOTIF= 1,
+   CONN_DISCONN_EVENT_FORCE_32BIT  = 0x
+};
+
+enum {
+   WILC_HIF_SDIO = 0,
+   WILC_HIF_SPI = BIT(0)
+};
+
+enum {
+   WILC_MAC_STATUS_INIT = -1,
+   WILC_MAC_STATUS_DISCONNECTED = 0,
+   WILC_MAC_STATUS_CONNECTED = 1
+};
+
+struct wilc_rcvd_net_info {
+   s8 rssi;
+   u8 ch;
+   u16 frame_len;
+   struct ieee80211_mgmt *mgmt;
+};
+
+struct wilc_user_scan_req {
+   void (*scan_result)(enum scan_event evt,
+   struct wilc_rcvd_net_info *info, void *priv);
+   void *arg;
+   u32 ch_cnt;
+};
+
+struct wilc_conn_info {
+   u8 bssid[ETH_ALEN];
+   u8 security;
+   enum authtype auth_type;
+   u8 ch;
+   u8 *req_ies;
+   size_t req_ies_len;
+   u8 *resp_ies;
+   u16 resp_ies_len;
+   u16 status;
+   void (*conn_result)(enum conn_event evt, u8 status, void *priv_data);
+   void *arg;
+   void *param;
+};
+
+struct wilc_remain_ch {
+   u16 ch;
+   u32 duration;
+   void (*expired)(void *priv, u64 cookie);
+   void *arg;
+   u32 cookie;
+};
+
+struct wilc;
+struct host_if_drv {
+   struct wilc_user_scan_req usr_scan_req;
+   struct wilc_conn_info conn_info;
+   struct wilc_remain_ch remain_on_ch;
+   u64 p2p_timeout;
+
+   enum host_if_state hif_state;
+
+   u8 assoc_bssid[ETH_ALEN];
+
+   struct timer_list scan_timer;
+   struct wilc_vif *scan_timer_vif;
+
+   struct timer_list connect_timer;
+   struct wilc_vif *connect_timer_vif;
+
+   struct timer_list remain_on_ch_timer;
+   struct wilc_vif *remain_on_ch_timer_vif;
+
+   bool ifc_up;
+   u8 assoc_resp[WILC_MAX_ASSOC_RESP_FRAME_SIZE];
+};
+
+struct wilc_vif;
+int wilc_remove_wep_key(struct wilc_vif *vif, u8 index);
+int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index);
+int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len,
+u8 index);
+int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len,
+   u8 index, u8 mode, enum authtype auth_type);
+int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len,
+const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic,
+u8 mode, u8 cipher_mode, u8 index);
+s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac,
+  u32 *out_val);
+int wilc_add_rx_gtk(struct wilc_vif 

[PATCH v4 03/18] wilc1000: add wlan_if.h

2020-03-02 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/wlan_if.h' to
'drivers/net/wireless/microchip/wilc1000/wlan_if.h'.

Signed-off-by: Ajay Singh 
---
 .../net/wireless/microchip/wilc1000/wlan_if.h | 803 ++
 1 file changed, 803 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/wlan_if.h

diff --git a/drivers/net/wireless/microchip/wilc1000/wlan_if.h 
b/drivers/net/wireless/microchip/wilc1000/wlan_if.h
new file mode 100644
index ..f85fd575136d
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/wlan_if.h
@@ -0,0 +1,803 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#ifndef WILC_WLAN_IF_H
+#define WILC_WLAN_IF_H
+
+#include 
+#include "fw.h"
+
+/
+ *
+ *  Wlan Configuration ID
+ *
+ /
+
+enum bss_types {
+   WILC_FW_BSS_TYPE_INFRA = 0,
+   WILC_FW_BSS_TYPE_INDEPENDENT,
+   WILC_FW_BSS_TYPE_AP,
+};
+
+enum {
+   WILC_FW_OPER_MODE_B_ONLY = 0,/* 1, 2 M, otherwise 5, 11 M */
+   WILC_FW_OPER_MODE_G_ONLY,/* 6,12,24 otherwise 9,18,36,48,54 */
+   WILC_FW_OPER_MODE_G_MIXED_11B_1, /* 1,2,5.5,11 otherwise all on */
+   WILC_FW_OPER_MODE_G_MIXED_11B_2, /* 1,2,5,11,6,12,24 otherwise all on */
+};
+
+enum {
+   WILC_FW_PREAMBLE_SHORT = 0, /* Short Preamble */
+   WILC_FW_PREAMBLE_LONG = 1,  /* Long Preamble */
+   WILC_FW_PREAMBLE_AUTO = 2,  /* Auto Preamble Selection */
+};
+
+enum {
+   WILC_FW_PASSIVE_SCAN = 0,
+   WILC_FW_ACTIVE_SCAN = 1,
+};
+
+enum {
+   WILC_FW_NO_POWERSAVE = 0,
+   WILC_FW_MIN_FAST_PS = 1,
+   WILC_FW_MAX_FAST_PS = 2,
+   WILC_FW_MIN_PSPOLL_PS = 3,
+   WILC_FW_MAX_PSPOLL_PS = 4
+};
+
+enum chip_ps_states {
+   WILC_CHIP_WAKEDUP = 0,
+   WILC_CHIP_SLEEPING_AUTO = 1,
+   WILC_CHIP_SLEEPING_MANUAL = 2
+};
+
+enum bus_acquire {
+   WILC_BUS_ACQUIRE_ONLY = 0,
+   WILC_BUS_ACQUIRE_AND_WAKEUP = 1,
+};
+
+enum bus_release {
+   WILC_BUS_RELEASE_ONLY = 0,
+   WILC_BUS_RELEASE_ALLOW_SLEEP = 1,
+};
+
+enum {
+   WILC_FW_NO_ENCRYPT = 0,
+   WILC_FW_ENCRYPT_ENABLED = BIT(0),
+   WILC_FW_WEP = BIT(1),
+   WILC_FW_WEP_EXTENDED = BIT(2),
+   WILC_FW_WPA = BIT(3),
+   WILC_FW_WPA2 = BIT(4),
+   WILC_FW_AES = BIT(5),
+   WILC_FW_TKIP = BIT(6)
+};
+
+enum {
+   WILC_FW_SEC_NO = WILC_FW_NO_ENCRYPT,
+   WILC_FW_SEC_WEP = WILC_FW_WEP | WILC_FW_ENCRYPT_ENABLED,
+   WILC_FW_SEC_WEP_EXTENDED = WILC_FW_WEP_EXTENDED | WILC_FW_SEC_WEP,
+   WILC_FW_SEC_WPA = WILC_FW_WPA | WILC_FW_ENCRYPT_ENABLED,
+   WILC_FW_SEC_WPA_AES = WILC_FW_AES | WILC_FW_SEC_WPA,
+   WILC_FW_SEC_WPA_TKIP = WILC_FW_TKIP | WILC_FW_SEC_WPA,
+   WILC_FW_SEC_WPA2 = WILC_FW_WPA2 | WILC_FW_ENCRYPT_ENABLED,
+   WILC_FW_SEC_WPA2_AES = WILC_FW_AES | WILC_FW_SEC_WPA2,
+   WILC_FW_SEC_WPA2_TKIP = WILC_FW_TKIP | WILC_FW_SEC_WPA2
+};
+
+enum authtype {
+   WILC_FW_AUTH_OPEN_SYSTEM = 1,
+   WILC_FW_AUTH_SHARED_KEY = 2,
+   WILC_FW_AUTH_ANY = 3,
+   WILC_FW_AUTH_IEEE8021 = 5
+};
+
+enum site_survey {
+   WILC_FW_SITE_SURVEY_1CH = 0,
+   WILC_FW_SITE_SURVEY_ALL_CH = 1,
+   WILC_FW_SITE_SURVEY_OFF = 2
+};
+
+enum {
+   WILC_FW_ACK_POLICY_NORMAL = 0,
+   WILC_FW_ACK_NO_POLICY,
+};
+
+enum {
+   WILC_FW_REKEY_POLICY_DISABLE = 1,
+   WILC_FW_REKEY_POLICY_TIME_BASE,
+   WILC_FW_REKEY_POLICY_PKT_BASE,
+   WILC_FW_REKEY_POLICY_TIME_PKT_BASE
+};
+
+enum {
+   WILC_FW_FILTER_NO = 0x00,
+   WILC_FW_FILTER_AP_ONLY = 0x01,
+   WILC_FW_FILTER_STA_ONLY = 0x02
+};
+
+enum {
+   WILC_FW_11N_PROT_AUTO = 0,  /* Auto */
+   WILC_FW_11N_NO_PROT,/* Do not use any protection */
+   WILC_FW_11N_PROT_ERP,   /* Protect all ERP frame exchanges */
+   WILC_FW_11N_PROT_HT,/* Protect all HT frame exchanges  */
+   WILC_FW_11N_PROT_GF /* Protect all GF frame exchanges  */
+};
+
+enum {
+   WILC_FW_ERP_PROT_SELF_CTS,
+   WILC_FW_ERP_PROT_RTS_CTS,
+};
+
+enum {
+   WILC_FW_11N_OP_MODE_HT_MIXED = 1,
+   WILC_FW_11N_OP_MODE_HT_ONLY_20MHZ,
+   WILC_FW_11N_OP_MODE_HT_ONLY_20_40MHZ,
+};
+
+enum {
+   WILC_FW_OBBS_NONHT_NO_DETECT = 0,
+   WILC_FW_OBBS_NONHT_DETECT_ONLY = 1,
+   WILC_FW_OBBS_NONHT_DETECT_PROTECT = 2,
+   WILC_FW_OBBS_NONHT_DETECT_PROTECT_REPORT = 3,
+};
+
+enum {
+   WILC_FW_HT_PROT_RTS_CTS_NONHT = 0,  /* RTS-CTS at non-HT rate */
+   WILC_FW_HT_PROT_FIRST_FRAME_NONHT,  /* First frame at non-HT rate */
+   WILC_FW_HT_PROT_LSIG_TXOP,  /* LSIG TXOP Protection */
+   WILC_FW_HT_PROT_FIRST_FRAME_MIXED,  /* First frame at Mixed format */
+};
+
+enum {
+   WILC_FW_SMPS_MODE_STATIC = 1,
+   WILC_FW_SMPS_MODE_DYNAMIC = 2,
+   WILC_FW_SMPS_MODE_MIMO = 3,  

[PATCH v4 15/18] wilc1000: add fw.h

2020-03-02 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/fw.h' to
'drivers/net/wireless/microchip/wilc1000/fw.h'.

Signed-off-by: Ajay Singh 
---
 drivers/net/wireless/microchip/wilc1000/fw.h | 119 +++
 1 file changed, 119 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/fw.h

diff --git a/drivers/net/wireless/microchip/wilc1000/fw.h 
b/drivers/net/wireless/microchip/wilc1000/fw.h
new file mode 100644
index ..a76e1dea4345
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/fw.h
@@ -0,0 +1,119 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#ifndef WILC_FW_H
+#define WILC_FW_H
+
+#include 
+
+#define WILC_MAX_NUM_STA   9
+#define WILC_MAX_RATES_SUPPORTED   12
+#define WILC_MAX_NUM_PMKIDS16
+#define WILC_MAX_NUM_SCANNED_CH14
+
+struct wilc_assoc_resp {
+   __le16 capab_info;
+   __le16 status_code;
+   __le16 aid;
+} __packed;
+
+struct wilc_pmkid {
+   u8 bssid[ETH_ALEN];
+   u8 pmkid[WLAN_PMKID_LEN];
+} __packed;
+
+struct wilc_pmkid_attr {
+   u8 numpmkid;
+   struct wilc_pmkid pmkidlist[WILC_MAX_NUM_PMKIDS];
+} __packed;
+
+struct wilc_reg_frame {
+   u8 reg;
+   u8 reg_id;
+   __le16 frame_type;
+} __packed;
+
+struct wilc_drv_handler {
+   __le32 handler;
+   u8 mode;
+} __packed;
+
+struct wilc_wep_key {
+   u8 index;
+   u8 key_len;
+   u8 key[0];
+} __packed;
+
+struct wilc_sta_wpa_ptk {
+   u8 mac_addr[ETH_ALEN];
+   u8 key_len;
+   u8 key[0];
+} __packed;
+
+struct wilc_ap_wpa_ptk {
+   u8 mac_addr[ETH_ALEN];
+   u8 index;
+   u8 key_len;
+   u8 key[0];
+} __packed;
+
+struct wilc_gtk_key {
+   u8 mac_addr[ETH_ALEN];
+   u8 rsc[8];
+   u8 index;
+   u8 key_len;
+   u8 key[0];
+} __packed;
+
+struct wilc_op_mode {
+   __le32 mode;
+} __packed;
+
+struct wilc_noa_opp_enable {
+   u8 ct_window;
+   u8 cnt;
+   __le32 duration;
+   __le32 interval;
+   __le32 start_time;
+} __packed;
+
+struct wilc_noa_opp_disable {
+   u8 cnt;
+   __le32 duration;
+   __le32 interval;
+   __le32 start_time;
+} __packed;
+
+struct wilc_join_bss_param {
+   char ssid[IEEE80211_MAX_SSID_LEN];
+   u8 ssid_terminator;
+   u8 bss_type;
+   u8 ch;
+   __le16 cap_info;
+   u8 sa[ETH_ALEN];
+   u8 bssid[ETH_ALEN];
+   __le16 beacon_period;
+   u8 dtim_period;
+   u8 supp_rates[WILC_MAX_RATES_SUPPORTED + 1];
+   u8 wmm_cap;
+   u8 uapsd_cap;
+   u8 ht_capable;
+   u8 rsn_found;
+   u8 rsn_grp_policy;
+   u8 mode_802_11i;
+   u8 p_suites[3];
+   u8 akm_suites[3];
+   u8 rsn_cap[2];
+   u8 noa_enabled;
+   __le32 tsf_lo;
+   u8 idx;
+   u8 opp_enabled;
+   union {
+   struct wilc_noa_opp_disable opp_dis;
+   struct wilc_noa_opp_enable opp_en;
+   };
+} __packed;
+#endif
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 00/18] wilc1000: move out of staging

2020-03-02 Thread Ajay.Kathat
From: Ajay Singh 

This patch series is to review and move wilc1000 driver out of staging.
Most of the review comments received in [1] & [2] are addressed in the
latest code. Please review and provide your inputs.

[1]. 
https://lore.kernel.org/linux-wireless/1537957525-11467-1-git-send-email-ajay.kat...@microchip.com/
[2]. 
https://lore.kernel.org/linux-wireless/1562896697-8002-1-git-send-email-ajay.kat...@microchip.com/

Changes since v3:
  - handle few Smatch static checker reported issues.
  - use flexible-array member instead of zero-length array.

Changes since v2:
  - use 'struct' to extract FW info from received commands.
  - make use of C style comments instead of C++.
  - remove use of bool type for firmware struct.
  - deleted unused code related to interrupt handling.
  - make use of RCU list to maintain interfaces list.
  - remove 'wilc_' prefix from file name.
  - added 'WILC_' prefix for header guard macro.
  - remove use of infinite loops(i.e. while(1)).
  - move firmware realted struct to a separate file.
  - refactor SPI command handling by using 'struct'.
  - use different functions to handle different SPI commands.
  - cleanup spi.c and sdio.c by removing unused code.
  - remove use of vendor specific IE for p2p handling.
  - refactor p2p related code to avoid use of buf pointer operation.
  - make use of FIELD_GET/PREP macro.
  - use #define instead of magic values.
  - use YAML schemes for DT binding documentation.
  - deleted unused code from spi.c and sdio.c.
  - added changes for few issues reported by smatch static code analyzer.

Changes since v1:
  - remove use of shadow buffer to keep scan result.
  - remove internal messaging flow to handle cfg80211_ops.
  - make use of cfg80211 provide API.
  - use 'struct' for packing firmware commands.
  - make use of kernel API's and Macro.
  - remove unnecessary log messages
  - supported dynamically add/remove interfaces.
  - cleanup and deleted around 3.3k lines of code.

Ajay Singh (18):
  wilc1000: add hif.h
  wilc1000: add hif.c
  wilc1000: add wlan_if.h
  wilc1000: add wlan_cfg.h
  wilc1000: add wlan_cfg.c
  wilc1000: add cfg80211.c
  wilc1000: add cfg80211.h
  wilc1000: add netdev.h
  wilc1000: add netdev.c
  wilc1000: add mon.c
  wilc1000: add spi.c
  wilc1000: add wlan.h
  wilc1000: add wlan.c
  wilc1000: add sdio.c
  wilc1000: add fw.h
  dt: bindings: net: add microchip,wilc1000,sdio.yaml
  dt: bindings: net: add microchip,wilc1000,spi.yaml
  wilc1000: add Makefile and Kconfig files for wilc1000 compilation

 .../net/wireless/microchip,wilc1000,sdio.yaml |   68 +
 .../net/wireless/microchip,wilc1000,spi.yaml  |   61 +
 drivers/net/wireless/Kconfig  |1 +
 drivers/net/wireless/Makefile |1 +
 drivers/net/wireless/microchip/Kconfig|   15 +
 drivers/net/wireless/microchip/Makefile   |2 +
 .../net/wireless/microchip/wilc1000/Kconfig   |   42 +
 .../net/wireless/microchip/wilc1000/Makefile  |   14 +
 .../wireless/microchip/wilc1000/cfg80211.c| 1850 
 .../wireless/microchip/wilc1000/cfg80211.h|   29 +
 drivers/net/wireless/microchip/wilc1000/fw.h  |  119 +
 drivers/net/wireless/microchip/wilc1000/hif.c | 1959 +
 drivers/net/wireless/microchip/wilc1000/hif.h |  214 ++
 drivers/net/wireless/microchip/wilc1000/mon.c |  260 +++
 .../net/wireless/microchip/wilc1000/netdev.c  |  940 
 .../net/wireless/microchip/wilc1000/netdev.h  |  295 +++
 .../net/wireless/microchip/wilc1000/sdio.c| 1030 +
 drivers/net/wireless/microchip/wilc1000/spi.c | 1001 +
 .../net/wireless/microchip/wilc1000/wlan.c| 1238 +++
 .../net/wireless/microchip/wilc1000/wlan.h|  398 
 .../wireless/microchip/wilc1000/wlan_cfg.c|  413 
 .../wireless/microchip/wilc1000/wlan_cfg.h|   54 +
 .../net/wireless/microchip/wilc1000/wlan_if.h |  803 +++
 drivers/staging/Kconfig   |2 -
 drivers/staging/Makefile  |1 -
 25 files changed, 10807 insertions(+), 3 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/net/wireless/microchip,wilc1000,sdio.yaml
 create mode 100644 
Documentation/devicetree/bindings/net/wireless/microchip,wilc1000,spi.yaml
 create mode 100644 drivers/net/wireless/microchip/Kconfig
 create mode 100644 drivers/net/wireless/microchip/Makefile
 create mode 100644 drivers/net/wireless/microchip/wilc1000/Kconfig
 create mode 100644 drivers/net/wireless/microchip/wilc1000/Makefile
 create mode 100644 drivers/net/wireless/microchip/wilc1000/cfg80211.c
 create mode 100644 drivers/net/wireless/microchip/wilc1000/cfg80211.h
 create mode 100644 drivers/net/wireless/microchip/wilc1000/fw.h
 create mode 100644 drivers/net/wireless/microchip/wilc1000/hif.c
 create mode 100644 drivers/net/wireless/microchip/wilc1000/hif.h
 create mode 100644 drivers/net/wireless/microchip/wilc1000/mon.c
 create mode 100644 drivers/net/wireless/microchip/wilc1000/netdev.c
 create 

[PATCH v4 05/18] wilc1000: add wlan_cfg.c

2020-03-02 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/wlan_cfg.c' to
'drivers/net/wireless/microchip/wilc1000/wlan_cfg.c'.

Signed-off-by: Ajay Singh 
---
 .../wireless/microchip/wilc1000/wlan_cfg.c| 413 ++
 1 file changed, 413 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/wlan_cfg.c

diff --git a/drivers/net/wireless/microchip/wilc1000/wlan_cfg.c 
b/drivers/net/wireless/microchip/wilc1000/wlan_cfg.c
new file mode 100644
index ..fe2a7ed8e5cd
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/wlan_cfg.c
@@ -0,0 +1,413 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#include 
+#include "wlan_if.h"
+#include "wlan.h"
+#include "wlan_cfg.h"
+#include "netdev.h"
+
+enum cfg_cmd_type {
+   CFG_BYTE_CMD= 0,
+   CFG_HWORD_CMD   = 1,
+   CFG_WORD_CMD= 2,
+   CFG_STR_CMD = 3,
+   CFG_BIN_CMD = 4
+};
+
+static const struct wilc_cfg_byte g_cfg_byte[] = {
+   {WID_STATUS, 0},
+   {WID_RSSI, 0},
+   {WID_LINKSPEED, 0},
+   {WID_NIL, 0}
+};
+
+static const struct wilc_cfg_hword g_cfg_hword[] = {
+   {WID_NIL, 0}
+};
+
+static const struct wilc_cfg_word g_cfg_word[] = {
+   {WID_FAILED_COUNT, 0},
+   {WID_RECEIVED_FRAGMENT_COUNT, 0},
+   {WID_SUCCESS_FRAME_COUNT, 0},
+   {WID_GET_INACTIVE_TIME, 0},
+   {WID_NIL, 0}
+
+};
+
+static const struct wilc_cfg_str g_cfg_str[] = {
+   {WID_FIRMWARE_VERSION, NULL},
+   {WID_MAC_ADDR, NULL},
+   {WID_ASSOC_RES_INFO, NULL},
+   {WID_NIL, NULL}
+};
+
+#define WILC_RESP_MSG_TYPE_CONFIG_REPLY'R'
+#define WILC_RESP_MSG_TYPE_STATUS_INFO 'I'
+#define WILC_RESP_MSG_TYPE_NETWORK_INFO'N'
+#define WILC_RESP_MSG_TYPE_SCAN_COMPLETE   'S'
+
+/
+ *
+ *  Configuration Functions
+ *
+ /
+
+static int wilc_wlan_cfg_set_byte(u8 *frame, u32 offset, u16 id, u8 val8)
+{
+   if ((offset + 4) >= WILC_MAX_CFG_FRAME_SIZE)
+   return 0;
+
+   put_unaligned_le16(id, [offset]);
+   put_unaligned_le16(1, [offset + 2]);
+   frame[offset + 4] = val8;
+   return 5;
+}
+
+static int wilc_wlan_cfg_set_hword(u8 *frame, u32 offset, u16 id, u16 val16)
+{
+   if ((offset + 5) >= WILC_MAX_CFG_FRAME_SIZE)
+   return 0;
+
+   put_unaligned_le16(id, [offset]);
+   put_unaligned_le16(2, [offset + 2]);
+   put_unaligned_le16(val16, [offset + 4]);
+
+   return 6;
+}
+
+static int wilc_wlan_cfg_set_word(u8 *frame, u32 offset, u16 id, u32 val32)
+{
+   if ((offset + 7) >= WILC_MAX_CFG_FRAME_SIZE)
+   return 0;
+
+   put_unaligned_le16(id, [offset]);
+   put_unaligned_le16(4, [offset + 2]);
+   put_unaligned_le32(val32, [offset + 4]);
+
+   return 8;
+}
+
+static int wilc_wlan_cfg_set_str(u8 *frame, u32 offset, u16 id, u8 *str,
+u32 size)
+{
+   if ((offset + size + 4) >= WILC_MAX_CFG_FRAME_SIZE)
+   return 0;
+
+   put_unaligned_le16(id, [offset]);
+   put_unaligned_le16(size, [offset + 2]);
+   if (str && size != 0)
+   memcpy([offset + 4], str, size);
+
+   return (size + 4);
+}
+
+static int wilc_wlan_cfg_set_bin(u8 *frame, u32 offset, u16 id, u8 *b, u32 
size)
+{
+   u32 i;
+   u8 checksum = 0;
+
+   if ((offset + size + 5) >= WILC_MAX_CFG_FRAME_SIZE)
+   return 0;
+
+   put_unaligned_le16(id, [offset]);
+   put_unaligned_le16(size, [offset + 2]);
+
+   if ((b) && size != 0) {
+   memcpy([offset + 4], b, size);
+   for (i = 0; i < size; i++)
+   checksum += frame[offset + i + 4];
+   }
+
+   frame[offset + size + 4] = checksum;
+
+   return (size + 5);
+}
+
+/
+ *
+ *  Configuration Response Functions
+ *
+ /
+
+static void wilc_wlan_parse_response_frame(struct wilc *wl, u8 *info, int size)
+{
+   u16 wid;
+   u32 len = 0, i = 0;
+   struct wilc_cfg *cfg = >cfg;
+
+   while (size > 0) {
+   i = 0;
+   wid = get_unaligned_le16(info);
+
+   switch (FIELD_GET(WILC_WID_TYPE, wid)) {
+   case WID_CHAR:
+   while (cfg->b[i].id != WID_NIL && cfg->b[i].id != wid)
+   i++;
+
+   if (cfg->b[i].id == wid)
+   cfg->b[i].val = info[4];
+
+   len = 3;
+   break;
+
+   case WID_SHORT:
+   while (cfg->hw[i].id != WID_NIL && cfg->hw[i].id != wid)
+   i++;
+
+   if (cfg->hw[i].id == wid)
+   

[PATCH v4 10/18] wilc1000: add mon.c

2020-03-02 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/mon.c' to
'drivers/net/wireless/microchip/wilc1000/mon.c'.

Signed-off-by: Ajay Singh 
---
 drivers/net/wireless/microchip/wilc1000/mon.c | 260 ++
 1 file changed, 260 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/mon.c

diff --git a/drivers/net/wireless/microchip/wilc1000/mon.c 
b/drivers/net/wireless/microchip/wilc1000/mon.c
new file mode 100644
index ..60331417bd98
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/mon.c
@@ -0,0 +1,260 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#include "cfg80211.h"
+
+struct wilc_wfi_radiotap_hdr {
+   struct ieee80211_radiotap_header hdr;
+   u8 rate;
+} __packed;
+
+struct wilc_wfi_radiotap_cb_hdr {
+   struct ieee80211_radiotap_header hdr;
+   u8 rate;
+   u8 dump;
+   u16 tx_flags;
+} __packed;
+
+#define TX_RADIOTAP_PRESENT ((1 << IEEE80211_RADIOTAP_RATE) |  \
+(1 << IEEE80211_RADIOTAP_TX_FLAGS))
+
+void wilc_wfi_monitor_rx(struct net_device *mon_dev, u8 *buff, u32 size)
+{
+   u32 header, pkt_offset;
+   struct sk_buff *skb = NULL;
+   struct wilc_wfi_radiotap_hdr *hdr;
+   struct wilc_wfi_radiotap_cb_hdr *cb_hdr;
+
+   if (!mon_dev)
+   return;
+
+   if (!netif_running(mon_dev))
+   return;
+
+   /* Get WILC header */
+   header = get_unaligned_le32(buff - HOST_HDR_OFFSET);
+   /*
+* The packet offset field contain info about what type of management
+* the frame we are dealing with and ack status
+*/
+   pkt_offset = FIELD_GET(WILC_PKT_HDR_OFFSET_FIELD, header);
+
+   if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {
+   /* hostapd callback mgmt frame */
+
+   skb = dev_alloc_skb(size + sizeof(*cb_hdr));
+   if (!skb)
+   return;
+
+   skb_put_data(skb, buff, size);
+
+   cb_hdr = skb_push(skb, sizeof(*cb_hdr));
+   memset(cb_hdr, 0, sizeof(*cb_hdr));
+
+   cb_hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */
+
+   cb_hdr->hdr.it_len = cpu_to_le16(sizeof(*cb_hdr));
+
+   cb_hdr->hdr.it_present = cpu_to_le32(TX_RADIOTAP_PRESENT);
+
+   cb_hdr->rate = 5;
+
+   if (pkt_offset & IS_MGMT_STATUS_SUCCES) {
+   /* success */
+   cb_hdr->tx_flags = IEEE80211_RADIOTAP_F_TX_RTS;
+   } else {
+   cb_hdr->tx_flags = IEEE80211_RADIOTAP_F_TX_FAIL;
+   }
+
+   } else {
+   skb = dev_alloc_skb(size + sizeof(*hdr));
+
+   if (!skb)
+   return;
+
+   skb_put_data(skb, buff, size);
+   hdr = skb_push(skb, sizeof(*hdr));
+   memset(hdr, 0, sizeof(struct wilc_wfi_radiotap_hdr));
+   hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */
+   hdr->hdr.it_len = cpu_to_le16(sizeof(*hdr));
+   hdr->hdr.it_present = cpu_to_le32
+   (1 << IEEE80211_RADIOTAP_RATE);
+   hdr->rate = 5;
+   }
+
+   skb->dev = mon_dev;
+   skb_reset_mac_header(skb);
+   skb->ip_summed = CHECKSUM_UNNECESSARY;
+   skb->pkt_type = PACKET_OTHERHOST;
+   skb->protocol = htons(ETH_P_802_2);
+   memset(skb->cb, 0, sizeof(skb->cb));
+
+   netif_rx(skb);
+}
+
+struct tx_complete_mon_data {
+   int size;
+   void *buff;
+};
+
+static void mgmt_tx_complete(void *priv, int status)
+{
+   struct tx_complete_mon_data *pv_data = priv;
+   /*
+* in case of fully hosting mode, the freeing will be done
+* in response to the cfg packet
+*/
+   kfree(pv_data->buff);
+
+   kfree(pv_data);
+}
+
+static int mon_mgmt_tx(struct net_device *dev, const u8 *buf, size_t len)
+{
+   struct tx_complete_mon_data *mgmt_tx = NULL;
+
+   if (!dev)
+   return -EFAULT;
+
+   netif_stop_queue(dev);
+   mgmt_tx = kmalloc(sizeof(*mgmt_tx), GFP_ATOMIC);
+   if (!mgmt_tx)
+   return -ENOMEM;
+
+   mgmt_tx->buff = kmemdup(buf, len, GFP_ATOMIC);
+   if (!mgmt_tx->buff) {
+   kfree(mgmt_tx);
+   return -ENOMEM;
+   }
+
+   mgmt_tx->size = len;
+
+   wilc_wlan_txq_add_mgmt_pkt(dev, mgmt_tx, mgmt_tx->buff, mgmt_tx->size,
+  mgmt_tx_complete);
+
+   netif_wake_queue(dev);
+   return 0;
+}
+
+static netdev_tx_t wilc_wfi_mon_xmit(struct sk_buff *skb,
+struct net_device *dev)
+{
+   u32 rtap_len, ret = 0;
+   struct wilc_wfi_mon_priv  *mon_priv;
+   struct sk_buff *skb2;
+   struct wilc_wfi_radiotap_cb_hdr *cb_hdr;
+   u8 srcadd[ETH_ALEN];
+   

[PATCH v4 02/18] wilc1000: add hif.c

2020-03-02 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/hif.c' to
'drivers/net/wireless/microchip/wilc1000/hif.c'.

Signed-off-by: Ajay Singh 
---
 drivers/net/wireless/microchip/wilc1000/hif.c | 1959 +
 1 file changed, 1959 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/hif.c

diff --git a/drivers/net/wireless/microchip/wilc1000/hif.c 
b/drivers/net/wireless/microchip/wilc1000/hif.c
new file mode 100644
index ..6c7de2f8d3f2
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/hif.c
@@ -0,0 +1,1959 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#include "netdev.h"
+
+#define WILC_HIF_SCAN_TIMEOUT_MS5000
+#define WILC_HIF_CONNECT_TIMEOUT_MS 9500
+
+#define WILC_FALSE_FRMWR_CHANNEL   100
+
+struct wilc_rcvd_mac_info {
+   u8 status;
+};
+
+struct wilc_set_multicast {
+   u32 enabled;
+   u32 cnt;
+   u8 *mc_list;
+};
+
+struct wilc_del_all_sta {
+   u8 assoc_sta;
+   u8 mac[WILC_MAX_NUM_STA][ETH_ALEN];
+};
+
+union wilc_message_body {
+   struct wilc_rcvd_net_info net_info;
+   struct wilc_rcvd_mac_info mac_info;
+   struct wilc_set_multicast mc_info;
+   struct wilc_remain_ch remain_on_ch;
+   char *data;
+};
+
+struct host_if_msg {
+   union wilc_message_body body;
+   struct wilc_vif *vif;
+   struct work_struct work;
+   void (*fn)(struct work_struct *ws);
+   struct completion work_comp;
+   bool is_sync;
+};
+
+/* 'msg' should be free by the caller for syc */
+static struct host_if_msg*
+wilc_alloc_work(struct wilc_vif *vif, void (*work_fun)(struct work_struct *),
+   bool is_sync)
+{
+   struct host_if_msg *msg;
+
+   if (!work_fun)
+   return ERR_PTR(-EINVAL);
+
+   msg = kzalloc(sizeof(*msg), GFP_ATOMIC);
+   if (!msg)
+   return ERR_PTR(-ENOMEM);
+   msg->fn = work_fun;
+   msg->vif = vif;
+   msg->is_sync = is_sync;
+   if (is_sync)
+   init_completion(>work_comp);
+
+   return msg;
+}
+
+static int wilc_enqueue_work(struct host_if_msg *msg)
+{
+   INIT_WORK(>work, msg->fn);
+
+   if (!msg->vif || !msg->vif->wilc || !msg->vif->wilc->hif_workqueue)
+   return -EINVAL;
+
+   if (!queue_work(msg->vif->wilc->hif_workqueue, >work))
+   return -EINVAL;
+
+   return 0;
+}
+
+/* The idx starts from 0 to (NUM_CONCURRENT_IFC - 1), but 0 index used as
+ * special purpose in wilc device, so we add 1 to the index to starts from 1.
+ * As a result, the returned index will be 1 to NUM_CONCURRENT_IFC.
+ */
+int wilc_get_vif_idx(struct wilc_vif *vif)
+{
+   return vif->idx + 1;
+}
+
+/* We need to minus 1 from idx which is from wilc device to get real index
+ * of wilc->vif[], because we add 1 when pass to wilc device in the function
+ * wilc_get_vif_idx.
+ * As a result, the index should be between 0 and (NUM_CONCURRENT_IFC - 1).
+ */
+static struct wilc_vif *wilc_get_vif_from_idx(struct wilc *wilc, int idx)
+{
+   int index = idx - 1;
+   struct wilc_vif *vif;
+
+   if (index < 0 || index >= WILC_NUM_CONCURRENT_IFC)
+   return NULL;
+
+   list_for_each_entry_rcu(vif, >vif_list, list) {
+   if (vif->idx == index)
+   return vif;
+   }
+
+   return NULL;
+}
+
+static int handle_scan_done(struct wilc_vif *vif, enum scan_event evt)
+{
+   int result = 0;
+   u8 abort_running_scan;
+   struct wid wid;
+   struct host_if_drv *hif_drv = vif->hif_drv;
+   struct wilc_user_scan_req *scan_req;
+
+   if (evt == SCAN_EVENT_ABORTED) {
+   abort_running_scan = 1;
+   wid.id = WID_ABORT_RUNNING_SCAN;
+   wid.type = WID_CHAR;
+   wid.val = (s8 *)_running_scan;
+   wid.size = sizeof(char);
+
+   result = wilc_send_config_pkt(vif, WILC_SET_CFG, , 1);
+   if (result) {
+   netdev_err(vif->ndev, "Failed to set abort running\n");
+   result = -EFAULT;
+   }
+   }
+
+   if (!hif_drv) {
+   netdev_err(vif->ndev, "%s: hif driver is NULL\n", __func__);
+   return result;
+   }
+
+   scan_req = _drv->usr_scan_req;
+   if (scan_req->scan_result) {
+   scan_req->scan_result(evt, NULL, scan_req->arg);
+   scan_req->scan_result = NULL;
+   }
+
+   return result;
+}
+
+int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
+ u8 *ch_freq_list, u8 ch_list_len,
+ void (*scan_result_fn)(enum scan_event,
+struct wilc_rcvd_net_info *, void *),
+ void *user_arg, struct cfg80211_scan_request *request)
+{
+   int result = 0;
+   struct wid wid_list[5];
+   u32 

[PATCH v4 07/18] wilc1000: add cfg80211.h

2020-03-02 Thread Ajay.Kathat
From: Ajay Singh 

Moved 'drivers/staging/wilc1000/cfg80211.h' to
'drivers/net/wireless/microchip/wilc1000/cfg80211.h'.

Signed-off-by: Ajay Singh 
---
 .../wireless/microchip/wilc1000/cfg80211.h| 29 +++
 1 file changed, 29 insertions(+)
 create mode 100644 drivers/net/wireless/microchip/wilc1000/cfg80211.h

diff --git a/drivers/net/wireless/microchip/wilc1000/cfg80211.h 
b/drivers/net/wireless/microchip/wilc1000/cfg80211.h
new file mode 100644
index ..5e5d63f70df2
--- /dev/null
+++ b/drivers/net/wireless/microchip/wilc1000/cfg80211.h
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
+ * All rights reserved.
+ */
+
+#ifndef WILC_CFG80211_H
+#define WILC_CFG80211_H
+#include "netdev.h"
+
+struct wiphy *wilc_cfg_alloc(void);
+int wilc_cfg80211_init(struct wilc **wilc, struct device *dev, int io_type,
+  const struct wilc_hif_func *ops);
+struct wilc *wilc_create_wiphy(struct device *dev);
+void wilc_deinit_host_int(struct net_device *net);
+int wilc_init_host_int(struct net_device *net);
+void wilc_wfi_monitor_rx(struct net_device *mon_dev, u8 *buff, u32 size);
+struct wilc_vif *wilc_netdev_interface(struct wilc *wl, const char *name,
+  enum nl80211_iftype type);
+void wilc_wfi_deinit_mon_interface(struct wilc *wl, bool rtnl_locked);
+struct net_device *wilc_wfi_init_mon_interface(struct wilc *wl,
+  const char *name,
+  struct net_device *real_dev);
+void wilc_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev,
+ u16 frame_type, bool reg);
+struct wilc_vif *wilc_get_interface(struct wilc *wl);
+struct wilc_vif *wilc_get_wl_to_vif(struct wilc *wl);
+void wlan_deinit_locks(struct wilc *wilc);
+#endif
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 0/3] staging: wilc1000: correct Smatch warnings & use flexible-array member

2020-03-02 Thread Ajay.Kathat
From: Ajay Singh 

This patch series contains changes to address few Smatch static checker
reported warnings. Also added one patch to make use of flexible-array
member instead of zero-length array for few cases which were missed
earlier.

Ajay Singh (3):
  staging: wilc1000: use correct data for memcpy in
wilc_hif_pack_sta_param()
  staging: wilc1000: remove unnecessary always true 'if' conditions
  staging: wilc1000: use flexible-array member instead of zero-length
array

 drivers/staging/wilc1000/cfg80211.c | 26 --
 drivers/staging/wilc1000/hif.c  |  2 +-
 drivers/staging/wilc1000/spi.c  | 10 +-
 drivers/staging/wilc1000/wlan.c |  6 ++
 4 files changed, 20 insertions(+), 24 deletions(-)

-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


  1   2   3   4   >