1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
|
/***************************************************************
A globalmem driver as an example of char device drivers
The initial developer of the original code is Baohua Song
<author@linuxdriver.cn>. All Rights Reserved.
****************************************************************/
#include <linux/types.h>
#include <linux/slab.h>
#include "ipc_info.h"
extern u32 mux_ipc_GetTxTransferSavedCount(void);
IPC_INFO_T s_ipc_info[IPC_CHANNEL_NUM];
#include "./../ts0710.h"
#include "./../ts0710_mux.h"
/*For BP UART problem Begin*/
#ifdef TS0710SEQ2
#define FIRST_BP_SEQ_OFFSET 0 /*offset from start flag */
#define SECOND_BP_SEQ_OFFSET 0 /*offset from start flag */
#define FIRST_AP_SEQ_OFFSET 0 /*offset from start flag */
#define SECOND_AP_SEQ_OFFSET 0 /*offset from start flag */
#define SLIDE_BP_SEQ_OFFSET 0 /*offset from start flag */
#define SEQ_FIELD_SIZE 0
#else
#define SLIDE_BP_SEQ_OFFSET 1 /*offset from start flag */
#define SEQ_FIELD_SIZE 0
#endif
#define ADDRESS_FIELD_OFFSET (1 + SEQ_FIELD_SIZE) /*offset from start flag */
#define TS0710MUX_MAX_TOTAL_FRAME_SIZE (DEF_TS0710_MTU + TS0710_MAX_HDR_SIZE + FLAG_SIZE)
extern __u32 mux_crc_check(__u8 * data, __u32 length, __u8 check_sum);
int sdio_frame_check(char* buf_ptr, size_t length)
{
__u8* frame_start_ptr = NULL;
__u8* end_ptr = NULL;
short_frame* short_pkt = NULL;
long_frame* long_pkt = NULL;
int framelen = 0;
__u32 crc_error = 0;
__u8 *uih_data_start = NULL;
__u32 uih_len = 0;
int ret = 0;
frame_start_ptr = (__u8*)buf_ptr;
end_ptr = (__u8*)buf_ptr + length;
/*while(frame_start_ptr < end_ptr)
{
short_pkt = NULL;
long_pkt = NULL;
crc_error = 0;
framelen = 0;
uih_data_start = NULL;
uih_len = 0;
if(TS0710_BASIC_FLAG != *frame_start_ptr)
{
printk("%s:Error,mux frame head error!\r\n", __func__);
ret = -1;
break;
}
short_pkt = (short_frame *) (frame_start_ptr + ADDRESS_FIELD_OFFSET);
if(short_pkt->h.length.ea == 1) //short frame
{
framelen = TS0710_MAX_HDR_SIZE + short_pkt->h.length.len + 1 + SEQ_FIELD_SIZE;
}
else
{
long_pkt = (long_frame *) (frame_start_ptr + ADDRESS_FIELD_OFFSET);
framelen = TS0710_MAX_HDR_SIZE + GET_LONG_LENGTH(long_pkt->h.length) + 2 + SEQ_FIELD_SIZE;
}
if (framelen > (TS0710MUX_MAX_TOTAL_FRAME_SIZE + SEQ_FIELD_SIZE))
{
printk("%s:Error,mux frame length:%d is bigger than Max frame size:%d\r\n",
__func__, framelen, (TS0710MUX_MAX_TOTAL_FRAME_SIZE + SEQ_FIELD_SIZE));
ret = -1;
break;
}
if (*(frame_start_ptr + framelen - 1) != TS0710_BASIC_FLAG)
{
int k = 0;
printk("%s:Error,mux frame end error!, framelen start addr:0x%x, framelen:%d, offset:%d, \r\n",
__func__, (__u32)frame_start_ptr, framelen, (__u32)frame_start_ptr - (__u32)buf_ptr);
printk("\r\n =================\r\n0x%X,0x%X,0x%X,0x%X,0x%X,0x%X,0x%X,0x%X\r\n================\r\n",
frame_start_ptr[framelen -8],frame_start_ptr[framelen -7],frame_start_ptr[framelen -6],frame_start_ptr[framelen -5],
frame_start_ptr[framelen -4],frame_start_ptr[framelen -3],frame_start_ptr[framelen -2],frame_start_ptr[framelen -1]);
ret = -1;
break;
}
if ((short_pkt->h.length.ea) == 1) //short frame
{
uih_len = short_pkt->h.length.len;
uih_data_start = short_pkt->data;
crc_error = mux_crc_check((__u8*) (frame_start_ptr + SLIDE_BP_SEQ_OFFSET),SHORT_CRC_CHECK + 1, *(uih_data_start + uih_len));
}
else
{
uih_len = GET_LONG_LENGTH(long_pkt->h.length);
uih_data_start = long_pkt->h.data;
crc_error =mux_crc_check((__u8*) (frame_start_ptr +SLIDE_BP_SEQ_OFFSET),LONG_CRC_CHECK + 1,*(uih_data_start +uih_len));
}
if(crc_error)
{
printk("%s:Error,mux frame crc error!\r\n", __func__);
ret = -1;
break;
}
frame_start_ptr += framelen;
if(frame_start_ptr > end_ptr)
{
printk("%s:Error,mux frame data error!\r\n", __func__);
ret = -1;
break;
}
}*/
return ret;
}
void ipc_info_init(void)
{
memset(&s_ipc_info[0], 0, sizeof(IPC_INFO_T)*IPC_CHANNEL_NUM);
}
void ipc_info_rate(u32 channel, u32 value)
{
if(channel >= IPC_CHANNEL_NUM) {
return;
}
s_ipc_info[channel].rate = value;
}
void ipc_info_change_status(u32 channel, u32 status)
{
if(channel >= IPC_CHANNEL_NUM) {
return;
}
s_ipc_info[channel].status = status;
}
void ipc_info_mux_write(u32 size)
{
s_ipc_info[IPC_TX_CHANNEL].mux_count += size;
}
void ipc_info_mux_read(u32 size)
{
s_ipc_info[IPC_RX_CHANNEL].mux_count += size;
}
void ipc_info_mux_read_overflow(u32 size)
{
s_ipc_info[IPC_RX_CHANNEL].overflow_count += size;
}
void ipc_info_sdio_write(u32 size)
{
s_ipc_info[IPC_TX_CHANNEL].sdio_count += size;
}
void ipc_info_sdio_write_payload(u32 size)
{
s_ipc_info[IPC_TX_CHANNEL].payload_count += size;
}
void ipc_info_sdio_write_overflow(u32 size)
{
s_ipc_info[IPC_TX_CHANNEL].overflow_count += size;
}
void ipc_info_sdio_read(u32 size)
{
s_ipc_info[IPC_RX_CHANNEL].sdio_count += size;
}
void ipc_info_sdio_read_payload(u32 size)
{
s_ipc_info[IPC_RX_CHANNEL].payload_count += size;
}
void ipc_info_sdio_read_saved_count(u32 size)
{
s_ipc_info[IPC_RX_CHANNEL].saved_count = size;
}
void ipc_info_error_status(u32 channel, u32 status)
{
if(channel >= IPC_CHANNEL_NUM) {
return;
}
s_ipc_info[channel].status = status;
if (IPC_STATUS_FLOW_STOP == status) {
s_ipc_info[channel].flow_stop_count++;
} else if (IPC_STATUS_INVALID_PACKET == status) {
s_ipc_info[channel].invalid_pkt_count++;
} else if (IPC_STATUS_CRC_ERROR == status) {
s_ipc_info[channel].crc_error_count++;
} else if (IPC_STATUS_PACKET_ERROR == status) {
s_ipc_info[channel].packet_error_count++;
}
}
IPC_INFO_T* ipc_info_getinfo(u32 channel)
{
if(channel >= IPC_CHANNEL_NUM) {
return NULL;
}
s_ipc_info[IPC_TX_CHANNEL].saved_count = mux_ipc_GetTxTransferSavedCount();
return &s_ipc_info[channel];
}
|