提交 965ae37a 编写于 作者: T Tomas Winkler 提交者: Greg Kroah-Hartman

mei: implement async notification hbm messages

Implement sending and reception handlers for the
async event notification hbm commands.
Add client notification book keeping data required for the messages
    notify_en to indicate whether notification is enabled
    notify_ev to indicate whether an event is pending
Signed-off-by: NTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: NAlexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 d3c1c809
......@@ -402,6 +402,125 @@ static int mei_hbm_fw_add_cl_req(struct mei_device *dev,
return mei_hbm_add_cl_resp(dev, req->me_addr, status);
}
/**
* mei_hbm_cl_notify_req - send notification request
*
* @dev: the device structure
* @cl: a client to disconnect from
* @start: true for start false for stop
*
* Return: 0 on success and -EIO on write failure
*/
int mei_hbm_cl_notify_req(struct mei_device *dev,
struct mei_cl *cl, u8 start)
{
struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
struct hbm_notification_request *req;
const size_t len = sizeof(struct hbm_notification_request);
int ret;
mei_hbm_hdr(mei_hdr, len);
mei_hbm_cl_hdr(cl, MEI_HBM_NOTIFY_REQ_CMD, dev->wr_msg.data, len);
req = (struct hbm_notification_request *)dev->wr_msg.data;
req->start = start;
ret = mei_write_message(dev, mei_hdr, dev->wr_msg.data);
if (ret)
dev_err(dev->dev, "notify request failed: ret = %d\n", ret);
return ret;
}
/**
* notify_res_to_fop - convert notification response to the proper
* notification FOP
*
* @cmd: client notification start response command
*
* Return: MEI_FOP_NOTIFY_START or MEI_FOP_NOTIFY_STOP;
*/
static inline enum mei_cb_file_ops notify_res_to_fop(struct mei_hbm_cl_cmd *cmd)
{
struct hbm_notification_response *rs =
(struct hbm_notification_response *)cmd;
if (rs->start == MEI_HBM_NOTIFICATION_START)
return MEI_FOP_NOTIFY_START;
else
return MEI_FOP_NOTIFY_STOP;
}
/**
* mei_hbm_cl_notify_start_res - update the client state according
* notify start response
*
* @dev: the device structure
* @cl: mei host client
* @cmd: client notification start response command
*/
static void mei_hbm_cl_notify_start_res(struct mei_device *dev,
struct mei_cl *cl,
struct mei_hbm_cl_cmd *cmd)
{
struct hbm_notification_response *rs =
(struct hbm_notification_response *)cmd;
cl_dbg(dev, cl, "hbm: notify start response status=%d\n", rs->status);
if (rs->status == MEI_HBMS_SUCCESS ||
rs->status == MEI_HBMS_ALREADY_STARTED) {
cl->notify_en = true;
cl->status = 0;
} else {
cl->status = -EINVAL;
}
}
/**
* mei_hbm_cl_notify_stop_res - update the client state according
* notify stop response
*
* @dev: the device structure
* @cl: mei host client
* @cmd: client notification stop response command
*/
static void mei_hbm_cl_notify_stop_res(struct mei_device *dev,
struct mei_cl *cl,
struct mei_hbm_cl_cmd *cmd)
{
struct hbm_notification_response *rs =
(struct hbm_notification_response *)cmd;
cl_dbg(dev, cl, "hbm: notify stop response status=%d\n", rs->status);
if (rs->status == MEI_HBMS_SUCCESS ||
rs->status == MEI_HBMS_NOT_STARTED) {
cl->notify_en = false;
cl->status = 0;
} else {
/* TODO: spec is not clear yet about other possible issues */
cl->status = -EINVAL;
}
}
/**
* mei_hbm_cl_notify - signal notification event
*
* @dev: the device structure
* @cmd: notification client message
*/
static void mei_hbm_cl_notify(struct mei_device *dev,
struct mei_hbm_cl_cmd *cmd)
{
struct mei_cl *cl;
cl = mei_hbm_cl_find_by_cmd(dev, cmd);
if (cl && cl->notify_en)
cl->notify_ev = true;
}
/**
* mei_hbm_prop_req - request property for a single client
*
......@@ -716,6 +835,12 @@ static void mei_hbm_cl_res(struct mei_device *dev,
case MEI_FOP_DISCONNECT:
mei_hbm_cl_disconnect_res(dev, cl, rs);
break;
case MEI_FOP_NOTIFY_START:
mei_hbm_cl_notify_start_res(dev, cl, rs);
break;
case MEI_FOP_NOTIFY_STOP:
mei_hbm_cl_notify_stop_res(dev, cl, rs);
break;
default:
return;
}
......@@ -1031,6 +1156,16 @@ int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
dev_dbg(dev->dev, "hbm: add client request processed\n");
break;
case MEI_HBM_NOTIFY_RES_CMD:
dev_dbg(dev->dev, "hbm: notify response received\n");
mei_hbm_cl_res(dev, cl_cmd, notify_res_to_fop(cl_cmd));
break;
case MEI_HBM_NOTIFICATION_CMD:
dev_dbg(dev->dev, "hbm: notification\n");
mei_hbm_cl_notify(dev, cl_cmd);
break;
default:
BUG();
break;
......
......@@ -54,6 +54,8 @@ int mei_hbm_cl_disconnect_rsp(struct mei_device *dev, struct mei_cl *cl);
int mei_hbm_cl_connect_req(struct mei_device *dev, struct mei_cl *cl);
bool mei_hbm_version_is_supported(struct mei_device *dev);
int mei_hbm_pg(struct mei_device *dev, u8 pg_cmd);
int mei_hbm_cl_notify_req(struct mei_device *dev,
struct mei_cl *cl, u8 request);
#endif /* _MEI_HBM_H_ */
......@@ -136,6 +136,8 @@ enum mei_wd_states {
* @MEI_FOP_CONNECT: connect
* @MEI_FOP_DISCONNECT: disconnect
* @MEI_FOP_DISCONNECT_RSP: disconnect response
* @MEI_FOP_NOTIFY_START: start notification
* @MEI_FOP_NOTIFY_STOP: stop notification
*/
enum mei_cb_file_ops {
MEI_FOP_READ = 0,
......@@ -143,6 +145,8 @@ enum mei_cb_file_ops {
MEI_FOP_CONNECT,
MEI_FOP_DISCONNECT,
MEI_FOP_DISCONNECT_RSP,
MEI_FOP_NOTIFY_START,
MEI_FOP_NOTIFY_STOP,
};
/*
......@@ -237,6 +241,8 @@ struct mei_cl_cb {
* @mei_flow_ctrl_creds: transmit flow credentials
* @timer_count: watchdog timer for operation completion
* @reserved: reserved for alignment
* @notify_en: notification - enabled/disabled
* @notify_ev: pending notification event
* @writing_state: state of the tx
* @rd_pending: pending read credits
* @rd_completed: completed read
......@@ -256,6 +262,8 @@ struct mei_cl {
u8 mei_flow_ctrl_creds;
u8 timer_count;
u8 reserved;
u8 notify_en;
u8 notify_ev;
enum mei_file_transaction_states writing_state;
struct list_head rd_pending;
struct list_head rd_completed;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册