aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/mei
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2012-12-25 12:06:12 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-01-07 13:31:30 -0500
commit6bbda15f279ec99c4ac0d56c4ad680299d0b768b (patch)
treeed4e6f50fec81c93cd90a629ccb5a0c9f1db701f /drivers/misc/mei
parent8120e7201cf9795bc98ffb2e3064b657c0f34c05 (diff)
mei: move hbm responses from interrupt.c to hbm.c
1. Add common prefix mei_hbm_ to all handlers and made them static 2. Drop now useless function same_flow_addr Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/mei')
-rw-r--r--drivers/misc/mei/hbm.c189
-rw-r--r--drivers/misc/mei/interrupt.c208
-rw-r--r--drivers/misc/mei/mei_dev.h9
3 files changed, 186 insertions, 220 deletions
diff --git a/drivers/misc/mei/hbm.c b/drivers/misc/mei/hbm.c
index 3c9914038490..6b58b0a10378 100644
--- a/drivers/misc/mei/hbm.c
+++ b/drivers/misc/mei/hbm.c
@@ -59,6 +59,33 @@ bool mei_hbm_cl_addr_equal(struct mei_cl *cl, void *buf)
59 59
60 60
61/** 61/**
62 * is_treat_specially_client - checks if the message belongs
63 * to the file private data.
64 *
65 * @cl: private data of the file object
66 * @rs: connect response bus message
67 *
68 */
69static bool is_treat_specially_client(struct mei_cl *cl,
70 struct hbm_client_connect_response *rs)
71{
72 if (mei_hbm_cl_addr_equal(cl, rs)) {
73 if (!rs->status) {
74 cl->state = MEI_FILE_CONNECTED;
75 cl->status = 0;
76
77 } else {
78 cl->state = MEI_FILE_DISCONNECTED;
79 cl->status = -ENODEV;
80 }
81 cl->timer_count = 0;
82
83 return true;
84 }
85 return false;
86}
87
88/**
62 * mei_hbm_start_req - sends start request message. 89 * mei_hbm_start_req - sends start request message.
63 * 90 *
64 * @dev: the device structure 91 * @dev: the device structure
@@ -218,6 +245,66 @@ int mei_hbm_cl_flow_control_req(struct mei_device *dev, struct mei_cl *cl)
218} 245}
219 246
220/** 247/**
248 * add_single_flow_creds - adds single buffer credentials.
249 *
250 * @file: private data ot the file object.
251 * @flow: flow control.
252 */
253static void mei_hbm_add_single_flow_creds(struct mei_device *dev,
254 struct hbm_flow_control *flow)
255{
256 struct mei_me_client *client;
257 int i;
258
259 for (i = 0; i < dev->me_clients_num; i++) {
260 client = &dev->me_clients[i];
261 if (client && flow->me_addr == client->client_id) {
262 if (client->props.single_recv_buf) {
263 client->mei_flow_ctrl_creds++;
264 dev_dbg(&dev->pdev->dev, "recv flow ctrl msg ME %d (single).\n",
265 flow->me_addr);
266 dev_dbg(&dev->pdev->dev, "flow control credentials =%d.\n",
267 client->mei_flow_ctrl_creds);
268 } else {
269 BUG(); /* error in flow control */
270 }
271 }
272 }
273}
274
275/**
276 * mei_hbm_cl_flow_control_res - flow control response from me
277 *
278 * @dev: the device structure
279 * @flow_control: flow control response bus message
280 */
281static void mei_hbm_cl_flow_control_res(struct mei_device *dev,
282 struct hbm_flow_control *flow_control)
283{
284 struct mei_cl *cl = NULL;
285 struct mei_cl *next = NULL;
286
287 if (!flow_control->host_addr) {
288 /* single receive buffer */
289 mei_hbm_add_single_flow_creds(dev, flow_control);
290 return;
291 }
292
293 /* normal connection */
294 list_for_each_entry_safe(cl, next, &dev->file_list, link) {
295 if (mei_hbm_cl_addr_equal(cl, flow_control)) {
296 cl->mei_flow_ctrl_creds++;
297 dev_dbg(&dev->pdev->dev, "flow ctrl msg for host %d ME %d.\n",
298 flow_control->host_addr, flow_control->me_addr);
299 dev_dbg(&dev->pdev->dev, "flow control credentials = %d.\n",
300 cl->mei_flow_ctrl_creds);
301 break;
302 }
303 }
304}
305
306
307/**
221 * mei_hbm_cl_disconnect_req - sends disconnect message to fw. 308 * mei_hbm_cl_disconnect_req - sends disconnect message to fw.
222 * 309 *
223 * @dev: the device structure 310 * @dev: the device structure
@@ -237,6 +324,48 @@ int mei_hbm_cl_disconnect_req(struct mei_device *dev, struct mei_cl *cl)
237} 324}
238 325
239/** 326/**
327 * mei_hbm_cl_disconnect_res - disconnect response from ME
328 *
329 * @dev: the device structure
330 * @rs: disconnect response bus message
331 */
332static void mei_hbm_cl_disconnect_res(struct mei_device *dev,
333 struct hbm_client_connect_response *rs)
334{
335 struct mei_cl *cl;
336 struct mei_cl_cb *pos = NULL, *next = NULL;
337
338 dev_dbg(&dev->pdev->dev,
339 "disconnect_response:\n"
340 "ME Client = %d\n"
341 "Host Client = %d\n"
342 "Status = %d\n",
343 rs->me_addr,
344 rs->host_addr,
345 rs->status);
346
347 list_for_each_entry_safe(pos, next, &dev->ctrl_rd_list.list, list) {
348 cl = pos->cl;
349
350 if (!cl) {
351 list_del(&pos->list);
352 return;
353 }
354
355 dev_dbg(&dev->pdev->dev, "list_for_each_entry_safe in ctrl_rd_list.\n");
356 if (mei_hbm_cl_addr_equal(cl, rs)) {
357 list_del(&pos->list);
358 if (!rs->status)
359 cl->state = MEI_FILE_DISCONNECTED;
360
361 cl->status = 0;
362 cl->timer_count = 0;
363 break;
364 }
365 }
366}
367
368/**
240 * mei_hbm_cl_connect_req - send connection request to specific me client 369 * mei_hbm_cl_connect_req - send connection request to specific me client
241 * 370 *
242 * @dev: the device structure 371 * @dev: the device structure
@@ -256,6 +385,60 @@ int mei_hbm_cl_connect_req(struct mei_device *dev, struct mei_cl *cl)
256} 385}
257 386
258/** 387/**
388 * mei_hbm_cl_connect_res - connect resposne from the ME
389 *
390 * @dev: the device structure
391 * @rs: connect response bus message
392 */
393static void mei_hbm_cl_connect_res(struct mei_device *dev,
394 struct hbm_client_connect_response *rs)
395{
396
397 struct mei_cl *cl;
398 struct mei_cl_cb *pos = NULL, *next = NULL;
399
400 dev_dbg(&dev->pdev->dev,
401 "connect_response:\n"
402 "ME Client = %d\n"
403 "Host Client = %d\n"
404 "Status = %d\n",
405 rs->me_addr,
406 rs->host_addr,
407 rs->status);
408
409 /* if WD or iamthif client treat specially */
410
411 if (is_treat_specially_client(&dev->wd_cl, rs)) {
412 dev_dbg(&dev->pdev->dev, "successfully connected to WD client.\n");
413 mei_watchdog_register(dev);
414
415 return;
416 }
417
418 if (is_treat_specially_client(&dev->iamthif_cl, rs)) {
419 dev->iamthif_state = MEI_IAMTHIF_IDLE;
420 return;
421 }
422 list_for_each_entry_safe(pos, next, &dev->ctrl_rd_list.list, list) {
423
424 cl = pos->cl;
425 if (!cl) {
426 list_del(&pos->list);
427 return;
428 }
429 if (pos->fop_type == MEI_FOP_IOCTL) {
430 if (is_treat_specially_client(cl, rs)) {
431 list_del(&pos->list);
432 cl->status = 0;
433 cl->timer_count = 0;
434 break;
435 }
436 }
437 }
438}
439
440
441/**
259 * mei_client_disconnect_request - disconnect request initiated by me 442 * mei_client_disconnect_request - disconnect request initiated by me
260 * host sends disoconnect response 443 * host sends disoconnect response
261 * 444 *
@@ -347,21 +530,21 @@ void mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
347 530
348 case CLIENT_CONNECT_RES_CMD: 531 case CLIENT_CONNECT_RES_CMD:
349 connect_res = (struct hbm_client_connect_response *) mei_msg; 532 connect_res = (struct hbm_client_connect_response *) mei_msg;
350 mei_client_connect_response(dev, connect_res); 533 mei_hbm_cl_connect_res(dev, connect_res);
351 dev_dbg(&dev->pdev->dev, "client connect response message received.\n"); 534 dev_dbg(&dev->pdev->dev, "client connect response message received.\n");
352 wake_up(&dev->wait_recvd_msg); 535 wake_up(&dev->wait_recvd_msg);
353 break; 536 break;
354 537
355 case CLIENT_DISCONNECT_RES_CMD: 538 case CLIENT_DISCONNECT_RES_CMD:
356 disconnect_res = (struct hbm_client_connect_response *) mei_msg; 539 disconnect_res = (struct hbm_client_connect_response *) mei_msg;
357 mei_client_disconnect_response(dev, disconnect_res); 540 mei_hbm_cl_disconnect_res(dev, disconnect_res);
358 dev_dbg(&dev->pdev->dev, "client disconnect response message received.\n"); 541 dev_dbg(&dev->pdev->dev, "client disconnect response message received.\n");
359 wake_up(&dev->wait_recvd_msg); 542 wake_up(&dev->wait_recvd_msg);
360 break; 543 break;
361 544
362 case MEI_FLOW_CONTROL_CMD: 545 case MEI_FLOW_CONTROL_CMD:
363 flow_control = (struct hbm_flow_control *) mei_msg; 546 flow_control = (struct hbm_flow_control *) mei_msg;
364 mei_client_flow_control_response(dev, flow_control); 547 mei_hbm_cl_flow_control_res(dev, flow_control);
365 dev_dbg(&dev->pdev->dev, "client flow control response message received.\n"); 548 dev_dbg(&dev->pdev->dev, "client flow control response message received.\n");
366 break; 549 break;
367 550
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
index eb744cc4f72a..a735c8b7ca82 100644
--- a/drivers/misc/mei/interrupt.c
+++ b/drivers/misc/mei/interrupt.c
@@ -173,214 +173,6 @@ static int _mei_irq_thread_close(struct mei_device *dev, s32 *slots,
173 return 0; 173 return 0;
174} 174}
175 175
176/**
177 * is_treat_specially_client - checks if the message belongs
178 * to the file private data.
179 *
180 * @cl: private data of the file object
181 * @rs: connect response bus message
182 *
183 */
184static bool is_treat_specially_client(struct mei_cl *cl,
185 struct hbm_client_connect_response *rs)
186{
187
188 if (cl->host_client_id == rs->host_addr &&
189 cl->me_client_id == rs->me_addr) {
190 if (!rs->status) {
191 cl->state = MEI_FILE_CONNECTED;
192 cl->status = 0;
193
194 } else {
195 cl->state = MEI_FILE_DISCONNECTED;
196 cl->status = -ENODEV;
197 }
198 cl->timer_count = 0;
199
200 return true;
201 }
202 return false;
203}
204
205/**
206 * mei_client_connect_response - connects to response irq routine
207 *
208 * @dev: the device structure
209 * @rs: connect response bus message
210 */
211void mei_client_connect_response(struct mei_device *dev,
212 struct hbm_client_connect_response *rs)
213{
214
215 struct mei_cl *cl;
216 struct mei_cl_cb *pos = NULL, *next = NULL;
217
218 dev_dbg(&dev->pdev->dev,
219 "connect_response:\n"
220 "ME Client = %d\n"
221 "Host Client = %d\n"
222 "Status = %d\n",
223 rs->me_addr,
224 rs->host_addr,
225 rs->status);
226
227 /* if WD or iamthif client treat specially */
228
229 if (is_treat_specially_client(&(dev->wd_cl), rs)) {
230 dev_dbg(&dev->pdev->dev, "successfully connected to WD client.\n");
231 mei_watchdog_register(dev);
232
233 return;
234 }
235
236 if (is_treat_specially_client(&(dev->iamthif_cl), rs)) {
237 dev->iamthif_state = MEI_IAMTHIF_IDLE;
238 return;
239 }
240 list_for_each_entry_safe(pos, next, &dev->ctrl_rd_list.list, list) {
241
242 cl = pos->cl;
243 if (!cl) {
244 list_del(&pos->list);
245 return;
246 }
247 if (pos->fop_type == MEI_FOP_IOCTL) {
248 if (is_treat_specially_client(cl, rs)) {
249 list_del(&pos->list);
250 cl->status = 0;
251 cl->timer_count = 0;
252 break;
253 }
254 }
255 }
256}
257
258/**
259 * mei_client_disconnect_response - disconnects from response irq routine
260 *
261 * @dev: the device structure
262 * @rs: disconnect response bus message
263 */
264void mei_client_disconnect_response(struct mei_device *dev,
265 struct hbm_client_connect_response *rs)
266{
267 struct mei_cl *cl;
268 struct mei_cl_cb *pos = NULL, *next = NULL;
269
270 dev_dbg(&dev->pdev->dev,
271 "disconnect_response:\n"
272 "ME Client = %d\n"
273 "Host Client = %d\n"
274 "Status = %d\n",
275 rs->me_addr,
276 rs->host_addr,
277 rs->status);
278
279 list_for_each_entry_safe(pos, next, &dev->ctrl_rd_list.list, list) {
280 cl = pos->cl;
281
282 if (!cl) {
283 list_del(&pos->list);
284 return;
285 }
286
287 dev_dbg(&dev->pdev->dev, "list_for_each_entry_safe in ctrl_rd_list.\n");
288 if (cl->host_client_id == rs->host_addr &&
289 cl->me_client_id == rs->me_addr) {
290
291 list_del(&pos->list);
292 if (!rs->status)
293 cl->state = MEI_FILE_DISCONNECTED;
294
295 cl->status = 0;
296 cl->timer_count = 0;
297 break;
298 }
299 }
300}
301
302/**
303 * same_flow_addr - tells if they have the same address.
304 *
305 * @file: private data of the file object.
306 * @flow: flow control.
307 *
308 * returns !=0, same; 0,not.
309 */
310static int same_flow_addr(struct mei_cl *cl, struct hbm_flow_control *flow)
311{
312 return (cl->host_client_id == flow->host_addr &&
313 cl->me_client_id == flow->me_addr);
314}
315
316/**
317 * add_single_flow_creds - adds single buffer credentials.
318 *
319 * @file: private data ot the file object.
320 * @flow: flow control.
321 */
322static void add_single_flow_creds(struct mei_device *dev,
323 struct hbm_flow_control *flow)
324{
325 struct mei_me_client *client;
326 int i;
327
328 for (i = 0; i < dev->me_clients_num; i++) {
329 client = &dev->me_clients[i];
330 if (client && flow->me_addr == client->client_id) {
331 if (client->props.single_recv_buf) {
332 client->mei_flow_ctrl_creds++;
333 dev_dbg(&dev->pdev->dev, "recv flow ctrl msg ME %d (single).\n",
334 flow->me_addr);
335 dev_dbg(&dev->pdev->dev, "flow control credentials =%d.\n",
336 client->mei_flow_ctrl_creds);
337 } else {
338 BUG(); /* error in flow control */
339 }
340 }
341 }
342}
343
344/**
345 * mei_client_flow_control_response - flow control response irq routine
346 *
347 * @dev: the device structure
348 * @flow_control: flow control response bus message
349 */
350void mei_client_flow_control_response(struct mei_device *dev,
351 struct hbm_flow_control *flow_control)
352{
353 struct mei_cl *cl_pos = NULL;
354 struct mei_cl *cl_next = NULL;
355
356 if (!flow_control->host_addr) {
357 /* single receive buffer */
358 add_single_flow_creds(dev, flow_control);
359 } else {
360 /* normal connection */
361 list_for_each_entry_safe(cl_pos, cl_next,
362 &dev->file_list, link) {
363 dev_dbg(&dev->pdev->dev, "list_for_each_entry_safe in file_list\n");
364
365 dev_dbg(&dev->pdev->dev, "cl of host client %d ME client %d.\n",
366 cl_pos->host_client_id,
367 cl_pos->me_client_id);
368 dev_dbg(&dev->pdev->dev, "flow ctrl msg for host %d ME %d.\n",
369 flow_control->host_addr,
370 flow_control->me_addr);
371 if (same_flow_addr(cl_pos, flow_control)) {
372 dev_dbg(&dev->pdev->dev, "recv ctrl msg for host %d ME %d.\n",
373 flow_control->host_addr,
374 flow_control->me_addr);
375 cl_pos->mei_flow_ctrl_creds++;
376 dev_dbg(&dev->pdev->dev, "flow control credentials = %d.\n",
377 cl_pos->mei_flow_ctrl_creds);
378 break;
379 }
380 }
381 }
382}
383
384 176
385/** 177/**
386 * _mei_hb_read - processes read related operation. 178 * _mei_hb_read - processes read related operation.
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index 0ad32cc49c06..54ddac324578 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -398,15 +398,6 @@ int mei_ioctl_connect_client(struct file *file,
398 398
399int mei_start_read(struct mei_device *dev, struct mei_cl *cl); 399int mei_start_read(struct mei_device *dev, struct mei_cl *cl);
400 400
401
402void mei_client_disconnect_response(struct mei_device *dev,
403 struct hbm_client_connect_response *rs);
404
405void mei_client_connect_response(struct mei_device *dev,
406 struct hbm_client_connect_response *rs);
407
408void mei_client_flow_control_response(struct mei_device *dev,
409 struct hbm_flow_control *flow_control);
410/* 401/*
411 * AMTHIF - AMT Host Interface Functions 402 * AMTHIF - AMT Host Interface Functions
412 */ 403 */