diff options
author | Samuel Ortiz <sameo@linux.intel.com> | 2012-05-07 16:03:34 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2012-06-04 15:34:28 -0400 |
commit | 7a06e586b9bfcaca310f40a857cf144d04abc8e6 (patch) | |
tree | 347a8fc55a08741fc3dcb6c771f1e80369431f57 /net/nfc/llcp | |
parent | a69f32af86e389dd232b1bb2269e202c1bfcc60f (diff) |
NFC: Move LLCP receiver window value to socket structure
RW can only be fetched from a CONNECT or a CC frame thus making it an
end points specific value, not a link one.
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'net/nfc/llcp')
-rw-r--r-- | net/nfc/llcp/commands.c | 45 | ||||
-rw-r--r-- | net/nfc/llcp/llcp.c | 21 | ||||
-rw-r--r-- | net/nfc/llcp/llcp.h | 9 | ||||
-rw-r--r-- | net/nfc/llcp/sock.c | 1 |
4 files changed, 55 insertions, 21 deletions
diff --git a/net/nfc/llcp/commands.c b/net/nfc/llcp/commands.c index bf8ae4f0b90c..eb51864089ef 100644 --- a/net/nfc/llcp/commands.c +++ b/net/nfc/llcp/commands.c | |||
@@ -117,8 +117,8 @@ u8 *nfc_llcp_build_tlv(u8 type, u8 *value, u8 value_length, u8 *tlv_length) | |||
117 | return tlv; | 117 | return tlv; |
118 | } | 118 | } |
119 | 119 | ||
120 | int nfc_llcp_parse_tlv(struct nfc_llcp_local *local, | 120 | int nfc_llcp_parse_gb_tlv(struct nfc_llcp_local *local, |
121 | u8 *tlv_array, u16 tlv_array_len) | 121 | u8 *tlv_array, u16 tlv_array_len) |
122 | { | 122 | { |
123 | u8 *tlv = tlv_array, type, length, offset = 0; | 123 | u8 *tlv = tlv_array, type, length, offset = 0; |
124 | 124 | ||
@@ -149,8 +149,42 @@ int nfc_llcp_parse_tlv(struct nfc_llcp_local *local, | |||
149 | case LLCP_TLV_OPT: | 149 | case LLCP_TLV_OPT: |
150 | local->remote_opt = llcp_tlv_opt(tlv); | 150 | local->remote_opt = llcp_tlv_opt(tlv); |
151 | break; | 151 | break; |
152 | default: | ||
153 | pr_err("Invalid gt tlv value 0x%x\n", type); | ||
154 | break; | ||
155 | } | ||
156 | |||
157 | offset += length + 2; | ||
158 | tlv += length + 2; | ||
159 | } | ||
160 | |||
161 | pr_debug("version 0x%x miu %d lto %d opt 0x%x wks 0x%x\n", | ||
162 | local->remote_version, local->remote_miu, | ||
163 | local->remote_lto, local->remote_opt, | ||
164 | local->remote_wks); | ||
165 | |||
166 | return 0; | ||
167 | } | ||
168 | |||
169 | int nfc_llcp_parse_connection_tlv(struct nfc_llcp_sock *sock, | ||
170 | u8 *tlv_array, u16 tlv_array_len) | ||
171 | { | ||
172 | u8 *tlv = tlv_array, type, length, offset = 0; | ||
173 | |||
174 | pr_debug("TLV array length %d\n", tlv_array_len); | ||
175 | |||
176 | if (sock == NULL) | ||
177 | return -ENOTCONN; | ||
178 | |||
179 | while (offset < tlv_array_len) { | ||
180 | type = tlv[0]; | ||
181 | length = tlv[1]; | ||
182 | |||
183 | pr_debug("type 0x%x length %d\n", type, length); | ||
184 | |||
185 | switch (type) { | ||
152 | case LLCP_TLV_RW: | 186 | case LLCP_TLV_RW: |
153 | local->remote_rw = llcp_tlv_rw(tlv); | 187 | sock->rw = llcp_tlv_rw(tlv); |
154 | break; | 188 | break; |
155 | case LLCP_TLV_SN: | 189 | case LLCP_TLV_SN: |
156 | break; | 190 | break; |
@@ -163,10 +197,7 @@ int nfc_llcp_parse_tlv(struct nfc_llcp_local *local, | |||
163 | tlv += length + 2; | 197 | tlv += length + 2; |
164 | } | 198 | } |
165 | 199 | ||
166 | pr_debug("version 0x%x miu %d lto %d opt 0x%x wks 0x%x rw %d\n", | 200 | pr_debug("sock %p rw %d\n", sock, sock->rw); |
167 | local->remote_version, local->remote_miu, | ||
168 | local->remote_lto, local->remote_opt, | ||
169 | local->remote_wks, local->remote_rw); | ||
170 | 201 | ||
171 | return 0; | 202 | return 0; |
172 | } | 203 | } |
diff --git a/net/nfc/llcp/llcp.c b/net/nfc/llcp/llcp.c index 262aa827fd7f..d3efc5b3c19f 100644 --- a/net/nfc/llcp/llcp.c +++ b/net/nfc/llcp/llcp.c | |||
@@ -406,9 +406,9 @@ int nfc_llcp_set_remote_gb(struct nfc_dev *dev, u8 *gb, u8 gb_len) | |||
406 | return -EINVAL; | 406 | return -EINVAL; |
407 | } | 407 | } |
408 | 408 | ||
409 | return nfc_llcp_parse_tlv(local, | 409 | return nfc_llcp_parse_gb_tlv(local, |
410 | &local->remote_gb[3], | 410 | &local->remote_gb[3], |
411 | local->remote_gb_len - 3); | 411 | local->remote_gb_len - 3); |
412 | } | 412 | } |
413 | 413 | ||
414 | static void nfc_llcp_tx_work(struct work_struct *work) | 414 | static void nfc_llcp_tx_work(struct work_struct *work) |
@@ -608,9 +608,6 @@ static void nfc_llcp_recv_connect(struct nfc_llcp_local *local, | |||
608 | 608 | ||
609 | pr_debug("%d %d\n", dsap, ssap); | 609 | pr_debug("%d %d\n", dsap, ssap); |
610 | 610 | ||
611 | nfc_llcp_parse_tlv(local, &skb->data[LLCP_HEADER_SIZE], | ||
612 | skb->len - LLCP_HEADER_SIZE); | ||
613 | |||
614 | if (dsap != LLCP_SAP_SDP) { | 611 | if (dsap != LLCP_SAP_SDP) { |
615 | sock = nfc_llcp_sock_get(local, dsap, LLCP_SAP_SDP); | 612 | sock = nfc_llcp_sock_get(local, dsap, LLCP_SAP_SDP); |
616 | if (sock == NULL || sock->sk.sk_state != LLCP_LISTEN) { | 613 | if (sock == NULL || sock->sk.sk_state != LLCP_LISTEN) { |
@@ -663,6 +660,9 @@ static void nfc_llcp_recv_connect(struct nfc_llcp_local *local, | |||
663 | new_sock->dsap = ssap; | 660 | new_sock->dsap = ssap; |
664 | new_sock->parent = parent; | 661 | new_sock->parent = parent; |
665 | 662 | ||
663 | nfc_llcp_parse_connection_tlv(new_sock, &skb->data[LLCP_HEADER_SIZE], | ||
664 | skb->len - LLCP_HEADER_SIZE); | ||
665 | |||
666 | pr_debug("new sock %p sk %p\n", new_sock, &new_sock->sk); | 666 | pr_debug("new sock %p sk %p\n", new_sock, &new_sock->sk); |
667 | 667 | ||
668 | nfc_llcp_sock_link(&local->sockets, new_sk); | 668 | nfc_llcp_sock_link(&local->sockets, new_sk); |
@@ -699,11 +699,11 @@ int nfc_llcp_queue_i_frames(struct nfc_llcp_sock *sock) | |||
699 | 699 | ||
700 | pr_debug("Remote ready %d tx queue len %d remote rw %d", | 700 | pr_debug("Remote ready %d tx queue len %d remote rw %d", |
701 | sock->remote_ready, skb_queue_len(&sock->tx_pending_queue), | 701 | sock->remote_ready, skb_queue_len(&sock->tx_pending_queue), |
702 | local->remote_rw); | 702 | sock->rw); |
703 | 703 | ||
704 | /* Try to queue some I frames for transmission */ | 704 | /* Try to queue some I frames for transmission */ |
705 | while (sock->remote_ready && | 705 | while (sock->remote_ready && |
706 | skb_queue_len(&sock->tx_pending_queue) < local->remote_rw) { | 706 | skb_queue_len(&sock->tx_pending_queue) < sock->rw) { |
707 | struct sk_buff *pdu, *pending_pdu; | 707 | struct sk_buff *pdu, *pending_pdu; |
708 | 708 | ||
709 | pdu = skb_dequeue(&sock->tx_queue); | 709 | pdu = skb_dequeue(&sock->tx_queue); |
@@ -851,8 +851,8 @@ static void nfc_llcp_recv_cc(struct nfc_llcp_local *local, struct sk_buff *skb) | |||
851 | nfc_llcp_sock_link(&local->sockets, sk); | 851 | nfc_llcp_sock_link(&local->sockets, sk); |
852 | llcp_sock->dsap = ssap; | 852 | llcp_sock->dsap = ssap; |
853 | 853 | ||
854 | nfc_llcp_parse_tlv(local, &skb->data[LLCP_HEADER_SIZE], | 854 | nfc_llcp_parse_connection_tlv(llcp_sock, &skb->data[LLCP_HEADER_SIZE], |
855 | skb->len - LLCP_HEADER_SIZE); | 855 | skb->len - LLCP_HEADER_SIZE); |
856 | 856 | ||
857 | sk->sk_state = LLCP_CONNECTED; | 857 | sk->sk_state = LLCP_CONNECTED; |
858 | sk->sk_state_change(sk); | 858 | sk->sk_state_change(sk); |
@@ -1036,7 +1036,6 @@ int nfc_llcp_register_device(struct nfc_dev *ndev) | |||
1036 | 1036 | ||
1037 | local->remote_miu = LLCP_DEFAULT_MIU; | 1037 | local->remote_miu = LLCP_DEFAULT_MIU; |
1038 | local->remote_lto = LLCP_DEFAULT_LTO; | 1038 | local->remote_lto = LLCP_DEFAULT_LTO; |
1039 | local->remote_rw = LLCP_DEFAULT_RW; | ||
1040 | 1039 | ||
1041 | list_add(&llcp_devices, &local->list); | 1040 | list_add(&llcp_devices, &local->list); |
1042 | 1041 | ||
diff --git a/net/nfc/llcp/llcp.h b/net/nfc/llcp/llcp.h index 705330470062..add03e74a9ea 100644 --- a/net/nfc/llcp/llcp.h +++ b/net/nfc/llcp/llcp.h | |||
@@ -83,7 +83,6 @@ struct nfc_llcp_local { | |||
83 | u16 remote_lto; | 83 | u16 remote_lto; |
84 | u8 remote_opt; | 84 | u8 remote_opt; |
85 | u16 remote_wks; | 85 | u16 remote_wks; |
86 | u8 remote_rw; | ||
87 | 86 | ||
88 | /* sockets array */ | 87 | /* sockets array */ |
89 | struct llcp_sock_list sockets; | 88 | struct llcp_sock_list sockets; |
@@ -97,10 +96,12 @@ struct nfc_llcp_sock { | |||
97 | u32 target_idx; | 96 | u32 target_idx; |
98 | u32 nfc_protocol; | 97 | u32 nfc_protocol; |
99 | 98 | ||
99 | /* Link parameters */ | ||
100 | u8 ssap; | 100 | u8 ssap; |
101 | u8 dsap; | 101 | u8 dsap; |
102 | char *service_name; | 102 | char *service_name; |
103 | size_t service_name_len; | 103 | size_t service_name_len; |
104 | u8 rw; | ||
104 | 105 | ||
105 | /* Link variables */ | 106 | /* Link variables */ |
106 | u8 send_n; | 107 | u8 send_n; |
@@ -189,8 +190,10 @@ void nfc_llcp_accept_enqueue(struct sock *parent, struct sock *sk); | |||
189 | struct sock *nfc_llcp_accept_dequeue(struct sock *sk, struct socket *newsock); | 190 | struct sock *nfc_llcp_accept_dequeue(struct sock *sk, struct socket *newsock); |
190 | 191 | ||
191 | /* TLV API */ | 192 | /* TLV API */ |
192 | int nfc_llcp_parse_tlv(struct nfc_llcp_local *local, | 193 | int nfc_llcp_parse_gb_tlv(struct nfc_llcp_local *local, |
193 | u8 *tlv_array, u16 tlv_array_len); | 194 | u8 *tlv_array, u16 tlv_array_len); |
195 | int nfc_llcp_parse_connection_tlv(struct nfc_llcp_sock *sock, | ||
196 | u8 *tlv_array, u16 tlv_array_len); | ||
194 | 197 | ||
195 | /* Commands API */ | 198 | /* Commands API */ |
196 | void nfc_llcp_recv(void *data, struct sk_buff *skb, int err); | 199 | void nfc_llcp_recv(void *data, struct sk_buff *skb, int err); |
diff --git a/net/nfc/llcp/sock.c b/net/nfc/llcp/sock.c index 8a60b53579b9..aab077e68094 100644 --- a/net/nfc/llcp/sock.c +++ b/net/nfc/llcp/sock.c | |||
@@ -678,6 +678,7 @@ struct sock *nfc_llcp_sock_alloc(struct socket *sock, int type, gfp_t gfp) | |||
678 | 678 | ||
679 | llcp_sock->ssap = 0; | 679 | llcp_sock->ssap = 0; |
680 | llcp_sock->dsap = LLCP_SAP_SDP; | 680 | llcp_sock->dsap = LLCP_SAP_SDP; |
681 | llcp_sock->rw = LLCP_DEFAULT_RW; | ||
681 | llcp_sock->send_n = llcp_sock->send_ack_n = 0; | 682 | llcp_sock->send_n = llcp_sock->send_ack_n = 0; |
682 | llcp_sock->recv_n = llcp_sock->recv_ack_n = 0; | 683 | llcp_sock->recv_n = llcp_sock->recv_ack_n = 0; |
683 | llcp_sock->remote_ready = 1; | 684 | llcp_sock->remote_ready = 1; |