aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGustavo F. Padovan <padovan@profusion.mobi>2011-03-25 19:15:28 -0400
committerGustavo F. Padovan <padovan@profusion.mobi>2011-04-07 17:06:27 -0400
commit2c03a7a49e0831646bd35d0877ec7d051d8f174b (patch)
tree30423f04924bf1e3ce5e0f34d5c5afb84a73a696
parent6f61fd475907bf0a1470cb969ee993a31d305513 (diff)
Bluetooth: Move remote info to struct l2cap_chan
As part of the moving channel stuff to l2cap_chan. Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
-rw-r--r--include/net/bluetooth/l2cap.h10
-rw-r--r--net/bluetooth/l2cap_core.c32
-rw-r--r--net/bluetooth/l2cap_sock.c4
3 files changed, 23 insertions, 23 deletions
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 19d613bbcf0..11c53cb4a11 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -302,6 +302,9 @@ struct l2cap_chan {
302 __u16 partial_sdu_len; 302 __u16 partial_sdu_len;
303 struct sk_buff *sdu; 303 struct sk_buff *sdu;
304 304
305 __u8 remote_tx_win;
306 __u8 remote_max_tx;
307 __u16 remote_mps;
305 308
306 struct list_head list; 309 struct list_head list;
307}; 310};
@@ -370,11 +373,8 @@ struct l2cap_pinfo {
370 373
371 __u8 tx_win; 374 __u8 tx_win;
372 __u8 max_tx; 375 __u8 max_tx;
373 __u8 remote_tx_win;
374 __u8 remote_max_tx;
375 __u16 retrans_timeout; 376 __u16 retrans_timeout;
376 __u16 monitor_timeout; 377 __u16 monitor_timeout;
377 __u16 remote_mps;
378 __u16 mps; 378 __u16 mps;
379 379
380 __le16 sport; 380 __le16 sport;
@@ -431,7 +431,7 @@ static inline int l2cap_tx_window_full(struct l2cap_chan *ch)
431 if (sub < 0) 431 if (sub < 0)
432 sub += 64; 432 sub += 64;
433 433
434 return sub == l2cap_pi(ch->sk)->remote_tx_win; 434 return sub == ch->remote_tx_win;
435} 435}
436 436
437#define __get_txseq(ctrl) (((ctrl) & L2CAP_CTRL_TXSEQ) >> 1) 437#define __get_txseq(ctrl) (((ctrl) & L2CAP_CTRL_TXSEQ) >> 1)
@@ -454,7 +454,7 @@ int __l2cap_wait_ack(struct sock *sk);
454struct sk_buff *l2cap_create_connless_pdu(struct sock *sk, struct msghdr *msg, size_t len); 454struct sk_buff *l2cap_create_connless_pdu(struct sock *sk, struct msghdr *msg, size_t len);
455struct sk_buff *l2cap_create_basic_pdu(struct sock *sk, struct msghdr *msg, size_t len); 455struct sk_buff *l2cap_create_basic_pdu(struct sock *sk, struct msghdr *msg, size_t len);
456struct sk_buff *l2cap_create_iframe_pdu(struct sock *sk, struct msghdr *msg, size_t len, u16 control, u16 sdulen); 456struct sk_buff *l2cap_create_iframe_pdu(struct sock *sk, struct msghdr *msg, size_t len, u16 control, u16 sdulen);
457int l2cap_sar_segment_sdu(struct sock *sk, struct msghdr *msg, size_t len); 457int l2cap_sar_segment_sdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len);
458void l2cap_do_send(struct sock *sk, struct sk_buff *skb); 458void l2cap_do_send(struct sock *sk, struct sk_buff *skb);
459void l2cap_streaming_send(struct l2cap_chan *chan); 459void l2cap_streaming_send(struct l2cap_chan *chan);
460int l2cap_ertm_send(struct l2cap_chan *chan); 460int l2cap_ertm_send(struct l2cap_chan *chan);
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 8ccfcdf3e08..2176a003087 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -956,7 +956,7 @@ static void l2cap_monitor_timeout(unsigned long arg)
956 BT_DBG("chan %p", chan); 956 BT_DBG("chan %p", chan);
957 957
958 bh_lock_sock(sk); 958 bh_lock_sock(sk);
959 if (chan->retry_count >= l2cap_pi(sk)->remote_max_tx) { 959 if (chan->retry_count >= chan->remote_max_tx) {
960 l2cap_send_disconn_req(l2cap_pi(sk)->conn, sk, ECONNABORTED); 960 l2cap_send_disconn_req(l2cap_pi(sk)->conn, sk, ECONNABORTED);
961 bh_unlock_sock(sk); 961 bh_unlock_sock(sk);
962 return; 962 return;
@@ -1065,8 +1065,8 @@ static void l2cap_retransmit_one_frame(struct l2cap_chan *chan, u8 tx_seq)
1065 1065
1066 } while ((skb = skb_queue_next(TX_QUEUE(sk), skb))); 1066 } while ((skb = skb_queue_next(TX_QUEUE(sk), skb)));
1067 1067
1068 if (pi->remote_max_tx && 1068 if (chan->remote_max_tx &&
1069 bt_cb(skb)->retries == pi->remote_max_tx) { 1069 bt_cb(skb)->retries == chan->remote_max_tx) {
1070 l2cap_send_disconn_req(pi->conn, sk, ECONNABORTED); 1070 l2cap_send_disconn_req(pi->conn, sk, ECONNABORTED);
1071 return; 1071 return;
1072 } 1072 }
@@ -1106,8 +1106,8 @@ int l2cap_ertm_send(struct l2cap_chan *chan)
1106 1106
1107 while ((skb = sk->sk_send_head) && (!l2cap_tx_window_full(chan))) { 1107 while ((skb = sk->sk_send_head) && (!l2cap_tx_window_full(chan))) {
1108 1108
1109 if (pi->remote_max_tx && 1109 if (chan->remote_max_tx &&
1110 bt_cb(skb)->retries == pi->remote_max_tx) { 1110 bt_cb(skb)->retries == chan->remote_max_tx) {
1111 l2cap_send_disconn_req(pi->conn, sk, ECONNABORTED); 1111 l2cap_send_disconn_req(pi->conn, sk, ECONNABORTED);
1112 break; 1112 break;
1113 } 1113 }
@@ -1337,9 +1337,9 @@ struct sk_buff *l2cap_create_iframe_pdu(struct sock *sk, struct msghdr *msg, siz
1337 return skb; 1337 return skb;
1338} 1338}
1339 1339
1340int l2cap_sar_segment_sdu(struct sock *sk, struct msghdr *msg, size_t len) 1340int l2cap_sar_segment_sdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len)
1341{ 1341{
1342 struct l2cap_pinfo *pi = l2cap_pi(sk); 1342 struct sock *sk = chan->sk;
1343 struct sk_buff *skb; 1343 struct sk_buff *skb;
1344 struct sk_buff_head sar_queue; 1344 struct sk_buff_head sar_queue;
1345 u16 control; 1345 u16 control;
@@ -1347,20 +1347,20 @@ int l2cap_sar_segment_sdu(struct sock *sk, struct msghdr *msg, size_t len)
1347 1347
1348 skb_queue_head_init(&sar_queue); 1348 skb_queue_head_init(&sar_queue);
1349 control = L2CAP_SDU_START; 1349 control = L2CAP_SDU_START;
1350 skb = l2cap_create_iframe_pdu(sk, msg, pi->remote_mps, control, len); 1350 skb = l2cap_create_iframe_pdu(sk, msg, chan->remote_mps, control, len);
1351 if (IS_ERR(skb)) 1351 if (IS_ERR(skb))
1352 return PTR_ERR(skb); 1352 return PTR_ERR(skb);
1353 1353
1354 __skb_queue_tail(&sar_queue, skb); 1354 __skb_queue_tail(&sar_queue, skb);
1355 len -= pi->remote_mps; 1355 len -= chan->remote_mps;
1356 size += pi->remote_mps; 1356 size += chan->remote_mps;
1357 1357
1358 while (len > 0) { 1358 while (len > 0) {
1359 size_t buflen; 1359 size_t buflen;
1360 1360
1361 if (len > pi->remote_mps) { 1361 if (len > chan->remote_mps) {
1362 control = L2CAP_SDU_CONTINUE; 1362 control = L2CAP_SDU_CONTINUE;
1363 buflen = pi->remote_mps; 1363 buflen = chan->remote_mps;
1364 } else { 1364 } else {
1365 control = L2CAP_SDU_END; 1365 control = L2CAP_SDU_END;
1366 buflen = len; 1366 buflen = len;
@@ -1810,13 +1810,13 @@ done:
1810 break; 1810 break;
1811 1811
1812 case L2CAP_MODE_ERTM: 1812 case L2CAP_MODE_ERTM:
1813 pi->remote_tx_win = rfc.txwin_size; 1813 chan->remote_tx_win = rfc.txwin_size;
1814 pi->remote_max_tx = rfc.max_transmit; 1814 chan->remote_max_tx = rfc.max_transmit;
1815 1815
1816 if (le16_to_cpu(rfc.max_pdu_size) > pi->conn->mtu - 10) 1816 if (le16_to_cpu(rfc.max_pdu_size) > pi->conn->mtu - 10)
1817 rfc.max_pdu_size = cpu_to_le16(pi->conn->mtu - 10); 1817 rfc.max_pdu_size = cpu_to_le16(pi->conn->mtu - 10);
1818 1818
1819 pi->remote_mps = le16_to_cpu(rfc.max_pdu_size); 1819 chan->remote_mps = le16_to_cpu(rfc.max_pdu_size);
1820 1820
1821 rfc.retrans_timeout = 1821 rfc.retrans_timeout =
1822 le16_to_cpu(L2CAP_DEFAULT_RETRANS_TO); 1822 le16_to_cpu(L2CAP_DEFAULT_RETRANS_TO);
@@ -1834,7 +1834,7 @@ done:
1834 if (le16_to_cpu(rfc.max_pdu_size) > pi->conn->mtu - 10) 1834 if (le16_to_cpu(rfc.max_pdu_size) > pi->conn->mtu - 10)
1835 rfc.max_pdu_size = cpu_to_le16(pi->conn->mtu - 10); 1835 rfc.max_pdu_size = cpu_to_le16(pi->conn->mtu - 10);
1836 1836
1837 pi->remote_mps = le16_to_cpu(rfc.max_pdu_size); 1837 chan->remote_mps = le16_to_cpu(rfc.max_pdu_size);
1838 1838
1839 pi->conf_state |= L2CAP_CONF_MODE_DONE; 1839 pi->conf_state |= L2CAP_CONF_MODE_DONE;
1840 1840
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 19574e43226..f90ca2586ea 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -757,7 +757,7 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct ms
757 case L2CAP_MODE_ERTM: 757 case L2CAP_MODE_ERTM:
758 case L2CAP_MODE_STREAMING: 758 case L2CAP_MODE_STREAMING:
759 /* Entire SDU fits into one PDU */ 759 /* Entire SDU fits into one PDU */
760 if (len <= pi->remote_mps) { 760 if (len <= pi->chan->remote_mps) {
761 control = L2CAP_SDU_UNSEGMENTED; 761 control = L2CAP_SDU_UNSEGMENTED;
762 skb = l2cap_create_iframe_pdu(sk, msg, len, control, 0); 762 skb = l2cap_create_iframe_pdu(sk, msg, len, control, 0);
763 if (IS_ERR(skb)) { 763 if (IS_ERR(skb)) {
@@ -771,7 +771,7 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct ms
771 771
772 } else { 772 } else {
773 /* Segment SDU into multiples PDUs */ 773 /* Segment SDU into multiples PDUs */
774 err = l2cap_sar_segment_sdu(sk, msg, len); 774 err = l2cap_sar_segment_sdu(pi->chan, msg, len);
775 if (err < 0) 775 if (err < 0)
776 goto done; 776 goto done;
777 } 777 }