aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2012-03-04 19:03:43 -0500
committerJohn W. Linville <linville@tuxdriver.com>2012-03-06 15:16:22 -0500
commiteda21f16a5ed2476c1740e83a7dfaae34d893d9b (patch)
tree7bbb9d2843d0d2cfb5640faa971bafbcfa92a560
parentd094afa155273e03b82981ea818d39c7a2dfba86 (diff)
NFC: Set MIU and RW values from CONNECT and CC LLCP frames
We use the maximum values for the LLCP Maximum Information Unit and Receive Window Size. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--net/nfc/llcp/commands.c48
-rw-r--r--net/nfc/llcp/llcp.h4
2 files changed, 49 insertions, 3 deletions
diff --git a/net/nfc/llcp/commands.c b/net/nfc/llcp/commands.c
index 8ebd322b11eb..a02292ba25c7 100644
--- a/net/nfc/llcp/commands.c
+++ b/net/nfc/llcp/commands.c
@@ -284,6 +284,9 @@ int nfc_llcp_send_connect(struct nfc_llcp_sock *sock)
284 struct nfc_llcp_local *local; 284 struct nfc_llcp_local *local;
285 struct sk_buff *skb; 285 struct sk_buff *skb;
286 u8 *service_name_tlv = NULL, service_name_tlv_length; 286 u8 *service_name_tlv = NULL, service_name_tlv_length;
287 u8 *miux_tlv = NULL, miux_tlv_length;
288 u8 *rw_tlv = NULL, rw_tlv_length, rw;
289 __be16 miux;
287 int err; 290 int err;
288 u16 size = 0; 291 u16 size = 0;
289 292
@@ -301,6 +304,14 @@ int nfc_llcp_send_connect(struct nfc_llcp_sock *sock)
301 size += service_name_tlv_length; 304 size += service_name_tlv_length;
302 } 305 }
303 306
307 miux = cpu_to_be16(LLCP_MAX_MIUX);
308 miux_tlv = nfc_llcp_build_tlv(LLCP_TLV_MIUX, (u8 *)&miux, 0, &miux_tlv_length);
309 size += miux_tlv_length;
310
311 rw = LLCP_MAX_RW;
312 rw_tlv = nfc_llcp_build_tlv(LLCP_TLV_RW, &rw, 0, &rw_tlv_length);
313 size += rw_tlv_length;
314
304 pr_debug("SKB size %d SN length %zu\n", size, sock->service_name_len); 315 pr_debug("SKB size %d SN length %zu\n", size, sock->service_name_len);
305 316
306 skb = llcp_allocate_pdu(sock, LLCP_PDU_CONNECT, size); 317 skb = llcp_allocate_pdu(sock, LLCP_PDU_CONNECT, size);
@@ -313,6 +324,9 @@ int nfc_llcp_send_connect(struct nfc_llcp_sock *sock)
313 skb = llcp_add_tlv(skb, service_name_tlv, 324 skb = llcp_add_tlv(skb, service_name_tlv,
314 service_name_tlv_length); 325 service_name_tlv_length);
315 326
327 skb = llcp_add_tlv(skb, miux_tlv, miux_tlv_length);
328 skb = llcp_add_tlv(skb, rw_tlv, rw_tlv_length);
329
316 skb_queue_tail(&local->tx_queue, skb); 330 skb_queue_tail(&local->tx_queue, skb);
317 331
318 return 0; 332 return 0;
@@ -321,6 +335,8 @@ error_tlv:
321 pr_err("error %d\n", err); 335 pr_err("error %d\n", err);
322 336
323 kfree(service_name_tlv); 337 kfree(service_name_tlv);
338 kfree(miux_tlv);
339 kfree(rw_tlv);
324 340
325 return err; 341 return err;
326} 342}
@@ -329,6 +345,11 @@ int nfc_llcp_send_cc(struct nfc_llcp_sock *sock)
329{ 345{
330 struct nfc_llcp_local *local; 346 struct nfc_llcp_local *local;
331 struct sk_buff *skb; 347 struct sk_buff *skb;
348 u8 *miux_tlv = NULL, miux_tlv_length;
349 u8 *rw_tlv = NULL, rw_tlv_length, rw;
350 __be16 miux;
351 int err;
352 u16 size = 0;
332 353
333 pr_debug("Sending CC\n"); 354 pr_debug("Sending CC\n");
334 355
@@ -336,13 +357,34 @@ int nfc_llcp_send_cc(struct nfc_llcp_sock *sock)
336 if (local == NULL) 357 if (local == NULL)
337 return -ENODEV; 358 return -ENODEV;
338 359
339 skb = llcp_allocate_pdu(sock, LLCP_PDU_CC, 0); 360 miux = cpu_to_be16(LLCP_MAX_MIUX);
340 if (skb == NULL) 361 miux_tlv = nfc_llcp_build_tlv(LLCP_TLV_MIUX, (u8 *)&miux, 0, &miux_tlv_length);
341 return -ENOMEM; 362 size += miux_tlv_length;
363
364 rw = LLCP_MAX_RW;
365 rw_tlv = nfc_llcp_build_tlv(LLCP_TLV_RW, &rw, 0, &rw_tlv_length);
366 size += rw_tlv_length;
367
368 skb = llcp_allocate_pdu(sock, LLCP_PDU_CC, size);
369 if (skb == NULL) {
370 err = -ENOMEM;
371 goto error_tlv;
372 }
373
374 skb = llcp_add_tlv(skb, miux_tlv, miux_tlv_length);
375 skb = llcp_add_tlv(skb, rw_tlv, rw_tlv_length);
342 376
343 skb_queue_tail(&local->tx_queue, skb); 377 skb_queue_tail(&local->tx_queue, skb);
344 378
345 return 0; 379 return 0;
380
381error_tlv:
382 pr_err("error %d\n", err);
383
384 kfree(miux_tlv);
385 kfree(rw_tlv);
386
387 return err;
346} 388}
347 389
348int nfc_llcp_send_dm(struct nfc_llcp_local *local, u8 ssap, u8 dsap, u8 reason) 390int nfc_llcp_send_dm(struct nfc_llcp_local *local, u8 ssap, u8 dsap, u8 reason)
diff --git a/net/nfc/llcp/llcp.h b/net/nfc/llcp/llcp.h
index 054c64ffdaa7..70e1762d6e8d 100644
--- a/net/nfc/llcp/llcp.h
+++ b/net/nfc/llcp/llcp.h
@@ -28,6 +28,10 @@ enum llcp_state {
28#define LLCP_DEFAULT_RW 1 28#define LLCP_DEFAULT_RW 1
29#define LLCP_DEFAULT_MIU 128 29#define LLCP_DEFAULT_MIU 128
30 30
31#define LLCP_MAX_LTO 0xff
32#define LLCP_MAX_RW 15
33#define LLCP_MAX_MIUX 0x7ff
34
31#define LLCP_WKS_NUM_SAP 16 35#define LLCP_WKS_NUM_SAP 16
32#define LLCP_SDP_NUM_SAP 16 36#define LLCP_SDP_NUM_SAP 16
33#define LLCP_LOCAL_NUM_SAP 32 37#define LLCP_LOCAL_NUM_SAP 32