190e0b5f1STomas Winkler /* 290e0b5f1STomas Winkler * 390e0b5f1STomas Winkler * Intel Management Engine Interface (Intel MEI) Linux driver 490e0b5f1STomas Winkler * Copyright (c) 2003-2012, Intel Corporation. 590e0b5f1STomas Winkler * 690e0b5f1STomas Winkler * This program is free software; you can redistribute it and/or modify it 790e0b5f1STomas Winkler * under the terms and conditions of the GNU General Public License, 890e0b5f1STomas Winkler * version 2, as published by the Free Software Foundation. 990e0b5f1STomas Winkler * 1090e0b5f1STomas Winkler * This program is distributed in the hope it will be useful, but WITHOUT 1190e0b5f1STomas Winkler * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1290e0b5f1STomas Winkler * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 1390e0b5f1STomas Winkler * more details. 1490e0b5f1STomas Winkler * 1590e0b5f1STomas Winkler */ 1690e0b5f1STomas Winkler 1790e0b5f1STomas Winkler #ifndef _MEI_CLIENT_H_ 1890e0b5f1STomas Winkler #define _MEI_CLIENT_H_ 1990e0b5f1STomas Winkler 2090e0b5f1STomas Winkler #include <linux/types.h> 2190e0b5f1STomas Winkler #include <linux/watchdog.h> 2290e0b5f1STomas Winkler #include <linux/poll.h> 2390e0b5f1STomas Winkler #include <linux/mei.h> 2490e0b5f1STomas Winkler 2590e0b5f1STomas Winkler #include "mei_dev.h" 2690e0b5f1STomas Winkler 2790e0b5f1STomas Winkler int mei_me_cl_by_uuid(const struct mei_device *dev, const uuid_le *cuuid); 2890e0b5f1STomas Winkler int mei_me_cl_by_id(struct mei_device *dev, u8 client_id); 2990e0b5f1STomas Winkler 3090e0b5f1STomas Winkler /* 3190e0b5f1STomas Winkler * MEI IO Functions 3290e0b5f1STomas Winkler */ 3390e0b5f1STomas Winkler struct mei_cl_cb *mei_io_cb_init(struct mei_cl *cl, struct file *fp); 3490e0b5f1STomas Winkler void mei_io_cb_free(struct mei_cl_cb *priv_cb); 3590e0b5f1STomas Winkler int mei_io_cb_alloc_req_buf(struct mei_cl_cb *cb, size_t length); 3690e0b5f1STomas Winkler int mei_io_cb_alloc_resp_buf(struct mei_cl_cb *cb, size_t length); 3790e0b5f1STomas Winkler 3890e0b5f1STomas Winkler 3990e0b5f1STomas Winkler /** 4090e0b5f1STomas Winkler * mei_io_list_init - Sets up a queue list. 4190e0b5f1STomas Winkler * 4290e0b5f1STomas Winkler * @list: An instance cl callback structure 4390e0b5f1STomas Winkler */ 4490e0b5f1STomas Winkler static inline void mei_io_list_init(struct mei_cl_cb *list) 4590e0b5f1STomas Winkler { 4690e0b5f1STomas Winkler INIT_LIST_HEAD(&list->list); 4790e0b5f1STomas Winkler } 4890e0b5f1STomas Winkler void mei_io_list_flush(struct mei_cl_cb *list, struct mei_cl *cl); 4990e0b5f1STomas Winkler 5090e0b5f1STomas Winkler /* 5190e0b5f1STomas Winkler * MEI Host Client Functions 5290e0b5f1STomas Winkler */ 5390e0b5f1STomas Winkler 5490e0b5f1STomas Winkler struct mei_cl *mei_cl_allocate(struct mei_device *dev); 5590e0b5f1STomas Winkler void mei_cl_init(struct mei_cl *cl, struct mei_device *dev); 5690e0b5f1STomas Winkler 5790e0b5f1STomas Winkler 58781d0d89STomas Winkler int mei_cl_link(struct mei_cl *cl, int id); 5990e0b5f1STomas Winkler int mei_cl_unlink(struct mei_cl *cl); 6090e0b5f1STomas Winkler 6190e0b5f1STomas Winkler int mei_cl_flush_queues(struct mei_cl *cl); 6290e0b5f1STomas Winkler struct mei_cl_cb *mei_cl_find_read_cb(struct mei_cl *cl); 6390e0b5f1STomas Winkler 6490e0b5f1STomas Winkler /** 6590e0b5f1STomas Winkler * mei_cl_cmp_id - tells if file private data have same id 6690e0b5f1STomas Winkler * 6790e0b5f1STomas Winkler * @fe1: private data of 1. file object 6890e0b5f1STomas Winkler * @fe2: private data of 2. file object 6990e0b5f1STomas Winkler * 7090e0b5f1STomas Winkler * returns true - if ids are the same and not NULL 7190e0b5f1STomas Winkler */ 7290e0b5f1STomas Winkler static inline bool mei_cl_cmp_id(const struct mei_cl *cl1, 7390e0b5f1STomas Winkler const struct mei_cl *cl2) 7490e0b5f1STomas Winkler { 7590e0b5f1STomas Winkler return cl1 && cl2 && 7690e0b5f1STomas Winkler (cl1->host_client_id == cl2->host_client_id) && 7790e0b5f1STomas Winkler (cl1->me_client_id == cl2->me_client_id); 7890e0b5f1STomas Winkler } 7990e0b5f1STomas Winkler 8090e0b5f1STomas Winkler 8190e0b5f1STomas Winkler int mei_cl_flow_ctrl_creds(struct mei_cl *cl); 8290e0b5f1STomas Winkler 8390e0b5f1STomas Winkler int mei_cl_flow_ctrl_reduce(struct mei_cl *cl); 8490e0b5f1STomas Winkler /* 8590e0b5f1STomas Winkler * MEI input output function prototype 8690e0b5f1STomas Winkler */ 8790e0b5f1STomas Winkler bool mei_cl_is_other_connecting(struct mei_cl *cl); 8890e0b5f1STomas Winkler int mei_cl_disconnect(struct mei_cl *cl); 8990e0b5f1STomas Winkler int mei_cl_connect(struct mei_cl *cl, struct file *file); 90fcb136e1STomas Winkler int mei_cl_read_start(struct mei_cl *cl, size_t length); 914234a6deSTomas Winkler int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb, bool blocking); 9221767546STomas Winkler int mei_cl_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb, 9321767546STomas Winkler s32 *slots, struct mei_cl_cb *cmpl_list); 9421767546STomas Winkler 95db086fa9STomas Winkler void mei_cl_complete(struct mei_cl *cl, struct mei_cl_cb *cb); 9690e0b5f1STomas Winkler 9790e0b5f1STomas Winkler void mei_host_client_init(struct work_struct *work); 9890e0b5f1STomas Winkler 9990e0b5f1STomas Winkler 1004234a6deSTomas Winkler 101074b4c01STomas Winkler void mei_cl_all_disconnect(struct mei_device *dev); 1025290801cSTomas Winkler void mei_cl_all_wakeup(struct mei_device *dev); 103074b4c01STomas Winkler void mei_cl_all_write_clear(struct mei_device *dev); 104074b4c01STomas Winkler 10590e0b5f1STomas Winkler #endif /* _MEI_CLIENT_H_ */ 106