1
+ ===================
1
2
Linux NFC subsystem
2
3
===================
3
4
@@ -8,7 +9,7 @@ This document covers the architecture overview, the device driver interface
8
9
description and the userspace interface description.
9
10
10
11
Architecture overview
11
- ---------------------
12
+ =====================
12
13
13
14
The NFC subsystem is responsible for:
14
15
- NFC adapters management;
@@ -25,33 +26,34 @@ The control operations are available to userspace via generic netlink.
25
26
The low-level data exchange interface is provided by the new socket family
26
27
PF_NFC. The NFC_SOCKPROTO_RAW performs raw communication with NFC targets.
27
28
28
-
29
- +--------------------------------------+
30
- | USER SPACE |
31
- +--------------------------------------+
32
- ^ ^
33
- | low-level | control
34
- | data exchange | operations
35
- | |
36
- | v
37
- | +-----------+
38
- | AF_NFC | netlink |
39
- | socket +-----------+
40
- | raw ^
41
- | |
42
- v v
43
- +---------+ +-----------+
44
- | rawsock | <--------> | core |
45
- +---------+ +-----------+
46
- ^
47
- |
48
- v
49
- +-----------+
50
- | driver |
51
- +-----------+
29
+ .. code-block :: none
30
+
31
+ +--------------------------------------+
32
+ | USER SPACE |
33
+ +--------------------------------------+
34
+ ^ ^
35
+ | low-level | control
36
+ | data exchange | operations
37
+ | |
38
+ | v
39
+ | +-----------+
40
+ | AF_NFC | netlink |
41
+ | socket +-----------+
42
+ | raw ^
43
+ | |
44
+ v v
45
+ +---------+ +-----------+
46
+ | rawsock | <--------> | core |
47
+ +---------+ +-----------+
48
+ ^
49
+ |
50
+ v
51
+ +-----------+
52
+ | driver |
53
+ +-----------+
52
54
53
55
Device Driver Interface
54
- -----------------------
56
+ =======================
55
57
56
58
When registering on the NFC subsystem, the device driver must inform the core
57
59
of the set of supported NFC protocols and the set of ops callbacks. The ops
@@ -64,7 +66,7 @@ callbacks that must be implemented are the following:
64
66
* data_exchange - send data and receive the response (transceive operation)
65
67
66
68
Userspace interface
67
- --------------------
69
+ ===================
68
70
69
71
The userspace interface is divided in control operations and low-level data
70
72
exchange operation.
@@ -82,7 +84,7 @@ The operations are composed by commands and events, all listed below:
82
84
* NFC_EVENT_DEVICE_ADDED - reports an NFC device addition
83
85
* NFC_EVENT_DEVICE_REMOVED - reports an NFC device removal
84
86
* NFC_EVENT_TARGETS_FOUND - reports START_POLL results when 1 or more targets
85
- are found
87
+ are found
86
88
87
89
The user must call START_POLL to poll for NFC targets, passing the desired NFC
88
90
protocols through NFC_ATTR_PROTOCOLS attribute. The device remains in polling
@@ -101,14 +103,14 @@ it's closed.
101
103
LOW-LEVEL DATA EXCHANGE:
102
104
103
105
The userspace must use PF_NFC sockets to perform any data communication with
104
- targets. All NFC sockets use AF_NFC:
105
-
106
- struct sockaddr_nfc {
107
- sa_family_t sa_family;
108
- __u32 dev_idx;
109
- __u32 target_idx;
110
- __u32 nfc_protocol;
111
- };
106
+ targets. All NFC sockets use AF_NFC::
107
+
108
+ struct sockaddr_nfc {
109
+ sa_family_t sa_family;
110
+ __u32 dev_idx;
111
+ __u32 target_idx;
112
+ __u32 nfc_protocol;
113
+ };
112
114
113
115
To establish a connection with one target, the user must create an
114
116
NFC_SOCKPROTO_RAW socket and call the 'connect' syscall with the sockaddr_nfc
0 commit comments