Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1461581 > unrolled thread
| Started by | Sebastian Reichel <sre@kernel.org> |
|---|---|
| First post | 2016-08-13 05:20 +0200 |
| Last post | 2016-08-16 10:00 +0200 |
| Articles | 4 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[RFC 4/7] Bluetooth: hci_uart: Add support for word alignment Sebastian Reichel <sre@kernel.org> - 2016-08-13 05:20 +0200
Re: [RFC 4/7] Bluetooth: hci_uart: Add support for word alignment Pavel Machek <pavel@ucw.cz> - 2016-08-14 11:00 +0200
Re: [RFC 4/7] Bluetooth: hci_uart: Add support for word alignment Marcel Holtmann <marcel@holtmann.org> - 2016-08-16 09:10 +0200
Re: [RFC 4/7] Bluetooth: hci_uart: Add support for word alignment Sebastian Reichel <sre@kernel.org> - 2016-08-16 10:00 +0200
| From | Sebastian Reichel <sre@kernel.org> |
|---|---|
| Date | 2016-08-13 05:20 +0200 |
| Subject | [RFC 4/7] Bluetooth: hci_uart: Add support for word alignment |
| Message-ID | <s5xEm-2xg-21@gated-at.bofh.it> |
This will be used by Nokia's H4+ protocol, which
adds padding to packets to reach word alignment.
---
drivers/bluetooth/hci_h4.c | 10 ++++++++++
drivers/bluetooth/hci_uart.h | 1 +
2 files changed, 11 insertions(+)
diff --git a/drivers/bluetooth/hci_h4.c b/drivers/bluetooth/hci_h4.c
index 635597b6e168..a934e4eb692b 100644
--- a/drivers/bluetooth/hci_h4.c
+++ b/drivers/bluetooth/hci_h4.c
@@ -253,11 +253,21 @@ struct sk_buff *h4_recv_buf(struct hci_dev *hdev, struct sk_buff *skb,
}
if (!dlen) {
+ if ((&pkts[i])->wordaligned && !(skb->len % 2)) {
+ buffer++;
+ count--;
+ }
+
/* No more data, complete frame */
(&pkts[i])->recv(hdev, skb);
skb = NULL;
}
} else {
+ if ((&pkts[i])->wordaligned && !(skb->len % 2)) {
+ buffer++;
+ count--;
+ }
+
/* Complete frame */
(&pkts[i])->recv(hdev, skb);
skb = NULL;
diff --git a/drivers/bluetooth/hci_uart.h b/drivers/bluetooth/hci_uart.h
index 839bad1d8152..a7d67aec3632 100644
--- a/drivers/bluetooth/hci_uart.h
+++ b/drivers/bluetooth/hci_uart.h
@@ -121,6 +121,7 @@ struct h4_recv_pkt {
u8 loff; /* Data length offset in header */
u8 lsize; /* Data length field size */
u16 maxlen; /* Max overall packet length */
+ bool wordaligned; /* packets are word aligned */
int (*recv)(struct hci_dev *hdev, struct sk_buff *skb);
};
--
2.8.1
[toc] | [next] | [standalone]
| From | Pavel Machek <pavel@ucw.cz> |
|---|---|
| Date | 2016-08-14 11:00 +0200 |
| Message-ID | <s5ZqW-5AD-13@gated-at.bofh.it> |
| In reply to | #1461581 |
On Sat 2016-08-13 05:14:35, Sebastian Reichel wrote: > This will be used by Nokia's H4+ protocol, which > adds padding to packets to reach word alignment. Add a sign-off. Acked-by: Pavel Machek <pavel@ucw.cz> Thanks, Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[toc] | [prev] | [next] | [standalone]
| From | Marcel Holtmann <marcel@holtmann.org> |
|---|---|
| Date | 2016-08-16 09:10 +0200 |
| Message-ID | <s6GFz-8pe-13@gated-at.bofh.it> |
| In reply to | #1461581 |
Hi Sebatian,
> This will be used by Nokia's H4+ protocol, which
> adds padding to packets to reach word alignment.
> ---
> drivers/bluetooth/hci_h4.c | 10 ++++++++++
> drivers/bluetooth/hci_uart.h | 1 +
> 2 files changed, 11 insertions(+)
>
> diff --git a/drivers/bluetooth/hci_h4.c b/drivers/bluetooth/hci_h4.c
> index 635597b6e168..a934e4eb692b 100644
> --- a/drivers/bluetooth/hci_h4.c
> +++ b/drivers/bluetooth/hci_h4.c
> @@ -253,11 +253,21 @@ struct sk_buff *h4_recv_buf(struct hci_dev *hdev, struct sk_buff *skb,
> }
>
> if (!dlen) {
> + if ((&pkts[i])->wordaligned && !(skb->len % 2)) {
> + buffer++;
> + count--;
> + }
> +
> /* No more data, complete frame */
> (&pkts[i])->recv(hdev, skb);
> skb = NULL;
> }
> } else {
> + if ((&pkts[i])->wordaligned && !(skb->len % 2)) {
> + buffer++;
> + count--;
> + }
> +
> /* Complete frame */
> (&pkts[i])->recv(hdev, skb);
> skb = NULL;
> diff --git a/drivers/bluetooth/hci_uart.h b/drivers/bluetooth/hci_uart.h
> index 839bad1d8152..a7d67aec3632 100644
> --- a/drivers/bluetooth/hci_uart.h
> +++ b/drivers/bluetooth/hci_uart.h
> @@ -121,6 +121,7 @@ struct h4_recv_pkt {
> u8 loff; /* Data length offset in header */
> u8 lsize; /* Data length field size */
> u16 maxlen; /* Max overall packet length */
> + bool wordaligned; /* packets are word aligned */
I wonder if not a u8 align would be a way better choice here. We set it to 1 for all existing packet types. And the Nokia driver can use 2 here.
> int (*recv)(struct hci_dev *hdev, struct sk_buff *skb);
Regards
Marcel
[toc] | [prev] | [next] | [standalone]
| From | Sebastian Reichel <sre@kernel.org> |
|---|---|
| Date | 2016-08-16 10:00 +0200 |
| Message-ID | <s6HrY-fU-27@gated-at.bofh.it> |
| In reply to | #1463468 |
[Multipart message — attachments visible in raw view] — view raw
Hi Marcel,
On Tue, Aug 16, 2016 at 09:05:19AM +0200, Marcel Holtmann wrote:
> Hi Sebatian,
>
> > This will be used by Nokia's H4+ protocol, which
> > adds padding to packets to reach word alignment.
> > ---
> > drivers/bluetooth/hci_h4.c | 10 ++++++++++
> > drivers/bluetooth/hci_uart.h | 1 +
> > 2 files changed, 11 insertions(+)
> >
> > diff --git a/drivers/bluetooth/hci_h4.c b/drivers/bluetooth/hci_h4.c
> > index 635597b6e168..a934e4eb692b 100644
> > --- a/drivers/bluetooth/hci_h4.c
> > +++ b/drivers/bluetooth/hci_h4.c
> > @@ -253,11 +253,21 @@ struct sk_buff *h4_recv_buf(struct hci_dev *hdev, struct sk_buff *skb,
> > }
> >
> > if (!dlen) {
> > + if ((&pkts[i])->wordaligned && !(skb->len % 2)) {
> > + buffer++;
> > + count--;
> > + }
> > +
> > /* No more data, complete frame */
> > (&pkts[i])->recv(hdev, skb);
> > skb = NULL;
> > }
> > } else {
> > + if ((&pkts[i])->wordaligned && !(skb->len % 2)) {
> > + buffer++;
> > + count--;
> > + }
> > +
> > /* Complete frame */
> > (&pkts[i])->recv(hdev, skb);
> > skb = NULL;
> > diff --git a/drivers/bluetooth/hci_uart.h b/drivers/bluetooth/hci_uart.h
> > index 839bad1d8152..a7d67aec3632 100644
> > --- a/drivers/bluetooth/hci_uart.h
> > +++ b/drivers/bluetooth/hci_uart.h
> > @@ -121,6 +121,7 @@ struct h4_recv_pkt {
> > u8 loff; /* Data length offset in header */
> > u8 lsize; /* Data length field size */
> > u16 maxlen; /* Max overall packet length */
> > + bool wordaligned; /* packets are word aligned */
>
> I wonder if not a u8 align would be a way better choice here. We
> set it to 1 for all existing packet types. And the Nokia driver
> can use 2 here.
Sounds less hacky than my approach. Also it made me notice, that my
code is not safe, since the buffer size is not checked. I will use
u8 align and fix the buffer size check.
-- Sebastian
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web