diff options
-rw-r--r-- | include/net/bluetooth/l2cap.h | 4 | ||||
-rw-r--r-- | net/bluetooth/l2cap_core.c | 40 | ||||
-rw-r--r-- | net/bluetooth/l2cap_sock.c | 7 |
3 files changed, 24 insertions, 27 deletions
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index ec56d8861a4e..7a215a7f9e39 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h | |||
@@ -314,6 +314,8 @@ struct l2cap_chan { | |||
314 | struct timer_list retrans_timer; | 314 | struct timer_list retrans_timer; |
315 | struct timer_list monitor_timer; | 315 | struct timer_list monitor_timer; |
316 | struct timer_list ack_timer; | 316 | struct timer_list ack_timer; |
317 | struct sk_buff *tx_send_head; | ||
318 | struct sk_buff_head tx_q; | ||
317 | struct sk_buff_head srej_q; | 319 | struct sk_buff_head srej_q; |
318 | struct sk_buff_head busy_q; | 320 | struct sk_buff_head busy_q; |
319 | struct work_struct busy_work; | 321 | struct work_struct busy_work; |
@@ -355,7 +357,6 @@ struct l2cap_conn { | |||
355 | 357 | ||
356 | /* ----- L2CAP socket info ----- */ | 358 | /* ----- L2CAP socket info ----- */ |
357 | #define l2cap_pi(sk) ((struct l2cap_pinfo *) sk) | 359 | #define l2cap_pi(sk) ((struct l2cap_pinfo *) sk) |
358 | #define TX_QUEUE(sk) (&l2cap_pi(sk)->tx_queue) | ||
359 | 360 | ||
360 | struct l2cap_pinfo { | 361 | struct l2cap_pinfo { |
361 | struct bt_sock bt; | 362 | struct bt_sock bt; |
@@ -384,7 +385,6 @@ struct l2cap_pinfo { | |||
384 | 385 | ||
385 | __le16 sport; | 386 | __le16 sport; |
386 | 387 | ||
387 | struct sk_buff_head tx_queue; | ||
388 | struct l2cap_conn *conn; | 388 | struct l2cap_conn *conn; |
389 | struct l2cap_chan *chan; | 389 | struct l2cap_chan *chan; |
390 | }; | 390 | }; |
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 5fc852a9ae59..97827506dc94 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -240,7 +240,7 @@ void l2cap_chan_del(struct l2cap_chan *chan, int err) | |||
240 | l2cap_pi(sk)->conf_state & L2CAP_CONF_INPUT_DONE)) | 240 | l2cap_pi(sk)->conf_state & L2CAP_CONF_INPUT_DONE)) |
241 | goto free; | 241 | goto free; |
242 | 242 | ||
243 | skb_queue_purge(TX_QUEUE(sk)); | 243 | skb_queue_purge(&chan->tx_q); |
244 | 244 | ||
245 | if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) { | 245 | if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) { |
246 | struct srej_list *l, *tmp; | 246 | struct srej_list *l, *tmp; |
@@ -477,7 +477,7 @@ void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *chan, in | |||
477 | 477 | ||
478 | sk = chan->sk; | 478 | sk = chan->sk; |
479 | 479 | ||
480 | skb_queue_purge(TX_QUEUE(sk)); | 480 | skb_queue_purge(&chan->tx_q); |
481 | 481 | ||
482 | if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) { | 482 | if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) { |
483 | del_timer(&chan->retrans_timer); | 483 | del_timer(&chan->retrans_timer); |
@@ -996,15 +996,14 @@ static void l2cap_retrans_timeout(unsigned long arg) | |||
996 | 996 | ||
997 | static void l2cap_drop_acked_frames(struct l2cap_chan *chan) | 997 | static void l2cap_drop_acked_frames(struct l2cap_chan *chan) |
998 | { | 998 | { |
999 | struct sock *sk = chan->sk; | ||
1000 | struct sk_buff *skb; | 999 | struct sk_buff *skb; |
1001 | 1000 | ||
1002 | while ((skb = skb_peek(TX_QUEUE(sk))) && | 1001 | while ((skb = skb_peek(&chan->tx_q)) && |
1003 | chan->unacked_frames) { | 1002 | chan->unacked_frames) { |
1004 | if (bt_cb(skb)->tx_seq == chan->expected_ack_seq) | 1003 | if (bt_cb(skb)->tx_seq == chan->expected_ack_seq) |
1005 | break; | 1004 | break; |
1006 | 1005 | ||
1007 | skb = skb_dequeue(TX_QUEUE(sk)); | 1006 | skb = skb_dequeue(&chan->tx_q); |
1008 | kfree_skb(skb); | 1007 | kfree_skb(skb); |
1009 | 1008 | ||
1010 | chan->unacked_frames--; | 1009 | chan->unacked_frames--; |
@@ -1037,7 +1036,7 @@ void l2cap_streaming_send(struct l2cap_chan *chan) | |||
1037 | struct l2cap_pinfo *pi = l2cap_pi(sk); | 1036 | struct l2cap_pinfo *pi = l2cap_pi(sk); |
1038 | u16 control, fcs; | 1037 | u16 control, fcs; |
1039 | 1038 | ||
1040 | while ((skb = skb_dequeue(TX_QUEUE(sk)))) { | 1039 | while ((skb = skb_dequeue(&chan->tx_q))) { |
1041 | control = get_unaligned_le16(skb->data + L2CAP_HDR_SIZE); | 1040 | control = get_unaligned_le16(skb->data + L2CAP_HDR_SIZE); |
1042 | control |= chan->next_tx_seq << L2CAP_CTRL_TXSEQ_SHIFT; | 1041 | control |= chan->next_tx_seq << L2CAP_CTRL_TXSEQ_SHIFT; |
1043 | put_unaligned_le16(control, skb->data + L2CAP_HDR_SIZE); | 1042 | put_unaligned_le16(control, skb->data + L2CAP_HDR_SIZE); |
@@ -1060,7 +1059,7 @@ static void l2cap_retransmit_one_frame(struct l2cap_chan *chan, u8 tx_seq) | |||
1060 | struct sk_buff *skb, *tx_skb; | 1059 | struct sk_buff *skb, *tx_skb; |
1061 | u16 control, fcs; | 1060 | u16 control, fcs; |
1062 | 1061 | ||
1063 | skb = skb_peek(TX_QUEUE(sk)); | 1062 | skb = skb_peek(&chan->tx_q); |
1064 | if (!skb) | 1063 | if (!skb) |
1065 | return; | 1064 | return; |
1066 | 1065 | ||
@@ -1068,10 +1067,10 @@ static void l2cap_retransmit_one_frame(struct l2cap_chan *chan, u8 tx_seq) | |||
1068 | if (bt_cb(skb)->tx_seq == tx_seq) | 1067 | if (bt_cb(skb)->tx_seq == tx_seq) |
1069 | break; | 1068 | break; |
1070 | 1069 | ||
1071 | if (skb_queue_is_last(TX_QUEUE(sk), skb)) | 1070 | if (skb_queue_is_last(&chan->tx_q, skb)) |
1072 | return; | 1071 | return; |
1073 | 1072 | ||
1074 | } while ((skb = skb_queue_next(TX_QUEUE(sk), skb))); | 1073 | } while ((skb = skb_queue_next(&chan->tx_q, skb))); |
1075 | 1074 | ||
1076 | if (chan->remote_max_tx && | 1075 | if (chan->remote_max_tx && |
1077 | bt_cb(skb)->retries == chan->remote_max_tx) { | 1076 | bt_cb(skb)->retries == chan->remote_max_tx) { |
@@ -1112,7 +1111,7 @@ int l2cap_ertm_send(struct l2cap_chan *chan) | |||
1112 | if (sk->sk_state != BT_CONNECTED) | 1111 | if (sk->sk_state != BT_CONNECTED) |
1113 | return -ENOTCONN; | 1112 | return -ENOTCONN; |
1114 | 1113 | ||
1115 | while ((skb = sk->sk_send_head) && (!l2cap_tx_window_full(chan))) { | 1114 | while ((skb = chan->tx_send_head) && (!l2cap_tx_window_full(chan))) { |
1116 | 1115 | ||
1117 | if (chan->remote_max_tx && | 1116 | if (chan->remote_max_tx && |
1118 | bt_cb(skb)->retries == chan->remote_max_tx) { | 1117 | bt_cb(skb)->retries == chan->remote_max_tx) { |
@@ -1153,10 +1152,10 @@ int l2cap_ertm_send(struct l2cap_chan *chan) | |||
1153 | 1152 | ||
1154 | chan->frames_sent++; | 1153 | chan->frames_sent++; |
1155 | 1154 | ||
1156 | if (skb_queue_is_last(TX_QUEUE(sk), skb)) | 1155 | if (skb_queue_is_last(&chan->tx_q, skb)) |
1157 | sk->sk_send_head = NULL; | 1156 | chan->tx_send_head = NULL; |
1158 | else | 1157 | else |
1159 | sk->sk_send_head = skb_queue_next(TX_QUEUE(sk), skb); | 1158 | chan->tx_send_head = skb_queue_next(&chan->tx_q, skb); |
1160 | 1159 | ||
1161 | nsent++; | 1160 | nsent++; |
1162 | } | 1161 | } |
@@ -1166,11 +1165,10 @@ int l2cap_ertm_send(struct l2cap_chan *chan) | |||
1166 | 1165 | ||
1167 | static int l2cap_retransmit_frames(struct l2cap_chan *chan) | 1166 | static int l2cap_retransmit_frames(struct l2cap_chan *chan) |
1168 | { | 1167 | { |
1169 | struct sock *sk = chan->sk; | ||
1170 | int ret; | 1168 | int ret; |
1171 | 1169 | ||
1172 | if (!skb_queue_empty(TX_QUEUE(sk))) | 1170 | if (!skb_queue_empty(&chan->tx_q)) |
1173 | sk->sk_send_head = TX_QUEUE(sk)->next; | 1171 | chan->tx_send_head = chan->tx_q.next; |
1174 | 1172 | ||
1175 | chan->next_tx_seq = chan->expected_ack_seq; | 1173 | chan->next_tx_seq = chan->expected_ack_seq; |
1176 | ret = l2cap_ertm_send(chan); | 1174 | ret = l2cap_ertm_send(chan); |
@@ -1384,9 +1382,9 @@ int l2cap_sar_segment_sdu(struct l2cap_chan *chan, struct msghdr *msg, size_t le | |||
1384 | len -= buflen; | 1382 | len -= buflen; |
1385 | size += buflen; | 1383 | size += buflen; |
1386 | } | 1384 | } |
1387 | skb_queue_splice_tail(&sar_queue, TX_QUEUE(sk)); | 1385 | skb_queue_splice_tail(&sar_queue, &chan->tx_q); |
1388 | if (sk->sk_send_head == NULL) | 1386 | if (chan->tx_send_head == NULL) |
1389 | sk->sk_send_head = sar_queue.next; | 1387 | chan->tx_send_head = sar_queue.next; |
1390 | 1388 | ||
1391 | return size; | 1389 | return size; |
1392 | } | 1390 | } |
@@ -2319,7 +2317,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr | |||
2319 | 2317 | ||
2320 | chan->next_tx_seq = 0; | 2318 | chan->next_tx_seq = 0; |
2321 | chan->expected_tx_seq = 0; | 2319 | chan->expected_tx_seq = 0; |
2322 | __skb_queue_head_init(TX_QUEUE(sk)); | 2320 | skb_queue_head_init(&chan->tx_q); |
2323 | if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) | 2321 | if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) |
2324 | l2cap_ertm_init(chan); | 2322 | l2cap_ertm_init(chan); |
2325 | 2323 | ||
@@ -2410,7 +2408,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr | |||
2410 | sk->sk_state = BT_CONNECTED; | 2408 | sk->sk_state = BT_CONNECTED; |
2411 | chan->next_tx_seq = 0; | 2409 | chan->next_tx_seq = 0; |
2412 | chan->expected_tx_seq = 0; | 2410 | chan->expected_tx_seq = 0; |
2413 | __skb_queue_head_init(TX_QUEUE(sk)); | 2411 | skb_queue_head_init(&chan->tx_q); |
2414 | if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) | 2412 | if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) |
2415 | l2cap_ertm_init(chan); | 2413 | l2cap_ertm_init(chan); |
2416 | 2414 | ||
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 16a223bfa8f5..b2bfa1e0d74e 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c | |||
@@ -764,10 +764,10 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct ms | |||
764 | err = PTR_ERR(skb); | 764 | err = PTR_ERR(skb); |
765 | goto done; | 765 | goto done; |
766 | } | 766 | } |
767 | __skb_queue_tail(TX_QUEUE(sk), skb); | 767 | __skb_queue_tail(&pi->chan->tx_q, skb); |
768 | 768 | ||
769 | if (sk->sk_send_head == NULL) | 769 | if (pi->chan->tx_send_head == NULL) |
770 | sk->sk_send_head = skb; | 770 | pi->chan->tx_send_head = skb; |
771 | 771 | ||
772 | } else { | 772 | } else { |
773 | /* Segment SDU into multiples PDUs */ | 773 | /* Segment SDU into multiples PDUs */ |
@@ -1017,7 +1017,6 @@ void l2cap_sock_init(struct sock *sk, struct sock *parent) | |||
1017 | 1017 | ||
1018 | /* Default config options */ | 1018 | /* Default config options */ |
1019 | pi->flush_to = L2CAP_DEFAULT_FLUSH_TO; | 1019 | pi->flush_to = L2CAP_DEFAULT_FLUSH_TO; |
1020 | skb_queue_head_init(TX_QUEUE(sk)); | ||
1021 | } | 1020 | } |
1022 | 1021 | ||
1023 | static struct proto l2cap_proto = { | 1022 | static struct proto l2cap_proto = { |