0001
0002
0003
0004
0005
0006
0007 #ifndef _MEI_CLIENT_H_
0008 #define _MEI_CLIENT_H_
0009
0010 #include <linux/types.h>
0011 #include <linux/poll.h>
0012 #include <linux/mei.h>
0013
0014 #include "mei_dev.h"
0015
0016
0017
0018
0019 void mei_me_cl_init(struct mei_me_client *me_cl);
0020 void mei_me_cl_put(struct mei_me_client *me_cl);
0021 struct mei_me_client *mei_me_cl_get(struct mei_me_client *me_cl);
0022
0023 void mei_me_cl_add(struct mei_device *dev, struct mei_me_client *me_cl);
0024 void mei_me_cl_del(struct mei_device *dev, struct mei_me_client *me_cl);
0025
0026 struct mei_me_client *mei_me_cl_by_uuid(struct mei_device *dev,
0027 const uuid_le *uuid);
0028 struct mei_me_client *mei_me_cl_by_id(struct mei_device *dev, u8 client_id);
0029 struct mei_me_client *mei_me_cl_by_uuid_id(struct mei_device *dev,
0030 const uuid_le *uuid, u8 client_id);
0031 void mei_me_cl_rm_by_uuid(struct mei_device *dev, const uuid_le *uuid);
0032 void mei_me_cl_rm_by_uuid_id(struct mei_device *dev,
0033 const uuid_le *uuid, u8 id);
0034 void mei_me_cl_rm_all(struct mei_device *dev);
0035
0036
0037
0038
0039
0040
0041
0042
0043 static inline bool mei_me_cl_is_active(const struct mei_me_client *me_cl)
0044 {
0045 return !list_empty_careful(&me_cl->list);
0046 }
0047
0048
0049
0050
0051
0052
0053
0054
0055 static inline const uuid_le *mei_me_cl_uuid(const struct mei_me_client *me_cl)
0056 {
0057 return &me_cl->props.protocol_name;
0058 }
0059
0060
0061
0062
0063
0064
0065
0066
0067 static inline u8 mei_me_cl_ver(const struct mei_me_client *me_cl)
0068 {
0069 return me_cl->props.protocol_version;
0070 }
0071
0072
0073
0074
0075
0076
0077
0078
0079 static inline u8 mei_me_cl_max_conn(const struct mei_me_client *me_cl)
0080 {
0081 return me_cl->props.max_number_of_connections;
0082 }
0083
0084
0085
0086
0087
0088
0089
0090
0091 static inline u8 mei_me_cl_fixed(const struct mei_me_client *me_cl)
0092 {
0093 return me_cl->props.fixed_address;
0094 }
0095
0096
0097
0098
0099
0100
0101
0102
0103 static inline bool mei_me_cl_vt(const struct mei_me_client *me_cl)
0104 {
0105 return me_cl->props.vt_supported == 1;
0106 }
0107
0108
0109
0110
0111
0112
0113
0114
0115 static inline u32 mei_me_cl_max_len(const struct mei_me_client *me_cl)
0116 {
0117 return me_cl->props.max_msg_length;
0118 }
0119
0120
0121
0122
0123 void mei_io_cb_free(struct mei_cl_cb *priv_cb);
0124
0125
0126
0127
0128
0129 struct mei_cl *mei_cl_allocate(struct mei_device *dev);
0130
0131 int mei_cl_link(struct mei_cl *cl);
0132 int mei_cl_unlink(struct mei_cl *cl);
0133
0134 struct mei_cl *mei_cl_alloc_linked(struct mei_device *dev);
0135
0136 struct mei_cl_cb *mei_cl_read_cb(struct mei_cl *cl, const struct file *fp);
0137
0138 void mei_cl_add_rd_completed(struct mei_cl *cl, struct mei_cl_cb *cb);
0139 void mei_cl_del_rd_completed(struct mei_cl *cl, struct mei_cl_cb *cb);
0140
0141 struct mei_cl_cb *mei_cl_alloc_cb(struct mei_cl *cl, size_t length,
0142 enum mei_cb_file_ops type,
0143 const struct file *fp);
0144 struct mei_cl_cb *mei_cl_enqueue_ctrl_wr_cb(struct mei_cl *cl, size_t length,
0145 enum mei_cb_file_ops type,
0146 const struct file *fp);
0147 int mei_cl_flush_queues(struct mei_cl *cl, const struct file *fp);
0148
0149 struct mei_cl_vtag *mei_cl_vtag_alloc(struct file *fp, u8 vtag);
0150 const struct file *mei_cl_fp_by_vtag(const struct mei_cl *cl, u8 vtag);
0151 int mei_cl_vt_support_check(const struct mei_cl *cl);
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163 static inline bool mei_cl_is_connected(const struct mei_cl *cl)
0164 {
0165 return cl->state == MEI_FILE_CONNECTED;
0166 }
0167
0168
0169
0170
0171
0172
0173
0174
0175 static inline u8 mei_cl_me_id(const struct mei_cl *cl)
0176 {
0177 return cl->me_cl ? cl->me_cl->client_id : 0;
0178 }
0179
0180
0181
0182
0183
0184
0185
0186
0187 static inline size_t mei_cl_mtu(const struct mei_cl *cl)
0188 {
0189 return cl->me_cl ? cl->me_cl->props.max_msg_length : 0;
0190 }
0191
0192
0193
0194
0195
0196
0197
0198
0199 static inline bool mei_cl_is_fixed_address(const struct mei_cl *cl)
0200 {
0201 return cl->me_cl && cl->me_cl->props.fixed_address;
0202 }
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212 static inline bool mei_cl_is_single_recv_buf(const struct mei_cl *cl)
0213 {
0214 return cl->me_cl->props.single_recv_buf;
0215 }
0216
0217
0218
0219
0220
0221
0222
0223
0224 static inline const uuid_le *mei_cl_uuid(const struct mei_cl *cl)
0225 {
0226 return mei_me_cl_uuid(cl->me_cl);
0227 }
0228
0229
0230
0231
0232
0233
0234
0235
0236 static inline u8 mei_cl_host_addr(const struct mei_cl *cl)
0237 {
0238 return mei_cl_is_fixed_address(cl) ? 0 : cl->host_client_id;
0239 }
0240
0241 int mei_cl_disconnect(struct mei_cl *cl);
0242 int mei_cl_irq_disconnect(struct mei_cl *cl, struct mei_cl_cb *cb,
0243 struct list_head *cmpl_list);
0244 int mei_cl_connect(struct mei_cl *cl, struct mei_me_client *me_cl,
0245 const struct file *file);
0246 int mei_cl_irq_connect(struct mei_cl *cl, struct mei_cl_cb *cb,
0247 struct list_head *cmpl_list);
0248 int mei_cl_read_start(struct mei_cl *cl, size_t length, const struct file *fp);
0249 ssize_t mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb);
0250 int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,
0251 struct list_head *cmpl_list);
0252
0253 void mei_cl_complete(struct mei_cl *cl, struct mei_cl_cb *cb);
0254
0255 void mei_host_client_init(struct mei_device *dev);
0256
0257 u8 mei_cl_notify_fop2req(enum mei_cb_file_ops fop);
0258 enum mei_cb_file_ops mei_cl_notify_req2fop(u8 request);
0259 int mei_cl_notify_request(struct mei_cl *cl,
0260 const struct file *file, u8 request);
0261 int mei_cl_irq_notify(struct mei_cl *cl, struct mei_cl_cb *cb,
0262 struct list_head *cmpl_list);
0263 int mei_cl_notify_get(struct mei_cl *cl, bool block, bool *notify_ev);
0264 void mei_cl_notify(struct mei_cl *cl);
0265
0266 void mei_cl_all_disconnect(struct mei_device *dev);
0267
0268 int mei_cl_irq_dma_map(struct mei_cl *cl, struct mei_cl_cb *cb,
0269 struct list_head *cmpl_list);
0270 int mei_cl_irq_dma_unmap(struct mei_cl *cl, struct mei_cl_cb *cb,
0271 struct list_head *cmpl_list);
0272 int mei_cl_dma_alloc_and_map(struct mei_cl *cl, const struct file *fp,
0273 u8 buffer_id, size_t size);
0274 int mei_cl_dma_unmap(struct mei_cl *cl, const struct file *fp);
0275
0276 #define MEI_CL_FMT "cl:host=%02d me=%02d "
0277 #define MEI_CL_PRM(cl) (cl)->host_client_id, mei_cl_me_id(cl)
0278
0279 #define cl_dbg(dev, cl, format, arg...) \
0280 dev_dbg((dev)->dev, MEI_CL_FMT format, MEI_CL_PRM(cl), ##arg)
0281
0282 #define cl_warn(dev, cl, format, arg...) \
0283 dev_warn((dev)->dev, MEI_CL_FMT format, MEI_CL_PRM(cl), ##arg)
0284
0285 #define cl_err(dev, cl, format, arg...) \
0286 dev_err((dev)->dev, MEI_CL_FMT format, MEI_CL_PRM(cl), ##arg)
0287
0288 #endif