Commit eda21f16 authored by Samuel Ortiz's avatar Samuel Ortiz Committed by John W. Linville

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: default avatarSamuel Ortiz <sameo@linux.intel.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent d094afa1
...@@ -284,6 +284,9 @@ int nfc_llcp_send_connect(struct nfc_llcp_sock *sock) ...@@ -284,6 +284,9 @@ int nfc_llcp_send_connect(struct nfc_llcp_sock *sock)
struct nfc_llcp_local *local; struct nfc_llcp_local *local;
struct sk_buff *skb; struct sk_buff *skb;
u8 *service_name_tlv = NULL, service_name_tlv_length; u8 *service_name_tlv = NULL, service_name_tlv_length;
u8 *miux_tlv = NULL, miux_tlv_length;
u8 *rw_tlv = NULL, rw_tlv_length, rw;
__be16 miux;
int err; int err;
u16 size = 0; u16 size = 0;
...@@ -301,6 +304,14 @@ int nfc_llcp_send_connect(struct nfc_llcp_sock *sock) ...@@ -301,6 +304,14 @@ int nfc_llcp_send_connect(struct nfc_llcp_sock *sock)
size += service_name_tlv_length; size += service_name_tlv_length;
} }
miux = cpu_to_be16(LLCP_MAX_MIUX);
miux_tlv = nfc_llcp_build_tlv(LLCP_TLV_MIUX, (u8 *)&miux, 0, &miux_tlv_length);
size += miux_tlv_length;
rw = LLCP_MAX_RW;
rw_tlv = nfc_llcp_build_tlv(LLCP_TLV_RW, &rw, 0, &rw_tlv_length);
size += rw_tlv_length;
pr_debug("SKB size %d SN length %zu\n", size, sock->service_name_len); pr_debug("SKB size %d SN length %zu\n", size, sock->service_name_len);
skb = llcp_allocate_pdu(sock, LLCP_PDU_CONNECT, size); skb = llcp_allocate_pdu(sock, LLCP_PDU_CONNECT, size);
...@@ -313,6 +324,9 @@ int nfc_llcp_send_connect(struct nfc_llcp_sock *sock) ...@@ -313,6 +324,9 @@ int nfc_llcp_send_connect(struct nfc_llcp_sock *sock)
skb = llcp_add_tlv(skb, service_name_tlv, skb = llcp_add_tlv(skb, service_name_tlv,
service_name_tlv_length); service_name_tlv_length);
skb = llcp_add_tlv(skb, miux_tlv, miux_tlv_length);
skb = llcp_add_tlv(skb, rw_tlv, rw_tlv_length);
skb_queue_tail(&local->tx_queue, skb); skb_queue_tail(&local->tx_queue, skb);
return 0; return 0;
...@@ -321,6 +335,8 @@ int nfc_llcp_send_connect(struct nfc_llcp_sock *sock) ...@@ -321,6 +335,8 @@ int nfc_llcp_send_connect(struct nfc_llcp_sock *sock)
pr_err("error %d\n", err); pr_err("error %d\n", err);
kfree(service_name_tlv); kfree(service_name_tlv);
kfree(miux_tlv);
kfree(rw_tlv);
return err; return err;
} }
...@@ -329,6 +345,11 @@ int nfc_llcp_send_cc(struct nfc_llcp_sock *sock) ...@@ -329,6 +345,11 @@ int nfc_llcp_send_cc(struct nfc_llcp_sock *sock)
{ {
struct nfc_llcp_local *local; struct nfc_llcp_local *local;
struct sk_buff *skb; struct sk_buff *skb;
u8 *miux_tlv = NULL, miux_tlv_length;
u8 *rw_tlv = NULL, rw_tlv_length, rw;
__be16 miux;
int err;
u16 size = 0;
pr_debug("Sending CC\n"); pr_debug("Sending CC\n");
...@@ -336,13 +357,34 @@ int nfc_llcp_send_cc(struct nfc_llcp_sock *sock) ...@@ -336,13 +357,34 @@ int nfc_llcp_send_cc(struct nfc_llcp_sock *sock)
if (local == NULL) if (local == NULL)
return -ENODEV; return -ENODEV;
skb = llcp_allocate_pdu(sock, LLCP_PDU_CC, 0); miux = cpu_to_be16(LLCP_MAX_MIUX);
if (skb == NULL) miux_tlv = nfc_llcp_build_tlv(LLCP_TLV_MIUX, (u8 *)&miux, 0, &miux_tlv_length);
return -ENOMEM; size += miux_tlv_length;
rw = LLCP_MAX_RW;
rw_tlv = nfc_llcp_build_tlv(LLCP_TLV_RW, &rw, 0, &rw_tlv_length);
size += rw_tlv_length;
skb = llcp_allocate_pdu(sock, LLCP_PDU_CC, size);
if (skb == NULL) {
err = -ENOMEM;
goto error_tlv;
}
skb = llcp_add_tlv(skb, miux_tlv, miux_tlv_length);
skb = llcp_add_tlv(skb, rw_tlv, rw_tlv_length);
skb_queue_tail(&local->tx_queue, skb); skb_queue_tail(&local->tx_queue, skb);
return 0; return 0;
error_tlv:
pr_err("error %d\n", err);
kfree(miux_tlv);
kfree(rw_tlv);
return err;
} }
int nfc_llcp_send_dm(struct nfc_llcp_local *local, u8 ssap, u8 dsap, u8 reason) int nfc_llcp_send_dm(struct nfc_llcp_local *local, u8 ssap, u8 dsap, u8 reason)
......
...@@ -28,6 +28,10 @@ enum llcp_state { ...@@ -28,6 +28,10 @@ enum llcp_state {
#define LLCP_DEFAULT_RW 1 #define LLCP_DEFAULT_RW 1
#define LLCP_DEFAULT_MIU 128 #define LLCP_DEFAULT_MIU 128
#define LLCP_MAX_LTO 0xff
#define LLCP_MAX_RW 15
#define LLCP_MAX_MIUX 0x7ff
#define LLCP_WKS_NUM_SAP 16 #define LLCP_WKS_NUM_SAP 16
#define LLCP_SDP_NUM_SAP 16 #define LLCP_SDP_NUM_SAP 16
#define LLCP_LOCAL_NUM_SAP 32 #define LLCP_LOCAL_NUM_SAP 32
......
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