Message ID | 1519046379-10068-6-git-send-email-amitkarwar@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Kalle Valo |
Headers | show |
Hi Prameela, Thank you for the patch! Yet something to improve: [auto build test ERROR on wireless-drivers-next/master] [also build test ERROR on v4.16-rc2 next-20180219] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Amitkumar-Karwar/rsi-add-rx-control-block-to-handle-rx-packets-in-USB/20180220-042908 base: https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git master config: ia64-allmodconfig (attached as .config) compiler: ia64-linux-gcc (GCC) 7.2.0 reproduce: 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 make.cross ARCH=ia64 All errors (new ones prefixed by >>): In file included from drivers/bluetooth/btrsi.c:21:0: >> include/linux/unaligned/le_byteshift.h:41:19: error: redefinition of 'get_unaligned_le16' static inline u16 get_unaligned_le16(const void *p) ^~~~~~~~~~~~~~~~~~ In file included from arch/ia64/include/asm/unaligned.h:5:0, from arch/ia64/include/asm/io.h:23, from arch/ia64/include/asm/smp.h:21, from include/linux/smp.h:64, from include/linux/topology.h:33, from include/linux/gfp.h:9, from include/linux/umh.h:4, from include/linux/kmod.h:22, from include/linux/module.h:13, from drivers/bluetooth/btrsi.c:17: include/linux/unaligned/le_struct.h:7:19: note: previous definition of 'get_unaligned_le16' was here static inline u16 get_unaligned_le16(const void *p) ^~~~~~~~~~~~~~~~~~ In file included from drivers/bluetooth/btrsi.c:21:0: >> include/linux/unaligned/le_byteshift.h:46:19: error: redefinition of 'get_unaligned_le32' static inline u32 get_unaligned_le32(const void *p) ^~~~~~~~~~~~~~~~~~ In file included from arch/ia64/include/asm/unaligned.h:5:0, from arch/ia64/include/asm/io.h:23, from arch/ia64/include/asm/smp.h:21, from include/linux/smp.h:64, from include/linux/topology.h:33, from include/linux/gfp.h:9, from include/linux/umh.h:4, from include/linux/kmod.h:22, from include/linux/module.h:13, from drivers/bluetooth/btrsi.c:17: include/linux/unaligned/le_struct.h:12:19: note: previous definition of 'get_unaligned_le32' was here static inline u32 get_unaligned_le32(const void *p) ^~~~~~~~~~~~~~~~~~ In file included from drivers/bluetooth/btrsi.c:21:0: >> include/linux/unaligned/le_byteshift.h:51:19: error: redefinition of 'get_unaligned_le64' static inline u64 get_unaligned_le64(const void *p) ^~~~~~~~~~~~~~~~~~ In file included from arch/ia64/include/asm/unaligned.h:5:0, from arch/ia64/include/asm/io.h:23, from arch/ia64/include/asm/smp.h:21, from include/linux/smp.h:64, from include/linux/topology.h:33, from include/linux/gfp.h:9, from include/linux/umh.h:4, from include/linux/kmod.h:22, from include/linux/module.h:13, from drivers/bluetooth/btrsi.c:17: include/linux/unaligned/le_struct.h:17:19: note: previous definition of 'get_unaligned_le64' was here static inline u64 get_unaligned_le64(const void *p) ^~~~~~~~~~~~~~~~~~ In file included from drivers/bluetooth/btrsi.c:21:0: >> include/linux/unaligned/le_byteshift.h:56:20: error: redefinition of 'put_unaligned_le16' static inline void put_unaligned_le16(u16 val, void *p) ^~~~~~~~~~~~~~~~~~ In file included from arch/ia64/include/asm/unaligned.h:5:0, from arch/ia64/include/asm/io.h:23, from arch/ia64/include/asm/smp.h:21, from include/linux/smp.h:64, from include/linux/topology.h:33, from include/linux/gfp.h:9, from include/linux/umh.h:4, from include/linux/kmod.h:22, from include/linux/module.h:13, from drivers/bluetooth/btrsi.c:17: include/linux/unaligned/le_struct.h:22:20: note: previous definition of 'put_unaligned_le16' was here static inline void put_unaligned_le16(u16 val, void *p) ^~~~~~~~~~~~~~~~~~ In file included from drivers/bluetooth/btrsi.c:21:0: >> include/linux/unaligned/le_byteshift.h:61:20: error: redefinition of 'put_unaligned_le32' static inline void put_unaligned_le32(u32 val, void *p) ^~~~~~~~~~~~~~~~~~ In file included from arch/ia64/include/asm/unaligned.h:5:0, from arch/ia64/include/asm/io.h:23, from arch/ia64/include/asm/smp.h:21, from include/linux/smp.h:64, from include/linux/topology.h:33, from include/linux/gfp.h:9, from include/linux/umh.h:4, from include/linux/kmod.h:22, from include/linux/module.h:13, from drivers/bluetooth/btrsi.c:17: include/linux/unaligned/le_struct.h:27:20: note: previous definition of 'put_unaligned_le32' was here static inline void put_unaligned_le32(u32 val, void *p) ^~~~~~~~~~~~~~~~~~ In file included from drivers/bluetooth/btrsi.c:21:0: >> include/linux/unaligned/le_byteshift.h:66:20: error: redefinition of 'put_unaligned_le64' static inline void put_unaligned_le64(u64 val, void *p) ^~~~~~~~~~~~~~~~~~ In file included from arch/ia64/include/asm/unaligned.h:5:0, from arch/ia64/include/asm/io.h:23, from arch/ia64/include/asm/smp.h:21, from include/linux/smp.h:64, from include/linux/topology.h:33, from include/linux/gfp.h:9, from include/linux/umh.h:4, from include/linux/kmod.h:22, from include/linux/module.h:13, from drivers/bluetooth/btrsi.c:17: include/linux/unaligned/le_struct.h:32:20: note: previous definition of 'put_unaligned_le64' was here static inline void put_unaligned_le64(u64 val, void *p) ^~~~~~~~~~~~~~~~~~ vim +/get_unaligned_le16 +41 include/linux/unaligned/le_byteshift.h 064106a9 Harvey Harrison 2008-04-29 40 064106a9 Harvey Harrison 2008-04-29 @41 static inline u16 get_unaligned_le16(const void *p) 064106a9 Harvey Harrison 2008-04-29 42 { 064106a9 Harvey Harrison 2008-04-29 43 return __get_unaligned_le16((const u8 *)p); 064106a9 Harvey Harrison 2008-04-29 44 } 064106a9 Harvey Harrison 2008-04-29 45 064106a9 Harvey Harrison 2008-04-29 @46 static inline u32 get_unaligned_le32(const void *p) 064106a9 Harvey Harrison 2008-04-29 47 { 064106a9 Harvey Harrison 2008-04-29 48 return __get_unaligned_le32((const u8 *)p); 064106a9 Harvey Harrison 2008-04-29 49 } 064106a9 Harvey Harrison 2008-04-29 50 064106a9 Harvey Harrison 2008-04-29 @51 static inline u64 get_unaligned_le64(const void *p) 064106a9 Harvey Harrison 2008-04-29 52 { 064106a9 Harvey Harrison 2008-04-29 53 return __get_unaligned_le64((const u8 *)p); 064106a9 Harvey Harrison 2008-04-29 54 } 064106a9 Harvey Harrison 2008-04-29 55 064106a9 Harvey Harrison 2008-04-29 @56 static inline void put_unaligned_le16(u16 val, void *p) 064106a9 Harvey Harrison 2008-04-29 57 { 064106a9 Harvey Harrison 2008-04-29 58 __put_unaligned_le16(val, p); 064106a9 Harvey Harrison 2008-04-29 59 } 064106a9 Harvey Harrison 2008-04-29 60 064106a9 Harvey Harrison 2008-04-29 @61 static inline void put_unaligned_le32(u32 val, void *p) 064106a9 Harvey Harrison 2008-04-29 62 { 064106a9 Harvey Harrison 2008-04-29 63 __put_unaligned_le32(val, p); 064106a9 Harvey Harrison 2008-04-29 64 } 064106a9 Harvey Harrison 2008-04-29 65 064106a9 Harvey Harrison 2008-04-29 @66 static inline void put_unaligned_le64(u64 val, void *p) 064106a9 Harvey Harrison 2008-04-29 67 { 064106a9 Harvey Harrison 2008-04-29 68 __put_unaligned_le64(val, p); 064106a9 Harvey Harrison 2008-04-29 69 } 064106a9 Harvey Harrison 2008-04-29 70 :::::: The code at line 41 was first introduced by commit :::::: 064106a91be5e76cb42c1ddf5d3871e3a1bd2a23 kernel: add common infrastructure for unaligned access :::::: TO: Harvey Harrison <harvey.harrison@gmail.com> :::::: CC: Linus Torvalds <torvalds@linux-foundation.org> --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig index 07e55cd..d8bbd66 100644 --- a/drivers/bluetooth/Kconfig +++ b/drivers/bluetooth/Kconfig @@ -392,4 +392,16 @@ config BT_QCOMSMD Say Y here to compile support for HCI over Qualcomm SMD into the kernel or say M to compile as a module. +config BT_HCIRSI + tristate "Redpine HCI support" + default n + select RSI_COEX + help + Redpine BT driver. + This driver handles BT traffic from upper layers and pass + to the RSI_91x coex module for further scheduling to device + + Say Y here to compile support for HCI over Redpine into the + kernel or say M to compile as a module. + endmenu diff --git a/drivers/bluetooth/Makefile b/drivers/bluetooth/Makefile index 4e4e44d..03cfc1b 100644 --- a/drivers/bluetooth/Makefile +++ b/drivers/bluetooth/Makefile @@ -28,6 +28,8 @@ obj-$(CONFIG_BT_QCA) += btqca.o obj-$(CONFIG_BT_HCIUART_NOKIA) += hci_nokia.o +obj-$(CONFIG_BT_HCIRSI) += btrsi.o + btmrvl-y := btmrvl_main.o btmrvl-$(CONFIG_DEBUG_FS) += btmrvl_debugfs.o diff --git a/drivers/bluetooth/btrsi.c b/drivers/bluetooth/btrsi.c new file mode 100644 index 0000000..803e045 --- /dev/null +++ b/drivers/bluetooth/btrsi.c @@ -0,0 +1,188 @@ +/** + * Copyright (c) 2017 Redpine Signals Inc. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ +#include <linux/version.h> +#include <linux/module.h> +#include <linux/kernel.h> +#include <net/bluetooth/bluetooth.h> +#include <net/bluetooth/hci_core.h> +#include <linux/unaligned/le_byteshift.h> +#include <net/rsi_91x.h> +#include <net/genetlink.h> + +#define RSI_HEADROOM_FOR_BT_HAL 16 +#define RSI_FRAME_DESC_SIZE 16 + +struct rsi_hci_adapter { + void *priv; + struct rsi_proto_ops *proto_ops; + struct hci_dev *hdev; +}; + +static int rsi_hci_open(struct hci_dev *hdev) +{ + return 0; +} + +static int rsi_hci_close(struct hci_dev *hdev) +{ + return 0; +} + +static int rsi_hci_flush(struct hci_dev *hdev) +{ + return 0; +} + +static int rsi_hci_send_pkt(struct hci_dev *hdev, struct sk_buff *skb) +{ + struct rsi_hci_adapter *h_adapter = hci_get_drvdata(hdev); + struct sk_buff *new_skb = NULL; + + switch (hci_skb_pkt_type(skb)) { + case HCI_COMMAND_PKT: + hdev->stat.cmd_tx++; + break; + case HCI_ACLDATA_PKT: + hdev->stat.acl_tx++; + break; + case HCI_SCODATA_PKT: + hdev->stat.sco_tx++; + break; + } + + if (skb_headroom(skb) < RSI_HEADROOM_FOR_BT_HAL) { + /* Insufficient skb headroom - allocate a new skb */ + new_skb = skb_realloc_headroom(skb, RSI_HEADROOM_FOR_BT_HAL); + if (unlikely(!new_skb)) + return -ENOMEM; + bt_cb(new_skb)->pkt_type = hci_skb_pkt_type(skb); + kfree_skb(skb); + skb = new_skb; + } + + return h_adapter->proto_ops->coex_send_pkt(h_adapter->priv, skb, + RSI_BT_Q); +} + +static int rsi_hci_recv_pkt(void *priv, const u8 *pkt) +{ + struct rsi_hci_adapter *h_adapter = priv; + struct hci_dev *hdev = h_adapter->hdev; + struct sk_buff *skb; + int pkt_len = get_unaligned_le16(pkt) & 0x0fff; + + skb = dev_alloc_skb(pkt_len); + if (!skb) + return -ENOMEM; + + memcpy(skb->data, pkt + RSI_FRAME_DESC_SIZE, pkt_len); + skb_put(skb, pkt_len); + h_adapter->hdev->stat.byte_rx += skb->len; + + hci_skb_pkt_type(skb) = pkt[14]; + + return hci_recv_frame(hdev, skb); +} + +static int rsi_hci_attach(void *priv, struct rsi_proto_ops *ops) +{ + struct rsi_hci_adapter *h_adapter = NULL; + struct hci_dev *hdev; + int err = 0; + + h_adapter = kzalloc(sizeof(*h_adapter), GFP_KERNEL); + if (!h_adapter) + return -ENOMEM; + + h_adapter->priv = priv; + ops->set_bt_context(priv, h_adapter); + h_adapter->proto_ops = ops; + + hdev = hci_alloc_dev(); + if (!hdev) { + BT_ERR("Failed to alloc HCI device"); + goto err; + } + + h_adapter->hdev = hdev; + + if (ops->get_host_intf(priv) == RSI_HOST_INTF_SDIO) + hdev->bus = HCI_SDIO; + else + hdev->bus = HCI_USB; + + hci_set_drvdata(hdev, h_adapter); + hdev->dev_type = HCI_PRIMARY; + hdev->open = rsi_hci_open; + hdev->close = rsi_hci_close; + hdev->flush = rsi_hci_flush; + hdev->send = rsi_hci_send_pkt; + + err = hci_register_dev(hdev); + if (err < 0) { + BT_ERR("HCI registration failed with errcode %d", err); + hci_free_dev(hdev); + goto err; + } + + return 0; +err: + h_adapter->hdev = NULL; + kfree(h_adapter); + return -EINVAL; +} + +static void rsi_hci_detach(void *priv) +{ + struct rsi_hci_adapter *h_adapter = priv; + struct hci_dev *hdev; + + if (!h_adapter) + return; + + hdev = h_adapter->hdev; + if (hdev) { + hci_unregister_dev(hdev); + hci_free_dev(hdev); + h_adapter->hdev = NULL; + } + + kfree(h_adapter); +} + +const struct rsi_mod_ops rsi_bt_ops = { + .attach = rsi_hci_attach, + .detach = rsi_hci_detach, + .recv_pkt = rsi_hci_recv_pkt, +}; +EXPORT_SYMBOL(rsi_bt_ops); + +static int rsi_91x_bt_module_init(void) +{ + return 0; +} + +static void rsi_91x_bt_module_exit(void) +{ + return; +} + +module_init(rsi_91x_bt_module_init); +module_exit(rsi_91x_bt_module_exit); +MODULE_AUTHOR("Redpine Signals Inc"); +MODULE_DESCRIPTION("RSI BT driver"); +MODULE_SUPPORTED_DEVICE("RSI-BT"); +MODULE_LICENSE("Dual BSD/GPL"); diff --git a/include/net/rsi_91x.h b/include/net/rsi_91x.h index 737ab4e..040f07b 100644 --- a/include/net/rsi_91x.h +++ b/include/net/rsi_91x.h @@ -49,6 +49,8 @@ struct rsi_proto_ops { struct rsi_mod_ops { int (*attach)(void *priv, struct rsi_proto_ops *ops); void (*detach)(void *priv); - int (*recv_pkt)(void *priv, u8 *msg); + int (*recv_pkt)(void *priv, const u8 *msg); }; + +extern const struct rsi_mod_ops rsi_bt_ops; #endif