import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / eccci / modem_ut.h
1 #ifndef __MODEM_UT_H__
2 #define __MODEM_UT_H__
3
4 #include <linux/wakelock.h>
5 #include <linux/dmapool.h>
6
7 #define LOOP_BACK // loop back, or gen Rx data
8 #ifdef LOOP_BACK
9 #ifdef CCCI_STATISTIC
10 #define STATISTIC // statistic data gathering for performance debug
11 #endif
12 //#define NO_RX_Q_LOCK // check comment in md_ut_rxq_process
13 #define NO_RX_Q_LOCK_IN_TX // check comment in md_ut_txq_process
14 #endif
15
16 #define MD_UT_MAJOR 169
17 #define MAX_QUEUE_LENGTH 32
18 #define QUEUE_BUDGET 16
19
20 typedef enum {
21 HIF_EX_INIT = 0, // interrupt
22 HIF_EX_ACK, // AP->MD
23 HIF_EX_INIT_DONE, // polling
24 HIF_EX_CLEARQ_DONE, //interrupt
25 HIF_EX_CLEARQ_ACK, // AP->MD
26 HIF_EX_ALLQ_RESET, // polling
27 }HIF_EX_STAGE;
28
29 struct md_ut_queue {
30 DIRECTION dir;
31 unsigned char index;
32 struct ccci_modem *modem;
33
34 struct list_head req_list;
35 spinlock_t req_lock;
36 int budget;
37 int length;
38 wait_queue_head_t req_wq;
39 // now only for Tx, Rx won't wait, just drop
40 int length_th;
41 #ifdef STATISTIC
42 unsigned int process_count; // write or dispatch operation
43 unsigned int not_complet_count; // have to wait due to list full
44 unsigned int data_count; // packet size accumulation
45 #endif
46 };
47
48 struct md_ut_ctrl{
49 struct md_ut_queue txq[3];
50 struct md_ut_queue rxq[3];
51 wait_queue_head_t sched_thread_wq;
52 unsigned char sched_thread_kick;
53 atomic_t reset_on_going;
54 struct wake_lock trm_wake_lock;
55
56 struct task_struct *sched_thread;
57 struct timer_list rx_gen_timer;
58 #ifdef STATISTIC
59 struct timer_list statistic_timer;
60 #endif
61 };
62
63 #define QUEUE_LEN(a) (sizeof(a)/sizeof(struct md_ut_queue))
64
65 static void inline md_ut_queue_struct_init(struct md_ut_queue *queue, struct ccci_modem *md,
66 DIRECTION dir, unsigned char index,
67 int th, int bg)
68 {
69 queue->dir = OUT;
70 queue->index = index;
71 queue->modem = md;
72
73 INIT_LIST_HEAD(&queue->req_list);
74 init_waitqueue_head(&queue->req_wq);
75 spin_lock_init(&queue->req_lock);
76 queue->length_th = th;
77 queue->budget = bg;
78 queue->length = 0;
79 #ifdef STATISTIC
80 queue->process_count = 0;
81 queue->not_complet_count = 0;
82 #endif
83 }
84
85 #endif //__MODEM_UT_H__