1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#ifndef _QTN_FMAC_SHM_IPC_H_
18#define _QTN_FMAC_SHM_IPC_H_
19
20#include <linux/workqueue.h>
21#include <linux/completion.h>
22#include <linux/mutex.h>
23#include <linux/spinlock.h>
24
25#include "shm_ipc_defs.h"
26
27#define QTN_SHM_IPC_ACK_TIMEOUT (2 * HZ)
28
29struct qtnf_shm_ipc_int {
30 void (*fn)(void *arg);
31 void *arg;
32};
33
34struct qtnf_shm_ipc_rx_callback {
35 void (*fn)(void *arg, const u8 *buf, size_t len);
36 void *arg;
37};
38
39enum qtnf_shm_ipc_direction {
40 QTNF_SHM_IPC_OUTBOUND = BIT(0),
41 QTNF_SHM_IPC_INBOUND = BIT(1),
42};
43
44struct qtnf_shm_ipc {
45 struct qtnf_shm_ipc_region __iomem *shm_region;
46 enum qtnf_shm_ipc_direction direction;
47 size_t tx_packet_count;
48 size_t rx_packet_count;
49
50 size_t tx_timeout_count;
51
52 u8 waiting_for_ack;
53
54 u8 rx_data[QTN_IPC_MAX_DATA_SZ] __aligned(sizeof(u32));
55
56 struct qtnf_shm_ipc_int interrupt;
57 struct qtnf_shm_ipc_rx_callback rx_callback;
58
59 void (*irq_handler)(struct qtnf_shm_ipc *ipc);
60
61 struct workqueue_struct *workqueue;
62 struct work_struct irq_work;
63 struct completion tx_completion;
64};
65
66int qtnf_shm_ipc_init(struct qtnf_shm_ipc *ipc,
67 enum qtnf_shm_ipc_direction direction,
68 struct qtnf_shm_ipc_region __iomem *shm_region,
69 struct workqueue_struct *workqueue,
70 const struct qtnf_shm_ipc_int *interrupt,
71 const struct qtnf_shm_ipc_rx_callback *rx_callback);
72void qtnf_shm_ipc_free(struct qtnf_shm_ipc *ipc);
73int qtnf_shm_ipc_send(struct qtnf_shm_ipc *ipc, const u8 *buf, size_t size);
74
75static inline void qtnf_shm_ipc_irq_handler(struct qtnf_shm_ipc *ipc)
76{
77 ipc->irq_handler(ipc);
78}
79
80#endif
81