• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * ITP interfaces for XRadio drivers
3  *
4  * Copyright (c) 2013
5  * Xradio Technology Co., Ltd. <www.xradiotech.com>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10  */
11 
12 #ifndef XRADIO_ITP_H_INCLUDED
13 #define XRADIO_ITP_H_INCLUDED
14 
15 struct wsm_tx_confirm;
16 struct dentry;
17 
18 #ifdef CONFIG_XRADIO_ITP
19 
20 /*extern*/ struct ieee80211_channel;
21 
22 #define TEST_MODE_NO_TEST	(0)
23 #define TEST_MODE_RX_TEST	(1)
24 #define TEST_MODE_TX_TEST	(2)
25 
26 #define ITP_DEFAULT_DA_ADDR {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
27 #define ITP_MIN_DATA_SIZE 6
28 #define ITP_MAX_DATA_SIZE 1600
29 #define ITP_TIME_THRES_US 10000
30 #define ITP_US_TO_MS(x) ((x)/1000)
31 #define ITP_MS_TO_US(x) ((x)*1000)
32 #if ((ITP_US_TO_MS(ITP_TIME_THRES_US))*HZ/1000) < 1
33 #warning not able to achieve non-busywaiting ITP_TIME_THRES_US\
34 precision with current HZ value !
35 #endif
36 #define ITP_BUF_SIZE 255
37 
38 
39 enum xradio_itp_data_modes {
40 	ITP_DATA_ZEROS,
41 	ITP_DATA_ONES,
42 	ITP_DATA_ZERONES,
43 	ITP_DATA_RANDOM,
44 	ITP_DATA_MAX_MODE,
45 };
46 
47 enum xradio_itp_version_type {
48 	ITP_CHIP_ID,
49 	ITP_FW_VER,
50 };
51 
52 enum xradio_itp_preamble_type {
53 	ITP_PREAMBLE_LONG,
54 	ITP_PREAMBLE_SHORT,
55 	ITP_PREAMBLE_OFDM,
56 	ITP_PREAMBLE_MIXED,
57 	ITP_PREAMBLE_GREENFIELD,
58 	ITP_PREAMBLE_MAX,
59 };
60 
61 
62 struct xradio_itp {
63 	struct xradio_common	*priv;
64 	atomic_t		open_count;
65 	atomic_t		awaiting_confirm;
66 	struct sk_buff_head	log_queue;
67 	wait_queue_head_t	read_wait;
68 	wait_queue_head_t	write_wait;
69 	wait_queue_head_t	close_wait;
70 	struct ieee80211_channel *saved_channel;
71 	atomic_t		stop_tx;
72 	struct delayed_work	tx_work;
73 	struct delayed_work	tx_finish;
74 	spinlock_t		tx_lock;
75 	struct timespec		last_sent;
76 	atomic_t		test_mode;
77 	int			rx_cnt;
78 	long			rx_rssi;
79 	int			rx_rssi_max;
80 	int			rx_rssi_min;
81 	unsigned		band;
82 	unsigned		ch;
83 	unsigned		rate;
84 	unsigned		preamble;
85 	unsigned int		number;
86 	unsigned		data_mode;
87 	int			interval_us;
88 	int			power;
89 	u8			*data;
90 	int			hdr_len;
91 	int			data_len;
92 	int			id;
93 };
94 
95 int xradio_itp_init(struct xradio_common *priv);
96 void xradio_itp_release(struct xradio_common *priv);
97 
98 bool xradio_is_itp(struct xradio_common *priv);
99 bool xradio_itp_rxed(struct xradio_common *priv, struct sk_buff *skb);
100 void xradio_itp_wake_up_tx(struct xradio_common *priv);
101 int xradio_itp_get_tx(struct xradio_common *priv, u8 **data,
102 		size_t *tx_len, int *burst);
103 bool xradio_itp_tx_running(struct xradio_common *priv);
104 
105 #else /* CONFIG_XRADIO_ITP */
106 
107 static inline int
xradio_itp_init(struct xradio_common * priv)108 xradio_itp_init(struct xradio_common *priv)
109 {
110 	return 0;
111 }
112 
xradio_itp_release(struct xradio_common * priv)113 static inline void xradio_itp_release(struct xradio_common *priv)
114 {
115 }
116 
xradio_is_itp(struct xradio_common * priv)117 static inline bool xradio_is_itp(struct xradio_common *priv)
118 {
119 	return false;
120 }
121 
xradio_itp_rxed(struct xradio_common * priv,struct sk_buff * skb)122 static inline bool xradio_itp_rxed(struct xradio_common *priv,
123 		struct sk_buff *skb)
124 {
125 	return false;
126 }
127 
128 
xradio_itp_consume_txed(struct xradio_common * priv)129 static inline void xradio_itp_consume_txed(struct xradio_common *priv)
130 {
131 }
132 
xradio_itp_wake_up_tx(struct xradio_common * priv)133 static inline void xradio_itp_wake_up_tx(struct xradio_common *priv)
134 {
135 }
136 
xradio_itp_get_tx(struct xradio_common * priv,u8 ** data,size_t * tx_len,int * burst)137 static inline int xradio_itp_get_tx(struct xradio_common *priv, u8 **data,
138 		size_t *tx_len, int *burst)
139 {
140 	return 0;
141 }
142 
xradio_itp_tx_running(struct xradio_common * priv)143 static inline bool xradio_itp_tx_running(struct xradio_common *priv)
144 {
145 	return false;
146 }
147 
148 #endif /* CONFIG_XRADIO_ITP */
149 
150 #endif /* XRADIO_ITP_H_INCLUDED */
151