1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#include <linux/sched.h>
24#include "ibmasm.h"
25#include "dot_command.h"
26
27
28
29
30
31
32
33
34#pragma pack(1)
35static struct {
36 struct dot_command_header header;
37 unsigned char command[3];
38} rhb_dot_cmd = {
39 .header = {
40 .type = sp_read,
41 .command_size = 3,
42 .data_size = 0,
43 .status = 0
44 },
45 .command = { 4, 3, 6 }
46};
47#pragma pack()
48
49void ibmasm_init_reverse_heartbeat(struct service_processor *sp, struct reverse_heartbeat *rhb)
50{
51 init_waitqueue_head(&rhb->wait);
52 rhb->stopped = 0;
53}
54
55
56
57
58
59
60
61int ibmasm_start_reverse_heartbeat(struct service_processor *sp, struct reverse_heartbeat *rhb)
62{
63 struct command *cmd;
64 int times_failed = 0;
65 int result = 1;
66
67 cmd = ibmasm_new_command(sp, sizeof rhb_dot_cmd);
68 if (!cmd)
69 return -ENOMEM;
70
71 while (times_failed < 3) {
72 memcpy(cmd->buffer, (void *)&rhb_dot_cmd, sizeof rhb_dot_cmd);
73 cmd->status = IBMASM_CMD_PENDING;
74 ibmasm_exec_command(sp, cmd);
75 ibmasm_wait_for_response(cmd, IBMASM_CMD_TIMEOUT_NORMAL);
76
77 if (cmd->status != IBMASM_CMD_COMPLETE)
78 times_failed++;
79
80 wait_event_interruptible_timeout(rhb->wait,
81 rhb->stopped,
82 REVERSE_HEARTBEAT_TIMEOUT * HZ);
83
84 if (signal_pending(current) || rhb->stopped) {
85 result = -EINTR;
86 break;
87 }
88 }
89 command_put(cmd);
90 rhb->stopped = 0;
91
92 return result;
93}
94
95void ibmasm_stop_reverse_heartbeat(struct reverse_heartbeat *rhb)
96{
97 rhb->stopped = 1;
98 wake_up_interruptible(&rhb->wait);
99}
100