Commit 58d35f87effa0235181a24d55576aaa756ef7312

Authored by Gustavo F. Padovan
1 parent c916fbe45c

Bluetooth: Move tx queue to struct l2cap_chan

tx_q is the queue used by ERTM mode.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>

Showing 3 changed files with 24 additions and 27 deletions Side-by-side Diff

include/net/bluetooth/l2cap.h
... ... @@ -314,6 +314,8 @@
314 314 struct timer_list retrans_timer;
315 315 struct timer_list monitor_timer;
316 316 struct timer_list ack_timer;
  317 + struct sk_buff *tx_send_head;
  318 + struct sk_buff_head tx_q;
317 319 struct sk_buff_head srej_q;
318 320 struct sk_buff_head busy_q;
319 321 struct work_struct busy_work;
... ... @@ -355,7 +357,6 @@
355 357  
356 358 /* ----- L2CAP socket info ----- */
357 359 #define l2cap_pi(sk) ((struct l2cap_pinfo *) sk)
358   -#define TX_QUEUE(sk) (&l2cap_pi(sk)->tx_queue)
359 360  
360 361 struct l2cap_pinfo {
361 362 struct bt_sock bt;
... ... @@ -384,7 +385,6 @@
384 385  
385 386 __le16 sport;
386 387  
387   - struct sk_buff_head tx_queue;
388 388 struct l2cap_conn *conn;
389 389 struct l2cap_chan *chan;
390 390 };
net/bluetooth/l2cap_core.c
... ... @@ -240,7 +240,7 @@
240 240 l2cap_pi(sk)->conf_state & L2CAP_CONF_INPUT_DONE))
241 241 goto free;
242 242  
243   - skb_queue_purge(TX_QUEUE(sk));
  243 + skb_queue_purge(&chan->tx_q);
244 244  
245 245 if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) {
246 246 struct srej_list *l, *tmp;
... ... @@ -477,7 +477,7 @@
477 477  
478 478 sk = chan->sk;
479 479  
480   - skb_queue_purge(TX_QUEUE(sk));
  480 + skb_queue_purge(&chan->tx_q);
481 481  
482 482 if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) {
483 483 del_timer(&chan->retrans_timer);
484 484  
485 485  
... ... @@ -996,15 +996,14 @@
996 996  
997 997 static void l2cap_drop_acked_frames(struct l2cap_chan *chan)
998 998 {
999   - struct sock *sk = chan->sk;
1000 999 struct sk_buff *skb;
1001 1000  
1002   - while ((skb = skb_peek(TX_QUEUE(sk))) &&
  1001 + while ((skb = skb_peek(&chan->tx_q)) &&
1003 1002 chan->unacked_frames) {
1004 1003 if (bt_cb(skb)->tx_seq == chan->expected_ack_seq)
1005 1004 break;
1006 1005  
1007   - skb = skb_dequeue(TX_QUEUE(sk));
  1006 + skb = skb_dequeue(&chan->tx_q);
1008 1007 kfree_skb(skb);
1009 1008  
1010 1009 chan->unacked_frames--;
... ... @@ -1037,7 +1036,7 @@
1037 1036 struct l2cap_pinfo *pi = l2cap_pi(sk);
1038 1037 u16 control, fcs;
1039 1038  
1040   - while ((skb = skb_dequeue(TX_QUEUE(sk)))) {
  1039 + while ((skb = skb_dequeue(&chan->tx_q))) {
1041 1040 control = get_unaligned_le16(skb->data + L2CAP_HDR_SIZE);
1042 1041 control |= chan->next_tx_seq << L2CAP_CTRL_TXSEQ_SHIFT;
1043 1042 put_unaligned_le16(control, skb->data + L2CAP_HDR_SIZE);
... ... @@ -1060,7 +1059,7 @@
1060 1059 struct sk_buff *skb, *tx_skb;
1061 1060 u16 control, fcs;
1062 1061  
1063   - skb = skb_peek(TX_QUEUE(sk));
  1062 + skb = skb_peek(&chan->tx_q);
1064 1063 if (!skb)
1065 1064 return;
1066 1065  
1067 1066  
... ... @@ -1068,10 +1067,10 @@
1068 1067 if (bt_cb(skb)->tx_seq == tx_seq)
1069 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 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 1075 if (chan->remote_max_tx &&
1077 1076 bt_cb(skb)->retries == chan->remote_max_tx) {
... ... @@ -1112,7 +1111,7 @@
1112 1111 if (sk->sk_state != BT_CONNECTED)
1113 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 1116 if (chan->remote_max_tx &&
1118 1117 bt_cb(skb)->retries == chan->remote_max_tx) {
1119 1118  
... ... @@ -1153,10 +1152,10 @@
1153 1152  
1154 1153 chan->frames_sent++;
1155 1154  
1156   - if (skb_queue_is_last(TX_QUEUE(sk), skb))
1157   - sk->sk_send_head = NULL;
  1155 + if (skb_queue_is_last(&chan->tx_q, skb))
  1156 + chan->tx_send_head = NULL;
1158 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 1160 nsent++;
1162 1161 }
1163 1162  
... ... @@ -1166,11 +1165,10 @@
1166 1165  
1167 1166 static int l2cap_retransmit_frames(struct l2cap_chan *chan)
1168 1167 {
1169   - struct sock *sk = chan->sk;
1170 1168 int ret;
1171 1169  
1172   - if (!skb_queue_empty(TX_QUEUE(sk)))
1173   - sk->sk_send_head = TX_QUEUE(sk)->next;
  1170 + if (!skb_queue_empty(&chan->tx_q))
  1171 + chan->tx_send_head = chan->tx_q.next;
1174 1172  
1175 1173 chan->next_tx_seq = chan->expected_ack_seq;
1176 1174 ret = l2cap_ertm_send(chan);
... ... @@ -1384,9 +1382,9 @@
1384 1382 len -= buflen;
1385 1383 size += buflen;
1386 1384 }
1387   - skb_queue_splice_tail(&sar_queue, TX_QUEUE(sk));
1388   - if (sk->sk_send_head == NULL)
1389   - sk->sk_send_head = sar_queue.next;
  1385 + skb_queue_splice_tail(&sar_queue, &chan->tx_q);
  1386 + if (chan->tx_send_head == NULL)
  1387 + chan->tx_send_head = sar_queue.next;
1390 1388  
1391 1389 return size;
1392 1390 }
... ... @@ -2319,7 +2317,7 @@
2319 2317  
2320 2318 chan->next_tx_seq = 0;
2321 2319 chan->expected_tx_seq = 0;
2322   - __skb_queue_head_init(TX_QUEUE(sk));
  2320 + skb_queue_head_init(&chan->tx_q);
2323 2321 if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM)
2324 2322 l2cap_ertm_init(chan);
2325 2323  
... ... @@ -2410,7 +2408,7 @@
2410 2408 sk->sk_state = BT_CONNECTED;
2411 2409 chan->next_tx_seq = 0;
2412 2410 chan->expected_tx_seq = 0;
2413   - __skb_queue_head_init(TX_QUEUE(sk));
  2411 + skb_queue_head_init(&chan->tx_q);
2414 2412 if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM)
2415 2413 l2cap_ertm_init(chan);
2416 2414  
net/bluetooth/l2cap_sock.c
... ... @@ -764,10 +764,10 @@
764 764 err = PTR_ERR(skb);
765 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)
770   - sk->sk_send_head = skb;
  769 + if (pi->chan->tx_send_head == NULL)
  770 + pi->chan->tx_send_head = skb;
771 771  
772 772 } else {
773 773 /* Segment SDU into multiples PDUs */
... ... @@ -1017,7 +1017,6 @@
1017 1017  
1018 1018 /* Default config options */
1019 1019 pi->flush_to = L2CAP_DEFAULT_FLUSH_TO;
1020   - skb_queue_head_init(TX_QUEUE(sk));
1021 1020 }
1022 1021  
1023 1022 static struct proto l2cap_proto = {