Commit 58d35f87 authored by Gustavo F. Padovan's avatar Gustavo F. Padovan

Bluetooth: Move tx queue to struct l2cap_chan

tx_q is the queue used by ERTM mode.
Signed-off-by: default avatarGustavo F. Padovan <padovan@profusion.mobi>
parent c916fbe4
...@@ -314,6 +314,8 @@ struct l2cap_chan { ...@@ -314,6 +314,8 @@ struct l2cap_chan {
struct timer_list retrans_timer; struct timer_list retrans_timer;
struct timer_list monitor_timer; struct timer_list monitor_timer;
struct timer_list ack_timer; struct timer_list ack_timer;
struct sk_buff *tx_send_head;
struct sk_buff_head tx_q;
struct sk_buff_head srej_q; struct sk_buff_head srej_q;
struct sk_buff_head busy_q; struct sk_buff_head busy_q;
struct work_struct busy_work; struct work_struct busy_work;
...@@ -355,7 +357,6 @@ struct l2cap_conn { ...@@ -355,7 +357,6 @@ struct l2cap_conn {
/* ----- L2CAP socket info ----- */ /* ----- L2CAP socket info ----- */
#define l2cap_pi(sk) ((struct l2cap_pinfo *) sk) #define l2cap_pi(sk) ((struct l2cap_pinfo *) sk)
#define TX_QUEUE(sk) (&l2cap_pi(sk)->tx_queue)
struct l2cap_pinfo { struct l2cap_pinfo {
struct bt_sock bt; struct bt_sock bt;
...@@ -384,7 +385,6 @@ struct l2cap_pinfo { ...@@ -384,7 +385,6 @@ struct l2cap_pinfo {
__le16 sport; __le16 sport;
struct sk_buff_head tx_queue;
struct l2cap_conn *conn; struct l2cap_conn *conn;
struct l2cap_chan *chan; struct l2cap_chan *chan;
}; };
......
...@@ -240,7 +240,7 @@ void l2cap_chan_del(struct l2cap_chan *chan, int err) ...@@ -240,7 +240,7 @@ void l2cap_chan_del(struct l2cap_chan *chan, int err)
l2cap_pi(sk)->conf_state & L2CAP_CONF_INPUT_DONE)) l2cap_pi(sk)->conf_state & L2CAP_CONF_INPUT_DONE))
goto free; goto free;
skb_queue_purge(TX_QUEUE(sk)); skb_queue_purge(&chan->tx_q);
if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) { if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) {
struct srej_list *l, *tmp; struct srej_list *l, *tmp;
...@@ -477,7 +477,7 @@ void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *chan, in ...@@ -477,7 +477,7 @@ void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *chan, in
sk = chan->sk; sk = chan->sk;
skb_queue_purge(TX_QUEUE(sk)); skb_queue_purge(&chan->tx_q);
if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) { if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) {
del_timer(&chan->retrans_timer); del_timer(&chan->retrans_timer);
...@@ -996,15 +996,14 @@ static void l2cap_retrans_timeout(unsigned long arg) ...@@ -996,15 +996,14 @@ static void l2cap_retrans_timeout(unsigned long arg)
static void l2cap_drop_acked_frames(struct l2cap_chan *chan) static void l2cap_drop_acked_frames(struct l2cap_chan *chan)
{ {
struct sock *sk = chan->sk;
struct sk_buff *skb; struct sk_buff *skb;
while ((skb = skb_peek(TX_QUEUE(sk))) && while ((skb = skb_peek(&chan->tx_q)) &&
chan->unacked_frames) { chan->unacked_frames) {
if (bt_cb(skb)->tx_seq == chan->expected_ack_seq) if (bt_cb(skb)->tx_seq == chan->expected_ack_seq)
break; break;
skb = skb_dequeue(TX_QUEUE(sk)); skb = skb_dequeue(&chan->tx_q);
kfree_skb(skb); kfree_skb(skb);
chan->unacked_frames--; chan->unacked_frames--;
...@@ -1037,7 +1036,7 @@ void l2cap_streaming_send(struct l2cap_chan *chan) ...@@ -1037,7 +1036,7 @@ void l2cap_streaming_send(struct l2cap_chan *chan)
struct l2cap_pinfo *pi = l2cap_pi(sk); struct l2cap_pinfo *pi = l2cap_pi(sk);
u16 control, fcs; u16 control, fcs;
while ((skb = skb_dequeue(TX_QUEUE(sk)))) { while ((skb = skb_dequeue(&chan->tx_q))) {
control = get_unaligned_le16(skb->data + L2CAP_HDR_SIZE); control = get_unaligned_le16(skb->data + L2CAP_HDR_SIZE);
control |= chan->next_tx_seq << L2CAP_CTRL_TXSEQ_SHIFT; control |= chan->next_tx_seq << L2CAP_CTRL_TXSEQ_SHIFT;
put_unaligned_le16(control, skb->data + L2CAP_HDR_SIZE); 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,7 +1059,7 @@ static void l2cap_retransmit_one_frame(struct l2cap_chan *chan, u8 tx_seq)
struct sk_buff *skb, *tx_skb; struct sk_buff *skb, *tx_skb;
u16 control, fcs; u16 control, fcs;
skb = skb_peek(TX_QUEUE(sk)); skb = skb_peek(&chan->tx_q);
if (!skb) if (!skb)
return; return;
...@@ -1068,10 +1067,10 @@ static void l2cap_retransmit_one_frame(struct l2cap_chan *chan, u8 tx_seq) ...@@ -1068,10 +1067,10 @@ static void l2cap_retransmit_one_frame(struct l2cap_chan *chan, u8 tx_seq)
if (bt_cb(skb)->tx_seq == tx_seq) if (bt_cb(skb)->tx_seq == tx_seq)
break; break;
if (skb_queue_is_last(TX_QUEUE(sk), skb)) if (skb_queue_is_last(&chan->tx_q, skb))
return; return;
} while ((skb = skb_queue_next(TX_QUEUE(sk), skb))); } while ((skb = skb_queue_next(&chan->tx_q, skb)));
if (chan->remote_max_tx && if (chan->remote_max_tx &&
bt_cb(skb)->retries == chan->remote_max_tx) { bt_cb(skb)->retries == chan->remote_max_tx) {
...@@ -1112,7 +1111,7 @@ int l2cap_ertm_send(struct l2cap_chan *chan) ...@@ -1112,7 +1111,7 @@ int l2cap_ertm_send(struct l2cap_chan *chan)
if (sk->sk_state != BT_CONNECTED) if (sk->sk_state != BT_CONNECTED)
return -ENOTCONN; return -ENOTCONN;
while ((skb = sk->sk_send_head) && (!l2cap_tx_window_full(chan))) { while ((skb = chan->tx_send_head) && (!l2cap_tx_window_full(chan))) {
if (chan->remote_max_tx && if (chan->remote_max_tx &&
bt_cb(skb)->retries == chan->remote_max_tx) { bt_cb(skb)->retries == chan->remote_max_tx) {
...@@ -1153,10 +1152,10 @@ int l2cap_ertm_send(struct l2cap_chan *chan) ...@@ -1153,10 +1152,10 @@ int l2cap_ertm_send(struct l2cap_chan *chan)
chan->frames_sent++; chan->frames_sent++;
if (skb_queue_is_last(TX_QUEUE(sk), skb)) if (skb_queue_is_last(&chan->tx_q, skb))
sk->sk_send_head = NULL; chan->tx_send_head = NULL;
else else
sk->sk_send_head = skb_queue_next(TX_QUEUE(sk), skb); chan->tx_send_head = skb_queue_next(&chan->tx_q, skb);
nsent++; nsent++;
} }
...@@ -1166,11 +1165,10 @@ int l2cap_ertm_send(struct l2cap_chan *chan) ...@@ -1166,11 +1165,10 @@ int l2cap_ertm_send(struct l2cap_chan *chan)
static int l2cap_retransmit_frames(struct l2cap_chan *chan) static int l2cap_retransmit_frames(struct l2cap_chan *chan)
{ {
struct sock *sk = chan->sk;
int ret; int ret;
if (!skb_queue_empty(TX_QUEUE(sk))) if (!skb_queue_empty(&chan->tx_q))
sk->sk_send_head = TX_QUEUE(sk)->next; chan->tx_send_head = chan->tx_q.next;
chan->next_tx_seq = chan->expected_ack_seq; chan->next_tx_seq = chan->expected_ack_seq;
ret = l2cap_ertm_send(chan); 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,9 +1382,9 @@ int l2cap_sar_segment_sdu(struct l2cap_chan *chan, struct msghdr *msg, size_t le
len -= buflen; len -= buflen;
size += buflen; size += buflen;
} }
skb_queue_splice_tail(&sar_queue, TX_QUEUE(sk)); skb_queue_splice_tail(&sar_queue, &chan->tx_q);
if (sk->sk_send_head == NULL) if (chan->tx_send_head == NULL)
sk->sk_send_head = sar_queue.next; chan->tx_send_head = sar_queue.next;
return size; return size;
} }
...@@ -2319,7 +2317,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr ...@@ -2319,7 +2317,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr
chan->next_tx_seq = 0; chan->next_tx_seq = 0;
chan->expected_tx_seq = 0; chan->expected_tx_seq = 0;
__skb_queue_head_init(TX_QUEUE(sk)); skb_queue_head_init(&chan->tx_q);
if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM)
l2cap_ertm_init(chan); l2cap_ertm_init(chan);
...@@ -2410,7 +2408,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr ...@@ -2410,7 +2408,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr
sk->sk_state = BT_CONNECTED; sk->sk_state = BT_CONNECTED;
chan->next_tx_seq = 0; chan->next_tx_seq = 0;
chan->expected_tx_seq = 0; chan->expected_tx_seq = 0;
__skb_queue_head_init(TX_QUEUE(sk)); skb_queue_head_init(&chan->tx_q);
if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM)
l2cap_ertm_init(chan); l2cap_ertm_init(chan);
......
...@@ -764,10 +764,10 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct ms ...@@ -764,10 +764,10 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct ms
err = PTR_ERR(skb); err = PTR_ERR(skb);
goto done; goto done;
} }
__skb_queue_tail(TX_QUEUE(sk), skb); __skb_queue_tail(&pi->chan->tx_q, skb);
if (sk->sk_send_head == NULL) if (pi->chan->tx_send_head == NULL)
sk->sk_send_head = skb; pi->chan->tx_send_head = skb;
} else { } else {
/* Segment SDU into multiples PDUs */ /* Segment SDU into multiples PDUs */
...@@ -1017,7 +1017,6 @@ void l2cap_sock_init(struct sock *sk, struct sock *parent) ...@@ -1017,7 +1017,6 @@ void l2cap_sock_init(struct sock *sk, struct sock *parent)
/* Default config options */ /* Default config options */
pi->flush_to = L2CAP_DEFAULT_FLUSH_TO; pi->flush_to = L2CAP_DEFAULT_FLUSH_TO;
skb_queue_head_init(TX_QUEUE(sk));
} }
static struct proto l2cap_proto = { static struct proto l2cap_proto = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment