0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef __LOCAL_NFC_H
0011 #define __LOCAL_NFC_H
0012
0013 #include <net/nfc/nfc.h>
0014 #include <net/sock.h>
0015
0016 #define NFC_TARGET_MODE_IDLE 0
0017 #define NFC_TARGET_MODE_SLEEP 1
0018
0019 struct nfc_protocol {
0020 int id;
0021 struct proto *proto;
0022 struct module *owner;
0023 int (*create)(struct net *net, struct socket *sock,
0024 const struct nfc_protocol *nfc_proto, int kern);
0025 };
0026
0027 struct nfc_rawsock {
0028 struct sock sk;
0029 struct nfc_dev *dev;
0030 u32 target_idx;
0031 struct work_struct tx_work;
0032 bool tx_work_scheduled;
0033 };
0034
0035 struct nfc_sock_list {
0036 struct hlist_head head;
0037 rwlock_t lock;
0038 };
0039
0040 #define nfc_rawsock(sk) ((struct nfc_rawsock *) sk)
0041 #define to_rawsock_sk(_tx_work) \
0042 ((struct sock *) container_of(_tx_work, struct nfc_rawsock, tx_work))
0043
0044 struct nfc_llcp_sdp_tlv;
0045
0046 void nfc_llcp_mac_is_down(struct nfc_dev *dev);
0047 void nfc_llcp_mac_is_up(struct nfc_dev *dev, u32 target_idx,
0048 u8 comm_mode, u8 rf_mode);
0049 int nfc_llcp_register_device(struct nfc_dev *dev);
0050 void nfc_llcp_unregister_device(struct nfc_dev *dev);
0051 int nfc_llcp_set_remote_gb(struct nfc_dev *dev, const u8 *gb, u8 gb_len);
0052 u8 *nfc_llcp_general_bytes(struct nfc_dev *dev, size_t *general_bytes_len);
0053 int nfc_llcp_data_received(struct nfc_dev *dev, struct sk_buff *skb);
0054 struct nfc_llcp_local *nfc_llcp_find_local(struct nfc_dev *dev);
0055 int __init nfc_llcp_init(void);
0056 void nfc_llcp_exit(void);
0057 void nfc_llcp_free_sdp_tlv(struct nfc_llcp_sdp_tlv *sdp);
0058 void nfc_llcp_free_sdp_tlv_list(struct hlist_head *head);
0059
0060 int __init rawsock_init(void);
0061 void rawsock_exit(void);
0062
0063 int __init af_nfc_init(void);
0064 void af_nfc_exit(void);
0065 int nfc_proto_register(const struct nfc_protocol *nfc_proto);
0066 void nfc_proto_unregister(const struct nfc_protocol *nfc_proto);
0067
0068 extern int nfc_devlist_generation;
0069 extern struct mutex nfc_devlist_mutex;
0070
0071 int __init nfc_genl_init(void);
0072 void nfc_genl_exit(void);
0073
0074 void nfc_genl_data_init(struct nfc_genl_data *genl_data);
0075 void nfc_genl_data_exit(struct nfc_genl_data *genl_data);
0076
0077 int nfc_genl_targets_found(struct nfc_dev *dev);
0078 int nfc_genl_target_lost(struct nfc_dev *dev, u32 target_idx);
0079
0080 int nfc_genl_device_added(struct nfc_dev *dev);
0081 int nfc_genl_device_removed(struct nfc_dev *dev);
0082
0083 int nfc_genl_dep_link_up_event(struct nfc_dev *dev, u32 target_idx,
0084 u8 comm_mode, u8 rf_mode);
0085 int nfc_genl_dep_link_down_event(struct nfc_dev *dev);
0086
0087 int nfc_genl_tm_activated(struct nfc_dev *dev, u32 protocol);
0088 int nfc_genl_tm_deactivated(struct nfc_dev *dev);
0089
0090 int nfc_genl_llc_send_sdres(struct nfc_dev *dev, struct hlist_head *sdres_list);
0091
0092 int nfc_genl_se_added(struct nfc_dev *dev, u32 se_idx, u16 type);
0093 int nfc_genl_se_removed(struct nfc_dev *dev, u32 se_idx);
0094 int nfc_genl_se_transaction(struct nfc_dev *dev, u8 se_idx,
0095 struct nfc_evt_transaction *evt_transaction);
0096 int nfc_genl_se_connectivity(struct nfc_dev *dev, u8 se_idx);
0097
0098 struct nfc_dev *nfc_get_device(unsigned int idx);
0099
0100 static inline void nfc_put_device(struct nfc_dev *dev)
0101 {
0102 put_device(&dev->dev);
0103 }
0104
0105 static inline void nfc_device_iter_init(struct class_dev_iter *iter)
0106 {
0107 class_dev_iter_init(iter, &nfc_class, NULL, NULL);
0108 }
0109
0110 static inline struct nfc_dev *nfc_device_iter_next(struct class_dev_iter *iter)
0111 {
0112 struct device *d = class_dev_iter_next(iter);
0113 if (!d)
0114 return NULL;
0115
0116 return to_nfc_dev(d);
0117 }
0118
0119 static inline void nfc_device_iter_exit(struct class_dev_iter *iter)
0120 {
0121 class_dev_iter_exit(iter);
0122 }
0123
0124 int nfc_fw_download(struct nfc_dev *dev, const char *firmware_name);
0125 int nfc_genl_fw_download_done(struct nfc_dev *dev, const char *firmware_name,
0126 u32 result);
0127
0128 int nfc_dev_up(struct nfc_dev *dev);
0129
0130 int nfc_dev_down(struct nfc_dev *dev);
0131
0132 int nfc_start_poll(struct nfc_dev *dev, u32 im_protocols, u32 tm_protocols);
0133
0134 int nfc_stop_poll(struct nfc_dev *dev);
0135
0136 int nfc_dep_link_up(struct nfc_dev *dev, int target_idx, u8 comm_mode);
0137
0138 int nfc_dep_link_down(struct nfc_dev *dev);
0139
0140 int nfc_activate_target(struct nfc_dev *dev, u32 target_idx, u32 protocol);
0141
0142 int nfc_deactivate_target(struct nfc_dev *dev, u32 target_idx, u8 mode);
0143
0144 int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx, struct sk_buff *skb,
0145 data_exchange_cb_t cb, void *cb_context);
0146
0147 int nfc_enable_se(struct nfc_dev *dev, u32 se_idx);
0148 int nfc_disable_se(struct nfc_dev *dev, u32 se_idx);
0149
0150 #endif