Re: [PATCH] [v5] wireless: Initial driver submission for pureLiFi STA devices
Mostly trivial comments: >> Ok Thanks, I will address them
Re: [PATCH] [v5] wireless: Initial driver submission for pureLiFi STA devices
On Mon, 2020-10-19 at 08:47 +0530, Srinivasan Raju wrote: > This introduces the pureLiFi LiFi driver for LiFi-X, LiFi-XC > and LiFi-XL USB devices. Mostly trivial comments: > diff --git a/drivers/net/wireless/purelifi/chip.c > b/drivers/net/wireless/purelifi/chip.c [] > +int purelifi_chip_set_rate(struct purelifi_chip *chip, u8 rate) > +{ > + int r; > + static struct purelifi_chip *chip_p; Isn't chip_p pointless? > + > + if (chip) > + chip_p = chip; > + if (!chip_p) > + return -EINVAL; > + chip_p is otherwise unused. > diff --git a/drivers/net/wireless/purelifi/mac.c > b/drivers/net/wireless/purelifi/mac.c [] > +int purelifi_mac_init_hw(struct ieee80211_hw *hw) > +{ > + int r; > + struct purelifi_mac *mac = purelifi_hw_mac(hw); > + struct purelifi_chip *chip = >chip; > + > + r = purelifi_chip_init_hw(chip); > + if (r) { > + dev_warn(purelifi_mac_dev(mac), "init hw failed (%d)\n", r); > + goto out; > + } > + > + dev_dbg(purelifi_mac_dev(mac), "irq_disabled %d\n", irqs_disabled()); > + > + r = regulatory_hint(hw->wiphy, "CA"); > +out: > + return r; > +} Simpler without the out: label and a direct return if (r) { dev_warn(...) return r; } ... return regulator_hint(hw->wiphy, "CA"); } > +static int download_fpga(struct usb_interface *intf) > +{ [] > + if ((le16_to_cpu(udev->descriptor.idVendor) == > + PURELIFI_X_VENDOR_ID_0) && > + (le16_to_cpu(udev->descriptor.idProduct) == > + PURELIFI_X_PRODUCT_ID_0)) { > + fw_name = "purelifi/li_fi_x/fpga.bit"; > + dev_info(>dev, "bit file for X selected.\n"); > + > + } else if ((le16_to_cpu(udev->descriptor.idVendor)) == > + PURELIFI_XC_VENDOR_ID_0 && > +(le16_to_cpu(udev->descriptor.idProduct) == > + PURELIFI_XC_PRODUCT_ID_0)) { > + fw_name = "purelifi/li_fi_x/fpga_xc.bit"; > + dev_info(>dev, "bit filefor XC selected.\n"); Inconsistent dev_info spacing: "file for" vs "filefor" > + for (fw_data_i = 0; fw_data_i < fw->size;) { > + int tbuf_idx; > + > + if ((fw->size - fw_data_i) < blk_tran_len) > + blk_tran_len = fw->size - fw_data_i; > + > + fw_data = kmalloc(blk_tran_len, GFP_KERNEL); > + > + memcpy(fw_data, >data[fw_data_i], blk_tran_len); > + > + for (tbuf_idx = 0; tbuf_idx < blk_tran_len; tbuf_idx++) { > + fw_data[tbuf_idx] = > + ((fw_data[tbuf_idx] & 128) >> 7) | > + ((fw_data[tbuf_idx] & 64) >> 5) | > + ((fw_data[tbuf_idx] & 32) >> 3) | > + ((fw_data[tbuf_idx] & 16) >> 1) | > + ((fw_data[tbuf_idx] & 8) << 1) | > + ((fw_data[tbuf_idx] & 4) << 3) | > + ((fw_data[tbuf_idx] & 2) << 5) | > + ((fw_data[tbuf_idx] & 1) << 7); > + } pity there isn't an u8_bit_reverse function/mechanism > +static void pretty_print_mac(struct usb_interface *intf, char *serial_number, > + unsigned char *hw_address > + ) > +{ > + unsigned char i; > + > + for (i = 0; i < ETH_ALEN; i++) > + dev_info(>dev, "hw_address[%d]=%x\n", i, hw_address[i]); I don't think this prettier than %pM > +} > + > +static int upload_mac_and_serial_number(struct usb_interface *intf, > + unsigned char *hw_address, > + unsigned char *serial_number) > +{ [] > + do { > + unsigned char buf[8]; > + > + msleep(200); > + > + send_vendor_request(udev, 0x40, buf, sizeof(buf)); > + flash.enabled = buf[0] & 0xFF; > + > + if (flash.enabled) { > + flash.sectors = ((buf[6] & 255) << 24) | buf is unsigned char[], rather pointless using & 255 > diff --git a/drivers/net/wireless/purelifi/usb.h > b/drivers/net/wireless/purelifi/usb.h [] > +struct station_t { > + // 7...3|2 | 1 | 0 | > + // Reserved | Hearbeat | FIFO full | Connected | heartbeat
[PATCH] [v5] wireless: Initial driver submission for pureLiFi STA devices
This introduces the pureLiFi LiFi driver for LiFi-X, LiFi-XC and LiFi-XL USB devices. This driver implementation has been based on the zd1211rw driver. Driver is based on 802.11 softMAC Architecture and uses native 802.11 for configuration and management. The driver is compiled and tested in ARM, x86 architectures and compiled in powerpc architecture. Reported-by: kernel test robot Signed-off-by: Srinivasan Raju --- MAINTAINERS|5 + drivers/net/wireless/Kconfig |1 + drivers/net/wireless/Makefile |1 + drivers/net/wireless/purelifi/Kconfig | 27 + drivers/net/wireless/purelifi/Makefile |3 + drivers/net/wireless/purelifi/chip.c | 97 ++ drivers/net/wireless/purelifi/chip.h | 82 ++ drivers/net/wireless/purelifi/intf.h | 38 + drivers/net/wireless/purelifi/mac.c| 861 + drivers/net/wireless/purelifi/mac.h| 180 +++ drivers/net/wireless/purelifi/usb.c| 1637 drivers/net/wireless/purelifi/usb.h| 148 +++ 12 files changed, 3080 insertions(+) create mode 100644 drivers/net/wireless/purelifi/Kconfig create mode 100644 drivers/net/wireless/purelifi/Makefile create mode 100644 drivers/net/wireless/purelifi/chip.c create mode 100644 drivers/net/wireless/purelifi/chip.h create mode 100644 drivers/net/wireless/purelifi/intf.h create mode 100644 drivers/net/wireless/purelifi/mac.c create mode 100644 drivers/net/wireless/purelifi/mac.h create mode 100644 drivers/net/wireless/purelifi/usb.c create mode 100644 drivers/net/wireless/purelifi/usb.h diff --git a/MAINTAINERS b/MAINTAINERS index c80f87d7258c..150f592fb6e4 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14108,6 +14108,11 @@ T: git git://linuxtv.org/media_tree.git F: Documentation/admin-guide/media/pulse8-cec.rst F: drivers/media/cec/usb/pulse8/ +PUREILIFI USB DRIVER +M: Srinivasan Raju +S: Maintained +F: drivers/net/wireless/purelifi + PVRUSB2 VIDEO4LINUX DRIVER M: Mike Isely L: pvru...@isely.net (subscribers-only) diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig index 170a64e67709..b87da3139f94 100644 --- a/drivers/net/wireless/Kconfig +++ b/drivers/net/wireless/Kconfig @@ -48,6 +48,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/purelifi/Kconfig" config PCMCIA_RAYCS tristate "Aviator/Raytheon 2.4GHz wireless support" diff --git a/drivers/net/wireless/Makefile b/drivers/net/wireless/Makefile index 80b324499786..e9fc770026f0 100644 --- a/drivers/net/wireless/Makefile +++ b/drivers/net/wireless/Makefile @@ -20,6 +20,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_PURELIFI) += purelifi/ # 16-bit wireless PCMCIA client drivers obj-$(CONFIG_PCMCIA_RAYCS) += ray_cs.o diff --git a/drivers/net/wireless/purelifi/Kconfig b/drivers/net/wireless/purelifi/Kconfig new file mode 100644 index ..f6630791df9d --- /dev/null +++ b/drivers/net/wireless/purelifi/Kconfig @@ -0,0 +1,27 @@ +# SPDX-License-Identifier: GPL-2.0 +config WLAN_VENDOR_PURELIFI + bool "pureLiFi devices" + default y + help + If you have a pureLiFi device, 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_PURELIFI + +config PURELIFI + + tristate "pureLiFi device support" + depends on CFG80211 && MAC80211 && USB + help + This driver makes the adapter appear as a normal WLAN interface. + + The pureLiFi device requires external STA firmware to be loaded. + + To compile this driver as a module, choose M here: the module will + be called purelifi. + +endif # WLAN_VENDOR_PURELIFI diff --git a/drivers/net/wireless/purelifi/Makefile b/drivers/net/wireless/purelifi/Makefile new file mode 100644 index ..1f20055e741f --- /dev/null +++ b/drivers/net/wireless/purelifi/Makefile @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_PURELIFI) := purelifi.o +purelifi-objs += chip.o usb.o mac.o diff --git a/drivers/net/wireless/purelifi/chip.c b/drivers/net/wireless/purelifi/chip.c new file mode 100644 index ..cca03697cb06 --- /dev/null +++ b/drivers/net/wireless/purelifi/chip.c @@ -0,0 +1,97 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include + +#include "chip.h" +#include "mac.h" +#include "usb.h" + +void purelifi_chip_init(struct purelifi_chip *chip, +