0001
0002
0003
0004 #ifndef _QTN_FMAC_SHM_IPC_H_
0005 #define _QTN_FMAC_SHM_IPC_H_
0006
0007 #include <linux/workqueue.h>
0008 #include <linux/completion.h>
0009 #include <linux/mutex.h>
0010 #include <linux/spinlock.h>
0011
0012 #include "shm_ipc_defs.h"
0013
0014 #define QTN_SHM_IPC_ACK_TIMEOUT (2 * HZ)
0015
0016 struct qtnf_shm_ipc_int {
0017 void (*fn)(void *arg);
0018 void *arg;
0019 };
0020
0021 struct qtnf_shm_ipc_rx_callback {
0022 void (*fn)(void *arg, const u8 __iomem *buf, size_t len);
0023 void *arg;
0024 };
0025
0026 enum qtnf_shm_ipc_direction {
0027 QTNF_SHM_IPC_OUTBOUND = BIT(0),
0028 QTNF_SHM_IPC_INBOUND = BIT(1),
0029 };
0030
0031 struct qtnf_shm_ipc {
0032 struct qtnf_shm_ipc_region __iomem *shm_region;
0033 enum qtnf_shm_ipc_direction direction;
0034 size_t tx_packet_count;
0035 size_t rx_packet_count;
0036
0037 size_t tx_timeout_count;
0038
0039 u8 waiting_for_ack;
0040
0041 struct qtnf_shm_ipc_int interrupt;
0042 struct qtnf_shm_ipc_rx_callback rx_callback;
0043
0044 void (*irq_handler)(struct qtnf_shm_ipc *ipc);
0045
0046 struct workqueue_struct *workqueue;
0047 struct work_struct irq_work;
0048 struct completion tx_completion;
0049 };
0050
0051 int qtnf_shm_ipc_init(struct qtnf_shm_ipc *ipc,
0052 enum qtnf_shm_ipc_direction direction,
0053 struct qtnf_shm_ipc_region __iomem *shm_region,
0054 struct workqueue_struct *workqueue,
0055 const struct qtnf_shm_ipc_int *interrupt,
0056 const struct qtnf_shm_ipc_rx_callback *rx_callback);
0057 void qtnf_shm_ipc_free(struct qtnf_shm_ipc *ipc);
0058 int qtnf_shm_ipc_send(struct qtnf_shm_ipc *ipc, const u8 *buf, size_t size);
0059
0060 static inline void qtnf_shm_ipc_irq_handler(struct qtnf_shm_ipc *ipc)
0061 {
0062 ipc->irq_handler(ipc);
0063 }
0064
0065 #endif