net/nfc/digital_dep.c

Source file repositories/reference/linux-study-clean/net/nfc/digital_dep.c

File Facts

System
Linux kernel
Corpus path
net/nfc/digital_dep.c
Extension
.c
Size
35067 bytes
Lines
1634
Domain
Networking Core
Bucket
Sockets, Protocols, Packet Path, And Network Policy
Inferred role
Networking Core: implementation source
Status
source implementation candidate

Why This File Exists

Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.

Dependency Surface

Detected Declarations

Annotated Snippet

struct digital_atr_req {
	u8 dir;
	u8 cmd;
	u8 nfcid3[10];
	u8 did;
	u8 bs;
	u8 br;
	u8 pp;
	u8 gb[];
} __packed;

struct digital_atr_res {
	u8 dir;
	u8 cmd;
	u8 nfcid3[10];
	u8 did;
	u8 bs;
	u8 br;
	u8 to;
	u8 pp;
	u8 gb[];
} __packed;

struct digital_psl_req {
	u8 dir;
	u8 cmd;
	u8 did;
	u8 brs;
	u8 fsl;
} __packed;

struct digital_psl_res {
	u8 dir;
	u8 cmd;
	u8 did;
} __packed;

struct digital_dep_req_res {
	u8 dir;
	u8 cmd;
	u8 pfb;
} __packed;

static void digital_in_recv_dep_res(struct nfc_digital_dev *ddev, void *arg,
				    struct sk_buff *resp);
static void digital_tg_recv_dep_req(struct nfc_digital_dev *ddev, void *arg,
				    struct sk_buff *resp);

static const u8 digital_payload_bits_map[4] = {
	[0] = 64,
	[1] = 128,
	[2] = 192,
	[3] = 254
};

/* Response Waiting Time for ATR_RES PDU in ms
 *
 * RWT(ATR_RES) = RWT(nfcdep,activation) + dRWT(nfcdep) + dT(nfcdep,initiator)
 *
 * with:
 *  RWT(nfcdep,activation) = 4096 * 2^12 / f(c) s
 *  dRWT(nfcdep) = 16 / f(c) s
 *  dT(nfcdep,initiator) = 100 ms
 *  f(c) = 13560000 Hz
 */
#define DIGITAL_ATR_RES_RWT 1337

/* Response Waiting Time for other DEP PDUs in ms
 *
 * max_rwt = rwt + dRWT(nfcdep) + dT(nfcdep,initiator)
 *
 * with:
 *  rwt = (256 * 16 / f(c)) * 2^wt s
 *  dRWT(nfcdep) = 16 / f(c) s
 *  dT(nfcdep,initiator) = 100 ms
 *  f(c) = 13560000 Hz
 *  0 <= wt <= 14 (given by the target by the TO field of ATR_RES response)
 */
#define DIGITAL_NFC_DEP_IN_MAX_WT 14
#define DIGITAL_NFC_DEP_TG_MAX_WT 14
static const u16 digital_rwt_map[DIGITAL_NFC_DEP_IN_MAX_WT + 1] = {
	100,  101,  101,  102,  105,
	110,  119,  139,  177,  255,
	409,  719, 1337, 2575, 5049,
};

static u8 digital_payload_bits_to_size(u8 payload_bits)
{
	if (payload_bits >= ARRAY_SIZE(digital_payload_bits_map))
		return 0;

Annotation

Implementation Notes