Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH v5 bluetooth-next 3/4] bluetooth:6lowpan: use consume_skb when packet processed successfully
From: Martin Townsend @ 2014-10-23 14:40 UTC (permalink / raw)
  To: linux-bluetooth, linux-wpan
  Cc: marcel, alex.aring, jukka.rissanen, Martin Townsend
In-Reply-To: <1414075256-9448-1-git-send-email-martin.townsend@xsilon.com>

From: Martin Townsend <mtownsend1973@gmail.com>

Signed-off-by: Martin Townsend <mtownsend1973@gmail.com>
---
 net/bluetooth/6lowpan.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
index 94bbb66..40e2cec 100644
--- a/net/bluetooth/6lowpan.c
+++ b/net/bluetooth/6lowpan.c
@@ -337,8 +337,8 @@ static int recv_pkt(struct sk_buff *skb, struct net_device *dev,
 		dev->stats.rx_bytes += skb->len;
 		dev->stats.rx_packets++;
 
-		kfree_skb(local_skb);
-		kfree_skb(skb);
+		consume_skb(local_skb);
+		consume_skb(skb);
 	} else {
 		switch (skb->data[0] & 0xe0) {
 		case LOWPAN_DISPATCH_IPHC:	/* ipv6 datagram */
@@ -363,7 +363,8 @@ static int recv_pkt(struct sk_buff *skb, struct net_device *dev,
 			dev->stats.rx_bytes += skb->len;
 			dev->stats.rx_packets++;
 
-			kfree_skb(skb);
+			consume_skb(local_skb);
+			consume_skb(skb);
 			break;
 		default:
 			break;
-- 
1.9.1

^ permalink raw reply related

* [PATCH v5 bluetooth-next 2/4] 6lowpan: fix process_data return values
From: Martin Townsend @ 2014-10-23 14:40 UTC (permalink / raw)
  To: linux-bluetooth, linux-wpan
  Cc: marcel, alex.aring, jukka.rissanen, Martin Townsend,
	Martin Townsend
In-Reply-To: <1414075256-9448-1-git-send-email-martin.townsend@xsilon.com>

As process_data now returns just error codes fix up the calls to this
function to only drop the skb if an error code is returned.

Signed-off-by: Martin Townsend <mtownsend1973@gmail.com>
---
 net/bluetooth/6lowpan.c       | 2 +-
 net/ieee802154/6lowpan_rtnl.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
index 45d9a9f..94bbb66 100644
--- a/net/bluetooth/6lowpan.c
+++ b/net/bluetooth/6lowpan.c
@@ -347,7 +347,7 @@ static int recv_pkt(struct sk_buff *skb, struct net_device *dev,
 				goto drop;
 
 			ret = process_data(local_skb, dev, chan);
-			if (ret != NET_RX_SUCCESS)
+			if (ret < 0)
 				goto drop;
 
 			local_skb->protocol = htons(ETH_P_IPV6);
diff --git a/net/ieee802154/6lowpan_rtnl.c b/net/ieee802154/6lowpan_rtnl.c
index 09feacf..577597d 100644
--- a/net/ieee802154/6lowpan_rtnl.c
+++ b/net/ieee802154/6lowpan_rtnl.c
@@ -542,7 +542,7 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
 		switch (skb->data[0] & 0xe0) {
 		case LOWPAN_DISPATCH_IPHC:	/* ipv6 datagram */
 			ret = process_data(skb, &hdr);
-			if (ret == NET_RX_DROP)
+			if (ret < 0)
 				goto drop;
 
 			return lowpan_give_skb_to_devices(skb, NULL);
@@ -550,7 +550,7 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
 			ret = lowpan_frag_rcv(skb, LOWPAN_DISPATCH_FRAG1);
 			if (ret == 1) {
 				ret = process_data(skb, &hdr);
-				if (ret == NET_RX_DROP)
+				if (ret < 0)
 					goto drop;
 
 				return lowpan_give_skb_to_devices(skb, NULL);
@@ -563,7 +563,7 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
 			ret = lowpan_frag_rcv(skb, LOWPAN_DISPATCH_FRAGN);
 			if (ret == 1) {
 				ret = process_data(skb, &hdr);
-				if (ret == NET_RX_DROP)
+				if (ret < 0)
 					goto drop;
 
 				return lowpan_give_skb_to_devices(skb, NULL);
-- 
1.9.1

^ permalink raw reply related

* [PATCH v5 bluetooth-next 1/4] 6lowpan: remove skb_deliver from IPHC
From: Martin Townsend @ 2014-10-23 14:40 UTC (permalink / raw)
  To: linux-bluetooth, linux-wpan
  Cc: marcel, alex.aring, jukka.rissanen, Martin Townsend,
	Martin Townsend
In-Reply-To: <1414075256-9448-1-git-send-email-martin.townsend@xsilon.com>

Separating skb delivery from decompression ensures that we can support further
decompression schemes and removes the mixed return value of error codes with
NET_RX_FOO.

Signed-off-by: Martin Townsend <mtownsend1973@gmail.com>
---
 include/net/6lowpan.h         |  4 +---
 net/6lowpan/iphc.c            | 32 ++++++--------------------------
 net/bluetooth/6lowpan.c       | 14 ++++++++++++--
 net/ieee802154/6lowpan_rtnl.c | 41 ++++++++++++++++++++++++++---------------
 4 files changed, 45 insertions(+), 46 deletions(-)

diff --git a/include/net/6lowpan.h b/include/net/6lowpan.h
index d184df1..abfa359 100644
--- a/include/net/6lowpan.h
+++ b/include/net/6lowpan.h
@@ -372,12 +372,10 @@ lowpan_uncompress_size(const struct sk_buff *skb, u16 *dgram_offset)
 	return skb->len + uncomp_header - ret;
 }
 
-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,
 		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 747b3cc..45714fe 100644
--- a/net/6lowpan/iphc.c
+++ b/net/6lowpan/iphc.c
@@ -171,29 +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)
-{
-	int stat;
-
-	skb_push(skb, sizeof(struct ipv6hdr));
-	skb_reset_network_header(skb);
-	skb_copy_to_linear_data(skb, hdr, sizeof(struct ipv6hdr));
-
-	skb->protocol = htons(ETH_P_IPV6);
-	skb->pkt_type = PACKET_HOST;
-	skb->dev = dev;
-
-	raw_dump_table(__func__, "raw skb data dump before receiving",
-		       skb->data, skb->len);
-
-	stat = deliver_skb(skb, dev);
-
-	consume_skb(skb);
-
-	return stat;
-}
-
 /* Uncompress function for multicast destination address,
  * when M bit is set.
  */
@@ -327,7 +304,7 @@ static const u8 lowpan_ttl_values[] = { 0, 1, 64, 255 };
 int lowpan_process_data(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;
@@ -492,10 +469,13 @@ 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);
 
-	raw_dump_table(__func__, "raw header dump", (u8 *)&hdr, sizeof(hdr));
+	skb_push(skb, sizeof(hdr));
+	skb_reset_network_header(skb);
+	skb_copy_to_linear_data(skb, &hdr, sizeof(hdr));
 
-	return skb_deliver(skb, &hdr, dev, deliver_skb);
+	raw_dump_table(__func__, "raw header dump", (u8 *)&hdr, sizeof(hdr));
 
+	return 0;
 drop:
 	kfree_skb(skb);
 	return -EINVAL;
diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
index 6c5c2ef..45d9a9f 100644
--- a/net/bluetooth/6lowpan.c
+++ b/net/bluetooth/6lowpan.c
@@ -252,7 +252,7 @@ static int give_skb_to_upper(struct sk_buff *skb, struct net_device *dev)
 
 	skb_cp = skb_copy(skb, GFP_ATOMIC);
 	if (!skb_cp)
-		return -ENOMEM;
+		return NET_RX_DROP;
 
 	return netif_rx(skb_cp);
 }
@@ -290,7 +290,7 @@ static int process_data(struct sk_buff *skb, struct net_device *netdev,
 	return lowpan_process_data(skb, netdev,
 				   saddr, IEEE802154_ADDR_LONG, EUI64_ADDR_LEN,
 				   daddr, IEEE802154_ADDR_LONG, EUI64_ADDR_LEN,
-				   iphc0, iphc1, give_skb_to_upper);
+				   iphc0, iphc1);
 
 drop:
 	kfree_skb(skb);
@@ -350,6 +350,16 @@ static int recv_pkt(struct sk_buff *skb, struct net_device *dev,
 			if (ret != NET_RX_SUCCESS)
 				goto drop;
 
+			local_skb->protocol = htons(ETH_P_IPV6);
+			local_skb->pkt_type = PACKET_HOST;
+			local_skb->dev = dev;
+
+			if (give_skb_to_upper(local_skb, dev)
+					!= NET_RX_SUCCESS) {
+				kfree_skb(local_skb);
+				goto drop;
+			}
+
 			dev->stats.rx_bytes += skb->len;
 			dev->stats.rx_packets++;
 
diff --git a/net/ieee802154/6lowpan_rtnl.c b/net/ieee802154/6lowpan_rtnl.c
index 0c1a49b..09feacf 100644
--- a/net/ieee802154/6lowpan_rtnl.c
+++ b/net/ieee802154/6lowpan_rtnl.c
@@ -141,20 +141,28 @@ 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;
 }
 
@@ -190,8 +198,7 @@ static int process_data(struct sk_buff *skb, const struct ieee802154_hdr *hdr)
 
 	return lowpan_process_data(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);
@@ -528,44 +535,48 @@ 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);
 			if (ret == NET_RX_DROP)
 				goto drop;
-			break;
+
+			return lowpan_give_skb_to_devices(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);
 				if (ret == NET_RX_DROP)
 					goto drop;
+
+				return lowpan_give_skb_to_devices(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);
 				if (ret == NET_RX_DROP)
 					goto drop;
+
+				return lowpan_give_skb_to_devices(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:
-- 
1.9.1

^ permalink raw reply related

* [PATCH v5 bluetooth-next 0/4] 6lowpan: Move skb delivery out of IPHC
From: Martin Townsend @ 2014-10-23 14:40 UTC (permalink / raw)
  To: linux-bluetooth, linux-wpan
  Cc: marcel, alex.aring, jukka.rissanen, Martin Townsend

This series moves skb delivery out of IPHC and into the receive routines of
both bluetooth and 802.15.4.  The reason is that we need to support more
(de)compression schemes in the future.  It also means that calling 
lowpan_process_data now only returns error codes or 0 for success so 
this has been cleaned up.  The final patch then renames occurences of
lowpan_process_data and process_data to something more meaningful.

v1 -> v2

* Handle freeing of skb in lowpan_give_skb_to_devices for 802.15.14
* Added another skb_consume in bluetooth code for uncompressed IPv6 headers
* Added missing skb_consume for local_skb for bluetooth in compreesed IPv6 header
  path
* Combine patch 4 into 1.

v2 -> v3

* Ensure error codes aren't returned in the bluetooth skb delivery function.
* In lowpan_give_skb_to_devices return NET_RX_DROP when the first call to
  netif_rx fails.

v3 -> v4

* Fixed incorrect frag return handling due to refactoring skb_deliver.

v4 -> v5

* Removed unnecessary break statements in lowpan_rcv

Martin Townsend (4):
  6lowpan: remove skb_deliver from IPHC
  6lowpan: fix process_data return values
  bluetooth:6lowpan: use consume_skb when packet processed successfully
  ieee802154: 6lowpan: rename process_data and lowpan_process_data

 include/net/6lowpan.h         | 12 ++++-----
 net/6lowpan/iphc.c            | 42 +++++++++---------------------
 net/bluetooth/6lowpan.c       | 36 +++++++++++++++++---------
 net/ieee802154/6lowpan_rtnl.c | 60 ++++++++++++++++++++++++++-----------------
 4 files changed, 78 insertions(+), 72 deletions(-)

-- 
1.9.1

^ permalink raw reply

* [PATCH 2/2] sbc: use an uint16 to store frame length in internal frame structure
From: Aurélien Zanelli @ 2014-10-23 14:32 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Aurélien Zanelli
In-Reply-To: <1414074741-20286-1-git-send-email-aurelien.zanelli@parrot.com>

Otherwise it could overflow in some cases.
For instance in DUAL_CHANNEL mode, with subbands set to SBC_SB_8, blocks
set to SBC_BLK_16 and bitpool set to 64 results in a frame length of 268.
---
 sbc/sbc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sbc/sbc.c b/sbc/sbc.c
index e830388..606f11c 100644
--- a/sbc/sbc.c
+++ b/sbc/sbc.c
@@ -119,7 +119,7 @@ struct sbc_frame {
 	uint8_t subbands;
 	uint8_t bitpool;
 	uint16_t codesize;
-	uint8_t length;
+	uint16_t length;
 
 	/* bit number x set means joint stereo has been used in subband x */
 	uint8_t joint;
-- 
1.7.10.4


^ permalink raw reply related

* [PATCH 1/2] sbc: fix frame length calculation for DUAL_CHANNEL mode
From: Aurélien Zanelli @ 2014-10-23 14:32 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Aurélien Zanelli
In-Reply-To: <1414074741-20286-1-git-send-email-aurelien.zanelli@parrot.com>

According to A2DP specification, section 12.9, for DUAL_CHANNEL mode, we
shall use the same formula as for MONO mode.
---
 sbc/sbc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sbc/sbc.c b/sbc/sbc.c
index 534027e..e830388 100644
--- a/sbc/sbc.c
+++ b/sbc/sbc.c
@@ -1402,7 +1402,7 @@ SBC_EXPORT size_t sbc_get_frame_length(sbc_t *sbc)
 
 	ret = 4 + (4 * subbands * channels) / 8;
 	/* This term is not always evenly divide so we round it up */
-	if (channels == 1)
+	if (channels == 1 || sbc->mode == SBC_MODE_DUAL_CHANNEL)
 		ret += ((blocks * channels * bitpool) + 7) / 8;
 	else
 		ret += (((joint ? subbands : 0) + blocks * bitpool) + 7) / 8;
-- 
1.7.10.4


^ permalink raw reply related

* [PATCH 0/2] sbc: fix frame length in DUAL_CHANNEL mode
From: Aurélien Zanelli @ 2014-10-23 14:32 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Aurélien Zanelli

Hi everyone,
I was playing with sbc encoder in GStreamer, which use bluez sbc library to
encode and I found two issues related to DUAL_CHANNEL mode in it.

First the frame length calculation for DUAL_CHANNEL mode was wrong. I found
the A2DP specification and it seems that for DUAL_CHANNEL mode, we should use
the same formula as MONO mode to calculate the frame length. The first patch
intend to fix this.

The second patch try to fix an overflow which can occur when the frame length
is greater than 255.

Aurélien Zanelli (2):
  sbc: fix frame length calculation for DUAL_CHANNEL mode
  sbc: use an uint16 to store frame length in internal frame structure

 sbc/sbc.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
1.7.10.4


^ permalink raw reply

* Re: [PATCH v3 bluetooth-next 1/4] 6lowpan: remove skb_deliver from IPHC
From: Alexander Aring @ 2014-10-23 14:28 UTC (permalink / raw)
  To: Martin Townsend
  Cc: linux-bluetooth, linux-wpan, marcel, jukka.rissanen,
	Martin Townsend
In-Reply-To: <1414069948-29731-2-git-send-email-martin.townsend@xsilon.com>

Hi Martin,

On Thu, Oct 23, 2014 at 02:12:25PM +0100, Martin Townsend wrote:
...
>  	} else {
>  		switch (skb->data[0] & 0xe0) {
>  		case LOWPAN_DISPATCH_IPHC:	/* ipv6 datagram */
>  			ret = process_data(skb, &hdr);
>  			if (ret == NET_RX_DROP)
>  				goto drop;
> -			break;
> +
> +			return lowpan_give_skb_to_devices(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);
>  				if (ret == NET_RX_DROP)
>  					goto drop;
> +
> +				return lowpan_give_skb_to_devices(skb, NULL);
> +			} else if (ret == -1) {
> +				return NET_RX_DROP;
> +			} else {
> +				return NET_RX_SUCCESS;
>  			}
>  			break;

break isn't necessary here.

>  		case LOWPAN_DISPATCH_FRAGN:	/* next fragments headers */
> @@ -558,6 +566,12 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
>  				ret = process_data(skb, &hdr);
>  				if (ret == NET_RX_DROP)
>  					goto drop;
> +
> +				return lowpan_give_skb_to_devices(skb, NULL);
> +			} else if (ret == -1) {
> +				return NET_RX_DROP;
> +			} else {
> +				return NET_RX_SUCCESS;
>  			}
>  			break;

same here.

You tagged this patch series as v3 but should be v4. Next series should
be v5.

- Alex

^ permalink raw reply

* Re: Attribute security permissions and CCC descriptors in shared/gatt-server.
From: Vinícius Costa Gomes @ 2014-10-23 13:53 UTC (permalink / raw)
  To: Luiz Augusto von Dentz
  Cc: Arman Uguray, BlueZ development, Marcin Kraglak, Marcel Holtmann
In-Reply-To: <CABBYNZLE_xxoaPXZ=9LY2AwT-Pa_mqEYRD8v4_TgMTdo77j-Qw@mail.gmail.com>

Hi Luiz,

On Thu, Oct 23, 2014 at 5:51 AM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:

[...]

>>
>>
>> *** 2. Is shared/gatt-server responsible for keeping track of Client
>> Characteristic Configuration descriptor states for each bonded client?
>> ***
>>
>> Currently, the descriptor read/write operations need to be handled by
>> the upper layer via the read/write callbacks anyway, since the
>> side-effects of a writing to a particular CCC descriptor need to be
>> implemented by the related profile. In the bonding case, the
>> read/write callbacks could determine what value to return and how to
>> cache the value on a per-device basis without shared/gatt-db having a
>> notion of "per-client CCC descriptors".
>
> Well making gatt_db have the notion of CCC would make things a little
> bit simpler for storing and reloading but it would probably force us
> to rethink how the db access the values, perhaps the db could cache
> CCC values per client so it could detect changes and send
> notifications automatically whenever the profiles tell it values has
> changed or when a write succeeds.
>
>> Does this make sense? If so, is there a point of keeping the "bdaddr_t
>> *bdaddr" arguments of gatt_db_read_t, gatt_db_write_t, gatt_db_read,
>> and gatt_db_write? Note that I'm currently passing NULL to all of
>> these calls for this parameter in shared/gatt-server, since bt_att
>> doesn't have a notion of a BD_ADDR.
>
> I guess this was inspired by Android, I would agree that if you
> register a characteristic and set the permission properly then it does
> not matter who is attempting to read/write as long as they are fulfill
> the requirements it should be okay but perhaps Android have pushed the
> notion of CCC up in the stack which force it to expose the remote
> address. Anyway for unit test I will have to address it since that
> will be using a socket pair, perhaps passing NULL is fine if we have
> CCC caching but in case of Android I don't think we can do much about
> it.
>

Don't know if I am following correctly here. But I guess that even
that, we would
need to have a way for the profile to identify who is writing in the CCC.

For example, in a (imaginary) Temperature profile that the client may
choose the unit (degrees Celsius or Fahrenheit) that is used for
indications/notifications. Each client would receive a different
notification value depending on what's written on the CCC.

Another solution would be for the "view" of the database that the profile has
depends on the device "operating" (not a very good word, because a
operation may be something like receiving a notification) on it. Just thinking
out loud.

>
> --
> Luiz Augusto von Dentz
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


Cheers,
-- 
Vinicius

^ permalink raw reply

* Re: [bluetooth]  btusb issues
From: Patrick Shirkey @ 2014-10-23 13:46 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <20141023122933.GA29656@aemeltch-mobl1.fi.intel.com>


On Thu, October 23, 2014 11:29 pm, Andrei Emeltchenko wrote:
> Hi Patrick,
>
> On Thu, Oct 23, 2014 at 09:59:23PM +1100, Patrick Shirkey wrote:
>>
>> On Thu, October 23, 2014 7:59 pm, Patrick Shirkey wrote:
>> > Hi,
>> >
>> > I have now got backports to run with bluez instead of bluedroid and
>> the
>> > btusb driver instead of rtk_btusb.
>> >
>> > However the android bluetooth system does not want to run for me.
>
> So what is not working? Do you have logcat with "BlueZ" and "bluetothd"
> logs?
>

It is working better now and I can see the BLE device in the Settings UI.

For reference I had to add the following insmod commands to my init file
to get all the backports drivers to load.

# Bluez bluetooth and backports modules
    insmod /system/vendor/modules/compat.ko
    insmod /system/vendor/modules/bluetooth.ko
    insmod /system/vendor/modules/btusb.ko
    insmod /system/vendor/modules/rfcomm.ko
    insmod /system/vendor/modules/bnep.ko


And I had to double check that Crypto configs were set (which is
referenced in the aosp-bluez docs on the website):

CONFIG_CRYPTO_CMAC=y
CONFIG_CRYPTO_USER_API=y
CONFIG_CRYPTO_USER_API_HASH=y
CONFIG_CRYPTO_USER_API_SKCIPHER=y



> Best regards
> Andrei Emeltchenko
>
>> >
>>
>> For reference purposes I have got bluez running on an 8723au chipset
>> with
>> the btusb driver from the "new" branch of the btusb git repo.
>>
>> Here's an overview of the steps required:
>>
>> - Patch the 3.4 kernel with the patch files from the aosp-bluez "misc"
>> repo
>> - Completely replace bluedroid in the android tree with bluez including
>> the modifed bionic tree from the aosp-bluez repo
>> - Cross compile the backports drivers replacing btusb.c with the version
>> from the "new" branch in the git repo.
>> - Copy the modules from the backports tree to the linux tree before
>> building the firmware image. (overwrite the .ko files generated by the
>> kernel build)
>> - Include the firmware binary images from the git repo "new" branch in
>> the
>> android build so they are copied to the /system/etc/firmware/ folder in
>> the firmware image
>> - Modify the init.rc script to include the init.bluetooth.rc file
>> - Modify the <platform>.mk file (in this case
>> /device/softwinner/wing-k70/wing-k70.mk) to load the following modules
>> on
>> boot:
>>     /system/vendor/modules/compat.ko
>>     /system/vendor/modules/bluetooth.ko
>>     /system/vendor/modules/btusb.ko
>>
>> enable debug logging with :
>>
>> setprop persist.sys.bluetooth.debug 1
>>
>>
>>
>> # btmgmt info
>> hci0:	addr CC:D2:9C:73:CB:45 version 6 manufacturer 93 class 0x000000
>> 	supported settings: powered connectable fast-connectable discoverable
>> bondable link-security ssp br/edr hs le advertising debug-keys privacy
>> 	current settings: bondable ssp br/edr le
>> 	name BlueZ for Android
>> 	short name
>>
>>
>> # haltest
>> audio_hw_device_open returned -98
>> hw_get_module_by_class returned -2
>> thread_evt_cb: evt=ASSOCIATE_JVM
>> if_bluetooth->init: BT_STATUS_SUCCESS
>> get_profile_interface(handsfree) : 0xb6e58134
>> get_profile_interface(a2dp) : 0xb6e580ec
>> get_profile_interface(avrcp) : 0xb6e58100
>> get_profile_interface(health) : 0xb6e583d0
>> get_profile_interface(hidhost) : 0xb6e580a0
>> get_profile_interface(pan) : 0xb6e580d0
>> get_profile_interface(gatt) : 0xb6e581ac
>> get_profile_interface(socket) : 0xb6e58094
>> if_bluetooth->init: BT_STATUS_DONE
>> if_av->init: BT_STATUS_SUCCESS
>> if_rc->init: BT_STATUS_SUCCESS
>> if_gatt->init: BT_STATUS_FAIL
>> adapter_properties_cb: status=BT_STATUS_SUCCESS num_properties=1
>> prop: type=BT_PROPERTY_UUIDS len=80 val={0000110e, 0000110c, 0000110a,
>> 0000113b, 00001200}
>> adapter_properties_cb: status=BT_STATUS_SUCCESS num_properties=1
>> prop: type=BT_PROPERTY_UUIDS len=80 val={0000110e, 0000110c, 0000110a,
>> 0000113b, 00001200}
>> adapter_properties_cb: status=BT_STATUS_SUCCESS num_properties=1
>> prop: type=BT_PROPERTY_UUIDS len=80 val={0000110e, 0000110c, 0000110a,
>> 0000113b, 00001200}
>> if_hf->init: BT_STATUS_FAIL
>> if_hh->init: BT_STATUS_SUCCESS
>> if_pan->init: BT_STATUS_FAIL
>> adapter_properties_cb: status=BT_STATUS_SUCCESS num_properties=1
>> prop: type=BT_PROPERTY_UUIDS len=80 val={0000110e, 0000110c, 0000110a,
>> 0000113b, 00001200}
>> adapter_properties_cb: status=BT_STATUS_SUCCESS num_properties=1
>> prop: type=BT_PROPERTY_UUIDS len=80 val={0000110e, 0000110c, 0000110a,
>> 0000113b, 00001200}
>> if_hl->init: BT_STATUS_SUCCESS
>> >
>>
>>
>> # btmgmt le on
>> hci0 Set Low Energy complete, settings: bondable ssp br/edr le
>> # btmgmt find
>> Unable to start discovery. status 0x0f (Not Powered)
>> # btmgmt power on
>> hci0 Set Powered complete, settings: powered bondable ssp br/edr le
>> # btmgmt find
>> Discovery started
>> hci0 dev_found: BC:6A:29:AB:2C:AA type LE Public rssi -44 flags 0x0000
>> AD
>> flags 0x06 eir_len 25
>>
>>
>>
>>
>>
>> --
>> Patrick Shirkey
>> Boost Hardware Ltd
>> --
>> To unsubscribe from this list: send the line "unsubscribe
>> linux-bluetooth" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth"
> in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>


--
Patrick Shirkey
Boost Hardware Ltd

^ permalink raw reply

* [PATCH v3 bluetooth-next 4/4] ieee802154: 6lowpan: rename process_data and lowpan_process_data
From: Martin Townsend @ 2014-10-23 13:12 UTC (permalink / raw)
  To: linux-bluetooth, linux-wpan
  Cc: marcel, alex.aring, jukka.rissanen, Martin Townsend
In-Reply-To: <1414069948-29731-1-git-send-email-martin.townsend@xsilon.com>

From: Martin Townsend <mtownsend1973@gmail.com>

As we have decouple decompression from data delivery we can now rename all
occurences of process_data in receive path.

Signed-off-by: Martin Townsend <mtownsend1973@gmail.com>
---
 include/net/6lowpan.h         | 10 ++++++----
 net/6lowpan/iphc.c            | 12 +++++++-----
 net/bluetooth/6lowpan.c       | 15 ++++++++-------
 net/ieee802154/6lowpan_rtnl.c | 15 ++++++++-------
 4 files changed, 29 insertions(+), 23 deletions(-)

diff --git a/include/net/6lowpan.h b/include/net/6lowpan.h
index abfa359..dc03d77 100644
--- a/include/net/6lowpan.h
+++ b/include/net/6lowpan.h
@@ -372,10 +372,12 @@ lowpan_uncompress_size(const struct sk_buff *skb, u16 *dgram_offset)
 	return skb->len + uncomp_header - ret;
 }
 
-int lowpan_process_data(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);
+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);
 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 45714fe..73a7065 100644
--- a/net/6lowpan/iphc.c
+++ b/net/6lowpan/iphc.c
@@ -301,10 +301,12 @@ 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,
-			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)
+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)
 {
 	struct ipv6hdr hdr = {};
 	u8 tmp, num_context = 0;
@@ -480,7 +482,7 @@ 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 40e2cec..aa6ebbf 100644
--- a/net/bluetooth/6lowpan.c
+++ b/net/bluetooth/6lowpan.c
@@ -257,8 +257,8 @@ static int give_skb_to_upper(struct sk_buff *skb, struct net_device *dev)
 	return netif_rx(skb_cp);
 }
 
-static int process_data(struct sk_buff *skb, struct net_device *netdev,
-			struct l2cap_chan *chan)
+static int iphc_decompress(struct sk_buff *skb, struct net_device *netdev,
+			   struct l2cap_chan *chan)
 {
 	const u8 *saddr, *daddr;
 	u8 iphc0, iphc1;
@@ -287,10 +287,11 @@ static int process_data(struct sk_buff *skb, struct net_device *netdev,
 	if (lowpan_fetch_skb_u8(skb, &iphc1))
 		goto drop;
 
-	return lowpan_process_data(skb, netdev,
-				   saddr, IEEE802154_ADDR_LONG, EUI64_ADDR_LEN,
-				   daddr, IEEE802154_ADDR_LONG, EUI64_ADDR_LEN,
-				   iphc0, iphc1);
+	return lowpan_header_decompress(skb, netdev,
+					saddr, IEEE802154_ADDR_LONG,
+					EUI64_ADDR_LEN, daddr,
+					IEEE802154_ADDR_LONG, EUI64_ADDR_LEN,
+					iphc0, iphc1);
 
 drop:
 	kfree_skb(skb);
@@ -346,7 +347,7 @@ static int recv_pkt(struct sk_buff *skb, struct net_device *dev,
 			if (!local_skb)
 				goto drop;
 
-			ret = process_data(local_skb, dev, chan);
+			ret = iphc_decompress(local_skb, dev, chan);
 			if (ret < 0)
 				goto drop;
 
diff --git a/net/ieee802154/6lowpan_rtnl.c b/net/ieee802154/6lowpan_rtnl.c
index 05a0a84..64ec0cd 100644
--- a/net/ieee802154/6lowpan_rtnl.c
+++ b/net/ieee802154/6lowpan_rtnl.c
@@ -166,7 +166,8 @@ static int lowpan_give_skb_to_devices(struct sk_buff *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;
@@ -196,9 +197,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,
-				   IEEE802154_ADDR_LEN, dap, da.addr_type,
-				   IEEE802154_ADDR_LEN, iphc0, iphc1);
+	return lowpan_header_decompress(skb, skb->dev, sap, sa.addr_type,
+					IEEE802154_ADDR_LEN, dap, da.addr_type,
+					IEEE802154_ADDR_LEN, iphc0, iphc1);
 
 drop:
 	kfree_skb(skb);
@@ -541,7 +542,7 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
 	} else {
 		switch (skb->data[0] & 0xe0) {
 		case LOWPAN_DISPATCH_IPHC:	/* ipv6 datagram */
-			ret = process_data(skb, &hdr);
+			ret = iphc_decompress(skb, &hdr);
 			if (ret < 0)
 				goto drop;
 
@@ -549,7 +550,7 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
 		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 < 0)
 					goto drop;
 
@@ -563,7 +564,7 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
 		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 < 0)
 					goto drop;
 
-- 
1.9.1

^ permalink raw reply related

* [PATCH v3 bluetooth-next 3/4] bluetooth:6lowpan: use consume_skb when packet processed successfully
From: Martin Townsend @ 2014-10-23 13:12 UTC (permalink / raw)
  To: linux-bluetooth, linux-wpan
  Cc: marcel, alex.aring, jukka.rissanen, Martin Townsend
In-Reply-To: <1414069948-29731-1-git-send-email-martin.townsend@xsilon.com>

From: Martin Townsend <mtownsend1973@gmail.com>

Signed-off-by: Martin Townsend <mtownsend1973@gmail.com>
---
 net/bluetooth/6lowpan.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
index 94bbb66..40e2cec 100644
--- a/net/bluetooth/6lowpan.c
+++ b/net/bluetooth/6lowpan.c
@@ -337,8 +337,8 @@ static int recv_pkt(struct sk_buff *skb, struct net_device *dev,
 		dev->stats.rx_bytes += skb->len;
 		dev->stats.rx_packets++;
 
-		kfree_skb(local_skb);
-		kfree_skb(skb);
+		consume_skb(local_skb);
+		consume_skb(skb);
 	} else {
 		switch (skb->data[0] & 0xe0) {
 		case LOWPAN_DISPATCH_IPHC:	/* ipv6 datagram */
@@ -363,7 +363,8 @@ static int recv_pkt(struct sk_buff *skb, struct net_device *dev,
 			dev->stats.rx_bytes += skb->len;
 			dev->stats.rx_packets++;
 
-			kfree_skb(skb);
+			consume_skb(local_skb);
+			consume_skb(skb);
 			break;
 		default:
 			break;
-- 
1.9.1

^ permalink raw reply related

* [PATCH v3 bluetooth-next 2/4] 6lowpan: fix process_data return values
From: Martin Townsend @ 2014-10-23 13:12 UTC (permalink / raw)
  To: linux-bluetooth, linux-wpan
  Cc: marcel, alex.aring, jukka.rissanen, Martin Townsend,
	Martin Townsend
In-Reply-To: <1414069948-29731-1-git-send-email-martin.townsend@xsilon.com>

As process_data now returns just error codes fix up the calls to this
function to only drop the skb if an error code is returned.

Signed-off-by: Martin Townsend <mtownsend1973@gmail.com>
---
 net/bluetooth/6lowpan.c       | 2 +-
 net/ieee802154/6lowpan_rtnl.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
index 45d9a9f..94bbb66 100644
--- a/net/bluetooth/6lowpan.c
+++ b/net/bluetooth/6lowpan.c
@@ -347,7 +347,7 @@ static int recv_pkt(struct sk_buff *skb, struct net_device *dev,
 				goto drop;
 
 			ret = process_data(local_skb, dev, chan);
-			if (ret != NET_RX_SUCCESS)
+			if (ret < 0)
 				goto drop;
 
 			local_skb->protocol = htons(ETH_P_IPV6);
diff --git a/net/ieee802154/6lowpan_rtnl.c b/net/ieee802154/6lowpan_rtnl.c
index 473aaa3..05a0a84 100644
--- a/net/ieee802154/6lowpan_rtnl.c
+++ b/net/ieee802154/6lowpan_rtnl.c
@@ -542,7 +542,7 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
 		switch (skb->data[0] & 0xe0) {
 		case LOWPAN_DISPATCH_IPHC:	/* ipv6 datagram */
 			ret = process_data(skb, &hdr);
-			if (ret == NET_RX_DROP)
+			if (ret < 0)
 				goto drop;
 
 			return lowpan_give_skb_to_devices(skb, NULL);
@@ -550,7 +550,7 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
 			ret = lowpan_frag_rcv(skb, LOWPAN_DISPATCH_FRAG1);
 			if (ret == 1) {
 				ret = process_data(skb, &hdr);
-				if (ret == NET_RX_DROP)
+				if (ret < 0)
 					goto drop;
 
 				return lowpan_give_skb_to_devices(skb, NULL);
@@ -564,7 +564,7 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
 			ret = lowpan_frag_rcv(skb, LOWPAN_DISPATCH_FRAGN);
 			if (ret == 1) {
 				ret = process_data(skb, &hdr);
-				if (ret == NET_RX_DROP)
+				if (ret < 0)
 					goto drop;
 
 				return lowpan_give_skb_to_devices(skb, NULL);
-- 
1.9.1

^ permalink raw reply related

* [PATCH v3 bluetooth-next 1/4] 6lowpan: remove skb_deliver from IPHC
From: Martin Townsend @ 2014-10-23 13:12 UTC (permalink / raw)
  To: linux-bluetooth, linux-wpan
  Cc: marcel, alex.aring, jukka.rissanen, Martin Townsend,
	Martin Townsend
In-Reply-To: <1414069948-29731-1-git-send-email-martin.townsend@xsilon.com>

Separating skb delivery from decompression ensures that we can support further
decompression schemes and removes the mixed return value of error codes with
NET_RX_FOO.

Signed-off-by: Martin Townsend <mtownsend1973@gmail.com>
---
 include/net/6lowpan.h         |  4 +---
 net/6lowpan/iphc.c            | 32 ++++++--------------------------
 net/bluetooth/6lowpan.c       | 14 ++++++++++++--
 net/ieee802154/6lowpan_rtnl.c | 39 ++++++++++++++++++++++++++-------------
 4 files changed, 45 insertions(+), 44 deletions(-)

diff --git a/include/net/6lowpan.h b/include/net/6lowpan.h
index d184df1..abfa359 100644
--- a/include/net/6lowpan.h
+++ b/include/net/6lowpan.h
@@ -372,12 +372,10 @@ lowpan_uncompress_size(const struct sk_buff *skb, u16 *dgram_offset)
 	return skb->len + uncomp_header - ret;
 }
 
-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,
 		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 747b3cc..45714fe 100644
--- a/net/6lowpan/iphc.c
+++ b/net/6lowpan/iphc.c
@@ -171,29 +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)
-{
-	int stat;
-
-	skb_push(skb, sizeof(struct ipv6hdr));
-	skb_reset_network_header(skb);
-	skb_copy_to_linear_data(skb, hdr, sizeof(struct ipv6hdr));
-
-	skb->protocol = htons(ETH_P_IPV6);
-	skb->pkt_type = PACKET_HOST;
-	skb->dev = dev;
-
-	raw_dump_table(__func__, "raw skb data dump before receiving",
-		       skb->data, skb->len);
-
-	stat = deliver_skb(skb, dev);
-
-	consume_skb(skb);
-
-	return stat;
-}
-
 /* Uncompress function for multicast destination address,
  * when M bit is set.
  */
@@ -327,7 +304,7 @@ static const u8 lowpan_ttl_values[] = { 0, 1, 64, 255 };
 int lowpan_process_data(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;
@@ -492,10 +469,13 @@ 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);
 
-	raw_dump_table(__func__, "raw header dump", (u8 *)&hdr, sizeof(hdr));
+	skb_push(skb, sizeof(hdr));
+	skb_reset_network_header(skb);
+	skb_copy_to_linear_data(skb, &hdr, sizeof(hdr));
 
-	return skb_deliver(skb, &hdr, dev, deliver_skb);
+	raw_dump_table(__func__, "raw header dump", (u8 *)&hdr, sizeof(hdr));
 
+	return 0;
 drop:
 	kfree_skb(skb);
 	return -EINVAL;
diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
index 6c5c2ef..45d9a9f 100644
--- a/net/bluetooth/6lowpan.c
+++ b/net/bluetooth/6lowpan.c
@@ -252,7 +252,7 @@ static int give_skb_to_upper(struct sk_buff *skb, struct net_device *dev)
 
 	skb_cp = skb_copy(skb, GFP_ATOMIC);
 	if (!skb_cp)
-		return -ENOMEM;
+		return NET_RX_DROP;
 
 	return netif_rx(skb_cp);
 }
@@ -290,7 +290,7 @@ static int process_data(struct sk_buff *skb, struct net_device *netdev,
 	return lowpan_process_data(skb, netdev,
 				   saddr, IEEE802154_ADDR_LONG, EUI64_ADDR_LEN,
 				   daddr, IEEE802154_ADDR_LONG, EUI64_ADDR_LEN,
-				   iphc0, iphc1, give_skb_to_upper);
+				   iphc0, iphc1);
 
 drop:
 	kfree_skb(skb);
@@ -350,6 +350,16 @@ static int recv_pkt(struct sk_buff *skb, struct net_device *dev,
 			if (ret != NET_RX_SUCCESS)
 				goto drop;
 
+			local_skb->protocol = htons(ETH_P_IPV6);
+			local_skb->pkt_type = PACKET_HOST;
+			local_skb->dev = dev;
+
+			if (give_skb_to_upper(local_skb, dev)
+					!= NET_RX_SUCCESS) {
+				kfree_skb(local_skb);
+				goto drop;
+			}
+
 			dev->stats.rx_bytes += skb->len;
 			dev->stats.rx_packets++;
 
diff --git a/net/ieee802154/6lowpan_rtnl.c b/net/ieee802154/6lowpan_rtnl.c
index 0c1a49b..473aaa3 100644
--- a/net/ieee802154/6lowpan_rtnl.c
+++ b/net/ieee802154/6lowpan_rtnl.c
@@ -141,20 +141,28 @@ 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;
 }
 
@@ -190,8 +198,7 @@ static int process_data(struct sk_buff *skb, const struct ieee802154_hdr *hdr)
 
 	return lowpan_process_data(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);
@@ -528,28 +535,29 @@ 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);
 			if (ret == NET_RX_DROP)
 				goto drop;
-			break;
+
+			return lowpan_give_skb_to_devices(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);
 				if (ret == NET_RX_DROP)
 					goto drop;
+
+				return lowpan_give_skb_to_devices(skb, NULL);
+			} else if (ret == -1) {
+				return NET_RX_DROP;
+			} else {
+				return NET_RX_SUCCESS;
 			}
 			break;
 		case LOWPAN_DISPATCH_FRAGN:	/* next fragments headers */
@@ -558,6 +566,12 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
 				ret = process_data(skb, &hdr);
 				if (ret == NET_RX_DROP)
 					goto drop;
+
+				return lowpan_give_skb_to_devices(skb, NULL);
+			} else if (ret == -1) {
+				return NET_RX_DROP;
+			} else {
+				return NET_RX_SUCCESS;
 			}
 			break;
 		default:
@@ -565,7 +579,6 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
 		}
 	}
 
-	return NET_RX_SUCCESS;
 drop_skb:
 	kfree_skb(skb);
 drop:
-- 
1.9.1

^ permalink raw reply related

* [PATCH v3 bluetooth-next 0/4] 6lowpan: Move skb delivery out of IPHC
From: Martin Townsend @ 2014-10-23 13:12 UTC (permalink / raw)
  To: linux-bluetooth, linux-wpan
  Cc: marcel, alex.aring, jukka.rissanen, Martin Townsend

This series moves skb delivery out of IPHC and into the receive routines of
both bluetooth and 802.15.4.  The reason is that we need to support more
(de)compression schemes in the future.  It also means that calling 
lowpan_process_data now only returns error codes or 0 for success so 
this has been cleaned up.  The final patch then renames occurences of
lowpan_process_data and process_data to something more meaningful.

v1 -> v2

* Handle freeing of skb in lowpan_give_skb_to_devices for 802.15.14
* Added another skb_consume in bluetooth code for uncompressed IPv6 headers
* Added missing skb_consume for local_skb for bluetooth in compreesed IPv6 header
  path
* Combine patch 4 into 1.

v2 -> v3

* Ensure error codes aren't returned in the bluetooth skb delivery function.
* In lowpan_give_skb_to_devices return NET_RX_DROP when the first call to
  netif_rx fails.

v3 -> v4

* Fixed incorrect frag return handling due to refactoring skb_deliver.

Martin Townsend (4):
  6lowpan: remove skb_deliver from IPHC
  6lowpan: fix process_data return values
  bluetooth:6lowpan: use consume_skb when packet processed successfully
  ieee802154: 6lowpan: rename process_data and lowpan_process_data

 include/net/6lowpan.h         | 12 ++++-----
 net/6lowpan/iphc.c            | 42 +++++++++----------------------
 net/bluetooth/6lowpan.c       | 36 ++++++++++++++++++---------
 net/ieee802154/6lowpan_rtnl.c | 58 +++++++++++++++++++++++++++----------------
 4 files changed, 78 insertions(+), 70 deletions(-)

-- 
1.9.1

^ permalink raw reply

* Re: [PATCHv6 00/14] Included service discovery
From: Szymon Janc @ 2014-10-23 12:59 UTC (permalink / raw)
  To: Marcin Kraglak; +Cc: linux-bluetooth
In-Reply-To: <1414059337-12040-1-git-send-email-marcin.kraglak@tieto.com>

Hi Marcin,

On Thursday 23 of October 2014 12:15:23 Marcin Kraglak wrote:
> v3:
> In this version after primary service discovery,
> secondary services are discovered. Next included
> services are resolved. With this approach we
> don't have recursively search for included service,
> like it was TODO in previous proposal.
> There is also small coding style fix suggested by Arman.
> 
> v4:
> If no secondary services found, continue include services search (fixed
> in gatt-client.c).
> Fixed wrong debug logs (primary->secondary).
> Fixed searching descriptors
> 
> v5:
> Ignore Unsupported Group Type Error in response to secondary service
> discovery and continue included services discovery.
> 
> v6
> * Added comments to specific calculations and numbers.
> * Fixed goto labels as suggested by Szymon
> * Changed printing type of service.
> * Typo fixes pointed by Szymon
> 
> Marcin Kraglak (14):
>   shared/gatt: Add discover_secondary_services()
>   shared/gatt: Add initial implementation of discover_included_services
>   shared/gatt: Discover included services 128 bit UUIDS
>   shared/gatt: Add extra check in characteristic iterator
>   shared/gatt: Add included service iterator
>   shared/gatt: Add function bt_gatt_result_included_count()
>   shared/gatt: Remove not needed function parameter
>   shared/gatt: Distinguish Primary from Secondary services
>   tools/btgatt-client: Print type of service
>   shared/gatt: Discover secondary services
>   shared/gatt: Discover included services
>   shared/gatt: Add gatt-client include service iterator
>   tools/btgatt-client: Print found include services
>   shared/gatt: Fix searching descriptors
> 
>  src/shared/gatt-client.c  | 252 +++++++++++++++++++++++--
>  src/shared/gatt-client.h  |  18 ++
>  src/shared/gatt-helpers.c | 462 ++++++++++++++++++++++++++++++++++++++++++++--
>  src/shared/gatt-helpers.h |  10 +-
>  tools/btgatt-client.c     |  20 +-
>  5 files changed, 725 insertions(+), 37 deletions(-)
> 

All patches in this set have been applied. Thanks a lot.

-- 
Best regards, 
Szymon Janc

^ permalink raw reply

* [PATCHv6 10/14] shared/gatt: Discover secondary services
From: Marcin Kraglak @ 2014-10-23 12:36 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1414059337-12040-11-git-send-email-marcin.kraglak@tieto.com>

Add searching of secondary services in gatt-client.
---
 src/shared/gatt-client.c | 113 +++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 100 insertions(+), 13 deletions(-)

diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c
index 724fde2..acc0cb9 100644
--- a/src/shared/gatt-client.c
+++ b/src/shared/gatt-client.c
@@ -200,23 +200,36 @@ static void mark_notify_data_invalid_if_in_range(void *data, void *user_data)
 		notify_data->invalid = true;
 }
 
-static bool service_list_add_service(struct service_list **head,
-						struct service_list **tail,
-						bool primary, uint16_t start,
-						uint16_t end,
+static struct service_list *new_service_list(uint16_t start, uint16_t end,
+						bool primary,
 						uint8_t uuid[BT_GATT_UUID_SIZE])
 {
 	struct service_list *list;
 
 	list = new0(struct service_list, 1);
 	if (!list)
-		return false;
+		return NULL;
 
 	list->service.primary = primary;
 	list->service.start_handle = start;
 	list->service.end_handle = end;
 	memcpy(list->service.uuid, uuid, UUID_BYTES);
 
+	return list;
+}
+
+static bool service_list_add_service(struct service_list **head,
+						struct service_list **tail,
+						bool primary, uint16_t start,
+						uint16_t end,
+						uint8_t uuid[BT_GATT_UUID_SIZE])
+{
+	struct service_list *list;
+
+	list = new_service_list(start, end, primary, uuid);
+	if (!list)
+		return false;
+
 	if (!(*head))
 		*head = *tail = list;
 	else {
@@ -364,6 +377,8 @@ struct discovery_op {
 	struct bt_gatt_client *client;
 	struct service_list *result_head, *result_tail, *cur_service;
 	struct chrc_data *cur_chrc;
+	uint16_t start;
+	uint16_t end;
 	int cur_chrc_index;
 	int ref_count;
 	void (*complete_func)(struct discovery_op *op, bool success,
@@ -634,6 +649,75 @@ done:
 	op->complete_func(op, success, att_ecode);
 }
 
+static void discover_secondary_cb(bool success, uint8_t att_ecode,
+						struct bt_gatt_result *result,
+						void *user_data)
+{
+	struct discovery_op *op = user_data;
+	struct bt_gatt_client *client = op->client;
+	struct bt_gatt_iter iter;
+	uint16_t start, end;
+	uint8_t uuid[BT_GATT_UUID_SIZE];
+	char uuid_str[MAX_LEN_UUID_STR];
+	struct service_list *service;
+
+	if (!success) {
+		util_debug(client->debug_callback, client->debug_data,
+					"Secondary service discovery failed."
+					" ATT ECODE: 0x%02x", att_ecode);
+		switch (att_ecode) {
+		case BT_ATT_ERROR_ATTRIBUTE_NOT_FOUND:
+		case BT_ATT_ERROR_UNSUPPORTED_GROUP_TYPE:
+			goto next;
+		default:
+			goto done;
+		}
+	}
+
+	if (!result || !bt_gatt_iter_init(&iter, result))
+		goto done;
+
+	util_debug(client->debug_callback, client->debug_data,
+					"Secondary services found: %u",
+					bt_gatt_result_service_count(result));
+
+	while (bt_gatt_iter_next_service(&iter, &start, &end, uuid)) {
+		uuid_to_string(uuid, uuid_str);
+		util_debug(client->debug_callback, client->debug_data,
+				"start: 0x%04x, end: 0x%04x, uuid: %s",
+				start, end, uuid_str);
+
+		/* Store the service */
+		service = new_service_list(start, end, false, uuid);
+		if (!service) {
+			util_debug(client->debug_callback, client->debug_data,
+						"Failed to create service");
+			goto done;
+		}
+
+		service_list_insert_services(&op->result_head, &op->result_tail,
+							service, service);
+	}
+
+next:
+	/* Sequentially discover the characteristics of all services */
+	op->cur_service = op->result_head;
+	if (bt_gatt_discover_characteristics(client->att,
+					op->cur_service->service.start_handle,
+					op->cur_service->service.end_handle,
+					discover_chrcs_cb,
+					discovery_op_ref(op),
+					discovery_op_unref))
+		return;
+
+	util_debug(client->debug_callback, client->debug_data,
+				"Failed to start characteristic discovery");
+	discovery_op_unref(op);
+
+done:
+	op->complete_func(op, false, att_ecode);
+}
+
 static void discover_primary_cb(bool success, uint8_t att_ecode,
 						struct bt_gatt_result *result,
 						void *user_data)
@@ -686,18 +770,17 @@ static void discover_primary_cb(bool success, uint8_t att_ecode,
 	if (!op->result_head)
 		goto done;
 
-	/* Sequentially discover the characteristics of all services */
+	/* Discover secondary services */
 	op->cur_service = op->result_head;
-	if (bt_gatt_discover_characteristics(client->att,
-					op->cur_service->service.start_handle,
-					op->cur_service->service.end_handle,
-					discover_chrcs_cb,
-					discovery_op_ref(op),
-					discovery_op_unref))
+	if (bt_gatt_discover_secondary_services(client->att, NULL,
+							op->start, op->end,
+							discover_secondary_cb,
+							discovery_op_ref(op),
+							discovery_op_unref))
 		return;
 
 	util_debug(client->debug_callback, client->debug_data,
-				"Failed to start characteristic discovery");
+				"Failed to start secondary service discovery");
 	discovery_op_unref(op);
 	success = false;
 
@@ -870,6 +953,8 @@ static void process_service_changed(struct bt_gatt_client *client,
 
 	op->client = client;
 	op->complete_func = service_changed_complete;
+	op->start = start_handle;
+	op->end = end_handle;
 
 	if (!bt_gatt_discover_primary_services(client->att, NULL,
 						start_handle, end_handle,
@@ -1002,6 +1087,8 @@ static bool gatt_client_init(struct bt_gatt_client *client, uint16_t mtu)
 
 	op->client = client;
 	op->complete_func = init_complete;
+	op->start = 0x0001;
+	op->end = 0xffff;
 
 	/* Configure the MTU */
 	if (!bt_gatt_exchange_mtu(client->att, MAX(BT_ATT_DEFAULT_LE_MTU, mtu),
-- 
1.9.3


^ permalink raw reply related

* [PATCHv6 10/14] shared/gatt: Discover secondary services
From: Marcin Kraglak @ 2014-10-23 12:35 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1414059337-12040-11-git-send-email-marcin.kraglak@tieto.com>

Add searching of secondary services in gatt-client.
---
 src/shared/gatt-client.c | 113 +++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 100 insertions(+), 13 deletions(-)

diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c
index 724fde2..acc0cb9 100644
--- a/src/shared/gatt-client.c
+++ b/src/shared/gatt-client.c
@@ -200,23 +200,36 @@ static void mark_notify_data_invalid_if_in_range(void *data, void *user_data)
 		notify_data->invalid = true;
 }
 
-static bool service_list_add_service(struct service_list **head,
-						struct service_list **tail,
-						bool primary, uint16_t start,
-						uint16_t end,
+static struct service_list *new_service_list(uint16_t start, uint16_t end,
+						bool primary,
 						uint8_t uuid[BT_GATT_UUID_SIZE])
 {
 	struct service_list *list;
 
 	list = new0(struct service_list, 1);
 	if (!list)
-		return false;
+		return NULL;
 
 	list->service.primary = primary;
 	list->service.start_handle = start;
 	list->service.end_handle = end;
 	memcpy(list->service.uuid, uuid, UUID_BYTES);
 
+	return list;
+}
+
+static bool service_list_add_service(struct service_list **head,
+						struct service_list **tail,
+						bool primary, uint16_t start,
+						uint16_t end,
+						uint8_t uuid[BT_GATT_UUID_SIZE])
+{
+	struct service_list *list;
+
+	list = new_service_list(start, end, primary, uuid);
+	if (!list)
+		return false;
+
 	if (!(*head))
 		*head = *tail = list;
 	else {
@@ -364,6 +377,8 @@ struct discovery_op {
 	struct bt_gatt_client *client;
 	struct service_list *result_head, *result_tail, *cur_service;
 	struct chrc_data *cur_chrc;
+	uint16_t start;
+	uint16_t end;
 	int cur_chrc_index;
 	int ref_count;
 	void (*complete_func)(struct discovery_op *op, bool success,
@@ -634,6 +649,75 @@ done:
 	op->complete_func(op, success, att_ecode);
 }
 
+static void discover_secondary_cb(bool success, uint8_t att_ecode,
+						struct bt_gatt_result *result,
+						void *user_data)
+{
+	struct discovery_op *op = user_data;
+	struct bt_gatt_client *client = op->client;
+	struct bt_gatt_iter iter;
+	uint16_t start, end;
+	uint8_t uuid[BT_GATT_UUID_SIZE];
+	char uuid_str[MAX_LEN_UUID_STR];
+	struct service_list *service;
+
+	if (!success) {
+		util_debug(client->debug_callback, client->debug_data,
+					"Secondary service discovery failed."
+					" ATT ECODE: 0x%02x", att_ecode);
+		switch (att_ecode) {
+		case BT_ATT_ERROR_ATTRIBUTE_NOT_FOUND:
+		case BT_ATT_ERROR_UNSUPPORTED_GROUP_TYPE:
+			goto next;
+		default:
+			goto done;
+		}
+	}
+
+	if (!result || !bt_gatt_iter_init(&iter, result))
+		goto done;
+
+	util_debug(client->debug_callback, client->debug_data,
+					"Secondary services found: %u",
+					bt_gatt_result_service_count(result));
+
+	while (bt_gatt_iter_next_service(&iter, &start, &end, uuid)) {
+		uuid_to_string(uuid, uuid_str);
+		util_debug(client->debug_callback, client->debug_data,
+				"start: 0x%04x, end: 0x%04x, uuid: %s",
+				start, end, uuid_str);
+
+		/* Store the service */
+		service = new_service_list(start, end, false, uuid);
+		if (!service) {
+			util_debug(client->debug_callback, client->debug_data,
+						"Failed to create service");
+			goto done;
+		}
+
+		service_list_insert_services(&op->result_head, &op->result_tail,
+							service, service);
+	}
+
+next:
+	/* Sequentially discover the characteristics of all services */
+	op->cur_service = op->result_head;
+	if (bt_gatt_discover_characteristics(client->att,
+					op->cur_service->service.start_handle,
+					op->cur_service->service.end_handle,
+					discover_chrcs_cb,
+					discovery_op_ref(op),
+					discovery_op_unref))
+		return;
+
+	util_debug(client->debug_callback, client->debug_data,
+				"Failed to start characteristic discovery");
+	discovery_op_unref(op);
+
+done:
+	op->complete_func(op, false, att_ecode);
+}
+
 static void discover_primary_cb(bool success, uint8_t att_ecode,
 						struct bt_gatt_result *result,
 						void *user_data)
@@ -686,18 +770,17 @@ static void discover_primary_cb(bool success, uint8_t att_ecode,
 	if (!op->result_head)
 		goto done;
 
-	/* Sequentially discover the characteristics of all services */
+	/* Discover secondary services */
 	op->cur_service = op->result_head;
-	if (bt_gatt_discover_characteristics(client->att,
-					op->cur_service->service.start_handle,
-					op->cur_service->service.end_handle,
-					discover_chrcs_cb,
-					discovery_op_ref(op),
-					discovery_op_unref))
+	if (bt_gatt_discover_secondary_services(client->att, NULL,
+							op->start, op->end,
+							discover_secondary_cb,
+							discovery_op_ref(op),
+							discovery_op_unref))
 		return;
 
 	util_debug(client->debug_callback, client->debug_data,
-				"Failed to start characteristic discovery");
+				"Failed to start secondary service discovery");
 	discovery_op_unref(op);
 	success = false;
 
@@ -870,6 +953,8 @@ static void process_service_changed(struct bt_gatt_client *client,
 
 	op->client = client;
 	op->complete_func = service_changed_complete;
+	op->start = start_handle;
+	op->end = end_handle;
 
 	if (!bt_gatt_discover_primary_services(client->att, NULL,
 						start_handle, end_handle,
@@ -1002,6 +1087,8 @@ static bool gatt_client_init(struct bt_gatt_client *client, uint16_t mtu)
 
 	op->client = client;
 	op->complete_func = init_complete;
+	op->start = 0x0001;
+	op->end = 0xffff;
 
 	/* Configure the MTU */
 	if (!bt_gatt_exchange_mtu(client->att, MAX(BT_ATT_DEFAULT_LE_MTU, mtu),
-- 
1.9.3


^ permalink raw reply related

* Re: [bluetooth]  btusb issues
From: Andrei Emeltchenko @ 2014-10-23 12:29 UTC (permalink / raw)
  To: Patrick Shirkey; +Cc: linux-bluetooth
In-Reply-To: <49444.86.105.94.79.1414061963.squirrel@boosthardware.com>

Hi Patrick,

On Thu, Oct 23, 2014 at 09:59:23PM +1100, Patrick Shirkey wrote:
> 
> On Thu, October 23, 2014 7:59 pm, Patrick Shirkey wrote:
> > Hi,
> >
> > I have now got backports to run with bluez instead of bluedroid and the
> > btusb driver instead of rtk_btusb.
> >
> > However the android bluetooth system does not want to run for me.

So what is not working? Do you have logcat with "BlueZ" and "bluetothd" logs?

Best regards 
Andrei Emeltchenko 

> >
> 
> For reference purposes I have got bluez running on an 8723au chipset with
> the btusb driver from the "new" branch of the btusb git repo.
> 
> Here's an overview of the steps required:
> 
> - Patch the 3.4 kernel with the patch files from the aosp-bluez "misc" repo
> - Completely replace bluedroid in the android tree with bluez including
> the modifed bionic tree from the aosp-bluez repo
> - Cross compile the backports drivers replacing btusb.c with the version
> from the "new" branch in the git repo.
> - Copy the modules from the backports tree to the linux tree before
> building the firmware image. (overwrite the .ko files generated by the
> kernel build)
> - Include the firmware binary images from the git repo "new" branch in the
> android build so they are copied to the /system/etc/firmware/ folder in
> the firmware image
> - Modify the init.rc script to include the init.bluetooth.rc file
> - Modify the <platform>.mk file (in this case
> /device/softwinner/wing-k70/wing-k70.mk) to load the following modules on
> boot:
>     /system/vendor/modules/compat.ko
>     /system/vendor/modules/bluetooth.ko
>     /system/vendor/modules/btusb.ko
> 
> enable debug logging with :
> 
> setprop persist.sys.bluetooth.debug 1
> 
> 
> 
> # btmgmt info
> hci0:	addr CC:D2:9C:73:CB:45 version 6 manufacturer 93 class 0x000000
> 	supported settings: powered connectable fast-connectable discoverable
> bondable link-security ssp br/edr hs le advertising debug-keys privacy
> 	current settings: bondable ssp br/edr le
> 	name BlueZ for Android
> 	short name
> 
> 
> # haltest
> audio_hw_device_open returned -98
> hw_get_module_by_class returned -2
> thread_evt_cb: evt=ASSOCIATE_JVM
> if_bluetooth->init: BT_STATUS_SUCCESS
> get_profile_interface(handsfree) : 0xb6e58134
> get_profile_interface(a2dp) : 0xb6e580ec
> get_profile_interface(avrcp) : 0xb6e58100
> get_profile_interface(health) : 0xb6e583d0
> get_profile_interface(hidhost) : 0xb6e580a0
> get_profile_interface(pan) : 0xb6e580d0
> get_profile_interface(gatt) : 0xb6e581ac
> get_profile_interface(socket) : 0xb6e58094
> if_bluetooth->init: BT_STATUS_DONE
> if_av->init: BT_STATUS_SUCCESS
> if_rc->init: BT_STATUS_SUCCESS
> if_gatt->init: BT_STATUS_FAIL
> adapter_properties_cb: status=BT_STATUS_SUCCESS num_properties=1
> prop: type=BT_PROPERTY_UUIDS len=80 val={0000110e, 0000110c, 0000110a,
> 0000113b, 00001200}
> adapter_properties_cb: status=BT_STATUS_SUCCESS num_properties=1
> prop: type=BT_PROPERTY_UUIDS len=80 val={0000110e, 0000110c, 0000110a,
> 0000113b, 00001200}
> adapter_properties_cb: status=BT_STATUS_SUCCESS num_properties=1
> prop: type=BT_PROPERTY_UUIDS len=80 val={0000110e, 0000110c, 0000110a,
> 0000113b, 00001200}
> if_hf->init: BT_STATUS_FAIL
> if_hh->init: BT_STATUS_SUCCESS
> if_pan->init: BT_STATUS_FAIL
> adapter_properties_cb: status=BT_STATUS_SUCCESS num_properties=1
> prop: type=BT_PROPERTY_UUIDS len=80 val={0000110e, 0000110c, 0000110a,
> 0000113b, 00001200}
> adapter_properties_cb: status=BT_STATUS_SUCCESS num_properties=1
> prop: type=BT_PROPERTY_UUIDS len=80 val={0000110e, 0000110c, 0000110a,
> 0000113b, 00001200}
> if_hl->init: BT_STATUS_SUCCESS
> >
> 
> 
> # btmgmt le on
> hci0 Set Low Energy complete, settings: bondable ssp br/edr le
> # btmgmt find
> Unable to start discovery. status 0x0f (Not Powered)
> # btmgmt power on
> hci0 Set Powered complete, settings: powered bondable ssp br/edr le
> # btmgmt find
> Discovery started
> hci0 dev_found: BC:6A:29:AB:2C:AA type LE Public rssi -44 flags 0x0000 AD
> flags 0x06 eir_len 25
> 
> 
> 
> 
> 
> --
> Patrick Shirkey
> Boost Hardware Ltd
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [bluetooth]  btusb issues
From: Patrick Shirkey @ 2014-10-23 10:59 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <65245.86.105.94.79.1414054796.squirrel@boosthardware.com>


On Thu, October 23, 2014 7:59 pm, Patrick Shirkey wrote:
> Hi,
>
> I have now got backports to run with bluez instead of bluedroid and the
> btusb driver instead of rtk_btusb.
>
> However the android bluetooth system does not want to run for me.
>

For reference purposes I have got bluez running on an 8723au chipset with
the btusb driver from the "new" branch of the btusb git repo.

Here's an overview of the steps required:

- Patch the 3.4 kernel with the patch files from the aosp-bluez "misc" repo
- Completely replace bluedroid in the android tree with bluez including
the modifed bionic tree from the aosp-bluez repo
- Cross compile the backports drivers replacing btusb.c with the version
from the "new" branch in the git repo.
- Copy the modules from the backports tree to the linux tree before
building the firmware image. (overwrite the .ko files generated by the
kernel build)
- Include the firmware binary images from the git repo "new" branch in the
android build so they are copied to the /system/etc/firmware/ folder in
the firmware image
- Modify the init.rc script to include the init.bluetooth.rc file
- Modify the <platform>.mk file (in this case
/device/softwinner/wing-k70/wing-k70.mk) to load the following modules on
boot:
    /system/vendor/modules/compat.ko
    /system/vendor/modules/bluetooth.ko
    /system/vendor/modules/btusb.ko

enable debug logging with :

setprop persist.sys.bluetooth.debug 1



# btmgmt info
hci0:	addr CC:D2:9C:73:CB:45 version 6 manufacturer 93 class 0x000000
	supported settings: powered connectable fast-connectable discoverable
bondable link-security ssp br/edr hs le advertising debug-keys privacy
	current settings: bondable ssp br/edr le
	name BlueZ for Android
	short name


# haltest
audio_hw_device_open returned -98
hw_get_module_by_class returned -2
thread_evt_cb: evt=ASSOCIATE_JVM
if_bluetooth->init: BT_STATUS_SUCCESS
get_profile_interface(handsfree) : 0xb6e58134
get_profile_interface(a2dp) : 0xb6e580ec
get_profile_interface(avrcp) : 0xb6e58100
get_profile_interface(health) : 0xb6e583d0
get_profile_interface(hidhost) : 0xb6e580a0
get_profile_interface(pan) : 0xb6e580d0
get_profile_interface(gatt) : 0xb6e581ac
get_profile_interface(socket) : 0xb6e58094
if_bluetooth->init: BT_STATUS_DONE
if_av->init: BT_STATUS_SUCCESS
if_rc->init: BT_STATUS_SUCCESS
if_gatt->init: BT_STATUS_FAIL
adapter_properties_cb: status=BT_STATUS_SUCCESS num_properties=1
prop: type=BT_PROPERTY_UUIDS len=80 val={0000110e, 0000110c, 0000110a,
0000113b, 00001200}
adapter_properties_cb: status=BT_STATUS_SUCCESS num_properties=1
prop: type=BT_PROPERTY_UUIDS len=80 val={0000110e, 0000110c, 0000110a,
0000113b, 00001200}
adapter_properties_cb: status=BT_STATUS_SUCCESS num_properties=1
prop: type=BT_PROPERTY_UUIDS len=80 val={0000110e, 0000110c, 0000110a,
0000113b, 00001200}
if_hf->init: BT_STATUS_FAIL
if_hh->init: BT_STATUS_SUCCESS
if_pan->init: BT_STATUS_FAIL
adapter_properties_cb: status=BT_STATUS_SUCCESS num_properties=1
prop: type=BT_PROPERTY_UUIDS len=80 val={0000110e, 0000110c, 0000110a,
0000113b, 00001200}
adapter_properties_cb: status=BT_STATUS_SUCCESS num_properties=1
prop: type=BT_PROPERTY_UUIDS len=80 val={0000110e, 0000110c, 0000110a,
0000113b, 00001200}
if_hl->init: BT_STATUS_SUCCESS
>


# btmgmt le on
hci0 Set Low Energy complete, settings: bondable ssp br/edr le
# btmgmt find
Unable to start discovery. status 0x0f (Not Powered)
# btmgmt power on
hci0 Set Powered complete, settings: powered bondable ssp br/edr le
# btmgmt find
Discovery started
hci0 dev_found: BC:6A:29:AB:2C:AA type LE Public rssi -44 flags 0x0000 AD
flags 0x06 eir_len 25





--
Patrick Shirkey
Boost Hardware Ltd

^ permalink raw reply

* Re: [PATCH v3 bluetooth-next 0/4] 6lowpan: Move skb delivery out of IPHC
From: Alexander Aring @ 2014-10-23 10:30 UTC (permalink / raw)
  To: Martin Townsend
  Cc: Martin Townsend, linux-bluetooth, linux-wpan, marcel,
	jukka.rissanen
In-Reply-To: <5448CFA8.3020604@xsilon.com>

Hi Martin,

On Thu, Oct 23, 2014 at 10:51:36AM +0100, Martin Townsend wrote:
> Hi Alex,
> 
> Looks like the SKB is now non-linear which causes the skb_put to assert.  Maybe skb_linearlize will help[0]
> 
> I'll also take a look.

yes, I did also take a fast look at:

"kernel BUG at net/core/skbuff.c:1275!"

But why occurs this now? I think you didn't change anything in this
behaviour in the sequence of skb_put, etc...



I know now why this happens, maybe I can't test it currently fast.

In file net/ieee802154/6lowpan_rtnl.c at function "lowpan_rcv"

case LOWPAN_DISPATCH_FRAG1:     /* first fragment header */
	ret = lowpan_frag_rcv(skb, LOWPAN_DISPATCH_FRAG1);
	if (ret == 1) {
		ret = iphc_decompress(skb, &hdr);
		if (ret < 0) 
			goto drop;
	}
	break;
case LOWPAN_DISPATCH_FRAGN:     /* next fragments headers */
	ret = lowpan_frag_rcv(skb, LOWPAN_DISPATCH_FRAGN);
	if (ret == 1) {
		ret = iphc_decompress(skb, &hdr);
		if (ret < 0) 
			goto drop;
	}
	break;

later you do _ALWAYS_ a "lowpan_give_skb_to_devices". But you changed
now the behaviour, because in case of LOWPAN_DISPATCH_FRAG1 or
LOWPAN_DISPATCH_FRAGN should lowpan_give_skb_to_devices only called when
lowpan_frag_rcv returns 1 and after iphc_decompress.

I think that's your problem. Always call lowpan_give_skb_to_devices
seems to be 100% wrong.

- Alex

^ permalink raw reply

* Re: [PATCHv2 1/3] bnep: Add error print and return errno instead of -1
From: Luiz Augusto von Dentz @ 2014-10-23 10:23 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1413984870-24023-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

On Wed, Oct 22, 2014 at 4:34 PM, Andrei Emeltchenko
<Andrei.Emeltchenko.news@gmail.com> wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>
> ---
>  profiles/network/bnep.c | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/profiles/network/bnep.c b/profiles/network/bnep.c
> index 927367c..f8fcd1f 100644
> --- a/profiles/network/bnep.c
> +++ b/profiles/network/bnep.c
> @@ -219,7 +219,7 @@ static int bnep_if_up(const char *devname)
>  static int bnep_if_down(const char *devname)
>  {
>         struct ifreq ifr;
> -       int sk, err;
> +       int sk, err = 0;
>
>         sk = socket(AF_INET, SOCK_DGRAM, 0);
>
> @@ -229,16 +229,15 @@ static int bnep_if_down(const char *devname)
>         ifr.ifr_flags &= ~IFF_UP;
>
>         /* Bring down the interface */
> -       err = ioctl(sk, SIOCSIFFLAGS, (void *) &ifr);
> +       if (ioctl(sk, SIOCSIFFLAGS, (void *) &ifr) < 0) {
> +               err = -errno;
> +               error("bnep: Could not bring down %s: %s(%d)",
> +                                               devname, strerror(-err), -err);
> +       }
>
>         close(sk);
>
> -       if (err < 0) {
> -               error("bnep: Could not bring down %s", devname);
> -               return err;
> -       }
> -
> -       return 0;
> +       return err;
>  }
>
>  static gboolean bnep_watchdog_cb(GIOChannel *chan, GIOCondition cond,
> --
> 1.9.1

Applied, thanks.

-- 
Luiz Augusto von Dentz

^ permalink raw reply

* [PATCHv6 14/14] shared/gatt: Fix searching descriptors
From: Marcin Kraglak @ 2014-10-23 10:15 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1414059337-12040-1-git-send-email-marcin.kraglak@tieto.com>

Descriptor discovery range started from characteristic value handle + 1
and end with characteristic end handle. If characteristic value handle
is 0xffff, then discovery range was set to 0x0000-0xffff.
Found during PTS test case TC_GAD_CL_BV_03_C.
---
 src/shared/gatt-client.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c
index 1c50d82..f884365 100644
--- a/src/shared/gatt-client.c
+++ b/src/shared/gatt-client.c
@@ -706,8 +706,8 @@ static void discover_chrcs_cb(bool success, uint8_t att_ecode,
 	for (i = 0; i < chrc_count; i++) {
 		op->cur_chrc_index = i;
 		op->cur_chrc = chrcs + i;
-		desc_start = chrcs[i].chrc_external.value_handle + 1;
-		if (desc_start > chrcs[i].chrc_external.end_handle)
+		desc_start = chrcs[i].chrc_external.value_handle;
+		if (desc_start++ == chrcs[i].chrc_external.end_handle)
 			continue;
 
 		if (bt_gatt_discover_descriptors(client->att, desc_start,
-- 
1.9.3


^ permalink raw reply related

* [PATCHv6 13/14] tools/btgatt-client: Print found include services
From: Marcin Kraglak @ 2014-10-23 10:15 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1414059337-12040-1-git-send-email-marcin.kraglak@tieto.com>

---
 tools/btgatt-client.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/tools/btgatt-client.c b/tools/btgatt-client.c
index d21bc34..b7bfa24 100644
--- a/tools/btgatt-client.c
+++ b/tools/btgatt-client.c
@@ -174,7 +174,9 @@ static void print_uuid(const uint8_t uuid[16])
 static void print_service(const bt_gatt_service_t *service)
 {
 	struct bt_gatt_characteristic_iter iter;
+	struct bt_gatt_incl_service_iter include_iter;
 	const bt_gatt_characteristic_t *chrc;
+	const bt_gatt_included_service_t *incl;
 	size_t i;
 
 	if (!bt_gatt_characteristic_iter_init(&iter, service)) {
@@ -182,12 +184,25 @@ static void print_service(const bt_gatt_service_t *service)
 		return;
 	}
 
+	if (!bt_gatt_include_service_iter_init(&include_iter, service)) {
+		PRLOG("Failed to initialize include service iterator\n");
+		return;
+	}
+
 	printf(COLOR_RED "service" COLOR_OFF " - start: 0x%04x, "
 				"end: 0x%04x, type: %s, uuid: ",
 				service->start_handle, service->end_handle,
 				service->primary ? "primary" : "secondary");
 	print_uuid(service->uuid);
 
+	while (bt_gatt_include_service_iter_next(&include_iter, &incl)) {
+		printf("\t  " COLOR_GREEN "include" COLOR_OFF " - handle: "
+					"0x%04x, - start: 0x%04x, end: 0x%04x,"
+					"uuid: ", incl->handle,
+					incl->start_handle, incl->end_handle);
+		print_uuid(incl->uuid);
+	}
+
 	while (bt_gatt_characteristic_iter_next(&iter, &chrc)) {
 		printf("\t  " COLOR_YELLOW "charac" COLOR_OFF
 				" - start: 0x%04x, end: 0x%04x, "
-- 
1.9.3


^ permalink raw reply related

* [PATCHv6 12/14] shared/gatt: Add gatt-client include service iterator
From: Marcin Kraglak @ 2014-10-23 10:15 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1414059337-12040-1-git-send-email-marcin.kraglak@tieto.com>

It will allow user to take value, handle, start and end handle
of included service.
---
 src/shared/gatt-client.c | 30 ++++++++++++++++++++++++++++++
 src/shared/gatt-client.h | 10 ++++++++++
 2 files changed, 40 insertions(+)

diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c
index b2c33e3..1c50d82 100644
--- a/src/shared/gatt-client.c
+++ b/src/shared/gatt-client.c
@@ -1666,6 +1666,36 @@ bool bt_gatt_characteristic_iter_next(struct bt_gatt_characteristic_iter *iter,
 	return true;
 }
 
+bool bt_gatt_include_service_iter_init(struct bt_gatt_incl_service_iter *iter,
+					const bt_gatt_service_t *service)
+{
+	if (!iter || !service)
+		return false;
+
+	memset(iter, 0, sizeof(*iter));
+	iter->service = (struct service_list *) service;
+
+	return true;
+}
+
+bool bt_gatt_include_service_iter_next(struct bt_gatt_incl_service_iter *iter,
+					const bt_gatt_included_service_t **incl)
+{
+	struct service_list *service;
+
+	if (!iter || !incl)
+		return false;
+
+	service = iter->service;
+
+	if (iter->pos >= service->num_includes)
+		return false;
+
+	*incl = &service->includes[iter->pos++];
+
+	return true;
+}
+
 struct read_op {
 	bt_gatt_client_read_callback_t callback;
 	void *user_data;
diff --git a/src/shared/gatt-client.h b/src/shared/gatt-client.h
index 05b4838..bf4e7bb 100644
--- a/src/shared/gatt-client.h
+++ b/src/shared/gatt-client.h
@@ -113,6 +113,11 @@ struct bt_gatt_characteristic_iter {
 	size_t pos;
 };
 
+struct bt_gatt_incl_service_iter {
+	void *service;
+	size_t pos;
+};
+
 bool bt_gatt_service_iter_init(struct bt_gatt_service_iter *iter,
 						struct bt_gatt_client *client);
 bool bt_gatt_service_iter_next(struct bt_gatt_service_iter *iter,
@@ -129,6 +134,11 @@ bool bt_gatt_characteristic_iter_init(struct bt_gatt_characteristic_iter *iter,
 bool bt_gatt_characteristic_iter_next(struct bt_gatt_characteristic_iter *iter,
 					const bt_gatt_characteristic_t **chrc);
 
+bool bt_gatt_include_service_iter_init(struct bt_gatt_incl_service_iter *iter,
+					const bt_gatt_service_t *service);
+bool bt_gatt_include_service_iter_next(struct bt_gatt_incl_service_iter *iter,
+					const bt_gatt_included_service_t **inc);
+
 typedef void (*bt_gatt_client_read_callback_t)(bool success, uint8_t att_ecode,
 					const uint8_t *value, uint16_t length,
 					void *user_data);
-- 
1.9.3


^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox