linux/include/net/nfc/nci_core.h

/* SPDX-License-Identifier: GPL-2.0-only */
/*
 *  The NFC Controller Interface is the communication protocol between an
 *  NFC Controller (NFCC) and a Device Host (DH).
 *
 *  Copyright (C) 2011 Texas Instruments, Inc.
 *  Copyright (C) 2013 Intel Corporation. All rights reserved.
 *  Copyright (C) 2014 Marvell International Ltd.
 *
 *  Written by Ilan Elias <[email protected]>
 *
 *  Acknowledgements:
 *  This file is based on hci_core.h, which was written
 *  by Maxim Krasnyansky.
 */

#ifndef __NCI_CORE_H
#define __NCI_CORE_H

#include <linux/interrupt.h>
#include <linux/skbuff.h>
#include <linux/tty.h>

#include <net/nfc/nfc.h>
#include <net/nfc/nci.h>

/* NCI device flags */
enum nci_flag {};

/* NCI device states */
enum nci_state {};

/* NCI timeouts */
#define NCI_RESET_TIMEOUT
#define NCI_INIT_TIMEOUT
#define NCI_SET_CONFIG_TIMEOUT
#define NCI_RF_DISC_TIMEOUT
#define NCI_RF_DISC_SELECT_TIMEOUT
#define NCI_RF_DEACTIVATE_TIMEOUT
#define NCI_CMD_TIMEOUT
#define NCI_DATA_TIMEOUT

struct nci_dev;

struct nci_driver_ops {};

struct nci_ops {};

#define NCI_MAX_SUPPORTED_RF_INTERFACES
#define NCI_MAX_DISCOVERED_TARGETS
#define NCI_MAX_NUM_NFCEE
#define NCI_MAX_CONN_ID
#define NCI_MAX_PROPRIETARY_CMD

struct nci_conn_info {};

#define NCI_INVALID_CONN_ID

#define NCI_HCI_ANY_OPEN_PIPE

/* Gates */
#define NCI_HCI_ADMIN_GATE
#define NCI_HCI_LOOPBACK_GATE
#define NCI_HCI_IDENTITY_MGMT_GATE
#define NCI_HCI_LINK_MGMT_GATE

/* Pipes */
#define NCI_HCI_LINK_MGMT_PIPE
#define NCI_HCI_ADMIN_PIPE

/* Generic responses */
#define NCI_HCI_ANY_OK
#define NCI_HCI_ANY_E_NOT_CONNECTED
#define NCI_HCI_ANY_E_CMD_PAR_UNKNOWN
#define NCI_HCI_ANY_E_NOK
#define NCI_HCI_ANY_E_PIPES_FULL
#define NCI_HCI_ANY_E_REG_PAR_UNKNOWN
#define NCI_HCI_ANY_E_PIPE_NOT_OPENED
#define NCI_HCI_ANY_E_CMD_NOT_SUPPORTED
#define NCI_HCI_ANY_E_INHIBITED
#define NCI_HCI_ANY_E_TIMEOUT
#define NCI_HCI_ANY_E_REG_ACCESS_DENIED
#define NCI_HCI_ANY_E_PIPE_ACCESS_DENIED

#define NCI_HCI_DO_NOT_OPEN_PIPE
#define NCI_HCI_INVALID_PIPE
#define NCI_HCI_INVALID_GATE
#define NCI_HCI_INVALID_HOST

#define NCI_HCI_MAX_CUSTOM_GATES
/*
 * According to specification 102 622 chapter 4.4 Pipes,
 * the pipe identifier is 7 bits long.
 */
#define NCI_HCI_MAX_PIPES

struct nci_hci_gate {} __packed;

struct nci_hci_pipe {} __packed;

struct nci_hci_init_data {};

#define NCI_HCI_MAX_GATES

struct nci_hci_dev {};

/* NCI Core structures */
struct nci_dev {};

/* ----- NCI Devices ----- */
struct nci_dev *nci_allocate_device(const struct nci_ops *ops,
				    __u32 supported_protocols,
				    int tx_headroom,
				    int tx_tailroom);
void nci_free_device(struct nci_dev *ndev);
int nci_register_device(struct nci_dev *ndev);
void nci_unregister_device(struct nci_dev *ndev);
int nci_request(struct nci_dev *ndev,
		void (*req)(struct nci_dev *ndev,
			    const void *opt),
		const void *opt, __u32 timeout);
int nci_prop_cmd(struct nci_dev *ndev, __u8 oid, size_t len,
		 const __u8 *payload);
int nci_core_cmd(struct nci_dev *ndev, __u16 opcode, size_t len,
		 const __u8 *payload);
int nci_core_reset(struct nci_dev *ndev);
int nci_core_init(struct nci_dev *ndev);

int nci_recv_frame(struct nci_dev *ndev, struct sk_buff *skb);
int nci_send_frame(struct nci_dev *ndev, struct sk_buff *skb);
int nci_set_config(struct nci_dev *ndev, __u8 id, size_t len, const __u8 *val);

int nci_nfcee_discover(struct nci_dev *ndev, u8 action);
int nci_nfcee_mode_set(struct nci_dev *ndev, u8 nfcee_id, u8 nfcee_mode);
int nci_core_conn_create(struct nci_dev *ndev, u8 destination_type,
			 u8 number_destination_params,
			 size_t params_len,
			 const struct core_conn_create_dest_spec_params *params);
int nci_core_conn_close(struct nci_dev *ndev, u8 conn_id);
int nci_nfcc_loopback(struct nci_dev *ndev, const void *data, size_t data_len,
		      struct sk_buff **resp);

struct nci_hci_dev *nci_hci_allocate(struct nci_dev *ndev);
void nci_hci_deallocate(struct nci_dev *ndev);
int nci_hci_send_event(struct nci_dev *ndev, u8 gate, u8 event,
		       const u8 *param, size_t param_len);
int nci_hci_send_cmd(struct nci_dev *ndev, u8 gate,
		     u8 cmd, const u8 *param, size_t param_len,
		     struct sk_buff **skb);
int nci_hci_open_pipe(struct nci_dev *ndev, u8 pipe);
int nci_hci_connect_gate(struct nci_dev *ndev, u8 dest_host,
			 u8 dest_gate, u8 pipe);
int nci_hci_set_param(struct nci_dev *ndev, u8 gate, u8 idx,
		      const u8 *param, size_t param_len);
int nci_hci_get_param(struct nci_dev *ndev, u8 gate, u8 idx,
		      struct sk_buff **skb);
int nci_hci_clear_all_pipes(struct nci_dev *ndev);
int nci_hci_dev_session_init(struct nci_dev *ndev);

static inline struct sk_buff *nci_skb_alloc(struct nci_dev *ndev,
					    unsigned int len,
					    gfp_t how)
{}

static inline void nci_set_parent_dev(struct nci_dev *ndev, struct device *dev)
{}

static inline void nci_set_drvdata(struct nci_dev *ndev, void *data)
{}

static inline void *nci_get_drvdata(struct nci_dev *ndev)
{}

static inline int nci_set_vendor_cmds(struct nci_dev *ndev,
				      const struct nfc_vendor_cmd *cmds,
				      int n_cmds)
{}

void nci_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb);
void nci_ntf_packet(struct nci_dev *ndev, struct sk_buff *skb);
int nci_prop_rsp_packet(struct nci_dev *ndev, __u16 opcode,
			struct sk_buff *skb);
int nci_prop_ntf_packet(struct nci_dev *ndev, __u16 opcode,
			struct sk_buff *skb);
int nci_core_rsp_packet(struct nci_dev *ndev, __u16 opcode,
			struct sk_buff *skb);
int nci_core_ntf_packet(struct nci_dev *ndev, __u16 opcode,
			struct sk_buff *skb);
void nci_rx_data_packet(struct nci_dev *ndev, struct sk_buff *skb);
int nci_send_cmd(struct nci_dev *ndev, __u16 opcode, __u8 plen, const void *payload);
int nci_send_data(struct nci_dev *ndev, __u8 conn_id, struct sk_buff *skb);
int nci_conn_max_data_pkt_payload_size(struct nci_dev *ndev, __u8 conn_id);
void nci_data_exchange_complete(struct nci_dev *ndev, struct sk_buff *skb,
				__u8 conn_id, int err);
void nci_hci_data_received_cb(void *context, struct sk_buff *skb, int err);

void nci_clear_target_list(struct nci_dev *ndev);

/* ----- NCI requests ----- */
#define NCI_REQ_DONE
#define NCI_REQ_PEND
#define NCI_REQ_CANCELED

void nci_req_complete(struct nci_dev *ndev, int result);
struct nci_conn_info *nci_get_conn_info_by_conn_id(struct nci_dev *ndev,
						   int conn_id);
int nci_get_conn_info_by_dest_type_params(struct nci_dev *ndev, u8 dest_type,
					  const struct dest_spec_params *params);

/* ----- NCI status code ----- */
int nci_to_errno(__u8 code);

/* ----- NCI over SPI acknowledge modes ----- */
#define NCI_SPI_CRC_DISABLED
#define NCI_SPI_CRC_ENABLED

/* ----- NCI SPI structures ----- */
struct nci_spi {};

/* ----- NCI SPI ----- */
struct nci_spi *nci_spi_allocate_spi(struct spi_device *spi,
				     u8 acknowledge_mode, unsigned int delay,
				     struct nci_dev *ndev);
int nci_spi_send(struct nci_spi *nspi,
		 struct completion *write_handshake_completion,
		 struct sk_buff *skb);
struct sk_buff *nci_spi_read(struct nci_spi *nspi);

/* ----- NCI UART ---- */

/* Ioctl */
#define NCIUARTSETDRIVER

enum nci_uart_driver {};

struct nci_uart;

struct nci_uart_ops {};

struct nci_uart {};

int nci_uart_register(struct nci_uart *nu);
void nci_uart_unregister(struct nci_uart *nu);
void nci_uart_set_config(struct nci_uart *nu, int baudrate, int flow_ctrl);

#endif /* __NCI_CORE_H */