From 73eb7e6a0f1626334b773efeff7a71425b030754 Mon Sep 17 00:00:00 2001 From: Ed Beroset Date: Mon, 9 Oct 2023 17:48:28 -0400 Subject: [PATCH] catfish: Add bluetooth_6lowpan This is intended to be a first step to implementing a generic data transfer profile over Bluetooth as described here: https://github.com/AsteroidOS/asteroid-btsyncd/issues/22 Signed-off-by: Ed Beroset --- ..._6LOWPAN-option-to-bluetooth-Kconfig.patch | 30 ++ ...estore-bluetooth_6lowpan-to-Makefile.patch | 27 ++ ...009-Move-const-to-the-right-location.patch | 27 ++ ...dule.h-copy-__init-__exit-attrs-to-i.patch | 78 +++++ ...ributes-add-support-for-__copy-gcc-9.patch | 99 ++++++ ...0012-Fix-alignment-of-struct-members.patch | 55 ++++ ...3-Apply-many-small-fixes-for-6lowpan.patch | 283 ++++++++++++++++++ .../linux/linux-catfish/defconfig | 3 +- .../recipes-kernel/linux/linux-catfish_p.bb | 27 +- 9 files changed, 618 insertions(+), 11 deletions(-) create mode 100644 meta-catfish/recipes-kernel/linux/linux-catfish/0007-Add-missing-BT_6LOWPAN-option-to-bluetooth-Kconfig.patch create mode 100644 meta-catfish/recipes-kernel/linux/linux-catfish/0008-Restore-bluetooth_6lowpan-to-Makefile.patch create mode 100644 meta-catfish/recipes-kernel/linux/linux-catfish/0009-Move-const-to-the-right-location.patch create mode 100644 meta-catfish/recipes-kernel/linux/linux-catfish/0010-include-linux-module.h-copy-__init-__exit-attrs-to-i.patch create mode 100644 meta-catfish/recipes-kernel/linux/linux-catfish/0011-Compiler-Attributes-add-support-for-__copy-gcc-9.patch create mode 100644 meta-catfish/recipes-kernel/linux/linux-catfish/0012-Fix-alignment-of-struct-members.patch create mode 100644 meta-catfish/recipes-kernel/linux/linux-catfish/0013-Apply-many-small-fixes-for-6lowpan.patch diff --git a/meta-catfish/recipes-kernel/linux/linux-catfish/0007-Add-missing-BT_6LOWPAN-option-to-bluetooth-Kconfig.patch b/meta-catfish/recipes-kernel/linux/linux-catfish/0007-Add-missing-BT_6LOWPAN-option-to-bluetooth-Kconfig.patch new file mode 100644 index 00000000..7a80664c --- /dev/null +++ b/meta-catfish/recipes-kernel/linux/linux-catfish/0007-Add-missing-BT_6LOWPAN-option-to-bluetooth-Kconfig.patch @@ -0,0 +1,30 @@ +From 3ef5cd9eece497e5af800a66a6a2beb2e45c1f15 Mon Sep 17 00:00:00 2001 +From: Ed Beroset +Date: Fri, 6 Oct 2023 11:59:35 -0400 +Subject: [PATCH] Add missing BT_6LOWPAN option to bluetooth Kconfig + +This adds the BT_6LOWPAN option back in. It may have been deleted by +accident. + +Signed-off-by: Ed Beroset +--- + net/bluetooth/Kconfig | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/net/bluetooth/Kconfig b/net/bluetooth/Kconfig +index 81f837f6d934..b8c794b87523 100644 +--- a/net/bluetooth/Kconfig ++++ b/net/bluetooth/Kconfig +@@ -58,6 +58,12 @@ config BT_LE + depends on BT + default y + ++config BT_6LOWPAN ++ tristate "Bluetooth 6LoWPAN support" ++ depends on BT_LE && 6LOWPAN ++ help ++ IPv6 compression over Bluetooth Low Energy. ++ + config BT_SELFTEST + bool "Bluetooth self testing support" + depends on BT && DEBUG_KERNEL diff --git a/meta-catfish/recipes-kernel/linux/linux-catfish/0008-Restore-bluetooth_6lowpan-to-Makefile.patch b/meta-catfish/recipes-kernel/linux/linux-catfish/0008-Restore-bluetooth_6lowpan-to-Makefile.patch new file mode 100644 index 00000000..fe53fcdb --- /dev/null +++ b/meta-catfish/recipes-kernel/linux/linux-catfish/0008-Restore-bluetooth_6lowpan-to-Makefile.patch @@ -0,0 +1,27 @@ +From 34215ae8e5e5edbaed72b120b167b2b6f120cd2b Mon Sep 17 00:00:00 2001 +From: Ed Beroset +Date: Fri, 6 Oct 2023 12:08:29 -0400 +Subject: [PATCH] Restore bluetooth_6lowpan to Makefile + +I'm not sure why or how this was removed, but it's required for using +6lowpan over Bluetooth. + +Signed-off-by: Ed Beroset +--- + net/bluetooth/Makefile | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/net/bluetooth/Makefile b/net/bluetooth/Makefile +index c85a6afc6fe1..9a8ea232d28f 100644 +--- a/net/bluetooth/Makefile ++++ b/net/bluetooth/Makefile +@@ -7,6 +7,9 @@ obj-$(CONFIG_BT_RFCOMM) += rfcomm/ + obj-$(CONFIG_BT_BNEP) += bnep/ + obj-$(CONFIG_BT_CMTP) += cmtp/ + obj-$(CONFIG_BT_HIDP) += hidp/ ++obj-$(CONFIG_BT_6LOWPAN) += bluetooth_6lowpan.o ++ ++bluetooth_6lowpan-y := 6lowpan.o + + bluetooth-y := af_bluetooth.o hci_core.o hci_conn.o hci_event.o mgmt.o \ + hci_sock.o hci_sysfs.o l2cap_core.o l2cap_sock.o smp.o sco.o lib.o \ diff --git a/meta-catfish/recipes-kernel/linux/linux-catfish/0009-Move-const-to-the-right-location.patch b/meta-catfish/recipes-kernel/linux/linux-catfish/0009-Move-const-to-the-right-location.patch new file mode 100644 index 00000000..a242d9c0 --- /dev/null +++ b/meta-catfish/recipes-kernel/linux/linux-catfish/0009-Move-const-to-the-right-location.patch @@ -0,0 +1,27 @@ +From 36893966a1b412a67fcd50cb4979d1ca5ed23bdc Mon Sep 17 00:00:00 2001 +From: Ed Beroset +Date: Fri, 6 Oct 2023 21:04:29 -0400 +Subject: [PATCH] Move const to the right location + +This fixes a small bug in the code in which a duplicate const +declaration was apparently intended to be a const pointer to a const +location. + +Signed-off-by: Ed Beroset +--- + include/linux/msm_mhi.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/include/linux/msm_mhi.h b/include/linux/msm_mhi.h +index 08dc3a23abfa..a5ffa23a32d0 100644 +--- a/include/linux/msm_mhi.h ++++ b/include/linux/msm_mhi.h +@@ -107,7 +107,7 @@ struct mhi_cb_info { + + struct mhi_client_info_t { + enum MHI_CLIENT_CHANNEL chan; +- const struct device const *dev; ++ const struct device * const dev; + const char *node_name; + void (*mhi_client_cb)(struct mhi_cb_info *); + bool pre_allocate; diff --git a/meta-catfish/recipes-kernel/linux/linux-catfish/0010-include-linux-module.h-copy-__init-__exit-attrs-to-i.patch b/meta-catfish/recipes-kernel/linux/linux-catfish/0010-include-linux-module.h-copy-__init-__exit-attrs-to-i.patch new file mode 100644 index 00000000..9e59a2a8 --- /dev/null +++ b/meta-catfish/recipes-kernel/linux/linux-catfish/0010-include-linux-module.h-copy-__init-__exit-attrs-to-i.patch @@ -0,0 +1,78 @@ +From f9981ae000018596f86f6c4ecbda34aef0253e2d Mon Sep 17 00:00:00 2001 +From: Miguel Ojeda +Date: Wed, 6 Feb 2019 18:56:27 +0100 +Subject: [PATCH] include/linux/module.h: copy __init/__exit attrs to + init/cleanup_module + +The upcoming GCC 9 release extends the -Wmissing-attributes warnings +(enabled by -Wall) to C and aliases: it warns when particular function +attributes are missing in the aliases but not in their target. + +In particular, it triggers for all the init/cleanup_module +aliases in the kernel (defined by the module_init/exit macros), +ending up being very noisy. + +These aliases point to the __init/__exit functions of a module, +which are defined as __cold (among other attributes). However, +the aliases themselves do not have the __cold attribute. + +Since the compiler behaves differently when compiling a __cold +function as well as when compiling paths leading to calls +to __cold functions, the warning is trying to point out +the possibly-forgotten attribute in the alias. + +In order to keep the warning enabled, we decided to silence +this case. Ideally, we would mark the aliases directly +as __init/__exit. However, there are currently around 132 modules +in the kernel which are missing __init/__exit in their init/cleanup +functions (either because they are missing, or for other reasons, +e.g. the functions being called from somewhere else); and +a section mismatch is a hard error. + +A conservative alternative was to mark the aliases as __cold only. +However, since we would like to eventually enforce __init/__exit +to be always marked, we chose to use the new __copy function +attribute (introduced by GCC 9 as well to deal with this). +With it, we copy the attributes used by the target functions +into the aliases. This way, functions that were not marked +as __init/__exit won't have their aliases marked either, +and therefore there won't be a section mismatch. + +Note that the warning would go away marking either the extern +declaration, the definition, or both. However, we only mark +the definition of the alias, since we do not want callers +(which only see the declaration) to be compiled as if the function +was __cold (and therefore the paths leading to those calls +would be assumed to be unlikely). + +Link: https://lore.kernel.org/lkml/20190123173707.GA16603@gmail.com/ +Link: https://lore.kernel.org/lkml/20190206175627.GA20399@gmail.com/ +Suggested-by: Martin Sebor +Acked-by: Jessica Yu +Signed-off-by: Miguel Ojeda + +Signed-off-by: Ed Beroset +--- + include/linux/init.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/include/linux/init.h b/include/linux/init.h +index 28ec4d128413..d68791117bd9 100644 +--- a/include/linux/init.h ++++ b/include/linux/init.h +@@ -331,13 +331,13 @@ void __init parse_early_options(char *cmdline); + #define module_init(initfn) \ + static inline initcall_t __inittest(void) \ + { return initfn; } \ +- int init_module(void) __attribute__((alias(#initfn))); ++ int init_module(void) __copy(initfn) __attribute__((alias(#initfn))); + + /* This is only required if you want to be unloadable. */ + #define module_exit(exitfn) \ + static inline exitcall_t __exittest(void) \ + { return exitfn; } \ +- void cleanup_module(void) __attribute__((alias(#exitfn))); ++ void cleanup_module(void) __copy(exitfn) __attribute__((alias(#exitfn))); + + #define __setup_param(str, unique_id, fn) /* nothing */ + #define __setup(str, func) /* nothing */ diff --git a/meta-catfish/recipes-kernel/linux/linux-catfish/0011-Compiler-Attributes-add-support-for-__copy-gcc-9.patch b/meta-catfish/recipes-kernel/linux/linux-catfish/0011-Compiler-Attributes-add-support-for-__copy-gcc-9.patch new file mode 100644 index 00000000..73606e95 --- /dev/null +++ b/meta-catfish/recipes-kernel/linux/linux-catfish/0011-Compiler-Attributes-add-support-for-__copy-gcc-9.patch @@ -0,0 +1,99 @@ +From b97a52261d797f2731178416dafbad4d26dd0bf5 Mon Sep 17 00:00:00 2001 +From: Miguel Ojeda +Date: Fri, 6 Oct 2023 22:27:17 -0400 +Subject: [PATCH] Compiler Attributes: add support for __copy (gcc >= 9) +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From the GCC manual: + + copy + copy(function) + + The copy attribute applies the set of attributes with which function + has been declared to the declaration of the function to which + the attribute is applied. The attribute is designed for libraries + that define aliases or function resolvers that are expected + to specify the same set of attributes as their targets. The copy + attribute can be used with functions, variables, or types. However, + the kind of symbol to which the attribute is applied (either + function or variable) must match the kind of symbol to which + the argument refers. The copy attribute copies only syntactic and + semantic attributes but not attributes that affect a symbol’s + linkage or visibility such as alias, visibility, or weak. + The deprecated attribute is also not copied. + + https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html + +The upcoming GCC 9 release extends the -Wmissing-attributes warnings +(enabled by -Wall) to C and aliases: it warns when particular function +attributes are missing in the aliases but not in their target, e.g.: + + void __cold f(void) {} + void __alias("f") g(void); + +diagnoses: + + warning: 'g' specifies less restrictive attribute than + its target 'f': 'cold' [-Wmissing-attributes] + +Using __copy(f) we can copy the __cold attribute from f to g: + + void __cold f(void) {} + void __copy(f) __alias("f") g(void); + +This attribute is most useful to deal with situations where an alias +is declared but we don't know the exact attributes the target has. + +For instance, in the kernel, the widely used module_init/exit macros +define the init/cleanup_module aliases, but those cannot be marked +always as __init/__exit since some modules do not have their +functions marked as such. + +Suggested-by: Martin Sebor +Reviewed-by: Nick Desaulniers +Signed-off-by: Miguel Ojeda + +Link: https://github.com/torvalds/linux/commit/c0d9782f5b6d7157635ae2fd782a4b27d55a6013 +Link: https://github.com/ojeda/linux/commit/8803fd49f7f86efa39b60957c74ccf98690ae2ab + +Signed-off-by: Ed Beroset +--- + include/linux/compiler.h | 23 +++++++++++++++++++++++ + 1 file changed, 23 insertions(+) + +diff --git a/include/linux/compiler.h b/include/linux/compiler.h +index 4c981adac770..682e8c0a95e5 100644 +--- a/include/linux/compiler.h ++++ b/include/linux/compiler.h +@@ -50,6 +50,29 @@ extern void __chk_io_ptr(const volatile void __iomem *); + + #ifdef __KERNEL__ + ++/* ++ * Minimal backport of compiler_attributes.h to add support for __copy ++ * to v4.9.y so that we can use it in init/exit_module to avoid ++ * -Werror=missing-attributes errors on GCC 9. ++ */ ++#ifndef __has_attribute ++# define __has_attribute(x) __GCC4_has_attribute_##x ++# define __GCC4_has_attribute___copy__ 0 ++#endif ++ ++/* ++ * Optional: only supported since gcc >= 9 ++ * Optional: not supported by clang ++ * Optional: not supported by icc ++ * ++ * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-copy-function-attribute ++ */ ++#if __has_attribute(__copy__) ++# define __copy(symbol) __attribute__((__copy__(symbol))) ++#else ++# define __copy(symbol) ++#endif ++ + #ifdef __GNUC__ + #include + #endif diff --git a/meta-catfish/recipes-kernel/linux/linux-catfish/0012-Fix-alignment-of-struct-members.patch b/meta-catfish/recipes-kernel/linux/linux-catfish/0012-Fix-alignment-of-struct-members.patch new file mode 100644 index 00000000..e223dc6d --- /dev/null +++ b/meta-catfish/recipes-kernel/linux/linux-catfish/0012-Fix-alignment-of-struct-members.patch @@ -0,0 +1,55 @@ +From 639c2a5098e96b510f7330e3084137bec0613985 Mon Sep 17 00:00:00 2001 +From: Ed Beroset +Date: Sat, 7 Oct 2023 11:42:34 -0400 +Subject: [PATCH] Fix alignment of struct members + +With newer versions (>9) of gcc, the compiler correctly warns that +"taking address of packed member of 'struct diag_mempool_t' may result +in an unaligned pointer value [-Waddress-of-packed-member]." + +A similar warning comes up for dci_pkt_req_entry_t. + +This removes the __packed attribute from both structs to address that +problem. + +Signed-off-by: Ed Beroset +--- + drivers/char/diag/diag_dci.h | 4 ++-- + drivers/char/diag/diagmem.h | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/drivers/char/diag/diag_dci.h b/drivers/char/diag/diag_dci.h +index a9e2d35cc50a..bf988c5fff23 100644 +--- a/drivers/char/diag/diag_dci.h ++++ b/drivers/char/diag/diag_dci.h +@@ -95,7 +95,7 @@ struct dci_pkt_req_entry_t { + int uid; + int tag; + struct list_head track; +-} __packed; ++}; + + struct diag_dci_reg_tbl_t { + int client_id; +@@ -164,7 +164,7 @@ struct diag_dci_health_stats_proc { + int client_id; + struct diag_dci_health_stats health; + int proc; +-} __packed; ++}; + + struct diag_dci_peripherals_t { + int proc; +diff --git a/drivers/char/diag/diagmem.h b/drivers/char/diag/diagmem.h +index d097a3799e9a..77ef3003559e 100644 +--- a/drivers/char/diag/diagmem.h ++++ b/drivers/char/diag/diagmem.h +@@ -50,7 +50,7 @@ struct diag_mempool_t { + unsigned int poolsize; + int count; + spinlock_t lock; +-} __packed; ++}; + + extern struct diag_mempool_t diag_mempools[NUM_MEMORY_POOLS]; + diff --git a/meta-catfish/recipes-kernel/linux/linux-catfish/0013-Apply-many-small-fixes-for-6lowpan.patch b/meta-catfish/recipes-kernel/linux/linux-catfish/0013-Apply-many-small-fixes-for-6lowpan.patch new file mode 100644 index 00000000..b9c77f7d --- /dev/null +++ b/meta-catfish/recipes-kernel/linux/linux-catfish/0013-Apply-many-small-fixes-for-6lowpan.patch @@ -0,0 +1,283 @@ +From cb018b6be3a09401946cacce563b51911c0c3e99 Mon Sep 17 00:00:00 2001 +From: Ed Beroset +Date: Sun, 8 Oct 2023 09:07:23 -0400 +Subject: [PATCH] Apply many small fixes for 6lowpan + +This applies a number of small fixes that are mostly from others but +don't apply cleanly to this kernel. They include: + +Link: https://github.com/torvalds/linux/commit/f8b361768ea2eaf9b21dfbe7388958ec31798c8b + +Signed-off-by: Ed Beroset +--- + drivers/mmc/core/sdio_io.c | 0 + .../staging/android/ion/ion_carveout_heap.c | 0 + include/linux/mmc/sdio_func.h | 0 + include/net/6lowpan.h | 4 +- + net/6lowpan/iphc.c | 43 +++------------- + net/bluetooth/6lowpan.c | 8 +-- + net/bluetooth/hci_event.c | 0 + net/ieee802154/6lowpan_rtnl.c | 51 +++++++++++-------- + scripts/Makefile.fwinst | 2 +- + 9 files changed, 46 insertions(+), 62 deletions(-) + mode change 100755 => 100644 drivers/mmc/core/sdio_io.c + mode change 100755 => 100644 drivers/staging/android/ion/ion_carveout_heap.c + mode change 100755 => 100644 include/linux/mmc/sdio_func.h + mode change 100755 => 100644 net/bluetooth/hci_event.c + +diff --git a/drivers/mmc/core/sdio_io.c b/drivers/mmc/core/sdio_io.c +old mode 100755 +new mode 100644 +diff --git a/drivers/staging/android/ion/ion_carveout_heap.c b/drivers/staging/android/ion/ion_carveout_heap.c +old mode 100755 +new mode 100644 +diff --git a/include/linux/mmc/sdio_func.h b/include/linux/mmc/sdio_func.h +old mode 100755 +new mode 100644 +diff --git a/include/net/6lowpan.h b/include/net/6lowpan.h +index d184df1d0d41..45035ae1413a 100644 +--- a/include/net/6lowpan.h ++++ b/include/net/6lowpan.h +@@ -374,10 +374,10 @@ lowpan_uncompress_size(const struct sk_buff *skb, u16 *dgram_offset) + + typedef int (*skb_delivery_cb)(struct sk_buff *skb, struct net_device *dev); + +-int lowpan_process_data(struct sk_buff *skb, struct net_device *dev, ++int lowpan_header_decompress(struct sk_buff *skb, struct net_device *dev, + const u8 *saddr, const u8 saddr_type, const u8 saddr_len, + const u8 *daddr, const u8 daddr_type, const u8 daddr_len, +- u8 iphc0, u8 iphc1, skb_delivery_cb skb_deliver); ++ u8 iphc0, u8 iphc1); + int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev, + unsigned short type, const void *_daddr, + const void *_saddr, unsigned int len); +diff --git a/net/6lowpan/iphc.c b/net/6lowpan/iphc.c +index 142eef55c9e2..5370da0a651d 100644 +--- a/net/6lowpan/iphc.c ++++ b/net/6lowpan/iphc.c +@@ -171,37 +171,6 @@ static int uncompress_context_based_src_addr(struct sk_buff *skb, + return 0; + } + +-static int skb_deliver(struct sk_buff *skb, struct ipv6hdr *hdr, +- struct net_device *dev, skb_delivery_cb deliver_skb) +-{ +- struct sk_buff *new; +- int stat; +- +- new = skb_copy_expand(skb, sizeof(struct ipv6hdr), skb_tailroom(skb), +- GFP_ATOMIC); +- kfree_skb(skb); +- +- if (!new) +- return -ENOMEM; +- +- skb_push(new, sizeof(struct ipv6hdr)); +- skb_reset_network_header(new); +- skb_copy_to_linear_data(new, hdr, sizeof(struct ipv6hdr)); +- +- new->protocol = htons(ETH_P_IPV6); +- new->pkt_type = PACKET_HOST; +- new->dev = dev; +- +- raw_dump_table(__func__, "raw skb data dump before receiving", +- new->data, new->len); +- +- stat = deliver_skb(new, dev); +- +- kfree_skb(new); +- +- return stat; +-} +- + /* Uncompress function for multicast destination address, + * when M bit is set. + */ +@@ -332,10 +301,10 @@ err: + /* TTL uncompression values */ + static const u8 lowpan_ttl_values[] = { 0, 1, 64, 255 }; + +-int lowpan_process_data(struct sk_buff *skb, struct net_device *dev, ++int lowpan_header_decompress(struct sk_buff *skb, struct net_device *dev, + const u8 *saddr, const u8 saddr_type, const u8 saddr_len, + const u8 *daddr, const u8 daddr_type, const u8 daddr_len, +- u8 iphc0, u8 iphc1, skb_delivery_cb deliver_skb) ++ u8 iphc0, u8 iphc1) + { + struct ipv6hdr hdr = {}; + u8 tmp, num_context = 0; +@@ -497,15 +466,19 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev, + hdr.version, ntohs(hdr.payload_len), hdr.nexthdr, + hdr.hop_limit, &hdr.daddr); + ++ skb_push(skb, sizeof(hdr)); ++ skb_reset_network_header(skb); ++ skb_copy_to_linear_data(skb, &hdr, sizeof(hdr)); ++ + raw_dump_table(__func__, "raw header dump", (u8 *)&hdr, sizeof(hdr)); + +- return skb_deliver(skb, &hdr, dev, deliver_skb); ++ return 0; + + drop: + kfree_skb(skb); + return -EINVAL; + } +-EXPORT_SYMBOL_GPL(lowpan_process_data); ++EXPORT_SYMBOL_GPL(lowpan_header_decompress); + + static u8 lowpan_compress_addr_64(u8 **hc_ptr, u8 shift, + const struct in6_addr *ipaddr, +diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c +index 1742b849fcff..77ebf5639196 100644 +--- a/net/bluetooth/6lowpan.c ++++ b/net/bluetooth/6lowpan.c +@@ -532,12 +532,12 @@ static int send_pkt(struct l2cap_chan *chan, struct sk_buff *skb, + */ + chan->data = skb; + ++ memset(&msg, 0, sizeof(msg)); ++ msg.msg_iov = (struct iovec *) &iv; ++ msg.msg_iovlen = 1; + iv.iov_base = skb->data; + iv.iov_len = skb->len; +- +- memset(&msg, 0, sizeof(msg)); +- iov_iter_kvec(&msg.msg_iter, WRITE | ITER_KVEC, &iv, 1, skb->len); +- ++ + err = l2cap_chan_send(chan, &msg, skb->len); + if (err > 0) { + netdev->stats.tx_bytes += err; +diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c +old mode 100755 +new mode 100644 +diff --git a/net/ieee802154/6lowpan_rtnl.c b/net/ieee802154/6lowpan_rtnl.c +index 44136297b673..fe646b1ec6ba 100644 +--- a/net/ieee802154/6lowpan_rtnl.c ++++ b/net/ieee802154/6lowpan_rtnl.c +@@ -140,24 +140,33 @@ static int lowpan_give_skb_to_devices(struct sk_buff *skb, + struct sk_buff *skb_cp; + int stat = NET_RX_SUCCESS; + ++ skb->protocol = htons(ETH_P_IPV6); ++ skb->pkt_type = PACKET_HOST; ++ + rcu_read_lock(); + list_for_each_entry_rcu(entry, &lowpan_devices, list) + if (lowpan_dev_info(entry->ldev)->real_dev == skb->dev) { + skb_cp = skb_copy(skb, GFP_ATOMIC); + if (!skb_cp) { +- stat = -ENOMEM; +- break; ++ kfree_skb(skb); ++ rcu_read_unlock(); ++ return NET_RX_DROP; + } + + skb_cp->dev = entry->ldev; + stat = netif_rx(skb_cp); ++ if (stat == NET_RX_DROP) ++ break; + } + rcu_read_unlock(); + ++ consume_skb(skb); ++ + return stat; + } + +-static int process_data(struct sk_buff *skb, const struct ieee802154_hdr *hdr) ++static int ++iphc_decompress(struct sk_buff *skb, const struct ieee802154_hdr *hdr) + { + u8 iphc0, iphc1; + struct ieee802154_addr_sa sa, da; +@@ -187,10 +196,9 @@ static int process_data(struct sk_buff *skb, const struct ieee802154_hdr *hdr) + else + dap = &da.hwaddr; + +- return lowpan_process_data(skb, skb->dev, sap, sa.addr_type, ++ return lowpan_header_decompress(skb, skb->dev, sap, sa.addr_type, + IEEE802154_ADDR_LEN, dap, da.addr_type, +- IEEE802154_ADDR_LEN, iphc0, iphc1, +- lowpan_give_skb_to_devices); ++ IEEE802154_ADDR_LEN, iphc0, iphc1); + + drop: + kfree_skb(skb); +@@ -523,44 +531,47 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev, + + /* check that it's our buffer */ + if (skb->data[0] == LOWPAN_DISPATCH_IPV6) { +- skb->protocol = htons(ETH_P_IPV6); +- skb->pkt_type = PACKET_HOST; +- + /* Pull off the 1-byte of 6lowpan header. */ + skb_pull(skb, 1); +- +- ret = lowpan_give_skb_to_devices(skb, NULL); +- if (ret == NET_RX_DROP) +- goto drop; ++ return lowpan_give_skb_to_devices(skb, NULL); + } else { + switch (skb->data[0] & 0xe0) { + case LOWPAN_DISPATCH_IPHC: /* ipv6 datagram */ +- ret = process_data(skb, &hdr); ++ ret = iphc_decompress(skb, &hdr); + if (ret == NET_RX_DROP) + goto drop; +- break; ++ return lowpan_give_skb_to_devics(skb, NULL); + case LOWPAN_DISPATCH_FRAG1: /* first fragment header */ + ret = lowpan_frag_rcv(skb, LOWPAN_DISPATCH_FRAG1); + if (ret == 1) { +- ret = process_data(skb, &hdr); ++ ret = iphc_decompress(skb, &hdr); + if (ret == NET_RX_DROP) + goto drop; ++ ++ return lowpan_give_skb_to_devics(skb, NULL); ++ } else if (ret == -1) { ++ return NET_RX_DROP; ++ } else { ++ return NET_RX_SUCCESS; + } +- break; + case LOWPAN_DISPATCH_FRAGN: /* next fragments headers */ + ret = lowpan_frag_rcv(skb, LOWPAN_DISPATCH_FRAGN); + if (ret == 1) { +- ret = process_data(skb, &hdr); ++ ret = iphc_decompress(skb, &hdr); + if (ret == NET_RX_DROP) + goto drop; ++ ++ return lowpan_give_skb_to_devics(skb, NULL); ++ } else if (ret == -1) { ++ return NET_RX_DROP; ++ } else { ++ return NET_RX_SUCCESS; + } +- break; + default: + break; + } + } + +- return NET_RX_SUCCESS; + drop_skb: + kfree_skb(skb); + drop: +diff --git a/scripts/Makefile.fwinst b/scripts/Makefile.fwinst +index 5b698add4f31..a2e75037bcda 100644 +--- a/scripts/Makefile.fwinst ++++ b/scripts/Makefile.fwinst +@@ -38,7 +38,7 @@ installed-mod-fw := $(addprefix $(INSTALL_FW_PATH)/,$(mod-fw)) + installed-fw := $(addprefix $(INSTALL_FW_PATH)/,$(fw-shipped-all)) + + quiet_cmd_install = INSTALL $(subst $(srctree)/,,$@) +- cmd_install = mkdir -p $(@D); $(INSTALL) -m0644 $< $@ ++ cmd_install = mkdir -p $(@D); $(INSTALL) -m 0644 $< $@ + + $(installed-fw): $(INSTALL_FW_PATH)/%: $(obj)/% + $(call cmd,install) diff --git a/meta-catfish/recipes-kernel/linux/linux-catfish/defconfig b/meta-catfish/recipes-kernel/linux/linux-catfish/defconfig index 69a1108f..5fdd9912 100644 --- a/meta-catfish/recipes-kernel/linux/linux-catfish/defconfig +++ b/meta-catfish/recipes-kernel/linux/linux-catfish/defconfig @@ -946,7 +946,7 @@ CONFIG_LLC=y # CONFIG_X25 is not set # CONFIG_LAPB is not set # CONFIG_PHONET is not set -# CONFIG_6LOWPAN is not set +CONFIG_6LOWPAN=m # CONFIG_IEEE802154 is not set CONFIG_NET_SCHED=y @@ -1053,6 +1053,7 @@ CONFIG_BT_BNEP_MC_FILTER=y CONFIG_BT_BNEP_PROTO_FILTER=y CONFIG_BT_HIDP=y CONFIG_BT_LE=y +CONFIG_BT_6LOWPAN=m # CONFIG_BT_SELFTEST is not set CONFIG_BT_DEBUGFS=y diff --git a/meta-catfish/recipes-kernel/linux/linux-catfish_p.bb b/meta-catfish/recipes-kernel/linux/linux-catfish_p.bb index ce56b212..c1cac29c 100644 --- a/meta-catfish/recipes-kernel/linux/linux-catfish_p.bb +++ b/meta-catfish/recipes-kernel/linux/linux-catfish_p.bb @@ -8,16 +8,23 @@ LICENSE = "GPL-2.0-only" LIC_FILES_CHKSUM = "file://COPYING;md5=d7810fab7487fb0aad327b76f1be7cd7" COMPATIBLE_MACHINE = "catfish" -SRC_URI = " git://android.googlesource.com/kernel/msm;branch=android-msm-catshark-3.18-pie-wear-dr;protocol=https \ - file://defconfig \ - file://img_info \ - file://0001-scripts-dtc-Remove-redundant-YYLOC-global-declaratio.patch \ - file://0002-usb-gadget-include-gadget-folder-to-fix-compilation.patch \ - file://0003-char-bbd2.0-Fix-include-error.patch \ - file://0004-Backport-mainline-4.1-Bluetooth-subsystem.patch \ - file://0005-Focaltech-Delay-when-sending-wakeup-event.patch \ - file://0006-dts-msm8909w-Enable-more-GPU-clock-frequencies.patch \ -" +SRC_URI = "git://android.googlesource.com/kernel/msm;branch=android-msm-catshark-3.18-pie-wear-dr;protocol=https \ + file://defconfig \ + file://img_info \ + file://0001-scripts-dtc-Remove-redundant-YYLOC-global-declaratio.patch \ + file://0002-usb-gadget-include-gadget-folder-to-fix-compilation.patch \ + file://0003-char-bbd2.0-Fix-include-error.patch \ + file://0004-Backport-mainline-4.1-Bluetooth-subsystem.patch \ + file://0005-Focaltech-Delay-when-sending-wakeup-event.patch \ + file://0006-dts-msm8909w-Enable-more-GPU-clock-frequencies.patch \ + file://0007-Add-missing-BT_6LOWPAN-option-to-bluetooth-Kconfig.patch \ + file://0008-Restore-bluetooth_6lowpan-to-Makefile.patch \ + file://0009-Move-const-to-the-right-location.patch \ + file://0010-include-linux-module.h-copy-__init-__exit-attrs-to-i.patch \ + file://0011-Compiler-Attributes-add-support-for-__copy-gcc-9.patch \ + file://0012-Fix-alignment-of-struct-members.patch \ + file://0013-Apply-many-small-fixes-for-6lowpan.patch \ + " SRCREV = "2b65638aaf038943506d1e6e7a942a4948490a42" LINUX_VERSION ?= "3.18"