diff options
author | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-03-25 19:09:37 -0400 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-04-07 17:06:27 -0400 |
commit | 6f61fd475907bf0a1470cb969ee993a31d305513 (patch) | |
tree | 3d95dd404d0375d796d75198036466920df214db | |
parent | 6a026610eee2c53ff59598905fcbaa979aec68d1 (diff) |
Bluetooth: Move SDU related vars 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.h | 8 | ||||
-rw-r--r-- | net/bluetooth/l2cap_core.c | 74 |
2 files changed, 41 insertions, 41 deletions
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 041213b4175a..19d613bbcf00 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h | |||
@@ -298,6 +298,10 @@ struct l2cap_chan { | |||
298 | __u8 unacked_frames; | 298 | __u8 unacked_frames; |
299 | __u8 retry_count; | 299 | __u8 retry_count; |
300 | __u8 num_acked; | 300 | __u8 num_acked; |
301 | __u16 sdu_len; | ||
302 | __u16 partial_sdu_len; | ||
303 | struct sk_buff *sdu; | ||
304 | |||
301 | 305 | ||
302 | struct list_head list; | 306 | struct list_head list; |
303 | }; | 307 | }; |
@@ -364,10 +368,6 @@ struct l2cap_pinfo { | |||
364 | 368 | ||
365 | __u8 conf_state; | 369 | __u8 conf_state; |
366 | 370 | ||
367 | __u16 sdu_len; | ||
368 | __u16 partial_sdu_len; | ||
369 | struct sk_buff *sdu; | ||
370 | |||
371 | __u8 tx_win; | 371 | __u8 tx_win; |
372 | __u8 max_tx; | 372 | __u8 max_tx; |
373 | __u8 remote_tx_win; | 373 | __u8 remote_tx_win; |
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 3f601d1c164a..8ccfcdf3e083 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -2875,13 +2875,13 @@ static int l2cap_ertm_reassembly_sdu(struct l2cap_chan *chan, struct sk_buff *sk | |||
2875 | if (chan->conn_state & L2CAP_CONN_SAR_SDU) | 2875 | if (chan->conn_state & L2CAP_CONN_SAR_SDU) |
2876 | goto drop; | 2876 | goto drop; |
2877 | 2877 | ||
2878 | pi->sdu_len = get_unaligned_le16(skb->data); | 2878 | chan->sdu_len = get_unaligned_le16(skb->data); |
2879 | 2879 | ||
2880 | if (pi->sdu_len > pi->imtu) | 2880 | if (chan->sdu_len > pi->imtu) |
2881 | goto disconnect; | 2881 | goto disconnect; |
2882 | 2882 | ||
2883 | pi->sdu = bt_skb_alloc(pi->sdu_len, GFP_ATOMIC); | 2883 | chan->sdu = bt_skb_alloc(chan->sdu_len, GFP_ATOMIC); |
2884 | if (!pi->sdu) | 2884 | if (!chan->sdu) |
2885 | return -ENOMEM; | 2885 | return -ENOMEM; |
2886 | 2886 | ||
2887 | /* pull sdu_len bytes only after alloc, because of Local Busy | 2887 | /* pull sdu_len bytes only after alloc, because of Local Busy |
@@ -2889,24 +2889,24 @@ static int l2cap_ertm_reassembly_sdu(struct l2cap_chan *chan, struct sk_buff *sk | |||
2889 | * only once, i.e., when alloc does not fail */ | 2889 | * only once, i.e., when alloc does not fail */ |
2890 | skb_pull(skb, 2); | 2890 | skb_pull(skb, 2); |
2891 | 2891 | ||
2892 | memcpy(skb_put(pi->sdu, skb->len), skb->data, skb->len); | 2892 | memcpy(skb_put(chan->sdu, skb->len), skb->data, skb->len); |
2893 | 2893 | ||
2894 | chan->conn_state |= L2CAP_CONN_SAR_SDU; | 2894 | chan->conn_state |= L2CAP_CONN_SAR_SDU; |
2895 | pi->partial_sdu_len = skb->len; | 2895 | chan->partial_sdu_len = skb->len; |
2896 | break; | 2896 | break; |
2897 | 2897 | ||
2898 | case L2CAP_SDU_CONTINUE: | 2898 | case L2CAP_SDU_CONTINUE: |
2899 | if (!(chan->conn_state & L2CAP_CONN_SAR_SDU)) | 2899 | if (!(chan->conn_state & L2CAP_CONN_SAR_SDU)) |
2900 | goto disconnect; | 2900 | goto disconnect; |
2901 | 2901 | ||
2902 | if (!pi->sdu) | 2902 | if (!chan->sdu) |
2903 | goto disconnect; | 2903 | goto disconnect; |
2904 | 2904 | ||
2905 | pi->partial_sdu_len += skb->len; | 2905 | chan->partial_sdu_len += skb->len; |
2906 | if (pi->partial_sdu_len > pi->sdu_len) | 2906 | if (chan->partial_sdu_len > chan->sdu_len) |
2907 | goto drop; | 2907 | goto drop; |
2908 | 2908 | ||
2909 | memcpy(skb_put(pi->sdu, skb->len), skb->data, skb->len); | 2909 | memcpy(skb_put(chan->sdu, skb->len), skb->data, skb->len); |
2910 | 2910 | ||
2911 | break; | 2911 | break; |
2912 | 2912 | ||
@@ -2914,22 +2914,22 @@ static int l2cap_ertm_reassembly_sdu(struct l2cap_chan *chan, struct sk_buff *sk | |||
2914 | if (!(chan->conn_state & L2CAP_CONN_SAR_SDU)) | 2914 | if (!(chan->conn_state & L2CAP_CONN_SAR_SDU)) |
2915 | goto disconnect; | 2915 | goto disconnect; |
2916 | 2916 | ||
2917 | if (!pi->sdu) | 2917 | if (!chan->sdu) |
2918 | goto disconnect; | 2918 | goto disconnect; |
2919 | 2919 | ||
2920 | if (!(chan->conn_state & L2CAP_CONN_SAR_RETRY)) { | 2920 | if (!(chan->conn_state & L2CAP_CONN_SAR_RETRY)) { |
2921 | pi->partial_sdu_len += skb->len; | 2921 | chan->partial_sdu_len += skb->len; |
2922 | 2922 | ||
2923 | if (pi->partial_sdu_len > pi->imtu) | 2923 | if (chan->partial_sdu_len > pi->imtu) |
2924 | goto drop; | 2924 | goto drop; |
2925 | 2925 | ||
2926 | if (pi->partial_sdu_len != pi->sdu_len) | 2926 | if (chan->partial_sdu_len != chan->sdu_len) |
2927 | goto drop; | 2927 | goto drop; |
2928 | 2928 | ||
2929 | memcpy(skb_put(pi->sdu, skb->len), skb->data, skb->len); | 2929 | memcpy(skb_put(chan->sdu, skb->len), skb->data, skb->len); |
2930 | } | 2930 | } |
2931 | 2931 | ||
2932 | _skb = skb_clone(pi->sdu, GFP_ATOMIC); | 2932 | _skb = skb_clone(chan->sdu, GFP_ATOMIC); |
2933 | if (!_skb) { | 2933 | if (!_skb) { |
2934 | chan->conn_state |= L2CAP_CONN_SAR_RETRY; | 2934 | chan->conn_state |= L2CAP_CONN_SAR_RETRY; |
2935 | return -ENOMEM; | 2935 | return -ENOMEM; |
@@ -2945,7 +2945,7 @@ static int l2cap_ertm_reassembly_sdu(struct l2cap_chan *chan, struct sk_buff *sk | |||
2945 | chan->conn_state &= ~L2CAP_CONN_SAR_RETRY; | 2945 | chan->conn_state &= ~L2CAP_CONN_SAR_RETRY; |
2946 | chan->conn_state &= ~L2CAP_CONN_SAR_SDU; | 2946 | chan->conn_state &= ~L2CAP_CONN_SAR_SDU; |
2947 | 2947 | ||
2948 | kfree_skb(pi->sdu); | 2948 | kfree_skb(chan->sdu); |
2949 | break; | 2949 | break; |
2950 | } | 2950 | } |
2951 | 2951 | ||
@@ -2953,8 +2953,8 @@ static int l2cap_ertm_reassembly_sdu(struct l2cap_chan *chan, struct sk_buff *sk | |||
2953 | return 0; | 2953 | return 0; |
2954 | 2954 | ||
2955 | drop: | 2955 | drop: |
2956 | kfree_skb(pi->sdu); | 2956 | kfree_skb(chan->sdu); |
2957 | pi->sdu = NULL; | 2957 | chan->sdu = NULL; |
2958 | 2958 | ||
2959 | disconnect: | 2959 | disconnect: |
2960 | l2cap_send_disconn_req(pi->conn, chan->sk, ECONNRESET); | 2960 | l2cap_send_disconn_req(pi->conn, chan->sk, ECONNRESET); |
@@ -3104,7 +3104,7 @@ static int l2cap_streaming_reassembly_sdu(struct l2cap_chan *chan, struct sk_buf | |||
3104 | switch (control & L2CAP_CTRL_SAR) { | 3104 | switch (control & L2CAP_CTRL_SAR) { |
3105 | case L2CAP_SDU_UNSEGMENTED: | 3105 | case L2CAP_SDU_UNSEGMENTED: |
3106 | if (chan->conn_state & L2CAP_CONN_SAR_SDU) { | 3106 | if (chan->conn_state & L2CAP_CONN_SAR_SDU) { |
3107 | kfree_skb(pi->sdu); | 3107 | kfree_skb(chan->sdu); |
3108 | break; | 3108 | break; |
3109 | } | 3109 | } |
3110 | 3110 | ||
@@ -3116,28 +3116,28 @@ static int l2cap_streaming_reassembly_sdu(struct l2cap_chan *chan, struct sk_buf | |||
3116 | 3116 | ||
3117 | case L2CAP_SDU_START: | 3117 | case L2CAP_SDU_START: |
3118 | if (chan->conn_state & L2CAP_CONN_SAR_SDU) { | 3118 | if (chan->conn_state & L2CAP_CONN_SAR_SDU) { |
3119 | kfree_skb(pi->sdu); | 3119 | kfree_skb(chan->sdu); |
3120 | break; | 3120 | break; |
3121 | } | 3121 | } |
3122 | 3122 | ||
3123 | pi->sdu_len = get_unaligned_le16(skb->data); | 3123 | chan->sdu_len = get_unaligned_le16(skb->data); |
3124 | skb_pull(skb, 2); | 3124 | skb_pull(skb, 2); |
3125 | 3125 | ||
3126 | if (pi->sdu_len > pi->imtu) { | 3126 | if (chan->sdu_len > pi->imtu) { |
3127 | err = -EMSGSIZE; | 3127 | err = -EMSGSIZE; |
3128 | break; | 3128 | break; |
3129 | } | 3129 | } |
3130 | 3130 | ||
3131 | pi->sdu = bt_skb_alloc(pi->sdu_len, GFP_ATOMIC); | 3131 | chan->sdu = bt_skb_alloc(chan->sdu_len, GFP_ATOMIC); |
3132 | if (!pi->sdu) { | 3132 | if (!chan->sdu) { |
3133 | err = -ENOMEM; | 3133 | err = -ENOMEM; |
3134 | break; | 3134 | break; |
3135 | } | 3135 | } |
3136 | 3136 | ||
3137 | memcpy(skb_put(pi->sdu, skb->len), skb->data, skb->len); | 3137 | memcpy(skb_put(chan->sdu, skb->len), skb->data, skb->len); |
3138 | 3138 | ||
3139 | chan->conn_state |= L2CAP_CONN_SAR_SDU; | 3139 | chan->conn_state |= L2CAP_CONN_SAR_SDU; |
3140 | pi->partial_sdu_len = skb->len; | 3140 | chan->partial_sdu_len = skb->len; |
3141 | err = 0; | 3141 | err = 0; |
3142 | break; | 3142 | break; |
3143 | 3143 | ||
@@ -3145,11 +3145,11 @@ static int l2cap_streaming_reassembly_sdu(struct l2cap_chan *chan, struct sk_buf | |||
3145 | if (!(chan->conn_state & L2CAP_CONN_SAR_SDU)) | 3145 | if (!(chan->conn_state & L2CAP_CONN_SAR_SDU)) |
3146 | break; | 3146 | break; |
3147 | 3147 | ||
3148 | memcpy(skb_put(pi->sdu, skb->len), skb->data, skb->len); | 3148 | memcpy(skb_put(chan->sdu, skb->len), skb->data, skb->len); |
3149 | 3149 | ||
3150 | pi->partial_sdu_len += skb->len; | 3150 | chan->partial_sdu_len += skb->len; |
3151 | if (pi->partial_sdu_len > pi->sdu_len) | 3151 | if (chan->partial_sdu_len > chan->sdu_len) |
3152 | kfree_skb(pi->sdu); | 3152 | kfree_skb(chan->sdu); |
3153 | else | 3153 | else |
3154 | err = 0; | 3154 | err = 0; |
3155 | 3155 | ||
@@ -3159,16 +3159,16 @@ static int l2cap_streaming_reassembly_sdu(struct l2cap_chan *chan, struct sk_buf | |||
3159 | if (!(chan->conn_state & L2CAP_CONN_SAR_SDU)) | 3159 | if (!(chan->conn_state & L2CAP_CONN_SAR_SDU)) |
3160 | break; | 3160 | break; |
3161 | 3161 | ||
3162 | memcpy(skb_put(pi->sdu, skb->len), skb->data, skb->len); | 3162 | memcpy(skb_put(chan->sdu, skb->len), skb->data, skb->len); |
3163 | 3163 | ||
3164 | chan->conn_state &= ~L2CAP_CONN_SAR_SDU; | 3164 | chan->conn_state &= ~L2CAP_CONN_SAR_SDU; |
3165 | pi->partial_sdu_len += skb->len; | 3165 | chan->partial_sdu_len += skb->len; |
3166 | 3166 | ||
3167 | if (pi->partial_sdu_len > pi->imtu) | 3167 | if (chan->partial_sdu_len > pi->imtu) |
3168 | goto drop; | 3168 | goto drop; |
3169 | 3169 | ||
3170 | if (pi->partial_sdu_len == pi->sdu_len) { | 3170 | if (chan->partial_sdu_len == chan->sdu_len) { |
3171 | _skb = skb_clone(pi->sdu, GFP_ATOMIC); | 3171 | _skb = skb_clone(chan->sdu, GFP_ATOMIC); |
3172 | err = sock_queue_rcv_skb(chan->sk, _skb); | 3172 | err = sock_queue_rcv_skb(chan->sk, _skb); |
3173 | if (err < 0) | 3173 | if (err < 0) |
3174 | kfree_skb(_skb); | 3174 | kfree_skb(_skb); |
@@ -3176,7 +3176,7 @@ static int l2cap_streaming_reassembly_sdu(struct l2cap_chan *chan, struct sk_buf | |||
3176 | err = 0; | 3176 | err = 0; |
3177 | 3177 | ||
3178 | drop: | 3178 | drop: |
3179 | kfree_skb(pi->sdu); | 3179 | kfree_skb(chan->sdu); |
3180 | break; | 3180 | break; |
3181 | } | 3181 | } |
3182 | 3182 | ||