All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aloisio Almeida Jr <aloisio.almeida@openbossa.org>
To: linville@tuxdriver.com
Cc: linux-wireless@vger.kernel.org, sameo@linux.intel.com,
	johannes@sipsolutions.net, lauro.venancio@openbossa.org,
	marcio.macedo@openbossa.org, Waldemar.Rymarkiewicz@tieto.com,
	Aloisio Almeida Jr <aloisio.almeida@openbossa.org>
Subject: [RFC][PATCH v2 7/7] NFC: add Documentation/networking/nfc.txt
Date: Mon, 20 Jun 2011 14:50:12 -0300	[thread overview]
Message-ID: <1308592212-5755-8-git-send-email-aloisio.almeida@openbossa.org> (raw)
In-Reply-To: <1308592212-5755-1-git-send-email-aloisio.almeida@openbossa.org>

Signed-off-by: Aloisio Almeida Jr <aloisio.almeida@openbossa.org>
Signed-off-by: Lauro Ramos Venancio <lauro.venancio@openbossa.org>
---
 Documentation/networking/nfc.txt |  127 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 127 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/networking/nfc.txt

diff --git a/Documentation/networking/nfc.txt b/Documentation/networking/nfc.txt
new file mode 100644
index 0000000..23cf411
--- /dev/null
+++ b/Documentation/networking/nfc.txt
@@ -0,0 +1,127 @@
+Linux NFC subsystem
+===================
+
+The Near Field Communication (NFC) subsystem is required to standardize the
+NFC device drivers development and to create an unified userspace interface.
+
+This document covers the architecture overview, the device driver interface
+description and the userspace interface description.
+
+Architecture overview
+---------------------
+
+The NFC subsystem is responsible for:
+      - NFC adapters management;
+      - Polling for targets;
+      - Low-level data exchange;
+
+The subsystem is divided in some parts. The 'core' is responsible for
+providing the device driver interface. On the other side, it is also
+responsible for providing an interface to control operations and low-level
+data exchange.
+
+The control operations are available to userspace via generic netlink.
+
+The low-level data exchage interface is provided by the new socket family
+PF_NFC. The NFC_SOCKPROTO_RAW performs raw communication with NFC targets.
+
+
+             +--------------------------------------+
+             |              USER SPACE              |
+             +--------------------------------------+
+                 ^                       ^
+                 | low-level             | control
+                 | data exchange         | operations
+                 |                       |
+                 |                       v
+                 |                  +-----------+
+                 | AF_NFC           |  netlink  |
+                 | socket           +-----------+
+                 | raw                   ^
+                 |                       |
+                 v                       v
+             +---------+            +-----------+
+             | rawsock | <--------> |   core    |
+             +---------+            +-----------+
+                                         ^
+                                         |
+                                         v
+                                    +-----------+
+                                    |  driver   |
+                                    +-----------+
+
+Device Driver Interface
+-----------------------
+
+When registering on the NFC subsystem, the device driver must inform the set
+of supported NFC protocols and the set of ops callbacks. The ops callbacks
+that must be implemented are the following:
+
+* start_poll - setup the device to poll for targets
+* stop_poll - stop on progress polling operation
+* activate_target - select and initialize one of the targets found
+* deactivate_target - deselect and deinitialize the selected target
+* data_exchange - send data and receive the response (transceive operation)
+
+Userspace interface
+--------------------
+
+The userspace interface is divided in control operations and low-level data
+exchange operation.
+
+CONTROL OPERATIONS:
+
+Generic netlink was used to implement the interface to the control operations.
+The operations are composed by commands and events, all listed below:
+
+* NFC_CMD_GET_DEVICE - get an specific device info or dump the device list
+* NFC_CMD_START_POLL - setup a specific device to polling for targets
+* NFC_CMD_STOP_POLL - stop the polling operation in a specifc device
+
+* NFC_EVENT_DEVICE_ADDED - reports a NFC device addition
+* NFC_EVENT_DEVICE_REMOVED - reports a NFC device removal
+* NFC_EVENT_TARGETS_FOUND - reports START_POLL results when 1 or more targets
+are found
+
+The user must call START_POLL to poll for NFC targets, passing the desired NFC
+protocols through NFC_ATTR_PROTOCOLS attribute. The device remains in polling
+state until it finds any target. However, the user can stop the polling
+operation by calling STOP_POLL command. In this case, it will be checked if
+the requester of STOP_POLL is the same of START_POLL.
+
+If the polling operation finds one or more targets, the event TARGETS_FOUND is
+sent. The event attributes have relevant information about the target, such as
+the supported NFC protocols. The TARGETS_FOUND event has the list of all
+targets found by a specific device.
+
+All polling operations requested through one netlink socket are stopped when
+it's closed.
+
+LOW-LEVEL DATA EXCHANGE:
+
+The userspace must use PF_NFC sockets to perform any data communication with
+targets. All NFC sockets use AF_NFC:
+
+struct sockaddr_nfc {
+       sa_family_t sa_family;
+       __u32 dev_idx;
+       __u32 target_idx;
+       __u32 nfc_protocol;
+};
+
+To establish a connection with one target, the user must create a
+NFC_SOCKPROTO_RAW socket and call the 'connect' syscall with the sockaddr_nfc
+struct correctly filled. All information comes from NFC_EVENT_TARGETS_FOUND
+netlink event. As a target can support more than one NFC protocol, the user
+must inform which protocol it wants to use.
+
+Internally, 'connect' will result in a activate_target call to the driver.
+When the socket is closed, the target is deactivated.
+
+The data format exchanged through the sockets is NFC protocol dependent. For
+instance, when communicating with MIFARE tags, the data exchanged are MIFARE
+commands and their responses.
+
+The first received package is the response to the first sent package and so
+on. In order to allow valid "empty" responses, every data received has a NULL
+header of 1 byte.
-- 
1.7.4.1


  parent reply	other threads:[~2011-06-20 17:52 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-20 17:50 [RFC][PATCH v2 0/7] NFC subsystem Aloisio Almeida Jr
2011-06-20 17:50 ` [RFC][PATCH v2 1/7] netlink: advertise incomplete dumps Aloisio Almeida Jr
2011-06-20 17:50 ` [RFC][PATCH v2 2/7] NFC: add nfc subsystem core Aloisio Almeida Jr
2011-06-21 21:55   ` Gustavo F. Padovan
2011-06-22  2:24     ` Marcel Holtmann
2011-06-22 14:18       ` Aloisio Almeida
2011-06-20 17:50 ` [RFC][PATCH v2 3/7] NFC: add nfc generic netlink interface Aloisio Almeida Jr
2011-06-21 22:05   ` Gustavo F. Padovan
2011-06-21 22:15     ` Eliad Peller
2011-06-22 20:03       ` Gustavo F. Padovan
2011-06-22  6:56     ` Johannes Berg
2011-06-22 19:55       ` Gustavo F. Padovan
2011-06-22 14:07     ` Aloisio Almeida
2011-06-22  7:34   ` Johannes Berg
2011-06-22 12:57     ` Samuel Ortiz
2011-06-22 13:08       ` Johannes Berg
2011-06-22 13:27         ` Samuel Ortiz
2011-06-22 16:49     ` Aloisio Almeida
2011-06-23  7:55   ` Johannes Berg
2011-06-20 17:50 ` [RFC][PATCH v2 4/7] NFC: add NFC socket family Aloisio Almeida Jr
2011-06-20 17:50 ` [RFC][PATCH v2 5/7] NFC: add the NFC socket raw protocol Aloisio Almeida Jr
2011-06-20 17:50 ` [RFC][PATCH v2 6/7] NFC: pn533: add NXP pn533 nfc device driver Aloisio Almeida Jr
2011-06-20 17:50 ` Aloisio Almeida Jr [this message]
2011-06-20 20:24   ` [RFC][PATCH v3 7/7] NFC: add Documentation/networking/nfc.txt Aloisio Almeida Jr
2011-06-21 21:23     ` Randy Dunlap
2011-06-22 14:13       ` Aloisio Almeida

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1308592212-5755-8-git-send-email-aloisio.almeida@openbossa.org \
    --to=aloisio.almeida@openbossa.org \
    --cc=Waldemar.Rymarkiewicz@tieto.com \
    --cc=johannes@sipsolutions.net \
    --cc=lauro.venancio@openbossa.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=marcio.macedo@openbossa.org \
    --cc=sameo@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.