2014-01-15 00:57:25

by Mark Greer

[permalink] [raw]
Subject: [PATCH 0/3] NFC: iso15693 - Add ISO/IEC 15693 support

This series of patches adds support for the ISO/IEC 15693 protocol
and Type V vicinity cards.

This code was tested on an ARM-based BeagleBone (white) with an
RF Cape and a trf7970atb from TI. So far, only TI tags have been
tested. I'm still working on the trf7970a driver that was used
for testing and will submit it separately once its ready.

The patches were tested on the current nfc-next/master repo/branch,
bb55dc2ae4367b8f711d43a2f8668a6ed42c4fd3 (NFC: nfcmrvl: Fix possible
memory leak issue).

The corresponding neard patches are ready and will be submitted shortly.

Example session with a TI Tag-it tag (from top-level dir of neard):

# nfctool -d nfc0 -p
Start polling on nfc0 as initiator

Targets found for nfc0
Tags: [ tag0 ]
Devices: [ ]

# test/test-tag list
[ /org/neard/nfc0/tag0 ]
Protocol = ISO-15693
ReadOnly = false
Type = Type V
Adapter = /org/neard/nfc0
#
# test/test-tag dump /org/neard/nfc0/tag0
[ /org/neard/nfc0/tag0/record0 ]
Type = URI
URI = https://01.org
#
# test/test-tag write /org/neard/nfc0/tag0 URI https://www.kernel.org/
#
# test/test-tag dump /org/neard/nfc0/tag0
[ /org/neard/nfc0/tag0/record1 ]
Type = URI
URI = https://www.kernel.org/

Mark A. Greer (3):
NFC: iso15693 - Add ISO/IEC 15693 header definitions
NFC: iso15693 - Add Digital Layer support for ISO/IEC 15693
NFC: iso15693 - Add netlink support for ISO/IEC 15693

include/net/nfc/digital.h | 4 ++
include/net/nfc/nfc.h | 3 ++
include/uapi/linux/nfc.h | 9 +++-
net/nfc/digital.h | 1 +
net/nfc/digital_core.c | 14 ++++++
net/nfc/digital_technology.c | 108 +++++++++++++++++++++++++++++++++++++++++++
net/nfc/netlink.c | 8 ++++
7 files changed, 146 insertions(+), 1 deletion(-)

--
1.8.3.4



2014-01-17 18:47:00

by Mark Greer

[permalink] [raw]
Subject: Re: [PATCH 2/3] NFC: iso15693 - Add Digital Layer support for ISO/IEC 15693

On Tue, Jan 14, 2014 at 05:52:10PM -0700, Mark A. Greer wrote:

> diff --git a/net/nfc/digital_technology.c b/net/nfc/digital_technology.c
> index 251c8c7..6d3d03f 100644
> --- a/net/nfc/digital_technology.c
> +++ b/net/nfc/digital_technology.c

> @@ -473,6 +495,92 @@ int digital_in_send_sensf_req(struct nfc_digital_dev *ddev, u8 rf_tech)
> return rc;
> }
>
> +static void digital_in_recv_iso15693_inv_res(struct nfc_digital_dev *ddev,
> + void *arg, struct sk_buff *resp)
> +{
> + struct digital_iso15693_inv_res *res;
> + struct nfc_target *target = NULL;
> + int rc;
> +
> + if (IS_ERR(resp)) {
> + rc = PTR_ERR(resp);
> + resp = NULL;
> + goto out_free_skb;
> + }
> +
> + if (resp->len != sizeof(*res)) {
> + rc = -EIO;
> + goto out_free_skb;
> + }
> +
> + res = (struct digital_iso15693_inv_res *)resp->data;
> +
> + if (!DIGITAL_ISO15693_RES_IS_VALID(res->flags)) {
> + PROTOCOL_ERR("ISO15693 - 10.3.1");
> + rc = -EINVAL;
> + goto out_free_skb;
> + }
> +
> + target = kzalloc(sizeof(struct nfc_target), GFP_KERNEL);

I have rewritten this line to be:

target = kzalloc(sizeof(*target), GFP_KERNEL);

> + if (!target) {
> + rc = -ENOMEM;
> + goto out_free_skb;
> + }
> +
> + target->is_iso15693 = 1;
> + target->iso15693_dsfid = res->dsfid;
> + memcpy(target->iso15693_uid, &res->uid, sizeof(target->iso15693_uid));
> +
> + rc = digital_target_found(ddev, target, NFC_PROTO_ISO15693);
> +
> + kfree(target);
> +
> +out_free_skb:
> + dev_kfree_skb(resp);
> +
> + if (rc)
> + digital_poll_next_tech(ddev);
> +}
> +
> +int digital_in_send_iso15693_inv_req(struct nfc_digital_dev *ddev, u8 rf_tech)
> +{
> + struct digital_iso15693_inv_req *req;
> + struct sk_buff *skb;
> + int rc;
> +
> + rc = digital_in_configure_hw(ddev, NFC_DIGITAL_CONFIG_RF_TECH,
> + NFC_DIGITAL_RF_TECH_ISO15693);
> + if (rc)
> + return rc;
> +
> + rc = digital_in_configure_hw(ddev, NFC_DIGITAL_CONFIG_FRAMING,
> + NFC_DIGITAL_FRAMING_ISO15693_INVENTORY);
> + if (rc)
> + return rc;
> +
> + skb = digital_skb_alloc(ddev, sizeof(*req));
> + if (!skb)
> + return -ENOMEM;
> +
> + skb_put(skb, sizeof(*req) - sizeof(req->mask)); /* No mask */
> + req = (struct digital_iso15693_inv_req *)skb->data;
> +
> + /* Single sub-carrier, high data rate, no AFI, single slot
> + * Inventory command
> + */
> + req->flags = DIGITAL_ISO15693_REQ_FLAG_DATA_RATE |
> + DIGITAL_ISO15693_REQ_FLAG_INVENTORY |
> + DIGITAL_ISO15693_REQ_FLAG_NB_SLOTS;
> + req->cmd = DIGITAL_CMD_ISO15693_INVENTORY_REQ;

And added this line:

req->mask_len = 0;

> + rc = digital_in_send_cmd(ddev, skb, 30,
> + digital_in_recv_iso15693_inv_res, NULL);
> + if (rc)
> + kfree_skb(skb);
> +
> + return rc;
> +}
> +
> static int digital_tg_send_sel_res(struct nfc_digital_dev *ddev)
> {
> struct sk_buff *skb;
> --
> 1.8.3.4
>

2014-01-21 23:24:04

by Mark Greer

[permalink] [raw]
Subject: [PATCH v2 2/3] NFC: iso15693 - Add Digital Layer support for ISO/IEC 15693

Add support for ISO/IEC 15693 to the digital layer. The code
currently uses single-slot anticollision only since the digital
layer infrastructure only supports one tag per adapter (making
it pointless to do 16-slot anticollision).

The code uses two new framing types:
'NFC_DIGITAL_FRAMING_ISO15693_INVENTORY' and
'NFC_DIGITAL_FRAMING_ISO15693_TVT'. The former is used to
tell the driver to prepare for an Inventory command and the
ensuing anticollision sequence. The latter is used to tell
the driver that the anticollision sequence is over and to
prepare for non-inventory commands.

Signed-off-by: Mark A. Greer <[email protected]>
---

Changes since v1:
- rewrote kzalloc line to use sizeof(*target) instead of target's type
- initialized the mask_len part of the 15693 inventory request

net/nfc/digital.h | 1 +
net/nfc/digital_core.c | 14 ++++++
net/nfc/digital_technology.c | 109 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 124 insertions(+)

diff --git a/net/nfc/digital.h b/net/nfc/digital.h
index 08b29b5..3c757dc 100644
--- a/net/nfc/digital.h
+++ b/net/nfc/digital.h
@@ -72,6 +72,7 @@ void digital_poll_next_tech(struct nfc_digital_dev *ddev);

int digital_in_send_sens_req(struct nfc_digital_dev *ddev, u8 rf_tech);
int digital_in_send_sensf_req(struct nfc_digital_dev *ddev, u8 rf_tech);
+int digital_in_send_iso15693_inv_req(struct nfc_digital_dev *ddev, u8 rf_tech);

int digital_target_found(struct nfc_digital_dev *ddev,
struct nfc_target *target, u8 protocol);
diff --git a/net/nfc/digital_core.c b/net/nfc/digital_core.c
index c129d15..48906ca 100644
--- a/net/nfc/digital_core.c
+++ b/net/nfc/digital_core.c
@@ -25,6 +25,8 @@
#define DIGITAL_PROTO_NFCF_RF_TECH \
(NFC_PROTO_FELICA_MASK | NFC_PROTO_NFC_DEP_MASK)

+#define DIGITAL_PROTO_ISO15693_RF_TECH NFC_PROTO_ISO15693_MASK
+
struct digital_cmd {
struct list_head queue;

@@ -331,6 +333,12 @@ int digital_target_found(struct nfc_digital_dev *ddev,
}
break;

+ case NFC_PROTO_ISO15693:
+ framing = NFC_DIGITAL_FRAMING_ISO15693_TVT;
+ check_crc = digital_skb_check_crc_b;
+ add_crc = digital_skb_add_crc_b;
+ break;
+
default:
pr_err("Invalid protocol %d\n", protocol);
return -EINVAL;
@@ -469,6 +477,10 @@ static int digital_start_poll(struct nfc_dev *nfc_dev, __u32 im_protocols,
digital_in_send_sensf_req);
}

+ if (matching_im_protocols & DIGITAL_PROTO_ISO15693_RF_TECH)
+ digital_add_poll_tech(ddev, NFC_DIGITAL_RF_TECH_ISO15693,
+ digital_in_send_iso15693_inv_req);
+
if (tm_protocols & NFC_PROTO_NFC_DEP_MASK) {
if (ddev->ops->tg_listen_mdaa) {
digital_add_poll_tech(ddev, 0,
@@ -700,6 +712,8 @@ struct nfc_digital_dev *nfc_digital_allocate_device(struct nfc_digital_ops *ops,
ddev->protocols |= NFC_PROTO_FELICA_MASK;
if (supported_protocols & NFC_PROTO_NFC_DEP_MASK)
ddev->protocols |= NFC_PROTO_NFC_DEP_MASK;
+ if (supported_protocols & NFC_PROTO_ISO15693_MASK)
+ ddev->protocols |= NFC_PROTO_ISO15693_MASK;

ddev->tx_headroom = tx_headroom + DIGITAL_MAX_HEADER_LEN;
ddev->tx_tailroom = tx_tailroom + DIGITAL_CRC_LEN;
diff --git a/net/nfc/digital_technology.c b/net/nfc/digital_technology.c
index 251c8c7..97d3f60 100644
--- a/net/nfc/digital_technology.c
+++ b/net/nfc/digital_technology.c
@@ -51,6 +51,15 @@
#define DIGITAL_SENSF_REQ_RC_SC 1
#define DIGITAL_SENSF_REQ_RC_AP 2

+#define DIGITAL_CMD_ISO15693_INVENTORY_REQ 0x01
+
+#define DIGITAL_ISO15693_REQ_FLAG_DATA_RATE BIT(1)
+#define DIGITAL_ISO15693_REQ_FLAG_INVENTORY BIT(2)
+#define DIGITAL_ISO15693_REQ_FLAG_NB_SLOTS BIT(5)
+#define DIGITAL_ISO15693_RES_FLAG_ERROR BIT(0)
+#define DIGITAL_ISO15693_RES_IS_VALID(flags) \
+ (!((flags) & DIGITAL_ISO15693_RES_FLAG_ERROR))
+
struct digital_sdd_res {
u8 nfcid1[4];
u8 bcc;
@@ -82,6 +91,19 @@ struct digital_sensf_res {
u8 rd[2];
} __packed;

+struct digital_iso15693_inv_req {
+ u8 flags;
+ u8 cmd;
+ u8 mask_len;
+ u64 mask;
+} __packed;
+
+struct digital_iso15693_inv_res {
+ u8 flags;
+ u8 dsfid;
+ u64 uid;
+} __packed;
+
static int digital_in_send_sdd_req(struct nfc_digital_dev *ddev,
struct nfc_target *target);

@@ -473,6 +495,93 @@ int digital_in_send_sensf_req(struct nfc_digital_dev *ddev, u8 rf_tech)
return rc;
}

+static void digital_in_recv_iso15693_inv_res(struct nfc_digital_dev *ddev,
+ void *arg, struct sk_buff *resp)
+{
+ struct digital_iso15693_inv_res *res;
+ struct nfc_target *target = NULL;
+ int rc;
+
+ if (IS_ERR(resp)) {
+ rc = PTR_ERR(resp);
+ resp = NULL;
+ goto out_free_skb;
+ }
+
+ if (resp->len != sizeof(*res)) {
+ rc = -EIO;
+ goto out_free_skb;
+ }
+
+ res = (struct digital_iso15693_inv_res *)resp->data;
+
+ if (!DIGITAL_ISO15693_RES_IS_VALID(res->flags)) {
+ PROTOCOL_ERR("ISO15693 - 10.3.1");
+ rc = -EINVAL;
+ goto out_free_skb;
+ }
+
+ target = kzalloc(sizeof(*target), GFP_KERNEL);
+ if (!target) {
+ rc = -ENOMEM;
+ goto out_free_skb;
+ }
+
+ target->is_iso15693 = 1;
+ target->iso15693_dsfid = res->dsfid;
+ memcpy(target->iso15693_uid, &res->uid, sizeof(target->iso15693_uid));
+
+ rc = digital_target_found(ddev, target, NFC_PROTO_ISO15693);
+
+ kfree(target);
+
+out_free_skb:
+ dev_kfree_skb(resp);
+
+ if (rc)
+ digital_poll_next_tech(ddev);
+}
+
+int digital_in_send_iso15693_inv_req(struct nfc_digital_dev *ddev, u8 rf_tech)
+{
+ struct digital_iso15693_inv_req *req;
+ struct sk_buff *skb;
+ int rc;
+
+ rc = digital_in_configure_hw(ddev, NFC_DIGITAL_CONFIG_RF_TECH,
+ NFC_DIGITAL_RF_TECH_ISO15693);
+ if (rc)
+ return rc;
+
+ rc = digital_in_configure_hw(ddev, NFC_DIGITAL_CONFIG_FRAMING,
+ NFC_DIGITAL_FRAMING_ISO15693_INVENTORY);
+ if (rc)
+ return rc;
+
+ skb = digital_skb_alloc(ddev, sizeof(*req));
+ if (!skb)
+ return -ENOMEM;
+
+ skb_put(skb, sizeof(*req) - sizeof(req->mask)); /* No mask */
+ req = (struct digital_iso15693_inv_req *)skb->data;
+
+ /* Single sub-carrier, high data rate, no AFI, single slot
+ * Inventory command
+ */
+ req->flags = DIGITAL_ISO15693_REQ_FLAG_DATA_RATE |
+ DIGITAL_ISO15693_REQ_FLAG_INVENTORY |
+ DIGITAL_ISO15693_REQ_FLAG_NB_SLOTS;
+ req->cmd = DIGITAL_CMD_ISO15693_INVENTORY_REQ;
+ req->mask_len = 0;
+
+ rc = digital_in_send_cmd(ddev, skb, 30,
+ digital_in_recv_iso15693_inv_res, NULL);
+ if (rc)
+ kfree_skb(skb);
+
+ return rc;
+}
+
static int digital_tg_send_sel_res(struct nfc_digital_dev *ddev)
{
struct sk_buff *skb;
--
1.8.3.4


2014-01-21 22:31:45

by Samuel Ortiz

[permalink] [raw]
Subject: Re: [PATCH 0/3] NFC: iso15693 - Add ISO/IEC 15693 support

Hi Mark,

On Tue, Jan 14, 2014 at 05:52:08PM -0700, Mark A. Greer wrote:
> This series of patches adds support for the ISO/IEC 15693 protocol
> and Type V vicinity cards.
The patches look good to me. I'll wait for a v2 that includes your
changes for patch #2 and apply it.

Cheers,
Samuel.

--
Intel Open Source Technology Centre
http://oss.intel.com/

2014-01-15 01:00:24

by Mark Greer

[permalink] [raw]
Subject: [PATCH 3/3] NFC: iso15693 - Add netlink support for ISO/IEC 15693

Add ISO/IEC 15693 support by having netlink push the
1-byte DSFID and 8-byte UID tag information upstream.

Signed-off-by: Mark A. Greer <[email protected]>
---
net/nfc/netlink.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c
index ebbf6fb..43cb1c1 100644
--- a/net/nfc/netlink.c
+++ b/net/nfc/netlink.c
@@ -94,6 +94,14 @@ static int nfc_genl_send_target(struct sk_buff *msg, struct nfc_target *target,
target->sensf_res))
goto nla_put_failure;

+ if (target->is_iso15693) {
+ if (nla_put_u8(msg, NFC_ATTR_TARGET_ISO15693_DSFID,
+ target->iso15693_dsfid) ||
+ nla_put(msg, NFC_ATTR_TARGET_ISO15693_UID,
+ sizeof(target->iso15693_uid), target->iso15693_uid))
+ goto nla_put_failure;
+ }
+
return genlmsg_end(msg, hdr);

nla_put_failure:
--
1.8.3.4


2014-01-15 00:57:42

by Mark Greer

[permalink] [raw]
Subject: [PATCH 2/3] NFC: iso15693 - Add Digital Layer support for ISO/IEC 15693

Add support for ISO/IEC 15693 to the digital layer. The code
currently uses single-slot anticollision only since the digital
layer infrastructure only supports one tag per adapter (making
it pointless to do 16-slot anticollision).

The code uses two new framing types:
'NFC_DIGITAL_FRAMING_ISO15693_INVENTORY' and
'NFC_DIGITAL_FRAMING_ISO15693_TVT'. The former is used to
tell the driver to prepare for an Inventory command and the
ensuing anticollision sequence. The latter is used to tell
the driver that the anticollision sequence is over and to
prepare for non-inventory commands.

Signed-off-by: Mark A. Greer <[email protected]>
---
net/nfc/digital.h | 1 +
net/nfc/digital_core.c | 14 ++++++
net/nfc/digital_technology.c | 108 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 123 insertions(+)

diff --git a/net/nfc/digital.h b/net/nfc/digital.h
index 08b29b5..3c757dc 100644
--- a/net/nfc/digital.h
+++ b/net/nfc/digital.h
@@ -72,6 +72,7 @@ void digital_poll_next_tech(struct nfc_digital_dev *ddev);

int digital_in_send_sens_req(struct nfc_digital_dev *ddev, u8 rf_tech);
int digital_in_send_sensf_req(struct nfc_digital_dev *ddev, u8 rf_tech);
+int digital_in_send_iso15693_inv_req(struct nfc_digital_dev *ddev, u8 rf_tech);

int digital_target_found(struct nfc_digital_dev *ddev,
struct nfc_target *target, u8 protocol);
diff --git a/net/nfc/digital_core.c b/net/nfc/digital_core.c
index c129d15..48906ca 100644
--- a/net/nfc/digital_core.c
+++ b/net/nfc/digital_core.c
@@ -25,6 +25,8 @@
#define DIGITAL_PROTO_NFCF_RF_TECH \
(NFC_PROTO_FELICA_MASK | NFC_PROTO_NFC_DEP_MASK)

+#define DIGITAL_PROTO_ISO15693_RF_TECH NFC_PROTO_ISO15693_MASK
+
struct digital_cmd {
struct list_head queue;

@@ -331,6 +333,12 @@ int digital_target_found(struct nfc_digital_dev *ddev,
}
break;

+ case NFC_PROTO_ISO15693:
+ framing = NFC_DIGITAL_FRAMING_ISO15693_TVT;
+ check_crc = digital_skb_check_crc_b;
+ add_crc = digital_skb_add_crc_b;
+ break;
+
default:
pr_err("Invalid protocol %d\n", protocol);
return -EINVAL;
@@ -469,6 +477,10 @@ static int digital_start_poll(struct nfc_dev *nfc_dev, __u32 im_protocols,
digital_in_send_sensf_req);
}

+ if (matching_im_protocols & DIGITAL_PROTO_ISO15693_RF_TECH)
+ digital_add_poll_tech(ddev, NFC_DIGITAL_RF_TECH_ISO15693,
+ digital_in_send_iso15693_inv_req);
+
if (tm_protocols & NFC_PROTO_NFC_DEP_MASK) {
if (ddev->ops->tg_listen_mdaa) {
digital_add_poll_tech(ddev, 0,
@@ -700,6 +712,8 @@ struct nfc_digital_dev *nfc_digital_allocate_device(struct nfc_digital_ops *ops,
ddev->protocols |= NFC_PROTO_FELICA_MASK;
if (supported_protocols & NFC_PROTO_NFC_DEP_MASK)
ddev->protocols |= NFC_PROTO_NFC_DEP_MASK;
+ if (supported_protocols & NFC_PROTO_ISO15693_MASK)
+ ddev->protocols |= NFC_PROTO_ISO15693_MASK;

ddev->tx_headroom = tx_headroom + DIGITAL_MAX_HEADER_LEN;
ddev->tx_tailroom = tx_tailroom + DIGITAL_CRC_LEN;
diff --git a/net/nfc/digital_technology.c b/net/nfc/digital_technology.c
index 251c8c7..6d3d03f 100644
--- a/net/nfc/digital_technology.c
+++ b/net/nfc/digital_technology.c
@@ -51,6 +51,15 @@
#define DIGITAL_SENSF_REQ_RC_SC 1
#define DIGITAL_SENSF_REQ_RC_AP 2

+#define DIGITAL_CMD_ISO15693_INVENTORY_REQ 0x01
+
+#define DIGITAL_ISO15693_REQ_FLAG_DATA_RATE BIT(1)
+#define DIGITAL_ISO15693_REQ_FLAG_INVENTORY BIT(2)
+#define DIGITAL_ISO15693_REQ_FLAG_NB_SLOTS BIT(5)
+#define DIGITAL_ISO15693_RES_FLAG_ERROR BIT(0)
+#define DIGITAL_ISO15693_RES_IS_VALID(flags) \
+ (!((flags) & DIGITAL_ISO15693_RES_FLAG_ERROR))
+
struct digital_sdd_res {
u8 nfcid1[4];
u8 bcc;
@@ -82,6 +91,19 @@ struct digital_sensf_res {
u8 rd[2];
} __packed;

+struct digital_iso15693_inv_req {
+ u8 flags;
+ u8 cmd;
+ u8 mask_len;
+ u64 mask;
+} __packed;
+
+struct digital_iso15693_inv_res {
+ u8 flags;
+ u8 dsfid;
+ u64 uid;
+} __packed;
+
static int digital_in_send_sdd_req(struct nfc_digital_dev *ddev,
struct nfc_target *target);

@@ -473,6 +495,92 @@ int digital_in_send_sensf_req(struct nfc_digital_dev *ddev, u8 rf_tech)
return rc;
}

+static void digital_in_recv_iso15693_inv_res(struct nfc_digital_dev *ddev,
+ void *arg, struct sk_buff *resp)
+{
+ struct digital_iso15693_inv_res *res;
+ struct nfc_target *target = NULL;
+ int rc;
+
+ if (IS_ERR(resp)) {
+ rc = PTR_ERR(resp);
+ resp = NULL;
+ goto out_free_skb;
+ }
+
+ if (resp->len != sizeof(*res)) {
+ rc = -EIO;
+ goto out_free_skb;
+ }
+
+ res = (struct digital_iso15693_inv_res *)resp->data;
+
+ if (!DIGITAL_ISO15693_RES_IS_VALID(res->flags)) {
+ PROTOCOL_ERR("ISO15693 - 10.3.1");
+ rc = -EINVAL;
+ goto out_free_skb;
+ }
+
+ target = kzalloc(sizeof(struct nfc_target), GFP_KERNEL);
+ if (!target) {
+ rc = -ENOMEM;
+ goto out_free_skb;
+ }
+
+ target->is_iso15693 = 1;
+ target->iso15693_dsfid = res->dsfid;
+ memcpy(target->iso15693_uid, &res->uid, sizeof(target->iso15693_uid));
+
+ rc = digital_target_found(ddev, target, NFC_PROTO_ISO15693);
+
+ kfree(target);
+
+out_free_skb:
+ dev_kfree_skb(resp);
+
+ if (rc)
+ digital_poll_next_tech(ddev);
+}
+
+int digital_in_send_iso15693_inv_req(struct nfc_digital_dev *ddev, u8 rf_tech)
+{
+ struct digital_iso15693_inv_req *req;
+ struct sk_buff *skb;
+ int rc;
+
+ rc = digital_in_configure_hw(ddev, NFC_DIGITAL_CONFIG_RF_TECH,
+ NFC_DIGITAL_RF_TECH_ISO15693);
+ if (rc)
+ return rc;
+
+ rc = digital_in_configure_hw(ddev, NFC_DIGITAL_CONFIG_FRAMING,
+ NFC_DIGITAL_FRAMING_ISO15693_INVENTORY);
+ if (rc)
+ return rc;
+
+ skb = digital_skb_alloc(ddev, sizeof(*req));
+ if (!skb)
+ return -ENOMEM;
+
+ skb_put(skb, sizeof(*req) - sizeof(req->mask)); /* No mask */
+ req = (struct digital_iso15693_inv_req *)skb->data;
+
+ /* Single sub-carrier, high data rate, no AFI, single slot
+ * Inventory command
+ */
+ req->flags = DIGITAL_ISO15693_REQ_FLAG_DATA_RATE |
+ DIGITAL_ISO15693_REQ_FLAG_INVENTORY |
+ DIGITAL_ISO15693_REQ_FLAG_NB_SLOTS;
+ req->cmd = DIGITAL_CMD_ISO15693_INVENTORY_REQ;
+
+ rc = digital_in_send_cmd(ddev, skb, 30,
+ digital_in_recv_iso15693_inv_res, NULL);
+ if (rc)
+ kfree_skb(skb);
+
+ return rc;
+}
+
static int digital_tg_send_sel_res(struct nfc_digital_dev *ddev)
{
struct sk_buff *skb;
--
1.8.3.4


2014-01-22 00:55:30

by Samuel Ortiz

[permalink] [raw]
Subject: Re: [PATCH v2 2/3] NFC: iso15693 - Add Digital Layer support for ISO/IEC 15693

Hi Mark,

On Tue, Jan 21, 2014 at 04:23:59PM -0700, Mark A. Greer wrote:
> Add support for ISO/IEC 15693 to the digital layer. The code
> currently uses single-slot anticollision only since the digital
> layer infrastructure only supports one tag per adapter (making
> it pointless to do 16-slot anticollision).
>
> The code uses two new framing types:
> 'NFC_DIGITAL_FRAMING_ISO15693_INVENTORY' and
> 'NFC_DIGITAL_FRAMING_ISO15693_TVT'. The former is used to
> tell the driver to prepare for an Inventory command and the
> ensuing anticollision sequence. The latter is used to tell
> the driver that the anticollision sequence is over and to
> prepare for non-inventory commands.
>
> Signed-off-by: Mark A. Greer <[email protected]>
> ---
>
> Changes since v1:
> - rewrote kzalloc line to use sizeof(*target) instead of target's type
> - initialized the mask_len part of the 15693 inventory request
Thanks, all 3 patches applied to nfc-next now.

Cheers,
Samuel.

--
Intel Open Source Technology Centre
http://oss.intel.com/

2014-01-15 01:00:12

by Mark Greer

[permalink] [raw]
Subject: [PATCH 1/3] NFC: iso15693 - Add ISO/IEC 15693 header definitions

Add the header definitions required by upcoming
patches that add support for ISO/IEC 15693.

Signed-off-by: Mark A. Greer <[email protected]>
---
include/net/nfc/digital.h | 4 ++++
include/net/nfc/nfc.h | 3 +++
include/uapi/linux/nfc.h | 9 ++++++++-
3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/include/net/nfc/digital.h b/include/net/nfc/digital.h
index 81af21e..1f0528d 100644
--- a/include/net/nfc/digital.h
+++ b/include/net/nfc/digital.h
@@ -35,6 +35,7 @@ enum {
NFC_DIGITAL_RF_TECH_106A = 0,
NFC_DIGITAL_RF_TECH_212F,
NFC_DIGITAL_RF_TECH_424F,
+ NFC_DIGITAL_RF_TECH_ISO15693,

NFC_DIGITAL_RF_TECH_LAST,
};
@@ -57,6 +58,9 @@ enum {
NFC_DIGITAL_FRAMING_NFCF_NFC_DEP,
NFC_DIGITAL_FRAMING_NFC_DEP_ACTIVATED,

+ NFC_DIGITAL_FRAMING_ISO15693_INVENTORY,
+ NFC_DIGITAL_FRAMING_ISO15693_TVT, /* Type V Tag (ISO/IEC 15693) */
+
NFC_DIGITAL_FRAMING_LAST,
};

diff --git a/include/net/nfc/nfc.h b/include/net/nfc/nfc.h
index 82fc4e4..44943e1 100644
--- a/include/net/nfc/nfc.h
+++ b/include/net/nfc/nfc.h
@@ -113,6 +113,9 @@ struct nfc_target {
u8 sensf_res[NFC_SENSF_RES_MAXSIZE];
u8 hci_reader_gate;
u8 logical_idx;
+ u8 is_iso15693;
+ u8 iso15693_dsfid;
+ u8 iso15693_uid[NFC_ISO15693_UID_MAXSIZE];
};

/**
diff --git a/include/uapi/linux/nfc.h b/include/uapi/linux/nfc.h
index 6ad6cc0..9789dc9 100644
--- a/include/uapi/linux/nfc.h
+++ b/include/uapi/linux/nfc.h
@@ -150,6 +150,8 @@ enum nfc_commands {
* @NFC_ATTR_SE_TYPE: Secure element type (UICC or EMBEDDED)
* @NFC_ATTR_FIRMWARE_DOWNLOAD_STATUS: Firmware download operation status
* @NFC_ATTR_APDU: Secure element APDU
+ * @NFC_ATTR_TARGET_ISO15693_DSFID: ISO 15693 Data Storage Format Identifier
+ * @NFC_ATTR_TARGET_ISO15693_UID: ISO 15693 Unique Identifier
*/
enum nfc_attrs {
NFC_ATTR_UNSPEC,
@@ -178,6 +180,8 @@ enum nfc_attrs {
NFC_ATTR_SE_AID,
NFC_ATTR_FIRMWARE_DOWNLOAD_STATUS,
NFC_ATTR_SE_APDU,
+ NFC_ATTR_TARGET_ISO15693_DSFID,
+ NFC_ATTR_TARGET_ISO15693_UID,
/* private: internal use only */
__NFC_ATTR_AFTER_LAST
};
@@ -200,6 +204,7 @@ enum nfc_sdp_attr {
#define NFC_SENSF_RES_MAXSIZE 18
#define NFC_GB_MAXSIZE 48
#define NFC_FIRMWARE_NAME_MAXSIZE 32
+#define NFC_ISO15693_UID_MAXSIZE 8

/* NFC protocols */
#define NFC_PROTO_JEWEL 1
@@ -208,8 +213,9 @@ enum nfc_sdp_attr {
#define NFC_PROTO_ISO14443 4
#define NFC_PROTO_NFC_DEP 5
#define NFC_PROTO_ISO14443_B 6
+#define NFC_PROTO_ISO15693 7

-#define NFC_PROTO_MAX 7
+#define NFC_PROTO_MAX 8

/* NFC communication modes */
#define NFC_COMM_ACTIVE 0
@@ -227,6 +233,7 @@ enum nfc_sdp_attr {
#define NFC_PROTO_ISO14443_MASK (1 << NFC_PROTO_ISO14443)
#define NFC_PROTO_NFC_DEP_MASK (1 << NFC_PROTO_NFC_DEP)
#define NFC_PROTO_ISO14443_B_MASK (1 << NFC_PROTO_ISO14443_B)
+#define NFC_PROTO_ISO15693_MASK (1 << NFC_PROTO_ISO15693)

/* NFC Secure Elements */
#define NFC_SE_UICC 0x1
--
1.8.3.4