7 #include <linux/kernel.h>
8 #include <linux/module.h>
9 #include <linux/slab.h>
12 #include <linux/connector.h>
26 #define DM_ULOG_RETRY_TIMEOUT (15 * HZ)
31 #define DM_ULOG_PREALLOCED_SIZE 512
32 static struct cn_msg *prealloced_cn_msg;
35 static struct cb_id ulog_cn_id = {
63 msg->
id.idx = ulog_cn_id.
idx;
64 msg->
id.val = ulog_cn_id.
val;
98 if (rtn_seq != pkg->
seq)
111 DMERR(
"Insufficient space to receive package [%u] "
140 spin_lock(&receiving_list_lock);
143 else if (msg->
len <
sizeof(*tfr))
144 DMERR(
"Incomplete message received (expected %u, got %u): [%u]",
145 (
unsigned)
sizeof(*tfr), msg->
len, msg->
seq);
148 spin_unlock(&receiving_list_lock);
172 char *rdata,
size_t *rdata_size)
176 int overhead_size =
sizeof(
struct dm_ulog_request) + sizeof(struct cn_msg);
186 DMINFO(
"Size of tfr exceeds preallocated size");
203 tfr->
seq = dm_ulog_seq++;
213 if (data && data_size)
216 memset(&pkg, 0,
sizeof(pkg));
221 spin_lock(&receiving_list_lock);
222 list_add(&(pkg.
list), &receiving_list);
223 spin_unlock(&receiving_list_lock);
225 r = dm_ulog_sendto_server(tfr);
230 DMERR(
"Unable to send log request [%u] to userspace: %d",
232 spin_lock(&receiving_list_lock);
233 list_del_init(&(pkg.
list));
234 spin_unlock(&receiving_list_lock);
240 spin_lock(&receiving_list_lock);
241 list_del_init(&(pkg.
list));
242 spin_unlock(&receiving_list_lock);
244 DMWARN(
"[%s] Request timed out: [%u/%u] - retrying",
246 (uuid + (
strlen(uuid) - 8)) : (uuid),
247 request_type, pkg.
seq);
264 INIT_LIST_HEAD(&receiving_list);
270 prealloced_cn_msg = prealloced;
271 prealloced_ulog_tfr = prealloced +
sizeof(
struct cn_msg);
285 kfree(prealloced_cn_msg);