ERTM state machine changes, part 1
Subsystems (2)
v4 cover ERTM state machine changes, part 1
This is the first of several patch series to rework the ERTM state machine.
PATCHv1: Four patches, two patches updating header files were merged
PATCHv2: Reworked utility functions for seq_lists and control headers.
PATCHv3: Removed extra debug output, added error handling for
allocation failure, used some long lines at Marcel's request, removed an unnecessary variable, and added a __set_control function.
PATCHv4: Use roundup_pow_of_two macro and kmalloc
Mat Martineau (2):
Bluetooth: Add the l2cap_seq_list structure for tracking frames
(Acked-by Marcel at v2, but added new error handling code in v3)
Bluetooth: Functions for handling ERTM control fields
include/net/bluetooth/l2cap.h | 12 ++ net/bluetooth/l2cap_core.c | 247 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 251 insertions(+), 8 deletions(-)
Signature · 6 lines
1.7.9.4 -- Mat Martineau Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
PATCH v4 1/2 Bluetooth: Add the l2cap_seq_list structure for tracking frames
A sequence list is a data structure used to track frames that need to be retransmitted, and frames that have been requested for retransmission by the remote device. It can compactly represent a list of sequence numbers within the ERTM transmit window. Memory for the list is allocated once at connection time, and common operations in ERTM are O(1).
--- include/net/bluetooth/l2cap.h | 12 ++++ net/bluetooth/l2cap_core.c | 148 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 152 insertions(+), 8 deletions(-)
include/net/bluetooth/l2cap.h +12 -0
@@ -407,6 +407,16 @@ struct l2cap_conn_param_update_rsp {#define L2CAP_CONN_PARAM_REJECTED 0x0001/* ----- L2CAP channels and connections ----- */ +struct l2cap_seq_list { +__u16 head; +__u16 tail; +__u16 mask; +__u16 *list; +}; + +#define L2CAP_SEQ_LIST_CLEAR 0xFFFF +#define L2CAP_SEQ_LIST_TAIL 0x8000 +struct srej_list {__u16 tx_seq;struct list_head list;
@@ -501,6 +511,8 @@ struct l2cap_chan {struct sk_buff *tx_send_head;struct sk_buff_head tx_q;struct sk_buff_head srej_q; +struct l2cap_seq_list srej_list; +struct l2cap_seq_list retrans_list;struct list_head srej_l;struct list_head list;
net/bluetooth/l2cap_core.c +140 -8
209 lines not on this page · raw message
Signature · 6 lines
1.7.9.4 -- Mat Martineau Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
Re: [PATCHv4 1/2] Bluetooth: Add the l2cap_seq_list structure for tracking frames
Hi Mat,
Quoted 7 lines
A sequence list is a data structure used to track frames that need to be retransmitted, and frames that have been requested for retransmission by the remote device. It can compactly represent a list of sequence numbers within the ERTM transmit window. Memory for the list is allocated once at connection time, and common operations in ERTM are O(1).
Quoted 5 lines
Signed-off-by Mat Martineau <[email protected]>--- include/net/bluetooth/l2cap.h | 12 ++++ net/bluetooth/l2cap_core.c | 148 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 152 insertions(+), 8 deletions(-)
Regards
Marcel
PATCH v4 2/2 Bluetooth: Functions for handling ERTM control fields
In reply to Mat MartineauThese functions encode or decode ERTM control fields (extended or enhanced) to or from the new l2cap_ctrl structure.
--- net/bluetooth/l2cap_core.c | 99 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+)
net/bluetooth/l2cap_core.c +99 -0
@@ -776,6 +776,103 @@ static inline void l2cap_send_rr_or_rnr(struct l2cap_chan *chan, u32 control)l2cap_send_sframe (chan, control); } +static u16 __pack_enhanced_control (struct l2cap_ctrl *control) +{ +u16 packed; + + packed = control->reqseq <<L2CAP_CTRL_REQSEQ_SHIFT ; + packed |= control->final <<L2CAP_CTRL_FINAL_SHIFT ; + +if (control->sframe) { + packed |= control->poll <<L2CAP_CTRL_POLL_SHIFT ; + packed |= control->super <<L2CAP_CTRL_SUPER_SHIFT ; + packed |=L2CAP_CTRL_FRAME_TYPE ; + }else { + packed |= control->sar <<L2CAP_CTRL_SAR_SHIFT ; + packed |= control->txseq <<L2CAP_CTRL_TXSEQ_SHIFT ; + } + +return packed; +} + +static void __get_enhanced_control (u16 enh,struct l2cap_ctrl *control) +{ + control->reqseq = (enh &L2CAP_CTRL_REQSEQ ) >>L2CAP_CTRL_REQSEQ_SHIFT ; + control->final = (enh &L2CAP_CTRL_FINAL ) >>L2CAP_CTRL_FINAL_SHIFT ; + +if (enh &L2CAP_CTRL_FRAME_TYPE ) { +/* S-Frame */ + control->sframe =1 ; + control->poll = (enh &L2CAP_CTRL_POLL ) >>L2CAP_CTRL_POLL_SHIFT ; + control->super = (enh &L2CAP_CTRL_SUPERVISE ) >>L2CAP_CTRL_SUPER_SHIFT ; + + control->sar =0 ; + control->txseq =0 ; + }else { +/* I-Frame */ + control->sframe =0 ; + control->sar = (enh &L2CAP_CTRL_SAR ) >>L2CAP_CTRL_SAR_SHIFT ; + control->txseq = (enh &L2CAP_CTRL_TXSEQ ) >>L2CAP_CTRL_TXSEQ_SHIFT ; + + control->poll =0 ; + control->super =0 ; + } +} + +static u32 __pack_extended_control (struct l2cap_ctrl *control) +{ +u32 packed; + + packed = control->reqseq <<L2CAP_EXT_CTRL_REQSEQ_SHIFT ; + packed |= control->final <<L2CAP_EXT_CTRL_FINAL_SHIFT ; + +if (control->sframe) { + packed |= control->poll <<L2CAP_EXT_CTRL_POLL_SHIFT ; + packed |= control->super <<L2CAP_EXT_CTRL_SUPER_SHIFT ; + packed |=L2CAP_EXT_CTRL_FRAME_TYPE ; + }else { + packed |= control->sar <<L2CAP_EXT_CTRL_SAR_SHIFT ; + packed |= control->txseq <<L2CAP_EXT_CTRL_TXSEQ_SHIFT ; + } + +return packed; +} + +static void __get_extended_control (u32 ext,struct l2cap_ctrl *control) +{ + control->reqseq = (ext &L2CAP_EXT_CTRL_REQSEQ ) >>L2CAP_EXT_CTRL_REQSEQ_SHIFT ; + control->final = (ext &L2CAP_EXT_CTRL_FINAL ) >>L2CAP_EXT_CTRL_FINAL_SHIFT ; + +if (ext &L2CAP_EXT_CTRL_FRAME_TYPE ) { +/* S-Frame */ + control->sframe =1 ; + control->poll = (ext &L2CAP_EXT_CTRL_POLL ) >>L2CAP_EXT_CTRL_POLL_SHIFT ; + control->super = (ext &L2CAP_EXT_CTRL_SUPERVISE ) >>L2CAP_EXT_CTRL_SUPER_SHIFT ; + + control->sar =0 ; + control->txseq =0 ; + }else { +/* I-Frame */ + control->sframe =0 ; + control->sar = (ext &L2CAP_EXT_CTRL_SAR ) >>L2CAP_EXT_CTRL_SAR_SHIFT ; + control->txseq = (ext &L2CAP_EXT_CTRL_TXSEQ ) >>L2CAP_EXT_CTRL_TXSEQ_SHIFT ; + + control->poll =0 ; + control->super =0 ; + } +} + +static void __set_control (struct l2cap_chan *chan,struct sk_buff *skb) +{ +if (test_bit (FLAG_EXT_CTRL , &chan->flags)) { +__get_extended_control (get_unaligned_le32 (skb->data), + &bt_cb (skb)->control); + }else { +__get_enhanced_control (get_unaligned_le16 (skb->data), + &bt_cb (skb)->control); + } +} +static inline int __l2cap_no_conn_pending (struct l2cap_chan *chan) {return !test_bit (CONF_CONNECT_PEND , &chan->conf_state);
@@ -4350,6 +4447,8 @@ static int l2cap_ertm_data_rcv(struct l2cap_chan *chan, struct sk_buff *skb)u16 req_seq;int len, next_tx_seq_offset, req_seq_offset; +__set_control (chan, skb); + control =__get_control (chan, skb->data);skb_pull (skb,__ctrl_size (chan)); len = skb->len;
Signature · 6 lines
1.7.9.4 -- Mat Martineau Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
Re: [PATCHv4 2/2] Bluetooth: Functions for handling ERTM control fields
Hi Mat,
Quoted 8 lines
These functions encode or decode ERTM control fields (extended or enhanced) to or from the new
l2cap_ctrlstructure.Signed-off-by Mat Martineau <[email protected]>--- net/bluetooth/l2cap_core.c | 99 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+)
Regards
Marcel
Re: [PATCHv4 2/2] Bluetooth: Functions for handling ERTM control fields
Gustavo (or Johan) -
Quoted 5 lines · Marcel Holtmann
Hi Mat,
Quoted 3 lines
These functions encode or decode ERTM control fields (extended or enhanced) to or from the new
l2cap_ctrlstructure.
Quoted 7 lines
Quoted 5 lines
Signed-off-by Mat Martineau <[email protected]>--- net/bluetooth/l2cap_core.c | 99 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+)Acked-by Marcel Holtmann <[email protected]>
Could you apply the two patches from this patchset?
Thanks,
--
Mat Martineau
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
Re: [PATCHv4 2/2] Bluetooth: Functions for handling ERTM control fields
In reply to Mat MartineauHi Mat,
Quoted 8 lines · Mat Martineau
These functions encode or decode ERTM control fields (extended or enhanced) to or from the new
l2cap_ctrlstructure.Signed-off-by Mat Martineau <[email protected]>--- net/bluetooth/l2cap_core.c | 99 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+)
Both patches were applied to bluetooth-next. thanks.
Gustavo
Re: [PATCHv4 2/2] Bluetooth: Functions for handling ERTM control fields
Hi Mat,
Quoted 11 lines · Gustavo Padovan
Hi Mat,
=20
* Mat Martineau <[email protected]> [2012-04-04 11:29:43 -0700]:
=20Quoted 7 lines
These functions encode or decode ERTM control fields (extended or enhanced) to or from the new
l2cap_ctrlstructure.
=20Signed-off-by Mat Martineau <[email protected]>---
net/bluetooth/l2cap_core.c| 99 ++++++++++++++++++++++++++++++++++++=
++++++++
Quoted 3 lines
Quoted 1 line
1 file changed, 99 insertions(+)=20
Both patches were applied to bluetooth-next. thanks.
net/bluetooth/l2cap_core.c:317:12: warning: =E2=80=98l2cap_seq_list_pop=E2= =80=99 defined but not used [-Wunused-function] net/bluetooth/l2cap_core.c:323:13: warning: =E2=80=98l2cap_seq_list_clear= =E2=80=99 defined but not used [-Wunused-function] net/bluetooth/l2cap_core.c:335:13: warning: =E2=80=98l2cap_seq_list_append= =E2=80=99 defined but not used [-Wunused-function] net/bluetooth/l2cap_core.c:780:12: warning: =E2=80=98__pack_enhanced_contro= l=E2=80=99 defined but not used [-Wunused-function] net/bluetooth/l2cap_core.c:823:12: warning: =E2=80=98__pack_extended_contro= l=E2=80=99 defined but not used [-Wunused-function]
So, this is not good, we can't just throw unused code here, they will gener= ate
warnings and I'll get complains from maintainers above me if I merge this. Both patches were reverted.
Gustavo