diff options
63 files changed, 27606 insertions, 0 deletions
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 35ad9397a6b..af9b8e471a7 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig | |||
@@ -161,5 +161,7 @@ source "drivers/staging/ath6kl/Kconfig" | |||
161 | 161 | ||
162 | source "drivers/staging/keucr/Kconfig" | 162 | source "drivers/staging/keucr/Kconfig" |
163 | 163 | ||
164 | source "drivers/staging/bcm/Kconfig" | ||
165 | |||
164 | endif # !STAGING_EXCLUDE_BUILD | 166 | endif # !STAGING_EXCLUDE_BUILD |
165 | endif # STAGING | 167 | endif # STAGING |
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index a33209be3ba..cad2574a219 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile | |||
@@ -61,3 +61,4 @@ obj-$(CONFIG_WESTBRIDGE_ASTORIA) += westbridge/astoria/ | |||
61 | obj-$(CONFIG_SBE_2T3E3) += sbe-2t3e3/ | 61 | obj-$(CONFIG_SBE_2T3E3) += sbe-2t3e3/ |
62 | obj-$(CONFIG_ATH6K_LEGACY) += ath6kl/ | 62 | obj-$(CONFIG_ATH6K_LEGACY) += ath6kl/ |
63 | obj-$(CONFIG_USB_ENESTORAGE) += keucr/ | 63 | obj-$(CONFIG_USB_ENESTORAGE) += keucr/ |
64 | obj-$(CONFIG_BCM_WIMAX) += bcm/ | ||
diff --git a/drivers/staging/bcm/Adapter.h b/drivers/staging/bcm/Adapter.h new file mode 100644 index 00000000000..a7c0ce9e7fa --- /dev/null +++ b/drivers/staging/bcm/Adapter.h | |||
@@ -0,0 +1,714 @@ | |||
1 | /*********************************** | ||
2 | * Adapter.h | ||
3 | ************************************/ | ||
4 | #ifndef __ADAPTER_H__ | ||
5 | #define __ADAPTER_H__ | ||
6 | |||
7 | #define MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES 256 | ||
8 | #include "Debug.h" | ||
9 | |||
10 | typedef struct _LIST_ENTRY{ | ||
11 | struct _LIST_ENTRY *next; | ||
12 | struct _LIST_ENTRY *prev; | ||
13 | } LIST_ENTRY, *PLIST_ENTRY; | ||
14 | |||
15 | typedef struct _BCM_LIST_ENTRY { | ||
16 | |||
17 | LIST_ENTRY Link; | ||
18 | |||
19 | } BCM_LIST_ENTRY, *PBCM_LIST_ENTRY; | ||
20 | |||
21 | typedef enum _RCB_STATUS | ||
22 | { | ||
23 | DRIVER_PROCESSED=1, | ||
24 | APPLICATION_PROCESSED | ||
25 | } RCB_STATUS, *PRCB_STATUS; | ||
26 | |||
27 | #define fFILLED 1 | ||
28 | #define fEMPTY 0 | ||
29 | |||
30 | struct _BCM_CB | ||
31 | { | ||
32 | // The network packet that this RCB is receiving | ||
33 | PVOID pv_packet; | ||
34 | // Describes the length of the packet . | ||
35 | UINT ui_packet_length; | ||
36 | // Pointer to the first buffer in the packet (only one buffer for Rx) | ||
37 | PUCHAR buffer; | ||
38 | atomic_t status; | ||
39 | UINT filled; | ||
40 | } __attribute__((packed)); | ||
41 | typedef struct _BCM_CB BCM_CB,*PBCM_CB; | ||
42 | |||
43 | typedef BCM_CB BCM_RCB, *PBCM_RCB; | ||
44 | typedef BCM_CB BCM_TCB, *PBCM_TCB; | ||
45 | |||
46 | /* This is to be stored in the "pvOsDepData" of ADAPTER */ | ||
47 | typedef struct LINUX_DEP_DATA | ||
48 | { | ||
49 | struct net_device *virtualdev; /* Our Interface (veth0) */ | ||
50 | struct net_device *actualdev; /* True Interface (eth0) */ | ||
51 | struct net_device_stats netstats; /* Net statistics */ | ||
52 | struct fasync_struct *async_queue; /* For asynchronus notification */ | ||
53 | |||
54 | } LINUX_DEP_DATA, *PLINUX_DEP_DATA; | ||
55 | |||
56 | |||
57 | struct _LEADER | ||
58 | { | ||
59 | USHORT Vcid; | ||
60 | USHORT PLength; | ||
61 | UCHAR Status; | ||
62 | UCHAR Unused[3]; | ||
63 | }__attribute__((packed)); | ||
64 | typedef struct _LEADER LEADER,*PLEADER; | ||
65 | |||
66 | struct _PACKETTOSEND | ||
67 | { | ||
68 | LEADER Leader; | ||
69 | UCHAR ucPayload; | ||
70 | }__attribute__((packed)); | ||
71 | typedef struct _PACKETTOSEND PACKETTOSEND, *PPACKETTOSEND; | ||
72 | |||
73 | |||
74 | struct _CONTROL_PACKET | ||
75 | { | ||
76 | PVOID ControlBuff; | ||
77 | UINT ControlBuffLen; | ||
78 | struct _CONTROL_PACKET* next; | ||
79 | }__attribute__((packed)); | ||
80 | typedef struct _CONTROL_PACKET CONTROL_PACKET,*PCONTROL_PACKET; | ||
81 | |||
82 | |||
83 | struct link_request | ||
84 | { | ||
85 | LEADER Leader; | ||
86 | UCHAR szData[4]; | ||
87 | }__attribute__((packed)); | ||
88 | typedef struct link_request LINK_REQUEST, *PLINK_REQUEST; | ||
89 | |||
90 | |||
91 | //classification extension is added | ||
92 | typedef struct _ADD_CONNECTION | ||
93 | { | ||
94 | ULONG SrcIpAddressCount; | ||
95 | ULONG SrcIpAddress[MAX_CONNECTIONS]; | ||
96 | ULONG SrcIpMask[MAX_CONNECTIONS]; | ||
97 | |||
98 | ULONG DestIpAddressCount; | ||
99 | ULONG DestIpAddress[MAX_CONNECTIONS]; | ||
100 | ULONG DestIpMask[MAX_CONNECTIONS]; | ||
101 | |||
102 | USHORT SrcPortBegin; | ||
103 | USHORT SrcPortEnd; | ||
104 | |||
105 | USHORT DestPortBegin; | ||
106 | USHORT DestPortEnd; | ||
107 | |||
108 | UCHAR SrcTOS; | ||
109 | UCHAR SrcProtocol; | ||
110 | } ADD_CONNECTION,*PADD_CONNECTION; | ||
111 | |||
112 | |||
113 | typedef struct _CLASSIFICATION_RULE | ||
114 | { | ||
115 | UCHAR ucIPSrcAddrLen; | ||
116 | UCHAR ucIPSrcAddr[32]; | ||
117 | UCHAR ucIPDestAddrLen; | ||
118 | UCHAR ucIPDestAddr[32]; | ||
119 | UCHAR ucSrcPortRangeLen; | ||
120 | UCHAR ucSrcPortRange[4]; | ||
121 | UCHAR ucDestPortRangeLen; | ||
122 | UCHAR ucDestPortRange[4]; | ||
123 | USHORT usVcid; | ||
124 | } CLASSIFICATION_RULE,*PCLASSIFICATION_RULE; | ||
125 | |||
126 | typedef struct _CLASSIFICATION_ONLY | ||
127 | { | ||
128 | USHORT usVcid; | ||
129 | ULONG DestIpAddress; | ||
130 | ULONG DestIpMask; | ||
131 | USHORT usPortLo; | ||
132 | USHORT usPortHi; | ||
133 | BOOLEAN bIpVersion; | ||
134 | UCHAR ucDestinationAddress[16]; | ||
135 | } CLASSIFICATION_ONLY, *PCLASSIFICATION_ONLY; | ||
136 | |||
137 | |||
138 | #define MAX_IP_RANGE_LENGTH 4 | ||
139 | #define MAX_PORT_RANGE 4 | ||
140 | #define MAX_PROTOCOL_LENGTH 32 | ||
141 | #define IPV6_ADDRESS_SIZEINBYTES 0x10 | ||
142 | |||
143 | typedef union _U_IP_ADDRESS | ||
144 | { | ||
145 | struct | ||
146 | { | ||
147 | ULONG ulIpv4Addr[MAX_IP_RANGE_LENGTH];//Source Ip Address Range | ||
148 | ULONG ulIpv4Mask[MAX_IP_RANGE_LENGTH];//Source Ip Mask Address Range | ||
149 | }; | ||
150 | struct | ||
151 | { | ||
152 | ULONG ulIpv6Addr[MAX_IP_RANGE_LENGTH * 4];//Source Ip Address Range | ||
153 | ULONG ulIpv6Mask[MAX_IP_RANGE_LENGTH * 4];//Source Ip Mask Address Range | ||
154 | |||
155 | }; | ||
156 | struct | ||
157 | { | ||
158 | UCHAR ucIpv4Address[MAX_IP_RANGE_LENGTH * IP_LENGTH_OF_ADDRESS]; | ||
159 | UCHAR ucIpv4Mask[MAX_IP_RANGE_LENGTH * IP_LENGTH_OF_ADDRESS]; | ||
160 | }; | ||
161 | struct | ||
162 | { | ||
163 | UCHAR ucIpv6Address[MAX_IP_RANGE_LENGTH * IPV6_ADDRESS_SIZEINBYTES]; | ||
164 | UCHAR ucIpv6Mask[MAX_IP_RANGE_LENGTH * IPV6_ADDRESS_SIZEINBYTES]; | ||
165 | }; | ||
166 | }U_IP_ADDRESS; | ||
167 | struct _packet_info; | ||
168 | |||
169 | typedef struct _S_HDR_SUPRESSION_CONTEXTINFO | ||
170 | { | ||
171 | |||
172 | UCHAR ucaHdrSupressionInBuf[MAX_PHS_LENGTHS]; //Intermediate buffer to accumulate pkt Header for PHS | ||
173 | UCHAR ucaHdrSupressionOutBuf[MAX_PHS_LENGTHS + PHSI_LEN]; //Intermediate buffer containing pkt Header after PHS | ||
174 | |||
175 | }S_HDR_SUPRESSION_CONTEXTINFO; | ||
176 | |||
177 | |||
178 | typedef struct _S_CLASSIFIER_RULE | ||
179 | { | ||
180 | ULONG ulSFID; | ||
181 | UCHAR ucReserved[2]; | ||
182 | B_UINT16 uiClassifierRuleIndex; | ||
183 | BOOLEAN bUsed; | ||
184 | USHORT usVCID_Value; | ||
185 | B_UINT8 u8ClassifierRulePriority; //This field detemines the Classifier Priority | ||
186 | U_IP_ADDRESS stSrcIpAddress; | ||
187 | UCHAR ucIPSourceAddressLength;//Ip Source Address Length | ||
188 | |||
189 | U_IP_ADDRESS stDestIpAddress; | ||
190 | UCHAR ucIPDestinationAddressLength;//Ip Destination Address Length | ||
191 | UCHAR ucIPTypeOfServiceLength;//Type of service Length | ||
192 | UCHAR ucTosLow;//Tos Low | ||
193 | UCHAR ucTosHigh;//Tos High | ||
194 | UCHAR ucTosMask;//Tos Mask | ||
195 | |||
196 | UCHAR ucProtocolLength;//protocol Length | ||
197 | UCHAR ucProtocol[MAX_PROTOCOL_LENGTH];//protocol Length | ||
198 | USHORT usSrcPortRangeLo[MAX_PORT_RANGE]; | ||
199 | USHORT usSrcPortRangeHi[MAX_PORT_RANGE]; | ||
200 | UCHAR ucSrcPortRangeLength; | ||
201 | |||
202 | USHORT usDestPortRangeLo[MAX_PORT_RANGE]; | ||
203 | USHORT usDestPortRangeHi[MAX_PORT_RANGE]; | ||
204 | UCHAR ucDestPortRangeLength; | ||
205 | |||
206 | BOOLEAN bProtocolValid; | ||
207 | BOOLEAN bTOSValid; | ||
208 | BOOLEAN bDestIpValid; | ||
209 | BOOLEAN bSrcIpValid; | ||
210 | |||
211 | //For IPv6 Addressing | ||
212 | UCHAR ucDirection; | ||
213 | BOOLEAN bIpv6Protocol; | ||
214 | UINT32 u32PHSRuleID; | ||
215 | S_PHS_RULE sPhsRule; | ||
216 | UCHAR u8AssociatedPHSI; | ||
217 | |||
218 | //Classification fields for ETH CS | ||
219 | UCHAR ucEthCSSrcMACLen; | ||
220 | UCHAR au8EThCSSrcMAC[MAC_ADDRESS_SIZE]; | ||
221 | UCHAR au8EThCSSrcMACMask[MAC_ADDRESS_SIZE]; | ||
222 | UCHAR ucEthCSDestMACLen; | ||
223 | UCHAR au8EThCSDestMAC[MAC_ADDRESS_SIZE]; | ||
224 | UCHAR au8EThCSDestMACMask[MAC_ADDRESS_SIZE]; | ||
225 | UCHAR ucEtherTypeLen; | ||
226 | UCHAR au8EthCSEtherType[NUM_ETHERTYPE_BYTES]; | ||
227 | UCHAR usUserPriority[2]; | ||
228 | USHORT usVLANID; | ||
229 | USHORT usValidityBitMap; | ||
230 | }S_CLASSIFIER_RULE; | ||
231 | //typedef struct _S_CLASSIFIER_RULE S_CLASSIFIER_RULE; | ||
232 | |||
233 | typedef struct _S_FRAGMENTED_PACKET_INFO | ||
234 | { | ||
235 | BOOLEAN bUsed; | ||
236 | ULONG ulSrcIpAddress; | ||
237 | USHORT usIpIdentification; | ||
238 | S_CLASSIFIER_RULE *pstMatchedClassifierEntry; | ||
239 | BOOLEAN bOutOfOrderFragment; | ||
240 | }S_FRAGMENTED_PACKET_INFO,*PS_FRAGMENTED_PACKET_INFO; | ||
241 | |||
242 | struct _packet_info | ||
243 | { | ||
244 | //classification extension Rule | ||
245 | ULONG ulSFID; | ||
246 | USHORT usVCID_Value; | ||
247 | UINT uiThreshold; | ||
248 | // This field determines the priority of the SF Queues | ||
249 | B_UINT8 u8TrafficPriority; | ||
250 | |||
251 | BOOLEAN bValid; | ||
252 | BOOLEAN bActive; | ||
253 | BOOLEAN bActivateRequestSent; | ||
254 | |||
255 | B_UINT8 u8QueueType;//BE or rtPS | ||
256 | |||
257 | UINT uiMaxBucketSize;//maximum size of the bucket for the queue | ||
258 | UINT uiCurrentQueueDepthOnTarget; | ||
259 | UINT uiCurrentBytesOnHost; | ||
260 | UINT uiCurrentPacketsOnHost; | ||
261 | UINT uiDroppedCountBytes; | ||
262 | UINT uiDroppedCountPackets; | ||
263 | UINT uiSentBytes; | ||
264 | UINT uiSentPackets; | ||
265 | UINT uiCurrentDrainRate; | ||
266 | UINT uiThisPeriodSentBytes; | ||
267 | LARGE_INTEGER liDrainCalculated; | ||
268 | UINT uiCurrentTokenCount; | ||
269 | LARGE_INTEGER liLastUpdateTokenAt; | ||
270 | UINT uiMaxAllowedRate; | ||
271 | UINT NumOfPacketsSent; | ||
272 | UCHAR ucDirection; | ||
273 | USHORT usCID; | ||
274 | S_MIBS_EXTSERVICEFLOW_PARAMETERS stMibsExtServiceFlowTable; | ||
275 | UINT uiCurrentRxRate; | ||
276 | UINT uiThisPeriodRxBytes; | ||
277 | UINT uiTotalRxBytes; | ||
278 | UINT uiTotalTxBytes; | ||
279 | UINT uiPendedLast; | ||
280 | UCHAR ucIpVersion; | ||
281 | |||
282 | union | ||
283 | { | ||
284 | struct | ||
285 | { | ||
286 | struct sk_buff* FirstTxQueue; | ||
287 | struct sk_buff* LastTxQueue; | ||
288 | }; | ||
289 | struct | ||
290 | { | ||
291 | struct sk_buff* ControlHead; | ||
292 | struct sk_buff* ControlTail; | ||
293 | }; | ||
294 | }; | ||
295 | BOOLEAN bProtocolValid; | ||
296 | BOOLEAN bTOSValid; | ||
297 | BOOLEAN bDestIpValid; | ||
298 | BOOLEAN bSrcIpValid; | ||
299 | |||
300 | BOOLEAN bActiveSet; | ||
301 | BOOLEAN bAdmittedSet; | ||
302 | BOOLEAN bAuthorizedSet; | ||
303 | BOOLEAN bClassifierPriority; | ||
304 | UCHAR ucServiceClassName[MAX_CLASS_NAME_LENGTH]; | ||
305 | BOOLEAN bHeaderSuppressionEnabled; | ||
306 | spinlock_t SFQueueLock; | ||
307 | void *pstSFIndication; | ||
308 | struct timeval stLastUpdateTokenAt; | ||
309 | atomic_t uiPerSFTxResourceCount; | ||
310 | UINT uiMaxLatency; | ||
311 | UCHAR bIPCSSupport; | ||
312 | UCHAR bEthCSSupport; | ||
313 | }; | ||
314 | typedef struct _packet_info PacketInfo; | ||
315 | |||
316 | |||
317 | typedef struct _PER_TARANG_DATA | ||
318 | { | ||
319 | struct _PER_TARANG_DATA * next; | ||
320 | struct _MINI_ADAPTER * Adapter; | ||
321 | struct sk_buff* RxAppControlHead; | ||
322 | struct sk_buff* RxAppControlTail; | ||
323 | volatile INT AppCtrlQueueLen; | ||
324 | BOOLEAN MacTracingEnabled; | ||
325 | BOOLEAN bApplicationToExit; | ||
326 | S_MIBS_DROPPED_APP_CNTRL_MESSAGES stDroppedAppCntrlMsgs; | ||
327 | ULONG RxCntrlMsgBitMask; | ||
328 | } PER_TARANG_DATA, *PPER_TARANG_DATA; | ||
329 | |||
330 | |||
331 | #ifdef REL_4_1 | ||
332 | typedef struct _TARGET_PARAMS | ||
333 | { | ||
334 | B_UINT32 m_u32CfgVersion; | ||
335 | |||
336 | // Scanning Related Params | ||
337 | B_UINT32 m_u32CenterFrequency; | ||
338 | B_UINT32 m_u32BandAScan; | ||
339 | B_UINT32 m_u32BandBScan; | ||
340 | B_UINT32 m_u32BandCScan; | ||
341 | |||
342 | // QoS Params | ||
343 | B_UINT32 m_u32minGrantsize; // size of minimum grant is 0 or 6 | ||
344 | B_UINT32 m_u32PHSEnable; | ||
345 | |||
346 | // HO Params | ||
347 | B_UINT32 m_u32HoEnable; | ||
348 | B_UINT32 m_u32HoReserved1; | ||
349 | B_UINT32 m_u32HoReserved2; | ||
350 | |||
351 | // Power Control Params | ||
352 | B_UINT32 m_u32MimoEnable; | ||
353 | B_UINT32 m_u32SecurityEnable; | ||
354 | /* | ||
355 | * bit 1: 1 Idlemode enable; | ||
356 | * bit 2: 1 Sleepmode Enable | ||
357 | */ | ||
358 | B_UINT32 m_u32PowerSavingModesEnable; | ||
359 | /* PowerSaving Mode Options: | ||
360 | bit 0 = 1: CPE mode - to keep pcmcia if alive; | ||
361 | bit 1 = 1: CINR reporing in Idlemode Msg | ||
362 | bit 2 = 1: Default PSC Enable in sleepmode*/ | ||
363 | B_UINT32 m_u32PowerSavingModeOptions; | ||
364 | |||
365 | B_UINT32 m_u32ArqEnable; | ||
366 | |||
367 | // From Version #3, the HARQ section renamed as general | ||
368 | B_UINT32 m_u32HarqEnable; | ||
369 | // EEPROM Param Location | ||
370 | B_UINT32 m_u32EEPROMFlag; | ||
371 | /* BINARY TYPE - 4th MSByte: | ||
372 | * Interface Type - 3rd MSByte: | ||
373 | * Vendor Type - 2nd MSByte | ||
374 | */ | ||
375 | // Unused - LSByte | ||
376 | B_UINT32 m_u32Customize; | ||
377 | B_UINT32 m_u32ConfigBW; /* In Hz */ | ||
378 | B_UINT32 m_u32ShutDownTimer; | ||
379 | |||
380 | |||
381 | B_UINT32 m_u32RadioParameter; | ||
382 | B_UINT32 m_u32PhyParameter1; | ||
383 | B_UINT32 m_u32PhyParameter2; | ||
384 | B_UINT32 m_u32PhyParameter3; | ||
385 | |||
386 | /* in eval mode only; | ||
387 | * lower 16bits = basic cid for testing; | ||
388 | * then bit 16 is test cqich, | ||
389 | * bit 17 test init rang; | ||
390 | * bit 18 test periodic rang | ||
391 | * bit 19 is test harq ack/nack | ||
392 | */ | ||
393 | B_UINT32 m_u32TestOptions; | ||
394 | |||
395 | B_UINT32 m_u32MaxMACDataperDLFrame; | ||
396 | B_UINT32 m_u32MaxMACDataperULFrame; | ||
397 | |||
398 | B_UINT32 m_u32Corr2MacFlags; | ||
399 | |||
400 | //adding driver params. | ||
401 | B_UINT32 HostDrvrConfig1; | ||
402 | B_UINT32 HostDrvrConfig2; | ||
403 | B_UINT32 HostDrvrConfig3; | ||
404 | B_UINT32 HostDrvrConfig4; | ||
405 | B_UINT32 HostDrvrConfig5; | ||
406 | B_UINT32 HostDrvrConfig6; | ||
407 | B_UINT32 m_u32SegmentedPUSCenable; | ||
408 | |||
409 | // BAMC enable - but 4.x does not support this feature | ||
410 | // This is added just to sync 4.x and 5.x CFGs | ||
411 | B_UINT32 m_u32BandAMCEnable; | ||
412 | } STARGETPARAMS, *PSTARGETPARAMS; | ||
413 | #endif | ||
414 | |||
415 | typedef struct _STTARGETDSXBUFFER | ||
416 | { | ||
417 | ULONG ulTargetDsxBuffer; | ||
418 | B_UINT16 tid; | ||
419 | BOOLEAN valid; | ||
420 | }STTARGETDSXBUFFER, *PSTTARGETDSXBUFFER; | ||
421 | |||
422 | typedef INT (*FP_FLASH_WRITE)(struct _MINI_ADAPTER*,UINT,PVOID); | ||
423 | |||
424 | typedef INT (*FP_FLASH_WRITE_STATUS)(struct _MINI_ADAPTER*,UINT,PVOID); | ||
425 | |||
426 | /** | ||
427 | Driver adapter data structure | ||
428 | */ | ||
429 | struct _MINI_ADAPTER | ||
430 | { | ||
431 | struct _MINI_ADAPTER *next; | ||
432 | PVOID pvOsDepData; | ||
433 | CHAR *caDsxReqResp; | ||
434 | atomic_t ApplicationRunning; | ||
435 | volatile INT CtrlQueueLen; | ||
436 | atomic_t AppCtrlQueueLen; | ||
437 | BOOLEAN AppCtrlQueueOverFlow; | ||
438 | atomic_t CurrentApplicationCount; | ||
439 | atomic_t RegisteredApplicationCount; | ||
440 | BOOLEAN TimerActive; | ||
441 | ULONG StatisticsPointer; | ||
442 | struct sk_buff *RxControlHead; | ||
443 | struct sk_buff *RxControlTail; | ||
444 | // spinlock_t RxControlQueuelock; | ||
445 | struct semaphore RxAppControlQueuelock; | ||
446 | struct semaphore fw_download_sema; | ||
447 | |||
448 | PPER_TARANG_DATA pTarangs; | ||
449 | spinlock_t control_queue_lock; | ||
450 | wait_queue_head_t process_read_wait_queue; | ||
451 | ULONG bcm_jiffies; /* Store Jiffies value */ | ||
452 | |||
453 | // the pointer to the first packet we have queued in send | ||
454 | // deserialized miniport support variables | ||
455 | atomic_t TotalPacketCount; | ||
456 | atomic_t TxPktAvail; | ||
457 | |||
458 | // this to keep track of the Tx and Rx MailBox Registers. | ||
459 | atomic_t CurrNumFreeTxDesc; | ||
460 | // to keep track the no of byte recieved | ||
461 | atomic_t RxRollOverCount; | ||
462 | USHORT PrevNumRecvDescs; | ||
463 | USHORT CurrNumRecvDescs; | ||
464 | atomic_t GoodRxByteCount; | ||
465 | atomic_t GoodRxPktCount; | ||
466 | atomic_t BadRxByteCount; | ||
467 | atomic_t RxPacketDroppedCount; | ||
468 | atomic_t GoodTxByteCount; | ||
469 | atomic_t TxTotalPacketCount; | ||
470 | atomic_t TxDroppedPacketCount; | ||
471 | ULONG LinkUpStatus; | ||
472 | BOOLEAN TransferMode; | ||
473 | UINT u32TotalDSD; | ||
474 | PacketInfo PackInfo[NO_OF_QUEUES]; | ||
475 | S_CLASSIFIER_RULE astClassifierTable[MAX_CLASSIFIERS]; | ||
476 | |||
477 | /*************** qos ******************/ | ||
478 | UINT bETHCSEnabled; | ||
479 | |||
480 | ULONG BEBucketSize; | ||
481 | ULONG rtPSBucketSize; | ||
482 | UCHAR LinkStatus; | ||
483 | BOOLEAN AutoLinkUp; | ||
484 | BOOLEAN AutoSyncup; | ||
485 | |||
486 | struct net_device *dev; | ||
487 | UINT major; | ||
488 | UINT minor; | ||
489 | wait_queue_head_t tx_packet_wait_queue; | ||
490 | wait_queue_head_t process_rx_cntrlpkt; | ||
491 | atomic_t process_waiting; | ||
492 | BOOLEAN fw_download_done; | ||
493 | |||
494 | unsigned int ctrlpkt_present; | ||
495 | BOOLEAN packets_given_to_all; | ||
496 | char *txctlpacket[MAX_CNTRL_PKTS]; | ||
497 | atomic_t cntrlpktCnt ; | ||
498 | atomic_t index_app_read_cntrlpkt; | ||
499 | atomic_t index_wr_txcntrlpkt; | ||
500 | atomic_t index_rd_txcntrlpkt; | ||
501 | UINT index_datpkt; | ||
502 | struct semaphore rdmwrmsync; | ||
503 | |||
504 | STTARGETDSXBUFFER astTargetDsxBuffer[MAX_TARGET_DSX_BUFFERS]; | ||
505 | ULONG ulFreeTargetBufferCnt; | ||
506 | ULONG ulCurrentTargetBuffer; | ||
507 | ULONG ulTotalTargetBuffersAvailable; | ||
508 | unsigned int timeout; | ||
509 | int irq; | ||
510 | unsigned long chip_id; | ||
511 | unsigned int bFlashBoot; | ||
512 | unsigned int if_up; | ||
513 | // spinlock_t sleeper_lock; | ||
514 | atomic_t rdm_wrm_access; | ||
515 | atomic_t tx_rx_access; | ||
516 | wait_queue_head_t lowpower_mode_wait_queue; | ||
517 | atomic_t bAbortedByHost; | ||
518 | BOOLEAN bBinDownloaded; | ||
519 | BOOLEAN bCfgDownloaded; | ||
520 | USHORT usBestEffortQueueIndex; | ||
521 | BOOLEAN bSyncUpRequestSent; | ||
522 | // struct semaphore data_packet_queue_lock; | ||
523 | wait_queue_head_t ioctl_fw_dnld_wait_queue; | ||
524 | BOOLEAN waiting_to_fw_download_done; | ||
525 | pid_t fw_download_process_pid; | ||
526 | PSTARGETPARAMS pstargetparams; | ||
527 | BOOLEAN device_removed; | ||
528 | BOOLEAN DeviceAccess; | ||
529 | INT DDRSetting; | ||
530 | BOOLEAN bDDRInitDone; | ||
531 | ULONG ulPowerSaveMode; | ||
532 | BOOLEAN bIsAutoCorrectEnabled; | ||
533 | spinlock_t txtransmitlock; | ||
534 | B_UINT8 txtransmit_running; | ||
535 | /* Thread for control packet handling */ | ||
536 | struct task_struct *control_packet_handler; | ||
537 | /* thread for transmitting packets. */ | ||
538 | struct task_struct *transmit_packet_thread; | ||
539 | |||
540 | /* LED Related Structures */ | ||
541 | LED_INFO_STRUCT LEDInfo; | ||
542 | |||
543 | /* Driver State for LED Blinking */ | ||
544 | LedEventInfo_t DriverState; | ||
545 | /* Interface Specific */ | ||
546 | PVOID pvInterfaceAdapter; | ||
547 | int (*bcm_file_download)( PVOID, | ||
548 | struct file *, | ||
549 | unsigned int); | ||
550 | int (*bcm_file_readback_from_chip)( PVOID, | ||
551 | struct file *, | ||
552 | unsigned int); | ||
553 | INT (*interface_rdm)(PVOID, | ||
554 | UINT , | ||
555 | PVOID , | ||
556 | INT); | ||
557 | INT (*interface_wrm)(PVOID, | ||
558 | UINT , | ||
559 | PVOID , | ||
560 | INT); | ||
561 | int (*interface_transmit)(PVOID, PVOID , UINT); | ||
562 | BOOLEAN IdleMode; | ||
563 | BOOLEAN bDregRequestSentInIdleMode; | ||
564 | BOOLEAN bTriedToWakeUpFromlowPowerMode; | ||
565 | BOOLEAN bShutStatus; | ||
566 | BOOLEAN bWakeUpDevice; | ||
567 | unsigned int usIdleModePattern; | ||
568 | //BOOLEAN bTriedToWakeUpFromShutdown; | ||
569 | BOOLEAN bLinkDownRequested; | ||
570 | unsigned int check_for_hang; | ||
571 | int downloadDDR; | ||
572 | PHS_DEVICE_EXTENSION stBCMPhsContext; | ||
573 | S_HDR_SUPRESSION_CONTEXTINFO stPhsTxContextInfo; | ||
574 | uint8_t ucaPHSPktRestoreBuf[2048]; | ||
575 | uint8_t bPHSEnabled; | ||
576 | int AutoFirmDld; | ||
577 | BOOLEAN bMipsConfig; | ||
578 | BOOLEAN bDPLLConfig; | ||
579 | UINT32 aTxPktSizeHist[MIBS_MAX_HIST_ENTRIES]; | ||
580 | UINT32 aRxPktSizeHist[MIBS_MAX_HIST_ENTRIES]; | ||
581 | S_FRAGMENTED_PACKET_INFO astFragmentedPktClassifierTable[MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES]; | ||
582 | atomic_t uiMBupdate; | ||
583 | UINT32 PmuMode; | ||
584 | NVM_TYPE eNVMType; | ||
585 | UINT uiSectorSize; | ||
586 | UINT uiSectorSizeInCFG; | ||
587 | BOOLEAN bSectorSizeOverride; | ||
588 | BOOLEAN bStatusWrite; | ||
589 | UINT uiNVMDSDSize; | ||
590 | UINT uiVendorExtnFlag; | ||
591 | //it will always represent choosed DSD at any point of time. | ||
592 | // Generally it is Active DSD but in case of NVM RD/WR it might be different. | ||
593 | UINT ulFlashCalStart; | ||
594 | ULONG ulFlashControlSectionStart; | ||
595 | ULONG ulFlashWriteSize; | ||
596 | ULONG ulFlashID; | ||
597 | FP_FLASH_WRITE fpFlashWrite; | ||
598 | FP_FLASH_WRITE_STATUS fpFlashWriteWithStatusCheck; | ||
599 | |||
600 | |||
601 | struct semaphore NVMRdmWrmLock; | ||
602 | BOOLEAN bNetworkInterfaceRegistered; | ||
603 | BOOLEAN bNetdeviceNotifierRegistered; | ||
604 | struct device *pstCreatedClassDevice; | ||
605 | BOOLEAN bUsbClassDriverRegistered; | ||
606 | // BOOLEAN InterfaceUpStatus; | ||
607 | PFLASH2X_CS_INFO psFlash2xCSInfo; | ||
608 | PFLASH_CS_INFO psFlashCSInfo ; | ||
609 | PFLASH2X_VENDORSPECIFIC_INFO psFlash2xVendorInfo; | ||
610 | UINT uiFlashBaseAdd; //Flash start address | ||
611 | UINT uiActiveISOOffset; //Active ISO offset choosen before f/w download | ||
612 | FLASH2X_SECTION_VAL eActiveISO; //Active ISO section val | ||
613 | FLASH2X_SECTION_VAL eActiveDSD; //Active DSD val choosen before f/w download | ||
614 | UINT uiActiveDSDOffsetAtFwDld; //For accessing Active DSD choosen before f/w download | ||
615 | UINT uiFlashLayoutMajorVersion ; | ||
616 | UINT uiFlashLayoutMinorVersion; | ||
617 | BOOLEAN bAllDSDWriteAllow ; | ||
618 | BOOLEAN bSigCorrupted ; | ||
619 | //this should be set who so ever want to change the Headers. after Wrtie it should be reset immediately. | ||
620 | BOOLEAN bHeaderChangeAllowed ; | ||
621 | INT SelectedChip ; | ||
622 | BOOLEAN bEndPointHalted; | ||
623 | //while bFlashRawRead will be true, Driver ignore map lay out and consider flash as of without any map. | ||
624 | BOOLEAN bFlashRawRead; | ||
625 | BOOLEAN bPreparingForLowPowerMode ; | ||
626 | BOOLEAN bDoSuspend ; | ||
627 | UINT syscfgBefFwDld ; | ||
628 | BOOLEAN StopAllXaction ; | ||
629 | UINT32 liTimeSinceLastNetEntry; //Used to Support extended CAPI requirements from | ||
630 | struct semaphore LowPowerModeSync; | ||
631 | ULONG liDrainCalculated; | ||
632 | UINT gpioBitMap; | ||
633 | S_BCM_DEBUG_STATE stDebugState; | ||
634 | |||
635 | }; | ||
636 | typedef struct _MINI_ADAPTER MINI_ADAPTER, *PMINI_ADAPTER; | ||
637 | |||
638 | |||
639 | typedef struct _DEVICE_EXTENSION | ||
640 | { | ||
641 | PMINI_ADAPTER pAdapt; | ||
642 | }DEVICE_EXTENSION,*PDEVICE_EXTENSION; | ||
643 | |||
644 | |||
645 | struct _ETH_HEADER_STRUC { | ||
646 | UCHAR au8DestinationAddress[6]; | ||
647 | UCHAR au8SourceAddress[6]; | ||
648 | USHORT u16Etype; | ||
649 | }__attribute__((packed)); | ||
650 | typedef struct _ETH_HEADER_STRUC ETH_HEADER_STRUC, *PETH_HEADER_STRUC; | ||
651 | |||
652 | |||
653 | typedef struct FirmwareInfo | ||
654 | { | ||
655 | PVOID pvMappedFirmwareAddress; | ||
656 | ULONG u32FirmwareLength; | ||
657 | ULONG u32StartingAddress; | ||
658 | }__attribute__((packed)) FIRMWARE_INFO, *PFIRMWARE_INFO; | ||
659 | |||
660 | // holds the value of net_device structure.. | ||
661 | extern struct net_device *gblpnetdev; | ||
662 | typedef struct _cntl_pkt{ | ||
663 | PMINI_ADAPTER Adapter; | ||
664 | PLEADER PLeader; | ||
665 | }cntl_pkt; | ||
666 | typedef LINK_REQUEST CONTROL_MESSAGE; | ||
667 | |||
668 | typedef struct _DDR_SETTING | ||
669 | { | ||
670 | ULONG ulRegAddress; | ||
671 | ULONG ulRegValue; | ||
672 | }DDR_SETTING, *PDDR_SETTING; | ||
673 | typedef DDR_SETTING DDR_SET_NODE, *PDDR_SET_NODE; | ||
674 | INT | ||
675 | InitAdapter(PMINI_ADAPTER psAdapter); | ||
676 | |||
677 | // ===================================================================== | ||
678 | // Beceem vendor request codes for EP0 | ||
679 | // ===================================================================== | ||
680 | |||
681 | #define BCM_REQUEST_READ 0x2 | ||
682 | #define BCM_REQUEST_WRITE 0x1 | ||
683 | #define EP2_MPS_REG 0x0F0110A0 | ||
684 | #define EP2_MPS 0x40 | ||
685 | |||
686 | #define EP2_CFG_REG 0x0F0110A8 | ||
687 | #define EP2_CFG_INT 0x27 | ||
688 | #define EP2_CFG_BULK 0x25 | ||
689 | |||
690 | #define EP4_MPS_REG 0x0F0110F0 | ||
691 | #define EP4_MPS 0x8C | ||
692 | |||
693 | #define EP4_CFG_REG 0x0F0110F8 | ||
694 | |||
695 | #define ISO_MPS_REG 0x0F0110C8 | ||
696 | #define ISO_MPS 0x00000000 | ||
697 | |||
698 | |||
699 | #define EP1 0 | ||
700 | #define EP2 1 | ||
701 | #define EP3 2 | ||
702 | #define EP4 3 | ||
703 | #define EP5 4 | ||
704 | #define EP6 5 | ||
705 | |||
706 | |||
707 | typedef enum eInterface_setting | ||
708 | { | ||
709 | DEFAULT_SETTING_0 = 0, | ||
710 | ALTERNATE_SETTING_1 = 1, | ||
711 | }INTERFACE_SETTING; | ||
712 | |||
713 | #endif //__ADAPTER_H__ | ||
714 | |||
diff --git a/drivers/staging/bcm/Arp.c b/drivers/staging/bcm/Arp.c new file mode 100644 index 00000000000..d60d8593d2e --- /dev/null +++ b/drivers/staging/bcm/Arp.c | |||
@@ -0,0 +1,94 @@ | |||
1 | |||
2 | /* | ||
3 | * File Name: Arp.c | ||
4 | * Abstract: This file contains the routines for handling ARP PACKETS | ||
5 | */ | ||
6 | #include "headers.h" | ||
7 | #define ARP_PKT_SIZE 60 | ||
8 | |||
9 | /* ========================================================================= | ||
10 | * Function - reply_to_arp_request() | ||
11 | * | ||
12 | * Description - When this host tries to broadcast ARP request packet through | ||
13 | * the virtual interface (veth0), reply directly to upper layer. | ||
14 | * This function allocates a new skb for ARP reply packet, | ||
15 | * fills in the fields of the packet and then sends it to | ||
16 | * upper layer. | ||
17 | * | ||
18 | * Parameters - skb: Pointer to sk_buff structure of the ARP request pkt. | ||
19 | * | ||
20 | * Returns - None | ||
21 | * =========================================================================*/ | ||
22 | |||
23 | VOID | ||
24 | reply_to_arp_request(struct sk_buff *skb) | ||
25 | { | ||
26 | PMINI_ADAPTER Adapter; | ||
27 | struct ArpHeader *pArpHdr = NULL; | ||
28 | struct ethhdr *pethhdr = NULL; | ||
29 | UCHAR uiIPHdr[4]; | ||
30 | /* Check for valid skb */ | ||
31 | if(skb == NULL) | ||
32 | { | ||
33 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Invalid skb: Cannot reply to ARP request\n"); | ||
34 | return; | ||
35 | } | ||
36 | |||
37 | |||
38 | Adapter = GET_BCM_ADAPTER(skb->dev); | ||
39 | /* Print the ARP Request Packet */ | ||
40 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, ARP_RESP, DBG_LVL_ALL, "ARP Packet Dump :"); | ||
41 | BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_TX, ARP_RESP, DBG_LVL_ALL, (PUCHAR)(skb->data), skb->len); | ||
42 | |||
43 | /* | ||
44 | * Extract the Ethernet Header and Arp Payload including Header | ||
45 | */ | ||
46 | pethhdr = (struct ethhdr *)skb->data; | ||
47 | pArpHdr = (struct ArpHeader *)(skb->data+ETH_HLEN); | ||
48 | |||
49 | if(Adapter->bETHCSEnabled) | ||
50 | { | ||
51 | if(memcmp(pethhdr->h_source, Adapter->dev->dev_addr, ETH_ALEN)) | ||
52 | { | ||
53 | bcm_kfree_skb(skb); | ||
54 | return; | ||
55 | } | ||
56 | } | ||
57 | |||
58 | // Set the Ethernet Header First. | ||
59 | memcpy(pethhdr->h_dest, pethhdr->h_source, ETH_ALEN); | ||
60 | if(!memcmp(pethhdr->h_source, Adapter->dev->dev_addr, ETH_ALEN)) | ||
61 | { | ||
62 | pethhdr->h_source[5]++; | ||
63 | } | ||
64 | |||
65 | /* Set the reply to ARP Reply */ | ||
66 | pArpHdr->arp.ar_op = ntohs(ARPOP_REPLY); | ||
67 | |||
68 | /* Set the HW Address properly */ | ||
69 | memcpy(pArpHdr->ar_sha, pethhdr->h_source, ETH_ALEN); | ||
70 | memcpy(pArpHdr->ar_tha, pethhdr->h_dest, ETH_ALEN); | ||
71 | |||
72 | // Swapping the IP Adddress | ||
73 | memcpy(uiIPHdr,pArpHdr->ar_sip,4); | ||
74 | memcpy(pArpHdr->ar_sip,pArpHdr->ar_tip,4); | ||
75 | memcpy(pArpHdr->ar_tip,uiIPHdr,4); | ||
76 | |||
77 | /* Print the ARP Reply Packet */ | ||
78 | |||
79 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, ARP_RESP, DBG_LVL_ALL, "ARP REPLY PACKET: "); | ||
80 | |||
81 | /* Send the Packet to upper layer */ | ||
82 | BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_TX, ARP_RESP, DBG_LVL_ALL, (PUCHAR)(skb->data), skb->len); | ||
83 | |||
84 | skb->protocol = eth_type_trans(skb,skb->dev); | ||
85 | skb->pkt_type = PACKET_HOST; | ||
86 | |||
87 | // skb->mac.raw=skb->data+LEADER_SIZE; | ||
88 | skb_set_mac_header (skb, LEADER_SIZE); | ||
89 | netif_rx(skb); | ||
90 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, ARP_RESP, DBG_LVL_ALL, "<=============\n"); | ||
91 | return; | ||
92 | } | ||
93 | |||
94 | |||
diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c new file mode 100644 index 00000000000..489487a6edb --- /dev/null +++ b/drivers/staging/bcm/Bcmchar.c | |||
@@ -0,0 +1,2420 @@ | |||
1 | #include "headers.h" | ||
2 | /*************************************************************** | ||
3 | * Function - bcm_char_open() | ||
4 | * | ||
5 | * Description - This is the "open" entry point for the character | ||
6 | * driver. | ||
7 | * | ||
8 | * Parameters - inode: Pointer to the Inode structure of char device | ||
9 | * filp : File pointer of the char device | ||
10 | * | ||
11 | * Returns - Zero(Success) | ||
12 | ****************************************************************/ | ||
13 | static struct class *bcm_class = NULL; | ||
14 | static int bcm_char_open(struct inode *inode, struct file * filp) | ||
15 | { | ||
16 | PMINI_ADAPTER Adapter = NULL; | ||
17 | PPER_TARANG_DATA pTarang = NULL; | ||
18 | |||
19 | Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
20 | pTarang = (PPER_TARANG_DATA)kmalloc(sizeof(PER_TARANG_DATA), GFP_KERNEL); | ||
21 | if (!pTarang) | ||
22 | return -ENOMEM; | ||
23 | |||
24 | memset (pTarang, 0, sizeof(PER_TARANG_DATA)); | ||
25 | pTarang->Adapter = Adapter; | ||
26 | pTarang->RxCntrlMsgBitMask = 0xFFFFFFFF & ~(1 << 0xB) ; | ||
27 | |||
28 | down(&Adapter->RxAppControlQueuelock); | ||
29 | pTarang->next = Adapter->pTarangs; | ||
30 | Adapter->pTarangs = pTarang; | ||
31 | up(&Adapter->RxAppControlQueuelock); | ||
32 | |||
33 | /* Store the Adapter structure */ | ||
34 | filp->private_data = pTarang; | ||
35 | |||
36 | /*Start Queuing the control response Packets*/ | ||
37 | atomic_inc(&Adapter->ApplicationRunning); | ||
38 | return 0; | ||
39 | } | ||
40 | static int bcm_char_release(struct inode *inode, struct file *filp) | ||
41 | { | ||
42 | PPER_TARANG_DATA pTarang, tmp, ptmp; | ||
43 | PMINI_ADAPTER Adapter=NULL; | ||
44 | struct sk_buff * pkt, * npkt; | ||
45 | |||
46 | pTarang = (PPER_TARANG_DATA)filp->private_data; | ||
47 | |||
48 | if(pTarang == NULL) | ||
49 | { | ||
50 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "ptarang is null\n"); | ||
51 | return 0; | ||
52 | } | ||
53 | |||
54 | Adapter = pTarang->Adapter; | ||
55 | |||
56 | down( &Adapter->RxAppControlQueuelock); | ||
57 | |||
58 | tmp = Adapter->pTarangs; | ||
59 | for ( ptmp = NULL; tmp; ptmp = tmp, tmp = tmp->next ) | ||
60 | { | ||
61 | if ( tmp == pTarang ) | ||
62 | break; | ||
63 | } | ||
64 | |||
65 | if ( tmp ) | ||
66 | { | ||
67 | if ( !ptmp ) | ||
68 | Adapter->pTarangs = tmp->next; | ||
69 | else | ||
70 | ptmp->next = tmp->next; | ||
71 | } | ||
72 | |||
73 | else | ||
74 | { | ||
75 | up( &Adapter->RxAppControlQueuelock); | ||
76 | return 0; | ||
77 | } | ||
78 | |||
79 | pkt = pTarang->RxAppControlHead; | ||
80 | while ( pkt ) | ||
81 | { | ||
82 | npkt = pkt->next; | ||
83 | kfree_skb(pkt); | ||
84 | pkt = npkt; | ||
85 | } | ||
86 | |||
87 | up( &Adapter->RxAppControlQueuelock); | ||
88 | |||
89 | /*Stop Queuing the control response Packets*/ | ||
90 | atomic_dec(&Adapter->ApplicationRunning); | ||
91 | |||
92 | bcm_kfree(pTarang); | ||
93 | |||
94 | /* remove this filp from the asynchronously notified filp's */ | ||
95 | filp->private_data = NULL; | ||
96 | return 0; | ||
97 | } | ||
98 | |||
99 | static int bcm_char_read(struct file *filp, PCHAR buf, size_t size, loff_t *f_pos) | ||
100 | { | ||
101 | PPER_TARANG_DATA pTarang = (PPER_TARANG_DATA)filp->private_data; | ||
102 | PMINI_ADAPTER Adapter = pTarang->Adapter; | ||
103 | struct sk_buff* Packet = NULL; | ||
104 | UINT PktLen = 0; | ||
105 | int wait_ret_val=0; | ||
106 | |||
107 | wait_ret_val = wait_event_interruptible(Adapter->process_read_wait_queue, | ||
108 | (pTarang->RxAppControlHead || Adapter->device_removed)); | ||
109 | if((wait_ret_val == -ERESTARTSYS)) | ||
110 | { | ||
111 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Exiting as i've been asked to exit!!!\n"); | ||
112 | return wait_ret_val; | ||
113 | } | ||
114 | |||
115 | if(Adapter->device_removed) | ||
116 | { | ||
117 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device Removed... Killing the Apps...\n"); | ||
118 | return -ENODEV; | ||
119 | } | ||
120 | |||
121 | if(FALSE == Adapter->fw_download_done) | ||
122 | return -EACCES; | ||
123 | |||
124 | down( &Adapter->RxAppControlQueuelock); | ||
125 | |||
126 | if(pTarang->RxAppControlHead) | ||
127 | { | ||
128 | Packet = pTarang->RxAppControlHead; | ||
129 | DEQUEUEPACKET(pTarang->RxAppControlHead,pTarang->RxAppControlTail); | ||
130 | pTarang->AppCtrlQueueLen--; | ||
131 | } | ||
132 | |||
133 | up(&Adapter->RxAppControlQueuelock); | ||
134 | |||
135 | if(Packet) | ||
136 | { | ||
137 | PktLen = Packet->len; | ||
138 | if(copy_to_user(buf, Packet->data, PktLen)) | ||
139 | { | ||
140 | bcm_kfree_skb(Packet); | ||
141 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "\nReturning from copy to user failure \n"); | ||
142 | return -EFAULT; | ||
143 | } | ||
144 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Read %d Bytes From Adapter packet = 0x%p by process %d!\n", PktLen, Packet, current->pid); | ||
145 | bcm_kfree_skb(Packet); | ||
146 | } | ||
147 | |||
148 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "<====\n"); | ||
149 | return PktLen; | ||
150 | } | ||
151 | |||
152 | static INT bcm_char_ioctl(struct inode *inode, struct file *filp, | ||
153 | UINT cmd, ULONG arg) | ||
154 | { | ||
155 | PPER_TARANG_DATA pTarang = (PPER_TARANG_DATA)filp->private_data; | ||
156 | PMINI_ADAPTER Adapter = pTarang->Adapter; | ||
157 | INT Status = STATUS_FAILURE; | ||
158 | IOCTL_BUFFER IoBuffer={0}; | ||
159 | #ifndef BCM_SHM_INTERFACE | ||
160 | int timeout = 0; | ||
161 | #endif | ||
162 | |||
163 | |||
164 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Parameters Passed to control IOCTL cmd=0x%X arg=0x%lX", cmd, arg); | ||
165 | |||
166 | if(_IOC_TYPE(cmd) != BCM_IOCTL) | ||
167 | return -EFAULT; | ||
168 | if(_IOC_DIR(cmd) & _IOC_READ) | ||
169 | Status = !access_ok(VERIFY_WRITE, (PVOID)arg, _IOC_SIZE(cmd)); | ||
170 | else if (_IOC_DIR(cmd) & _IOC_WRITE) | ||
171 | Status = !access_ok(VERIFY_READ, (PVOID)arg, _IOC_SIZE(cmd)); | ||
172 | else if (_IOC_NONE == (_IOC_DIR(cmd) & _IOC_NONE)) | ||
173 | Status = STATUS_SUCCESS; | ||
174 | |||
175 | if(Status) | ||
176 | return -EFAULT; | ||
177 | |||
178 | if(Adapter->device_removed) | ||
179 | { | ||
180 | return -EFAULT; | ||
181 | } | ||
182 | |||
183 | if(FALSE == Adapter->fw_download_done) | ||
184 | { | ||
185 | switch (cmd) | ||
186 | { | ||
187 | case IOCTL_MAC_ADDR_REQ: | ||
188 | case IOCTL_LINK_REQ: | ||
189 | case IOCTL_CM_REQUEST: | ||
190 | case IOCTL_SS_INFO_REQ: | ||
191 | case IOCTL_SEND_CONTROL_MESSAGE: | ||
192 | case IOCTL_IDLE_REQ: | ||
193 | case IOCTL_BCM_GPIO_SET_REQUEST: | ||
194 | case IOCTL_BCM_GPIO_STATUS_REQUEST: | ||
195 | return -EACCES; | ||
196 | default: | ||
197 | break; | ||
198 | } | ||
199 | } | ||
200 | |||
201 | Status = vendorextnIoctl(Adapter, cmd, arg); | ||
202 | if(Status != CONTINUE_COMMON_PATH ) | ||
203 | { | ||
204 | return Status; | ||
205 | } | ||
206 | |||
207 | switch(cmd){ | ||
208 | // Rdms for Swin Idle... | ||
209 | case IOCTL_BCM_REGISTER_READ_PRIVATE: | ||
210 | { | ||
211 | RDM_BUFFER sRdmBuffer = {0}; | ||
212 | PCHAR temp_buff = NULL; | ||
213 | UINT Bufflen = 0; | ||
214 | /* Copy Ioctl Buffer structure */ | ||
215 | if(copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, | ||
216 | sizeof(IOCTL_BUFFER))) | ||
217 | { | ||
218 | Status = -EFAULT; | ||
219 | break; | ||
220 | } | ||
221 | |||
222 | Bufflen = IoBuffer.OutputLength + (4 - IoBuffer.OutputLength%4)%4; | ||
223 | temp_buff = (PCHAR)kmalloc(Bufflen, GFP_KERNEL); | ||
224 | if(!temp_buff) | ||
225 | { | ||
226 | return STATUS_FAILURE; | ||
227 | } | ||
228 | if(copy_from_user(&sRdmBuffer, IoBuffer.InputBuffer, | ||
229 | IoBuffer.InputLength)) | ||
230 | { | ||
231 | Status = -EFAULT; | ||
232 | break; | ||
233 | } | ||
234 | Status = rdmalt(Adapter, (UINT)sRdmBuffer.Register, | ||
235 | (PUINT)temp_buff, Bufflen); | ||
236 | if(Status != STATUS_SUCCESS) | ||
237 | { | ||
238 | bcm_kfree(temp_buff); | ||
239 | return Status; | ||
240 | } | ||
241 | if(copy_to_user((PCHAR)IoBuffer.OutputBuffer, | ||
242 | (PCHAR)temp_buff, (UINT)IoBuffer.OutputLength)) | ||
243 | { | ||
244 | Status = -EFAULT; | ||
245 | } | ||
246 | bcm_kfree(temp_buff); | ||
247 | break; | ||
248 | } | ||
249 | case IOCTL_BCM_REGISTER_WRITE_PRIVATE: | ||
250 | { | ||
251 | WRM_BUFFER sWrmBuffer = {0}; | ||
252 | UINT uiTempVar=0; | ||
253 | /* Copy Ioctl Buffer structure */ | ||
254 | |||
255 | if(copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, | ||
256 | sizeof(IOCTL_BUFFER))) | ||
257 | { | ||
258 | Status = -EFAULT; | ||
259 | break; | ||
260 | } | ||
261 | /* Get WrmBuffer structure */ | ||
262 | if(copy_from_user(&sWrmBuffer, IoBuffer.InputBuffer, | ||
263 | IoBuffer.InputLength)) | ||
264 | { | ||
265 | Status = -EFAULT; | ||
266 | break; | ||
267 | } | ||
268 | uiTempVar = sWrmBuffer.Register & EEPROM_REJECT_MASK; | ||
269 | if(!((Adapter->pstargetparams->m_u32Customize) & VSG_MODE) && | ||
270 | ((uiTempVar == EEPROM_REJECT_REG_1)|| | ||
271 | (uiTempVar == EEPROM_REJECT_REG_2) || | ||
272 | (uiTempVar == EEPROM_REJECT_REG_3) || | ||
273 | (uiTempVar == EEPROM_REJECT_REG_4))) | ||
274 | { | ||
275 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "EEPROM Access Denied, not in VSG Mode\n"); | ||
276 | Status = -EFAULT; | ||
277 | break; | ||
278 | } | ||
279 | Status = wrmalt(Adapter, (UINT)sWrmBuffer.Register, | ||
280 | (PUINT)sWrmBuffer.Data, sizeof(ULONG)); | ||
281 | if(Status == STATUS_SUCCESS) | ||
282 | { | ||
283 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"WRM Done\n"); | ||
284 | } | ||
285 | else | ||
286 | { | ||
287 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "WRM Failed\n"); | ||
288 | Status = -EFAULT; | ||
289 | } | ||
290 | break; | ||
291 | } | ||
292 | |||
293 | case IOCTL_BCM_REGISTER_READ: | ||
294 | case IOCTL_BCM_EEPROM_REGISTER_READ: | ||
295 | { | ||
296 | RDM_BUFFER sRdmBuffer = {0}; | ||
297 | PCHAR temp_buff = NULL; | ||
298 | UINT uiTempVar = 0; | ||
299 | if((Adapter->IdleMode == TRUE) || | ||
300 | (Adapter->bShutStatus ==TRUE) || | ||
301 | (Adapter->bPreparingForLowPowerMode ==TRUE)) | ||
302 | { | ||
303 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Device in Idle Mode, Blocking Rdms\n"); | ||
304 | Status = -EACCES; | ||
305 | break; | ||
306 | } | ||
307 | /* Copy Ioctl Buffer structure */ | ||
308 | if(copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, | ||
309 | sizeof(IOCTL_BUFFER))) | ||
310 | { | ||
311 | Status = -EFAULT; | ||
312 | break; | ||
313 | } | ||
314 | |||
315 | temp_buff = (PCHAR)kmalloc(IoBuffer.OutputLength, GFP_KERNEL); | ||
316 | if(!temp_buff) | ||
317 | { | ||
318 | return STATUS_FAILURE; | ||
319 | } | ||
320 | if(copy_from_user(&sRdmBuffer, IoBuffer.InputBuffer, | ||
321 | IoBuffer.InputLength)) | ||
322 | { | ||
323 | Status = -EFAULT; | ||
324 | break; | ||
325 | } | ||
326 | |||
327 | if( | ||
328 | #if !defined(BCM_SHM_INTERFACE) | ||
329 | (((ULONG)sRdmBuffer.Register & 0x0F000000) != 0x0F000000) || | ||
330 | #endif | ||
331 | ((ULONG)sRdmBuffer.Register & 0x3) | ||
332 | ) | ||
333 | { | ||
334 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "RDM Done On invalid Address : %x Access Denied.\n", | ||
335 | (int)sRdmBuffer.Register); | ||
336 | Status = -EINVAL; | ||
337 | break; | ||
338 | } | ||
339 | |||
340 | uiTempVar = sRdmBuffer.Register & EEPROM_REJECT_MASK; | ||
341 | Status = rdmaltWithLock(Adapter, (UINT)sRdmBuffer.Register, | ||
342 | (PUINT)temp_buff, IoBuffer.OutputLength); | ||
343 | if(Status != STATUS_SUCCESS) | ||
344 | { | ||
345 | bcm_kfree(temp_buff); | ||
346 | return Status; | ||
347 | } | ||
348 | if(copy_to_user((PCHAR)IoBuffer.OutputBuffer, | ||
349 | (PCHAR)temp_buff, (UINT)IoBuffer.OutputLength)) | ||
350 | { | ||
351 | Status = -EFAULT; | ||
352 | } | ||
353 | bcm_kfree(temp_buff); | ||
354 | break; | ||
355 | } | ||
356 | case IOCTL_BCM_REGISTER_WRITE: | ||
357 | case IOCTL_BCM_EEPROM_REGISTER_WRITE: | ||
358 | { | ||
359 | WRM_BUFFER sWrmBuffer = {0}; | ||
360 | UINT uiTempVar=0; | ||
361 | if((Adapter->IdleMode == TRUE) || | ||
362 | (Adapter->bShutStatus ==TRUE) || | ||
363 | (Adapter->bPreparingForLowPowerMode ==TRUE)) | ||
364 | { | ||
365 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Device in Idle Mode, Blocking Wrms\n"); | ||
366 | Status = -EACCES; | ||
367 | break; | ||
368 | } | ||
369 | /* Copy Ioctl Buffer structure */ | ||
370 | if(copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, | ||
371 | sizeof(IOCTL_BUFFER))) | ||
372 | { | ||
373 | Status = -EFAULT; | ||
374 | break; | ||
375 | } | ||
376 | /* Get WrmBuffer structure */ | ||
377 | if(copy_from_user(&sWrmBuffer, IoBuffer.InputBuffer, | ||
378 | IoBuffer.InputLength)) | ||
379 | { | ||
380 | Status = -EFAULT; | ||
381 | break; | ||
382 | } | ||
383 | if( | ||
384 | #if !defined(BCM_SHM_INTERFACE) | ||
385 | |||
386 | (((ULONG)sWrmBuffer.Register & 0x0F000000) != 0x0F000000) || | ||
387 | #endif | ||
388 | ((ULONG)sWrmBuffer.Register & 0x3) | ||
389 | ) | ||
390 | { | ||
391 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "WRM Done On invalid Address : %x Access Denied.\n", | ||
392 | (int)sWrmBuffer.Register); | ||
393 | Status = -EINVAL; | ||
394 | break; | ||
395 | } | ||
396 | uiTempVar = sWrmBuffer.Register & EEPROM_REJECT_MASK; | ||
397 | if(!((Adapter->pstargetparams->m_u32Customize) & VSG_MODE) && | ||
398 | ((uiTempVar == EEPROM_REJECT_REG_1)|| | ||
399 | (uiTempVar == EEPROM_REJECT_REG_2) || | ||
400 | (uiTempVar == EEPROM_REJECT_REG_3) || | ||
401 | (uiTempVar == EEPROM_REJECT_REG_4)) && | ||
402 | (cmd == IOCTL_BCM_REGISTER_WRITE)) | ||
403 | { | ||
404 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "EEPROM Access Denied, not in VSG Mode\n"); | ||
405 | Status = -EFAULT; | ||
406 | break; | ||
407 | } | ||
408 | |||
409 | Status = wrmaltWithLock(Adapter, (UINT)sWrmBuffer.Register, | ||
410 | (PUINT)sWrmBuffer.Data, sWrmBuffer.Length); | ||
411 | if(Status == STATUS_SUCCESS) | ||
412 | { | ||
413 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, OSAL_DBG, DBG_LVL_ALL, "WRM Done\n"); | ||
414 | } | ||
415 | else | ||
416 | { | ||
417 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "WRM Failed\n"); | ||
418 | Status = -EFAULT; | ||
419 | } | ||
420 | break; | ||
421 | } | ||
422 | case IOCTL_BCM_GPIO_SET_REQUEST: | ||
423 | { | ||
424 | UCHAR ucResetValue[4]; | ||
425 | UINT value =0; | ||
426 | UINT uiBit = 0; | ||
427 | UINT uiOperation = 0; | ||
428 | |||
429 | GPIO_INFO gpio_info = {0}; | ||
430 | if((Adapter->IdleMode == TRUE) || | ||
431 | (Adapter->bShutStatus ==TRUE) || | ||
432 | (Adapter->bPreparingForLowPowerMode ==TRUE)) | ||
433 | { | ||
434 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"GPIO Can't be set/clear in Low power Mode"); | ||
435 | Status = -EACCES; | ||
436 | break; | ||
437 | } | ||
438 | if(copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER))) | ||
439 | { | ||
440 | Status = -EFAULT; | ||
441 | break; | ||
442 | } | ||
443 | if(copy_from_user(&gpio_info, IoBuffer.InputBuffer, IoBuffer.InputLength)) | ||
444 | { | ||
445 | Status = -EFAULT; | ||
446 | break; | ||
447 | } | ||
448 | uiBit = gpio_info.uiGpioNumber; | ||
449 | uiOperation = gpio_info.uiGpioValue; | ||
450 | |||
451 | value= (1<<uiBit); | ||
452 | |||
453 | if(IsReqGpioIsLedInNVM(Adapter,value) ==FALSE) | ||
454 | { | ||
455 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Sorry, Requested GPIO<0x%X> is not correspond to LED !!!",value); | ||
456 | Status = -EINVAL; | ||
457 | break; | ||
458 | } | ||
459 | |||
460 | |||
461 | if(uiOperation)//Set - setting 1 | ||
462 | { | ||
463 | //Set the gpio output register | ||
464 | Status = wrmaltWithLock(Adapter,BCM_GPIO_OUTPUT_SET_REG , | ||
465 | (PUINT)(&value), sizeof(UINT)); | ||
466 | if(Status == STATUS_SUCCESS) | ||
467 | { | ||
468 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Set the GPIO bit\n"); | ||
469 | } | ||
470 | else | ||
471 | { | ||
472 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Failed to set the %dth GPIO \n",uiBit); | ||
473 | break; | ||
474 | } | ||
475 | } | ||
476 | else//Unset - setting 0 | ||
477 | { | ||
478 | //Set the gpio output register | ||
479 | Status = wrmaltWithLock(Adapter,BCM_GPIO_OUTPUT_CLR_REG , | ||
480 | (PUINT)(&value), sizeof(UINT)); | ||
481 | if(Status == STATUS_SUCCESS) | ||
482 | { | ||
483 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Set the GPIO bit\n"); | ||
484 | } | ||
485 | else | ||
486 | { | ||
487 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Failed to clear the %dth GPIO \n",uiBit); | ||
488 | break; | ||
489 | } | ||
490 | } | ||
491 | |||
492 | Status = rdmaltWithLock(Adapter, (UINT)GPIO_MODE_REGISTER, | ||
493 | (PUINT)ucResetValue, sizeof(UINT)); | ||
494 | if (STATUS_SUCCESS != Status) | ||
495 | { | ||
496 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"GPIO_MODE_REGISTER read failed"); | ||
497 | break; | ||
498 | } | ||
499 | //Set the gpio mode register to output | ||
500 | *(UINT*)ucResetValue |= (1<<uiBit); | ||
501 | Status = wrmaltWithLock(Adapter,GPIO_MODE_REGISTER , | ||
502 | (PUINT)ucResetValue, sizeof(UINT)); | ||
503 | if(Status == STATUS_SUCCESS) | ||
504 | { | ||
505 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Set the GPIO to output Mode\n"); | ||
506 | } | ||
507 | else | ||
508 | { | ||
509 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Failed to put GPIO in Output Mode\n"); | ||
510 | break; | ||
511 | } | ||
512 | } | ||
513 | break; | ||
514 | case BCM_LED_THREAD_STATE_CHANGE_REQ: | ||
515 | { | ||
516 | |||
517 | USER_THREAD_REQ threadReq = {0}; | ||
518 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"User made LED thread InActive"); | ||
519 | |||
520 | if((Adapter->IdleMode == TRUE) || | ||
521 | (Adapter->bShutStatus ==TRUE) || | ||
522 | (Adapter->bPreparingForLowPowerMode ==TRUE)) | ||
523 | { | ||
524 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"GPIO Can't be set/clear in Low power Mode"); | ||
525 | Status = -EACCES; | ||
526 | break; | ||
527 | } | ||
528 | Status =copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER)); | ||
529 | if(Status) | ||
530 | { | ||
531 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Failed while copying the IOBufer from user space err:%d",Status); | ||
532 | break; | ||
533 | } | ||
534 | |||
535 | Status= copy_from_user(&threadReq, IoBuffer.InputBuffer, IoBuffer.InputLength); | ||
536 | if(Status) | ||
537 | { | ||
538 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Failed while copying the InputBuffer from user space err:%d",Status); | ||
539 | break; | ||
540 | } | ||
541 | //if LED thread is running(Actively or Inactively) set it state to make inactive | ||
542 | if(Adapter->LEDInfo.led_thread_running) | ||
543 | { | ||
544 | if(threadReq.ThreadState == LED_THREAD_ACTIVATION_REQ) | ||
545 | { | ||
546 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Activating thread req"); | ||
547 | Adapter->DriverState = LED_THREAD_ACTIVE; | ||
548 | } | ||
549 | else | ||
550 | { | ||
551 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"DeActivating Thread req....."); | ||
552 | Adapter->DriverState = LED_THREAD_INACTIVE; | ||
553 | } | ||
554 | |||
555 | //signal thread. | ||
556 | wake_up(&Adapter->LEDInfo.notify_led_event); | ||
557 | |||
558 | } | ||
559 | } | ||
560 | break; | ||
561 | case IOCTL_BCM_GPIO_STATUS_REQUEST: | ||
562 | { | ||
563 | ULONG uiBit = 0; | ||
564 | UCHAR ucRead[4]; | ||
565 | GPIO_INFO gpio_info = {0}; | ||
566 | if((Adapter->IdleMode == TRUE) || | ||
567 | (Adapter->bShutStatus ==TRUE) || | ||
568 | (Adapter->bPreparingForLowPowerMode ==TRUE)) | ||
569 | { | ||
570 | Status = -EACCES; | ||
571 | break; | ||
572 | } | ||
573 | if(copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER))) | ||
574 | { | ||
575 | Status = -EFAULT; | ||
576 | break; | ||
577 | } | ||
578 | if(copy_from_user(&gpio_info, IoBuffer.InputBuffer, IoBuffer.InputLength)) | ||
579 | { | ||
580 | Status = -EFAULT; | ||
581 | break; | ||
582 | } | ||
583 | uiBit = gpio_info.uiGpioNumber; | ||
584 | //Set the gpio output register | ||
585 | Status = rdmaltWithLock(Adapter, (UINT)GPIO_PIN_STATE_REGISTER, | ||
586 | (PUINT)ucRead, sizeof(UINT)); | ||
587 | if(Status != STATUS_SUCCESS) | ||
588 | { | ||
589 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "RDM Failed\n"); | ||
590 | return Status; | ||
591 | } | ||
592 | |||
593 | } | ||
594 | break; | ||
595 | case IOCTL_BCM_GPIO_MULTI_REQUEST: | ||
596 | { | ||
597 | UCHAR ucResetValue[4]; | ||
598 | GPIO_MULTI_INFO gpio_multi_info[MAX_IDX]; | ||
599 | PGPIO_MULTI_INFO pgpio_multi_info = (PGPIO_MULTI_INFO)gpio_multi_info; | ||
600 | |||
601 | memset( pgpio_multi_info, 0, MAX_IDX * sizeof( GPIO_MULTI_INFO)); | ||
602 | |||
603 | if((Adapter->IdleMode == TRUE) || | ||
604 | (Adapter->bShutStatus ==TRUE) || | ||
605 | (Adapter->bPreparingForLowPowerMode ==TRUE)) | ||
606 | { | ||
607 | Status = -EINVAL; | ||
608 | break; | ||
609 | } | ||
610 | Status = copy_from_user( (PCHAR)&IoBuffer, ( PCHAR)arg, sizeof( IOCTL_BUFFER)); | ||
611 | if(Status) | ||
612 | { | ||
613 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Failed while copying the IOBufer from user space err:%d",Status); | ||
614 | break; | ||
615 | } | ||
616 | |||
617 | Status = copy_from_user( &gpio_multi_info, IoBuffer.InputBuffer, IoBuffer.InputLength); | ||
618 | if(Status) | ||
619 | { | ||
620 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Failed while copying the IOBufer Contents from user space err:%d",Status); | ||
621 | break; | ||
622 | } | ||
623 | if(IsReqGpioIsLedInNVM(Adapter,pgpio_multi_info[WIMAX_IDX].uiGPIOMask)== FALSE) | ||
624 | { | ||
625 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Sorry, Requested GPIO<0x%X> is not correspond to NVM LED bit map<0x%X>!!!",pgpio_multi_info[WIMAX_IDX].uiGPIOMask,Adapter->gpioBitMap); | ||
626 | Status = -EINVAL; | ||
627 | break; | ||
628 | } | ||
629 | |||
630 | /* Set the gpio output register */ | ||
631 | |||
632 | if( ( pgpio_multi_info[WIMAX_IDX].uiGPIOMask) & | ||
633 | ( pgpio_multi_info[WIMAX_IDX].uiGPIOCommand)) | ||
634 | { | ||
635 | /* Set 1's in GPIO OUTPUT REGISTER */ | ||
636 | *(UINT*) ucResetValue = pgpio_multi_info[WIMAX_IDX].uiGPIOMask & | ||
637 | pgpio_multi_info[WIMAX_IDX].uiGPIOCommand & | ||
638 | pgpio_multi_info[WIMAX_IDX].uiGPIOValue; | ||
639 | |||
640 | if( *(UINT*) ucResetValue) | ||
641 | Status = wrmaltWithLock( Adapter, BCM_GPIO_OUTPUT_SET_REG , (PUINT) ucResetValue, sizeof(ULONG)); | ||
642 | |||
643 | if( Status != STATUS_SUCCESS) | ||
644 | { | ||
645 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_PRINTK, 0, 0,"WRM to BCM_GPIO_OUTPUT_SET_REG Failed."); | ||
646 | return Status; | ||
647 | } | ||
648 | |||
649 | /* Clear to 0's in GPIO OUTPUT REGISTER */ | ||
650 | *(UINT*) ucResetValue = (pgpio_multi_info[WIMAX_IDX].uiGPIOMask & | ||
651 | pgpio_multi_info[WIMAX_IDX].uiGPIOCommand & | ||
652 | ( ~( pgpio_multi_info[WIMAX_IDX].uiGPIOValue))); | ||
653 | |||
654 | if( *(UINT*) ucResetValue) | ||
655 | Status = wrmaltWithLock( Adapter, BCM_GPIO_OUTPUT_CLR_REG , (PUINT) ucResetValue, sizeof(ULONG)); | ||
656 | |||
657 | if( Status != STATUS_SUCCESS) | ||
658 | { | ||
659 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_PRINTK, 0, 0,"WRM to BCM_GPIO_OUTPUT_CLR_REG Failed." ); | ||
660 | return Status; | ||
661 | } | ||
662 | } | ||
663 | |||
664 | if( pgpio_multi_info[WIMAX_IDX].uiGPIOMask) | ||
665 | { | ||
666 | Status = rdmaltWithLock(Adapter, (UINT)GPIO_PIN_STATE_REGISTER, (PUINT)ucResetValue, sizeof(UINT)); | ||
667 | |||
668 | if(Status != STATUS_SUCCESS) | ||
669 | { | ||
670 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_PRINTK, 0, 0,"RDM to GPIO_PIN_STATE_REGISTER Failed."); | ||
671 | return Status; | ||
672 | } | ||
673 | |||
674 | pgpio_multi_info[WIMAX_IDX].uiGPIOValue = ( *(UINT*)ucResetValue & | ||
675 | pgpio_multi_info[WIMAX_IDX].uiGPIOMask); | ||
676 | } | ||
677 | |||
678 | Status = copy_to_user( (PCHAR)IoBuffer.OutputBuffer, &gpio_multi_info, IoBuffer.OutputLength); | ||
679 | if(Status) | ||
680 | { | ||
681 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Failed while copying Content to IOBufer for user space err:%d",Status); | ||
682 | break; | ||
683 | } | ||
684 | } | ||
685 | break; | ||
686 | case IOCTL_BCM_GPIO_MODE_REQUEST: | ||
687 | { | ||
688 | UCHAR ucResetValue[4]; | ||
689 | GPIO_MULTI_MODE gpio_multi_mode[MAX_IDX]; | ||
690 | PGPIO_MULTI_MODE pgpio_multi_mode = ( PGPIO_MULTI_MODE) gpio_multi_mode; | ||
691 | |||
692 | if((Adapter->IdleMode == TRUE) || | ||
693 | (Adapter->bShutStatus ==TRUE) || | ||
694 | (Adapter->bPreparingForLowPowerMode ==TRUE)) | ||
695 | { | ||
696 | Status = -EINVAL; | ||
697 | break; | ||
698 | } | ||
699 | Status = copy_from_user( (PCHAR)&IoBuffer, ( PCHAR)arg, sizeof( IOCTL_BUFFER)); | ||
700 | if(Status) | ||
701 | { | ||
702 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Failed while copying the IOBufer from user space err:%d",Status); | ||
703 | break; | ||
704 | } | ||
705 | |||
706 | Status = copy_from_user( &gpio_multi_mode, IoBuffer.InputBuffer, IoBuffer.InputLength); | ||
707 | if(Status) | ||
708 | { | ||
709 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Failed while copying the IOBufer Contents from user space err:%d",Status); | ||
710 | break; | ||
711 | } | ||
712 | |||
713 | Status = rdmaltWithLock( Adapter, ( UINT) GPIO_MODE_REGISTER, ( PUINT) ucResetValue, sizeof( UINT)); | ||
714 | if( STATUS_SUCCESS != Status) | ||
715 | { | ||
716 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Read of GPIO_MODE_REGISTER failed"); | ||
717 | return Status; | ||
718 | } | ||
719 | |||
720 | //Validating the request | ||
721 | if(IsReqGpioIsLedInNVM(Adapter,pgpio_multi_mode[WIMAX_IDX].uiGPIOMask)== FALSE) | ||
722 | { | ||
723 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Sorry, Requested GPIO<0x%X> is not correspond to NVM LED bit map<0x%X>!!!",pgpio_multi_mode[WIMAX_IDX].uiGPIOMask,Adapter->gpioBitMap); | ||
724 | Status = -EINVAL; | ||
725 | break; | ||
726 | } | ||
727 | |||
728 | if( pgpio_multi_mode[WIMAX_IDX].uiGPIOMask) | ||
729 | { | ||
730 | /* write all OUT's (1's) */ | ||
731 | *( UINT*) ucResetValue |= ( pgpio_multi_mode[WIMAX_IDX].uiGPIOMode & | ||
732 | pgpio_multi_mode[WIMAX_IDX].uiGPIOMask); | ||
733 | /* write all IN's (0's) */ | ||
734 | *( UINT*) ucResetValue &= ~( ( ~pgpio_multi_mode[WIMAX_IDX].uiGPIOMode) & | ||
735 | pgpio_multi_mode[WIMAX_IDX].uiGPIOMask); | ||
736 | |||
737 | /* Currently implemented return the modes of all GPIO's | ||
738 | * else needs to bit AND with mask | ||
739 | * */ | ||
740 | pgpio_multi_mode[WIMAX_IDX].uiGPIOMode = *(UINT*)ucResetValue; | ||
741 | |||
742 | Status = wrmaltWithLock( Adapter, GPIO_MODE_REGISTER , ( PUINT) ucResetValue, sizeof( ULONG)); | ||
743 | if( Status == STATUS_SUCCESS) | ||
744 | { | ||
745 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "WRM to GPIO_MODE_REGISTER Done"); | ||
746 | } | ||
747 | else | ||
748 | { | ||
749 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_PRINTK, 0, 0,"WRM to GPIO_MODE_REGISTER Failed"); | ||
750 | Status = -EFAULT; | ||
751 | break; | ||
752 | } | ||
753 | } | ||
754 | else /* if uiGPIOMask is 0 then return mode register configuration */ | ||
755 | { | ||
756 | pgpio_multi_mode[WIMAX_IDX].uiGPIOMode = *( UINT*) ucResetValue; | ||
757 | } | ||
758 | Status = copy_to_user( (PCHAR)IoBuffer.OutputBuffer, &gpio_multi_mode, IoBuffer.OutputLength); | ||
759 | if(Status) | ||
760 | { | ||
761 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Failed while copying Content to IOBufer for user space err:%d",Status); | ||
762 | break; | ||
763 | } | ||
764 | } | ||
765 | break; | ||
766 | |||
767 | case IOCTL_MAC_ADDR_REQ: | ||
768 | case IOCTL_LINK_REQ: | ||
769 | case IOCTL_CM_REQUEST: | ||
770 | case IOCTL_SS_INFO_REQ: | ||
771 | case IOCTL_SEND_CONTROL_MESSAGE: | ||
772 | case IOCTL_IDLE_REQ: | ||
773 | { | ||
774 | PVOID pvBuffer=NULL; | ||
775 | /* Copy Ioctl Buffer structure */ | ||
776 | if(copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, | ||
777 | sizeof(IOCTL_BUFFER))) | ||
778 | { | ||
779 | Status = -EFAULT; | ||
780 | break; | ||
781 | } | ||
782 | pvBuffer=kmalloc(IoBuffer.InputLength, GFP_KERNEL); | ||
783 | if(!pvBuffer) | ||
784 | { | ||
785 | return -ENOMEM; | ||
786 | } | ||
787 | |||
788 | if(copy_from_user(pvBuffer, IoBuffer.InputBuffer, | ||
789 | IoBuffer.InputLength)) | ||
790 | { | ||
791 | Status = -EFAULT; | ||
792 | bcm_kfree(pvBuffer); | ||
793 | break; | ||
794 | } | ||
795 | |||
796 | down(&Adapter->LowPowerModeSync); | ||
797 | Status = wait_event_interruptible_timeout(Adapter->lowpower_mode_wait_queue, | ||
798 | !Adapter->bPreparingForLowPowerMode, | ||
799 | (1 * HZ)); | ||
800 | if(Status == -ERESTARTSYS) | ||
801 | goto cntrlEnd; | ||
802 | |||
803 | if(Adapter->bPreparingForLowPowerMode) | ||
804 | { | ||
805 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Preparing Idle Mode is still True - Hence Rejecting control message\n"); | ||
806 | Status = STATUS_FAILURE ; | ||
807 | goto cntrlEnd ; | ||
808 | } | ||
809 | Status = CopyBufferToControlPacket(Adapter, (PVOID)pvBuffer); | ||
810 | cntrlEnd: | ||
811 | up(&Adapter->LowPowerModeSync); | ||
812 | bcm_kfree(pvBuffer); | ||
813 | break; | ||
814 | } | ||
815 | #ifndef BCM_SHM_INTERFACE | ||
816 | case IOCTL_BCM_BUFFER_DOWNLOAD_START: | ||
817 | { | ||
818 | INT NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock) ; | ||
819 | if(NVMAccess) | ||
820 | { | ||
821 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, " IOCTL_BCM_CHIP_RESET not allowed as EEPROM Read/Write is in progress\n"); | ||
822 | return -EACCES; | ||
823 | } | ||
824 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Starting the firmware download PID =0x%x!!!!\n", current->pid); | ||
825 | if(!down_trylock(&Adapter->fw_download_sema)) | ||
826 | { | ||
827 | Adapter->bBinDownloaded=FALSE; | ||
828 | Adapter->fw_download_process_pid=current->pid; | ||
829 | Adapter->bCfgDownloaded=FALSE; | ||
830 | Adapter->fw_download_done=FALSE; | ||
831 | netif_carrier_off(Adapter->dev); | ||
832 | netif_stop_queue(Adapter->dev); | ||
833 | Status = reset_card_proc(Adapter); | ||
834 | if(Status) | ||
835 | { | ||
836 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "reset_card_proc Failed!\n"); | ||
837 | up(&Adapter->fw_download_sema); | ||
838 | up(&Adapter->NVMRdmWrmLock); | ||
839 | break; | ||
840 | } | ||
841 | mdelay(10); | ||
842 | } | ||
843 | else | ||
844 | { | ||
845 | |||
846 | Status = -EBUSY; | ||
847 | |||
848 | } | ||
849 | up(&Adapter->NVMRdmWrmLock); | ||
850 | break; | ||
851 | } | ||
852 | case IOCTL_BCM_BUFFER_DOWNLOAD: | ||
853 | { | ||
854 | FIRMWARE_INFO *psFwInfo=NULL; | ||
855 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Starting the firmware download PID =0x%x!!!!\n", current->pid); | ||
856 | do{ | ||
857 | if(!down_trylock(&Adapter->fw_download_sema)) | ||
858 | { | ||
859 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Invalid way to download buffer. Use Start and then call this!!!\n"); | ||
860 | Status=-EINVAL; | ||
861 | break; | ||
862 | } | ||
863 | /* Copy Ioctl Buffer structure */ | ||
864 | if(copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, | ||
865 | sizeof(IOCTL_BUFFER))) | ||
866 | { | ||
867 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "copy_from_user 1 failed\n"); | ||
868 | Status = -EFAULT; | ||
869 | break; | ||
870 | } | ||
871 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Length for FW DLD is : %lx\n", | ||
872 | IoBuffer.InputLength); | ||
873 | psFwInfo=kmalloc(sizeof(*psFwInfo), GFP_KERNEL); | ||
874 | if(!psFwInfo) | ||
875 | { | ||
876 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Failed to allocate buffer!!!!\n"); | ||
877 | Status = -ENOMEM; | ||
878 | break; | ||
879 | } | ||
880 | if(copy_from_user(psFwInfo, IoBuffer.InputBuffer, | ||
881 | IoBuffer.InputLength)) | ||
882 | { | ||
883 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy_from_user 2 failed\n"); | ||
884 | Status = -EFAULT; | ||
885 | break; | ||
886 | } | ||
887 | |||
888 | if(!psFwInfo->pvMappedFirmwareAddress || | ||
889 | (psFwInfo->u32FirmwareLength == 0)) | ||
890 | { | ||
891 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Something else is wrong %lu\n", | ||
892 | psFwInfo->u32FirmwareLength); | ||
893 | Status = -EINVAL; | ||
894 | break; | ||
895 | } | ||
896 | Status = bcm_ioctl_fw_download(Adapter, psFwInfo); | ||
897 | if(Status != STATUS_SUCCESS) | ||
898 | { | ||
899 | if(psFwInfo->u32StartingAddress==CONFIG_BEGIN_ADDR) | ||
900 | { | ||
901 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "IOCTL: Configuration File Upload Failed\n"); | ||
902 | } | ||
903 | else | ||
904 | { | ||
905 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "IOCTL: Firmware File Upload Failed\n"); | ||
906 | } | ||
907 | //up(&Adapter->fw_download_sema); | ||
908 | |||
909 | if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) | ||
910 | { | ||
911 | Adapter->DriverState = DRIVER_INIT; | ||
912 | Adapter->LEDInfo.bLedInitDone = FALSE; | ||
913 | wake_up(&Adapter->LEDInfo.notify_led_event); | ||
914 | } | ||
915 | } | ||
916 | break ; | ||
917 | }while(0); | ||
918 | |||
919 | if(Status != STATUS_SUCCESS) | ||
920 | up(&Adapter->fw_download_sema); | ||
921 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, OSAL_DBG, DBG_LVL_ALL, "IOCTL: Firmware File Uploaded\n"); | ||
922 | bcm_kfree(psFwInfo); | ||
923 | break; | ||
924 | } | ||
925 | case IOCTL_BCM_BUFFER_DOWNLOAD_STOP: | ||
926 | { | ||
927 | INT NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock); | ||
928 | if(NVMAccess) | ||
929 | { | ||
930 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, " FW download blocked as EEPROM Read/Write is in progress\n"); | ||
931 | up(&Adapter->fw_download_sema); | ||
932 | return -EACCES; | ||
933 | } | ||
934 | if(down_trylock(&Adapter->fw_download_sema)) | ||
935 | { | ||
936 | Adapter->bBinDownloaded=TRUE; | ||
937 | Adapter->bCfgDownloaded=TRUE; | ||
938 | atomic_set(&Adapter->CurrNumFreeTxDesc, 0); | ||
939 | atomic_set(&Adapter->RxRollOverCount, 0); | ||
940 | Adapter->CurrNumRecvDescs=0; | ||
941 | Adapter->downloadDDR = 0; | ||
942 | |||
943 | //setting the Mips to Run | ||
944 | Status = run_card_proc(Adapter); | ||
945 | if(Status) | ||
946 | { | ||
947 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Firm Download Failed\n"); | ||
948 | up(&Adapter->fw_download_sema); | ||
949 | up(&Adapter->NVMRdmWrmLock); | ||
950 | break; | ||
951 | } | ||
952 | else | ||
953 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Firm Download Over...\n"); | ||
954 | mdelay(10); | ||
955 | /* Wait for MailBox Interrupt */ | ||
956 | if(StartInterruptUrb((PS_INTERFACE_ADAPTER)Adapter->pvInterfaceAdapter)) | ||
957 | { | ||
958 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Unable to send interrupt...\n"); | ||
959 | } | ||
960 | timeout = 5*HZ; | ||
961 | Adapter->waiting_to_fw_download_done = FALSE; | ||
962 | wait_event_timeout(Adapter->ioctl_fw_dnld_wait_queue, | ||
963 | Adapter->waiting_to_fw_download_done, timeout); | ||
964 | Adapter->fw_download_process_pid=INVALID_PID; | ||
965 | Adapter->fw_download_done=TRUE; | ||
966 | atomic_set(&Adapter->CurrNumFreeTxDesc, 0); | ||
967 | Adapter->CurrNumRecvDescs = 0; | ||
968 | Adapter->PrevNumRecvDescs = 0; | ||
969 | atomic_set(&Adapter->cntrlpktCnt,0); | ||
970 | Adapter->LinkUpStatus = 0; | ||
971 | Adapter->LinkStatus = 0; | ||
972 | |||
973 | if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) | ||
974 | { | ||
975 | Adapter->DriverState = FW_DOWNLOAD_DONE; | ||
976 | wake_up(&Adapter->LEDInfo.notify_led_event); | ||
977 | } | ||
978 | |||
979 | if(!timeout) | ||
980 | { | ||
981 | Status = -ENODEV; | ||
982 | } | ||
983 | } | ||
984 | else | ||
985 | { | ||
986 | Status = -EINVAL; | ||
987 | } | ||
988 | up(&Adapter->fw_download_sema); | ||
989 | up(&Adapter->NVMRdmWrmLock); | ||
990 | break; | ||
991 | } | ||
992 | #endif | ||
993 | case IOCTL_BE_BUCKET_SIZE: | ||
994 | Adapter->BEBucketSize = *(PULONG)arg; | ||
995 | Status = STATUS_SUCCESS; | ||
996 | break; | ||
997 | |||
998 | case IOCTL_RTPS_BUCKET_SIZE: | ||
999 | Adapter->rtPSBucketSize = *(PULONG)arg; | ||
1000 | Status = STATUS_SUCCESS; | ||
1001 | break; | ||
1002 | case IOCTL_CHIP_RESET: | ||
1003 | { | ||
1004 | INT NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock); | ||
1005 | if(NVMAccess) | ||
1006 | { | ||
1007 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, " IOCTL_BCM_CHIP_RESET not allowed as EEPROM Read/Write is in progress\n"); | ||
1008 | return -EACCES; | ||
1009 | } | ||
1010 | down(&Adapter->RxAppControlQueuelock); | ||
1011 | Status = reset_card_proc(Adapter); | ||
1012 | flushAllAppQ(); | ||
1013 | up(&Adapter->RxAppControlQueuelock); | ||
1014 | up(&Adapter->NVMRdmWrmLock); | ||
1015 | ResetCounters(Adapter); | ||
1016 | break; | ||
1017 | } | ||
1018 | case IOCTL_QOS_THRESHOLD: | ||
1019 | { | ||
1020 | USHORT uiLoopIndex; | ||
1021 | for(uiLoopIndex = 0 ; uiLoopIndex < NO_OF_QUEUES ; uiLoopIndex++) | ||
1022 | { | ||
1023 | Adapter->PackInfo[uiLoopIndex].uiThreshold = *(PULONG)arg; | ||
1024 | } | ||
1025 | Status = STATUS_SUCCESS; | ||
1026 | break; | ||
1027 | } | ||
1028 | |||
1029 | case IOCTL_DUMP_PACKET_INFO: | ||
1030 | |||
1031 | DumpPackInfo(Adapter); | ||
1032 | DumpPhsRules(&Adapter->stBCMPhsContext); | ||
1033 | Status = STATUS_SUCCESS; | ||
1034 | break; | ||
1035 | |||
1036 | case IOCTL_GET_PACK_INFO: | ||
1037 | if(copy_to_user((PCHAR)arg, &Adapter->PackInfo, | ||
1038 | sizeof(PacketInfo)*NO_OF_QUEUES)) | ||
1039 | { | ||
1040 | Status = -EFAULT; | ||
1041 | break; | ||
1042 | } | ||
1043 | Status = STATUS_SUCCESS; | ||
1044 | break; | ||
1045 | case IOCTL_BCM_SWITCH_TRANSFER_MODE: | ||
1046 | { | ||
1047 | UINT uiData = 0; | ||
1048 | if(copy_from_user(&uiData, (PUINT)arg, sizeof(UINT))) | ||
1049 | { | ||
1050 | Status = -EFAULT; | ||
1051 | break; | ||
1052 | } | ||
1053 | if(uiData) /* Allow All Packets */ | ||
1054 | { | ||
1055 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_SWITCH_TRANSFER_MODE: ETH_PACKET_TUNNELING_MODE\n"); | ||
1056 | Adapter->TransferMode = ETH_PACKET_TUNNELING_MODE; | ||
1057 | } | ||
1058 | else /* Allow IP only Packets */ | ||
1059 | { | ||
1060 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_SWITCH_TRANSFER_MODE: IP_PACKET_ONLY_MODE\n"); | ||
1061 | Adapter->TransferMode = IP_PACKET_ONLY_MODE; | ||
1062 | } | ||
1063 | Status = STATUS_SUCCESS; | ||
1064 | break; | ||
1065 | } | ||
1066 | |||
1067 | case IOCTL_BCM_GET_DRIVER_VERSION: | ||
1068 | { | ||
1069 | /* Copy Ioctl Buffer structure */ | ||
1070 | if(copy_from_user((PCHAR)&IoBuffer, | ||
1071 | (PCHAR)arg, sizeof(IOCTL_BUFFER))) | ||
1072 | { | ||
1073 | Status = -EFAULT; | ||
1074 | break; | ||
1075 | } | ||
1076 | if(copy_to_user((PUCHAR)IoBuffer.OutputBuffer, | ||
1077 | VER_FILEVERSION_STR, (UINT)IoBuffer.OutputLength)) | ||
1078 | { | ||
1079 | Status = -EFAULT; | ||
1080 | break; | ||
1081 | } | ||
1082 | Status = STATUS_SUCCESS; | ||
1083 | break; | ||
1084 | } | ||
1085 | case IOCTL_BCM_GET_CURRENT_STATUS: | ||
1086 | { | ||
1087 | LINK_STATE *plink_state = NULL; | ||
1088 | /* Copy Ioctl Buffer structure */ | ||
1089 | if(copy_from_user((PCHAR)&IoBuffer, | ||
1090 | (PCHAR)arg, sizeof(IOCTL_BUFFER))) | ||
1091 | { | ||
1092 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "copy_from_user failed..\n"); | ||
1093 | Status = -EFAULT; | ||
1094 | break; | ||
1095 | } | ||
1096 | plink_state = (LINK_STATE*)arg; | ||
1097 | plink_state->bIdleMode = (UCHAR)Adapter->IdleMode; | ||
1098 | plink_state->bShutdownMode = Adapter->bShutStatus; | ||
1099 | plink_state->ucLinkStatus = (UCHAR)Adapter->LinkStatus; | ||
1100 | if(copy_to_user((PUCHAR)IoBuffer.OutputBuffer, | ||
1101 | (PUCHAR)plink_state, (UINT)IoBuffer.OutputLength)) | ||
1102 | { | ||
1103 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy_to_user Failed..\n"); | ||
1104 | Status = -EFAULT; | ||
1105 | break; | ||
1106 | } | ||
1107 | Status = STATUS_SUCCESS; | ||
1108 | break; | ||
1109 | } | ||
1110 | case IOCTL_BCM_SET_MAC_TRACING: | ||
1111 | { | ||
1112 | UINT tracing_flag; | ||
1113 | /* copy ioctl Buffer structure */ | ||
1114 | if(copy_from_user((PCHAR)&IoBuffer, | ||
1115 | (PCHAR)arg, sizeof(IOCTL_BUFFER))) | ||
1116 | { | ||
1117 | Status = -EFAULT; | ||
1118 | break; | ||
1119 | } | ||
1120 | if(copy_from_user((PCHAR)&tracing_flag, | ||
1121 | (PCHAR)IoBuffer.InputBuffer,sizeof(UINT))) | ||
1122 | { | ||
1123 | Status = -EFAULT; | ||
1124 | break; | ||
1125 | } | ||
1126 | if (tracing_flag) | ||
1127 | Adapter->pTarangs->MacTracingEnabled = TRUE; | ||
1128 | else | ||
1129 | Adapter->pTarangs->MacTracingEnabled = FALSE; | ||
1130 | break; | ||
1131 | } | ||
1132 | case IOCTL_BCM_GET_DSX_INDICATION: | ||
1133 | { | ||
1134 | ULONG ulSFId=0; | ||
1135 | if(copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, | ||
1136 | sizeof(IOCTL_BUFFER))) | ||
1137 | { | ||
1138 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Invalid IO buffer!!!" ); | ||
1139 | Status = -EFAULT; | ||
1140 | break; | ||
1141 | } | ||
1142 | if(IoBuffer.OutputLength < sizeof(stLocalSFAddIndicationAlt)) | ||
1143 | { | ||
1144 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Mismatch req: %lx needed is =0x%x!!!", | ||
1145 | IoBuffer.OutputLength, sizeof(stLocalSFAddIndicationAlt)); | ||
1146 | return -EINVAL; | ||
1147 | } | ||
1148 | if(copy_from_user((PCHAR)&ulSFId, (PCHAR)IoBuffer.InputBuffer, | ||
1149 | sizeof(ulSFId))) | ||
1150 | { | ||
1151 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Invalid SFID!!! %lu", ulSFId ); | ||
1152 | Status = -EFAULT; | ||
1153 | break; | ||
1154 | } | ||
1155 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Get DSX Data SF ID is =%lx\n", ulSFId ); | ||
1156 | get_dsx_sf_data_to_application(Adapter, ulSFId, | ||
1157 | IoBuffer.OutputBuffer); | ||
1158 | Status=STATUS_SUCCESS; | ||
1159 | } | ||
1160 | break; | ||
1161 | case IOCTL_BCM_GET_HOST_MIBS: | ||
1162 | { | ||
1163 | PCHAR temp_buff; | ||
1164 | |||
1165 | if(copy_from_user((PCHAR)&IoBuffer, | ||
1166 | (PCHAR)arg, sizeof(IOCTL_BUFFER))) | ||
1167 | { | ||
1168 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy_from user for IoBuff failed\n"); | ||
1169 | Status = -EFAULT; | ||
1170 | break; | ||
1171 | } | ||
1172 | |||
1173 | if(IoBuffer.OutputLength != sizeof(S_MIBS_HOST_STATS_MIBS)) | ||
1174 | { | ||
1175 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Length Check failed %lu %d\n", IoBuffer.OutputLength, | ||
1176 | sizeof(S_MIBS_HOST_STATS_MIBS)); | ||
1177 | return -EINVAL; | ||
1178 | } | ||
1179 | |||
1180 | temp_buff = (PCHAR)kmalloc(IoBuffer.OutputLength, GFP_KERNEL); | ||
1181 | |||
1182 | if(!temp_buff) | ||
1183 | { | ||
1184 | return STATUS_FAILURE; | ||
1185 | } | ||
1186 | |||
1187 | Status = ProcessGetHostMibs(Adapter, | ||
1188 | (PUCHAR)temp_buff, IoBuffer.OutputLength); | ||
1189 | |||
1190 | Status = GetDroppedAppCntrlPktMibs((PVOID)temp_buff, | ||
1191 | (PPER_TARANG_DATA)filp->private_data); | ||
1192 | |||
1193 | if(copy_to_user((PCHAR)IoBuffer.OutputBuffer,(PCHAR)temp_buff, | ||
1194 | sizeof(S_MIBS_HOST_STATS_MIBS))) | ||
1195 | { | ||
1196 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy to user failed\n"); | ||
1197 | bcm_kfree(temp_buff); | ||
1198 | return -EFAULT; | ||
1199 | } | ||
1200 | |||
1201 | bcm_kfree(temp_buff); | ||
1202 | break; | ||
1203 | } | ||
1204 | |||
1205 | case IOCTL_BCM_WAKE_UP_DEVICE_FROM_IDLE: | ||
1206 | if((FALSE == Adapter->bTriedToWakeUpFromlowPowerMode) && (TRUE==Adapter->IdleMode)) | ||
1207 | { | ||
1208 | Adapter->usIdleModePattern = ABORT_IDLE_MODE; | ||
1209 | Adapter->bWakeUpDevice = TRUE; | ||
1210 | wake_up(&Adapter->process_rx_cntrlpkt); | ||
1211 | #if 0 | ||
1212 | Adapter->bTriedToWakeUpFromlowPowerMode = TRUE; | ||
1213 | InterfaceAbortIdlemode (Adapter, Adapter->usIdleModePattern); | ||
1214 | #endif | ||
1215 | } | ||
1216 | Status = STATUS_SUCCESS; | ||
1217 | break; | ||
1218 | |||
1219 | case IOCTL_BCM_BULK_WRM: | ||
1220 | { | ||
1221 | PBULKWRM_BUFFER pBulkBuffer; | ||
1222 | UINT uiTempVar=0; | ||
1223 | PCHAR pvBuffer = NULL; | ||
1224 | |||
1225 | if((Adapter->IdleMode == TRUE) || | ||
1226 | (Adapter->bShutStatus ==TRUE) || | ||
1227 | (Adapter->bPreparingForLowPowerMode ==TRUE)) | ||
1228 | { | ||
1229 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "Device in Idle/Shutdown Mode, Blocking Wrms\n"); | ||
1230 | Status = -EACCES; | ||
1231 | break; | ||
1232 | } | ||
1233 | /* Copy Ioctl Buffer structure */ | ||
1234 | if(copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER))) | ||
1235 | { | ||
1236 | Status = -EFAULT; | ||
1237 | break; | ||
1238 | } | ||
1239 | |||
1240 | pvBuffer=kmalloc(IoBuffer.InputLength, GFP_KERNEL); | ||
1241 | if(!pvBuffer) | ||
1242 | { | ||
1243 | return -ENOMEM; | ||
1244 | break; | ||
1245 | } | ||
1246 | |||
1247 | /* Get WrmBuffer structure */ | ||
1248 | if(copy_from_user(pvBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) | ||
1249 | { | ||
1250 | bcm_kfree(pvBuffer); | ||
1251 | Status = -EFAULT; | ||
1252 | break; | ||
1253 | } | ||
1254 | |||
1255 | pBulkBuffer = (PBULKWRM_BUFFER)pvBuffer; | ||
1256 | |||
1257 | if(((ULONG)pBulkBuffer->Register & 0x0F000000) != 0x0F000000 || | ||
1258 | ((ULONG)pBulkBuffer->Register & 0x3)) | ||
1259 | { | ||
1260 | bcm_kfree(pvBuffer); | ||
1261 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0,"WRM Done On invalid Address : %x Access Denied.\n",(int)pBulkBuffer->Register); | ||
1262 | Status = -EINVAL; | ||
1263 | break; | ||
1264 | } | ||
1265 | |||
1266 | |||
1267 | uiTempVar = pBulkBuffer->Register & EEPROM_REJECT_MASK; | ||
1268 | if(!((Adapter->pstargetparams->m_u32Customize)&VSG_MODE) | ||
1269 | && ((uiTempVar == EEPROM_REJECT_REG_1)|| | ||
1270 | (uiTempVar == EEPROM_REJECT_REG_2) || | ||
1271 | (uiTempVar == EEPROM_REJECT_REG_3) || | ||
1272 | (uiTempVar == EEPROM_REJECT_REG_4)) && | ||
1273 | (cmd == IOCTL_BCM_REGISTER_WRITE)) | ||
1274 | { | ||
1275 | bcm_kfree(pvBuffer); | ||
1276 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0,"EEPROM Access Denied, not in VSG Mode\n"); | ||
1277 | Status = -EFAULT; | ||
1278 | break; | ||
1279 | } | ||
1280 | |||
1281 | if(pBulkBuffer->SwapEndian == FALSE) | ||
1282 | Status = wrmWithLock(Adapter, (UINT)pBulkBuffer->Register, (PCHAR)pBulkBuffer->Values, IoBuffer.InputLength - 2*sizeof(ULONG)); | ||
1283 | else | ||
1284 | Status = wrmaltWithLock(Adapter, (UINT)pBulkBuffer->Register, (PUINT)pBulkBuffer->Values, IoBuffer.InputLength - 2*sizeof(ULONG)); | ||
1285 | |||
1286 | if(Status != STATUS_SUCCESS) | ||
1287 | { | ||
1288 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "WRM Failed\n"); | ||
1289 | } | ||
1290 | |||
1291 | bcm_kfree(pvBuffer); | ||
1292 | break; | ||
1293 | } | ||
1294 | |||
1295 | case IOCTL_BCM_GET_NVM_SIZE: | ||
1296 | { | ||
1297 | |||
1298 | if(copy_from_user((unsigned char *)&IoBuffer, | ||
1299 | (unsigned char *)arg, sizeof(IOCTL_BUFFER))) | ||
1300 | { | ||
1301 | //IOLog("failed NVM first"); | ||
1302 | Status = -EFAULT; | ||
1303 | break; | ||
1304 | } | ||
1305 | if(Adapter->eNVMType == NVM_EEPROM || Adapter->eNVMType == NVM_FLASH ) { | ||
1306 | if(copy_to_user(IoBuffer.OutputBuffer, | ||
1307 | (unsigned char *)&Adapter->uiNVMDSDSize, (UINT)sizeof(UINT))) | ||
1308 | { | ||
1309 | Status = -EFAULT; | ||
1310 | return Status; | ||
1311 | } | ||
1312 | } | ||
1313 | |||
1314 | Status = STATUS_SUCCESS ; | ||
1315 | } | ||
1316 | break; | ||
1317 | |||
1318 | case IOCTL_BCM_CAL_INIT : | ||
1319 | |||
1320 | { | ||
1321 | UINT uiSectorSize = 0 ; | ||
1322 | if(Adapter->eNVMType == NVM_FLASH) | ||
1323 | { | ||
1324 | Status = copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER)); | ||
1325 | if(Status) | ||
1326 | { | ||
1327 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Copy From User space failed. status :%d", Status); | ||
1328 | return Status; | ||
1329 | } | ||
1330 | uiSectorSize = *((PUINT)(IoBuffer.InputBuffer)); | ||
1331 | if((uiSectorSize < MIN_SECTOR_SIZE) || (uiSectorSize > MAX_SECTOR_SIZE)) | ||
1332 | { | ||
1333 | |||
1334 | Status = copy_to_user(IoBuffer.OutputBuffer, | ||
1335 | (unsigned char *)&Adapter->uiSectorSize , | ||
1336 | (UINT)sizeof(UINT)); | ||
1337 | if(Status) | ||
1338 | { | ||
1339 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Coping the sector size to use space failed. status:%d",Status); | ||
1340 | return Status; | ||
1341 | } | ||
1342 | } | ||
1343 | else | ||
1344 | { | ||
1345 | if(IsFlash2x(Adapter)) | ||
1346 | { | ||
1347 | Status = copy_to_user(IoBuffer.OutputBuffer, | ||
1348 | (unsigned char *)&Adapter->uiSectorSize , | ||
1349 | (UINT)sizeof(UINT)); | ||
1350 | if(Status) | ||
1351 | { | ||
1352 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Coping the sector size to use space failed. status:%d",Status); | ||
1353 | return Status; | ||
1354 | } | ||
1355 | |||
1356 | } | ||
1357 | else | ||
1358 | { | ||
1359 | if((TRUE == Adapter->bShutStatus) || | ||
1360 | (TRUE == Adapter->IdleMode)) | ||
1361 | { | ||
1362 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Device is in Idle/Shutdown Mode\n"); | ||
1363 | return -EACCES; | ||
1364 | } | ||
1365 | |||
1366 | Adapter->uiSectorSize = uiSectorSize ; | ||
1367 | BcmUpdateSectorSize(Adapter,Adapter->uiSectorSize); | ||
1368 | } | ||
1369 | } | ||
1370 | Status = STATUS_SUCCESS ; | ||
1371 | } | ||
1372 | else | ||
1373 | { | ||
1374 | Status = STATUS_FAILURE; | ||
1375 | } | ||
1376 | } | ||
1377 | break; | ||
1378 | case IOCTL_BCM_SET_DEBUG : | ||
1379 | { | ||
1380 | USER_BCM_DBG_STATE sUserDebugState; | ||
1381 | |||
1382 | // BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "Entered the ioctl %x \n", IOCTL_BCM_SET_DEBUG ); | ||
1383 | |||
1384 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "In SET_DEBUG ioctl\n"); | ||
1385 | Status = copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER)); | ||
1386 | if(Status) | ||
1387 | { | ||
1388 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy from user failed\n"); | ||
1389 | break; | ||
1390 | } | ||
1391 | Status = copy_from_user(&sUserDebugState,(USER_BCM_DBG_STATE *)IoBuffer.InputBuffer, sizeof(USER_BCM_DBG_STATE)); | ||
1392 | if(Status) | ||
1393 | { | ||
1394 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of IoBuffer.InputBuffer failed"); | ||
1395 | return Status; | ||
1396 | } | ||
1397 | |||
1398 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "IOCTL_BCM_SET_DEBUG: OnOff=%d Type = 0x%x ", | ||
1399 | sUserDebugState.OnOff, sUserDebugState.Type); | ||
1400 | //sUserDebugState.Subtype <<= 1; | ||
1401 | sUserDebugState.Subtype = 1 << sUserDebugState.Subtype; | ||
1402 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "actual Subtype=0x%x\n", sUserDebugState.Subtype); | ||
1403 | |||
1404 | // Update new 'DebugState' in the Adapter | ||
1405 | Adapter->stDebugState.type |= sUserDebugState.Type; | ||
1406 | /* Subtype: A bitmap of 32 bits for Subtype per Type. | ||
1407 | * Valid indexes in 'subtype' array: 1,2,4,8 | ||
1408 | * corresponding to valid Type values. Hence we can use the 'Type' field | ||
1409 | * as the index value, ignoring the array entries 0,3,5,6,7 ! | ||
1410 | */ | ||
1411 | if (sUserDebugState.OnOff) | ||
1412 | Adapter->stDebugState.subtype[sUserDebugState.Type] |= sUserDebugState.Subtype; | ||
1413 | else | ||
1414 | Adapter->stDebugState.subtype[sUserDebugState.Type] &= ~sUserDebugState.Subtype; | ||
1415 | |||
1416 | BCM_SHOW_DEBUG_BITMAP(Adapter); | ||
1417 | |||
1418 | } | ||
1419 | break; | ||
1420 | case IOCTL_BCM_NVM_READ: | ||
1421 | case IOCTL_BCM_NVM_WRITE: | ||
1422 | { | ||
1423 | |||
1424 | NVM_READWRITE stNVMReadWrite = {0}; | ||
1425 | PUCHAR pReadData = NULL; | ||
1426 | PUCHAR pBuffertobeCopied = NULL; | ||
1427 | ULONG ulDSDMagicNumInUsrBuff = 0 ; | ||
1428 | struct timeval tv0, tv1; | ||
1429 | memset(&tv0,0,sizeof(struct timeval)); | ||
1430 | memset(&tv1,0,sizeof(struct timeval)); | ||
1431 | if((Adapter->eNVMType == NVM_FLASH) && (Adapter->uiFlashLayoutMajorVersion == 0)) | ||
1432 | { | ||
1433 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0,"The Flash Control Section is Corrupted. Hence Rejection on NVM Read/Write\n"); | ||
1434 | Status = -EFAULT; | ||
1435 | break; | ||
1436 | } | ||
1437 | |||
1438 | if(IsFlash2x(Adapter)) | ||
1439 | { | ||
1440 | if((Adapter->eActiveDSD != DSD0) && | ||
1441 | (Adapter->eActiveDSD != DSD1) && | ||
1442 | (Adapter->eActiveDSD != DSD2)) | ||
1443 | { | ||
1444 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"No DSD is active..hence NVM Command is blocked"); | ||
1445 | return STATUS_FAILURE ; | ||
1446 | } | ||
1447 | } | ||
1448 | |||
1449 | /* Copy Ioctl Buffer structure */ | ||
1450 | |||
1451 | if(copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER))) | ||
1452 | { | ||
1453 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"copy_from_user failed\n"); | ||
1454 | Status = -EFAULT; | ||
1455 | break; | ||
1456 | } | ||
1457 | if(IOCTL_BCM_NVM_READ == cmd) | ||
1458 | pBuffertobeCopied = IoBuffer.OutputBuffer; | ||
1459 | else | ||
1460 | pBuffertobeCopied = IoBuffer.InputBuffer; | ||
1461 | |||
1462 | if(copy_from_user(&stNVMReadWrite, pBuffertobeCopied,sizeof(NVM_READWRITE))) | ||
1463 | { | ||
1464 | Status = -EFAULT; | ||
1465 | break; | ||
1466 | } | ||
1467 | |||
1468 | // | ||
1469 | // Deny the access if the offset crosses the cal area limit. | ||
1470 | // | ||
1471 | if((stNVMReadWrite.uiOffset + stNVMReadWrite.uiNumBytes) > Adapter->uiNVMDSDSize) | ||
1472 | { | ||
1473 | //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Can't allow access beyond NVM Size: 0x%x 0x%x\n", stNVMReadWrite.uiOffset , | ||
1474 | // stNVMReadWrite.uiNumBytes); | ||
1475 | Status = STATUS_FAILURE; | ||
1476 | break; | ||
1477 | } | ||
1478 | |||
1479 | pReadData =(PCHAR)kmalloc(stNVMReadWrite.uiNumBytes, GFP_KERNEL); | ||
1480 | |||
1481 | if(!pReadData) | ||
1482 | return -ENOMEM; | ||
1483 | |||
1484 | memset(pReadData,0,stNVMReadWrite.uiNumBytes); | ||
1485 | |||
1486 | if(copy_from_user(pReadData, stNVMReadWrite.pBuffer, | ||
1487 | stNVMReadWrite.uiNumBytes)) | ||
1488 | { | ||
1489 | Status = -EFAULT; | ||
1490 | bcm_kfree(pReadData); | ||
1491 | break; | ||
1492 | } | ||
1493 | |||
1494 | do_gettimeofday(&tv0); | ||
1495 | if(IOCTL_BCM_NVM_READ == cmd) | ||
1496 | { | ||
1497 | down(&Adapter->NVMRdmWrmLock); | ||
1498 | |||
1499 | if((Adapter->IdleMode == TRUE) || | ||
1500 | (Adapter->bShutStatus ==TRUE) || | ||
1501 | (Adapter->bPreparingForLowPowerMode ==TRUE)) | ||
1502 | { | ||
1503 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n"); | ||
1504 | up(&Adapter->NVMRdmWrmLock); | ||
1505 | bcm_kfree(pReadData); | ||
1506 | return -EACCES; | ||
1507 | } | ||
1508 | |||
1509 | Status = BeceemNVMRead(Adapter, (PUINT)pReadData, | ||
1510 | stNVMReadWrite.uiOffset, stNVMReadWrite.uiNumBytes); | ||
1511 | |||
1512 | up(&Adapter->NVMRdmWrmLock); | ||
1513 | |||
1514 | if(Status != STATUS_SUCCESS) | ||
1515 | { | ||
1516 | bcm_kfree(pReadData); | ||
1517 | return Status; | ||
1518 | } | ||
1519 | if(copy_to_user((PCHAR)stNVMReadWrite.pBuffer, | ||
1520 | (PCHAR)pReadData, (UINT)stNVMReadWrite.uiNumBytes)) | ||
1521 | { | ||
1522 | bcm_kfree(pReadData); | ||
1523 | Status = -EFAULT; | ||
1524 | } | ||
1525 | } | ||
1526 | else | ||
1527 | { | ||
1528 | |||
1529 | down(&Adapter->NVMRdmWrmLock); | ||
1530 | |||
1531 | if((Adapter->IdleMode == TRUE) || | ||
1532 | (Adapter->bShutStatus ==TRUE) || | ||
1533 | (Adapter->bPreparingForLowPowerMode ==TRUE)) | ||
1534 | { | ||
1535 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n"); | ||
1536 | up(&Adapter->NVMRdmWrmLock); | ||
1537 | bcm_kfree(pReadData); | ||
1538 | return -EACCES; | ||
1539 | } | ||
1540 | |||
1541 | Adapter->bHeaderChangeAllowed = TRUE ; | ||
1542 | if(IsFlash2x(Adapter)) | ||
1543 | { | ||
1544 | /* | ||
1545 | New Requirement:- | ||
1546 | DSD section updation will be allowed in two case:- | ||
1547 | 1. if DSD sig is present in DSD header means dongle is ok and updation is fruitfull | ||
1548 | 2. if point 1 failes then user buff should have DSD sig. this point ensures that if dongle is | ||
1549 | corrupted then user space program first modify the DSD header with valid DSD sig so | ||
1550 | that this as well as further write may be worthwhile. | ||
1551 | |||
1552 | This restriction has been put assuming that if DSD sig is corrupted, DSD | ||
1553 | data won't be considered valid. | ||
1554 | |||
1555 | |||
1556 | */ | ||
1557 | Status = BcmFlash2xCorruptSig(Adapter,Adapter->eActiveDSD); | ||
1558 | if(Status != STATUS_SUCCESS) | ||
1559 | { | ||
1560 | if(( (stNVMReadWrite.uiOffset + stNVMReadWrite.uiNumBytes) != Adapter->uiNVMDSDSize ) || | ||
1561 | (stNVMReadWrite.uiNumBytes < SIGNATURE_SIZE)) | ||
1562 | { | ||
1563 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"DSD Sig is present neither in Flash nor User provided Input.."); | ||
1564 | up(&Adapter->NVMRdmWrmLock); | ||
1565 | bcm_kfree(pReadData); | ||
1566 | return Status; | ||
1567 | } | ||
1568 | |||
1569 | ulDSDMagicNumInUsrBuff = ntohl(*(PUINT)(pReadData + stNVMReadWrite.uiNumBytes - SIGNATURE_SIZE)); | ||
1570 | if(ulDSDMagicNumInUsrBuff != DSD_IMAGE_MAGIC_NUMBER) | ||
1571 | { | ||
1572 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"DSD Sig is present neither in Flash nor User provided Input.."); | ||
1573 | up(&Adapter->NVMRdmWrmLock); | ||
1574 | bcm_kfree(pReadData); | ||
1575 | return Status; | ||
1576 | } | ||
1577 | } | ||
1578 | } | ||
1579 | Status = BeceemNVMWrite(Adapter, (PUINT )pReadData, | ||
1580 | stNVMReadWrite.uiOffset, stNVMReadWrite.uiNumBytes, stNVMReadWrite.bVerify); | ||
1581 | if(IsFlash2x(Adapter)) | ||
1582 | BcmFlash2xWriteSig(Adapter,Adapter->eActiveDSD); | ||
1583 | |||
1584 | Adapter->bHeaderChangeAllowed = FALSE ; | ||
1585 | |||
1586 | up(&Adapter->NVMRdmWrmLock); | ||
1587 | |||
1588 | |||
1589 | if(Status != STATUS_SUCCESS) | ||
1590 | { | ||
1591 | bcm_kfree(pReadData); | ||
1592 | return Status; | ||
1593 | } | ||
1594 | } | ||
1595 | do_gettimeofday(&tv1); | ||
1596 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, " timetaken by Write/read :%ld msec\n",(tv1.tv_sec - tv0.tv_sec)*1000 +(tv1.tv_usec - tv0.tv_usec)/1000); | ||
1597 | |||
1598 | |||
1599 | bcm_kfree(pReadData); | ||
1600 | Status = STATUS_SUCCESS; | ||
1601 | } | ||
1602 | break; | ||
1603 | case IOCTL_BCM_FLASH2X_SECTION_READ : | ||
1604 | { | ||
1605 | |||
1606 | FLASH2X_READWRITE sFlash2xRead = {0}; | ||
1607 | PUCHAR pReadBuff = NULL ; | ||
1608 | UINT NOB = 0; | ||
1609 | UINT BuffSize = 0; | ||
1610 | UINT ReadBytes = 0; | ||
1611 | UINT ReadOffset = 0; | ||
1612 | PUCHAR OutPutBuff = NULL; | ||
1613 | |||
1614 | if(IsFlash2x(Adapter) != TRUE) | ||
1615 | { | ||
1616 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Flash Does not have 2.x map"); | ||
1617 | return -EINVAL; | ||
1618 | } | ||
1619 | |||
1620 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_FLASH2X_SECTION_READ Called"); | ||
1621 | Status = copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER)); | ||
1622 | if(Status) | ||
1623 | { | ||
1624 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); | ||
1625 | return Status ; | ||
1626 | } | ||
1627 | |||
1628 | //Reading FLASH 2.x READ structure | ||
1629 | Status = copy_from_user((PUCHAR)&sFlash2xRead, (PUCHAR)IoBuffer.InputBuffer,sizeof(FLASH2X_READWRITE)); | ||
1630 | if(Status) | ||
1631 | { | ||
1632 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of Input Buffer failed"); | ||
1633 | return Status ; | ||
1634 | } | ||
1635 | |||
1636 | |||
1637 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\nsFlash2xRead.Section :%x" ,sFlash2xRead.Section); | ||
1638 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\nsFlash2xRead.offset :%x" ,sFlash2xRead.offset); | ||
1639 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\nsFlash2xRead.numOfBytes :%x" ,sFlash2xRead.numOfBytes); | ||
1640 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\nsFlash2xRead.bVerify :%x\n" ,sFlash2xRead.bVerify); | ||
1641 | |||
1642 | //This was internal to driver for raw read. now it has ben exposed to user space app. | ||
1643 | if(validateFlash2xReadWrite(Adapter,&sFlash2xRead) == FALSE) | ||
1644 | return STATUS_FAILURE ; | ||
1645 | |||
1646 | NOB = sFlash2xRead.numOfBytes; | ||
1647 | if(NOB > Adapter->uiSectorSize ) | ||
1648 | BuffSize = Adapter->uiSectorSize; | ||
1649 | else | ||
1650 | BuffSize = NOB ; | ||
1651 | |||
1652 | ReadOffset = sFlash2xRead.offset ; | ||
1653 | OutPutBuff = (PUCHAR)(IoBuffer.OutputBuffer) ; | ||
1654 | |||
1655 | |||
1656 | pReadBuff = (PCHAR)kzalloc(BuffSize , GFP_KERNEL); | ||
1657 | if(pReadBuff == NULL) | ||
1658 | { | ||
1659 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Memory allocation failed for Flash 2.x Read Structure"); | ||
1660 | return -ENOMEM; | ||
1661 | } | ||
1662 | down(&Adapter->NVMRdmWrmLock); | ||
1663 | |||
1664 | if((Adapter->IdleMode == TRUE) || | ||
1665 | (Adapter->bShutStatus ==TRUE) || | ||
1666 | (Adapter->bPreparingForLowPowerMode ==TRUE)) | ||
1667 | { | ||
1668 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n"); | ||
1669 | up(&Adapter->NVMRdmWrmLock); | ||
1670 | bcm_kfree(pReadBuff); | ||
1671 | return -EACCES; | ||
1672 | } | ||
1673 | |||
1674 | while(NOB) | ||
1675 | { | ||
1676 | |||
1677 | if(NOB > Adapter->uiSectorSize ) | ||
1678 | ReadBytes = Adapter->uiSectorSize; | ||
1679 | else | ||
1680 | ReadBytes = NOB; | ||
1681 | |||
1682 | |||
1683 | //Reading the data from Flash 2.x | ||
1684 | |||
1685 | Status = BcmFlash2xBulkRead(Adapter,(PUINT)pReadBuff,sFlash2xRead.Section,ReadOffset,ReadBytes); | ||
1686 | if(Status) | ||
1687 | { | ||
1688 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Flash 2x read err with Status :%d", Status); | ||
1689 | break ; | ||
1690 | } | ||
1691 | |||
1692 | BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,pReadBuff, ReadBytes); | ||
1693 | |||
1694 | Status = copy_to_user(OutPutBuff, pReadBuff,ReadBytes); | ||
1695 | if(Status) | ||
1696 | { | ||
1697 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Copy to use failed with status :%d", Status); | ||
1698 | break; | ||
1699 | } | ||
1700 | NOB = NOB - ReadBytes; | ||
1701 | if(NOB) | ||
1702 | { | ||
1703 | ReadOffset = ReadOffset + ReadBytes ; | ||
1704 | OutPutBuff = OutPutBuff + ReadBytes ; | ||
1705 | } | ||
1706 | |||
1707 | } | ||
1708 | up(&Adapter->NVMRdmWrmLock); | ||
1709 | bcm_kfree(pReadBuff); | ||
1710 | |||
1711 | } | ||
1712 | break ; | ||
1713 | case IOCTL_BCM_FLASH2X_SECTION_WRITE : | ||
1714 | { | ||
1715 | FLASH2X_READWRITE sFlash2xWrite = {0}; | ||
1716 | PUCHAR pWriteBuff = NULL; | ||
1717 | PUCHAR InputAddr = NULL; | ||
1718 | UINT NOB = 0; | ||
1719 | UINT BuffSize = 0; | ||
1720 | UINT WriteOffset = 0; | ||
1721 | UINT WriteBytes = 0; | ||
1722 | |||
1723 | if(IsFlash2x(Adapter) != TRUE) | ||
1724 | { | ||
1725 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Flash Does not have 2.x map"); | ||
1726 | return -EINVAL; | ||
1727 | } | ||
1728 | |||
1729 | //First make this False so that we can enable the Sector Permission Check in BeceemFlashBulkWrite | ||
1730 | Adapter->bAllDSDWriteAllow = FALSE; | ||
1731 | |||
1732 | |||
1733 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, " IOCTL_BCM_FLASH2X_SECTION_WRITE Called"); | ||
1734 | Status = copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER)); | ||
1735 | if(Status) | ||
1736 | { | ||
1737 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); | ||
1738 | return Status; | ||
1739 | } | ||
1740 | |||
1741 | //Reading FLASH 2.x READ structure | ||
1742 | Status = copy_from_user((PCHAR)&sFlash2xWrite, (PCHAR)IoBuffer.InputBuffer, sizeof(FLASH2X_READWRITE)); | ||
1743 | if(Status) | ||
1744 | { | ||
1745 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Reading of output Buffer from IOCTL buffer fails"); | ||
1746 | return Status; | ||
1747 | } | ||
1748 | |||
1749 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\nsFlash2xRead.Section :%x" ,sFlash2xWrite.Section); | ||
1750 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\nsFlash2xRead.offset :%d" ,sFlash2xWrite.offset); | ||
1751 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\nsFlash2xRead.numOfBytes :%x" ,sFlash2xWrite.numOfBytes); | ||
1752 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\nsFlash2xRead.bVerify :%x\n" ,sFlash2xWrite.bVerify); | ||
1753 | #if 0 | ||
1754 | if((sFlash2xWrite.Section == ISO_IMAGE1) ||(sFlash2xWrite.Section == ISO_IMAGE2) || | ||
1755 | (sFlash2xWrite.Section == DSD0) || (sFlash2xWrite.Section == DSD1) || (sFlash2xWrite.Section == DSD2)) | ||
1756 | { | ||
1757 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"ISO/DSD Image write is not allowed.... "); | ||
1758 | return STATUS_FAILURE ; | ||
1759 | } | ||
1760 | #endif | ||
1761 | if((sFlash2xWrite.Section != VSA0) && (sFlash2xWrite.Section != VSA1) && | ||
1762 | (sFlash2xWrite.Section != VSA2) ) | ||
1763 | { | ||
1764 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Only VSA write is allowed"); | ||
1765 | return -EINVAL; | ||
1766 | } | ||
1767 | |||
1768 | if(validateFlash2xReadWrite(Adapter,&sFlash2xWrite) == FALSE) | ||
1769 | return STATUS_FAILURE ; | ||
1770 | |||
1771 | InputAddr = (PCHAR)(sFlash2xWrite.pDataBuff) ; | ||
1772 | WriteOffset = sFlash2xWrite.offset ; | ||
1773 | NOB = sFlash2xWrite.numOfBytes; | ||
1774 | |||
1775 | if(NOB > Adapter->uiSectorSize ) | ||
1776 | BuffSize = Adapter->uiSectorSize; | ||
1777 | else | ||
1778 | BuffSize = NOB ; | ||
1779 | |||
1780 | pWriteBuff = (PCHAR)kmalloc(BuffSize, GFP_KERNEL); | ||
1781 | if(pWriteBuff == NULL) | ||
1782 | { | ||
1783 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Memory allocation failed for Flash 2.x Read Structure"); | ||
1784 | return -ENOMEM; | ||
1785 | } | ||
1786 | |||
1787 | //extracting the remainder of the given offset. | ||
1788 | WriteBytes = Adapter->uiSectorSize ; | ||
1789 | if(WriteOffset % Adapter->uiSectorSize) | ||
1790 | WriteBytes =Adapter->uiSectorSize - (WriteOffset % Adapter->uiSectorSize); | ||
1791 | if(NOB < WriteBytes) | ||
1792 | WriteBytes = NOB; | ||
1793 | |||
1794 | down(&Adapter->NVMRdmWrmLock); | ||
1795 | |||
1796 | if((Adapter->IdleMode == TRUE) || | ||
1797 | (Adapter->bShutStatus ==TRUE) || | ||
1798 | (Adapter->bPreparingForLowPowerMode ==TRUE)) | ||
1799 | { | ||
1800 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n"); | ||
1801 | up(&Adapter->NVMRdmWrmLock); | ||
1802 | bcm_kfree(pWriteBuff); | ||
1803 | return -EACCES; | ||
1804 | } | ||
1805 | |||
1806 | BcmFlash2xCorruptSig(Adapter,sFlash2xWrite.Section); | ||
1807 | do | ||
1808 | { | ||
1809 | Status = copy_from_user(pWriteBuff,InputAddr,WriteBytes); | ||
1810 | if(Status) | ||
1811 | { | ||
1812 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Copy to user failed with status :%d", Status); | ||
1813 | break ; | ||
1814 | } | ||
1815 | BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,pWriteBuff,WriteBytes); | ||
1816 | //Writing the data from Flash 2.x | ||
1817 | Status = BcmFlash2xBulkWrite(Adapter,(PUINT)pWriteBuff,sFlash2xWrite.Section,WriteOffset,WriteBytes,sFlash2xWrite.bVerify); | ||
1818 | |||
1819 | if(Status) | ||
1820 | { | ||
1821 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Flash 2x read err with Status :%d", Status); | ||
1822 | break ; | ||
1823 | } | ||
1824 | |||
1825 | NOB = NOB - WriteBytes; | ||
1826 | if(NOB) | ||
1827 | { | ||
1828 | WriteOffset = WriteOffset + WriteBytes ; | ||
1829 | InputAddr = InputAddr + WriteBytes ; | ||
1830 | if(NOB > Adapter->uiSectorSize ) | ||
1831 | WriteBytes = Adapter->uiSectorSize; | ||
1832 | else | ||
1833 | WriteBytes = NOB; | ||
1834 | } | ||
1835 | |||
1836 | |||
1837 | } while(NOB > 0); | ||
1838 | BcmFlash2xWriteSig(Adapter,sFlash2xWrite.Section); | ||
1839 | up(&Adapter->NVMRdmWrmLock); | ||
1840 | bcm_kfree(pWriteBuff); | ||
1841 | } | ||
1842 | break ; | ||
1843 | case IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP : | ||
1844 | { | ||
1845 | |||
1846 | PFLASH2X_BITMAP psFlash2xBitMap = NULL ; | ||
1847 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP Called"); | ||
1848 | |||
1849 | Status = copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER)); | ||
1850 | if(Status) | ||
1851 | { | ||
1852 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); | ||
1853 | return Status; | ||
1854 | } | ||
1855 | if(IoBuffer.OutputLength != sizeof(FLASH2X_BITMAP)) | ||
1856 | { | ||
1857 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Structure size mismatch Lib :0x%lx Driver :0x%x ",IoBuffer.OutputLength, sizeof(FLASH2X_BITMAP)); | ||
1858 | break; | ||
1859 | } | ||
1860 | |||
1861 | psFlash2xBitMap = (PFLASH2X_BITMAP)kzalloc(sizeof(FLASH2X_BITMAP), GFP_KERNEL); | ||
1862 | if(psFlash2xBitMap == NULL) | ||
1863 | { | ||
1864 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Memory is not available"); | ||
1865 | return -ENOMEM ; | ||
1866 | } | ||
1867 | //Reading the Flash Sectio Bit map | ||
1868 | down(&Adapter->NVMRdmWrmLock); | ||
1869 | |||
1870 | if((Adapter->IdleMode == TRUE) || | ||
1871 | (Adapter->bShutStatus ==TRUE) || | ||
1872 | (Adapter->bPreparingForLowPowerMode ==TRUE)) | ||
1873 | { | ||
1874 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n"); | ||
1875 | up(&Adapter->NVMRdmWrmLock); | ||
1876 | bcm_kfree(psFlash2xBitMap); | ||
1877 | return -EACCES; | ||
1878 | } | ||
1879 | |||
1880 | BcmGetFlash2xSectionalBitMap(Adapter, psFlash2xBitMap); | ||
1881 | up(&Adapter->NVMRdmWrmLock); | ||
1882 | Status = copy_to_user((PCHAR)IoBuffer.OutputBuffer, (PCHAR)psFlash2xBitMap, sizeof(FLASH2X_BITMAP)); | ||
1883 | if(Status) | ||
1884 | { | ||
1885 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "copying Flash2x bitMap failed"); | ||
1886 | bcm_kfree(psFlash2xBitMap); | ||
1887 | return Status; | ||
1888 | } | ||
1889 | bcm_kfree(psFlash2xBitMap); | ||
1890 | } | ||
1891 | break ; | ||
1892 | case IOCTL_BCM_SET_ACTIVE_SECTION : | ||
1893 | { | ||
1894 | FLASH2X_SECTION_VAL eFlash2xSectionVal = 0; | ||
1895 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_SET_ACTIVE_SECTION Called"); | ||
1896 | |||
1897 | if(IsFlash2x(Adapter) != TRUE) | ||
1898 | { | ||
1899 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Flash Does not have 2.x map"); | ||
1900 | return -EINVAL; | ||
1901 | } | ||
1902 | |||
1903 | Status = copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER)); | ||
1904 | if(Status) | ||
1905 | { | ||
1906 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); | ||
1907 | return Status; | ||
1908 | } | ||
1909 | |||
1910 | Status = copy_from_user((PCHAR)&eFlash2xSectionVal,(PCHAR)IoBuffer.InputBuffer, sizeof(INT)); | ||
1911 | if(Status) | ||
1912 | { | ||
1913 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of flash section val failed"); | ||
1914 | return Status; | ||
1915 | } | ||
1916 | |||
1917 | down(&Adapter->NVMRdmWrmLock); | ||
1918 | |||
1919 | if((Adapter->IdleMode == TRUE) || | ||
1920 | (Adapter->bShutStatus ==TRUE) || | ||
1921 | (Adapter->bPreparingForLowPowerMode ==TRUE)) | ||
1922 | { | ||
1923 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n"); | ||
1924 | up(&Adapter->NVMRdmWrmLock); | ||
1925 | return -EACCES; | ||
1926 | } | ||
1927 | |||
1928 | Status = BcmSetActiveSection(Adapter,eFlash2xSectionVal); | ||
1929 | if(Status) | ||
1930 | { | ||
1931 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Failed to make it's priority Highest. Status %d", Status); | ||
1932 | } | ||
1933 | up(&Adapter->NVMRdmWrmLock); | ||
1934 | } | ||
1935 | break ; | ||
1936 | case IOCTL_BCM_IDENTIFY_ACTIVE_SECTION : | ||
1937 | { | ||
1938 | //Right Now we are taking care of only DSD | ||
1939 | Adapter->bAllDSDWriteAllow = FALSE ; | ||
1940 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"IOCTL_BCM_IDENTIFY_ACTIVE_SECTION called"); | ||
1941 | |||
1942 | #if 0 | ||
1943 | SECTION_TYPE section = 0 ; | ||
1944 | |||
1945 | |||
1946 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_IDENTIFY_ACTIVE_SECTION Called"); | ||
1947 | Status = copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER)); | ||
1948 | if(Status) | ||
1949 | { | ||
1950 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Copy of IOCTL BUFFER failed"); | ||
1951 | return Status; | ||
1952 | } | ||
1953 | Status = copy_from_user((PCHAR)section,(PCHAR)&IoBuffer, sizeof(INT)); | ||
1954 | if(Status) | ||
1955 | { | ||
1956 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Copy of section type failed failed"); | ||
1957 | return Status; | ||
1958 | } | ||
1959 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Read Section :%d", section); | ||
1960 | if(section == DSD) | ||
1961 | Adapter->ulFlashCalStart = Adapter->uiActiveDSDOffsetAtFwDld ; | ||
1962 | else | ||
1963 | Status = STATUS_FAILURE ; | ||
1964 | #endif | ||
1965 | Status = STATUS_SUCCESS ; | ||
1966 | } | ||
1967 | break ; | ||
1968 | case IOCTL_BCM_COPY_SECTION : | ||
1969 | { | ||
1970 | FLASH2X_COPY_SECTION sCopySectStrut = {0}; | ||
1971 | Status = STATUS_SUCCESS; | ||
1972 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_COPY_SECTION Called"); | ||
1973 | |||
1974 | Adapter->bAllDSDWriteAllow = FALSE ; | ||
1975 | if(IsFlash2x(Adapter) != TRUE) | ||
1976 | { | ||
1977 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Flash Does not have 2.x map"); | ||
1978 | return -EINVAL; | ||
1979 | } | ||
1980 | |||
1981 | Status = copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER)); | ||
1982 | if(Status) | ||
1983 | { | ||
1984 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed Status :%d", Status); | ||
1985 | return Status; | ||
1986 | } | ||
1987 | |||
1988 | Status = copy_from_user((PCHAR)&sCopySectStrut,(PCHAR)IoBuffer.InputBuffer, sizeof(FLASH2X_COPY_SECTION)); | ||
1989 | if(Status) | ||
1990 | { | ||
1991 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of Copy_Section_Struct failed with Status :%d", Status); | ||
1992 | return Status; | ||
1993 | } | ||
1994 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Source SEction :%x", sCopySectStrut.SrcSection); | ||
1995 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Destination SEction :%x", sCopySectStrut.DstSection); | ||
1996 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "offset :%x", sCopySectStrut.offset); | ||
1997 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "NOB :%x", sCopySectStrut.numOfBytes); | ||
1998 | |||
1999 | |||
2000 | if(IsSectionExistInFlash(Adapter,sCopySectStrut.SrcSection) == FALSE) | ||
2001 | { | ||
2002 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Source Section<%x> does not exixt in Flash ", sCopySectStrut.SrcSection); | ||
2003 | return -EINVAL; | ||
2004 | } | ||
2005 | |||
2006 | if(IsSectionExistInFlash(Adapter,sCopySectStrut.DstSection) == FALSE) | ||
2007 | { | ||
2008 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Destinatio Section<%x> does not exixt in Flash ", sCopySectStrut.DstSection); | ||
2009 | return -EINVAL; | ||
2010 | } | ||
2011 | |||
2012 | if(sCopySectStrut.SrcSection == sCopySectStrut.DstSection) | ||
2013 | { | ||
2014 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Source and Destination section should be different"); | ||
2015 | return -EINVAL; | ||
2016 | } | ||
2017 | |||
2018 | down(&Adapter->NVMRdmWrmLock); | ||
2019 | |||
2020 | if((Adapter->IdleMode == TRUE) || | ||
2021 | (Adapter->bShutStatus ==TRUE) || | ||
2022 | (Adapter->bPreparingForLowPowerMode ==TRUE)) | ||
2023 | { | ||
2024 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n"); | ||
2025 | up(&Adapter->NVMRdmWrmLock); | ||
2026 | return -EACCES; | ||
2027 | } | ||
2028 | |||
2029 | if(sCopySectStrut.SrcSection == ISO_IMAGE1 || sCopySectStrut.SrcSection == ISO_IMAGE2) | ||
2030 | { | ||
2031 | if(IsNonCDLessDevice(Adapter)) | ||
2032 | { | ||
2033 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Device is Non-CDLess hence won't have ISO !!"); | ||
2034 | Status = -EINVAL ; | ||
2035 | } | ||
2036 | else if(sCopySectStrut.numOfBytes == 0) | ||
2037 | { | ||
2038 | Status = BcmCopyISO(Adapter,sCopySectStrut); | ||
2039 | } | ||
2040 | else | ||
2041 | { | ||
2042 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Partial Copy of ISO section is not Allowed.."); | ||
2043 | Status = STATUS_FAILURE ; | ||
2044 | } | ||
2045 | up(&Adapter->NVMRdmWrmLock); | ||
2046 | return Status; | ||
2047 | } | ||
2048 | |||
2049 | Status = BcmCopySection(Adapter, sCopySectStrut.SrcSection, | ||
2050 | sCopySectStrut.DstSection,sCopySectStrut.offset,sCopySectStrut.numOfBytes); | ||
2051 | up(&Adapter->NVMRdmWrmLock); | ||
2052 | } | ||
2053 | break ; | ||
2054 | case IOCTL_BCM_GET_FLASH_CS_INFO : | ||
2055 | { | ||
2056 | Status = STATUS_SUCCESS; | ||
2057 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, " IOCTL_BCM_GET_FLASH_CS_INFO Called"); | ||
2058 | |||
2059 | Status = copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER)); | ||
2060 | if(Status) | ||
2061 | { | ||
2062 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); | ||
2063 | break; | ||
2064 | } | ||
2065 | if(Adapter->eNVMType != NVM_FLASH) | ||
2066 | { | ||
2067 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Connected device does not have flash"); | ||
2068 | Status = -EINVAL; | ||
2069 | break; | ||
2070 | } | ||
2071 | if(IsFlash2x(Adapter) == TRUE) | ||
2072 | { | ||
2073 | |||
2074 | if(IoBuffer.OutputLength < sizeof(FLASH2X_CS_INFO)) | ||
2075 | { | ||
2076 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0," Passed buffer size:0x%lX is insufficient for the CS structure.. \nRequired size :0x%x ",IoBuffer.OutputLength, sizeof(FLASH2X_CS_INFO)); | ||
2077 | Status = -EINVAL; | ||
2078 | break; | ||
2079 | } | ||
2080 | |||
2081 | Status = copy_to_user((PCHAR)IoBuffer.OutputBuffer, (PCHAR)Adapter->psFlash2xCSInfo, sizeof(FLASH2X_CS_INFO)); | ||
2082 | if(Status) | ||
2083 | { | ||
2084 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "copying Flash2x cs info failed"); | ||
2085 | break; | ||
2086 | } | ||
2087 | } | ||
2088 | else | ||
2089 | { | ||
2090 | if(IoBuffer.OutputLength < sizeof(FLASH_CS_INFO)) | ||
2091 | { | ||
2092 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0," Passed buffer size:0x%lX is insufficient for the CS structure.. Required size :0x%u ",IoBuffer.OutputLength, sizeof(FLASH_CS_INFO)); | ||
2093 | Status = -EINVAL; | ||
2094 | break; | ||
2095 | } | ||
2096 | Status = copy_to_user((PCHAR)IoBuffer.OutputBuffer, (PCHAR)Adapter->psFlashCSInfo, sizeof(FLASH_CS_INFO)); | ||
2097 | if(Status) | ||
2098 | { | ||
2099 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "copying Flash CS info failed"); | ||
2100 | break; | ||
2101 | } | ||
2102 | |||
2103 | } | ||
2104 | } | ||
2105 | break ; | ||
2106 | case IOCTL_BCM_SELECT_DSD : | ||
2107 | { | ||
2108 | UINT SectOfset = 0; | ||
2109 | FLASH2X_SECTION_VAL eFlash2xSectionVal; | ||
2110 | eFlash2xSectionVal = NO_SECTION_VAL ; | ||
2111 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, " IOCTL_BCM_SELECT_DSD Called"); | ||
2112 | |||
2113 | if(IsFlash2x(Adapter) != TRUE) | ||
2114 | { | ||
2115 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Flash Does not have 2.x map"); | ||
2116 | return -EINVAL; | ||
2117 | } | ||
2118 | |||
2119 | Status = copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER)); | ||
2120 | if(Status) | ||
2121 | { | ||
2122 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); | ||
2123 | return Status; | ||
2124 | } | ||
2125 | Status = copy_from_user((PCHAR)&eFlash2xSectionVal,(PCHAR)IoBuffer.InputBuffer, sizeof(INT)); | ||
2126 | if(Status) | ||
2127 | { | ||
2128 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of flash section val failed"); | ||
2129 | return Status; | ||
2130 | } | ||
2131 | |||
2132 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Read Section :%d", eFlash2xSectionVal); | ||
2133 | if((eFlash2xSectionVal != DSD0) && | ||
2134 | (eFlash2xSectionVal != DSD1) && | ||
2135 | (eFlash2xSectionVal != DSD2) ) | ||
2136 | { | ||
2137 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Passed section<%x> is not DSD section", eFlash2xSectionVal); | ||
2138 | return STATUS_FAILURE ; | ||
2139 | } | ||
2140 | |||
2141 | SectOfset= BcmGetSectionValStartOffset(Adapter,eFlash2xSectionVal); | ||
2142 | if(SectOfset == INVALID_OFFSET) | ||
2143 | { | ||
2144 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Provided Section val <%d> does not exixt in Flash 2.x", eFlash2xSectionVal); | ||
2145 | return -EINVAL; | ||
2146 | } | ||
2147 | |||
2148 | Adapter->bAllDSDWriteAllow = TRUE ; | ||
2149 | |||
2150 | Adapter->ulFlashCalStart = SectOfset ; | ||
2151 | Adapter->eActiveDSD = eFlash2xSectionVal; | ||
2152 | } | ||
2153 | Status = STATUS_SUCCESS ; | ||
2154 | break; | ||
2155 | |||
2156 | case IOCTL_BCM_NVM_RAW_READ : | ||
2157 | { | ||
2158 | |||
2159 | NVM_READWRITE stNVMRead = {0}; | ||
2160 | INT NOB ; | ||
2161 | INT BuffSize ; | ||
2162 | INT ReadOffset = 0; | ||
2163 | UINT ReadBytes = 0 ; | ||
2164 | PUCHAR pReadBuff = NULL ; | ||
2165 | PUCHAR OutPutBuff = NULL ; | ||
2166 | |||
2167 | if(Adapter->eNVMType != NVM_FLASH) | ||
2168 | { | ||
2169 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"NVM TYPE is not Flash "); | ||
2170 | return -EINVAL ; | ||
2171 | } | ||
2172 | |||
2173 | /* Copy Ioctl Buffer structure */ | ||
2174 | if(copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER))) | ||
2175 | { | ||
2176 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "copy_from_user 1 failed\n"); | ||
2177 | Status = -EFAULT; | ||
2178 | break; | ||
2179 | } | ||
2180 | |||
2181 | if(copy_from_user(&stNVMRead, (PUCHAR)IoBuffer.OutputBuffer,sizeof(NVM_READWRITE))) | ||
2182 | { | ||
2183 | Status = -EFAULT; | ||
2184 | break; | ||
2185 | } | ||
2186 | |||
2187 | NOB = stNVMRead.uiNumBytes; | ||
2188 | //In Raw-Read max Buff size : 64MB | ||
2189 | |||
2190 | if(NOB > DEFAULT_BUFF_SIZE) | ||
2191 | BuffSize = DEFAULT_BUFF_SIZE; | ||
2192 | else | ||
2193 | BuffSize = NOB ; | ||
2194 | |||
2195 | ReadOffset = stNVMRead.uiOffset ; | ||
2196 | OutPutBuff = (PUCHAR)(stNVMRead.pBuffer) ; | ||
2197 | |||
2198 | |||
2199 | pReadBuff = (PCHAR)kzalloc(BuffSize , GFP_KERNEL); | ||
2200 | if(pReadBuff == NULL) | ||
2201 | { | ||
2202 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Memory allocation failed for Flash 2.x Read Structure"); | ||
2203 | Status = -ENOMEM; | ||
2204 | break; | ||
2205 | } | ||
2206 | down(&Adapter->NVMRdmWrmLock); | ||
2207 | |||
2208 | if((Adapter->IdleMode == TRUE) || | ||
2209 | (Adapter->bShutStatus ==TRUE) || | ||
2210 | (Adapter->bPreparingForLowPowerMode ==TRUE)) | ||
2211 | { | ||
2212 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n"); | ||
2213 | bcm_kfree(pReadBuff); | ||
2214 | up(&Adapter->NVMRdmWrmLock); | ||
2215 | return -EACCES; | ||
2216 | } | ||
2217 | |||
2218 | Adapter->bFlashRawRead = TRUE ; | ||
2219 | while(NOB) | ||
2220 | { | ||
2221 | if(NOB > DEFAULT_BUFF_SIZE ) | ||
2222 | ReadBytes = DEFAULT_BUFF_SIZE; | ||
2223 | else | ||
2224 | ReadBytes = NOB; | ||
2225 | |||
2226 | //Reading the data from Flash 2.x | ||
2227 | Status = BeceemNVMRead(Adapter,(PUINT)pReadBuff,ReadOffset,ReadBytes); | ||
2228 | if(Status) | ||
2229 | { | ||
2230 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Flash 2x read err with Status :%d", Status); | ||
2231 | break; | ||
2232 | } | ||
2233 | |||
2234 | BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,pReadBuff, ReadBytes); | ||
2235 | |||
2236 | Status = copy_to_user(OutPutBuff, pReadBuff,ReadBytes); | ||
2237 | if(Status) | ||
2238 | { | ||
2239 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Copy to use failed with status :%d", Status); | ||
2240 | break; | ||
2241 | } | ||
2242 | NOB = NOB - ReadBytes; | ||
2243 | if(NOB) | ||
2244 | { | ||
2245 | ReadOffset = ReadOffset + ReadBytes ; | ||
2246 | OutPutBuff = OutPutBuff + ReadBytes ; | ||
2247 | } | ||
2248 | |||
2249 | } | ||
2250 | Adapter->bFlashRawRead = FALSE ; | ||
2251 | up(&Adapter->NVMRdmWrmLock); | ||
2252 | bcm_kfree(pReadBuff); | ||
2253 | break ; | ||
2254 | } | ||
2255 | |||
2256 | case IOCTL_BCM_CNTRLMSG_MASK: | ||
2257 | { | ||
2258 | ULONG RxCntrlMsgBitMask = 0 ; | ||
2259 | |||
2260 | /* Copy Ioctl Buffer structure */ | ||
2261 | Status = copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER)); | ||
2262 | if(Status) | ||
2263 | { | ||
2264 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"copy of Ioctl buffer is failed from user space"); | ||
2265 | break; | ||
2266 | } | ||
2267 | |||
2268 | Status = copy_from_user(&RxCntrlMsgBitMask, IoBuffer.InputBuffer, IoBuffer.InputLength); | ||
2269 | if(Status) | ||
2270 | { | ||
2271 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"copy of control bit mask failed from user space"); | ||
2272 | break; | ||
2273 | } | ||
2274 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\n Got user defined cntrl msg bit mask :%lx", RxCntrlMsgBitMask); | ||
2275 | pTarang->RxCntrlMsgBitMask = RxCntrlMsgBitMask ; | ||
2276 | } | ||
2277 | break; | ||
2278 | case IOCTL_BCM_GET_DEVICE_DRIVER_INFO: | ||
2279 | { | ||
2280 | DEVICE_DRIVER_INFO DevInfo; | ||
2281 | |||
2282 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Called IOCTL_BCM_GET_DEVICE_DRIVER_INFO\n"); | ||
2283 | |||
2284 | DevInfo.MaxRDMBufferSize = BUFFER_4K; | ||
2285 | DevInfo.u32DSDStartOffset = EEPROM_CALPARAM_START; | ||
2286 | DevInfo.u32RxAlignmentCorrection = 0; | ||
2287 | DevInfo.u32NVMType = Adapter->eNVMType; | ||
2288 | DevInfo.u32InterfaceType = BCM_USB; | ||
2289 | |||
2290 | Status = copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER)); | ||
2291 | if(Status) | ||
2292 | { | ||
2293 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); | ||
2294 | break; | ||
2295 | } | ||
2296 | if(IoBuffer.OutputLength < sizeof(DevInfo)) | ||
2297 | { | ||
2298 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"User Passed buffer length is less than actural buffer size"); | ||
2299 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"user passed buffer size :0x%lX, expected size :0x%x",IoBuffer.OutputLength, sizeof(DevInfo)); | ||
2300 | Status = -EINVAL; | ||
2301 | break; | ||
2302 | } | ||
2303 | Status = copy_to_user((PCHAR)IoBuffer.OutputBuffer, (PCHAR)&DevInfo, sizeof(DevInfo)); | ||
2304 | if(Status) | ||
2305 | { | ||
2306 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"copying Dev info structure to user space buffer failed"); | ||
2307 | break; | ||
2308 | } | ||
2309 | } | ||
2310 | break ; | ||
2311 | |||
2312 | case IOCTL_BCM_TIME_SINCE_NET_ENTRY: | ||
2313 | { | ||
2314 | ST_TIME_ELAPSED stTimeElapsedSinceNetEntry = {0}; | ||
2315 | struct timeval tv = {0} ; | ||
2316 | |||
2317 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"IOCTL_BCM_TIME_SINCE_NET_ENTRY called"); | ||
2318 | |||
2319 | Status = copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER)); | ||
2320 | if(Status) | ||
2321 | { | ||
2322 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); | ||
2323 | break; | ||
2324 | } | ||
2325 | if(IoBuffer.OutputLength < sizeof(ST_TIME_ELAPSED)) | ||
2326 | { | ||
2327 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"User Passed buffer length:0x%lx is less than expected buff size :0x%X",IoBuffer.OutputLength,sizeof(ST_TIME_ELAPSED)); | ||
2328 | Status = -EINVAL; | ||
2329 | break; | ||
2330 | } | ||
2331 | |||
2332 | //stTimeElapsedSinceNetEntry.ul64TimeElapsedSinceNetEntry = Adapter->liTimeSinceLastNetEntry; | ||
2333 | do_gettimeofday(&tv); | ||
2334 | stTimeElapsedSinceNetEntry.ul64TimeElapsedSinceNetEntry = tv.tv_sec - Adapter->liTimeSinceLastNetEntry; | ||
2335 | |||
2336 | Status = copy_to_user((PCHAR)IoBuffer.OutputBuffer, (PCHAR)&stTimeElapsedSinceNetEntry, sizeof(ST_TIME_ELAPSED)); | ||
2337 | if(Status) | ||
2338 | { | ||
2339 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"copying ST_TIME_ELAPSED structure to user space buffer failed"); | ||
2340 | break; | ||
2341 | } | ||
2342 | |||
2343 | } | ||
2344 | break; | ||
2345 | |||
2346 | default: | ||
2347 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "wrong input %x",cmd); | ||
2348 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "In default ioctl %d\n", cmd); | ||
2349 | Status = STATUS_FAILURE; | ||
2350 | |||
2351 | break; | ||
2352 | } | ||
2353 | return Status; | ||
2354 | } | ||
2355 | |||
2356 | |||
2357 | static struct file_operations bcm_fops = { | ||
2358 | .owner = THIS_MODULE, | ||
2359 | .open = bcm_char_open, | ||
2360 | .release = bcm_char_release, | ||
2361 | .read = bcm_char_read, | ||
2362 | .unlocked_ioctl = bcm_char_ioctl, | ||
2363 | }; | ||
2364 | |||
2365 | |||
2366 | int register_control_device_interface(PMINI_ADAPTER Adapter) | ||
2367 | { | ||
2368 | if(Adapter->major>0) | ||
2369 | return Adapter->major; | ||
2370 | Adapter->major = register_chrdev(0, "tarang", &bcm_fops); | ||
2371 | if(Adapter->major < 0) | ||
2372 | { | ||
2373 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "register_chrdev:Failed to registering WiMax control char device!"); | ||
2374 | return Adapter->major; | ||
2375 | } | ||
2376 | |||
2377 | bcm_class = NULL; | ||
2378 | bcm_class = class_create (THIS_MODULE, "tarang"); | ||
2379 | if(IS_ERR (bcm_class)) | ||
2380 | { | ||
2381 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Unable to create class\n"); | ||
2382 | unregister_chrdev(Adapter->major, "tarang"); | ||
2383 | Adapter->major = 0; | ||
2384 | return -ENODEV; | ||
2385 | } | ||
2386 | Adapter->pstCreatedClassDevice = device_create (bcm_class, NULL, | ||
2387 | MKDEV(Adapter->major, 0), | ||
2388 | #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26) | ||
2389 | NULL , | ||
2390 | #endif | ||
2391 | "tarang"); | ||
2392 | |||
2393 | if(IS_ERR(Adapter->pstCreatedClassDevice)) | ||
2394 | { | ||
2395 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "class device did not get created : %ld", PTR_ERR(Adapter->pstCreatedClassDevice) ); | ||
2396 | } | ||
2397 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Got Major No: %d", Adapter->major); | ||
2398 | return 0; | ||
2399 | } | ||
2400 | |||
2401 | void unregister_control_device_interface(PMINI_ADAPTER Adapter) | ||
2402 | { | ||
2403 | if(Adapter->major > 0) | ||
2404 | { | ||
2405 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "destroying class device"); | ||
2406 | device_destroy (bcm_class, MKDEV(Adapter->major, 0)); | ||
2407 | } | ||
2408 | if(!IS_ERR(bcm_class)) | ||
2409 | { | ||
2410 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "destroying created class "); | ||
2411 | class_destroy (bcm_class); | ||
2412 | bcm_class = NULL; | ||
2413 | } | ||
2414 | if(Adapter->major > 0) | ||
2415 | { | ||
2416 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"unregistering character interface"); | ||
2417 | unregister_chrdev(Adapter->major, "tarang"); | ||
2418 | } | ||
2419 | |||
2420 | } | ||
diff --git a/drivers/staging/bcm/Bcmnet.c b/drivers/staging/bcm/Bcmnet.c new file mode 100644 index 00000000000..d4f4800ca5d --- /dev/null +++ b/drivers/staging/bcm/Bcmnet.c | |||
@@ -0,0 +1,266 @@ | |||
1 | #include "headers.h" | ||
2 | |||
3 | static INT bcm_notify_event(struct notifier_block *nb, ULONG event, PVOID dev) | ||
4 | { | ||
5 | struct net_device *ndev = (struct net_device*)dev; | ||
6 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
7 | //PMINI_ADAPTER Adapter = (PMINI_ADAPTER)ndev->priv; | ||
8 | if(strncmp(ndev->name,gblpnetdev->name,5)==0) | ||
9 | { | ||
10 | switch(event) | ||
11 | { | ||
12 | case NETDEV_CHANGEADDR: | ||
13 | case NETDEV_GOING_DOWN: | ||
14 | /*ignore this */ | ||
15 | break; | ||
16 | case NETDEV_DOWN: | ||
17 | break; | ||
18 | |||
19 | case NETDEV_UP: | ||
20 | break; | ||
21 | |||
22 | case NETDEV_REGISTER: | ||
23 | /* Increment the Reference Count for "veth0" */ | ||
24 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Register RefCount: %x\n", | ||
25 | atomic_read(&ndev->refcnt)); | ||
26 | atomic_inc(&ndev->refcnt); | ||
27 | break; | ||
28 | |||
29 | case NETDEV_UNREGISTER: | ||
30 | /* Decrement the Reference Count for "veth0" */ | ||
31 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Unregister RefCnt: %x\n", | ||
32 | atomic_read(&ndev->refcnt)); | ||
33 | atomic_dec(&ndev->refcnt); | ||
34 | if((int)atomic_read(&ndev->refcnt) < 0) | ||
35 | atomic_set(&ndev->refcnt, 0); | ||
36 | break; | ||
37 | }; | ||
38 | } | ||
39 | return NOTIFY_DONE; | ||
40 | } | ||
41 | |||
42 | /* Notifier block to receive netdevice events */ | ||
43 | static struct notifier_block bcm_notifier_block = | ||
44 | { | ||
45 | .notifier_call = bcm_notify_event, | ||
46 | }; | ||
47 | |||
48 | struct net_device *gblpnetdev; | ||
49 | /***************************************************************************************/ | ||
50 | /* proto-type of lower function */ | ||
51 | #ifdef BCM_SHM_INTERFACE | ||
52 | const char *bcmVirtDeviceName="bcmeth"; | ||
53 | #endif | ||
54 | |||
55 | static INT bcm_open(struct net_device *dev) | ||
56 | { | ||
57 | PMINI_ADAPTER Adapter = NULL ; //(PMINI_ADAPTER)dev->priv; | ||
58 | Adapter = GET_BCM_ADAPTER(dev); | ||
59 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "======>"); | ||
60 | if(Adapter->fw_download_done==FALSE) | ||
61 | return -EINVAL; | ||
62 | Adapter->if_up=1; | ||
63 | if(Adapter->LinkUpStatus == 1){ | ||
64 | if(netif_queue_stopped(Adapter->dev)){ | ||
65 | netif_carrier_on(Adapter->dev); | ||
66 | netif_start_queue(Adapter->dev); | ||
67 | } | ||
68 | } | ||
69 | |||
70 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "<======"); | ||
71 | return 0; | ||
72 | } | ||
73 | |||
74 | static INT bcm_close(struct net_device *dev) | ||
75 | { | ||
76 | PMINI_ADAPTER Adapter = NULL ;//gpadapter ; | ||
77 | Adapter = GET_BCM_ADAPTER(dev); | ||
78 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "=====>"); | ||
79 | Adapter->if_up=0; | ||
80 | if(!netif_queue_stopped(dev)) { | ||
81 | netif_carrier_off(dev); | ||
82 | netif_stop_queue(dev); | ||
83 | } | ||
84 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"<====="); | ||
85 | return 0; | ||
86 | } | ||
87 | |||
88 | static struct net_device_stats *bcm_get_stats(struct net_device *dev) | ||
89 | { | ||
90 | PLINUX_DEP_DATA pLinuxData=NULL; | ||
91 | PMINI_ADAPTER Adapter = NULL ;// gpadapter ; | ||
92 | Adapter = GET_BCM_ADAPTER(dev); | ||
93 | pLinuxData = (PLINUX_DEP_DATA)(Adapter->pvOsDepData); | ||
94 | |||
95 | //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Dev = %p, pLinuxData = %p", dev, pLinuxData); | ||
96 | pLinuxData->netstats.rx_packets=atomic_read(&Adapter->RxRollOverCount)*64*1024+Adapter->PrevNumRecvDescs; | ||
97 | pLinuxData->netstats.rx_bytes=atomic_read(&Adapter->GoodRxByteCount)+atomic_read(&Adapter->BadRxByteCount); | ||
98 | pLinuxData->netstats.rx_dropped=atomic_read(&Adapter->RxPacketDroppedCount); | ||
99 | pLinuxData->netstats.rx_errors=atomic_read(&Adapter->RxPacketDroppedCount); | ||
100 | pLinuxData->netstats.rx_length_errors=0; | ||
101 | pLinuxData->netstats.rx_frame_errors=0; | ||
102 | pLinuxData->netstats.rx_crc_errors=0; | ||
103 | pLinuxData->netstats.tx_bytes=atomic_read(&Adapter->GoodTxByteCount); | ||
104 | pLinuxData->netstats.tx_packets=atomic_read(&Adapter->TxTotalPacketCount); | ||
105 | pLinuxData->netstats.tx_dropped=atomic_read(&Adapter->TxDroppedPacketCount); | ||
106 | |||
107 | return &(pLinuxData->netstats); | ||
108 | } | ||
109 | /** | ||
110 | @ingroup init_functions | ||
111 | Register other driver entry points with the kernel | ||
112 | */ | ||
113 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) | ||
114 | struct net_device_ops bcmNetDevOps = { | ||
115 | .ndo_open = bcm_open, | ||
116 | .ndo_stop = bcm_close, | ||
117 | .ndo_get_stats = bcm_get_stats, | ||
118 | .ndo_start_xmit = bcm_transmit, | ||
119 | .ndo_change_mtu = eth_change_mtu, | ||
120 | .ndo_set_mac_address = eth_mac_addr, | ||
121 | .ndo_validate_addr = eth_validate_addr, | ||
122 | }; | ||
123 | #endif | ||
124 | |||
125 | int register_networkdev(PMINI_ADAPTER Adapter) | ||
126 | { | ||
127 | int result=0; | ||
128 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) | ||
129 | int *temp = NULL ; | ||
130 | #endif | ||
131 | Adapter->dev = alloc_etherdev(sizeof(PMINI_ADAPTER)); | ||
132 | if(!Adapter->dev) | ||
133 | { | ||
134 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "ERR: No Dev"); | ||
135 | return -ENOMEM; | ||
136 | } | ||
137 | gblpnetdev = Adapter->dev; | ||
138 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) | ||
139 | Adapter->dev->priv = Adapter; | ||
140 | #else | ||
141 | temp = netdev_priv(Adapter->dev); | ||
142 | *temp = (UINT)Adapter; | ||
143 | #endif | ||
144 | //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "init adapterptr: %x %x\n", (UINT)Adapter, temp); | ||
145 | |||
146 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) | ||
147 | Adapter->dev->netdev_ops = &bcmNetDevOps; | ||
148 | #else | ||
149 | Adapter->dev->open = bcm_open; | ||
150 | Adapter->dev->stop = bcm_close; | ||
151 | Adapter->dev->get_stats = bcm_get_stats; | ||
152 | Adapter->dev->hard_start_xmit = bcm_transmit; | ||
153 | Adapter->dev->hard_header_len = ETH_HLEN + LEADER_SIZE; | ||
154 | #endif | ||
155 | |||
156 | #ifndef BCM_SHM_INTERFACE | ||
157 | Adapter->dev->mtu = MTU_SIZE; /* 1400 Bytes */ | ||
158 | /* Read the MAC Address from EEPROM */ | ||
159 | ReadMacAddressFromNVM(Adapter); | ||
160 | |||
161 | |||
162 | /* Register the notifier block for getting netdevice events */ | ||
163 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Registering netdevice notifier\n"); | ||
164 | result = register_netdevice_notifier(&bcm_notifier_block); | ||
165 | if(result) | ||
166 | { | ||
167 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "BCM Notifier Block did not get registered"); | ||
168 | Adapter->bNetdeviceNotifierRegistered = FALSE; | ||
169 | return result; | ||
170 | } | ||
171 | else | ||
172 | { | ||
173 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "BCM Notifier got Registered"); | ||
174 | Adapter->bNetdeviceNotifierRegistered = TRUE; | ||
175 | } | ||
176 | |||
177 | #else | ||
178 | |||
179 | Adapter->dev->mtu = CPE_MTU_SIZE; | ||
180 | |||
181 | #if 0 | ||
182 | //for CPE - harcode the virtual mac address | ||
183 | Adapter->dev->dev_addr[0] = MII_WIMAX_MACADDRESS[0]; | ||
184 | Adapter->dev->dev_addr[1] = MII_WIMAX_MACADDRESS[1]; | ||
185 | Adapter->dev->dev_addr[2] = MII_WIMAX_MACADDRESS[2]; | ||
186 | Adapter->dev->dev_addr[3] = MII_WIMAX_MACADDRESS[3]; | ||
187 | Adapter->dev->dev_addr[4] = MII_WIMAX_MACADDRESS[4]; | ||
188 | Adapter->dev->dev_addr[5] = MII_WIMAX_MACADDRESS[5]; | ||
189 | #else | ||
190 | ReadMacAddressFromNVM(Adapter); | ||
191 | #endif | ||
192 | strcpy(Adapter->dev->name, bcmVirtDeviceName); //Copy the device name | ||
193 | |||
194 | #endif | ||
195 | |||
196 | result = register_netdev(Adapter->dev); | ||
197 | if (!result) | ||
198 | { | ||
199 | Adapter->bNetworkInterfaceRegistered = TRUE ; | ||
200 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Beceem Network device name is %s!", Adapter->dev->name); | ||
201 | } | ||
202 | else | ||
203 | { | ||
204 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Network device can not be registered!"); | ||
205 | Adapter->bNetworkInterfaceRegistered = FALSE ; | ||
206 | return result; | ||
207 | } | ||
208 | |||
209 | #if 0 | ||
210 | Adapter->stDebugState.debug_level = DBG_LVL_CURR; | ||
211 | Adapter->stDebugState.type =(UINT)0xffffffff; | ||
212 | Adapter->stDebugState.subtype[DBG_TYPE_OTHERS] = 0xffffffff; | ||
213 | Adapter->stDebugState.subtype[DBG_TYPE_RX] = 0xffffffff; | ||
214 | Adapter->stDebugState.subtype[DBG_TYPE_TX] = 0xffffffff; | ||
215 | Adapter->stDebugState.subtype[DBG_TYPE_INITEXIT] = 0xffffffff; | ||
216 | |||
217 | printk("-------ps_adapter->stDebugState.type=%x\n",Adapter->stDebugState.type); | ||
218 | printk("-------ps_adapter->stDebugState.subtype[DBG_TYPE_OTHERS]=%x\n",Adapter->stDebugState.subtype[DBG_TYPE_OTHERS]); | ||
219 | printk("-------ps_adapter->stDebugState.subtype[DBG_TYPE_RX]=%x\n",Adapter->stDebugState.subtype[DBG_TYPE_RX]); | ||
220 | printk("-------ps_adapter->stDebugState.subtype[DBG_TYPE_TX]=%x\n",Adapter->stDebugState.subtype[DBG_TYPE_TX]); | ||
221 | #endif | ||
222 | |||
223 | return 0; | ||
224 | } | ||
225 | |||
226 | void bcm_unregister_networkdev(PMINI_ADAPTER Adapter) | ||
227 | { | ||
228 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Unregistering the Net Dev...\n"); | ||
229 | if(Adapter->dev && !IS_ERR(Adapter->dev) && Adapter->bNetworkInterfaceRegistered) | ||
230 | unregister_netdev(Adapter->dev); | ||
231 | /* Unregister the notifier block */ | ||
232 | if(Adapter->bNetdeviceNotifierRegistered == TRUE) | ||
233 | { | ||
234 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Unregistering netdevice notifier\n"); | ||
235 | unregister_netdevice_notifier(&bcm_notifier_block); | ||
236 | } | ||
237 | } | ||
238 | |||
239 | static int bcm_init(void) | ||
240 | { | ||
241 | int result; | ||
242 | result = InterfaceInitialize(); | ||
243 | if(result) | ||
244 | { | ||
245 | printk("Initialisation failed for usbbcm"); | ||
246 | } | ||
247 | else | ||
248 | { | ||
249 | printk("Initialised usbbcm"); | ||
250 | } | ||
251 | return result; | ||
252 | } | ||
253 | |||
254 | |||
255 | static void bcm_exit(void) | ||
256 | { | ||
257 | printk("%s %s Calling InterfaceExit\n",__FILE__, __FUNCTION__); | ||
258 | InterfaceExit(); | ||
259 | printk("%s %s InterfaceExit returned\n",__FILE__, __FUNCTION__); | ||
260 | } | ||
261 | |||
262 | module_init(bcm_init); | ||
263 | module_exit(bcm_exit); | ||
264 | MODULE_LICENSE ("GPL"); | ||
265 | |||
266 | |||
diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c new file mode 100644 index 00000000000..d1a66833998 --- /dev/null +++ b/drivers/staging/bcm/CmHost.c | |||
@@ -0,0 +1,2443 @@ | |||
1 | /************************************************************ | ||
2 | * CMHOST.C | ||
3 | * This file contains the routines for handling Connnection | ||
4 | * Management. | ||
5 | ************************************************************/ | ||
6 | |||
7 | //#define CONN_MSG | ||
8 | #include "headers.h" | ||
9 | |||
10 | typedef enum _E_CLASSIFIER_ACTION | ||
11 | { | ||
12 | eInvalidClassifierAction, | ||
13 | eAddClassifier, | ||
14 | eReplaceClassifier, | ||
15 | eDeleteClassifier | ||
16 | }E_CLASSIFIER_ACTION; | ||
17 | |||
18 | |||
19 | /************************************************************ | ||
20 | * Function - SearchSfid | ||
21 | * | ||
22 | * Description - This routinue would search QOS queues having | ||
23 | * specified SFID as input parameter. | ||
24 | * | ||
25 | * Parameters - Adapter: Pointer to the Adapter structure | ||
26 | * uiSfid : Given SFID for matching | ||
27 | * | ||
28 | * Returns - Queue index for this SFID(If matched) | ||
29 | Else Invalid Queue Index(If Not matched) | ||
30 | ************************************************************/ | ||
31 | __inline INT SearchSfid(PMINI_ADAPTER Adapter,UINT uiSfid) | ||
32 | { | ||
33 | INT iIndex=0; | ||
34 | for(iIndex=(NO_OF_QUEUES-1); iIndex>=0; iIndex--) | ||
35 | if(Adapter->PackInfo[iIndex].ulSFID==uiSfid) | ||
36 | return iIndex; | ||
37 | return NO_OF_QUEUES+1; | ||
38 | } | ||
39 | |||
40 | /*************************************************************** | ||
41 | * Function - SearchFreeSfid | ||
42 | * | ||
43 | * Description - This routinue would search Free available SFID. | ||
44 | * | ||
45 | * Parameter - Adapter: Pointer to the Adapter structure | ||
46 | * | ||
47 | * Returns - Queue index for the free SFID | ||
48 | * Else returns Invalid Index. | ||
49 | ****************************************************************/ | ||
50 | __inline INT SearchFreeSfid(PMINI_ADAPTER Adapter) | ||
51 | { | ||
52 | UINT uiIndex=0; | ||
53 | for(uiIndex=0; uiIndex < (NO_OF_QUEUES-1); uiIndex++) | ||
54 | if(Adapter->PackInfo[uiIndex].ulSFID==0) | ||
55 | return uiIndex; | ||
56 | return NO_OF_QUEUES+1; | ||
57 | } | ||
58 | |||
59 | __inline int SearchVcid(PMINI_ADAPTER Adapter,unsigned short usVcid) | ||
60 | { | ||
61 | int iIndex=0; | ||
62 | for(iIndex=(NO_OF_QUEUES-1);iIndex>=0;iIndex--) | ||
63 | if(Adapter->PackInfo[iIndex].usVCID_Value == usVcid) | ||
64 | return iIndex; | ||
65 | return NO_OF_QUEUES+1; | ||
66 | |||
67 | } | ||
68 | |||
69 | |||
70 | /* | ||
71 | Function: SearchClsid | ||
72 | Description: This routinue would search Classifier having specified ClassifierID as input parameter | ||
73 | Input parameters: PMINI_ADAPTER Adapter - Adapter Context | ||
74 | unsigned int uiSfid - The SF in which the classifier is to searched | ||
75 | B_UINT16 uiClassifierID - The classifier ID to be searched | ||
76 | Return: int :Classifier table index of matching entry | ||
77 | */ | ||
78 | |||
79 | __inline int SearchClsid(PMINI_ADAPTER Adapter,ULONG ulSFID,B_UINT16 uiClassifierID) | ||
80 | { | ||
81 | unsigned int uiClassifierIndex = 0; | ||
82 | for(uiClassifierIndex=0;uiClassifierIndex<MAX_CLASSIFIERS;uiClassifierIndex++) | ||
83 | { | ||
84 | if((Adapter->astClassifierTable[uiClassifierIndex].bUsed) && | ||
85 | (Adapter->astClassifierTable[uiClassifierIndex].uiClassifierRuleIndex == uiClassifierID)&& | ||
86 | (Adapter->astClassifierTable[uiClassifierIndex].ulSFID == ulSFID)) | ||
87 | return uiClassifierIndex; | ||
88 | } | ||
89 | return MAX_CLASSIFIERS+1; | ||
90 | } | ||
91 | |||
92 | /** | ||
93 | @ingroup ctrl_pkt_functions | ||
94 | This routinue would search Free available Classifier entry in classifier table. | ||
95 | @return free Classifier Entry index in classifier table for specified SF | ||
96 | */ | ||
97 | static __inline int SearchFreeClsid(PMINI_ADAPTER Adapter /**Adapter Context*/ | ||
98 | ) | ||
99 | { | ||
100 | unsigned int uiClassifierIndex = 0; | ||
101 | for(uiClassifierIndex=0;uiClassifierIndex<MAX_CLASSIFIERS;uiClassifierIndex++) | ||
102 | { | ||
103 | if(!Adapter->astClassifierTable[uiClassifierIndex].bUsed) | ||
104 | return uiClassifierIndex; | ||
105 | } | ||
106 | return MAX_CLASSIFIERS+1; | ||
107 | } | ||
108 | |||
109 | VOID deleteSFBySfid(PMINI_ADAPTER Adapter, UINT uiSearchRuleIndex) | ||
110 | { | ||
111 | //deleting all the packet held in the SF | ||
112 | flush_queue(Adapter,uiSearchRuleIndex); | ||
113 | |||
114 | //Deleting the all classifiers for this SF | ||
115 | DeleteAllClassifiersForSF(Adapter,uiSearchRuleIndex); | ||
116 | |||
117 | //Resetting only MIBS related entries in the SF | ||
118 | memset((PVOID)&Adapter->PackInfo[uiSearchRuleIndex], 0, sizeof(S_MIBS_SERVICEFLOW_TABLE)); | ||
119 | } | ||
120 | |||
121 | static inline VOID | ||
122 | CopyIpAddrToClassifier(S_CLASSIFIER_RULE *pstClassifierEntry , | ||
123 | B_UINT8 u8IpAddressLen , B_UINT8 *pu8IpAddressMaskSrc , | ||
124 | BOOLEAN bIpVersion6 , E_IPADDR_CONTEXT eIpAddrContext) | ||
125 | { | ||
126 | UINT ucLoopIndex=0; | ||
127 | UINT nSizeOfIPAddressInBytes = IP_LENGTH_OF_ADDRESS; | ||
128 | UCHAR *ptrClassifierIpAddress = NULL; | ||
129 | UCHAR *ptrClassifierIpMask = NULL; | ||
130 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
131 | |||
132 | if(bIpVersion6) | ||
133 | { | ||
134 | nSizeOfIPAddressInBytes = IPV6_ADDRESS_SIZEINBYTES; | ||
135 | } | ||
136 | //Destination Ip Address | ||
137 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Ip Address Range Length:0x%X ", | ||
138 | u8IpAddressLen); | ||
139 | if((bIpVersion6?(IPV6_ADDRESS_SIZEINBYTES * MAX_IP_RANGE_LENGTH * 2): | ||
140 | (TOTAL_MASKED_ADDRESS_IN_BYTES)) >= u8IpAddressLen) | ||
141 | { | ||
142 | /* | ||
143 | //checking both the mask and address togethor in Classification. | ||
144 | //So length will be : TotalLengthInBytes/nSizeOfIPAddressInBytes * 2 | ||
145 | //(nSizeOfIPAddressInBytes for address and nSizeOfIPAddressInBytes for mask) | ||
146 | */ | ||
147 | if(eIpAddrContext == eDestIpAddress) | ||
148 | { | ||
149 | pstClassifierEntry->ucIPDestinationAddressLength = | ||
150 | u8IpAddressLen/(nSizeOfIPAddressInBytes * 2); | ||
151 | if(bIpVersion6) | ||
152 | { | ||
153 | ptrClassifierIpAddress = | ||
154 | pstClassifierEntry->stDestIpAddress.ucIpv6Address; | ||
155 | ptrClassifierIpMask = | ||
156 | pstClassifierEntry->stDestIpAddress.ucIpv6Mask; | ||
157 | } | ||
158 | else | ||
159 | { | ||
160 | ptrClassifierIpAddress = | ||
161 | pstClassifierEntry->stDestIpAddress.ucIpv4Address; | ||
162 | ptrClassifierIpMask = | ||
163 | pstClassifierEntry->stDestIpAddress.ucIpv4Mask; | ||
164 | } | ||
165 | } | ||
166 | else if(eIpAddrContext == eSrcIpAddress) | ||
167 | { | ||
168 | pstClassifierEntry->ucIPSourceAddressLength = | ||
169 | u8IpAddressLen/(nSizeOfIPAddressInBytes * 2); | ||
170 | if(bIpVersion6) | ||
171 | { | ||
172 | ptrClassifierIpAddress = | ||
173 | pstClassifierEntry->stSrcIpAddress.ucIpv6Address; | ||
174 | ptrClassifierIpMask = | ||
175 | pstClassifierEntry->stSrcIpAddress.ucIpv6Mask; | ||
176 | } | ||
177 | else | ||
178 | { | ||
179 | ptrClassifierIpAddress = | ||
180 | pstClassifierEntry->stSrcIpAddress.ucIpv4Address; | ||
181 | ptrClassifierIpMask = | ||
182 | pstClassifierEntry->stSrcIpAddress.ucIpv4Mask; | ||
183 | } | ||
184 | } | ||
185 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Address Length:0x%X \n", | ||
186 | pstClassifierEntry->ucIPDestinationAddressLength); | ||
187 | while((u8IpAddressLen>= nSizeOfIPAddressInBytes) && | ||
188 | (ucLoopIndex < MAX_IP_RANGE_LENGTH)) | ||
189 | { | ||
190 | memcpy(ptrClassifierIpAddress + | ||
191 | (ucLoopIndex * nSizeOfIPAddressInBytes), | ||
192 | (pu8IpAddressMaskSrc+(ucLoopIndex*nSizeOfIPAddressInBytes*2)), | ||
193 | nSizeOfIPAddressInBytes); | ||
194 | if(!bIpVersion6) | ||
195 | { | ||
196 | if(eIpAddrContext == eSrcIpAddress) | ||
197 | { | ||
198 | pstClassifierEntry->stSrcIpAddress.ulIpv4Addr[ucLoopIndex]= | ||
199 | ntohl(pstClassifierEntry->stSrcIpAddress. | ||
200 | ulIpv4Addr[ucLoopIndex]); | ||
201 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Src Ip Address:0x%luX ",pstClassifierEntry->stSrcIpAddress.ulIpv4Addr[ucLoopIndex]); | ||
202 | } | ||
203 | else if(eIpAddrContext == eDestIpAddress) | ||
204 | { | ||
205 | pstClassifierEntry->stDestIpAddress.ulIpv4Addr[ucLoopIndex]= ntohl(pstClassifierEntry->stDestIpAddress. | ||
206 | ulIpv4Addr[ucLoopIndex]); | ||
207 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Dest Ip Address:0x%luX ",pstClassifierEntry->stDestIpAddress.ulIpv4Addr[ucLoopIndex]); | ||
208 | } | ||
209 | } | ||
210 | u8IpAddressLen-=nSizeOfIPAddressInBytes; | ||
211 | if(u8IpAddressLen >= nSizeOfIPAddressInBytes) | ||
212 | { | ||
213 | memcpy(ptrClassifierIpMask + | ||
214 | (ucLoopIndex * nSizeOfIPAddressInBytes), | ||
215 | (pu8IpAddressMaskSrc+nSizeOfIPAddressInBytes + | ||
216 | (ucLoopIndex*nSizeOfIPAddressInBytes*2)), | ||
217 | nSizeOfIPAddressInBytes); | ||
218 | if(!bIpVersion6) | ||
219 | { | ||
220 | if(eIpAddrContext == eSrcIpAddress) | ||
221 | { | ||
222 | pstClassifierEntry->stSrcIpAddress. | ||
223 | ulIpv4Mask[ucLoopIndex]= | ||
224 | ntohl(pstClassifierEntry->stSrcIpAddress. | ||
225 | ulIpv4Mask[ucLoopIndex]); | ||
226 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Src Ip Mask Address:0x%luX ",pstClassifierEntry->stSrcIpAddress.ulIpv4Mask[ucLoopIndex]); | ||
227 | } | ||
228 | else if(eIpAddrContext == eDestIpAddress) | ||
229 | { | ||
230 | pstClassifierEntry->stDestIpAddress. | ||
231 | ulIpv4Mask[ucLoopIndex] = | ||
232 | ntohl(pstClassifierEntry->stDestIpAddress. | ||
233 | ulIpv4Mask[ucLoopIndex]); | ||
234 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Dest Ip Mask Address:0x%luX ",pstClassifierEntry->stDestIpAddress.ulIpv4Mask[ucLoopIndex]); | ||
235 | } | ||
236 | } | ||
237 | u8IpAddressLen-=nSizeOfIPAddressInBytes; | ||
238 | } | ||
239 | if(0==u8IpAddressLen) | ||
240 | { | ||
241 | pstClassifierEntry->bDestIpValid=TRUE; | ||
242 | } | ||
243 | ucLoopIndex++; | ||
244 | } | ||
245 | if(bIpVersion6) | ||
246 | { | ||
247 | //Restore EndianNess of Struct | ||
248 | for(ucLoopIndex =0 ; ucLoopIndex < MAX_IP_RANGE_LENGTH * 4 ; | ||
249 | ucLoopIndex++) | ||
250 | { | ||
251 | if(eIpAddrContext == eSrcIpAddress) | ||
252 | { | ||
253 | pstClassifierEntry->stSrcIpAddress.ulIpv6Addr[ucLoopIndex]= | ||
254 | ntohl(pstClassifierEntry->stSrcIpAddress. | ||
255 | ulIpv6Addr[ucLoopIndex]); | ||
256 | pstClassifierEntry->stSrcIpAddress.ulIpv6Mask[ucLoopIndex]= ntohl(pstClassifierEntry->stSrcIpAddress. | ||
257 | ulIpv6Mask[ucLoopIndex]); | ||
258 | } | ||
259 | else if(eIpAddrContext == eDestIpAddress) | ||
260 | { | ||
261 | pstClassifierEntry->stDestIpAddress.ulIpv6Addr[ucLoopIndex]= ntohl(pstClassifierEntry->stDestIpAddress. | ||
262 | ulIpv6Addr[ucLoopIndex]); | ||
263 | pstClassifierEntry->stDestIpAddress.ulIpv6Mask[ucLoopIndex]= ntohl(pstClassifierEntry->stDestIpAddress. | ||
264 | ulIpv6Mask[ucLoopIndex]); | ||
265 | } | ||
266 | } | ||
267 | } | ||
268 | } | ||
269 | } | ||
270 | |||
271 | |||
272 | void ClearTargetDSXBuffer(PMINI_ADAPTER Adapter,B_UINT16 TID,BOOLEAN bFreeAll) | ||
273 | { | ||
274 | ULONG ulIndex; | ||
275 | for(ulIndex=0; ulIndex < Adapter->ulTotalTargetBuffersAvailable; ulIndex++) | ||
276 | { | ||
277 | if(Adapter->astTargetDsxBuffer[ulIndex].valid) | ||
278 | continue; | ||
279 | if ((bFreeAll) || (Adapter->astTargetDsxBuffer[ulIndex].tid == TID)){ | ||
280 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "ClearTargetDSXBuffer: found tid %d buffer cleared %lx\n", | ||
281 | TID, Adapter->astTargetDsxBuffer[ulIndex].ulTargetDsxBuffer); | ||
282 | Adapter->astTargetDsxBuffer[ulIndex].valid=1; | ||
283 | Adapter->astTargetDsxBuffer[ulIndex].tid=0; | ||
284 | Adapter->ulFreeTargetBufferCnt++; | ||
285 | } | ||
286 | } | ||
287 | } | ||
288 | |||
289 | /** | ||
290 | @ingroup ctrl_pkt_functions | ||
291 | copy classifier rule into the specified SF index | ||
292 | */ | ||
293 | static inline VOID CopyClassifierRuleToSF(PMINI_ADAPTER Adapter,stConvergenceSLTypes *psfCSType,UINT uiSearchRuleIndex,UINT nClassifierIndex) | ||
294 | { | ||
295 | S_CLASSIFIER_RULE *pstClassifierEntry = NULL; | ||
296 | //VOID *pvPhsContext = NULL; | ||
297 | UINT ucLoopIndex=0; | ||
298 | //UCHAR ucProtocolLength=0; | ||
299 | //ULONG ulPhsStatus; | ||
300 | |||
301 | |||
302 | if(Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value == 0 || | ||
303 | nClassifierIndex > (MAX_CLASSIFIERS-1)) | ||
304 | return; | ||
305 | |||
306 | |||
307 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Storing Classifier Rule Index : %X",ntohs(psfCSType->cCPacketClassificationRule.u16PacketClassificationRuleIndex)); | ||
308 | |||
309 | if(nClassifierIndex > MAX_CLASSIFIERS-1) | ||
310 | return; | ||
311 | |||
312 | pstClassifierEntry = &Adapter->astClassifierTable[nClassifierIndex]; | ||
313 | if(pstClassifierEntry) | ||
314 | { | ||
315 | //Store if Ipv6 | ||
316 | pstClassifierEntry->bIpv6Protocol = | ||
317 | (Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion == IPV6)?TRUE:FALSE; | ||
318 | |||
319 | //Destinaiton Port | ||
320 | pstClassifierEntry->ucDestPortRangeLength=psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRangeLength/4; | ||
321 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Destination Port Range Length:0x%X ",pstClassifierEntry->ucDestPortRangeLength); | ||
322 | if( MAX_PORT_RANGE >= psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRangeLength) | ||
323 | { | ||
324 | for(ucLoopIndex=0;ucLoopIndex<(pstClassifierEntry->ucDestPortRangeLength);ucLoopIndex++) | ||
325 | { | ||
326 | pstClassifierEntry->usDestPortRangeLo[ucLoopIndex] = | ||
327 | *((PUSHORT)(psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange+ucLoopIndex)); | ||
328 | pstClassifierEntry->usDestPortRangeHi[ucLoopIndex] = | ||
329 | *((PUSHORT)(psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange+2+ucLoopIndex)); | ||
330 | pstClassifierEntry->usDestPortRangeLo[ucLoopIndex]=ntohs(pstClassifierEntry->usDestPortRangeLo[ucLoopIndex]); | ||
331 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Destination Port Range Lo:0x%X ",pstClassifierEntry->usDestPortRangeLo[ucLoopIndex]); | ||
332 | pstClassifierEntry->usDestPortRangeHi[ucLoopIndex]=ntohs(pstClassifierEntry->usDestPortRangeHi[ucLoopIndex]); | ||
333 | } | ||
334 | } | ||
335 | else | ||
336 | { | ||
337 | pstClassifierEntry->ucDestPortRangeLength=0; | ||
338 | } | ||
339 | //Source Port | ||
340 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Source Port Range Length:0x%X ",psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRangeLength); | ||
341 | if(MAX_PORT_RANGE >= | ||
342 | psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRangeLength) | ||
343 | { | ||
344 | pstClassifierEntry->ucSrcPortRangeLength = | ||
345 | psfCSType->cCPacketClassificationRule. | ||
346 | u8ProtocolSourcePortRangeLength/4; | ||
347 | for(ucLoopIndex = 0; ucLoopIndex < | ||
348 | (pstClassifierEntry->ucSrcPortRangeLength); ucLoopIndex++) | ||
349 | { | ||
350 | pstClassifierEntry->usSrcPortRangeLo[ucLoopIndex] = | ||
351 | *((PUSHORT)(psfCSType->cCPacketClassificationRule. | ||
352 | u8ProtocolSourcePortRange+ucLoopIndex)); | ||
353 | pstClassifierEntry->usSrcPortRangeHi[ucLoopIndex] = | ||
354 | *((PUSHORT)(psfCSType->cCPacketClassificationRule. | ||
355 | u8ProtocolSourcePortRange+2+ucLoopIndex)); | ||
356 | pstClassifierEntry->usSrcPortRangeLo[ucLoopIndex] = | ||
357 | ntohs(pstClassifierEntry->usSrcPortRangeLo[ucLoopIndex]); | ||
358 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Source Port Range Lo:0x%X ",pstClassifierEntry->usSrcPortRangeLo[ucLoopIndex]); | ||
359 | pstClassifierEntry->usSrcPortRangeHi[ucLoopIndex]=ntohs(pstClassifierEntry->usSrcPortRangeHi[ucLoopIndex]); | ||
360 | } | ||
361 | } | ||
362 | //Destination Ip Address and Mask | ||
363 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Ip Destination Parameters : "); | ||
364 | |||
365 | CopyIpAddrToClassifier(pstClassifierEntry, | ||
366 | psfCSType->cCPacketClassificationRule.u8IPDestinationAddressLength, | ||
367 | psfCSType->cCPacketClassificationRule.u8IPDestinationAddress, | ||
368 | (Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion == IPV6)? | ||
369 | TRUE:FALSE, eDestIpAddress); | ||
370 | |||
371 | //Source Ip Address and Mask | ||
372 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Ip Source Parameters : "); | ||
373 | |||
374 | CopyIpAddrToClassifier(pstClassifierEntry, | ||
375 | psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddressLength, | ||
376 | psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddress, | ||
377 | (Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion == IPV6)?TRUE:FALSE, | ||
378 | eSrcIpAddress); | ||
379 | |||
380 | //TOS | ||
381 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"TOS Length:0x%X ",psfCSType->cCPacketClassificationRule.u8IPTypeOfServiceLength); | ||
382 | if(3 == psfCSType->cCPacketClassificationRule.u8IPTypeOfServiceLength) | ||
383 | { | ||
384 | pstClassifierEntry->ucIPTypeOfServiceLength = | ||
385 | psfCSType->cCPacketClassificationRule.u8IPTypeOfServiceLength; | ||
386 | pstClassifierEntry->ucTosLow = | ||
387 | psfCSType->cCPacketClassificationRule.u8IPTypeOfService[0]; | ||
388 | pstClassifierEntry->ucTosHigh = | ||
389 | psfCSType->cCPacketClassificationRule.u8IPTypeOfService[1]; | ||
390 | pstClassifierEntry->ucTosMask = | ||
391 | psfCSType->cCPacketClassificationRule.u8IPTypeOfService[2]; | ||
392 | pstClassifierEntry->bTOSValid = TRUE; | ||
393 | } | ||
394 | if(psfCSType->cCPacketClassificationRule.u8Protocol == 0) | ||
395 | { | ||
396 | //we didnt get protocol field filled in by the BS | ||
397 | pstClassifierEntry->ucProtocolLength=0; | ||
398 | } | ||
399 | else | ||
400 | { | ||
401 | pstClassifierEntry->ucProtocolLength=1;// 1 valid protocol | ||
402 | } | ||
403 | |||
404 | pstClassifierEntry->ucProtocol[0] = | ||
405 | psfCSType->cCPacketClassificationRule.u8Protocol; | ||
406 | |||
407 | pstClassifierEntry->u8ClassifierRulePriority = | ||
408 | psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority; | ||
409 | |||
410 | //store the classifier rule ID and set this classifier entry as valid | ||
411 | pstClassifierEntry->ucDirection = | ||
412 | Adapter->PackInfo[uiSearchRuleIndex].ucDirection; | ||
413 | pstClassifierEntry->uiClassifierRuleIndex = ntohs(psfCSType-> | ||
414 | cCPacketClassificationRule.u16PacketClassificationRuleIndex); | ||
415 | pstClassifierEntry->usVCID_Value = | ||
416 | Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value; | ||
417 | pstClassifierEntry->ulSFID = | ||
418 | Adapter->PackInfo[uiSearchRuleIndex].ulSFID; | ||
419 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Search Index %d Dir: %d, Index: %d, Vcid: %d\n", | ||
420 | uiSearchRuleIndex, pstClassifierEntry->ucDirection, | ||
421 | pstClassifierEntry->uiClassifierRuleIndex, | ||
422 | pstClassifierEntry->usVCID_Value); | ||
423 | |||
424 | if(psfCSType->cCPacketClassificationRule.u8AssociatedPHSI) | ||
425 | { | ||
426 | pstClassifierEntry->u8AssociatedPHSI = psfCSType->cCPacketClassificationRule.u8AssociatedPHSI; | ||
427 | } | ||
428 | |||
429 | //Copy ETH CS Parameters | ||
430 | pstClassifierEntry->ucEthCSSrcMACLen = (psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddressLength); | ||
431 | memcpy(pstClassifierEntry->au8EThCSSrcMAC,psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress,MAC_ADDRESS_SIZE); | ||
432 | memcpy(pstClassifierEntry->au8EThCSSrcMACMask,psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress+MAC_ADDRESS_SIZE,MAC_ADDRESS_SIZE); | ||
433 | pstClassifierEntry->ucEthCSDestMACLen = (psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength); | ||
434 | memcpy(pstClassifierEntry->au8EThCSDestMAC,psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress,MAC_ADDRESS_SIZE); | ||
435 | memcpy(pstClassifierEntry->au8EThCSDestMACMask,psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress+MAC_ADDRESS_SIZE,MAC_ADDRESS_SIZE); | ||
436 | pstClassifierEntry->ucEtherTypeLen = (psfCSType->cCPacketClassificationRule.u8EthertypeLength); | ||
437 | memcpy(pstClassifierEntry->au8EthCSEtherType,psfCSType->cCPacketClassificationRule.u8Ethertype,NUM_ETHERTYPE_BYTES); | ||
438 | memcpy(pstClassifierEntry->usUserPriority, &psfCSType->cCPacketClassificationRule.u16UserPriority, 2); | ||
439 | pstClassifierEntry->usVLANID = ntohs(psfCSType->cCPacketClassificationRule.u16VLANID); | ||
440 | pstClassifierEntry->usValidityBitMap = ntohs(psfCSType->cCPacketClassificationRule.u16ValidityBitMap); | ||
441 | |||
442 | pstClassifierEntry->bUsed = TRUE; | ||
443 | } | ||
444 | } | ||
445 | |||
446 | |||
447 | /** | ||
448 | @ingroup ctrl_pkt_functions | ||
449 | */ | ||
450 | static inline VOID DeleteClassifierRuleFromSF(PMINI_ADAPTER Adapter,UINT uiSearchRuleIndex,UINT nClassifierIndex) | ||
451 | { | ||
452 | S_CLASSIFIER_RULE *pstClassifierEntry = NULL; | ||
453 | B_UINT16 u16PacketClassificationRuleIndex; | ||
454 | USHORT usVCID; | ||
455 | //VOID *pvPhsContext = NULL; | ||
456 | //ULONG ulPhsStatus; | ||
457 | |||
458 | usVCID = Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value; | ||
459 | |||
460 | if(nClassifierIndex > MAX_CLASSIFIERS-1) | ||
461 | return; | ||
462 | |||
463 | if(usVCID == 0) | ||
464 | return; | ||
465 | |||
466 | u16PacketClassificationRuleIndex = Adapter->astClassifierTable[nClassifierIndex].uiClassifierRuleIndex; | ||
467 | |||
468 | |||
469 | pstClassifierEntry = &Adapter->astClassifierTable[nClassifierIndex]; | ||
470 | if(pstClassifierEntry) | ||
471 | { | ||
472 | pstClassifierEntry->bUsed = FALSE; | ||
473 | pstClassifierEntry->uiClassifierRuleIndex = 0; | ||
474 | memset(pstClassifierEntry,0,sizeof(S_CLASSIFIER_RULE)); | ||
475 | |||
476 | //Delete the PHS Rule for this classifier | ||
477 | PhsDeleteClassifierRule( | ||
478 | &Adapter->stBCMPhsContext, | ||
479 | usVCID, | ||
480 | u16PacketClassificationRuleIndex); | ||
481 | } | ||
482 | } | ||
483 | |||
484 | /** | ||
485 | @ingroup ctrl_pkt_functions | ||
486 | */ | ||
487 | VOID DeleteAllClassifiersForSF(PMINI_ADAPTER Adapter,UINT uiSearchRuleIndex) | ||
488 | { | ||
489 | S_CLASSIFIER_RULE *pstClassifierEntry = NULL; | ||
490 | UINT nClassifierIndex; | ||
491 | //B_UINT16 u16PacketClassificationRuleIndex; | ||
492 | USHORT ulVCID; | ||
493 | //VOID *pvPhsContext = NULL; | ||
494 | //ULONG ulPhsStatus; | ||
495 | |||
496 | ulVCID = Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value; | ||
497 | |||
498 | if(ulVCID == 0) | ||
499 | return; | ||
500 | |||
501 | |||
502 | for(nClassifierIndex =0 ; nClassifierIndex < MAX_CLASSIFIERS ; nClassifierIndex++) | ||
503 | { | ||
504 | if(Adapter->astClassifierTable[nClassifierIndex].usVCID_Value == ulVCID) | ||
505 | { | ||
506 | pstClassifierEntry = &Adapter->astClassifierTable[nClassifierIndex]; | ||
507 | if(pstClassifierEntry->bUsed) | ||
508 | { | ||
509 | DeleteClassifierRuleFromSF(Adapter,uiSearchRuleIndex,nClassifierIndex); | ||
510 | } | ||
511 | } | ||
512 | } | ||
513 | |||
514 | //Delete All Phs Rules Associated with this SF | ||
515 | PhsDeleteSFRules( | ||
516 | &Adapter->stBCMPhsContext, | ||
517 | ulVCID); | ||
518 | |||
519 | } | ||
520 | |||
521 | |||
522 | /** | ||
523 | This routinue copies the Connection Management | ||
524 | related data into the Adapter structure. | ||
525 | @ingroup ctrl_pkt_functions | ||
526 | */ | ||
527 | |||
528 | static VOID CopyToAdapter( register PMINI_ADAPTER Adapter, /**<Pointer to the Adapter structure*/ | ||
529 | register pstServiceFlowParamSI psfLocalSet, /**<Pointer to the ServiceFlowParamSI structure*/ | ||
530 | register UINT uiSearchRuleIndex, /**<Index of Queue, to which this data belongs*/ | ||
531 | register UCHAR ucDsxType, | ||
532 | stLocalSFAddIndicationAlt *pstAddIndication) | ||
533 | { | ||
534 | //UCHAR ucProtocolLength=0; | ||
535 | ULONG ulSFID; | ||
536 | UINT nClassifierIndex = 0; | ||
537 | E_CLASSIFIER_ACTION eClassifierAction = eInvalidClassifierAction; | ||
538 | B_UINT16 u16PacketClassificationRuleIndex=0; | ||
539 | UINT nIndex=0; | ||
540 | stConvergenceSLTypes *psfCSType = NULL; | ||
541 | S_PHS_RULE sPhsRule; | ||
542 | USHORT uVCID = Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value; | ||
543 | UINT UGIValue = 0; | ||
544 | |||
545 | |||
546 | Adapter->PackInfo[uiSearchRuleIndex].bValid=TRUE; | ||
547 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Search Rule Index = %d\n", uiSearchRuleIndex); | ||
548 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"%s: SFID= %x ",__FUNCTION__, ntohl(psfLocalSet->u32SFID)); | ||
549 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Updating Queue %d",uiSearchRuleIndex); | ||
550 | |||
551 | ulSFID = ntohl(psfLocalSet->u32SFID); | ||
552 | //Store IP Version used | ||
553 | //Get The Version Of IP used (IPv6 or IPv4) from CSSpecification field of SF | ||
554 | |||
555 | Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = 0; | ||
556 | Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = 0; | ||
557 | |||
558 | /*Enable IP/ETh CS Support As Required*/ | ||
559 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"CopyToAdapter : u8CSSpecification : %X\n",psfLocalSet->u8CSSpecification); | ||
560 | switch(psfLocalSet->u8CSSpecification) | ||
561 | { | ||
562 | case eCSPacketIPV4: | ||
563 | { | ||
564 | Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV4_CS; | ||
565 | break; | ||
566 | } | ||
567 | case eCSPacketIPV6: | ||
568 | { | ||
569 | Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV6_CS; | ||
570 | break; | ||
571 | } | ||
572 | |||
573 | case eCS802_3PacketEthernet: | ||
574 | case eCS802_1QPacketVLAN: | ||
575 | { | ||
576 | Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = ETH_CS_802_3; | ||
577 | break; | ||
578 | } | ||
579 | |||
580 | case eCSPacketIPV4Over802_1QVLAN: | ||
581 | case eCSPacketIPV4Over802_3Ethernet: | ||
582 | { | ||
583 | Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV4_CS; | ||
584 | Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = ETH_CS_802_3; | ||
585 | break; | ||
586 | } | ||
587 | |||
588 | case eCSPacketIPV6Over802_1QVLAN: | ||
589 | case eCSPacketIPV6Over802_3Ethernet: | ||
590 | { | ||
591 | Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV6_CS; | ||
592 | Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = ETH_CS_802_3; | ||
593 | break; | ||
594 | } | ||
595 | |||
596 | default: | ||
597 | { | ||
598 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Error in value of CS Classification.. setting default to IP CS\n"); | ||
599 | Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV4_CS; | ||
600 | break; | ||
601 | } | ||
602 | } | ||
603 | |||
604 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"CopyToAdapter : Queue No : %X ETH CS Support : %X , IP CS Support : %X \n", | ||
605 | uiSearchRuleIndex, | ||
606 | Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport, | ||
607 | Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport); | ||
608 | |||
609 | //Store IP Version used | ||
610 | //Get The Version Of IP used (IPv6 or IPv4) from CSSpecification field of SF | ||
611 | if(Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport == IPV6_CS) | ||
612 | { | ||
613 | Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion = IPV6; | ||
614 | } | ||
615 | else | ||
616 | { | ||
617 | Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion = IPV4; | ||
618 | } | ||
619 | |||
620 | /* To ensure that the ETH CS code doesn't gets executed if the BS doesn't supports ETH CS */ | ||
621 | if(!Adapter->bETHCSEnabled) | ||
622 | Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = 0; | ||
623 | |||
624 | if(psfLocalSet->u8ServiceClassNameLength > 0 && | ||
625 | psfLocalSet->u8ServiceClassNameLength < 32) | ||
626 | { | ||
627 | memcpy(Adapter->PackInfo[uiSearchRuleIndex].ucServiceClassName, | ||
628 | psfLocalSet->u8ServiceClassName, | ||
629 | psfLocalSet->u8ServiceClassNameLength); | ||
630 | } | ||
631 | Adapter->PackInfo[uiSearchRuleIndex].u8QueueType = | ||
632 | psfLocalSet->u8ServiceFlowSchedulingType; | ||
633 | |||
634 | if(Adapter->PackInfo[uiSearchRuleIndex].u8QueueType==BE && | ||
635 | Adapter->PackInfo[uiSearchRuleIndex].ucDirection) | ||
636 | { | ||
637 | Adapter->usBestEffortQueueIndex=uiSearchRuleIndex; | ||
638 | } | ||
639 | |||
640 | Adapter->PackInfo[uiSearchRuleIndex].ulSFID = ntohl(psfLocalSet->u32SFID); | ||
641 | |||
642 | Adapter->PackInfo[uiSearchRuleIndex].u8TrafficPriority = psfLocalSet->u8TrafficPriority; | ||
643 | |||
644 | //copy all the classifier in the Service Flow param structure | ||
645 | for(nIndex=0; nIndex<psfLocalSet->u8TotalClassifiers; nIndex++) | ||
646 | { | ||
647 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Classifier index =%d",nIndex); | ||
648 | psfCSType = &psfLocalSet->cConvergenceSLTypes[nIndex]; | ||
649 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Classifier index =%d",nIndex); | ||
650 | |||
651 | if(psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority) | ||
652 | { | ||
653 | Adapter->PackInfo[uiSearchRuleIndex].bClassifierPriority=TRUE; | ||
654 | } | ||
655 | |||
656 | if(psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority) | ||
657 | { | ||
658 | Adapter->PackInfo[uiSearchRuleIndex].bClassifierPriority=TRUE; | ||
659 | } | ||
660 | |||
661 | |||
662 | if(ucDsxType== DSA_ACK) | ||
663 | { | ||
664 | eClassifierAction = eAddClassifier; | ||
665 | } | ||
666 | else if(ucDsxType == DSC_ACK) | ||
667 | { | ||
668 | switch(psfCSType->u8ClassfierDSCAction) | ||
669 | { | ||
670 | case 0://DSC Add Classifier | ||
671 | { | ||
672 | eClassifierAction = eAddClassifier; | ||
673 | } | ||
674 | break; | ||
675 | case 1://DSC Replace Classifier | ||
676 | { | ||
677 | eClassifierAction = eReplaceClassifier; | ||
678 | } | ||
679 | break; | ||
680 | case 2://DSC Delete Classifier | ||
681 | { | ||
682 | eClassifierAction = eDeleteClassifier; | ||
683 | |||
684 | } | ||
685 | break; | ||
686 | default: | ||
687 | { | ||
688 | eClassifierAction = eInvalidClassifierAction; | ||
689 | } | ||
690 | } | ||
691 | } | ||
692 | |||
693 | u16PacketClassificationRuleIndex = ntohs(psfCSType->cCPacketClassificationRule.u16PacketClassificationRuleIndex); | ||
694 | |||
695 | switch(eClassifierAction) | ||
696 | { | ||
697 | case eAddClassifier: | ||
698 | { | ||
699 | //Get a Free Classifier Index From Classifier table for this SF to add the Classifier | ||
700 | //Contained in this message | ||
701 | nClassifierIndex = SearchClsid(Adapter,ulSFID,u16PacketClassificationRuleIndex); | ||
702 | |||
703 | if(nClassifierIndex > MAX_CLASSIFIERS) | ||
704 | { | ||
705 | nClassifierIndex = SearchFreeClsid(Adapter); | ||
706 | if(nClassifierIndex > MAX_CLASSIFIERS) | ||
707 | { | ||
708 | //Failed To get a free Entry | ||
709 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Error Failed To get a free Classifier Entry"); | ||
710 | break; | ||
711 | } | ||
712 | //Copy the Classifier Rule for this service flow into our Classifier table maintained per SF. | ||
713 | CopyClassifierRuleToSF(Adapter,psfCSType,uiSearchRuleIndex,nClassifierIndex); | ||
714 | } | ||
715 | |||
716 | else | ||
717 | { | ||
718 | //This Classifier Already Exists and it is invalid to Add Classifier with existing PCRI | ||
719 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"CopyToAdapter : Error The Specified Classifier Already Exists \ | ||
720 | and attempted To Add Classifier with Same PCRI : 0x%x\n", u16PacketClassificationRuleIndex); | ||
721 | } | ||
722 | } | ||
723 | break; | ||
724 | |||
725 | case eReplaceClassifier: | ||
726 | { | ||
727 | //Get the Classifier Index From Classifier table for this SF and replace existing Classifier | ||
728 | //with the new classifier Contained in this message | ||
729 | nClassifierIndex = SearchClsid(Adapter,ulSFID,u16PacketClassificationRuleIndex); | ||
730 | if(nClassifierIndex > MAX_CLASSIFIERS) | ||
731 | { | ||
732 | //Failed To search the classifier | ||
733 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Error Search for Classifier To be replaced failed"); | ||
734 | break; | ||
735 | } | ||
736 | //Copy the Classifier Rule for this service flow into our Classifier table maintained per SF. | ||
737 | CopyClassifierRuleToSF(Adapter,psfCSType,uiSearchRuleIndex,nClassifierIndex); | ||
738 | } | ||
739 | break; | ||
740 | |||
741 | case eDeleteClassifier: | ||
742 | { | ||
743 | //Get the Classifier Index From Classifier table for this SF and replace existing Classifier | ||
744 | //with the new classifier Contained in this message | ||
745 | nClassifierIndex = SearchClsid(Adapter,ulSFID,u16PacketClassificationRuleIndex); | ||
746 | if(nClassifierIndex > MAX_CLASSIFIERS) | ||
747 | { | ||
748 | //Failed To search the classifier | ||
749 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Error Search for Classifier To be deleted failed"); | ||
750 | break; | ||
751 | } | ||
752 | |||
753 | //Delete This classifier | ||
754 | DeleteClassifierRuleFromSF(Adapter,uiSearchRuleIndex,nClassifierIndex); | ||
755 | } | ||
756 | break; | ||
757 | |||
758 | default: | ||
759 | { | ||
760 | //Invalid Action for classifier | ||
761 | break; | ||
762 | } | ||
763 | } | ||
764 | } | ||
765 | |||
766 | //Repeat parsing Classification Entries to process PHS Rules | ||
767 | for(nIndex=0; nIndex < psfLocalSet->u8TotalClassifiers; nIndex++) | ||
768 | { | ||
769 | psfCSType = &psfLocalSet->cConvergenceSLTypes[nIndex]; | ||
770 | |||
771 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "psfCSType->u8PhsDSCAction : 0x%x\n", | ||
772 | psfCSType->u8PhsDSCAction ); | ||
773 | |||
774 | switch (psfCSType->u8PhsDSCAction) | ||
775 | { | ||
776 | case eDeleteAllPHSRules: | ||
777 | { | ||
778 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Deleting All PHS Rules For VCID: 0x%X\n",uVCID); | ||
779 | |||
780 | //Delete All the PHS rules for this Service flow | ||
781 | |||
782 | PhsDeleteSFRules( | ||
783 | &Adapter->stBCMPhsContext, | ||
784 | uVCID); | ||
785 | |||
786 | break; | ||
787 | } | ||
788 | case eDeletePHSRule: | ||
789 | { | ||
790 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"PHS DSC Action = Delete PHS Rule \n"); | ||
791 | |||
792 | if(psfCSType->cPhsRule.u8PHSI) | ||
793 | { | ||
794 | PhsDeletePHSRule( | ||
795 | &Adapter->stBCMPhsContext, | ||
796 | uVCID, | ||
797 | psfCSType->cCPacketClassificationRule.u8AssociatedPHSI); | ||
798 | } | ||
799 | else | ||
800 | { | ||
801 | //BCM_DEBUG_PRINT(CONN_MSG,("Error CPHSRule.PHSI is ZERO \n")); | ||
802 | } | ||
803 | break; | ||
804 | } | ||
805 | default : | ||
806 | { | ||
807 | if(ucDsxType == DSC_ACK) | ||
808 | { | ||
809 | //BCM_DEBUG_PRINT(CONN_MSG,("Invalid PHS DSC Action For DSC \n",psfCSType->cPhsRule.u8PHSI)); | ||
810 | break; //FOr DSC ACK Case PHS DSC Action must be in valid set | ||
811 | } | ||
812 | } | ||
813 | //Proceed To Add PHS rule for DSA_ACK case even if PHS DSC action is unspecified | ||
814 | //No Break Here . Intentionally! | ||
815 | |||
816 | case eAddPHSRule: | ||
817 | case eSetPHSRule: | ||
818 | { | ||
819 | if(psfCSType->cPhsRule.u8PHSI) | ||
820 | { | ||
821 | //Apply This PHS Rule to all classifiers whose Associated PHSI Match | ||
822 | unsigned int uiClassifierIndex = 0; | ||
823 | if(pstAddIndication->u8Direction == UPLINK_DIR ) | ||
824 | { | ||
825 | for(uiClassifierIndex=0;uiClassifierIndex<MAX_CLASSIFIERS;uiClassifierIndex++) | ||
826 | { | ||
827 | if((Adapter->astClassifierTable[uiClassifierIndex].bUsed) && | ||
828 | (Adapter->astClassifierTable[uiClassifierIndex].ulSFID == Adapter->PackInfo[uiSearchRuleIndex].ulSFID) && | ||
829 | (Adapter->astClassifierTable[uiClassifierIndex].u8AssociatedPHSI == psfCSType->cPhsRule.u8PHSI)) | ||
830 | { | ||
831 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Adding PHS Rule For Classifier : 0x%x cPhsRule.u8PHSI : 0x%x\n", | ||
832 | Adapter->astClassifierTable[uiClassifierIndex].uiClassifierRuleIndex, | ||
833 | psfCSType->cPhsRule.u8PHSI); | ||
834 | //Update The PHS Rule for this classifier as Associated PHSI id defined | ||
835 | |||
836 | //Copy the PHS Rule | ||
837 | sPhsRule.u8PHSI = psfCSType->cPhsRule.u8PHSI; | ||
838 | sPhsRule.u8PHSFLength = psfCSType->cPhsRule.u8PHSFLength; | ||
839 | sPhsRule.u8PHSMLength = psfCSType->cPhsRule.u8PHSMLength; | ||
840 | sPhsRule.u8PHSS = psfCSType->cPhsRule.u8PHSS; | ||
841 | sPhsRule.u8PHSV = psfCSType->cPhsRule.u8PHSV; | ||
842 | memcpy(sPhsRule.u8PHSF,psfCSType->cPhsRule.u8PHSF,MAX_PHS_LENGTHS); | ||
843 | memcpy(sPhsRule.u8PHSM,psfCSType->cPhsRule.u8PHSM,MAX_PHS_LENGTHS); | ||
844 | sPhsRule.u8RefCnt = 0; | ||
845 | sPhsRule.bUnclassifiedPHSRule = FALSE; | ||
846 | sPhsRule.PHSModifiedBytes = 0; | ||
847 | sPhsRule.PHSModifiedNumPackets = 0; | ||
848 | sPhsRule.PHSErrorNumPackets = 0; | ||
849 | |||
850 | //bPHSRuleAssociated = TRUE; | ||
851 | //Store The PHS Rule for this classifier | ||
852 | |||
853 | PhsUpdateClassifierRule( | ||
854 | &Adapter->stBCMPhsContext, | ||
855 | uVCID, | ||
856 | Adapter->astClassifierTable[uiClassifierIndex].uiClassifierRuleIndex, | ||
857 | &sPhsRule, | ||
858 | Adapter->astClassifierTable[uiClassifierIndex].u8AssociatedPHSI); | ||
859 | |||
860 | //Update PHS Rule For the Classifier | ||
861 | if(sPhsRule.u8PHSI) | ||
862 | { | ||
863 | Adapter->astClassifierTable[uiClassifierIndex].u32PHSRuleID = sPhsRule.u8PHSI; | ||
864 | memcpy(&Adapter->astClassifierTable[uiClassifierIndex].sPhsRule,&sPhsRule,sizeof(S_PHS_RULE)); | ||
865 | } | ||
866 | |||
867 | } | ||
868 | } | ||
869 | } | ||
870 | else | ||
871 | { | ||
872 | //Error PHS Rule specified in signaling could not be applied to any classifier | ||
873 | |||
874 | //Copy the PHS Rule | ||
875 | sPhsRule.u8PHSI = psfCSType->cPhsRule.u8PHSI; | ||
876 | sPhsRule.u8PHSFLength = psfCSType->cPhsRule.u8PHSFLength; | ||
877 | sPhsRule.u8PHSMLength = psfCSType->cPhsRule.u8PHSMLength; | ||
878 | sPhsRule.u8PHSS = psfCSType->cPhsRule.u8PHSS; | ||
879 | sPhsRule.u8PHSV = psfCSType->cPhsRule.u8PHSV; | ||
880 | memcpy(sPhsRule.u8PHSF,psfCSType->cPhsRule.u8PHSF,MAX_PHS_LENGTHS); | ||
881 | memcpy(sPhsRule.u8PHSM,psfCSType->cPhsRule.u8PHSM,MAX_PHS_LENGTHS); | ||
882 | sPhsRule.u8RefCnt = 0; | ||
883 | sPhsRule.bUnclassifiedPHSRule = TRUE; | ||
884 | sPhsRule.PHSModifiedBytes = 0; | ||
885 | sPhsRule.PHSModifiedNumPackets = 0; | ||
886 | sPhsRule.PHSErrorNumPackets = 0; | ||
887 | //Store The PHS Rule for this classifier | ||
888 | |||
889 | /* | ||
890 | Passing the argument u8PHSI instead of clsid. Because for DL with no classifier rule, | ||
891 | clsid will be zero hence we cant have multiple PHS rules for the same SF. | ||
892 | To support multiple PHS rule, passing u8PHSI. | ||
893 | */ | ||
894 | |||
895 | PhsUpdateClassifierRule( | ||
896 | &Adapter->stBCMPhsContext, | ||
897 | uVCID, | ||
898 | sPhsRule.u8PHSI, | ||
899 | &sPhsRule, | ||
900 | sPhsRule.u8PHSI); | ||
901 | |||
902 | } | ||
903 | |||
904 | } | ||
905 | } | ||
906 | break; | ||
907 | } | ||
908 | } | ||
909 | |||
910 | if(psfLocalSet->u32MaxSustainedTrafficRate == 0 ) | ||
911 | { | ||
912 | //No Rate Limit . Set Max Sustained Traffic Rate to Maximum | ||
913 | Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate = | ||
914 | WIMAX_MAX_ALLOWED_RATE; | ||
915 | |||
916 | } | ||
917 | else if (ntohl(psfLocalSet->u32MaxSustainedTrafficRate) > | ||
918 | WIMAX_MAX_ALLOWED_RATE) | ||
919 | { | ||
920 | //Too large Allowed Rate specified. Limiting to Wi Max Allowed rate | ||
921 | Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate = | ||
922 | WIMAX_MAX_ALLOWED_RATE; | ||
923 | } | ||
924 | else | ||
925 | { | ||
926 | Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate = | ||
927 | ntohl(psfLocalSet->u32MaxSustainedTrafficRate); | ||
928 | } | ||
929 | |||
930 | Adapter->PackInfo[uiSearchRuleIndex].uiMaxLatency = ntohl(psfLocalSet->u32MaximumLatency); | ||
931 | |||
932 | if(Adapter->PackInfo[uiSearchRuleIndex].uiMaxLatency == 0) /* 0 should be treated as infinite */ | ||
933 | Adapter->PackInfo[uiSearchRuleIndex].uiMaxLatency = MAX_LATENCY_ALLOWED; | ||
934 | |||
935 | |||
936 | if(( Adapter->PackInfo[uiSearchRuleIndex].u8QueueType == ERTPS || | ||
937 | Adapter->PackInfo[uiSearchRuleIndex].u8QueueType == UGS ) ) | ||
938 | UGIValue = ntohs(psfLocalSet->u16UnsolicitedGrantInterval); | ||
939 | |||
940 | if(UGIValue == 0) | ||
941 | UGIValue = DEFAULT_UG_INTERVAL; | ||
942 | |||
943 | /* | ||
944 | For UGI based connections... | ||
945 | DEFAULT_UGI_FACTOR*UGIInterval worth of data is the max token count at host... | ||
946 | The extra amount of token is to ensure that a large amount of jitter won't have loss in throughput... | ||
947 | In case of non-UGI based connection, 200 frames worth of data is the max token count at host... | ||
948 | */ | ||
949 | |||
950 | Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize = | ||
951 | (DEFAULT_UGI_FACTOR*Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate*UGIValue)/1000; | ||
952 | |||
953 | if(Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize < WIMAX_MAX_MTU*8) | ||
954 | { | ||
955 | UINT UGIFactor = 0; | ||
956 | /* Special Handling to ensure the biggest size of packet can go out from host to FW as follows: | ||
957 | 1. Any packet from Host to FW can go out in different packet size. | ||
958 | 2. So in case the Bucket count is smaller than MTU, the packets of size (Size > TokenCount), will get dropped. | ||
959 | 3. We can allow packets of MaxSize from Host->FW that can go out from FW in multiple SDUs by fragmentation at Wimax Layer | ||
960 | */ | ||
961 | UGIFactor = (Adapter->PackInfo[uiSearchRuleIndex].uiMaxLatency/UGIValue + 1); | ||
962 | |||
963 | if(UGIFactor > DEFAULT_UGI_FACTOR) | ||
964 | Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize = | ||
965 | (UGIFactor*Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate*UGIValue)/1000; | ||
966 | |||
967 | if(Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize > WIMAX_MAX_MTU*8) | ||
968 | Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize = WIMAX_MAX_MTU*8; | ||
969 | } | ||
970 | |||
971 | |||
972 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"LAT: %d, UGI: %d \n", Adapter->PackInfo[uiSearchRuleIndex].uiMaxLatency, UGIValue); | ||
973 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"uiMaxAllowedRate: 0x%x, u32MaxSustainedTrafficRate: 0x%x ,uiMaxBucketSize: 0x%x", | ||
974 | Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate, | ||
975 | ntohl(psfLocalSet->u32MaxSustainedTrafficRate), | ||
976 | Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize); | ||
977 | |||
978 | //copy the extended SF Parameters to Support MIBS | ||
979 | CopyMIBSExtendedSFParameters(Adapter,psfLocalSet,uiSearchRuleIndex); | ||
980 | |||
981 | //store header suppression enabled flag per SF | ||
982 | Adapter->PackInfo[uiSearchRuleIndex].bHeaderSuppressionEnabled = | ||
983 | !(psfLocalSet->u8RequesttransmissionPolicy & | ||
984 | MASK_DISABLE_HEADER_SUPPRESSION); | ||
985 | |||
986 | if(Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication) | ||
987 | { | ||
988 | bcm_kfree(Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication); | ||
989 | Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication = NULL; | ||
990 | } | ||
991 | Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication = pstAddIndication; | ||
992 | |||
993 | //Re Sort the SF list in PackInfo according to Traffic Priority | ||
994 | SortPackInfo(Adapter); | ||
995 | |||
996 | /* Re Sort the Classifier Rules table and re - arrange | ||
997 | according to Classifier Rule Priority */ | ||
998 | SortClassifiers(Adapter); | ||
999 | |||
1000 | DumpPhsRules(&Adapter->stBCMPhsContext); | ||
1001 | |||
1002 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"%s <=====", __FUNCTION__); | ||
1003 | } | ||
1004 | |||
1005 | |||
1006 | /*********************************************************************** | ||
1007 | * Function - DumpCmControlPacket | ||
1008 | * | ||
1009 | * Description - This routinue Dumps the Contents of the AddIndication | ||
1010 | * Structure in the Connection Management Control Packet | ||
1011 | * | ||
1012 | * Parameter - pvBuffer: Pointer to the buffer containing the | ||
1013 | * AddIndication data. | ||
1014 | * | ||
1015 | * Returns - None | ||
1016 | *************************************************************************/ | ||
1017 | VOID DumpCmControlPacket(PVOID pvBuffer) | ||
1018 | { | ||
1019 | UINT uiLoopIndex; | ||
1020 | UINT nIndex; | ||
1021 | stLocalSFAddIndicationAlt *pstAddIndication; | ||
1022 | UINT nCurClassifierCnt; | ||
1023 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
1024 | |||
1025 | pstAddIndication = (stLocalSFAddIndicationAlt *)pvBuffer; | ||
1026 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "======>"); | ||
1027 | |||
1028 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Type : 0x%X",pstAddIndication->u8Type); | ||
1029 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Direction : 0x%X",pstAddIndication->u8Direction); | ||
1030 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16TID: 0x%X", ntohs(pstAddIndication->u16TID)); | ||
1031 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16CID : 0x%X",ntohs(pstAddIndication->u16CID)); | ||
1032 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16VCID : 0x%X",ntohs(pstAddIndication->u16VCID)); | ||
1033 | |||
1034 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " AuthorizedSet--->"); | ||
1035 | |||
1036 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32SFID : 0x%X",htonl(pstAddIndication->sfAuthorizedSet.u32SFID)); | ||
1037 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16CID : 0x%X",htons(pstAddIndication->sfAuthorizedSet.u16CID)); | ||
1038 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceClassNameLength : 0x%X", | ||
1039 | pstAddIndication->sfAuthorizedSet.u8ServiceClassNameLength); | ||
1040 | |||
1041 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceClassName : 0x%X ,0x%X , 0x%X, 0x%X, 0x%X, 0x%X", | ||
1042 | pstAddIndication->sfAuthorizedSet.u8ServiceClassName[0], | ||
1043 | pstAddIndication->sfAuthorizedSet.u8ServiceClassName[1], | ||
1044 | pstAddIndication->sfAuthorizedSet.u8ServiceClassName[2], | ||
1045 | pstAddIndication->sfAuthorizedSet.u8ServiceClassName[3], | ||
1046 | pstAddIndication->sfAuthorizedSet.u8ServiceClassName[4], | ||
1047 | pstAddIndication->sfAuthorizedSet.u8ServiceClassName[5]); | ||
1048 | |||
1049 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8MBSService : 0x%X", | ||
1050 | pstAddIndication->sfAuthorizedSet.u8MBSService); | ||
1051 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8QosParamSet : 0x%X", | ||
1052 | pstAddIndication->sfAuthorizedSet.u8QosParamSet); | ||
1053 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TrafficPriority : 0x%X, %p", | ||
1054 | pstAddIndication->sfAuthorizedSet.u8TrafficPriority, &pstAddIndication->sfAuthorizedSet.u8TrafficPriority); | ||
1055 | |||
1056 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaxSustainedTrafficRate : 0x%X 0x%p", | ||
1057 | pstAddIndication->sfAuthorizedSet.u32MaxSustainedTrafficRate, | ||
1058 | &pstAddIndication->sfAuthorizedSet.u32MaxSustainedTrafficRate); | ||
1059 | |||
1060 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaxTrafficBurst : 0x%X", | ||
1061 | pstAddIndication->sfAuthorizedSet.u32MaxTrafficBurst); | ||
1062 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MinReservedTrafficRate : 0x%X", | ||
1063 | pstAddIndication->sfAuthorizedSet.u32MinReservedTrafficRate); | ||
1064 | #if 0 | ||
1065 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MinimumTolerableTrafficRate : 0x%X", | ||
1066 | pstAddIndication->sfAuthorizedSet.u32MinimumTolerableTrafficRate); | ||
1067 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32RequesttransmissionPolicy : 0x%X", | ||
1068 | pstAddIndication->sfAuthorizedSet.u32RequesttransmissionPolicy); | ||
1069 | #endif | ||
1070 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParamLength : 0x%X", | ||
1071 | pstAddIndication->sfAuthorizedSet.u8VendorSpecificQoSParamLength); | ||
1072 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParam : 0x%X", | ||
1073 | pstAddIndication->sfAuthorizedSet.u8VendorSpecificQoSParam[0]); | ||
1074 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceFlowSchedulingType : 0x%X", | ||
1075 | pstAddIndication->sfAuthorizedSet.u8ServiceFlowSchedulingType); | ||
1076 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32ToleratedJitter : 0x%X", | ||
1077 | pstAddIndication->sfAuthorizedSet.u32ToleratedJitter); | ||
1078 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaximumLatency : 0x%X", | ||
1079 | pstAddIndication->sfAuthorizedSet.u32MaximumLatency); | ||
1080 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8FixedLengthVSVariableLengthSDUIndicator: 0x%X", | ||
1081 | pstAddIndication->sfAuthorizedSet.u8FixedLengthVSVariableLengthSDUIndicator); | ||
1082 | |||
1083 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8SDUSize : 0x%X", | ||
1084 | pstAddIndication->sfAuthorizedSet.u8SDUSize); | ||
1085 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16TargetSAID : 0x%X", | ||
1086 | pstAddIndication->sfAuthorizedSet.u16TargetSAID); | ||
1087 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ARQEnable : 0x%X", | ||
1088 | pstAddIndication->sfAuthorizedSet.u8ARQEnable); | ||
1089 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQWindowSize : 0x%X", | ||
1090 | pstAddIndication->sfAuthorizedSet.u16ARQWindowSize); | ||
1091 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQRetryTxTimeOut : 0x%X", | ||
1092 | pstAddIndication->sfAuthorizedSet.u16ARQRetryTxTimeOut); | ||
1093 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQRetryRxTimeOut : 0x%X", | ||
1094 | pstAddIndication->sfAuthorizedSet.u16ARQRetryRxTimeOut); | ||
1095 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQBlockLifeTime : 0x%X", | ||
1096 | pstAddIndication->sfAuthorizedSet.u16ARQBlockLifeTime); | ||
1097 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQSyncLossTimeOut : 0x%X", | ||
1098 | pstAddIndication->sfAuthorizedSet.u16ARQSyncLossTimeOut); | ||
1099 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ARQDeliverInOrder : 0x%X", | ||
1100 | pstAddIndication->sfAuthorizedSet.u8ARQDeliverInOrder); | ||
1101 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQRxPurgeTimeOut : 0x%X", | ||
1102 | pstAddIndication->sfAuthorizedSet.u16ARQRxPurgeTimeOut); | ||
1103 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQBlockSize : 0x%X", | ||
1104 | pstAddIndication->sfAuthorizedSet.u16ARQBlockSize); | ||
1105 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8CSSpecification : 0x%X", | ||
1106 | pstAddIndication->sfAuthorizedSet.u8CSSpecification); | ||
1107 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TypeOfDataDeliveryService : 0x%X", | ||
1108 | pstAddIndication->sfAuthorizedSet.u8TypeOfDataDeliveryService); | ||
1109 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16SDUInterArrivalTime : 0x%X", | ||
1110 | pstAddIndication->sfAuthorizedSet.u16SDUInterArrivalTime); | ||
1111 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16TimeBase : 0x%X", | ||
1112 | pstAddIndication->sfAuthorizedSet.u16TimeBase); | ||
1113 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8PagingPreference : 0x%X", | ||
1114 | pstAddIndication->sfAuthorizedSet.u8PagingPreference); | ||
1115 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16UnsolicitedPollingInterval : 0x%X", | ||
1116 | pstAddIndication->sfAuthorizedSet.u16UnsolicitedPollingInterval); | ||
1117 | #if 0 | ||
1118 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "MBSZoneIdentifierassignmentLength : 0x%X", | ||
1119 | pstAddIndication->sfAuthorizedSet.MBSZoneIdentifierassignmentLength); | ||
1120 | for(uiLoopIndex=0; uiLoopIndex < MAX_STRING_LEN; uiLoopIndex++) | ||
1121 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "MBSZoneIdentifierassignment : 0x%X", | ||
1122 | pstAddIndication->sfAuthorizedSet.MBSZoneIdentifierassignment[uiLoopIndex]); | ||
1123 | #endif | ||
1124 | |||
1125 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "sfAuthorizedSet.u8HARQChannelMapping %x %x %x ", | ||
1126 | *(unsigned int*)pstAddIndication->sfAuthorizedSet.u8HARQChannelMapping, | ||
1127 | *(unsigned int*)&pstAddIndication->sfAuthorizedSet.u8HARQChannelMapping[4], | ||
1128 | *(USHORT*) &pstAddIndication->sfAuthorizedSet.u8HARQChannelMapping[8]); | ||
1129 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TrafficIndicationPreference : 0x%X", | ||
1130 | pstAddIndication->sfAuthorizedSet.u8TrafficIndicationPreference); | ||
1131 | |||
1132 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " Total Classifiers Recieved : 0x%X",pstAddIndication->sfAuthorizedSet.u8TotalClassifiers); | ||
1133 | |||
1134 | nCurClassifierCnt = pstAddIndication->sfAuthorizedSet.u8TotalClassifiers; | ||
1135 | |||
1136 | if(nCurClassifierCnt > MAX_CLASSIFIERS_IN_SF) | ||
1137 | { | ||
1138 | nCurClassifierCnt = MAX_CLASSIFIERS_IN_SF; | ||
1139 | } | ||
1140 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "pstAddIndication->sfAuthorizedSet.bValid %d", pstAddIndication->sfAuthorizedSet.bValid); | ||
1141 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "pstAddIndication->sfAuthorizedSet.u16MacOverhead %x", pstAddIndication->sfAuthorizedSet.u16MacOverhead); | ||
1142 | if(!pstAddIndication->sfAuthorizedSet.bValid) | ||
1143 | pstAddIndication->sfAuthorizedSet.bValid=1; | ||
1144 | for(nIndex = 0 ; nIndex < nCurClassifierCnt ; nIndex++) | ||
1145 | { | ||
1146 | stConvergenceSLTypes *psfCSType = NULL; | ||
1147 | psfCSType = &pstAddIndication->sfAuthorizedSet.cConvergenceSLTypes[nIndex]; | ||
1148 | |||
1149 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "psfCSType = %p", psfCSType); | ||
1150 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "CCPacketClassificationRuleSI====>"); | ||
1151 | |||
1152 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ClassifierRulePriority :0x%X ", | ||
1153 | psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority); | ||
1154 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPTypeOfServiceLength :0x%X ", | ||
1155 | psfCSType->cCPacketClassificationRule.u8IPTypeOfServiceLength); | ||
1156 | |||
1157 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPTypeOfService[3] :0x%X ,0x%X ,0x%X ", | ||
1158 | psfCSType->cCPacketClassificationRule.u8IPTypeOfService[0], | ||
1159 | psfCSType->cCPacketClassificationRule.u8IPTypeOfService[1], | ||
1160 | psfCSType->cCPacketClassificationRule.u8IPTypeOfService[2]); | ||
1161 | #if 0 | ||
1162 | |||
1163 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u8ProtocolLength :0x%X ", | ||
1164 | psfCSType->cCPacketClassificationRule.u8ProtocolLength); | ||
1165 | #endif | ||
1166 | |||
1167 | for(uiLoopIndex=0; uiLoopIndex < 1; uiLoopIndex++) | ||
1168 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Protocol : 0x%02X ", | ||
1169 | psfCSType->cCPacketClassificationRule.u8Protocol); | ||
1170 | |||
1171 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPMaskedSourceAddressLength :0x%X ", | ||
1172 | psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddressLength); | ||
1173 | |||
1174 | for(uiLoopIndex=0; uiLoopIndex < 32; uiLoopIndex++) | ||
1175 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPMaskedSourceAddress[32] : 0x%02X ", | ||
1176 | psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddress[uiLoopIndex]); | ||
1177 | |||
1178 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPDestinationAddressLength : 0x%X ", | ||
1179 | psfCSType->cCPacketClassificationRule.u8IPDestinationAddressLength); | ||
1180 | |||
1181 | for(uiLoopIndex=0; uiLoopIndex < 32; uiLoopIndex++) | ||
1182 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPDestinationAddress[32] : 0x%02X ", | ||
1183 | psfCSType->cCPacketClassificationRule.u8IPDestinationAddress[uiLoopIndex]); | ||
1184 | |||
1185 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolSourcePortRangeLength:0x%X ", | ||
1186 | psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRangeLength); | ||
1187 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolSourcePortRange[4]: 0x%02X ,0x%02X ,0x%02X ,0x%02X ", | ||
1188 | psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[0], | ||
1189 | psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[1], | ||
1190 | psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[2], | ||
1191 | psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[3]); | ||
1192 | |||
1193 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolDestPortRangeLength : 0x%02X ", | ||
1194 | psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRangeLength); | ||
1195 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolDestPortRange[4]: 0x%02X ,0x%02X ,0x%02X ,0x%02X ", | ||
1196 | psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[0], | ||
1197 | psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[1], | ||
1198 | psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[2], | ||
1199 | psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[3]); | ||
1200 | |||
1201 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetDestMacAddressLength : 0x%02X ", | ||
1202 | psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength); | ||
1203 | |||
1204 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetDestMacAddress[6] : 0x %02X %02X %02X %02X %02X %02X", | ||
1205 | psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[0], | ||
1206 | psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[1], | ||
1207 | psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[2], | ||
1208 | psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[3], | ||
1209 | psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[4], | ||
1210 | psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[5]); | ||
1211 | |||
1212 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetSourceMACAddressLength : 0x%02X ", | ||
1213 | psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength); | ||
1214 | |||
1215 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetSourceMACAddress[6] : 0x %02X %02X %02X %02X %02X %02X", | ||
1216 | psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[0], | ||
1217 | psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[1], | ||
1218 | psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[2], | ||
1219 | psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[3], | ||
1220 | psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[4], | ||
1221 | psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[5]); | ||
1222 | |||
1223 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthertypeLength : 0x%02X ", | ||
1224 | psfCSType->cCPacketClassificationRule.u8EthertypeLength); | ||
1225 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Ethertype[3] : 0x%02X ,0x%02X ,0x%02X ", | ||
1226 | psfCSType->cCPacketClassificationRule.u8Ethertype[0], | ||
1227 | psfCSType->cCPacketClassificationRule.u8Ethertype[1], | ||
1228 | psfCSType->cCPacketClassificationRule.u8Ethertype[2]); | ||
1229 | |||
1230 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16UserPriority : 0x%X ", | ||
1231 | psfCSType->cCPacketClassificationRule.u16UserPriority); | ||
1232 | |||
1233 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16VLANID : 0x%X ", | ||
1234 | psfCSType->cCPacketClassificationRule.u16VLANID); | ||
1235 | |||
1236 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8AssociatedPHSI : 0x%02X ", | ||
1237 | psfCSType->cCPacketClassificationRule.u8AssociatedPHSI); | ||
1238 | |||
1239 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16PacketClassificationRuleIndex : 0x%X ", | ||
1240 | psfCSType->cCPacketClassificationRule.u16PacketClassificationRuleIndex); | ||
1241 | |||
1242 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificClassifierParamLength : 0x%X ", | ||
1243 | psfCSType->cCPacketClassificationRule.u8VendorSpecificClassifierParamLength); | ||
1244 | |||
1245 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificClassifierParam[1] : 0x%X ", | ||
1246 | psfCSType->cCPacketClassificationRule.u8VendorSpecificClassifierParam[0]); | ||
1247 | #ifdef VERSION_D5 | ||
1248 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPv6FlowLableLength :0x%X ", | ||
1249 | psfCSType->cCPacketClassificationRule.u8IPv6FlowLableLength); | ||
1250 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPv6FlowLable[6] : 0x %02X %02X %02X %02X %02X %02X ", | ||
1251 | psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[0], | ||
1252 | psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[1], | ||
1253 | psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[2], | ||
1254 | psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[3], | ||
1255 | psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[4], | ||
1256 | psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[5]); | ||
1257 | #endif | ||
1258 | } | ||
1259 | |||
1260 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "bValid : 0x%02X",pstAddIndication->sfAuthorizedSet.bValid); | ||
1261 | |||
1262 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "AdmittedSet--->"); | ||
1263 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32SFID : 0x%X",pstAddIndication->sfAdmittedSet.u32SFID); | ||
1264 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16CID : 0x%X",pstAddIndication->sfAdmittedSet.u16CID); | ||
1265 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceClassNameLength : 0x%X", | ||
1266 | pstAddIndication->sfAdmittedSet.u8ServiceClassNameLength); | ||
1267 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceClassName : 0x %02X %02X %02X %02X %02X %02X", | ||
1268 | pstAddIndication->sfAdmittedSet.u8ServiceClassName[0], | ||
1269 | pstAddIndication->sfAdmittedSet.u8ServiceClassName[1], | ||
1270 | pstAddIndication->sfAdmittedSet.u8ServiceClassName[2], | ||
1271 | pstAddIndication->sfAdmittedSet.u8ServiceClassName[3], | ||
1272 | pstAddIndication->sfAdmittedSet.u8ServiceClassName[4], | ||
1273 | pstAddIndication->sfAdmittedSet.u8ServiceClassName[5]); | ||
1274 | |||
1275 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8MBSService : 0x%02X", | ||
1276 | pstAddIndication->sfAdmittedSet.u8MBSService); | ||
1277 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8QosParamSet : 0x%02X", | ||
1278 | pstAddIndication->sfAdmittedSet.u8QosParamSet); | ||
1279 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TrafficPriority : 0x%02X", | ||
1280 | pstAddIndication->sfAdmittedSet.u8TrafficPriority); | ||
1281 | #if 0 | ||
1282 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u32MaxSustainedTrafficRate : 0x%02X", | ||
1283 | ntohl(pstAddIndication->sfAdmittedSet.u32MaxSustainedTrafficRate)); | ||
1284 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u32MinimumTolerableTrafficRate : 0x%X", | ||
1285 | pstAddIndication->sfAdmittedSet.u32MinimumTolerableTrafficRate); | ||
1286 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u32RequesttransmissionPolicy : 0x%X", | ||
1287 | pstAddIndication->sfAdmittedSet.u32RequesttransmissionPolicy); | ||
1288 | #endif | ||
1289 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaxTrafficBurst : 0x%X", | ||
1290 | pstAddIndication->sfAdmittedSet.u32MaxTrafficBurst); | ||
1291 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MinReservedTrafficRate : 0x%X", | ||
1292 | pstAddIndication->sfAdmittedSet.u32MinReservedTrafficRate); | ||
1293 | |||
1294 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParamLength : 0x%02X", | ||
1295 | pstAddIndication->sfAdmittedSet.u8VendorSpecificQoSParamLength); | ||
1296 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParam : 0x%02X", | ||
1297 | pstAddIndication->sfAdmittedSet.u8VendorSpecificQoSParam[0]); | ||
1298 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceFlowSchedulingType : 0x%02X", | ||
1299 | pstAddIndication->sfAdmittedSet.u8ServiceFlowSchedulingType); | ||
1300 | |||
1301 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32ToleratedJitter : 0x%X", | ||
1302 | pstAddIndication->sfAdmittedSet.u32ToleratedJitter); | ||
1303 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaximumLatency : 0x%X", | ||
1304 | pstAddIndication->sfAdmittedSet.u32MaximumLatency); | ||
1305 | |||
1306 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8FixedLengthVSVariableLengthSDUIndicator: 0x%02X", | ||
1307 | pstAddIndication->sfAdmittedSet.u8FixedLengthVSVariableLengthSDUIndicator); | ||
1308 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8SDUSize : 0x%02X", | ||
1309 | pstAddIndication->sfAdmittedSet.u8SDUSize); | ||
1310 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16TargetSAID : 0x%02X", | ||
1311 | pstAddIndication->sfAdmittedSet.u16TargetSAID); | ||
1312 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ARQEnable : 0x%02X", | ||
1313 | pstAddIndication->sfAdmittedSet.u8ARQEnable); | ||
1314 | |||
1315 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQWindowSize : 0x%X", | ||
1316 | pstAddIndication->sfAdmittedSet.u16ARQWindowSize); | ||
1317 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQRetryTxTimeOut : 0x%X", | ||
1318 | pstAddIndication->sfAdmittedSet.u16ARQRetryTxTimeOut); | ||
1319 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQRetryRxTimeOut : 0x%X", | ||
1320 | pstAddIndication->sfAdmittedSet.u16ARQRetryRxTimeOut); | ||
1321 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQBlockLifeTime : 0x%X", | ||
1322 | pstAddIndication->sfAdmittedSet.u16ARQBlockLifeTime); | ||
1323 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQSyncLossTimeOut : 0x%X", | ||
1324 | pstAddIndication->sfAdmittedSet.u16ARQSyncLossTimeOut); | ||
1325 | |||
1326 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ARQDeliverInOrder : 0x%02X", | ||
1327 | pstAddIndication->sfAdmittedSet.u8ARQDeliverInOrder); | ||
1328 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQRxPurgeTimeOut : 0x%X", | ||
1329 | pstAddIndication->sfAdmittedSet.u16ARQRxPurgeTimeOut); | ||
1330 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQBlockSize : 0x%X", | ||
1331 | pstAddIndication->sfAdmittedSet.u16ARQBlockSize); | ||
1332 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8CSSpecification : 0x%02X", | ||
1333 | pstAddIndication->sfAdmittedSet.u8CSSpecification); | ||
1334 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TypeOfDataDeliveryService : 0x%02X", | ||
1335 | pstAddIndication->sfAdmittedSet.u8TypeOfDataDeliveryService); | ||
1336 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16SDUInterArrivalTime : 0x%X", | ||
1337 | pstAddIndication->sfAdmittedSet.u16SDUInterArrivalTime); | ||
1338 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16TimeBase : 0x%X", | ||
1339 | pstAddIndication->sfAdmittedSet.u16TimeBase); | ||
1340 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8PagingPreference : 0x%X", | ||
1341 | pstAddIndication->sfAdmittedSet.u8PagingPreference); | ||
1342 | #if 0 | ||
1343 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "MBSZoneIdentifierassignmentLength : 0x%X", | ||
1344 | pstAddIndication->sfAdmittedSet.MBSZoneIdentifierassignmentLength); | ||
1345 | for(uiLoopIndex=0; uiLoopIndex < MAX_STRING_LEN; uiLoopIndex++) | ||
1346 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "MBSZoneIdentifierassignment : 0x%X", | ||
1347 | pstAddIndication->sfAdmittedSet.MBSZoneIdentifierassignment[uiLoopIndex]); | ||
1348 | #endif | ||
1349 | |||
1350 | |||
1351 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TrafficIndicationPreference : 0x%02X", | ||
1352 | pstAddIndication->sfAdmittedSet.u8TrafficIndicationPreference); | ||
1353 | |||
1354 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " Total Classifiers Recieved : 0x%X",pstAddIndication->sfAdmittedSet.u8TotalClassifiers); | ||
1355 | |||
1356 | nCurClassifierCnt = pstAddIndication->sfAdmittedSet.u8TotalClassifiers; | ||
1357 | |||
1358 | if(nCurClassifierCnt > MAX_CLASSIFIERS_IN_SF) | ||
1359 | { | ||
1360 | nCurClassifierCnt = MAX_CLASSIFIERS_IN_SF; | ||
1361 | } | ||
1362 | |||
1363 | |||
1364 | for(nIndex = 0 ; nIndex < nCurClassifierCnt ; nIndex++) | ||
1365 | { | ||
1366 | |||
1367 | stConvergenceSLTypes *psfCSType = NULL; | ||
1368 | psfCSType = &pstAddIndication->sfAdmittedSet.cConvergenceSLTypes[nIndex]; | ||
1369 | |||
1370 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " CCPacketClassificationRuleSI====>"); | ||
1371 | |||
1372 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ClassifierRulePriority :0x%02X ", | ||
1373 | psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority); | ||
1374 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPTypeOfServiceLength :0x%02X", | ||
1375 | psfCSType->cCPacketClassificationRule.u8IPTypeOfServiceLength); | ||
1376 | |||
1377 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPTypeOfService[3] :0x%02X %02X %02X", | ||
1378 | psfCSType->cCPacketClassificationRule.u8IPTypeOfService[0], | ||
1379 | psfCSType->cCPacketClassificationRule.u8IPTypeOfService[1], | ||
1380 | psfCSType->cCPacketClassificationRule.u8IPTypeOfService[2]); | ||
1381 | #if 0 | ||
1382 | |||
1383 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolLength :0x%02X ", | ||
1384 | psfCSType->cCPacketClassificationRule.u8ProtocolLength); | ||
1385 | #endif | ||
1386 | for(uiLoopIndex=0; uiLoopIndex < 1; uiLoopIndex++) | ||
1387 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Protocol: 0x%02X ", | ||
1388 | psfCSType->cCPacketClassificationRule.u8Protocol); | ||
1389 | |||
1390 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPMaskedSourceAddressLength :0x%02X ", | ||
1391 | psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddressLength); | ||
1392 | |||
1393 | for(uiLoopIndex=0; uiLoopIndex < 32; uiLoopIndex++) | ||
1394 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPMaskedSourceAddress[32] : 0x%02X ", | ||
1395 | psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddress[uiLoopIndex]); | ||
1396 | |||
1397 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPDestinationAddressLength : 0x%02X ", | ||
1398 | psfCSType->cCPacketClassificationRule.u8IPDestinationAddressLength); | ||
1399 | |||
1400 | for(uiLoopIndex=0; uiLoopIndex < 32; uiLoopIndex++) | ||
1401 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPDestinationAddress[32] : 0x%02X ", | ||
1402 | psfCSType->cCPacketClassificationRule.u8IPDestinationAddress[uiLoopIndex]); | ||
1403 | |||
1404 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolSourcePortRangeLength : 0x%02X ", | ||
1405 | psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRangeLength); | ||
1406 | |||
1407 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolSourcePortRange[4] : 0x %02X %02X %02X %02X ", | ||
1408 | psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[0], | ||
1409 | psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[1], | ||
1410 | psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[2], | ||
1411 | psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[3]); | ||
1412 | |||
1413 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolDestPortRangeLength : 0x%02X ", | ||
1414 | psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRangeLength); | ||
1415 | |||
1416 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolDestPortRange[4] : 0x %02X %02X %02X %02X ", | ||
1417 | psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[0], | ||
1418 | psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[1], | ||
1419 | psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[2], | ||
1420 | psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[3]); | ||
1421 | |||
1422 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetDestMacAddressLength : 0x%02X ", | ||
1423 | psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength); | ||
1424 | |||
1425 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetDestMacAddress[6] : 0x %02X %02X %02X %02X %02X %02X", | ||
1426 | psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[0], | ||
1427 | psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[1], | ||
1428 | psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[2], | ||
1429 | psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[3], | ||
1430 | psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[4], | ||
1431 | psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[5]); | ||
1432 | |||
1433 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetSourceMACAddressLength : 0x%02X ", | ||
1434 | psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength); | ||
1435 | |||
1436 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetSourceMACAddress[6] : 0x %02X %02X %02X %02X %02X %02X", | ||
1437 | psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[0], | ||
1438 | psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[1], | ||
1439 | psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[2], | ||
1440 | psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[3], | ||
1441 | psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[4], | ||
1442 | psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[5]); | ||
1443 | |||
1444 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthertypeLength : 0x%02X ", | ||
1445 | psfCSType->cCPacketClassificationRule.u8EthertypeLength); | ||
1446 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Ethertype[3] : 0x%02X %02X %02X", | ||
1447 | psfCSType->cCPacketClassificationRule.u8Ethertype[0], | ||
1448 | psfCSType->cCPacketClassificationRule.u8Ethertype[1], | ||
1449 | psfCSType->cCPacketClassificationRule.u8Ethertype[2]); | ||
1450 | |||
1451 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16UserPriority : 0x%X ", | ||
1452 | psfCSType->cCPacketClassificationRule.u16UserPriority); | ||
1453 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16VLANID : 0x%X ", | ||
1454 | psfCSType->cCPacketClassificationRule.u16VLANID); | ||
1455 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8AssociatedPHSI : 0x%02X ", | ||
1456 | psfCSType->cCPacketClassificationRule.u8AssociatedPHSI); | ||
1457 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16PacketClassificationRuleIndex : 0x%X ", | ||
1458 | psfCSType->cCPacketClassificationRule.u16PacketClassificationRuleIndex); | ||
1459 | |||
1460 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificClassifierParamLength : 0x%02X", | ||
1461 | psfCSType->cCPacketClassificationRule.u8VendorSpecificClassifierParamLength); | ||
1462 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificClassifierParam[1] : 0x%02X ", | ||
1463 | psfCSType->cCPacketClassificationRule.u8VendorSpecificClassifierParam[0]); | ||
1464 | #ifdef VERSION_D5 | ||
1465 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPv6FlowLableLength : 0x%X ", | ||
1466 | psfCSType->cCPacketClassificationRule.u8IPv6FlowLableLength); | ||
1467 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPv6FlowLable[6] : 0x %02X %02X %02X %02X %02X %02X ", | ||
1468 | psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[0], | ||
1469 | psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[1], | ||
1470 | psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[2], | ||
1471 | psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[3], | ||
1472 | psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[4], | ||
1473 | psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[5]); | ||
1474 | #endif | ||
1475 | } | ||
1476 | |||
1477 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "bValid : 0x%X",pstAddIndication->sfAdmittedSet.bValid); | ||
1478 | |||
1479 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " ActiveSet--->"); | ||
1480 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32SFID : 0x%X",pstAddIndication->sfActiveSet.u32SFID); | ||
1481 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16CID : 0x%X",pstAddIndication->sfActiveSet.u16CID); | ||
1482 | |||
1483 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceClassNameLength : 0x%X", | ||
1484 | pstAddIndication->sfActiveSet.u8ServiceClassNameLength); | ||
1485 | |||
1486 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceClassName : 0x %02X %02X %02X %02X %02X %02X", | ||
1487 | pstAddIndication->sfActiveSet.u8ServiceClassName[0], | ||
1488 | pstAddIndication->sfActiveSet.u8ServiceClassName[1], | ||
1489 | pstAddIndication->sfActiveSet.u8ServiceClassName[2], | ||
1490 | pstAddIndication->sfActiveSet.u8ServiceClassName[3], | ||
1491 | pstAddIndication->sfActiveSet.u8ServiceClassName[4], | ||
1492 | pstAddIndication->sfActiveSet.u8ServiceClassName[5]); | ||
1493 | |||
1494 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8MBSService : 0x%02X", | ||
1495 | pstAddIndication->sfActiveSet.u8MBSService); | ||
1496 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8QosParamSet : 0x%02X", | ||
1497 | pstAddIndication->sfActiveSet.u8QosParamSet); | ||
1498 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TrafficPriority : 0x%02X", | ||
1499 | pstAddIndication->sfActiveSet.u8TrafficPriority); | ||
1500 | #if 0 | ||
1501 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u32MaxSustainedTrafficRate : 0x%02X", | ||
1502 | ntohl(pstAddIndication->sfActiveSet.u32MaxSustainedTrafficRate)); | ||
1503 | #endif | ||
1504 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaxTrafficBurst : 0x%X", | ||
1505 | pstAddIndication->sfActiveSet.u32MaxTrafficBurst); | ||
1506 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MinReservedTrafficRate : 0x%X", | ||
1507 | pstAddIndication->sfActiveSet.u32MinReservedTrafficRate); | ||
1508 | #if 0 | ||
1509 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u32MinimumTolerableTrafficRate : 0x%X", | ||
1510 | pstAddIndication->sfActiveSet.u32MinimumTolerableTrafficRate); | ||
1511 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u32RequesttransmissionPolicy : 0x%X", | ||
1512 | pstAddIndication->sfActiveSet.u32RequesttransmissionPolicy); | ||
1513 | #endif | ||
1514 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParamLength : 0x%02X", | ||
1515 | pstAddIndication->sfActiveSet.u8VendorSpecificQoSParamLength); | ||
1516 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParam : 0x%02X", | ||
1517 | pstAddIndication->sfActiveSet.u8VendorSpecificQoSParam[0]); | ||
1518 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceFlowSchedulingType : 0x%02X", | ||
1519 | pstAddIndication->sfActiveSet.u8ServiceFlowSchedulingType); | ||
1520 | |||
1521 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32ToleratedJitter : 0x%X", | ||
1522 | pstAddIndication->sfActiveSet.u32ToleratedJitter); | ||
1523 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaximumLatency : 0x%X", | ||
1524 | pstAddIndication->sfActiveSet.u32MaximumLatency); | ||
1525 | |||
1526 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8FixedLengthVSVariableLengthSDUIndicator: 0x%02X", | ||
1527 | pstAddIndication->sfActiveSet.u8FixedLengthVSVariableLengthSDUIndicator); | ||
1528 | |||
1529 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8SDUSize : 0x%X", | ||
1530 | pstAddIndication->sfActiveSet.u8SDUSize); | ||
1531 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16TargetSAID : 0x%X", | ||
1532 | pstAddIndication->sfActiveSet.u16TargetSAID); | ||
1533 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ARQEnable : 0x%X", | ||
1534 | pstAddIndication->sfActiveSet.u8ARQEnable); | ||
1535 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQWindowSize : 0x%X", | ||
1536 | pstAddIndication->sfActiveSet.u16ARQWindowSize); | ||
1537 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQRetryTxTimeOut : 0x%X", | ||
1538 | pstAddIndication->sfActiveSet.u16ARQRetryTxTimeOut); | ||
1539 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQRetryRxTimeOut : 0x%X", | ||
1540 | pstAddIndication->sfActiveSet.u16ARQRetryRxTimeOut); | ||
1541 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQBlockLifeTime : 0x%X", | ||
1542 | pstAddIndication->sfActiveSet.u16ARQBlockLifeTime); | ||
1543 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQSyncLossTimeOut : 0x%X", | ||
1544 | pstAddIndication->sfActiveSet.u16ARQSyncLossTimeOut); | ||
1545 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ARQDeliverInOrder : 0x%X", | ||
1546 | pstAddIndication->sfActiveSet.u8ARQDeliverInOrder); | ||
1547 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQRxPurgeTimeOut : 0x%X", | ||
1548 | pstAddIndication->sfActiveSet.u16ARQRxPurgeTimeOut); | ||
1549 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQBlockSize : 0x%X", | ||
1550 | pstAddIndication->sfActiveSet.u16ARQBlockSize); | ||
1551 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8CSSpecification : 0x%X", | ||
1552 | pstAddIndication->sfActiveSet.u8CSSpecification); | ||
1553 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8TypeOfDataDeliveryService : 0x%X", | ||
1554 | pstAddIndication->sfActiveSet.u8TypeOfDataDeliveryService); | ||
1555 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16SDUInterArrivalTime : 0x%X", | ||
1556 | pstAddIndication->sfActiveSet.u16SDUInterArrivalTime); | ||
1557 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16TimeBase : 0x%X", | ||
1558 | pstAddIndication->sfActiveSet.u16TimeBase); | ||
1559 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8PagingPreference : 0x%X", | ||
1560 | pstAddIndication->sfActiveSet.u8PagingPreference); | ||
1561 | #if 0 | ||
1562 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " MBSZoneIdentifierassignmentLength : 0x%X", | ||
1563 | pstAddIndication->sfActiveSet.MBSZoneIdentifierassignmentLength); | ||
1564 | for(uiLoopIndex=0; uiLoopIndex < MAX_STRING_LEN; uiLoopIndex++) | ||
1565 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " MBSZoneIdentifierassignment : 0x%X", | ||
1566 | pstAddIndication->sfActiveSet.MBSZoneIdentifierassignment[uiLoopIndex]); | ||
1567 | #endif | ||
1568 | |||
1569 | |||
1570 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8TrafficIndicationPreference : 0x%X", | ||
1571 | pstAddIndication->sfActiveSet.u8TrafficIndicationPreference); | ||
1572 | |||
1573 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " Total Classifiers Recieved : 0x%X",pstAddIndication->sfActiveSet.u8TotalClassifiers); | ||
1574 | |||
1575 | nCurClassifierCnt = pstAddIndication->sfActiveSet.u8TotalClassifiers; | ||
1576 | |||
1577 | if(nCurClassifierCnt > MAX_CLASSIFIERS_IN_SF) | ||
1578 | { | ||
1579 | nCurClassifierCnt = MAX_CLASSIFIERS_IN_SF; | ||
1580 | } | ||
1581 | |||
1582 | for(nIndex = 0 ; nIndex < nCurClassifierCnt ; nIndex++) | ||
1583 | { | ||
1584 | |||
1585 | stConvergenceSLTypes *psfCSType = NULL; | ||
1586 | psfCSType = &pstAddIndication->sfActiveSet.cConvergenceSLTypes[nIndex]; | ||
1587 | |||
1588 | |||
1589 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " CCPacketClassificationRuleSI====>"); | ||
1590 | |||
1591 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ClassifierRulePriority :0x%X ", | ||
1592 | psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority); | ||
1593 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8IPTypeOfServiceLength :0x%X ", | ||
1594 | psfCSType->cCPacketClassificationRule.u8IPTypeOfServiceLength); | ||
1595 | |||
1596 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8IPTypeOfService[3] :0x%X ,0x%X ,0x%X ", | ||
1597 | psfCSType->cCPacketClassificationRule.u8IPTypeOfService[0], | ||
1598 | psfCSType->cCPacketClassificationRule.u8IPTypeOfService[1], | ||
1599 | psfCSType->cCPacketClassificationRule.u8IPTypeOfService[2]); | ||
1600 | #if 0 | ||
1601 | |||
1602 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " u8ProtocolLength :0x%X ", | ||
1603 | psfCSType->cCPacketClassificationRule.u8ProtocolLength); | ||
1604 | #endif | ||
1605 | for(uiLoopIndex=0; uiLoopIndex < 1; uiLoopIndex++) | ||
1606 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8Protocol : 0x%X ", | ||
1607 | psfCSType->cCPacketClassificationRule.u8Protocol); | ||
1608 | |||
1609 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPMaskedSourceAddressLength :0x%X ", | ||
1610 | psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddressLength); | ||
1611 | |||
1612 | for(uiLoopIndex=0; uiLoopIndex < 32; uiLoopIndex++) | ||
1613 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPMaskedSourceAddress[32]:0x%X ", | ||
1614 | psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddress[uiLoopIndex]); | ||
1615 | |||
1616 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPDestinationAddressLength : 0x%02X ", | ||
1617 | psfCSType->cCPacketClassificationRule.u8IPDestinationAddressLength); | ||
1618 | |||
1619 | for(uiLoopIndex=0;uiLoopIndex<32;uiLoopIndex++) | ||
1620 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8IPDestinationAddress[32]:0x%X ", | ||
1621 | psfCSType->cCPacketClassificationRule.u8IPDestinationAddress[uiLoopIndex]); | ||
1622 | |||
1623 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ProtocolSourcePortRangeLength:0x%X ", | ||
1624 | psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRangeLength); | ||
1625 | |||
1626 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ProtocolSourcePortRange[4]:0x%X ,0x%X ,0x%X ,0x%X ", | ||
1627 | psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[0], | ||
1628 | psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[1], | ||
1629 | psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[2], | ||
1630 | psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[3]); | ||
1631 | |||
1632 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ProtocolDestPortRangeLength:0x%X ", | ||
1633 | psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRangeLength); | ||
1634 | |||
1635 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ProtocolDestPortRange[4]:0x%X ,0x%X ,0x%X ,0x%X ", | ||
1636 | psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[0], | ||
1637 | psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[1], | ||
1638 | psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[2], | ||
1639 | psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[3]); | ||
1640 | |||
1641 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8EthernetDestMacAddressLength:0x%X ", | ||
1642 | psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength); | ||
1643 | |||
1644 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8EthernetDestMacAddress[6]:0x%X ,0x%X ,0x%X ,0x%X ,0x%X ,0x%X", | ||
1645 | psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[0], | ||
1646 | psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[1], | ||
1647 | psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[2], | ||
1648 | psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[3], | ||
1649 | psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[4], | ||
1650 | psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[5]); | ||
1651 | |||
1652 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8EthernetSourceMACAddressLength:0x%X ", | ||
1653 | psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength); | ||
1654 | |||
1655 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetSourceMACAddress[6]:0x%X ,0x%X ,0x%X ,0x%X ,0x%X ,0x%X", | ||
1656 | psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[0], | ||
1657 | psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[1], | ||
1658 | psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[2], | ||
1659 | psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[3], | ||
1660 | psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[4], | ||
1661 | psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[5]); | ||
1662 | |||
1663 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8EthertypeLength :0x%X ", | ||
1664 | psfCSType->cCPacketClassificationRule.u8EthertypeLength); | ||
1665 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8Ethertype[3] :0x%X ,0x%X ,0x%X ", | ||
1666 | psfCSType->cCPacketClassificationRule.u8Ethertype[0], | ||
1667 | psfCSType->cCPacketClassificationRule.u8Ethertype[1], | ||
1668 | psfCSType->cCPacketClassificationRule.u8Ethertype[2]); | ||
1669 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16UserPriority :0x%X ", | ||
1670 | psfCSType->cCPacketClassificationRule.u16UserPriority); | ||
1671 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16VLANID :0x%X ", | ||
1672 | psfCSType->cCPacketClassificationRule.u16VLANID); | ||
1673 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8AssociatedPHSI :0x%X ", | ||
1674 | psfCSType->cCPacketClassificationRule.u8AssociatedPHSI); | ||
1675 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16PacketClassificationRuleIndex:0x%X ", | ||
1676 | psfCSType->cCPacketClassificationRule.u16PacketClassificationRuleIndex); | ||
1677 | |||
1678 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8VendorSpecificClassifierParamLength:0x%X ", | ||
1679 | psfCSType->cCPacketClassificationRule.u8VendorSpecificClassifierParamLength); | ||
1680 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8VendorSpecificClassifierParam[1]:0x%X ", | ||
1681 | psfCSType->cCPacketClassificationRule.u8VendorSpecificClassifierParam[0]); | ||
1682 | #ifdef VERSION_D5 | ||
1683 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8IPv6FlowLableLength :0x%X ", | ||
1684 | psfCSType->cCPacketClassificationRule.u8IPv6FlowLableLength); | ||
1685 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8IPv6FlowLable[6] :0x%X ,0x%X ,0x%X ,0x%X ,0x%X ,0x%X ", | ||
1686 | psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[0], | ||
1687 | psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[1], | ||
1688 | psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[2], | ||
1689 | psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[3], | ||
1690 | psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[4], | ||
1691 | psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[5]); | ||
1692 | #endif | ||
1693 | } | ||
1694 | |||
1695 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " bValid : 0x%X",pstAddIndication->sfActiveSet.bValid); | ||
1696 | |||
1697 | } | ||
1698 | |||
1699 | static inline ULONG RestoreSFParam(PMINI_ADAPTER Adapter, ULONG ulAddrSFParamSet,PUCHAR pucDestBuffer) | ||
1700 | { | ||
1701 | UINT nBytesToRead = sizeof(stServiceFlowParamSI); | ||
1702 | |||
1703 | if(ulAddrSFParamSet == 0 || NULL == pucDestBuffer) | ||
1704 | { | ||
1705 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Got Param address as 0!!"); | ||
1706 | return 0; | ||
1707 | } | ||
1708 | ulAddrSFParamSet = ntohl(ulAddrSFParamSet); | ||
1709 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " RestoreSFParam: Total Words of DSX Message To Read: 0x%x From Target At : 0x%lx ", | ||
1710 | nBytesToRead/sizeof(ULONG),ulAddrSFParamSet); | ||
1711 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "sizeof(stServiceFlowParamSI) = %x", sizeof(stServiceFlowParamSI)); | ||
1712 | |||
1713 | //Read out the SF Param Set At the indicated Location | ||
1714 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "nBytesToRead = %x", nBytesToRead); | ||
1715 | if(rdm(Adapter, ulAddrSFParamSet, (PUCHAR)pucDestBuffer, nBytesToRead) < 0) | ||
1716 | return STATUS_FAILURE; | ||
1717 | |||
1718 | return 1; | ||
1719 | } | ||
1720 | |||
1721 | |||
1722 | static __inline ULONG StoreSFParam(PMINI_ADAPTER Adapter,PUCHAR pucSrcBuffer,ULONG ulAddrSFParamSet) | ||
1723 | { | ||
1724 | UINT nBytesToWrite = sizeof(stServiceFlowParamSI); | ||
1725 | UINT uiRetVal =0; | ||
1726 | |||
1727 | if(ulAddrSFParamSet == 0 || NULL == pucSrcBuffer) | ||
1728 | { | ||
1729 | return 0; | ||
1730 | } | ||
1731 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " StoreSFParam: Total Words of DSX Message To Write: 0x%X To Target At : 0x%lX ",(nBytesToWrite/sizeof(ULONG)),ulAddrSFParamSet); | ||
1732 | |||
1733 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "WRM with %x bytes",nBytesToWrite); | ||
1734 | |||
1735 | uiRetVal = wrm(Adapter,ulAddrSFParamSet,(PUCHAR)pucSrcBuffer, nBytesToWrite); | ||
1736 | if(uiRetVal < 0) { | ||
1737 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "%s:%d WRM failed",__FUNCTION__, __LINE__); | ||
1738 | return uiRetVal; | ||
1739 | } | ||
1740 | return 1; | ||
1741 | } | ||
1742 | |||
1743 | ULONG StoreCmControlResponseMessage(PMINI_ADAPTER Adapter,PVOID pvBuffer,UINT *puBufferLength) | ||
1744 | { | ||
1745 | stLocalSFAddIndicationAlt *pstAddIndicationAlt = NULL; | ||
1746 | stLocalSFAddIndication * pstAddIndication = NULL; | ||
1747 | stLocalSFDeleteRequest *pstDeletionRequest; | ||
1748 | UINT uiSearchRuleIndex; | ||
1749 | ULONG ulSFID; | ||
1750 | |||
1751 | pstAddIndicationAlt = (stLocalSFAddIndicationAlt *)(pvBuffer); | ||
1752 | |||
1753 | /* | ||
1754 | * In case of DSD Req By MS, we should immediately delete this SF so that | ||
1755 | * we can stop the further classifying the pkt for this SF. | ||
1756 | */ | ||
1757 | if(pstAddIndicationAlt->u8Type == DSD_REQ) | ||
1758 | { | ||
1759 | pstDeletionRequest = (stLocalSFDeleteRequest *)pvBuffer; | ||
1760 | |||
1761 | ulSFID = ntohl(pstDeletionRequest->u32SFID); | ||
1762 | uiSearchRuleIndex=SearchSfid(Adapter,ulSFID); | ||
1763 | |||
1764 | if(uiSearchRuleIndex < NO_OF_QUEUES) | ||
1765 | { | ||
1766 | deleteSFBySfid(Adapter,uiSearchRuleIndex); | ||
1767 | Adapter->u32TotalDSD++; | ||
1768 | } | ||
1769 | return 1; | ||
1770 | } | ||
1771 | |||
1772 | |||
1773 | if( (pstAddIndicationAlt->u8Type == DSD_RSP) || | ||
1774 | (pstAddIndicationAlt->u8Type == DSD_ACK)) | ||
1775 | { | ||
1776 | //No Special handling send the message as it is | ||
1777 | return 1; | ||
1778 | } | ||
1779 | // For DSA_REQ, only upto "psfAuthorizedSet" parameter should be accessed by driver! | ||
1780 | |||
1781 | pstAddIndication=(stLocalSFAddIndication *)kmalloc(sizeof(*pstAddIndication), GFP_KERNEL); | ||
1782 | if(NULL==pstAddIndication) | ||
1783 | return 0; | ||
1784 | |||
1785 | /* AUTHORIZED SET */ | ||
1786 | pstAddIndication->psfAuthorizedSet = (stServiceFlowParamSI *) | ||
1787 | GetNextTargetBufferLocation(Adapter, pstAddIndicationAlt->u16TID); | ||
1788 | if(!pstAddIndication->psfAuthorizedSet) | ||
1789 | return 0; | ||
1790 | |||
1791 | if(StoreSFParam(Adapter,(PUCHAR)&pstAddIndicationAlt->sfAuthorizedSet, | ||
1792 | (ULONG)pstAddIndication->psfAuthorizedSet)!= 1) | ||
1793 | return 0; | ||
1794 | |||
1795 | pstAddIndication->psfAuthorizedSet = (stServiceFlowParamSI *) | ||
1796 | ntohl((ULONG)pstAddIndication->psfAuthorizedSet); | ||
1797 | |||
1798 | if(pstAddIndicationAlt->u8Type == DSA_REQ) | ||
1799 | { | ||
1800 | stLocalSFAddRequest AddRequest; | ||
1801 | |||
1802 | AddRequest.u8Type = pstAddIndicationAlt->u8Type; | ||
1803 | AddRequest.eConnectionDir = pstAddIndicationAlt->u8Direction; | ||
1804 | AddRequest.u16TID = pstAddIndicationAlt->u16TID; | ||
1805 | AddRequest.u16CID = pstAddIndicationAlt->u16CID; | ||
1806 | AddRequest.u16VCID = pstAddIndicationAlt->u16VCID; | ||
1807 | AddRequest.psfParameterSet =pstAddIndication->psfAuthorizedSet ; | ||
1808 | (*puBufferLength) = sizeof(stLocalSFAddRequest); | ||
1809 | memcpy(pvBuffer,&AddRequest,sizeof(stLocalSFAddRequest)); | ||
1810 | return 1; | ||
1811 | } | ||
1812 | |||
1813 | // Since it's not DSA_REQ, we can access all field in pstAddIndicationAlt | ||
1814 | |||
1815 | //We need to extract the structure from the buffer and pack it differently | ||
1816 | |||
1817 | pstAddIndication->u8Type = pstAddIndicationAlt->u8Type; | ||
1818 | pstAddIndication->eConnectionDir= pstAddIndicationAlt->u8Direction ; | ||
1819 | pstAddIndication->u16TID = pstAddIndicationAlt->u16TID; | ||
1820 | pstAddIndication->u16CID = pstAddIndicationAlt->u16CID; | ||
1821 | pstAddIndication->u16VCID = pstAddIndicationAlt->u16VCID; | ||
1822 | pstAddIndication->u8CC = pstAddIndicationAlt->u8CC; | ||
1823 | |||
1824 | /* ADMITTED SET */ | ||
1825 | pstAddIndication->psfAdmittedSet = (stServiceFlowParamSI *) | ||
1826 | GetNextTargetBufferLocation(Adapter, pstAddIndicationAlt->u16TID); | ||
1827 | if(!pstAddIndication->psfAdmittedSet) | ||
1828 | return 0; | ||
1829 | if(StoreSFParam(Adapter,(PUCHAR)&pstAddIndicationAlt->sfAdmittedSet,(ULONG)pstAddIndication->psfAdmittedSet) != 1) | ||
1830 | return 0; | ||
1831 | |||
1832 | pstAddIndication->psfAdmittedSet = (stServiceFlowParamSI *)ntohl((ULONG)pstAddIndication->psfAdmittedSet); | ||
1833 | |||
1834 | |||
1835 | /* ACTIVE SET */ | ||
1836 | pstAddIndication->psfActiveSet = (stServiceFlowParamSI *) | ||
1837 | GetNextTargetBufferLocation(Adapter, pstAddIndicationAlt->u16TID); | ||
1838 | if(!pstAddIndication->psfActiveSet) | ||
1839 | return 0; | ||
1840 | if(StoreSFParam(Adapter,(PUCHAR)&pstAddIndicationAlt->sfActiveSet,(ULONG)pstAddIndication->psfActiveSet) != 1) | ||
1841 | return 0; | ||
1842 | |||
1843 | pstAddIndication->psfActiveSet = (stServiceFlowParamSI *)ntohl((ULONG)pstAddIndication->psfActiveSet); | ||
1844 | |||
1845 | (*puBufferLength) = sizeof(stLocalSFAddIndication); | ||
1846 | *(stLocalSFAddIndication *)pvBuffer = *pstAddIndication; | ||
1847 | bcm_kfree(pstAddIndication); | ||
1848 | return 1; | ||
1849 | } | ||
1850 | |||
1851 | |||
1852 | static inline stLocalSFAddIndicationAlt | ||
1853 | *RestoreCmControlResponseMessage(register PMINI_ADAPTER Adapter,register PVOID pvBuffer) | ||
1854 | { | ||
1855 | ULONG ulStatus=0; | ||
1856 | stLocalSFAddIndication *pstAddIndication = NULL; | ||
1857 | stLocalSFAddIndicationAlt *pstAddIndicationDest = NULL; | ||
1858 | pstAddIndication = (stLocalSFAddIndication *)(pvBuffer); | ||
1859 | |||
1860 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "=====>" ); | ||
1861 | if ((pstAddIndication->u8Type == DSD_REQ) || | ||
1862 | (pstAddIndication->u8Type == DSD_RSP) || | ||
1863 | (pstAddIndication->u8Type == DSD_ACK)) | ||
1864 | { | ||
1865 | return (stLocalSFAddIndicationAlt *)pvBuffer; | ||
1866 | } | ||
1867 | |||
1868 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Inside RestoreCmControlResponseMessage "); | ||
1869 | /* | ||
1870 | //Need to Allocate memory to contain the SUPER Large structures | ||
1871 | //Our driver cant create these structures on Stack :( | ||
1872 | */ | ||
1873 | pstAddIndicationDest=kmalloc(sizeof(stLocalSFAddIndicationAlt), GFP_KERNEL); | ||
1874 | |||
1875 | if(pstAddIndicationDest) | ||
1876 | { | ||
1877 | memset(pstAddIndicationDest,0,sizeof(stLocalSFAddIndicationAlt)); | ||
1878 | } | ||
1879 | else | ||
1880 | { | ||
1881 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Failed to allocate memory for SF Add Indication Structure "); | ||
1882 | return NULL; | ||
1883 | } | ||
1884 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-u8Type : 0x%X",pstAddIndication->u8Type); | ||
1885 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-u8Direction : 0x%X",pstAddIndication->eConnectionDir); | ||
1886 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-u8TID : 0x%X",ntohs(pstAddIndication->u16TID)); | ||
1887 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-u8CID : 0x%X",ntohs(pstAddIndication->u16CID)); | ||
1888 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-u16VCID : 0x%X",ntohs(pstAddIndication->u16VCID)); | ||
1889 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-autorized set loc : 0x%x",ntohl(pstAddIndication->psfAuthorizedSet)); | ||
1890 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-admitted set loc : 0x%x",ntohl(pstAddIndication->psfAdmittedSet)); | ||
1891 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-Active set loc : 0x%x",ntohl(pstAddIndication->psfActiveSet)); | ||
1892 | |||
1893 | pstAddIndicationDest->u8Type = pstAddIndication->u8Type; | ||
1894 | pstAddIndicationDest->u8Direction = pstAddIndication->eConnectionDir; | ||
1895 | pstAddIndicationDest->u16TID = pstAddIndication->u16TID; | ||
1896 | pstAddIndicationDest->u16CID = pstAddIndication->u16CID; | ||
1897 | pstAddIndicationDest->u16VCID = pstAddIndication->u16VCID; | ||
1898 | pstAddIndicationDest->u8CC = pstAddIndication->u8CC; | ||
1899 | |||
1900 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Restoring Active Set "); | ||
1901 | ulStatus=RestoreSFParam(Adapter,(ULONG)pstAddIndication->psfActiveSet, (PUCHAR)&pstAddIndicationDest->sfActiveSet); | ||
1902 | if(ulStatus != 1) | ||
1903 | { | ||
1904 | goto failed_restore_sf_param; | ||
1905 | } | ||
1906 | if(pstAddIndicationDest->sfActiveSet.u8TotalClassifiers > MAX_CLASSIFIERS_IN_SF) | ||
1907 | pstAddIndicationDest->sfActiveSet.u8TotalClassifiers = MAX_CLASSIFIERS_IN_SF; | ||
1908 | |||
1909 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Restoring Admitted Set "); | ||
1910 | ulStatus=RestoreSFParam(Adapter,(ULONG)pstAddIndication->psfAdmittedSet,(PUCHAR)&pstAddIndicationDest->sfAdmittedSet); | ||
1911 | if(ulStatus != 1) | ||
1912 | { | ||
1913 | goto failed_restore_sf_param; | ||
1914 | } | ||
1915 | if(pstAddIndicationDest->sfAdmittedSet.u8TotalClassifiers > MAX_CLASSIFIERS_IN_SF) | ||
1916 | pstAddIndicationDest->sfAdmittedSet.u8TotalClassifiers = MAX_CLASSIFIERS_IN_SF; | ||
1917 | |||
1918 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Restoring Authorized Set "); | ||
1919 | ulStatus=RestoreSFParam(Adapter,(ULONG)pstAddIndication->psfAuthorizedSet,(PUCHAR)&pstAddIndicationDest->sfAuthorizedSet); | ||
1920 | if(ulStatus != 1) | ||
1921 | { | ||
1922 | goto failed_restore_sf_param; | ||
1923 | } | ||
1924 | if(pstAddIndicationDest->sfAuthorizedSet.u8TotalClassifiers > MAX_CLASSIFIERS_IN_SF) | ||
1925 | pstAddIndicationDest->sfAuthorizedSet.u8TotalClassifiers = MAX_CLASSIFIERS_IN_SF; | ||
1926 | |||
1927 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Dumping the whole raw packet"); | ||
1928 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "============================================================"); | ||
1929 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " pstAddIndicationDest->sfActiveSet size %x %p", sizeof(*pstAddIndicationDest), pstAddIndicationDest); | ||
1930 | //BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, (unsigned char *)pstAddIndicationDest, sizeof(*pstAddIndicationDest)); | ||
1931 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "============================================================"); | ||
1932 | return pstAddIndicationDest; | ||
1933 | failed_restore_sf_param: | ||
1934 | bcm_kfree(pstAddIndicationDest); | ||
1935 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "<=====" ); | ||
1936 | return NULL; | ||
1937 | } | ||
1938 | |||
1939 | ULONG SetUpTargetDsxBuffers(PMINI_ADAPTER Adapter) | ||
1940 | { | ||
1941 | ULONG ulTargetDsxBuffersBase = 0; | ||
1942 | ULONG ulCntTargetBuffers; | ||
1943 | ULONG ulIndex=0; | ||
1944 | int Status; | ||
1945 | |||
1946 | if(Adapter->astTargetDsxBuffer[0].ulTargetDsxBuffer) | ||
1947 | return 1; | ||
1948 | |||
1949 | if(NULL == Adapter) | ||
1950 | { | ||
1951 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Adapter was NULL!!!"); | ||
1952 | return 0; | ||
1953 | } | ||
1954 | |||
1955 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Size of Each DSX Buffer(Also size of ServiceFlowParamSI): %x ",sizeof(stServiceFlowParamSI)); | ||
1956 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Reading DSX buffer From Target location %x ",DSX_MESSAGE_EXCHANGE_BUFFER); | ||
1957 | |||
1958 | Status = rdmalt(Adapter, DSX_MESSAGE_EXCHANGE_BUFFER, | ||
1959 | (PUINT)&ulTargetDsxBuffersBase, sizeof(UINT)); | ||
1960 | if(Status < 0) | ||
1961 | { | ||
1962 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "RDM failed!!"); | ||
1963 | return 0; | ||
1964 | } | ||
1965 | |||
1966 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Base Address Of DSX Target Buffer : 0x%lx",ulTargetDsxBuffersBase); | ||
1967 | |||
1968 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Tgt Buffer is Now %lx :",ulTargetDsxBuffersBase); | ||
1969 | |||
1970 | ulCntTargetBuffers = DSX_MESSAGE_EXCHANGE_BUFFER_SIZE/sizeof(stServiceFlowParamSI); | ||
1971 | |||
1972 | Adapter->ulTotalTargetBuffersAvailable = | ||
1973 | ulCntTargetBuffers > MAX_TARGET_DSX_BUFFERS ? | ||
1974 | MAX_TARGET_DSX_BUFFERS : ulCntTargetBuffers; | ||
1975 | |||
1976 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " Total Target DSX Buffer setup %lx ",Adapter->ulTotalTargetBuffersAvailable); | ||
1977 | |||
1978 | for(ulIndex=0; ulIndex < Adapter->ulTotalTargetBuffersAvailable ; ulIndex++) | ||
1979 | { | ||
1980 | Adapter->astTargetDsxBuffer[ulIndex].ulTargetDsxBuffer = ulTargetDsxBuffersBase; | ||
1981 | Adapter->astTargetDsxBuffer[ulIndex].valid=1; | ||
1982 | Adapter->astTargetDsxBuffer[ulIndex].tid=0; | ||
1983 | ulTargetDsxBuffersBase+=sizeof(stServiceFlowParamSI); | ||
1984 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " Target DSX Buffer %lx setup at 0x%lx", | ||
1985 | ulIndex, Adapter->astTargetDsxBuffer[ulIndex].ulTargetDsxBuffer); | ||
1986 | } | ||
1987 | Adapter->ulCurrentTargetBuffer = 0; | ||
1988 | Adapter->ulFreeTargetBufferCnt = Adapter->ulTotalTargetBuffersAvailable; | ||
1989 | return 1; | ||
1990 | } | ||
1991 | |||
1992 | ULONG GetNextTargetBufferLocation(PMINI_ADAPTER Adapter,B_UINT16 tid) | ||
1993 | { | ||
1994 | ULONG ulTargetDSXBufferAddress; | ||
1995 | ULONG ulTargetDsxBufferIndexToUse,ulMaxTry; | ||
1996 | |||
1997 | if((Adapter->ulTotalTargetBuffersAvailable == 0)|| | ||
1998 | (Adapter->ulFreeTargetBufferCnt == 0)) | ||
1999 | { | ||
2000 | ClearTargetDSXBuffer(Adapter,tid,FALSE); | ||
2001 | return 0; | ||
2002 | } | ||
2003 | |||
2004 | ulTargetDsxBufferIndexToUse = Adapter->ulCurrentTargetBuffer; | ||
2005 | ulMaxTry = Adapter->ulTotalTargetBuffersAvailable; | ||
2006 | while((ulMaxTry)&&(Adapter->astTargetDsxBuffer[ulTargetDsxBufferIndexToUse].valid != 1)) | ||
2007 | { | ||
2008 | ulTargetDsxBufferIndexToUse = (ulTargetDsxBufferIndexToUse+1)% | ||
2009 | Adapter->ulTotalTargetBuffersAvailable; | ||
2010 | ulMaxTry--; | ||
2011 | } | ||
2012 | |||
2013 | if(ulMaxTry==0) | ||
2014 | { | ||
2015 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "\n GetNextTargetBufferLocation : Error No Free Target DSX Buffers FreeCnt : %lx ",Adapter->ulFreeTargetBufferCnt); | ||
2016 | ClearTargetDSXBuffer(Adapter,tid,FALSE); | ||
2017 | return 0; | ||
2018 | } | ||
2019 | |||
2020 | |||
2021 | ulTargetDSXBufferAddress = | ||
2022 | Adapter->astTargetDsxBuffer[ulTargetDsxBufferIndexToUse].ulTargetDsxBuffer; | ||
2023 | Adapter->astTargetDsxBuffer[ulTargetDsxBufferIndexToUse].valid=0; | ||
2024 | Adapter->astTargetDsxBuffer[ulTargetDsxBufferIndexToUse].tid=tid; | ||
2025 | Adapter->ulFreeTargetBufferCnt--; | ||
2026 | |||
2027 | |||
2028 | ulTargetDsxBufferIndexToUse = | ||
2029 | (ulTargetDsxBufferIndexToUse+1)%Adapter->ulTotalTargetBuffersAvailable; | ||
2030 | Adapter->ulCurrentTargetBuffer = ulTargetDsxBufferIndexToUse; | ||
2031 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "GetNextTargetBufferLocation :Returning address %lx tid %d\n", | ||
2032 | ulTargetDSXBufferAddress,tid); | ||
2033 | return ulTargetDSXBufferAddress; | ||
2034 | } | ||
2035 | |||
2036 | |||
2037 | INT AllocAdapterDsxBuffer(PMINI_ADAPTER Adapter) | ||
2038 | { | ||
2039 | /* | ||
2040 | //Need to Allocate memory to contain the SUPER Large structures | ||
2041 | //Our driver cant create these structures on Stack | ||
2042 | */ | ||
2043 | Adapter->caDsxReqResp=kmalloc(sizeof(stLocalSFAddIndicationAlt)+LEADER_SIZE, GFP_KERNEL); | ||
2044 | if(!Adapter->caDsxReqResp) | ||
2045 | return -ENOMEM; | ||
2046 | return 0; | ||
2047 | } | ||
2048 | |||
2049 | INT FreeAdapterDsxBuffer(PMINI_ADAPTER Adapter) | ||
2050 | { | ||
2051 | if(Adapter->caDsxReqResp) | ||
2052 | { | ||
2053 | bcm_kfree(Adapter->caDsxReqResp); | ||
2054 | } | ||
2055 | return 0; | ||
2056 | |||
2057 | } | ||
2058 | /** | ||
2059 | @ingroup ctrl_pkt_functions | ||
2060 | This routinue would process the Control responses | ||
2061 | for the Connection Management. | ||
2062 | @return - Queue index for the free SFID else returns Invalid Index. | ||
2063 | */ | ||
2064 | BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter, /**<Pointer to the Adapter structure*/ | ||
2065 | PVOID pvBuffer /**Starting Address of the Buffer, that contains the AddIndication Data*/ | ||
2066 | ) | ||
2067 | { | ||
2068 | stServiceFlowParamSI *psfLocalSet=NULL; | ||
2069 | stLocalSFAddIndicationAlt *pstAddIndication = NULL; | ||
2070 | stLocalSFChangeIndicationAlt *pstChangeIndication = NULL; | ||
2071 | PLEADER pLeader=NULL; | ||
2072 | /* | ||
2073 | //Otherwise the message contains a target address from where we need to | ||
2074 | //read out the rest of the service flow param structure | ||
2075 | */ | ||
2076 | if((pstAddIndication = RestoreCmControlResponseMessage(Adapter,pvBuffer)) | ||
2077 | == NULL) | ||
2078 | { | ||
2079 | ClearTargetDSXBuffer(Adapter,((stLocalSFAddIndication *)pvBuffer)->u16TID, FALSE); | ||
2080 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_PRINTK, 0, 0, "Error in restoring Service Flow param structure from DSx message"); | ||
2081 | return FALSE; | ||
2082 | } | ||
2083 | |||
2084 | DumpCmControlPacket(pstAddIndication); | ||
2085 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "====>"); | ||
2086 | pLeader = (PLEADER)Adapter->caDsxReqResp; | ||
2087 | |||
2088 | pLeader->Status =CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ; | ||
2089 | pLeader->Vcid = 0; | ||
2090 | |||
2091 | ClearTargetDSXBuffer(Adapter,pstAddIndication->u16TID,FALSE); | ||
2092 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "### TID RECEIVED %d\n",pstAddIndication->u16TID); | ||
2093 | switch(pstAddIndication->u8Type) | ||
2094 | { | ||
2095 | case DSA_REQ: | ||
2096 | { | ||
2097 | pLeader->PLength = sizeof(stLocalSFAddIndicationAlt); | ||
2098 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Sending DSA Response....\n"); | ||
2099 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSA RESPONSE TO MAC %d", pLeader->PLength ); | ||
2100 | *((stLocalSFAddIndicationAlt*)&(Adapter->caDsxReqResp[LEADER_SIZE])) | ||
2101 | = *pstAddIndication; | ||
2102 | ((stLocalSFAddIndicationAlt*)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSA_RSP; | ||
2103 | |||
2104 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " VCID = %x", ntohs(pstAddIndication->u16VCID)); | ||
2105 | CopyBufferToControlPacket(Adapter,(PVOID)Adapter->caDsxReqResp); | ||
2106 | bcm_kfree(pstAddIndication); | ||
2107 | } | ||
2108 | break; | ||
2109 | case DSA_RSP: | ||
2110 | { | ||
2111 | pLeader->PLength = sizeof(stLocalSFAddIndicationAlt); | ||
2112 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSA ACK TO MAC %d", | ||
2113 | pLeader->PLength); | ||
2114 | *((stLocalSFAddIndicationAlt*)&(Adapter->caDsxReqResp[LEADER_SIZE])) | ||
2115 | = *pstAddIndication; | ||
2116 | ((stLocalSFAddIndicationAlt*)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSA_ACK; | ||
2117 | |||
2118 | }//no break here..we should go down. | ||
2119 | case DSA_ACK: | ||
2120 | { | ||
2121 | UINT uiSearchRuleIndex=0; | ||
2122 | struct timeval tv = {0}; | ||
2123 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "VCID:0x%X", | ||
2124 | ntohs(pstAddIndication->u16VCID)); | ||
2125 | uiSearchRuleIndex=SearchFreeSfid(Adapter); | ||
2126 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"uiSearchRuleIndex:0x%X ", | ||
2127 | uiSearchRuleIndex); | ||
2128 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Direction:0x%X ", | ||
2129 | pstAddIndication->u8Direction); | ||
2130 | if((uiSearchRuleIndex< NO_OF_QUEUES) ) | ||
2131 | { | ||
2132 | Adapter->PackInfo[uiSearchRuleIndex].ucDirection = | ||
2133 | pstAddIndication->u8Direction; | ||
2134 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "bValid:0x%X ", | ||
2135 | pstAddIndication->sfActiveSet.bValid); | ||
2136 | if(pstAddIndication->sfActiveSet.bValid==TRUE) | ||
2137 | { | ||
2138 | Adapter->PackInfo[uiSearchRuleIndex].bActiveSet=TRUE; | ||
2139 | } | ||
2140 | if(pstAddIndication->sfAuthorizedSet.bValid==TRUE) | ||
2141 | { | ||
2142 | Adapter->PackInfo[uiSearchRuleIndex].bAuthorizedSet=TRUE; | ||
2143 | } | ||
2144 | if(pstAddIndication->sfAdmittedSet.bValid==TRUE) | ||
2145 | { | ||
2146 | Adapter->PackInfo[uiSearchRuleIndex].bAdmittedSet=TRUE; | ||
2147 | } | ||
2148 | if(FALSE == pstAddIndication->sfActiveSet.bValid) | ||
2149 | { | ||
2150 | Adapter->PackInfo[uiSearchRuleIndex].bActive = FALSE; | ||
2151 | Adapter->PackInfo[uiSearchRuleIndex].bActivateRequestSent = FALSE; | ||
2152 | if(pstAddIndication->sfAdmittedSet.bValid) | ||
2153 | { | ||
2154 | psfLocalSet = &pstAddIndication->sfAdmittedSet; | ||
2155 | } | ||
2156 | else if(pstAddIndication->sfAuthorizedSet.bValid) | ||
2157 | { | ||
2158 | psfLocalSet = &pstAddIndication->sfAuthorizedSet; | ||
2159 | } | ||
2160 | } | ||
2161 | else | ||
2162 | { | ||
2163 | psfLocalSet = &pstAddIndication->sfActiveSet; | ||
2164 | Adapter->PackInfo[uiSearchRuleIndex].bActive=TRUE; | ||
2165 | } | ||
2166 | |||
2167 | if(!psfLocalSet) | ||
2168 | { | ||
2169 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "No set is valid\n"); | ||
2170 | Adapter->PackInfo[uiSearchRuleIndex].bActive=FALSE; | ||
2171 | Adapter->PackInfo[uiSearchRuleIndex].bValid=FALSE; | ||
2172 | Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value=0; | ||
2173 | bcm_kfree(pstAddIndication); | ||
2174 | } | ||
2175 | |||
2176 | else if(psfLocalSet->bValid && (pstAddIndication->u8CC == 0)) | ||
2177 | { | ||
2178 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "DSA ACK"); | ||
2179 | Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value = | ||
2180 | ntohs(pstAddIndication->u16VCID); | ||
2181 | Adapter->PackInfo[uiSearchRuleIndex].usCID = | ||
2182 | ntohs(pstAddIndication->u16CID); | ||
2183 | |||
2184 | if(UPLINK_DIR == pstAddIndication->u8Direction) | ||
2185 | atomic_set(&Adapter->PackInfo[uiSearchRuleIndex].uiPerSFTxResourceCount, DEFAULT_PERSFCOUNT); | ||
2186 | CopyToAdapter(Adapter,psfLocalSet,uiSearchRuleIndex, | ||
2187 | DSA_ACK, pstAddIndication); | ||
2188 | // don't free pstAddIndication | ||
2189 | |||
2190 | /* Inside CopyToAdapter, Sorting of all the SFs take place. | ||
2191 | Hence any access to the newly added SF through uiSearchRuleIndex is invalid. | ||
2192 | SHOULD BE STRICTLY AVOIDED. | ||
2193 | */ | ||
2194 | // *(PULONG)(((PUCHAR)pvBuffer)+1)=psfLocalSet->u32SFID; | ||
2195 | memcpy((((PUCHAR)pvBuffer)+1), &psfLocalSet->u32SFID, 4); | ||
2196 | |||
2197 | if(pstAddIndication->sfActiveSet.bValid == TRUE) | ||
2198 | { | ||
2199 | if(UPLINK_DIR == pstAddIndication->u8Direction) | ||
2200 | { | ||
2201 | if(!Adapter->LinkUpStatus) | ||
2202 | { | ||
2203 | netif_carrier_on(Adapter->dev); | ||
2204 | netif_start_queue(Adapter->dev); | ||
2205 | Adapter->LinkUpStatus = 1; | ||
2206 | do_gettimeofday(&tv); | ||
2207 | |||
2208 | atomic_set(&Adapter->TxPktAvail, 1); | ||
2209 | wake_up(&Adapter->tx_packet_wait_queue); | ||
2210 | Adapter->liTimeSinceLastNetEntry = tv.tv_sec; | ||
2211 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "============Tx Service Flow Created!"); | ||
2212 | } | ||
2213 | } | ||
2214 | } | ||
2215 | } | ||
2216 | |||
2217 | else | ||
2218 | { | ||
2219 | Adapter->PackInfo[uiSearchRuleIndex].bActive=FALSE; | ||
2220 | Adapter->PackInfo[uiSearchRuleIndex].bValid=FALSE; | ||
2221 | Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value=0; | ||
2222 | bcm_kfree(pstAddIndication); | ||
2223 | } | ||
2224 | } | ||
2225 | else | ||
2226 | { | ||
2227 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_PRINTK, 0, 0, "DSA ACK did not get valid SFID"); | ||
2228 | bcm_kfree(pstAddIndication); | ||
2229 | return FALSE; | ||
2230 | } | ||
2231 | } | ||
2232 | break; | ||
2233 | case DSC_REQ: | ||
2234 | { | ||
2235 | pLeader->PLength = sizeof(stLocalSFChangeIndicationAlt); | ||
2236 | pstChangeIndication = (stLocalSFChangeIndicationAlt*)pstAddIndication; | ||
2237 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSC RESPONSE TO MAC %d", pLeader->PLength); | ||
2238 | |||
2239 | *((stLocalSFChangeIndicationAlt*)&(Adapter->caDsxReqResp[LEADER_SIZE])) = *pstChangeIndication; | ||
2240 | ((stLocalSFChangeIndicationAlt*)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSC_RSP; | ||
2241 | |||
2242 | CopyBufferToControlPacket(Adapter,(PVOID)Adapter->caDsxReqResp); | ||
2243 | bcm_kfree(pstAddIndication); | ||
2244 | } | ||
2245 | break; | ||
2246 | case DSC_RSP: | ||
2247 | { | ||
2248 | pLeader->PLength = sizeof(stLocalSFChangeIndicationAlt); | ||
2249 | pstChangeIndication = (stLocalSFChangeIndicationAlt*)pstAddIndication; | ||
2250 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSC ACK TO MAC %d", pLeader->PLength); | ||
2251 | *((stLocalSFChangeIndicationAlt*)&(Adapter->caDsxReqResp[LEADER_SIZE])) = *pstChangeIndication; | ||
2252 | ((stLocalSFChangeIndicationAlt*)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSC_ACK; | ||
2253 | } | ||
2254 | case DSC_ACK: | ||
2255 | { | ||
2256 | UINT uiSearchRuleIndex=0; | ||
2257 | |||
2258 | pstChangeIndication = (stLocalSFChangeIndicationAlt *)pstAddIndication; | ||
2259 | uiSearchRuleIndex=SearchSfid(Adapter,ntohl(pstChangeIndication->sfActiveSet.u32SFID)); | ||
2260 | if(uiSearchRuleIndex > NO_OF_QUEUES-1) | ||
2261 | { | ||
2262 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_PRINTK, 0, 0, "SF doesn't exist for which DSC_ACK is received"); | ||
2263 | } | ||
2264 | if((uiSearchRuleIndex < NO_OF_QUEUES)) | ||
2265 | { | ||
2266 | Adapter->PackInfo[uiSearchRuleIndex].ucDirection = pstChangeIndication->u8Direction; | ||
2267 | if(pstChangeIndication->sfActiveSet.bValid==TRUE) | ||
2268 | { | ||
2269 | Adapter->PackInfo[uiSearchRuleIndex].bActiveSet=TRUE; | ||
2270 | } | ||
2271 | if(pstChangeIndication->sfAuthorizedSet.bValid==TRUE) | ||
2272 | { | ||
2273 | Adapter->PackInfo[uiSearchRuleIndex].bAuthorizedSet=TRUE; | ||
2274 | } | ||
2275 | if(pstChangeIndication->sfAdmittedSet.bValid==TRUE) | ||
2276 | { | ||
2277 | Adapter->PackInfo[uiSearchRuleIndex].bAdmittedSet=TRUE; | ||
2278 | } | ||
2279 | |||
2280 | if(FALSE==pstChangeIndication->sfActiveSet.bValid) | ||
2281 | { | ||
2282 | Adapter->PackInfo[uiSearchRuleIndex].bActive = FALSE; | ||
2283 | Adapter->PackInfo[uiSearchRuleIndex].bActivateRequestSent = FALSE; | ||
2284 | if(pstChangeIndication->sfAdmittedSet.bValid) | ||
2285 | { | ||
2286 | psfLocalSet = &pstChangeIndication->sfAdmittedSet; | ||
2287 | } | ||
2288 | else if(pstChangeIndication->sfAuthorizedSet.bValid) | ||
2289 | { | ||
2290 | psfLocalSet = &pstChangeIndication->sfAuthorizedSet; | ||
2291 | } | ||
2292 | } | ||
2293 | |||
2294 | else | ||
2295 | { | ||
2296 | psfLocalSet = &pstChangeIndication->sfActiveSet; | ||
2297 | Adapter->PackInfo[uiSearchRuleIndex].bActive=TRUE; | ||
2298 | } | ||
2299 | if(psfLocalSet->bValid && (pstChangeIndication->u8CC == 0)) | ||
2300 | { | ||
2301 | Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value = | ||
2302 | ntohs(pstChangeIndication->u16VCID); | ||
2303 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "CC field is %d bvalid = %d\n", | ||
2304 | pstChangeIndication->u8CC, psfLocalSet->bValid); | ||
2305 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "VCID= %d\n", ntohs(pstChangeIndication->u16VCID)); | ||
2306 | Adapter->PackInfo[uiSearchRuleIndex].usCID = | ||
2307 | ntohs(pstChangeIndication->u16CID); | ||
2308 | CopyToAdapter(Adapter,psfLocalSet,uiSearchRuleIndex, | ||
2309 | DSC_ACK, pstAddIndication); | ||
2310 | |||
2311 | *(PULONG)(((PUCHAR)pvBuffer)+1)=psfLocalSet->u32SFID; | ||
2312 | } | ||
2313 | else if(pstChangeIndication->u8CC == 6) | ||
2314 | { | ||
2315 | deleteSFBySfid(Adapter,uiSearchRuleIndex); | ||
2316 | bcm_kfree(pstAddIndication); | ||
2317 | } | ||
2318 | } | ||
2319 | else | ||
2320 | { | ||
2321 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_PRINTK, 0, 0, "DSC ACK did not get valid SFID"); | ||
2322 | bcm_kfree(pstAddIndication); | ||
2323 | return FALSE; | ||
2324 | } | ||
2325 | } | ||
2326 | break; | ||
2327 | case DSD_REQ: | ||
2328 | { | ||
2329 | UINT uiSearchRuleIndex; | ||
2330 | ULONG ulSFID; | ||
2331 | |||
2332 | pLeader->PLength = sizeof(stLocalSFDeleteIndication); | ||
2333 | *((stLocalSFDeleteIndication*)&(Adapter->caDsxReqResp[LEADER_SIZE])) = *((stLocalSFDeleteIndication*)pstAddIndication); | ||
2334 | |||
2335 | ulSFID = ntohl(((stLocalSFDeleteIndication*)pstAddIndication)->u32SFID); | ||
2336 | uiSearchRuleIndex=SearchSfid(Adapter,ulSFID); | ||
2337 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "DSD - Removing connection %x",uiSearchRuleIndex); | ||
2338 | |||
2339 | if(uiSearchRuleIndex < NO_OF_QUEUES) | ||
2340 | { | ||
2341 | //Delete All Classifiers Associated with this SFID | ||
2342 | deleteSFBySfid(Adapter,uiSearchRuleIndex); | ||
2343 | Adapter->u32TotalDSD++; | ||
2344 | } | ||
2345 | |||
2346 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSD RESPONSE TO MAC"); | ||
2347 | ((stLocalSFDeleteIndication*)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSD_RSP; | ||
2348 | CopyBufferToControlPacket(Adapter,(PVOID)Adapter->caDsxReqResp); | ||
2349 | } | ||
2350 | case DSD_RSP: | ||
2351 | { | ||
2352 | //Do nothing as SF has already got Deleted | ||
2353 | } | ||
2354 | break; | ||
2355 | case DSD_ACK: | ||
2356 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "DSD ACK Rcd, let App handle it\n"); | ||
2357 | break; | ||
2358 | default: | ||
2359 | bcm_kfree(pstAddIndication); | ||
2360 | return FALSE ; | ||
2361 | } | ||
2362 | return TRUE; | ||
2363 | } | ||
2364 | |||
2365 | int get_dsx_sf_data_to_application(PMINI_ADAPTER Adapter, UINT uiSFId, PUCHAR user_buffer) | ||
2366 | { | ||
2367 | int status = 0; | ||
2368 | struct _packet_info *psSfInfo=NULL; | ||
2369 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "status =%d",status); | ||
2370 | status = SearchSfid(Adapter, uiSFId); | ||
2371 | if(status>NO_OF_QUEUES) | ||
2372 | { | ||
2373 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SFID %d not present in queue !!!", uiSFId ); | ||
2374 | return -EINVAL; | ||
2375 | } | ||
2376 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "status =%d",status); | ||
2377 | psSfInfo=&Adapter->PackInfo[status]; | ||
2378 | if(psSfInfo->pstSFIndication && copy_to_user((PCHAR)user_buffer, | ||
2379 | (PCHAR)psSfInfo->pstSFIndication, sizeof(stLocalSFAddIndicationAlt))) | ||
2380 | { | ||
2381 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "copy to user failed SFID %d, present in queue !!!", uiSFId ); | ||
2382 | status = -EFAULT; | ||
2383 | return status; | ||
2384 | } | ||
2385 | return STATUS_SUCCESS; | ||
2386 | } | ||
2387 | |||
2388 | VOID OverrideServiceFlowParams(PMINI_ADAPTER Adapter,PUINT puiBuffer) | ||
2389 | { | ||
2390 | B_UINT32 u32NumofSFsinMsg = ntohl(*(puiBuffer + 1)); | ||
2391 | stIM_SFHostNotify *pHostInfo = NULL; | ||
2392 | UINT uiSearchRuleIndex = 0; | ||
2393 | ULONG ulSFID = 0; | ||
2394 | |||
2395 | puiBuffer+=2; | ||
2396 | |||
2397 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u32NumofSFsinMsg: 0x%x\n",u32NumofSFsinMsg); | ||
2398 | |||
2399 | while(u32NumofSFsinMsg != 0 && u32NumofSFsinMsg < NO_OF_QUEUES) | ||
2400 | { | ||
2401 | u32NumofSFsinMsg--; | ||
2402 | pHostInfo = (stIM_SFHostNotify *)puiBuffer; | ||
2403 | puiBuffer = (PUINT)(pHostInfo + 1); | ||
2404 | |||
2405 | ulSFID = ntohl(pHostInfo->SFID); | ||
2406 | uiSearchRuleIndex=SearchSfid(Adapter,ulSFID); | ||
2407 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"SFID: 0x%lx\n",ulSFID); | ||
2408 | |||
2409 | if(uiSearchRuleIndex >= NO_OF_QUEUES || uiSearchRuleIndex == HiPriority) | ||
2410 | { | ||
2411 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"The SFID <%lx> doesn't exist in host entry or is Invalid\n", ulSFID); | ||
2412 | continue; | ||
2413 | } | ||
2414 | |||
2415 | if(pHostInfo->RetainSF == FALSE) | ||
2416 | { | ||
2417 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Going to Delete SF"); | ||
2418 | deleteSFBySfid(Adapter,uiSearchRuleIndex); | ||
2419 | } | ||
2420 | else | ||
2421 | { | ||
2422 | |||
2423 | Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value = ntohs(pHostInfo->VCID); | ||
2424 | Adapter->PackInfo[uiSearchRuleIndex].usCID = ntohs(pHostInfo->newCID); | ||
2425 | Adapter->PackInfo[uiSearchRuleIndex].bActive=FALSE; | ||
2426 | |||
2427 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"pHostInfo->QoSParamSet: 0x%x\n",pHostInfo->QoSParamSet); | ||
2428 | |||
2429 | if(pHostInfo->QoSParamSet & 0x1) | ||
2430 | Adapter->PackInfo[uiSearchRuleIndex].bAuthorizedSet =TRUE; | ||
2431 | if(pHostInfo->QoSParamSet & 0x2) | ||
2432 | Adapter->PackInfo[uiSearchRuleIndex].bAdmittedSet =TRUE; | ||
2433 | if(pHostInfo->QoSParamSet & 0x4) | ||
2434 | { | ||
2435 | Adapter->PackInfo[uiSearchRuleIndex].bActiveSet =TRUE; | ||
2436 | Adapter->PackInfo[uiSearchRuleIndex].bActive=TRUE; | ||
2437 | } | ||
2438 | } | ||
2439 | } | ||
2440 | } | ||
2441 | |||
2442 | |||
2443 | |||
diff --git a/drivers/staging/bcm/CmHost.h b/drivers/staging/bcm/CmHost.h new file mode 100644 index 00000000000..847782c3765 --- /dev/null +++ b/drivers/staging/bcm/CmHost.h | |||
@@ -0,0 +1,166 @@ | |||
1 | /// ************************************************************************** | ||
2 | /// (c) Beceem Communications Inc. | ||
3 | /// All Rights Reserved | ||
4 | /// | ||
5 | /// \file : CmHost.h | ||
6 | /// \author : Rajeev Tirumala | ||
7 | /// \date : September 8 , 2006 | ||
8 | /// \brief : Definitions for Connection Management Requests structure | ||
9 | /// which we will use to setup our connection structures.Its high | ||
10 | /// time we had a header file for CmHost.cpp to isolate the way | ||
11 | /// f/w sends DSx messages and the way we interpret them in code. | ||
12 | /// Revision History | ||
13 | /// | ||
14 | /// Date Author Version Description | ||
15 | /// 08-Sep-06 Rajeev 0.1 Created | ||
16 | /// ************************************************************************** | ||
17 | #ifndef _CM_HOST_H | ||
18 | #define _CM_HOST_H | ||
19 | |||
20 | #pragma once | ||
21 | #pragma pack (push,4) | ||
22 | |||
23 | #define DSX_MESSAGE_EXCHANGE_BUFFER 0xBF60AC84 // This contains the pointer | ||
24 | #define DSX_MESSAGE_EXCHANGE_BUFFER_SIZE 72000 // 24 K Bytes | ||
25 | |||
26 | /// \brief structure stLocalSFAddRequest | ||
27 | typedef struct stLocalSFAddRequestAlt{ | ||
28 | B_UINT8 u8Type; | ||
29 | B_UINT8 u8Direction; | ||
30 | |||
31 | B_UINT16 u16TID; | ||
32 | /// \brief 16bitCID | ||
33 | B_UINT16 u16CID; | ||
34 | /// \brief 16bitVCID | ||
35 | B_UINT16 u16VCID; | ||
36 | |||
37 | |||
38 | /// \brief structure ParameterSet | ||
39 | stServiceFlowParamSI sfParameterSet; | ||
40 | |||
41 | //USE_MEMORY_MANAGER(); | ||
42 | }stLocalSFAddRequestAlt; | ||
43 | |||
44 | /// \brief structure stLocalSFAddIndication | ||
45 | typedef struct stLocalSFAddIndicationAlt{ | ||
46 | B_UINT8 u8Type; | ||
47 | B_UINT8 u8Direction; | ||
48 | B_UINT16 u16TID; | ||
49 | /// \brief 16bitCID | ||
50 | B_UINT16 u16CID; | ||
51 | /// \brief 16bitVCID | ||
52 | B_UINT16 u16VCID; | ||
53 | /// \brief structure AuthorizedSet | ||
54 | stServiceFlowParamSI sfAuthorizedSet; | ||
55 | /// \brief structure AdmittedSet | ||
56 | stServiceFlowParamSI sfAdmittedSet; | ||
57 | /// \brief structure ActiveSet | ||
58 | stServiceFlowParamSI sfActiveSet; | ||
59 | |||
60 | B_UINT8 u8CC; /**< Confirmation Code*/ | ||
61 | B_UINT8 u8Padd; /**< 8-bit Padding */ | ||
62 | B_UINT16 u16Padd; /**< 16 bit Padding */ | ||
63 | // USE_MEMORY_MANAGER(); | ||
64 | }stLocalSFAddIndicationAlt; | ||
65 | |||
66 | /// \brief structure stLocalSFAddConfirmation | ||
67 | typedef struct stLocalSFAddConfirmationAlt{ | ||
68 | B_UINT8 u8Type; | ||
69 | B_UINT8 u8Direction; | ||
70 | B_UINT16 u16TID; | ||
71 | /// \brief 16bitCID | ||
72 | B_UINT16 u16CID; | ||
73 | /// \brief 16bitVCID | ||
74 | B_UINT16 u16VCID; | ||
75 | /// \brief structure AuthorizedSet | ||
76 | stServiceFlowParamSI sfAuthorizedSet; | ||
77 | /// \brief structure AdmittedSet | ||
78 | stServiceFlowParamSI sfAdmittedSet; | ||
79 | /// \brief structure ActiveSet | ||
80 | stServiceFlowParamSI sfActiveSet; | ||
81 | }stLocalSFAddConfirmationAlt; | ||
82 | |||
83 | |||
84 | /// \brief structure stLocalSFChangeRequest | ||
85 | typedef struct stLocalSFChangeRequestAlt{ | ||
86 | B_UINT8 u8Type; | ||
87 | B_UINT8 u8Direction; | ||
88 | B_UINT16 u16TID; | ||
89 | /// \brief 16bitCID | ||
90 | B_UINT16 u16CID; | ||
91 | /// \brief 16bitVCID | ||
92 | B_UINT16 u16VCID; | ||
93 | /* | ||
94 | //Pointer location at which following Service Flow param Structure can be read | ||
95 | //from the target. We get only the address location and we need to read out the | ||
96 | //entire SF param structure at the given location on target | ||
97 | */ | ||
98 | /// \brief structure AuthorizedSet | ||
99 | stServiceFlowParamSI sfAuthorizedSet; | ||
100 | /// \brief structure AdmittedSet | ||
101 | stServiceFlowParamSI sfAdmittedSet; | ||
102 | /// \brief structure ParameterSet | ||
103 | stServiceFlowParamSI sfActiveSet; | ||
104 | |||
105 | B_UINT8 u8CC; /**< Confirmation Code*/ | ||
106 | B_UINT8 u8Padd; /**< 8-bit Padding */ | ||
107 | B_UINT16 u16Padd; /**< 16 bit */ | ||
108 | |||
109 | }stLocalSFChangeRequestAlt; | ||
110 | |||
111 | /// \brief structure stLocalSFChangeConfirmation | ||
112 | typedef struct stLocalSFChangeConfirmationAlt{ | ||
113 | B_UINT8 u8Type; | ||
114 | B_UINT8 u8Direction; | ||
115 | B_UINT16 u16TID; | ||
116 | /// \brief 16bitCID | ||
117 | B_UINT16 u16CID; | ||
118 | /// \brief 16bitVCID | ||
119 | B_UINT16 u16VCID; | ||
120 | /// \brief structure AuthorizedSet | ||
121 | stServiceFlowParamSI sfAuthorizedSet; | ||
122 | /// \brief structure AdmittedSet | ||
123 | stServiceFlowParamSI sfAdmittedSet; | ||
124 | /// \brief structure ActiveSet | ||
125 | stServiceFlowParamSI sfActiveSet; | ||
126 | |||
127 | }stLocalSFChangeConfirmationAlt; | ||
128 | |||
129 | /// \brief structure stLocalSFChangeIndication | ||
130 | typedef struct stLocalSFChangeIndicationAlt{ | ||
131 | B_UINT8 u8Type; | ||
132 | B_UINT8 u8Direction; | ||
133 | B_UINT16 u16TID; | ||
134 | /// \brief 16bitCID | ||
135 | B_UINT16 u16CID; | ||
136 | /// \brief 16bitVCID | ||
137 | B_UINT16 u16VCID; | ||
138 | /// \brief structure AuthorizedSet | ||
139 | stServiceFlowParamSI sfAuthorizedSet; | ||
140 | /// \brief structure AdmittedSet | ||
141 | stServiceFlowParamSI sfAdmittedSet; | ||
142 | /// \brief structure ActiveSet | ||
143 | stServiceFlowParamSI sfActiveSet; | ||
144 | |||
145 | B_UINT8 u8CC; /**< Confirmation Code*/ | ||
146 | B_UINT8 u8Padd; /**< 8-bit Padding */ | ||
147 | B_UINT16 u16Padd; /**< 16 bit */ | ||
148 | |||
149 | }stLocalSFChangeIndicationAlt; | ||
150 | |||
151 | ULONG StoreCmControlResponseMessage(PMINI_ADAPTER Adapter,PVOID pvBuffer,UINT *puBufferLength); | ||
152 | |||
153 | ULONG GetNextTargetBufferLocation(PMINI_ADAPTER Adapter,B_UINT16 tid); | ||
154 | |||
155 | INT AllocAdapterDsxBuffer(PMINI_ADAPTER Adapter); | ||
156 | |||
157 | INT FreeAdapterDsxBuffer(PMINI_ADAPTER Adapter); | ||
158 | ULONG SetUpTargetDsxBuffers(PMINI_ADAPTER Adapter); | ||
159 | |||
160 | BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter,PVOID pvBuffer); | ||
161 | |||
162 | VOID deleteSFBySfid(PMINI_ADAPTER Adapter, UINT uiSearchRuleIndex); | ||
163 | |||
164 | #pragma pack (pop) | ||
165 | |||
166 | #endif | ||
diff --git a/drivers/staging/bcm/DDRInit.c b/drivers/staging/bcm/DDRInit.c new file mode 100644 index 00000000000..8907e211d48 --- /dev/null +++ b/drivers/staging/bcm/DDRInit.c | |||
@@ -0,0 +1,1302 @@ | |||
1 | #include "headers.h" | ||
2 | |||
3 | #ifndef BCM_SHM_INTERFACE | ||
4 | |||
5 | |||
6 | #define DDR_DUMP_INTERNAL_DEVICE_MEMORY 0xBFC02B00 | ||
7 | #define MIPS_CLOCK_REG 0x0f000820 | ||
8 | |||
9 | //DDR INIT-133Mhz | ||
10 | #define T3_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 12 //index for 0x0F007000 | ||
11 | static DDR_SET_NODE asT3_DDRSetting133MHz[]= {// # DPLL Clock Setting | ||
12 | {0x0F000800,0x00007212}, | ||
13 | {0x0f000820,0x07F13FFF}, | ||
14 | {0x0f000810,0x00000F95}, | ||
15 | {0x0f000860,0x00000000}, | ||
16 | {0x0f000880,0x000003DD}, | ||
17 | // Changed source for X-bar and MIPS clock to APLL | ||
18 | {0x0f000840,0x0FFF1B00}, | ||
19 | {0x0f000870,0x00000002}, | ||
20 | {0x0F00a044,0x1fffffff}, | ||
21 | {0x0F00a040,0x1f000000}, | ||
22 | {0x0F00a084,0x1Cffffff}, | ||
23 | {0x0F00a080,0x1C000000}, | ||
24 | {0x0F00a04C,0x0000000C}, | ||
25 | //Memcontroller Default values | ||
26 | {0x0F007000,0x00010001}, | ||
27 | {0x0F007004,0x01010100}, | ||
28 | {0x0F007008,0x01000001}, | ||
29 | {0x0F00700c,0x00000000}, | ||
30 | {0x0F007010,0x01000000}, | ||
31 | {0x0F007014,0x01000100}, | ||
32 | {0x0F007018,0x01000000}, | ||
33 | {0x0F00701c,0x01020001},// POP - 0x00020001 Normal 0x01020001 | ||
34 | {0x0F007020,0x04030107}, //Normal - 0x04030107 POP - 0x05030107 | ||
35 | {0x0F007024,0x02000007}, | ||
36 | {0x0F007028,0x02020202}, | ||
37 | {0x0F00702c,0x0206060a},//ROB- 0x0205050a,//0x0206060a | ||
38 | {0x0F007030,0x05000000}, | ||
39 | {0x0F007034,0x00000003}, | ||
40 | {0x0F007038,0x110a0200},//ROB - 0x110a0200,//0x180a0200,// 0x1f0a0200 | ||
41 | {0x0F00703C,0x02101010},//ROB - 0x02101010,//0x02101018}, | ||
42 | {0x0F007040,0x45751200},//ROB - 0x45751200,//0x450f1200}, | ||
43 | {0x0F007044,0x110a0d00},//ROB - 0x110a0d00//0x111f0d00 | ||
44 | {0x0F007048,0x081b0306}, | ||
45 | {0x0F00704c,0x00000000}, | ||
46 | {0x0F007050,0x0000001c}, | ||
47 | {0x0F007054,0x00000000}, | ||
48 | {0x0F007058,0x00000000}, | ||
49 | {0x0F00705c,0x00000000}, | ||
50 | {0x0F007060,0x0010246c}, | ||
51 | {0x0F007064,0x00000010}, | ||
52 | {0x0F007068,0x00000000}, | ||
53 | {0x0F00706c,0x00000001}, | ||
54 | {0x0F007070,0x00007000}, | ||
55 | {0x0F007074,0x00000000}, | ||
56 | {0x0F007078,0x00000000}, | ||
57 | {0x0F00707C,0x00000000}, | ||
58 | {0x0F007080,0x00000000}, | ||
59 | {0x0F007084,0x00000000}, | ||
60 | //# Enable BW improvement within memory controller | ||
61 | {0x0F007094,0x00000104}, | ||
62 | //# Enable 2 ports within X-bar | ||
63 | {0x0F00A000,0x00000016}, | ||
64 | //# Enable start bit within memory controller | ||
65 | {0x0F007018,0x01010000} | ||
66 | }; | ||
67 | //80Mhz | ||
68 | #define T3_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 10 //index for 0x0F007000 | ||
69 | static DDR_SET_NODE asT3_DDRSetting80MHz[]= {// # DPLL Clock Setting | ||
70 | {0x0f000810,0x00000F95}, | ||
71 | {0x0f000820,0x07f1ffff}, | ||
72 | {0x0f000860,0x00000000}, | ||
73 | {0x0f000880,0x000003DD}, | ||
74 | {0x0F00a044,0x1fffffff}, | ||
75 | {0x0F00a040,0x1f000000}, | ||
76 | {0x0F00a084,0x1Cffffff}, | ||
77 | {0x0F00a080,0x1C000000}, | ||
78 | {0x0F00a000,0x00000016}, | ||
79 | {0x0F00a04C,0x0000000C}, | ||
80 | //Memcontroller Default values | ||
81 | {0x0F007000,0x00010001}, | ||
82 | {0x0F007004,0x01000000}, | ||
83 | {0x0F007008,0x01000001}, | ||
84 | {0x0F00700c,0x00000000}, | ||
85 | {0x0F007010,0x01000000}, | ||
86 | {0x0F007014,0x01000100}, | ||
87 | {0x0F007018,0x01000000}, | ||
88 | {0x0F00701c,0x01020000}, | ||
89 | {0x0F007020,0x04020107}, | ||
90 | {0x0F007024,0x00000007}, | ||
91 | {0x0F007028,0x02020201}, | ||
92 | {0x0F00702c,0x0204040a}, | ||
93 | {0x0F007030,0x04000000}, | ||
94 | {0x0F007034,0x00000002}, | ||
95 | {0x0F007038,0x1F060200}, | ||
96 | {0x0F00703C,0x1C22221F}, | ||
97 | {0x0F007040,0x8A006600}, | ||
98 | {0x0F007044,0x221a0800}, | ||
99 | {0x0F007048,0x02690204}, | ||
100 | {0x0F00704c,0x00000000}, | ||
101 | {0x0F007050,0x0000001c}, | ||
102 | {0x0F007054,0x00000000}, | ||
103 | {0x0F007058,0x00000000}, | ||
104 | {0x0F00705c,0x00000000}, | ||
105 | {0x0F007060,0x000A15D6}, | ||
106 | {0x0F007064,0x0000000A}, | ||
107 | {0x0F007068,0x00000000}, | ||
108 | {0x0F00706c,0x00000001}, | ||
109 | {0x0F007070,0x00004000}, | ||
110 | {0x0F007074,0x00000000}, | ||
111 | {0x0F007078,0x00000000}, | ||
112 | {0x0F00707C,0x00000000}, | ||
113 | {0x0F007080,0x00000000}, | ||
114 | {0x0F007084,0x00000000}, | ||
115 | {0x0F007094,0x00000104}, | ||
116 | //# Enable start bit within memory controller | ||
117 | {0x0F007018,0x01010000} | ||
118 | }; | ||
119 | //100Mhz | ||
120 | #define T3_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 13 //index for 0x0F007000 | ||
121 | static DDR_SET_NODE asT3_DDRSetting100MHz[]= {// # DPLL Clock Setting | ||
122 | {0x0F000800,0x00007008}, | ||
123 | {0x0f000810,0x00000F95}, | ||
124 | {0x0f000820,0x07F13E3F}, | ||
125 | {0x0f000860,0x00000000}, | ||
126 | {0x0f000880,0x000003DD}, | ||
127 | // Changed source for X-bar and MIPS clock to APLL | ||
128 | //0x0f000840,0x0FFF1800, | ||
129 | {0x0f000840,0x0FFF1B00}, | ||
130 | {0x0f000870,0x00000002}, | ||
131 | {0x0F00a044,0x1fffffff}, | ||
132 | {0x0F00a040,0x1f000000}, | ||
133 | {0x0F00a084,0x1Cffffff}, | ||
134 | {0x0F00a080,0x1C000000}, | ||
135 | {0x0F00a04C,0x0000000C}, | ||
136 | //# Enable 2 ports within X-bar | ||
137 | {0x0F00A000,0x00000016}, | ||
138 | //Memcontroller Default values | ||
139 | {0x0F007000,0x00010001}, | ||
140 | {0x0F007004,0x01010100}, | ||
141 | {0x0F007008,0x01000001}, | ||
142 | {0x0F00700c,0x00000000}, | ||
143 | {0x0F007010,0x01000000}, | ||
144 | {0x0F007014,0x01000100}, | ||
145 | {0x0F007018,0x01000000}, | ||
146 | {0x0F00701c,0x01020001}, // POP - 0x00020000 Normal 0x01020000 | ||
147 | {0x0F007020,0x04020107},//Normal - 0x04030107 POP - 0x05030107 | ||
148 | {0x0F007024,0x00000007}, | ||
149 | {0x0F007028,0x01020201}, | ||
150 | {0x0F00702c,0x0204040A}, | ||
151 | {0x0F007030,0x06000000}, | ||
152 | {0x0F007034,0x00000004}, | ||
153 | {0x0F007038,0x20080200}, | ||
154 | {0x0F00703C,0x02030320}, | ||
155 | {0x0F007040,0x6E7F1200}, | ||
156 | {0x0F007044,0x01190A00}, | ||
157 | {0x0F007048,0x06120305},//0x02690204 // 0x06120305 | ||
158 | {0x0F00704c,0x00000000}, | ||
159 | {0x0F007050,0x0000001C}, | ||
160 | {0x0F007054,0x00000000}, | ||
161 | {0x0F007058,0x00000000}, | ||
162 | {0x0F00705c,0x00000000}, | ||
163 | {0x0F007060,0x00082ED6}, | ||
164 | {0x0F007064,0x0000000A}, | ||
165 | {0x0F007068,0x00000000}, | ||
166 | {0x0F00706c,0x00000001}, | ||
167 | {0x0F007070,0x00005000}, | ||
168 | {0x0F007074,0x00000000}, | ||
169 | {0x0F007078,0x00000000}, | ||
170 | {0x0F00707C,0x00000000}, | ||
171 | {0x0F007080,0x00000000}, | ||
172 | {0x0F007084,0x00000000}, | ||
173 | //# Enable BW improvement within memory controller | ||
174 | {0x0F007094,0x00000104}, | ||
175 | //# Enable start bit within memory controller | ||
176 | {0x0F007018,0x01010000} | ||
177 | }; | ||
178 | |||
179 | //Net T3B DDR Settings | ||
180 | //DDR INIT-133Mhz | ||
181 | static DDR_SET_NODE asDPLL_266MHZ[] = { | ||
182 | {0x0F000800,0x00007212}, | ||
183 | {0x0f000820,0x07F13FFF}, | ||
184 | {0x0f000810,0x00000F95}, | ||
185 | {0x0f000860,0x00000000}, | ||
186 | {0x0f000880,0x000003DD}, | ||
187 | // Changed source for X-bar and MIPS clock to APLL | ||
188 | {0x0f000840,0x0FFF1B00}, | ||
189 | {0x0f000870,0x00000002} | ||
190 | }; | ||
191 | #if 0 | ||
192 | static DDR_SET_NODE asDPLL_800MHZ[] = { | ||
193 | {0x0f000810,0x00000F95}, | ||
194 | {0x0f000810,0x00000F95}, | ||
195 | {0x0f000810,0x00000F95}, | ||
196 | {0x0f000820,0x03F1365B}, | ||
197 | {0x0f000840,0x0FFF0000}, | ||
198 | {0x0f000880,0x000003DD}, | ||
199 | {0x0f000860,0x00000000} | ||
200 | }; | ||
201 | #endif | ||
202 | |||
203 | #define T3B_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 11 //index for 0x0F007000 | ||
204 | static DDR_SET_NODE asT3B_DDRSetting133MHz[] = {// # DPLL Clock Setting | ||
205 | {0x0f000810,0x00000F95}, | ||
206 | {0x0f000810,0x00000F95}, | ||
207 | {0x0f000810,0x00000F95}, | ||
208 | {0x0f000820,0x07F13652}, | ||
209 | {0x0f000840,0x0FFF0800}, | ||
210 | // Changed source for X-bar and MIPS clock to APLL | ||
211 | {0x0f000880,0x000003DD}, | ||
212 | {0x0f000860,0x00000000}, | ||
213 | // Changed source for X-bar and MIPS clock to APLL | ||
214 | {0x0F00a044,0x1fffffff}, | ||
215 | {0x0F00a040,0x1f000000}, | ||
216 | {0x0F00a084,0x1Cffffff}, | ||
217 | {0x0F00a080,0x1C000000}, | ||
218 | //# Enable 2 ports within X-bar | ||
219 | {0x0F00A000,0x00000016}, | ||
220 | //Memcontroller Default values | ||
221 | {0x0F007000,0x00010001}, | ||
222 | {0x0F007004,0x01010100}, | ||
223 | {0x0F007008,0x01000001}, | ||
224 | {0x0F00700c,0x00000000}, | ||
225 | {0x0F007010,0x01000000}, | ||
226 | {0x0F007014,0x01000100}, | ||
227 | {0x0F007018,0x01000000}, | ||
228 | {0x0F00701c,0x01020001},// POP - 0x00020001 Normal 0x01020001 | ||
229 | {0x0F007020,0x04030107}, //Normal - 0x04030107 POP - 0x05030107 | ||
230 | {0x0F007024,0x02000007}, | ||
231 | {0x0F007028,0x02020202}, | ||
232 | {0x0F00702c,0x0206060a},//ROB- 0x0205050a,//0x0206060a | ||
233 | {0x0F007030,0x05000000}, | ||
234 | {0x0F007034,0x00000003}, | ||
235 | {0x0F007038,0x130a0200},//ROB - 0x110a0200,//0x180a0200,// 0x1f0a0200 | ||
236 | {0x0F00703C,0x02101012},//ROB - 0x02101010,//0x02101018}, | ||
237 | {0x0F007040,0x457D1200},//ROB - 0x45751200,//0x450f1200}, | ||
238 | {0x0F007044,0x11130d00},//ROB - 0x110a0d00//0x111f0d00 | ||
239 | {0x0F007048,0x040D0306}, | ||
240 | {0x0F00704c,0x00000000}, | ||
241 | {0x0F007050,0x0000001c}, | ||
242 | {0x0F007054,0x00000000}, | ||
243 | {0x0F007058,0x00000000}, | ||
244 | {0x0F00705c,0x00000000}, | ||
245 | {0x0F007060,0x0010246c}, | ||
246 | {0x0F007064,0x00000012}, | ||
247 | {0x0F007068,0x00000000}, | ||
248 | {0x0F00706c,0x00000001}, | ||
249 | {0x0F007070,0x00007000}, | ||
250 | {0x0F007074,0x00000000}, | ||
251 | {0x0F007078,0x00000000}, | ||
252 | {0x0F00707C,0x00000000}, | ||
253 | {0x0F007080,0x00000000}, | ||
254 | {0x0F007084,0x00000000}, | ||
255 | //# Enable BW improvement within memory controller | ||
256 | {0x0F007094,0x00000104}, | ||
257 | //# Enable start bit within memory controller | ||
258 | {0x0F007018,0x01010000}, | ||
259 | }; | ||
260 | |||
261 | #define T3B_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 9 //index for 0x0F007000 | ||
262 | static DDR_SET_NODE asT3B_DDRSetting80MHz[] = {// # DPLL Clock Setting | ||
263 | {0x0f000810,0x00000F95}, | ||
264 | {0x0f000820,0x07F13FFF}, | ||
265 | {0x0f000840,0x0FFF1F00}, | ||
266 | {0x0f000880,0x000003DD}, | ||
267 | {0x0f000860,0x00000000}, | ||
268 | |||
269 | {0x0F00a044,0x1fffffff}, | ||
270 | {0x0F00a040,0x1f000000}, | ||
271 | {0x0F00a084,0x1Cffffff}, | ||
272 | {0x0F00a080,0x1C000000}, | ||
273 | {0x0F00a000,0x00000016}, | ||
274 | //Memcontroller Default values | ||
275 | {0x0F007000,0x00010001}, | ||
276 | {0x0F007004,0x01000000}, | ||
277 | {0x0F007008,0x01000001}, | ||
278 | {0x0F00700c,0x00000000}, | ||
279 | {0x0F007010,0x01000000}, | ||
280 | {0x0F007014,0x01000100}, | ||
281 | {0x0F007018,0x01000000}, | ||
282 | {0x0F00701c,0x01020000}, | ||
283 | {0x0F007020,0x04020107}, | ||
284 | {0x0F007024,0x00000007}, | ||
285 | {0x0F007028,0x02020201}, | ||
286 | {0x0F00702c,0x0204040a}, | ||
287 | {0x0F007030,0x04000000}, | ||
288 | {0x0F007034,0x02000002}, | ||
289 | {0x0F007038,0x1F060202}, | ||
290 | {0x0F00703C,0x1C22221F}, | ||
291 | {0x0F007040,0x8A006600}, | ||
292 | {0x0F007044,0x221a0800}, | ||
293 | {0x0F007048,0x02690204}, | ||
294 | {0x0F00704c,0x00000000}, | ||
295 | {0x0F007050,0x0100001c}, | ||
296 | {0x0F007054,0x00000000}, | ||
297 | {0x0F007058,0x00000000}, | ||
298 | {0x0F00705c,0x00000000}, | ||
299 | {0x0F007060,0x000A15D6}, | ||
300 | {0x0F007064,0x0000000A}, | ||
301 | {0x0F007068,0x00000000}, | ||
302 | {0x0F00706c,0x00000001}, | ||
303 | {0x0F007070,0x00004000}, | ||
304 | {0x0F007074,0x00000000}, | ||
305 | {0x0F007078,0x00000000}, | ||
306 | {0x0F00707C,0x00000000}, | ||
307 | {0x0F007080,0x00000000}, | ||
308 | {0x0F007084,0x00000000}, | ||
309 | {0x0F007094,0x00000104}, | ||
310 | //# Enable start bit within memory controller | ||
311 | {0x0F007018,0x01010000} | ||
312 | }; | ||
313 | |||
314 | //100Mhz | ||
315 | #define T3B_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 9 //index for 0x0F007000 | ||
316 | static DDR_SET_NODE asT3B_DDRSetting100MHz[] = {// # DPLL Clock Setting | ||
317 | {0x0f000810,0x00000F95}, | ||
318 | {0x0f000820,0x07F1369B}, | ||
319 | {0x0f000840,0x0FFF0800}, | ||
320 | {0x0f000880,0x000003DD}, | ||
321 | {0x0f000860,0x00000000}, | ||
322 | {0x0F00a044,0x1fffffff}, | ||
323 | {0x0F00a040,0x1f000000}, | ||
324 | {0x0F00a084,0x1Cffffff}, | ||
325 | {0x0F00a080,0x1C000000}, | ||
326 | //# Enable 2 ports within X-bar | ||
327 | {0x0F00A000,0x00000016}, | ||
328 | //Memcontroller Default values | ||
329 | {0x0F007000,0x00010001}, | ||
330 | {0x0F007004,0x01010100}, | ||
331 | {0x0F007008,0x01000001}, | ||
332 | {0x0F00700c,0x00000000}, | ||
333 | {0x0F007010,0x01000000}, | ||
334 | {0x0F007014,0x01000100}, | ||
335 | {0x0F007018,0x01000000}, | ||
336 | {0x0F00701c,0x01020000}, // POP - 0x00020000 Normal 0x01020000 | ||
337 | {0x0F007020,0x04020107},//Normal - 0x04030107 POP - 0x05030107 | ||
338 | {0x0F007024,0x00000007}, | ||
339 | {0x0F007028,0x01020201}, | ||
340 | {0x0F00702c,0x0204040A}, | ||
341 | {0x0F007030,0x06000000}, | ||
342 | {0x0F007034,0x02000004}, | ||
343 | {0x0F007038,0x20080200}, | ||
344 | {0x0F00703C,0x02030320}, | ||
345 | {0x0F007040,0x6E7F1200}, | ||
346 | {0x0F007044,0x01190A00}, | ||
347 | {0x0F007048,0x06120305},//0x02690204 // 0x06120305 | ||
348 | {0x0F00704c,0x00000000}, | ||
349 | {0x0F007050,0x0100001C}, | ||
350 | {0x0F007054,0x00000000}, | ||
351 | {0x0F007058,0x00000000}, | ||
352 | {0x0F00705c,0x00000000}, | ||
353 | {0x0F007060,0x00082ED6}, | ||
354 | {0x0F007064,0x0000000A}, | ||
355 | {0x0F007068,0x00000000}, | ||
356 | {0x0F00706c,0x00000001}, | ||
357 | {0x0F007070,0x00005000}, | ||
358 | {0x0F007074,0x00000000}, | ||
359 | {0x0F007078,0x00000000}, | ||
360 | {0x0F00707C,0x00000000}, | ||
361 | {0x0F007080,0x00000000}, | ||
362 | {0x0F007084,0x00000000}, | ||
363 | //# Enable BW improvement within memory controller | ||
364 | {0x0F007094,0x00000104}, | ||
365 | //# Enable start bit within memory controller | ||
366 | {0x0F007018,0x01010000} | ||
367 | }; | ||
368 | |||
369 | |||
370 | #define T3LP_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 9 //index for 0x0F007000 | ||
371 | static DDR_SET_NODE asT3LP_DDRSetting133MHz[]= {// # DPLL Clock Setting | ||
372 | {0x0f000820,0x03F1365B}, | ||
373 | {0x0f000810,0x00002F95}, | ||
374 | {0x0f000880,0x000003DD}, | ||
375 | // Changed source for X-bar and MIPS clock to APLL | ||
376 | {0x0f000840,0x0FFF0000}, | ||
377 | {0x0f000860,0x00000000}, | ||
378 | {0x0F00a044,0x1fffffff}, | ||
379 | {0x0F00a040,0x1f000000}, | ||
380 | {0x0F00a084,0x1Cffffff}, | ||
381 | {0x0F00a080,0x1C000000}, | ||
382 | {0x0F00A000,0x00000016}, | ||
383 | //Memcontroller Default values | ||
384 | {0x0F007000,0x00010001}, | ||
385 | {0x0F007004,0x01010100}, | ||
386 | {0x0F007008,0x01000001}, | ||
387 | {0x0F00700c,0x00000000}, | ||
388 | {0x0F007010,0x01000000}, | ||
389 | {0x0F007014,0x01000100}, | ||
390 | {0x0F007018,0x01000000}, | ||
391 | {0x0F00701c,0x01020001},// POP - 0x00020001 Normal 0x01020001 | ||
392 | {0x0F007020,0x04030107}, //Normal - 0x04030107 POP - 0x05030107 | ||
393 | {0x0F007024,0x02000007}, | ||
394 | {0x0F007028,0x02020200}, | ||
395 | {0x0F00702c,0x0206060a},//ROB- 0x0205050a,//0x0206060a | ||
396 | {0x0F007030,0x05000000}, | ||
397 | {0x0F007034,0x00000003}, | ||
398 | {0x0F007038,0x200a0200},//ROB - 0x110a0200,//0x180a0200,// 0x1f0a0200 | ||
399 | {0x0F00703C,0x02101020},//ROB - 0x02101010,//0x02101018, | ||
400 | {0x0F007040,0x45711200},//ROB - 0x45751200,//0x450f1200, | ||
401 | {0x0F007044,0x110D0D00},//ROB - 0x110a0d00//0x111f0d00 | ||
402 | {0x0F007048,0x04080306}, | ||
403 | {0x0F00704c,0x00000000}, | ||
404 | {0x0F007050,0x0100001c}, | ||
405 | {0x0F007054,0x00000000}, | ||
406 | {0x0F007058,0x00000000}, | ||
407 | {0x0F00705c,0x00000000}, | ||
408 | {0x0F007060,0x0010245F}, | ||
409 | {0x0F007064,0x00000010}, | ||
410 | {0x0F007068,0x00000000}, | ||
411 | {0x0F00706c,0x00000001}, | ||
412 | {0x0F007070,0x00007000}, | ||
413 | {0x0F007074,0x00000000}, | ||
414 | {0x0F007078,0x00000000}, | ||
415 | {0x0F00707C,0x00000000}, | ||
416 | {0x0F007080,0x00000000}, | ||
417 | {0x0F007084,0x00000000}, | ||
418 | {0x0F007088,0x01000001}, | ||
419 | {0x0F00708c,0x00000101}, | ||
420 | {0x0F007090,0x00000000}, | ||
421 | //# Enable BW improvement within memory controller | ||
422 | {0x0F007094,0x00040000}, | ||
423 | {0x0F007098,0x00000000}, | ||
424 | {0x0F0070c8,0x00000104}, | ||
425 | //# Enable 2 ports within X-bar | ||
426 | //# Enable start bit within memory controller | ||
427 | {0x0F007018,0x01010000} | ||
428 | }; | ||
429 | |||
430 | #define T3LP_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 11 //index for 0x0F007000 | ||
431 | static DDR_SET_NODE asT3LP_DDRSetting100MHz[]= {// # DPLL Clock Setting | ||
432 | {0x0f000810,0x00002F95}, | ||
433 | {0x0f000820,0x03F1369B}, | ||
434 | {0x0f000840,0x0fff0000}, | ||
435 | {0x0f000860,0x00000000}, | ||
436 | {0x0f000880,0x000003DD}, | ||
437 | // Changed source for X-bar and MIPS clock to APLL | ||
438 | {0x0f000840,0x0FFF0000}, | ||
439 | {0x0F00a044,0x1fffffff}, | ||
440 | {0x0F00a040,0x1f000000}, | ||
441 | {0x0F00a084,0x1Cffffff}, | ||
442 | {0x0F00a080,0x1C000000}, | ||
443 | //Memcontroller Default values | ||
444 | {0x0F007000,0x00010001}, | ||
445 | {0x0F007004,0x01010100}, | ||
446 | {0x0F007008,0x01000001}, | ||
447 | {0x0F00700c,0x00000000}, | ||
448 | {0x0F007010,0x01000000}, | ||
449 | {0x0F007014,0x01000100}, | ||
450 | {0x0F007018,0x01000000}, | ||
451 | {0x0F00701c,0x01020000},// POP - 0x00020001 Normal 0x01020001 | ||
452 | {0x0F007020,0x04020107}, //Normal - 0x04030107 POP - 0x05030107 | ||
453 | {0x0F007024,0x00000007}, | ||
454 | {0x0F007028,0x01020200}, | ||
455 | {0x0F00702c,0x0204040a},//ROB- 0x0205050a,//0x0206060a | ||
456 | {0x0F007030,0x06000000}, | ||
457 | {0x0F007034,0x00000004}, | ||
458 | {0x0F007038,0x1F080200},//ROB - 0x110a0200,//0x180a0200,// 0x1f0a0200 | ||
459 | {0x0F00703C,0x0203031F},//ROB - 0x02101010,//0x02101018, | ||
460 | {0x0F007040,0x6e001200},//ROB - 0x45751200,//0x450f1200, | ||
461 | {0x0F007044,0x011a0a00},//ROB - 0x110a0d00//0x111f0d00 | ||
462 | {0x0F007048,0x03000305}, | ||
463 | {0x0F00704c,0x00000000}, | ||
464 | {0x0F007050,0x0100001c}, | ||
465 | {0x0F007054,0x00000000}, | ||
466 | {0x0F007058,0x00000000}, | ||
467 | {0x0F00705c,0x00000000}, | ||
468 | {0x0F007060,0x00082ED6}, | ||
469 | {0x0F007064,0x0000000A}, | ||
470 | {0x0F007068,0x00000000}, | ||
471 | {0x0F00706c,0x00000001}, | ||
472 | {0x0F007070,0x00005000}, | ||
473 | {0x0F007074,0x00000000}, | ||
474 | {0x0F007078,0x00000000}, | ||
475 | {0x0F00707C,0x00000000}, | ||
476 | {0x0F007080,0x00000000}, | ||
477 | {0x0F007084,0x00000000}, | ||
478 | {0x0F007088,0x01000001}, | ||
479 | {0x0F00708c,0x00000101}, | ||
480 | {0x0F007090,0x00000000}, | ||
481 | {0x0F007094,0x00010000}, | ||
482 | {0x0F007098,0x00000000}, | ||
483 | {0x0F0070C8,0x00000104}, | ||
484 | //# Enable 2 ports within X-bar | ||
485 | {0x0F00A000,0x00000016}, | ||
486 | //# Enable start bit within memory controller | ||
487 | {0x0F007018,0x01010000} | ||
488 | }; | ||
489 | |||
490 | #define T3LP_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 9 //index for 0x0F007000 | ||
491 | static DDR_SET_NODE asT3LP_DDRSetting80MHz[]= {// # DPLL Clock Setting | ||
492 | {0x0f000820,0x07F13FFF}, | ||
493 | {0x0f000810,0x00002F95}, | ||
494 | {0x0f000860,0x00000000}, | ||
495 | {0x0f000880,0x000003DD}, | ||
496 | {0x0f000840,0x0FFF1F00}, | ||
497 | {0x0F00a044,0x1fffffff}, | ||
498 | {0x0F00a040,0x1f000000}, | ||
499 | {0x0F00a084,0x1Cffffff}, | ||
500 | {0x0F00a080,0x1C000000}, | ||
501 | {0x0F00A000,0x00000016}, | ||
502 | {0x0f007000,0x00010001}, | ||
503 | {0x0f007004,0x01000000}, | ||
504 | {0x0f007008,0x01000001}, | ||
505 | {0x0f00700c,0x00000000}, | ||
506 | {0x0f007010,0x01000000}, | ||
507 | {0x0f007014,0x01000100}, | ||
508 | {0x0f007018,0x01000000}, | ||
509 | {0x0f00701c,0x01020000}, | ||
510 | {0x0f007020,0x04020107}, | ||
511 | {0x0f007024,0x00000007}, | ||
512 | {0x0f007028,0x02020200}, | ||
513 | {0x0f00702c,0x0204040a}, | ||
514 | {0x0f007030,0x04000000}, | ||
515 | {0x0f007034,0x00000002}, | ||
516 | {0x0f007038,0x1d060200}, | ||
517 | {0x0f00703c,0x1c22221d}, | ||
518 | {0x0f007040,0x8A116600}, | ||
519 | {0x0f007044,0x222d0800}, | ||
520 | {0x0f007048,0x02690204}, | ||
521 | {0x0f00704c,0x00000000}, | ||
522 | {0x0f007050,0x0100001c}, | ||
523 | {0x0f007054,0x00000000}, | ||
524 | {0x0f007058,0x00000000}, | ||
525 | {0x0f00705c,0x00000000}, | ||
526 | {0x0f007060,0x000A15D6}, | ||
527 | {0x0f007064,0x0000000A}, | ||
528 | {0x0f007068,0x00000000}, | ||
529 | {0x0f00706c,0x00000001}, | ||
530 | {0x0f007070,0x00004000}, | ||
531 | {0x0f007074,0x00000000}, | ||
532 | {0x0f007078,0x00000000}, | ||
533 | {0x0f00707c,0x00000000}, | ||
534 | {0x0f007080,0x00000000}, | ||
535 | {0x0f007084,0x00000000}, | ||
536 | {0x0f007088,0x01000001}, | ||
537 | {0x0f00708c,0x00000101}, | ||
538 | {0x0f007090,0x00000000}, | ||
539 | {0x0f007094,0x00010000}, | ||
540 | {0x0f007098,0x00000000}, | ||
541 | {0x0F0070C8,0x00000104}, | ||
542 | {0x0F007018,0x01010000} | ||
543 | }; | ||
544 | |||
545 | |||
546 | |||
547 | |||
548 | ///T3 LP-B (UMA-B) | ||
549 | |||
550 | #define T3LPB_SKIP_CLOCK_PROGRAM_DUMP_160MHZ 7 //index for 0x0F007000 | ||
551 | static DDR_SET_NODE asT3LPB_DDRSetting160MHz[]= {// # DPLL Clock Setting | ||
552 | |||
553 | {0x0f000820,0x03F137DB}, | ||
554 | {0x0f000810,0x01842795}, | ||
555 | {0x0f000860,0x00000000}, | ||
556 | {0x0f000880,0x000003DD}, | ||
557 | {0x0f000840,0x0FFF0400}, | ||
558 | {0x0F00a044,0x1fffffff}, | ||
559 | {0x0F00a040,0x1f000000}, | ||
560 | {0x0f003050,0x00000021},//this is flash/eeprom clock divisor which set the flash clock to 20 MHz | ||
561 | {0x0F00a084,0x1Cffffff},//Now dump from her in internal memory | ||
562 | {0x0F00a080,0x1C000000}, | ||
563 | {0x0F00A000,0x00000016}, | ||
564 | {0x0f007000,0x00010001}, | ||
565 | {0x0f007004,0x01000001}, | ||
566 | {0x0f007008,0x01000101}, | ||
567 | {0x0f00700c,0x00000000}, | ||
568 | {0x0f007010,0x01000100}, | ||
569 | {0x0f007014,0x01000100}, | ||
570 | {0x0f007018,0x01000000}, | ||
571 | {0x0f00701c,0x01020000}, | ||
572 | {0x0f007020,0x04030107}, | ||
573 | {0x0f007024,0x02000007}, | ||
574 | {0x0f007028,0x02020200}, | ||
575 | {0x0f00702c,0x0206060a}, | ||
576 | {0x0f007030,0x050d0d00}, | ||
577 | {0x0f007034,0x00000003}, | ||
578 | {0x0f007038,0x170a0200}, | ||
579 | {0x0f00703c,0x02101012}, | ||
580 | {0x0f007040,0x45161200}, | ||
581 | {0x0f007044,0x11250c00}, | ||
582 | {0x0f007048,0x04da0307}, | ||
583 | {0x0f00704c,0x00000000}, | ||
584 | {0x0f007050,0x0000001c}, | ||
585 | {0x0f007054,0x00000000}, | ||
586 | {0x0f007058,0x00000000}, | ||
587 | {0x0f00705c,0x00000000}, | ||
588 | {0x0f007060,0x00142bb6}, | ||
589 | {0x0f007064,0x20430014}, | ||
590 | {0x0f007068,0x00000000}, | ||
591 | {0x0f00706c,0x00000001}, | ||
592 | {0x0f007070,0x00009000}, | ||
593 | {0x0f007074,0x00000000}, | ||
594 | {0x0f007078,0x00000000}, | ||
595 | {0x0f00707c,0x00000000}, | ||
596 | {0x0f007080,0x00000000}, | ||
597 | {0x0f007084,0x00000000}, | ||
598 | {0x0f007088,0x01000001}, | ||
599 | {0x0f00708c,0x00000101}, | ||
600 | {0x0f007090,0x00000000}, | ||
601 | {0x0f007094,0x00040000}, | ||
602 | {0x0f007098,0x00000000}, | ||
603 | {0x0F0070C8,0x00000104}, | ||
604 | {0x0F007018,0x01010000} | ||
605 | }; | ||
606 | |||
607 | |||
608 | #define T3LPB_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 7 //index for 0x0F007000 | ||
609 | static DDR_SET_NODE asT3LPB_DDRSetting133MHz[]= {// # DPLL Clock Setting | ||
610 | {0x0f000820,0x03F1365B}, | ||
611 | {0x0f000810,0x00002F95}, | ||
612 | {0x0f000880,0x000003DD}, | ||
613 | // Changed source for X-bar and MIPS clock to APLL | ||
614 | {0x0f000840,0x0FFF0000}, | ||
615 | {0x0f000860,0x00000000}, | ||
616 | {0x0F00a044,0x1fffffff}, | ||
617 | {0x0F00a040,0x1f000000}, | ||
618 | {0x0f003050,0x00000021},//flash/eeprom clock divisor which set the flash clock to 20 MHz | ||
619 | {0x0F00a084,0x1Cffffff},//dump from here in internal memory | ||
620 | {0x0F00a080,0x1C000000}, | ||
621 | {0x0F00A000,0x00000016}, | ||
622 | //Memcontroller Default values | ||
623 | {0x0F007000,0x00010001}, | ||
624 | {0x0F007004,0x01010100}, | ||
625 | {0x0F007008,0x01000001}, | ||
626 | {0x0F00700c,0x00000000}, | ||
627 | {0x0F007010,0x01000000}, | ||
628 | {0x0F007014,0x01000100}, | ||
629 | {0x0F007018,0x01000000}, | ||
630 | {0x0F00701c,0x01020001},// POP - 0x00020001 Normal 0x01020001 | ||
631 | {0x0F007020,0x04030107}, //Normal - 0x04030107 POP - 0x05030107 | ||
632 | {0x0F007024,0x02000007}, | ||
633 | {0x0F007028,0x02020200}, | ||
634 | {0x0F00702c,0x0206060a},//ROB- 0x0205050a,//0x0206060a | ||
635 | {0x0F007030,0x05000000}, | ||
636 | {0x0F007034,0x00000003}, | ||
637 | {0x0F007038,0x190a0200},//ROB - 0x110a0200,//0x180a0200,// 0x1f0a0200 | ||
638 | {0x0F00703C,0x02101017},//ROB - 0x02101010,//0x02101018, | ||
639 | {0x0F007040,0x45171200},//ROB - 0x45751200,//0x450f1200, | ||
640 | {0x0F007044,0x11290D00},//ROB - 0x110a0d00//0x111f0d00 | ||
641 | {0x0F007048,0x04080306}, | ||
642 | {0x0F00704c,0x00000000}, | ||
643 | {0x0F007050,0x0100001c}, | ||
644 | {0x0F007054,0x00000000}, | ||
645 | {0x0F007058,0x00000000}, | ||
646 | {0x0F00705c,0x00000000}, | ||
647 | {0x0F007060,0x0010245F}, | ||
648 | {0x0F007064,0x00000010}, | ||
649 | {0x0F007068,0x00000000}, | ||
650 | {0x0F00706c,0x00000001}, | ||
651 | {0x0F007070,0x00007000}, | ||
652 | {0x0F007074,0x00000000}, | ||
653 | {0x0F007078,0x00000000}, | ||
654 | {0x0F00707C,0x00000000}, | ||
655 | {0x0F007080,0x00000000}, | ||
656 | {0x0F007084,0x00000000}, | ||
657 | {0x0F007088,0x01000001}, | ||
658 | {0x0F00708c,0x00000101}, | ||
659 | {0x0F007090,0x00000000}, | ||
660 | //# Enable BW improvement within memory controller | ||
661 | {0x0F007094,0x00040000}, | ||
662 | {0x0F007098,0x00000000}, | ||
663 | {0x0F0070c8,0x00000104}, | ||
664 | //# Enable 2 ports within X-bar | ||
665 | //# Enable start bit within memory controller | ||
666 | {0x0F007018,0x01010000} | ||
667 | }; | ||
668 | |||
669 | #define T3LPB_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 8 //index for 0x0F007000 | ||
670 | static DDR_SET_NODE asT3LPB_DDRSetting100MHz[]= {// # DPLL Clock Setting | ||
671 | {0x0f000810,0x00002F95}, | ||
672 | {0x0f000820,0x03F1369B}, | ||
673 | {0x0f000840,0x0fff0000}, | ||
674 | {0x0f000860,0x00000000}, | ||
675 | {0x0f000880,0x000003DD}, | ||
676 | // Changed source for X-bar and MIPS clock to APLL | ||
677 | {0x0f000840,0x0FFF0000}, | ||
678 | {0x0F00a044,0x1fffffff}, | ||
679 | {0x0F00a040,0x1f000000}, | ||
680 | {0x0f003050,0x00000021},//flash/eeprom clock divisor which set the flash clock to 20 MHz | ||
681 | {0x0F00a084,0x1Cffffff}, //dump from here in internal memory | ||
682 | {0x0F00a080,0x1C000000}, | ||
683 | //Memcontroller Default values | ||
684 | {0x0F007000,0x00010001}, | ||
685 | {0x0F007004,0x01010100}, | ||
686 | {0x0F007008,0x01000001}, | ||
687 | {0x0F00700c,0x00000000}, | ||
688 | {0x0F007010,0x01000000}, | ||
689 | {0x0F007014,0x01000100}, | ||
690 | {0x0F007018,0x01000000}, | ||
691 | {0x0F00701c,0x01020000},// POP - 0x00020001 Normal 0x01020001 | ||
692 | {0x0F007020,0x04020107}, //Normal - 0x04030107 POP - 0x05030107 | ||
693 | {0x0F007024,0x00000007}, | ||
694 | {0x0F007028,0x01020200}, | ||
695 | {0x0F00702c,0x0204040a},//ROB- 0x0205050a,//0x0206060a | ||
696 | {0x0F007030,0x06000000}, | ||
697 | {0x0F007034,0x00000004}, | ||
698 | {0x0F007038,0x1F080200},//ROB - 0x110a0200,//0x180a0200,// 0x1f0a0200 | ||
699 | {0x0F00703C,0x0203031F},//ROB - 0x02101010,//0x02101018, | ||
700 | {0x0F007040,0x6e001200},//ROB - 0x45751200,//0x450f1200, | ||
701 | {0x0F007044,0x011a0a00},//ROB - 0x110a0d00//0x111f0d00 | ||
702 | {0x0F007048,0x03000305}, | ||
703 | {0x0F00704c,0x00000000}, | ||
704 | {0x0F007050,0x0100001c}, | ||
705 | {0x0F007054,0x00000000}, | ||
706 | {0x0F007058,0x00000000}, | ||
707 | {0x0F00705c,0x00000000}, | ||
708 | {0x0F007060,0x00082ED6}, | ||
709 | {0x0F007064,0x0000000A}, | ||
710 | {0x0F007068,0x00000000}, | ||
711 | {0x0F00706c,0x00000001}, | ||
712 | {0x0F007070,0x00005000}, | ||
713 | {0x0F007074,0x00000000}, | ||
714 | {0x0F007078,0x00000000}, | ||
715 | {0x0F00707C,0x00000000}, | ||
716 | {0x0F007080,0x00000000}, | ||
717 | {0x0F007084,0x00000000}, | ||
718 | {0x0F007088,0x01000001}, | ||
719 | {0x0F00708c,0x00000101}, | ||
720 | {0x0F007090,0x00000000}, | ||
721 | {0x0F007094,0x00010000}, | ||
722 | {0x0F007098,0x00000000}, | ||
723 | {0x0F0070C8,0x00000104}, | ||
724 | //# Enable 2 ports within X-bar | ||
725 | {0x0F00A000,0x00000016}, | ||
726 | //# Enable start bit within memory controller | ||
727 | {0x0F007018,0x01010000} | ||
728 | }; | ||
729 | |||
730 | #define T3LPB_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 7 //index for 0x0F007000 | ||
731 | static DDR_SET_NODE asT3LPB_DDRSetting80MHz[]= {// # DPLL Clock Setting | ||
732 | {0x0f000820,0x07F13FFF}, | ||
733 | {0x0f000810,0x00002F95}, | ||
734 | {0x0f000860,0x00000000}, | ||
735 | {0x0f000880,0x000003DD}, | ||
736 | {0x0f000840,0x0FFF1F00}, | ||
737 | {0x0F00a044,0x1fffffff}, | ||
738 | {0x0F00a040,0x1f000000}, | ||
739 | {0x0f003050,0x00000021},//flash/eeprom clock divisor which set the flash clock to 20 MHz | ||
740 | {0x0F00a084,0x1Cffffff},// dump from here in internal memory | ||
741 | {0x0F00a080,0x1C000000}, | ||
742 | {0x0F00A000,0x00000016}, | ||
743 | {0x0f007000,0x00010001}, | ||
744 | {0x0f007004,0x01000000}, | ||
745 | {0x0f007008,0x01000001}, | ||
746 | {0x0f00700c,0x00000000}, | ||
747 | {0x0f007010,0x01000000}, | ||
748 | {0x0f007014,0x01000100}, | ||
749 | {0x0f007018,0x01000000}, | ||
750 | {0x0f00701c,0x01020000}, | ||
751 | {0x0f007020,0x04020107}, | ||
752 | {0x0f007024,0x00000007}, | ||
753 | {0x0f007028,0x02020200}, | ||
754 | {0x0f00702c,0x0204040a}, | ||
755 | {0x0f007030,0x04000000}, | ||
756 | {0x0f007034,0x00000002}, | ||
757 | {0x0f007038,0x1d060200}, | ||
758 | {0x0f00703c,0x1c22221d}, | ||
759 | {0x0f007040,0x8A116600}, | ||
760 | {0x0f007044,0x222d0800}, | ||
761 | {0x0f007048,0x02690204}, | ||
762 | {0x0f00704c,0x00000000}, | ||
763 | {0x0f007050,0x0100001c}, | ||
764 | {0x0f007054,0x00000000}, | ||
765 | {0x0f007058,0x00000000}, | ||
766 | {0x0f00705c,0x00000000}, | ||
767 | {0x0f007060,0x000A15D6}, | ||
768 | {0x0f007064,0x0000000A}, | ||
769 | {0x0f007068,0x00000000}, | ||
770 | {0x0f00706c,0x00000001}, | ||
771 | {0x0f007070,0x00004000}, | ||
772 | {0x0f007074,0x00000000}, | ||
773 | {0x0f007078,0x00000000}, | ||
774 | {0x0f00707c,0x00000000}, | ||
775 | {0x0f007080,0x00000000}, | ||
776 | {0x0f007084,0x00000000}, | ||
777 | {0x0f007088,0x01000001}, | ||
778 | {0x0f00708c,0x00000101}, | ||
779 | {0x0f007090,0x00000000}, | ||
780 | {0x0f007094,0x00010000}, | ||
781 | {0x0f007098,0x00000000}, | ||
782 | {0x0F0070C8,0x00000104}, | ||
783 | {0x0F007018,0x01010000} | ||
784 | }; | ||
785 | |||
786 | |||
787 | int ddr_init(MINI_ADAPTER *Adapter) | ||
788 | { | ||
789 | PDDR_SETTING psDDRSetting=NULL; | ||
790 | ULONG RegCount=0; | ||
791 | ULONG value = 0; | ||
792 | UINT uiResetValue = 0; | ||
793 | UINT uiClockSetting = 0; | ||
794 | int retval = STATUS_SUCCESS; | ||
795 | |||
796 | switch (Adapter->chip_id) | ||
797 | { | ||
798 | case 0xbece3200: | ||
799 | switch (Adapter->DDRSetting) | ||
800 | { | ||
801 | case DDR_80_MHZ: | ||
802 | psDDRSetting=asT3LP_DDRSetting80MHz; | ||
803 | RegCount=(sizeof(asT3LP_DDRSetting80MHz)/ | ||
804 | sizeof(DDR_SETTING)); | ||
805 | break; | ||
806 | case DDR_100_MHZ: | ||
807 | psDDRSetting=asT3LP_DDRSetting100MHz; | ||
808 | RegCount=(sizeof(asT3LP_DDRSetting100MHz)/ | ||
809 | sizeof(DDR_SETTING)); | ||
810 | break; | ||
811 | case DDR_133_MHZ: | ||
812 | psDDRSetting=asT3LP_DDRSetting133MHz; | ||
813 | RegCount=(sizeof(asT3LP_DDRSetting133MHz)/ | ||
814 | sizeof(DDR_SETTING)); | ||
815 | if(Adapter->bMipsConfig == MIPS_200_MHZ) | ||
816 | { | ||
817 | uiClockSetting = 0x03F13652; | ||
818 | } | ||
819 | else | ||
820 | { | ||
821 | uiClockSetting = 0x03F1365B; | ||
822 | } | ||
823 | break; | ||
824 | default: | ||
825 | return -EINVAL; | ||
826 | } | ||
827 | |||
828 | break; | ||
829 | case T3LPB: | ||
830 | case BCS220_2: | ||
831 | case BCS220_2BC: | ||
832 | case BCS250_BC: | ||
833 | case BCS220_3 : | ||
834 | /* Set bit 2 and bit 6 to 1 for BBIC 2mA drive | ||
835 | * (please check current value and additionally set these bits) | ||
836 | */ | ||
837 | if( (Adapter->chip_id != BCS220_2) && | ||
838 | (Adapter->chip_id != BCS220_2BC) && | ||
839 | (Adapter->chip_id != BCS220_3) ) | ||
840 | { | ||
841 | retval= rdmalt(Adapter,(UINT)0x0f000830, &uiResetValue, sizeof(uiResetValue)); | ||
842 | if(retval < 0) { | ||
843 | BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); | ||
844 | return retval; | ||
845 | } | ||
846 | uiResetValue |= 0x44; | ||
847 | retval = wrmalt(Adapter,(UINT)0x0f000830, &uiResetValue, sizeof(uiResetValue)); | ||
848 | if(retval < 0) { | ||
849 | BCM_DEBUG_PRINT(Adapter,CMHOST, WRM, DBG_LVL_ALL, "%s:%d WRM failed\n", __FUNCTION__, __LINE__); | ||
850 | return retval; | ||
851 | } | ||
852 | } | ||
853 | switch(Adapter->DDRSetting) | ||
854 | { | ||
855 | |||
856 | |||
857 | |||
858 | case DDR_80_MHZ: | ||
859 | psDDRSetting = asT3LPB_DDRSetting80MHz; | ||
860 | RegCount=(sizeof(asT3B_DDRSetting80MHz)/ | ||
861 | sizeof(DDR_SETTING)); | ||
862 | break; | ||
863 | case DDR_100_MHZ: | ||
864 | psDDRSetting=asT3LPB_DDRSetting100MHz; | ||
865 | RegCount=(sizeof(asT3B_DDRSetting100MHz)/ | ||
866 | sizeof(DDR_SETTING)); | ||
867 | break; | ||
868 | case DDR_133_MHZ: | ||
869 | psDDRSetting = asT3LPB_DDRSetting133MHz; | ||
870 | RegCount=(sizeof(asT3B_DDRSetting133MHz)/ | ||
871 | sizeof(DDR_SETTING)); | ||
872 | |||
873 | if(Adapter->bMipsConfig == MIPS_200_MHZ) | ||
874 | { | ||
875 | uiClockSetting = 0x03F13652; | ||
876 | } | ||
877 | else | ||
878 | { | ||
879 | uiClockSetting = 0x03F1365B; | ||
880 | } | ||
881 | break; | ||
882 | |||
883 | case DDR_160_MHZ: | ||
884 | psDDRSetting = asT3LPB_DDRSetting160MHz; | ||
885 | RegCount = sizeof(asT3LPB_DDRSetting160MHz)/sizeof(DDR_SETTING); | ||
886 | |||
887 | if(Adapter->bMipsConfig == MIPS_200_MHZ) | ||
888 | { | ||
889 | uiClockSetting = 0x03F137D2; | ||
890 | } | ||
891 | else | ||
892 | { | ||
893 | uiClockSetting = 0x03F137DB; | ||
894 | } | ||
895 | } | ||
896 | break; | ||
897 | |||
898 | case 0xbece0110: | ||
899 | case 0xbece0120: | ||
900 | case 0xbece0121: | ||
901 | case 0xbece0130: | ||
902 | case 0xbece0300: | ||
903 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "DDR Setting: %x\n", Adapter->DDRSetting); | ||
904 | switch (Adapter->DDRSetting) | ||
905 | { | ||
906 | case DDR_80_MHZ: | ||
907 | psDDRSetting = asT3_DDRSetting80MHz; | ||
908 | RegCount = (sizeof(asT3_DDRSetting80MHz)/ | ||
909 | sizeof(DDR_SETTING)); | ||
910 | break; | ||
911 | case DDR_100_MHZ: | ||
912 | psDDRSetting = asT3_DDRSetting100MHz; | ||
913 | RegCount = (sizeof(asT3_DDRSetting100MHz)/ | ||
914 | sizeof(DDR_SETTING)); | ||
915 | break; | ||
916 | case DDR_133_MHZ: | ||
917 | psDDRSetting = asT3_DDRSetting133MHz; | ||
918 | RegCount = (sizeof(asT3_DDRSetting133MHz)/ | ||
919 | sizeof(DDR_SETTING)); | ||
920 | break; | ||
921 | default: | ||
922 | return -EINVAL; | ||
923 | } | ||
924 | case 0xbece0310: | ||
925 | { | ||
926 | switch (Adapter->DDRSetting) | ||
927 | { | ||
928 | case DDR_80_MHZ: | ||
929 | psDDRSetting = asT3B_DDRSetting80MHz; | ||
930 | RegCount=(sizeof(asT3B_DDRSetting80MHz)/ | ||
931 | sizeof(DDR_SETTING)); | ||
932 | break; | ||
933 | case DDR_100_MHZ: | ||
934 | psDDRSetting=asT3B_DDRSetting100MHz; | ||
935 | RegCount=(sizeof(asT3B_DDRSetting100MHz)/ | ||
936 | sizeof(DDR_SETTING)); | ||
937 | break; | ||
938 | case DDR_133_MHZ: | ||
939 | |||
940 | if(Adapter->bDPLLConfig == PLL_266_MHZ)//266Mhz PLL selected. | ||
941 | { | ||
942 | memcpy(asT3B_DDRSetting133MHz, asDPLL_266MHZ, | ||
943 | sizeof(asDPLL_266MHZ)); | ||
944 | psDDRSetting = asT3B_DDRSetting133MHz; | ||
945 | RegCount=(sizeof(asT3B_DDRSetting133MHz)/ | ||
946 | sizeof(DDR_SETTING)); | ||
947 | } | ||
948 | else | ||
949 | { | ||
950 | psDDRSetting = asT3B_DDRSetting133MHz; | ||
951 | RegCount=(sizeof(asT3B_DDRSetting133MHz)/ | ||
952 | sizeof(DDR_SETTING)); | ||
953 | if(Adapter->bMipsConfig == MIPS_200_MHZ) | ||
954 | { | ||
955 | uiClockSetting = 0x07F13652; | ||
956 | } | ||
957 | else | ||
958 | { | ||
959 | uiClockSetting = 0x07F1365B; | ||
960 | } | ||
961 | } | ||
962 | break; | ||
963 | default: | ||
964 | return -EINVAL; | ||
965 | } | ||
966 | break; | ||
967 | |||
968 | } | ||
969 | default: | ||
970 | return -EINVAL; | ||
971 | } | ||
972 | |||
973 | value=0; | ||
974 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Register Count is =%lu\n", RegCount); | ||
975 | while(RegCount && !retval) | ||
976 | { | ||
977 | if(uiClockSetting && psDDRSetting->ulRegAddress == MIPS_CLOCK_REG) | ||
978 | { | ||
979 | value = uiClockSetting; | ||
980 | } | ||
981 | else | ||
982 | { | ||
983 | value = psDDRSetting->ulRegValue; | ||
984 | } | ||
985 | retval = wrmalt(Adapter, psDDRSetting->ulRegAddress, (PUINT)&value, sizeof(value)); | ||
986 | if(STATUS_SUCCESS != retval) { | ||
987 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"%s:%d\n", __FUNCTION__, __LINE__); | ||
988 | break; | ||
989 | } | ||
990 | |||
991 | RegCount--; | ||
992 | psDDRSetting++; | ||
993 | } | ||
994 | |||
995 | if(Adapter->chip_id >= 0xbece3300 ) | ||
996 | { | ||
997 | |||
998 | mdelay(3); | ||
999 | if( (Adapter->chip_id != BCS220_2)&& | ||
1000 | (Adapter->chip_id != BCS220_2BC)&& | ||
1001 | (Adapter->chip_id != BCS220_3)) | ||
1002 | { | ||
1003 | /* drive MDDR to half in case of UMA-B: */ | ||
1004 | uiResetValue = 0x01010001; | ||
1005 | retval = wrmalt(Adapter, (UINT)0x0F007018, &uiResetValue, sizeof(uiResetValue)); | ||
1006 | if(retval < 0) { | ||
1007 | BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); | ||
1008 | return retval; | ||
1009 | } | ||
1010 | uiResetValue = 0x00040020; | ||
1011 | retval = wrmalt(Adapter, (UINT)0x0F007094, &uiResetValue, sizeof(uiResetValue)); | ||
1012 | if(retval < 0) { | ||
1013 | BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); | ||
1014 | return retval; | ||
1015 | } | ||
1016 | uiResetValue = 0x01020101; | ||
1017 | retval = wrmalt(Adapter, (UINT)0x0F00701c, &uiResetValue, sizeof(uiResetValue)); | ||
1018 | if(retval < 0) { | ||
1019 | BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); | ||
1020 | return retval; | ||
1021 | } | ||
1022 | uiResetValue = 0x01010000; | ||
1023 | retval = wrmalt(Adapter, (UINT)0x0F007018, &uiResetValue, sizeof(uiResetValue)); | ||
1024 | if(retval < 0) { | ||
1025 | BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); | ||
1026 | return retval; | ||
1027 | } | ||
1028 | } | ||
1029 | mdelay(3); | ||
1030 | |||
1031 | /* DC/DC standby change... | ||
1032 | * This is to be done only for Hybrid PMU mode. | ||
1033 | * with the current h/w there is no way to detect this. | ||
1034 | * and since we dont have internal PMU lets do it under UMA-B chip id. | ||
1035 | * we will change this when we will have internal PMU. | ||
1036 | */ | ||
1037 | if(Adapter->PmuMode == HYBRID_MODE_7C) | ||
1038 | { | ||
1039 | retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); | ||
1040 | if(retval < 0) { | ||
1041 | BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); | ||
1042 | return retval; | ||
1043 | } | ||
1044 | retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); | ||
1045 | if(retval < 0) { | ||
1046 | BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); | ||
1047 | return retval; | ||
1048 | } | ||
1049 | uiResetValue = 0x1322a8; | ||
1050 | retval = wrmalt(Adapter, (UINT)0x0f000d1c, &uiResetValue, sizeof(uiResetValue)); | ||
1051 | if(retval < 0) { | ||
1052 | BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); | ||
1053 | return retval; | ||
1054 | } | ||
1055 | retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); | ||
1056 | if(retval < 0) { | ||
1057 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); | ||
1058 | return retval; | ||
1059 | } | ||
1060 | retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); | ||
1061 | if(retval < 0) { | ||
1062 | BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); | ||
1063 | return retval; | ||
1064 | } | ||
1065 | uiResetValue = 0x132296; | ||
1066 | retval = wrmalt(Adapter, (UINT)0x0f000d14, &uiResetValue, sizeof(uiResetValue)); | ||
1067 | if(retval < 0) { | ||
1068 | BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); | ||
1069 | return retval; | ||
1070 | } | ||
1071 | } | ||
1072 | else if(Adapter->PmuMode == HYBRID_MODE_6 ) | ||
1073 | { | ||
1074 | |||
1075 | retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); | ||
1076 | if(retval < 0) { | ||
1077 | BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); | ||
1078 | return retval; | ||
1079 | } | ||
1080 | retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); | ||
1081 | if(retval < 0) { | ||
1082 | BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); | ||
1083 | return retval; | ||
1084 | } | ||
1085 | uiResetValue = 0x6003229a; | ||
1086 | retval = wrmalt(Adapter, (UINT)0x0f000d14, &uiResetValue, sizeof(uiResetValue)); | ||
1087 | if(retval < 0) { | ||
1088 | BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); | ||
1089 | return retval; | ||
1090 | } | ||
1091 | retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); | ||
1092 | if(retval < 0) { | ||
1093 | BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); | ||
1094 | return retval; | ||
1095 | } | ||
1096 | retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); | ||
1097 | if(retval < 0) { | ||
1098 | BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); | ||
1099 | return retval; | ||
1100 | } | ||
1101 | uiResetValue = 0x1322a8; | ||
1102 | retval = wrmalt(Adapter, (UINT)0x0f000d1c, &uiResetValue, sizeof(uiResetValue)); | ||
1103 | if(retval < 0) { | ||
1104 | BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); | ||
1105 | return retval; | ||
1106 | } | ||
1107 | } | ||
1108 | |||
1109 | } | ||
1110 | Adapter->bDDRInitDone = TRUE; | ||
1111 | return retval; | ||
1112 | } | ||
1113 | |||
1114 | int download_ddr_settings(PMINI_ADAPTER Adapter) | ||
1115 | { | ||
1116 | PDDR_SET_NODE psDDRSetting=NULL; | ||
1117 | ULONG RegCount=0; | ||
1118 | unsigned long ul_ddr_setting_load_addr = DDR_DUMP_INTERNAL_DEVICE_MEMORY; | ||
1119 | UINT value = 0; | ||
1120 | int retval = STATUS_SUCCESS; | ||
1121 | BOOLEAN bOverrideSelfRefresh = FALSE; | ||
1122 | |||
1123 | switch (Adapter->chip_id) | ||
1124 | { | ||
1125 | case 0xbece3200: | ||
1126 | switch (Adapter->DDRSetting) | ||
1127 | { | ||
1128 | case DDR_80_MHZ: | ||
1129 | psDDRSetting = asT3LP_DDRSetting80MHz; | ||
1130 | RegCount = (sizeof(asT3LP_DDRSetting80MHz)/sizeof(DDR_SET_NODE)); | ||
1131 | RegCount -= T3LP_SKIP_CLOCK_PROGRAM_DUMP_80MHZ ; | ||
1132 | psDDRSetting += T3LP_SKIP_CLOCK_PROGRAM_DUMP_80MHZ; | ||
1133 | break; | ||
1134 | case DDR_100_MHZ: | ||
1135 | psDDRSetting = asT3LP_DDRSetting100MHz; | ||
1136 | RegCount = (sizeof(asT3LP_DDRSetting100MHz)/sizeof(DDR_SET_NODE)); | ||
1137 | RegCount -= T3LP_SKIP_CLOCK_PROGRAM_DUMP_100MHZ ; | ||
1138 | psDDRSetting += T3LP_SKIP_CLOCK_PROGRAM_DUMP_100MHZ; | ||
1139 | break; | ||
1140 | case DDR_133_MHZ: | ||
1141 | bOverrideSelfRefresh = TRUE; | ||
1142 | psDDRSetting = asT3LP_DDRSetting133MHz; | ||
1143 | RegCount = (sizeof(asT3LP_DDRSetting133MHz)/sizeof(DDR_SET_NODE)); | ||
1144 | RegCount -= T3LP_SKIP_CLOCK_PROGRAM_DUMP_133MHZ ; | ||
1145 | psDDRSetting += T3LP_SKIP_CLOCK_PROGRAM_DUMP_133MHZ; | ||
1146 | break; | ||
1147 | default: | ||
1148 | return -EINVAL; | ||
1149 | } | ||
1150 | break; | ||
1151 | |||
1152 | case T3LPB: | ||
1153 | case BCS220_2: | ||
1154 | case BCS220_2BC: | ||
1155 | case BCS250_BC: | ||
1156 | case BCS220_3 : | ||
1157 | switch (Adapter->DDRSetting) | ||
1158 | { | ||
1159 | case DDR_80_MHZ: | ||
1160 | psDDRSetting = asT3LPB_DDRSetting80MHz; | ||
1161 | RegCount=(sizeof(asT3LPB_DDRSetting80MHz)/sizeof(DDR_SET_NODE)); | ||
1162 | RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_80MHZ ; | ||
1163 | psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_80MHZ; | ||
1164 | break; | ||
1165 | case DDR_100_MHZ: | ||
1166 | psDDRSetting = asT3LPB_DDRSetting100MHz; | ||
1167 | RegCount = (sizeof(asT3LPB_DDRSetting100MHz)/sizeof(DDR_SET_NODE)); | ||
1168 | RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_100MHZ ; | ||
1169 | psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_100MHZ; | ||
1170 | break; | ||
1171 | case DDR_133_MHZ: | ||
1172 | bOverrideSelfRefresh = TRUE; | ||
1173 | psDDRSetting = asT3LPB_DDRSetting133MHz; | ||
1174 | RegCount = (sizeof(asT3LPB_DDRSetting133MHz)/sizeof(DDR_SET_NODE)); | ||
1175 | RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_133MHZ ; | ||
1176 | psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_133MHZ; | ||
1177 | break; | ||
1178 | |||
1179 | case DDR_160_MHZ: | ||
1180 | bOverrideSelfRefresh = TRUE; | ||
1181 | psDDRSetting = asT3LPB_DDRSetting160MHz; | ||
1182 | RegCount = sizeof(asT3LPB_DDRSetting160MHz)/sizeof(DDR_SET_NODE); | ||
1183 | RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_160MHZ; | ||
1184 | psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_160MHZ; | ||
1185 | |||
1186 | break; | ||
1187 | default: | ||
1188 | return -EINVAL; | ||
1189 | } | ||
1190 | break; | ||
1191 | case 0xbece0300: | ||
1192 | switch (Adapter->DDRSetting) | ||
1193 | { | ||
1194 | case DDR_80_MHZ: | ||
1195 | psDDRSetting = asT3_DDRSetting80MHz; | ||
1196 | RegCount = (sizeof(asT3_DDRSetting80MHz)/sizeof(DDR_SET_NODE)); | ||
1197 | RegCount-=T3_SKIP_CLOCK_PROGRAM_DUMP_80MHZ ; | ||
1198 | psDDRSetting += T3_SKIP_CLOCK_PROGRAM_DUMP_80MHZ; | ||
1199 | break; | ||
1200 | case DDR_100_MHZ: | ||
1201 | psDDRSetting = asT3_DDRSetting100MHz; | ||
1202 | RegCount = (sizeof(asT3_DDRSetting100MHz)/sizeof(DDR_SET_NODE)); | ||
1203 | RegCount-=T3_SKIP_CLOCK_PROGRAM_DUMP_100MHZ ; | ||
1204 | psDDRSetting += T3_SKIP_CLOCK_PROGRAM_DUMP_100MHZ; | ||
1205 | break; | ||
1206 | case DDR_133_MHZ: | ||
1207 | psDDRSetting = asT3_DDRSetting133MHz; | ||
1208 | RegCount = (sizeof(asT3_DDRSetting133MHz)/sizeof(DDR_SET_NODE)); | ||
1209 | RegCount-=T3_SKIP_CLOCK_PROGRAM_DUMP_133MHZ ; | ||
1210 | psDDRSetting += T3_SKIP_CLOCK_PROGRAM_DUMP_133MHZ ; | ||
1211 | break; | ||
1212 | default: | ||
1213 | return -EINVAL; | ||
1214 | } | ||
1215 | break; | ||
1216 | case 0xbece0310: | ||
1217 | { | ||
1218 | switch (Adapter->DDRSetting) | ||
1219 | { | ||
1220 | case DDR_80_MHZ: | ||
1221 | psDDRSetting = asT3B_DDRSetting80MHz; | ||
1222 | RegCount = (sizeof(asT3B_DDRSetting80MHz)/sizeof(DDR_SET_NODE)); | ||
1223 | RegCount -= T3B_SKIP_CLOCK_PROGRAM_DUMP_80MHZ ; | ||
1224 | psDDRSetting += T3B_SKIP_CLOCK_PROGRAM_DUMP_80MHZ; | ||
1225 | break; | ||
1226 | case DDR_100_MHZ: | ||
1227 | psDDRSetting = asT3B_DDRSetting100MHz; | ||
1228 | RegCount = (sizeof(asT3B_DDRSetting100MHz)/sizeof(DDR_SET_NODE)); | ||
1229 | RegCount -= T3B_SKIP_CLOCK_PROGRAM_DUMP_100MHZ ; | ||
1230 | psDDRSetting += T3B_SKIP_CLOCK_PROGRAM_DUMP_100MHZ; | ||
1231 | break; | ||
1232 | case DDR_133_MHZ: | ||
1233 | bOverrideSelfRefresh = TRUE; | ||
1234 | psDDRSetting = asT3B_DDRSetting133MHz; | ||
1235 | RegCount = (sizeof(asT3B_DDRSetting133MHz)/sizeof(DDR_SET_NODE)); | ||
1236 | RegCount -= T3B_SKIP_CLOCK_PROGRAM_DUMP_133MHZ ; | ||
1237 | psDDRSetting += T3B_SKIP_CLOCK_PROGRAM_DUMP_133MHZ; | ||
1238 | break; | ||
1239 | } | ||
1240 | break; | ||
1241 | } | ||
1242 | default: | ||
1243 | return -EINVAL; | ||
1244 | } | ||
1245 | //total number of Register that has to be dumped | ||
1246 | value =RegCount ; | ||
1247 | retval = wrmalt(Adapter, ul_ddr_setting_load_addr, &value, sizeof(value)); | ||
1248 | if(retval) | ||
1249 | { | ||
1250 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"%s:%d\n", __FUNCTION__, __LINE__); | ||
1251 | |||
1252 | return retval; | ||
1253 | } | ||
1254 | ul_ddr_setting_load_addr+=sizeof(ULONG); | ||
1255 | /*signature */ | ||
1256 | value =(0x1d1e0dd0); | ||
1257 | retval = wrmalt(Adapter, ul_ddr_setting_load_addr, &value, sizeof(value)); | ||
1258 | if(retval) | ||
1259 | { | ||
1260 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"%s:%d\n", __FUNCTION__, __LINE__); | ||
1261 | return retval; | ||
1262 | } | ||
1263 | |||
1264 | ul_ddr_setting_load_addr+=sizeof(ULONG); | ||
1265 | RegCount*=(sizeof(DDR_SETTING)/sizeof(ULONG)); | ||
1266 | |||
1267 | while(RegCount && !retval) | ||
1268 | { | ||
1269 | value = psDDRSetting->ulRegAddress ; | ||
1270 | retval = wrmalt( Adapter, ul_ddr_setting_load_addr, &value, sizeof(value)); | ||
1271 | ul_ddr_setting_load_addr+=sizeof(ULONG); | ||
1272 | if(!retval) | ||
1273 | { | ||
1274 | if(bOverrideSelfRefresh && (psDDRSetting->ulRegAddress == 0x0F007018)) | ||
1275 | { | ||
1276 | value = (psDDRSetting->ulRegValue |(1<<8)); | ||
1277 | if(STATUS_SUCCESS != wrmalt(Adapter, ul_ddr_setting_load_addr, | ||
1278 | &value, sizeof(value))){ | ||
1279 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"%s:%d\n", __FUNCTION__, __LINE__); | ||
1280 | break; | ||
1281 | } | ||
1282 | } | ||
1283 | else | ||
1284 | { | ||
1285 | value = psDDRSetting->ulRegValue; | ||
1286 | |||
1287 | if(STATUS_SUCCESS != wrmalt(Adapter, ul_ddr_setting_load_addr , | ||
1288 | &value, sizeof(value))){ | ||
1289 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"%s:%d\n", __FUNCTION__, __LINE__); | ||
1290 | break; | ||
1291 | } | ||
1292 | } | ||
1293 | } | ||
1294 | ul_ddr_setting_load_addr+=sizeof(ULONG); | ||
1295 | RegCount--; | ||
1296 | psDDRSetting++; | ||
1297 | } | ||
1298 | return retval; | ||
1299 | } | ||
1300 | |||
1301 | #endif | ||
1302 | |||
diff --git a/drivers/staging/bcm/DDRInit.h b/drivers/staging/bcm/DDRInit.h new file mode 100644 index 00000000000..550e260df53 --- /dev/null +++ b/drivers/staging/bcm/DDRInit.h | |||
@@ -0,0 +1,9 @@ | |||
1 | #ifndef _DDR_INIT_H_ | ||
2 | #define _DDR_INIT_H_ | ||
3 | |||
4 | |||
5 | |||
6 | int ddr_init(PMINI_ADAPTER psAdapter); | ||
7 | int download_ddr_settings(PMINI_ADAPTER psAdapter); | ||
8 | |||
9 | #endif | ||
diff --git a/drivers/staging/bcm/Debug.c b/drivers/staging/bcm/Debug.c new file mode 100644 index 00000000000..213f4bcc5df --- /dev/null +++ b/drivers/staging/bcm/Debug.c | |||
@@ -0,0 +1,40 @@ | |||
1 | #include "headers.h" | ||
2 | |||
3 | char *buff_dump_base[]={"DEC", "HEX", "OCT", "BIN" }; | ||
4 | |||
5 | static UINT current_debug_level=BCM_SCREAM; | ||
6 | |||
7 | int bcm_print_buffer( UINT debug_level, const char *function_name, | ||
8 | char *file_name, int line_number, unsigned char *buffer, int bufferlen, unsigned int base) | ||
9 | { | ||
10 | if(debug_level>=current_debug_level) | ||
11 | { | ||
12 | int i=0; | ||
13 | printk("\n%s:%s:%d:Buffer dump of size 0x%x in the %s:\n", file_name, function_name, line_number, bufferlen, buff_dump_base[1]); | ||
14 | for(;i<bufferlen;i++) | ||
15 | { | ||
16 | if(i && !(i%16) ) | ||
17 | printk("\n"); | ||
18 | switch(base) | ||
19 | { | ||
20 | case BCM_BASE_TYPE_DEC: | ||
21 | printk("%03d ", buffer[i]); | ||
22 | break; | ||
23 | case BCM_BASE_TYPE_OCT: | ||
24 | printk("%0x03o ", buffer[i]); | ||
25 | break; | ||
26 | case BCM_BASE_TYPE_BIN: | ||
27 | printk("%02x ", buffer[i]); | ||
28 | break; | ||
29 | case BCM_BASE_TYPE_HEX: | ||
30 | default: | ||
31 | printk("%02X ", buffer[i]); | ||
32 | break; | ||
33 | } | ||
34 | } | ||
35 | printk("\n"); | ||
36 | } | ||
37 | return 0; | ||
38 | } | ||
39 | |||
40 | |||
diff --git a/drivers/staging/bcm/Debug.h b/drivers/staging/bcm/Debug.h new file mode 100644 index 00000000000..3d788b59ab5 --- /dev/null +++ b/drivers/staging/bcm/Debug.h | |||
@@ -0,0 +1,297 @@ | |||
1 | /* | ||
2 | * Debug.h | ||
3 | * | ||
4 | * Dynamic (runtime) debug framework implementation. | ||
5 | * -kaiwan. | ||
6 | */ | ||
7 | #ifndef _DEBUG_H | ||
8 | #define _DEBUG_H | ||
9 | #include <linux/string.h> | ||
10 | #define NONE 0xFFFF | ||
11 | |||
12 | typedef enum _BASE_TYPE | ||
13 | { | ||
14 | BCM_BASE_TYPE_DEC, | ||
15 | BCM_BASE_TYPE_OCT, | ||
16 | BCM_BASE_TYPE_BIN, | ||
17 | BCM_BASE_TYPE_HEX, | ||
18 | BCM_BASE_TYPE_NONE, | ||
19 | } BASE_TYPE, *PBASE_TYPE; | ||
20 | |||
21 | int bcm_print_buffer( UINT debug_level, const char *function_name, | ||
22 | char *file_name, int line_number, unsigned char *buffer, int bufferlen, BASE_TYPE base); | ||
23 | |||
24 | #ifdef BCM_SHM_INTERFACE | ||
25 | #define CPE_VIRTUAL_ERROR_CODE_BASE_ADDR (0xBFC02E00 + 0x4C) | ||
26 | // ERROR codes for debugging | ||
27 | extern unsigned char u32ErrorCounter ; | ||
28 | #define ERROR_DEVICE_REMOVED 0x1 | ||
29 | #define ERROR_LEADER_LENGTH_ZERO 0x2 | ||
30 | #define ERROR_LEADER_LENGTH_CORRUPTED 0x3 | ||
31 | #define ERROR_NO_SKBUFF 0x4 | ||
32 | |||
33 | #define ERROR_DL_MODULE 0xaa000000 | ||
34 | extern void CPE_ERROR_LOG(unsigned int module,unsigned int code); | ||
35 | |||
36 | #endif | ||
37 | |||
38 | |||
39 | |||
40 | |||
41 | //-------------------------------------------------------------------------------- | ||
42 | |||
43 | /* TYPE and SUBTYPE | ||
44 | * Define valid TYPE (or category or code-path, however you like to think of it) | ||
45 | * and SUBTYPE s. | ||
46 | * Type and SubType are treated as bitmasks. | ||
47 | */ | ||
48 | /*-----------------BEGIN TYPEs------------------------------------------*/ | ||
49 | #define DBG_TYPE_INITEXIT (1 << 0) // 1 | ||
50 | #define DBG_TYPE_TX (1 << 1) // 2 | ||
51 | #define DBG_TYPE_RX (1 << 2) // 4 | ||
52 | #define DBG_TYPE_OTHERS (1 << 3) // 8 | ||
53 | /*-----------------END TYPEs------------------------------------------*/ | ||
54 | #define NUMTYPES 4 // careful! | ||
55 | |||
56 | /*-----------------BEGIN SUBTYPEs---------------------------------------*/ | ||
57 | |||
58 | /*-SUBTYPEs for TX : TYPE is DBG_TYPE_TX -----// | ||
59 | Transmit.c ,Arp.c, LeakyBucket.c, And Qos.c | ||
60 | total 17 macros */ | ||
61 | // Transmit.c | ||
62 | #define TX 1 | ||
63 | #define MP_SEND (TX<<0) | ||
64 | #define NEXT_SEND (TX<<1) | ||
65 | #define TX_FIFO (TX<<2) | ||
66 | #define TX_CONTROL (TX<<3) | ||
67 | |||
68 | // Arp.c | ||
69 | #define IP_ADDR (TX<<4) | ||
70 | #define ARP_REQ (TX<<5) | ||
71 | #define ARP_RESP (TX<<6) | ||
72 | |||
73 | // dhcp.c | ||
74 | //#define DHCP TX | ||
75 | //#define DHCP_REQ (DHCP<<7) | ||
76 | |||
77 | // Leakybucket.c | ||
78 | #define TOKEN_COUNTS (TX<<8) | ||
79 | #define CHECK_TOKENS (TX<<9) | ||
80 | #define TX_PACKETS (TX<<10) | ||
81 | #define TIMER (TX<<11) | ||
82 | |||
83 | // Qos.c | ||
84 | #define QOS TX | ||
85 | #define QUEUE_INDEX (QOS<<12) | ||
86 | #define IPV4_DBG (QOS<<13) | ||
87 | #define IPV6_DBG (QOS<<14) | ||
88 | #define PRUNE_QUEUE (QOS<<15) | ||
89 | #define SEND_QUEUE (QOS<<16) | ||
90 | |||
91 | //TX_Misc | ||
92 | #define TX_OSAL_DBG (TX<<17) | ||
93 | |||
94 | |||
95 | //--SUBTYPEs for ------INIT & EXIT--------------------- | ||
96 | /*------------ TYPE is DBG_TYPE_INITEXIT -----// | ||
97 | DriverEntry.c, bcmfwup.c, ChipDetectTask.c, HaltnReset.c, InterfaceDDR.c */ | ||
98 | #define MP 1 | ||
99 | #define DRV_ENTRY (MP<<0) | ||
100 | #define MP_INIT (MP<<1) | ||
101 | #define READ_REG (MP<<3) | ||
102 | #define DISPATCH (MP<<2) | ||
103 | #define CLAIM_ADAP (MP<<4) | ||
104 | #define REG_IO_PORT (MP<<5) | ||
105 | #define INIT_DISP (MP<<6) | ||
106 | #define RX_INIT (MP<<7) | ||
107 | |||
108 | |||
109 | //-SUBTYPEs for --RX---------------------------------- | ||
110 | //------------RX : TYPE is DBG_TYPE_RX -----// | ||
111 | // Receive.c | ||
112 | #define RX 1 | ||
113 | #define RX_DPC (RX<<0) | ||
114 | #define RX_CTRL (RX<<3) | ||
115 | #define RX_DATA (RX<<4) | ||
116 | #define MP_RETURN (RX<<1) | ||
117 | #define LINK_MSG (RX<<2) | ||
118 | |||
119 | |||
120 | //-SUBTYPEs for ----OTHER ROUTINES------------------ | ||
121 | //------------OTHERS : TYPE is DBG_TYPE_OTHER -----// | ||
122 | // HaltnReset,CheckForHang,PnP,Misc,CmHost | ||
123 | // total 12 macros | ||
124 | #define OTHERS 1 | ||
125 | // ??ISR.C | ||
126 | |||
127 | #define ISR OTHERS | ||
128 | #define MP_DPC (ISR<<0) | ||
129 | |||
130 | // HaltnReset.c | ||
131 | #define HALT OTHERS | ||
132 | #define MP_HALT (HALT<<1) | ||
133 | #define CHECK_HANG (HALT<<2) | ||
134 | #define MP_RESET (HALT<<3) | ||
135 | #define MP_SHUTDOWN (HALT<<4) | ||
136 | |||
137 | // pnp.c | ||
138 | #define PNP OTHERS | ||
139 | #define MP_PNP (PNP<<5) | ||
140 | |||
141 | // Misc.c | ||
142 | #define MISC OTHERS | ||
143 | #define DUMP_INFO (MISC<<6) | ||
144 | #define CLASSIFY (MISC<<7) | ||
145 | #define LINK_UP_MSG (MISC<<8) | ||
146 | #define CP_CTRL_PKT (MISC<<9) | ||
147 | #define DUMP_CONTROL (MISC<<10) | ||
148 | #define LED_DUMP_INFO (MISC<<11) | ||
149 | |||
150 | // CmHost.c | ||
151 | #define CMHOST OTHERS | ||
152 | |||
153 | |||
154 | #define SERIAL (OTHERS<<12) | ||
155 | #define IDLE_MODE (OTHERS<<13) | ||
156 | |||
157 | #define WRM (OTHERS<<14) | ||
158 | #define RDM (OTHERS<<15) | ||
159 | |||
160 | // TODO - put PHS_SEND in Tx PHS_RECEIVE in Rx path ? | ||
161 | #define PHS_SEND (OTHERS<<16) | ||
162 | #define PHS_RECIEVE (OTHERS<<17) | ||
163 | #define PHS_MODULE (OTHERS<<18) | ||
164 | |||
165 | #define INTF_INIT (OTHERS<<19) | ||
166 | #define INTF_ERR (OTHERS<<20) | ||
167 | #define INTF_WARN (OTHERS<<21) | ||
168 | #define INTF_NORM (OTHERS<<22) | ||
169 | |||
170 | #define IRP_COMPLETION (OTHERS<<23) | ||
171 | #define SF_DESCRIPTOR_CNTS (OTHERS<<24) | ||
172 | #define PHS_DISPATCH (OTHERS << 25) | ||
173 | #define OSAL_DBG (OTHERS << 26) | ||
174 | #define NVM_RW (OTHERS << 27) | ||
175 | |||
176 | #define HOST_MIBS (OTHERS << 28) | ||
177 | #define CONN_MSG (CMHOST << 29) | ||
178 | //#define OTHERS_MISC (OTHERS << 29) // ProcSupport.c | ||
179 | /*-----------------END SUBTYPEs------------------------------------------*/ | ||
180 | |||
181 | |||
182 | /* Debug level | ||
183 | * We have 8 debug levels, in (numerical) increasing order of verbosity. | ||
184 | * IMP: Currently implementing ONLY DBG_LVL_ALL , i.e. , all debug prints will | ||
185 | * appear (of course, iff global debug flag is ON and we match the Type and SubType). | ||
186 | * Finer granularity debug levels are currently not in use, although the feature exists. | ||
187 | * | ||
188 | * Another way to say this: | ||
189 | * All the debug prints currently have 'debug_level' set to DBG_LVL_ALL . | ||
190 | * You can compile-time change that to any of the below, if you wish to. However, as of now, there's | ||
191 | * no dynamic facility to have the userspace 'TestApp' set debug_level. Slated for future expansion. | ||
192 | */ | ||
193 | #define BCM_ALL 7 | ||
194 | #define BCM_LOW 6 | ||
195 | #define BCM_PRINT 5 | ||
196 | #define BCM_NORMAL 4 | ||
197 | #define BCM_MEDIUM 3 | ||
198 | #define BCM_SCREAM 2 | ||
199 | #define BCM_ERR 1 | ||
200 | /* Not meant for developer in debug prints. | ||
201 | * To be used to disable all prints by setting the DBG_LVL_CURR to this value */ | ||
202 | #define BCM_NONE 0 | ||
203 | |||
204 | /* The current driver logging level. | ||
205 | * Everything at this level and (numerically) lower (meaning higher prio) | ||
206 | * is logged. | ||
207 | * Replace 'BCM_ALL' in the DBG_LVL_CURR macro with the logging level desired. | ||
208 | * For eg. to set the logging level to 'errors only' use: | ||
209 | * #define DBG_LVL_CURR (BCM_ERR) | ||
210 | */ | ||
211 | |||
212 | #define DBG_LVL_CURR (BCM_ALL) | ||
213 | #define DBG_LVL_ALL BCM_ALL | ||
214 | |||
215 | /*---Userspace mapping of Debug State. | ||
216 | * Delibrately matches that of the Windows driver.. | ||
217 | * The TestApp's ioctl passes this struct to us. | ||
218 | */ | ||
219 | typedef struct | ||
220 | { | ||
221 | unsigned int Subtype, Type; | ||
222 | unsigned int OnOff; | ||
223 | // unsigned int debug_level; /* future expansion */ | ||
224 | } __attribute__((packed)) USER_BCM_DBG_STATE; | ||
225 | |||
226 | //---Kernel-space mapping of Debug State | ||
227 | typedef struct _S_BCM_DEBUG_STATE { | ||
228 | UINT type; | ||
229 | /* A bitmap of 32 bits for Subtype per Type. | ||
230 | * Valid indexes in 'subtype' array are *only* 1,2,4 and 8, | ||
231 | * corresponding to valid Type values. Hence we use the 'Type' field | ||
232 | * as the index value, ignoring the array entries 0,3,5,6,7 ! | ||
233 | */ | ||
234 | UINT subtype[(NUMTYPES*2)+1]; | ||
235 | UINT debug_level; | ||
236 | } S_BCM_DEBUG_STATE; | ||
237 | /* Instantiated in the Adapter structure */ | ||
238 | /* We'll reuse the debug level parameter to include a bit (the MSB) to indicate whether or not | ||
239 | * we want the function's name printed. */ | ||
240 | #define DBG_NO_FUNC_PRINT 1 << 31 | ||
241 | #define DBG_LVL_BITMASK 0xFF | ||
242 | |||
243 | //--- Only for direct printk's; "hidden" to API. | ||
244 | #define DBG_TYPE_PRINTK 3 | ||
245 | #define PRINTKS_ON 1 // "hidden" from API, set to 0 to turn off all printk's | ||
246 | |||
247 | #define BCM_DEBUG_PRINT(Adapter, Type, SubType, dbg_level, string, args...) do { \ | ||
248 | if ((DBG_TYPE_PRINTK == Type) && (PRINTKS_ON)) { \ | ||
249 | printk ("%s:" string, __FUNCTION__, ##args); \ | ||
250 | printk("\n"); \ | ||
251 | } else if (!Adapter) \ | ||
252 | ; \ | ||
253 | else { \ | ||
254 | if (((dbg_level & DBG_LVL_BITMASK) <= Adapter->stDebugState.debug_level) && \ | ||
255 | ((Type & Adapter->stDebugState.type) && (SubType & Adapter->stDebugState.subtype[Type]))) { \ | ||
256 | if (dbg_level & DBG_NO_FUNC_PRINT) \ | ||
257 | printk (string, ##args); \ | ||
258 | else \ | ||
259 | { \ | ||
260 | printk ("%s:" string, __FUNCTION__, ##args); \ | ||
261 | printk("\n"); \ | ||
262 | } \ | ||
263 | } \ | ||
264 | } \ | ||
265 | } while (0) | ||
266 | |||
267 | #define BCM_DEBUG_PRINT_BUFFER(Adapter, Type, SubType, dbg_level, buffer, bufferlen) do { \ | ||
268 | if ((DBG_TYPE_PRINTK == Type) && (PRINTKS_ON)) { \ | ||
269 | bcm_print_buffer( dbg_level, __FUNCTION__, __FILE__, __LINE__, buffer, bufferlen, BCM_BASE_TYPE_HEX); \ | ||
270 | } else if (!Adapter) \ | ||
271 | ; \ | ||
272 | else { \ | ||
273 | if (((dbg_level & DBG_LVL_BITMASK) <= Adapter->stDebugState.debug_level) && \ | ||
274 | ((Type & Adapter->stDebugState.type) && (SubType & Adapter->stDebugState.subtype[Type]))) { \ | ||
275 | if (dbg_level & DBG_NO_FUNC_PRINT) \ | ||
276 | bcm_print_buffer( dbg_level, NULL, NULL, __LINE__, buffer, bufferlen, BCM_BASE_TYPE_HEX); \ | ||
277 | else \ | ||
278 | bcm_print_buffer( dbg_level, __FUNCTION__, __FILE__, __LINE__, buffer, bufferlen, BCM_BASE_TYPE_HEX); \ | ||
279 | } \ | ||
280 | } \ | ||
281 | } while (0) | ||
282 | |||
283 | |||
284 | #define BCM_SHOW_DEBUG_BITMAP(Adapter) do { \ | ||
285 | int i; \ | ||
286 | for (i=0; i<(NUMTYPES*2)+1; i++) { \ | ||
287 | if ((i == 1) || (i == 2) || (i == 4) || (i == 8)) { \ | ||
288 | /* CAUTION! Forcefully turn on ALL debug paths and subpaths! \ | ||
289 | Adapter->stDebugState.subtype[i] = 0xffffffff; */ \ | ||
290 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "subtype[%d] = 0x%08x\n", \ | ||
291 | i, Adapter->stDebugState.subtype[i]); \ | ||
292 | } \ | ||
293 | } \ | ||
294 | } while (0) | ||
295 | |||
296 | #endif | ||
297 | |||
diff --git a/drivers/staging/bcm/HandleControlPacket.c b/drivers/staging/bcm/HandleControlPacket.c new file mode 100644 index 00000000000..849951345ab --- /dev/null +++ b/drivers/staging/bcm/HandleControlPacket.c | |||
@@ -0,0 +1,247 @@ | |||
1 | /** | ||
2 | @file HandleControlPacket.c | ||
3 | This file contains the routines to deal with | ||
4 | sending and receiving of control packets. | ||
5 | */ | ||
6 | #include "headers.h" | ||
7 | |||
8 | /** | ||
9 | When a control packet is received, analyze the | ||
10 | "status" and call appropriate response function. | ||
11 | Enqueue the control packet for Application. | ||
12 | @return None | ||
13 | */ | ||
14 | VOID handle_rx_control_packet(PMINI_ADAPTER Adapter, /**<Pointer to the Adapter structure*/ | ||
15 | struct sk_buff *skb) /**<Pointer to the socket buffer*/ | ||
16 | { | ||
17 | PPER_TARANG_DATA pTarang = NULL; | ||
18 | BOOLEAN HighPriorityMessage = FALSE; | ||
19 | struct sk_buff * newPacket = NULL; | ||
20 | CHAR cntrl_msg_mask_bit = 0; | ||
21 | BOOLEAN drop_pkt_flag = TRUE ; | ||
22 | USHORT usStatus = *(PUSHORT)(skb->data); | ||
23 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL, "=====>"); | ||
24 | /* Get the Leader field */ | ||
25 | |||
26 | switch(usStatus) | ||
27 | { | ||
28 | case CM_RESPONSES: // 0xA0 | ||
29 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL, "MAC Version Seems to be Non Multi-Classifier, rejected by Driver"); | ||
30 | HighPriorityMessage = TRUE ; | ||
31 | break; | ||
32 | case CM_CONTROL_NEWDSX_MULTICLASSIFIER_RESP: | ||
33 | HighPriorityMessage = TRUE ; | ||
34 | if(Adapter->LinkStatus==LINKUP_DONE) | ||
35 | { | ||
36 | CmControlResponseMessage(Adapter,(skb->data +sizeof(USHORT))); | ||
37 | } | ||
38 | break; | ||
39 | case LINK_CONTROL_RESP: //0xA2 | ||
40 | case STATUS_RSP: //0xA1 | ||
41 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL,"LINK_CONTROL_RESP"); | ||
42 | HighPriorityMessage = TRUE ; | ||
43 | LinkControlResponseMessage(Adapter,(skb->data + sizeof(USHORT))); | ||
44 | break; | ||
45 | case STATS_POINTER_RESP: //0xA6 | ||
46 | HighPriorityMessage = TRUE ; | ||
47 | StatisticsResponse(Adapter, (skb->data + sizeof(USHORT))); | ||
48 | break; | ||
49 | case IDLE_MODE_STATUS: //0xA3 | ||
50 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL,"IDLE_MODE_STATUS Type Message Got from F/W"); | ||
51 | InterfaceIdleModeRespond(Adapter, (PUINT)(skb->data + | ||
52 | sizeof(USHORT))); | ||
53 | HighPriorityMessage = TRUE ; | ||
54 | break; | ||
55 | |||
56 | case AUTH_SS_HOST_MSG: | ||
57 | HighPriorityMessage = TRUE ; | ||
58 | break; | ||
59 | |||
60 | default: | ||
61 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL,"Got Default Response"); | ||
62 | /* Let the Application Deal with This Packet */ | ||
63 | break; | ||
64 | } | ||
65 | |||
66 | //Queue The Control Packet to The Application Queues | ||
67 | down(&Adapter->RxAppControlQueuelock); | ||
68 | |||
69 | for (pTarang = Adapter->pTarangs; pTarang; pTarang = pTarang->next) | ||
70 | { | ||
71 | if(Adapter->device_removed) | ||
72 | { | ||
73 | break; | ||
74 | } | ||
75 | |||
76 | drop_pkt_flag = TRUE ; | ||
77 | /* | ||
78 | There are cntrl msg from A0 to AC. It has been mapped to 0 to C bit in the cntrl mask. | ||
79 | Also, by default AD to BF has been masked to the rest of the bits... which wil be ON by default. | ||
80 | if mask bit is enable to particular pkt status, send it out to app else stop it. | ||
81 | */ | ||
82 | cntrl_msg_mask_bit = (usStatus & 0x1F); | ||
83 | //printk("\ninew msg mask bit which is disable in mask:%X", cntrl_msg_mask_bit); | ||
84 | if(pTarang->RxCntrlMsgBitMask & (1<<cntrl_msg_mask_bit)) | ||
85 | drop_pkt_flag = FALSE; | ||
86 | |||
87 | if ((drop_pkt_flag == TRUE) || (pTarang->AppCtrlQueueLen > MAX_APP_QUEUE_LEN) || | ||
88 | ((pTarang->AppCtrlQueueLen > MAX_APP_QUEUE_LEN/2) && (HighPriorityMessage == FALSE))) | ||
89 | { | ||
90 | /* | ||
91 | Assumption:- | ||
92 | 1. every tarang manages it own dropped pkt statitistics | ||
93 | 2. Total packet dropped per tarang will be equal to the sum of all types of dropped | ||
94 | pkt by that tarang only. | ||
95 | |||
96 | */ | ||
97 | switch(*(PUSHORT)skb->data) | ||
98 | { | ||
99 | case CM_RESPONSES: | ||
100 | pTarang->stDroppedAppCntrlMsgs.cm_responses++; | ||
101 | break; | ||
102 | case CM_CONTROL_NEWDSX_MULTICLASSIFIER_RESP: | ||
103 | pTarang->stDroppedAppCntrlMsgs.cm_control_newdsx_multiclassifier_resp++; | ||
104 | break; | ||
105 | case LINK_CONTROL_RESP: | ||
106 | pTarang->stDroppedAppCntrlMsgs.link_control_resp++; | ||
107 | break; | ||
108 | case STATUS_RSP: | ||
109 | pTarang->stDroppedAppCntrlMsgs.status_rsp++; | ||
110 | break; | ||
111 | case STATS_POINTER_RESP: | ||
112 | pTarang->stDroppedAppCntrlMsgs.stats_pointer_resp++; | ||
113 | break; | ||
114 | case IDLE_MODE_STATUS: | ||
115 | pTarang->stDroppedAppCntrlMsgs.idle_mode_status++ ; | ||
116 | break; | ||
117 | case AUTH_SS_HOST_MSG: | ||
118 | pTarang->stDroppedAppCntrlMsgs.auth_ss_host_msg++ ; | ||
119 | break; | ||
120 | default: | ||
121 | pTarang->stDroppedAppCntrlMsgs.low_priority_message++ ; | ||
122 | break; | ||
123 | } | ||
124 | |||
125 | continue; | ||
126 | } | ||
127 | |||
128 | newPacket = skb_clone(skb, GFP_KERNEL); | ||
129 | if (!newPacket) | ||
130 | break; | ||
131 | ENQUEUEPACKET(pTarang->RxAppControlHead,pTarang->RxAppControlTail, | ||
132 | newPacket); | ||
133 | pTarang->AppCtrlQueueLen++; | ||
134 | } | ||
135 | up(&Adapter->RxAppControlQueuelock); | ||
136 | wake_up(&Adapter->process_read_wait_queue); | ||
137 | bcm_kfree_skb(skb); | ||
138 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL, "After wake_up_interruptible"); | ||
139 | } | ||
140 | |||
141 | /** | ||
142 | @ingroup ctrl_pkt_functions | ||
143 | Thread to handle control pkt reception | ||
144 | */ | ||
145 | int control_packet_handler (PMINI_ADAPTER Adapter /**< pointer to adapter object*/ | ||
146 | ) | ||
147 | { | ||
148 | struct sk_buff *ctrl_packet= NULL; | ||
149 | unsigned long flags = 0; | ||
150 | //struct timeval tv ; | ||
151 | //int *puiBuffer = NULL ; | ||
152 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL, "Entering to make thread wait on control packet event!"); | ||
153 | while(1) | ||
154 | { | ||
155 | wait_event_interruptible(Adapter->process_rx_cntrlpkt, | ||
156 | atomic_read(&Adapter->cntrlpktCnt) || | ||
157 | Adapter->bWakeUpDevice || | ||
158 | kthread_should_stop() | ||
159 | ); | ||
160 | |||
161 | |||
162 | if(kthread_should_stop()) | ||
163 | { | ||
164 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL, "Exiting \n"); | ||
165 | return 0; | ||
166 | } | ||
167 | if(TRUE == Adapter->bWakeUpDevice) | ||
168 | { | ||
169 | Adapter->bWakeUpDevice = FALSE; | ||
170 | if((FALSE == Adapter->bTriedToWakeUpFromlowPowerMode) && | ||
171 | ((TRUE == Adapter->IdleMode)|| (TRUE == Adapter->bShutStatus))) | ||
172 | { | ||
173 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL, "Calling InterfaceAbortIdlemode\n"); | ||
174 | // Adapter->bTriedToWakeUpFromlowPowerMode = TRUE; | ||
175 | InterfaceIdleModeWakeup (Adapter); | ||
176 | } | ||
177 | continue; | ||
178 | } | ||
179 | |||
180 | while(atomic_read(&Adapter->cntrlpktCnt)) | ||
181 | { | ||
182 | spin_lock_irqsave(&Adapter->control_queue_lock, flags); | ||
183 | ctrl_packet = Adapter->RxControlHead; | ||
184 | if(ctrl_packet) | ||
185 | { | ||
186 | DEQUEUEPACKET(Adapter->RxControlHead,Adapter->RxControlTail); | ||
187 | // Adapter->RxControlHead=ctrl_packet->next; | ||
188 | ((PLINUX_DEP_DATA)Adapter->pvOsDepData)->netstats.rx_packets++; | ||
189 | ((PLINUX_DEP_DATA)Adapter->pvOsDepData)->netstats.rx_bytes+= | ||
190 | ((PLEADER)ctrl_packet->data)->PLength; | ||
191 | } | ||
192 | #if 0 //Idle mode debug profiling... | ||
193 | if(*(PUSHORT)ctrl_packet->data == IDLE_MODE_STATUS) | ||
194 | { | ||
195 | puiBuffer = (PUINT)(ctrl_packet->data +sizeof(USHORT)); | ||
196 | if((ntohl(*puiBuffer) == GO_TO_IDLE_MODE_PAYLOAD)) | ||
197 | { | ||
198 | memset(&tv, 0, sizeof(tv)); | ||
199 | do_gettimeofday(&tv); | ||
200 | if((ntohl(*(puiBuffer+1)) == 0)) | ||
201 | { | ||
202 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL, "IdleMode Wake-up Msg from f/w at time :%ld ms", tv.tv_sec *1000 + tv.tv_usec /1000); | ||
203 | } | ||
204 | else | ||
205 | { | ||
206 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL, "IdleMode req Msg from f/w at time :%ld ms", tv.tv_sec *1000 + tv.tv_usec /1000); | ||
207 | } | ||
208 | } | ||
209 | else if((ntohl(*puiBuffer) == IDLE_MODE_SF_UPDATE_MSG)) | ||
210 | { | ||
211 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL, "GOT IDLE_MODE_SF_UPDATE MSG at time :%ld ms", tv.tv_sec *1000 + tv.tv_usec /1000); | ||
212 | } | ||
213 | } | ||
214 | #endif | ||
215 | |||
216 | spin_unlock_irqrestore (&Adapter->control_queue_lock, flags); | ||
217 | handle_rx_control_packet(Adapter, ctrl_packet); | ||
218 | atomic_dec(&Adapter->cntrlpktCnt); | ||
219 | } | ||
220 | |||
221 | SetUpTargetDsxBuffers(Adapter); | ||
222 | } | ||
223 | return STATUS_SUCCESS; | ||
224 | } | ||
225 | |||
226 | INT flushAllAppQ() | ||
227 | { | ||
228 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
229 | PPER_TARANG_DATA pTarang = NULL; | ||
230 | struct sk_buff *PacketToDrop = NULL; | ||
231 | for(pTarang = Adapter->pTarangs; pTarang; pTarang = pTarang->next) | ||
232 | { | ||
233 | while(pTarang->RxAppControlHead != NULL) | ||
234 | { | ||
235 | PacketToDrop=pTarang->RxAppControlHead; | ||
236 | DEQUEUEPACKET(pTarang->RxAppControlHead,pTarang->RxAppControlTail); | ||
237 | bcm_kfree_skb(PacketToDrop); | ||
238 | } | ||
239 | pTarang->AppCtrlQueueLen = 0; | ||
240 | //dropped contrl packet statistics also should be reset. | ||
241 | memset((PVOID)&pTarang->stDroppedAppCntrlMsgs, 0, sizeof(S_MIBS_DROPPED_APP_CNTRL_MESSAGES)); | ||
242 | |||
243 | } | ||
244 | return STATUS_SUCCESS ; | ||
245 | } | ||
246 | |||
247 | |||
diff --git a/drivers/staging/bcm/HostMIBSInterface.h b/drivers/staging/bcm/HostMIBSInterface.h new file mode 100644 index 00000000000..f17a4f13474 --- /dev/null +++ b/drivers/staging/bcm/HostMIBSInterface.h | |||
@@ -0,0 +1,230 @@ | |||
1 | |||
2 | |||
3 | #ifndef _HOST_MIBSINTERFACE_H | ||
4 | #define _HOST_MIBSINTERFACE_H | ||
5 | |||
6 | /* | ||
7 | * Copyright (c) 2007 Beceem Communications Pvt. Ltd | ||
8 | * File Name: HostMIBSInterface.h | ||
9 | * Abstract: This file contains DS used by the Host to update the Host | ||
10 | * statistics used for the MIBS. | ||
11 | */ | ||
12 | |||
13 | #define MIBS_MAX_CLASSIFIERS 100 | ||
14 | #define MIBS_MAX_PHSRULES 100 | ||
15 | #define MIBS_MAX_SERVICEFLOWS 17 | ||
16 | #define MIBS_MAX_IP_RANGE_LENGTH 4 | ||
17 | #define MIBS_MAX_PORT_RANGE 4 | ||
18 | #define MIBS_MAX_PROTOCOL_LENGTH 32 | ||
19 | #define MIBS_MAX_PHS_LENGTHS 255 | ||
20 | #define MIBS_IPV6_ADDRESS_SIZEINBYTES 0x10 | ||
21 | #define MIBS_IP_LENGTH_OF_ADDRESS 4 | ||
22 | #define MIBS_MAX_HIST_ENTRIES 12 | ||
23 | #define MIBS_PKTSIZEHIST_RANGE 128 | ||
24 | |||
25 | typedef union _U_MIBS_IP_ADDRESS | ||
26 | { | ||
27 | struct | ||
28 | { | ||
29 | //Source Ip Address Range | ||
30 | ULONG ulIpv4Addr[MIBS_MAX_IP_RANGE_LENGTH]; | ||
31 | //Source Ip Mask Address Range | ||
32 | ULONG ulIpv4Mask[MIBS_MAX_IP_RANGE_LENGTH]; | ||
33 | }; | ||
34 | struct | ||
35 | { | ||
36 | //Source Ip Address Range | ||
37 | ULONG ulIpv6Addr[MIBS_MAX_IP_RANGE_LENGTH * 4]; | ||
38 | //Source Ip Mask Address Range | ||
39 | ULONG ulIpv6Mask[MIBS_MAX_IP_RANGE_LENGTH * 4]; | ||
40 | |||
41 | }; | ||
42 | struct | ||
43 | { | ||
44 | UCHAR ucIpv4Address[MIBS_MAX_IP_RANGE_LENGTH * | ||
45 | MIBS_IP_LENGTH_OF_ADDRESS]; | ||
46 | UCHAR ucIpv4Mask[MIBS_MAX_IP_RANGE_LENGTH * | ||
47 | MIBS_IP_LENGTH_OF_ADDRESS]; | ||
48 | }; | ||
49 | struct | ||
50 | { | ||
51 | UCHAR ucIpv6Address[MIBS_MAX_IP_RANGE_LENGTH * MIBS_IPV6_ADDRESS_SIZEINBYTES]; | ||
52 | UCHAR ucIpv6Mask[MIBS_MAX_IP_RANGE_LENGTH * MIBS_IPV6_ADDRESS_SIZEINBYTES]; | ||
53 | }; | ||
54 | }U_MIBS_IP_ADDRESS; | ||
55 | |||
56 | |||
57 | typedef struct _S_MIBS_HOST_INFO | ||
58 | { | ||
59 | ULONG64 GoodTransmits; | ||
60 | ULONG64 GoodReceives; | ||
61 | // this to keep track of the Tx and Rx MailBox Registers. | ||
62 | ULONG NumDesUsed; | ||
63 | ULONG CurrNumFreeDesc; | ||
64 | ULONG PrevNumFreeDesc; | ||
65 | // to keep track the no of byte recieved | ||
66 | ULONG PrevNumRcevBytes; | ||
67 | ULONG CurrNumRcevBytes; | ||
68 | |||
69 | /* QOS Related */ | ||
70 | ULONG BEBucketSize; | ||
71 | ULONG rtPSBucketSize; | ||
72 | ULONG LastTxQueueIndex; | ||
73 | BOOLEAN TxOutofDescriptors; | ||
74 | BOOLEAN TimerActive; | ||
75 | UINT32 u32TotalDSD; | ||
76 | UINT32 aTxPktSizeHist[MIBS_MAX_HIST_ENTRIES]; | ||
77 | UINT32 aRxPktSizeHist[MIBS_MAX_HIST_ENTRIES]; | ||
78 | }S_MIBS_HOST_INFO; | ||
79 | |||
80 | typedef struct _S_MIBS_CLASSIFIER_RULE | ||
81 | { | ||
82 | ULONG ulSFID; | ||
83 | UCHAR ucReserved[2]; | ||
84 | B_UINT16 uiClassifierRuleIndex; | ||
85 | BOOLEAN bUsed; | ||
86 | USHORT usVCID_Value; | ||
87 | // This field detemines the Classifier Priority | ||
88 | B_UINT8 u8ClassifierRulePriority; | ||
89 | U_MIBS_IP_ADDRESS stSrcIpAddress; | ||
90 | /*IP Source Address Length*/ | ||
91 | UCHAR ucIPSourceAddressLength; | ||
92 | |||
93 | U_MIBS_IP_ADDRESS stDestIpAddress; | ||
94 | /* IP Destination Address Length */ | ||
95 | UCHAR ucIPDestinationAddressLength; | ||
96 | UCHAR ucIPTypeOfServiceLength;//Type of service Length | ||
97 | UCHAR ucTosLow;//Tos Low | ||
98 | UCHAR ucTosHigh;//Tos High | ||
99 | UCHAR ucTosMask;//Tos Mask | ||
100 | UCHAR ucProtocolLength;//protocol Length | ||
101 | UCHAR ucProtocol[MIBS_MAX_PROTOCOL_LENGTH];//protocol Length | ||
102 | USHORT usSrcPortRangeLo[MIBS_MAX_PORT_RANGE]; | ||
103 | USHORT usSrcPortRangeHi[MIBS_MAX_PORT_RANGE]; | ||
104 | UCHAR ucSrcPortRangeLength; | ||
105 | USHORT usDestPortRangeLo[MIBS_MAX_PORT_RANGE]; | ||
106 | USHORT usDestPortRangeHi[MIBS_MAX_PORT_RANGE]; | ||
107 | UCHAR ucDestPortRangeLength; | ||
108 | BOOLEAN bProtocolValid; | ||
109 | BOOLEAN bTOSValid; | ||
110 | BOOLEAN bDestIpValid; | ||
111 | BOOLEAN bSrcIpValid; | ||
112 | UCHAR ucDirection; | ||
113 | BOOLEAN bIpv6Protocol; | ||
114 | UINT32 u32PHSRuleID; | ||
115 | }S_MIBS_CLASSIFIER_RULE; | ||
116 | |||
117 | |||
118 | typedef struct _S_MIBS_PHS_RULE | ||
119 | { | ||
120 | ULONG ulSFID; | ||
121 | /// brief 8bit PHSI Of The Service Flow | ||
122 | B_UINT8 u8PHSI; | ||
123 | /// brief PHSF Of The Service Flow | ||
124 | B_UINT8 u8PHSFLength; | ||
125 | B_UINT8 u8PHSF[MIBS_MAX_PHS_LENGTHS]; | ||
126 | /// brief PHSM Of The Service Flow | ||
127 | B_UINT8 u8PHSMLength; | ||
128 | B_UINT8 u8PHSM[MIBS_MAX_PHS_LENGTHS]; | ||
129 | /// brief 8bit PHSS Of The Service Flow | ||
130 | B_UINT8 u8PHSS; | ||
131 | /// brief 8bit PHSV Of The Service Flow | ||
132 | B_UINT8 u8PHSV; | ||
133 | // Reserved bytes are 5, so that it is similar to S_PHS_RULE structure. | ||
134 | B_UINT8 reserved[5]; | ||
135 | |||
136 | LONG PHSModifiedBytes; | ||
137 | ULONG PHSModifiedNumPackets; | ||
138 | ULONG PHSErrorNumPackets; | ||
139 | }S_MIBS_PHS_RULE; | ||
140 | |||
141 | typedef struct _S_MIBS_EXTSERVICEFLOW_PARAMETERS | ||
142 | { | ||
143 | UINT32 wmanIfSfid; | ||
144 | UINT32 wmanIfCmnCpsSfState; | ||
145 | UINT32 wmanIfCmnCpsMaxSustainedRate; | ||
146 | UINT32 wmanIfCmnCpsMaxTrafficBurst; | ||
147 | UINT32 wmanIfCmnCpsMinReservedRate; | ||
148 | UINT32 wmanIfCmnCpsToleratedJitter; | ||
149 | UINT32 wmanIfCmnCpsMaxLatency; | ||
150 | UINT32 wmanIfCmnCpsFixedVsVariableSduInd; | ||
151 | UINT32 wmanIfCmnCpsSduSize; | ||
152 | UINT32 wmanIfCmnCpsSfSchedulingType; | ||
153 | UINT32 wmanIfCmnCpsArqEnable; | ||
154 | UINT32 wmanIfCmnCpsArqWindowSize; | ||
155 | UINT32 wmanIfCmnCpsArqBlockLifetime; | ||
156 | UINT32 wmanIfCmnCpsArqSyncLossTimeout; | ||
157 | UINT32 wmanIfCmnCpsArqDeliverInOrder; | ||
158 | UINT32 wmanIfCmnCpsArqRxPurgeTimeout; | ||
159 | UINT32 wmanIfCmnCpsArqBlockSize; | ||
160 | UINT32 wmanIfCmnCpsMinRsvdTolerableRate; | ||
161 | UINT32 wmanIfCmnCpsReqTxPolicy; | ||
162 | UINT32 wmanIfCmnSfCsSpecification; | ||
163 | UINT32 wmanIfCmnCpsTargetSaid; | ||
164 | |||
165 | }S_MIBS_EXTSERVICEFLOW_PARAMETERS; | ||
166 | |||
167 | |||
168 | typedef struct _S_MIBS_SERVICEFLOW_TABLE | ||
169 | { | ||
170 | //classification extension Rule | ||
171 | ULONG ulSFID; | ||
172 | USHORT usVCID_Value; | ||
173 | UINT uiThreshold; | ||
174 | // This field determines the priority of the SF Queues | ||
175 | B_UINT8 u8TrafficPriority; | ||
176 | |||
177 | BOOLEAN bValid; | ||
178 | BOOLEAN bActive; | ||
179 | BOOLEAN bActivateRequestSent; | ||
180 | //BE or rtPS | ||
181 | B_UINT8 u8QueueType; | ||
182 | //maximum size of the bucket for the queue | ||
183 | UINT uiMaxBucketSize; | ||
184 | UINT uiCurrentQueueDepthOnTarget; | ||
185 | UINT uiCurrentBytesOnHost; | ||
186 | UINT uiCurrentPacketsOnHost; | ||
187 | UINT uiDroppedCountBytes; | ||
188 | UINT uiDroppedCountPackets; | ||
189 | UINT uiSentBytes; | ||
190 | UINT uiSentPackets; | ||
191 | UINT uiCurrentDrainRate; | ||
192 | UINT uiThisPeriodSentBytes; | ||
193 | LARGE_INTEGER liDrainCalculated; | ||
194 | UINT uiCurrentTokenCount; | ||
195 | LARGE_INTEGER liLastUpdateTokenAt; | ||
196 | UINT uiMaxAllowedRate; | ||
197 | UINT NumOfPacketsSent; | ||
198 | UCHAR ucDirection; | ||
199 | USHORT usCID; | ||
200 | S_MIBS_EXTSERVICEFLOW_PARAMETERS stMibsExtServiceFlowTable; | ||
201 | UINT uiCurrentRxRate; | ||
202 | UINT uiThisPeriodRxBytes; | ||
203 | UINT uiTotalRxBytes; | ||
204 | UINT uiTotalTxBytes; | ||
205 | }S_MIBS_SERVICEFLOW_TABLE; | ||
206 | |||
207 | typedef struct _S_MIBS_DROPPED_APP_CNTRL_MESSAGES | ||
208 | { | ||
209 | ULONG cm_responses; | ||
210 | ULONG cm_control_newdsx_multiclassifier_resp; | ||
211 | ULONG link_control_resp; | ||
212 | ULONG status_rsp; | ||
213 | ULONG stats_pointer_resp; | ||
214 | ULONG idle_mode_status; | ||
215 | ULONG auth_ss_host_msg; | ||
216 | ULONG low_priority_message; | ||
217 | |||
218 | }S_MIBS_DROPPED_APP_CNTRL_MESSAGES; | ||
219 | |||
220 | typedef struct _S_MIBS_HOST_STATS_MIBS | ||
221 | { | ||
222 | S_MIBS_HOST_INFO stHostInfo; | ||
223 | S_MIBS_CLASSIFIER_RULE astClassifierTable[MIBS_MAX_CLASSIFIERS]; | ||
224 | S_MIBS_SERVICEFLOW_TABLE astSFtable[MIBS_MAX_SERVICEFLOWS]; | ||
225 | S_MIBS_PHS_RULE astPhsRulesTable[MIBS_MAX_PHSRULES]; | ||
226 | S_MIBS_DROPPED_APP_CNTRL_MESSAGES stDroppedAppCntrlMsgs; | ||
227 | }S_MIBS_HOST_STATS_MIBS; | ||
228 | #endif | ||
229 | |||
230 | |||
diff --git a/drivers/staging/bcm/HostMibs.h b/drivers/staging/bcm/HostMibs.h new file mode 100644 index 00000000000..28a57831137 --- /dev/null +++ b/drivers/staging/bcm/HostMibs.h | |||
@@ -0,0 +1,7 @@ | |||
1 | #ifndef _HOST_MIBS_H | ||
2 | #define _HOST_MIBS_H | ||
3 | |||
4 | INT ProcessGetHostMibs(PMINI_ADAPTER Adapter, | ||
5 | PVOID ioBuffer, | ||
6 | ULONG inputBufferLength); | ||
7 | #endif | ||
diff --git a/drivers/staging/bcm/IPv6Protocol.c b/drivers/staging/bcm/IPv6Protocol.c new file mode 100644 index 00000000000..cb4ca9a44c8 --- /dev/null +++ b/drivers/staging/bcm/IPv6Protocol.c | |||
@@ -0,0 +1,400 @@ | |||
1 | #include "headers.h" | ||
2 | |||
3 | UCHAR * GetNextIPV6ChainedHeader(UCHAR **ppucPayload,UCHAR *pucNextHeader,BOOLEAN *bParseDone,USHORT *pusPayloadLength) | ||
4 | { | ||
5 | UCHAR *pucRetHeaderPtr = NULL; | ||
6 | UCHAR *pucPayloadPtr = NULL; | ||
7 | USHORT usNextHeaderOffset = 0 ; | ||
8 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
9 | |||
10 | if((NULL == ppucPayload) || (*pusPayloadLength == 0) || (*bParseDone)) | ||
11 | { | ||
12 | *bParseDone = TRUE; | ||
13 | return NULL; | ||
14 | |||
15 | } | ||
16 | |||
17 | pucRetHeaderPtr = *ppucPayload; | ||
18 | pucPayloadPtr = *ppucPayload; | ||
19 | |||
20 | if(!pucRetHeaderPtr || !pucPayloadPtr) | ||
21 | { | ||
22 | *bParseDone = TRUE; | ||
23 | return NULL; | ||
24 | } | ||
25 | |||
26 | //Get the Nextt Header Type | ||
27 | *bParseDone = FALSE; | ||
28 | |||
29 | |||
30 | |||
31 | switch(*pucNextHeader) | ||
32 | { | ||
33 | case IPV6HDR_TYPE_HOPBYHOP: | ||
34 | { | ||
35 | |||
36 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 HopByHop Header"); | ||
37 | usNextHeaderOffset+=sizeof(IPV6HopByHopOptionsHeader); | ||
38 | } | ||
39 | break; | ||
40 | |||
41 | case IPV6HDR_TYPE_ROUTING: | ||
42 | { | ||
43 | IPV6RoutingHeader *pstIpv6RoutingHeader; | ||
44 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 Routing Header"); | ||
45 | pstIpv6RoutingHeader = (IPV6RoutingHeader *)pucPayloadPtr; | ||
46 | usNextHeaderOffset += sizeof(IPV6RoutingHeader); | ||
47 | usNextHeaderOffset += pstIpv6RoutingHeader->ucNumAddresses * IPV6_ADDRESS_SIZEINBYTES; | ||
48 | |||
49 | } | ||
50 | break; | ||
51 | case IPV6HDR_TYPE_FRAGMENTATION: | ||
52 | { | ||
53 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 Fragmentation Header"); | ||
54 | usNextHeaderOffset+= sizeof(IPV6FragmentHeader); | ||
55 | |||
56 | } | ||
57 | break; | ||
58 | case IPV6HDR_TYPE_DESTOPTS: | ||
59 | { | ||
60 | IPV6DestOptionsHeader *pstIpv6DestOptsHdr = (IPV6DestOptionsHeader *)pucPayloadPtr; | ||
61 | int nTotalOptions = pstIpv6DestOptsHdr->ucHdrExtLen; | ||
62 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 DestOpts Header Header"); | ||
63 | usNextHeaderOffset+= sizeof(IPV6DestOptionsHeader); | ||
64 | usNextHeaderOffset+= nTotalOptions * IPV6_DESTOPTS_HDR_OPTIONSIZE ; | ||
65 | |||
66 | } | ||
67 | break; | ||
68 | case IPV6HDR_TYPE_AUTHENTICATION: | ||
69 | { | ||
70 | IPV6AuthenticationHeader *pstIpv6AuthHdr = (IPV6AuthenticationHeader *)pucPayloadPtr; | ||
71 | int nHdrLen = pstIpv6AuthHdr->ucLength; | ||
72 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 Authentication Header"); | ||
73 | usNextHeaderOffset+= nHdrLen * 4; | ||
74 | } | ||
75 | break; | ||
76 | case IPV6HDR_TYPE_ENCRYPTEDSECURITYPAYLOAD: | ||
77 | { | ||
78 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 Encrypted Security Payload Header"); | ||
79 | *bParseDone = TRUE; | ||
80 | |||
81 | } | ||
82 | break; | ||
83 | case IPV6_ICMP_HDR_TYPE: | ||
84 | { | ||
85 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, " ICMP Header"); | ||
86 | *bParseDone = TRUE; | ||
87 | } | ||
88 | break; | ||
89 | case TCP_HEADER_TYPE: | ||
90 | { | ||
91 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, " \nTCP Header"); | ||
92 | *bParseDone = TRUE; | ||
93 | } | ||
94 | break; | ||
95 | case UDP_HEADER_TYPE: | ||
96 | { | ||
97 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, " \nUDP Header"); | ||
98 | *bParseDone = TRUE; | ||
99 | } | ||
100 | break; | ||
101 | default : | ||
102 | { | ||
103 | *bParseDone = TRUE; | ||
104 | |||
105 | } | ||
106 | break; | ||
107 | |||
108 | |||
109 | } | ||
110 | |||
111 | if(*bParseDone == FALSE) | ||
112 | { | ||
113 | if(*pusPayloadLength <= usNextHeaderOffset) | ||
114 | { | ||
115 | *bParseDone = TRUE; | ||
116 | } | ||
117 | else | ||
118 | { | ||
119 | *pucNextHeader = *pucPayloadPtr; | ||
120 | pucPayloadPtr+=usNextHeaderOffset; | ||
121 | (*pusPayloadLength)-=usNextHeaderOffset; | ||
122 | } | ||
123 | |||
124 | } | ||
125 | |||
126 | |||
127 | |||
128 | *ppucPayload = pucPayloadPtr; | ||
129 | return pucRetHeaderPtr; | ||
130 | } | ||
131 | |||
132 | |||
133 | UCHAR GetIpv6ProtocolPorts(UCHAR *pucPayload,USHORT *pusSrcPort,USHORT *pusDestPort,USHORT usPayloadLength,UCHAR ucNextHeader) | ||
134 | { | ||
135 | UCHAR *pIpv6HdrScanContext = pucPayload; | ||
136 | BOOLEAN bDone = FALSE; | ||
137 | UCHAR ucHeaderType =0; | ||
138 | UCHAR *pucNextHeader = NULL; | ||
139 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
140 | |||
141 | if( !pucPayload || (usPayloadLength == 0)) | ||
142 | { | ||
143 | return 0; | ||
144 | } | ||
145 | |||
146 | *pusSrcPort = *pusDestPort = 0; | ||
147 | ucHeaderType = ucNextHeader; | ||
148 | while(!bDone) | ||
149 | { | ||
150 | pucNextHeader = GetNextIPV6ChainedHeader(&pIpv6HdrScanContext,&ucHeaderType,&bDone,&usPayloadLength); | ||
151 | if(bDone) | ||
152 | { | ||
153 | if((ucHeaderType==TCP_HEADER_TYPE) || (ucHeaderType == UDP_HEADER_TYPE)) | ||
154 | { | ||
155 | *pusSrcPort=*((PUSHORT)(pucNextHeader)); | ||
156 | *pusDestPort=*((PUSHORT)(pucNextHeader+2)); | ||
157 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, " \nProtocol Ports - Src Port :0x%x Dest Port : 0x%x",ntohs(*pusSrcPort),ntohs(*pusDestPort)); | ||
158 | } | ||
159 | break; | ||
160 | |||
161 | } | ||
162 | } | ||
163 | return ucHeaderType; | ||
164 | } | ||
165 | |||
166 | |||
167 | |||
168 | USHORT IpVersion6(PMINI_ADAPTER Adapter, /**< Pointer to the driver control structure */ | ||
169 | PVOID pcIpHeader, /**<Pointer to the IP Hdr of the packet*/ | ||
170 | S_CLASSIFIER_RULE *pstClassifierRule ) | ||
171 | { | ||
172 | USHORT ushDestPort = 0; | ||
173 | USHORT ushSrcPort = 0; | ||
174 | UCHAR ucNextProtocolAboveIP =0; | ||
175 | IPV6Header *pstIpv6Header = NULL; | ||
176 | BOOLEAN bClassificationSucceed = FALSE; | ||
177 | |||
178 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "IpVersion6 ==========>\n"); | ||
179 | |||
180 | pstIpv6Header = (IPV6Header *)pcIpHeader; | ||
181 | |||
182 | DumpIpv6Header(pstIpv6Header); | ||
183 | |||
184 | //Try to get the next higher layer protocol and the Ports Nos if TCP or UDP | ||
185 | ucNextProtocolAboveIP = GetIpv6ProtocolPorts((UCHAR *)(pcIpHeader + sizeof(IPV6Header)), | ||
186 | &ushSrcPort, | ||
187 | &ushDestPort, | ||
188 | pstIpv6Header->usPayloadLength, | ||
189 | pstIpv6Header->ucNextHeader); | ||
190 | |||
191 | do | ||
192 | { | ||
193 | if(0 == pstClassifierRule->ucDirection) | ||
194 | { | ||
195 | //cannot be processed for classification. | ||
196 | // it is a down link connection | ||
197 | break; | ||
198 | } | ||
199 | |||
200 | if(!pstClassifierRule->bIpv6Protocol) | ||
201 | { | ||
202 | //We are looking for Ipv6 Classifiers . Lets ignore this classifier and try the next one. | ||
203 | break; | ||
204 | } | ||
205 | |||
206 | bClassificationSucceed=MatchSrcIpv6Address(pstClassifierRule,pstIpv6Header); | ||
207 | if(!bClassificationSucceed) | ||
208 | break; | ||
209 | |||
210 | bClassificationSucceed=MatchDestIpv6Address(pstClassifierRule,pstIpv6Header); | ||
211 | if(!bClassificationSucceed) | ||
212 | break; | ||
213 | |||
214 | //Match the protocol type.For IPv6 the next protocol at end of Chain of IPv6 prot headers | ||
215 | bClassificationSucceed=MatchProtocol(pstClassifierRule,ucNextProtocolAboveIP); | ||
216 | if(!bClassificationSucceed) | ||
217 | break; | ||
218 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 Protocol Matched"); | ||
219 | |||
220 | if((ucNextProtocolAboveIP == TCP_HEADER_TYPE) || (ucNextProtocolAboveIP == UDP_HEADER_TYPE)) | ||
221 | { | ||
222 | //Match Src Port | ||
223 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 Source Port:%x\n",ntohs(ushSrcPort)); | ||
224 | bClassificationSucceed=MatchSrcPort(pstClassifierRule,ntohs(ushSrcPort)); | ||
225 | if(!bClassificationSucceed) | ||
226 | break; | ||
227 | |||
228 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 Src Port Matched"); | ||
229 | |||
230 | //Match Dest Port | ||
231 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 Destination Port:%x\n",ntohs(ushDestPort)); | ||
232 | bClassificationSucceed=MatchDestPort(pstClassifierRule,ntohs(ushDestPort)); | ||
233 | if(!bClassificationSucceed) | ||
234 | break; | ||
235 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 Dest Port Matched"); | ||
236 | } | ||
237 | }while(0); | ||
238 | |||
239 | if(TRUE==bClassificationSucceed) | ||
240 | { | ||
241 | INT iMatchedSFQueueIndex = 0; | ||
242 | iMatchedSFQueueIndex = SearchSfid(Adapter,pstClassifierRule->ulSFID); | ||
243 | if(iMatchedSFQueueIndex >= NO_OF_QUEUES) | ||
244 | { | ||
245 | bClassificationSucceed = FALSE; | ||
246 | } | ||
247 | else | ||
248 | { | ||
249 | if(FALSE == Adapter->PackInfo[iMatchedSFQueueIndex].bActive) | ||
250 | { | ||
251 | bClassificationSucceed = FALSE; | ||
252 | } | ||
253 | } | ||
254 | } | ||
255 | |||
256 | return bClassificationSucceed; | ||
257 | } | ||
258 | |||
259 | |||
260 | BOOLEAN MatchSrcIpv6Address(S_CLASSIFIER_RULE *pstClassifierRule,IPV6Header *pstIpv6Header) | ||
261 | { | ||
262 | UINT uiLoopIndex=0; | ||
263 | UINT uiIpv6AddIndex=0; | ||
264 | UINT uiIpv6AddrNoLongWords = 4; | ||
265 | ULONG aulSrcIP[4]; | ||
266 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
267 | /* | ||
268 | //This is the no. of Src Addresses ie Range of IP Addresses contained | ||
269 | //in the classifier rule for which we need to match | ||
270 | */ | ||
271 | UINT uiCountIPSrcAddresses = (UINT)pstClassifierRule->ucIPSourceAddressLength; | ||
272 | |||
273 | |||
274 | if(0 == uiCountIPSrcAddresses) | ||
275 | return TRUE; | ||
276 | |||
277 | |||
278 | //First Convert the Ip Address in the packet to Host Endian order | ||
279 | for(uiIpv6AddIndex=0;uiIpv6AddIndex<uiIpv6AddrNoLongWords;uiIpv6AddIndex++) | ||
280 | { | ||
281 | aulSrcIP[uiIpv6AddIndex]=ntohl(pstIpv6Header->ulSrcIpAddress[uiIpv6AddIndex]); | ||
282 | } | ||
283 | |||
284 | for(uiLoopIndex=0;uiLoopIndex<uiCountIPSrcAddresses;uiLoopIndex+=uiIpv6AddrNoLongWords) | ||
285 | { | ||
286 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\n Src Ipv6 Address In Recieved Packet : \n "); | ||
287 | DumpIpv6Address(aulSrcIP); | ||
288 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\n Src Ipv6 Mask In Classifier Rule: \n"); | ||
289 | DumpIpv6Address(&pstClassifierRule->stSrcIpAddress.ulIpv6Mask[uiLoopIndex]); | ||
290 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\n Src Ipv6 Address In Classifier Rule : \n"); | ||
291 | DumpIpv6Address(&pstClassifierRule->stSrcIpAddress.ulIpv6Addr[uiLoopIndex]); | ||
292 | |||
293 | for(uiIpv6AddIndex=0;uiIpv6AddIndex<uiIpv6AddrNoLongWords;uiIpv6AddIndex++) | ||
294 | { | ||
295 | if((pstClassifierRule->stSrcIpAddress.ulIpv6Mask[uiLoopIndex+uiIpv6AddIndex] & aulSrcIP[uiIpv6AddIndex]) | ||
296 | != pstClassifierRule->stSrcIpAddress.ulIpv6Addr[uiLoopIndex+uiIpv6AddIndex]) | ||
297 | { | ||
298 | //Match failed for current Ipv6 Address.Try next Ipv6 Address | ||
299 | break; | ||
300 | } | ||
301 | |||
302 | if(uiIpv6AddIndex == uiIpv6AddrNoLongWords-1) | ||
303 | { | ||
304 | //Match Found | ||
305 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "Ipv6 Src Ip Address Matched\n"); | ||
306 | return TRUE; | ||
307 | } | ||
308 | } | ||
309 | } | ||
310 | return FALSE; | ||
311 | } | ||
312 | |||
313 | BOOLEAN MatchDestIpv6Address(S_CLASSIFIER_RULE *pstClassifierRule,IPV6Header *pstIpv6Header) | ||
314 | { | ||
315 | UINT uiLoopIndex=0; | ||
316 | UINT uiIpv6AddIndex=0; | ||
317 | UINT uiIpv6AddrNoLongWords = 4; | ||
318 | ULONG aulDestIP[4]; | ||
319 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
320 | /* | ||
321 | //This is the no. of Destination Addresses ie Range of IP Addresses contained | ||
322 | //in the classifier rule for which we need to match | ||
323 | */ | ||
324 | UINT uiCountIPDestinationAddresses = (UINT)pstClassifierRule->ucIPDestinationAddressLength; | ||
325 | |||
326 | |||
327 | if(0 == uiCountIPDestinationAddresses) | ||
328 | return TRUE; | ||
329 | |||
330 | |||
331 | //First Convert the Ip Address in the packet to Host Endian order | ||
332 | for(uiIpv6AddIndex=0;uiIpv6AddIndex<uiIpv6AddrNoLongWords;uiIpv6AddIndex++) | ||
333 | { | ||
334 | aulDestIP[uiIpv6AddIndex]=ntohl(pstIpv6Header->ulDestIpAddress[uiIpv6AddIndex]); | ||
335 | } | ||
336 | |||
337 | for(uiLoopIndex=0;uiLoopIndex<uiCountIPDestinationAddresses;uiLoopIndex+=uiIpv6AddrNoLongWords) | ||
338 | { | ||
339 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\n Destination Ipv6 Address In Recieved Packet : \n "); | ||
340 | DumpIpv6Address(aulDestIP); | ||
341 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\n Destination Ipv6 Mask In Classifier Rule: \n"); | ||
342 | DumpIpv6Address(&pstClassifierRule->stDestIpAddress.ulIpv6Mask[uiLoopIndex]); | ||
343 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\n Destination Ipv6 Address In Classifier Rule : \n"); | ||
344 | DumpIpv6Address(&pstClassifierRule->stDestIpAddress.ulIpv6Addr[uiLoopIndex]); | ||
345 | |||
346 | for(uiIpv6AddIndex=0;uiIpv6AddIndex<uiIpv6AddrNoLongWords;uiIpv6AddIndex++) | ||
347 | { | ||
348 | if((pstClassifierRule->stDestIpAddress.ulIpv6Mask[uiLoopIndex+uiIpv6AddIndex] & aulDestIP[uiIpv6AddIndex]) | ||
349 | != pstClassifierRule->stDestIpAddress.ulIpv6Addr[uiLoopIndex+uiIpv6AddIndex]) | ||
350 | { | ||
351 | //Match failed for current Ipv6 Address.Try next Ipv6 Address | ||
352 | break; | ||
353 | } | ||
354 | |||
355 | if(uiIpv6AddIndex == uiIpv6AddrNoLongWords-1) | ||
356 | { | ||
357 | //Match Found | ||
358 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "Ipv6 Destination Ip Address Matched\n"); | ||
359 | return TRUE; | ||
360 | } | ||
361 | } | ||
362 | } | ||
363 | return FALSE; | ||
364 | |||
365 | } | ||
366 | |||
367 | VOID DumpIpv6Address(ULONG *puIpv6Address) | ||
368 | { | ||
369 | UINT uiIpv6AddrNoLongWords = 4; | ||
370 | UINT uiIpv6AddIndex=0; | ||
371 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
372 | for(uiIpv6AddIndex=0;uiIpv6AddIndex<uiIpv6AddrNoLongWords;uiIpv6AddIndex++) | ||
373 | { | ||
374 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, ":%lx",puIpv6Address[uiIpv6AddIndex]); | ||
375 | } | ||
376 | |||
377 | } | ||
378 | |||
379 | VOID DumpIpv6Header(IPV6Header *pstIpv6Header) | ||
380 | { | ||
381 | UCHAR ucVersion; | ||
382 | UCHAR ucPrio ; | ||
383 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
384 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "----Ipv6 Header---"); | ||
385 | ucVersion = pstIpv6Header->ucVersionPrio & 0xf0; | ||
386 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "Version : %x \n",ucVersion); | ||
387 | ucPrio = pstIpv6Header->ucVersionPrio & 0x0f; | ||
388 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "Priority : %x \n",ucPrio); | ||
389 | //BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "Flow Label : %x \n",(pstIpv6Header->ucVersionPrio &0xf0); | ||
390 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "Payload Length : %x \n",ntohs(pstIpv6Header->usPayloadLength)); | ||
391 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "Next Header : %x \n",pstIpv6Header->ucNextHeader); | ||
392 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "Hop Limit : %x \n",pstIpv6Header->ucHopLimit); | ||
393 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "Src Address :\n"); | ||
394 | DumpIpv6Address(pstIpv6Header->ulSrcIpAddress); | ||
395 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "Dest Address :\n"); | ||
396 | DumpIpv6Address(pstIpv6Header->ulDestIpAddress); | ||
397 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "----Ipv6 Header End---"); | ||
398 | |||
399 | |||
400 | } | ||
diff --git a/drivers/staging/bcm/IPv6ProtocolHdr.h b/drivers/staging/bcm/IPv6ProtocolHdr.h new file mode 100644 index 00000000000..b93f7902e28 --- /dev/null +++ b/drivers/staging/bcm/IPv6ProtocolHdr.h | |||
@@ -0,0 +1,119 @@ | |||
1 | #ifndef _IPV6_PROTOCOL_DEFINES_ | ||
2 | #define _IPV6_PROTOCOL_DEFINES_ | ||
3 | |||
4 | |||
5 | #define IPV6HDR_TYPE_HOPBYHOP 0x0 | ||
6 | #define IPV6HDR_TYPE_ROUTING 0x2B | ||
7 | #define IPV6HDR_TYPE_FRAGMENTATION 0x2C | ||
8 | #define IPV6HDR_TYPE_DESTOPTS 0x3c | ||
9 | #define IPV6HDR_TYPE_AUTHENTICATION 0x33 | ||
10 | #define IPV6HDR_TYPE_ENCRYPTEDSECURITYPAYLOAD 0x34 | ||
11 | #define MASK_IPV6_CS_SPEC 0x2 | ||
12 | |||
13 | |||
14 | #define TCP_HEADER_TYPE 0x6 | ||
15 | #define UDP_HEADER_TYPE 0x11 | ||
16 | #define IPV6_ICMP_HDR_TYPE 0x2 | ||
17 | #define IPV6_FLOWLABEL_BITOFFSET 9 | ||
18 | |||
19 | #define IPV6_MAX_CHAINEDHDR_BUFFBYTES 0x64 | ||
20 | /* | ||
21 | // Size of Dest Options field of Destinations Options Header | ||
22 | // in bytes. | ||
23 | */ | ||
24 | #define IPV6_DESTOPTS_HDR_OPTIONSIZE 0x8 | ||
25 | |||
26 | //typedef unsigned char UCHAR; | ||
27 | //typedef unsigned short USHORT; | ||
28 | //typedef unsigned long int ULONG; | ||
29 | |||
30 | typedef struct IPV6HeaderFormatTag | ||
31 | { | ||
32 | UCHAR ucVersionPrio; | ||
33 | UCHAR aucFlowLabel[3]; | ||
34 | USHORT usPayloadLength; | ||
35 | UCHAR ucNextHeader; | ||
36 | UCHAR ucHopLimit; | ||
37 | ULONG ulSrcIpAddress[4]; | ||
38 | ULONG ulDestIpAddress[4]; | ||
39 | }IPV6Header; | ||
40 | |||
41 | typedef struct IPV6RoutingHeaderFormatTag | ||
42 | { | ||
43 | UCHAR ucNextHeader; | ||
44 | UCHAR ucRoutingType; | ||
45 | UCHAR ucNumAddresses; | ||
46 | UCHAR ucNextAddress; | ||
47 | ULONG ulReserved; | ||
48 | //UCHAR aucAddressList[0]; | ||
49 | |||
50 | }IPV6RoutingHeader; | ||
51 | |||
52 | typedef struct IPV6FragmentHeaderFormatTag | ||
53 | { | ||
54 | UCHAR ucNextHeader; | ||
55 | UCHAR ucReserved; | ||
56 | USHORT usFragmentOffset; | ||
57 | ULONG ulIdentification; | ||
58 | }IPV6FragmentHeader; | ||
59 | |||
60 | typedef struct IPV6DestOptionsHeaderFormatTag | ||
61 | { | ||
62 | UCHAR ucNextHeader; | ||
63 | UCHAR ucHdrExtLen; | ||
64 | UCHAR ucDestOptions[6]; | ||
65 | //UCHAR udExtDestOptions[0]; | ||
66 | }IPV6DestOptionsHeader; | ||
67 | |||
68 | typedef struct IPV6HopByHopOptionsHeaderFormatTag | ||
69 | { | ||
70 | UCHAR ucNextHeader; | ||
71 | UCHAR ucMisc[3]; | ||
72 | ULONG ulJumboPayloadLen; | ||
73 | }IPV6HopByHopOptionsHeader; | ||
74 | |||
75 | typedef struct IPV6AuthenticationHeaderFormatTag | ||
76 | { | ||
77 | UCHAR ucNextHeader; | ||
78 | UCHAR ucLength; | ||
79 | USHORT usReserved; | ||
80 | ULONG ulSecurityParametersIndex; | ||
81 | //UCHAR ucAuthenticationData[0]; | ||
82 | |||
83 | }IPV6AuthenticationHeader; | ||
84 | |||
85 | typedef struct IPV6IcmpHeaderFormatTag | ||
86 | { | ||
87 | UCHAR ucType; | ||
88 | UCHAR ucCode; | ||
89 | USHORT usChecksum; | ||
90 | //UCHAR ucIcmpMsg[0]; | ||
91 | |||
92 | }IPV6IcmpHeader; | ||
93 | |||
94 | typedef enum _E_IPADDR_CONTEXT | ||
95 | { | ||
96 | eSrcIpAddress, | ||
97 | eDestIpAddress | ||
98 | |||
99 | }E_IPADDR_CONTEXT; | ||
100 | |||
101 | |||
102 | |||
103 | //Function Prototypes | ||
104 | BOOLEAN MatchSrcIpv6Address(S_CLASSIFIER_RULE *pstClassifierRule,IPV6Header *pstIpv6Header); | ||
105 | BOOLEAN MatchDestIpv6Address(S_CLASSIFIER_RULE *pstClassifierRule,IPV6Header *pstIpv6Header); | ||
106 | |||
107 | USHORT IpVersion6(PMINI_ADAPTER Adapter, /**< Pointer to the driver control structure */ | ||
108 | PVOID pcIpHeader, /**<Pointer to the IP Hdr of the packet*/ | ||
109 | S_CLASSIFIER_RULE *pstClassifierRule ); | ||
110 | |||
111 | VOID DumpIpv6Address(ULONG *puIpv6Address); | ||
112 | VOID DumpIpv6Header(IPV6Header *pstIpv6Header); | ||
113 | |||
114 | extern BOOLEAN MatchSrcPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushSrcPort); | ||
115 | extern BOOLEAN MatchDestPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushSrcPort); | ||
116 | extern BOOLEAN MatchProtocol(S_CLASSIFIER_RULE *pstClassifierRule,UCHAR ucProtocol); | ||
117 | |||
118 | |||
119 | #endif | ||
diff --git a/drivers/staging/bcm/InterfaceAdapter.h b/drivers/staging/bcm/InterfaceAdapter.h new file mode 100644 index 00000000000..6397c20f4f6 --- /dev/null +++ b/drivers/staging/bcm/InterfaceAdapter.h | |||
@@ -0,0 +1,97 @@ | |||
1 | #ifndef _INTERFACE_ADAPTER_H | ||
2 | #define _INTERFACE_ADAPTER_H | ||
3 | |||
4 | typedef struct _BULK_ENDP_IN | ||
5 | { | ||
6 | PCHAR bulk_in_buffer; | ||
7 | size_t bulk_in_size; | ||
8 | UCHAR bulk_in_endpointAddr; | ||
9 | UINT bulk_in_pipe; | ||
10 | }BULK_ENDP_IN, *PBULK_ENDP_IN; | ||
11 | |||
12 | |||
13 | typedef struct _BULK_ENDP_OUT | ||
14 | { | ||
15 | UCHAR bulk_out_buffer; | ||
16 | size_t bulk_out_size; | ||
17 | UCHAR bulk_out_endpointAddr; | ||
18 | UINT bulk_out_pipe; | ||
19 | //this is used when int out endpoint is used as bulk out end point | ||
20 | UCHAR int_out_interval; | ||
21 | }BULK_ENDP_OUT, *PBULK_ENDP_OUT; | ||
22 | |||
23 | typedef struct _INTR_ENDP_IN | ||
24 | { | ||
25 | PCHAR int_in_buffer; | ||
26 | size_t int_in_size; | ||
27 | UCHAR int_in_endpointAddr; | ||
28 | UCHAR int_in_interval; | ||
29 | UINT int_in_pipe; | ||
30 | }INTR_ENDP_IN, *PINTR_ENDP_IN; | ||
31 | |||
32 | typedef struct _INTR_ENDP_OUT | ||
33 | { | ||
34 | PCHAR int_out_buffer; | ||
35 | size_t int_out_size; | ||
36 | UCHAR int_out_endpointAddr; | ||
37 | UCHAR int_out_interval; | ||
38 | UINT int_out_pipe; | ||
39 | }INTR_ENDP_OUT, *PINTR_ENDP_OUT; | ||
40 | |||
41 | |||
42 | typedef struct _USB_TCB | ||
43 | { | ||
44 | struct urb *urb; | ||
45 | PVOID psIntfAdapter; | ||
46 | BOOLEAN bUsed; | ||
47 | }USB_TCB, *PUSB_TCB; | ||
48 | |||
49 | |||
50 | typedef struct _USB_RCB | ||
51 | { | ||
52 | struct urb *urb; | ||
53 | PVOID psIntfAdapter; | ||
54 | BOOLEAN bUsed; | ||
55 | }USB_RCB, *PUSB_RCB; | ||
56 | |||
57 | /* | ||
58 | //This is the interface specific Sub-Adapter | ||
59 | //Structure. | ||
60 | */ | ||
61 | typedef struct _S_INTERFACE_ADAPTER | ||
62 | { | ||
63 | struct usb_device * udev; | ||
64 | struct usb_interface * interface; | ||
65 | |||
66 | /* Bulk endpoint in info */ | ||
67 | BULK_ENDP_IN sBulkIn; | ||
68 | /* Bulk endpoint out info */ | ||
69 | BULK_ENDP_OUT sBulkOut; | ||
70 | /* Interrupt endpoint in info */ | ||
71 | INTR_ENDP_IN sIntrIn; | ||
72 | /* Interrupt endpoint out info */ | ||
73 | INTR_ENDP_OUT sIntrOut; | ||
74 | |||
75 | |||
76 | |||
77 | ULONG ulInterruptData[2]; | ||
78 | |||
79 | struct urb *psInterruptUrb; | ||
80 | |||
81 | USB_TCB asUsbTcb[MAXIMUM_USB_TCB]; | ||
82 | USB_RCB asUsbRcb[MAXIMUM_USB_RCB]; | ||
83 | atomic_t uNumTcbUsed; | ||
84 | atomic_t uCurrTcb; | ||
85 | atomic_t uNumRcbUsed; | ||
86 | atomic_t uCurrRcb; | ||
87 | |||
88 | PMINI_ADAPTER psAdapter; | ||
89 | BOOLEAN bFlashBoot; | ||
90 | BOOLEAN bHighSpeedDevice ; | ||
91 | |||
92 | BOOLEAN bSuspended; | ||
93 | BOOLEAN bPreparingForBusSuspend; | ||
94 | struct work_struct usbSuspendWork; | ||
95 | }S_INTERFACE_ADAPTER,*PS_INTERFACE_ADAPTER; | ||
96 | |||
97 | #endif | ||
diff --git a/drivers/staging/bcm/InterfaceDld.c b/drivers/staging/bcm/InterfaceDld.c new file mode 100644 index 00000000000..f9761dbd5e4 --- /dev/null +++ b/drivers/staging/bcm/InterfaceDld.c | |||
@@ -0,0 +1,509 @@ | |||
1 | #include "headers.h" | ||
2 | |||
3 | #ifndef BCM_SHM_INTERFACE | ||
4 | |||
5 | int InterfaceFileDownload( PVOID arg, | ||
6 | struct file *flp, | ||
7 | unsigned int on_chip_loc) | ||
8 | { | ||
9 | char *buff=NULL; | ||
10 | // unsigned int reg=0; | ||
11 | mm_segment_t oldfs={0}; | ||
12 | int errno=0, len=0 /*,is_config_file = 0*/; | ||
13 | loff_t pos=0; | ||
14 | PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)arg; | ||
15 | //PMINI_ADAPTER Adapter = psIntfAdapter->psAdapter; | ||
16 | |||
17 | buff=(PCHAR)kmalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_KERNEL); | ||
18 | if(!buff) | ||
19 | { | ||
20 | return -ENOMEM; | ||
21 | } | ||
22 | while(1) | ||
23 | { | ||
24 | oldfs=get_fs(); set_fs(get_ds()); | ||
25 | len=vfs_read(flp, buff, MAX_TRANSFER_CTRL_BYTE_USB, &pos); | ||
26 | set_fs(oldfs); | ||
27 | if(len<=0) | ||
28 | { | ||
29 | if(len<0) | ||
30 | { | ||
31 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "len < 0"); | ||
32 | errno=len; | ||
33 | } | ||
34 | else | ||
35 | { | ||
36 | errno = 0; | ||
37 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Got end of file!"); | ||
38 | } | ||
39 | break; | ||
40 | } | ||
41 | //BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, buff, MAX_TRANSFER_CTRL_BYTE_USB); | ||
42 | errno = InterfaceWRM(psIntfAdapter, on_chip_loc, buff, len) ; | ||
43 | if(errno) | ||
44 | { | ||
45 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "WRM Failed! status: %d", errno); | ||
46 | break; | ||
47 | |||
48 | } | ||
49 | on_chip_loc+=MAX_TRANSFER_CTRL_BYTE_USB; | ||
50 | }/* End of for(;;)*/ | ||
51 | |||
52 | bcm_kfree(buff); | ||
53 | return errno; | ||
54 | } | ||
55 | |||
56 | int InterfaceFileReadbackFromChip( PVOID arg, | ||
57 | struct file *flp, | ||
58 | unsigned int on_chip_loc) | ||
59 | { | ||
60 | char *buff=NULL, *buff_readback=NULL; | ||
61 | unsigned int reg=0; | ||
62 | mm_segment_t oldfs={0}; | ||
63 | int errno=0, len=0, is_config_file = 0; | ||
64 | loff_t pos=0; | ||
65 | static int fw_down = 0; | ||
66 | INT Status = STATUS_SUCCESS; | ||
67 | PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)arg; | ||
68 | |||
69 | buff=(PCHAR)kmalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_DMA); | ||
70 | buff_readback=(PCHAR)kmalloc(MAX_TRANSFER_CTRL_BYTE_USB , GFP_DMA); | ||
71 | if(!buff || !buff_readback) | ||
72 | { | ||
73 | bcm_kfree(buff); | ||
74 | bcm_kfree(buff_readback); | ||
75 | |||
76 | return -ENOMEM; | ||
77 | } | ||
78 | |||
79 | is_config_file = (on_chip_loc == CONFIG_BEGIN_ADDR)? 1:0; | ||
80 | |||
81 | memset(buff_readback, 0, MAX_TRANSFER_CTRL_BYTE_USB); | ||
82 | memset(buff, 0, MAX_TRANSFER_CTRL_BYTE_USB); | ||
83 | while(1) | ||
84 | { | ||
85 | oldfs=get_fs(); set_fs(get_ds()); | ||
86 | len=vfs_read(flp, buff, MAX_TRANSFER_CTRL_BYTE_USB, &pos); | ||
87 | set_fs(oldfs); | ||
88 | fw_down++; | ||
89 | if(len<=0) | ||
90 | { | ||
91 | if(len<0) | ||
92 | { | ||
93 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "len < 0"); | ||
94 | errno=len; | ||
95 | } | ||
96 | else | ||
97 | { | ||
98 | errno = 0; | ||
99 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Got end of file!"); | ||
100 | } | ||
101 | break; | ||
102 | } | ||
103 | |||
104 | |||
105 | Status = InterfaceRDM(psIntfAdapter, on_chip_loc, buff_readback, len); | ||
106 | if(Status) | ||
107 | { | ||
108 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "RDM of len %d Failed! %d", len, reg); | ||
109 | goto exit; | ||
110 | } | ||
111 | reg++; | ||
112 | if((len-sizeof(unsigned int))<4) | ||
113 | { | ||
114 | if(memcmp(buff_readback, buff, len)) | ||
115 | { | ||
116 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Firmware Download is not proper %d", fw_down); | ||
117 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT,DBG_LVL_ALL,"Length is: %d",len); | ||
118 | Status = -EIO; | ||
119 | goto exit; | ||
120 | } | ||
121 | } | ||
122 | else | ||
123 | { | ||
124 | len-=4; | ||
125 | while(len) | ||
126 | { | ||
127 | if(*(unsigned int*)&buff_readback[len] != *(unsigned int *)&buff[len]) | ||
128 | { | ||
129 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Firmware Download is not proper %d", fw_down); | ||
130 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Val from Binary %x, Val From Read Back %x ", *(unsigned int *)&buff[len], *(unsigned int*)&buff_readback[len]); | ||
131 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "len =%x!!!", len); | ||
132 | Status = -EIO; | ||
133 | goto exit; | ||
134 | } | ||
135 | len-=4; | ||
136 | } | ||
137 | } | ||
138 | on_chip_loc+=MAX_TRANSFER_CTRL_BYTE_USB; | ||
139 | }/* End of while(1)*/ | ||
140 | exit: | ||
141 | bcm_kfree(buff); | ||
142 | bcm_kfree(buff_readback); | ||
143 | return Status; | ||
144 | } | ||
145 | |||
146 | static int bcm_download_config_file(PMINI_ADAPTER Adapter, | ||
147 | FIRMWARE_INFO *psFwInfo) | ||
148 | { | ||
149 | int retval = STATUS_SUCCESS; | ||
150 | B_UINT32 value = 0; | ||
151 | |||
152 | if(Adapter->pstargetparams == NULL) | ||
153 | { | ||
154 | if((Adapter->pstargetparams = | ||
155 | kmalloc(sizeof(STARGETPARAMS), GFP_KERNEL)) == NULL) | ||
156 | { | ||
157 | return -ENOMEM; | ||
158 | } | ||
159 | } | ||
160 | if(psFwInfo->u32FirmwareLength != sizeof(STARGETPARAMS)) | ||
161 | { | ||
162 | return -EIO; | ||
163 | } | ||
164 | retval = copy_from_user(Adapter->pstargetparams, | ||
165 | psFwInfo->pvMappedFirmwareAddress, psFwInfo->u32FirmwareLength); | ||
166 | if(retval) | ||
167 | { | ||
168 | bcm_kfree (Adapter->pstargetparams); | ||
169 | Adapter->pstargetparams = NULL; | ||
170 | return retval; | ||
171 | } | ||
172 | /* Parse the structure and then Download the Firmware */ | ||
173 | beceem_parse_target_struct(Adapter); | ||
174 | |||
175 | //Initializing the NVM. | ||
176 | BcmInitNVM(Adapter); | ||
177 | |||
178 | retval = InitLedSettings (Adapter); | ||
179 | |||
180 | if(retval) | ||
181 | { | ||
182 | BCM_DEBUG_PRINT (Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "INIT LED Failed\n"); | ||
183 | return retval; | ||
184 | } | ||
185 | |||
186 | if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) | ||
187 | { | ||
188 | Adapter->LEDInfo.bLedInitDone = FALSE; | ||
189 | Adapter->DriverState = DRIVER_INIT; | ||
190 | wake_up(&Adapter->LEDInfo.notify_led_event); | ||
191 | } | ||
192 | |||
193 | if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) | ||
194 | { | ||
195 | Adapter->DriverState = FW_DOWNLOAD; | ||
196 | wake_up(&Adapter->LEDInfo.notify_led_event); | ||
197 | } | ||
198 | |||
199 | /* Initialize the DDR Controller */ | ||
200 | retval = ddr_init(Adapter); | ||
201 | if(retval) | ||
202 | { | ||
203 | BCM_DEBUG_PRINT (Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "DDR Init Failed\n"); | ||
204 | return retval; | ||
205 | } | ||
206 | |||
207 | value = 0; | ||
208 | wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 4, &value, sizeof(value)); | ||
209 | wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 8, &value, sizeof(value)); | ||
210 | |||
211 | if(Adapter->eNVMType == NVM_FLASH) | ||
212 | { | ||
213 | retval = PropagateCalParamsFromFlashToMemory(Adapter); | ||
214 | if(retval) | ||
215 | { | ||
216 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"propagaion of cal param failed with status :%d", retval); | ||
217 | return retval; | ||
218 | } | ||
219 | } | ||
220 | |||
221 | |||
222 | retval =buffDnldVerify(Adapter,(PUCHAR)Adapter->pstargetparams,sizeof(STARGETPARAMS),CONFIG_BEGIN_ADDR); | ||
223 | |||
224 | if(retval) | ||
225 | { | ||
226 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "configuration file not downloaded properly"); | ||
227 | } | ||
228 | else | ||
229 | Adapter->bCfgDownloaded = TRUE; | ||
230 | |||
231 | |||
232 | return retval; | ||
233 | } | ||
234 | #if 0 | ||
235 | static int bcm_download_buffer(PMINI_ADAPTER Adapter, | ||
236 | unsigned char *mappedbuffer, unsigned int u32FirmwareLength, | ||
237 | unsigned long u32StartingAddress) | ||
238 | { | ||
239 | char *buff=NULL; | ||
240 | unsigned int len = 0; | ||
241 | int retval = STATUS_SUCCESS; | ||
242 | buff = kzalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_KERNEL); | ||
243 | |||
244 | len = u32FirmwareLength; | ||
245 | |||
246 | while(u32FirmwareLength) | ||
247 | { | ||
248 | len = MIN_VAL (u32FirmwareLength, MAX_TRANSFER_CTRL_BYTE_USB); | ||
249 | if(STATUS_SUCCESS != (retval = copy_from_user(buff, | ||
250 | (unsigned char *)mappedbuffer, len))) | ||
251 | { | ||
252 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "copy_from_user failed\n"); | ||
253 | break; | ||
254 | } | ||
255 | retval = wrm (Adapter, u32StartingAddress, buff, len); | ||
256 | if(retval) | ||
257 | { | ||
258 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "wrm failed\n"); | ||
259 | break; | ||
260 | } | ||
261 | u32StartingAddress += len; | ||
262 | u32FirmwareLength -= len; | ||
263 | mappedbuffer +=len; | ||
264 | } | ||
265 | bcm_kfree(buff); | ||
266 | return retval; | ||
267 | } | ||
268 | #endif | ||
269 | static int bcm_compare_buff_contents(unsigned char *readbackbuff, | ||
270 | unsigned char *buff,unsigned int len) | ||
271 | { | ||
272 | int retval = STATUS_SUCCESS; | ||
273 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
274 | if((len-sizeof(unsigned int))<4) | ||
275 | { | ||
276 | if(memcmp(readbackbuff , buff, len)) | ||
277 | { | ||
278 | retval=-EINVAL; | ||
279 | } | ||
280 | } | ||
281 | else | ||
282 | { | ||
283 | len-=4; | ||
284 | while(len) | ||
285 | { | ||
286 | if(*(unsigned int*)&readbackbuff[len] != | ||
287 | *(unsigned int *)&buff[len]) | ||
288 | { | ||
289 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Firmware Download is not proper"); | ||
290 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Val from Binary %x, Val From Read Back %x ", *(unsigned int *)&buff[len], *(unsigned int*)&readbackbuff[len]); | ||
291 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "len =%x!!!", len); | ||
292 | retval=-EINVAL; | ||
293 | break; | ||
294 | } | ||
295 | len-=4; | ||
296 | } | ||
297 | } | ||
298 | return retval; | ||
299 | } | ||
300 | #if 0 | ||
301 | static int bcm_buffer_readback(PMINI_ADAPTER Adapter, | ||
302 | unsigned char *mappedbuffer, unsigned int u32FirmwareLength, | ||
303 | unsigned long u32StartingAddress) | ||
304 | { | ||
305 | unsigned char *buff = NULL; | ||
306 | unsigned char *readbackbuff = NULL; | ||
307 | unsigned int len = u32FirmwareLength; | ||
308 | int retval = STATUS_SUCCESS; | ||
309 | |||
310 | buff=(unsigned char *)kzalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_KERNEL); | ||
311 | if(NULL == buff) | ||
312 | return -ENOMEM; | ||
313 | readbackbuff = (unsigned char *)kzalloc(MAX_TRANSFER_CTRL_BYTE_USB, | ||
314 | GFP_KERNEL); | ||
315 | if(NULL == readbackbuff) | ||
316 | { | ||
317 | bcm_kfree(buff); | ||
318 | return -ENOMEM; | ||
319 | } | ||
320 | while (u32FirmwareLength && !retval) | ||
321 | { | ||
322 | len = MIN_VAL (u32FirmwareLength, MAX_TRANSFER_CTRL_BYTE_USB); | ||
323 | |||
324 | /* read from the appl buff and then read from the target, compare */ | ||
325 | if(STATUS_SUCCESS != (retval = copy_from_user(buff, | ||
326 | (unsigned char *)mappedbuffer, len))) | ||
327 | { | ||
328 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "copy_from_user failed\n"); | ||
329 | break; | ||
330 | } | ||
331 | retval = rdm (Adapter, u32StartingAddress, readbackbuff, len); | ||
332 | if(retval) | ||
333 | { | ||
334 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "rdm failed\n"); | ||
335 | break; | ||
336 | } | ||
337 | |||
338 | if (STATUS_SUCCESS != | ||
339 | (retval = bcm_compare_buff_contents (readbackbuff, buff, len))) | ||
340 | { | ||
341 | break; | ||
342 | } | ||
343 | u32StartingAddress += len; | ||
344 | u32FirmwareLength -= len; | ||
345 | mappedbuffer +=len; | ||
346 | }/* end of while (u32FirmwareLength && !retval) */ | ||
347 | bcm_kfree(buff); | ||
348 | bcm_kfree(readbackbuff); | ||
349 | return retval; | ||
350 | } | ||
351 | #endif | ||
352 | int bcm_ioctl_fw_download(PMINI_ADAPTER Adapter, FIRMWARE_INFO *psFwInfo) | ||
353 | { | ||
354 | int retval = STATUS_SUCCESS; | ||
355 | PUCHAR buff = NULL; | ||
356 | |||
357 | /* Config File is needed for the Driver to download the Config file and | ||
358 | Firmware. Check for the Config file to be first to be sent from the | ||
359 | Application | ||
360 | */ | ||
361 | atomic_set (&Adapter->uiMBupdate, FALSE); | ||
362 | if(!Adapter->bCfgDownloaded && | ||
363 | psFwInfo->u32StartingAddress != CONFIG_BEGIN_ADDR) | ||
364 | { | ||
365 | /*Can't Download Firmware.*/ | ||
366 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Download the config File first\n"); | ||
367 | return -EINVAL; | ||
368 | } | ||
369 | |||
370 | /* If Config File, Finish the DDR Settings and then Download CFG File */ | ||
371 | if(psFwInfo->u32StartingAddress == CONFIG_BEGIN_ADDR) | ||
372 | { | ||
373 | retval = bcm_download_config_file (Adapter, psFwInfo); | ||
374 | } | ||
375 | else | ||
376 | { | ||
377 | |||
378 | buff = (PUCHAR)kzalloc(psFwInfo->u32FirmwareLength,GFP_KERNEL); | ||
379 | if(buff==NULL) | ||
380 | { | ||
381 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Failed in allocation memory"); | ||
382 | return -ENOMEM; | ||
383 | } | ||
384 | retval = copy_from_user(buff,(PUCHAR)psFwInfo->pvMappedFirmwareAddress, psFwInfo->u32FirmwareLength); | ||
385 | if(retval != STATUS_SUCCESS) | ||
386 | { | ||
387 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "copying buffer from user space failed"); | ||
388 | goto error ; | ||
389 | } | ||
390 | |||
391 | #if 0 | ||
392 | retval = bcm_download_buffer(Adapter, | ||
393 | (unsigned char *)psFwInfo->pvMappedFirmwareAddress, | ||
394 | psFwInfo->u32FirmwareLength, psFwInfo->u32StartingAddress); | ||
395 | if(retval != STATUS_SUCCESS) | ||
396 | { | ||
397 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "User space buffer download fails...."); | ||
398 | } | ||
399 | retval = bcm_buffer_readback (Adapter, | ||
400 | (unsigned char *)psFwInfo->pvMappedFirmwareAddress, | ||
401 | psFwInfo->u32FirmwareLength, psFwInfo->u32StartingAddress); | ||
402 | |||
403 | if(retval != STATUS_SUCCESS) | ||
404 | { | ||
405 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "read back verifier failed ...."); | ||
406 | } | ||
407 | #endif | ||
408 | retval = buffDnldVerify(Adapter, | ||
409 | buff, | ||
410 | psFwInfo->u32FirmwareLength, | ||
411 | psFwInfo->u32StartingAddress); | ||
412 | if(retval != STATUS_SUCCESS) | ||
413 | { | ||
414 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"f/w download failed status :%d", retval); | ||
415 | goto error; | ||
416 | } | ||
417 | } | ||
418 | error: | ||
419 | bcm_kfree(buff); | ||
420 | return retval; | ||
421 | } | ||
422 | |||
423 | static INT buffDnld(PMINI_ADAPTER Adapter, PUCHAR mappedbuffer, UINT u32FirmwareLength, | ||
424 | ULONG u32StartingAddress) | ||
425 | { | ||
426 | |||
427 | unsigned int len = 0; | ||
428 | int retval = STATUS_SUCCESS; | ||
429 | len = u32FirmwareLength; | ||
430 | |||
431 | while(u32FirmwareLength) | ||
432 | { | ||
433 | len = MIN_VAL (u32FirmwareLength, MAX_TRANSFER_CTRL_BYTE_USB); | ||
434 | retval = wrm (Adapter, u32StartingAddress, mappedbuffer, len); | ||
435 | if(retval) | ||
436 | { | ||
437 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "wrm failed with status :%d", retval); | ||
438 | break; | ||
439 | } | ||
440 | u32StartingAddress += len; | ||
441 | u32FirmwareLength -= len; | ||
442 | mappedbuffer +=len; | ||
443 | } | ||
444 | return retval; | ||
445 | |||
446 | } | ||
447 | |||
448 | static INT buffRdbkVerify(PMINI_ADAPTER Adapter, | ||
449 | PUCHAR mappedbuffer, UINT u32FirmwareLength, | ||
450 | ULONG u32StartingAddress) | ||
451 | { | ||
452 | PUCHAR readbackbuff = NULL; | ||
453 | UINT len = u32FirmwareLength; | ||
454 | INT retval = STATUS_SUCCESS; | ||
455 | |||
456 | readbackbuff = (PUCHAR)kzalloc(MAX_TRANSFER_CTRL_BYTE_USB,GFP_KERNEL); | ||
457 | if(NULL == readbackbuff) | ||
458 | { | ||
459 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "MEMORY ALLOCATION FAILED"); | ||
460 | return -ENOMEM; | ||
461 | } | ||
462 | while (u32FirmwareLength && !retval) | ||
463 | { | ||
464 | |||
465 | len = MIN_VAL (u32FirmwareLength, MAX_TRANSFER_CTRL_BYTE_USB); | ||
466 | |||
467 | retval = rdm (Adapter, u32StartingAddress, readbackbuff, len); | ||
468 | if(retval) | ||
469 | { | ||
470 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "rdm failed with status %d" ,retval); | ||
471 | break; | ||
472 | } | ||
473 | |||
474 | if (STATUS_SUCCESS != (retval = bcm_compare_buff_contents (readbackbuff, mappedbuffer, len))) | ||
475 | { | ||
476 | break; | ||
477 | } | ||
478 | u32StartingAddress += len; | ||
479 | u32FirmwareLength -= len; | ||
480 | mappedbuffer +=len; | ||
481 | }/* end of while (u32FirmwareLength && !retval) */ | ||
482 | bcm_kfree(readbackbuff); | ||
483 | return retval; | ||
484 | } | ||
485 | |||
486 | INT buffDnldVerify(PMINI_ADAPTER Adapter, unsigned char *mappedbuffer, unsigned int u32FirmwareLength, | ||
487 | unsigned long u32StartingAddress) | ||
488 | { | ||
489 | INT status = STATUS_SUCCESS; | ||
490 | |||
491 | status = buffDnld(Adapter,mappedbuffer,u32FirmwareLength,u32StartingAddress); | ||
492 | if(status != STATUS_SUCCESS) | ||
493 | { | ||
494 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Buffer download failed"); | ||
495 | goto error; | ||
496 | } | ||
497 | |||
498 | status= buffRdbkVerify(Adapter,mappedbuffer,u32FirmwareLength,u32StartingAddress); | ||
499 | if(status != STATUS_SUCCESS) | ||
500 | { | ||
501 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Buffer readback verifier failed"); | ||
502 | goto error; | ||
503 | } | ||
504 | error: | ||
505 | return status; | ||
506 | } | ||
507 | |||
508 | #endif | ||
509 | |||
diff --git a/drivers/staging/bcm/InterfaceIdleMode.c b/drivers/staging/bcm/InterfaceIdleMode.c new file mode 100644 index 00000000000..d99fc7c31a1 --- /dev/null +++ b/drivers/staging/bcm/InterfaceIdleMode.c | |||
@@ -0,0 +1,318 @@ | |||
1 | #include "headers.h" | ||
2 | |||
3 | /* | ||
4 | Function: InterfaceIdleModeWakeup | ||
5 | |||
6 | Description: This is the hardware specific Function for waking up HW device from Idle mode. | ||
7 | A software abort pattern is written to the device to wake it and necessary power state | ||
8 | transitions from host are performed here. | ||
9 | |||
10 | Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context | ||
11 | |||
12 | |||
13 | Return: BCM_STATUS_SUCCESS - If Wakeup of the HW Interface was successful. | ||
14 | Other - If an error occured. | ||
15 | */ | ||
16 | |||
17 | |||
18 | /* | ||
19 | Function: InterfaceIdleModeRespond | ||
20 | |||
21 | Description: This is the hardware specific Function for responding to Idle mode request from target. | ||
22 | Necessary power state transitions from host for idle mode or other device specific | ||
23 | initializations are performed here. | ||
24 | |||
25 | Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context | ||
26 | |||
27 | |||
28 | Return: BCM_STATUS_SUCCESS - If Idle mode response related HW configuration was successful. | ||
29 | Other - If an error occured. | ||
30 | */ | ||
31 | |||
32 | /* | ||
33 | "dmem bfc02f00 100" tells how many time device went in Idle mode. | ||
34 | this value will be at address bfc02fa4.just before value d0ea1dle. | ||
35 | |||
36 | Set time value by writing at bfc02f98 7d0 | ||
37 | |||
38 | checking the Ack timer expire on kannon by running command | ||
39 | d qcslog .. if it shows e means host has not send response to f/w with in 200 ms. Response should be | ||
40 | send to f/w with in 200 ms after the Idle/Shutdown req issued | ||
41 | |||
42 | */ | ||
43 | |||
44 | |||
45 | int InterfaceIdleModeRespond(PMINI_ADAPTER Adapter,int* puiBuffer) | ||
46 | { | ||
47 | int status = STATUS_SUCCESS; | ||
48 | unsigned int uiRegRead = 0; | ||
49 | |||
50 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"SubType of Message :0x%X", ntohl(*puiBuffer)); | ||
51 | |||
52 | if(ntohl(*puiBuffer) == GO_TO_IDLE_MODE_PAYLOAD) | ||
53 | { | ||
54 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL," Got GO_TO_IDLE_MODE_PAYLOAD(210) Msg Subtype"); | ||
55 | if(ntohl(*(puiBuffer+1)) == 0 ) | ||
56 | { | ||
57 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"Got IDLE MODE WAKE UP Response From F/W"); | ||
58 | |||
59 | status = wrmalt (Adapter,SW_ABORT_IDLEMODE_LOC, &uiRegRead, sizeof(uiRegRead)); | ||
60 | if(status) | ||
61 | { | ||
62 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "wrm failed while clearing Idle Mode Reg"); | ||
63 | return status; | ||
64 | } | ||
65 | |||
66 | if(Adapter->ulPowerSaveMode == DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING) | ||
67 | { | ||
68 | uiRegRead = 0x00000000 ; | ||
69 | status = wrmalt (Adapter,DEBUG_INTERRUPT_GENERATOR_REGISTOR, &uiRegRead, sizeof(uiRegRead)); | ||
70 | if(status) | ||
71 | { | ||
72 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "wrm failed while clearing Idle Mode Reg"); | ||
73 | return status; | ||
74 | } | ||
75 | } | ||
76 | //Below Register should not br read in case of Manual and Protocol Idle mode. | ||
77 | else if(Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE) | ||
78 | { | ||
79 | //clear on read Register | ||
80 | status = rdmalt(Adapter, DEVICE_INT_OUT_EP_REG0, &uiRegRead, sizeof(uiRegRead)); | ||
81 | if(status) | ||
82 | { | ||
83 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "rdm failed while clearing H/W Abort Reg0"); | ||
84 | return status; | ||
85 | } | ||
86 | //clear on read Register | ||
87 | status = rdmalt (Adapter, DEVICE_INT_OUT_EP_REG1, &uiRegRead, sizeof(uiRegRead)); | ||
88 | if(status) | ||
89 | { | ||
90 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "rdm failed while clearing H/W Abort Reg1"); | ||
91 | return status; | ||
92 | } | ||
93 | } | ||
94 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "Device Up from Idle Mode"); | ||
95 | |||
96 | // Set Idle Mode Flag to False and Clear IdleMode reg. | ||
97 | Adapter->IdleMode = FALSE; | ||
98 | Adapter->bTriedToWakeUpFromlowPowerMode = FALSE; | ||
99 | |||
100 | wake_up(&Adapter->lowpower_mode_wait_queue); | ||
101 | #if 0 | ||
102 | if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) | ||
103 | { | ||
104 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"LED Thread is Running. Hence Setting the LED Event as IDLEMODE_EXIT"); | ||
105 | Adapter->DriverState = IDLEMODE_EXIT; | ||
106 | wake_up(&Adapter->LEDInfo.notify_led_event); | ||
107 | } | ||
108 | #endif | ||
109 | |||
110 | } | ||
111 | else | ||
112 | { | ||
113 | if(TRUE == Adapter->IdleMode) | ||
114 | { | ||
115 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"Device is already in Idle mode...."); | ||
116 | return status ; | ||
117 | } | ||
118 | |||
119 | uiRegRead = 0; | ||
120 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "Got Req from F/W to go in IDLE mode \n"); | ||
121 | |||
122 | if (Adapter->chip_id== BCS220_2 || | ||
123 | Adapter->chip_id == BCS220_2BC || | ||
124 | Adapter->chip_id== BCS250_BC || | ||
125 | Adapter->chip_id== BCS220_3) | ||
126 | { | ||
127 | |||
128 | status = rdmalt(Adapter, HPM_CONFIG_MSW, &uiRegRead, sizeof(uiRegRead)); | ||
129 | if(status) | ||
130 | { | ||
131 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "rdm failed while Reading HPM_CONFIG_LDO145 Reg 0\n"); | ||
132 | return status; | ||
133 | } | ||
134 | |||
135 | |||
136 | uiRegRead |= (1<<17); | ||
137 | |||
138 | status = wrmalt (Adapter,HPM_CONFIG_MSW, &uiRegRead, sizeof(uiRegRead)); | ||
139 | if(status) | ||
140 | { | ||
141 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "wrm failed while clearing Idle Mode Reg\n"); | ||
142 | return status; | ||
143 | } | ||
144 | |||
145 | } | ||
146 | SendIdleModeResponse(Adapter); | ||
147 | } | ||
148 | } | ||
149 | else if(ntohl(*puiBuffer) == IDLE_MODE_SF_UPDATE_MSG) | ||
150 | { | ||
151 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "OverRiding Service Flow Params"); | ||
152 | OverrideServiceFlowParams(Adapter,puiBuffer); | ||
153 | } | ||
154 | return status; | ||
155 | } | ||
156 | |||
157 | |||
158 | VOID InterfaceWriteIdleModeWakePattern(PMINI_ADAPTER Adapter) | ||
159 | { | ||
160 | /* BeceemWriteMemoryUshort(Adapter, Host2CPU_Mailbox_Low, 0x1d1e); | ||
161 | BeceemWriteMemoryUshort(Adapter, Host2CPU_Mailbox_Low, 0x1d1e); | ||
162 | BeceemWriteMemoryUshort(Adapter, Host2CPU_Mailbox_Upp, 0xd0ea); | ||
163 | BeceemWriteMemoryUshort(Adapter, Host2CPU_Mailbox_Upp, 0xd0ea);*/ | ||
164 | return; | ||
165 | } | ||
166 | |||
167 | int InterfaceAbortIdlemode(PMINI_ADAPTER Adapter, unsigned int Pattern) | ||
168 | { | ||
169 | int status = STATUS_SUCCESS; | ||
170 | unsigned int value; | ||
171 | unsigned int chip_id ; | ||
172 | unsigned long timeout = 0 ,itr = 0; | ||
173 | |||
174 | int lenwritten = 0; | ||
175 | unsigned char aucAbortPattern[8]={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; | ||
176 | PS_INTERFACE_ADAPTER psInterfaceAdapter = Adapter->pvInterfaceAdapter; | ||
177 | |||
178 | //Abort Bus suspend if its already suspended | ||
179 | if((TRUE == psInterfaceAdapter->bSuspended) && (TRUE == Adapter->bDoSuspend)) | ||
180 | { | ||
181 | status = usb_autopm_get_interface(psInterfaceAdapter->interface); | ||
182 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"Bus got wakeup..Aborting Idle mode... status:%d \n",status); | ||
183 | |||
184 | } | ||
185 | |||
186 | if((Adapter->ulPowerSaveMode == DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING) | ||
187 | || | ||
188 | (Adapter->ulPowerSaveMode == DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE)) | ||
189 | { | ||
190 | //write the SW abort pattern. | ||
191 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "Writing pattern<%d> to SW_ABORT_IDLEMODE_LOC\n", Pattern); | ||
192 | status = wrmalt(Adapter,SW_ABORT_IDLEMODE_LOC, &Pattern, sizeof(Pattern)); | ||
193 | if(status) | ||
194 | { | ||
195 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"WRM to Register SW_ABORT_IDLEMODE_LOC failed.."); | ||
196 | return status; | ||
197 | } | ||
198 | } | ||
199 | |||
200 | if(Adapter->ulPowerSaveMode == DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING) | ||
201 | { | ||
202 | value = 0x80000000; | ||
203 | status = wrmalt(Adapter,DEBUG_INTERRUPT_GENERATOR_REGISTOR, &value, sizeof(value)); | ||
204 | if(status) | ||
205 | { | ||
206 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"WRM to DEBUG_INTERRUPT_GENERATOR_REGISTOR Register failed"); | ||
207 | return status; | ||
208 | } | ||
209 | } | ||
210 | else if(Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE) | ||
211 | { | ||
212 | /* | ||
213 | * Get a Interrupt Out URB and send 8 Bytes Down | ||
214 | * To be Done in Thread Context. | ||
215 | * Not using Asynchronous Mechanism. | ||
216 | */ | ||
217 | status = usb_interrupt_msg (psInterfaceAdapter->udev, | ||
218 | usb_sndintpipe(psInterfaceAdapter->udev, | ||
219 | psInterfaceAdapter->sIntrOut.int_out_endpointAddr), | ||
220 | aucAbortPattern, | ||
221 | 8, | ||
222 | &lenwritten, | ||
223 | 5000); | ||
224 | if(status) | ||
225 | { | ||
226 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "Sending Abort pattern down fails with status:%d..\n",status); | ||
227 | return status; | ||
228 | } | ||
229 | else | ||
230 | { | ||
231 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "NOB Sent down :%d", lenwritten); | ||
232 | } | ||
233 | |||
234 | //mdelay(25); | ||
235 | |||
236 | timeout= jiffies + msecs_to_jiffies(50) ; | ||
237 | while( timeout > jiffies ) | ||
238 | { | ||
239 | itr++ ; | ||
240 | rdmalt(Adapter, CHIP_ID_REG, &chip_id, sizeof(UINT)); | ||
241 | if(0xbece3200==(chip_id&~(0xF0))) | ||
242 | { | ||
243 | chip_id = chip_id&~(0xF0); | ||
244 | } | ||
245 | if(chip_id == Adapter->chip_id) | ||
246 | break; | ||
247 | } | ||
248 | if(timeout < jiffies ) | ||
249 | { | ||
250 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"Not able to read chip-id even after 25 msec"); | ||
251 | } | ||
252 | else | ||
253 | { | ||
254 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"Number of completed iteration to read chip-id :%lu", itr); | ||
255 | } | ||
256 | |||
257 | status = wrmalt(Adapter,SW_ABORT_IDLEMODE_LOC, &Pattern, sizeof(status)); | ||
258 | if(status) | ||
259 | { | ||
260 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"WRM to Register SW_ABORT_IDLEMODE_LOC failed.."); | ||
261 | return status; | ||
262 | } | ||
263 | } | ||
264 | return status; | ||
265 | } | ||
266 | int InterfaceIdleModeWakeup(PMINI_ADAPTER Adapter) | ||
267 | { | ||
268 | ULONG Status = 0; | ||
269 | if(Adapter->bTriedToWakeUpFromlowPowerMode) | ||
270 | { | ||
271 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "Wake up already attempted.. ignoring\n"); | ||
272 | } | ||
273 | else | ||
274 | { | ||
275 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"Writing Low Power Mode Abort pattern to the Device\n"); | ||
276 | Adapter->bTriedToWakeUpFromlowPowerMode = TRUE; | ||
277 | InterfaceAbortIdlemode(Adapter, Adapter->usIdleModePattern); | ||
278 | |||
279 | } | ||
280 | return Status; | ||
281 | } | ||
282 | |||
283 | void InterfaceHandleShutdownModeWakeup(PMINI_ADAPTER Adapter) | ||
284 | { | ||
285 | unsigned int uiRegVal = 0; | ||
286 | INT Status = 0; | ||
287 | if(Adapter->ulPowerSaveMode == DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING) | ||
288 | { | ||
289 | // clear idlemode interrupt. | ||
290 | uiRegVal = 0; | ||
291 | Status =wrmalt(Adapter,DEBUG_INTERRUPT_GENERATOR_REGISTOR, &uiRegVal, sizeof(uiRegVal)); | ||
292 | if(Status) | ||
293 | { | ||
294 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"WRM to DEBUG_INTERRUPT_GENERATOR_REGISTOR Failed with err :%d", Status); | ||
295 | return; | ||
296 | } | ||
297 | } | ||
298 | |||
299 | else | ||
300 | { | ||
301 | |||
302 | //clear Interrupt EP registers. | ||
303 | Status = rdmalt(Adapter,DEVICE_INT_OUT_EP_REG0, &uiRegVal, sizeof(uiRegVal)); | ||
304 | if(Status) | ||
305 | { | ||
306 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"RDM of DEVICE_INT_OUT_EP_REG0 failed with Err :%d", Status); | ||
307 | return; | ||
308 | } | ||
309 | |||
310 | Status = rdmalt(Adapter,DEVICE_INT_OUT_EP_REG1, &uiRegVal, sizeof(uiRegVal)); | ||
311 | if(Status) | ||
312 | { | ||
313 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"RDM of DEVICE_INT_OUT_EP_REG1 failed with Err :%d", Status); | ||
314 | return; | ||
315 | } | ||
316 | } | ||
317 | } | ||
318 | |||
diff --git a/drivers/staging/bcm/InterfaceIdleMode.h b/drivers/staging/bcm/InterfaceIdleMode.h new file mode 100644 index 00000000000..f87c132989f --- /dev/null +++ b/drivers/staging/bcm/InterfaceIdleMode.h | |||
@@ -0,0 +1,16 @@ | |||
1 | #ifndef _INTERFACE_IDLEMODE_H | ||
2 | #define _INTERFACE_IDLEMODE_H | ||
3 | |||
4 | INT InterfaceIdleModeWakeup(PMINI_ADAPTER Adapter); | ||
5 | |||
6 | INT InterfaceIdleModeRespond(PMINI_ADAPTER Adapter,PINT puiBuffer); | ||
7 | |||
8 | VOID InterfaceWriteIdleModeWakePattern(PMINI_ADAPTER Adapter); | ||
9 | |||
10 | INT InterfaceAbortIdlemode(PMINI_ADAPTER Adapter, unsigned int Pattern); | ||
11 | |||
12 | INT InterfaceWakeUp(PMINI_ADAPTER Adapter); | ||
13 | |||
14 | VOID InterfaceHandleShutdownModeWakeup(PMINI_ADAPTER Adapter); | ||
15 | #endif | ||
16 | |||
diff --git a/drivers/staging/bcm/InterfaceInit.c b/drivers/staging/bcm/InterfaceInit.c new file mode 100644 index 00000000000..e06f168a52b --- /dev/null +++ b/drivers/staging/bcm/InterfaceInit.c | |||
@@ -0,0 +1,868 @@ | |||
1 | #include "headers.h" | ||
2 | |||
3 | static struct usb_device_id InterfaceUsbtable[] = { | ||
4 | { USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_T3) }, | ||
5 | { USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_T3B) }, | ||
6 | { USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_T3L) }, | ||
7 | { USB_DEVICE(BCM_USB_VENDOR_ID_ZTE, BCM_USB_PRODUCT_ID_226) }, | ||
8 | { USB_DEVICE(BCM_USB_VENDOR_ID_FOXCONN, BCM_USB_PRODUCT_ID_1901) }, | ||
9 | {} | ||
10 | }; | ||
11 | |||
12 | VOID InterfaceAdapterFree(PS_INTERFACE_ADAPTER psIntfAdapter) | ||
13 | { | ||
14 | INT i = 0; | ||
15 | // Wake up the wait_queue... | ||
16 | if(psIntfAdapter->psAdapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) | ||
17 | { | ||
18 | psIntfAdapter->psAdapter->DriverState = DRIVER_HALT; | ||
19 | wake_up(&psIntfAdapter->psAdapter->LEDInfo.notify_led_event); | ||
20 | } | ||
21 | reset_card_proc(psIntfAdapter->psAdapter); | ||
22 | |||
23 | //worst case time taken by the RDM/WRM will be 5 sec. will check after every 100 ms | ||
24 | //to accertain the device is not being accessed. After this No RDM/WRM should be made. | ||
25 | while(psIntfAdapter->psAdapter->DeviceAccess) | ||
26 | { | ||
27 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"Device is being Accessed \n"); | ||
28 | msleep(100); | ||
29 | } | ||
30 | /* Free interrupt URB */ | ||
31 | //psIntfAdapter->psAdapter->device_removed = TRUE; | ||
32 | if(psIntfAdapter->psInterruptUrb) | ||
33 | { | ||
34 | usb_free_urb(psIntfAdapter->psInterruptUrb); | ||
35 | } | ||
36 | |||
37 | /* Free transmit URBs */ | ||
38 | for(i = 0; i < MAXIMUM_USB_TCB; i++) | ||
39 | { | ||
40 | if(psIntfAdapter->asUsbTcb[i].urb != NULL) | ||
41 | { | ||
42 | usb_free_urb(psIntfAdapter->asUsbTcb[i].urb); | ||
43 | psIntfAdapter->asUsbTcb[i].urb = NULL; | ||
44 | } | ||
45 | } | ||
46 | /* Free receive URB and buffers */ | ||
47 | for(i = 0; i < MAXIMUM_USB_RCB; i++) | ||
48 | { | ||
49 | if (psIntfAdapter->asUsbRcb[i].urb != NULL) | ||
50 | { | ||
51 | bcm_kfree(psIntfAdapter->asUsbRcb[i].urb->transfer_buffer); | ||
52 | usb_free_urb(psIntfAdapter->asUsbRcb[i].urb); | ||
53 | psIntfAdapter->asUsbRcb[i].urb = NULL; | ||
54 | } | ||
55 | } | ||
56 | AdapterFree(psIntfAdapter->psAdapter); | ||
57 | } | ||
58 | |||
59 | |||
60 | |||
61 | static int usbbcm_open(struct inode *inode, struct file *file) | ||
62 | { | ||
63 | return 0; | ||
64 | } | ||
65 | |||
66 | static int usbbcm_release(struct inode *inode, struct file *file) | ||
67 | { | ||
68 | return 0; | ||
69 | } | ||
70 | |||
71 | static ssize_t usbbcm_read(struct file *file, char *buffer, size_t count, loff_t *ppos) | ||
72 | { | ||
73 | return 0; | ||
74 | } | ||
75 | |||
76 | static ssize_t usbbcm_write(struct file *file, const char *user_buffer, size_t count, loff_t *ppos) | ||
77 | { | ||
78 | return 0; | ||
79 | } | ||
80 | |||
81 | |||
82 | VOID ConfigureEndPointTypesThroughEEPROM(PMINI_ADAPTER Adapter) | ||
83 | { | ||
84 | ULONG ulReg = 0; | ||
85 | |||
86 | // Program EP2 MAX_PKT_SIZE | ||
87 | ulReg = ntohl(EP2_MPS_REG); | ||
88 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x128,4,TRUE); | ||
89 | ulReg = ntohl(EP2_MPS); | ||
90 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x12C,4,TRUE); | ||
91 | |||
92 | ulReg = ntohl(EP2_CFG_REG); | ||
93 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x132,4,TRUE); | ||
94 | if(((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter))->bHighSpeedDevice == TRUE) | ||
95 | { | ||
96 | ulReg = ntohl(EP2_CFG_INT); | ||
97 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x136,4,TRUE); | ||
98 | } | ||
99 | else | ||
100 | { | ||
101 | // USE BULK EP as TX in FS mode. | ||
102 | ulReg = ntohl(EP2_CFG_BULK); | ||
103 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x136,4,TRUE); | ||
104 | } | ||
105 | |||
106 | |||
107 | // Program EP4 MAX_PKT_SIZE. | ||
108 | ulReg = ntohl(EP4_MPS_REG); | ||
109 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x13C,4,TRUE); | ||
110 | ulReg = ntohl(EP4_MPS); | ||
111 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x140,4,TRUE); | ||
112 | |||
113 | // Program TX EP as interrupt (Alternate Setting) | ||
114 | if( rdmalt(Adapter,0x0F0110F8, (PUINT)&ulReg,4)) | ||
115 | { | ||
116 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "reading of Tx EP is failing"); | ||
117 | return ; | ||
118 | } | ||
119 | ulReg |= 0x6; | ||
120 | |||
121 | ulReg = ntohl(ulReg); | ||
122 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x1CC,4,TRUE); | ||
123 | |||
124 | ulReg = ntohl(EP4_CFG_REG); | ||
125 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x1C8,4,TRUE); | ||
126 | // Program ISOCHRONOUS EP size to zero. | ||
127 | ulReg = ntohl(ISO_MPS_REG); | ||
128 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x1D2,4,TRUE); | ||
129 | ulReg = ntohl(ISO_MPS); | ||
130 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x1D6,4,TRUE); | ||
131 | |||
132 | // Update EEPROM Version. | ||
133 | // Read 4 bytes from 508 and modify 511 and 510. | ||
134 | // | ||
135 | ReadBeceemEEPROM(Adapter,0x1FC,(PUINT)&ulReg); | ||
136 | ulReg &= 0x0101FFFF; | ||
137 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x1FC,4,TRUE); | ||
138 | // | ||
139 | //Update length field if required. Also make the string NULL terminated. | ||
140 | // | ||
141 | ReadBeceemEEPROM(Adapter,0xA8,(PUINT)&ulReg); | ||
142 | if((ulReg&0x00FF0000)>>16 > 0x30) | ||
143 | { | ||
144 | ulReg = (ulReg&0xFF00FFFF)|(0x30<<16); | ||
145 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0xA8,4,TRUE); | ||
146 | } | ||
147 | ReadBeceemEEPROM(Adapter,0x148,(PUINT)&ulReg); | ||
148 | if((ulReg&0x00FF0000)>>16 > 0x30) | ||
149 | { | ||
150 | ulReg = (ulReg&0xFF00FFFF)|(0x30<<16); | ||
151 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x148,4,TRUE); | ||
152 | } | ||
153 | ulReg = 0; | ||
154 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x122,4,TRUE); | ||
155 | ulReg = 0; | ||
156 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x1C2,4,TRUE); | ||
157 | |||
158 | } | ||
159 | |||
160 | static struct file_operations usbbcm_fops = { | ||
161 | .open = usbbcm_open, | ||
162 | .release = usbbcm_release, | ||
163 | .read = usbbcm_read, | ||
164 | .write = usbbcm_write, | ||
165 | .owner = THIS_MODULE, | ||
166 | }; | ||
167 | |||
168 | static struct usb_class_driver usbbcm_class = { | ||
169 | .name = "usbbcm", | ||
170 | .fops = &usbbcm_fops, | ||
171 | .minor_base = BCM_USB_MINOR_BASE, | ||
172 | }; | ||
173 | |||
174 | static int | ||
175 | usbbcm_device_probe(struct usb_interface *intf, const struct usb_device_id *id) | ||
176 | { | ||
177 | int retval =0 ; | ||
178 | PMINI_ADAPTER psAdapter = NULL; | ||
179 | PS_INTERFACE_ADAPTER psIntfAdapter = NULL; | ||
180 | struct usb_device *udev = NULL; | ||
181 | |||
182 | // BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Usbbcm probe!!"); | ||
183 | if((intf == NULL) || (id == NULL)) | ||
184 | { | ||
185 | // BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "intf or id is NULL"); | ||
186 | return -EINVAL; | ||
187 | } | ||
188 | |||
189 | /* Allocate Adapter structure */ | ||
190 | if((psAdapter = kmalloc(sizeof(MINI_ADAPTER), GFP_KERNEL)) == NULL) | ||
191 | { | ||
192 | //BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0, "Out of memory"); | ||
193 | return -ENOMEM; | ||
194 | } | ||
195 | |||
196 | memset(psAdapter, 0, sizeof(MINI_ADAPTER)); | ||
197 | |||
198 | /* Init default driver debug state */ | ||
199 | |||
200 | psAdapter->stDebugState.debug_level = DBG_LVL_CURR; | ||
201 | psAdapter->stDebugState.type = DBG_TYPE_INITEXIT; | ||
202 | memset (psAdapter->stDebugState.subtype, 0, sizeof (psAdapter->stDebugState.subtype)); | ||
203 | |||
204 | /* Technically, one can start using BCM_DEBUG_PRINT after this point. | ||
205 | * However, realize that by default the Type/Subtype bitmaps are all zero now; | ||
206 | * so no prints will actually appear until the TestApp turns on debug paths via | ||
207 | * the ioctl(); so practically speaking, in early init, no logging happens. | ||
208 | * | ||
209 | * A solution (used below): we explicitly set the bitmaps to 1 for Type=DBG_TYPE_INITEXIT | ||
210 | * and ALL subtype's of the same. Now all bcm debug statements get logged, enabling debug | ||
211 | * during early init. | ||
212 | * Further, we turn this OFF once init_module() completes. | ||
213 | */ | ||
214 | |||
215 | psAdapter->stDebugState.subtype[DBG_TYPE_INITEXIT] = 0xff; | ||
216 | BCM_SHOW_DEBUG_BITMAP(psAdapter); | ||
217 | |||
218 | retval = InitAdapter(psAdapter); | ||
219 | if(retval) | ||
220 | { | ||
221 | BCM_DEBUG_PRINT (psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "InitAdapter Failed\n"); | ||
222 | AdapterFree(psAdapter); | ||
223 | return retval; | ||
224 | } | ||
225 | |||
226 | /* Allocate interface adapter structure */ | ||
227 | if((psAdapter->pvInterfaceAdapter = | ||
228 | kmalloc(sizeof(S_INTERFACE_ADAPTER), GFP_KERNEL)) == NULL) | ||
229 | { | ||
230 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0, "Out of memory"); | ||
231 | AdapterFree (psAdapter); | ||
232 | return -ENOMEM; | ||
233 | } | ||
234 | memset(psAdapter->pvInterfaceAdapter, 0, sizeof(S_INTERFACE_ADAPTER)); | ||
235 | |||
236 | psIntfAdapter = InterfaceAdapterGet(psAdapter); | ||
237 | psIntfAdapter->psAdapter = psAdapter; | ||
238 | |||
239 | /* Store usb interface in Interface Adapter */ | ||
240 | psIntfAdapter->interface = intf; | ||
241 | usb_set_intfdata(intf, psIntfAdapter); | ||
242 | |||
243 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "psIntfAdapter 0x%x",(unsigned int)psIntfAdapter); | ||
244 | retval = InterfaceAdapterInit(psIntfAdapter); | ||
245 | if(retval) | ||
246 | { | ||
247 | /* If the Firmware/Cfg File is not present | ||
248 | * then return success, let the application | ||
249 | * download the files. | ||
250 | */ | ||
251 | if(-ENOENT == retval){ | ||
252 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "File Not Found, Use App to Download\n"); | ||
253 | return STATUS_SUCCESS; | ||
254 | } | ||
255 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "InterfaceAdapterInit Failed \n"); | ||
256 | usb_set_intfdata(intf, NULL); | ||
257 | udev = interface_to_usbdev (intf); | ||
258 | usb_put_dev(udev); | ||
259 | if(psAdapter->bUsbClassDriverRegistered == TRUE) | ||
260 | usb_deregister_dev (intf, &usbbcm_class); | ||
261 | InterfaceAdapterFree(psIntfAdapter); | ||
262 | return retval ; | ||
263 | } | ||
264 | if(psAdapter->chip_id > T3) | ||
265 | { | ||
266 | uint32_t uiNackZeroLengthInt=4; | ||
267 | if(wrmalt(psAdapter, DISABLE_USB_ZERO_LEN_INT, &uiNackZeroLengthInt, sizeof(uiNackZeroLengthInt))) | ||
268 | { | ||
269 | return -EIO;; | ||
270 | } | ||
271 | } | ||
272 | |||
273 | udev = interface_to_usbdev (intf); | ||
274 | /* Check whether the USB-Device Supports remote Wake-Up */ | ||
275 | if(USB_CONFIG_ATT_WAKEUP & udev->actconfig->desc.bmAttributes) | ||
276 | { | ||
277 | /* If Suspend then only support dynamic suspend */ | ||
278 | if(psAdapter->bDoSuspend) | ||
279 | { | ||
280 | udev->autosuspend_delay = 0; | ||
281 | intf->needs_remote_wakeup = 1; | ||
282 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35) | ||
283 | udev->autosuspend_disabled = 0; | ||
284 | #else | ||
285 | usb_enable_autosuspend(udev); | ||
286 | #endif | ||
287 | device_init_wakeup(&intf->dev,1); | ||
288 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 32) | ||
289 | usb_autopm_disable(intf); | ||
290 | #endif | ||
291 | INIT_WORK(&psIntfAdapter->usbSuspendWork, putUsbSuspend); | ||
292 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Enabling USB Auto-Suspend\n"); | ||
293 | } | ||
294 | else | ||
295 | { | ||
296 | intf->needs_remote_wakeup = 0; | ||
297 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35) | ||
298 | udev->autosuspend_disabled = 1; | ||
299 | #else | ||
300 | usb_disable_autosuspend(udev); | ||
301 | #endif | ||
302 | } | ||
303 | } | ||
304 | |||
305 | psAdapter->stDebugState.subtype[DBG_TYPE_INITEXIT] = 0x0; | ||
306 | return retval; | ||
307 | } | ||
308 | |||
309 | static void usbbcm_disconnect (struct usb_interface *intf) | ||
310 | { | ||
311 | PS_INTERFACE_ADAPTER psIntfAdapter = NULL; | ||
312 | PMINI_ADAPTER psAdapter = NULL; | ||
313 | struct usb_device *udev = NULL; | ||
314 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
315 | |||
316 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Usb disconnected"); | ||
317 | if(intf == NULL) | ||
318 | { | ||
319 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "intf pointer is NULL"); | ||
320 | return; | ||
321 | } | ||
322 | psIntfAdapter = usb_get_intfdata(intf); | ||
323 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "psIntfAdapter 0x%x",(unsigned int)psIntfAdapter); | ||
324 | if(psIntfAdapter == NULL) | ||
325 | { | ||
326 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "InterfaceAdapter pointer is NULL"); | ||
327 | return; | ||
328 | } | ||
329 | psAdapter = psIntfAdapter->psAdapter; | ||
330 | if(psAdapter->bDoSuspend) | ||
331 | intf->needs_remote_wakeup = 0; | ||
332 | |||
333 | psAdapter->device_removed = TRUE ; | ||
334 | usb_set_intfdata(intf, NULL); | ||
335 | InterfaceAdapterFree(psIntfAdapter); | ||
336 | udev = interface_to_usbdev (intf); | ||
337 | usb_put_dev(udev); | ||
338 | usb_deregister_dev (intf, &usbbcm_class); | ||
339 | } | ||
340 | |||
341 | |||
342 | static __inline int AllocUsbCb(PS_INTERFACE_ADAPTER psIntfAdapter) | ||
343 | { | ||
344 | int i = 0; | ||
345 | for(i = 0; i < MAXIMUM_USB_TCB; i++) | ||
346 | { | ||
347 | if((psIntfAdapter->asUsbTcb[i].urb = | ||
348 | usb_alloc_urb(0, GFP_KERNEL)) == NULL) | ||
349 | { | ||
350 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Cant allocate Tx urb for index %d", i); | ||
351 | return -ENOMEM; | ||
352 | } | ||
353 | } | ||
354 | |||
355 | for(i = 0; i < MAXIMUM_USB_RCB; i++) | ||
356 | { | ||
357 | if ((psIntfAdapter->asUsbRcb[i].urb = | ||
358 | usb_alloc_urb(0, GFP_KERNEL)) == NULL) | ||
359 | { | ||
360 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Cant allocate Rx urb for index %d", i); | ||
361 | return -ENOMEM; | ||
362 | } | ||
363 | if((psIntfAdapter->asUsbRcb[i].urb->transfer_buffer = | ||
364 | kmalloc(MAX_DATA_BUFFER_SIZE, GFP_KERNEL)) == NULL) | ||
365 | { | ||
366 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Cant allocate Rx buffer for index %d", i); | ||
367 | return -ENOMEM; | ||
368 | } | ||
369 | psIntfAdapter->asUsbRcb[i].urb->transfer_buffer_length = MAX_DATA_BUFFER_SIZE; | ||
370 | } | ||
371 | return 0; | ||
372 | } | ||
373 | |||
374 | |||
375 | |||
376 | static int device_run(PS_INTERFACE_ADAPTER psIntfAdapter) | ||
377 | { | ||
378 | INT value = 0; | ||
379 | UINT status = STATUS_SUCCESS; | ||
380 | |||
381 | status = InitCardAndDownloadFirmware(psIntfAdapter->psAdapter); | ||
382 | if(status != STATUS_SUCCESS) | ||
383 | { | ||
384 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "InitCardAndDownloadFirmware failed.\n"); | ||
385 | return status; | ||
386 | } | ||
387 | if(TRUE == psIntfAdapter->psAdapter->fw_download_done) | ||
388 | { | ||
389 | |||
390 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Sending first interrupt URB down......"); | ||
391 | if(StartInterruptUrb(psIntfAdapter)) | ||
392 | { | ||
393 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Cannot send interrupt in URB"); | ||
394 | } | ||
395 | //now register the cntrl interface. | ||
396 | //after downloading the f/w waiting for 5 sec to get the mailbox interrupt. | ||
397 | |||
398 | psIntfAdapter->psAdapter->waiting_to_fw_download_done = FALSE; | ||
399 | value = wait_event_timeout(psIntfAdapter->psAdapter->ioctl_fw_dnld_wait_queue, | ||
400 | psIntfAdapter->psAdapter->waiting_to_fw_download_done, 5*HZ); | ||
401 | |||
402 | if(value == 0) | ||
403 | { | ||
404 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"Mailbox Interrupt has not reached to Driver.."); | ||
405 | } | ||
406 | else | ||
407 | { | ||
408 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"Got the mailbox interrupt ...Registering control interface...\n "); | ||
409 | } | ||
410 | if(register_control_device_interface(psIntfAdapter->psAdapter) < 0) | ||
411 | { | ||
412 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Register Control Device failed..."); | ||
413 | return -EIO; | ||
414 | } | ||
415 | } | ||
416 | return 0; | ||
417 | } | ||
418 | |||
419 | #if 0 | ||
420 | static void print_usb_interface_desc(struct usb_interface_descriptor *usb_intf_desc) | ||
421 | { | ||
422 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "**************** INTERFACE DESCRIPTOR *********************"); | ||
423 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bLength: %x", usb_intf_desc->bLength); | ||
424 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bDescriptorType: %x", usb_intf_desc->bDescriptorType); | ||
425 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bInterfaceNumber: %x", usb_intf_desc->bInterfaceNumber); | ||
426 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bAlternateSetting: %x", usb_intf_desc->bAlternateSetting); | ||
427 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bNumEndpoints: %x", usb_intf_desc->bNumEndpoints); | ||
428 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bInterfaceClass: %x", usb_intf_desc->bInterfaceClass); | ||
429 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bInterfaceSubClass: %x", usb_intf_desc->bInterfaceSubClass); | ||
430 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bInterfaceProtocol: %x", usb_intf_desc->bInterfaceProtocol); | ||
431 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "iInterface :%x\n",usb_intf_desc->iInterface); | ||
432 | } | ||
433 | static void print_usb_endpoint_descriptor(struct usb_endpoint_descriptor *usb_ep_desc) | ||
434 | { | ||
435 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "**************** ENDPOINT DESCRIPTOR *********************"); | ||
436 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bLength :%x ", usb_ep_desc->bLength); | ||
437 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bDescriptorType :%x ", usb_ep_desc->bDescriptorType); | ||
438 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bEndpointAddress :%x ", usb_ep_desc->bEndpointAddress); | ||
439 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bmAttributes :%x ", usb_ep_desc->bmAttributes); | ||
440 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "wMaxPacketSize :%x ",usb_ep_desc->wMaxPacketSize); | ||
441 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bInterval :%x ",usb_ep_desc->bInterval); | ||
442 | } | ||
443 | |||
444 | #endif | ||
445 | |||
446 | static inline int bcm_usb_endpoint_num(const struct usb_endpoint_descriptor *epd) | ||
447 | { | ||
448 | return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; | ||
449 | } | ||
450 | |||
451 | static inline int bcm_usb_endpoint_type(const struct usb_endpoint_descriptor *epd) | ||
452 | { | ||
453 | return epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; | ||
454 | } | ||
455 | |||
456 | static inline int bcm_usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd) | ||
457 | { | ||
458 | return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN); | ||
459 | } | ||
460 | |||
461 | static inline int bcm_usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd) | ||
462 | { | ||
463 | return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT); | ||
464 | } | ||
465 | |||
466 | static inline int bcm_usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd) | ||
467 | { | ||
468 | return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | ||
469 | USB_ENDPOINT_XFER_BULK); | ||
470 | } | ||
471 | |||
472 | static inline int bcm_usb_endpoint_xfer_control(const struct usb_endpoint_descriptor *epd) | ||
473 | { | ||
474 | return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | ||
475 | USB_ENDPOINT_XFER_CONTROL); | ||
476 | } | ||
477 | |||
478 | static inline int bcm_usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd) | ||
479 | { | ||
480 | return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | ||
481 | USB_ENDPOINT_XFER_INT); | ||
482 | } | ||
483 | |||
484 | static inline int bcm_usb_endpoint_xfer_isoc(const struct usb_endpoint_descriptor *epd) | ||
485 | { | ||
486 | return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | ||
487 | USB_ENDPOINT_XFER_ISOC); | ||
488 | } | ||
489 | |||
490 | static inline int bcm_usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd) | ||
491 | { | ||
492 | return (bcm_usb_endpoint_xfer_bulk(epd) && bcm_usb_endpoint_dir_in(epd)); | ||
493 | } | ||
494 | |||
495 | static inline int bcm_usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd) | ||
496 | { | ||
497 | return (bcm_usb_endpoint_xfer_bulk(epd) && bcm_usb_endpoint_dir_out(epd)); | ||
498 | } | ||
499 | |||
500 | static inline int bcm_usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd) | ||
501 | { | ||
502 | return (bcm_usb_endpoint_xfer_int(epd) && bcm_usb_endpoint_dir_in(epd)); | ||
503 | } | ||
504 | |||
505 | static inline int bcm_usb_endpoint_is_int_out(const struct usb_endpoint_descriptor *epd) | ||
506 | { | ||
507 | return (bcm_usb_endpoint_xfer_int(epd) && bcm_usb_endpoint_dir_out(epd)); | ||
508 | } | ||
509 | |||
510 | static inline int bcm_usb_endpoint_is_isoc_in(const struct usb_endpoint_descriptor *epd) | ||
511 | { | ||
512 | return (bcm_usb_endpoint_xfer_isoc(epd) && bcm_usb_endpoint_dir_in(epd)); | ||
513 | } | ||
514 | |||
515 | static inline int bcm_usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor *epd) | ||
516 | { | ||
517 | return (bcm_usb_endpoint_xfer_isoc(epd) && bcm_usb_endpoint_dir_out(epd)); | ||
518 | } | ||
519 | |||
520 | INT InterfaceAdapterInit(PS_INTERFACE_ADAPTER psIntfAdapter) | ||
521 | { | ||
522 | struct usb_host_interface *iface_desc; | ||
523 | struct usb_endpoint_descriptor *endpoint; | ||
524 | size_t buffer_size; | ||
525 | ULONG value; | ||
526 | INT retval = 0; | ||
527 | INT usedIntOutForBulkTransfer = 0 ; | ||
528 | BOOLEAN bBcm16 = FALSE; | ||
529 | UINT uiData = 0; | ||
530 | |||
531 | if(psIntfAdapter == NULL) | ||
532 | { | ||
533 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Interface Adapter is NULL"); | ||
534 | return -EINVAL; | ||
535 | } | ||
536 | /* Store the usb dev into interface adapter */ | ||
537 | psIntfAdapter->udev = usb_get_dev(interface_to_usbdev( | ||
538 | psIntfAdapter->interface)); | ||
539 | |||
540 | if((psIntfAdapter->udev->speed == USB_SPEED_HIGH)) | ||
541 | { | ||
542 | psIntfAdapter->bHighSpeedDevice = TRUE ; | ||
543 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "MODEM IS CONFIGURED TO HIGH_SPEED "); | ||
544 | } | ||
545 | else | ||
546 | { | ||
547 | psIntfAdapter->bHighSpeedDevice = FALSE ; | ||
548 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "MODEM IS CONFIGURED TO FULL_SPEED "); | ||
549 | } | ||
550 | |||
551 | psIntfAdapter->psAdapter->interface_rdm = BcmRDM; | ||
552 | psIntfAdapter->psAdapter->interface_wrm = BcmWRM; | ||
553 | |||
554 | if(rdmalt(psIntfAdapter->psAdapter, CHIP_ID_REG, (PUINT)&(psIntfAdapter->psAdapter->chip_id), sizeof(UINT)) < 0) | ||
555 | { | ||
556 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "CHIP ID Read Failed\n"); | ||
557 | return STATUS_FAILURE; | ||
558 | } | ||
559 | if(0xbece3200==(psIntfAdapter->psAdapter->chip_id&~(0xF0))) | ||
560 | { | ||
561 | psIntfAdapter->psAdapter->chip_id=(psIntfAdapter->psAdapter->chip_id&~(0xF0)); | ||
562 | } | ||
563 | |||
564 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "First RDM Chip ID 0x%lx\n", psIntfAdapter->psAdapter->chip_id); | ||
565 | |||
566 | iface_desc = psIntfAdapter->interface->cur_altsetting; | ||
567 | //print_usb_interface_desc(&(iface_desc->desc)); | ||
568 | |||
569 | if(psIntfAdapter->psAdapter->chip_id == T3B) | ||
570 | { | ||
571 | |||
572 | // | ||
573 | //T3B device will have EEPROM,check if EEPROM is proper and BCM16 can be done or not. | ||
574 | // | ||
575 | BeceemEEPROMBulkRead(psIntfAdapter->psAdapter,&uiData,0x0,4); | ||
576 | if(uiData == BECM) | ||
577 | { | ||
578 | bBcm16 = TRUE; | ||
579 | } | ||
580 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Number of Altsetting aviailable for This Modem 0x%x\n", psIntfAdapter->interface->num_altsetting); | ||
581 | if(bBcm16 == TRUE) | ||
582 | { | ||
583 | //selecting alternate setting one as a default setting for High Speed modem. | ||
584 | if(psIntfAdapter->bHighSpeedDevice) | ||
585 | retval= usb_set_interface(psIntfAdapter->udev,DEFAULT_SETTING_0,ALTERNATE_SETTING_1); | ||
586 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "BCM16 is Applicable on this dongle"); | ||
587 | if(retval || (psIntfAdapter->bHighSpeedDevice == FALSE)) | ||
588 | { | ||
589 | usedIntOutForBulkTransfer = EP2 ; | ||
590 | endpoint = &iface_desc->endpoint[EP2].desc; | ||
591 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Interface altsetting got failed or Moemd is configured to FS.hence will work on default setting 0 \n"); | ||
592 | /* | ||
593 | If Modem is high speed device EP2 should be INT OUT End point | ||
594 | If Mode is FS then EP2 should be bulk end point | ||
595 | */ | ||
596 | if(((psIntfAdapter->bHighSpeedDevice ==TRUE ) && (bcm_usb_endpoint_is_int_out(endpoint)== FALSE)) | ||
597 | ||((psIntfAdapter->bHighSpeedDevice == FALSE)&& (bcm_usb_endpoint_is_bulk_out(endpoint)== FALSE))) | ||
598 | { | ||
599 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"Configuring the EEPROM "); | ||
600 | //change the EP2, EP4 to INT OUT end point | ||
601 | ConfigureEndPointTypesThroughEEPROM(psIntfAdapter->psAdapter); | ||
602 | |||
603 | /* | ||
604 | It resets the device and if any thing gets changed in USB descriptor it will show fail and | ||
605 | re-enumerate the device | ||
606 | */ | ||
607 | retval = usb_reset_device(psIntfAdapter->udev); | ||
608 | if(retval) | ||
609 | { | ||
610 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "reset got failed. hence Re-enumerating the device \n"); | ||
611 | return retval ; | ||
612 | } | ||
613 | |||
614 | } | ||
615 | if((psIntfAdapter->bHighSpeedDevice == FALSE) && bcm_usb_endpoint_is_bulk_out(endpoint)) | ||
616 | { | ||
617 | // Once BULK is selected in FS mode. Revert it back to INT. Else USB_IF will fail. | ||
618 | UINT uiData = ntohl(EP2_CFG_INT); | ||
619 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"Reverting Bulk to INT as it is FS MODE"); | ||
620 | BeceemEEPROMBulkWrite(psIntfAdapter->psAdapter,(PUCHAR)&uiData,0x136,4,TRUE); | ||
621 | } | ||
622 | } | ||
623 | else | ||
624 | { | ||
625 | usedIntOutForBulkTransfer = EP4 ; | ||
626 | endpoint = &iface_desc->endpoint[EP4].desc; | ||
627 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Choosing AltSetting as a default setting"); | ||
628 | if( bcm_usb_endpoint_is_int_out(endpoint) == FALSE) | ||
629 | { | ||
630 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, " Dongle does not have BCM16 Fix"); | ||
631 | //change the EP2, EP4 to INT OUT end point and use EP4 in altsetting | ||
632 | ConfigureEndPointTypesThroughEEPROM(psIntfAdapter->psAdapter); | ||
633 | |||
634 | /* | ||
635 | It resets the device and if any thing gets changed in USB descriptor it will show fail and | ||
636 | re-enumerate the device | ||
637 | */ | ||
638 | retval = usb_reset_device(psIntfAdapter->udev); | ||
639 | if(retval) | ||
640 | { | ||
641 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "reset got failed. hence Re-enumerating the device \n"); | ||
642 | return retval ; | ||
643 | } | ||
644 | |||
645 | } | ||
646 | } | ||
647 | } | ||
648 | } | ||
649 | |||
650 | iface_desc = psIntfAdapter->interface->cur_altsetting; | ||
651 | //print_usb_interface_desc(&(iface_desc->desc)); | ||
652 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Current number of endpoints :%x \n", iface_desc->desc.bNumEndpoints); | ||
653 | for (value = 0; value < iface_desc->desc.bNumEndpoints; ++value) | ||
654 | { | ||
655 | endpoint = &iface_desc->endpoint[value].desc; | ||
656 | //print_usb_endpoint_descriptor(endpoint); | ||
657 | |||
658 | if (!psIntfAdapter->sBulkIn.bulk_in_endpointAddr && bcm_usb_endpoint_is_bulk_in(endpoint)) | ||
659 | { | ||
660 | buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); | ||
661 | psIntfAdapter->sBulkIn.bulk_in_size = buffer_size; | ||
662 | psIntfAdapter->sBulkIn.bulk_in_endpointAddr = | ||
663 | endpoint->bEndpointAddress; | ||
664 | psIntfAdapter->sBulkIn.bulk_in_pipe = | ||
665 | usb_rcvbulkpipe(psIntfAdapter->udev, | ||
666 | psIntfAdapter->sBulkIn.bulk_in_endpointAddr); | ||
667 | } | ||
668 | |||
669 | if (!psIntfAdapter->sBulkOut.bulk_out_endpointAddr && bcm_usb_endpoint_is_bulk_out(endpoint)) | ||
670 | { | ||
671 | |||
672 | psIntfAdapter->sBulkOut.bulk_out_endpointAddr = | ||
673 | endpoint->bEndpointAddress; | ||
674 | psIntfAdapter->sBulkOut.bulk_out_pipe = | ||
675 | usb_sndbulkpipe(psIntfAdapter->udev, | ||
676 | psIntfAdapter->sBulkOut.bulk_out_endpointAddr); | ||
677 | } | ||
678 | |||
679 | if (!psIntfAdapter->sIntrIn.int_in_endpointAddr && bcm_usb_endpoint_is_int_in(endpoint)) | ||
680 | { | ||
681 | buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); | ||
682 | psIntfAdapter->sIntrIn.int_in_size = buffer_size; | ||
683 | psIntfAdapter->sIntrIn.int_in_endpointAddr = | ||
684 | endpoint->bEndpointAddress; | ||
685 | psIntfAdapter->sIntrIn.int_in_interval = endpoint->bInterval; | ||
686 | psIntfAdapter->sIntrIn.int_in_buffer = | ||
687 | kmalloc(buffer_size, GFP_KERNEL); | ||
688 | if (!psIntfAdapter->sIntrIn.int_in_buffer) { | ||
689 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Could not allocate interrupt_in_buffer"); | ||
690 | return -EINVAL; | ||
691 | } | ||
692 | //psIntfAdapter->sIntrIn.int_in_pipe = | ||
693 | } | ||
694 | |||
695 | if (!psIntfAdapter->sIntrOut.int_out_endpointAddr && bcm_usb_endpoint_is_int_out(endpoint)) | ||
696 | { | ||
697 | |||
698 | if( !psIntfAdapter->sBulkOut.bulk_out_endpointAddr && | ||
699 | (psIntfAdapter->psAdapter->chip_id == T3B) && (value == usedIntOutForBulkTransfer)) | ||
700 | { | ||
701 | //use first intout end point as a bulk out end point | ||
702 | buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); | ||
703 | psIntfAdapter->sBulkOut.bulk_out_size = buffer_size; | ||
704 | //printk("\nINT OUT Endpoing buffer size :%x endpoint :%x\n", buffer_size, value +1); | ||
705 | psIntfAdapter->sBulkOut.bulk_out_endpointAddr = | ||
706 | endpoint->bEndpointAddress; | ||
707 | psIntfAdapter->sBulkOut.bulk_out_pipe = | ||
708 | usb_sndintpipe(psIntfAdapter->udev, | ||
709 | psIntfAdapter->sBulkOut.bulk_out_endpointAddr); | ||
710 | psIntfAdapter->sBulkOut.int_out_interval = endpoint->bInterval; | ||
711 | |||
712 | } | ||
713 | else if(value == EP6) | ||
714 | { | ||
715 | buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); | ||
716 | psIntfAdapter->sIntrOut.int_out_size = buffer_size; | ||
717 | psIntfAdapter->sIntrOut.int_out_endpointAddr = | ||
718 | endpoint->bEndpointAddress; | ||
719 | psIntfAdapter->sIntrOut.int_out_interval = endpoint->bInterval; | ||
720 | psIntfAdapter->sIntrOut.int_out_buffer= kmalloc(buffer_size, | ||
721 | GFP_KERNEL); | ||
722 | if (!psIntfAdapter->sIntrOut.int_out_buffer) | ||
723 | { | ||
724 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Could not allocate interrupt_out_buffer"); | ||
725 | return -EINVAL; | ||
726 | } | ||
727 | } | ||
728 | } | ||
729 | } | ||
730 | usb_set_intfdata(psIntfAdapter->interface, psIntfAdapter); | ||
731 | retval = usb_register_dev(psIntfAdapter->interface, &usbbcm_class); | ||
732 | if(retval) | ||
733 | { | ||
734 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "usb register dev failed = %d", retval); | ||
735 | psIntfAdapter->psAdapter->bUsbClassDriverRegistered = FALSE; | ||
736 | return retval; | ||
737 | } | ||
738 | else | ||
739 | { | ||
740 | psIntfAdapter->psAdapter->bUsbClassDriverRegistered = TRUE; | ||
741 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "usb dev registered"); | ||
742 | } | ||
743 | |||
744 | psIntfAdapter->psAdapter->bcm_file_download = InterfaceFileDownload; | ||
745 | psIntfAdapter->psAdapter->bcm_file_readback_from_chip = | ||
746 | InterfaceFileReadbackFromChip; | ||
747 | psIntfAdapter->psAdapter->interface_transmit = InterfaceTransmitPacket; | ||
748 | |||
749 | retval = CreateInterruptUrb(psIntfAdapter); | ||
750 | |||
751 | if(retval) | ||
752 | { | ||
753 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Cannot create interrupt urb"); | ||
754 | return retval; | ||
755 | } | ||
756 | |||
757 | retval = AllocUsbCb(psIntfAdapter); | ||
758 | if(retval) | ||
759 | { | ||
760 | return retval; | ||
761 | } | ||
762 | |||
763 | |||
764 | retval = device_run(psIntfAdapter); | ||
765 | if(retval) | ||
766 | { | ||
767 | return retval; | ||
768 | } | ||
769 | |||
770 | |||
771 | return 0; | ||
772 | } | ||
773 | int InterfaceSuspend (struct usb_interface *intf, pm_message_t message) | ||
774 | { | ||
775 | PS_INTERFACE_ADAPTER psIntfAdapter = usb_get_intfdata(intf); | ||
776 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "=================================\n"); | ||
777 | //Bcm_kill_all_URBs(psIntfAdapter); | ||
778 | psIntfAdapter->bSuspended = TRUE; | ||
779 | |||
780 | if(TRUE == psIntfAdapter->bPreparingForBusSuspend) | ||
781 | { | ||
782 | psIntfAdapter->bPreparingForBusSuspend = FALSE; | ||
783 | |||
784 | if(psIntfAdapter->psAdapter->LinkStatus == LINKUP_DONE) | ||
785 | { | ||
786 | psIntfAdapter->psAdapter->IdleMode = TRUE ; | ||
787 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Host Entered in PMU Idle Mode.."); | ||
788 | } | ||
789 | else | ||
790 | { | ||
791 | psIntfAdapter->psAdapter->bShutStatus = TRUE; | ||
792 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Host Entered in PMU Shutdown Mode.."); | ||
793 | } | ||
794 | } | ||
795 | psIntfAdapter->psAdapter->bPreparingForLowPowerMode = FALSE; | ||
796 | |||
797 | //Signaling the control pkt path | ||
798 | wake_up(&psIntfAdapter->psAdapter->lowpower_mode_wait_queue); | ||
799 | |||
800 | return 0; | ||
801 | } | ||
802 | int InterfaceResume (struct usb_interface *intf) | ||
803 | { | ||
804 | PS_INTERFACE_ADAPTER psIntfAdapter = usb_get_intfdata(intf); | ||
805 | printk("=================================\n"); | ||
806 | mdelay(100); | ||
807 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 32) | ||
808 | intf->pm_usage_cnt =1 ; | ||
809 | #endif | ||
810 | psIntfAdapter->bSuspended = FALSE; | ||
811 | |||
812 | StartInterruptUrb(psIntfAdapter); | ||
813 | InterfaceRx(psIntfAdapter); | ||
814 | return 0; | ||
815 | } | ||
816 | int InterfacePreReset(struct usb_interface *intf) | ||
817 | { | ||
818 | printk("====================>"); | ||
819 | return STATUS_SUCCESS; | ||
820 | } | ||
821 | int InterfacePostReset(struct usb_interface *intf) | ||
822 | { | ||
823 | printk("Do Post chip reset setting here if it is required"); | ||
824 | return STATUS_SUCCESS; | ||
825 | } | ||
826 | static struct usb_driver usbbcm_driver = { | ||
827 | .name = "usbbcm", | ||
828 | .probe = usbbcm_device_probe, | ||
829 | .disconnect = usbbcm_disconnect, | ||
830 | .suspend = InterfaceSuspend, | ||
831 | .resume = InterfaceResume, | ||
832 | .pre_reset=InterfacePreReset, | ||
833 | .post_reset=InterfacePostReset, | ||
834 | .id_table = InterfaceUsbtable, | ||
835 | .supports_autosuspend = 1, | ||
836 | }; | ||
837 | |||
838 | |||
839 | /* | ||
840 | Function: InterfaceInitialize | ||
841 | |||
842 | Description: This is the hardware specific initialization Function. | ||
843 | Registering the driver with NDIS , other device specific NDIS | ||
844 | and hardware initializations are done here. | ||
845 | |||
846 | Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context | ||
847 | |||
848 | |||
849 | Return: BCM_STATUS_SUCCESS - If Initialization of the | ||
850 | HW Interface was successful. | ||
851 | Other - If an error occured. | ||
852 | */ | ||
853 | INT InterfaceInitialize(void) | ||
854 | { | ||
855 | // BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Registering Usb driver!!"); | ||
856 | return usb_register(&usbbcm_driver); | ||
857 | } | ||
858 | |||
859 | INT InterfaceExit(void) | ||
860 | { | ||
861 | //PMINI_ADAPTER psAdapter = NULL; | ||
862 | int status = 0; | ||
863 | |||
864 | //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Deregistering Usb driver!!"); | ||
865 | usb_deregister(&usbbcm_driver); | ||
866 | return status; | ||
867 | } | ||
868 | MODULE_LICENSE ("GPL"); | ||
diff --git a/drivers/staging/bcm/InterfaceInit.h b/drivers/staging/bcm/InterfaceInit.h new file mode 100644 index 00000000000..e7a96e5c5c5 --- /dev/null +++ b/drivers/staging/bcm/InterfaceInit.h | |||
@@ -0,0 +1,51 @@ | |||
1 | #ifndef _INTERFACE_INIT_H | ||
2 | #define _INTERFACE_INIT_H | ||
3 | |||
4 | #define BCM_USB_VENDOR_ID_T3 0x198f | ||
5 | #define BCM_USB_VENDOR_ID_FOXCONN 0x0489 | ||
6 | #define BCM_USB_VENDOR_ID_ZTE 0x19d2 | ||
7 | |||
8 | #define BCM_USB_PRODUCT_ID_T3 0x0300 | ||
9 | #define BCM_USB_PRODUCT_ID_T3B 0x0210 | ||
10 | #define BCM_USB_PRODUCT_ID_T3L 0x0220 | ||
11 | #define BCM_USB_PRODUCT_ID_SYM 0x15E | ||
12 | #define BCM_USB_PRODUCT_ID_1901 0xe017 | ||
13 | #define BCM_USB_PRODUCT_ID_226 0x0132 | ||
14 | |||
15 | #define BCM_USB_MINOR_BASE 192 | ||
16 | |||
17 | |||
18 | INT InterfaceInitialize(void); | ||
19 | |||
20 | INT InterfaceExit(void); | ||
21 | |||
22 | #ifndef BCM_SHM_INTERFACE | ||
23 | INT InterfaceAdapterInit(PS_INTERFACE_ADAPTER Adapter); | ||
24 | |||
25 | INT usbbcm_worker_thread(PS_INTERFACE_ADAPTER psIntfAdapter); | ||
26 | |||
27 | VOID InterfaceAdapterFree(PS_INTERFACE_ADAPTER psIntfAdapter); | ||
28 | |||
29 | #else | ||
30 | INT InterfaceAdapterInit(PMINI_ADAPTER Adapter); | ||
31 | #endif | ||
32 | |||
33 | |||
34 | #if 0 | ||
35 | |||
36 | ULONG InterfaceClaimAdapter(PMINI_ADAPTER Adapter); | ||
37 | |||
38 | VOID InterfaceDDRControllerInit(PMINI_ADAPTER Adapter); | ||
39 | |||
40 | ULONG InterfaceReset(PMINI_ADAPTER Adapter); | ||
41 | |||
42 | ULONG InterfaceRegisterResources(PMINI_ADAPTER Adapter); | ||
43 | |||
44 | VOID InterfaceUnRegisterResources(PMINI_ADAPTER Adapter); | ||
45 | |||
46 | ULONG InterfaceFirmwareDownload(PMINI_ADAPTER Adapter); | ||
47 | |||
48 | #endif | ||
49 | |||
50 | #endif | ||
51 | |||
diff --git a/drivers/staging/bcm/InterfaceIsr.c b/drivers/staging/bcm/InterfaceIsr.c new file mode 100644 index 00000000000..f928fe4d564 --- /dev/null +++ b/drivers/staging/bcm/InterfaceIsr.c | |||
@@ -0,0 +1,203 @@ | |||
1 | #include "headers.h" | ||
2 | |||
3 | #ifndef BCM_SHM_INTERFACE | ||
4 | |||
5 | static void read_int_callback(struct urb *urb/*, struct pt_regs *regs*/) | ||
6 | { | ||
7 | int status = urb->status; | ||
8 | PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)urb->context; | ||
9 | PMINI_ADAPTER Adapter = psIntfAdapter->psAdapter ; | ||
10 | |||
11 | if(Adapter->device_removed == TRUE) | ||
12 | { | ||
13 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Device has Got Removed."); | ||
14 | return ; | ||
15 | } | ||
16 | |||
17 | if(((Adapter->bPreparingForLowPowerMode == TRUE) && (Adapter->bDoSuspend == TRUE)) || | ||
18 | psIntfAdapter->bSuspended || | ||
19 | psIntfAdapter->bPreparingForBusSuspend) | ||
20 | { | ||
21 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Interrupt call back is called while suspending the device"); | ||
22 | return ; | ||
23 | } | ||
24 | |||
25 | //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "interrupt urb status %d", status); | ||
26 | switch (status) { | ||
27 | /* success */ | ||
28 | case STATUS_SUCCESS: | ||
29 | if ( urb->actual_length ) | ||
30 | { | ||
31 | |||
32 | if(psIntfAdapter->ulInterruptData[1] & 0xFF) | ||
33 | { | ||
34 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL, "Got USIM interrupt"); | ||
35 | } | ||
36 | |||
37 | if(psIntfAdapter->ulInterruptData[1] & 0xFF00) | ||
38 | { | ||
39 | atomic_set(&Adapter->CurrNumFreeTxDesc, | ||
40 | (psIntfAdapter->ulInterruptData[1] & 0xFF00) >> 8); | ||
41 | atomic_set (&Adapter->uiMBupdate, TRUE); | ||
42 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL, "TX mailbox contains %d", | ||
43 | atomic_read(&Adapter->CurrNumFreeTxDesc)); | ||
44 | } | ||
45 | if(psIntfAdapter->ulInterruptData[1] >> 16) | ||
46 | { | ||
47 | Adapter->CurrNumRecvDescs= | ||
48 | (psIntfAdapter->ulInterruptData[1] >> 16); | ||
49 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"RX mailbox contains %d", | ||
50 | Adapter->CurrNumRecvDescs); | ||
51 | InterfaceRx(psIntfAdapter); | ||
52 | } | ||
53 | if(Adapter->fw_download_done && | ||
54 | !Adapter->downloadDDR && | ||
55 | atomic_read(&Adapter->CurrNumFreeTxDesc)) | ||
56 | { | ||
57 | psIntfAdapter->psAdapter->downloadDDR +=1; | ||
58 | wake_up(&Adapter->tx_packet_wait_queue); | ||
59 | } | ||
60 | if(FALSE == Adapter->waiting_to_fw_download_done) | ||
61 | { | ||
62 | Adapter->waiting_to_fw_download_done = TRUE; | ||
63 | wake_up(&Adapter->ioctl_fw_dnld_wait_queue); | ||
64 | } | ||
65 | if(!atomic_read(&Adapter->TxPktAvail)) | ||
66 | { | ||
67 | atomic_set(&Adapter->TxPktAvail, 1); | ||
68 | wake_up(&Adapter->tx_packet_wait_queue); | ||
69 | } | ||
70 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Firing interrupt in URB"); | ||
71 | } | ||
72 | break; | ||
73 | case -ENOENT : | ||
74 | { | ||
75 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"URB has got disconnected ...."); | ||
76 | return ; | ||
77 | } | ||
78 | case -EINPROGRESS: | ||
79 | { | ||
80 | //This situation may happend when URBunlink is used. for detail check usb_unlink_urb documentation. | ||
81 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Impossibe condition has occured... something very bad is going on"); | ||
82 | break ; | ||
83 | //return; | ||
84 | } | ||
85 | case -EPIPE: | ||
86 | { | ||
87 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Interrupt IN endPoint has got halted/stalled...need to clear this"); | ||
88 | Adapter->bEndPointHalted = TRUE ; | ||
89 | wake_up(&Adapter->tx_packet_wait_queue); | ||
90 | urb->status = STATUS_SUCCESS ;; | ||
91 | return; | ||
92 | } | ||
93 | /* software-driven interface shutdown */ | ||
94 | case -ECONNRESET: //URB got unlinked. | ||
95 | case -ESHUTDOWN: // hardware gone. this is the serious problem. | ||
96 | //Occurs only when something happens with the host controller device | ||
97 | case -ENODEV : //Device got removed | ||
98 | case -EINVAL : //Some thing very bad happened with the URB. No description is available. | ||
99 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"interrupt urb error %d", status); | ||
100 | urb->status = STATUS_SUCCESS ; | ||
101 | break ; | ||
102 | //return; | ||
103 | default: | ||
104 | //This is required to check what is the defaults conditions when it occurs.. | ||
105 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL,"GOT DEFAULT INTERRUPT URB STATUS :%d..Please Analyze it...", status); | ||
106 | break; | ||
107 | } | ||
108 | |||
109 | StartInterruptUrb(psIntfAdapter); | ||
110 | |||
111 | |||
112 | } | ||
113 | |||
114 | int CreateInterruptUrb(PS_INTERFACE_ADAPTER psIntfAdapter) | ||
115 | { | ||
116 | psIntfAdapter->psInterruptUrb = usb_alloc_urb(0, GFP_KERNEL); | ||
117 | if (!psIntfAdapter->psInterruptUrb) | ||
118 | { | ||
119 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Cannot allocate interrupt urb"); | ||
120 | return -ENOMEM; | ||
121 | } | ||
122 | psIntfAdapter->psInterruptUrb->transfer_buffer = | ||
123 | psIntfAdapter->ulInterruptData; | ||
124 | psIntfAdapter->psInterruptUrb->transfer_buffer_length = | ||
125 | sizeof(psIntfAdapter->ulInterruptData); | ||
126 | |||
127 | psIntfAdapter->sIntrIn.int_in_pipe = usb_rcvintpipe(psIntfAdapter->udev, | ||
128 | psIntfAdapter->sIntrIn.int_in_endpointAddr); | ||
129 | |||
130 | usb_fill_int_urb(psIntfAdapter->psInterruptUrb, psIntfAdapter->udev, | ||
131 | psIntfAdapter->sIntrIn.int_in_pipe, | ||
132 | psIntfAdapter->psInterruptUrb->transfer_buffer, | ||
133 | psIntfAdapter->psInterruptUrb->transfer_buffer_length, | ||
134 | read_int_callback, psIntfAdapter, | ||
135 | psIntfAdapter->sIntrIn.int_in_interval); | ||
136 | |||
137 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Interrupt Interval: %d\n", | ||
138 | psIntfAdapter->sIntrIn.int_in_interval); | ||
139 | return 0; | ||
140 | } | ||
141 | |||
142 | |||
143 | INT StartInterruptUrb(PS_INTERFACE_ADAPTER psIntfAdapter) | ||
144 | { | ||
145 | INT status = 0; | ||
146 | |||
147 | if( FALSE == psIntfAdapter->psAdapter->device_removed && | ||
148 | FALSE == psIntfAdapter->psAdapter->bEndPointHalted && | ||
149 | FALSE == psIntfAdapter->bSuspended && | ||
150 | FALSE == psIntfAdapter->bPreparingForBusSuspend && | ||
151 | FALSE == psIntfAdapter->psAdapter->StopAllXaction) | ||
152 | { | ||
153 | status = usb_submit_urb(psIntfAdapter->psInterruptUrb, GFP_ATOMIC); | ||
154 | if (status) | ||
155 | { | ||
156 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Cannot send int urb %d\n", status); | ||
157 | if(status == -EPIPE) | ||
158 | { | ||
159 | psIntfAdapter->psAdapter->bEndPointHalted = TRUE ; | ||
160 | wake_up(&psIntfAdapter->psAdapter->tx_packet_wait_queue); | ||
161 | } | ||
162 | } | ||
163 | } | ||
164 | return status; | ||
165 | } | ||
166 | |||
167 | /* | ||
168 | Function: InterfaceEnableInterrupt | ||
169 | |||
170 | Description: This is the hardware specific Function for configuring | ||
171 | and enabling the interrupts on the device. | ||
172 | |||
173 | Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context | ||
174 | |||
175 | |||
176 | Return: BCM_STATUS_SUCCESS - If configuring the interrupts was successful. | ||
177 | Other - If an error occured. | ||
178 | */ | ||
179 | |||
180 | void InterfaceEnableInterrupt(PMINI_ADAPTER Adapter) | ||
181 | { | ||
182 | |||
183 | } | ||
184 | |||
185 | /* | ||
186 | Function: InterfaceDisableInterrupt | ||
187 | |||
188 | Description: This is the hardware specific Function for disabling the interrupts on the device. | ||
189 | |||
190 | Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context | ||
191 | |||
192 | |||
193 | Return: BCM_STATUS_SUCCESS - If disabling the interrupts was successful. | ||
194 | Other - If an error occured. | ||
195 | */ | ||
196 | |||
197 | void InterfaceDisableInterrupt(PMINI_ADAPTER Adapter) | ||
198 | { | ||
199 | |||
200 | } | ||
201 | |||
202 | #endif | ||
203 | |||
diff --git a/drivers/staging/bcm/InterfaceIsr.h b/drivers/staging/bcm/InterfaceIsr.h new file mode 100644 index 00000000000..6065a7141bc --- /dev/null +++ b/drivers/staging/bcm/InterfaceIsr.h | |||
@@ -0,0 +1,15 @@ | |||
1 | #ifndef _INTERFACE_ISR_H | ||
2 | #define _INTERFACE_ISR_H | ||
3 | |||
4 | int CreateInterruptUrb(PS_INTERFACE_ADAPTER psIntfAdapter); | ||
5 | |||
6 | |||
7 | INT StartInterruptUrb(PS_INTERFACE_ADAPTER psIntfAdapter); | ||
8 | |||
9 | |||
10 | VOID InterfaceEnableInterrupt(PMINI_ADAPTER Adapter); | ||
11 | |||
12 | VOID InterfaceDisableInterrupt(PMINI_ADAPTER Adapter); | ||
13 | |||
14 | #endif | ||
15 | |||
diff --git a/drivers/staging/bcm/InterfaceMacros.h b/drivers/staging/bcm/InterfaceMacros.h new file mode 100644 index 00000000000..7001caff9e2 --- /dev/null +++ b/drivers/staging/bcm/InterfaceMacros.h | |||
@@ -0,0 +1,18 @@ | |||
1 | #ifndef _INTERFACE_MACROS_H | ||
2 | #define _INTERFACE_MACROS_H | ||
3 | |||
4 | #define BCM_USB_MAX_READ_LENGTH 2048 | ||
5 | |||
6 | #define MAXIMUM_USB_TCB 128 | ||
7 | #define MAXIMUM_USB_RCB 128 | ||
8 | |||
9 | #define MAX_BUFFERS_PER_QUEUE 256 | ||
10 | |||
11 | #define MAX_DATA_BUFFER_SIZE 2048 | ||
12 | |||
13 | //Num of Asynchronous reads pending | ||
14 | #define NUM_RX_DESC 64 | ||
15 | |||
16 | #define SYS_CFG 0x0F000C00 | ||
17 | |||
18 | #endif | ||
diff --git a/drivers/staging/bcm/InterfaceMisc.c b/drivers/staging/bcm/InterfaceMisc.c new file mode 100644 index 00000000000..8fc893b37fe --- /dev/null +++ b/drivers/staging/bcm/InterfaceMisc.c | |||
@@ -0,0 +1,290 @@ | |||
1 | #include "headers.h" | ||
2 | |||
3 | #ifndef BCM_SHM_INTERFACE | ||
4 | |||
5 | PS_INTERFACE_ADAPTER | ||
6 | InterfaceAdapterGet(PMINI_ADAPTER psAdapter) | ||
7 | { | ||
8 | if(psAdapter == NULL) | ||
9 | { | ||
10 | return NULL; | ||
11 | } | ||
12 | return (PS_INTERFACE_ADAPTER)(psAdapter->pvInterfaceAdapter); | ||
13 | } | ||
14 | |||
15 | INT | ||
16 | InterfaceRDM(PS_INTERFACE_ADAPTER psIntfAdapter, | ||
17 | UINT addr, | ||
18 | PVOID buff, | ||
19 | INT len) | ||
20 | { | ||
21 | int retval = 0; | ||
22 | USHORT usRetries = 0 ; | ||
23 | if(psIntfAdapter == NULL ) | ||
24 | { | ||
25 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0,"Interface Adapter is NULL"); | ||
26 | return -EINVAL ; | ||
27 | } | ||
28 | |||
29 | if(psIntfAdapter->psAdapter->device_removed == TRUE) | ||
30 | { | ||
31 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0,"Device got removed"); | ||
32 | return -ENODEV; | ||
33 | } | ||
34 | |||
35 | if((psIntfAdapter->psAdapter->StopAllXaction == TRUE) && (psIntfAdapter->psAdapter->chip_id >= T3LPB)) | ||
36 | { | ||
37 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, RDM, DBG_LVL_ALL,"Currently Xaction is not allowed on the bus"); | ||
38 | return -EACCES; | ||
39 | } | ||
40 | |||
41 | if(psIntfAdapter->bSuspended ==TRUE || psIntfAdapter->bPreparingForBusSuspend == TRUE) | ||
42 | { | ||
43 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, RDM, DBG_LVL_ALL,"Bus is in suspended states hence RDM not allowed.."); | ||
44 | return -EACCES; | ||
45 | } | ||
46 | psIntfAdapter->psAdapter->DeviceAccess = TRUE ; | ||
47 | do { | ||
48 | retval = usb_control_msg(psIntfAdapter->udev, | ||
49 | usb_rcvctrlpipe(psIntfAdapter->udev,0), | ||
50 | 0x02, | ||
51 | 0xC2, | ||
52 | (addr & 0xFFFF), | ||
53 | ((addr >> 16) & 0xFFFF), | ||
54 | buff, | ||
55 | len, | ||
56 | 5000); | ||
57 | |||
58 | usRetries++ ; | ||
59 | if(-ENODEV == retval) | ||
60 | { | ||
61 | psIntfAdapter->psAdapter->device_removed =TRUE; | ||
62 | break; | ||
63 | } | ||
64 | |||
65 | }while((retval < 0) && (usRetries < MAX_RDM_WRM_RETIRES ) ); | ||
66 | |||
67 | if(retval < 0) | ||
68 | { | ||
69 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, RDM, DBG_LVL_ALL, "RDM failed status :%d, retires :%d", retval,usRetries); | ||
70 | psIntfAdapter->psAdapter->DeviceAccess = FALSE ; | ||
71 | return retval; | ||
72 | } | ||
73 | else | ||
74 | { | ||
75 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, RDM, DBG_LVL_ALL, "RDM sent %d", retval); | ||
76 | psIntfAdapter->psAdapter->DeviceAccess = FALSE ; | ||
77 | return STATUS_SUCCESS; | ||
78 | } | ||
79 | } | ||
80 | |||
81 | INT | ||
82 | InterfaceWRM(PS_INTERFACE_ADAPTER psIntfAdapter, | ||
83 | UINT addr, | ||
84 | PVOID buff, | ||
85 | INT len) | ||
86 | { | ||
87 | int retval = 0; | ||
88 | USHORT usRetries = 0 ; | ||
89 | |||
90 | if(psIntfAdapter == NULL ) | ||
91 | { | ||
92 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Interface Adapter is NULL"); | ||
93 | return -EINVAL; | ||
94 | } | ||
95 | if(psIntfAdapter->psAdapter->device_removed == TRUE) | ||
96 | { | ||
97 | |||
98 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0,"Device got removed"); | ||
99 | return -ENODEV; | ||
100 | } | ||
101 | |||
102 | if((psIntfAdapter->psAdapter->StopAllXaction == TRUE) && (psIntfAdapter->psAdapter->chip_id >= T3LPB)) | ||
103 | { | ||
104 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, WRM, DBG_LVL_ALL,"Currently Xaction is not allowed on the bus..."); | ||
105 | return EACCES; | ||
106 | } | ||
107 | |||
108 | if(psIntfAdapter->bSuspended ==TRUE || psIntfAdapter->bPreparingForBusSuspend == TRUE) | ||
109 | { | ||
110 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, WRM, DBG_LVL_ALL,"Bus is in suspended states hence RDM not allowed.."); | ||
111 | return -EACCES; | ||
112 | } | ||
113 | psIntfAdapter->psAdapter->DeviceAccess = TRUE ; | ||
114 | do{ | ||
115 | retval = usb_control_msg(psIntfAdapter->udev, | ||
116 | usb_sndctrlpipe(psIntfAdapter->udev,0), | ||
117 | 0x01, | ||
118 | 0x42, | ||
119 | (addr & 0xFFFF), | ||
120 | ((addr >> 16) & 0xFFFF), | ||
121 | buff, | ||
122 | len, | ||
123 | 5000); | ||
124 | |||
125 | usRetries++ ; | ||
126 | if(-ENODEV == retval) | ||
127 | { | ||
128 | psIntfAdapter->psAdapter->device_removed = TRUE ; | ||
129 | break; | ||
130 | } | ||
131 | |||
132 | }while((retval < 0) && ( usRetries < MAX_RDM_WRM_RETIRES)); | ||
133 | |||
134 | if(retval < 0) | ||
135 | { | ||
136 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, WRM, DBG_LVL_ALL, "WRM failed status :%d, retires :%d", retval, usRetries); | ||
137 | psIntfAdapter->psAdapter->DeviceAccess = FALSE ; | ||
138 | return retval; | ||
139 | } | ||
140 | else | ||
141 | { | ||
142 | psIntfAdapter->psAdapter->DeviceAccess = FALSE ; | ||
143 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, WRM, DBG_LVL_ALL, "WRM sent %d", retval); | ||
144 | return STATUS_SUCCESS; | ||
145 | |||
146 | } | ||
147 | |||
148 | } | ||
149 | |||
150 | INT | ||
151 | BcmRDM(PVOID arg, | ||
152 | UINT addr, | ||
153 | PVOID buff, | ||
154 | INT len) | ||
155 | { | ||
156 | return InterfaceRDM((PS_INTERFACE_ADAPTER)arg, addr, buff, len); | ||
157 | } | ||
158 | |||
159 | INT | ||
160 | BcmWRM(PVOID arg, | ||
161 | UINT addr, | ||
162 | PVOID buff, | ||
163 | INT len) | ||
164 | { | ||
165 | return InterfaceWRM((PS_INTERFACE_ADAPTER)arg, addr, buff, len); | ||
166 | } | ||
167 | |||
168 | |||
169 | |||
170 | INT Bcm_clear_halt_of_endpoints(PMINI_ADAPTER Adapter) | ||
171 | { | ||
172 | PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter); | ||
173 | INT status = STATUS_SUCCESS ; | ||
174 | |||
175 | /* | ||
176 | usb_clear_halt - tells device to clear endpoint halt/stall condition | ||
177 | @dev: device whose endpoint is halted | ||
178 | @pipe: endpoint "pipe" being cleared | ||
179 | @ Context: !in_interrupt () | ||
180 | |||
181 | usb_clear_halt is the synchrnous call and returns 0 on success else returns with error code. | ||
182 | This is used to clear halt conditions for bulk and interrupt endpoints only. | ||
183 | Control and isochronous endpoints never halts. | ||
184 | |||
185 | Any URBs queued for such an endpoint should normally be unlinked by the driver | ||
186 | before clearing the halt condition. | ||
187 | |||
188 | */ | ||
189 | |||
190 | //Killing all the submitted urbs to different end points. | ||
191 | Bcm_kill_all_URBs(psIntfAdapter); | ||
192 | |||
193 | |||
194 | //clear the halted/stalled state for every end point | ||
195 | status = usb_clear_halt(psIntfAdapter->udev,psIntfAdapter->sIntrIn.int_in_pipe); | ||
196 | if(status != STATUS_SUCCESS) | ||
197 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL, "Unable to Clear Halt of Interrupt IN end point. :%d ", status); | ||
198 | |||
199 | status = usb_clear_halt(psIntfAdapter->udev,psIntfAdapter->sBulkIn.bulk_in_pipe); | ||
200 | if(status != STATUS_SUCCESS) | ||
201 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL, "Unable to Clear Halt of Bulk IN end point. :%d ", status); | ||
202 | |||
203 | status = usb_clear_halt(psIntfAdapter->udev,psIntfAdapter->sBulkOut.bulk_out_pipe); | ||
204 | if(status != STATUS_SUCCESS) | ||
205 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL, "Unable to Clear Halt of Bulk OUT end point. :%d ", status); | ||
206 | |||
207 | return status ; | ||
208 | } | ||
209 | |||
210 | |||
211 | VOID Bcm_kill_all_URBs(PS_INTERFACE_ADAPTER psIntfAdapter) | ||
212 | { | ||
213 | struct urb *tempUrb = NULL; | ||
214 | UINT i; | ||
215 | |||
216 | /** | ||
217 | * usb_kill_urb - cancel a transfer request and wait for it to finish | ||
218 | * @urb: pointer to URB describing a previously submitted request, | ||
219 | * returns nothing as it is void returned API. | ||
220 | * | ||
221 | * This routine cancels an in-progress request. It is guaranteed that | ||
222 | * upon return all completion handlers will have finished and the URB | ||
223 | * will be totally idle and available for reuse | ||
224 | |||
225 | * This routine may not be used in an interrupt context (such as a bottom | ||
226 | * half or a completion handler), or when holding a spinlock, or in other | ||
227 | * situations where the caller can't schedule(). | ||
228 | * | ||
229 | **/ | ||
230 | |||
231 | /* Cancel submitted Interrupt-URB's */ | ||
232 | if(psIntfAdapter->psInterruptUrb != NULL) | ||
233 | { | ||
234 | if(psIntfAdapter->psInterruptUrb->status == -EINPROGRESS) | ||
235 | usb_kill_urb(psIntfAdapter->psInterruptUrb); | ||
236 | } | ||
237 | |||
238 | /* Cancel All submitted TX URB's */ | ||
239 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Cancelling All Submitted TX Urbs \n"); | ||
240 | |||
241 | for(i = 0; i < MAXIMUM_USB_TCB; i++) | ||
242 | { | ||
243 | tempUrb = psIntfAdapter->asUsbTcb[i].urb; | ||
244 | if(tempUrb) | ||
245 | { | ||
246 | if(tempUrb->status == -EINPROGRESS) | ||
247 | usb_kill_urb(tempUrb); | ||
248 | } | ||
249 | } | ||
250 | |||
251 | |||
252 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Cancelling All submitted Rx Urbs \n"); | ||
253 | |||
254 | for(i = 0; i < MAXIMUM_USB_RCB; i++) | ||
255 | { | ||
256 | tempUrb = psIntfAdapter->asUsbRcb[i].urb; | ||
257 | if(tempUrb) | ||
258 | { | ||
259 | if(tempUrb->status == -EINPROGRESS) | ||
260 | usb_kill_urb(tempUrb); | ||
261 | } | ||
262 | } | ||
263 | |||
264 | |||
265 | atomic_set(&psIntfAdapter->uNumTcbUsed, 0); | ||
266 | atomic_set(&psIntfAdapter->uCurrTcb, 0); | ||
267 | |||
268 | atomic_set(&psIntfAdapter->uNumRcbUsed, 0); | ||
269 | atomic_set(&psIntfAdapter->uCurrRcb, 0); | ||
270 | |||
271 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "TCB: used- %d cur-%d\n", atomic_read(&psIntfAdapter->uNumTcbUsed), atomic_read(&psIntfAdapter->uCurrTcb)); | ||
272 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "RCB: used- %d cur-%d\n", atomic_read(&psIntfAdapter->uNumRcbUsed), atomic_read(&psIntfAdapter->uCurrRcb)); | ||
273 | |||
274 | } | ||
275 | |||
276 | VOID putUsbSuspend(struct work_struct *work) | ||
277 | { | ||
278 | PS_INTERFACE_ADAPTER psIntfAdapter = NULL ; | ||
279 | struct usb_interface *intf = NULL ; | ||
280 | psIntfAdapter = container_of(work, S_INTERFACE_ADAPTER,usbSuspendWork); | ||
281 | intf=psIntfAdapter->interface ; | ||
282 | |||
283 | if(psIntfAdapter->bSuspended == FALSE) | ||
284 | usb_autopm_put_interface(intf); | ||
285 | else | ||
286 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Interface Resumed Completely\n"); | ||
287 | |||
288 | } | ||
289 | |||
290 | #endif | ||
diff --git a/drivers/staging/bcm/InterfaceMisc.h b/drivers/staging/bcm/InterfaceMisc.h new file mode 100644 index 00000000000..74c81d45cff --- /dev/null +++ b/drivers/staging/bcm/InterfaceMisc.h | |||
@@ -0,0 +1,45 @@ | |||
1 | #ifndef __INTERFACE_MISC_H | ||
2 | #define __INTERFACE_MISC_H | ||
3 | |||
4 | PS_INTERFACE_ADAPTER | ||
5 | InterfaceAdapterGet(PMINI_ADAPTER psAdapter); | ||
6 | |||
7 | INT | ||
8 | InterfaceRDM(PS_INTERFACE_ADAPTER psIntfAdapter, | ||
9 | UINT addr, | ||
10 | PVOID buff, | ||
11 | INT len); | ||
12 | |||
13 | INT | ||
14 | InterfaceWRM(PS_INTERFACE_ADAPTER psIntfAdapter, | ||
15 | UINT addr, | ||
16 | PVOID buff, | ||
17 | INT len); | ||
18 | |||
19 | |||
20 | int InterfaceFileDownload( PVOID psIntfAdapter, | ||
21 | struct file *flp, | ||
22 | unsigned int on_chip_loc); | ||
23 | |||
24 | int InterfaceFileReadbackFromChip( PVOID psIntfAdapter, | ||
25 | struct file *flp, | ||
26 | unsigned int on_chip_loc); | ||
27 | |||
28 | |||
29 | int BcmRDM(PVOID arg, | ||
30 | UINT addr, | ||
31 | PVOID buff, | ||
32 | INT len); | ||
33 | |||
34 | int BcmWRM(PVOID arg, | ||
35 | UINT addr, | ||
36 | PVOID buff, | ||
37 | INT len); | ||
38 | |||
39 | INT Bcm_clear_halt_of_endpoints(PMINI_ADAPTER Adapter); | ||
40 | |||
41 | VOID Bcm_kill_all_URBs(PS_INTERFACE_ADAPTER psIntfAdapter); | ||
42 | |||
43 | #define DISABLE_USB_ZERO_LEN_INT 0x0F011878 | ||
44 | |||
45 | #endif // __INTERFACE_MISC_H | ||
diff --git a/drivers/staging/bcm/InterfaceRx.c b/drivers/staging/bcm/InterfaceRx.c new file mode 100644 index 00000000000..6fee9684f2e --- /dev/null +++ b/drivers/staging/bcm/InterfaceRx.c | |||
@@ -0,0 +1,256 @@ | |||
1 | #include "headers.h" | ||
2 | extern int SearchVcid(PMINI_ADAPTER , unsigned short); | ||
3 | |||
4 | |||
5 | static PUSB_RCB | ||
6 | GetBulkInRcb(PS_INTERFACE_ADAPTER psIntfAdapter) | ||
7 | { | ||
8 | PUSB_RCB pRcb = NULL; | ||
9 | UINT index = 0; | ||
10 | |||
11 | if((atomic_read(&psIntfAdapter->uNumRcbUsed) < MAXIMUM_USB_RCB) && | ||
12 | (psIntfAdapter->psAdapter->StopAllXaction == FALSE)) | ||
13 | { | ||
14 | index = atomic_read(&psIntfAdapter->uCurrRcb); | ||
15 | pRcb = &psIntfAdapter->asUsbRcb[index]; | ||
16 | pRcb->bUsed = TRUE; | ||
17 | pRcb->psIntfAdapter= psIntfAdapter; | ||
18 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "Got Rx desc %d used %d", | ||
19 | index, atomic_read(&psIntfAdapter->uNumRcbUsed)); | ||
20 | index = (index + 1) % MAXIMUM_USB_RCB; | ||
21 | atomic_set(&psIntfAdapter->uCurrRcb, index); | ||
22 | atomic_inc(&psIntfAdapter->uNumRcbUsed); | ||
23 | } | ||
24 | return pRcb; | ||
25 | } | ||
26 | |||
27 | /*this is receive call back - when pkt avilable for receive (BULK IN- end point)*/ | ||
28 | static void read_bulk_callback(struct urb *urb) | ||
29 | { | ||
30 | struct sk_buff *skb = NULL; | ||
31 | BOOLEAN bHeaderSupressionEnabled = FALSE; | ||
32 | int QueueIndex = NO_OF_QUEUES + 1; | ||
33 | UINT uiIndex=0; | ||
34 | int process_done = 1; | ||
35 | //int idleflag = 0 ; | ||
36 | PUSB_RCB pRcb = (PUSB_RCB)urb->context; | ||
37 | PS_INTERFACE_ADAPTER psIntfAdapter = pRcb->psIntfAdapter; | ||
38 | PMINI_ADAPTER Adapter = psIntfAdapter->psAdapter; | ||
39 | PLEADER pLeader = urb->transfer_buffer; | ||
40 | |||
41 | |||
42 | #if 0 | ||
43 | int *puiBuffer = NULL; | ||
44 | struct timeval tv; | ||
45 | memset(&tv, 0, sizeof(tv)); | ||
46 | do_gettimeofday(&tv); | ||
47 | #endif | ||
48 | |||
49 | if((Adapter->device_removed == TRUE) || | ||
50 | (TRUE == Adapter->bEndPointHalted) || | ||
51 | (0 == urb->actual_length) | ||
52 | ) | ||
53 | { | ||
54 | pRcb->bUsed = FALSE; | ||
55 | atomic_dec(&psIntfAdapter->uNumRcbUsed); | ||
56 | return; | ||
57 | } | ||
58 | |||
59 | if(urb->status != STATUS_SUCCESS) | ||
60 | { | ||
61 | if(urb->status == -EPIPE) | ||
62 | { | ||
63 | Adapter->bEndPointHalted = TRUE ; | ||
64 | wake_up(&Adapter->tx_packet_wait_queue); | ||
65 | } | ||
66 | else | ||
67 | { | ||
68 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL,"Rx URB has got cancelled. status :%d", urb->status); | ||
69 | } | ||
70 | pRcb->bUsed = FALSE; | ||
71 | atomic_dec(&psIntfAdapter->uNumRcbUsed); | ||
72 | urb->status = STATUS_SUCCESS ; | ||
73 | return ; | ||
74 | } | ||
75 | |||
76 | if(Adapter->bDoSuspend && (Adapter->bPreparingForLowPowerMode)) | ||
77 | { | ||
78 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL,"device is going in low power mode while PMU option selected..hence rx packet should not be process"); | ||
79 | return ; | ||
80 | } | ||
81 | |||
82 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "Read back done len %d\n", pLeader->PLength); | ||
83 | if(!pLeader->PLength) | ||
84 | { | ||
85 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "Leader Length 0"); | ||
86 | atomic_dec(&psIntfAdapter->uNumRcbUsed); | ||
87 | return; | ||
88 | } | ||
89 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "Leader Status:0x%hX, Length:0x%hX, VCID:0x%hX", pLeader->Status,pLeader->PLength,pLeader->Vcid); | ||
90 | if(MAX_CNTL_PKT_SIZE < pLeader->PLength) | ||
91 | { | ||
92 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Corrupted leader length...%d\n", | ||
93 | pLeader->PLength); | ||
94 | atomic_inc(&Adapter->RxPacketDroppedCount); | ||
95 | atomic_add(pLeader->PLength, &Adapter->BadRxByteCount); | ||
96 | atomic_dec(&psIntfAdapter->uNumRcbUsed); | ||
97 | return; | ||
98 | } | ||
99 | |||
100 | QueueIndex = SearchVcid( Adapter,pLeader->Vcid); | ||
101 | if(QueueIndex < NO_OF_QUEUES) | ||
102 | { | ||
103 | bHeaderSupressionEnabled = | ||
104 | Adapter->PackInfo[QueueIndex].bHeaderSuppressionEnabled; | ||
105 | bHeaderSupressionEnabled = | ||
106 | bHeaderSupressionEnabled & Adapter->bPHSEnabled; | ||
107 | } | ||
108 | |||
109 | skb = dev_alloc_skb (pLeader->PLength + SKB_RESERVE_PHS_BYTES + SKB_RESERVE_ETHERNET_HEADER);//2 //2 for allignment | ||
110 | if(!skb) | ||
111 | { | ||
112 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "NO SKBUFF!!! Dropping the Packet"); | ||
113 | atomic_dec(&psIntfAdapter->uNumRcbUsed); | ||
114 | return; | ||
115 | } | ||
116 | /* If it is a control Packet, then call handle_bcm_packet ()*/ | ||
117 | if((ntohs(pLeader->Vcid) == VCID_CONTROL_PACKET) || | ||
118 | (!(pLeader->Status >= 0x20 && pLeader->Status <= 0x3F))) | ||
119 | { | ||
120 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_RX, RX_CTRL, DBG_LVL_ALL, "Recived control pkt..."); | ||
121 | *(PUSHORT)skb->data = pLeader->Status; | ||
122 | memcpy(skb->data+sizeof(USHORT), urb->transfer_buffer + | ||
123 | (sizeof(LEADER)), pLeader->PLength); | ||
124 | skb->len = pLeader->PLength + sizeof(USHORT); | ||
125 | |||
126 | spin_lock(&Adapter->control_queue_lock); | ||
127 | ENQUEUEPACKET(Adapter->RxControlHead,Adapter->RxControlTail,skb); | ||
128 | spin_unlock(&Adapter->control_queue_lock); | ||
129 | |||
130 | atomic_inc(&Adapter->cntrlpktCnt); | ||
131 | wake_up(&Adapter->process_rx_cntrlpkt); | ||
132 | } | ||
133 | else | ||
134 | { | ||
135 | /* | ||
136 | * Data Packet, Format a proper Ethernet Header | ||
137 | * and give it to the stack | ||
138 | */ | ||
139 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_RX, RX_DATA, DBG_LVL_ALL, "Recived Data pkt..."); | ||
140 | skb_reserve(skb, 2 + SKB_RESERVE_PHS_BYTES); | ||
141 | memcpy(skb->data+ETH_HLEN, (PUCHAR)urb->transfer_buffer + sizeof(LEADER), pLeader->PLength); | ||
142 | skb->dev = Adapter->dev; | ||
143 | |||
144 | /* currently skb->len has extra ETH_HLEN bytes in the beginning */ | ||
145 | skb_put (skb, pLeader->PLength + ETH_HLEN); | ||
146 | Adapter->PackInfo[QueueIndex].uiTotalRxBytes+=pLeader->PLength; | ||
147 | Adapter->PackInfo[QueueIndex].uiThisPeriodRxBytes+= pLeader->PLength; | ||
148 | atomic_add(pLeader->PLength, &Adapter->GoodRxByteCount); | ||
149 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_RX, RX_DATA, DBG_LVL_ALL, "Recived Data pkt of len :0x%X", pLeader->PLength); | ||
150 | |||
151 | if(Adapter->if_up) | ||
152 | { | ||
153 | /* Moving ahead by ETH_HLEN to the data ptr as received from FW */ | ||
154 | skb_pull(skb, ETH_HLEN); | ||
155 | PHSRecieve(Adapter, pLeader->Vcid, skb, &skb->len, | ||
156 | NULL,bHeaderSupressionEnabled); | ||
157 | |||
158 | if(!Adapter->PackInfo[QueueIndex].bEthCSSupport) | ||
159 | { | ||
160 | skb_push(skb, ETH_HLEN); | ||
161 | |||
162 | memcpy(skb->data, skb->dev->dev_addr, 6); | ||
163 | memcpy(skb->data+6, skb->dev->dev_addr, 6); | ||
164 | (*(skb->data+11))++; | ||
165 | *(skb->data+12) = 0x08; | ||
166 | *(skb->data+13) = 0x00; | ||
167 | pLeader->PLength+=ETH_HLEN; | ||
168 | } | ||
169 | |||
170 | skb->protocol = eth_type_trans(skb, Adapter->dev); | ||
171 | process_done = netif_rx(skb); | ||
172 | } | ||
173 | else | ||
174 | { | ||
175 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_RX, RX_DATA, DBG_LVL_ALL, "i/f not up hance freeing SKB..."); | ||
176 | bcm_kfree_skb(skb); | ||
177 | } | ||
178 | atomic_inc(&Adapter->GoodRxPktCount); | ||
179 | for(uiIndex = 0 ; uiIndex < MIBS_MAX_HIST_ENTRIES ; uiIndex++) | ||
180 | { | ||
181 | if((pLeader->PLength <= MIBS_PKTSIZEHIST_RANGE*(uiIndex+1)) | ||
182 | && (pLeader->PLength > MIBS_PKTSIZEHIST_RANGE*(uiIndex))) | ||
183 | Adapter->aRxPktSizeHist[uiIndex]++; | ||
184 | } | ||
185 | } | ||
186 | Adapter->PrevNumRecvDescs++; | ||
187 | pRcb->bUsed = FALSE; | ||
188 | atomic_dec(&psIntfAdapter->uNumRcbUsed); | ||
189 | } | ||
190 | |||
191 | static int ReceiveRcb(PS_INTERFACE_ADAPTER psIntfAdapter, PUSB_RCB pRcb) | ||
192 | { | ||
193 | struct urb *urb = pRcb->urb; | ||
194 | int retval = 0; | ||
195 | |||
196 | usb_fill_bulk_urb(urb, psIntfAdapter->udev, usb_rcvbulkpipe( | ||
197 | psIntfAdapter->udev, psIntfAdapter->sBulkIn.bulk_in_endpointAddr), | ||
198 | urb->transfer_buffer, BCM_USB_MAX_READ_LENGTH, read_bulk_callback, | ||
199 | pRcb); | ||
200 | if(FALSE == psIntfAdapter->psAdapter->device_removed && | ||
201 | FALSE == psIntfAdapter->psAdapter->bEndPointHalted && | ||
202 | FALSE == psIntfAdapter->bSuspended && | ||
203 | FALSE == psIntfAdapter->bPreparingForBusSuspend) | ||
204 | { | ||
205 | retval = usb_submit_urb(urb, GFP_ATOMIC); | ||
206 | if (retval) | ||
207 | { | ||
208 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "failed submitting read urb, error %d", retval); | ||
209 | //if this return value is because of pipe halt. need to clear this. | ||
210 | if(retval == -EPIPE) | ||
211 | { | ||
212 | psIntfAdapter->psAdapter->bEndPointHalted = TRUE ; | ||
213 | wake_up(&psIntfAdapter->psAdapter->tx_packet_wait_queue); | ||
214 | } | ||
215 | |||
216 | } | ||
217 | } | ||
218 | return retval; | ||
219 | } | ||
220 | |||
221 | /* | ||
222 | Function: InterfaceRx | ||
223 | |||
224 | Description: This is the hardware specific Function for Recieveing | ||
225 | data packet/control packets from the device. | ||
226 | |||
227 | Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context | ||
228 | |||
229 | |||
230 | |||
231 | Return: TRUE - If Rx was successful. | ||
232 | Other - If an error occured. | ||
233 | */ | ||
234 | |||
235 | BOOLEAN InterfaceRx (PS_INTERFACE_ADAPTER psIntfAdapter) | ||
236 | { | ||
237 | USHORT RxDescCount = NUM_RX_DESC - atomic_read(&psIntfAdapter->uNumRcbUsed); | ||
238 | PUSB_RCB pRcb = NULL; | ||
239 | |||
240 | // RxDescCount = psIntfAdapter->psAdapter->CurrNumRecvDescs - | ||
241 | // psIntfAdapter->psAdapter->PrevNumRecvDescs; | ||
242 | while(RxDescCount) | ||
243 | { | ||
244 | pRcb = GetBulkInRcb(psIntfAdapter); | ||
245 | if(pRcb == NULL) | ||
246 | { | ||
247 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Unable to get Rcb pointer"); | ||
248 | return FALSE; | ||
249 | } | ||
250 | //atomic_inc(&psIntfAdapter->uNumRcbUsed); | ||
251 | ReceiveRcb(psIntfAdapter, pRcb); | ||
252 | RxDescCount--; | ||
253 | } | ||
254 | return TRUE; | ||
255 | } | ||
256 | |||
diff --git a/drivers/staging/bcm/InterfaceRx.h b/drivers/staging/bcm/InterfaceRx.h new file mode 100644 index 00000000000..96e81a1d37b --- /dev/null +++ b/drivers/staging/bcm/InterfaceRx.h | |||
@@ -0,0 +1,7 @@ | |||
1 | #ifndef _INTERFACE_RX_H | ||
2 | #define _INTERFACE_RX_H | ||
3 | |||
4 | BOOLEAN InterfaceRx(PS_INTERFACE_ADAPTER Adapter); | ||
5 | |||
6 | #endif | ||
7 | |||
diff --git a/drivers/staging/bcm/InterfaceTx.c b/drivers/staging/bcm/InterfaceTx.c new file mode 100644 index 00000000000..771f7b34d2e --- /dev/null +++ b/drivers/staging/bcm/InterfaceTx.c | |||
@@ -0,0 +1,259 @@ | |||
1 | #include "headers.h" | ||
2 | |||
3 | #ifndef BCM_SHM_INTERFACE | ||
4 | |||
5 | /* | ||
6 | Function: InterfaceTxDataPacket | ||
7 | |||
8 | Description: This is the hardware specific Function for Transmitting | ||
9 | data packet to the device. | ||
10 | |||
11 | Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context | ||
12 | PVOID Packet - Packet Containing the data to be transmitted | ||
13 | USHORT usVcid - VCID on which data packet is to be sent | ||
14 | |||
15 | |||
16 | Return: BCM_STATUS_SUCCESS - If Tx was successful. | ||
17 | Other - If an error occured. | ||
18 | */ | ||
19 | |||
20 | ULONG InterfaceTxDataPacket(PMINI_ADAPTER Adapter,PVOID Packet,USHORT usVcid) | ||
21 | { | ||
22 | ULONG Status = 0; | ||
23 | return Status; | ||
24 | } | ||
25 | |||
26 | /* | ||
27 | Function: InterfaceTxControlPacket | ||
28 | |||
29 | Description: This is the hardware specific Function for Transmitting | ||
30 | control packet to the device. | ||
31 | |||
32 | Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context | ||
33 | PVOID pvBuffer - Buffer containg control packet | ||
34 | UINT uiBufferLength - Buffer Length | ||
35 | |||
36 | Return: BCM_STATUS_SUCCESS - If control packet transmit was successful. | ||
37 | Other - If an error occured. | ||
38 | */ | ||
39 | |||
40 | ULONG InterfaceTxControlPacket(PMINI_ADAPTER Adapter,PVOID pvBuffer,UINT uiBufferLength) | ||
41 | { | ||
42 | ULONG Status = 0; | ||
43 | |||
44 | |||
45 | |||
46 | return Status; | ||
47 | } | ||
48 | /*this is transmit call-back(BULK OUT)*/ | ||
49 | static void write_bulk_callback(struct urb *urb/*, struct pt_regs *regs*/) | ||
50 | { | ||
51 | PUSB_TCB pTcb= (PUSB_TCB)urb->context; | ||
52 | PS_INTERFACE_ADAPTER psIntfAdapter = pTcb->psIntfAdapter; | ||
53 | CONTROL_MESSAGE *pControlMsg = (CONTROL_MESSAGE *)urb->transfer_buffer; | ||
54 | PMINI_ADAPTER psAdapter = psIntfAdapter->psAdapter ; | ||
55 | BOOLEAN bpowerDownMsg = FALSE ; | ||
56 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
57 | #if 0 | ||
58 | struct timeval tv; | ||
59 | UINT time_ms = 0; | ||
60 | #endif | ||
61 | if(urb->status != STATUS_SUCCESS) | ||
62 | { | ||
63 | if(urb->status == -EPIPE) | ||
64 | { | ||
65 | psIntfAdapter->psAdapter->bEndPointHalted = TRUE ; | ||
66 | wake_up(&psIntfAdapter->psAdapter->tx_packet_wait_queue); | ||
67 | } | ||
68 | else | ||
69 | { | ||
70 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL,"Tx URB has got cancelled. status :%d", urb->status); | ||
71 | } | ||
72 | } | ||
73 | |||
74 | pTcb->bUsed = FALSE; | ||
75 | atomic_dec(&psIntfAdapter->uNumTcbUsed); | ||
76 | |||
77 | |||
78 | |||
79 | if(TRUE == psAdapter->bPreparingForLowPowerMode) | ||
80 | { | ||
81 | #if 0 | ||
82 | do_gettimeofday(&tv); | ||
83 | time_ms = tv.tv_sec *1000 + tv.tv_usec/1000; | ||
84 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, " %s Idle Mode ACK_Sent got from device at time :0x%x", __FUNCTION__, time_ms); | ||
85 | #endif | ||
86 | |||
87 | if(((pControlMsg->szData[0] == GO_TO_IDLE_MODE_PAYLOAD) && | ||
88 | (pControlMsg->szData[1] == TARGET_CAN_GO_TO_IDLE_MODE))) | ||
89 | |||
90 | { | ||
91 | bpowerDownMsg = TRUE ; | ||
92 | //This covers the bus err while Idle Request msg sent down. | ||
93 | if(urb->status != STATUS_SUCCESS) | ||
94 | { | ||
95 | psAdapter->bPreparingForLowPowerMode = FALSE ; | ||
96 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL,"Idle Mode Request msg failed to reach to Modem"); | ||
97 | //Signalling the cntrl pkt path in Ioctl | ||
98 | wake_up(&psAdapter->lowpower_mode_wait_queue); | ||
99 | StartInterruptUrb(psIntfAdapter); | ||
100 | goto err_exit; | ||
101 | } | ||
102 | |||
103 | if(psAdapter->bDoSuspend == FALSE) | ||
104 | { | ||
105 | psAdapter->IdleMode = TRUE; | ||
106 | //since going in Idle mode completed hence making this var false; | ||
107 | psAdapter->bPreparingForLowPowerMode = FALSE ; | ||
108 | |||
109 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Host Entered in Idle Mode State..."); | ||
110 | //Signalling the cntrl pkt path in Ioctl | ||
111 | wake_up(&psAdapter->lowpower_mode_wait_queue); | ||
112 | } | ||
113 | |||
114 | } | ||
115 | else if((pControlMsg->Leader.Status == LINK_UP_CONTROL_REQ) && | ||
116 | (pControlMsg->szData[0] == LINK_UP_ACK) && | ||
117 | (pControlMsg->szData[1] == LINK_SHUTDOWN_REQ_FROM_FIRMWARE) && | ||
118 | (pControlMsg->szData[2] == SHUTDOWN_ACK_FROM_DRIVER)) | ||
119 | { | ||
120 | //This covers the bus err while shutdown Request msg sent down. | ||
121 | if(urb->status != STATUS_SUCCESS) | ||
122 | { | ||
123 | psAdapter->bPreparingForLowPowerMode = FALSE ; | ||
124 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL,"Shutdown Request Msg failed to reach to Modem"); | ||
125 | //Signalling the cntrl pkt path in Ioctl | ||
126 | wake_up(&psAdapter->lowpower_mode_wait_queue); | ||
127 | StartInterruptUrb(psIntfAdapter); | ||
128 | goto err_exit; | ||
129 | } | ||
130 | |||
131 | bpowerDownMsg = TRUE ; | ||
132 | if(psAdapter->bDoSuspend == FALSE) | ||
133 | { | ||
134 | psAdapter->bShutStatus = TRUE; | ||
135 | //since going in shutdown mode completed hence making this var false; | ||
136 | psAdapter->bPreparingForLowPowerMode = FALSE ; | ||
137 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL,"Host Entered in shutdown Mode State..."); | ||
138 | //Signalling the cntrl pkt path in Ioctl | ||
139 | wake_up(&psAdapter->lowpower_mode_wait_queue); | ||
140 | } | ||
141 | } | ||
142 | |||
143 | if(psAdapter->bDoSuspend && bpowerDownMsg) | ||
144 | { | ||
145 | //issuing bus suspend request | ||
146 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL,"Issuing the Bus suspend request to USB stack"); | ||
147 | psIntfAdapter->bPreparingForBusSuspend = TRUE; | ||
148 | schedule_work(&psIntfAdapter->usbSuspendWork); | ||
149 | |||
150 | } | ||
151 | |||
152 | } | ||
153 | |||
154 | err_exit : | ||
155 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35) | ||
156 | usb_buffer_free(urb->dev, urb->transfer_buffer_length, | ||
157 | urb->transfer_buffer, urb->transfer_dma); | ||
158 | #else | ||
159 | usb_free_coherent(urb->dev, urb->transfer_buffer_length, | ||
160 | urb->transfer_buffer, urb->transfer_dma); | ||
161 | #endif | ||
162 | } | ||
163 | |||
164 | |||
165 | static __inline PUSB_TCB GetBulkOutTcb(PS_INTERFACE_ADAPTER psIntfAdapter) | ||
166 | { | ||
167 | PUSB_TCB pTcb = NULL; | ||
168 | UINT index = 0; | ||
169 | |||
170 | if((atomic_read(&psIntfAdapter->uNumTcbUsed) < MAXIMUM_USB_TCB) && | ||
171 | (psIntfAdapter->psAdapter->StopAllXaction ==FALSE)) | ||
172 | { | ||
173 | index = atomic_read(&psIntfAdapter->uCurrTcb); | ||
174 | pTcb = &psIntfAdapter->asUsbTcb[index]; | ||
175 | pTcb->bUsed = TRUE; | ||
176 | pTcb->psIntfAdapter= psIntfAdapter; | ||
177 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Got Tx desc %d used %d", | ||
178 | index, atomic_read(&psIntfAdapter->uNumTcbUsed)); | ||
179 | index = (index + 1) % MAXIMUM_USB_TCB; | ||
180 | atomic_set(&psIntfAdapter->uCurrTcb, index); | ||
181 | atomic_inc(&psIntfAdapter->uNumTcbUsed); | ||
182 | } | ||
183 | return pTcb; | ||
184 | } | ||
185 | |||
186 | static __inline int TransmitTcb(PS_INTERFACE_ADAPTER psIntfAdapter, PUSB_TCB pTcb, PVOID data, int len) | ||
187 | { | ||
188 | |||
189 | struct urb *urb = pTcb->urb; | ||
190 | int retval = 0; | ||
191 | |||
192 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35) | ||
193 | urb->transfer_buffer = usb_buffer_alloc(psIntfAdapter->udev, len, | ||
194 | GFP_ATOMIC, &urb->transfer_dma); | ||
195 | #else | ||
196 | urb->transfer_buffer = usb_alloc_coherent(psIntfAdapter->udev, len, | ||
197 | GFP_ATOMIC, &urb->transfer_dma); | ||
198 | #endif | ||
199 | |||
200 | if (!urb->transfer_buffer) | ||
201 | { | ||
202 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Error allocating memory\n"); | ||
203 | return -ENOMEM; | ||
204 | } | ||
205 | memcpy(urb->transfer_buffer, data, len); | ||
206 | urb->transfer_buffer_length = len; | ||
207 | |||
208 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Sending Bulk out packet\n"); | ||
209 | //For T3B,INT OUT end point will be used as bulk out end point | ||
210 | if((psIntfAdapter->psAdapter->chip_id == T3B) && (psIntfAdapter->bHighSpeedDevice == TRUE)) | ||
211 | { | ||
212 | usb_fill_int_urb(urb, psIntfAdapter->udev, | ||
213 | psIntfAdapter->sBulkOut.bulk_out_pipe, | ||
214 | urb->transfer_buffer, len, write_bulk_callback, pTcb, | ||
215 | psIntfAdapter->sBulkOut.int_out_interval); | ||
216 | } | ||
217 | else | ||
218 | { | ||
219 | usb_fill_bulk_urb(urb, psIntfAdapter->udev, | ||
220 | psIntfAdapter->sBulkOut.bulk_out_pipe, | ||
221 | urb->transfer_buffer, len, write_bulk_callback, pTcb); | ||
222 | } | ||
223 | urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; /* For DMA transfer */ | ||
224 | |||
225 | if(FALSE == psIntfAdapter->psAdapter->device_removed && | ||
226 | FALSE == psIntfAdapter->psAdapter->bEndPointHalted && | ||
227 | FALSE == psIntfAdapter->bSuspended && | ||
228 | FALSE == psIntfAdapter->bPreparingForBusSuspend) | ||
229 | { | ||
230 | retval = usb_submit_urb(urb, GFP_ATOMIC); | ||
231 | if (retval) | ||
232 | { | ||
233 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "failed submitting write urb, error %d", retval); | ||
234 | if(retval == -EPIPE) | ||
235 | { | ||
236 | psIntfAdapter->psAdapter->bEndPointHalted = TRUE ; | ||
237 | wake_up(&psIntfAdapter->psAdapter->tx_packet_wait_queue); | ||
238 | } | ||
239 | } | ||
240 | } | ||
241 | return retval; | ||
242 | } | ||
243 | |||
244 | int InterfaceTransmitPacket(PVOID arg, PVOID data, UINT len) | ||
245 | { | ||
246 | PUSB_TCB pTcb= NULL; | ||
247 | |||
248 | PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)arg; | ||
249 | pTcb= GetBulkOutTcb(psIntfAdapter); | ||
250 | if(pTcb == NULL) | ||
251 | { | ||
252 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "No URB to transmit packet, dropping packet"); | ||
253 | return -EFAULT; | ||
254 | } | ||
255 | return TransmitTcb(psIntfAdapter, pTcb, data, len); | ||
256 | } | ||
257 | |||
258 | #endif | ||
259 | |||
diff --git a/drivers/staging/bcm/InterfaceTx.h b/drivers/staging/bcm/InterfaceTx.h new file mode 100644 index 00000000000..053f631e204 --- /dev/null +++ b/drivers/staging/bcm/InterfaceTx.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef _INTERFACE_TX_H | ||
2 | #define _INTERFACE_TX_H | ||
3 | |||
4 | INT InterfaceTransmitPacket(PVOID arg, PVOID data, UINT len); | ||
5 | |||
6 | |||
7 | ULONG InterfaceTxDataPacket(PMINI_ADAPTER Adapter,PVOID Packet,USHORT usVcid); | ||
8 | |||
9 | ULONG InterfaceTxControlPacket(PMINI_ADAPTER Adapter,PVOID pvBuffer,UINT uiBufferLength); | ||
10 | |||
11 | |||
12 | #endif | ||
13 | |||
diff --git a/drivers/staging/bcm/Interfacemain.h b/drivers/staging/bcm/Interfacemain.h new file mode 100644 index 00000000000..e0db563c5e0 --- /dev/null +++ b/drivers/staging/bcm/Interfacemain.h | |||
@@ -0,0 +1,10 @@ | |||
1 | #ifndef _MAIN_ | ||
2 | #define _MAIN_ | ||
3 | #if 0 | ||
4 | typedef struct _MINI_ADAPTER | ||
5 | { | ||
6 | S_INTERFACE_ADAPTER stInterfaceAdapter; | ||
7 | }MINI_ADAPTER,*PMINI_ADAPTER; | ||
8 | |||
9 | #endif | ||
10 | #endif | ||
diff --git a/drivers/staging/bcm/Ioctl.h b/drivers/staging/bcm/Ioctl.h new file mode 100644 index 00000000000..2651fc2432c --- /dev/null +++ b/drivers/staging/bcm/Ioctl.h | |||
@@ -0,0 +1,360 @@ | |||
1 | #ifndef _IOCTL_H_ | ||
2 | #define _IOCTL_H_ | ||
3 | |||
4 | typedef struct rdmbuffer | ||
5 | { | ||
6 | ULONG Register; | ||
7 | ULONG Length; | ||
8 | }__attribute__((packed)) RDM_BUFFER, *PRDM_BUFFER; | ||
9 | |||
10 | |||
11 | typedef struct wrmbuffer | ||
12 | { | ||
13 | ULONG Register; | ||
14 | ULONG Length; | ||
15 | UCHAR Data[4]; | ||
16 | }__attribute__((packed)) WRM_BUFFER, *PWRM_BUFFER; | ||
17 | |||
18 | |||
19 | typedef struct ioctlbuffer | ||
20 | { | ||
21 | PVOID InputBuffer; | ||
22 | ULONG InputLength; | ||
23 | PVOID OutputBuffer; | ||
24 | ULONG OutputLength; | ||
25 | }__attribute__((packed)) IOCTL_BUFFER, *PIOCTL_BUFFER; | ||
26 | |||
27 | typedef struct stGPIOInfo | ||
28 | { | ||
29 | UINT uiGpioNumber ; /* valid numbers 0-15 */ | ||
30 | UINT uiGpioValue; /* 1 set ; 0 not set */ | ||
31 | }__attribute__((packed))GPIO_INFO,*PGPIO_INFO; | ||
32 | typedef struct stUserThreadReq | ||
33 | { | ||
34 | //0->Inactivate LED thread. | ||
35 | //1->Activate the LED thread | ||
36 | UINT ThreadState; | ||
37 | }__attribute__((packed))USER_THREAD_REQ,*PUSER_THREAD_REQ; | ||
38 | #define LED_THREAD_ACTIVATION_REQ 1 | ||
39 | |||
40 | |||
41 | ////********** ioctl codes ***********//// | ||
42 | |||
43 | #define BCM_IOCTL 'k' | ||
44 | |||
45 | //1.Control code for CONTROL MESSAGES | ||
46 | |||
47 | #define IOCTL_SEND_CONTROL_MESSAGE _IOW(BCM_IOCTL, 0x801,int) | ||
48 | |||
49 | //2.Control code to write a particular value to a particular register | ||
50 | #define IOCTL_BCM_REGISTER_WRITE _IOW(BCM_IOCTL, 0x802, int) // | ||
51 | |||
52 | //3. | ||
53 | #define IOCTL_BCM_REGISTER_READ _IOR(BCM_IOCTL, 0x803, int) // | ||
54 | |||
55 | //4.Control code to write x number of bytes to common memory | ||
56 | //starting from address y | ||
57 | #define IOCTL_BCM_COMMON_MEMORY_WRITE _IOW(BCM_IOCTL, 0x804, int)// | ||
58 | |||
59 | //5.Control code to write x number of bytes to common memory | ||
60 | //starting from address y | ||
61 | #define IOCTL_BCM_COMMON_MEMORY_READ _IOR(BCM_IOCTL, 0x805, int)// | ||
62 | |||
63 | //6.Control code for CONTROL MESSAGES | ||
64 | #define IOCTL_GET_CONTROL_MESSAGE _IOR(BCM_IOCTL, 0x806, int)// | ||
65 | |||
66 | //7.Control code for FIRMWARE DOWNLOAD | ||
67 | #define IOCTL_BCM_FIRMWARE_DOWNLOAD _IOW(BCM_IOCTL, 0x807, int)// | ||
68 | |||
69 | #define IOCTL_BCM_SET_SEND_VCID _IOW(BCM_IOCTL, 0x808, int) | ||
70 | |||
71 | //9.Control code for TRANSFER MODE SWITCHING | ||
72 | #define IOCTL_BCM_SWITCH_TRANSFER_MODE _IOW(BCM_IOCTL, 0x809, int) | ||
73 | //10.Control code for LINK UP | ||
74 | #define IOCTL_LINK_REQ _IOW(BCM_IOCTL, 0x80A, int) | ||
75 | |||
76 | //11.Control code for RSSI Level Request | ||
77 | #define IOCTL_RSSI_LEVEL_REQ _IOW(BCM_IOCTL, 0x80B, int) | ||
78 | //12.Control code for IDLE MODE CONTROL | ||
79 | #define IOCTL_IDLE_REQ _IOW(BCM_IOCTL, 0x80C, int) | ||
80 | //13.Control code for SS/BS info | ||
81 | #define IOCTL_SS_INFO_REQ _IOW(BCM_IOCTL, 0x80D, int) | ||
82 | |||
83 | #define IOCTL_GET_STATISTICS_POINTER _IOW(BCM_IOCTL, 0x80E, int) | ||
84 | |||
85 | #define IOCTL_CM_REQUEST _IOW(BCM_IOCTL, 0x80F, int) | ||
86 | |||
87 | #define IOCTL_INIT_PARAM_REQ _IOW(BCM_IOCTL, 0x810, int) | ||
88 | |||
89 | #define IOCTL_MAC_ADDR_REQ _IOW(BCM_IOCTL, 0x811, int) | ||
90 | |||
91 | #define IOCTL_MAC_ADDR_RESP _IOWR(BCM_IOCTL, 0x812, int) | ||
92 | |||
93 | #define IOCTL_CLASSIFICATION_RULE _IOW(BCM_IOCTL, 0x813, char) | ||
94 | |||
95 | #define IOCTL_CLOSE_NOTIFICATION _IO(BCM_IOCTL, 0x814) | ||
96 | |||
97 | #define IOCTL_LINK_UP _IO(BCM_IOCTL, 0x815) | ||
98 | |||
99 | #define IOCTL_LINK_DOWN _IO(BCM_IOCTL, 0x816, IOCTL_BUFFER) | ||
100 | |||
101 | #define IOCTL_CHIP_RESET _IO(BCM_IOCTL, 0x816) | ||
102 | |||
103 | #define IOCTL_CINR_LEVEL_REQ _IOW(BCM_IOCTL, 0x817, char) | ||
104 | |||
105 | #define IOCTL_WTM_CONTROL_REQ _IOW(BCM_IOCTL, 0x817,char) | ||
106 | |||
107 | #define IOCTL_BE_BUCKET_SIZE _IOW(BCM_IOCTL, 0x818, unsigned long) | ||
108 | |||
109 | #define IOCTL_RTPS_BUCKET_SIZE _IOW(BCM_IOCTL, 0x819, unsigned long) | ||
110 | |||
111 | #define IOCTL_QOS_THRESHOLD _IOW(BCM_IOCTL, 0x820, unsigned long) | ||
112 | |||
113 | #define IOCTL_DUMP_PACKET_INFO _IO(BCM_IOCTL, 0x821) | ||
114 | |||
115 | #define IOCTL_GET_PACK_INFO _IOR(BCM_IOCTL, 0x823, int) | ||
116 | |||
117 | #define IOCTL_BCM_GET_DRIVER_VERSION _IOR(BCM_IOCTL, 0x829, int) | ||
118 | |||
119 | #define IOCTL_BCM_GET_CURRENT_STATUS _IOW(BCM_IOCTL, 0x828, int) | ||
120 | |||
121 | #define IOCTL_BCM_GPIO_SET_REQUEST _IOW(BCM_IOCTL, 0x82A, int) | ||
122 | |||
123 | #define IOCTL_BCM_GPIO_STATUS_REQUEST _IOW(BCM_IOCTL, 0x82b, int) | ||
124 | |||
125 | #define IOCTL_BCM_GET_DSX_INDICATION _IOR(BCM_IOCTL, 0x854, int) | ||
126 | |||
127 | #define IOCTL_BCM_BUFFER_DOWNLOAD_START _IOW(BCM_IOCTL, 0x855, int) | ||
128 | |||
129 | #define IOCTL_BCM_BUFFER_DOWNLOAD _IOW(BCM_IOCTL, 0x856, int) | ||
130 | |||
131 | #define IOCTL_BCM_BUFFER_DOWNLOAD_STOP _IOW(BCM_IOCTL, 0x857, int) | ||
132 | |||
133 | #define IOCTL_BCM_REGISTER_WRITE_PRIVATE _IOW(BCM_IOCTL, 0x826, char) | ||
134 | |||
135 | #define IOCTL_BCM_REGISTER_READ_PRIVATE _IOW(BCM_IOCTL, 0x827, char) | ||
136 | |||
137 | #define IOCTL_BCM_SET_DEBUG _IOW(BCM_IOCTL, 0x824, IOCTL_BUFFER) | ||
138 | |||
139 | #define IOCTL_BCM_EEPROM_REGISTER_WRITE _IOW(BCM_IOCTL, 0x858, int) | ||
140 | |||
141 | #define IOCTL_BCM_EEPROM_REGISTER_READ _IOR(BCM_IOCTL, 0x859, int) | ||
142 | |||
143 | #define IOCTL_BCM_WAKE_UP_DEVICE_FROM_IDLE _IOR(BCM_IOCTL, 0x860, int) | ||
144 | |||
145 | #define IOCTL_BCM_SET_MAC_TRACING _IOW(BCM_IOCTL, 0x82c, int) | ||
146 | |||
147 | #define IOCTL_BCM_GET_HOST_MIBS _IOW(BCM_IOCTL, 0x853, int) | ||
148 | |||
149 | #define IOCTL_BCM_NVM_READ _IOR(BCM_IOCTL, 0x861, int) | ||
150 | |||
151 | #define IOCTL_BCM_NVM_WRITE _IOW(BCM_IOCTL, 0x862, int) | ||
152 | |||
153 | #define IOCTL_BCM_GET_NVM_SIZE _IOR(BCM_IOCTL, 0x863, int) | ||
154 | |||
155 | #define IOCTL_BCM_CAL_INIT _IOR(BCM_IOCTL, 0x864, int) | ||
156 | |||
157 | #define IOCTL_BCM_BULK_WRM _IOW(BCM_IOCTL, 0x90B, int) | ||
158 | |||
159 | #define IOCTL_BCM_FLASH2X_SECTION_READ _IOR(BCM_IOCTL, 0x865, int) | ||
160 | |||
161 | #define IOCTL_BCM_FLASH2X_SECTION_WRITE _IOW(BCM_IOCTL, 0x866, int) | ||
162 | |||
163 | #define IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP _IOR(BCM_IOCTL,0x867, int) | ||
164 | |||
165 | #define IOCTL_BCM_SET_ACTIVE_SECTION _IOW(BCM_IOCTL,0x868, int) | ||
166 | |||
167 | #define IOCTL_BCM_IDENTIFY_ACTIVE_SECTION _IO(BCM_IOCTL,0x869) | ||
168 | |||
169 | #define IOCTL_BCM_COPY_SECTION _IOW(BCM_IOCTL, 0x870,int) | ||
170 | |||
171 | #define IOCTL_BCM_GET_FLASH_CS_INFO _IOR(BCM_IOCTL, 0x871, int) | ||
172 | |||
173 | #define IOCTL_BCM_SELECT_DSD _IOW(BCM_IOCTL, 0x872, int) | ||
174 | |||
175 | #define IOCTL_BCM_NVM_RAW_READ _IOR(BCM_IOCTL, 0x875, int) | ||
176 | |||
177 | #define IOCTL_BCM_CNTRLMSG_MASK _IOW(BCM_IOCTL, 0x874, int) | ||
178 | |||
179 | #define IOCTL_BCM_GET_DEVICE_DRIVER_INFO _IOR(BCM_IOCTL, 0x877, int) | ||
180 | |||
181 | #define IOCTL_BCM_TIME_SINCE_NET_ENTRY _IOR(BCM_IOCTL, 0x876, int) | ||
182 | |||
183 | #define BCM_LED_THREAD_STATE_CHANGE_REQ _IOW(BCM_IOCTL, 0x878, int) | ||
184 | |||
185 | #define IOCTL_BCM_GPIO_MULTI_REQUEST _IOW(BCM_IOCTL, 0x82D, IOCTL_BUFFER) | ||
186 | #define IOCTL_BCM_GPIO_MODE_REQUEST _IOW(BCM_IOCTL, 0x82E, IOCTL_BUFFER) | ||
187 | |||
188 | |||
189 | |||
190 | typedef enum _BCM_INTERFACE_TYPE | ||
191 | { | ||
192 | BCM_MII, | ||
193 | BCM_CARDBUS, | ||
194 | BCM_USB, | ||
195 | BCM_SDIO, | ||
196 | BCM_PCMCIA | ||
197 | }BCM_INTERFACE_TYPE; | ||
198 | |||
199 | typedef struct _DEVICE_DRIVER_INFO | ||
200 | { | ||
201 | NVM_TYPE u32NVMType; | ||
202 | UINT MaxRDMBufferSize; | ||
203 | BCM_INTERFACE_TYPE u32InterfaceType; | ||
204 | UINT u32DSDStartOffset; | ||
205 | UINT u32RxAlignmentCorrection; | ||
206 | UINT u32Reserved[10]; | ||
207 | } DEVICE_DRIVER_INFO; | ||
208 | |||
209 | typedef struct _NVM_READWRITE | ||
210 | { | ||
211 | |||
212 | void *pBuffer; | ||
213 | // Data to be written from|read to. Memory should be allocated by the caller. | ||
214 | |||
215 | uint32_t uiOffset; | ||
216 | // offset at which data should be written to or read from. | ||
217 | |||
218 | uint32_t uiNumBytes; | ||
219 | // No. of bytes to be written or read. | ||
220 | |||
221 | bool bVerify; | ||
222 | // Applicable only for write. If set verification of written data will be done. | ||
223 | |||
224 | } NVM_READWRITE,*PNVM_READWRITE; | ||
225 | typedef struct bulkwrmbuffer | ||
226 | { | ||
227 | ULONG Register; | ||
228 | ULONG SwapEndian; | ||
229 | ULONG Values[1]; | ||
230 | |||
231 | }BULKWRM_BUFFER,*PBULKWRM_BUFFER; | ||
232 | |||
233 | |||
234 | /***********Structure used for FlashMap2.x *******************************/ | ||
235 | |||
236 | /* | ||
237 | * These are Sction present inside the Flash. | ||
238 | * There is sectional RD/WR for flash Map 2.x. | ||
239 | * hence these section will be used in read/write API. | ||
240 | */ | ||
241 | |||
242 | typedef enum _FLASH2X_SECTION_VAL | ||
243 | { | ||
244 | NO_SECTION_VAL = 0, //no section is choosen when absolute offset is given for RD/WR | ||
245 | ISO_IMAGE1, | ||
246 | ISO_IMAGE2, | ||
247 | DSD0, | ||
248 | DSD1, | ||
249 | DSD2, | ||
250 | VSA0, | ||
251 | VSA1, | ||
252 | VSA2, | ||
253 | SCSI, | ||
254 | CONTROL_SECTION, | ||
255 | ISO_IMAGE1_PART2, | ||
256 | ISO_IMAGE1_PART3, | ||
257 | ISO_IMAGE2_PART2, | ||
258 | ISO_IMAGE2_PART3, | ||
259 | TOTAL_SECTIONS | ||
260 | }FLASH2X_SECTION_VAL; | ||
261 | |||
262 | /* | ||
263 | * Structure used for READ/WRITE Flash Map2.x | ||
264 | */ | ||
265 | typedef struct _FLASH2X_READWRITE | ||
266 | { | ||
267 | |||
268 | FLASH2X_SECTION_VAL Section; //which section has to be read/written | ||
269 | B_UINT32 offset; //Offset within Section. | ||
270 | B_UINT32 numOfBytes; //NOB from the offset | ||
271 | B_UINT32 bVerify; | ||
272 | PVOID pDataBuff; //Buffer for reading/writing | ||
273 | |||
274 | }FLASH2X_READWRITE, *PFLASH2X_READWRITE; | ||
275 | /* | ||
276 | * This structure is used for coping one section to other. | ||
277 | * there are two ways to copy one section to other. | ||
278 | * it NOB =0, complete section will be copied on to other. | ||
279 | * if NOB !=0, only NOB will be copied from the given offset. | ||
280 | */ | ||
281 | |||
282 | typedef struct _FLASH2X_COPY_SECTION | ||
283 | { | ||
284 | //Src Section from which Data has to be copied to DstSection | ||
285 | FLASH2X_SECTION_VAL SrcSection; | ||
286 | |||
287 | //Destination Section from where Data has to be coppied. | ||
288 | FLASH2X_SECTION_VAL DstSection; | ||
289 | |||
290 | //Offset within Section. if NOB =0 it will be ignored and data will be coped from offset 0. | ||
291 | B_UINT32 offset; | ||
292 | |||
293 | //NOB from the offset. if NOB = 0 complete src section will be copied to Destination section. | ||
294 | B_UINT32 numOfBytes; | ||
295 | } FLASH2X_COPY_SECTION, *PFLASH2X_COPY_SECTION; | ||
296 | |||
297 | |||
298 | typedef enum _SECTION_TYPE | ||
299 | { | ||
300 | ISO = 0, | ||
301 | VSA = 1, | ||
302 | DSD = 2 | ||
303 | } SECTION_TYPE, *PSECTION_TYPE; | ||
304 | |||
305 | /* | ||
306 | * This section provide the complete bitmap of the Flash. | ||
307 | * using this map lib/APP will isssue read/write command. | ||
308 | Fields are defined as : | ||
309 | Bit [0] = section is present //1:present, 0: Not present | ||
310 | * Bit [1] = section is valid //1: valid, 0: not valid | ||
311 | * Bit [2] = Section is R/W //0: RW, 1: RO | ||
312 | * Bit [3] = Section is Active or not 1 means Active, 0->inactive | ||
313 | * Bit [7...3] = Reserved | ||
314 | */ | ||
315 | |||
316 | typedef struct _FLASH2X_BITMAP | ||
317 | { | ||
318 | UCHAR ISO_IMAGE1; | ||
319 | UCHAR ISO_IMAGE2; | ||
320 | UCHAR DSD0; | ||
321 | UCHAR DSD1; | ||
322 | UCHAR DSD2; | ||
323 | UCHAR VSA0; | ||
324 | UCHAR VSA1; | ||
325 | UCHAR VSA2; | ||
326 | UCHAR SCSI; | ||
327 | UCHAR CONTROL_SECTION; | ||
328 | //Reserved for future use | ||
329 | UCHAR Reserved0; | ||
330 | UCHAR Reserved1; | ||
331 | UCHAR Reserved2; | ||
332 | }FLASH2X_BITMAP, *PFLASH2X_BITMAP; | ||
333 | |||
334 | //for net entry time check | ||
335 | typedef struct _ST_TIME_ELAPSED_ | ||
336 | { | ||
337 | ULONG64 ul64TimeElapsedSinceNetEntry; | ||
338 | UINT32 uiReserved[4]; //By chance if required for future proofing | ||
339 | }ST_TIME_ELAPSED,*PST_TIME_ELAPSED; | ||
340 | |||
341 | enum { | ||
342 | WIMAX_IDX=0, /*To access WiMAX chip GPIO's for GPIO_MULTI_INFO or GPIO_MULTI_MODE*/ | ||
343 | HOST_IDX, /*To access Host chip GPIO's for GPIO_MULTI_INFO or GPIO_MULTI_MODE*/ | ||
344 | MAX_IDX | ||
345 | }; | ||
346 | typedef struct stGPIOMultiInfo | ||
347 | { | ||
348 | UINT uiGPIOCommand; /* 1 for set and 0 for get*/ | ||
349 | UINT uiGPIOMask; /* set the correspondig bit to 1 to access GPIO*/ | ||
350 | UINT uiGPIOValue; /* 0 or 1; value to be set when command is 1.*/ | ||
351 | }__attribute__((packed))GPIO_MULTI_INFO , *PGPIO_MULTI_INFO; | ||
352 | |||
353 | typedef struct stGPIOMultiMode | ||
354 | { | ||
355 | UINT uiGPIOMode; /* 1 for OUT mode, 0 for IN mode*/ | ||
356 | UINT uiGPIOMask; /* GPIO mask to set mode*/ | ||
357 | }__attribute__((packed))GPIO_MULTI_MODE, *PGPIO_MULTI_MODE; | ||
358 | |||
359 | |||
360 | #endif | ||
diff --git a/drivers/staging/bcm/Kconfig b/drivers/staging/bcm/Kconfig new file mode 100644 index 00000000000..96adb1026c4 --- /dev/null +++ b/drivers/staging/bcm/Kconfig | |||
@@ -0,0 +1,7 @@ | |||
1 | config BCM_WIMAX | ||
2 | tristate "Beceem BCS200/BCS220-3 and BCSM250 wimax support" | ||
3 | depends on USB && NET && EXPERIMENTAL | ||
4 | default N | ||
5 | help | ||
6 | This is an experimental driver for the Beceem WIMAX chipset used | ||
7 | by Sprint 4G. | ||
diff --git a/drivers/staging/bcm/LeakyBucket.c b/drivers/staging/bcm/LeakyBucket.c new file mode 100644 index 00000000000..1875c828901 --- /dev/null +++ b/drivers/staging/bcm/LeakyBucket.c | |||
@@ -0,0 +1,399 @@ | |||
1 | /********************************************************************** | ||
2 | * LEAKYBUCKET.C | ||
3 | * This file contains the routines related to Leaky Bucket Algorithm. | ||
4 | ***********************************************************************/ | ||
5 | #include "headers.h" | ||
6 | |||
7 | /********************************************************************* | ||
8 | * Function - UpdateTokenCount() | ||
9 | * | ||
10 | * Description - This function calculates the token count for each | ||
11 | * channel and updates the same in Adapter strucuture. | ||
12 | * | ||
13 | * Parameters - Adapter: Pointer to the Adapter structure. | ||
14 | * | ||
15 | * Returns - None | ||
16 | **********************************************************************/ | ||
17 | |||
18 | VOID UpdateTokenCount(register PMINI_ADAPTER Adapter) | ||
19 | { | ||
20 | ULONG liCurrentTime; | ||
21 | INT i = 0; | ||
22 | struct timeval tv; | ||
23 | |||
24 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "=====>\n"); | ||
25 | if(NULL == Adapter) | ||
26 | { | ||
27 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "Adapter found NULL!\n"); | ||
28 | return; | ||
29 | } | ||
30 | |||
31 | do_gettimeofday(&tv); | ||
32 | for(i = 0; i < NO_OF_QUEUES; i++) | ||
33 | { | ||
34 | if(TRUE == Adapter->PackInfo[i].bValid && | ||
35 | (1 == Adapter->PackInfo[i].ucDirection)) | ||
36 | { | ||
37 | liCurrentTime = ((tv.tv_sec- | ||
38 | Adapter->PackInfo[i].stLastUpdateTokenAt.tv_sec)*1000 + | ||
39 | (tv.tv_usec-Adapter->PackInfo[i].stLastUpdateTokenAt.tv_usec)/ | ||
40 | 1000); | ||
41 | if(0!=liCurrentTime) | ||
42 | { | ||
43 | Adapter->PackInfo[i].uiCurrentTokenCount += (ULONG) | ||
44 | ((Adapter->PackInfo[i].uiMaxAllowedRate) * | ||
45 | ((ULONG)((liCurrentTime)))/1000); | ||
46 | memcpy(&Adapter->PackInfo[i].stLastUpdateTokenAt, | ||
47 | &tv, sizeof(struct timeval)); | ||
48 | Adapter->PackInfo[i].liLastUpdateTokenAt = liCurrentTime; | ||
49 | if((Adapter->PackInfo[i].uiCurrentTokenCount) >= | ||
50 | Adapter->PackInfo[i].uiMaxBucketSize) | ||
51 | { | ||
52 | Adapter->PackInfo[i].uiCurrentTokenCount = | ||
53 | Adapter->PackInfo[i].uiMaxBucketSize; | ||
54 | } | ||
55 | } | ||
56 | } | ||
57 | } | ||
58 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "<=====\n"); | ||
59 | return; | ||
60 | |||
61 | } | ||
62 | |||
63 | |||
64 | /********************************************************************* | ||
65 | * Function - IsPacketAllowedForFlow() | ||
66 | * | ||
67 | * Description - This function checks whether the given packet from the | ||
68 | * specified queue can be allowed for transmission by | ||
69 | * checking the token count. | ||
70 | * | ||
71 | * Parameters - Adapter : Pointer to the Adpater structure. | ||
72 | * - iQIndex : The queue Identifier. | ||
73 | * - ulPacketLength: Number of bytes to be transmitted. | ||
74 | * | ||
75 | * Returns - The number of bytes allowed for transmission. | ||
76 | * | ||
77 | ***********************************************************************/ | ||
78 | static __inline ULONG GetSFTokenCount(PMINI_ADAPTER Adapter, PacketInfo *psSF) | ||
79 | { | ||
80 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IsPacketAllowedForFlow ===>"); | ||
81 | /* Validate the parameters */ | ||
82 | if(NULL == Adapter || (psSF < Adapter->PackInfo && | ||
83 | (UINT)psSF > (UINT) &Adapter->PackInfo[HiPriority])) | ||
84 | { | ||
85 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IPAFF: Got wrong Parameters:Adapter: %p, QIndex: %d\n", Adapter, (psSF-Adapter->PackInfo)); | ||
86 | return 0; | ||
87 | } | ||
88 | |||
89 | if(FALSE != psSF->bValid && psSF->ucDirection) | ||
90 | { | ||
91 | if(0 != psSF->uiCurrentTokenCount) | ||
92 | { | ||
93 | return psSF->uiCurrentTokenCount; | ||
94 | } | ||
95 | else | ||
96 | { | ||
97 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "Not enough tokens in queue %d Available %u\n", | ||
98 | psSF-Adapter->PackInfo, psSF->uiCurrentTokenCount); | ||
99 | psSF->uiPendedLast = 1; | ||
100 | } | ||
101 | } | ||
102 | else | ||
103 | { | ||
104 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IPAFF: Queue %d not valid\n", psSF-Adapter->PackInfo); | ||
105 | } | ||
106 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IsPacketAllowedForFlow <==="); | ||
107 | return 0; | ||
108 | } | ||
109 | |||
110 | static __inline void RemovePacketFromQueue(PacketInfo *pPackInfo , struct sk_buff *Packet) | ||
111 | { | ||
112 | struct sk_buff *psQueueCurrent=NULL, *psLastQueueNode=NULL; | ||
113 | psQueueCurrent = pPackInfo->FirstTxQueue; | ||
114 | while(psQueueCurrent) | ||
115 | { | ||
116 | if((UINT)Packet == (UINT)psQueueCurrent) | ||
117 | { | ||
118 | if((UINT)psQueueCurrent == (UINT)pPackInfo->FirstTxQueue) | ||
119 | { | ||
120 | pPackInfo->FirstTxQueue=psQueueCurrent->next; | ||
121 | if((UINT)psQueueCurrent==(UINT)pPackInfo->LastTxQueue) | ||
122 | pPackInfo->LastTxQueue=NULL; | ||
123 | } | ||
124 | else | ||
125 | { | ||
126 | psLastQueueNode->next=psQueueCurrent->next; | ||
127 | } | ||
128 | break; | ||
129 | } | ||
130 | psLastQueueNode = psQueueCurrent; | ||
131 | psQueueCurrent=psQueueCurrent->next; | ||
132 | } | ||
133 | } | ||
134 | /** | ||
135 | @ingroup tx_functions | ||
136 | This function despatches packet from the specified queue. | ||
137 | @return Zero(success) or Negative value(failure) | ||
138 | */ | ||
139 | static __inline INT SendPacketFromQueue(PMINI_ADAPTER Adapter,/**<Logical Adapter*/ | ||
140 | PacketInfo *psSF, /**<Queue identifier*/ | ||
141 | struct sk_buff* Packet) /**<Pointer to the packet to be sent*/ | ||
142 | { | ||
143 | INT Status=STATUS_FAILURE; | ||
144 | UINT uiIndex =0,PktLen = 0; | ||
145 | |||
146 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, SEND_QUEUE, DBG_LVL_ALL, "=====>"); | ||
147 | if(!Adapter || !Packet || !psSF) | ||
148 | { | ||
149 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, SEND_QUEUE, DBG_LVL_ALL, "Got NULL Adapter or Packet"); | ||
150 | return -EINVAL; | ||
151 | } | ||
152 | |||
153 | if(psSF->liDrainCalculated==0) | ||
154 | { | ||
155 | psSF->liDrainCalculated = jiffies; | ||
156 | } | ||
157 | ///send the packet to the fifo.. | ||
158 | PktLen = Packet->len; | ||
159 | Status = SetupNextSend(Adapter, Packet, psSF->usVCID_Value); | ||
160 | if(Status == 0) | ||
161 | { | ||
162 | for(uiIndex = 0 ; uiIndex < MIBS_MAX_HIST_ENTRIES ; uiIndex++) | ||
163 | { if((PktLen <= MIBS_PKTSIZEHIST_RANGE*(uiIndex+1)) && (PktLen > MIBS_PKTSIZEHIST_RANGE*(uiIndex))) | ||
164 | Adapter->aTxPktSizeHist[uiIndex]++; | ||
165 | } | ||
166 | } | ||
167 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, SEND_QUEUE, DBG_LVL_ALL, "<====="); | ||
168 | return Status; | ||
169 | } | ||
170 | |||
171 | /************************************************************************ | ||
172 | * Function - CheckAndSendPacketFromIndex() | ||
173 | * | ||
174 | * Description - This function dequeues the data/control packet from the | ||
175 | * specified queue for transmission. | ||
176 | * | ||
177 | * Parameters - Adapter : Pointer to the driver control structure. | ||
178 | * - iQIndex : The queue Identifier. | ||
179 | * | ||
180 | * Returns - None. | ||
181 | * | ||
182 | ****************************************************************************/ | ||
183 | static __inline VOID CheckAndSendPacketFromIndex | ||
184 | (PMINI_ADAPTER Adapter, PacketInfo *psSF) | ||
185 | { | ||
186 | struct sk_buff *QueuePacket=NULL; | ||
187 | char *pControlPacket = NULL; | ||
188 | INT Status=0; | ||
189 | int iPacketLen=0; | ||
190 | |||
191 | |||
192 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "%d ====>", (psSF-Adapter->PackInfo)); | ||
193 | if(((UINT)psSF != (UINT)&Adapter->PackInfo[HiPriority]) && Adapter->LinkUpStatus && atomic_read(&psSF->uiPerSFTxResourceCount))//Get data packet | ||
194 | { | ||
195 | if(!psSF->ucDirection ) | ||
196 | return; | ||
197 | |||
198 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "UpdateTokenCount "); | ||
199 | if(Adapter->IdleMode || Adapter->bPreparingForLowPowerMode) | ||
200 | { | ||
201 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Device is in Idle Mode..Hence blocking Data Packets..\n"); | ||
202 | return; | ||
203 | } | ||
204 | // Check for Free Descriptors | ||
205 | if(atomic_read(&Adapter->CurrNumFreeTxDesc) <= MINIMUM_PENDING_DESCRIPTORS) | ||
206 | { | ||
207 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, " No Free Tx Descriptor(%d) is available for Data pkt..",atomic_read(&Adapter->CurrNumFreeTxDesc)); | ||
208 | return ; | ||
209 | } | ||
210 | |||
211 | #if 0 | ||
212 | PruneQueue(Adapter,(psSF-Adapter->PackInfo)); | ||
213 | #endif | ||
214 | spin_lock_bh(&psSF->SFQueueLock); | ||
215 | QueuePacket=psSF->FirstTxQueue; | ||
216 | |||
217 | if(QueuePacket) | ||
218 | { | ||
219 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Dequeuing Data Packet"); | ||
220 | |||
221 | if(psSF->bEthCSSupport) | ||
222 | iPacketLen = QueuePacket->len; | ||
223 | else | ||
224 | iPacketLen = QueuePacket->len-ETH_HLEN; | ||
225 | |||
226 | iPacketLen<<=3; | ||
227 | if(iPacketLen <= GetSFTokenCount(Adapter, psSF)) | ||
228 | { | ||
229 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Allowed bytes %d", | ||
230 | (iPacketLen >> 3)); | ||
231 | |||
232 | DEQUEUEPACKET(psSF->FirstTxQueue,psSF->LastTxQueue); | ||
233 | psSF->uiCurrentBytesOnHost -= (QueuePacket->len); | ||
234 | psSF->uiCurrentPacketsOnHost--; | ||
235 | atomic_dec(&Adapter->TotalPacketCount); | ||
236 | spin_unlock_bh(&psSF->SFQueueLock); | ||
237 | |||
238 | Status = SendPacketFromQueue(Adapter, psSF, QueuePacket); | ||
239 | psSF->uiPendedLast = FALSE; | ||
240 | } | ||
241 | else | ||
242 | { | ||
243 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "For Queue: %d\n", psSF-Adapter->PackInfo); | ||
244 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "\nAvailable Tokens = %d required = %d\n", | ||
245 | psSF->uiCurrentTokenCount, iPacketLen); | ||
246 | //this part indicates that becuase of non-availability of the tokens | ||
247 | //pkt has not been send out hence setting the pending flag indicating the host to send it out | ||
248 | //first next iteration . | ||
249 | psSF->uiPendedLast = TRUE; | ||
250 | spin_unlock_bh(&psSF->SFQueueLock); | ||
251 | } | ||
252 | } | ||
253 | else | ||
254 | { | ||
255 | spin_unlock_bh(&psSF->SFQueueLock); | ||
256 | } | ||
257 | } | ||
258 | else | ||
259 | { | ||
260 | |||
261 | if((atomic_read(&Adapter->CurrNumFreeTxDesc) > 0 ) && | ||
262 | (atomic_read(&Adapter->index_rd_txcntrlpkt) != | ||
263 | atomic_read(&Adapter->index_wr_txcntrlpkt)) | ||
264 | ) | ||
265 | { | ||
266 | pControlPacket = Adapter->txctlpacket | ||
267 | [(atomic_read(&Adapter->index_rd_txcntrlpkt)%MAX_CNTRL_PKTS)]; | ||
268 | if(pControlPacket) | ||
269 | { | ||
270 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Sending Control packet"); | ||
271 | Status = SendControlPacket(Adapter, pControlPacket); | ||
272 | if(STATUS_SUCCESS==Status) | ||
273 | { | ||
274 | spin_lock_bh(&psSF->SFQueueLock); | ||
275 | psSF->NumOfPacketsSent++; | ||
276 | psSF->uiSentBytes+=((PLEADER)pControlPacket)->PLength; | ||
277 | psSF->uiSentPackets++; | ||
278 | atomic_dec(&Adapter->TotalPacketCount); | ||
279 | psSF->uiCurrentBytesOnHost -= ((PLEADER)pControlPacket)->PLength; | ||
280 | psSF->uiCurrentPacketsOnHost--; | ||
281 | atomic_inc(&Adapter->index_rd_txcntrlpkt); | ||
282 | spin_unlock_bh(&psSF->SFQueueLock); | ||
283 | } | ||
284 | else | ||
285 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "SendControlPacket Failed\n"); | ||
286 | } | ||
287 | else | ||
288 | { | ||
289 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, " Control Pkt is not available, Indexing is wrong...."); | ||
290 | } | ||
291 | } | ||
292 | } | ||
293 | |||
294 | if(Status != STATUS_SUCCESS) //Tx of data packet to device Failed | ||
295 | { | ||
296 | if(Adapter->bcm_jiffies == 0) | ||
297 | Adapter->bcm_jiffies = jiffies; | ||
298 | } | ||
299 | else | ||
300 | { | ||
301 | Adapter->bcm_jiffies = 0; | ||
302 | } | ||
303 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "<====="); | ||
304 | } | ||
305 | |||
306 | |||
307 | /******************************************************************* | ||
308 | * Function - transmit_packets() | ||
309 | * | ||
310 | * Description - This function transmits the packets from different | ||
311 | * queues, if free descriptors are available on target. | ||
312 | * | ||
313 | * Parameters - Adapter: Pointer to the Adapter structure. | ||
314 | * | ||
315 | * Returns - None. | ||
316 | ********************************************************************/ | ||
317 | VOID transmit_packets(PMINI_ADAPTER Adapter) | ||
318 | { | ||
319 | UINT uiPrevTotalCount = 0; | ||
320 | int iIndex = 0; | ||
321 | |||
322 | BOOLEAN exit_flag = TRUE ; | ||
323 | |||
324 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "=====>"); | ||
325 | |||
326 | if(NULL == Adapter) | ||
327 | { | ||
328 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX,TX_PACKETS, DBG_LVL_ALL, "Got NULL Adapter"); | ||
329 | return; | ||
330 | } | ||
331 | if(Adapter->device_removed == TRUE) | ||
332 | { | ||
333 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Device removed"); | ||
334 | return; | ||
335 | } | ||
336 | |||
337 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "\nUpdateTokenCount ====>\n"); | ||
338 | |||
339 | UpdateTokenCount(Adapter); | ||
340 | |||
341 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "\nPruneQueueAllSF ====>\n"); | ||
342 | |||
343 | PruneQueueAllSF(Adapter); | ||
344 | |||
345 | uiPrevTotalCount = atomic_read(&Adapter->TotalPacketCount); | ||
346 | |||
347 | for(iIndex=HiPriority;iIndex>=0;iIndex--) | ||
348 | { | ||
349 | if( !uiPrevTotalCount || (TRUE == Adapter->device_removed)) | ||
350 | break; | ||
351 | |||
352 | if(Adapter->PackInfo[iIndex].bValid && | ||
353 | Adapter->PackInfo[iIndex].uiPendedLast && | ||
354 | Adapter->PackInfo[iIndex].uiCurrentBytesOnHost) | ||
355 | { | ||
356 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Calling CheckAndSendPacketFromIndex.."); | ||
357 | CheckAndSendPacketFromIndex(Adapter, &Adapter->PackInfo[iIndex]); | ||
358 | uiPrevTotalCount--; | ||
359 | } | ||
360 | } | ||
361 | |||
362 | while(uiPrevTotalCount > 0 && !Adapter->device_removed) | ||
363 | { | ||
364 | exit_flag = TRUE ; | ||
365 | //second iteration to parse non-pending queues | ||
366 | for(iIndex=HiPriority;iIndex>=0;iIndex--) | ||
367 | { | ||
368 | if( !uiPrevTotalCount || (TRUE == Adapter->device_removed)) | ||
369 | break; | ||
370 | |||
371 | if(Adapter->PackInfo[iIndex].bValid && | ||
372 | Adapter->PackInfo[iIndex].uiCurrentBytesOnHost && | ||
373 | !Adapter->PackInfo[iIndex].uiPendedLast ) | ||
374 | { | ||
375 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Calling CheckAndSendPacketFromIndex.."); | ||
376 | CheckAndSendPacketFromIndex(Adapter, &Adapter->PackInfo[iIndex]); | ||
377 | uiPrevTotalCount--; | ||
378 | exit_flag = FALSE; | ||
379 | } | ||
380 | } | ||
381 | |||
382 | if(Adapter->IdleMode || Adapter->bPreparingForLowPowerMode) | ||
383 | { | ||
384 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "In Idle Mode\n"); | ||
385 | break; | ||
386 | } | ||
387 | if(exit_flag == TRUE ) | ||
388 | break ; | ||
389 | }/* end of inner while loop */ | ||
390 | if(Adapter->bcm_jiffies == 0 && | ||
391 | atomic_read(&Adapter->TotalPacketCount) != 0 && | ||
392 | uiPrevTotalCount == atomic_read(&Adapter->TotalPacketCount)) | ||
393 | { | ||
394 | Adapter->bcm_jiffies = jiffies; | ||
395 | } | ||
396 | update_per_cid_rx (Adapter); | ||
397 | Adapter->txtransmit_running = 0; | ||
398 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "<======"); | ||
399 | } | ||
diff --git a/drivers/staging/bcm/Macros.h b/drivers/staging/bcm/Macros.h new file mode 100644 index 00000000000..f559b599bd2 --- /dev/null +++ b/drivers/staging/bcm/Macros.h | |||
@@ -0,0 +1,399 @@ | |||
1 | /************************************* | ||
2 | * Macros.h | ||
3 | **************************************/ | ||
4 | #ifndef __MACROS_H__ | ||
5 | #define __MACROS_H__ | ||
6 | |||
7 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) | ||
8 | #define kthread_run(threadfn,data,datafmt)(struct task_struct *)kernel_thread(threadfn,data,0) | ||
9 | #endif | ||
10 | |||
11 | #define TX_TIMER_PERIOD 10 //10 msec | ||
12 | #define MAX_CLASSIFIERS 100 | ||
13 | //#define MAX_CLASSIFIERS_PER_SF 20 | ||
14 | #define MAX_TARGET_DSX_BUFFERS 24 | ||
15 | |||
16 | #define MAX_CNTRL_PKTS 100 | ||
17 | #define MAX_DATA_PKTS 200 | ||
18 | #define MAX_ETH_SIZE 1536 | ||
19 | #define MAX_CNTL_PKT_SIZE 2048 | ||
20 | /* TIMER RELATED */ | ||
21 | #define JIFFIES_2_QUADPART() (ULONG)(jiffies * 10000) // jiffies(1msec) to Quadpart(100nsec) | ||
22 | |||
23 | #define MTU_SIZE 1400 | ||
24 | |||
25 | #define MAC_ADDR_REGISTER 0xbf60d000 | ||
26 | |||
27 | |||
28 | ///////////Quality of Service/////////////////////////// | ||
29 | #define NO_OF_QUEUES 17 | ||
30 | #define HiPriority NO_OF_QUEUES-1 | ||
31 | #define LowPriority 0 | ||
32 | #define BE 2 | ||
33 | #define rtPS 4 | ||
34 | #define ERTPS 5 | ||
35 | #define UGS 6 | ||
36 | |||
37 | #define BE_BUCKET_SIZE 1024*1024*100 //32kb | ||
38 | #define rtPS_BUCKET_SIZE 1024*1024*100 //8kb | ||
39 | #define MAX_ALLOWED_RATE 1024*1024*100 | ||
40 | #define TX_PACKET_THRESHOLD 10 | ||
41 | #define XSECONDS 1*HZ | ||
42 | #define DSC_ACTIVATE_REQUEST 248 | ||
43 | #define QUEUE_DEPTH_OFFSET 0x1fc01000 | ||
44 | #define MAX_DEVICE_DESC_SIZE 2040 | ||
45 | #define MAX_CTRL_QUEUE_LEN 100 | ||
46 | #define MAX_APP_QUEUE_LEN 200 | ||
47 | #define MAX_LATENCY_ALLOWED 0xFFFFFFFF | ||
48 | #define DEFAULT_UG_INTERVAL 250 | ||
49 | #define DEFAULT_UGI_FACTOR 4 | ||
50 | |||
51 | #define DEFAULT_PERSFCOUNT 60 | ||
52 | #define MAX_CONNECTIONS 10 | ||
53 | #define MAX_CLASS_NAME_LENGTH 32 | ||
54 | |||
55 | #define ETH_LENGTH_OF_ADDRESS 6 | ||
56 | #define MAX_MULTICAST_ADDRESSES 32 | ||
57 | #define IP_LENGTH_OF_ADDRESS 4 | ||
58 | |||
59 | #define IP_PACKET_ONLY_MODE 0 | ||
60 | #define ETH_PACKET_TUNNELING_MODE 1 | ||
61 | |||
62 | ////////////Link Request////////////// | ||
63 | #define SET_MAC_ADDRESS_REQUEST 0 | ||
64 | #define SYNC_UP_REQUEST 1 | ||
65 | #define SYNCED_UP 2 | ||
66 | #define LINK_UP_REQUEST 3 | ||
67 | #define LINK_CONNECTED 4 | ||
68 | #define SYNC_UP_NOTIFICATION 2 | ||
69 | #define LINK_UP_NOTIFICATION 4 | ||
70 | |||
71 | |||
72 | #define LINK_NET_ENTRY 0x0002 | ||
73 | #define HMC_STATUS 0x0004 | ||
74 | #define LINK_UP_CONTROL_REQ 0x83 | ||
75 | |||
76 | #define STATS_POINTER_REQ_STATUS 0x86 | ||
77 | #define NETWORK_ENTRY_REQ_PAYLOAD 198 | ||
78 | #define LINK_DOWN_REQ_PAYLOAD 226 | ||
79 | #define SYNC_UP_REQ_PAYLOAD 228 | ||
80 | #define STATISTICS_POINTER_REQ 237 | ||
81 | #define LINK_UP_REQ_PAYLOAD 245 | ||
82 | #define LINK_UP_ACK 246 | ||
83 | |||
84 | #define STATS_MSG_SIZE 4 | ||
85 | #define INDEX_TO_DATA 4 | ||
86 | |||
87 | #define GO_TO_IDLE_MODE_PAYLOAD 210 | ||
88 | #define COME_UP_FROM_IDLE_MODE_PAYLOAD 211 | ||
89 | #define IDLE_MODE_SF_UPDATE_MSG 187 | ||
90 | |||
91 | #define SKB_RESERVE_ETHERNET_HEADER 16 | ||
92 | #define SKB_RESERVE_PHS_BYTES 32 | ||
93 | |||
94 | #define IP_PACKET_ONLY_MODE 0 | ||
95 | #define ETH_PACKET_TUNNELING_MODE 1 | ||
96 | |||
97 | #define ETH_CS_802_3 1 | ||
98 | #define ETH_CS_802_1Q_VLAN 3 | ||
99 | #define IPV4_CS 1 | ||
100 | #define IPV6_CS 2 | ||
101 | #define ETH_CS_MASK 0x3f | ||
102 | |||
103 | /** \brief Validity bit maps for TLVs in packet classification rule */ | ||
104 | |||
105 | #define PKT_CLASSIFICATION_USER_PRIORITY_VALID 0 | ||
106 | #define PKT_CLASSIFICATION_VLANID_VALID 1 | ||
107 | |||
108 | #ifndef MIN | ||
109 | #define MIN(_a, _b) ((_a) < (_b)? (_a): (_b)) | ||
110 | #endif | ||
111 | |||
112 | |||
113 | /*Leader related terms */ | ||
114 | #define LEADER_STATUS 0x00 | ||
115 | #define LEADER_STATUS_TCP_ACK 0x1 | ||
116 | #define LEADER_SIZE sizeof(LEADER) | ||
117 | #define MAC_ADDR_REQ_SIZE sizeof(PACKETTOSEND) | ||
118 | #define SS_INFO_REQ_SIZE sizeof(PACKETTOSEND) | ||
119 | #define CM_REQUEST_SIZE LEADER_SIZE + sizeof(stLocalSFChangeRequest) | ||
120 | #define IDLE_REQ_SIZE sizeof(PACKETTOSEND) | ||
121 | |||
122 | |||
123 | #define MAX_TRANSFER_CTRL_BYTE_USB 2 * 1024 | ||
124 | |||
125 | #define GET_MAILBOX1_REG_REQUEST 0x87 | ||
126 | #define GET_MAILBOX1_REG_RESPONSE 0x67 | ||
127 | #define VCID_CONTROL_PACKET 0x00 | ||
128 | |||
129 | #define TRANSMIT_NETWORK_DATA 0x00 | ||
130 | #define RECEIVED_NETWORK_DATA 0x20 | ||
131 | |||
132 | #define CM_RESPONSES 0xA0 | ||
133 | #define STATUS_RSP 0xA1 | ||
134 | #define LINK_CONTROL_RESP 0xA2 | ||
135 | #define IDLE_MODE_STATUS 0xA3 | ||
136 | #define STATS_POINTER_RESP 0xA6 | ||
137 | #define MGMT_MSG_INFO_SW_STATUS 0xA7 | ||
138 | #define AUTH_SS_HOST_MSG 0xA8 | ||
139 | |||
140 | #define CM_DSA_ACK_PAYLOAD 247 | ||
141 | #define CM_DSC_ACK_PAYLOAD 248 | ||
142 | #define CM_DSD_ACK_PAYLOAD 249 | ||
143 | #define CM_DSDEACTVATE 250 | ||
144 | #define TOTAL_MASKED_ADDRESS_IN_BYTES 32 | ||
145 | |||
146 | #define MAC_REQ 0 | ||
147 | #define LINK_RESP 1 | ||
148 | #define RSSI_INDICATION 2 | ||
149 | |||
150 | #define SS_INFO 4 | ||
151 | #define STATISTICS_INFO 5 | ||
152 | #define CM_INDICATION 6 | ||
153 | #define PARAM_RESP 7 | ||
154 | #define BUFFER_1K 1024 | ||
155 | #define BUFFER_2K BUFFER_1K*2 | ||
156 | #define BUFFER_4K BUFFER_2K*2 | ||
157 | #define BUFFER_8K BUFFER_4K*2 | ||
158 | #define BUFFER_16K BUFFER_8K*2 | ||
159 | #define DOWNLINK_DIR 0 | ||
160 | #define UPLINK_DIR 1 | ||
161 | |||
162 | #define BCM_SIGNATURE "BECEEM" | ||
163 | |||
164 | |||
165 | #define GPIO_OUTPUT_REGISTER 0x0F00003C | ||
166 | #define BCM_GPIO_OUTPUT_SET_REG 0x0F000040 | ||
167 | #define BCM_GPIO_OUTPUT_CLR_REG 0x0F000044 | ||
168 | #define GPIO_MODE_REGISTER 0x0F000034 | ||
169 | #define GPIO_PIN_STATE_REGISTER 0x0F000038 | ||
170 | |||
171 | |||
172 | typedef struct _LINK_STATE { | ||
173 | UCHAR ucLinkStatus; | ||
174 | UCHAR bIdleMode; | ||
175 | UCHAR bShutdownMode; | ||
176 | }LINK_STATE, *PLINK_STATE; | ||
177 | |||
178 | |||
179 | enum enLinkStatus { | ||
180 | WAIT_FOR_SYNC = 1, | ||
181 | PHY_SYNC_ACHIVED = 2, | ||
182 | LINKUP_IN_PROGRESS = 3, | ||
183 | LINKUP_DONE = 4, | ||
184 | DREG_RECIEVED = 5, | ||
185 | LINK_STATUS_RESET_RECIEVED = 6, | ||
186 | PERIODIC_WAKE_UP_NOTIFICATION_FRM_FW = 7, | ||
187 | LINK_SHUTDOWN_REQ_FROM_FIRMWARE = 8, | ||
188 | COMPLETE_WAKE_UP_NOTIFICATION_FRM_FW =9 | ||
189 | }; | ||
190 | |||
191 | typedef enum _E_PHS_DSC_ACTION | ||
192 | { | ||
193 | eAddPHSRule=0, | ||
194 | eSetPHSRule, | ||
195 | eDeletePHSRule, | ||
196 | eDeleteAllPHSRules | ||
197 | }E_PHS_DSC_ACTION; | ||
198 | |||
199 | |||
200 | #define CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ 0x89 // Host to Mac | ||
201 | #define CM_CONTROL_NEWDSX_MULTICLASSIFIER_RESP 0xA9 // Mac to Host | ||
202 | #define MASK_DISABLE_HEADER_SUPPRESSION 0x10 //0b000010000 | ||
203 | #define MINIMUM_PENDING_DESCRIPTORS 5 | ||
204 | |||
205 | #define SHUTDOWN_HOSTINITIATED_REQUESTPAYLOAD 0xCC | ||
206 | #define SHUTDOWN_ACK_FROM_DRIVER 0x1 | ||
207 | #define SHUTDOWN_NACK_FROM_DRIVER 0x2 | ||
208 | |||
209 | #define LINK_SYNC_UP_SUBTYPE 0x0001 | ||
210 | #define LINK_SYNC_DOWN_SUBTYPE 0x0001 | ||
211 | |||
212 | |||
213 | |||
214 | #define CONT_MODE 1 | ||
215 | #define SINGLE_DESCRIPTOR 1 | ||
216 | |||
217 | |||
218 | #define DESCRIPTOR_LENGTH 0x30 | ||
219 | #define FIRMWARE_DESCS_ADDRESS 0x1F100000 | ||
220 | |||
221 | |||
222 | #define CLOCK_RESET_CNTRL_REG_1 0x0F00000C | ||
223 | #define CLOCK_RESET_CNTRL_REG_2 0x0F000840 | ||
224 | |||
225 | |||
226 | |||
227 | #define TX_DESCRIPTOR_HEAD_REGISTER 0x0F010034 | ||
228 | #define RX_DESCRIPTOR_HEAD_REGISTER 0x0F010094 | ||
229 | |||
230 | #define STATISTICS_BEGIN_ADDR 0xbf60f02c | ||
231 | |||
232 | #define MAX_PENDING_CTRL_PACKET (MAX_CTRL_QUEUE_LEN-10) | ||
233 | |||
234 | #define WIMAX_MAX_MTU MTU_SIZE + ETH_HLEN | ||
235 | #define AUTO_LINKUP_ENABLE 0x2 | ||
236 | #define AUTO_SYNC_DISABLE 0x1 | ||
237 | #define AUTO_FIRM_DOWNLOAD 0x1 | ||
238 | #define SETTLE_DOWN_TIME 50 | ||
239 | |||
240 | #define HOST_BUS_SUSPEND_BIT 16 | ||
241 | |||
242 | #define IDLE_MESSAGE 0x81 | ||
243 | |||
244 | #define MIPS_CLOCK_133MHz 1 | ||
245 | |||
246 | #define TARGET_CAN_GO_TO_IDLE_MODE 2 | ||
247 | #define TARGET_CAN_NOT_GO_TO_IDLE_MODE 3 | ||
248 | #define IDLE_MODE_PAYLOAD_LENGTH 8 | ||
249 | |||
250 | #define IP_HEADER(Buffer) ((IPHeaderFormat*)(Buffer)) | ||
251 | #define IPV4 4 | ||
252 | #define IP_VERSION(byte) (((byte&0xF0)>>4)) | ||
253 | |||
254 | #define SET_MAC_ADDRESS 193 | ||
255 | #define SET_MAC_ADDRESS_RESPONSE 236 | ||
256 | |||
257 | #define IDLE_MODE_WAKEUP_PATTERN 0xd0ea1d1e | ||
258 | #define IDLE_MODE_WAKEUP_NOTIFIER_ADDRESS 0x1FC02FA8 | ||
259 | #define IDLE_MODE_MAX_RETRY_COUNT 1000 | ||
260 | |||
261 | #ifdef REL_4_1 | ||
262 | #define CONFIG_BEGIN_ADDR 0xBF60B004 | ||
263 | #else | ||
264 | #define CONFIG_BEGIN_ADDR 0xBF60B000 | ||
265 | #endif | ||
266 | |||
267 | #define FIRMWARE_BEGIN_ADDR 0xBFC00000 | ||
268 | |||
269 | #define INVALID_QUEUE_INDEX (USHORT)-1 | ||
270 | |||
271 | #define INVALID_PID (pid_t)-1 | ||
272 | #define DDR_80_MHZ 0 | ||
273 | #define DDR_100_MHZ 1 | ||
274 | #define DDR_120_MHZ 2 // Additional Frequency for T3LP | ||
275 | #define DDR_133_MHZ 3 | ||
276 | #define DDR_140_MHZ 4 // Not Used (Reserved for future) | ||
277 | #define DDR_160_MHZ 5 // Additional Frequency for T3LP | ||
278 | #define DDR_180_MHZ 6 // Not Used (Reserved for future) | ||
279 | #define DDR_200_MHZ 7 // Not Used (Reserved for future) | ||
280 | |||
281 | #define MIPS_200_MHZ 0 | ||
282 | #define MIPS_160_MHZ 1 | ||
283 | |||
284 | #define PLL_800_MHZ 0 | ||
285 | #define PLL_266_MHZ 1 | ||
286 | |||
287 | #define DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING 0 | ||
288 | #define DEVICE_POWERSAVE_MODE_AS_PMU_CLOCK_GATING 1 | ||
289 | #define DEVICE_POWERSAVE_MODE_AS_PMU_SHUTDOWN 2 | ||
290 | #define DEVICE_POWERSAVE_MODE_AS_RESERVED 3 | ||
291 | #define DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE 4 | ||
292 | |||
293 | |||
294 | #define EEPROM_REJECT_REG_1 0x0f003018 | ||
295 | #define EEPROM_REJECT_REG_2 0x0f00301c | ||
296 | #define EEPROM_REJECT_REG_3 0x0f003008 | ||
297 | #define EEPROM_REJECT_REG_4 0x0f003020 | ||
298 | #define EEPROM_REJECT_MASK 0x0fffffff | ||
299 | #define VSG_MODE 0x3 | ||
300 | |||
301 | /* Idle Mode Related Registers */ | ||
302 | #define DEBUG_INTERRUPT_GENERATOR_REGISTOR 0x0F00007C | ||
303 | #ifdef BCM_SHM_INTERFACE | ||
304 | #define SW_ABORT_IDLEMODE_LOC 0xbfc02f9c | ||
305 | #define CPE_VIRTUAL_MAILBOX_REG 0xBFC02E58 | ||
306 | #else | ||
307 | #define SW_ABORT_IDLEMODE_LOC 0x0FF01FFC | ||
308 | #endif | ||
309 | |||
310 | #define SW_ABORT_IDLEMODE_PATTERN 0xd0ea1d1e | ||
311 | #define DEVICE_INT_OUT_EP_REG0 0x0F011870 | ||
312 | #define DEVICE_INT_OUT_EP_REG1 0x0F011874 | ||
313 | |||
314 | #define BIN_FILE "/lib/firmware/macxvi200.bin" | ||
315 | #define CFG_FILE "/lib/firmware/macxvi.cfg" | ||
316 | #define SF_MAX_ALLOWED_PACKETS_TO_BACKUP 128 | ||
317 | #define MIN_VAL(x,y) ((x)<(y)?(x):(y)) | ||
318 | #define MAC_ADDRESS_SIZE 6 | ||
319 | #define EEPROM_COMMAND_Q_REG 0x0F003018 | ||
320 | #define EEPROM_READ_DATA_Q_REG 0x0F003020 | ||
321 | #define CHIP_ID_REG 0x0F000000 | ||
322 | #define GPIO_MODE_REG 0x0F000034 | ||
323 | #define GPIO_OUTPUT_REG 0x0F00003C | ||
324 | #define WIMAX_MAX_ALLOWED_RATE 1024*1024*50 | ||
325 | |||
326 | #define T3 0xbece0300 | ||
327 | #define TARGET_SFID_TXDESC_MAP_LOC 0xBFFFF400 | ||
328 | |||
329 | #define RWM_READ 0 | ||
330 | #define RWM_WRITE 1 | ||
331 | |||
332 | #define T3LPB 0xbece3300 | ||
333 | #define BCS220_2 0xbece3311 | ||
334 | #define BCS220_2BC 0xBECE3310 | ||
335 | #define BCS250_BC 0xbece3301 | ||
336 | #define BCS220_3 0xbece3321 | ||
337 | |||
338 | |||
339 | #define HPM_CONFIG_LDO145 0x0F000D54 | ||
340 | #define HPM_CONFIG_MSW 0x0F000D58 | ||
341 | |||
342 | #define T3B 0xbece0310 | ||
343 | typedef enum eNVM_TYPE | ||
344 | { | ||
345 | NVM_AUTODETECT = 0, | ||
346 | NVM_EEPROM, | ||
347 | NVM_FLASH, | ||
348 | NVM_UNKNOWN | ||
349 | }NVM_TYPE; | ||
350 | |||
351 | typedef enum ePMU_MODES | ||
352 | { | ||
353 | HYBRID_MODE_7C = 0, | ||
354 | INTERNAL_MODE_6 = 1, | ||
355 | HYBRID_MODE_6 = 2 | ||
356 | }PMU_MODE; | ||
357 | |||
358 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) | ||
359 | #define MAX_RDM_WRM_RETIRES 16 | ||
360 | #else | ||
361 | #define MAX_RDM_WRM_RETIRES 1 | ||
362 | #endif | ||
363 | |||
364 | |||
365 | enum eAbortPattern { | ||
366 | ABORT_SHUTDOWN_MODE = 1, | ||
367 | ABORT_IDLE_REG = 1, | ||
368 | ABORT_IDLE_MODE = 2, | ||
369 | ABORT_IDLE_SYNCDOWN = 3 | ||
370 | }; | ||
371 | |||
372 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) | ||
373 | #define GET_BCM_ADAPTER(net_dev) ({\ | ||
374 | PMINI_ADAPTER __Adapter = NULL; \ | ||
375 | if (net_dev) { \ | ||
376 | __Adapter = (PMINI_ADAPTER)(net_dev->priv); \ | ||
377 | } \ | ||
378 | else { \ | ||
379 | __Adapter = NULL; \ | ||
380 | }__Adapter;} ) | ||
381 | #else | ||
382 | #define GET_BCM_ADAPTER(net_dev) ({\ | ||
383 | PMINI_ADAPTER __Adapter = NULL; \ | ||
384 | if (net_dev) { \ | ||
385 | __Adapter = (PMINI_ADAPTER)(*((UINT *)netdev_priv(net_dev))); \ | ||
386 | } \ | ||
387 | else { \ | ||
388 | __Adapter = NULL; \ | ||
389 | }__Adapter;}) | ||
390 | |||
391 | |||
392 | #endif | ||
393 | |||
394 | /* Offsets used by driver in skb cb variable */ | ||
395 | #define SKB_CB_CLASSIFICATION_OFFSET 0 | ||
396 | #define SKB_CB_LATENCY_OFFSET 1 | ||
397 | #define SKB_CB_TCPACK_OFFSET 2 | ||
398 | |||
399 | #endif //__MACROS_H__ | ||
diff --git a/drivers/staging/bcm/Makefile b/drivers/staging/bcm/Makefile new file mode 100644 index 00000000000..3fdec2ea0c4 --- /dev/null +++ b/drivers/staging/bcm/Makefile | |||
@@ -0,0 +1,12 @@ | |||
1 | # | ||
2 | # Makefile for Beceem USB Wimax card | ||
3 | # | ||
4 | |||
5 | obj-$(CONFIG_BCM_WIMAX) += bcm_wimax.o | ||
6 | |||
7 | bcm_wimax-objs := InterfaceDld.o InterfaceIdleMode.o InterfaceInit.o InterfaceRx.o \ | ||
8 | InterfaceIsr.o InterfaceMisc.o InterfaceTx.o \ | ||
9 | Arp.o CmHost.o Debug.o IPv6Protocol.o Qos.o Transmit.o\ | ||
10 | Bcmnet.o DDRInit.o HandleControlPacket.o\ | ||
11 | LeakyBucket.o Misc.o sort.o Bcmchar.o hostmibs.o PHSModule.o\ | ||
12 | Osal_Misc.o led_control.o nvm.o vendorspecificextn.o | ||
diff --git a/drivers/staging/bcm/Misc.c b/drivers/staging/bcm/Misc.c new file mode 100644 index 00000000000..5ed58a863eb --- /dev/null +++ b/drivers/staging/bcm/Misc.c | |||
@@ -0,0 +1,2239 @@ | |||
1 | #include "headers.h" | ||
2 | |||
3 | static VOID default_wimax_protocol_initialize(PMINI_ADAPTER Adapter) | ||
4 | { | ||
5 | |||
6 | UINT uiLoopIndex; | ||
7 | |||
8 | for(uiLoopIndex=0; uiLoopIndex < NO_OF_QUEUES-1; uiLoopIndex++) | ||
9 | { | ||
10 | Adapter->PackInfo[uiLoopIndex].uiThreshold=TX_PACKET_THRESHOLD; | ||
11 | Adapter->PackInfo[uiLoopIndex].uiMaxAllowedRate=MAX_ALLOWED_RATE; | ||
12 | Adapter->PackInfo[uiLoopIndex].uiMaxBucketSize=20*1024*1024; | ||
13 | } | ||
14 | |||
15 | Adapter->BEBucketSize=BE_BUCKET_SIZE; | ||
16 | Adapter->rtPSBucketSize=rtPS_BUCKET_SIZE; | ||
17 | Adapter->LinkStatus=SYNC_UP_REQUEST; | ||
18 | Adapter->TransferMode=IP_PACKET_ONLY_MODE; | ||
19 | Adapter->usBestEffortQueueIndex=-1; | ||
20 | return; | ||
21 | } | ||
22 | |||
23 | |||
24 | INT | ||
25 | InitAdapter(PMINI_ADAPTER psAdapter) | ||
26 | { | ||
27 | int i = 0; | ||
28 | INT Status = STATUS_SUCCESS ; | ||
29 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Initialising Adapter = 0x%x",(unsigned int) psAdapter); | ||
30 | |||
31 | if(psAdapter == NULL) | ||
32 | { | ||
33 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Adapter is NULL"); | ||
34 | return -EINVAL; | ||
35 | } | ||
36 | |||
37 | sema_init(&psAdapter->NVMRdmWrmLock,1); | ||
38 | // psAdapter->ulFlashCalStart = FLASH_AUTO_INIT_BASE_ADDR; | ||
39 | |||
40 | sema_init(&psAdapter->rdmwrmsync, 1); | ||
41 | spin_lock_init(&psAdapter->control_queue_lock); | ||
42 | spin_lock_init(&psAdapter->txtransmitlock); | ||
43 | sema_init(&psAdapter->RxAppControlQueuelock, 1); | ||
44 | // sema_init(&psAdapter->data_packet_queue_lock, 1); | ||
45 | sema_init(&psAdapter->fw_download_sema, 1); | ||
46 | sema_init(&psAdapter->LowPowerModeSync,1); | ||
47 | |||
48 | // spin_lock_init(&psAdapter->sleeper_lock); | ||
49 | |||
50 | for(i=0;i<NO_OF_QUEUES; i++) | ||
51 | spin_lock_init(&psAdapter->PackInfo[i].SFQueueLock); | ||
52 | i=0; | ||
53 | |||
54 | init_waitqueue_head(&psAdapter->process_rx_cntrlpkt); | ||
55 | init_waitqueue_head(&psAdapter->tx_packet_wait_queue); | ||
56 | init_waitqueue_head(&psAdapter->process_read_wait_queue); | ||
57 | init_waitqueue_head(&psAdapter->ioctl_fw_dnld_wait_queue); | ||
58 | init_waitqueue_head(&psAdapter->lowpower_mode_wait_queue); | ||
59 | psAdapter->waiting_to_fw_download_done = TRUE; | ||
60 | //init_waitqueue_head(&psAdapter->device_wake_queue); | ||
61 | psAdapter->fw_download_done=FALSE; | ||
62 | |||
63 | psAdapter->pvOsDepData = (PLINUX_DEP_DATA) kmalloc(sizeof(LINUX_DEP_DATA), | ||
64 | GFP_KERNEL); | ||
65 | |||
66 | if(psAdapter->pvOsDepData == NULL) | ||
67 | { | ||
68 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Linux Specific Data allocation failed"); | ||
69 | return -ENOMEM; | ||
70 | } | ||
71 | memset(psAdapter->pvOsDepData, 0, sizeof(LINUX_DEP_DATA)); | ||
72 | |||
73 | default_wimax_protocol_initialize(psAdapter); | ||
74 | for (i=0;i<MAX_CNTRL_PKTS;i++) | ||
75 | { | ||
76 | psAdapter->txctlpacket[i] = (char *)kmalloc(MAX_CNTL_PKT_SIZE, | ||
77 | GFP_KERNEL); | ||
78 | if(!psAdapter->txctlpacket[i]) | ||
79 | { | ||
80 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "No More Cntl pkts got, max got is %d", i); | ||
81 | return -ENOMEM; | ||
82 | } | ||
83 | } | ||
84 | if(AllocAdapterDsxBuffer(psAdapter)) | ||
85 | { | ||
86 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Failed to allocate DSX buffers"); | ||
87 | return -EINVAL; | ||
88 | } | ||
89 | |||
90 | //Initialize PHS interface | ||
91 | if(phs_init(&psAdapter->stBCMPhsContext,psAdapter)!=0) | ||
92 | { | ||
93 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"%s:%s:%d:Error PHS Init Failed=====>\n", __FILE__, __FUNCTION__, __LINE__); | ||
94 | return -ENOMEM; | ||
95 | } | ||
96 | |||
97 | Status = BcmAllocFlashCSStructure(psAdapter); | ||
98 | if(Status) | ||
99 | { | ||
100 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Memory Allocation for Flash structure failed"); | ||
101 | return Status ; | ||
102 | } | ||
103 | |||
104 | Status = vendorextnInit(psAdapter); | ||
105 | |||
106 | if(STATUS_SUCCESS != Status) | ||
107 | { | ||
108 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Vendor Init Failed"); | ||
109 | return Status ; | ||
110 | } | ||
111 | |||
112 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Adapter initialised"); | ||
113 | |||
114 | |||
115 | return STATUS_SUCCESS; | ||
116 | } | ||
117 | |||
118 | VOID AdapterFree(PMINI_ADAPTER Adapter) | ||
119 | { | ||
120 | INT count = 0; | ||
121 | |||
122 | beceem_protocol_reset(Adapter); | ||
123 | |||
124 | vendorextnExit(Adapter); | ||
125 | |||
126 | if(Adapter->control_packet_handler && !IS_ERR(Adapter->control_packet_handler)) | ||
127 | kthread_stop (Adapter->control_packet_handler); | ||
128 | if(Adapter->transmit_packet_thread && !IS_ERR(Adapter->transmit_packet_thread)) | ||
129 | kthread_stop (Adapter->transmit_packet_thread); | ||
130 | wake_up(&Adapter->process_read_wait_queue); | ||
131 | if(Adapter->LEDInfo.led_thread_running & (BCM_LED_THREAD_RUNNING_ACTIVELY | BCM_LED_THREAD_RUNNING_INACTIVELY)) | ||
132 | kthread_stop (Adapter->LEDInfo.led_cntrl_threadid); | ||
133 | bcm_unregister_networkdev(Adapter); | ||
134 | while(atomic_read(&Adapter->ApplicationRunning)) | ||
135 | { | ||
136 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Waiting for Application to close.. %d\n",atomic_read(&Adapter->ApplicationRunning)); | ||
137 | msleep(100); | ||
138 | } | ||
139 | unregister_control_device_interface(Adapter); | ||
140 | if(Adapter->dev && !IS_ERR(Adapter->dev)) | ||
141 | free_netdev(Adapter->dev); | ||
142 | if(Adapter->pstargetparams != NULL) | ||
143 | { | ||
144 | bcm_kfree(Adapter->pstargetparams); | ||
145 | } | ||
146 | for (count =0;count < MAX_CNTRL_PKTS;count++) | ||
147 | { | ||
148 | if(Adapter->txctlpacket[count]) | ||
149 | bcm_kfree(Adapter->txctlpacket[count]); | ||
150 | } | ||
151 | FreeAdapterDsxBuffer(Adapter); | ||
152 | if(Adapter->pvOsDepData) | ||
153 | bcm_kfree (Adapter->pvOsDepData); | ||
154 | if(Adapter->pvInterfaceAdapter) | ||
155 | bcm_kfree(Adapter->pvInterfaceAdapter); | ||
156 | |||
157 | //Free the PHS Interface | ||
158 | PhsCleanup(&Adapter->stBCMPhsContext); | ||
159 | |||
160 | #ifndef BCM_SHM_INTERFACE | ||
161 | BcmDeAllocFlashCSStructure(Adapter); | ||
162 | #endif | ||
163 | |||
164 | bcm_kfree (Adapter); | ||
165 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "<========\n"); | ||
166 | } | ||
167 | |||
168 | |||
169 | int create_worker_threads(PMINI_ADAPTER psAdapter) | ||
170 | { | ||
171 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Init Threads..."); | ||
172 | // Rx Control Packets Processing | ||
173 | psAdapter->control_packet_handler = kthread_run((int (*)(void *)) | ||
174 | control_packet_handler, psAdapter, "CtrlPktHdlr"); | ||
175 | if(IS_ERR(psAdapter->control_packet_handler)) | ||
176 | { | ||
177 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "No Kernel Thread, but still returning success\n"); | ||
178 | return PTR_ERR(psAdapter->control_packet_handler); | ||
179 | } | ||
180 | // Tx Thread | ||
181 | psAdapter->transmit_packet_thread = kthread_run((int (*)(void *)) | ||
182 | tx_pkt_handler, psAdapter, "TxPktThread"); | ||
183 | if(IS_ERR (psAdapter->transmit_packet_thread)) | ||
184 | { | ||
185 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "No Kernel Thread, but still returning success"); | ||
186 | kthread_stop(psAdapter->control_packet_handler); | ||
187 | return PTR_ERR(psAdapter->transmit_packet_thread); | ||
188 | } | ||
189 | return 0; | ||
190 | } | ||
191 | |||
192 | |||
193 | static inline struct file *open_firmware_file(PMINI_ADAPTER Adapter, char *path) | ||
194 | { | ||
195 | struct file *flp=NULL; | ||
196 | mm_segment_t oldfs; | ||
197 | oldfs=get_fs(); | ||
198 | set_fs(get_ds()); | ||
199 | flp=filp_open(path, O_RDONLY, S_IRWXU); | ||
200 | set_fs(oldfs); | ||
201 | if(IS_ERR(flp)) | ||
202 | { | ||
203 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Unable To Open File %s, err %lx", | ||
204 | path, PTR_ERR(flp)); | ||
205 | flp = NULL; | ||
206 | } | ||
207 | else | ||
208 | { | ||
209 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Got file descriptor pointer of %s!", | ||
210 | path); | ||
211 | } | ||
212 | if(Adapter->device_removed) | ||
213 | { | ||
214 | flp = NULL; | ||
215 | } | ||
216 | |||
217 | return flp; | ||
218 | } | ||
219 | |||
220 | |||
221 | int BcmFileDownload(PMINI_ADAPTER Adapter,/**< Logical Adapter */ | ||
222 | char *path, /**< path to image file */ | ||
223 | unsigned int loc /**< Download Address on the chip*/ | ||
224 | ) | ||
225 | { | ||
226 | int errorno=0; | ||
227 | struct file *flp=NULL; | ||
228 | mm_segment_t oldfs; | ||
229 | struct timeval tv={0}; | ||
230 | |||
231 | flp=open_firmware_file(Adapter, path); | ||
232 | if(!flp) | ||
233 | { | ||
234 | errorno = -ENOENT; | ||
235 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Unable to Open %s\n", path); | ||
236 | goto exit_download; | ||
237 | } | ||
238 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Opened file is = %s and length =0x%lx to be downloaded at =0x%x", path,(unsigned long)flp->f_dentry->d_inode->i_size, loc); | ||
239 | do_gettimeofday(&tv); | ||
240 | |||
241 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "download start %lx", ((tv.tv_sec * 1000) + | ||
242 | (tv.tv_usec/1000))); | ||
243 | if(Adapter->bcm_file_download(Adapter->pvInterfaceAdapter, flp, loc)) | ||
244 | { | ||
245 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Failed to download the firmware with error\ | ||
246 | %x!!!", -EIO); | ||
247 | errorno=-EIO; | ||
248 | goto exit_download; | ||
249 | } | ||
250 | oldfs=get_fs();set_fs(get_ds()); | ||
251 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) | ||
252 | vfs_llseek(flp, 0, 0); | ||
253 | #endif | ||
254 | set_fs(oldfs); | ||
255 | if(Adapter->bcm_file_readback_from_chip(Adapter->pvInterfaceAdapter, | ||
256 | flp, loc)) | ||
257 | { | ||
258 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Failed to read back firmware!"); | ||
259 | errorno=-EIO; | ||
260 | goto exit_download; | ||
261 | } | ||
262 | |||
263 | exit_download: | ||
264 | oldfs=get_fs();set_fs(get_ds()); | ||
265 | if(flp && !(IS_ERR(flp))) | ||
266 | filp_close(flp, current->files); | ||
267 | set_fs(oldfs); | ||
268 | do_gettimeofday(&tv); | ||
269 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "file download done at %lx", ((tv.tv_sec * 1000) + | ||
270 | (tv.tv_usec/1000))); | ||
271 | return errorno; | ||
272 | } | ||
273 | |||
274 | |||
275 | void bcm_kfree_skb(struct sk_buff *skb) | ||
276 | { | ||
277 | if(skb) | ||
278 | { | ||
279 | kfree_skb(skb); | ||
280 | } | ||
281 | skb = NULL ; | ||
282 | } | ||
283 | |||
284 | VOID bcm_kfree(VOID *ptr) | ||
285 | { | ||
286 | if(ptr) | ||
287 | { | ||
288 | kfree(ptr); | ||
289 | } | ||
290 | ptr = NULL ; | ||
291 | } | ||
292 | |||
293 | /** | ||
294 | @ingroup ctrl_pkt_functions | ||
295 | This function copies the contents of given buffer | ||
296 | to the control packet and queues it for transmission. | ||
297 | @note Do not acquire the spinock, as it it already acquired. | ||
298 | @return SUCCESS/FAILURE. | ||
299 | */ | ||
300 | INT CopyBufferToControlPacket(PMINI_ADAPTER Adapter,/**<Logical Adapter*/ | ||
301 | PVOID ioBuffer/**<Control Packet Buffer*/ | ||
302 | ) | ||
303 | { | ||
304 | PLEADER pLeader=NULL; | ||
305 | INT Status=0; | ||
306 | unsigned char *ctrl_buff=NULL; | ||
307 | UINT pktlen=0; | ||
308 | PLINK_REQUEST pLinkReq = NULL; | ||
309 | PUCHAR pucAddIndication = NULL; | ||
310 | |||
311 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "======>"); | ||
312 | if(!ioBuffer) | ||
313 | { | ||
314 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Got Null Buffer\n"); | ||
315 | return -EINVAL; | ||
316 | } | ||
317 | |||
318 | pLinkReq = (PLINK_REQUEST)ioBuffer; | ||
319 | pLeader=(PLEADER)ioBuffer; //ioBuffer Contains sw_Status and Payload | ||
320 | |||
321 | if(Adapter->bShutStatus == TRUE && | ||
322 | pLinkReq->szData[0] == LINK_DOWN_REQ_PAYLOAD && | ||
323 | pLinkReq->szData[1] == LINK_SYNC_UP_SUBTYPE) | ||
324 | { | ||
325 | //Got sync down in SHUTDOWN..we could not process this. | ||
326 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "SYNC DOWN Request in Shut Down Mode..\n"); | ||
327 | return STATUS_FAILURE; | ||
328 | } | ||
329 | |||
330 | if((pLeader->Status == LINK_UP_CONTROL_REQ) && | ||
331 | ((pLinkReq->szData[0] == LINK_UP_REQ_PAYLOAD && | ||
332 | (pLinkReq->szData[1] == LINK_SYNC_UP_SUBTYPE)) ||//Sync Up Command | ||
333 | pLinkReq->szData[0] == NETWORK_ENTRY_REQ_PAYLOAD)) //Net Entry Command | ||
334 | { | ||
335 | if(Adapter->LinkStatus > PHY_SYNC_ACHIVED) | ||
336 | { | ||
337 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL,"LinkStatus is Greater than PHY_SYN_ACHIEVED"); | ||
338 | return STATUS_FAILURE; | ||
339 | } | ||
340 | if(TRUE == Adapter->bShutStatus) | ||
341 | { | ||
342 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "SYNC UP IN SHUTDOWN..Device WakeUp\n"); | ||
343 | if(Adapter->bTriedToWakeUpFromlowPowerMode == FALSE) | ||
344 | { | ||
345 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Waking up for the First Time..\n"); | ||
346 | Adapter->usIdleModePattern = ABORT_SHUTDOWN_MODE; // change it to 1 for current support. | ||
347 | Adapter->bWakeUpDevice = TRUE; | ||
348 | wake_up(&Adapter->process_rx_cntrlpkt); | ||
349 | |||
350 | Status = wait_event_interruptible_timeout(Adapter->lowpower_mode_wait_queue, | ||
351 | !Adapter->bShutStatus, (5 * HZ)); | ||
352 | |||
353 | if(Status == -ERESTARTSYS) | ||
354 | return Status; | ||
355 | |||
356 | if(Adapter->bShutStatus) | ||
357 | { | ||
358 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Shutdown Mode Wake up Failed - No Wake Up Received\n"); | ||
359 | return STATUS_FAILURE; | ||
360 | } | ||
361 | } | ||
362 | else | ||
363 | { | ||
364 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Wakeup has been tried already...\n"); | ||
365 | } | ||
366 | } | ||
367 | |||
368 | } | ||
369 | if(TRUE == Adapter->IdleMode) | ||
370 | { | ||
371 | //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Device is in Idle mode ... hence \n"); | ||
372 | if(pLeader->Status == LINK_UP_CONTROL_REQ || pLeader->Status == 0x80 || | ||
373 | pLeader->Status == CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ ) | ||
374 | |||
375 | { | ||
376 | if((pLeader->Status == LINK_UP_CONTROL_REQ) && (pLinkReq->szData[0]==LINK_DOWN_REQ_PAYLOAD)) | ||
377 | { | ||
378 | if((pLinkReq->szData[1] == LINK_SYNC_DOWN_SUBTYPE)) | ||
379 | { | ||
380 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Link Down Sent in Idle Mode\n"); | ||
381 | Adapter->usIdleModePattern = ABORT_IDLE_SYNCDOWN;//LINK DOWN sent in Idle Mode | ||
382 | } | ||
383 | else | ||
384 | { | ||
385 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL,"ABORT_IDLE_MODE pattern is being written\n"); | ||
386 | Adapter->usIdleModePattern = ABORT_IDLE_REG; | ||
387 | } | ||
388 | } | ||
389 | else | ||
390 | { | ||
391 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL,"ABORT_IDLE_MODE pattern is being written\n"); | ||
392 | Adapter->usIdleModePattern = ABORT_IDLE_MODE; | ||
393 | } | ||
394 | |||
395 | /*Setting bIdleMode_tx_from_host to TRUE to indicate LED control thread to represent | ||
396 | the wake up from idlemode is from host*/ | ||
397 | //Adapter->LEDInfo.bIdleMode_tx_from_host = TRUE; | ||
398 | #if 0 | ||
399 | if(STATUS_SUCCESS != InterfaceIdleModeWakeup(Adapter)) | ||
400 | { | ||
401 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Idle Mode Wake up Failed\n"); | ||
402 | return STATUS_FAILURE; | ||
403 | } | ||
404 | #endif | ||
405 | Adapter->bWakeUpDevice = TRUE; | ||
406 | wake_up(&Adapter->process_rx_cntrlpkt); | ||
407 | |||
408 | |||
409 | |||
410 | if(LINK_DOWN_REQ_PAYLOAD == pLinkReq->szData[0]) | ||
411 | { | ||
412 | // We should not send DREG message down while in idlemode. | ||
413 | return STATUS_SUCCESS; | ||
414 | } | ||
415 | |||
416 | Status = wait_event_interruptible_timeout(Adapter->lowpower_mode_wait_queue, | ||
417 | !Adapter->IdleMode, (5 * HZ)); | ||
418 | |||
419 | if(Status == -ERESTARTSYS) | ||
420 | return Status; | ||
421 | |||
422 | if(Adapter->IdleMode) | ||
423 | { | ||
424 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Idle Mode Wake up Failed - No Wake Up Received\n"); | ||
425 | return STATUS_FAILURE; | ||
426 | } | ||
427 | } | ||
428 | else | ||
429 | return STATUS_SUCCESS; | ||
430 | } | ||
431 | //The Driver has to send control messages with a particular VCID | ||
432 | pLeader->Vcid = VCID_CONTROL_PACKET;//VCID for control packet. | ||
433 | |||
434 | /* Allocate skb for Control Packet */ | ||
435 | pktlen = pLeader->PLength; | ||
436 | ctrl_buff = (char *)Adapter->txctlpacket[atomic_read(&Adapter->index_wr_txcntrlpkt)%MAX_CNTRL_PKTS]; | ||
437 | |||
438 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Control packet to be taken =%d and address is =%pincoming address is =%p and packet len=%x", | ||
439 | atomic_read(&Adapter->index_wr_txcntrlpkt), ctrl_buff, ioBuffer, pktlen); | ||
440 | if(ctrl_buff) | ||
441 | { | ||
442 | if(pLeader) | ||
443 | { | ||
444 | if((pLeader->Status == 0x80) || | ||
445 | (pLeader->Status == CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ)) | ||
446 | { | ||
447 | /* | ||
448 | //Restructure the DSX message to handle Multiple classifier Support | ||
449 | // Write the Service Flow param Structures directly to the target | ||
450 | //and embed the pointers in the DSX messages sent to target. | ||
451 | */ | ||
452 | //Lets store the current length of the control packet we are transmitting | ||
453 | pucAddIndication = (PUCHAR)ioBuffer + LEADER_SIZE; | ||
454 | pktlen = pLeader->PLength; | ||
455 | Status = StoreCmControlResponseMessage(Adapter,pucAddIndication, &pktlen); | ||
456 | if(Status != 1) | ||
457 | { | ||
458 | ClearTargetDSXBuffer(Adapter,((stLocalSFAddIndicationAlt *)pucAddIndication)->u16TID, FALSE); | ||
459 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, " Error Restoring The DSX Control Packet. Dsx Buffers on Target may not be Setup Properly "); | ||
460 | return STATUS_FAILURE; | ||
461 | } | ||
462 | /* | ||
463 | //update the leader to use the new length | ||
464 | //The length of the control packet is length of message being sent + Leader length | ||
465 | */ | ||
466 | pLeader->PLength = pktlen; | ||
467 | } | ||
468 | } | ||
469 | memset(ctrl_buff, 0, pktlen+LEADER_SIZE); | ||
470 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Copying the Control Packet Buffer with length=%d\n", pLeader->PLength); | ||
471 | *(PLEADER)ctrl_buff=*pLeader; | ||
472 | memcpy(ctrl_buff + LEADER_SIZE, ((PUCHAR)ioBuffer + LEADER_SIZE), pLeader->PLength); | ||
473 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Enqueuing the Control Packet"); | ||
474 | |||
475 | /*Update the statistics counters */ | ||
476 | spin_lock_bh(&Adapter->PackInfo[HiPriority].SFQueueLock); | ||
477 | Adapter->PackInfo[HiPriority].uiCurrentBytesOnHost+=pLeader->PLength; | ||
478 | Adapter->PackInfo[HiPriority].uiCurrentPacketsOnHost++; | ||
479 | atomic_inc(&Adapter->TotalPacketCount); | ||
480 | spin_unlock_bh(&Adapter->PackInfo[HiPriority].SFQueueLock); | ||
481 | |||
482 | Adapter->PackInfo[HiPriority].bValid = TRUE; | ||
483 | |||
484 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "CurrBytesOnHost: %x bValid: %x", | ||
485 | Adapter->PackInfo[HiPriority].uiCurrentBytesOnHost, | ||
486 | Adapter->PackInfo[HiPriority].bValid); | ||
487 | Status=STATUS_SUCCESS; | ||
488 | /*Queue the packet for transmission */ | ||
489 | atomic_inc(&Adapter->index_wr_txcntrlpkt); | ||
490 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Calling transmit_packets"); | ||
491 | atomic_set(&Adapter->TxPktAvail, 1); | ||
492 | #ifdef BCM_SHM_INTERFACE | ||
493 | virtual_mail_box_interrupt(); | ||
494 | #endif | ||
495 | wake_up(&Adapter->tx_packet_wait_queue); | ||
496 | } | ||
497 | else | ||
498 | { | ||
499 | Status=-ENOMEM; | ||
500 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "mem allocation Failed"); | ||
501 | } | ||
502 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "<===="); | ||
503 | return Status; | ||
504 | } | ||
505 | |||
506 | /***************************************************************** | ||
507 | * Function - SendStatisticsPointerRequest() | ||
508 | * | ||
509 | * Description - This function builds and forwards the Statistics | ||
510 | * Pointer Request control Packet. | ||
511 | * | ||
512 | * Parameters - Adapter : Pointer to Adapter structure. | ||
513 | * - pstStatisticsPtrRequest : Pointer to link request. | ||
514 | * | ||
515 | * Returns - None. | ||
516 | *****************************************************************/ | ||
517 | VOID SendStatisticsPointerRequest(PMINI_ADAPTER Adapter, | ||
518 | PLINK_REQUEST pstStatisticsPtrRequest) | ||
519 | { | ||
520 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "======>"); | ||
521 | pstStatisticsPtrRequest->Leader.Status = STATS_POINTER_REQ_STATUS; | ||
522 | pstStatisticsPtrRequest->Leader.PLength = sizeof(ULONG);//minimum 4 bytes | ||
523 | pstStatisticsPtrRequest->szData[0] = STATISTICS_POINTER_REQ; | ||
524 | |||
525 | CopyBufferToControlPacket(Adapter,pstStatisticsPtrRequest); | ||
526 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "<====="); | ||
527 | return; | ||
528 | } | ||
529 | |||
530 | |||
531 | |||
532 | void SendLinkDown(PMINI_ADAPTER Adapter) | ||
533 | { | ||
534 | LINK_REQUEST stLinkDownRequest; | ||
535 | memset(&stLinkDownRequest, 0, sizeof(LINK_REQUEST)); | ||
536 | stLinkDownRequest.Leader.Status=LINK_UP_CONTROL_REQ; | ||
537 | stLinkDownRequest.Leader.PLength=sizeof(ULONG);//minimum 4 bytes | ||
538 | stLinkDownRequest.szData[0]=LINK_DOWN_REQ_PAYLOAD; | ||
539 | Adapter->bLinkDownRequested = TRUE; | ||
540 | |||
541 | CopyBufferToControlPacket(Adapter,&stLinkDownRequest); | ||
542 | } | ||
543 | |||
544 | /****************************************************************** | ||
545 | * Function - LinkMessage() | ||
546 | * | ||
547 | * Description - This function builds the Sync-up and Link-up request | ||
548 | * packet messages depending on the device Link status. | ||
549 | * | ||
550 | * Parameters - Adapter: Pointer to the Adapter structure. | ||
551 | * | ||
552 | * Returns - None. | ||
553 | *******************************************************************/ | ||
554 | __inline VOID LinkMessage(PMINI_ADAPTER Adapter) | ||
555 | { | ||
556 | PLINK_REQUEST pstLinkRequest=NULL; | ||
557 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "=====>"); | ||
558 | if(Adapter->LinkStatus == SYNC_UP_REQUEST && Adapter->AutoSyncup) | ||
559 | { | ||
560 | pstLinkRequest=kmalloc(sizeof(LINK_REQUEST), GFP_ATOMIC); | ||
561 | if(!pstLinkRequest) | ||
562 | { | ||
563 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Can not allocate memory for Link request!"); | ||
564 | return; | ||
565 | } | ||
566 | memset(pstLinkRequest,0,sizeof(LINK_REQUEST)); | ||
567 | //sync up request... | ||
568 | Adapter->LinkStatus = WAIT_FOR_SYNC;// current link status | ||
569 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Requesting For SyncUp..."); | ||
570 | pstLinkRequest->szData[0]=LINK_UP_REQ_PAYLOAD; | ||
571 | pstLinkRequest->szData[1]=LINK_SYNC_UP_SUBTYPE; | ||
572 | pstLinkRequest->Leader.Status=LINK_UP_CONTROL_REQ; | ||
573 | pstLinkRequest->Leader.PLength=sizeof(ULONG); | ||
574 | Adapter->bSyncUpRequestSent = TRUE; | ||
575 | } | ||
576 | else if(Adapter->LinkStatus == PHY_SYNC_ACHIVED && Adapter->AutoLinkUp) | ||
577 | { | ||
578 | pstLinkRequest=kmalloc(sizeof(LINK_REQUEST), GFP_ATOMIC); | ||
579 | if(!pstLinkRequest) | ||
580 | { | ||
581 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Can not allocate memory for Link request!"); | ||
582 | return; | ||
583 | } | ||
584 | memset(pstLinkRequest,0,sizeof(LINK_REQUEST)); | ||
585 | //LINK_UP_REQUEST | ||
586 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Requesting For LinkUp..."); | ||
587 | pstLinkRequest->szData[0]=LINK_UP_REQ_PAYLOAD; | ||
588 | pstLinkRequest->szData[1]=LINK_NET_ENTRY; | ||
589 | pstLinkRequest->Leader.Status=LINK_UP_CONTROL_REQ; | ||
590 | pstLinkRequest->Leader.PLength=sizeof(ULONG); | ||
591 | } | ||
592 | if(pstLinkRequest) | ||
593 | { | ||
594 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Calling CopyBufferToControlPacket"); | ||
595 | CopyBufferToControlPacket(Adapter, pstLinkRequest); | ||
596 | bcm_kfree(pstLinkRequest); | ||
597 | } | ||
598 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "LinkMessage <====="); | ||
599 | return; | ||
600 | } | ||
601 | |||
602 | |||
603 | /********************************************************************** | ||
604 | * Function - StatisticsResponse() | ||
605 | * | ||
606 | * Description - This function handles the Statistics response packet. | ||
607 | * | ||
608 | * Parameters - Adapter : Pointer to the Adapter structure. | ||
609 | * - pvBuffer: Starting address of Statistic response data. | ||
610 | * | ||
611 | * Returns - None. | ||
612 | ************************************************************************/ | ||
613 | VOID StatisticsResponse(PMINI_ADAPTER Adapter,PVOID pvBuffer) | ||
614 | { | ||
615 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "%s====>",__FUNCTION__); | ||
616 | Adapter->StatisticsPointer = ntohl(*(PULONG)pvBuffer); | ||
617 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Stats at %lx", Adapter->StatisticsPointer); | ||
618 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "%s <====",__FUNCTION__); | ||
619 | return; | ||
620 | } | ||
621 | |||
622 | |||
623 | /********************************************************************** | ||
624 | * Function - LinkControlResponseMessage() | ||
625 | * | ||
626 | * Description - This function handles the Link response packets. | ||
627 | * | ||
628 | * Parameters - Adapter : Pointer to the Adapter structure. | ||
629 | * - pucBuffer: Starting address of Link response data. | ||
630 | * | ||
631 | * Returns - None. | ||
632 | ***********************************************************************/ | ||
633 | VOID LinkControlResponseMessage(PMINI_ADAPTER Adapter,PUCHAR pucBuffer) | ||
634 | { | ||
635 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "=====>"); | ||
636 | |||
637 | if(*pucBuffer==LINK_UP_ACK) | ||
638 | { | ||
639 | switch(*(pucBuffer+1)) | ||
640 | { | ||
641 | case PHY_SYNC_ACHIVED: //SYNCed UP | ||
642 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "PHY_SYNC_ACHIVED"); | ||
643 | |||
644 | if(Adapter->LinkStatus == LINKUP_DONE) | ||
645 | { | ||
646 | beceem_protocol_reset(Adapter); | ||
647 | } | ||
648 | |||
649 | Adapter->usBestEffortQueueIndex=INVALID_QUEUE_INDEX ; | ||
650 | Adapter->LinkStatus=PHY_SYNC_ACHIVED; | ||
651 | |||
652 | if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) | ||
653 | { | ||
654 | Adapter->DriverState = NO_NETWORK_ENTRY; | ||
655 | wake_up(&Adapter->LEDInfo.notify_led_event); | ||
656 | } | ||
657 | |||
658 | LinkMessage(Adapter); | ||
659 | break; | ||
660 | |||
661 | case LINKUP_DONE: | ||
662 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "LINKUP_DONE"); | ||
663 | Adapter->LinkStatus=LINKUP_DONE; | ||
664 | Adapter->bPHSEnabled = *(pucBuffer+3); | ||
665 | Adapter->bETHCSEnabled = *(pucBuffer+4) & ETH_CS_MASK; | ||
666 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "PHS Support Status Recieved In LinkUp Ack : %x \n",Adapter->bPHSEnabled); | ||
667 | if((FALSE == Adapter->bShutStatus)&& | ||
668 | (FALSE == Adapter->IdleMode)) | ||
669 | { | ||
670 | if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) | ||
671 | { | ||
672 | Adapter->DriverState = NORMAL_OPERATION; | ||
673 | wake_up(&Adapter->LEDInfo.notify_led_event); | ||
674 | } | ||
675 | } | ||
676 | LinkMessage(Adapter); | ||
677 | break; | ||
678 | case WAIT_FOR_SYNC: | ||
679 | |||
680 | /* | ||
681 | * Driver to ignore the DREG_RECEIVED | ||
682 | * WiMAX Application should handle this Message | ||
683 | */ | ||
684 | //Adapter->liTimeSinceLastNetEntry = 0; | ||
685 | Adapter->LinkUpStatus = 0; | ||
686 | Adapter->LinkStatus = 0; | ||
687 | Adapter->usBestEffortQueueIndex=INVALID_QUEUE_INDEX ; | ||
688 | Adapter->bTriedToWakeUpFromlowPowerMode = FALSE; | ||
689 | Adapter->IdleMode = FALSE; | ||
690 | beceem_protocol_reset(Adapter); | ||
691 | |||
692 | break; | ||
693 | case LINK_SHUTDOWN_REQ_FROM_FIRMWARE: | ||
694 | case COMPLETE_WAKE_UP_NOTIFICATION_FRM_FW: | ||
695 | { | ||
696 | HandleShutDownModeRequest(Adapter, pucBuffer); | ||
697 | } | ||
698 | break; | ||
699 | default: | ||
700 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "default case:LinkResponse %x",*(pucBuffer+1)); | ||
701 | break; | ||
702 | } | ||
703 | } | ||
704 | else if(SET_MAC_ADDRESS_RESPONSE==*pucBuffer) | ||
705 | { | ||
706 | PUCHAR puMacAddr = (pucBuffer + 1); | ||
707 | Adapter->LinkStatus=SYNC_UP_REQUEST; | ||
708 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "MAC address response, sending SYNC_UP"); | ||
709 | LinkMessage(Adapter); | ||
710 | memcpy(Adapter->dev->dev_addr, puMacAddr, MAC_ADDRESS_SIZE); | ||
711 | } | ||
712 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "%s <=====",__FUNCTION__); | ||
713 | return; | ||
714 | } | ||
715 | |||
716 | void SendIdleModeResponse(PMINI_ADAPTER Adapter) | ||
717 | { | ||
718 | INT status = 0, NVMAccess = 0,lowPwrAbortMsg = 0; | ||
719 | struct timeval tv; | ||
720 | CONTROL_MESSAGE stIdleResponse = {{0}}; | ||
721 | memset(&tv, 0, sizeof(tv)); | ||
722 | stIdleResponse.Leader.Status = IDLE_MESSAGE; | ||
723 | stIdleResponse.Leader.PLength = IDLE_MODE_PAYLOAD_LENGTH; | ||
724 | stIdleResponse.szData[0] = GO_TO_IDLE_MODE_PAYLOAD; | ||
725 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL," ============>"); | ||
726 | |||
727 | /********************************* | ||
728 | **down_trylock - | ||
729 | ** if [ semaphore is available ] | ||
730 | ** acquire semaphone and return value 0 ; | ||
731 | ** else | ||
732 | ** return non-zero value ; | ||
733 | ** | ||
734 | ***********************************/ | ||
735 | |||
736 | NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock); | ||
737 | |||
738 | lowPwrAbortMsg= down_trylock(&Adapter->LowPowerModeSync); | ||
739 | |||
740 | |||
741 | if((NVMAccess || lowPwrAbortMsg || atomic_read(&Adapter->TotalPacketCount)) && | ||
742 | (Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE) ) | ||
743 | { | ||
744 | if(!NVMAccess) | ||
745 | up(&Adapter->NVMRdmWrmLock); | ||
746 | |||
747 | if(!lowPwrAbortMsg) | ||
748 | up(&Adapter->LowPowerModeSync); | ||
749 | |||
750 | stIdleResponse.szData[1] = TARGET_CAN_NOT_GO_TO_IDLE_MODE;//NACK- device access is going on. | ||
751 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "HOST IS NACKING Idle mode To F/W!!!!!!!!"); | ||
752 | Adapter->bPreparingForLowPowerMode = FALSE; | ||
753 | } | ||
754 | else | ||
755 | { | ||
756 | stIdleResponse.szData[1] = TARGET_CAN_GO_TO_IDLE_MODE; //2;//Idle ACK | ||
757 | Adapter->StatisticsPointer = 0; | ||
758 | |||
759 | /* Wait for the LED to TURN OFF before sending ACK response */ | ||
760 | if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) | ||
761 | { | ||
762 | INT iRetVal = 0; | ||
763 | |||
764 | /* Wake the LED Thread with IDLEMODE_ENTER State */ | ||
765 | Adapter->DriverState = LOWPOWER_MODE_ENTER; | ||
766 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL,"LED Thread is Running..Hence Setting LED Event as IDLEMODE_ENTER jiffies:%ld",jiffies);; | ||
767 | wake_up(&Adapter->LEDInfo.notify_led_event); | ||
768 | |||
769 | /* Wait for 1 SEC for LED to OFF */ | ||
770 | iRetVal = wait_event_timeout(Adapter->LEDInfo.idleModeSyncEvent, \ | ||
771 | Adapter->LEDInfo.bIdle_led_off, msecs_to_jiffies(1000)); | ||
772 | |||
773 | |||
774 | /* If Timed Out to Sync IDLE MODE Enter, do IDLE mode Exit and Send NACK to device */ | ||
775 | if(iRetVal <= 0) | ||
776 | { | ||
777 | stIdleResponse.szData[1] = TARGET_CAN_NOT_GO_TO_IDLE_MODE;//NACK- device access is going on. | ||
778 | Adapter->DriverState = NORMAL_OPERATION; | ||
779 | wake_up(&Adapter->LEDInfo.notify_led_event); | ||
780 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "NACKING Idle mode as time out happen from LED side!!!!!!!!"); | ||
781 | } | ||
782 | } | ||
783 | if(stIdleResponse.szData[1] == TARGET_CAN_GO_TO_IDLE_MODE) | ||
784 | { | ||
785 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL,"ACKING IDLE MODE !!!!!!!!!"); | ||
786 | down(&Adapter->rdmwrmsync); | ||
787 | Adapter->bPreparingForLowPowerMode = TRUE; | ||
788 | up(&Adapter->rdmwrmsync); | ||
789 | #ifndef BCM_SHM_INTERFACE | ||
790 | //Killing all URBS. | ||
791 | if(Adapter->bDoSuspend == TRUE) | ||
792 | Bcm_kill_all_URBs((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter)); | ||
793 | |||
794 | #endif | ||
795 | } | ||
796 | else | ||
797 | { | ||
798 | Adapter->bPreparingForLowPowerMode = FALSE; | ||
799 | } | ||
800 | |||
801 | if(!NVMAccess) | ||
802 | up(&Adapter->NVMRdmWrmLock); | ||
803 | |||
804 | if(!lowPwrAbortMsg) | ||
805 | up(&Adapter->LowPowerModeSync); | ||
806 | |||
807 | } | ||
808 | status = CopyBufferToControlPacket(Adapter,&stIdleResponse); | ||
809 | if((status != STATUS_SUCCESS)) | ||
810 | { | ||
811 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"fail to send the Idle mode Request \n"); | ||
812 | Adapter->bPreparingForLowPowerMode = FALSE; | ||
813 | #ifndef BCM_SHM_INTERFACE | ||
814 | StartInterruptUrb((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter)); | ||
815 | #endif | ||
816 | } | ||
817 | do_gettimeofday(&tv); | ||
818 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "IdleMode Msg submitter to Q :%ld ms", tv.tv_sec *1000 + tv.tv_usec /1000); | ||
819 | |||
820 | } | ||
821 | |||
822 | /****************************************************************** | ||
823 | * Function - DumpPackInfo() | ||
824 | * | ||
825 | * Description - This function dumps the all Queue(PackInfo[]) details. | ||
826 | * | ||
827 | * Parameters - Adapter: Pointer to the Adapter structure. | ||
828 | * | ||
829 | * Returns - None. | ||
830 | *******************************************************************/ | ||
831 | VOID DumpPackInfo(PMINI_ADAPTER Adapter) | ||
832 | { | ||
833 | |||
834 | UINT uiLoopIndex = 0; | ||
835 | UINT uiIndex = 0; | ||
836 | UINT uiClsfrIndex = 0; | ||
837 | S_CLASSIFIER_RULE *pstClassifierEntry = NULL; | ||
838 | |||
839 | for(uiLoopIndex=0;uiLoopIndex<NO_OF_QUEUES;uiLoopIndex++) | ||
840 | { | ||
841 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"*********** Showing Details Of Queue %d***** ******",uiLoopIndex); | ||
842 | if(FALSE == Adapter->PackInfo[uiLoopIndex].bValid) | ||
843 | { | ||
844 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"bValid is FALSE for %X index\n",uiLoopIndex); | ||
845 | continue; | ||
846 | } | ||
847 | |||
848 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL," Dumping SF Rule Entry For SFID %lX \n",Adapter->PackInfo[uiLoopIndex].ulSFID); | ||
849 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL," ucDirection %X \n",Adapter->PackInfo[uiLoopIndex].ucDirection); | ||
850 | if(Adapter->PackInfo[uiLoopIndex].ucIpVersion == IPV6) | ||
851 | { | ||
852 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"Ipv6 Service Flow \n"); | ||
853 | } | ||
854 | else | ||
855 | { | ||
856 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"Ipv4 Service Flow \n"); | ||
857 | } | ||
858 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL," SF Traffic Priority %X \n",Adapter->PackInfo[uiLoopIndex].u8TrafficPriority); | ||
859 | |||
860 | for(uiClsfrIndex=0;uiClsfrIndex<MAX_CLASSIFIERS;uiClsfrIndex++) | ||
861 | { | ||
862 | pstClassifierEntry = &Adapter->astClassifierTable[uiClsfrIndex]; | ||
863 | if(!pstClassifierEntry->bUsed) | ||
864 | continue; | ||
865 | |||
866 | if(pstClassifierEntry->ulSFID != Adapter->PackInfo[uiLoopIndex].ulSFID) | ||
867 | continue; | ||
868 | |||
869 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tDumping Classifier Rule Entry For Index: %X Classifier Rule ID : %X\n",uiClsfrIndex,pstClassifierEntry->uiClassifierRuleIndex); | ||
870 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tDumping Classifier Rule Entry For Index: %X usVCID_Value : %X\n",uiClsfrIndex,pstClassifierEntry->usVCID_Value); | ||
871 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tDumping Classifier Rule Entry For Index: %X bProtocolValid : %X\n",uiClsfrIndex,pstClassifierEntry->bProtocolValid); | ||
872 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tDumping Classifier Rule Entry For Index: %X bTOSValid : %X\n",uiClsfrIndex,pstClassifierEntry->bTOSValid); | ||
873 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tDumping Classifier Rule Entry For Index: %X bDestIpValid : %X\n",uiClsfrIndex,pstClassifierEntry->bDestIpValid); | ||
874 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tDumping Classifier Rule Entry For Index: %X bSrcIpValid : %X\n",uiClsfrIndex,pstClassifierEntry->bSrcIpValid); | ||
875 | |||
876 | |||
877 | for(uiIndex=0;uiIndex<MAX_PORT_RANGE;uiIndex++) | ||
878 | { | ||
879 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tusSrcPortRangeLo:%X\n",pstClassifierEntry->usSrcPortRangeLo[uiIndex]); | ||
880 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tusSrcPortRangeHi:%X\n",pstClassifierEntry->usSrcPortRangeHi[uiIndex]); | ||
881 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tusDestPortRangeLo:%X\n",pstClassifierEntry->usDestPortRangeLo[uiIndex]); | ||
882 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tusDestPortRangeHi:%X\n",pstClassifierEntry->usDestPortRangeHi[uiIndex]); | ||
883 | } | ||
884 | |||
885 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL," \tucIPSourceAddressLength : 0x%x\n",pstClassifierEntry->ucIPSourceAddressLength); | ||
886 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tucIPDestinationAddressLength : 0x%x\n",pstClassifierEntry->ucIPDestinationAddressLength); | ||
887 | for(uiIndex=0;uiIndex<pstClassifierEntry->ucIPSourceAddressLength;uiIndex++) | ||
888 | { | ||
889 | if(Adapter->PackInfo[uiLoopIndex].ucIpVersion == IPV6) | ||
890 | { | ||
891 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tIpv6 ulSrcIpAddr :\n"); | ||
892 | DumpIpv6Address(pstClassifierEntry->stSrcIpAddress.ulIpv6Addr); | ||
893 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tIpv6 ulSrcIpMask :\n"); | ||
894 | DumpIpv6Address(pstClassifierEntry->stSrcIpAddress.ulIpv6Mask); | ||
895 | } | ||
896 | else | ||
897 | { | ||
898 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tulSrcIpAddr:%lX\n",pstClassifierEntry->stSrcIpAddress.ulIpv4Addr[uiIndex]); | ||
899 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tulSrcIpMask:%lX\n",pstClassifierEntry->stSrcIpAddress.ulIpv4Mask[uiIndex]); | ||
900 | } | ||
901 | } | ||
902 | for(uiIndex=0;uiIndex<pstClassifierEntry->ucIPDestinationAddressLength;uiIndex++) | ||
903 | { | ||
904 | if(Adapter->PackInfo[uiLoopIndex].ucIpVersion == IPV6) | ||
905 | { | ||
906 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tIpv6 ulDestIpAddr :\n"); | ||
907 | DumpIpv6Address(pstClassifierEntry->stDestIpAddress.ulIpv6Addr); | ||
908 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tIpv6 ulDestIpMask :\n"); | ||
909 | DumpIpv6Address(pstClassifierEntry->stDestIpAddress.ulIpv6Mask); | ||
910 | |||
911 | } | ||
912 | else | ||
913 | { | ||
914 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tulDestIpAddr:%lX\n",pstClassifierEntry->stDestIpAddress.ulIpv4Addr[uiIndex]); | ||
915 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tulDestIpMask:%lX\n",pstClassifierEntry->stDestIpAddress.ulIpv4Mask[uiIndex]); | ||
916 | } | ||
917 | } | ||
918 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tucProtocol:0x%X\n",pstClassifierEntry->ucProtocol[0]); | ||
919 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tu8ClassifierRulePriority:%X\n",pstClassifierEntry->u8ClassifierRulePriority); | ||
920 | |||
921 | |||
922 | } | ||
923 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"ulSFID:%lX\n",Adapter->PackInfo[uiLoopIndex].ulSFID); | ||
924 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"usVCID_Value:%X\n",Adapter->PackInfo[uiLoopIndex].usVCID_Value); | ||
925 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"PhsEnabled: 0x%X\n",Adapter->PackInfo[uiLoopIndex].bHeaderSuppressionEnabled); | ||
926 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiThreshold:%X\n",Adapter->PackInfo[uiLoopIndex].uiThreshold); | ||
927 | |||
928 | |||
929 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"bValid:%X\n",Adapter->PackInfo[uiLoopIndex].bValid); | ||
930 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"bActive:%X\n",Adapter->PackInfo[uiLoopIndex].bActive); | ||
931 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"ActivateReqSent: %x", Adapter->PackInfo[uiLoopIndex].bActivateRequestSent); | ||
932 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"u8QueueType:%X\n",Adapter->PackInfo[uiLoopIndex].u8QueueType); | ||
933 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiMaxBucketSize:%X\n",Adapter->PackInfo[uiLoopIndex].uiMaxBucketSize); | ||
934 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiPerSFTxResourceCount:%X\n",atomic_read(&Adapter->PackInfo[uiLoopIndex].uiPerSFTxResourceCount)); | ||
935 | //DumpDebug(DUMP_INFO,(" bCSSupport:%X\n",Adapter->PackInfo[uiLoopIndex].bCSSupport)); | ||
936 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"CurrQueueDepthOnTarget: %x\n", Adapter->PackInfo[uiLoopIndex].uiCurrentQueueDepthOnTarget); | ||
937 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiCurrentBytesOnHost:%X\n",Adapter->PackInfo[uiLoopIndex].uiCurrentBytesOnHost); | ||
938 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiCurrentPacketsOnHost:%X\n",Adapter->PackInfo[uiLoopIndex].uiCurrentPacketsOnHost); | ||
939 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiDroppedCountBytes:%X\n",Adapter->PackInfo[uiLoopIndex].uiDroppedCountBytes); | ||
940 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiDroppedCountPackets:%X\n",Adapter->PackInfo[uiLoopIndex].uiDroppedCountPackets); | ||
941 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiSentBytes:%X\n",Adapter->PackInfo[uiLoopIndex].uiSentBytes); | ||
942 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiSentPackets:%X\n",Adapter->PackInfo[uiLoopIndex].uiSentPackets); | ||
943 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiCurrentDrainRate:%X\n",Adapter->PackInfo[uiLoopIndex].uiCurrentDrainRate); | ||
944 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiThisPeriodSentBytes:%X\n",Adapter->PackInfo[uiLoopIndex].uiThisPeriodSentBytes); | ||
945 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"liDrainCalculated:%llX\n",Adapter->PackInfo[uiLoopIndex].liDrainCalculated); | ||
946 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiCurrentTokenCount:%X\n",Adapter->PackInfo[uiLoopIndex].uiCurrentTokenCount); | ||
947 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"liLastUpdateTokenAt:%llX\n",Adapter->PackInfo[uiLoopIndex].liLastUpdateTokenAt); | ||
948 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiMaxAllowedRate:%X\n",Adapter->PackInfo[uiLoopIndex].uiMaxAllowedRate); | ||
949 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiPendedLast:%X\n",Adapter->PackInfo[uiLoopIndex].uiPendedLast); | ||
950 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"NumOfPacketsSent:%X\n",Adapter->PackInfo[uiLoopIndex].NumOfPacketsSent); | ||
951 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Direction: %x\n", Adapter->PackInfo[uiLoopIndex].ucDirection); | ||
952 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "CID: %x\n", Adapter->PackInfo[uiLoopIndex].usCID); | ||
953 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ProtocolValid: %x\n", Adapter->PackInfo[uiLoopIndex].bProtocolValid); | ||
954 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "TOSValid: %x\n", Adapter->PackInfo[uiLoopIndex].bTOSValid); | ||
955 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "DestIpValid: %x\n", Adapter->PackInfo[uiLoopIndex].bDestIpValid); | ||
956 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "SrcIpValid: %x\n", Adapter->PackInfo[uiLoopIndex].bSrcIpValid); | ||
957 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ActiveSet: %x\n", Adapter->PackInfo[uiLoopIndex].bActiveSet); | ||
958 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "AdmittedSet: %x\n", Adapter->PackInfo[uiLoopIndex].bAdmittedSet); | ||
959 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "AuthzSet: %x\n", Adapter->PackInfo[uiLoopIndex].bAuthorizedSet); | ||
960 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ClassifyPrority: %x\n", Adapter->PackInfo[uiLoopIndex].bClassifierPriority); | ||
961 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiMaxLatency: %x\n",Adapter->PackInfo[uiLoopIndex].uiMaxLatency); | ||
962 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ServiceClassName: %x %x %x %x\n",Adapter->PackInfo[uiLoopIndex].ucServiceClassName[0],Adapter->PackInfo[uiLoopIndex].ucServiceClassName[1],Adapter->PackInfo[uiLoopIndex].ucServiceClassName[2],Adapter->PackInfo[uiLoopIndex].ucServiceClassName[3]); | ||
963 | // BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "bHeaderSuppressionEnabled :%X\n", Adapter->PackInfo[uiLoopIndex].bHeaderSuppressionEnabled); | ||
964 | // BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiTotalTxBytes:%X\n", Adapter->PackInfo[uiLoopIndex].uiTotalTxBytes); | ||
965 | // BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiTotalRxBytes:%X\n", Adapter->PackInfo[uiLoopIndex].uiTotalRxBytes); | ||
966 | // DumpDebug(DUMP_INFO,(" uiRanOutOfResCount:%X\n",Adapter->PackInfo[uiLoopIndex].uiRanOutOfResCount)); | ||
967 | } | ||
968 | |||
969 | for(uiLoopIndex = 0 ; uiLoopIndex < MIBS_MAX_HIST_ENTRIES ; uiLoopIndex++) | ||
970 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"Adapter->aRxPktSizeHist[%x] = %x\n",uiLoopIndex,Adapter->aRxPktSizeHist[uiLoopIndex]); | ||
971 | |||
972 | for(uiLoopIndex = 0 ; uiLoopIndex < MIBS_MAX_HIST_ENTRIES ; uiLoopIndex++) | ||
973 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"Adapter->aTxPktSizeHist[%x] = %x\n",uiLoopIndex,Adapter->aTxPktSizeHist[uiLoopIndex]); | ||
974 | |||
975 | |||
976 | |||
977 | return; | ||
978 | |||
979 | |||
980 | } | ||
981 | |||
982 | |||
983 | __inline int reset_card_proc(PMINI_ADAPTER ps_adapter) | ||
984 | { | ||
985 | int retval = STATUS_SUCCESS; | ||
986 | |||
987 | #ifndef BCM_SHM_INTERFACE | ||
988 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
989 | PS_INTERFACE_ADAPTER psIntfAdapter = NULL; | ||
990 | unsigned int value = 0, uiResetValue = 0; | ||
991 | |||
992 | psIntfAdapter = ((PS_INTERFACE_ADAPTER)(ps_adapter->pvInterfaceAdapter)) ; | ||
993 | |||
994 | ps_adapter->bDDRInitDone = FALSE; | ||
995 | |||
996 | if(ps_adapter->chip_id >= T3LPB) | ||
997 | { | ||
998 | //SYS_CFG register is write protected hence for modifying this reg value, it should be read twice before | ||
999 | rdmalt(ps_adapter,SYS_CFG, &value, sizeof(value)); | ||
1000 | rdmalt(ps_adapter,SYS_CFG, &value, sizeof(value)); | ||
1001 | |||
1002 | //making bit[6...5] same as was before f/w download. this setting force the h/w to | ||
1003 | //re-populated the SP RAM area with the string descriptor . | ||
1004 | value = value | (ps_adapter->syscfgBefFwDld & 0x00000060) ; | ||
1005 | wrmalt(ps_adapter, SYS_CFG, &value, sizeof(value)); | ||
1006 | } | ||
1007 | |||
1008 | #ifndef BCM_SHM_INTERFACE | ||
1009 | //killing all submitted URBs. | ||
1010 | psIntfAdapter->psAdapter->StopAllXaction = TRUE ; | ||
1011 | Bcm_kill_all_URBs(psIntfAdapter); | ||
1012 | #endif | ||
1013 | /* Reset the UMA-B Device */ | ||
1014 | if(ps_adapter->chip_id >= T3LPB) | ||
1015 | { | ||
1016 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Reseting UMA-B \n"); | ||
1017 | retval = usb_reset_device(psIntfAdapter->udev); | ||
1018 | |||
1019 | psIntfAdapter->psAdapter->StopAllXaction = FALSE ; | ||
1020 | |||
1021 | if(retval != STATUS_SUCCESS) | ||
1022 | { | ||
1023 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Reset failed with ret value :%d", retval); | ||
1024 | goto err_exit; | ||
1025 | } | ||
1026 | if (ps_adapter->chip_id == BCS220_2 || | ||
1027 | ps_adapter->chip_id == BCS220_2BC || | ||
1028 | ps_adapter->chip_id == BCS250_BC || | ||
1029 | ps_adapter->chip_id == BCS220_3) | ||
1030 | { | ||
1031 | retval = rdmalt(ps_adapter,HPM_CONFIG_LDO145, &value, sizeof(value)); | ||
1032 | if( retval < 0) | ||
1033 | { | ||
1034 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"read failed with status :%d",retval); | ||
1035 | goto err_exit; | ||
1036 | } | ||
1037 | //setting 0th bit | ||
1038 | value |= (1<<0); | ||
1039 | retval = wrmalt(ps_adapter, HPM_CONFIG_LDO145, &value, sizeof(value)); | ||
1040 | if( retval < 0) | ||
1041 | { | ||
1042 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"write failed with status :%d",retval); | ||
1043 | goto err_exit; | ||
1044 | } | ||
1045 | } | ||
1046 | |||
1047 | } | ||
1048 | else | ||
1049 | { | ||
1050 | retval = rdmalt(ps_adapter,0x0f007018, &value, sizeof(value)); | ||
1051 | if( retval < 0) { | ||
1052 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"read failed with status :%d",retval); | ||
1053 | goto err_exit; | ||
1054 | } | ||
1055 | value&=(~(1<<16)); | ||
1056 | retval= wrmalt(ps_adapter, 0x0f007018, &value, sizeof(value)) ; | ||
1057 | if( retval < 0) { | ||
1058 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"write failed with status :%d",retval); | ||
1059 | goto err_exit; | ||
1060 | } | ||
1061 | |||
1062 | // Toggling the GPIO 8, 9 | ||
1063 | value = 0; | ||
1064 | retval = wrmalt(ps_adapter, GPIO_OUTPUT_REGISTER, &value, sizeof(value)); | ||
1065 | if(retval < 0) { | ||
1066 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"write failed with status :%d",retval); | ||
1067 | goto err_exit; | ||
1068 | } | ||
1069 | value = 0x300; | ||
1070 | retval = wrmalt(ps_adapter, GPIO_MODE_REGISTER, &value, sizeof(value)) ; | ||
1071 | if(retval < 0) { | ||
1072 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"write failed with status :%d",retval); | ||
1073 | goto err_exit; | ||
1074 | } | ||
1075 | mdelay(50); | ||
1076 | } | ||
1077 | |||
1078 | //ps_adapter->downloadDDR = false; | ||
1079 | |||
1080 | if(ps_adapter->bFlashBoot) | ||
1081 | { | ||
1082 | //In flash boot mode MIPS state register has reverse polarity. | ||
1083 | // So just or with setting bit 30. | ||
1084 | //Make the MIPS in Reset state. | ||
1085 | rdmalt(ps_adapter, CLOCK_RESET_CNTRL_REG_1, &uiResetValue, sizeof(uiResetValue)); | ||
1086 | |||
1087 | uiResetValue |=(1<<30); | ||
1088 | wrmalt(ps_adapter, CLOCK_RESET_CNTRL_REG_1, &uiResetValue, sizeof(uiResetValue)); | ||
1089 | } | ||
1090 | |||
1091 | if(ps_adapter->chip_id >= T3LPB) | ||
1092 | { | ||
1093 | uiResetValue = 0; | ||
1094 | // | ||
1095 | // WA for SYSConfig Issue. | ||
1096 | // Read SYSCFG Twice to make it writable. | ||
1097 | // | ||
1098 | rdmalt(ps_adapter, SYS_CFG, &uiResetValue, sizeof(uiResetValue)); | ||
1099 | if(uiResetValue & (1<<4)) | ||
1100 | { | ||
1101 | uiResetValue = 0; | ||
1102 | rdmalt(ps_adapter, SYS_CFG, &uiResetValue, sizeof(uiResetValue));//2nd read to make it writable. | ||
1103 | uiResetValue &= (~(1<<4)); | ||
1104 | wrmalt(ps_adapter,SYS_CFG, &uiResetValue, sizeof(uiResetValue)); | ||
1105 | } | ||
1106 | |||
1107 | } | ||
1108 | uiResetValue = 0; | ||
1109 | wrmalt(ps_adapter, 0x0f01186c, &uiResetValue, sizeof(uiResetValue)); | ||
1110 | |||
1111 | err_exit : | ||
1112 | psIntfAdapter->psAdapter->StopAllXaction = FALSE ; | ||
1113 | #endif | ||
1114 | return retval; | ||
1115 | } | ||
1116 | |||
1117 | __inline int run_card_proc(PMINI_ADAPTER ps_adapter ) | ||
1118 | { | ||
1119 | unsigned int value=0; | ||
1120 | { | ||
1121 | |||
1122 | if(rdmalt(ps_adapter, CLOCK_RESET_CNTRL_REG_1, &value, sizeof(value)) < 0) { | ||
1123 | BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"%s:%d\n", __FUNCTION__, __LINE__); | ||
1124 | return STATUS_FAILURE; | ||
1125 | } | ||
1126 | |||
1127 | if(ps_adapter->bFlashBoot) | ||
1128 | { | ||
1129 | |||
1130 | value&=(~(1<<30)); | ||
1131 | } | ||
1132 | else | ||
1133 | { | ||
1134 | value |=(1<<30); | ||
1135 | } | ||
1136 | |||
1137 | if(wrmalt(ps_adapter, CLOCK_RESET_CNTRL_REG_1, &value, sizeof(value)) < 0) { | ||
1138 | BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"%s:%d\n", __FUNCTION__, __LINE__); | ||
1139 | return STATUS_FAILURE; | ||
1140 | } | ||
1141 | } | ||
1142 | return STATUS_SUCCESS; | ||
1143 | } | ||
1144 | |||
1145 | int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter) | ||
1146 | { | ||
1147 | |||
1148 | UINT status = STATUS_SUCCESS; | ||
1149 | UINT value = 0; | ||
1150 | #ifdef BCM_SHM_INTERFACE | ||
1151 | unsigned char *pConfigFileAddr = (unsigned char *)CPE_MACXVI_CFG_ADDR; | ||
1152 | #endif | ||
1153 | /* | ||
1154 | * Create the threads first and then download the | ||
1155 | * Firm/DDR Settings.. | ||
1156 | */ | ||
1157 | |||
1158 | if((status = create_worker_threads(ps_adapter))<0) | ||
1159 | { | ||
1160 | BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Cannot create thread"); | ||
1161 | return status; | ||
1162 | } | ||
1163 | /* | ||
1164 | * For Downloading the Firm, parse the cfg file first. | ||
1165 | */ | ||
1166 | status = bcm_parse_target_params (ps_adapter); | ||
1167 | if(status){ | ||
1168 | return status; | ||
1169 | } | ||
1170 | |||
1171 | #ifndef BCM_SHM_INTERFACE | ||
1172 | if(ps_adapter->chip_id >= T3LPB) | ||
1173 | { | ||
1174 | rdmalt(ps_adapter, SYS_CFG, &value, sizeof (value)); | ||
1175 | ps_adapter->syscfgBefFwDld = value ; | ||
1176 | if((value & 0x60)== 0) | ||
1177 | { | ||
1178 | ps_adapter->bFlashBoot = TRUE; | ||
1179 | } | ||
1180 | } | ||
1181 | |||
1182 | reset_card_proc(ps_adapter); | ||
1183 | |||
1184 | //Initializing the NVM. | ||
1185 | BcmInitNVM(ps_adapter); | ||
1186 | status = ddr_init(ps_adapter); | ||
1187 | if(status) | ||
1188 | { | ||
1189 | BCM_DEBUG_PRINT (ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "ddr_init Failed\n"); | ||
1190 | return status; | ||
1191 | } | ||
1192 | |||
1193 | /* Download cfg file */ | ||
1194 | status = buffDnldVerify(ps_adapter, | ||
1195 | (PUCHAR)ps_adapter->pstargetparams, | ||
1196 | sizeof(STARGETPARAMS), | ||
1197 | CONFIG_BEGIN_ADDR); | ||
1198 | if(status) | ||
1199 | { | ||
1200 | BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Error downloading CFG file"); | ||
1201 | goto OUT; | ||
1202 | } | ||
1203 | BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "CFG file downloaded"); | ||
1204 | |||
1205 | if(register_networkdev(ps_adapter)) | ||
1206 | { | ||
1207 | BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Register Netdevice failed. Cleanup needs to be performed."); | ||
1208 | return -EIO; | ||
1209 | } | ||
1210 | |||
1211 | if(FALSE == ps_adapter->AutoFirmDld) | ||
1212 | { | ||
1213 | BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "AutoFirmDld Disabled in CFG File..\n"); | ||
1214 | //If Auto f/w download is disable, register the control interface, | ||
1215 | //register the control interface after the mailbox. | ||
1216 | if(register_control_device_interface(ps_adapter) < 0) | ||
1217 | { | ||
1218 | BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Register Control Device failed. Cleanup needs to be performed."); | ||
1219 | return -EIO; | ||
1220 | } | ||
1221 | |||
1222 | return STATUS_SUCCESS; | ||
1223 | } | ||
1224 | |||
1225 | /* | ||
1226 | * Do the LED Settings here. It will be used by the Firmware Download | ||
1227 | * Thread. | ||
1228 | */ | ||
1229 | |||
1230 | /* | ||
1231 | * 1. If the LED Settings fails, do not stop and do the Firmware download. | ||
1232 | * 2. This init would happend only if the cfg file is present, else | ||
1233 | * call from the ioctl context. | ||
1234 | */ | ||
1235 | |||
1236 | status = InitLedSettings (ps_adapter); | ||
1237 | |||
1238 | if(status) | ||
1239 | { | ||
1240 | BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_PRINTK, 0, 0,"INIT LED FAILED\n"); | ||
1241 | return status; | ||
1242 | } | ||
1243 | if(ps_adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) | ||
1244 | { | ||
1245 | ps_adapter->DriverState = DRIVER_INIT; | ||
1246 | wake_up(&ps_adapter->LEDInfo.notify_led_event); | ||
1247 | } | ||
1248 | |||
1249 | if(ps_adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) | ||
1250 | { | ||
1251 | ps_adapter->DriverState = FW_DOWNLOAD; | ||
1252 | wake_up(&ps_adapter->LEDInfo.notify_led_event); | ||
1253 | } | ||
1254 | |||
1255 | value = 0; | ||
1256 | wrmalt(ps_adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 4, &value, sizeof(value)); | ||
1257 | wrmalt(ps_adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 8, &value, sizeof(value)); | ||
1258 | |||
1259 | if(ps_adapter->eNVMType == NVM_FLASH) | ||
1260 | { | ||
1261 | status = PropagateCalParamsFromFlashToMemory(ps_adapter); | ||
1262 | if(status) | ||
1263 | { | ||
1264 | BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL," Propogation of Cal param failed .." ); | ||
1265 | goto OUT; | ||
1266 | } | ||
1267 | } | ||
1268 | #if 0 | ||
1269 | else if(psAdapter->eNVMType == NVM_EEPROM) | ||
1270 | { | ||
1271 | PropagateCalParamsFromEEPROMToMemory(); | ||
1272 | } | ||
1273 | #endif | ||
1274 | |||
1275 | /* Download Firmare */ | ||
1276 | if ((status = BcmFileDownload( ps_adapter, BIN_FILE, FIRMWARE_BEGIN_ADDR))) | ||
1277 | { | ||
1278 | BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "No Firmware File is present... \n"); | ||
1279 | goto OUT; | ||
1280 | } | ||
1281 | |||
1282 | BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "BIN file downloaded"); | ||
1283 | status = run_card_proc(ps_adapter); | ||
1284 | if(status) | ||
1285 | { | ||
1286 | BCM_DEBUG_PRINT (ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "run_card_proc Failed\n"); | ||
1287 | goto OUT; | ||
1288 | } | ||
1289 | |||
1290 | |||
1291 | ps_adapter->fw_download_done = TRUE; | ||
1292 | mdelay(10); | ||
1293 | |||
1294 | OUT: | ||
1295 | if(ps_adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) | ||
1296 | { | ||
1297 | ps_adapter->DriverState = FW_DOWNLOAD_DONE; | ||
1298 | wake_up(&ps_adapter->LEDInfo.notify_led_event); | ||
1299 | } | ||
1300 | |||
1301 | #else | ||
1302 | |||
1303 | ps_adapter->bDDRInitDone = TRUE; | ||
1304 | //Initializing the NVM. | ||
1305 | BcmInitNVM(ps_adapter); | ||
1306 | |||
1307 | //Propagating the cal param from Flash to DDR | ||
1308 | value = 0; | ||
1309 | wrmalt(ps_adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 4, &value, sizeof(value)); | ||
1310 | wrmalt(ps_adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 8, &value, sizeof(value)); | ||
1311 | |||
1312 | if(ps_adapter->eNVMType == NVM_FLASH) | ||
1313 | { | ||
1314 | status = PropagateCalParamsFromFlashToMemory(ps_adapter); | ||
1315 | if(status) | ||
1316 | { | ||
1317 | printk("\nPropogation of Cal param from flash to DDR failed ..\n" ); | ||
1318 | } | ||
1319 | } | ||
1320 | |||
1321 | //Copy config file param to DDR. | ||
1322 | memcpy(pConfigFileAddr,ps_adapter->pstargetparams, sizeof(STARGETPARAMS)); | ||
1323 | |||
1324 | if(register_networkdev(ps_adapter)) | ||
1325 | { | ||
1326 | BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Register Netdevice failed. Cleanup needs to be performed."); | ||
1327 | return -EIO; | ||
1328 | } | ||
1329 | |||
1330 | |||
1331 | status = InitLedSettings (ps_adapter); | ||
1332 | if(status) | ||
1333 | { | ||
1334 | BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_PRINTK, 0, 0,"INIT LED FAILED\n"); | ||
1335 | return status; | ||
1336 | } | ||
1337 | |||
1338 | |||
1339 | if(register_control_device_interface(ps_adapter) < 0) | ||
1340 | { | ||
1341 | BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Register Control Device failed. Cleanup needs to be performed."); | ||
1342 | return -EIO; | ||
1343 | } | ||
1344 | |||
1345 | ps_adapter->fw_download_done = TRUE; | ||
1346 | #endif | ||
1347 | return status; | ||
1348 | } | ||
1349 | |||
1350 | |||
1351 | int bcm_parse_target_params(PMINI_ADAPTER Adapter) | ||
1352 | { | ||
1353 | #ifdef BCM_SHM_INTERFACE | ||
1354 | extern void read_cfg_file(PMINI_ADAPTER Adapter); | ||
1355 | #endif | ||
1356 | struct file *flp=NULL; | ||
1357 | mm_segment_t oldfs={0}; | ||
1358 | char *buff = NULL; | ||
1359 | int len = 0; | ||
1360 | loff_t pos = 0; | ||
1361 | |||
1362 | buff=(PCHAR)kmalloc(BUFFER_1K, GFP_KERNEL); | ||
1363 | if(!buff) | ||
1364 | { | ||
1365 | return -ENOMEM; | ||
1366 | } | ||
1367 | if((Adapter->pstargetparams = | ||
1368 | kmalloc(sizeof(STARGETPARAMS), GFP_KERNEL)) == NULL) | ||
1369 | { | ||
1370 | bcm_kfree(buff); | ||
1371 | return -ENOMEM; | ||
1372 | } | ||
1373 | flp=open_firmware_file(Adapter, CFG_FILE); | ||
1374 | if(!flp) { | ||
1375 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "NOT ABLE TO OPEN THE %s FILE \n", CFG_FILE); | ||
1376 | bcm_kfree(buff); | ||
1377 | bcm_kfree(Adapter->pstargetparams); | ||
1378 | Adapter->pstargetparams = NULL; | ||
1379 | return -ENOENT; | ||
1380 | } | ||
1381 | oldfs=get_fs(); set_fs(get_ds()); | ||
1382 | len=vfs_read(flp, buff, BUFFER_1K, &pos); | ||
1383 | set_fs(oldfs); | ||
1384 | |||
1385 | if(len != sizeof(STARGETPARAMS)) | ||
1386 | { | ||
1387 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Mismatch in Target Param Structure!\n"); | ||
1388 | bcm_kfree(buff); | ||
1389 | bcm_kfree(Adapter->pstargetparams); | ||
1390 | Adapter->pstargetparams = NULL; | ||
1391 | filp_close(flp, current->files); | ||
1392 | return -ENOENT; | ||
1393 | } | ||
1394 | filp_close(flp, current->files); | ||
1395 | |||
1396 | /* Check for autolink in config params */ | ||
1397 | /* | ||
1398 | * Values in Adapter->pstargetparams are in network byte order | ||
1399 | */ | ||
1400 | memcpy(Adapter->pstargetparams, buff, sizeof(STARGETPARAMS)); | ||
1401 | bcm_kfree (buff); | ||
1402 | beceem_parse_target_struct(Adapter); | ||
1403 | #ifdef BCM_SHM_INTERFACE | ||
1404 | read_cfg_file(Adapter); | ||
1405 | |||
1406 | #endif | ||
1407 | return STATUS_SUCCESS; | ||
1408 | } | ||
1409 | |||
1410 | void beceem_parse_target_struct(PMINI_ADAPTER Adapter) | ||
1411 | { | ||
1412 | UINT uiHostDrvrCfg6 =0, uiEEPROMFlag = 0;; | ||
1413 | |||
1414 | if(ntohl(Adapter->pstargetparams->m_u32PhyParameter2) & AUTO_SYNC_DISABLE) | ||
1415 | { | ||
1416 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "AutoSyncup is Disabled\n"); | ||
1417 | Adapter->AutoSyncup = FALSE; | ||
1418 | } | ||
1419 | else | ||
1420 | { | ||
1421 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "AutoSyncup is Enabled\n"); | ||
1422 | Adapter->AutoSyncup = TRUE; | ||
1423 | } | ||
1424 | if(ntohl(Adapter->pstargetparams->HostDrvrConfig6) & AUTO_LINKUP_ENABLE) | ||
1425 | { | ||
1426 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Enabling autolink up"); | ||
1427 | Adapter->AutoLinkUp = TRUE; | ||
1428 | } | ||
1429 | else | ||
1430 | { | ||
1431 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Disabling autolink up"); | ||
1432 | Adapter->AutoLinkUp = FALSE; | ||
1433 | } | ||
1434 | // Setting the DDR Setting.. | ||
1435 | Adapter->DDRSetting = | ||
1436 | (ntohl(Adapter->pstargetparams->HostDrvrConfig6) >>8)&0x0F; | ||
1437 | Adapter->ulPowerSaveMode = | ||
1438 | (ntohl(Adapter->pstargetparams->HostDrvrConfig6)>>12)&0x0F; | ||
1439 | |||
1440 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "DDR Setting: %x\n", Adapter->DDRSetting); | ||
1441 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT,DBG_LVL_ALL, "Power Save Mode: %lx\n", | ||
1442 | Adapter->ulPowerSaveMode); | ||
1443 | if(ntohl(Adapter->pstargetparams->HostDrvrConfig6) & AUTO_FIRM_DOWNLOAD) | ||
1444 | { | ||
1445 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Enabling Auto Firmware Download\n"); | ||
1446 | Adapter->AutoFirmDld = TRUE; | ||
1447 | } | ||
1448 | else | ||
1449 | { | ||
1450 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Disabling Auto Firmware Download\n"); | ||
1451 | Adapter->AutoFirmDld = FALSE; | ||
1452 | } | ||
1453 | uiHostDrvrCfg6 = ntohl(Adapter->pstargetparams->HostDrvrConfig6); | ||
1454 | Adapter->bMipsConfig = (uiHostDrvrCfg6>>20)&0x01; | ||
1455 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"MIPSConfig : 0x%X\n",Adapter->bMipsConfig); | ||
1456 | //used for backward compatibility. | ||
1457 | Adapter->bDPLLConfig = (uiHostDrvrCfg6>>19)&0x01; | ||
1458 | |||
1459 | Adapter->PmuMode= (uiHostDrvrCfg6 >> 24 ) & 0x03; | ||
1460 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "PMU MODE: %x", Adapter->PmuMode); | ||
1461 | |||
1462 | if((uiHostDrvrCfg6 >> HOST_BUS_SUSPEND_BIT ) & (0x01)) | ||
1463 | { | ||
1464 | Adapter->bDoSuspend = TRUE; | ||
1465 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Making DoSuspend TRUE as per configFile"); | ||
1466 | } | ||
1467 | |||
1468 | uiEEPROMFlag = ntohl(Adapter->pstargetparams->m_u32EEPROMFlag); | ||
1469 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "uiEEPROMFlag : 0x%X\n",uiEEPROMFlag); | ||
1470 | Adapter->eNVMType = (NVM_TYPE)((uiEEPROMFlag>>4)&0x3); | ||
1471 | |||
1472 | |||
1473 | Adapter->bStatusWrite = (uiEEPROMFlag>>6)&0x1; | ||
1474 | //printk(("bStatusWrite : 0x%X\n", Adapter->bStatusWrite)); | ||
1475 | |||
1476 | Adapter->uiSectorSizeInCFG = 1024*(0xFFFF & ntohl(Adapter->pstargetparams->HostDrvrConfig4)); | ||
1477 | //printk(("uiSectorSize : 0x%X\n", Adapter->uiSectorSizeInCFG)); | ||
1478 | |||
1479 | Adapter->bSectorSizeOverride =(bool) ((ntohl(Adapter->pstargetparams->HostDrvrConfig4))>>16)&0x1; | ||
1480 | //printk(MP_INIT,("bSectorSizeOverride : 0x%X\n",Adapter->bSectorSizeOverride)); | ||
1481 | |||
1482 | if(ntohl(Adapter->pstargetparams->m_u32PowerSavingModeOptions) &0x01) | ||
1483 | Adapter->ulPowerSaveMode = DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE; | ||
1484 | //autocorrection part | ||
1485 | if(Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE) | ||
1486 | doPowerAutoCorrection(Adapter); | ||
1487 | |||
1488 | } | ||
1489 | |||
1490 | VOID doPowerAutoCorrection(PMINI_ADAPTER psAdapter) | ||
1491 | { | ||
1492 | UINT reporting_mode = 0; | ||
1493 | |||
1494 | reporting_mode = ntohl(psAdapter->pstargetparams->m_u32PowerSavingModeOptions) &0x02 ; | ||
1495 | psAdapter->bIsAutoCorrectEnabled = !((char)(psAdapter->ulPowerSaveMode >> 3) & 0x1); | ||
1496 | |||
1497 | if(reporting_mode == TRUE) | ||
1498 | { | ||
1499 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"can't do suspen/resume as reporting mode is enable"); | ||
1500 | psAdapter->bDoSuspend = FALSE; | ||
1501 | } | ||
1502 | |||
1503 | if (psAdapter->bIsAutoCorrectEnabled && (psAdapter->chip_id >= T3LPB)) | ||
1504 | { | ||
1505 | //If reporting mode is enable, switch PMU to PMC | ||
1506 | #if 0 | ||
1507 | if(reporting_mode == FALSE) | ||
1508 | { | ||
1509 | psAdapter->ulPowerSaveMode = DEVICE_POWERSAVE_MODE_AS_PMU_SHUTDOWN; | ||
1510 | psAdapter->bDoSuspend = TRUE; | ||
1511 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"PMU selected ...."); | ||
1512 | |||
1513 | } | ||
1514 | else | ||
1515 | #endif | ||
1516 | { | ||
1517 | psAdapter->ulPowerSaveMode = DEVICE_POWERSAVE_MODE_AS_PMU_CLOCK_GATING; | ||
1518 | psAdapter->bDoSuspend =FALSE; | ||
1519 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"PMC selected.."); | ||
1520 | |||
1521 | } | ||
1522 | |||
1523 | //clearing space bit[15..12] | ||
1524 | psAdapter->pstargetparams->HostDrvrConfig6 &= ~(htonl((0xF << 12))); | ||
1525 | //placing the power save mode option | ||
1526 | psAdapter->pstargetparams->HostDrvrConfig6 |= htonl((psAdapter->ulPowerSaveMode << 12)); | ||
1527 | |||
1528 | } | ||
1529 | else if (psAdapter->bIsAutoCorrectEnabled == FALSE) | ||
1530 | { | ||
1531 | |||
1532 | // remove the autocorrect disable bit set before dumping. | ||
1533 | psAdapter->ulPowerSaveMode &= ~(1 << 3); | ||
1534 | psAdapter->pstargetparams->HostDrvrConfig6 &= ~(htonl(1 << 15)); | ||
1535 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Using Forced User Choice: %lx\n", psAdapter->ulPowerSaveMode); | ||
1536 | } | ||
1537 | } | ||
1538 | unsigned char *ReadMacAddrEEPROM(PMINI_ADAPTER Adapter, ulong dwAddress) | ||
1539 | { | ||
1540 | unsigned char *pucmacaddr = NULL; | ||
1541 | int status = 0, i=0; | ||
1542 | unsigned int temp =0; | ||
1543 | |||
1544 | |||
1545 | pucmacaddr = (unsigned char *)kmalloc(MAC_ADDRESS_SIZE, GFP_KERNEL); | ||
1546 | if(!pucmacaddr) | ||
1547 | { | ||
1548 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "No Buffers to Read the EEPROM Address\n"); | ||
1549 | return NULL; | ||
1550 | } | ||
1551 | |||
1552 | dwAddress |= 0x5b000000; | ||
1553 | status = wrmalt(Adapter, EEPROM_COMMAND_Q_REG, | ||
1554 | (PUINT)&dwAddress, sizeof(UINT)); | ||
1555 | if(status != STATUS_SUCCESS) | ||
1556 | { | ||
1557 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "wrm Failed..\n"); | ||
1558 | bcm_kfree(pucmacaddr); | ||
1559 | pucmacaddr = NULL; | ||
1560 | goto OUT; | ||
1561 | } | ||
1562 | for(i=0;i<MAC_ADDRESS_SIZE;i++) | ||
1563 | { | ||
1564 | status = rdmalt(Adapter, EEPROM_READ_DATA_Q_REG, &temp,sizeof(temp)); | ||
1565 | if(status != STATUS_SUCCESS) | ||
1566 | { | ||
1567 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "rdm Failed..\n"); | ||
1568 | bcm_kfree(pucmacaddr); | ||
1569 | pucmacaddr = NULL; | ||
1570 | goto OUT; | ||
1571 | } | ||
1572 | pucmacaddr[i] = temp & 0xff; | ||
1573 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"%x \n", pucmacaddr[i]); | ||
1574 | } | ||
1575 | OUT: | ||
1576 | return pucmacaddr; | ||
1577 | } | ||
1578 | |||
1579 | #if 0 | ||
1580 | INT ReadMacAddressFromEEPROM(PMINI_ADAPTER Adapter) | ||
1581 | { | ||
1582 | unsigned char *puMacAddr = NULL; | ||
1583 | int i =0; | ||
1584 | |||
1585 | puMacAddr = ReadMacAddrEEPROM(Adapter,0x200); | ||
1586 | if(!puMacAddr) | ||
1587 | { | ||
1588 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Couldn't retrieve the Mac Address\n"); | ||
1589 | return STATUS_FAILURE; | ||
1590 | } | ||
1591 | else | ||
1592 | { | ||
1593 | if((puMacAddr[0] == 0x0 && puMacAddr[1] == 0x0 && | ||
1594 | puMacAddr[2] == 0x0 && puMacAddr[3] == 0x0 && | ||
1595 | puMacAddr[4] == 0x0 && puMacAddr[5] == 0x0) || | ||
1596 | (puMacAddr[0] == 0xFF && puMacAddr[1] == 0xFF && | ||
1597 | puMacAddr[2] == 0xFF && puMacAddr[3] == 0xFF && | ||
1598 | puMacAddr[4] == 0xFF && puMacAddr[5] == 0xFF)) | ||
1599 | { | ||
1600 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Invalid Mac Address\n"); | ||
1601 | bcm_kfree(puMacAddr); | ||
1602 | return STATUS_FAILURE; | ||
1603 | } | ||
1604 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "The Mac Address received is: \n"); | ||
1605 | memcpy(Adapter->dev->dev_addr, puMacAddr, MAC_ADDRESS_SIZE); | ||
1606 | for(i=0;i<MAC_ADDRESS_SIZE;i++) | ||
1607 | { | ||
1608 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"%02x ", Adapter->dev->dev_addr[i]); | ||
1609 | } | ||
1610 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"\n"); | ||
1611 | bcm_kfree(puMacAddr); | ||
1612 | } | ||
1613 | return STATUS_SUCCESS; | ||
1614 | } | ||
1615 | #endif | ||
1616 | |||
1617 | void convertEndian(B_UINT8 rwFlag, PUINT puiBuffer, UINT uiByteCount) | ||
1618 | { | ||
1619 | UINT uiIndex = 0; | ||
1620 | |||
1621 | if(RWM_WRITE == rwFlag) { | ||
1622 | for(uiIndex =0; uiIndex < (uiByteCount/sizeof(UINT)); uiIndex++) { | ||
1623 | puiBuffer[uiIndex] = htonl(puiBuffer[uiIndex]); | ||
1624 | } | ||
1625 | } else { | ||
1626 | for(uiIndex =0; uiIndex < (uiByteCount/sizeof(UINT)); uiIndex++) { | ||
1627 | puiBuffer[uiIndex] = ntohl(puiBuffer[uiIndex]); | ||
1628 | } | ||
1629 | } | ||
1630 | } | ||
1631 | |||
1632 | #define CACHE_ADDRESS_MASK 0x80000000 | ||
1633 | #define UNCACHE_ADDRESS_MASK 0xa0000000 | ||
1634 | |||
1635 | int rdm(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize) | ||
1636 | { | ||
1637 | INT uiRetVal =0; | ||
1638 | |||
1639 | #ifndef BCM_SHM_INTERFACE | ||
1640 | uiRetVal = Adapter->interface_rdm(Adapter->pvInterfaceAdapter, | ||
1641 | uiAddress, pucBuff, sSize); | ||
1642 | |||
1643 | if(uiRetVal < 0) | ||
1644 | return uiRetVal; | ||
1645 | |||
1646 | #else | ||
1647 | int indx; | ||
1648 | uiRetVal = STATUS_SUCCESS; | ||
1649 | if(uiAddress & 0x10000000) { | ||
1650 | // DDR Memory Access | ||
1651 | uiAddress |= CACHE_ADDRESS_MASK; | ||
1652 | memcpy(pucBuff,(unsigned char *)uiAddress ,sSize); | ||
1653 | } | ||
1654 | else { | ||
1655 | // Register, SPRAM, Flash | ||
1656 | uiAddress |= UNCACHE_ADDRESS_MASK; | ||
1657 | if ((uiAddress & FLASH_ADDR_MASK) == (FLASH_CONTIGIOUS_START_ADDR_BCS350 & FLASH_ADDR_MASK)) | ||
1658 | { | ||
1659 | #if defined(FLASH_DIRECT_ACCESS) | ||
1660 | memcpy(pucBuff,(unsigned char *)uiAddress ,sSize); | ||
1661 | #else | ||
1662 | printk("\nInvalid GSPI ACCESS :Addr :%#X", uiAddress); | ||
1663 | uiRetVal = STATUS_FAILURE; | ||
1664 | #endif | ||
1665 | } | ||
1666 | else if(((unsigned int )uiAddress & 0x3) || | ||
1667 | ((unsigned int )pucBuff & 0x3) || | ||
1668 | ((unsigned int )sSize & 0x3)) { | ||
1669 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"rdmalt :unalligned register access uiAddress = %x,pucBuff = %x size = %x\n",(unsigned int )uiAddress,(unsigned int )pucBuff,(unsigned int )sSize); | ||
1670 | uiRetVal = STATUS_FAILURE; | ||
1671 | } | ||
1672 | else { | ||
1673 | for (indx=0;indx<sSize;indx+=4){ | ||
1674 | *(PUINT)(pucBuff + indx) = *(PUINT)(uiAddress + indx); | ||
1675 | } | ||
1676 | } | ||
1677 | } | ||
1678 | #endif | ||
1679 | return uiRetVal; | ||
1680 | } | ||
1681 | int wrm(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize) | ||
1682 | { | ||
1683 | int iRetVal; | ||
1684 | |||
1685 | #ifndef BCM_SHM_INTERFACE | ||
1686 | iRetVal = Adapter->interface_wrm(Adapter->pvInterfaceAdapter, | ||
1687 | uiAddress, pucBuff, sSize); | ||
1688 | |||
1689 | #else | ||
1690 | int indx; | ||
1691 | if(uiAddress & 0x10000000) { | ||
1692 | // DDR Memory Access | ||
1693 | uiAddress |= CACHE_ADDRESS_MASK; | ||
1694 | memcpy((unsigned char *)(uiAddress),pucBuff,sSize); | ||
1695 | } | ||
1696 | else { | ||
1697 | // Register, SPRAM, Flash | ||
1698 | uiAddress |= UNCACHE_ADDRESS_MASK; | ||
1699 | |||
1700 | if(((unsigned int )uiAddress & 0x3) || | ||
1701 | ((unsigned int )pucBuff & 0x3) || | ||
1702 | ((unsigned int )sSize & 0x3)) { | ||
1703 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"wrmalt: unalligned register access uiAddress = %x,pucBuff = %x size = %x\n",(unsigned int )uiAddress,(unsigned int )pucBuff,(unsigned int )sSize); | ||
1704 | iRetVal = STATUS_FAILURE; | ||
1705 | } | ||
1706 | else { | ||
1707 | for (indx=0;indx<sSize;indx+=4) { | ||
1708 | *(PUINT)(uiAddress + indx) = *(PUINT)(pucBuff + indx); | ||
1709 | } | ||
1710 | } | ||
1711 | } | ||
1712 | iRetVal = STATUS_SUCCESS; | ||
1713 | #endif | ||
1714 | |||
1715 | return iRetVal; | ||
1716 | } | ||
1717 | |||
1718 | int wrmalt (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t size) | ||
1719 | { | ||
1720 | convertEndian(RWM_WRITE, pucBuff, size); | ||
1721 | return wrm(Adapter, uiAddress, (PUCHAR)pucBuff, size); | ||
1722 | } | ||
1723 | |||
1724 | int rdmalt (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t size) | ||
1725 | { | ||
1726 | INT uiRetVal =0; | ||
1727 | |||
1728 | uiRetVal = rdm(Adapter,uiAddress,(PUCHAR)pucBuff,size); | ||
1729 | convertEndian(RWM_READ, (PUINT)pucBuff, size); | ||
1730 | |||
1731 | return uiRetVal; | ||
1732 | } | ||
1733 | |||
1734 | int rdmWithLock(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize) | ||
1735 | { | ||
1736 | |||
1737 | INT status = STATUS_SUCCESS ; | ||
1738 | down(&Adapter->rdmwrmsync); | ||
1739 | |||
1740 | if((Adapter->IdleMode == TRUE) || | ||
1741 | (Adapter->bShutStatus ==TRUE) || | ||
1742 | (Adapter->bPreparingForLowPowerMode ==TRUE)) | ||
1743 | { | ||
1744 | status = -EACCES; | ||
1745 | goto exit; | ||
1746 | } | ||
1747 | |||
1748 | status = rdm(Adapter, uiAddress, pucBuff, sSize); | ||
1749 | |||
1750 | exit: | ||
1751 | up(&Adapter->rdmwrmsync); | ||
1752 | return status ; | ||
1753 | } | ||
1754 | int wrmWithLock(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize) | ||
1755 | { | ||
1756 | INT status = STATUS_SUCCESS ; | ||
1757 | down(&Adapter->rdmwrmsync); | ||
1758 | |||
1759 | if((Adapter->IdleMode == TRUE) || | ||
1760 | (Adapter->bShutStatus ==TRUE) || | ||
1761 | (Adapter->bPreparingForLowPowerMode ==TRUE)) | ||
1762 | { | ||
1763 | status = -EACCES; | ||
1764 | goto exit; | ||
1765 | } | ||
1766 | |||
1767 | status =wrm(Adapter, uiAddress, pucBuff, sSize); | ||
1768 | |||
1769 | exit: | ||
1770 | up(&Adapter->rdmwrmsync); | ||
1771 | return status ; | ||
1772 | } | ||
1773 | |||
1774 | int wrmaltWithLock (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t size) | ||
1775 | { | ||
1776 | int iRetVal = STATUS_SUCCESS; | ||
1777 | |||
1778 | down(&Adapter->rdmwrmsync); | ||
1779 | |||
1780 | if((Adapter->IdleMode == TRUE) || | ||
1781 | (Adapter->bShutStatus ==TRUE) || | ||
1782 | (Adapter->bPreparingForLowPowerMode ==TRUE)) | ||
1783 | { | ||
1784 | iRetVal = -EACCES; | ||
1785 | goto exit; | ||
1786 | } | ||
1787 | |||
1788 | iRetVal = wrmalt(Adapter,uiAddress,pucBuff,size); | ||
1789 | |||
1790 | exit: | ||
1791 | up(&Adapter->rdmwrmsync); | ||
1792 | return iRetVal; | ||
1793 | } | ||
1794 | |||
1795 | int rdmaltWithLock (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t size) | ||
1796 | { | ||
1797 | INT uiRetVal =STATUS_SUCCESS; | ||
1798 | |||
1799 | down(&Adapter->rdmwrmsync); | ||
1800 | |||
1801 | if((Adapter->IdleMode == TRUE) || | ||
1802 | (Adapter->bShutStatus ==TRUE) || | ||
1803 | (Adapter->bPreparingForLowPowerMode ==TRUE)) | ||
1804 | { | ||
1805 | uiRetVal = -EACCES; | ||
1806 | goto exit; | ||
1807 | } | ||
1808 | |||
1809 | uiRetVal = rdmalt(Adapter,uiAddress, pucBuff, size); | ||
1810 | |||
1811 | exit: | ||
1812 | up(&Adapter->rdmwrmsync); | ||
1813 | return uiRetVal; | ||
1814 | } | ||
1815 | |||
1816 | |||
1817 | VOID HandleShutDownModeWakeup(PMINI_ADAPTER Adapter) | ||
1818 | { | ||
1819 | int clear_abort_pattern = 0,Status = 0; | ||
1820 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "====>\n"); | ||
1821 | //target has woken up From Shut Down | ||
1822 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "Clearing Shut Down Software abort pattern\n"); | ||
1823 | Status = wrmalt(Adapter,SW_ABORT_IDLEMODE_LOC, (PUINT)&clear_abort_pattern, sizeof(clear_abort_pattern)); | ||
1824 | if(Status) | ||
1825 | { | ||
1826 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL,"WRM to SW_ABORT_IDLEMODE_LOC failed with err:%d", Status); | ||
1827 | return; | ||
1828 | } | ||
1829 | if(Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE) | ||
1830 | { | ||
1831 | msleep(100); | ||
1832 | InterfaceHandleShutdownModeWakeup(Adapter); | ||
1833 | msleep(100); | ||
1834 | } | ||
1835 | if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) | ||
1836 | { | ||
1837 | Adapter->DriverState = NO_NETWORK_ENTRY; | ||
1838 | wake_up(&Adapter->LEDInfo.notify_led_event); | ||
1839 | } | ||
1840 | |||
1841 | Adapter->bTriedToWakeUpFromlowPowerMode = FALSE; | ||
1842 | Adapter->bShutStatus = FALSE; | ||
1843 | wake_up(&Adapter->lowpower_mode_wait_queue); | ||
1844 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "<====\n"); | ||
1845 | } | ||
1846 | |||
1847 | VOID SendShutModeResponse(PMINI_ADAPTER Adapter) | ||
1848 | { | ||
1849 | CONTROL_MESSAGE stShutdownResponse; | ||
1850 | UINT NVMAccess = 0,lowPwrAbortMsg = 0; | ||
1851 | UINT Status = 0; | ||
1852 | |||
1853 | memset (&stShutdownResponse, 0, sizeof(CONTROL_MESSAGE)); | ||
1854 | stShutdownResponse.Leader.Status = LINK_UP_CONTROL_REQ; | ||
1855 | stShutdownResponse.Leader.PLength = 8;//8 bytes; | ||
1856 | stShutdownResponse.szData[0] = LINK_UP_ACK; | ||
1857 | stShutdownResponse.szData[1] = LINK_SHUTDOWN_REQ_FROM_FIRMWARE; | ||
1858 | |||
1859 | /********************************* | ||
1860 | **down_trylock - | ||
1861 | ** if [ semaphore is available ] | ||
1862 | ** acquire semaphone and return value 0 ; | ||
1863 | ** else | ||
1864 | ** return non-zero value ; | ||
1865 | ** | ||
1866 | ***********************************/ | ||
1867 | |||
1868 | NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock); | ||
1869 | |||
1870 | lowPwrAbortMsg= down_trylock(&Adapter->LowPowerModeSync); | ||
1871 | |||
1872 | |||
1873 | if(NVMAccess || lowPwrAbortMsg|| atomic_read(&Adapter->TotalPacketCount)) | ||
1874 | { | ||
1875 | if(!NVMAccess) | ||
1876 | up(&Adapter->NVMRdmWrmLock); | ||
1877 | |||
1878 | if(!lowPwrAbortMsg) | ||
1879 | up(&Adapter->LowPowerModeSync); | ||
1880 | |||
1881 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "Device Access is going on NACK the Shut Down MODE\n"); | ||
1882 | stShutdownResponse.szData[2] = SHUTDOWN_NACK_FROM_DRIVER;//NACK- device access is going on. | ||
1883 | Adapter->bPreparingForLowPowerMode = FALSE; | ||
1884 | } | ||
1885 | else | ||
1886 | { | ||
1887 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "Sending SHUTDOWN MODE ACK\n"); | ||
1888 | stShutdownResponse.szData[2] = SHUTDOWN_ACK_FROM_DRIVER;//ShutDown ACK | ||
1889 | |||
1890 | /* Wait for the LED to TURN OFF before sending ACK response */ | ||
1891 | if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) | ||
1892 | { | ||
1893 | INT iRetVal = 0; | ||
1894 | |||
1895 | /* Wake the LED Thread with LOWPOWER_MODE_ENTER State */ | ||
1896 | Adapter->DriverState = LOWPOWER_MODE_ENTER; | ||
1897 | wake_up(&Adapter->LEDInfo.notify_led_event); | ||
1898 | |||
1899 | /* Wait for 1 SEC for LED to OFF */ | ||
1900 | iRetVal = wait_event_timeout(Adapter->LEDInfo.idleModeSyncEvent,\ | ||
1901 | Adapter->LEDInfo.bIdle_led_off, msecs_to_jiffies(1000)); | ||
1902 | |||
1903 | /* If Timed Out to Sync IDLE MODE Enter, do IDLE mode Exit and Send NACK to device */ | ||
1904 | if(iRetVal <= 0) | ||
1905 | { | ||
1906 | stShutdownResponse.szData[1] = SHUTDOWN_NACK_FROM_DRIVER;//NACK- device access is going on. | ||
1907 | |||
1908 | Adapter->DriverState = NO_NETWORK_ENTRY; | ||
1909 | wake_up(&Adapter->LEDInfo.notify_led_event); | ||
1910 | } | ||
1911 | } | ||
1912 | |||
1913 | if(stShutdownResponse.szData[2] == SHUTDOWN_ACK_FROM_DRIVER) | ||
1914 | { | ||
1915 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL,"ACKING SHUTDOWN MODE !!!!!!!!!"); | ||
1916 | down(&Adapter->rdmwrmsync); | ||
1917 | Adapter->bPreparingForLowPowerMode = TRUE; | ||
1918 | up(&Adapter->rdmwrmsync); | ||
1919 | //Killing all URBS. | ||
1920 | #ifndef BCM_SHM_INTERFACE | ||
1921 | if(Adapter->bDoSuspend == TRUE) | ||
1922 | Bcm_kill_all_URBs((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter)); | ||
1923 | #endif | ||
1924 | } | ||
1925 | else | ||
1926 | { | ||
1927 | Adapter->bPreparingForLowPowerMode = FALSE; | ||
1928 | } | ||
1929 | |||
1930 | if(!NVMAccess) | ||
1931 | up(&Adapter->NVMRdmWrmLock); | ||
1932 | |||
1933 | if(!lowPwrAbortMsg) | ||
1934 | up(&Adapter->LowPowerModeSync); | ||
1935 | } | ||
1936 | Status = CopyBufferToControlPacket(Adapter,&stShutdownResponse); | ||
1937 | if((Status != STATUS_SUCCESS)) | ||
1938 | { | ||
1939 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL,"fail to send the Idle mode Request \n"); | ||
1940 | Adapter->bPreparingForLowPowerMode = FALSE; | ||
1941 | |||
1942 | #ifndef BCM_SHM_INTERFACE | ||
1943 | StartInterruptUrb((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter)); | ||
1944 | #endif | ||
1945 | } | ||
1946 | } | ||
1947 | |||
1948 | |||
1949 | void HandleShutDownModeRequest(PMINI_ADAPTER Adapter,PUCHAR pucBuffer) | ||
1950 | { | ||
1951 | B_UINT32 uiResetValue = 0; | ||
1952 | |||
1953 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "====>\n"); | ||
1954 | |||
1955 | if(*(pucBuffer+1) == COMPLETE_WAKE_UP_NOTIFICATION_FRM_FW) | ||
1956 | { | ||
1957 | HandleShutDownModeWakeup(Adapter); | ||
1958 | } | ||
1959 | else if(*(pucBuffer+1) == LINK_SHUTDOWN_REQ_FROM_FIRMWARE) | ||
1960 | { | ||
1961 | //Target wants to go to Shut Down Mode | ||
1962 | //InterfacePrepareForShutdown(Adapter); | ||
1963 | if(Adapter->chip_id == BCS220_2 || | ||
1964 | Adapter->chip_id == BCS220_2BC || | ||
1965 | Adapter->chip_id == BCS250_BC || | ||
1966 | Adapter->chip_id == BCS220_3) | ||
1967 | { | ||
1968 | rdmalt(Adapter,HPM_CONFIG_MSW, &uiResetValue, 4); | ||
1969 | uiResetValue |= (1<<17); | ||
1970 | wrmalt(Adapter, HPM_CONFIG_MSW, &uiResetValue, 4); | ||
1971 | } | ||
1972 | |||
1973 | SendShutModeResponse(Adapter); | ||
1974 | BCM_DEBUG_PRINT (Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL,"ShutDownModeResponse:Notification received: Sending the response(Ack/Nack)\n"); | ||
1975 | } | ||
1976 | |||
1977 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "<====\n"); | ||
1978 | return; | ||
1979 | |||
1980 | } | ||
1981 | |||
1982 | VOID ResetCounters(PMINI_ADAPTER Adapter) | ||
1983 | { | ||
1984 | |||
1985 | beceem_protocol_reset(Adapter); | ||
1986 | |||
1987 | Adapter->CurrNumRecvDescs = 0; | ||
1988 | Adapter->PrevNumRecvDescs = 0; | ||
1989 | Adapter->LinkUpStatus = 0; | ||
1990 | Adapter->LinkStatus = 0; | ||
1991 | atomic_set(&Adapter->cntrlpktCnt,0); | ||
1992 | atomic_set (&Adapter->TotalPacketCount,0); | ||
1993 | Adapter->fw_download_done=FALSE; | ||
1994 | Adapter->LinkStatus = 0; | ||
1995 | Adapter->AutoLinkUp = FALSE; | ||
1996 | Adapter->IdleMode = FALSE; | ||
1997 | Adapter->bShutStatus = FALSE; | ||
1998 | |||
1999 | } | ||
2000 | S_CLASSIFIER_RULE *GetFragIPClsEntry(PMINI_ADAPTER Adapter,USHORT usIpIdentification,ULONG SrcIP) | ||
2001 | { | ||
2002 | UINT uiIndex=0; | ||
2003 | for(uiIndex=0;uiIndex<MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES;uiIndex++) | ||
2004 | { | ||
2005 | if((Adapter->astFragmentedPktClassifierTable[uiIndex].bUsed)&& | ||
2006 | (Adapter->astFragmentedPktClassifierTable[uiIndex].usIpIdentification == usIpIdentification)&& | ||
2007 | (Adapter->astFragmentedPktClassifierTable[uiIndex].ulSrcIpAddress== SrcIP)&& | ||
2008 | !Adapter->astFragmentedPktClassifierTable[uiIndex].bOutOfOrderFragment) | ||
2009 | return Adapter->astFragmentedPktClassifierTable[uiIndex].pstMatchedClassifierEntry; | ||
2010 | } | ||
2011 | return NULL; | ||
2012 | } | ||
2013 | |||
2014 | void AddFragIPClsEntry(PMINI_ADAPTER Adapter,PS_FRAGMENTED_PACKET_INFO psFragPktInfo) | ||
2015 | { | ||
2016 | UINT uiIndex=0; | ||
2017 | for(uiIndex=0;uiIndex<MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES;uiIndex++) | ||
2018 | { | ||
2019 | if(!Adapter->astFragmentedPktClassifierTable[uiIndex].bUsed) | ||
2020 | { | ||
2021 | memcpy(&Adapter->astFragmentedPktClassifierTable[uiIndex],psFragPktInfo,sizeof(S_FRAGMENTED_PACKET_INFO)); | ||
2022 | break; | ||
2023 | } | ||
2024 | } | ||
2025 | |||
2026 | } | ||
2027 | |||
2028 | void DelFragIPClsEntry(PMINI_ADAPTER Adapter,USHORT usIpIdentification,ULONG SrcIp) | ||
2029 | { | ||
2030 | UINT uiIndex=0; | ||
2031 | for(uiIndex=0;uiIndex<MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES;uiIndex++) | ||
2032 | { | ||
2033 | if((Adapter->astFragmentedPktClassifierTable[uiIndex].bUsed)&& | ||
2034 | (Adapter->astFragmentedPktClassifierTable[uiIndex].usIpIdentification == usIpIdentification)&& | ||
2035 | (Adapter->astFragmentedPktClassifierTable[uiIndex].ulSrcIpAddress== SrcIp)) | ||
2036 | memset(&Adapter->astFragmentedPktClassifierTable[uiIndex],0,sizeof(S_FRAGMENTED_PACKET_INFO)); | ||
2037 | } | ||
2038 | } | ||
2039 | |||
2040 | void update_per_cid_rx (PMINI_ADAPTER Adapter) | ||
2041 | { | ||
2042 | UINT qindex = 0; | ||
2043 | |||
2044 | if((jiffies - Adapter->liDrainCalculated) < XSECONDS) | ||
2045 | return; | ||
2046 | |||
2047 | for(qindex = 0; qindex < HiPriority; qindex++) | ||
2048 | { | ||
2049 | if(Adapter->PackInfo[qindex].ucDirection == 0) | ||
2050 | { | ||
2051 | Adapter->PackInfo[qindex].uiCurrentRxRate = | ||
2052 | (Adapter->PackInfo[qindex].uiCurrentRxRate + | ||
2053 | Adapter->PackInfo[qindex].uiThisPeriodRxBytes)/2; | ||
2054 | |||
2055 | Adapter->PackInfo[qindex].uiThisPeriodRxBytes = 0; | ||
2056 | } | ||
2057 | else | ||
2058 | { | ||
2059 | Adapter->PackInfo[qindex].uiCurrentDrainRate = | ||
2060 | (Adapter->PackInfo[qindex].uiCurrentDrainRate + | ||
2061 | Adapter->PackInfo[qindex].uiThisPeriodSentBytes)/2; | ||
2062 | |||
2063 | Adapter->PackInfo[qindex].uiThisPeriodSentBytes=0; | ||
2064 | } | ||
2065 | } | ||
2066 | Adapter->liDrainCalculated=jiffies; | ||
2067 | } | ||
2068 | void update_per_sf_desc_cnts( PMINI_ADAPTER Adapter) | ||
2069 | { | ||
2070 | INT iIndex = 0; | ||
2071 | u32 uibuff[MAX_TARGET_DSX_BUFFERS]; | ||
2072 | |||
2073 | if(!atomic_read (&Adapter->uiMBupdate)) | ||
2074 | return; | ||
2075 | |||
2076 | #ifdef BCM_SHM_INTERFACE | ||
2077 | if(rdmalt(Adapter, TARGET_SFID_TXDESC_MAP_LOC, (PUINT)uibuff, sizeof(UINT) * MAX_TARGET_DSX_BUFFERS)<0) | ||
2078 | #else | ||
2079 | if(rdmaltWithLock(Adapter, TARGET_SFID_TXDESC_MAP_LOC, (PUINT)uibuff, sizeof(UINT) * MAX_TARGET_DSX_BUFFERS)<0) | ||
2080 | #endif | ||
2081 | { | ||
2082 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "rdm failed\n"); | ||
2083 | return; | ||
2084 | } | ||
2085 | for(iIndex = 0;iIndex < HiPriority; iIndex++) | ||
2086 | { | ||
2087 | if(Adapter->PackInfo[iIndex].bValid && Adapter->PackInfo[iIndex].ucDirection) | ||
2088 | { | ||
2089 | if(Adapter->PackInfo[iIndex].usVCID_Value < MAX_TARGET_DSX_BUFFERS) | ||
2090 | { | ||
2091 | atomic_set(&Adapter->PackInfo[iIndex].uiPerSFTxResourceCount, uibuff[Adapter->PackInfo[iIndex].usVCID_Value]); | ||
2092 | } | ||
2093 | else | ||
2094 | { | ||
2095 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Invalid VCID : %x \n", | ||
2096 | Adapter->PackInfo[iIndex].usVCID_Value); | ||
2097 | } | ||
2098 | } | ||
2099 | } | ||
2100 | atomic_set (&Adapter->uiMBupdate, FALSE); | ||
2101 | } | ||
2102 | |||
2103 | void flush_queue(PMINI_ADAPTER Adapter, UINT iQIndex) | ||
2104 | { | ||
2105 | struct sk_buff* PacketToDrop=NULL; | ||
2106 | struct net_device_stats* netstats=NULL; | ||
2107 | |||
2108 | netstats = &((PLINUX_DEP_DATA)Adapter->pvOsDepData)->netstats; | ||
2109 | |||
2110 | spin_lock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock); | ||
2111 | |||
2112 | while(Adapter->PackInfo[iQIndex].FirstTxQueue && | ||
2113 | atomic_read(&Adapter->TotalPacketCount)) | ||
2114 | { | ||
2115 | PacketToDrop = Adapter->PackInfo[iQIndex].FirstTxQueue; | ||
2116 | if(PacketToDrop && PacketToDrop->len) | ||
2117 | { | ||
2118 | netstats->tx_dropped++; | ||
2119 | DEQUEUEPACKET(Adapter->PackInfo[iQIndex].FirstTxQueue, \ | ||
2120 | Adapter->PackInfo[iQIndex].LastTxQueue); | ||
2121 | |||
2122 | Adapter->PackInfo[iQIndex].uiCurrentPacketsOnHost--; | ||
2123 | Adapter->PackInfo[iQIndex].uiCurrentBytesOnHost -= PacketToDrop->len; | ||
2124 | |||
2125 | //Adding dropped statistics | ||
2126 | Adapter->PackInfo[iQIndex].uiDroppedCountBytes += PacketToDrop->len; | ||
2127 | Adapter->PackInfo[iQIndex].uiDroppedCountPackets++; | ||
2128 | |||
2129 | bcm_kfree_skb(PacketToDrop); | ||
2130 | atomic_dec(&Adapter->TotalPacketCount); | ||
2131 | atomic_inc(&Adapter->TxDroppedPacketCount); | ||
2132 | |||
2133 | } | ||
2134 | } | ||
2135 | spin_unlock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock); | ||
2136 | |||
2137 | } | ||
2138 | |||
2139 | void beceem_protocol_reset (PMINI_ADAPTER Adapter) | ||
2140 | { | ||
2141 | int i =0; | ||
2142 | |||
2143 | if(NULL != Adapter->dev) | ||
2144 | { | ||
2145 | netif_carrier_off(Adapter->dev); | ||
2146 | netif_stop_queue(Adapter->dev); | ||
2147 | } | ||
2148 | |||
2149 | Adapter->IdleMode = FALSE; | ||
2150 | Adapter->LinkUpStatus = FALSE; | ||
2151 | ClearTargetDSXBuffer(Adapter,0, TRUE); | ||
2152 | //Delete All Classifier Rules | ||
2153 | |||
2154 | for(i = 0;i<HiPriority;i++) | ||
2155 | { | ||
2156 | DeleteAllClassifiersForSF(Adapter,i); | ||
2157 | } | ||
2158 | |||
2159 | flush_all_queues(Adapter); | ||
2160 | |||
2161 | if(Adapter->TimerActive == TRUE) | ||
2162 | Adapter->TimerActive = FALSE; | ||
2163 | |||
2164 | memset(Adapter->astFragmentedPktClassifierTable, 0, | ||
2165 | sizeof(S_FRAGMENTED_PACKET_INFO) * | ||
2166 | MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES); | ||
2167 | |||
2168 | for(i = 0;i<HiPriority;i++) | ||
2169 | { | ||
2170 | //resetting only the first size (S_MIBS_SERVICEFLOW_TABLE) for the SF. | ||
2171 | // It is same between MIBs and SF. | ||
2172 | memset((PVOID)&Adapter->PackInfo[i],0,sizeof(S_MIBS_SERVICEFLOW_TABLE)); | ||
2173 | } | ||
2174 | } | ||
2175 | |||
2176 | |||
2177 | |||
2178 | #ifdef BCM_SHM_INTERFACE | ||
2179 | |||
2180 | |||
2181 | #define GET_GTB_DIFF(start, end) \ | ||
2182 | ( (start) < (end) )? ( (end) - (start) ) : ( ~0x0 - ( (start) - (end)) +1 ) | ||
2183 | |||
2184 | void usdelay ( unsigned int a) { | ||
2185 | unsigned int start= *(unsigned int *)0xaf8051b4; | ||
2186 | unsigned int end = start+1; | ||
2187 | unsigned int diff = 0; | ||
2188 | |||
2189 | while(1) { | ||
2190 | end = *(unsigned int *)0xaf8051b4; | ||
2191 | diff = (GET_GTB_DIFF(start,end))/80; | ||
2192 | if (diff >= a) | ||
2193 | break; | ||
2194 | } | ||
2195 | } | ||
2196 | void read_cfg_file(PMINI_ADAPTER Adapter) { | ||
2197 | |||
2198 | |||
2199 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Config File Version = 0x%x \n",Adapter->pstargetparams->m_u32CfgVersion ); | ||
2200 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Center Frequency = 0x%x \n",Adapter->pstargetparams->m_u32CenterFrequency ); | ||
2201 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Band A Scan = 0x%x \n",Adapter->pstargetparams->m_u32BandAScan ); | ||
2202 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Band B Scan = 0x%x \n",Adapter->pstargetparams->m_u32BandBScan ); | ||
2203 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Band C Scan = 0x%x \n",Adapter->pstargetparams->m_u32BandCScan ); | ||
2204 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"ERTPS Options = 0x%x \n",Adapter->pstargetparams->m_u32ErtpsOptions ); | ||
2205 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"PHS Enable = 0x%x \n",Adapter->pstargetparams->m_u32PHSEnable ); | ||
2206 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Handoff Enable = 0x%x \n",Adapter->pstargetparams->m_u32HoEnable ); | ||
2207 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"HO Reserved1 = 0x%x \n",Adapter->pstargetparams->m_u32HoReserved1 ); | ||
2208 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"HO Reserved2 = 0x%x \n",Adapter->pstargetparams->m_u32HoReserved2 ); | ||
2209 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"MIMO Enable = 0x%x \n",Adapter->pstargetparams->m_u32MimoEnable ); | ||
2210 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"PKMv2 Enable = 0x%x \n",Adapter->pstargetparams->m_u32SecurityEnable ); | ||
2211 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Powersaving Modes Enable = 0x%x \n",Adapter->pstargetparams->m_u32PowerSavingModesEnable ); | ||
2212 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Power Saving Mode Options = 0x%x \n",Adapter->pstargetparams->m_u32PowerSavingModeOptions ); | ||
2213 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"ARQ Enable = 0x%x \n",Adapter->pstargetparams->m_u32ArqEnable ); | ||
2214 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Harq Enable = 0x%x \n",Adapter->pstargetparams->m_u32HarqEnable ); | ||
2215 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"EEPROM Flag = 0x%x \n",Adapter->pstargetparams->m_u32EEPROMFlag ); | ||
2216 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Customize = 0x%x \n",Adapter->pstargetparams->m_u32Customize ); | ||
2217 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Bandwidth = 0x%x \n",Adapter->pstargetparams->m_u32ConfigBW ); | ||
2218 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"ShutDown Timer Value = 0x%x \n",Adapter->pstargetparams->m_u32ShutDownInitThresholdTimer ); | ||
2219 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"RadioParameter = 0x%x \n",Adapter->pstargetparams->m_u32RadioParameter ); | ||
2220 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"PhyParameter1 = 0x%x \n",Adapter->pstargetparams->m_u32PhyParameter1 ); | ||
2221 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"PhyParameter2 = 0x%x \n",Adapter->pstargetparams->m_u32PhyParameter2 ); | ||
2222 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"PhyParameter3 = 0x%x \n",Adapter->pstargetparams->m_u32PhyParameter3 ); | ||
2223 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"m_u32TestOptions = 0x%x \n",Adapter->pstargetparams->m_u32TestOptions ); | ||
2224 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"MaxMACDataperDLFrame = 0x%x \n",Adapter->pstargetparams->m_u32MaxMACDataperDLFrame ); | ||
2225 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"MaxMACDataperULFrame = 0x%x \n",Adapter->pstargetparams->m_u32MaxMACDataperULFrame ); | ||
2226 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Corr2MacFlags = 0x%x \n",Adapter->pstargetparams->m_u32Corr2MacFlags ); | ||
2227 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"HostDrvrConfig1 = 0x%x \n",Adapter->pstargetparams->HostDrvrConfig1 ); | ||
2228 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"HostDrvrConfig2 = 0x%x \n",Adapter->pstargetparams->HostDrvrConfig2 ); | ||
2229 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"HostDrvrConfig3 = 0x%x \n",Adapter->pstargetparams->HostDrvrConfig3 ); | ||
2230 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"HostDrvrConfig4 = 0x%x \n",Adapter->pstargetparams->HostDrvrConfig4 ); | ||
2231 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"HostDrvrConfig5 = 0x%x \n",Adapter->pstargetparams->HostDrvrConfig5 ); | ||
2232 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"HostDrvrConfig6 = 0x%x \n",Adapter->pstargetparams->HostDrvrConfig6 ); | ||
2233 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Segmented PUSC Enable = 0x%x \n",Adapter->pstargetparams->m_u32SegmentedPUSCenable ); | ||
2234 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"BamcEnable = 0x%x \n",Adapter->pstargetparams->m_u32BandAMCEnable ); | ||
2235 | } | ||
2236 | |||
2237 | #endif | ||
2238 | |||
2239 | |||
diff --git a/drivers/staging/bcm/Osal_Misc.c b/drivers/staging/bcm/Osal_Misc.c new file mode 100644 index 00000000000..feefd20a529 --- /dev/null +++ b/drivers/staging/bcm/Osal_Misc.c | |||
@@ -0,0 +1,27 @@ | |||
1 | /*++ | ||
2 | |||
3 | Copyright (c) Beceem Communications Inc. | ||
4 | |||
5 | Module Name: | ||
6 | WIN_Misc.c | ||
7 | |||
8 | Abstract: | ||
9 | Implements the Miscelanneous OS Construts | ||
10 | Linked Lists | ||
11 | Dispatcher Objects(Events,Semaphores,Spin Locks and the like) | ||
12 | Files | ||
13 | |||
14 | Revision History: | ||
15 | Who When What | ||
16 | -------- -------- ---------------------------------------------- | ||
17 | Name Date Created/reviewed/modified | ||
18 | Rajeev 24/1/08 Created | ||
19 | Notes: | ||
20 | |||
21 | --*/ | ||
22 | #include "headers.h" | ||
23 | |||
24 | bool OsalMemCompare(void *dest, void *src, UINT len) | ||
25 | { | ||
26 | return (memcmp(src, dest, len)); | ||
27 | } | ||
diff --git a/drivers/staging/bcm/PHSDefines.h b/drivers/staging/bcm/PHSDefines.h new file mode 100644 index 00000000000..9889a993ad5 --- /dev/null +++ b/drivers/staging/bcm/PHSDefines.h | |||
@@ -0,0 +1,125 @@ | |||
1 | #ifndef BCM_PHS_DEFINES_H | ||
2 | #define BCM_PHS_DEFINES_H | ||
3 | |||
4 | #define PHS_INVALID_TABLE_INDEX 0xffffffff | ||
5 | |||
6 | /************************* MACROS **********************************************/ | ||
7 | #define PHS_MEM_TAG '_SHP' | ||
8 | |||
9 | |||
10 | |||
11 | //PHS Defines | ||
12 | #define STATUS_PHS_COMPRESSED 0xa1 | ||
13 | #define STATUS_PHS_NOCOMPRESSION 0xa2 | ||
14 | #define APPLY_PHS 1 | ||
15 | #define MAX_NO_BIT 7 | ||
16 | #define ZERO_PHSI 0 | ||
17 | #define VERIFY 0 | ||
18 | #define SIZE_MULTIPLE_32 4 | ||
19 | #define UNCOMPRESSED_PACKET 0 | ||
20 | #define DYNAMIC 0 | ||
21 | #define SUPPRESS 0x80 | ||
22 | #define NO_CLASSIFIER_MATCH 0 | ||
23 | #define SEND_PACKET_UNCOMPRESSED 0 | ||
24 | #define PHSI_IS_ZERO 0 | ||
25 | #define PHSI_LEN 1 | ||
26 | #define ERROR_LEN 0 | ||
27 | #define PHS_BUFFER_SIZE 1532 | ||
28 | |||
29 | |||
30 | //#define MAX_PHS_LENGTHS 100 | ||
31 | #define MAX_PHSRULE_PER_SF 20 | ||
32 | #define MAX_SERVICEFLOWS 17 | ||
33 | |||
34 | //PHS Error Defines | ||
35 | #define PHS_SUCCESS 0 | ||
36 | #define ERR_PHS_INVALID_DEVICE_EXETENSION 0x800 | ||
37 | #define ERR_PHS_INVALID_PHS_RULE 0x801 | ||
38 | #define ERR_PHS_RULE_ALREADY_EXISTS 0x802 | ||
39 | #define ERR_SF_MATCH_FAIL 0x803 | ||
40 | #define ERR_INVALID_CLASSIFIERTABLE_FOR_SF 0x804 | ||
41 | #define ERR_SFTABLE_FULL 0x805 | ||
42 | #define ERR_CLSASSIFIER_TABLE_FULL 0x806 | ||
43 | #define ERR_PHSRULE_MEMALLOC_FAIL 0x807 | ||
44 | #define ERR_CLSID_MATCH_FAIL 0x808 | ||
45 | #define ERR_PHSRULE_MATCH_FAIL 0x809 | ||
46 | |||
47 | typedef struct _S_PHS_RULE | ||
48 | { | ||
49 | /// brief 8bit PHSI Of The Service Flow | ||
50 | B_UINT8 u8PHSI; | ||
51 | /// brief PHSF Of The Service Flow | ||
52 | B_UINT8 u8PHSFLength; | ||
53 | B_UINT8 u8PHSF[MAX_PHS_LENGTHS]; | ||
54 | /// brief PHSM Of The Service Flow | ||
55 | B_UINT8 u8PHSMLength; | ||
56 | B_UINT8 u8PHSM[MAX_PHS_LENGTHS]; | ||
57 | /// brief 8bit PHSS Of The Service Flow | ||
58 | B_UINT8 u8PHSS; | ||
59 | /// brief 8bit PHSV Of The Service Flow | ||
60 | B_UINT8 u8PHSV; | ||
61 | //Reference Count for this PHS Rule | ||
62 | B_UINT8 u8RefCnt; | ||
63 | //Flag to Store Unclassified PHS rules only in DL | ||
64 | B_UINT8 bUnclassifiedPHSRule; | ||
65 | |||
66 | B_UINT8 u8Reserved[3]; | ||
67 | |||
68 | LONG PHSModifiedBytes; | ||
69 | ULONG PHSModifiedNumPackets; | ||
70 | ULONG PHSErrorNumPackets; | ||
71 | }S_PHS_RULE; | ||
72 | |||
73 | |||
74 | typedef enum _E_CLASSIFIER_ENTRY_CONTEXT | ||
75 | { | ||
76 | eActiveClassifierRuleContext, | ||
77 | eOldClassifierRuleContext | ||
78 | }E_CLASSIFIER_ENTRY_CONTEXT; | ||
79 | |||
80 | typedef struct _S_CLASSIFIER_ENTRY | ||
81 | { | ||
82 | B_UINT8 bUsed; | ||
83 | B_UINT16 uiClassifierRuleId; | ||
84 | B_UINT8 u8PHSI; | ||
85 | S_PHS_RULE *pstPhsRule; | ||
86 | B_UINT8 bUnclassifiedPHSRule; | ||
87 | |||
88 | }S_CLASSIFIER_ENTRY; | ||
89 | |||
90 | |||
91 | typedef struct _S_CLASSIFIER_TABLE | ||
92 | { | ||
93 | B_UINT16 uiTotalClassifiers; | ||
94 | S_CLASSIFIER_ENTRY stActivePhsRulesList[MAX_PHSRULE_PER_SF]; | ||
95 | S_CLASSIFIER_ENTRY stOldPhsRulesList[MAX_PHSRULE_PER_SF]; | ||
96 | B_UINT16 uiOldestPhsRuleIndex; | ||
97 | |||
98 | }S_CLASSIFIER_TABLE; | ||
99 | |||
100 | |||
101 | typedef struct _S_SERVICEFLOW_ENTRY | ||
102 | { | ||
103 | B_UINT8 bUsed; | ||
104 | B_UINT16 uiVcid; | ||
105 | S_CLASSIFIER_TABLE *pstClassifierTable; | ||
106 | }S_SERVICEFLOW_ENTRY; | ||
107 | |||
108 | typedef struct _S_SERVICEFLOW_TABLE | ||
109 | { | ||
110 | B_UINT16 uiTotalServiceFlows; | ||
111 | S_SERVICEFLOW_ENTRY stSFList[MAX_SERVICEFLOWS]; | ||
112 | |||
113 | }S_SERVICEFLOW_TABLE; | ||
114 | |||
115 | |||
116 | typedef struct _PHS_DEVICE_EXTENSION | ||
117 | { | ||
118 | /* PHS Specific data*/ | ||
119 | S_SERVICEFLOW_TABLE *pstServiceFlowPhsRulesTable; | ||
120 | void *CompressedTxBuffer; | ||
121 | void *UnCompressedRxBuffer; | ||
122 | }PHS_DEVICE_EXTENSION,*PPHS_DEVICE_EXTENSION; | ||
123 | |||
124 | |||
125 | #endif | ||
diff --git a/drivers/staging/bcm/PHSModule.c b/drivers/staging/bcm/PHSModule.c new file mode 100644 index 00000000000..8ba8489afc2 --- /dev/null +++ b/drivers/staging/bcm/PHSModule.c | |||
@@ -0,0 +1,1641 @@ | |||
1 | #include "headers.h" | ||
2 | |||
3 | #define IN | ||
4 | #define OUT | ||
5 | |||
6 | void DumpDataPacketHeader(PUCHAR pPkt); | ||
7 | |||
8 | /* | ||
9 | Function: PHSTransmit | ||
10 | |||
11 | Description: This routine handle PHS(Payload Header Suppression for Tx path. | ||
12 | It extracts a fragment of the NDIS_PACKET containing the header | ||
13 | to be suppressed.It then supresses the header by invoking PHS exported compress routine. | ||
14 | The header data after supression is copied back to the NDIS_PACKET. | ||
15 | |||
16 | |||
17 | Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context | ||
18 | IN Packet - NDIS packet containing data to be transmitted | ||
19 | IN USHORT Vcid - vcid pertaining to connection on which the packet is being sent.Used to | ||
20 | identify PHS rule to be applied. | ||
21 | B_UINT16 uiClassifierRuleID - Classifier Rule ID | ||
22 | BOOLEAN bHeaderSuppressionEnabled - indicates if header suprression is enabled for SF. | ||
23 | |||
24 | Return: STATUS_SUCCESS - If the send was successful. | ||
25 | Other - If an error occured. | ||
26 | */ | ||
27 | |||
28 | int PHSTransmit(PMINI_ADAPTER Adapter, | ||
29 | struct sk_buff **pPacket, | ||
30 | USHORT Vcid, | ||
31 | B_UINT16 uiClassifierRuleID, | ||
32 | BOOLEAN bHeaderSuppressionEnabled, | ||
33 | UINT *PacketLen, | ||
34 | UCHAR bEthCSSupport) | ||
35 | { | ||
36 | |||
37 | //PHS Sepcific | ||
38 | UINT unPHSPktHdrBytesCopied = 0; | ||
39 | UINT unPhsOldHdrSize = 0; | ||
40 | UINT unPHSNewPktHeaderLen = 0; | ||
41 | /* Pointer to PHS IN Hdr Buffer */ | ||
42 | PUCHAR pucPHSPktHdrInBuf = | ||
43 | Adapter->stPhsTxContextInfo.ucaHdrSupressionInBuf; | ||
44 | /* Pointer to PHS OUT Hdr Buffer */ | ||
45 | PUCHAR pucPHSPktHdrOutBuf = | ||
46 | Adapter->stPhsTxContextInfo.ucaHdrSupressionOutBuf; | ||
47 | UINT usPacketType; | ||
48 | UINT BytesToRemove=0; | ||
49 | BOOLEAN bPHSI = 0; | ||
50 | LONG ulPhsStatus = 0; | ||
51 | UINT numBytesCompressed = 0; | ||
52 | struct sk_buff *newPacket = NULL; | ||
53 | struct sk_buff *Packet = *pPacket; | ||
54 | |||
55 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "In PHSTransmit"); | ||
56 | |||
57 | if(!bEthCSSupport) | ||
58 | BytesToRemove=ETH_HLEN; | ||
59 | /* | ||
60 | Accumulate the header upto the size we support supression | ||
61 | from NDIS packet | ||
62 | */ | ||
63 | |||
64 | usPacketType=((struct ethhdr *)(Packet->data))->h_proto; | ||
65 | |||
66 | |||
67 | pucPHSPktHdrInBuf = Packet->data + BytesToRemove; | ||
68 | //considering data after ethernet header | ||
69 | if((*PacketLen - BytesToRemove) < MAX_PHS_LENGTHS) | ||
70 | { | ||
71 | |||
72 | unPHSPktHdrBytesCopied = (*PacketLen - BytesToRemove); | ||
73 | } | ||
74 | else | ||
75 | { | ||
76 | unPHSPktHdrBytesCopied = MAX_PHS_LENGTHS; | ||
77 | } | ||
78 | |||
79 | if( (unPHSPktHdrBytesCopied > 0 ) && | ||
80 | (unPHSPktHdrBytesCopied <= MAX_PHS_LENGTHS)) | ||
81 | { | ||
82 | |||
83 | |||
84 | //DumpDataPacketHeader(pucPHSPktHdrInBuf); | ||
85 | |||
86 | // Step 2 Supress Header using PHS and fill into intermediate ucaPHSPktHdrOutBuf. | ||
87 | // Suppress only if IP Header and PHS Enabled For the Service Flow | ||
88 | if(((usPacketType == ETHERNET_FRAMETYPE_IPV4) || | ||
89 | (usPacketType == ETHERNET_FRAMETYPE_IPV6)) && | ||
90 | (bHeaderSuppressionEnabled)) | ||
91 | { | ||
92 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nTrying to PHS Compress Using Classifier rule 0x%X",uiClassifierRuleID); | ||
93 | |||
94 | |||
95 | unPHSNewPktHeaderLen = unPHSPktHdrBytesCopied; | ||
96 | ulPhsStatus = PhsCompress(&Adapter->stBCMPhsContext, | ||
97 | Vcid, | ||
98 | uiClassifierRuleID, | ||
99 | pucPHSPktHdrInBuf, | ||
100 | pucPHSPktHdrOutBuf, | ||
101 | &unPhsOldHdrSize, | ||
102 | &unPHSNewPktHeaderLen); | ||
103 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nPHS Old header Size : %d New Header Size %d\n",unPhsOldHdrSize,unPHSNewPktHeaderLen); | ||
104 | |||
105 | if(unPHSNewPktHeaderLen == unPhsOldHdrSize) | ||
106 | { | ||
107 | if( ulPhsStatus == STATUS_PHS_COMPRESSED) | ||
108 | bPHSI = *pucPHSPktHdrOutBuf; | ||
109 | ulPhsStatus = STATUS_PHS_NOCOMPRESSION; | ||
110 | } | ||
111 | |||
112 | if( ulPhsStatus == STATUS_PHS_COMPRESSED) | ||
113 | { | ||
114 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"PHS Sending packet Compressed"); | ||
115 | |||
116 | if(skb_cloned(Packet)) | ||
117 | { | ||
118 | newPacket = skb_copy(Packet, GFP_ATOMIC); | ||
119 | |||
120 | if(newPacket == NULL) | ||
121 | return STATUS_FAILURE; | ||
122 | |||
123 | bcm_kfree_skb(Packet); | ||
124 | *pPacket = Packet = newPacket; | ||
125 | pucPHSPktHdrInBuf = Packet->data + BytesToRemove; | ||
126 | } | ||
127 | |||
128 | numBytesCompressed = unPhsOldHdrSize - (unPHSNewPktHeaderLen+PHSI_LEN); | ||
129 | |||
130 | OsalMemMove(pucPHSPktHdrInBuf + numBytesCompressed, pucPHSPktHdrOutBuf, unPHSNewPktHeaderLen + PHSI_LEN); | ||
131 | OsalMemMove(Packet->data + numBytesCompressed, Packet->data, BytesToRemove); | ||
132 | skb_pull(Packet, numBytesCompressed); | ||
133 | |||
134 | return STATUS_SUCCESS; | ||
135 | } | ||
136 | |||
137 | else | ||
138 | { | ||
139 | //if one byte headroom is not available, increase it through skb_cow | ||
140 | if(!(skb_headroom(Packet) > 0)) | ||
141 | { | ||
142 | if(skb_cow(Packet, 1)) | ||
143 | { | ||
144 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "SKB Cow Failed\n"); | ||
145 | return STATUS_FAILURE; | ||
146 | } | ||
147 | } | ||
148 | skb_push(Packet, 1); | ||
149 | |||
150 | // CAUTION: The MAC Header is getting corrupted here for IP CS - can be saved by copying 14 Bytes. not needed .... hence corrupting it. | ||
151 | *(Packet->data + BytesToRemove) = bPHSI; | ||
152 | return STATUS_SUCCESS; | ||
153 | } | ||
154 | } | ||
155 | else | ||
156 | { | ||
157 | if(!bHeaderSuppressionEnabled) | ||
158 | { | ||
159 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nHeader Suppression Disabled For SF: No PHS\n"); | ||
160 | } | ||
161 | |||
162 | return STATUS_SUCCESS; | ||
163 | } | ||
164 | } | ||
165 | |||
166 | //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"PHSTransmit : Dumping data packet After PHS"); | ||
167 | return STATUS_SUCCESS; | ||
168 | } | ||
169 | |||
170 | int PHSRecieve(PMINI_ADAPTER Adapter, | ||
171 | USHORT usVcid, | ||
172 | struct sk_buff *packet, | ||
173 | UINT *punPacketLen, | ||
174 | UCHAR *pucEthernetHdr, | ||
175 | UINT bHeaderSuppressionEnabled) | ||
176 | { | ||
177 | u32 nStandardPktHdrLen = 0; | ||
178 | u32 nTotalsupressedPktHdrBytes = 0; | ||
179 | int ulPhsStatus = 0; | ||
180 | PUCHAR pucInBuff = NULL ; | ||
181 | UINT TotalBytesAdded = 0; | ||
182 | if(!bHeaderSuppressionEnabled) | ||
183 | { | ||
184 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECIEVE,DBG_LVL_ALL,"\nPhs Disabled for incoming packet"); | ||
185 | return ulPhsStatus; | ||
186 | } | ||
187 | |||
188 | pucInBuff = packet->data; | ||
189 | |||
190 | //Restore PHS suppressed header | ||
191 | nStandardPktHdrLen = packet->len; | ||
192 | ulPhsStatus = PhsDeCompress(&Adapter->stBCMPhsContext, | ||
193 | usVcid, | ||
194 | pucInBuff, | ||
195 | Adapter->ucaPHSPktRestoreBuf, | ||
196 | &nTotalsupressedPktHdrBytes, | ||
197 | &nStandardPktHdrLen); | ||
198 | |||
199 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECIEVE,DBG_LVL_ALL,"\nSupressed PktHdrLen : 0x%x Restored PktHdrLen : 0x%x", | ||
200 | nTotalsupressedPktHdrBytes,nStandardPktHdrLen); | ||
201 | |||
202 | if(ulPhsStatus != STATUS_PHS_COMPRESSED) | ||
203 | { | ||
204 | skb_pull(packet, 1); | ||
205 | return STATUS_SUCCESS; | ||
206 | } | ||
207 | else | ||
208 | { | ||
209 | TotalBytesAdded = nStandardPktHdrLen - nTotalsupressedPktHdrBytes - PHSI_LEN; | ||
210 | if(TotalBytesAdded) | ||
211 | { | ||
212 | if(skb_headroom(packet) >= (SKB_RESERVE_ETHERNET_HEADER + TotalBytesAdded)) | ||
213 | skb_push(packet, TotalBytesAdded); | ||
214 | else | ||
215 | { | ||
216 | if(skb_cow(packet, skb_headroom(packet) + TotalBytesAdded)) | ||
217 | { | ||
218 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "cow failed in receive\n"); | ||
219 | return STATUS_FAILURE; | ||
220 | } | ||
221 | |||
222 | skb_push(packet, TotalBytesAdded); | ||
223 | } | ||
224 | } | ||
225 | |||
226 | OsalMemMove(packet->data, Adapter->ucaPHSPktRestoreBuf, nStandardPktHdrLen); | ||
227 | } | ||
228 | |||
229 | return STATUS_SUCCESS; | ||
230 | } | ||
231 | |||
232 | void DumpDataPacketHeader(PUCHAR pPkt) | ||
233 | { | ||
234 | struct iphdr *iphd = (struct iphdr*)pPkt; | ||
235 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
236 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"Phs Send/Recieve : IP Packet Hdr \n"); | ||
237 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"TOS : %x \n",iphd->tos); | ||
238 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"Src IP : %x \n",iphd->saddr); | ||
239 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"Dest IP : %x \n \n",iphd->daddr); | ||
240 | |||
241 | } | ||
242 | |||
243 | void DumpFullPacket(UCHAR *pBuf,UINT nPktLen) | ||
244 | { | ||
245 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
246 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,"Dumping Data Packet"); | ||
247 | BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,pBuf,nPktLen); | ||
248 | } | ||
249 | |||
250 | //----------------------------------------------------------------------------- | ||
251 | // Procedure: phs_init | ||
252 | // | ||
253 | // Description: This routine is responsible for allocating memory for classifier and | ||
254 | // PHS rules. | ||
255 | // | ||
256 | // Arguments: | ||
257 | // pPhsdeviceExtension - ptr to Device extension containing PHS Classifier rules and PHS Rules , RX, TX buffer etc | ||
258 | // | ||
259 | // Returns: | ||
260 | // TRUE(1) -If allocation of memory was success full. | ||
261 | // FALSE -If allocation of memory fails. | ||
262 | //----------------------------------------------------------------------------- | ||
263 | int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension,PMINI_ADAPTER Adapter) | ||
264 | { | ||
265 | int i; | ||
266 | S_SERVICEFLOW_TABLE *pstServiceFlowTable; | ||
267 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nPHS:phs_init function "); | ||
268 | |||
269 | if(pPhsdeviceExtension->pstServiceFlowPhsRulesTable) | ||
270 | return -EINVAL; | ||
271 | |||
272 | pPhsdeviceExtension->pstServiceFlowPhsRulesTable = | ||
273 | (S_SERVICEFLOW_TABLE*)OsalMemAlloc(sizeof(S_SERVICEFLOW_TABLE), | ||
274 | PHS_MEM_TAG); | ||
275 | |||
276 | if(pPhsdeviceExtension->pstServiceFlowPhsRulesTable) | ||
277 | { | ||
278 | OsalZeroMemory(pPhsdeviceExtension->pstServiceFlowPhsRulesTable, | ||
279 | sizeof(S_SERVICEFLOW_TABLE)); | ||
280 | } | ||
281 | else | ||
282 | { | ||
283 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation ServiceFlowPhsRulesTable failed"); | ||
284 | return -ENOMEM; | ||
285 | } | ||
286 | |||
287 | pstServiceFlowTable = pPhsdeviceExtension->pstServiceFlowPhsRulesTable; | ||
288 | for(i=0;i<MAX_SERVICEFLOWS;i++) | ||
289 | { | ||
290 | S_SERVICEFLOW_ENTRY sServiceFlow = pstServiceFlowTable->stSFList[i]; | ||
291 | sServiceFlow.pstClassifierTable = (S_CLASSIFIER_TABLE*)OsalMemAlloc( | ||
292 | sizeof(S_CLASSIFIER_TABLE), PHS_MEM_TAG); | ||
293 | if(sServiceFlow.pstClassifierTable) | ||
294 | { | ||
295 | OsalZeroMemory(sServiceFlow.pstClassifierTable,sizeof(S_CLASSIFIER_TABLE)); | ||
296 | pstServiceFlowTable->stSFList[i].pstClassifierTable = sServiceFlow.pstClassifierTable; | ||
297 | } | ||
298 | else | ||
299 | { | ||
300 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation failed"); | ||
301 | free_phs_serviceflow_rules(pPhsdeviceExtension-> | ||
302 | pstServiceFlowPhsRulesTable); | ||
303 | pPhsdeviceExtension->pstServiceFlowPhsRulesTable = NULL; | ||
304 | return -ENOMEM; | ||
305 | } | ||
306 | } | ||
307 | |||
308 | |||
309 | pPhsdeviceExtension->CompressedTxBuffer = | ||
310 | OsalMemAlloc(PHS_BUFFER_SIZE,PHS_MEM_TAG); | ||
311 | |||
312 | if(pPhsdeviceExtension->CompressedTxBuffer == NULL) | ||
313 | { | ||
314 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation failed"); | ||
315 | free_phs_serviceflow_rules(pPhsdeviceExtension->pstServiceFlowPhsRulesTable); | ||
316 | pPhsdeviceExtension->pstServiceFlowPhsRulesTable = NULL; | ||
317 | return -ENOMEM; | ||
318 | } | ||
319 | |||
320 | pPhsdeviceExtension->UnCompressedRxBuffer = | ||
321 | OsalMemAlloc(PHS_BUFFER_SIZE,PHS_MEM_TAG); | ||
322 | if(pPhsdeviceExtension->UnCompressedRxBuffer == NULL) | ||
323 | { | ||
324 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation failed"); | ||
325 | OsalMemFree(pPhsdeviceExtension->CompressedTxBuffer,PHS_BUFFER_SIZE); | ||
326 | free_phs_serviceflow_rules(pPhsdeviceExtension->pstServiceFlowPhsRulesTable); | ||
327 | pPhsdeviceExtension->pstServiceFlowPhsRulesTable = NULL; | ||
328 | return -ENOMEM; | ||
329 | } | ||
330 | |||
331 | |||
332 | |||
333 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\n phs_init Successfull"); | ||
334 | return STATUS_SUCCESS; | ||
335 | } | ||
336 | |||
337 | |||
338 | int PhsCleanup(IN PPHS_DEVICE_EXTENSION pPHSDeviceExt) | ||
339 | { | ||
340 | if(pPHSDeviceExt->pstServiceFlowPhsRulesTable) | ||
341 | { | ||
342 | free_phs_serviceflow_rules(pPHSDeviceExt->pstServiceFlowPhsRulesTable); | ||
343 | pPHSDeviceExt->pstServiceFlowPhsRulesTable = NULL; | ||
344 | } | ||
345 | |||
346 | if(pPHSDeviceExt->CompressedTxBuffer) | ||
347 | { | ||
348 | OsalMemFree(pPHSDeviceExt->CompressedTxBuffer,PHS_BUFFER_SIZE); | ||
349 | pPHSDeviceExt->CompressedTxBuffer = NULL; | ||
350 | } | ||
351 | if(pPHSDeviceExt->UnCompressedRxBuffer) | ||
352 | { | ||
353 | OsalMemFree(pPHSDeviceExt->UnCompressedRxBuffer,PHS_BUFFER_SIZE); | ||
354 | pPHSDeviceExt->UnCompressedRxBuffer = NULL; | ||
355 | } | ||
356 | |||
357 | return 0; | ||
358 | } | ||
359 | |||
360 | |||
361 | |||
362 | //PHS functions | ||
363 | /*++ | ||
364 | PhsUpdateClassifierRule | ||
365 | |||
366 | Routine Description: | ||
367 | Exported function to add or modify a PHS Rule. | ||
368 | |||
369 | Arguments: | ||
370 | IN void* pvContext - PHS Driver Specific Context | ||
371 | IN B_UINT16 uiVcid - The Service Flow ID for which the PHS rule applies | ||
372 | IN B_UINT16 uiClsId - The Classifier ID within the Service Flow for which the PHS rule applies. | ||
373 | IN S_PHS_RULE *psPhsRule - The PHS Rule strcuture to be added to the PHS Rule table. | ||
374 | |||
375 | Return Value: | ||
376 | |||
377 | 0 if successful, | ||
378 | >0 Error. | ||
379 | |||
380 | --*/ | ||
381 | ULONG PhsUpdateClassifierRule(IN void* pvContext, | ||
382 | IN B_UINT16 uiVcid , | ||
383 | IN B_UINT16 uiClsId , | ||
384 | IN S_PHS_RULE *psPhsRule, | ||
385 | IN B_UINT8 u8AssociatedPHSI) | ||
386 | { | ||
387 | ULONG lStatus =0; | ||
388 | UINT nSFIndex =0 ; | ||
389 | S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL; | ||
390 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
391 | |||
392 | |||
393 | |||
394 | PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext; | ||
395 | |||
396 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,"PHS With Corr2 Changes \n"); | ||
397 | |||
398 | if(pDeviceExtension == NULL) | ||
399 | { | ||
400 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,"Invalid Device Extension\n"); | ||
401 | return ERR_PHS_INVALID_DEVICE_EXETENSION; | ||
402 | } | ||
403 | |||
404 | |||
405 | if(u8AssociatedPHSI == 0) | ||
406 | { | ||
407 | return ERR_PHS_INVALID_PHS_RULE; | ||
408 | } | ||
409 | |||
410 | /* Retrieve the SFID Entry Index for requested Service Flow */ | ||
411 | |||
412 | nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable, | ||
413 | uiVcid,&pstServiceFlowEntry); | ||
414 | |||
415 | if(nSFIndex == PHS_INVALID_TABLE_INDEX) | ||
416 | { | ||
417 | /* This is a new SF. Create a mapping entry for this */ | ||
418 | lStatus = CreateSFToClassifierRuleMapping(uiVcid, uiClsId, | ||
419 | pDeviceExtension->pstServiceFlowPhsRulesTable, psPhsRule, u8AssociatedPHSI); | ||
420 | return lStatus; | ||
421 | } | ||
422 | |||
423 | /* SF already Exists Add PHS Rule to existing SF */ | ||
424 | lStatus = CreateClassiferToPHSRuleMapping(uiVcid, uiClsId, | ||
425 | pstServiceFlowEntry, psPhsRule, u8AssociatedPHSI); | ||
426 | |||
427 | return lStatus; | ||
428 | } | ||
429 | |||
430 | /*++ | ||
431 | PhsDeletePHSRule | ||
432 | |||
433 | Routine Description: | ||
434 | Deletes the specified phs Rule within Vcid | ||
435 | |||
436 | Arguments: | ||
437 | IN void* pvContext - PHS Driver Specific Context | ||
438 | IN B_UINT16 uiVcid - The Service Flow ID for which the PHS rule applies | ||
439 | IN B_UINT8 u8PHSI - the PHS Index identifying PHS rule to be deleted. | ||
440 | |||
441 | Return Value: | ||
442 | |||
443 | 0 if successful, | ||
444 | >0 Error. | ||
445 | |||
446 | --*/ | ||
447 | |||
448 | ULONG PhsDeletePHSRule(IN void* pvContext,IN B_UINT16 uiVcid,IN B_UINT8 u8PHSI) | ||
449 | { | ||
450 | ULONG lStatus =0; | ||
451 | UINT nSFIndex =0, nClsidIndex =0 ; | ||
452 | S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL; | ||
453 | S_CLASSIFIER_TABLE *pstClassifierRulesTable = NULL; | ||
454 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
455 | |||
456 | |||
457 | PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext; | ||
458 | |||
459 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "======>\n"); | ||
460 | |||
461 | if(pDeviceExtension) | ||
462 | { | ||
463 | |||
464 | //Retrieve the SFID Entry Index for requested Service Flow | ||
465 | nSFIndex = GetServiceFlowEntry(pDeviceExtension | ||
466 | ->pstServiceFlowPhsRulesTable,uiVcid,&pstServiceFlowEntry); | ||
467 | |||
468 | if(nSFIndex == PHS_INVALID_TABLE_INDEX) | ||
469 | { | ||
470 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "SFID Match Failed\n"); | ||
471 | return ERR_SF_MATCH_FAIL; | ||
472 | } | ||
473 | |||
474 | pstClassifierRulesTable=pstServiceFlowEntry->pstClassifierTable; | ||
475 | if(pstClassifierRulesTable) | ||
476 | { | ||
477 | for(nClsidIndex=0;nClsidIndex<MAX_PHSRULE_PER_SF;nClsidIndex++) | ||
478 | { | ||
479 | if(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].bUsed && pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule) | ||
480 | { | ||
481 | if(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex] | ||
482 | .pstPhsRule->u8PHSI == u8PHSI) | ||
483 | { | ||
484 | if(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule | ||
485 | ->u8RefCnt) | ||
486 | pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule | ||
487 | ->u8RefCnt--; | ||
488 | if(0 == pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex] | ||
489 | .pstPhsRule->u8RefCnt) | ||
490 | OsalMemFree(pstClassifierRulesTable | ||
491 | ->stActivePhsRulesList[nClsidIndex].pstPhsRule, | ||
492 | sizeof(S_PHS_RULE)); | ||
493 | OsalZeroMemory(&pstClassifierRulesTable | ||
494 | ->stActivePhsRulesList[nClsidIndex], | ||
495 | sizeof(S_CLASSIFIER_ENTRY)); | ||
496 | } | ||
497 | } | ||
498 | } | ||
499 | } | ||
500 | |||
501 | } | ||
502 | return lStatus; | ||
503 | } | ||
504 | |||
505 | /*++ | ||
506 | PhsDeleteClassifierRule | ||
507 | |||
508 | Routine Description: | ||
509 | Exported function to Delete a PHS Rule for the SFID,CLSID Pair. | ||
510 | |||
511 | Arguments: | ||
512 | IN void* pvContext - PHS Driver Specific Context | ||
513 | IN B_UINT16 uiVcid - The Service Flow ID for which the PHS rule applies | ||
514 | IN B_UINT16 uiClsId - The Classifier ID within the Service Flow for which the PHS rule applies. | ||
515 | |||
516 | Return Value: | ||
517 | |||
518 | 0 if successful, | ||
519 | >0 Error. | ||
520 | |||
521 | --*/ | ||
522 | ULONG PhsDeleteClassifierRule(IN void* pvContext,IN B_UINT16 uiVcid ,IN B_UINT16 uiClsId) | ||
523 | { | ||
524 | ULONG lStatus =0; | ||
525 | UINT nSFIndex =0, nClsidIndex =0 ; | ||
526 | S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL; | ||
527 | S_CLASSIFIER_ENTRY *pstClassifierEntry = NULL; | ||
528 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
529 | PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext; | ||
530 | |||
531 | if(pDeviceExtension) | ||
532 | { | ||
533 | //Retrieve the SFID Entry Index for requested Service Flow | ||
534 | nSFIndex = GetServiceFlowEntry(pDeviceExtension | ||
535 | ->pstServiceFlowPhsRulesTable, uiVcid, &pstServiceFlowEntry); | ||
536 | if(nSFIndex == PHS_INVALID_TABLE_INDEX) | ||
537 | { | ||
538 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,"SFID Match Failed\n"); | ||
539 | return ERR_SF_MATCH_FAIL; | ||
540 | } | ||
541 | |||
542 | nClsidIndex = GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable, | ||
543 | uiClsId, eActiveClassifierRuleContext, &pstClassifierEntry); | ||
544 | if((nClsidIndex != PHS_INVALID_TABLE_INDEX) && (!pstClassifierEntry->bUnclassifiedPHSRule)) | ||
545 | { | ||
546 | if(pstClassifierEntry->pstPhsRule) | ||
547 | { | ||
548 | if(pstClassifierEntry->pstPhsRule->u8RefCnt) | ||
549 | pstClassifierEntry->pstPhsRule->u8RefCnt--; | ||
550 | if(0==pstClassifierEntry->pstPhsRule->u8RefCnt) | ||
551 | OsalMemFree(pstClassifierEntry->pstPhsRule,sizeof(S_PHS_RULE)); | ||
552 | |||
553 | } | ||
554 | OsalZeroMemory(pstClassifierEntry,sizeof(S_CLASSIFIER_ENTRY)); | ||
555 | } | ||
556 | |||
557 | nClsidIndex = GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable, | ||
558 | uiClsId,eOldClassifierRuleContext,&pstClassifierEntry); | ||
559 | |||
560 | if((nClsidIndex != PHS_INVALID_TABLE_INDEX) && (!pstClassifierEntry->bUnclassifiedPHSRule)) | ||
561 | { | ||
562 | if(pstClassifierEntry->pstPhsRule) | ||
563 | //Delete the classifier entry | ||
564 | OsalMemFree(pstClassifierEntry->pstPhsRule,sizeof(S_PHS_RULE)); | ||
565 | OsalZeroMemory(pstClassifierEntry,sizeof(S_CLASSIFIER_ENTRY)); | ||
566 | } | ||
567 | } | ||
568 | return lStatus; | ||
569 | } | ||
570 | |||
571 | /*++ | ||
572 | PhsDeleteSFRules | ||
573 | |||
574 | Routine Description: | ||
575 | Exported function to Delete a all PHS Rules for the SFID. | ||
576 | |||
577 | Arguments: | ||
578 | IN void* pvContext - PHS Driver Specific Context | ||
579 | IN B_UINT16 uiVcid - The Service Flow ID for which the PHS rules need to be deleted | ||
580 | |||
581 | Return Value: | ||
582 | |||
583 | 0 if successful, | ||
584 | >0 Error. | ||
585 | |||
586 | --*/ | ||
587 | ULONG PhsDeleteSFRules(IN void* pvContext,IN B_UINT16 uiVcid) | ||
588 | { | ||
589 | |||
590 | ULONG lStatus =0; | ||
591 | UINT nSFIndex =0, nClsidIndex =0 ; | ||
592 | S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL; | ||
593 | S_CLASSIFIER_TABLE *pstClassifierRulesTable = NULL; | ||
594 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
595 | PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext; | ||
596 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,"====> \n"); | ||
597 | |||
598 | if(pDeviceExtension) | ||
599 | { | ||
600 | //Retrieve the SFID Entry Index for requested Service Flow | ||
601 | nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable, | ||
602 | uiVcid,&pstServiceFlowEntry); | ||
603 | if(nSFIndex == PHS_INVALID_TABLE_INDEX) | ||
604 | { | ||
605 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "SFID Match Failed\n"); | ||
606 | return ERR_SF_MATCH_FAIL; | ||
607 | } | ||
608 | |||
609 | pstClassifierRulesTable=pstServiceFlowEntry->pstClassifierTable; | ||
610 | if(pstClassifierRulesTable) | ||
611 | { | ||
612 | for(nClsidIndex=0;nClsidIndex<MAX_PHSRULE_PER_SF;nClsidIndex++) | ||
613 | { | ||
614 | if(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule) | ||
615 | { | ||
616 | if(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex] | ||
617 | .pstPhsRule->u8RefCnt) | ||
618 | pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex] | ||
619 | .pstPhsRule->u8RefCnt--; | ||
620 | if(0==pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex] | ||
621 | .pstPhsRule->u8RefCnt) | ||
622 | OsalMemFree(pstClassifierRulesTable | ||
623 | ->stActivePhsRulesList[nClsidIndex].pstPhsRule, | ||
624 | sizeof(S_PHS_RULE)); | ||
625 | pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex] | ||
626 | .pstPhsRule = NULL; | ||
627 | } | ||
628 | OsalZeroMemory(&pstClassifierRulesTable | ||
629 | ->stActivePhsRulesList[nClsidIndex],sizeof(S_CLASSIFIER_ENTRY)); | ||
630 | if(pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex].pstPhsRule) | ||
631 | { | ||
632 | if(pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex] | ||
633 | .pstPhsRule->u8RefCnt) | ||
634 | pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex] | ||
635 | .pstPhsRule->u8RefCnt--; | ||
636 | if(0 == pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex] | ||
637 | .pstPhsRule->u8RefCnt) | ||
638 | OsalMemFree(pstClassifierRulesTable | ||
639 | ->stOldPhsRulesList[nClsidIndex].pstPhsRule, | ||
640 | sizeof(S_PHS_RULE)); | ||
641 | pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex] | ||
642 | .pstPhsRule = NULL; | ||
643 | } | ||
644 | OsalZeroMemory(&pstClassifierRulesTable | ||
645 | ->stOldPhsRulesList[nClsidIndex], | ||
646 | sizeof(S_CLASSIFIER_ENTRY)); | ||
647 | } | ||
648 | } | ||
649 | pstServiceFlowEntry->bUsed = FALSE; | ||
650 | pstServiceFlowEntry->uiVcid = 0; | ||
651 | |||
652 | } | ||
653 | |||
654 | return lStatus; | ||
655 | } | ||
656 | |||
657 | |||
658 | /*++ | ||
659 | PhsCompress | ||
660 | |||
661 | Routine Description: | ||
662 | Exported function to compress the data using PHS. | ||
663 | |||
664 | Arguments: | ||
665 | IN void* pvContext - PHS Driver Specific Context. | ||
666 | IN B_UINT16 uiVcid - The Service Flow ID to which current packet header compression applies. | ||
667 | IN UINT uiClsId - The Classifier ID to which current packet header compression applies. | ||
668 | IN void *pvInputBuffer - The Input buffer containg packet header data | ||
669 | IN void *pvOutputBuffer - The output buffer returned by this function after PHS | ||
670 | IN UINT *pOldHeaderSize - The actual size of the header before PHS | ||
671 | IN UINT *pNewHeaderSize - The new size of the header after applying PHS | ||
672 | |||
673 | Return Value: | ||
674 | |||
675 | 0 if successful, | ||
676 | >0 Error. | ||
677 | |||
678 | --*/ | ||
679 | ULONG PhsCompress(IN void* pvContext, | ||
680 | IN B_UINT16 uiVcid, | ||
681 | IN B_UINT16 uiClsId, | ||
682 | IN void *pvInputBuffer, | ||
683 | OUT void *pvOutputBuffer, | ||
684 | OUT UINT *pOldHeaderSize, | ||
685 | OUT UINT *pNewHeaderSize ) | ||
686 | { | ||
687 | UINT nSFIndex =0, nClsidIndex =0 ; | ||
688 | S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL; | ||
689 | S_CLASSIFIER_ENTRY *pstClassifierEntry = NULL; | ||
690 | S_PHS_RULE *pstPhsRule = NULL; | ||
691 | ULONG lStatus =0; | ||
692 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
693 | |||
694 | |||
695 | |||
696 | PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext; | ||
697 | |||
698 | |||
699 | if(pDeviceExtension == NULL) | ||
700 | { | ||
701 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"Invalid Device Extension\n"); | ||
702 | lStatus = STATUS_PHS_NOCOMPRESSION ; | ||
703 | return lStatus; | ||
704 | |||
705 | } | ||
706 | |||
707 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"Suppressing header \n"); | ||
708 | |||
709 | |||
710 | //Retrieve the SFID Entry Index for requested Service Flow | ||
711 | nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable, | ||
712 | uiVcid,&pstServiceFlowEntry); | ||
713 | if(nSFIndex == PHS_INVALID_TABLE_INDEX) | ||
714 | { | ||
715 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"SFID Match Failed\n"); | ||
716 | lStatus = STATUS_PHS_NOCOMPRESSION ; | ||
717 | return lStatus; | ||
718 | } | ||
719 | |||
720 | nClsidIndex = GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable, | ||
721 | uiClsId,eActiveClassifierRuleContext,&pstClassifierEntry); | ||
722 | |||
723 | if(nClsidIndex == PHS_INVALID_TABLE_INDEX) | ||
724 | { | ||
725 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"No PHS Rule Defined For Classifier\n"); | ||
726 | lStatus = STATUS_PHS_NOCOMPRESSION ; | ||
727 | return lStatus; | ||
728 | } | ||
729 | |||
730 | |||
731 | //get rule from SF id,Cls ID pair and proceed | ||
732 | pstPhsRule = pstClassifierEntry->pstPhsRule; | ||
733 | |||
734 | if(!ValidatePHSRuleComplete(pstPhsRule)) | ||
735 | { | ||
736 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,"PHS Rule Defined For Classifier But Not Complete\n"); | ||
737 | lStatus = STATUS_PHS_NOCOMPRESSION ; | ||
738 | return lStatus; | ||
739 | } | ||
740 | |||
741 | //Compress Packet | ||
742 | lStatus = phs_compress(pstPhsRule,(PUCHAR)pvInputBuffer, | ||
743 | (PUCHAR)pvOutputBuffer, pOldHeaderSize,pNewHeaderSize); | ||
744 | |||
745 | if(lStatus == STATUS_PHS_COMPRESSED) | ||
746 | { | ||
747 | pstPhsRule->PHSModifiedBytes += *pOldHeaderSize - *pNewHeaderSize - 1; | ||
748 | pstPhsRule->PHSModifiedNumPackets++; | ||
749 | } | ||
750 | else | ||
751 | pstPhsRule->PHSErrorNumPackets++; | ||
752 | |||
753 | return lStatus; | ||
754 | } | ||
755 | |||
756 | /*++ | ||
757 | PhsDeCompress | ||
758 | |||
759 | Routine Description: | ||
760 | Exported function to restore the packet header in Rx path. | ||
761 | |||
762 | Arguments: | ||
763 | IN void* pvContext - PHS Driver Specific Context. | ||
764 | IN B_UINT16 uiVcid - The Service Flow ID to which current packet header restoration applies. | ||
765 | IN void *pvInputBuffer - The Input buffer containg suppressed packet header data | ||
766 | OUT void *pvOutputBuffer - The output buffer returned by this function after restoration | ||
767 | OUT UINT *pHeaderSize - The packet header size after restoration is returned in this parameter. | ||
768 | |||
769 | Return Value: | ||
770 | |||
771 | 0 if successful, | ||
772 | >0 Error. | ||
773 | |||
774 | --*/ | ||
775 | ULONG PhsDeCompress(IN void* pvContext, | ||
776 | IN B_UINT16 uiVcid, | ||
777 | IN void *pvInputBuffer, | ||
778 | OUT void *pvOutputBuffer, | ||
779 | OUT UINT *pInHeaderSize, | ||
780 | OUT UINT *pOutHeaderSize ) | ||
781 | { | ||
782 | UINT nSFIndex =0, nPhsRuleIndex =0 ; | ||
783 | S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL; | ||
784 | S_PHS_RULE *pstPhsRule = NULL; | ||
785 | UINT phsi; | ||
786 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
787 | PPHS_DEVICE_EXTENSION pDeviceExtension= | ||
788 | (PPHS_DEVICE_EXTENSION)pvContext; | ||
789 | |||
790 | *pInHeaderSize = 0; | ||
791 | |||
792 | if(pDeviceExtension == NULL) | ||
793 | { | ||
794 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECIEVE,DBG_LVL_ALL,"Invalid Device Extension\n"); | ||
795 | return ERR_PHS_INVALID_DEVICE_EXETENSION; | ||
796 | } | ||
797 | |||
798 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECIEVE,DBG_LVL_ALL,"Restoring header \n"); | ||
799 | |||
800 | phsi = *((unsigned char *)(pvInputBuffer)); | ||
801 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECIEVE,DBG_LVL_ALL,"PHSI To Be Used For restore : %x \n",phsi); | ||
802 | if(phsi == UNCOMPRESSED_PACKET ) | ||
803 | { | ||
804 | return STATUS_PHS_NOCOMPRESSION; | ||
805 | } | ||
806 | |||
807 | //Retrieve the SFID Entry Index for requested Service Flow | ||
808 | nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable, | ||
809 | uiVcid,&pstServiceFlowEntry); | ||
810 | if(nSFIndex == PHS_INVALID_TABLE_INDEX) | ||
811 | { | ||
812 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECIEVE,DBG_LVL_ALL,"SFID Match Failed During Lookup\n"); | ||
813 | return ERR_SF_MATCH_FAIL; | ||
814 | } | ||
815 | |||
816 | nPhsRuleIndex = GetPhsRuleEntry(pstServiceFlowEntry->pstClassifierTable,phsi, | ||
817 | eActiveClassifierRuleContext,&pstPhsRule); | ||
818 | if(nPhsRuleIndex == PHS_INVALID_TABLE_INDEX) | ||
819 | { | ||
820 | //Phs Rule does not exist in active rules table. Lets try in the old rules table. | ||
821 | nPhsRuleIndex = GetPhsRuleEntry(pstServiceFlowEntry->pstClassifierTable, | ||
822 | phsi,eOldClassifierRuleContext,&pstPhsRule); | ||
823 | if(nPhsRuleIndex == PHS_INVALID_TABLE_INDEX) | ||
824 | { | ||
825 | return ERR_PHSRULE_MATCH_FAIL; | ||
826 | } | ||
827 | |||
828 | } | ||
829 | |||
830 | *pInHeaderSize = phs_decompress((PUCHAR)pvInputBuffer, | ||
831 | (PUCHAR)pvOutputBuffer,pstPhsRule,pOutHeaderSize); | ||
832 | |||
833 | pstPhsRule->PHSModifiedBytes += *pOutHeaderSize - *pInHeaderSize - 1; | ||
834 | |||
835 | pstPhsRule->PHSModifiedNumPackets++; | ||
836 | return STATUS_PHS_COMPRESSED; | ||
837 | } | ||
838 | |||
839 | |||
840 | //----------------------------------------------------------------------------- | ||
841 | // Procedure: free_phs_serviceflow_rules | ||
842 | // | ||
843 | // Description: This routine is responsible for freeing memory allocated for PHS rules. | ||
844 | // | ||
845 | // Arguments: | ||
846 | // rules - ptr to S_SERVICEFLOW_TABLE structure. | ||
847 | // | ||
848 | // Returns: | ||
849 | // Does not return any value. | ||
850 | //----------------------------------------------------------------------------- | ||
851 | |||
852 | void free_phs_serviceflow_rules(S_SERVICEFLOW_TABLE *psServiceFlowRulesTable) | ||
853 | { | ||
854 | int i,j; | ||
855 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
856 | |||
857 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "=======>\n"); | ||
858 | if(psServiceFlowRulesTable) | ||
859 | { | ||
860 | for(i=0;i<MAX_SERVICEFLOWS;i++) | ||
861 | { | ||
862 | S_SERVICEFLOW_ENTRY stServiceFlowEntry = | ||
863 | psServiceFlowRulesTable->stSFList[i]; | ||
864 | S_CLASSIFIER_TABLE *pstClassifierRulesTable = | ||
865 | stServiceFlowEntry.pstClassifierTable; | ||
866 | |||
867 | if(pstClassifierRulesTable) | ||
868 | { | ||
869 | for(j=0;j<MAX_PHSRULE_PER_SF;j++) | ||
870 | { | ||
871 | if(pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule) | ||
872 | { | ||
873 | if(pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule | ||
874 | ->u8RefCnt) | ||
875 | pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule | ||
876 | ->u8RefCnt--; | ||
877 | if(0==pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule | ||
878 | ->u8RefCnt) | ||
879 | OsalMemFree(pstClassifierRulesTable->stActivePhsRulesList[j]. | ||
880 | pstPhsRule, sizeof(S_PHS_RULE)); | ||
881 | pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule = NULL; | ||
882 | } | ||
883 | if(pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule) | ||
884 | { | ||
885 | if(pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule | ||
886 | ->u8RefCnt) | ||
887 | pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule | ||
888 | ->u8RefCnt--; | ||
889 | if(0==pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule | ||
890 | ->u8RefCnt) | ||
891 | OsalMemFree(pstClassifierRulesTable->stOldPhsRulesList[j] | ||
892 | .pstPhsRule,sizeof(S_PHS_RULE)); | ||
893 | pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule = NULL; | ||
894 | } | ||
895 | } | ||
896 | OsalMemFree(pstClassifierRulesTable,sizeof(S_CLASSIFIER_TABLE)); | ||
897 | stServiceFlowEntry.pstClassifierTable = pstClassifierRulesTable = NULL; | ||
898 | } | ||
899 | } | ||
900 | } | ||
901 | |||
902 | OsalMemFree(psServiceFlowRulesTable,sizeof(S_SERVICEFLOW_TABLE)); | ||
903 | psServiceFlowRulesTable = NULL; | ||
904 | } | ||
905 | |||
906 | |||
907 | |||
908 | BOOLEAN ValidatePHSRuleComplete(IN S_PHS_RULE *psPhsRule) | ||
909 | { | ||
910 | if(psPhsRule) | ||
911 | { | ||
912 | if(!psPhsRule->u8PHSI) | ||
913 | { | ||
914 | // PHSI is not valid | ||
915 | return FALSE; | ||
916 | } | ||
917 | |||
918 | if(!psPhsRule->u8PHSS) | ||
919 | { | ||
920 | //PHSS Is Undefined | ||
921 | return FALSE; | ||
922 | } | ||
923 | |||
924 | //Check if PHSF is defines for the PHS Rule | ||
925 | if(!psPhsRule->u8PHSFLength) // If any part of PHSF is valid then Rule contains valid PHSF | ||
926 | { | ||
927 | return FALSE; | ||
928 | } | ||
929 | return TRUE; | ||
930 | } | ||
931 | else | ||
932 | { | ||
933 | return FALSE; | ||
934 | } | ||
935 | } | ||
936 | |||
937 | UINT GetServiceFlowEntry(IN S_SERVICEFLOW_TABLE *psServiceFlowTable, | ||
938 | IN B_UINT16 uiVcid,S_SERVICEFLOW_ENTRY **ppstServiceFlowEntry) | ||
939 | { | ||
940 | int i; | ||
941 | for(i=0;i<MAX_SERVICEFLOWS;i++) | ||
942 | { | ||
943 | if(psServiceFlowTable->stSFList[i].bUsed) | ||
944 | { | ||
945 | if(psServiceFlowTable->stSFList[i].uiVcid == uiVcid) | ||
946 | { | ||
947 | *ppstServiceFlowEntry = &psServiceFlowTable->stSFList[i]; | ||
948 | return i; | ||
949 | } | ||
950 | } | ||
951 | } | ||
952 | |||
953 | *ppstServiceFlowEntry = NULL; | ||
954 | return PHS_INVALID_TABLE_INDEX; | ||
955 | } | ||
956 | |||
957 | |||
958 | UINT GetClassifierEntry(IN S_CLASSIFIER_TABLE *pstClassifierTable, | ||
959 | IN B_UINT32 uiClsid,E_CLASSIFIER_ENTRY_CONTEXT eClsContext, | ||
960 | OUT S_CLASSIFIER_ENTRY **ppstClassifierEntry) | ||
961 | { | ||
962 | int i; | ||
963 | S_CLASSIFIER_ENTRY *psClassifierRules = NULL; | ||
964 | for(i=0;i<MAX_PHSRULE_PER_SF;i++) | ||
965 | { | ||
966 | |||
967 | if(eClsContext == eActiveClassifierRuleContext) | ||
968 | { | ||
969 | psClassifierRules = &pstClassifierTable->stActivePhsRulesList[i]; | ||
970 | } | ||
971 | else | ||
972 | { | ||
973 | psClassifierRules = &pstClassifierTable->stOldPhsRulesList[i]; | ||
974 | } | ||
975 | |||
976 | if(psClassifierRules->bUsed) | ||
977 | { | ||
978 | if(psClassifierRules->uiClassifierRuleId == uiClsid) | ||
979 | { | ||
980 | *ppstClassifierEntry = psClassifierRules; | ||
981 | return i; | ||
982 | } | ||
983 | } | ||
984 | |||
985 | } | ||
986 | |||
987 | *ppstClassifierEntry = NULL; | ||
988 | return PHS_INVALID_TABLE_INDEX; | ||
989 | } | ||
990 | |||
991 | UINT GetPhsRuleEntry(IN S_CLASSIFIER_TABLE *pstClassifierTable, | ||
992 | IN B_UINT32 uiPHSI,E_CLASSIFIER_ENTRY_CONTEXT eClsContext, | ||
993 | OUT S_PHS_RULE **ppstPhsRule) | ||
994 | { | ||
995 | int i; | ||
996 | S_CLASSIFIER_ENTRY *pstClassifierRule = NULL; | ||
997 | for(i=0;i<MAX_PHSRULE_PER_SF;i++) | ||
998 | { | ||
999 | if(eClsContext == eActiveClassifierRuleContext) | ||
1000 | { | ||
1001 | pstClassifierRule = &pstClassifierTable->stActivePhsRulesList[i]; | ||
1002 | } | ||
1003 | else | ||
1004 | { | ||
1005 | pstClassifierRule = &pstClassifierTable->stOldPhsRulesList[i]; | ||
1006 | } | ||
1007 | if(pstClassifierRule->bUsed) | ||
1008 | { | ||
1009 | if(pstClassifierRule->u8PHSI == uiPHSI) | ||
1010 | { | ||
1011 | *ppstPhsRule = pstClassifierRule->pstPhsRule; | ||
1012 | return i; | ||
1013 | } | ||
1014 | } | ||
1015 | |||
1016 | } | ||
1017 | |||
1018 | *ppstPhsRule = NULL; | ||
1019 | return PHS_INVALID_TABLE_INDEX; | ||
1020 | } | ||
1021 | |||
1022 | UINT CreateSFToClassifierRuleMapping(IN B_UINT16 uiVcid,IN B_UINT16 uiClsId, | ||
1023 | IN S_SERVICEFLOW_TABLE *psServiceFlowTable,S_PHS_RULE *psPhsRule, | ||
1024 | B_UINT8 u8AssociatedPHSI) | ||
1025 | { | ||
1026 | |||
1027 | S_CLASSIFIER_TABLE *psaClassifiertable = NULL; | ||
1028 | UINT uiStatus = 0; | ||
1029 | int iSfIndex; | ||
1030 | BOOLEAN bFreeEntryFound =FALSE; | ||
1031 | //Check for a free entry in SFID table | ||
1032 | for(iSfIndex=0;iSfIndex < MAX_SERVICEFLOWS;iSfIndex++) | ||
1033 | { | ||
1034 | if(!psServiceFlowTable->stSFList[iSfIndex].bUsed) | ||
1035 | { | ||
1036 | bFreeEntryFound = TRUE; | ||
1037 | break; | ||
1038 | } | ||
1039 | } | ||
1040 | |||
1041 | if(!bFreeEntryFound) | ||
1042 | return ERR_SFTABLE_FULL; | ||
1043 | |||
1044 | |||
1045 | psaClassifiertable = psServiceFlowTable->stSFList[iSfIndex].pstClassifierTable; | ||
1046 | uiStatus = CreateClassifierPHSRule(uiClsId,psaClassifiertable,psPhsRule, | ||
1047 | eActiveClassifierRuleContext,u8AssociatedPHSI); | ||
1048 | if(uiStatus == PHS_SUCCESS) | ||
1049 | { | ||
1050 | //Add entry at free index to the SF | ||
1051 | psServiceFlowTable->stSFList[iSfIndex].bUsed = TRUE; | ||
1052 | psServiceFlowTable->stSFList[iSfIndex].uiVcid = uiVcid; | ||
1053 | } | ||
1054 | |||
1055 | return uiStatus; | ||
1056 | |||
1057 | } | ||
1058 | |||
1059 | UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid, | ||
1060 | IN B_UINT16 uiClsId,IN S_SERVICEFLOW_ENTRY *pstServiceFlowEntry, | ||
1061 | S_PHS_RULE *psPhsRule,B_UINT8 u8AssociatedPHSI) | ||
1062 | { | ||
1063 | S_CLASSIFIER_ENTRY *pstClassifierEntry = NULL; | ||
1064 | UINT uiStatus =PHS_SUCCESS; | ||
1065 | UINT nClassifierIndex = 0; | ||
1066 | S_CLASSIFIER_TABLE *psaClassifiertable = NULL; | ||
1067 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
1068 | psaClassifiertable = pstServiceFlowEntry->pstClassifierTable; | ||
1069 | |||
1070 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "==>"); | ||
1071 | |||
1072 | /* Check if the supplied Classifier already exists */ | ||
1073 | nClassifierIndex =GetClassifierEntry( | ||
1074 | pstServiceFlowEntry->pstClassifierTable,uiClsId, | ||
1075 | eActiveClassifierRuleContext,&pstClassifierEntry); | ||
1076 | if(nClassifierIndex == PHS_INVALID_TABLE_INDEX) | ||
1077 | { | ||
1078 | /* | ||
1079 | The Classifier doesn't exist. So its a new classifier being added. | ||
1080 | Add new entry to associate PHS Rule to the Classifier | ||
1081 | */ | ||
1082 | |||
1083 | uiStatus = CreateClassifierPHSRule(uiClsId,psaClassifiertable, | ||
1084 | psPhsRule,eActiveClassifierRuleContext,u8AssociatedPHSI); | ||
1085 | return uiStatus; | ||
1086 | } | ||
1087 | |||
1088 | /* | ||
1089 | The Classifier exists.The PHS Rule for this classifier | ||
1090 | is being modified | ||
1091 | */ | ||
1092 | if(pstClassifierEntry->u8PHSI == psPhsRule->u8PHSI) | ||
1093 | { | ||
1094 | if(pstClassifierEntry->pstPhsRule == NULL) | ||
1095 | return ERR_PHS_INVALID_PHS_RULE; | ||
1096 | |||
1097 | /* | ||
1098 | This rule already exists if any fields are changed for this PHS | ||
1099 | rule update them. | ||
1100 | */ | ||
1101 | /* If any part of PHSF is valid then we update PHSF */ | ||
1102 | if(psPhsRule->u8PHSFLength) | ||
1103 | { | ||
1104 | //update PHSF | ||
1105 | OsalMemMove(pstClassifierEntry->pstPhsRule->u8PHSF, | ||
1106 | psPhsRule->u8PHSF , MAX_PHS_LENGTHS); | ||
1107 | } | ||
1108 | if(psPhsRule->u8PHSFLength) | ||
1109 | { | ||
1110 | //update PHSFLen | ||
1111 | pstClassifierEntry->pstPhsRule->u8PHSFLength = | ||
1112 | psPhsRule->u8PHSFLength; | ||
1113 | } | ||
1114 | if(psPhsRule->u8PHSMLength) | ||
1115 | { | ||
1116 | //update PHSM | ||
1117 | OsalMemMove(pstClassifierEntry->pstPhsRule->u8PHSM, | ||
1118 | psPhsRule->u8PHSM, MAX_PHS_LENGTHS); | ||
1119 | } | ||
1120 | if(psPhsRule->u8PHSMLength) | ||
1121 | { | ||
1122 | //update PHSM Len | ||
1123 | pstClassifierEntry->pstPhsRule->u8PHSMLength = | ||
1124 | psPhsRule->u8PHSMLength; | ||
1125 | } | ||
1126 | if(psPhsRule->u8PHSS) | ||
1127 | { | ||
1128 | //update PHSS | ||
1129 | pstClassifierEntry->pstPhsRule->u8PHSS = psPhsRule->u8PHSS; | ||
1130 | } | ||
1131 | |||
1132 | //update PHSV | ||
1133 | pstClassifierEntry->pstPhsRule->u8PHSV = psPhsRule->u8PHSV; | ||
1134 | |||
1135 | } | ||
1136 | else | ||
1137 | { | ||
1138 | /* | ||
1139 | A new rule is being set for this classifier. | ||
1140 | */ | ||
1141 | uiStatus=UpdateClassifierPHSRule( uiClsId, pstClassifierEntry, | ||
1142 | psaClassifiertable, psPhsRule, u8AssociatedPHSI); | ||
1143 | } | ||
1144 | |||
1145 | |||
1146 | |||
1147 | return uiStatus; | ||
1148 | } | ||
1149 | |||
1150 | UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId, | ||
1151 | S_CLASSIFIER_TABLE *psaClassifiertable ,S_PHS_RULE *psPhsRule, | ||
1152 | E_CLASSIFIER_ENTRY_CONTEXT eClsContext,B_UINT8 u8AssociatedPHSI) | ||
1153 | { | ||
1154 | UINT iClassifierIndex = 0; | ||
1155 | BOOLEAN bFreeEntryFound = FALSE; | ||
1156 | S_CLASSIFIER_ENTRY *psClassifierRules = NULL; | ||
1157 | UINT nStatus = PHS_SUCCESS; | ||
1158 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
1159 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,"Inside CreateClassifierPHSRule"); | ||
1160 | if(psaClassifiertable == NULL) | ||
1161 | { | ||
1162 | return ERR_INVALID_CLASSIFIERTABLE_FOR_SF; | ||
1163 | } | ||
1164 | |||
1165 | if(eClsContext == eOldClassifierRuleContext) | ||
1166 | { | ||
1167 | /* If An Old Entry for this classifier ID already exists in the | ||
1168 | old rules table replace it. */ | ||
1169 | |||
1170 | iClassifierIndex = | ||
1171 | GetClassifierEntry(psaClassifiertable, uiClsId, | ||
1172 | eClsContext,&psClassifierRules); | ||
1173 | if(iClassifierIndex != PHS_INVALID_TABLE_INDEX) | ||
1174 | { | ||
1175 | /* | ||
1176 | The Classifier already exists in the old rules table | ||
1177 | Lets replace the old classifier with the new one. | ||
1178 | */ | ||
1179 | bFreeEntryFound = TRUE; | ||
1180 | } | ||
1181 | } | ||
1182 | |||
1183 | if(!bFreeEntryFound) | ||
1184 | { | ||
1185 | /* | ||
1186 | Continue to search for a free location to add the rule | ||
1187 | */ | ||
1188 | for(iClassifierIndex = 0; iClassifierIndex < | ||
1189 | MAX_PHSRULE_PER_SF; iClassifierIndex++) | ||
1190 | { | ||
1191 | if(eClsContext == eActiveClassifierRuleContext) | ||
1192 | { | ||
1193 | psClassifierRules = | ||
1194 | &psaClassifiertable->stActivePhsRulesList[iClassifierIndex]; | ||
1195 | } | ||
1196 | else | ||
1197 | { | ||
1198 | psClassifierRules = | ||
1199 | &psaClassifiertable->stOldPhsRulesList[iClassifierIndex]; | ||
1200 | } | ||
1201 | |||
1202 | if(!psClassifierRules->bUsed) | ||
1203 | { | ||
1204 | bFreeEntryFound = TRUE; | ||
1205 | break; | ||
1206 | } | ||
1207 | } | ||
1208 | } | ||
1209 | |||
1210 | if(!bFreeEntryFound) | ||
1211 | { | ||
1212 | if(eClsContext == eActiveClassifierRuleContext) | ||
1213 | { | ||
1214 | return ERR_CLSASSIFIER_TABLE_FULL; | ||
1215 | } | ||
1216 | else | ||
1217 | { | ||
1218 | //Lets replace the oldest rule if we are looking in old Rule table | ||
1219 | if(psaClassifiertable->uiOldestPhsRuleIndex >= | ||
1220 | MAX_PHSRULE_PER_SF) | ||
1221 | { | ||
1222 | psaClassifiertable->uiOldestPhsRuleIndex =0; | ||
1223 | } | ||
1224 | |||
1225 | iClassifierIndex = psaClassifiertable->uiOldestPhsRuleIndex; | ||
1226 | psClassifierRules = | ||
1227 | &psaClassifiertable->stOldPhsRulesList[iClassifierIndex]; | ||
1228 | |||
1229 | (psaClassifiertable->uiOldestPhsRuleIndex)++; | ||
1230 | } | ||
1231 | } | ||
1232 | |||
1233 | if(eClsContext == eOldClassifierRuleContext) | ||
1234 | { | ||
1235 | if(psClassifierRules->pstPhsRule == NULL) | ||
1236 | { | ||
1237 | psClassifierRules->pstPhsRule = (S_PHS_RULE*)OsalMemAlloc | ||
1238 | (sizeof(S_PHS_RULE),PHS_MEM_TAG); | ||
1239 | |||
1240 | if(NULL == psClassifierRules->pstPhsRule) | ||
1241 | return ERR_PHSRULE_MEMALLOC_FAIL; | ||
1242 | } | ||
1243 | |||
1244 | psClassifierRules->bUsed = TRUE; | ||
1245 | psClassifierRules->uiClassifierRuleId = uiClsId; | ||
1246 | psClassifierRules->u8PHSI = psPhsRule->u8PHSI; | ||
1247 | psClassifierRules->bUnclassifiedPHSRule = psPhsRule->bUnclassifiedPHSRule; | ||
1248 | |||
1249 | /* Update The PHS rule */ | ||
1250 | OsalMemMove(psClassifierRules->pstPhsRule, | ||
1251 | psPhsRule, sizeof(S_PHS_RULE)); | ||
1252 | } | ||
1253 | else | ||
1254 | { | ||
1255 | nStatus = UpdateClassifierPHSRule(uiClsId,psClassifierRules, | ||
1256 | psaClassifiertable,psPhsRule,u8AssociatedPHSI); | ||
1257 | } | ||
1258 | return nStatus; | ||
1259 | } | ||
1260 | |||
1261 | |||
1262 | UINT UpdateClassifierPHSRule(IN B_UINT16 uiClsId, | ||
1263 | IN S_CLASSIFIER_ENTRY *pstClassifierEntry, | ||
1264 | S_CLASSIFIER_TABLE *psaClassifiertable ,S_PHS_RULE *psPhsRule, | ||
1265 | B_UINT8 u8AssociatedPHSI) | ||
1266 | { | ||
1267 | S_PHS_RULE *pstAddPhsRule = NULL; | ||
1268 | UINT nPhsRuleIndex = 0; | ||
1269 | BOOLEAN bPHSRuleOrphaned = FALSE; | ||
1270 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
1271 | psPhsRule->u8RefCnt =0; | ||
1272 | |||
1273 | /* Step 1 Deref Any Exisiting PHS Rule in this classifier Entry*/ | ||
1274 | bPHSRuleOrphaned = DerefPhsRule( uiClsId, psaClassifiertable, | ||
1275 | pstClassifierEntry->pstPhsRule); | ||
1276 | |||
1277 | //Step 2 Search if there is a PHS Rule with u8AssociatedPHSI in Classifier table for this SF | ||
1278 | nPhsRuleIndex =GetPhsRuleEntry(psaClassifiertable,u8AssociatedPHSI, | ||
1279 | eActiveClassifierRuleContext, &pstAddPhsRule); | ||
1280 | if(PHS_INVALID_TABLE_INDEX == nPhsRuleIndex) | ||
1281 | { | ||
1282 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAdding New PHSRuleEntry For Classifier"); | ||
1283 | |||
1284 | if(psPhsRule->u8PHSI == 0) | ||
1285 | { | ||
1286 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nError PHSI is Zero\n"); | ||
1287 | return ERR_PHS_INVALID_PHS_RULE; | ||
1288 | } | ||
1289 | //Step 2.a PHS Rule Does Not Exist .Create New PHS Rule for uiClsId | ||
1290 | if(FALSE == bPHSRuleOrphaned) | ||
1291 | { | ||
1292 | pstClassifierEntry->pstPhsRule = (S_PHS_RULE*)OsalMemAlloc(sizeof(S_PHS_RULE),PHS_MEM_TAG); | ||
1293 | if(NULL == pstClassifierEntry->pstPhsRule) | ||
1294 | { | ||
1295 | return ERR_PHSRULE_MEMALLOC_FAIL; | ||
1296 | } | ||
1297 | } | ||
1298 | OsalMemMove(pstClassifierEntry->pstPhsRule, psPhsRule, sizeof(S_PHS_RULE)); | ||
1299 | |||
1300 | } | ||
1301 | else | ||
1302 | { | ||
1303 | //Step 2.b PHS Rule Exists Tie uiClsId with the existing PHS Rule | ||
1304 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nTying Classifier to Existing PHS Rule"); | ||
1305 | if(bPHSRuleOrphaned) | ||
1306 | { | ||
1307 | if(pstClassifierEntry->pstPhsRule) | ||
1308 | { | ||
1309 | //Just Free the PHS Rule as Ref Count is Zero | ||
1310 | OsalMemFree(pstClassifierEntry->pstPhsRule,sizeof(S_PHS_RULE)); | ||
1311 | pstClassifierEntry->pstPhsRule = NULL; | ||
1312 | |||
1313 | } | ||
1314 | |||
1315 | } | ||
1316 | pstClassifierEntry->pstPhsRule = pstAddPhsRule; | ||
1317 | |||
1318 | } | ||
1319 | pstClassifierEntry->bUsed = TRUE; | ||
1320 | pstClassifierEntry->u8PHSI = pstClassifierEntry->pstPhsRule->u8PHSI; | ||
1321 | pstClassifierEntry->uiClassifierRuleId = uiClsId; | ||
1322 | pstClassifierEntry->pstPhsRule->u8RefCnt++; | ||
1323 | pstClassifierEntry->bUnclassifiedPHSRule = pstClassifierEntry->pstPhsRule->bUnclassifiedPHSRule; | ||
1324 | |||
1325 | return PHS_SUCCESS; | ||
1326 | |||
1327 | } | ||
1328 | |||
1329 | BOOLEAN DerefPhsRule(IN B_UINT16 uiClsId,S_CLASSIFIER_TABLE *psaClassifiertable,S_PHS_RULE *pstPhsRule) | ||
1330 | { | ||
1331 | if(pstPhsRule==NULL) | ||
1332 | return FALSE; | ||
1333 | if(pstPhsRule->u8RefCnt) | ||
1334 | pstPhsRule->u8RefCnt--; | ||
1335 | if(0==pstPhsRule->u8RefCnt) | ||
1336 | { | ||
1337 | /*if(pstPhsRule->u8PHSI) | ||
1338 | //Store the currently active rule into the old rules list | ||
1339 | CreateClassifierPHSRule(uiClsId,psaClassifiertable,pstPhsRule,eOldClassifierRuleContext,pstPhsRule->u8PHSI);*/ | ||
1340 | return TRUE; | ||
1341 | } | ||
1342 | else | ||
1343 | { | ||
1344 | return FALSE; | ||
1345 | } | ||
1346 | } | ||
1347 | |||
1348 | void DumpBuffer(PVOID BuffVAddress, int xferSize) | ||
1349 | { | ||
1350 | int i; | ||
1351 | int iPrintLength; | ||
1352 | PUCHAR temp=(PUCHAR)BuffVAddress; | ||
1353 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
1354 | iPrintLength=(xferSize<32?xferSize:32); | ||
1355 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\n"); | ||
1356 | |||
1357 | for (i=0;i < iPrintLength;i++) { | ||
1358 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "%x|",temp[i]); | ||
1359 | } | ||
1360 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\n"); | ||
1361 | } | ||
1362 | |||
1363 | |||
1364 | void DumpPhsRules(PPHS_DEVICE_EXTENSION pDeviceExtension) | ||
1365 | { | ||
1366 | int i,j,k,l; | ||
1367 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
1368 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\n Dumping PHS Rules : \n"); | ||
1369 | for(i=0;i<MAX_SERVICEFLOWS;i++) | ||
1370 | { | ||
1371 | S_SERVICEFLOW_ENTRY stServFlowEntry = | ||
1372 | pDeviceExtension->pstServiceFlowPhsRulesTable->stSFList[i]; | ||
1373 | if(stServFlowEntry.bUsed) | ||
1374 | { | ||
1375 | for(j=0;j<MAX_PHSRULE_PER_SF;j++) | ||
1376 | { | ||
1377 | for(l=0;l<2;l++) | ||
1378 | { | ||
1379 | S_CLASSIFIER_ENTRY stClsEntry; | ||
1380 | if(l==0) | ||
1381 | { | ||
1382 | stClsEntry = stServFlowEntry.pstClassifierTable->stActivePhsRulesList[j]; | ||
1383 | if(stClsEntry.bUsed) | ||
1384 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n Active PHS Rule : \n"); | ||
1385 | } | ||
1386 | else | ||
1387 | { | ||
1388 | stClsEntry = stServFlowEntry.pstClassifierTable->stOldPhsRulesList[j]; | ||
1389 | if(stClsEntry.bUsed) | ||
1390 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n Old PHS Rule : \n"); | ||
1391 | } | ||
1392 | if(stClsEntry.bUsed) | ||
1393 | { | ||
1394 | |||
1395 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\n VCID : %#X",stServFlowEntry.uiVcid); | ||
1396 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n ClassifierID : %#X",stClsEntry.uiClassifierRuleId); | ||
1397 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSRuleID : %#X",stClsEntry.u8PHSI); | ||
1398 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n****************PHS Rule********************\n"); | ||
1399 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSI : %#X",stClsEntry.pstPhsRule->u8PHSI); | ||
1400 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSFLength : %#X ",stClsEntry.pstPhsRule->u8PHSFLength); | ||
1401 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSF : "); | ||
1402 | for(k=0;k<stClsEntry.pstPhsRule->u8PHSFLength;k++) | ||
1403 | { | ||
1404 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "%#X ",stClsEntry.pstPhsRule->u8PHSF[k]); | ||
1405 | } | ||
1406 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSMLength : %#X",stClsEntry.pstPhsRule->u8PHSMLength); | ||
1407 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSM :"); | ||
1408 | for(k=0;k<stClsEntry.pstPhsRule->u8PHSMLength;k++) | ||
1409 | { | ||
1410 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "%#X ",stClsEntry.pstPhsRule->u8PHSM[k]); | ||
1411 | } | ||
1412 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSS : %#X ",stClsEntry.pstPhsRule->u8PHSS); | ||
1413 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSV : %#X",stClsEntry.pstPhsRule->u8PHSV); | ||
1414 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\n********************************************\n"); | ||
1415 | } | ||
1416 | } | ||
1417 | } | ||
1418 | } | ||
1419 | } | ||
1420 | } | ||
1421 | |||
1422 | |||
1423 | //----------------------------------------------------------------------------- | ||
1424 | // Procedure: phs_decompress | ||
1425 | // | ||
1426 | // Description: This routine restores the static fields within the packet. | ||
1427 | // | ||
1428 | // Arguments: | ||
1429 | // in_buf - ptr to incoming packet buffer. | ||
1430 | // out_buf - ptr to output buffer where the suppressed header is copied. | ||
1431 | // decomp_phs_rules - ptr to PHS rule. | ||
1432 | // header_size - ptr to field which holds the phss or phsf_length. | ||
1433 | // | ||
1434 | // Returns: | ||
1435 | // size -The number of bytes of dynamic fields present with in the incoming packet | ||
1436 | // header. | ||
1437 | // 0 -If PHS rule is NULL.If PHSI is 0 indicateing packet as uncompressed. | ||
1438 | //----------------------------------------------------------------------------- | ||
1439 | |||
1440 | int phs_decompress(unsigned char *in_buf,unsigned char *out_buf, | ||
1441 | S_PHS_RULE *decomp_phs_rules,UINT *header_size) | ||
1442 | { | ||
1443 | int phss,size=0; | ||
1444 | S_PHS_RULE *tmp_memb; | ||
1445 | int bit,i=0; | ||
1446 | unsigned char *phsf,*phsm; | ||
1447 | int in_buf_len = *header_size-1; | ||
1448 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
1449 | in_buf++; | ||
1450 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECIEVE,DBG_LVL_ALL,"====>\n"); | ||
1451 | *header_size = 0; | ||
1452 | |||
1453 | if((decomp_phs_rules == NULL )) | ||
1454 | return 0; | ||
1455 | |||
1456 | |||
1457 | tmp_memb = decomp_phs_rules; | ||
1458 | //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECIEVE,DBG_LVL_ALL,"\nDECOMP:In phs_decompress PHSI 1 %d",phsi)); | ||
1459 | //*header_size = tmp_memb->u8PHSFLength; | ||
1460 | phss = tmp_memb->u8PHSS; | ||
1461 | phsf = tmp_memb->u8PHSF; | ||
1462 | phsm = tmp_memb->u8PHSM; | ||
1463 | |||
1464 | if(phss > MAX_PHS_LENGTHS) | ||
1465 | phss = MAX_PHS_LENGTHS; | ||
1466 | //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECIEVE,DBG_LVL_ALL,"\nDECOMP:In phs_decompress PHSI %d phss %d index %d",phsi,phss,index)); | ||
1467 | while((phss > 0) && (size < in_buf_len)) | ||
1468 | { | ||
1469 | bit = ((*phsm << i)& SUPPRESS); | ||
1470 | |||
1471 | if(bit == SUPPRESS) | ||
1472 | { | ||
1473 | *out_buf = *phsf; | ||
1474 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECIEVE,DBG_LVL_ALL,"\nDECOMP:In phss %d phsf %d ouput %d", | ||
1475 | phss,*phsf,*out_buf); | ||
1476 | } | ||
1477 | else | ||
1478 | { | ||
1479 | *out_buf = *in_buf; | ||
1480 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECIEVE,DBG_LVL_ALL,"\nDECOMP:In phss %d input %d ouput %d", | ||
1481 | phss,*in_buf,*out_buf); | ||
1482 | in_buf++; | ||
1483 | size++; | ||
1484 | } | ||
1485 | out_buf++; | ||
1486 | phsf++; | ||
1487 | phss--; | ||
1488 | i++; | ||
1489 | *header_size=*header_size + 1; | ||
1490 | |||
1491 | if(i > MAX_NO_BIT) | ||
1492 | { | ||
1493 | i=0; | ||
1494 | phsm++; | ||
1495 | } | ||
1496 | } | ||
1497 | return size; | ||
1498 | } | ||
1499 | |||
1500 | |||
1501 | |||
1502 | |||
1503 | //----------------------------------------------------------------------------- | ||
1504 | // Procedure: phs_compress | ||
1505 | // | ||
1506 | // Description: This routine suppresses the static fields within the packet.Before | ||
1507 | // that it will verify the fields to be suppressed with the corresponding fields in the | ||
1508 | // phsf. For verification it checks the phsv field of PHS rule. If set and verification | ||
1509 | // succeeds it suppresses the field.If any one static field is found different none of | ||
1510 | // the static fields are suppressed then the packet is sent as uncompressed packet with | ||
1511 | // phsi=0. | ||
1512 | // | ||
1513 | // Arguments: | ||
1514 | // phs_rule - ptr to PHS rule. | ||
1515 | // in_buf - ptr to incoming packet buffer. | ||
1516 | // out_buf - ptr to output buffer where the suppressed header is copied. | ||
1517 | // header_size - ptr to field which holds the phss. | ||
1518 | // | ||
1519 | // Returns: | ||
1520 | // size-The number of bytes copied into the output buffer i.e dynamic fields | ||
1521 | // 0 -If PHS rule is NULL.If PHSV field is not set.If the verification fails. | ||
1522 | //----------------------------------------------------------------------------- | ||
1523 | int phs_compress(S_PHS_RULE *phs_rule,unsigned char *in_buf | ||
1524 | ,unsigned char *out_buf,UINT *header_size,UINT *new_header_size) | ||
1525 | { | ||
1526 | unsigned char *old_addr = out_buf; | ||
1527 | int supress = 0; | ||
1528 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
1529 | if(phs_rule == NULL) | ||
1530 | { | ||
1531 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nphs_compress(): phs_rule null!"); | ||
1532 | *out_buf = ZERO_PHSI; | ||
1533 | return STATUS_PHS_NOCOMPRESSION; | ||
1534 | } | ||
1535 | |||
1536 | |||
1537 | if(phs_rule->u8PHSS <= *new_header_size) | ||
1538 | { | ||
1539 | *header_size = phs_rule->u8PHSS; | ||
1540 | } | ||
1541 | else | ||
1542 | { | ||
1543 | *header_size = *new_header_size; | ||
1544 | } | ||
1545 | //To copy PHSI | ||
1546 | out_buf++; | ||
1547 | supress = verify_suppress_phsf(in_buf,out_buf,phs_rule->u8PHSF, | ||
1548 | phs_rule->u8PHSM, phs_rule->u8PHSS, phs_rule->u8PHSV,new_header_size); | ||
1549 | |||
1550 | if(supress == STATUS_PHS_COMPRESSED) | ||
1551 | { | ||
1552 | *old_addr = (unsigned char)phs_rule->u8PHSI; | ||
1553 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In phs_compress phsi %d",phs_rule->u8PHSI); | ||
1554 | } | ||
1555 | else | ||
1556 | { | ||
1557 | *old_addr = ZERO_PHSI; | ||
1558 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In phs_compress PHSV Verification failed"); | ||
1559 | } | ||
1560 | return supress; | ||
1561 | } | ||
1562 | |||
1563 | |||
1564 | //----------------------------------------------------------------------------- | ||
1565 | // Procedure: verify_suppress_phsf | ||
1566 | // | ||
1567 | // Description: This routine verifies the fields of the packet and if all the | ||
1568 | // static fields are equal it adds the phsi of that PHS rule.If any static | ||
1569 | // field differs it woun't suppress any field. | ||
1570 | // | ||
1571 | // Arguments: | ||
1572 | // rules_set - ptr to classifier_rules. | ||
1573 | // in_buffer - ptr to incoming packet buffer. | ||
1574 | // out_buffer - ptr to output buffer where the suppressed header is copied. | ||
1575 | // phsf - ptr to phsf. | ||
1576 | // phsm - ptr to phsm. | ||
1577 | // phss - variable holding phss. | ||
1578 | // | ||
1579 | // Returns: | ||
1580 | // size-The number of bytes copied into the output buffer i.e dynamic fields. | ||
1581 | // 0 -Packet has failed the verification. | ||
1582 | //----------------------------------------------------------------------------- | ||
1583 | |||
1584 | int verify_suppress_phsf(unsigned char *in_buffer,unsigned char *out_buffer, | ||
1585 | unsigned char *phsf,unsigned char *phsm,unsigned int phss, | ||
1586 | unsigned int phsv,UINT* new_header_size) | ||
1587 | { | ||
1588 | unsigned int size=0; | ||
1589 | int bit,i=0; | ||
1590 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
1591 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In verify_phsf PHSM - 0x%X",*phsm); | ||
1592 | |||
1593 | |||
1594 | if(phss>(*new_header_size)) | ||
1595 | { | ||
1596 | phss=*new_header_size; | ||
1597 | } | ||
1598 | while(phss > 0) | ||
1599 | { | ||
1600 | bit = ((*phsm << i)& SUPPRESS); | ||
1601 | if(bit == SUPPRESS) | ||
1602 | { | ||
1603 | |||
1604 | if(*in_buffer != *phsf) | ||
1605 | { | ||
1606 | if(phsv == VERIFY) | ||
1607 | { | ||
1608 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In verify_phsf failed for field %d buf %d phsf %d",phss,*in_buffer,*phsf); | ||
1609 | return STATUS_PHS_NOCOMPRESSION; | ||
1610 | } | ||
1611 | } | ||
1612 | else | ||
1613 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In verify_phsf success for field %d buf %d phsf %d",phss,*in_buffer,*phsf); | ||
1614 | } | ||
1615 | else | ||
1616 | { | ||
1617 | *out_buffer = *in_buffer; | ||
1618 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In copying_header input %d out %d",*in_buffer,*out_buffer); | ||
1619 | out_buffer++; | ||
1620 | size++; | ||
1621 | } | ||
1622 | in_buffer++; | ||
1623 | phsf++; | ||
1624 | phss--; | ||
1625 | i++; | ||
1626 | if(i > MAX_NO_BIT) | ||
1627 | { | ||
1628 | i=0; | ||
1629 | phsm++; | ||
1630 | } | ||
1631 | } | ||
1632 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In verify_phsf success"); | ||
1633 | *new_header_size = size; | ||
1634 | return STATUS_PHS_COMPRESSED; | ||
1635 | } | ||
1636 | |||
1637 | |||
1638 | |||
1639 | |||
1640 | |||
1641 | |||
diff --git a/drivers/staging/bcm/PHSModule.h b/drivers/staging/bcm/PHSModule.h new file mode 100644 index 00000000000..bf2b5763252 --- /dev/null +++ b/drivers/staging/bcm/PHSModule.h | |||
@@ -0,0 +1,95 @@ | |||
1 | #ifndef BCM_MINIPORT_PHSMODULE_H | ||
2 | #define BCM_MINIPORT_PHSMODULE_H | ||
3 | |||
4 | int PHSTransmit(PMINI_ADAPTER Adapter, | ||
5 | struct sk_buff **pPacket, | ||
6 | USHORT Vcid, | ||
7 | B_UINT16 uiClassifierRuleID, | ||
8 | BOOLEAN bHeaderSuppressionEnabled, | ||
9 | PUINT PacketLen, | ||
10 | UCHAR bEthCSSupport); | ||
11 | |||
12 | int PHSRecieve(PMINI_ADAPTER Adapter, | ||
13 | USHORT usVcid, | ||
14 | struct sk_buff *packet, | ||
15 | UINT *punPacketLen, | ||
16 | UCHAR *pucEthernetHdr, | ||
17 | UINT | ||
18 | ); | ||
19 | |||
20 | |||
21 | void DumpDataPacketHeader(PUCHAR pPkt); | ||
22 | |||
23 | void DumpFullPacket(UCHAR *pBuf,UINT nPktLen); | ||
24 | |||
25 | void DumpPhsRules(PPHS_DEVICE_EXTENSION pDeviceExtension); | ||
26 | |||
27 | |||
28 | int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension,PMINI_ADAPTER Adapter); | ||
29 | |||
30 | void free_phs_serviceflow_rules(S_SERVICEFLOW_TABLE *psServiceFlowRulesTable); | ||
31 | |||
32 | int phs_compress(S_PHS_RULE *phs_members,unsigned char *in_buf, | ||
33 | unsigned char *out_buf,unsigned int *header_size,UINT *new_header_size ); | ||
34 | |||
35 | |||
36 | int verify_suppress_phsf(unsigned char *in_buffer,unsigned char *out_buffer, | ||
37 | unsigned char *phsf,unsigned char *phsm,unsigned int phss,unsigned int phsv,UINT *new_header_size ); | ||
38 | |||
39 | int phs_decompress(unsigned char *in_buf,unsigned char *out_buf,\ | ||
40 | S_PHS_RULE *phs_rules,UINT *header_size); | ||
41 | |||
42 | |||
43 | int PhsCleanup(PPHS_DEVICE_EXTENSION pPHSDeviceExt); | ||
44 | |||
45 | //Utility Functions | ||
46 | ULONG PhsUpdateClassifierRule(void* pvContext,B_UINT16 uiVcid,B_UINT16 uiClsId,S_PHS_RULE *psPhsRule,B_UINT8 u8AssociatedPHSI ); | ||
47 | |||
48 | ULONG PhsDeletePHSRule(void* pvContext,B_UINT16 uiVcid,B_UINT8 u8PHSI); | ||
49 | |||
50 | ULONG PhsDeleteClassifierRule(void* pvContext, B_UINT16 uiVcid ,B_UINT16 uiClsId); | ||
51 | |||
52 | ULONG PhsDeleteSFRules(void* pvContext,B_UINT16 uiVcid) ; | ||
53 | |||
54 | |||
55 | ULONG PhsCompress(void* pvContext, | ||
56 | B_UINT16 uiVcid, | ||
57 | B_UINT16 uiClsId, | ||
58 | void *pvInputBuffer, | ||
59 | void *pvOutputBuffer, | ||
60 | UINT *pOldHeaderSize, | ||
61 | UINT *pNewHeaderSize ); | ||
62 | |||
63 | ULONG PhsDeCompress(void* pvContext, | ||
64 | B_UINT16 uiVcid, | ||
65 | void *pvInputBuffer, | ||
66 | void *pvOutputBuffer, | ||
67 | UINT *pInHeaderSize, | ||
68 | UINT *pOutHeaderSize); | ||
69 | |||
70 | |||
71 | BOOLEAN ValidatePHSRule(S_PHS_RULE *psPhsRule); | ||
72 | |||
73 | BOOLEAN ValidatePHSRuleComplete(S_PHS_RULE *psPhsRule); | ||
74 | |||
75 | UINT GetServiceFlowEntry(S_SERVICEFLOW_TABLE *psServiceFlowTable,B_UINT16 uiVcid,S_SERVICEFLOW_ENTRY **ppstServiceFlowEntry); | ||
76 | |||
77 | UINT GetClassifierEntry(S_CLASSIFIER_TABLE *pstClassifierTable,B_UINT32 uiClsid,E_CLASSIFIER_ENTRY_CONTEXT eClsContext, S_CLASSIFIER_ENTRY **ppstClassifierEntry); | ||
78 | |||
79 | UINT GetPhsRuleEntry(S_CLASSIFIER_TABLE *pstClassifierTable,B_UINT32 uiPHSI,E_CLASSIFIER_ENTRY_CONTEXT eClsContext,S_PHS_RULE **ppstPhsRule); | ||
80 | |||
81 | |||
82 | UINT CreateSFToClassifierRuleMapping(B_UINT16 uiVcid,B_UINT16 uiClsId,S_SERVICEFLOW_TABLE *psServiceFlowTable,S_PHS_RULE *psPhsRule,B_UINT8 u8AssociatedPHSI); | ||
83 | |||
84 | UINT CreateClassiferToPHSRuleMapping(B_UINT16 uiVcid,B_UINT16 uiClsId,S_SERVICEFLOW_ENTRY *pstServiceFlowEntry,S_PHS_RULE *psPhsRule,B_UINT8 u8AssociatedPHSI); | ||
85 | |||
86 | UINT CreateClassifierPHSRule(B_UINT16 uiClsId,S_CLASSIFIER_TABLE *psaClassifiertable ,S_PHS_RULE *psPhsRule,E_CLASSIFIER_ENTRY_CONTEXT eClsContext,B_UINT8 u8AssociatedPHSI); | ||
87 | |||
88 | UINT UpdateClassifierPHSRule(B_UINT16 uiClsId,S_CLASSIFIER_ENTRY *pstClassifierEntry,S_CLASSIFIER_TABLE *psaClassifiertable ,S_PHS_RULE *psPhsRule,B_UINT8 u8AssociatedPHSI); | ||
89 | |||
90 | BOOLEAN DerefPhsRule(B_UINT16 uiClsId,S_CLASSIFIER_TABLE *psaClassifiertable,S_PHS_RULE *pstPhsRule); | ||
91 | |||
92 | void DumpPhsRules(PPHS_DEVICE_EXTENSION pDeviceExtension); | ||
93 | |||
94 | |||
95 | #endif | ||
diff --git a/drivers/staging/bcm/Protocol.h b/drivers/staging/bcm/Protocol.h new file mode 100644 index 00000000000..00f1cc12356 --- /dev/null +++ b/drivers/staging/bcm/Protocol.h | |||
@@ -0,0 +1,151 @@ | |||
1 | /************************************ | ||
2 | * Protocol.h | ||
3 | *************************************/ | ||
4 | #ifndef __PROTOCOL_H__ | ||
5 | #define __PROTOCOL_H__ | ||
6 | |||
7 | |||
8 | #define IPV4 4 | ||
9 | #define IPV6 6 | ||
10 | |||
11 | |||
12 | struct ArpHeader { | ||
13 | struct arphdr arp; | ||
14 | unsigned char ar_sha[ETH_ALEN]; /* sender hardware address */ | ||
15 | unsigned char ar_sip[4]; /* sender IP address */ | ||
16 | unsigned char ar_tha[ETH_ALEN]; /* target hardware address */ | ||
17 | unsigned char ar_tip[4]; /* target IP address */ | ||
18 | }/*__attribute__((packed))*/; | ||
19 | |||
20 | |||
21 | struct TransportHeaderT | ||
22 | { | ||
23 | union | ||
24 | { | ||
25 | struct udphdr uhdr; | ||
26 | struct tcphdr thdr; | ||
27 | }; | ||
28 | } __attribute__((packed)); | ||
29 | typedef struct TransportHeaderT xporthdr; | ||
30 | |||
31 | |||
32 | typedef enum _E_NWPKT_IPFRAME_TYPE | ||
33 | { | ||
34 | eNonIPPacket, | ||
35 | eIPv4Packet, | ||
36 | eIPv6Packet | ||
37 | }E_NWPKT_IPFRAME_TYPE; | ||
38 | |||
39 | typedef enum _E_NWPKT_ETHFRAME_TYPE | ||
40 | { | ||
41 | eEthUnsupportedFrame, | ||
42 | eEth802LLCFrame, | ||
43 | eEth802LLCSNAPFrame, | ||
44 | eEth802QVLANFrame, | ||
45 | eEthOtherFrame | ||
46 | } E_NWPKT_ETHFRAME_TYPE; | ||
47 | |||
48 | typedef struct _S_ETHCS_PKT_INFO | ||
49 | { | ||
50 | E_NWPKT_IPFRAME_TYPE eNwpktIPFrameType; | ||
51 | E_NWPKT_ETHFRAME_TYPE eNwpktEthFrameType; | ||
52 | USHORT usEtherType; | ||
53 | UCHAR ucDSAP; | ||
54 | }S_ETHCS_PKT_INFO,*PS_ETHCS_PKT_INFO; | ||
55 | |||
56 | typedef struct _ETH_CS_802_Q_FRAME | ||
57 | { | ||
58 | ETH_HEADER_STRUC EThHdr; | ||
59 | USHORT UserPriority:3; | ||
60 | USHORT CFI:1; | ||
61 | USHORT VLANID:12; | ||
62 | USHORT EthType; | ||
63 | } __attribute__((packed)) ETH_CS_802_Q_FRAME; | ||
64 | |||
65 | typedef struct _ETH_CS_802_LLC_FRAME | ||
66 | { | ||
67 | ETH_HEADER_STRUC EThHdr; | ||
68 | unsigned char DSAP; | ||
69 | unsigned char SSAP; | ||
70 | unsigned char Control; | ||
71 | }__attribute__((packed)) ETH_CS_802_LLC_FRAME; | ||
72 | |||
73 | typedef struct _ETH_CS_802_LLC_SNAP_FRAME | ||
74 | { | ||
75 | ETH_HEADER_STRUC EThHdr; | ||
76 | unsigned char DSAP; | ||
77 | unsigned char SSAP; | ||
78 | unsigned char Control; | ||
79 | unsigned char OUI[3]; | ||
80 | unsigned short usEtherType; | ||
81 | } __attribute__((packed)) ETH_CS_802_LLC_SNAP_FRAME; | ||
82 | |||
83 | typedef struct _ETH_CS_ETH2_FRAME | ||
84 | { | ||
85 | ETH_HEADER_STRUC EThHdr; | ||
86 | } __attribute__((packed)) ETH_CS_ETH2_FRAME; | ||
87 | |||
88 | |||
89 | #define ETHERNET_FRAMETYPE_IPV4 ntohs(0x0800) | ||
90 | #define ETHERNET_FRAMETYPE_IPV6 ntohs(0x86dd) | ||
91 | #define ETHERNET_FRAMETYPE_802QVLAN 0x8100 | ||
92 | //Per SF CS Specification Encodings | ||
93 | typedef enum _E_SERVICEFLOW_CS_SPEC_ | ||
94 | { | ||
95 | eCSSpecUnspecified =0, | ||
96 | eCSPacketIPV4, | ||
97 | eCSPacketIPV6, | ||
98 | eCS802_3PacketEthernet, | ||
99 | eCS802_1QPacketVLAN, | ||
100 | eCSPacketIPV4Over802_3Ethernet, | ||
101 | eCSPacketIPV6Over802_3Ethernet, | ||
102 | eCSPacketIPV4Over802_1QVLAN, | ||
103 | eCSPacketIPV6Over802_1QVLAN, | ||
104 | eCSPacketUnsupported | ||
105 | }E_SERVICEFLOW_CS_SPEC; | ||
106 | |||
107 | |||
108 | #define IP6_HEADER_LEN 40 | ||
109 | |||
110 | #define IP_VERSION(byte) (((byte&0xF0)>>4)) | ||
111 | |||
112 | |||
113 | |||
114 | #define MAC_ADDRESS_SIZE 6 | ||
115 | #define ETH_AND_IP_HEADER_LEN 14 + 20 | ||
116 | #define L4_SRC_PORT_LEN 2 | ||
117 | #define L4_DEST_PORT_LEN 2 | ||
118 | |||
119 | |||
120 | |||
121 | #define CTRL_PKT_LEN 8 + ETH_AND_IP_HEADER_LEN | ||
122 | |||
123 | #define ETH_ARP_FRAME 0x806 | ||
124 | #define ETH_IPV4_FRAME 0x800 | ||
125 | #define ETH_IPV6_FRAME 0x86DD | ||
126 | #define UDP 0x11 | ||
127 | #define TCP 0x06 | ||
128 | |||
129 | #define ARP_OP_REQUEST 0x01 | ||
130 | #define ARP_OP_REPLY 0x02 | ||
131 | #define ARP_PKT_SIZE 60 | ||
132 | |||
133 | // This is the format for the TCP packet header | ||
134 | typedef struct _TCP_HEADER | ||
135 | { | ||
136 | USHORT usSrcPort; | ||
137 | USHORT usDestPort; | ||
138 | ULONG ulSeqNumber; | ||
139 | ULONG ulAckNumber; | ||
140 | UCHAR HeaderLength; | ||
141 | UCHAR ucFlags; | ||
142 | USHORT usWindowsSize; | ||
143 | USHORT usChkSum; | ||
144 | USHORT usUrgetPtr; | ||
145 | } TCP_HEADER,*PTCP_HEADER; | ||
146 | #define TCP_HEADER_LEN sizeof(TCP_HEADER) | ||
147 | #define TCP_ACK 0x10 //Bit 4 in tcpflags field. | ||
148 | #define GET_TCP_HEADER_LEN(byte) ((byte&0xF0)>>4) | ||
149 | |||
150 | |||
151 | #endif //__PROTOCOL_H__ | ||
diff --git a/drivers/staging/bcm/Prototypes.h b/drivers/staging/bcm/Prototypes.h new file mode 100644 index 00000000000..7718937c5bd --- /dev/null +++ b/drivers/staging/bcm/Prototypes.h | |||
@@ -0,0 +1,323 @@ | |||
1 | #ifndef _PROTOTYPES_H_ | ||
2 | #define _PROTOTYPES_H_ | ||
3 | |||
4 | int BcmFileDownload(PMINI_ADAPTER Adapter,/**< Logical Adapter */ | ||
5 | char *path, /**< path to image file */ | ||
6 | unsigned int loc /**< Download Address on the chip*/ | ||
7 | ); | ||
8 | VOID LinkControlResponseMessage(PMINI_ADAPTER Adapter, PUCHAR pucBuffer); | ||
9 | |||
10 | VOID StatisticsResponse(PMINI_ADAPTER Adapter,PVOID pvBuffer); | ||
11 | |||
12 | VOID IdleModeResponse(PMINI_ADAPTER Adapter,PUINT puiBuffer); | ||
13 | |||
14 | void bcm_kfree_skb(struct sk_buff *skb); | ||
15 | VOID bcm_kfree(VOID *ptr); | ||
16 | |||
17 | |||
18 | VOID handle_rx_control_packet(PMINI_ADAPTER Adapter, /**<Pointer to the Adapter structure*/ | ||
19 | struct sk_buff *skb); /**<Pointer to the socket buffer*/ | ||
20 | |||
21 | int control_packet_handler (PMINI_ADAPTER Adapter); | ||
22 | |||
23 | VOID DeleteAllClassifiersForSF(PMINI_ADAPTER Adapter,UINT uiSearchRuleIndex); | ||
24 | |||
25 | VOID flush_all_queues(PMINI_ADAPTER Adapter); | ||
26 | |||
27 | int register_control_device_interface(PMINI_ADAPTER ps_adapter); | ||
28 | |||
29 | void unregister_control_device_interface(PMINI_ADAPTER Adapter); | ||
30 | |||
31 | INT CopyBufferToControlPacket(PMINI_ADAPTER Adapter,/**<Logical Adapter*/ | ||
32 | PVOID ioBuffer/**<Control Packet Buffer*/ | ||
33 | ); | ||
34 | |||
35 | VOID SortPackInfo(PMINI_ADAPTER Adapter); | ||
36 | |||
37 | VOID SortClassifiers(PMINI_ADAPTER Adapter); | ||
38 | |||
39 | VOID flush_all_queues(PMINI_ADAPTER Adapter); | ||
40 | |||
41 | USHORT IpVersion4(PMINI_ADAPTER Adapter, /**< Pointer to the driver control structure */ | ||
42 | struct iphdr *iphd, /**<Pointer to the IP Hdr of the packet*/ | ||
43 | S_CLASSIFIER_RULE *pstClassifierRule ); | ||
44 | |||
45 | VOID PruneQueue(PMINI_ADAPTER Adapter,/**<Pointer to the driver control structure*/ | ||
46 | INT iIndex/**<Queue Index*/ | ||
47 | ); | ||
48 | |||
49 | VOID PruneQueueAllSF(PMINI_ADAPTER Adapter); | ||
50 | |||
51 | INT SearchSfid(PMINI_ADAPTER Adapter,UINT uiSfid); | ||
52 | |||
53 | USHORT GetPacketQueueIndex(PMINI_ADAPTER Adapter, /**<Pointer to the driver control structure */ | ||
54 | struct sk_buff* Packet /**< Pointer to the Packet to be sent*/ | ||
55 | ); | ||
56 | |||
57 | VOID | ||
58 | reply_to_arp_request(struct sk_buff *skb /**<sk_buff of ARP request*/ | ||
59 | ); | ||
60 | |||
61 | INT SetupNextSend(PMINI_ADAPTER Adapter, /**<Logical Adapter*/ | ||
62 | struct sk_buff *Packet, /**<data buffer*/ | ||
63 | USHORT Vcid) ; | ||
64 | |||
65 | VOID LinkMessage(PMINI_ADAPTER Adapter); | ||
66 | |||
67 | VOID transmit_packets(PMINI_ADAPTER Adapter); | ||
68 | |||
69 | INT SendControlPacket(PMINI_ADAPTER Adapter, /**<Logical Adapter*/ | ||
70 | char *pControlPacket/**<Control Packet*/ | ||
71 | ); | ||
72 | |||
73 | INT bcm_transmit(struct sk_buff *skb, /**< skb */ | ||
74 | struct net_device *dev /**< net device pointer */ | ||
75 | ); | ||
76 | |||
77 | int register_networkdev(PMINI_ADAPTER Adapter); | ||
78 | |||
79 | INT AllocAdapterDsxBuffer(PMINI_ADAPTER Adapter); | ||
80 | |||
81 | VOID AdapterFree(PMINI_ADAPTER Adapter); | ||
82 | |||
83 | INT FreeAdapterDsxBuffer(PMINI_ADAPTER Adapter); | ||
84 | |||
85 | int create_worker_threads(PMINI_ADAPTER psAdapter); | ||
86 | |||
87 | int tx_pkt_handler(PMINI_ADAPTER Adapter); | ||
88 | |||
89 | int reset_card_proc(PMINI_ADAPTER Adapter ); | ||
90 | |||
91 | int run_card_proc(PMINI_ADAPTER Adapter ); | ||
92 | |||
93 | int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter); | ||
94 | |||
95 | int bcm_parse_target_params(PMINI_ADAPTER Adapter); | ||
96 | |||
97 | INT ReadMacAddressFromNVM(PMINI_ADAPTER Adapter); | ||
98 | |||
99 | int register_control_device_interface(PMINI_ADAPTER ps_adapter); | ||
100 | |||
101 | void DumpPackInfo(PMINI_ADAPTER Adapter); | ||
102 | |||
103 | int rdm(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t size); | ||
104 | |||
105 | int wrm(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t size); | ||
106 | |||
107 | int wrmalt (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t sSize); | ||
108 | |||
109 | int rdmalt (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t sSize); | ||
110 | |||
111 | int get_dsx_sf_data_to_application(PMINI_ADAPTER Adapter, UINT uiSFId, | ||
112 | PUCHAR user_buffer); | ||
113 | |||
114 | void SendLinkDown(PMINI_ADAPTER Adapter); | ||
115 | |||
116 | void SendIdleModeResponse(PMINI_ADAPTER Adapter); | ||
117 | |||
118 | void HandleShutDownModeRequest(PMINI_ADAPTER Adapter,PUCHAR pucBuffer); | ||
119 | |||
120 | int ProcessGetHostMibs(PMINI_ADAPTER Adapter, PVOID ioBuffer, | ||
121 | ULONG inputBufferLength); | ||
122 | |||
123 | int GetDroppedAppCntrlPktMibs(PVOID ioBuffer, PPER_TARANG_DATA pTarang); | ||
124 | void beceem_parse_target_struct(PMINI_ADAPTER Adapter); | ||
125 | |||
126 | void doPowerAutoCorrection(PMINI_ADAPTER psAdapter); | ||
127 | |||
128 | int bcm_ioctl_fw_download(PMINI_ADAPTER Adapter, FIRMWARE_INFO *psFwInfo); | ||
129 | |||
130 | void bcm_unregister_networkdev(PMINI_ADAPTER Adapter); | ||
131 | |||
132 | int SearchVcid(PMINI_ADAPTER Adapter,unsigned short usVcid); | ||
133 | |||
134 | void CopyMIBSExtendedSFParameters(PMINI_ADAPTER Adapter, | ||
135 | CServiceFlowParamSI *psfLocalSet, UINT uiSearchRuleIndex); | ||
136 | |||
137 | VOID ResetCounters(PMINI_ADAPTER Adapter); | ||
138 | |||
139 | int InitLedSettings(PMINI_ADAPTER Adapter); | ||
140 | |||
141 | S_CLASSIFIER_RULE *GetFragIPClsEntry(PMINI_ADAPTER Adapter,USHORT usIpIdentification,ULONG SrcIP); | ||
142 | |||
143 | void AddFragIPClsEntry(PMINI_ADAPTER Adapter,PS_FRAGMENTED_PACKET_INFO psFragPktInfo); | ||
144 | |||
145 | void DelFragIPClsEntry(PMINI_ADAPTER Adapter,USHORT usIpIdentification,ULONG SrcIp); | ||
146 | |||
147 | void update_per_cid_rx (PMINI_ADAPTER Adapter); | ||
148 | |||
149 | void update_per_sf_desc_cnts( PMINI_ADAPTER Adapter); | ||
150 | |||
151 | void ClearTargetDSXBuffer(PMINI_ADAPTER Adapter,B_UINT16 TID,BOOLEAN bFreeAll); | ||
152 | |||
153 | void beceem_protocol_reset (PMINI_ADAPTER Adapter); | ||
154 | |||
155 | void flush_queue(PMINI_ADAPTER Adapter, UINT iQIndex); | ||
156 | |||
157 | |||
158 | INT flushAllAppQ(VOID); | ||
159 | |||
160 | |||
161 | INT BeceemEEPROMBulkRead( | ||
162 | PMINI_ADAPTER Adapter, | ||
163 | PUINT pBuffer, | ||
164 | UINT uiOffset, | ||
165 | UINT uiNumBytes); | ||
166 | |||
167 | |||
168 | INT BeceemFlashBulkRead( | ||
169 | PMINI_ADAPTER Adapter, | ||
170 | PUINT pBuffer, | ||
171 | UINT uiOffset, | ||
172 | UINT uiNumBytes); | ||
173 | |||
174 | UINT BcmGetEEPROMSize(PMINI_ADAPTER Adapter); | ||
175 | |||
176 | INT WriteBeceemEEPROM(PMINI_ADAPTER Adapter,UINT uiEEPROMOffset, UINT uiData); | ||
177 | |||
178 | UINT BcmGetFlashSize(PMINI_ADAPTER Adapter); | ||
179 | |||
180 | UINT BcmGetFlashSectorSize(PMINI_ADAPTER Adapter, UINT FlashSectorSizeSig, UINT FlashSectorSize); | ||
181 | |||
182 | INT BeceemFlashBulkWrite( | ||
183 | PMINI_ADAPTER Adapter, | ||
184 | PUINT pBuffer, | ||
185 | UINT uiOffset, | ||
186 | UINT uiNumBytes, | ||
187 | BOOLEAN bVerify); | ||
188 | |||
189 | INT PropagateCalParamsFromFlashToMemory(PMINI_ADAPTER Adapter); | ||
190 | |||
191 | INT PropagateCalParamsFromEEPROMToMemory(PMINI_ADAPTER Adapter); | ||
192 | |||
193 | |||
194 | INT BeceemEEPROMBulkWrite( | ||
195 | PMINI_ADAPTER Adapter, | ||
196 | PUCHAR pBuffer, | ||
197 | UINT uiOffset, | ||
198 | UINT uiNumBytes, | ||
199 | BOOLEAN bVerify); | ||
200 | |||
201 | |||
202 | INT ReadBeceemEEPROMBulk(PMINI_ADAPTER Adapter,UINT dwAddress, UINT *pdwData, UINT dwNumData); | ||
203 | |||
204 | INT ReadBeceemEEPROM(PMINI_ADAPTER Adapter,UINT dwAddress, UINT *pdwData); | ||
205 | |||
206 | NVM_TYPE BcmGetNvmType(PMINI_ADAPTER Adapter); | ||
207 | |||
208 | INT BeceemNVMRead( | ||
209 | PMINI_ADAPTER Adapter, | ||
210 | PUINT pBuffer, | ||
211 | UINT uiOffset, | ||
212 | UINT uiNumBytes); | ||
213 | |||
214 | INT BeceemNVMWrite( | ||
215 | PMINI_ADAPTER Adapter, | ||
216 | PUINT pBuffer, | ||
217 | UINT uiOffset, | ||
218 | UINT uiNumBytes, | ||
219 | BOOLEAN bVerify); | ||
220 | |||
221 | INT BcmUpdateSectorSize(PMINI_ADAPTER Adapter,UINT uiSectorSize); | ||
222 | |||
223 | INT BcmInitNVM(PMINI_ADAPTER Adapter); | ||
224 | |||
225 | INT BcmGetNvmSize(PMINI_ADAPTER Adapter); | ||
226 | |||
227 | INT IsSectionExistInVendorInfo(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL section); | ||
228 | |||
229 | VOID BcmValidateNvmType(PMINI_ADAPTER Adapter); | ||
230 | |||
231 | VOID ConfigureEndPointTypesThroughEEPROM(PMINI_ADAPTER Adapter); | ||
232 | |||
233 | INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter); | ||
234 | INT ReadDSDHeader(PMINI_ADAPTER Adapter, PDSD_HEADER psDSDHeader, FLASH2X_SECTION_VAL dsd); | ||
235 | INT BcmGetActiveDSD(PMINI_ADAPTER Adapter); | ||
236 | INT ReadISOHeader(PMINI_ADAPTER Adapter, PISO_HEADER psISOHeader, FLASH2X_SECTION_VAL IsoImage); | ||
237 | INT BcmGetActiveISO(PMINI_ADAPTER Adapter); | ||
238 | B_UINT8 IsOffsetWritable(PMINI_ADAPTER Adapter, UINT uiOffset); | ||
239 | INT BcmGetFlash2xSectionalBitMap(PMINI_ADAPTER Adapter, PFLASH2X_BITMAP psFlash2xBitMap); | ||
240 | |||
241 | INT BcmFlash2xBulkWrite( | ||
242 | PMINI_ADAPTER Adapter, | ||
243 | PUINT pBuffer, | ||
244 | FLASH2X_SECTION_VAL eFlashSectionVal, | ||
245 | UINT uiOffset, | ||
246 | UINT uiNumBytes, | ||
247 | UINT bVerify); | ||
248 | |||
249 | INT BcmFlash2xBulkRead( | ||
250 | PMINI_ADAPTER Adapter, | ||
251 | PUINT pBuffer, | ||
252 | FLASH2X_SECTION_VAL eFlashSectionVal, | ||
253 | UINT uiOffsetWithinSectionVal, | ||
254 | UINT uiNumBytes); | ||
255 | INT BcmGetSectionValEndOffset(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlashSectionVal); | ||
256 | |||
257 | INT BcmGetSectionValStartOffset(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlashSectionVal); | ||
258 | |||
259 | INT BcmSetActiveSection(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectVal); | ||
260 | INT BcmAllocFlashCSStructure(PMINI_ADAPTER psAdapter); | ||
261 | INT BcmDeAllocFlashCSStructure(PMINI_ADAPTER psAdapter); | ||
262 | |||
263 | INT BcmCopyISO(PMINI_ADAPTER Adapter, FLASH2X_COPY_SECTION sCopySectStrut); | ||
264 | INT BcmFlash2xCorruptSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal); | ||
265 | INT BcmFlash2xWriteSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlashSectionVal); | ||
266 | INT validateFlash2xReadWrite(PMINI_ADAPTER Adapter, PFLASH2X_READWRITE psFlash2xReadWrite); | ||
267 | INT IsFlash2x(PMINI_ADAPTER Adapter); | ||
268 | INT GetFlashBaseAddr(PMINI_ADAPTER Adapter); | ||
269 | INT SaveHeaderIfPresent(PMINI_ADAPTER Adapter, PUCHAR pBuff, UINT uiSectAlignAddr); | ||
270 | INT BcmCopySection(PMINI_ADAPTER Adapter, | ||
271 | FLASH2X_SECTION_VAL SrcSection, | ||
272 | FLASH2X_SECTION_VAL DstSection, | ||
273 | UINT offset, | ||
274 | UINT numOfBytes); | ||
275 | |||
276 | INT BcmDoChipSelect(PMINI_ADAPTER Adapter, UINT offset); | ||
277 | INT BcmMakeFlashCSActive(PMINI_ADAPTER Adapter, UINT offset); | ||
278 | INT ReadDSDSignature(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL dsd); | ||
279 | INT ReadDSDPriority(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL dsd); | ||
280 | FLASH2X_SECTION_VAL getHighestPriDSD(PMINI_ADAPTER Adapter); | ||
281 | INT ReadISOSignature(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL iso); | ||
282 | INT ReadISOPriority(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL iso); | ||
283 | FLASH2X_SECTION_VAL getHighestPriISO(PMINI_ADAPTER Adapter); | ||
284 | INT WriteToFlashWithoutSectorErase(PMINI_ADAPTER Adapter, | ||
285 | PUINT pBuff, | ||
286 | FLASH2X_SECTION_VAL eFlash2xSectionVal, | ||
287 | UINT uiOffset, | ||
288 | UINT uiNumBytes | ||
289 | ); | ||
290 | |||
291 | //UINT getNumOfSubSectionWithWRPermisson(PMINI_ADAPTER Adapter, SECTION_TYPE secType); | ||
292 | BOOLEAN IsSectionExistInFlash(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL section); | ||
293 | INT IsSectionWritable(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL Section); | ||
294 | INT CorruptDSDSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal); | ||
295 | INT CorruptISOSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal); | ||
296 | BOOLEAN IsNonCDLessDevice(PMINI_ADAPTER Adapter); | ||
297 | |||
298 | |||
299 | VOID OverrideServiceFlowParams(PMINI_ADAPTER Adapter,PUINT puiBuffer); | ||
300 | |||
301 | int wrmaltWithLock (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t sSize); | ||
302 | int rdmaltWithLock (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t sSize); | ||
303 | |||
304 | int rdmWithLock(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t size); | ||
305 | int wrmWithLock(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t size); | ||
306 | INT buffDnldVerify(PMINI_ADAPTER Adapter, unsigned char *mappedbuffer, unsigned int u32FirmwareLength, | ||
307 | unsigned long u32StartingAddress); | ||
308 | |||
309 | |||
310 | VOID putUsbSuspend(struct work_struct *work); | ||
311 | BOOLEAN IsReqGpioIsLedInNVM(PMINI_ADAPTER Adapter, UINT gpios); | ||
312 | |||
313 | #ifdef BCM_SHM_INTERFACE | ||
314 | INT beceem_virtual_device_init(void); | ||
315 | VOID virtual_mail_box_interrupt(void); | ||
316 | INT beceem_virtual_device_exit(void); | ||
317 | #endif | ||
318 | |||
319 | #endif | ||
320 | |||
321 | |||
322 | |||
323 | |||
diff --git a/drivers/staging/bcm/Qos.c b/drivers/staging/bcm/Qos.c new file mode 100644 index 00000000000..000382511e6 --- /dev/null +++ b/drivers/staging/bcm/Qos.c | |||
@@ -0,0 +1,893 @@ | |||
1 | /** | ||
2 | @file Qos.C | ||
3 | This file contains the routines related to Quality of Service. | ||
4 | */ | ||
5 | #include "headers.h" | ||
6 | |||
7 | BOOLEAN MatchSrcIpAddress(S_CLASSIFIER_RULE *pstClassifierRule,ULONG ulSrcIP); | ||
8 | BOOLEAN MatchTos(S_CLASSIFIER_RULE *pstClassifierRule,UCHAR ucTypeOfService); | ||
9 | BOOLEAN MatchSrcPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushSrcPort); | ||
10 | BOOLEAN MatchDestPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushDestPort); | ||
11 | BOOLEAN MatchProtocol(S_CLASSIFIER_RULE *pstClassifierRule,UCHAR ucProtocol); | ||
12 | BOOLEAN MatchDestIpAddress(S_CLASSIFIER_RULE *pstClassifierRule,ULONG ulDestIP); | ||
13 | USHORT ClassifyPacket(PMINI_ADAPTER Adapter,struct sk_buff* skb); | ||
14 | void EThCSGetPktInfo(PMINI_ADAPTER Adapter,PVOID pvEthPayload,PS_ETHCS_PKT_INFO pstEthCsPktInfo); | ||
15 | BOOLEAN EThCSClassifyPkt(PMINI_ADAPTER Adapter,struct sk_buff* skb,PS_ETHCS_PKT_INFO pstEthCsPktInfo,S_CLASSIFIER_RULE *pstClassifierRule, B_UINT8 EthCSCupport); | ||
16 | |||
17 | /******************************************************************* | ||
18 | * Function - MatchSrcIpAddress() | ||
19 | * | ||
20 | * Description - Checks whether the Source IP address from the packet | ||
21 | * matches with that of Queue. | ||
22 | * | ||
23 | * Parameters - pstClassifierRule: Pointer to the packet info structure. | ||
24 | * - ulSrcIP : Source IP address from the packet. | ||
25 | * | ||
26 | * Returns - TRUE(If address matches) else FAIL . | ||
27 | *********************************************************************/ | ||
28 | BOOLEAN MatchSrcIpAddress(S_CLASSIFIER_RULE *pstClassifierRule,ULONG ulSrcIP) | ||
29 | { | ||
30 | UCHAR ucLoopIndex=0; | ||
31 | |||
32 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
33 | |||
34 | ulSrcIP=ntohl(ulSrcIP); | ||
35 | if(0 == pstClassifierRule->ucIPSourceAddressLength) | ||
36 | return TRUE; | ||
37 | for(ucLoopIndex=0; ucLoopIndex < (pstClassifierRule->ucIPSourceAddressLength);ucLoopIndex++) | ||
38 | { | ||
39 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Src Ip Address Mask:0x%x PacketIp:0x%x and Classification:0x%x", (UINT)pstClassifierRule->stSrcIpAddress.ulIpv4Mask[ucLoopIndex], (UINT)ulSrcIP, (UINT)pstClassifierRule->stSrcIpAddress.ulIpv6Addr[ucLoopIndex]); | ||
40 | if((pstClassifierRule->stSrcIpAddress.ulIpv4Mask[ucLoopIndex] & ulSrcIP)== | ||
41 | (pstClassifierRule->stSrcIpAddress.ulIpv4Addr[ucLoopIndex] & pstClassifierRule->stSrcIpAddress.ulIpv4Mask[ucLoopIndex] )) | ||
42 | { | ||
43 | return TRUE; | ||
44 | } | ||
45 | } | ||
46 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Src Ip Address Not Matched"); | ||
47 | return FALSE; | ||
48 | } | ||
49 | |||
50 | |||
51 | /******************************************************************* | ||
52 | * Function - MatchDestIpAddress() | ||
53 | * | ||
54 | * Description - Checks whether the Destination IP address from the packet | ||
55 | * matches with that of Queue. | ||
56 | * | ||
57 | * Parameters - pstClassifierRule: Pointer to the packet info structure. | ||
58 | * - ulDestIP : Destination IP address from the packet. | ||
59 | * | ||
60 | * Returns - TRUE(If address matches) else FAIL . | ||
61 | *********************************************************************/ | ||
62 | BOOLEAN MatchDestIpAddress(S_CLASSIFIER_RULE *pstClassifierRule,ULONG ulDestIP) | ||
63 | { | ||
64 | UCHAR ucLoopIndex=0; | ||
65 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
66 | |||
67 | ulDestIP=ntohl(ulDestIP); | ||
68 | if(0 == pstClassifierRule->ucIPDestinationAddressLength) | ||
69 | return TRUE; | ||
70 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Destination Ip Address 0x%x 0x%x 0x%x ", (UINT)ulDestIP, (UINT)pstClassifierRule->stDestIpAddress.ulIpv4Mask[ucLoopIndex], (UINT)pstClassifierRule->stDestIpAddress.ulIpv4Addr[ucLoopIndex]); | ||
71 | |||
72 | for(ucLoopIndex=0;ucLoopIndex<(pstClassifierRule->ucIPDestinationAddressLength);ucLoopIndex++) | ||
73 | { | ||
74 | if((pstClassifierRule->stDestIpAddress.ulIpv4Mask[ucLoopIndex] & ulDestIP)== | ||
75 | (pstClassifierRule->stDestIpAddress.ulIpv4Addr[ucLoopIndex] & pstClassifierRule->stDestIpAddress.ulIpv4Mask[ucLoopIndex])) | ||
76 | { | ||
77 | return TRUE; | ||
78 | } | ||
79 | } | ||
80 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Destination Ip Address Not Matched"); | ||
81 | return FALSE; | ||
82 | } | ||
83 | |||
84 | |||
85 | /************************************************************************ | ||
86 | * Function - MatchTos() | ||
87 | * | ||
88 | * Description - Checks the TOS from the packet matches with that of queue. | ||
89 | * | ||
90 | * Parameters - pstClassifierRule : Pointer to the packet info structure. | ||
91 | * - ucTypeOfService: TOS from the packet. | ||
92 | * | ||
93 | * Returns - TRUE(If address matches) else FAIL. | ||
94 | **************************************************************************/ | ||
95 | BOOLEAN MatchTos(S_CLASSIFIER_RULE *pstClassifierRule,UCHAR ucTypeOfService) | ||
96 | { | ||
97 | |||
98 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
99 | if( 3 != pstClassifierRule->ucIPTypeOfServiceLength ) | ||
100 | return TRUE; | ||
101 | |||
102 | if(((pstClassifierRule->ucTosMask & ucTypeOfService)<=pstClassifierRule->ucTosHigh) && ((pstClassifierRule->ucTosMask & ucTypeOfService)>=pstClassifierRule->ucTosLow)) | ||
103 | { | ||
104 | return TRUE; | ||
105 | } | ||
106 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Type Of Service Not Matched"); | ||
107 | return FALSE; | ||
108 | } | ||
109 | |||
110 | |||
111 | /*************************************************************************** | ||
112 | * Function - MatchProtocol() | ||
113 | * | ||
114 | * Description - Checks the protocol from the packet matches with that of queue. | ||
115 | * | ||
116 | * Parameters - pstClassifierRule: Pointer to the packet info structure. | ||
117 | * - ucProtocol : Protocol from the packet. | ||
118 | * | ||
119 | * Returns - TRUE(If address matches) else FAIL. | ||
120 | ****************************************************************************/ | ||
121 | BOOLEAN MatchProtocol(S_CLASSIFIER_RULE *pstClassifierRule,UCHAR ucProtocol) | ||
122 | { | ||
123 | UCHAR ucLoopIndex=0; | ||
124 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
125 | if(0 == pstClassifierRule->ucProtocolLength) | ||
126 | return TRUE; | ||
127 | for(ucLoopIndex=0;ucLoopIndex<pstClassifierRule->ucProtocolLength;ucLoopIndex++) | ||
128 | { | ||
129 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Protocol:0x%X Classification Protocol:0x%X",ucProtocol,pstClassifierRule->ucProtocol[ucLoopIndex]); | ||
130 | if(pstClassifierRule->ucProtocol[ucLoopIndex]==ucProtocol) | ||
131 | { | ||
132 | return TRUE; | ||
133 | } | ||
134 | } | ||
135 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Protocol Not Matched"); | ||
136 | return FALSE; | ||
137 | } | ||
138 | |||
139 | |||
140 | /*********************************************************************** | ||
141 | * Function - MatchSrcPort() | ||
142 | * | ||
143 | * Description - Checks, Source port from the packet matches with that of queue. | ||
144 | * | ||
145 | * Parameters - pstClassifierRule: Pointer to the packet info structure. | ||
146 | * - ushSrcPort : Source port from the packet. | ||
147 | * | ||
148 | * Returns - TRUE(If address matches) else FAIL. | ||
149 | ***************************************************************************/ | ||
150 | BOOLEAN MatchSrcPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushSrcPort) | ||
151 | { | ||
152 | UCHAR ucLoopIndex=0; | ||
153 | |||
154 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
155 | |||
156 | |||
157 | if(0 == pstClassifierRule->ucSrcPortRangeLength) | ||
158 | return TRUE; | ||
159 | for(ucLoopIndex=0;ucLoopIndex<pstClassifierRule->ucSrcPortRangeLength;ucLoopIndex++) | ||
160 | { | ||
161 | if(ushSrcPort <= pstClassifierRule->usSrcPortRangeHi[ucLoopIndex] && | ||
162 | ushSrcPort >= pstClassifierRule->usSrcPortRangeLo[ucLoopIndex]) | ||
163 | { | ||
164 | return TRUE; | ||
165 | } | ||
166 | } | ||
167 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Src Port: %x Not Matched ",ushSrcPort); | ||
168 | return FALSE; | ||
169 | } | ||
170 | |||
171 | |||
172 | /*********************************************************************** | ||
173 | * Function - MatchDestPort() | ||
174 | * | ||
175 | * Description - Checks, Destination port from packet matches with that of queue. | ||
176 | * | ||
177 | * Parameters - pstClassifierRule: Pointer to the packet info structure. | ||
178 | * - ushDestPort : Destination port from the packet. | ||
179 | * | ||
180 | * Returns - TRUE(If address matches) else FAIL. | ||
181 | ***************************************************************************/ | ||
182 | BOOLEAN MatchDestPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushDestPort) | ||
183 | { | ||
184 | UCHAR ucLoopIndex=0; | ||
185 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
186 | |||
187 | if(0 == pstClassifierRule->ucDestPortRangeLength) | ||
188 | return TRUE; | ||
189 | |||
190 | for(ucLoopIndex=0;ucLoopIndex<pstClassifierRule->ucDestPortRangeLength;ucLoopIndex++) | ||
191 | { | ||
192 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Matching Port:0x%X 0x%X 0x%X",ushDestPort,pstClassifierRule->usDestPortRangeLo[ucLoopIndex],pstClassifierRule->usDestPortRangeHi[ucLoopIndex]); | ||
193 | |||
194 | if(ushDestPort <= pstClassifierRule->usDestPortRangeHi[ucLoopIndex] && | ||
195 | ushDestPort >= pstClassifierRule->usDestPortRangeLo[ucLoopIndex]) | ||
196 | { | ||
197 | return TRUE; | ||
198 | } | ||
199 | } | ||
200 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Dest Port: %x Not Matched",ushDestPort); | ||
201 | return FALSE; | ||
202 | } | ||
203 | /** | ||
204 | @ingroup tx_functions | ||
205 | Compares IPV4 Ip address and port number | ||
206 | @return Queue Index. | ||
207 | */ | ||
208 | USHORT IpVersion4(PMINI_ADAPTER Adapter, /**< Pointer to the driver control structure */ | ||
209 | struct iphdr *iphd, /**<Pointer to the IP Hdr of the packet*/ | ||
210 | S_CLASSIFIER_RULE *pstClassifierRule ) | ||
211 | { | ||
212 | //IPHeaderFormat *pIpHeader=NULL; | ||
213 | xporthdr *xprt_hdr=NULL; | ||
214 | BOOLEAN bClassificationSucceed=FALSE; | ||
215 | |||
216 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "========>"); | ||
217 | |||
218 | xprt_hdr=(xporthdr *)((PUCHAR)iphd + sizeof(struct iphdr)); | ||
219 | |||
220 | do { | ||
221 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Trying to see Direction = %d %d", | ||
222 | pstClassifierRule->ucDirection, | ||
223 | pstClassifierRule->usVCID_Value); | ||
224 | |||
225 | //Checking classifier validity | ||
226 | if(!pstClassifierRule->bUsed || pstClassifierRule->ucDirection == DOWNLINK_DIR) | ||
227 | { | ||
228 | bClassificationSucceed = FALSE; | ||
229 | break; | ||
230 | } | ||
231 | |||
232 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "is IPv6 check!"); | ||
233 | if(pstClassifierRule->bIpv6Protocol) | ||
234 | break; | ||
235 | |||
236 | //**************Checking IP header parameter**************************// | ||
237 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Trying to match Source IP Address"); | ||
238 | if(FALSE == (bClassificationSucceed = | ||
239 | MatchSrcIpAddress(pstClassifierRule, iphd->saddr))) | ||
240 | break; | ||
241 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Source IP Address Matched"); | ||
242 | |||
243 | if(FALSE == (bClassificationSucceed = | ||
244 | MatchDestIpAddress(pstClassifierRule, iphd->daddr))) | ||
245 | break; | ||
246 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Destination IP Address Matched"); | ||
247 | |||
248 | if(FALSE == (bClassificationSucceed = | ||
249 | MatchTos(pstClassifierRule, iphd->tos))) | ||
250 | { | ||
251 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "TOS Match failed\n"); | ||
252 | break; | ||
253 | } | ||
254 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "TOS Matched"); | ||
255 | |||
256 | if(FALSE == (bClassificationSucceed = | ||
257 | MatchProtocol(pstClassifierRule,iphd->protocol))) | ||
258 | break; | ||
259 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Protocol Matched"); | ||
260 | |||
261 | //if protocol is not TCP or UDP then no need of comparing source port and destination port | ||
262 | if(iphd->protocol!=TCP && iphd->protocol!=UDP) | ||
263 | break; | ||
264 | #if 0 | ||
265 | //check if memory is available of src and Dest port | ||
266 | if(ETH_AND_IP_HEADER_LEN + L4_SRC_PORT_LEN + L4_DEST_PORT_LEN > Packet->len) | ||
267 | { | ||
268 | //This is not an erroneous condition and pkt will be checked for next classification. | ||
269 | bClassificationSucceed = FALSE; | ||
270 | break; | ||
271 | } | ||
272 | #endif | ||
273 | //******************Checking Transport Layer Header field if present *****************// | ||
274 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Source Port %04x", | ||
275 | (iphd->protocol==UDP)?xprt_hdr->uhdr.source:xprt_hdr->thdr.source); | ||
276 | |||
277 | if(FALSE == (bClassificationSucceed = | ||
278 | MatchSrcPort(pstClassifierRule, | ||
279 | ntohs((iphd->protocol == UDP)? | ||
280 | xprt_hdr->uhdr.source:xprt_hdr->thdr.source)))) | ||
281 | break; | ||
282 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Src Port Matched"); | ||
283 | |||
284 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Destination Port %04x", | ||
285 | (iphd->protocol==UDP)?xprt_hdr->uhdr.dest: | ||
286 | xprt_hdr->thdr.dest); | ||
287 | if(FALSE == (bClassificationSucceed = | ||
288 | MatchDestPort(pstClassifierRule, | ||
289 | ntohs((iphd->protocol == UDP)? | ||
290 | xprt_hdr->uhdr.dest:xprt_hdr->thdr.dest)))) | ||
291 | break; | ||
292 | } while(0); | ||
293 | |||
294 | if(TRUE==bClassificationSucceed) | ||
295 | { | ||
296 | INT iMatchedSFQueueIndex = 0; | ||
297 | iMatchedSFQueueIndex = SearchSfid(Adapter,pstClassifierRule->ulSFID); | ||
298 | if(iMatchedSFQueueIndex >= NO_OF_QUEUES) | ||
299 | { | ||
300 | bClassificationSucceed = FALSE; | ||
301 | } | ||
302 | else | ||
303 | { | ||
304 | if(FALSE == Adapter->PackInfo[iMatchedSFQueueIndex].bActive) | ||
305 | { | ||
306 | bClassificationSucceed = FALSE; | ||
307 | } | ||
308 | } | ||
309 | } | ||
310 | |||
311 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "IpVersion4 <=========="); | ||
312 | |||
313 | return bClassificationSucceed; | ||
314 | } | ||
315 | /** | ||
316 | @ingroup tx_functions | ||
317 | @return Queue Index based on priority. | ||
318 | */ | ||
319 | USHORT GetPacketQueueIndex(PMINI_ADAPTER Adapter, /**<Pointer to the driver control structure */ | ||
320 | struct sk_buff* Packet /**< Pointer to the Packet to be sent*/ | ||
321 | ) | ||
322 | { | ||
323 | USHORT usIndex=-1; | ||
324 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, QUEUE_INDEX, DBG_LVL_ALL, "=====>"); | ||
325 | |||
326 | if(NULL==Adapter || NULL==Packet) | ||
327 | { | ||
328 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, QUEUE_INDEX, DBG_LVL_ALL, "Got NULL Values<======"); | ||
329 | return -1; | ||
330 | } | ||
331 | |||
332 | usIndex = ClassifyPacket(Adapter,Packet); | ||
333 | |||
334 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, QUEUE_INDEX, DBG_LVL_ALL, "Got Queue Index %x",usIndex); | ||
335 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, QUEUE_INDEX, DBG_LVL_ALL, "GetPacketQueueIndex <=============="); | ||
336 | return usIndex; | ||
337 | } | ||
338 | |||
339 | VOID PruneQueueAllSF(PMINI_ADAPTER Adapter) | ||
340 | { | ||
341 | UINT iIndex = 0; | ||
342 | |||
343 | for(iIndex = 0; iIndex < HiPriority; iIndex++) | ||
344 | { | ||
345 | if(!Adapter->PackInfo[iIndex].bValid) | ||
346 | continue; | ||
347 | |||
348 | PruneQueue(Adapter, iIndex); | ||
349 | } | ||
350 | } | ||
351 | |||
352 | |||
353 | /** | ||
354 | @ingroup tx_functions | ||
355 | This function checks if the max queue size for a queue | ||
356 | is less than number of bytes in the queue. If so - | ||
357 | drops packets from the Head till the number of bytes is | ||
358 | less than or equal to max queue size for the queue. | ||
359 | */ | ||
360 | VOID PruneQueue(PMINI_ADAPTER Adapter,/**<Pointer to the driver control structure*/ | ||
361 | INT iIndex/**<Queue Index*/ | ||
362 | ) | ||
363 | { | ||
364 | struct sk_buff* PacketToDrop=NULL; | ||
365 | struct net_device_stats* netstats=NULL; | ||
366 | |||
367 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "=====> Index %d",iIndex); | ||
368 | |||
369 | if(iIndex == HiPriority) | ||
370 | return; | ||
371 | |||
372 | if(!Adapter || (iIndex < 0) || (iIndex > HiPriority)) | ||
373 | return; | ||
374 | |||
375 | /* To Store the netdevice statistic */ | ||
376 | netstats = &((PLINUX_DEP_DATA)Adapter->pvOsDepData)->netstats; | ||
377 | |||
378 | spin_lock_bh(&Adapter->PackInfo[iIndex].SFQueueLock); | ||
379 | |||
380 | while(1) | ||
381 | // while((UINT)Adapter->PackInfo[iIndex].uiCurrentPacketsOnHost > | ||
382 | // SF_MAX_ALLOWED_PACKETS_TO_BACKUP) | ||
383 | { | ||
384 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "uiCurrentBytesOnHost:%x uiMaxBucketSize :%x", | ||
385 | Adapter->PackInfo[iIndex].uiCurrentBytesOnHost, | ||
386 | Adapter->PackInfo[iIndex].uiMaxBucketSize); | ||
387 | |||
388 | PacketToDrop = Adapter->PackInfo[iIndex].FirstTxQueue; | ||
389 | |||
390 | if(PacketToDrop == NULL) | ||
391 | break; | ||
392 | if((Adapter->PackInfo[iIndex].uiCurrentPacketsOnHost < SF_MAX_ALLOWED_PACKETS_TO_BACKUP) && | ||
393 | ((1000*(jiffies - *((B_UINT32 *)(PacketToDrop->cb)+SKB_CB_LATENCY_OFFSET))/HZ) <= Adapter->PackInfo[iIndex].uiMaxLatency)) | ||
394 | break; | ||
395 | |||
396 | if(PacketToDrop) | ||
397 | { | ||
398 | if(netstats) | ||
399 | netstats->tx_dropped++; | ||
400 | atomic_inc(&Adapter->TxDroppedPacketCount); | ||
401 | DEQUEUEPACKET(Adapter->PackInfo[iIndex].FirstTxQueue, | ||
402 | Adapter->PackInfo[iIndex].LastTxQueue); | ||
403 | /// update current bytes and packets count | ||
404 | Adapter->PackInfo[iIndex].uiCurrentBytesOnHost -= | ||
405 | PacketToDrop->len; | ||
406 | Adapter->PackInfo[iIndex].uiCurrentPacketsOnHost--; | ||
407 | /// update dropped bytes and packets counts | ||
408 | Adapter->PackInfo[iIndex].uiDroppedCountBytes += PacketToDrop->len; | ||
409 | Adapter->PackInfo[iIndex].uiDroppedCountPackets++; | ||
410 | bcm_kfree_skb(PacketToDrop); | ||
411 | |||
412 | } | ||
413 | |||
414 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "Dropped Bytes:%x Dropped Packets:%x", | ||
415 | Adapter->PackInfo[iIndex].uiDroppedCountBytes, | ||
416 | Adapter->PackInfo[iIndex].uiDroppedCountPackets); | ||
417 | |||
418 | atomic_dec(&Adapter->TotalPacketCount); | ||
419 | Adapter->bcm_jiffies = jiffies; | ||
420 | } | ||
421 | |||
422 | spin_unlock_bh(&Adapter->PackInfo[iIndex].SFQueueLock); | ||
423 | |||
424 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "TotalPacketCount:%x", | ||
425 | atomic_read(&Adapter->TotalPacketCount)); | ||
426 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "<====="); | ||
427 | } | ||
428 | |||
429 | VOID flush_all_queues(PMINI_ADAPTER Adapter) | ||
430 | { | ||
431 | INT iQIndex; | ||
432 | UINT uiTotalPacketLength; | ||
433 | struct sk_buff* PacketToDrop=NULL; | ||
434 | struct net_device_stats* netstats=NULL; | ||
435 | |||
436 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "=====>"); | ||
437 | /* To Store the netdevice statistic */ | ||
438 | netstats = &((PLINUX_DEP_DATA)Adapter->pvOsDepData)->netstats; | ||
439 | |||
440 | // down(&Adapter->data_packet_queue_lock); | ||
441 | for(iQIndex=LowPriority; iQIndex<HiPriority; iQIndex++) | ||
442 | { | ||
443 | spin_lock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock); | ||
444 | while(Adapter->PackInfo[iQIndex].FirstTxQueue) | ||
445 | { | ||
446 | PacketToDrop = Adapter->PackInfo[iQIndex].FirstTxQueue; | ||
447 | if(PacketToDrop) | ||
448 | { | ||
449 | uiTotalPacketLength = PacketToDrop->len; | ||
450 | netstats->tx_dropped++; | ||
451 | atomic_inc(&Adapter->TxDroppedPacketCount); | ||
452 | } | ||
453 | else | ||
454 | uiTotalPacketLength = 0; | ||
455 | |||
456 | DEQUEUEPACKET(Adapter->PackInfo[iQIndex].FirstTxQueue, | ||
457 | Adapter->PackInfo[iQIndex].LastTxQueue); | ||
458 | |||
459 | /* Free the skb */ | ||
460 | bcm_kfree_skb(PacketToDrop); | ||
461 | |||
462 | /// update current bytes and packets count | ||
463 | Adapter->PackInfo[iQIndex].uiCurrentBytesOnHost -= uiTotalPacketLength; | ||
464 | Adapter->PackInfo[iQIndex].uiCurrentPacketsOnHost--; | ||
465 | |||
466 | /// update dropped bytes and packets counts | ||
467 | Adapter->PackInfo[iQIndex].uiDroppedCountBytes += uiTotalPacketLength; | ||
468 | Adapter->PackInfo[iQIndex].uiDroppedCountPackets++; | ||
469 | |||
470 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Dropped Bytes:%x Dropped Packets:%x", | ||
471 | Adapter->PackInfo[iQIndex].uiDroppedCountBytes, | ||
472 | Adapter->PackInfo[iQIndex].uiDroppedCountPackets); | ||
473 | atomic_dec(&Adapter->TotalPacketCount); | ||
474 | } | ||
475 | spin_unlock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock); | ||
476 | } | ||
477 | // up(&Adapter->data_packet_queue_lock); | ||
478 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "<====="); | ||
479 | } | ||
480 | |||
481 | USHORT ClassifyPacket(PMINI_ADAPTER Adapter,struct sk_buff* skb) | ||
482 | { | ||
483 | INT uiLoopIndex=0; | ||
484 | S_CLASSIFIER_RULE *pstClassifierRule = NULL; | ||
485 | S_ETHCS_PKT_INFO stEthCsPktInfo; | ||
486 | PVOID pvEThPayload = NULL; | ||
487 | struct iphdr *pIpHeader = NULL; | ||
488 | INT uiSfIndex=0; | ||
489 | USHORT usIndex=Adapter->usBestEffortQueueIndex; | ||
490 | BOOLEAN bFragmentedPkt=FALSE,bClassificationSucceed=FALSE; | ||
491 | USHORT usCurrFragment =0; | ||
492 | |||
493 | PTCP_HEADER pTcpHeader; | ||
494 | UCHAR IpHeaderLength; | ||
495 | UCHAR TcpHeaderLength; | ||
496 | |||
497 | pvEThPayload = skb->data; | ||
498 | *((UINT32*) (skb->cb) +SKB_CB_TCPACK_OFFSET ) = 0; | ||
499 | EThCSGetPktInfo(Adapter,pvEThPayload,&stEthCsPktInfo); | ||
500 | |||
501 | switch(stEthCsPktInfo.eNwpktEthFrameType) | ||
502 | { | ||
503 | case eEth802LLCFrame: | ||
504 | { | ||
505 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : 802LLCFrame\n"); | ||
506 | pIpHeader = pvEThPayload + sizeof(ETH_CS_802_LLC_FRAME); | ||
507 | break; | ||
508 | } | ||
509 | |||
510 | case eEth802LLCSNAPFrame: | ||
511 | { | ||
512 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : 802LLC SNAP Frame\n"); | ||
513 | pIpHeader = pvEThPayload + sizeof(ETH_CS_802_LLC_SNAP_FRAME); | ||
514 | break; | ||
515 | } | ||
516 | case eEth802QVLANFrame: | ||
517 | { | ||
518 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : 802.1Q VLANFrame\n"); | ||
519 | pIpHeader = pvEThPayload + sizeof(ETH_CS_802_Q_FRAME); | ||
520 | break; | ||
521 | } | ||
522 | case eEthOtherFrame: | ||
523 | { | ||
524 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : ETH Other Frame\n"); | ||
525 | pIpHeader = pvEThPayload + sizeof(ETH_CS_ETH2_FRAME); | ||
526 | break; | ||
527 | } | ||
528 | default: | ||
529 | { | ||
530 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : Unrecognized ETH Frame\n"); | ||
531 | pIpHeader = pvEThPayload + sizeof(ETH_CS_ETH2_FRAME); | ||
532 | break; | ||
533 | } | ||
534 | } | ||
535 | |||
536 | if(stEthCsPktInfo.eNwpktIPFrameType == eIPv4Packet) | ||
537 | { | ||
538 | usCurrFragment = (ntohs(pIpHeader->frag_off) & IP_OFFSET); | ||
539 | if((ntohs(pIpHeader->frag_off) & IP_MF) || usCurrFragment) | ||
540 | bFragmentedPkt = TRUE; | ||
541 | |||
542 | if(bFragmentedPkt) | ||
543 | { | ||
544 | //Fragmented Packet. Get Frag Classifier Entry. | ||
545 | pstClassifierRule = GetFragIPClsEntry(Adapter,pIpHeader->id, pIpHeader->saddr); | ||
546 | if(pstClassifierRule) | ||
547 | { | ||
548 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,"It is next Fragmented pkt"); | ||
549 | bClassificationSucceed=TRUE; | ||
550 | } | ||
551 | if(!(ntohs(pIpHeader->frag_off) & IP_MF)) | ||
552 | { | ||
553 | //Fragmented Last packet . Remove Frag Classifier Entry | ||
554 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,"This is the last fragmented Pkt"); | ||
555 | DelFragIPClsEntry(Adapter,pIpHeader->id, pIpHeader->saddr); | ||
556 | } | ||
557 | } | ||
558 | } | ||
559 | |||
560 | for(uiLoopIndex = MAX_CLASSIFIERS - 1; uiLoopIndex >= 0; uiLoopIndex--) | ||
561 | { | ||
562 | if (Adapter->device_removed) | ||
563 | { | ||
564 | bClassificationSucceed = FALSE; | ||
565 | break; | ||
566 | } | ||
567 | |||
568 | if(bClassificationSucceed) | ||
569 | break; | ||
570 | //Iterate through all classifiers which are already in order of priority | ||
571 | //to classify the packet until match found | ||
572 | do | ||
573 | { | ||
574 | if(FALSE==Adapter->astClassifierTable[uiLoopIndex].bUsed) | ||
575 | { | ||
576 | bClassificationSucceed=FALSE; | ||
577 | break; | ||
578 | } | ||
579 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Adapter->PackInfo[%d].bvalid=True\n",uiLoopIndex); | ||
580 | |||
581 | if(0 == Adapter->astClassifierTable[uiLoopIndex].ucDirection) | ||
582 | { | ||
583 | bClassificationSucceed=FALSE;//cannot be processed for classification. | ||
584 | break; // it is a down link connection | ||
585 | } | ||
586 | |||
587 | pstClassifierRule = &Adapter->astClassifierTable[uiLoopIndex]; | ||
588 | |||
589 | uiSfIndex = SearchSfid(Adapter,pstClassifierRule->ulSFID); | ||
590 | if(uiSfIndex > NO_OF_QUEUES) | ||
591 | { | ||
592 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Queue Not Valid. SearchSfid for this classifier Failed\n"); | ||
593 | break; | ||
594 | } | ||
595 | |||
596 | if(Adapter->PackInfo[uiSfIndex].bEthCSSupport) | ||
597 | { | ||
598 | |||
599 | if(eEthUnsupportedFrame==stEthCsPktInfo.eNwpktEthFrameType) | ||
600 | { | ||
601 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, " ClassifyPacket : Packet Not a Valid Supported Ethernet Frame \n"); | ||
602 | bClassificationSucceed = FALSE; | ||
603 | break; | ||
604 | } | ||
605 | |||
606 | |||
607 | |||
608 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Performing ETH CS Classification on Classifier Rule ID : %x Service Flow ID : %lx\n",pstClassifierRule->uiClassifierRuleIndex,Adapter->PackInfo[uiSfIndex].ulSFID); | ||
609 | bClassificationSucceed = EThCSClassifyPkt(Adapter,skb,&stEthCsPktInfo,pstClassifierRule, Adapter->PackInfo[uiSfIndex].bEthCSSupport); | ||
610 | |||
611 | if(!bClassificationSucceed) | ||
612 | { | ||
613 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : Ethernet CS Classification Failed\n"); | ||
614 | break; | ||
615 | } | ||
616 | } | ||
617 | |||
618 | else // No ETH Supported on this SF | ||
619 | { | ||
620 | if(eEthOtherFrame != stEthCsPktInfo.eNwpktEthFrameType) | ||
621 | { | ||
622 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, " ClassifyPacket : Packet Not a 802.3 Ethernet Frame... hence not allowed over non-ETH CS SF \n"); | ||
623 | bClassificationSucceed = FALSE; | ||
624 | break; | ||
625 | } | ||
626 | } | ||
627 | |||
628 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Proceeding to IP CS Clasification"); | ||
629 | |||
630 | if(Adapter->PackInfo[uiSfIndex].bIPCSSupport) | ||
631 | { | ||
632 | |||
633 | if(stEthCsPktInfo.eNwpktIPFrameType == eNonIPPacket) | ||
634 | { | ||
635 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, " ClassifyPacket : Packet is Not an IP Packet \n"); | ||
636 | bClassificationSucceed = FALSE; | ||
637 | break; | ||
638 | } | ||
639 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Dump IP Header : \n"); | ||
640 | DumpFullPacket((PUCHAR)pIpHeader,20); | ||
641 | |||
642 | if(stEthCsPktInfo.eNwpktIPFrameType == eIPv4Packet) | ||
643 | bClassificationSucceed = IpVersion4(Adapter,pIpHeader,pstClassifierRule); | ||
644 | else if(stEthCsPktInfo.eNwpktIPFrameType == eIPv6Packet) | ||
645 | bClassificationSucceed = IpVersion6(Adapter,pIpHeader,pstClassifierRule); | ||
646 | } | ||
647 | |||
648 | }while(0); | ||
649 | } | ||
650 | |||
651 | if(bClassificationSucceed == TRUE) | ||
652 | { | ||
653 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "CF id : %d, SF ID is =%lu",pstClassifierRule->uiClassifierRuleIndex, pstClassifierRule->ulSFID); | ||
654 | |||
655 | //Store The matched Classifier in SKB | ||
656 | *((UINT32*)(skb->cb)+SKB_CB_CLASSIFICATION_OFFSET) = pstClassifierRule->uiClassifierRuleIndex; | ||
657 | if((TCP == pIpHeader->protocol ) && !bFragmentedPkt && (ETH_AND_IP_HEADER_LEN + TCP_HEADER_LEN <= skb->len) ) | ||
658 | { | ||
659 | IpHeaderLength = pIpHeader->ihl; | ||
660 | pTcpHeader = (PTCP_HEADER)(((PUCHAR)pIpHeader)+(IpHeaderLength*4)); | ||
661 | TcpHeaderLength = GET_TCP_HEADER_LEN(pTcpHeader->HeaderLength); | ||
662 | |||
663 | if((pTcpHeader->ucFlags & TCP_ACK) && | ||
664 | (ntohs(pIpHeader->tot_len) == (IpHeaderLength*4)+(TcpHeaderLength*4))) | ||
665 | { | ||
666 | *((UINT32*) (skb->cb) +SKB_CB_TCPACK_OFFSET ) = TCP_ACK; | ||
667 | } | ||
668 | } | ||
669 | |||
670 | usIndex = SearchSfid(Adapter, pstClassifierRule->ulSFID); | ||
671 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "index is =%d", usIndex); | ||
672 | |||
673 | //If this is the first fragment of a Fragmented pkt, add this CF. Only This CF should be used for all other fragment of this Pkt. | ||
674 | if(bFragmentedPkt && (usCurrFragment == 0)) | ||
675 | { | ||
676 | //First Fragment of Fragmented Packet. Create Frag CLS Entry | ||
677 | S_FRAGMENTED_PACKET_INFO stFragPktInfo; | ||
678 | stFragPktInfo.bUsed = TRUE; | ||
679 | stFragPktInfo.ulSrcIpAddress = pIpHeader->saddr; | ||
680 | stFragPktInfo.usIpIdentification = pIpHeader->id; | ||
681 | stFragPktInfo.pstMatchedClassifierEntry = pstClassifierRule; | ||
682 | stFragPktInfo.bOutOfOrderFragment = FALSE; | ||
683 | AddFragIPClsEntry(Adapter,&stFragPktInfo); | ||
684 | } | ||
685 | |||
686 | |||
687 | } | ||
688 | |||
689 | if(bClassificationSucceed) | ||
690 | return usIndex; | ||
691 | else | ||
692 | return INVALID_QUEUE_INDEX; | ||
693 | } | ||
694 | |||
695 | BOOLEAN EthCSMatchSrcMACAddress(S_CLASSIFIER_RULE *pstClassifierRule,PUCHAR Mac) | ||
696 | { | ||
697 | UINT i=0; | ||
698 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
699 | if(pstClassifierRule->ucEthCSSrcMACLen==0) | ||
700 | return TRUE; | ||
701 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s \n",__FUNCTION__); | ||
702 | for(i=0;i<MAC_ADDRESS_SIZE;i++) | ||
703 | { | ||
704 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "SRC MAC[%x] = %x ClassifierRuleSrcMAC = %x Mask : %x\n",i,Mac[i],pstClassifierRule->au8EThCSSrcMAC[i],pstClassifierRule->au8EThCSSrcMACMask[i]); | ||
705 | if((pstClassifierRule->au8EThCSSrcMAC[i] & pstClassifierRule->au8EThCSSrcMACMask[i])!= | ||
706 | (Mac[i] & pstClassifierRule->au8EThCSSrcMACMask[i])) | ||
707 | return FALSE; | ||
708 | } | ||
709 | return TRUE; | ||
710 | } | ||
711 | |||
712 | BOOLEAN EthCSMatchDestMACAddress(S_CLASSIFIER_RULE *pstClassifierRule,PUCHAR Mac) | ||
713 | { | ||
714 | UINT i=0; | ||
715 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
716 | if(pstClassifierRule->ucEthCSDestMACLen==0) | ||
717 | return TRUE; | ||
718 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s \n",__FUNCTION__); | ||
719 | for(i=0;i<MAC_ADDRESS_SIZE;i++) | ||
720 | { | ||
721 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "SRC MAC[%x] = %x ClassifierRuleSrcMAC = %x Mask : %x\n",i,Mac[i],pstClassifierRule->au8EThCSDestMAC[i],pstClassifierRule->au8EThCSDestMACMask[i]); | ||
722 | if((pstClassifierRule->au8EThCSDestMAC[i] & pstClassifierRule->au8EThCSDestMACMask[i])!= | ||
723 | (Mac[i] & pstClassifierRule->au8EThCSDestMACMask[i])) | ||
724 | return FALSE; | ||
725 | } | ||
726 | return TRUE; | ||
727 | } | ||
728 | |||
729 | BOOLEAN EthCSMatchEThTypeSAP(S_CLASSIFIER_RULE *pstClassifierRule,struct sk_buff* skb,PS_ETHCS_PKT_INFO pstEthCsPktInfo) | ||
730 | { | ||
731 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
732 | if((pstClassifierRule->ucEtherTypeLen==0)|| | ||
733 | (pstClassifierRule->au8EthCSEtherType[0] == 0)) | ||
734 | return TRUE; | ||
735 | |||
736 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s SrcEtherType:%x CLS EtherType[0]:%x\n",__FUNCTION__,pstEthCsPktInfo->usEtherType,pstClassifierRule->au8EthCSEtherType[0]); | ||
737 | if(pstClassifierRule->au8EthCSEtherType[0] == 1) | ||
738 | { | ||
739 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s CLS EtherType[1]:%x EtherType[2]:%x\n",__FUNCTION__,pstClassifierRule->au8EthCSEtherType[1],pstClassifierRule->au8EthCSEtherType[2]); | ||
740 | |||
741 | if(memcmp(&pstEthCsPktInfo->usEtherType,&pstClassifierRule->au8EthCSEtherType[1],2)==0) | ||
742 | return TRUE; | ||
743 | else | ||
744 | return FALSE; | ||
745 | } | ||
746 | |||
747 | if(pstClassifierRule->au8EthCSEtherType[0] == 2) | ||
748 | { | ||
749 | if(eEth802LLCFrame != pstEthCsPktInfo->eNwpktEthFrameType) | ||
750 | return FALSE; | ||
751 | |||
752 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s EthCS DSAP:%x EtherType[2]:%x\n",__FUNCTION__,pstEthCsPktInfo->ucDSAP,pstClassifierRule->au8EthCSEtherType[2]); | ||
753 | if(pstEthCsPktInfo->ucDSAP == pstClassifierRule->au8EthCSEtherType[2]) | ||
754 | return TRUE; | ||
755 | else | ||
756 | return FALSE; | ||
757 | |||
758 | } | ||
759 | |||
760 | return FALSE; | ||
761 | |||
762 | } | ||
763 | |||
764 | BOOLEAN EthCSMatchVLANRules(S_CLASSIFIER_RULE *pstClassifierRule,struct sk_buff* skb,PS_ETHCS_PKT_INFO pstEthCsPktInfo) | ||
765 | { | ||
766 | BOOLEAN bClassificationSucceed = FALSE; | ||
767 | USHORT usVLANID; | ||
768 | B_UINT8 uPriority = 0; | ||
769 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
770 | |||
771 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s CLS UserPrio:%x CLS VLANID:%x\n",__FUNCTION__,ntohs(*((USHORT *)pstClassifierRule->usUserPriority)),pstClassifierRule->usVLANID); | ||
772 | |||
773 | /* In case FW didn't recieve the TLV, the priority field should be ignored */ | ||
774 | if(pstClassifierRule->usValidityBitMap & (1<<PKT_CLASSIFICATION_USER_PRIORITY_VALID)) | ||
775 | { | ||
776 | if(pstEthCsPktInfo->eNwpktEthFrameType!=eEth802QVLANFrame) | ||
777 | return FALSE; | ||
778 | |||
779 | uPriority = (ntohs(*(USHORT *)(skb->data + sizeof(ETH_HEADER_STRUC))) & 0xF000) >> 13; | ||
780 | |||
781 | if((uPriority >= pstClassifierRule->usUserPriority[0]) && (uPriority <= pstClassifierRule->usUserPriority[1])) | ||
782 | bClassificationSucceed = TRUE; | ||
783 | |||
784 | if(!bClassificationSucceed) | ||
785 | return FALSE; | ||
786 | } | ||
787 | |||
788 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ETH CS 802.1 D User Priority Rule Matched\n"); | ||
789 | |||
790 | bClassificationSucceed = FALSE; | ||
791 | |||
792 | if(pstClassifierRule->usValidityBitMap & (1<<PKT_CLASSIFICATION_VLANID_VALID)) | ||
793 | { | ||
794 | if(pstEthCsPktInfo->eNwpktEthFrameType!=eEth802QVLANFrame) | ||
795 | return FALSE; | ||
796 | |||
797 | usVLANID = ntohs(*(USHORT *)(skb->data + sizeof(ETH_HEADER_STRUC))) & 0xFFF; | ||
798 | |||
799 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s Pkt VLANID %x Priority: %d\n",__FUNCTION__,usVLANID, uPriority); | ||
800 | |||
801 | if(usVLANID == ((pstClassifierRule->usVLANID & 0xFFF0) >> 4)) | ||
802 | bClassificationSucceed = TRUE; | ||
803 | |||
804 | if(!bClassificationSucceed) | ||
805 | return FALSE; | ||
806 | } | ||
807 | |||
808 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ETH CS 802.1 Q VLAN ID Rule Matched\n"); | ||
809 | |||
810 | return TRUE; | ||
811 | } | ||
812 | |||
813 | |||
814 | BOOLEAN EThCSClassifyPkt(PMINI_ADAPTER Adapter,struct sk_buff* skb,PS_ETHCS_PKT_INFO pstEthCsPktInfo,S_CLASSIFIER_RULE *pstClassifierRule, B_UINT8 EthCSCupport) | ||
815 | { | ||
816 | BOOLEAN bClassificationSucceed = FALSE; | ||
817 | bClassificationSucceed = EthCSMatchSrcMACAddress(pstClassifierRule,((ETH_HEADER_STRUC *)(skb->data))->au8SourceAddress); | ||
818 | if(!bClassificationSucceed) | ||
819 | return FALSE; | ||
820 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ETH CS SrcMAC Matched\n"); | ||
821 | |||
822 | bClassificationSucceed = EthCSMatchDestMACAddress(pstClassifierRule,((ETH_HEADER_STRUC*)(skb->data))->au8DestinationAddress); | ||
823 | if(!bClassificationSucceed) | ||
824 | return FALSE; | ||
825 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ETH CS DestMAC Matched\n"); | ||
826 | |||
827 | //classify on ETHType/802.2SAP TLV | ||
828 | bClassificationSucceed = EthCSMatchEThTypeSAP(pstClassifierRule,skb,pstEthCsPktInfo); | ||
829 | if(!bClassificationSucceed) | ||
830 | return FALSE; | ||
831 | |||
832 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ETH CS EthType/802.2SAP Matched\n"); | ||
833 | |||
834 | //classify on 802.1VLAN Header Parameters | ||
835 | |||
836 | bClassificationSucceed = EthCSMatchVLANRules(pstClassifierRule,skb,pstEthCsPktInfo); | ||
837 | if(!bClassificationSucceed) | ||
838 | return FALSE; | ||
839 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ETH CS 802.1 VLAN Rules Matched\n"); | ||
840 | |||
841 | return bClassificationSucceed; | ||
842 | } | ||
843 | |||
844 | void EThCSGetPktInfo(PMINI_ADAPTER Adapter,PVOID pvEthPayload,PS_ETHCS_PKT_INFO pstEthCsPktInfo) | ||
845 | { | ||
846 | USHORT u16Etype = ntohs(((ETH_HEADER_STRUC*)pvEthPayload)->u16Etype); | ||
847 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCSGetPktInfo : Eth Hdr Type : %X\n",u16Etype); | ||
848 | if(u16Etype > 0x5dc) | ||
849 | { | ||
850 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCSGetPktInfo : ETH2 Frame \n"); | ||
851 | //ETH2 Frame | ||
852 | if(u16Etype == ETHERNET_FRAMETYPE_802QVLAN) | ||
853 | { | ||
854 | //802.1Q VLAN Header | ||
855 | pstEthCsPktInfo->eNwpktEthFrameType = eEth802QVLANFrame; | ||
856 | u16Etype = ((ETH_CS_802_Q_FRAME*)pvEthPayload)->EthType; | ||
857 | //((ETH_CS_802_Q_FRAME*)pvEthPayload)->UserPriority | ||
858 | } | ||
859 | else | ||
860 | { | ||
861 | pstEthCsPktInfo->eNwpktEthFrameType = eEthOtherFrame; | ||
862 | u16Etype = ntohs(u16Etype); | ||
863 | } | ||
864 | |||
865 | } | ||
866 | else | ||
867 | { | ||
868 | //802.2 LLC | ||
869 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "802.2 LLC Frame \n"); | ||
870 | pstEthCsPktInfo->eNwpktEthFrameType = eEth802LLCFrame; | ||
871 | pstEthCsPktInfo->ucDSAP = ((ETH_CS_802_LLC_FRAME*)pvEthPayload)->DSAP; | ||
872 | if(pstEthCsPktInfo->ucDSAP == 0xAA && ((ETH_CS_802_LLC_FRAME*)pvEthPayload)->SSAP == 0xAA) | ||
873 | { | ||
874 | //SNAP Frame | ||
875 | pstEthCsPktInfo->eNwpktEthFrameType = eEth802LLCSNAPFrame; | ||
876 | u16Etype = ((ETH_CS_802_LLC_SNAP_FRAME*)pvEthPayload)->usEtherType; | ||
877 | } | ||
878 | } | ||
879 | if(u16Etype == ETHERNET_FRAMETYPE_IPV4) | ||
880 | pstEthCsPktInfo->eNwpktIPFrameType = eIPv4Packet; | ||
881 | else if(u16Etype == ETHERNET_FRAMETYPE_IPV6) | ||
882 | pstEthCsPktInfo->eNwpktIPFrameType = eIPv6Packet; | ||
883 | else | ||
884 | pstEthCsPktInfo->eNwpktIPFrameType = eNonIPPacket; | ||
885 | |||
886 | pstEthCsPktInfo->usEtherType = ((ETH_HEADER_STRUC*)pvEthPayload)->u16Etype; | ||
887 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCsPktInfo->eNwpktIPFrameType : %x\n",pstEthCsPktInfo->eNwpktIPFrameType); | ||
888 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCsPktInfo->eNwpktEthFrameType : %x\n",pstEthCsPktInfo->eNwpktEthFrameType); | ||
889 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCsPktInfo->usEtherType : %x\n",pstEthCsPktInfo->usEtherType); | ||
890 | } | ||
891 | |||
892 | |||
893 | |||
diff --git a/drivers/staging/bcm/Queue.h b/drivers/staging/bcm/Queue.h new file mode 100644 index 00000000000..e1f1da2bb6d --- /dev/null +++ b/drivers/staging/bcm/Queue.h | |||
@@ -0,0 +1,31 @@ | |||
1 | /************************************* | ||
2 | * Queue.h | ||
3 | **************************************/ | ||
4 | #ifndef __QUEUE_H__ | ||
5 | #define __QUEUE_H__ | ||
6 | |||
7 | |||
8 | |||
9 | #define ENQUEUEPACKET(_Head, _Tail,_Packet) \ | ||
10 | do \ | ||
11 | { \ | ||
12 | if (!_Head) { \ | ||
13 | _Head = _Packet; \ | ||
14 | } \ | ||
15 | else { \ | ||
16 | (_Tail)->next = _Packet; \ | ||
17 | } \ | ||
18 | (_Packet)->next = NULL; \ | ||
19 | _Tail = _Packet; \ | ||
20 | }while(0) | ||
21 | #define DEQUEUEPACKET(Head, Tail ) \ | ||
22 | do \ | ||
23 | { if(Head) \ | ||
24 | { \ | ||
25 | if (!Head->next) { \ | ||
26 | Tail = NULL; \ | ||
27 | } \ | ||
28 | Head = Head->next; \ | ||
29 | } \ | ||
30 | }while(0) | ||
31 | #endif //__QUEUE_H__ | ||
diff --git a/drivers/staging/bcm/TODO b/drivers/staging/bcm/TODO new file mode 100644 index 00000000000..366634be5fe --- /dev/null +++ b/drivers/staging/bcm/TODO | |||
@@ -0,0 +1,15 @@ | |||
1 | TODO: | ||
2 | - fix non-standard kernel style | ||
3 | - sparse warnings | ||
4 | - checkpatch warnings | ||
5 | - remove compatiablity code for older kernels | ||
6 | - remove #ifdef's | ||
7 | - fix bogus device nameing and reference counting (see bcm_notify_event) | ||
8 | - fix use of file I/O to load config | ||
9 | - request firmware | ||
10 | - update to current network device API | ||
11 | - merge some files together | ||
12 | - cleanup/eliminate debug messages | ||
13 | |||
14 | - integrate with existing Wimax stack? | ||
15 | |||
diff --git a/drivers/staging/bcm/Transmit.c b/drivers/staging/bcm/Transmit.c new file mode 100644 index 00000000000..9a076b54324 --- /dev/null +++ b/drivers/staging/bcm/Transmit.c | |||
@@ -0,0 +1,553 @@ | |||
1 | /** | ||
2 | @file Transmit.c | ||
3 | @defgroup tx_functions Transmission | ||
4 | @section Queueing | ||
5 | @dot | ||
6 | digraph transmit1 { | ||
7 | node[shape=box] | ||
8 | edge[weight=5;color=red] | ||
9 | bcm_transmit->reply_to_arp_request[label="ARP"] | ||
10 | bcm_transmit->GetPacketQueueIndex[label="IP Packet"] | ||
11 | GetPacketQueueIndex->IpVersion4[label="IPV4"] | ||
12 | GetPacketQueueIndex->IpVersion6[label="IPV6"] | ||
13 | } | ||
14 | |||
15 | @enddot | ||
16 | |||
17 | @section De-Queueing | ||
18 | @dot | ||
19 | digraph transmit2 { | ||
20 | node[shape=box] | ||
21 | edge[weight=5;color=red] | ||
22 | interrupt_service_thread->transmit_packets | ||
23 | tx_pkt_hdler->transmit_packets | ||
24 | transmit_packets->CheckAndSendPacketFromIndex | ||
25 | transmit_packets->UpdateTokenCount | ||
26 | CheckAndSendPacketFromIndex->PruneQueue | ||
27 | CheckAndSendPacketFromIndex->IsPacketAllowedForFlow | ||
28 | CheckAndSendPacketFromIndex->SendControlPacket[label="control pkt"] | ||
29 | SendControlPacket->bcm_cmd53 | ||
30 | CheckAndSendPacketFromIndex->SendPacketFromQueue[label="data pkt"] | ||
31 | SendPacketFromQueue->SetupNextSend->bcm_cmd53 | ||
32 | } | ||
33 | @enddot | ||
34 | */ | ||
35 | |||
36 | #include "headers.h" | ||
37 | |||
38 | /******************************************************************* | ||
39 | * Function - bcm_transmit() | ||
40 | * | ||
41 | * Description - This is the main transmit function for our virtual | ||
42 | * interface(veth0). It handles the ARP packets. It | ||
43 | * clones this packet and then Queue it to a suitable | ||
44 | * Queue. Then calls the transmit_packet(). | ||
45 | * | ||
46 | * Parameter - skb - Pointer to the socket buffer structure | ||
47 | * dev - Pointer to the virtual net device structure | ||
48 | * | ||
49 | * Returns - zero (success) or -ve value (failure) | ||
50 | * | ||
51 | *********************************************************************/ | ||
52 | |||
53 | INT bcm_transmit(struct sk_buff *skb, /**< skb */ | ||
54 | struct net_device *dev /**< net device pointer */ | ||
55 | ) | ||
56 | { | ||
57 | PMINI_ADAPTER Adapter = NULL; | ||
58 | USHORT qindex=0; | ||
59 | struct timeval tv; | ||
60 | UINT pkt_type = 0; | ||
61 | UINT calltransmit = 0; | ||
62 | |||
63 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_TX, TX_OSAL_DBG, DBG_LVL_ALL, "\n%s====>\n",__FUNCTION__); | ||
64 | |||
65 | memset(&tv, 0, sizeof(tv)); | ||
66 | /* Check for valid parameters */ | ||
67 | if(skb == NULL || dev==NULL) | ||
68 | { | ||
69 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_TX,TX_OSAL_DBG, DBG_LVL_ALL, "Got NULL skb or dev\n"); | ||
70 | return -EINVAL; | ||
71 | } | ||
72 | |||
73 | Adapter = GET_BCM_ADAPTER(dev); | ||
74 | if(!Adapter) | ||
75 | { | ||
76 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_TX, TX_OSAL_DBG, DBG_LVL_ALL, "Got Invalid Adapter\n"); | ||
77 | return -EINVAL; | ||
78 | } | ||
79 | if(Adapter->device_removed == TRUE || !Adapter->LinkUpStatus) | ||
80 | { | ||
81 | if(!netif_queue_stopped(dev)) { | ||
82 | netif_carrier_off(dev); | ||
83 | netif_stop_queue(dev); | ||
84 | } | ||
85 | return STATUS_FAILURE; | ||
86 | } | ||
87 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_TX, TX_OSAL_DBG, DBG_LVL_ALL, "Packet size : %d\n", skb->len); | ||
88 | |||
89 | /*Add Ethernet CS check here*/ | ||
90 | if(Adapter->TransferMode == IP_PACKET_ONLY_MODE ) | ||
91 | { | ||
92 | pkt_type = ntohs(*(PUSHORT)(skb->data + 12)); | ||
93 | /* Get the queue index where the packet is to be queued */ | ||
94 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_TX, TX_OSAL_DBG, DBG_LVL_ALL, "Getting the Queue Index....."); | ||
95 | |||
96 | qindex = GetPacketQueueIndex(Adapter,skb); | ||
97 | |||
98 | if((SHORT)INVALID_QUEUE_INDEX==(SHORT)qindex) | ||
99 | { | ||
100 | if(pkt_type == ETH_ARP_FRAME) | ||
101 | { | ||
102 | /* | ||
103 | Reply directly to ARP request packet | ||
104 | ARP Spoofing only if NO ETH CS rule matches for it | ||
105 | */ | ||
106 | BCM_DEBUG_PRINT (Adapter,DBG_TYPE_TX, TX_OSAL_DBG, DBG_LVL_ALL,"ARP OPCODE = %02x", | ||
107 | |||
108 | (*(PUCHAR)(skb->data + 21))); | ||
109 | |||
110 | reply_to_arp_request(skb); | ||
111 | |||
112 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_TX,TX_OSAL_DBG, DBG_LVL_ALL,"After reply_to_arp_request \n"); | ||
113 | |||
114 | } | ||
115 | else | ||
116 | { | ||
117 | BCM_DEBUG_PRINT (Adapter, DBG_TYPE_TX, TX_OSAL_DBG, DBG_LVL_ALL, | ||
118 | "Invalid queue index, dropping pkt\n"); | ||
119 | |||
120 | bcm_kfree_skb(skb); | ||
121 | } | ||
122 | return STATUS_SUCCESS; | ||
123 | } | ||
124 | |||
125 | if(Adapter->PackInfo[qindex].uiCurrentPacketsOnHost >= SF_MAX_ALLOWED_PACKETS_TO_BACKUP) | ||
126 | { | ||
127 | atomic_inc(&Adapter->TxDroppedPacketCount); | ||
128 | bcm_kfree_skb(skb); | ||
129 | return STATUS_SUCCESS; | ||
130 | } | ||
131 | |||
132 | /* Now Enqueue the packet */ | ||
133 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "bcm_transmit Enqueueing the Packet To Queue %d",qindex); | ||
134 | spin_lock(&Adapter->PackInfo[qindex].SFQueueLock); | ||
135 | Adapter->PackInfo[qindex].uiCurrentBytesOnHost += skb->len; | ||
136 | Adapter->PackInfo[qindex].uiCurrentPacketsOnHost++; | ||
137 | |||
138 | *((B_UINT32 *)skb->cb + SKB_CB_LATENCY_OFFSET ) = jiffies; | ||
139 | ENQUEUEPACKET(Adapter->PackInfo[qindex].FirstTxQueue, | ||
140 | Adapter->PackInfo[qindex].LastTxQueue, skb); | ||
141 | atomic_inc(&Adapter->TotalPacketCount); | ||
142 | spin_unlock(&Adapter->PackInfo[qindex].SFQueueLock); | ||
143 | do_gettimeofday(&tv); | ||
144 | |||
145 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_OSAL_DBG, DBG_LVL_ALL,"ENQ: \n"); | ||
146 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_OSAL_DBG, DBG_LVL_ALL, "Pkt Len = %d, sec: %ld, usec: %ld\n", | ||
147 | (skb->len-ETH_HLEN), tv.tv_sec, tv.tv_usec); | ||
148 | |||
149 | #ifdef BCM_SHM_INTERFACE | ||
150 | spin_lock(&Adapter->txtransmitlock); | ||
151 | if(Adapter->txtransmit_running == 0) | ||
152 | { | ||
153 | Adapter->txtransmit_running = 1; | ||
154 | calltransmit = 1; | ||
155 | } | ||
156 | else | ||
157 | calltransmit = 0; | ||
158 | |||
159 | spin_unlock(&Adapter->txtransmitlock); | ||
160 | #endif | ||
161 | if(calltransmit == 1) | ||
162 | transmit_packets(Adapter); | ||
163 | else | ||
164 | { | ||
165 | if(!atomic_read(&Adapter->TxPktAvail)) | ||
166 | { | ||
167 | atomic_set(&Adapter->TxPktAvail, 1); | ||
168 | #ifdef BCM_SHM_INTERFACE | ||
169 | virtual_mail_box_interrupt(); | ||
170 | #endif | ||
171 | wake_up(&Adapter->tx_packet_wait_queue); | ||
172 | } | ||
173 | } | ||
174 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_OSAL_DBG, DBG_LVL_ALL, "<===="); | ||
175 | } | ||
176 | else | ||
177 | bcm_kfree_skb(skb); | ||
178 | |||
179 | return STATUS_SUCCESS; | ||
180 | } | ||
181 | |||
182 | |||
183 | /** | ||
184 | @ingroup ctrl_pkt_functions | ||
185 | This function dispatches control packet to the h/w interface | ||
186 | @return zero(success) or -ve value(failure) | ||
187 | */ | ||
188 | INT SendControlPacket(PMINI_ADAPTER Adapter, /**<Logical Adapter*/ | ||
189 | char *pControlPacket/**<Control Packet*/ | ||
190 | ) | ||
191 | { | ||
192 | PLEADER PLeader = NULL; | ||
193 | struct timeval tv; | ||
194 | memset(&tv, 0, sizeof(tv)); | ||
195 | |||
196 | |||
197 | |||
198 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "========>"); | ||
199 | |||
200 | PLeader=(PLEADER)pControlPacket; | ||
201 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Tx"); | ||
202 | if(!pControlPacket || !Adapter) | ||
203 | { | ||
204 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Got NULL Control Packet or Adapter"); | ||
205 | return STATUS_FAILURE; | ||
206 | } | ||
207 | if((atomic_read( &Adapter->CurrNumFreeTxDesc ) < | ||
208 | ((PLeader->PLength-1)/MAX_DEVICE_DESC_SIZE)+1)) | ||
209 | { | ||
210 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "NO FREE DESCRIPTORS TO SEND CONTROL PACKET"); | ||
211 | if(Adapter->bcm_jiffies == 0) | ||
212 | { | ||
213 | Adapter->bcm_jiffies = jiffies; | ||
214 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "UPDATED TIME(hex): %lu", | ||
215 | Adapter->bcm_jiffies); | ||
216 | } | ||
217 | return STATUS_FAILURE; | ||
218 | } | ||
219 | |||
220 | /* Update the netdevice statistics */ | ||
221 | /* Dump Packet */ | ||
222 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Leader Status: %x", PLeader->Status); | ||
223 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Leader VCID: %x",PLeader->Vcid); | ||
224 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Leader Length: %x",PLeader->PLength); | ||
225 | if(Adapter->device_removed) | ||
226 | return 0; | ||
227 | #ifndef BCM_SHM_INTERFACE | ||
228 | Adapter->interface_transmit(Adapter->pvInterfaceAdapter, | ||
229 | pControlPacket, (PLeader->PLength + LEADER_SIZE)); | ||
230 | #else | ||
231 | tx_pkts_to_firmware(pControlPacket,(PLeader->PLength + LEADER_SIZE),1); | ||
232 | |||
233 | if(PLeader->Status==IDLE_MESSAGE) | ||
234 | { | ||
235 | if(((CONTROL_MESSAGE*)PLeader)->szData[0] == GO_TO_IDLE_MODE_PAYLOAD && | ||
236 | ((CONTROL_MESSAGE*)PLeader)->szData[1] == TARGET_CAN_GO_TO_IDLE_MODE) | ||
237 | { | ||
238 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Idle Mode Ack Sent to the Device\n"); | ||
239 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Host Entering into Idle Mode\n"); | ||
240 | do_gettimeofday(&tv); | ||
241 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "IdleMode Msg sent to f/w at time :%ld ms", tv.tv_sec *1000 + tv.tv_usec /1000); | ||
242 | if(Adapter->bDoSuspend != TRUE) | ||
243 | { | ||
244 | Adapter->IdleMode = TRUE; | ||
245 | Adapter->bPreparingForLowPowerMode = FALSE ; | ||
246 | } | ||
247 | } | ||
248 | } | ||
249 | if((PLeader->Status == LINK_UP_CONTROL_REQ) && | ||
250 | ((PUCHAR)pControlPacket)[sizeof(LEADER)] == LINK_UP_ACK && | ||
251 | ((PUCHAR)pControlPacket)[sizeof(LEADER)+1] == | ||
252 | LINK_SHUTDOWN_REQ_FROM_FIRMWARE && | ||
253 | ((PUCHAR)pControlPacket)[sizeof(LEADER)+2] == SHUTDOWN_ACK_FROM_DRIVER) | ||
254 | { | ||
255 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Shut Down ACK Sent and Host entering Shut State \n"); | ||
256 | if(Adapter->bDoSuspend != TRUE) | ||
257 | { | ||
258 | Adapter->bShutStatus = TRUE; | ||
259 | Adapter->bPreparingForLowPowerMode = FALSE; | ||
260 | Adapter->bTriedToWakeUpFromlowPowerMode = FALSE; | ||
261 | } | ||
262 | |||
263 | } | ||
264 | #endif | ||
265 | |||
266 | ((PLINUX_DEP_DATA)Adapter->pvOsDepData)->netstats.tx_packets++; | ||
267 | ((PLINUX_DEP_DATA)Adapter->pvOsDepData)->netstats.tx_bytes+= | ||
268 | PLeader->PLength; | ||
269 | atomic_dec(&Adapter->CurrNumFreeTxDesc); | ||
270 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "<========="); | ||
271 | return STATUS_SUCCESS; | ||
272 | } | ||
273 | static LEADER Leader={0}; | ||
274 | /** | ||
275 | @ingroup tx_functions | ||
276 | This function despatches the IP packets with the given vcid | ||
277 | to the target via the host h/w interface. | ||
278 | @return zero(success) or -ve value(failure) | ||
279 | */ | ||
280 | INT SetupNextSend(PMINI_ADAPTER Adapter, /**<Logical Adapter*/ | ||
281 | struct sk_buff *Packet, /**<data buffer*/ | ||
282 | USHORT Vcid) /**<VCID for this packet*/ | ||
283 | { | ||
284 | int status=0; | ||
285 | int dontfree = 0; | ||
286 | BOOLEAN bHeaderSupressionEnabled = FALSE; | ||
287 | B_UINT16 uiClassifierRuleID; | ||
288 | int QueueIndex = NO_OF_QUEUES + 1; | ||
289 | |||
290 | if(!Adapter || !Packet) | ||
291 | { | ||
292 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Got NULL Adapter or Packet"); | ||
293 | return -EINVAL; | ||
294 | } | ||
295 | if(Packet->len > MAX_DEVICE_DESC_SIZE) | ||
296 | { | ||
297 | status = STATUS_FAILURE; | ||
298 | goto errExit; | ||
299 | } | ||
300 | |||
301 | /* Get the Classifier Rule ID */ | ||
302 | uiClassifierRuleID = *((UINT32*) (Packet->cb)+SKB_CB_CLASSIFICATION_OFFSET); | ||
303 | QueueIndex = SearchVcid( Adapter,Vcid); | ||
304 | if(QueueIndex < NO_OF_QUEUES) | ||
305 | { | ||
306 | bHeaderSupressionEnabled = | ||
307 | Adapter->PackInfo[QueueIndex].bHeaderSuppressionEnabled; | ||
308 | bHeaderSupressionEnabled = | ||
309 | bHeaderSupressionEnabled & Adapter->bPHSEnabled; | ||
310 | } | ||
311 | if(Adapter->device_removed) | ||
312 | { | ||
313 | status = STATUS_FAILURE; | ||
314 | goto errExit; | ||
315 | } | ||
316 | |||
317 | status = PHSTransmit(Adapter, &Packet, Vcid, uiClassifierRuleID, bHeaderSupressionEnabled, | ||
318 | (UINT *)&Packet->len, Adapter->PackInfo[QueueIndex].bEthCSSupport); | ||
319 | |||
320 | if(status != STATUS_SUCCESS) | ||
321 | { | ||
322 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "PHS Transmit failed..\n"); | ||
323 | goto errExit; | ||
324 | } | ||
325 | |||
326 | Leader.Vcid = Vcid; | ||
327 | |||
328 | if(TCP_ACK == *((UINT32*) (Packet->cb) + SKB_CB_TCPACK_OFFSET )) | ||
329 | { | ||
330 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Sending TCP ACK\n"); | ||
331 | Leader.Status = LEADER_STATUS_TCP_ACK; | ||
332 | } | ||
333 | else | ||
334 | { | ||
335 | Leader.Status = LEADER_STATUS; | ||
336 | } | ||
337 | |||
338 | if(Adapter->PackInfo[QueueIndex].bEthCSSupport) | ||
339 | { | ||
340 | Leader.PLength = Packet->len; | ||
341 | if(skb_headroom(Packet) < LEADER_SIZE) | ||
342 | { | ||
343 | if((status = skb_cow(Packet,LEADER_SIZE))) | ||
344 | { | ||
345 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL,"bcm_transmit : Failed To Increase headRoom\n"); | ||
346 | goto errExit; | ||
347 | } | ||
348 | } | ||
349 | skb_push(Packet, LEADER_SIZE); | ||
350 | memcpy(Packet->data, &Leader, LEADER_SIZE); | ||
351 | } | ||
352 | |||
353 | else | ||
354 | { | ||
355 | Leader.PLength = Packet->len - ETH_HLEN; | ||
356 | memcpy((LEADER*)skb_pull(Packet, (ETH_HLEN - LEADER_SIZE)), &Leader, LEADER_SIZE); | ||
357 | } | ||
358 | |||
359 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Packet->len = %d", Packet->len); | ||
360 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Vcid = %d", Vcid); | ||
361 | |||
362 | #ifndef BCM_SHM_INTERFACE | ||
363 | status = Adapter->interface_transmit(Adapter->pvInterfaceAdapter, | ||
364 | Packet->data, (Leader.PLength + LEADER_SIZE)); | ||
365 | #else | ||
366 | status = tx_pkts_to_firmware(Packet,Packet->len,0); | ||
367 | #endif | ||
368 | if(status) | ||
369 | { | ||
370 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Tx Failed..\n"); | ||
371 | } | ||
372 | else | ||
373 | { | ||
374 | Adapter->PackInfo[QueueIndex].uiTotalTxBytes += Leader.PLength; | ||
375 | atomic_add(Leader.PLength, &Adapter->GoodTxByteCount); | ||
376 | atomic_inc(&Adapter->TxTotalPacketCount); | ||
377 | #ifdef GDMA_INTERFACE | ||
378 | dontfree = 1; | ||
379 | #endif | ||
380 | } | ||
381 | |||
382 | atomic_dec(&Adapter->CurrNumFreeTxDesc); | ||
383 | |||
384 | errExit: | ||
385 | |||
386 | if(STATUS_SUCCESS == status) | ||
387 | { | ||
388 | Adapter->PackInfo[QueueIndex].uiCurrentTokenCount -= Leader.PLength << 3; | ||
389 | Adapter->PackInfo[QueueIndex].uiSentBytes += (Packet->len); | ||
390 | Adapter->PackInfo[QueueIndex].uiSentPackets++; | ||
391 | Adapter->PackInfo[QueueIndex].NumOfPacketsSent++; | ||
392 | |||
393 | atomic_dec(&Adapter->PackInfo[QueueIndex].uiPerSFTxResourceCount); | ||
394 | #ifdef BCM_SHM_INTERFACE | ||
395 | if(atomic_read(&Adapter->PackInfo[QueueIndex].uiPerSFTxResourceCount) < 0) | ||
396 | { | ||
397 | atomic_set(&Adapter->PackInfo[QueueIndex].uiPerSFTxResourceCount, 0); | ||
398 | } | ||
399 | #endif | ||
400 | Adapter->PackInfo[QueueIndex].uiThisPeriodSentBytes += Leader.PLength; | ||
401 | } | ||
402 | |||
403 | |||
404 | #ifdef GDMA_INTERFACE | ||
405 | if(!dontfree){ | ||
406 | bcm_kfree_skb(Packet); | ||
407 | } | ||
408 | #else | ||
409 | bcm_kfree_skb(Packet); | ||
410 | #endif | ||
411 | return status; | ||
412 | } | ||
413 | |||
414 | /** | ||
415 | @ingroup tx_functions | ||
416 | Transmit thread | ||
417 | */ | ||
418 | int tx_pkt_handler(PMINI_ADAPTER Adapter /**< pointer to adapter object*/ | ||
419 | ) | ||
420 | { | ||
421 | #ifndef BCM_SHM_INTERFACE | ||
422 | int status = 0; | ||
423 | #endif | ||
424 | |||
425 | UINT calltransmit = 1; | ||
426 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Entring to wait for signal from the interrupt service thread!Adapter = 0x%x",(unsigned int) Adapter); | ||
427 | |||
428 | |||
429 | while(1) | ||
430 | { | ||
431 | if(Adapter->LinkUpStatus){ | ||
432 | wait_event_timeout(Adapter->tx_packet_wait_queue, | ||
433 | ((atomic_read(&Adapter->TxPktAvail) && | ||
434 | (MINIMUM_PENDING_DESCRIPTORS < | ||
435 | atomic_read(&Adapter->CurrNumFreeTxDesc)) && | ||
436 | (Adapter->device_removed == FALSE))) || | ||
437 | (1 == Adapter->downloadDDR) || kthread_should_stop() | ||
438 | #ifndef BCM_SHM_INTERFACE | ||
439 | || (TRUE == Adapter->bEndPointHalted) | ||
440 | #endif | ||
441 | , msecs_to_jiffies(10)); | ||
442 | } | ||
443 | else{ | ||
444 | wait_event(Adapter->tx_packet_wait_queue, | ||
445 | ((atomic_read(&Adapter->TxPktAvail) && | ||
446 | (MINIMUM_PENDING_DESCRIPTORS < | ||
447 | atomic_read(&Adapter->CurrNumFreeTxDesc)) && | ||
448 | (Adapter->device_removed == FALSE))) || | ||
449 | (1 == Adapter->downloadDDR) || kthread_should_stop() | ||
450 | #ifndef BCM_SHM_INTERFACE | ||
451 | || (TRUE == Adapter->bEndPointHalted) | ||
452 | #endif | ||
453 | ); | ||
454 | } | ||
455 | |||
456 | if(kthread_should_stop() || Adapter->device_removed) | ||
457 | { | ||
458 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Exiting the tx thread..\n"); | ||
459 | Adapter->transmit_packet_thread = NULL; | ||
460 | return 0; | ||
461 | } | ||
462 | |||
463 | #ifndef BCM_SHM_INTERFACE | ||
464 | |||
465 | if(Adapter->downloadDDR == 1) | ||
466 | { | ||
467 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Downloading DDR Settings\n"); | ||
468 | Adapter->downloadDDR +=1; | ||
469 | status = download_ddr_settings(Adapter); | ||
470 | if(status) | ||
471 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "DDR DOWNLOAD FAILED!\n"); | ||
472 | continue; | ||
473 | } | ||
474 | |||
475 | //Check end point for halt/stall. | ||
476 | if(Adapter->bEndPointHalted == TRUE) | ||
477 | { | ||
478 | Bcm_clear_halt_of_endpoints(Adapter); | ||
479 | Adapter->bEndPointHalted = FALSE; | ||
480 | StartInterruptUrb((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter)); | ||
481 | } | ||
482 | |||
483 | if(Adapter->LinkUpStatus && !Adapter->IdleMode) | ||
484 | { | ||
485 | if(atomic_read(&Adapter->TotalPacketCount)) | ||
486 | { | ||
487 | update_per_sf_desc_cnts(Adapter); | ||
488 | } | ||
489 | } | ||
490 | #endif | ||
491 | |||
492 | if( atomic_read(&Adapter->CurrNumFreeTxDesc) && | ||
493 | Adapter->LinkStatus == SYNC_UP_REQUEST && | ||
494 | !Adapter->bSyncUpRequestSent) | ||
495 | { | ||
496 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Calling LinkMessage"); | ||
497 | LinkMessage(Adapter); | ||
498 | } | ||
499 | |||
500 | if((Adapter->IdleMode || Adapter->bShutStatus) && atomic_read(&Adapter->TotalPacketCount)) | ||
501 | { | ||
502 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Device in Low Power mode...waking up"); | ||
503 | Adapter->usIdleModePattern = ABORT_IDLE_MODE; | ||
504 | Adapter->bWakeUpDevice = TRUE; | ||
505 | wake_up(&Adapter->process_rx_cntrlpkt); | ||
506 | } | ||
507 | |||
508 | #ifdef BCM_SHM_INTERFACE | ||
509 | spin_lock_bh(&Adapter->txtransmitlock); | ||
510 | if(Adapter->txtransmit_running == 0) | ||
511 | { | ||
512 | Adapter->txtransmit_running = 1; | ||
513 | calltransmit = 1; | ||
514 | } | ||
515 | else | ||
516 | calltransmit = 0; | ||
517 | spin_unlock_bh(&Adapter->txtransmitlock); | ||
518 | #endif | ||
519 | |||
520 | if(calltransmit) | ||
521 | transmit_packets(Adapter); | ||
522 | |||
523 | atomic_set(&Adapter->TxPktAvail, 0); | ||
524 | } | ||
525 | return 0; | ||
526 | } | ||
527 | |||
528 | #ifdef BCM_SHM_INTERFACE | ||
529 | extern PMINI_ADAPTER psAdaptertest; | ||
530 | void virtual_mail_box_interrupt(void) | ||
531 | { | ||
532 | |||
533 | #ifndef GDMA_INTERFACE | ||
534 | PUINT ptr = (PUINT)CPE_VIRTUAL_MAILBOX_REG; | ||
535 | UINT intval = (UINT)((*ptr & 0xFF00) >> 8); | ||
536 | if (intval != 0) | ||
537 | { | ||
538 | atomic_set(&psAdaptertest->CurrNumFreeTxDesc, intval); | ||
539 | atomic_set (&psAdaptertest->uiMBupdate, TRUE); | ||
540 | |||
541 | //make it to 0 | ||
542 | *ptr = *ptr & 0xffff00ff; | ||
543 | } | ||
544 | #endif | ||
545 | } | ||
546 | unsigned int total_tx_pkts_pending(void) | ||
547 | { | ||
548 | return atomic_read(&psAdaptertest->TotalPacketCount); | ||
549 | } | ||
550 | |||
551 | #endif | ||
552 | |||
553 | |||
diff --git a/drivers/staging/bcm/Typedefs.h b/drivers/staging/bcm/Typedefs.h new file mode 100644 index 00000000000..a985abf194f --- /dev/null +++ b/drivers/staging/bcm/Typedefs.h | |||
@@ -0,0 +1,47 @@ | |||
1 | /**************************** | ||
2 | * Typedefs.h | ||
3 | ****************************/ | ||
4 | #ifndef __TYPEDEFS_H__ | ||
5 | #define __TYPEDEFS_H__ | ||
6 | #define STATUS_SUCCESS 0 | ||
7 | #define STATUS_FAILURE -1 | ||
8 | |||
9 | #define FALSE 0 | ||
10 | #define TRUE 1 | ||
11 | |||
12 | typedef char BOOLEAN; | ||
13 | typedef char CHAR; | ||
14 | typedef int INT; | ||
15 | typedef short SHORT; | ||
16 | typedef long LONG; | ||
17 | typedef void VOID; | ||
18 | |||
19 | typedef unsigned char UCHAR; | ||
20 | typedef unsigned char B_UINT8; | ||
21 | typedef unsigned short USHORT; | ||
22 | typedef unsigned short B_UINT16; | ||
23 | typedef unsigned int UINT; | ||
24 | typedef unsigned int B_UINT32; | ||
25 | typedef unsigned long ULONG; | ||
26 | typedef unsigned long DWORD; | ||
27 | |||
28 | typedef char* PCHAR; | ||
29 | typedef short* PSHORT; | ||
30 | typedef int* PINT; | ||
31 | typedef long* PLONG; | ||
32 | typedef void* PVOID; | ||
33 | |||
34 | typedef unsigned char* PUCHAR; | ||
35 | typedef unsigned short* PUSHORT; | ||
36 | typedef unsigned int* PUINT; | ||
37 | typedef unsigned long* PULONG; | ||
38 | typedef unsigned long long ULONG64; | ||
39 | typedef unsigned long long LARGE_INTEGER; | ||
40 | typedef unsigned int UINT32; | ||
41 | #ifndef NULL | ||
42 | #define NULL 0 | ||
43 | #endif | ||
44 | |||
45 | |||
46 | #endif //__TYPEDEFS_H__ | ||
47 | |||
diff --git a/drivers/staging/bcm/Version.h b/drivers/staging/bcm/Version.h new file mode 100644 index 00000000000..a07b956b9ff --- /dev/null +++ b/drivers/staging/bcm/Version.h | |||
@@ -0,0 +1,35 @@ | |||
1 | |||
2 | /*Copyright (c) 2005 Beceem Communications Inc. | ||
3 | |||
4 | Module Name: | ||
5 | |||
6 | Version.h | ||
7 | |||
8 | Abstract: | ||
9 | |||
10 | |||
11 | --*/ | ||
12 | |||
13 | #ifndef VERSION_H | ||
14 | #define VERSION_H | ||
15 | |||
16 | |||
17 | #define VER_FILETYPE VFT_DRV | ||
18 | #define VER_FILESUBTYPE VFT2_DRV_NETWORK | ||
19 | |||
20 | |||
21 | #define VER_FILEVERSION 5.2.45 | ||
22 | #define VER_FILEVERSION_STR "5.2.45" | ||
23 | |||
24 | #undef VER_PRODUCTVERSION | ||
25 | #define VER_PRODUCTVERSION VER_FILEVERSION | ||
26 | |||
27 | #undef VER_PRODUCTVERSION_STR | ||
28 | #define VER_PRODUCTVERSION_STR VER_FILEVERSION_STR | ||
29 | |||
30 | |||
31 | |||
32 | |||
33 | //#include "common.ver" | ||
34 | |||
35 | #endif //VERSION_H | ||
diff --git a/drivers/staging/bcm/cntrl_SignalingInterface.h b/drivers/staging/bcm/cntrl_SignalingInterface.h new file mode 100644 index 00000000000..4cbe3002224 --- /dev/null +++ b/drivers/staging/bcm/cntrl_SignalingInterface.h | |||
@@ -0,0 +1,677 @@ | |||
1 | #ifndef CNTRL_SIGNALING_INTERFACE_ | ||
2 | #define CNTRL_SIGNALING_INTERFACE_ | ||
3 | |||
4 | |||
5 | #ifdef BECEEM_TARGET | ||
6 | |||
7 | #include <mac_common.h> | ||
8 | #include <msg_Dsa.h> | ||
9 | #include <msg_Dsc.h> | ||
10 | #include <msg_Dsd.h> | ||
11 | #include <sch_definitions.h> | ||
12 | using namespace Beceem; | ||
13 | #ifdef ENABLE_CORRIGENDUM2_UPDATE | ||
14 | extern B_UINT32 g_u32Corr2MacFlags; | ||
15 | #endif | ||
16 | |||
17 | #else | ||
18 | |||
19 | |||
20 | #define DSA_REQ 11 | ||
21 | #define DSA_RSP 12 | ||
22 | #define DSA_ACK 13 | ||
23 | #define DSC_REQ 14 | ||
24 | #define DSC_RSP 15 | ||
25 | #define DSC_ACK 16 | ||
26 | #define DSD_REQ 17 | ||
27 | #define DSD_RSP 18 | ||
28 | #define DSD_ACK 19 | ||
29 | #define MAX_CLASSIFIERS_IN_SF 4 | ||
30 | |||
31 | #endif | ||
32 | |||
33 | #define MAX_STRING_LEN 20 | ||
34 | #define MAX_PHS_LENGTHS 255 | ||
35 | #define VENDOR_PHS_PARAM_LENGTH 10 | ||
36 | #define MAX_NUM_ACTIVE_BS 10 | ||
37 | #define AUTH_TOKEN_LENGTH 10 | ||
38 | #define NUM_HARQ_CHANNELS 16 //Changed from 10 to 16 to accomodate all HARQ channels | ||
39 | #define VENDOR_CLASSIFIER_PARAM_LENGTH 1 //Changed the size to 1 byte since we dnt use it | ||
40 | #define VENDOR_SPECIF_QOS_PARAM 1 | ||
41 | #define VENDOR_PHS_PARAM_LENGTH 10 | ||
42 | #define MBS_CONTENTS_ID_LENGTH 10 | ||
43 | #define GLOBAL_SF_CLASSNAME_LENGTH 6 | ||
44 | |||
45 | #define TYPE_OF_SERVICE_LENGTH 3 | ||
46 | #define IP_MASKED_SRC_ADDRESS_LENGTH 32 | ||
47 | #define IP_MASKED_DEST_ADDRESS_LENGTH 32 | ||
48 | #define PROTOCOL_SRC_PORT_RANGE_LENGTH 4 | ||
49 | #define PROTOCOL_DEST_PORT_RANGE_LENGTH 4 | ||
50 | #define ETHERNET_DEST_MAC_ADDR_LENGTH 12 | ||
51 | #define ETHERNET_SRC_MAC_ADDR_LENGTH 12 | ||
52 | #define NUM_ETHERTYPE_BYTES 3 | ||
53 | #define NUM_IPV6_FLOWLABLE_BYTES 3 | ||
54 | |||
55 | |||
56 | //////////////////////////////////////////////////////////////////////////////// | ||
57 | ////////////////////////structure Definitions/////////////////////////////////// | ||
58 | //////////////////////////////////////////////////////////////////////////////// | ||
59 | /// \brief class cCPacketClassificationRule | ||
60 | #ifdef BECEEM_TARGET | ||
61 | class CCPacketClassificationRuleSI{ | ||
62 | public: | ||
63 | /// \brief Constructor for the class | ||
64 | CCPacketClassificationRuleSI(): | ||
65 | u8ClassifierRulePriority(mClassifierRulePriority), | ||
66 | u8IPTypeOfServiceLength(mIPTypeOfService), | ||
67 | u8Protocol(mProtocol), | ||
68 | u8IPMaskedSourceAddressLength(0), | ||
69 | u8IPDestinationAddressLength(0), | ||
70 | u8ProtocolSourcePortRangeLength(0), | ||
71 | u8ProtocolDestPortRangeLength(0), | ||
72 | u8EthernetDestMacAddressLength(0), | ||
73 | u8EthernetSourceMACAddressLength(0), | ||
74 | u8EthertypeLength(0), | ||
75 | u16UserPriority(mUserPriority), | ||
76 | u16VLANID(mVLANID), | ||
77 | u8AssociatedPHSI(mAssociatedPHSI), | ||
78 | u16PacketClassificationRuleIndex(mPacketClassifierRuleIndex), | ||
79 | u8VendorSpecificClassifierParamLength(mVendorSpecificClassifierParamLength), | ||
80 | u8IPv6FlowLableLength(mIPv6FlowLableLength), | ||
81 | u8ClassifierActionRule(mClassifierActionRule) | ||
82 | |||
83 | {} | ||
84 | void Reset() | ||
85 | { | ||
86 | CCPacketClassificationRuleSI(); | ||
87 | } | ||
88 | #else | ||
89 | struct _stCPacketClassificationRuleSI{ | ||
90 | #endif | ||
91 | |||
92 | /** 16bit UserPriority Of The Service Flow*/ | ||
93 | B_UINT16 u16UserPriority; | ||
94 | /** 16bit VLANID Of The Service Flow*/ | ||
95 | B_UINT16 u16VLANID; | ||
96 | /** 16bit Packet Classification RuleIndex Of The Service Flow*/ | ||
97 | B_UINT16 u16PacketClassificationRuleIndex; | ||
98 | /** 8bit Classifier Rule Priority Of The Service Flow*/ | ||
99 | B_UINT8 u8ClassifierRulePriority; | ||
100 | /** Length of IP TypeOfService field*/ | ||
101 | B_UINT8 u8IPTypeOfServiceLength; | ||
102 | /** 3bytes IP TypeOfService */ | ||
103 | B_UINT8 u8IPTypeOfService[TYPE_OF_SERVICE_LENGTH]; | ||
104 | /** Protocol used in classification of Service Flow*/ | ||
105 | B_UINT8 u8Protocol; | ||
106 | /** Length of IP Masked Source Address */ | ||
107 | B_UINT8 u8IPMaskedSourceAddressLength; | ||
108 | /** IP Masked Source Address used in classification for the Service Flow*/ | ||
109 | B_UINT8 u8IPMaskedSourceAddress[IP_MASKED_SRC_ADDRESS_LENGTH]; | ||
110 | /** Length of IP Destination Address */ | ||
111 | B_UINT8 u8IPDestinationAddressLength; | ||
112 | /** IP Destination Address used in classification for the Service Flow*/ | ||
113 | B_UINT8 u8IPDestinationAddress[IP_MASKED_DEST_ADDRESS_LENGTH]; | ||
114 | /** Length of Protocol Source Port Range */ | ||
115 | B_UINT8 u8ProtocolSourcePortRangeLength; | ||
116 | /** Protocol Source Port Range used in the Service Flow*/ | ||
117 | B_UINT8 u8ProtocolSourcePortRange[PROTOCOL_SRC_PORT_RANGE_LENGTH]; | ||
118 | /** Length of Protocol Dest Port Range */ | ||
119 | B_UINT8 u8ProtocolDestPortRangeLength; | ||
120 | /** Protocol Dest Port Range used in the Service Flow*/ | ||
121 | B_UINT8 u8ProtocolDestPortRange[PROTOCOL_DEST_PORT_RANGE_LENGTH]; | ||
122 | /** Length of Ethernet Destination MAC Address */ | ||
123 | B_UINT8 u8EthernetDestMacAddressLength; | ||
124 | /** Ethernet Destination MAC Address used in classification of the Service Flow*/ | ||
125 | B_UINT8 u8EthernetDestMacAddress[ETHERNET_DEST_MAC_ADDR_LENGTH]; | ||
126 | /** Length of Ethernet Source MAC Address */ | ||
127 | B_UINT8 u8EthernetSourceMACAddressLength; | ||
128 | /** Ethernet Source MAC Address used in classification of the Service Flow*/ | ||
129 | B_UINT8 u8EthernetSourceMACAddress[ETHERNET_SRC_MAC_ADDR_LENGTH]; | ||
130 | /** Length of Ethertype */ | ||
131 | B_UINT8 u8EthertypeLength; | ||
132 | /** 3bytes Ethertype Of The Service Flow*/ | ||
133 | B_UINT8 u8Ethertype[NUM_ETHERTYPE_BYTES]; | ||
134 | /** 8bit Associated PHSI Of The Service Flow*/ | ||
135 | B_UINT8 u8AssociatedPHSI; | ||
136 | /** Length of Vendor Specific Classifier Param length Of The Service Flow*/ | ||
137 | B_UINT8 u8VendorSpecificClassifierParamLength; | ||
138 | /** Vendor Specific Classifier Param Of The Service Flow*/ | ||
139 | B_UINT8 u8VendorSpecificClassifierParam[VENDOR_CLASSIFIER_PARAM_LENGTH]; | ||
140 | /** Length Of IPv6 Flow Lable of the Service Flow*/ | ||
141 | B_UINT8 u8IPv6FlowLableLength; | ||
142 | /** IPv6 Flow Lable Of The Service Flow*/ | ||
143 | B_UINT8 u8IPv6FlowLable[NUM_IPV6_FLOWLABLE_BYTES]; | ||
144 | /** Action associated with the classifier rule*/ | ||
145 | B_UINT8 u8ClassifierActionRule; | ||
146 | B_UINT16 u16ValidityBitMap; | ||
147 | }; | ||
148 | #ifndef BECEEM_TARGET | ||
149 | typedef struct _stCPacketClassificationRuleSI CCPacketClassificationRuleSI,stCPacketClassificationRuleSI, *pstCPacketClassificationRuleSI; | ||
150 | #endif | ||
151 | |||
152 | /// \brief class CPhsRuleSI | ||
153 | #ifdef BECEEM_TARGET | ||
154 | class CPhsRuleSI{ | ||
155 | public: | ||
156 | /// \brief Constructor for the class | ||
157 | CPhsRuleSI(): | ||
158 | u8PHSI(mPHSI), | ||
159 | u8PHSFLength(0), | ||
160 | u8PHSMLength(0), | ||
161 | u8PHSS(mPHSS), | ||
162 | u8PHSV(mPHSV), | ||
163 | u8VendorSpecificPHSParamsLength(mVendorSpecificPHSParamLength){} | ||
164 | void Reset() | ||
165 | { | ||
166 | CPhsRuleSI(); | ||
167 | } | ||
168 | #else | ||
169 | typedef struct _stPhsRuleSI { | ||
170 | #endif | ||
171 | /** 8bit PHS Index Of The Service Flow*/ | ||
172 | B_UINT8 u8PHSI; | ||
173 | /** PHSF Length Of The Service Flow*/ | ||
174 | B_UINT8 u8PHSFLength; | ||
175 | /** String of bytes containing header information to be supressed by the sending CS and reconstructed by the receiving CS*/ | ||
176 | B_UINT8 u8PHSF[MAX_PHS_LENGTHS]; | ||
177 | /** PHSM Length Of The Service Flow*/ | ||
178 | B_UINT8 u8PHSMLength; | ||
179 | /** PHS Mask for the SF*/ | ||
180 | B_UINT8 u8PHSM[MAX_PHS_LENGTHS]; | ||
181 | /** 8bit Total number of bytes to be supressed for the Service Flow*/ | ||
182 | B_UINT8 u8PHSS; | ||
183 | /** 8bit Indicates whether or not Packet Header contents need to be verified prior to supression */ | ||
184 | B_UINT8 u8PHSV; | ||
185 | /** Vendor Specific PHS param Length Of The Service Flow*/ | ||
186 | B_UINT8 u8VendorSpecificPHSParamsLength; | ||
187 | /** Vendor Specific PHS param Of The Service Flow*/ | ||
188 | B_UINT8 u8VendorSpecificPHSParams[VENDOR_PHS_PARAM_LENGTH]; | ||
189 | |||
190 | B_UINT8 u8Padding[2]; | ||
191 | #ifdef BECEEM_TARGET | ||
192 | }; | ||
193 | #else | ||
194 | }stPhsRuleSI,*pstPhsRuleSI; | ||
195 | typedef stPhsRuleSI CPhsRuleSI; | ||
196 | #endif | ||
197 | |||
198 | /// \brief structure cConvergenceSLTypes | ||
199 | #ifdef BECEEM_TARGET | ||
200 | class CConvergenceSLTypes{ | ||
201 | public: | ||
202 | /// \brief Constructor for the class | ||
203 | CConvergenceSLTypes(): | ||
204 | u8ClassfierDSCAction(mClassifierDSCAction), | ||
205 | u8PhsDSCAction (mPhsDSCAction) | ||
206 | {} | ||
207 | void Reset() | ||
208 | { | ||
209 | CConvergenceSLTypes(); | ||
210 | cCPacketClassificationRule.Reset(); | ||
211 | cPhsRule.Reset(); | ||
212 | } | ||
213 | #else | ||
214 | struct _stConvergenceSLTypes{ | ||
215 | #endif | ||
216 | /** 8bit Phs Classfier Action Of The Service Flow*/ | ||
217 | B_UINT8 u8ClassfierDSCAction; | ||
218 | /** 8bit Phs DSC Action Of The Service Flow*/ | ||
219 | B_UINT8 u8PhsDSCAction; | ||
220 | /** 16bit Padding */ | ||
221 | B_UINT8 u8Padding[2]; | ||
222 | /// \brief class cCPacketClassificationRule | ||
223 | #ifdef BECEEM_TARGET | ||
224 | CCPacketClassificationRuleSI cCPacketClassificationRule; | ||
225 | #else | ||
226 | stCPacketClassificationRuleSI cCPacketClassificationRule; | ||
227 | #endif | ||
228 | /// \brief class CPhsRuleSI | ||
229 | #ifdef BECEEM_TARGET | ||
230 | CPhsRuleSI cPhsRule; | ||
231 | #else | ||
232 | struct _stPhsRuleSI cPhsRule; | ||
233 | #endif | ||
234 | }; | ||
235 | #ifndef BECEEM_TARGET | ||
236 | typedef struct _stConvergenceSLTypes stConvergenceSLTypes,CConvergenceSLTypes, *pstConvergenceSLTypes; | ||
237 | #endif | ||
238 | |||
239 | |||
240 | /// \brief structure CServiceFlowParamSI | ||
241 | #ifdef BECEEM_TARGET | ||
242 | class CServiceFlowParamSI{ | ||
243 | public: | ||
244 | /// \brief Constructor for the class | ||
245 | CServiceFlowParamSI(): | ||
246 | u32SFID(mSFid), | ||
247 | u16CID(mCid), | ||
248 | u8ServiceClassNameLength(mServiceClassNameLength), | ||
249 | u8MBSService(mMBSService), | ||
250 | u8QosParamSet(mQosParamSetType), | ||
251 | u8TrafficPriority(mTrafficPriority), | ||
252 | u32MaxSustainedTrafficRate(mMaximumSustainedTrafficRate), | ||
253 | u32MaxTrafficBurst(mMaximumTrafficBurst), | ||
254 | u32MinReservedTrafficRate(mMinimumReservedTrafficRate), | ||
255 | u8ServiceFlowSchedulingType(mServiceFlowSchedulingType), | ||
256 | u8RequesttransmissionPolicy(mRequestTransmissionPolicy), | ||
257 | u32ToleratedJitter(mToleratedJitter), | ||
258 | u32MaximumLatency(mMaximumLatency), | ||
259 | u8FixedLengthVSVariableLengthSDUIndicator | ||
260 | (mFixedLengthVSVariableLength), | ||
261 | u8SDUSize(mSDUSize), | ||
262 | u16TargetSAID(mTargetSAID), | ||
263 | u8ARQEnable(mARQEnable), | ||
264 | u16ARQWindowSize(mARQWindowSize), | ||
265 | u16ARQBlockLifeTime(mARQBlockLifeTime), | ||
266 | u16ARQSyncLossTimeOut(mARQSyncLossTimeOut), | ||
267 | u8ARQDeliverInOrder(mARQDeliverInOrder), | ||
268 | u16ARQRxPurgeTimeOut(mARQRXPurgeTimeOut), | ||
269 | //Add ARQ BLOCK SIZE, ARQ TX and RX delay initializations here | ||
270 | //after we move to only CORR2 | ||
271 | u8RxARQAckProcessingTime(mRxARQAckProcessingTime), | ||
272 | u8CSSpecification(mCSSpecification), | ||
273 | u8TypeOfDataDeliveryService(mTypeOfDataDeliveryService), | ||
274 | u16SDUInterArrivalTime(mSDUInterArrivalTime), | ||
275 | u16TimeBase(mTimeBase), | ||
276 | u8PagingPreference(mPagingPreference), | ||
277 | u8MBSZoneIdentifierassignment(mMBSZoneIdentifierassignmentLength), | ||
278 | u8TrafficIndicationPreference(mTrafficIndicationPreference), | ||
279 | u8GlobalServicesClassNameLength(mGlobalServicesClassNameLength), | ||
280 | u8SNFeedbackEnabled(mSNFeedbackEnabled), | ||
281 | u8FSNSize(mFSNSize), | ||
282 | u8CIDAllocation4activeBSsLength(mCIDAllocation4activeBSsLength), | ||
283 | u16UnsolicitedGrantInterval(mUnsolicitedGrantInterval), | ||
284 | u16UnsolicitedPollingInterval(mUnsolicitedPollingInterval), | ||
285 | u8PDUSNExtendedSubheader4HarqReordering(mPDUSNExtendedSubheader4HarqReordering), | ||
286 | u8MBSContentsIDLength(mMBSContentsIDLength), | ||
287 | u8HARQServiceFlows(mHARQServiceFlows), | ||
288 | u8AuthTokenLength(mAuthTokenLength), | ||
289 | u8HarqChannelMappingLength(mHarqChannelMappingLength), | ||
290 | u8VendorSpecificQoSParamLength(mVendorSpecificQoSParamLength), | ||
291 | bValid(FALSE), | ||
292 | u8TotalClassifiers() | ||
293 | { | ||
294 | //Remove the bolck after we move to Corr2 only code | ||
295 | #ifdef ENABLE_CORRIGENDUM2_UPDATE | ||
296 | if((g_u32Corr2MacFlags & CORR_2_DSX) || (g_u32Corr2MacFlags & CORR_2_ARQ)) | ||
297 | { | ||
298 | /* IEEE Comment #627 / MTG Comment #426 */ | ||
299 | u16ARQBlockSize = mARQBlockSize; | ||
300 | if(g_u32Corr2MacFlags & CORR_2_ARQ) { | ||
301 | u16ARQRetryTxTimeOut = mARQRetryTimeOutTxDelay; | ||
302 | if(g_u32VENDOR_TYPE == VENDOR_ALCATEL) { | ||
303 | u16ARQRetryRxTimeOut = mARQRetryTimeOutRxDelay_ALU; | ||
304 | } else { | ||
305 | u16ARQRetryRxTimeOut = mARQRetryTimeOutRxDelay; | ||
306 | } | ||
307 | } | ||
308 | else | ||
309 | { | ||
310 | u16ARQRetryTxTimeOut = mARQRetryTimeOutTxDelayCorr1; | ||
311 | u16ARQRetryRxTimeOut = mARQRetryTimeOutRxDelayCorr1; | ||
312 | } | ||
313 | } | ||
314 | else | ||
315 | #endif | ||
316 | { | ||
317 | u16ARQBlockSize = mARQBlockSizeCorr1; | ||
318 | u16ARQRetryTxTimeOut = mARQRetryTimeOutTxDelayCorr1; | ||
319 | u16ARQRetryRxTimeOut = mARQRetryTimeOutRxDelayCorr1; | ||
320 | } | ||
321 | } | ||
322 | |||
323 | void ComputeMacOverhead(B_UINT8 u8SecOvrhead); | ||
324 | B_UINT16 GetMacOverhead() { return u16MacOverhead; } | ||
325 | #else | ||
326 | typedef struct _stServiceFlowParamSI{ | ||
327 | #endif //end of ifdef BECEEM_TARGET | ||
328 | |||
329 | /** 32bitSFID Of The Service Flow*/ | ||
330 | B_UINT32 u32SFID; | ||
331 | |||
332 | /** 32bit Maximum Sustained Traffic Rate of the Service Flow*/ | ||
333 | B_UINT32 u32MaxSustainedTrafficRate; | ||
334 | |||
335 | /** 32bit Maximum Traffic Burst allowed for the Service Flow*/ | ||
336 | B_UINT32 u32MaxTrafficBurst; | ||
337 | |||
338 | /** 32bit Minimum Reserved Traffic Rate of the Service Flow*/ | ||
339 | B_UINT32 u32MinReservedTrafficRate; | ||
340 | |||
341 | /** 32bit Tolerated Jitter of the Service Flow*/ | ||
342 | B_UINT32 u32ToleratedJitter; | ||
343 | |||
344 | /** 32bit Maximum Latency of the Service Flow*/ | ||
345 | B_UINT32 u32MaximumLatency; | ||
346 | |||
347 | /** 16bitCID Of The Service Flow*/ | ||
348 | B_UINT16 u16CID; | ||
349 | |||
350 | /** 16bit SAID on which the service flow being set up shall be mapped*/ | ||
351 | B_UINT16 u16TargetSAID; | ||
352 | |||
353 | /** 16bit ARQ window size negotiated*/ | ||
354 | B_UINT16 u16ARQWindowSize; | ||
355 | |||
356 | /** 16bit Total Tx delay incl sending, receiving & processing delays */ | ||
357 | B_UINT16 u16ARQRetryTxTimeOut; | ||
358 | |||
359 | /** 16bit Total Rx delay incl sending, receiving & processing delays */ | ||
360 | B_UINT16 u16ARQRetryRxTimeOut; | ||
361 | |||
362 | /** 16bit ARQ block lifetime */ | ||
363 | B_UINT16 u16ARQBlockLifeTime; | ||
364 | |||
365 | /** 16bit ARQ Sync loss timeout*/ | ||
366 | B_UINT16 u16ARQSyncLossTimeOut; | ||
367 | |||
368 | /** 16bit ARQ Purge timeout */ | ||
369 | B_UINT16 u16ARQRxPurgeTimeOut; | ||
370 | #if 0 //def ENABLE_CORRIGENDUM2_UPDATE | ||
371 | /* IEEE Comment #627 / MTG Comment #426 */ | ||
372 | /// \brief Size of an ARQ block, changed from 2 bytes to 1 | ||
373 | B_UINT8 u8ARQBlockSize; | ||
374 | #endif | ||
375 | //TODO::Remove this once we move to a new CORR2 driver | ||
376 | /// \brief Size of an ARQ block | ||
377 | B_UINT16 u16ARQBlockSize; | ||
378 | |||
379 | //#endif | ||
380 | /** 16bit Nominal interval b/w consecutive SDU arrivals at MAC SAP*/ | ||
381 | B_UINT16 u16SDUInterArrivalTime; | ||
382 | |||
383 | /** 16bit Specifies the time base for rate measurement */ | ||
384 | B_UINT16 u16TimeBase; | ||
385 | |||
386 | /** 16bit Interval b/w Successive Grant oppurtunities*/ | ||
387 | B_UINT16 u16UnsolicitedGrantInterval; | ||
388 | |||
389 | /** 16bit Interval b/w Successive Polling grant oppurtunities*/ | ||
390 | B_UINT16 u16UnsolicitedPollingInterval; | ||
391 | |||
392 | /** internal var to get the overhead */ | ||
393 | B_UINT16 u16MacOverhead; | ||
394 | |||
395 | /** MBS contents Identifier*/ | ||
396 | B_UINT16 u16MBSContentsID[MBS_CONTENTS_ID_LENGTH]; | ||
397 | |||
398 | /** MBS contents Identifier length*/ | ||
399 | B_UINT8 u8MBSContentsIDLength; | ||
400 | |||
401 | /** ServiceClassName Length Of The Service Flow*/ | ||
402 | B_UINT8 u8ServiceClassNameLength; | ||
403 | |||
404 | /** 32bytes ServiceClassName Of The Service Flow*/ | ||
405 | B_UINT8 u8ServiceClassName[32]; | ||
406 | |||
407 | /** 8bit Indicates whether or not MBS service is requested for this Serivce Flow*/ | ||
408 | B_UINT8 u8MBSService; | ||
409 | |||
410 | /** 8bit QOS Parameter Set specifies proper application of QoS paramters to Provisioned, Admitted and Active sets*/ | ||
411 | B_UINT8 u8QosParamSet; | ||
412 | |||
413 | /** 8bit Traffic Priority Of the Service Flow */ | ||
414 | B_UINT8 u8TrafficPriority; | ||
415 | |||
416 | /** 8bit Uplink Grant Scheduling Type of The Service Flow */ | ||
417 | B_UINT8 u8ServiceFlowSchedulingType; | ||
418 | |||
419 | /** 8bit Request transmission Policy of the Service Flow*/ | ||
420 | B_UINT8 u8RequesttransmissionPolicy; | ||
421 | |||
422 | /** 8bit Specifies whether SDUs for this Service flow are of FixedLength or Variable length */ | ||
423 | B_UINT8 u8FixedLengthVSVariableLengthSDUIndicator; | ||
424 | |||
425 | /** 8bit Length of the SDU for a fixed length SDU service flow*/ | ||
426 | B_UINT8 u8SDUSize; | ||
427 | |||
428 | /** 8bit Indicates whether or not ARQ is requested for this connection*/ | ||
429 | B_UINT8 u8ARQEnable; | ||
430 | |||
431 | /**< 8bit Indicates whether or not data has tobe delivered in order to higher layer*/ | ||
432 | B_UINT8 u8ARQDeliverInOrder; | ||
433 | |||
434 | /** 8bit Receiver ARQ ACK processing time */ | ||
435 | B_UINT8 u8RxARQAckProcessingTime; | ||
436 | |||
437 | /** 8bit Convergence Sublayer Specification Of The Service Flow*/ | ||
438 | B_UINT8 u8CSSpecification; | ||
439 | |||
440 | /** 8 bit Type of data delivery service*/ | ||
441 | B_UINT8 u8TypeOfDataDeliveryService; | ||
442 | |||
443 | /** 8bit Specifies whether a service flow may generate Paging */ | ||
444 | B_UINT8 u8PagingPreference; | ||
445 | |||
446 | /** 8bit Indicates the MBS Zone through which the connection or virtual connection is valid */ | ||
447 | B_UINT8 u8MBSZoneIdentifierassignment; | ||
448 | |||
449 | /** 8bit Specifies whether traffic on SF should generate MOB_TRF_IND to MS in sleep mode*/ | ||
450 | B_UINT8 u8TrafficIndicationPreference; | ||
451 | |||
452 | /** 8bit Speciifes the length of predefined Global QoS parameter set encoding for this SF */ | ||
453 | B_UINT8 u8GlobalServicesClassNameLength; | ||
454 | |||
455 | /** 6 byte Speciifes the predefined Global QoS parameter set encoding for this SF */ | ||
456 | B_UINT8 u8GlobalServicesClassName[GLOBAL_SF_CLASSNAME_LENGTH]; | ||
457 | |||
458 | /** 8bit Indicates whether or not SN feedback is enabled for the conn */ | ||
459 | B_UINT8 u8SNFeedbackEnabled; | ||
460 | |||
461 | /** Indicates the size of the Fragment Sequence Number for the connection */ | ||
462 | B_UINT8 u8FSNSize; | ||
463 | |||
464 | /** 8bit Number of CIDs in active BS list */ | ||
465 | B_UINT8 u8CIDAllocation4activeBSsLength; | ||
466 | |||
467 | /** CIDs of BS in the active list */ | ||
468 | B_UINT8 u8CIDAllocation4activeBSs[MAX_NUM_ACTIVE_BS]; | ||
469 | |||
470 | /** Specifies if PDU extended subheader should be applied on every PDU on this conn*/ | ||
471 | B_UINT8 u8PDUSNExtendedSubheader4HarqReordering; | ||
472 | |||
473 | /** 8bit Specifies whether the connection uses HARQ or not */ | ||
474 | B_UINT8 u8HARQServiceFlows; | ||
475 | |||
476 | /** Specifies the length of Authorization token*/ | ||
477 | B_UINT8 u8AuthTokenLength; | ||
478 | |||
479 | /** Specifies the Authorization token*/ | ||
480 | B_UINT8 u8AuthToken[AUTH_TOKEN_LENGTH]; | ||
481 | |||
482 | /** specifes Number of HARQ channels used to carry data length*/ | ||
483 | B_UINT8 u8HarqChannelMappingLength; | ||
484 | |||
485 | /** specifes HARQ channels used to carry data*/ | ||
486 | B_UINT8 u8HARQChannelMapping[NUM_HARQ_CHANNELS]; | ||
487 | |||
488 | /** 8bit Length of Vendor Specific QoS Params */ | ||
489 | B_UINT8 u8VendorSpecificQoSParamLength; | ||
490 | |||
491 | /** 1byte Vendor Specific QoS Param Of The Service Flow*/ | ||
492 | B_UINT8 u8VendorSpecificQoSParam[VENDOR_SPECIF_QOS_PARAM]; | ||
493 | |||
494 | // indicates total classifiers in the SF | ||
495 | B_UINT8 u8TotalClassifiers; /**< Total number of valid classifiers*/ | ||
496 | B_UINT8 bValid; /**< Validity flag */ | ||
497 | B_UINT8 u8Padding; /**< Padding byte*/ | ||
498 | |||
499 | #ifdef BECEEM_TARGET | ||
500 | /** | ||
501 | Structure for Convergence SubLayer Types with a maximum of 4 classifiers | ||
502 | */ | ||
503 | CConvergenceSLTypes cConvergenceSLTypes[MAX_CLASSIFIERS_IN_SF]; | ||
504 | #else | ||
505 | /** | ||
506 | Structure for Convergence SubLayer Types with a maximum of 4 classifiers | ||
507 | */ | ||
508 | stConvergenceSLTypes cConvergenceSLTypes[MAX_CLASSIFIERS_IN_SF]; | ||
509 | #endif | ||
510 | |||
511 | #ifdef BECEEM_TARGET | ||
512 | }; | ||
513 | #else | ||
514 | } stServiceFlowParamSI, *pstServiceFlowParamSI; | ||
515 | typedef stServiceFlowParamSI CServiceFlowParamSI; | ||
516 | #endif | ||
517 | |||
518 | /** | ||
519 | structure stLocalSFAddRequest | ||
520 | */ | ||
521 | typedef struct _stLocalSFAddRequest{ | ||
522 | #ifdef BECEEM_TARGET | ||
523 | _stLocalSFAddRequest( ) : | ||
524 | u8Type(0x00), eConnectionDir(0x00), | ||
525 | u16TID(0x0000), u16CID(0x0000), u16VCID(0x0000) | ||
526 | {} | ||
527 | #endif | ||
528 | |||
529 | B_UINT8 u8Type; /**< Type*/ | ||
530 | B_UINT8 eConnectionDir; /**< Connection direction*/ | ||
531 | /// \brief 16 bit TID | ||
532 | B_UINT16 u16TID; /**< 16bit TID*/ | ||
533 | /// \brief 16bitCID | ||
534 | B_UINT16 u16CID; /**< 16bit CID*/ | ||
535 | /// \brief 16bitVCID | ||
536 | B_UINT16 u16VCID; /**< 16bit VCID*/ | ||
537 | /// \brief structure ParameterSet | ||
538 | #ifdef BECEEM_SIGNALLING_INTERFACE_API | ||
539 | CServiceFlowParamSI sfParameterSet; | ||
540 | #endif | ||
541 | |||
542 | #ifdef BECEEM_TARGET | ||
543 | CServiceFlowParamSI *psfParameterSet; | ||
544 | #else | ||
545 | stServiceFlowParamSI *psfParameterSet; /**< structure ParameterSet*/ | ||
546 | #endif | ||
547 | |||
548 | #ifdef USING_VXWORKS | ||
549 | USE_DATA_MEMORY_MANAGER(); | ||
550 | #endif | ||
551 | }stLocalSFAddRequest, *pstLocalSFAddRequest; | ||
552 | |||
553 | |||
554 | /** | ||
555 | structure stLocalSFAddIndication | ||
556 | */ | ||
557 | typedef struct _stLocalSFAddIndication{ | ||
558 | #ifdef BECEEM_TARGET | ||
559 | _stLocalSFAddIndication( ) : | ||
560 | u8Type(0x00), eConnectionDir(0x00), | ||
561 | u16TID(0x0000), u16CID(0x0000), u16VCID(0x0000) | ||
562 | {} | ||
563 | #endif | ||
564 | |||
565 | B_UINT8 u8Type; /**< Type*/ | ||
566 | B_UINT8 eConnectionDir; /**< Connection Direction*/ | ||
567 | /// \brief 16 bit TID | ||
568 | B_UINT16 u16TID; /**< TID*/ | ||
569 | /// \brief 16bitCID | ||
570 | B_UINT16 u16CID; /**< 16bitCID*/ | ||
571 | /// \brief 16bitVCID | ||
572 | B_UINT16 u16VCID; /**< 16bitVCID*/ | ||
573 | |||
574 | #ifdef BECEEM_SIGNALLING_INTERFACE_API | ||
575 | CServiceFlowParamSI sfAuthorizedSet; | ||
576 | /// \brief structure AdmittedSet | ||
577 | CServiceFlowParamSI sfAdmittedSet; | ||
578 | /// \brief structure ActiveSet | ||
579 | CServiceFlowParamSI sfActiveSet; | ||
580 | #endif | ||
581 | |||
582 | /// \brief structure AuthorizedSet | ||
583 | #ifdef BECEEM_TARGET | ||
584 | CServiceFlowParamSI *psfAuthorizedSet; | ||
585 | /// \brief structure AdmittedSet | ||
586 | CServiceFlowParamSI *psfAdmittedSet; | ||
587 | /// \brief structure ActiveSet | ||
588 | CServiceFlowParamSI *psfActiveSet; | ||
589 | #else | ||
590 | /// \brief structure AuthorizedSet | ||
591 | stServiceFlowParamSI *psfAuthorizedSet; /**< AuthorizedSet of type stServiceFlowParamSI*/ | ||
592 | /// \brief structure AdmittedSet | ||
593 | stServiceFlowParamSI *psfAdmittedSet; /**< AdmittedSet of type stServiceFlowParamSI*/ | ||
594 | /// \brief structure ActiveSet | ||
595 | stServiceFlowParamSI *psfActiveSet; /**< sfActiveSet of type stServiceFlowParamSI*/ | ||
596 | #endif | ||
597 | B_UINT8 u8CC; /**< Confirmation Code*/ | ||
598 | B_UINT8 u8Padd; /**< 8-bit Padding */ | ||
599 | |||
600 | B_UINT16 u16Padd; /**< 16 bit Padding */ | ||
601 | |||
602 | #ifdef USING_VXWORKS | ||
603 | USE_DATA_MEMORY_MANAGER(); | ||
604 | #endif | ||
605 | }stLocalSFAddIndication; | ||
606 | |||
607 | |||
608 | typedef struct _stLocalSFAddIndication *pstLocalSFAddIndication; | ||
609 | /** | ||
610 | structure stLocalSFChangeRequest is same as structure stLocalSFAddIndication | ||
611 | */ | ||
612 | typedef struct _stLocalSFAddIndication stLocalSFChangeRequest, *pstLocalSFChangeRequest; | ||
613 | /** | ||
614 | structure stLocalSFChangeIndication is same as structure stLocalSFAddIndication | ||
615 | */ | ||
616 | typedef struct _stLocalSFAddIndication stLocalSFChangeIndication, *pstLocalSFChangeIndication; | ||
617 | |||
618 | /** | ||
619 | structure stLocalSFDeleteRequest | ||
620 | */ | ||
621 | typedef struct _stLocalSFDeleteRequest{ | ||
622 | #ifdef BECEEM_TARGET | ||
623 | _stLocalSFDeleteRequest( ) : | ||
624 | u8Type(0x00), u8Padding(0x00), | ||
625 | u16TID(0x0000), u32SFID (0x00000000) | ||
626 | {} | ||
627 | #endif | ||
628 | B_UINT8 u8Type; /**< Type*/ | ||
629 | B_UINT8 u8Padding; /**< Padding byte*/ | ||
630 | B_UINT16 u16TID; /**< TID*/ | ||
631 | /// \brief 32bitSFID | ||
632 | B_UINT32 u32SFID; /**< SFID*/ | ||
633 | #ifdef USING_VXWORKS | ||
634 | USE_DATA_MEMORY_MANAGER(); | ||
635 | #endif | ||
636 | }stLocalSFDeleteRequest, *pstLocalSFDeleteRequest; | ||
637 | |||
638 | /** | ||
639 | structure stLocalSFDeleteIndication | ||
640 | */ | ||
641 | typedef struct stLocalSFDeleteIndication{ | ||
642 | #ifdef BECEEM_TARGET | ||
643 | stLocalSFDeleteIndication( ) : | ||
644 | u8Type(0x00), u8Padding(0x00), | ||
645 | u16TID(0x0000), u16CID(0x0000), | ||
646 | u16VCID(0x0000),u32SFID (0x00000000) | ||
647 | {} | ||
648 | #endif | ||
649 | B_UINT8 u8Type; /**< Type */ | ||
650 | B_UINT8 u8Padding; /**< Padding */ | ||
651 | B_UINT16 u16TID; /**< TID */ | ||
652 | /// \brief 16bitCID | ||
653 | B_UINT16 u16CID; /**< CID */ | ||
654 | /// \brief 16bitVCID | ||
655 | B_UINT16 u16VCID; /**< VCID */ | ||
656 | /// \brief 32bitSFID | ||
657 | B_UINT32 u32SFID; /**< SFID */ | ||
658 | /// \brief 8bit Confirmation code | ||
659 | B_UINT8 u8ConfirmationCode; /**< Confirmation code */ | ||
660 | B_UINT8 u8Padding1[3]; /**< 3 byte Padding */ | ||
661 | #ifdef USING_VXWORKS | ||
662 | USE_DATA_MEMORY_MANAGER(); | ||
663 | #endif | ||
664 | }stLocalSFDeleteIndication; | ||
665 | |||
666 | typedef struct _stIM_SFHostNotify | ||
667 | { | ||
668 | B_UINT32 SFID; //SFID of the service flow | ||
669 | B_UINT16 newCID; //the new/changed CID | ||
670 | B_UINT16 VCID; //Get new Vcid if the flow has been made active in CID update TLV, but was inactive earlier or the orig vcid | ||
671 | B_UINT8 RetainSF; //Indication to Host if the SF is to be retained or deleted; if TRUE-retain else delete | ||
672 | B_UINT8 QoSParamSet; //QoS paramset of the retained SF | ||
673 | B_UINT16 u16reserved; //For byte alignment | ||
674 | |||
675 | } stIM_SFHostNotify; | ||
676 | |||
677 | #endif | ||
diff --git a/drivers/staging/bcm/headers.h b/drivers/staging/bcm/headers.h new file mode 100644 index 00000000000..9d4e3aca1b3 --- /dev/null +++ b/drivers/staging/bcm/headers.h | |||
@@ -0,0 +1,109 @@ | |||
1 | |||
2 | /******************************************************************* | ||
3 | * Headers.h | ||
4 | *******************************************************************/ | ||
5 | #ifndef __HEADERS_H__ | ||
6 | #define __HEADERS_H__ | ||
7 | |||
8 | #include <linux/kernel.h> | ||
9 | #include <linux/module.h> | ||
10 | #include <linux/types.h> | ||
11 | #include <linux/netdevice.h> | ||
12 | #include <linux/skbuff.h> | ||
13 | #include <linux/socket.h> | ||
14 | #include <linux/netfilter.h> | ||
15 | #include <linux/netfilter_ipv4.h> | ||
16 | #include <linux/if_arp.h> | ||
17 | #include <linux/delay.h> | ||
18 | #include <linux/spinlock.h> | ||
19 | #include <linux/fs.h> | ||
20 | #include <linux/file.h> | ||
21 | #include <linux/string.h> | ||
22 | #include <linux/etherdevice.h> | ||
23 | #include <net/ip.h> | ||
24 | #include <linux/wait.h> | ||
25 | #include <linux/notifier.h> | ||
26 | #include <linux/proc_fs.h> | ||
27 | #include <linux/interrupt.h> | ||
28 | |||
29 | #include <linux/version.h> | ||
30 | #include <linux/stddef.h> | ||
31 | #include <linux/kernel.h> | ||
32 | #include <linux/stat.h> | ||
33 | #include <linux/fcntl.h> | ||
34 | #include <linux/unistd.h> | ||
35 | #include <linux/sched.h> | ||
36 | #include <linux/mm.h> | ||
37 | #include <linux/pagemap.h> | ||
38 | #include <asm/uaccess.h> | ||
39 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) | ||
40 | #include <linux/kthread.h> | ||
41 | #endif | ||
42 | #include <linux/tcp.h> | ||
43 | #include <linux/udp.h> | ||
44 | #ifndef BCM_SHM_INTERFACE | ||
45 | #include <linux/usb.h> | ||
46 | #endif | ||
47 | #ifdef BECEEM_TARGET | ||
48 | |||
49 | #include <mac_common.h> | ||
50 | #include <msg_Dsa.h> | ||
51 | #include <msg_Dsc.h> | ||
52 | #include <msg_Dsd.h> | ||
53 | #include <sch_definitions.h> | ||
54 | using namespace Beceem; | ||
55 | #ifdef ENABLE_CORRIGENDUM2_UPDATE | ||
56 | extern B_UINT32 g_u32Corr2MacFlags; | ||
57 | #endif | ||
58 | #endif | ||
59 | |||
60 | #include "Typedefs.h" | ||
61 | #include "Version.h" | ||
62 | #include "Macros.h" | ||
63 | #include "HostMIBSInterface.h" | ||
64 | #include "cntrl_SignalingInterface.h" | ||
65 | #include "PHSDefines.h" | ||
66 | #include "led_control.h" | ||
67 | #include "Ioctl.h" | ||
68 | #include "nvm.h" | ||
69 | #include "target_params.h" | ||
70 | #include "Adapter.h" | ||
71 | #include "CmHost.h" | ||
72 | #include "DDRInit.h" | ||
73 | #include "Debug.h" | ||
74 | #include "HostMibs.h" | ||
75 | #include "IPv6ProtocolHdr.h" | ||
76 | #include "osal_misc.h" | ||
77 | #include "PHSModule.h" | ||
78 | #include "Protocol.h" | ||
79 | #include "Prototypes.h" | ||
80 | #include "Queue.h" | ||
81 | #include "vendorspecificextn.h" | ||
82 | |||
83 | #ifndef BCM_SHM_INTERFACE | ||
84 | |||
85 | #include "InterfaceMacros.h" | ||
86 | #include "InterfaceAdapter.h" | ||
87 | #include "InterfaceIsr.h" | ||
88 | #include "Interfacemain.h" | ||
89 | #include "InterfaceMisc.h" | ||
90 | #include "InterfaceRx.h" | ||
91 | #include "InterfaceTx.h" | ||
92 | #endif | ||
93 | #include "InterfaceIdleMode.h" | ||
94 | #include "InterfaceInit.h" | ||
95 | |||
96 | #ifdef BCM_SHM_INTERFACE | ||
97 | #include <linux/cpe_config.h> | ||
98 | |||
99 | #ifdef GDMA_INTERFACE | ||
100 | #include "GdmaInterface.h" | ||
101 | #include "symphony.h" | ||
102 | #else | ||
103 | #include "virtual_interface.h" | ||
104 | |||
105 | #endif | ||
106 | |||
107 | #endif | ||
108 | |||
109 | #endif | ||
diff --git a/drivers/staging/bcm/hostmibs.c b/drivers/staging/bcm/hostmibs.c new file mode 100644 index 00000000000..e9da513b3c2 --- /dev/null +++ b/drivers/staging/bcm/hostmibs.c | |||
@@ -0,0 +1,164 @@ | |||
1 | |||
2 | /* | ||
3 | * File Name: hostmibs.c | ||
4 | * | ||
5 | * Author: Beceem Communications Pvt. Ltd | ||
6 | * | ||
7 | * Abstract: This file contains the routines to copy the statistics used by | ||
8 | * the driver to the Host MIBS structure and giving the same to Application. | ||
9 | * | ||
10 | */ | ||
11 | #include "headers.h" | ||
12 | |||
13 | INT ProcessGetHostMibs(PMINI_ADAPTER Adapter, | ||
14 | PVOID ioBuffer, | ||
15 | ULONG inputBufferLength) | ||
16 | { | ||
17 | |||
18 | S_MIBS_HOST_STATS_MIBS *pstHostMibs = NULL; | ||
19 | S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL; | ||
20 | S_PHS_RULE *pstPhsRule = NULL; | ||
21 | S_CLASSIFIER_TABLE *pstClassifierTable = NULL; | ||
22 | S_CLASSIFIER_ENTRY *pstClassifierRule = NULL; | ||
23 | PPHS_DEVICE_EXTENSION pDeviceExtension = (PPHS_DEVICE_EXTENSION)&Adapter->stBCMPhsContext; | ||
24 | |||
25 | UINT nClassifierIndex = 0, nPhsTableIndex = 0,nSfIndex = 0, uiIndex = 0; | ||
26 | |||
27 | if(pDeviceExtension == NULL) | ||
28 | { | ||
29 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, HOST_MIBS, DBG_LVL_ALL, "Invalid Device Extension\n"); | ||
30 | return STATUS_FAILURE; | ||
31 | } | ||
32 | |||
33 | if(ioBuffer == NULL) | ||
34 | { | ||
35 | return -EINVAL; | ||
36 | } | ||
37 | memset(ioBuffer,0,sizeof(S_MIBS_HOST_STATS_MIBS)); | ||
38 | |||
39 | pstHostMibs = (S_MIBS_HOST_STATS_MIBS *)ioBuffer; | ||
40 | |||
41 | |||
42 | //Copy the classifier Table | ||
43 | for(nClassifierIndex=0; nClassifierIndex < MAX_CLASSIFIERS; | ||
44 | nClassifierIndex++) | ||
45 | { | ||
46 | if(Adapter->astClassifierTable[nClassifierIndex].bUsed == TRUE) | ||
47 | memcpy((PVOID)&pstHostMibs->astClassifierTable[nClassifierIndex], | ||
48 | (PVOID)&Adapter->astClassifierTable[nClassifierIndex], | ||
49 | sizeof(S_MIBS_CLASSIFIER_RULE)); | ||
50 | } | ||
51 | |||
52 | //Copy the SF Table | ||
53 | for(nSfIndex=0; nSfIndex < NO_OF_QUEUES ; nSfIndex++) | ||
54 | { | ||
55 | if(Adapter->PackInfo[nSfIndex].bValid) | ||
56 | { | ||
57 | OsalMemMove((PVOID)&pstHostMibs->astSFtable[nSfIndex],(PVOID)&Adapter->PackInfo[nSfIndex],sizeof(S_MIBS_SERVICEFLOW_TABLE)); | ||
58 | } | ||
59 | else | ||
60 | { | ||
61 | //if index in not valid, don't process this for the PHS table. Go For the next entry. | ||
62 | continue ; | ||
63 | } | ||
64 | |||
65 | //Retrieve the SFID Entry Index for requested Service Flow | ||
66 | if(PHS_INVALID_TABLE_INDEX == GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable, | ||
67 | Adapter->PackInfo[nSfIndex].usVCID_Value ,&pstServiceFlowEntry)) | ||
68 | { | ||
69 | |||
70 | continue; | ||
71 | } | ||
72 | |||
73 | pstClassifierTable = pstServiceFlowEntry->pstClassifierTable; | ||
74 | |||
75 | |||
76 | for(uiIndex = 0; uiIndex < MAX_PHSRULE_PER_SF; uiIndex++) | ||
77 | { | ||
78 | pstClassifierRule = &pstClassifierTable->stActivePhsRulesList[uiIndex]; | ||
79 | |||
80 | if(pstClassifierRule->bUsed) | ||
81 | { | ||
82 | pstPhsRule = pstClassifierRule->pstPhsRule; | ||
83 | |||
84 | pstHostMibs->astPhsRulesTable[nPhsTableIndex].ulSFID = Adapter->PackInfo[nSfIndex].ulSFID; | ||
85 | |||
86 | OsalMemMove(&pstHostMibs->astPhsRulesTable[nPhsTableIndex].u8PHSI, | ||
87 | &pstPhsRule->u8PHSI, | ||
88 | sizeof(S_PHS_RULE)); | ||
89 | nPhsTableIndex++; | ||
90 | |||
91 | } | ||
92 | |||
93 | } | ||
94 | |||
95 | } | ||
96 | |||
97 | |||
98 | |||
99 | //copy other Host Statistics parameters | ||
100 | pstHostMibs->stHostInfo.GoodTransmits = | ||
101 | atomic_read(&Adapter->TxTotalPacketCount); | ||
102 | pstHostMibs->stHostInfo.GoodReceives = | ||
103 | atomic_read(&Adapter->GoodRxPktCount); | ||
104 | pstHostMibs->stHostInfo.CurrNumFreeDesc = | ||
105 | atomic_read(&Adapter->CurrNumFreeTxDesc); | ||
106 | pstHostMibs->stHostInfo.BEBucketSize = Adapter->BEBucketSize; | ||
107 | pstHostMibs->stHostInfo.rtPSBucketSize = Adapter->rtPSBucketSize; | ||
108 | pstHostMibs->stHostInfo.TimerActive = Adapter->TimerActive; | ||
109 | pstHostMibs->stHostInfo.u32TotalDSD = Adapter->u32TotalDSD; | ||
110 | |||
111 | memcpy(pstHostMibs->stHostInfo.aTxPktSizeHist,Adapter->aTxPktSizeHist,sizeof(UINT32)*MIBS_MAX_HIST_ENTRIES); | ||
112 | memcpy(pstHostMibs->stHostInfo.aRxPktSizeHist,Adapter->aRxPktSizeHist,sizeof(UINT32)*MIBS_MAX_HIST_ENTRIES); | ||
113 | |||
114 | return STATUS_SUCCESS; | ||
115 | } | ||
116 | |||
117 | |||
118 | INT GetDroppedAppCntrlPktMibs(PVOID ioBuffer, PPER_TARANG_DATA pTarang) | ||
119 | { | ||
120 | S_MIBS_HOST_STATS_MIBS *pstHostMibs = (S_MIBS_HOST_STATS_MIBS *)ioBuffer; | ||
121 | |||
122 | memcpy((PVOID)&(pstHostMibs->stDroppedAppCntrlMsgs),(PVOID)&(pTarang->stDroppedAppCntrlMsgs),sizeof(S_MIBS_DROPPED_APP_CNTRL_MESSAGES)); | ||
123 | |||
124 | return STATUS_SUCCESS ; | ||
125 | } | ||
126 | |||
127 | |||
128 | VOID CopyMIBSExtendedSFParameters(PMINI_ADAPTER Adapter, | ||
129 | CServiceFlowParamSI *psfLocalSet, UINT uiSearchRuleIndex) | ||
130 | { | ||
131 | Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfSfid = psfLocalSet->u32SFID; | ||
132 | Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsMaxSustainedRate = psfLocalSet->u32MaxSustainedTrafficRate; | ||
133 | Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsMaxTrafficBurst = psfLocalSet->u32MaxTrafficBurst; | ||
134 | Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsMinReservedRate = psfLocalSet->u32MinReservedTrafficRate; | ||
135 | Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsToleratedJitter = psfLocalSet->u32ToleratedJitter; | ||
136 | Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsMaxLatency = psfLocalSet->u32MaximumLatency; | ||
137 | Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsFixedVsVariableSduInd = psfLocalSet->u8FixedLengthVSVariableLengthSDUIndicator; | ||
138 | Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsFixedVsVariableSduInd = ntohl(Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsFixedVsVariableSduInd); | ||
139 | Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsSduSize = psfLocalSet->u8SDUSize; | ||
140 | Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsSduSize = ntohl(Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsSduSize); | ||
141 | Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsSfSchedulingType = psfLocalSet->u8ServiceFlowSchedulingType; | ||
142 | Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsSfSchedulingType = ntohl(Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsSfSchedulingType); | ||
143 | Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqEnable = psfLocalSet->u8ARQEnable; | ||
144 | Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqEnable = ntohl(Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqEnable); | ||
145 | Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqWindowSize = ntohs(psfLocalSet->u16ARQWindowSize); | ||
146 | Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqWindowSize = ntohl(Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqWindowSize); | ||
147 | Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqBlockLifetime = ntohs(psfLocalSet->u16ARQBlockLifeTime); | ||
148 | Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqBlockLifetime = ntohl(Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqBlockLifetime); | ||
149 | Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqSyncLossTimeout = ntohs(psfLocalSet->u16ARQSyncLossTimeOut); | ||
150 | Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqSyncLossTimeout = ntohl(Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqSyncLossTimeout); | ||
151 | Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqDeliverInOrder = psfLocalSet->u8ARQDeliverInOrder; | ||
152 | Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqDeliverInOrder = ntohl(Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqDeliverInOrder); | ||
153 | Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqRxPurgeTimeout = ntohs(psfLocalSet->u16ARQRxPurgeTimeOut); | ||
154 | Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqRxPurgeTimeout = ntohl(Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqRxPurgeTimeout); | ||
155 | Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqBlockSize = ntohs(psfLocalSet->u16ARQBlockSize); | ||
156 | Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqBlockSize = ntohl(Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqBlockSize); | ||
157 | Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsReqTxPolicy = psfLocalSet->u8RequesttransmissionPolicy; | ||
158 | Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsReqTxPolicy = ntohl(Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsReqTxPolicy); | ||
159 | Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnSfCsSpecification = psfLocalSet->u8CSSpecification; | ||
160 | Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnSfCsSpecification = ntohl(Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnSfCsSpecification); | ||
161 | Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsTargetSaid = ntohs(psfLocalSet->u16TargetSAID); | ||
162 | Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsTargetSaid = ntohl(Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsTargetSaid); | ||
163 | |||
164 | } | ||
diff --git a/drivers/staging/bcm/led_control.c b/drivers/staging/bcm/led_control.c new file mode 100644 index 00000000000..0d07664e10f --- /dev/null +++ b/drivers/staging/bcm/led_control.c | |||
@@ -0,0 +1,1006 @@ | |||
1 | #include "headers.h" | ||
2 | |||
3 | #define STATUS_IMAGE_CHECKSUM_MISMATCH -199 | ||
4 | #define EVENT_SIGNALED 1 | ||
5 | |||
6 | static B_UINT16 CFG_CalculateChecksum(B_UINT8 *pu8Buffer, B_UINT32 u32Size) | ||
7 | { | ||
8 | B_UINT16 u16CheckSum=0; | ||
9 | while(u32Size--) { | ||
10 | u16CheckSum += (B_UINT8)~(*pu8Buffer); | ||
11 | pu8Buffer++; | ||
12 | } | ||
13 | return u16CheckSum; | ||
14 | } | ||
15 | BOOLEAN IsReqGpioIsLedInNVM(PMINI_ADAPTER Adapter, UINT gpios) | ||
16 | { | ||
17 | INT Status ; | ||
18 | Status = (Adapter->gpioBitMap & gpios) ^ gpios ; | ||
19 | if(Status) | ||
20 | return FALSE; | ||
21 | else | ||
22 | return TRUE; | ||
23 | } | ||
24 | |||
25 | INT LED_Blink(PMINI_ADAPTER Adapter, UINT GPIO_Num, UCHAR uiLedIndex, ULONG timeout, INT num_of_time, LedEventInfo_t currdriverstate) | ||
26 | { | ||
27 | int Status = STATUS_SUCCESS; | ||
28 | BOOLEAN bInfinite = FALSE; | ||
29 | |||
30 | /*Check if num_of_time is -ve. If yes, blink led in infinite loop*/ | ||
31 | if(num_of_time < 0) | ||
32 | { | ||
33 | bInfinite = TRUE; | ||
34 | num_of_time = 1; | ||
35 | } | ||
36 | while(num_of_time) | ||
37 | { | ||
38 | |||
39 | if(currdriverstate == Adapter->DriverState) | ||
40 | TURN_ON_LED(GPIO_Num, uiLedIndex); | ||
41 | |||
42 | /*Wait for timeout after setting on the LED*/ | ||
43 | Status = wait_event_interruptible_timeout(Adapter->LEDInfo.notify_led_event, | ||
44 | currdriverstate != Adapter->DriverState || kthread_should_stop(), | ||
45 | msecs_to_jiffies(timeout)); | ||
46 | |||
47 | if(kthread_should_stop()) | ||
48 | { | ||
49 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL, "Led thread got signal to exit..hence exiting"); | ||
50 | Adapter->LEDInfo.led_thread_running= BCM_LED_THREAD_DISABLED; | ||
51 | TURN_OFF_LED(GPIO_Num, uiLedIndex); | ||
52 | Status=EVENT_SIGNALED; | ||
53 | break; | ||
54 | } | ||
55 | if(Status) | ||
56 | { | ||
57 | TURN_OFF_LED(GPIO_Num, uiLedIndex); | ||
58 | Status=EVENT_SIGNALED; | ||
59 | break; | ||
60 | } | ||
61 | |||
62 | TURN_OFF_LED(GPIO_Num, uiLedIndex); | ||
63 | Status = wait_event_interruptible_timeout(Adapter->LEDInfo.notify_led_event, | ||
64 | currdriverstate!= Adapter->DriverState || kthread_should_stop(), | ||
65 | msecs_to_jiffies(timeout)); | ||
66 | if(bInfinite == FALSE) | ||
67 | num_of_time--; | ||
68 | } | ||
69 | return Status; | ||
70 | } | ||
71 | |||
72 | INT ScaleRateofTransfer(ULONG rate) | ||
73 | { | ||
74 | if(rate <= 3) | ||
75 | return rate; | ||
76 | else if((rate > 3) && (rate <= 100)) | ||
77 | return 5; | ||
78 | else if((rate > 100) && (rate <= 200)) | ||
79 | return 6; | ||
80 | else if((rate > 200) && (rate <= 300)) | ||
81 | return 7; | ||
82 | else if((rate > 300) && (rate <= 400)) | ||
83 | return 8; | ||
84 | else if((rate > 400) && (rate <= 500)) | ||
85 | return 9; | ||
86 | else if((rate > 500) && (rate <= 600)) | ||
87 | return 10; | ||
88 | else | ||
89 | return MAX_NUM_OF_BLINKS; | ||
90 | } | ||
91 | |||
92 | |||
93 | |||
94 | INT LED_Proportional_Blink(PMINI_ADAPTER Adapter, UCHAR GPIO_Num_tx, | ||
95 | UCHAR uiTxLedIndex, UCHAR GPIO_Num_rx, UCHAR uiRxLedIndex, LedEventInfo_t currdriverstate) | ||
96 | { | ||
97 | /* Initial values of TX and RX packets*/ | ||
98 | ULONG64 Initial_num_of_packts_tx = 0, Initial_num_of_packts_rx = 0; | ||
99 | /*values of TX and RX packets after 1 sec*/ | ||
100 | ULONG64 Final_num_of_packts_tx = 0, Final_num_of_packts_rx = 0; | ||
101 | /*Rate of transfer of Tx and Rx in 1 sec*/ | ||
102 | ULONG64 rate_of_transfer_tx = 0, rate_of_transfer_rx = 0; | ||
103 | int Status = STATUS_SUCCESS; | ||
104 | INT num_of_time = 0, num_of_time_tx = 0, num_of_time_rx = 0; | ||
105 | UINT remDelay = 0; | ||
106 | BOOLEAN bBlinkBothLED = TRUE; | ||
107 | //UINT GPIO_num = DISABLE_GPIO_NUM; | ||
108 | ulong timeout = 0; | ||
109 | |||
110 | /*Read initial value of packets sent/received */ | ||
111 | Initial_num_of_packts_tx = atomic_read(&Adapter->TxTotalPacketCount); | ||
112 | Initial_num_of_packts_rx = atomic_read(&Adapter->GoodRxPktCount); | ||
113 | /*Scale the rate of transfer to no of blinks.*/ | ||
114 | num_of_time_tx= ScaleRateofTransfer((ULONG)rate_of_transfer_tx); | ||
115 | num_of_time_rx= ScaleRateofTransfer((ULONG)rate_of_transfer_rx); | ||
116 | |||
117 | while((Adapter->device_removed == FALSE)) | ||
118 | { | ||
119 | #if 0 | ||
120 | if(0 == num_of_time_tx && 0 == num_of_time_rx) | ||
121 | { | ||
122 | timeout = 1000; | ||
123 | Status = wait_event_interruptible_timeout(Adapter->LEDInfo.notify_led_event, | ||
124 | currdriverstate!= Adapter->DriverState || kthread_should_stop(), | ||
125 | msecs_to_jiffies (timeout)); | ||
126 | if(kthread_should_stop()) | ||
127 | { | ||
128 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL, "Led thread got signal to exit..hence exiting"); | ||
129 | Adapter->LEDInfo.led_thread_running= BCM_LED_THREAD_DISABLED; | ||
130 | return EVENT_SIGNALED; | ||
131 | } | ||
132 | if(Status) | ||
133 | return EVENT_SIGNALED; | ||
134 | |||
135 | } | ||
136 | #endif | ||
137 | |||
138 | timeout = 50; | ||
139 | #if 0 | ||
140 | /*Turn on LED if Tx is high bandwidth*/ | ||
141 | if(num_of_time_tx > MAX_NUM_OF_BLINKS) | ||
142 | { | ||
143 | TURN_ON_LED(1<<GPIO_Num_tx, uiTxLedIndex); | ||
144 | num_of_time_tx = 0; | ||
145 | bBlinkBothLED = FALSE; | ||
146 | num_of_time = num_of_time_rx; | ||
147 | } | ||
148 | /*Turn on LED if Rx is high bandwidth*/ | ||
149 | if(num_of_time_rx > MAX_NUM_OF_BLINKS) | ||
150 | { | ||
151 | TURN_ON_LED(1<<GPIO_Num_rx, uiRxLedIndex); | ||
152 | num_of_time_rx = 0; | ||
153 | bBlinkBothLED = FALSE; | ||
154 | num_of_time = num_of_time_tx; | ||
155 | } | ||
156 | #endif | ||
157 | /*Blink Tx and Rx LED when both Tx and Rx is in normal bandwidth*/ | ||
158 | if(bBlinkBothLED) | ||
159 | { | ||
160 | /*Assign minimum number of blinks of either Tx or Rx.*/ | ||
161 | if(num_of_time_tx > num_of_time_rx) | ||
162 | num_of_time = num_of_time_rx; | ||
163 | else | ||
164 | num_of_time = num_of_time_tx; | ||
165 | if(num_of_time > 0) | ||
166 | { | ||
167 | /*Blink both Tx and Rx LEDs*/ | ||
168 | if(LED_Blink(Adapter, 1<<GPIO_Num_tx, uiTxLedIndex, timeout, num_of_time,currdriverstate) | ||
169 | == EVENT_SIGNALED) | ||
170 | { | ||
171 | return EVENT_SIGNALED; | ||
172 | } | ||
173 | if(LED_Blink(Adapter, 1<<GPIO_Num_rx, uiRxLedIndex, timeout, num_of_time,currdriverstate) | ||
174 | == EVENT_SIGNALED) | ||
175 | { | ||
176 | return EVENT_SIGNALED; | ||
177 | } | ||
178 | |||
179 | } | ||
180 | |||
181 | if(num_of_time == num_of_time_tx) | ||
182 | { | ||
183 | /*Blink pending rate of Rx*/ | ||
184 | if(LED_Blink(Adapter, (1 << GPIO_Num_rx), uiRxLedIndex, timeout, | ||
185 | num_of_time_rx-num_of_time,currdriverstate) == EVENT_SIGNALED) | ||
186 | { | ||
187 | return EVENT_SIGNALED; | ||
188 | } | ||
189 | num_of_time = num_of_time_rx; | ||
190 | } | ||
191 | else | ||
192 | { | ||
193 | /*Blink pending rate of Tx*/ | ||
194 | if(LED_Blink(Adapter, 1<<GPIO_Num_tx, uiTxLedIndex, timeout, | ||
195 | num_of_time_tx-num_of_time,currdriverstate) == EVENT_SIGNALED) | ||
196 | { | ||
197 | return EVENT_SIGNALED; | ||
198 | } | ||
199 | num_of_time = num_of_time_tx; | ||
200 | } | ||
201 | } | ||
202 | else | ||
203 | { | ||
204 | if(num_of_time == num_of_time_tx) | ||
205 | { | ||
206 | /*Blink pending rate of Rx*/ | ||
207 | if(LED_Blink(Adapter, 1<<GPIO_Num_tx, uiTxLedIndex, timeout, num_of_time,currdriverstate) | ||
208 | == EVENT_SIGNALED) | ||
209 | { | ||
210 | return EVENT_SIGNALED; | ||
211 | } | ||
212 | } | ||
213 | else | ||
214 | { | ||
215 | /*Blink pending rate of Tx*/ | ||
216 | if(LED_Blink(Adapter, 1<<GPIO_Num_rx, uiRxLedIndex, timeout, | ||
217 | num_of_time,currdriverstate) == EVENT_SIGNALED) | ||
218 | { | ||
219 | return EVENT_SIGNALED; | ||
220 | } | ||
221 | } | ||
222 | } | ||
223 | /* If Tx/Rx rate is less than maximum blinks per second, | ||
224 | * wait till delay completes to 1 second | ||
225 | */ | ||
226 | remDelay = MAX_NUM_OF_BLINKS - num_of_time; | ||
227 | if(remDelay > 0) | ||
228 | { | ||
229 | timeout= 100 * remDelay; | ||
230 | Status = wait_event_interruptible_timeout(Adapter->LEDInfo.notify_led_event, | ||
231 | currdriverstate!= Adapter->DriverState ||kthread_should_stop() , | ||
232 | msecs_to_jiffies (timeout)); | ||
233 | |||
234 | if(kthread_should_stop()) | ||
235 | { | ||
236 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL, "Led thread got signal to exit..hence exiting"); | ||
237 | Adapter->LEDInfo.led_thread_running= BCM_LED_THREAD_DISABLED; | ||
238 | return EVENT_SIGNALED; | ||
239 | } | ||
240 | if(Status) | ||
241 | return EVENT_SIGNALED; | ||
242 | } | ||
243 | |||
244 | /*Turn off both Tx and Rx LEDs before next second*/ | ||
245 | TURN_OFF_LED(1<<GPIO_Num_tx, uiTxLedIndex); | ||
246 | TURN_OFF_LED(1<<GPIO_Num_rx, uiTxLedIndex); | ||
247 | |||
248 | /* | ||
249 | * Read the Tx & Rx packets transmission after 1 second and | ||
250 | * calculate rate of transfer | ||
251 | */ | ||
252 | Final_num_of_packts_tx = atomic_read(&Adapter->TxTotalPacketCount); | ||
253 | rate_of_transfer_tx = Final_num_of_packts_tx - Initial_num_of_packts_tx; | ||
254 | Final_num_of_packts_rx = atomic_read(&Adapter->GoodRxPktCount); | ||
255 | rate_of_transfer_rx = Final_num_of_packts_rx - Initial_num_of_packts_rx; | ||
256 | |||
257 | /*Read initial value of packets sent/received */ | ||
258 | Initial_num_of_packts_tx = Final_num_of_packts_tx; | ||
259 | Initial_num_of_packts_rx = Final_num_of_packts_rx ; | ||
260 | |||
261 | /*Scale the rate of transfer to no of blinks.*/ | ||
262 | num_of_time_tx= ScaleRateofTransfer((ULONG)rate_of_transfer_tx); | ||
263 | num_of_time_rx= ScaleRateofTransfer((ULONG)rate_of_transfer_rx); | ||
264 | |||
265 | } | ||
266 | return Status; | ||
267 | } | ||
268 | |||
269 | |||
270 | //----------------------------------------------------------------------------- | ||
271 | // Procedure: ValidateDSDParamsChecksum | ||
272 | // | ||
273 | // Description: Reads DSD Params and validates checkusm. | ||
274 | // | ||
275 | // Arguments: | ||
276 | // Adapter - Pointer to Adapter structure. | ||
277 | // ulParamOffset - Start offset of the DSD parameter to be read and validated. | ||
278 | // usParamLen - Length of the DSD Parameter. | ||
279 | // | ||
280 | // Returns: | ||
281 | // <OSAL_STATUS_CODE> | ||
282 | //----------------------------------------------------------------------------- | ||
283 | |||
284 | INT ValidateDSDParamsChecksum( | ||
285 | PMINI_ADAPTER Adapter, | ||
286 | ULONG ulParamOffset, | ||
287 | USHORT usParamLen ) | ||
288 | { | ||
289 | INT Status = STATUS_SUCCESS; | ||
290 | PUCHAR puBuffer = NULL; | ||
291 | USHORT usChksmOrg = 0; | ||
292 | USHORT usChecksumCalculated = 0; | ||
293 | |||
294 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"LED Thread:ValidateDSDParamsChecksum: 0x%lx 0x%X",ulParamOffset, usParamLen); | ||
295 | |||
296 | puBuffer = OsalMemAlloc(usParamLen,'!MEM'); | ||
297 | if(!puBuffer) | ||
298 | { | ||
299 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"LED Thread: ValidateDSDParamsChecksum Allocation failed"); | ||
300 | return -ENOMEM; | ||
301 | |||
302 | } | ||
303 | |||
304 | // | ||
305 | // Read the DSD data from the parameter offset. | ||
306 | // | ||
307 | if(STATUS_SUCCESS != BeceemNVMRead(Adapter,(PUINT)puBuffer,ulParamOffset,usParamLen)) | ||
308 | { | ||
309 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"LED Thread: ValidateDSDParamsChecksum BeceemNVMRead failed"); | ||
310 | Status=STATUS_IMAGE_CHECKSUM_MISMATCH; | ||
311 | goto exit; | ||
312 | } | ||
313 | |||
314 | // | ||
315 | // Calculate the checksum of the data read from the DSD parameter. | ||
316 | // | ||
317 | usChecksumCalculated = CFG_CalculateChecksum(puBuffer,usParamLen); | ||
318 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"LED Thread: usCheckSumCalculated = 0x%x\n", usChecksumCalculated); | ||
319 | |||
320 | // | ||
321 | // End of the DSD parameter will have a TWO bytes checksum stored in it. Read it and compare with the calculated | ||
322 | // Checksum. | ||
323 | // | ||
324 | if(STATUS_SUCCESS != BeceemNVMRead(Adapter,(PUINT)&usChksmOrg,ulParamOffset+usParamLen,2)) | ||
325 | { | ||
326 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"LED Thread: ValidateDSDParamsChecksum BeceemNVMRead failed"); | ||
327 | Status=STATUS_IMAGE_CHECKSUM_MISMATCH; | ||
328 | goto exit; | ||
329 | } | ||
330 | usChksmOrg = ntohs(usChksmOrg); | ||
331 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"LED Thread: usChksmOrg = 0x%x", usChksmOrg); | ||
332 | |||
333 | // | ||
334 | // Compare the checksum calculated with the checksum read from DSD section | ||
335 | // | ||
336 | if(usChecksumCalculated ^ usChksmOrg) | ||
337 | { | ||
338 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"LED Thread: ValidateDSDParamsChecksum: Checksums don't match"); | ||
339 | Status = STATUS_IMAGE_CHECKSUM_MISMATCH; | ||
340 | goto exit; | ||
341 | } | ||
342 | |||
343 | exit: | ||
344 | if(puBuffer) | ||
345 | { | ||
346 | OsalMemFree(puBuffer, usParamLen); | ||
347 | } | ||
348 | return Status; | ||
349 | } | ||
350 | |||
351 | |||
352 | //----------------------------------------------------------------------------- | ||
353 | // Procedure: ValidateHWParmStructure | ||
354 | // | ||
355 | // Description: Validates HW Parameters. | ||
356 | // | ||
357 | // Arguments: | ||
358 | // Adapter - Pointer to Adapter structure. | ||
359 | // ulHwParamOffset - Start offset of the HW parameter Section to be read and validated. | ||
360 | // | ||
361 | // Returns: | ||
362 | // <OSAL_STATUS_CODE> | ||
363 | //----------------------------------------------------------------------------- | ||
364 | |||
365 | INT ValidateHWParmStructure(PMINI_ADAPTER Adapter, ULONG ulHwParamOffset) | ||
366 | { | ||
367 | |||
368 | INT Status = STATUS_SUCCESS ; | ||
369 | USHORT HwParamLen = 0; | ||
370 | // Add DSD start offset to the hwParamOffset to get the actual address. | ||
371 | ulHwParamOffset += DSD_START_OFFSET; | ||
372 | |||
373 | /*Read the Length of HW_PARAM structure*/ | ||
374 | BeceemNVMRead(Adapter,(PUINT)&HwParamLen,ulHwParamOffset,2); | ||
375 | HwParamLen = ntohs(HwParamLen); | ||
376 | if(0==HwParamLen || HwParamLen > Adapter->uiNVMDSDSize) | ||
377 | { | ||
378 | return STATUS_IMAGE_CHECKSUM_MISMATCH; | ||
379 | } | ||
380 | |||
381 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL, "LED Thread:HwParamLen = 0x%x", HwParamLen); | ||
382 | Status =ValidateDSDParamsChecksum(Adapter,ulHwParamOffset,HwParamLen); | ||
383 | return Status; | ||
384 | } /* ValidateHWParmStructure() */ | ||
385 | |||
386 | int ReadLEDInformationFromEEPROM(PMINI_ADAPTER Adapter, UCHAR GPIO_Array[]) | ||
387 | { | ||
388 | int Status = STATUS_SUCCESS; | ||
389 | |||
390 | ULONG dwReadValue = 0; | ||
391 | USHORT usHwParamData = 0; | ||
392 | USHORT usEEPROMVersion = 0; | ||
393 | UCHAR ucIndex = 0; | ||
394 | UCHAR ucGPIOInfo[32] = {0}; | ||
395 | |||
396 | BeceemNVMRead(Adapter,(PUINT)&usEEPROMVersion,EEPROM_VERSION_OFFSET,2); | ||
397 | |||
398 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"usEEPROMVersion: Minor:0x%X Major:0x%x",usEEPROMVersion&0xFF, ((usEEPROMVersion>>8)&0xFF)); | ||
399 | |||
400 | |||
401 | if(((usEEPROMVersion>>8)&0xFF) < EEPROM_MAP5_MAJORVERSION) | ||
402 | { | ||
403 | BeceemNVMRead(Adapter,(PUINT)&usHwParamData,EEPROM_HW_PARAM_POINTER_ADDRESS,2); | ||
404 | usHwParamData = ntohs(usHwParamData); | ||
405 | dwReadValue = usHwParamData; | ||
406 | } | ||
407 | else | ||
408 | { | ||
409 | // | ||
410 | // Validate Compatibility section and then read HW param if compatibility section is valid. | ||
411 | // | ||
412 | Status = ValidateDSDParamsChecksum(Adapter, | ||
413 | DSD_START_OFFSET, | ||
414 | COMPATIBILITY_SECTION_LENGTH_MAP5); | ||
415 | |||
416 | if(Status != STATUS_SUCCESS) | ||
417 | { | ||
418 | return Status; | ||
419 | } | ||
420 | BeceemNVMRead(Adapter,(PUINT)&dwReadValue,EEPROM_HW_PARAM_POINTER_ADDRRES_MAP5,4); | ||
421 | dwReadValue = ntohl(dwReadValue); | ||
422 | } | ||
423 | |||
424 | |||
425 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"LED Thread: Start address of HW_PARAM structure = 0x%lx",dwReadValue); | ||
426 | |||
427 | // | ||
428 | // Validate if the address read out is within the DSD. | ||
429 | // Adapter->uiNVMDSDSize gives whole DSD size inclusive of Autoinit. | ||
430 | // lower limit should be above DSD_START_OFFSET and | ||
431 | // upper limit should be below (Adapter->uiNVMDSDSize-DSD_START_OFFSET) | ||
432 | // | ||
433 | if(dwReadValue < DSD_START_OFFSET || | ||
434 | dwReadValue > (Adapter->uiNVMDSDSize-DSD_START_OFFSET)) | ||
435 | { | ||
436 | return STATUS_IMAGE_CHECKSUM_MISMATCH; | ||
437 | } | ||
438 | |||
439 | Status = ValidateHWParmStructure(Adapter, dwReadValue); | ||
440 | if(Status){ | ||
441 | return Status; | ||
442 | } | ||
443 | |||
444 | /* | ||
445 | Add DSD_START_OFFSET to the offset read from the EEPROM. | ||
446 | This will give the actual start HW Parameters start address. | ||
447 | To read GPIO section, add GPIO offset further. | ||
448 | */ | ||
449 | |||
450 | dwReadValue += DSD_START_OFFSET; // = start address of hw param section. | ||
451 | dwReadValue += GPIO_SECTION_START_OFFSET; // = GPIO start offset within HW Param section. | ||
452 | |||
453 | /* Read the GPIO values for 32 GPIOs from EEPROM and map the function | ||
454 | * number to GPIO pin number to GPIO_Array | ||
455 | */ | ||
456 | BeceemNVMRead(Adapter, (UINT *)ucGPIOInfo,dwReadValue,32); | ||
457 | for(ucIndex = 0; ucIndex < 32; ucIndex++) | ||
458 | { | ||
459 | |||
460 | switch(ucGPIOInfo[ucIndex]) | ||
461 | { | ||
462 | case RED_LED: | ||
463 | { | ||
464 | GPIO_Array[RED_LED] = ucIndex; | ||
465 | Adapter->gpioBitMap |= (1<<ucIndex); | ||
466 | break; | ||
467 | } | ||
468 | case BLUE_LED: | ||
469 | { | ||
470 | GPIO_Array[BLUE_LED] = ucIndex; | ||
471 | Adapter->gpioBitMap |= (1<<ucIndex); | ||
472 | break; | ||
473 | } | ||
474 | case YELLOW_LED: | ||
475 | { | ||
476 | GPIO_Array[YELLOW_LED] = ucIndex; | ||
477 | Adapter->gpioBitMap |= (1<<ucIndex); | ||
478 | break; | ||
479 | } | ||
480 | case GREEN_LED: | ||
481 | { | ||
482 | GPIO_Array[GREEN_LED] = ucIndex; | ||
483 | Adapter->gpioBitMap |= (1<<ucIndex); | ||
484 | break; | ||
485 | } | ||
486 | default: | ||
487 | break; | ||
488 | } | ||
489 | |||
490 | } | ||
491 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"GPIO's bit map correspond to LED :0x%X",Adapter->gpioBitMap); | ||
492 | return Status; | ||
493 | } | ||
494 | |||
495 | |||
496 | int ReadConfigFileStructure(PMINI_ADAPTER Adapter, BOOLEAN *bEnableThread) | ||
497 | { | ||
498 | int Status = STATUS_SUCCESS; | ||
499 | UCHAR GPIO_Array[NUM_OF_LEDS+1]; /*Array to store GPIO numbers from EEPROM*/ | ||
500 | #ifndef BCM_SHM_INTERFACE | ||
501 | UINT uiIndex = 0; | ||
502 | UINT uiNum_of_LED_Type = 0; | ||
503 | PUCHAR puCFGData = NULL; | ||
504 | UCHAR bData = 0; | ||
505 | #endif | ||
506 | memset(GPIO_Array, DISABLE_GPIO_NUM, NUM_OF_LEDS+1); | ||
507 | |||
508 | if(!Adapter->pstargetparams || IS_ERR(Adapter->pstargetparams)) | ||
509 | { | ||
510 | BCM_DEBUG_PRINT (Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL, "Target Params not Avail.\n"); | ||
511 | return -ENOENT; | ||
512 | } | ||
513 | |||
514 | /*Populate GPIO_Array with GPIO numbers for LED functions*/ | ||
515 | /*Read the GPIO numbers from EEPROM*/ | ||
516 | Status = ReadLEDInformationFromEEPROM(Adapter, GPIO_Array); | ||
517 | if(Status == STATUS_IMAGE_CHECKSUM_MISMATCH) | ||
518 | { | ||
519 | *bEnableThread = FALSE; | ||
520 | return STATUS_SUCCESS; | ||
521 | } | ||
522 | else if(Status) | ||
523 | { | ||
524 | *bEnableThread = FALSE; | ||
525 | return Status; | ||
526 | } | ||
527 | #ifdef BCM_SHM_INTERFACE | ||
528 | *bEnableThread = FALSE; | ||
529 | return Status ; | ||
530 | #else | ||
531 | /* | ||
532 | * CONFIG file read successfully. Deallocate the memory of | ||
533 | * uiFileNameBufferSize | ||
534 | */ | ||
535 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"LED Thread: Config file read successfully\n"); | ||
536 | puCFGData = (PUCHAR) &Adapter->pstargetparams->HostDrvrConfig1; | ||
537 | |||
538 | /* | ||
539 | * Offset for HostDrvConfig1, HostDrvConfig2, HostDrvConfig3 which | ||
540 | * will have the information of LED type, LED on state for different | ||
541 | * driver state and LED blink state. | ||
542 | */ | ||
543 | |||
544 | for(uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) | ||
545 | { | ||
546 | bData = *puCFGData; | ||
547 | |||
548 | /*Check Bit 8 for polarity. If it is set, polarity is reverse polarity*/ | ||
549 | if(bData & 0x80) | ||
550 | { | ||
551 | Adapter->LEDInfo.LEDState[uiIndex].BitPolarity = 0; | ||
552 | /*unset the bit 8*/ | ||
553 | bData = bData & 0x7f; | ||
554 | } | ||
555 | |||
556 | Adapter->LEDInfo.LEDState[uiIndex].LED_Type = bData; | ||
557 | if(bData <= NUM_OF_LEDS) | ||
558 | Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num = GPIO_Array[bData]; | ||
559 | else | ||
560 | Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num = DISABLE_GPIO_NUM; | ||
561 | |||
562 | puCFGData++; | ||
563 | bData = *puCFGData; | ||
564 | Adapter->LEDInfo.LEDState[uiIndex].LED_On_State = bData; | ||
565 | puCFGData++; | ||
566 | bData = *puCFGData; | ||
567 | Adapter->LEDInfo.LEDState[uiIndex].LED_Blink_State= bData; | ||
568 | puCFGData++; | ||
569 | } | ||
570 | |||
571 | /*Check if all the LED settings are disabled. If it is disabled, dont launch the LED control thread.*/ | ||
572 | for(uiIndex = 0; uiIndex<NUM_OF_LEDS; uiIndex++) | ||
573 | { | ||
574 | if((Adapter->LEDInfo.LEDState[uiIndex].LED_Type == DISABLE_GPIO_NUM) || | ||
575 | (Adapter->LEDInfo.LEDState[uiIndex].LED_Type == 0x7f) || | ||
576 | (Adapter->LEDInfo.LEDState[uiIndex].LED_Type == 0)) | ||
577 | uiNum_of_LED_Type++; | ||
578 | } | ||
579 | if(uiNum_of_LED_Type >= NUM_OF_LEDS) | ||
580 | *bEnableThread = FALSE; | ||
581 | #endif | ||
582 | |||
583 | #if 0 | ||
584 | for(uiIndex=0; uiIndex<NUM_OF_LEDS; uiIndex++) | ||
585 | { | ||
586 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"LEDState[%d].LED_Type = %x\n", uiIndex, | ||
587 | Adapter->LEDInfo.LEDState[uiIndex].LED_Type); | ||
588 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"LEDState[%d].LED_On_State = %x\n", uiIndex, | ||
589 | Adapter->LEDInfo.LEDState[uiIndex].LED_On_State); | ||
590 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"LEDState[%d].LED_Blink_State = %x\n", uiIndex, | ||
591 | Adapter->LEDInfo.LEDState[uiIndex].LED_Blink_State); | ||
592 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"LEDState[%d].GPIO_Num = %x\n", uiIndex, | ||
593 | Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num); | ||
594 | } | ||
595 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"LED Thread: Polarity = %d\n", | ||
596 | Adapter->LEDInfo.BitPolarty); | ||
597 | #endif | ||
598 | return Status; | ||
599 | } | ||
600 | //-------------------------------------------------------------------------- | ||
601 | // Procedure: LedGpioInit | ||
602 | // | ||
603 | // Description: Initializes LED GPIOs. Makes the LED GPIOs to OUTPUT mode and make the | ||
604 | // initial state to be OFF. | ||
605 | // | ||
606 | // Arguments: | ||
607 | // Adapter - Pointer to MINI_ADAPTER structure. | ||
608 | // | ||
609 | // Returns: VOID | ||
610 | // | ||
611 | //----------------------------------------------------------------------------- | ||
612 | |||
613 | VOID LedGpioInit(PMINI_ADAPTER Adapter) | ||
614 | { | ||
615 | UINT uiResetValue = 0; | ||
616 | UINT uiIndex = 0; | ||
617 | |||
618 | /* Set all LED GPIO Mode to output mode */ | ||
619 | if(rdmalt(Adapter, GPIO_MODE_REGISTER, &uiResetValue, sizeof(uiResetValue)) <0) | ||
620 | BCM_DEBUG_PRINT (Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"LED Thread: RDM Failed\n"); | ||
621 | for(uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) | ||
622 | { | ||
623 | if(Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num != DISABLE_GPIO_NUM) | ||
624 | uiResetValue |= (1 << Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num); | ||
625 | TURN_OFF_LED(1<<Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num,uiIndex); | ||
626 | } | ||
627 | if(wrmalt(Adapter, GPIO_MODE_REGISTER, &uiResetValue, sizeof(uiResetValue)) < 0) | ||
628 | BCM_DEBUG_PRINT (Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"LED Thread: WRM Failed\n"); | ||
629 | |||
630 | Adapter->LEDInfo.bIdle_led_off = FALSE; | ||
631 | } | ||
632 | //----------------------------------------------------------------------------- | ||
633 | |||
634 | INT BcmGetGPIOPinInfo(PMINI_ADAPTER Adapter, UCHAR *GPIO_num_tx, UCHAR *GPIO_num_rx ,UCHAR *uiLedTxIndex, UCHAR *uiLedRxIndex,LedEventInfo_t currdriverstate) | ||
635 | { | ||
636 | UINT uiIndex = 0; | ||
637 | |||
638 | *GPIO_num_tx = DISABLE_GPIO_NUM; | ||
639 | *GPIO_num_rx = DISABLE_GPIO_NUM; | ||
640 | |||
641 | for(uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) | ||
642 | { | ||
643 | |||
644 | if((currdriverstate == NORMAL_OPERATION)|| | ||
645 | (currdriverstate == IDLEMODE_EXIT)|| | ||
646 | (currdriverstate == FW_DOWNLOAD)) | ||
647 | { | ||
648 | if(Adapter->LEDInfo.LEDState[uiIndex].LED_Blink_State & currdriverstate) | ||
649 | { | ||
650 | if(Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num != DISABLE_GPIO_NUM) | ||
651 | { | ||
652 | if(*GPIO_num_tx == DISABLE_GPIO_NUM) | ||
653 | { | ||
654 | *GPIO_num_tx = Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num; | ||
655 | *uiLedTxIndex = uiIndex; | ||
656 | } | ||
657 | else | ||
658 | { | ||
659 | *GPIO_num_rx = Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num; | ||
660 | *uiLedRxIndex = uiIndex; | ||
661 | } | ||
662 | } | ||
663 | } | ||
664 | } | ||
665 | else | ||
666 | { | ||
667 | if(Adapter->LEDInfo.LEDState[uiIndex].LED_On_State & currdriverstate) | ||
668 | { | ||
669 | if(Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num != DISABLE_GPIO_NUM) | ||
670 | { | ||
671 | *GPIO_num_tx = Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num; | ||
672 | *uiLedTxIndex = uiIndex; | ||
673 | } | ||
674 | } | ||
675 | } | ||
676 | } | ||
677 | return STATUS_SUCCESS ; | ||
678 | } | ||
679 | VOID LEDControlThread(PMINI_ADAPTER Adapter) | ||
680 | { | ||
681 | UINT uiIndex = 0; | ||
682 | UCHAR GPIO_num = 0; | ||
683 | UCHAR uiLedIndex = 0 ; | ||
684 | UINT uiResetValue = 0; | ||
685 | LedEventInfo_t currdriverstate = 0; | ||
686 | ulong timeout = 0; | ||
687 | |||
688 | INT Status = 0; | ||
689 | |||
690 | UCHAR dummyGPIONum = 0; | ||
691 | UCHAR dummyIndex = 0; | ||
692 | |||
693 | //currdriverstate = Adapter->DriverState; | ||
694 | Adapter->LEDInfo.bIdleMode_tx_from_host = FALSE; | ||
695 | |||
696 | /*Wait till event is triggered*/ | ||
697 | //wait_event(Adapter->LEDInfo.notify_led_event, | ||
698 | // currdriverstate!= Adapter->DriverState); | ||
699 | |||
700 | GPIO_num = DISABLE_GPIO_NUM ; | ||
701 | |||
702 | while(TRUE) | ||
703 | { | ||
704 | /*Wait till event is triggered*/ | ||
705 | if( (GPIO_num == DISABLE_GPIO_NUM) | ||
706 | || | ||
707 | ((currdriverstate != FW_DOWNLOAD) && | ||
708 | (currdriverstate != NORMAL_OPERATION) && | ||
709 | (currdriverstate != LOWPOWER_MODE_ENTER)) | ||
710 | || | ||
711 | (currdriverstate == LED_THREAD_INACTIVE) ) | ||
712 | { | ||
713 | Status = wait_event_interruptible(Adapter->LEDInfo.notify_led_event, | ||
714 | currdriverstate != Adapter->DriverState || kthread_should_stop()); | ||
715 | } | ||
716 | |||
717 | if(kthread_should_stop() || Adapter->device_removed ) | ||
718 | { | ||
719 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL, "Led thread got signal to exit..hence exiting"); | ||
720 | Adapter->LEDInfo.led_thread_running = BCM_LED_THREAD_DISABLED; | ||
721 | TURN_OFF_LED(1<<GPIO_num, uiLedIndex); | ||
722 | return ;//STATUS_FAILURE; | ||
723 | } | ||
724 | #if 0 | ||
725 | if(Adapter->device_removed) | ||
726 | { | ||
727 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"Device removed hence exiting from Led Thread.."); | ||
728 | return ; //-ENODEV; | ||
729 | } | ||
730 | #endif | ||
731 | #if 0 | ||
732 | if((GPIO_num != DISABLE_GPIO_NUM) && | ||
733 | ((currdriverstate != FW_DOWNLOAD) && | ||
734 | (currdriverstate != NORMAL_OPERATION) && | ||
735 | (currdriverstate != IDLEMODE_EXIT))) | ||
736 | TURN_OFF_LED(1<<GPIO_num, uiLedIndex); | ||
737 | #endif | ||
738 | |||
739 | if(GPIO_num != DISABLE_GPIO_NUM) | ||
740 | { | ||
741 | TURN_OFF_LED(1<<GPIO_num, uiLedIndex); | ||
742 | } | ||
743 | |||
744 | if(Adapter->LEDInfo.bLedInitDone == FALSE) | ||
745 | { | ||
746 | LedGpioInit(Adapter); | ||
747 | Adapter->LEDInfo.bLedInitDone = TRUE; | ||
748 | } | ||
749 | |||
750 | switch(Adapter->DriverState) | ||
751 | { | ||
752 | case DRIVER_INIT: | ||
753 | { | ||
754 | currdriverstate = DRIVER_INIT;//Adapter->DriverState; | ||
755 | #if 0 | ||
756 | LedGpioInit(Adapter); | ||
757 | Adapter->LEDInfo.bLedInitDone = TRUE; | ||
758 | #endif | ||
759 | BcmGetGPIOPinInfo(Adapter, &GPIO_num, &dummyGPIONum, &uiLedIndex, &dummyIndex, currdriverstate); | ||
760 | |||
761 | if(GPIO_num != DISABLE_GPIO_NUM) | ||
762 | { | ||
763 | TURN_ON_LED(1<<GPIO_num, uiLedIndex); | ||
764 | } | ||
765 | } | ||
766 | break; | ||
767 | case FW_DOWNLOAD: | ||
768 | { | ||
769 | //BCM_DEBUG_PRINT (Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"LED Thread: FW_DN_DONE called\n"); | ||
770 | currdriverstate = FW_DOWNLOAD; | ||
771 | #if 0 | ||
772 | if(Adapter->LEDInfo.bLedInitDone == FALSE) | ||
773 | { | ||
774 | LedGpioInit(Adapter); | ||
775 | Adapter->LEDInfo.bLedInitDone = TRUE; | ||
776 | } | ||
777 | #endif | ||
778 | BcmGetGPIOPinInfo(Adapter, &GPIO_num, &dummyGPIONum, &uiLedIndex, &dummyIndex, currdriverstate); | ||
779 | |||
780 | if(GPIO_num != DISABLE_GPIO_NUM) | ||
781 | { | ||
782 | timeout = 50; | ||
783 | LED_Blink(Adapter, 1<<GPIO_num, uiLedIndex, timeout, -1,currdriverstate); | ||
784 | } | ||
785 | } | ||
786 | break; | ||
787 | case FW_DOWNLOAD_DONE: | ||
788 | { | ||
789 | currdriverstate = FW_DOWNLOAD_DONE; | ||
790 | BcmGetGPIOPinInfo(Adapter, &GPIO_num, &dummyGPIONum, &uiLedIndex, &dummyIndex,currdriverstate); | ||
791 | if(GPIO_num != DISABLE_GPIO_NUM) | ||
792 | { | ||
793 | TURN_ON_LED(1<<GPIO_num, uiLedIndex); | ||
794 | } | ||
795 | } | ||
796 | break; | ||
797 | |||
798 | case SHUTDOWN_EXIT: | ||
799 | #if 0 | ||
800 | if(Adapter->ulPowerSaveMode == DEVICE_POWERSAVE_MODE_AS_PMU_SHUTDOWN) | ||
801 | { | ||
802 | LedGpioInit(Adapter); | ||
803 | } | ||
804 | #endif | ||
805 | //no break, continue to NO_NETWORK_ENTRY state as well. | ||
806 | |||
807 | case NO_NETWORK_ENTRY: | ||
808 | { | ||
809 | currdriverstate = NO_NETWORK_ENTRY; | ||
810 | BcmGetGPIOPinInfo(Adapter, &GPIO_num, &dummyGPIONum, &uiLedIndex,&dummyGPIONum,currdriverstate); | ||
811 | if(GPIO_num != DISABLE_GPIO_NUM) | ||
812 | { | ||
813 | TURN_ON_LED(1<<GPIO_num, uiLedIndex); | ||
814 | } | ||
815 | } | ||
816 | break; | ||
817 | case NORMAL_OPERATION: | ||
818 | { | ||
819 | UCHAR GPIO_num_tx = DISABLE_GPIO_NUM; | ||
820 | UCHAR GPIO_num_rx = DISABLE_GPIO_NUM; | ||
821 | UCHAR uiLEDTx = 0; | ||
822 | UCHAR uiLEDRx = 0; | ||
823 | currdriverstate = NORMAL_OPERATION; | ||
824 | Adapter->LEDInfo.bIdle_led_off = FALSE; | ||
825 | |||
826 | BcmGetGPIOPinInfo(Adapter, &GPIO_num_tx, &GPIO_num_rx, &uiLEDTx,&uiLEDRx,currdriverstate); | ||
827 | if((GPIO_num_tx == DISABLE_GPIO_NUM) && (GPIO_num_rx == DISABLE_GPIO_NUM)) | ||
828 | { | ||
829 | GPIO_num = DISABLE_GPIO_NUM ; | ||
830 | } | ||
831 | else | ||
832 | { | ||
833 | /*If single LED is selected, use same for both Tx and Rx*/ | ||
834 | if(GPIO_num_tx == DISABLE_GPIO_NUM) | ||
835 | { | ||
836 | GPIO_num_tx = GPIO_num_rx; | ||
837 | uiLEDTx = uiLEDRx; | ||
838 | } | ||
839 | else if(GPIO_num_rx == DISABLE_GPIO_NUM) | ||
840 | { | ||
841 | GPIO_num_rx = GPIO_num_tx; | ||
842 | uiLEDRx = uiLEDTx; | ||
843 | } | ||
844 | /*Blink the LED in proportionate to Tx and Rx transmissions.*/ | ||
845 | LED_Proportional_Blink(Adapter, GPIO_num_tx, uiLEDTx, GPIO_num_rx, uiLEDRx,currdriverstate); | ||
846 | } | ||
847 | } | ||
848 | break; | ||
849 | case LOWPOWER_MODE_ENTER: | ||
850 | { | ||
851 | currdriverstate = LOWPOWER_MODE_ENTER; | ||
852 | if( DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING == Adapter->ulPowerSaveMode) | ||
853 | { | ||
854 | /* Turn OFF all the LED */ | ||
855 | uiResetValue = 0; | ||
856 | for(uiIndex =0; uiIndex < NUM_OF_LEDS; uiIndex++) | ||
857 | { | ||
858 | if(Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num != DISABLE_GPIO_NUM) | ||
859 | TURN_OFF_LED((1<<Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num),uiIndex); | ||
860 | } | ||
861 | |||
862 | } | ||
863 | /* Turn off LED And WAKE-UP for Sendinf IDLE mode ACK */ | ||
864 | Adapter->LEDInfo.bLedInitDone = FALSE; | ||
865 | Adapter->LEDInfo.bIdle_led_off = TRUE; | ||
866 | wake_up(&Adapter->LEDInfo.idleModeSyncEvent); | ||
867 | GPIO_num = DISABLE_GPIO_NUM; | ||
868 | break; | ||
869 | } | ||
870 | case IDLEMODE_CONTINUE: | ||
871 | { | ||
872 | currdriverstate = IDLEMODE_CONTINUE; | ||
873 | GPIO_num = DISABLE_GPIO_NUM; | ||
874 | } | ||
875 | break; | ||
876 | case IDLEMODE_EXIT: | ||
877 | { | ||
878 | #if 0 | ||
879 | UCHAR GPIO_num_tx = DISABLE_GPIO_NUM; | ||
880 | UCHAR GPIO_num_rx = DISABLE_GPIO_NUM; | ||
881 | UCHAR uiTxLedIndex = 0; | ||
882 | UCHAR uiRxLedIndex = 0; | ||
883 | |||
884 | currdriverstate = IDLEMODE_EXIT; | ||
885 | if(DEVICE_POWERSAVE_MODE_AS_PMU_SHUTDOWN == Adapter->ulPowerSaveMode) | ||
886 | { | ||
887 | LedGpioInit(Adapter); | ||
888 | } | ||
889 | BcmGetGPIOPinInfo(Adapter, &GPIO_num_tx, &GPIO_num_rx, &uiTxLedIndex,&uiRxLedIndex,currdriverstate); | ||
890 | |||
891 | Adapter->LEDInfo.bIdle_led_off = FALSE; | ||
892 | |||
893 | if((GPIO_num_tx == DISABLE_GPIO_NUM) && (GPIO_num_rx == DISABLE_GPIO_NUM)) | ||
894 | { | ||
895 | GPIO_num = DISABLE_GPIO_NUM ; | ||
896 | } | ||
897 | else | ||
898 | { | ||
899 | timeout = 50; | ||
900 | if(Adapter->LEDInfo.bIdleMode_tx_from_host) | ||
901 | LED_Blink(Adapter, 1<<GPIO_num_tx, uiTxLedIndex, timeout, -1,currdriverstate); | ||
902 | else | ||
903 | LED_Blink(Adapter, 1<<GPIO_num_rx, uiRxLedIndex, timeout, -1,currdriverstate); | ||
904 | } | ||
905 | #endif | ||
906 | } | ||
907 | break; | ||
908 | case DRIVER_HALT: | ||
909 | { | ||
910 | currdriverstate = DRIVER_HALT; | ||
911 | GPIO_num = DISABLE_GPIO_NUM; | ||
912 | for(uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) | ||
913 | { | ||
914 | if(Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num != | ||
915 | DISABLE_GPIO_NUM) | ||
916 | TURN_OFF_LED((1<<Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num),uiIndex); | ||
917 | } | ||
918 | //Adapter->DriverState = DRIVER_INIT; | ||
919 | } | ||
920 | break; | ||
921 | case LED_THREAD_INACTIVE : | ||
922 | { | ||
923 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"InActivating LED thread..."); | ||
924 | currdriverstate = LED_THREAD_INACTIVE; | ||
925 | Adapter->LEDInfo.led_thread_running = BCM_LED_THREAD_RUNNING_INACTIVELY ; | ||
926 | Adapter->LEDInfo.bLedInitDone = FALSE ; | ||
927 | //disable ALL LED | ||
928 | for(uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) | ||
929 | { | ||
930 | if(Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num != | ||
931 | DISABLE_GPIO_NUM) | ||
932 | TURN_OFF_LED((1<<Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num),uiIndex); | ||
933 | } | ||
934 | } | ||
935 | break; | ||
936 | case LED_THREAD_ACTIVE : | ||
937 | { | ||
938 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"Activating LED thread again..."); | ||
939 | if(Adapter->LinkUpStatus == FALSE) | ||
940 | Adapter->DriverState = NO_NETWORK_ENTRY; | ||
941 | else | ||
942 | Adapter->DriverState = NORMAL_OPERATION; | ||
943 | |||
944 | Adapter->LEDInfo.led_thread_running = BCM_LED_THREAD_RUNNING_ACTIVELY ; | ||
945 | } | ||
946 | break; | ||
947 | //return; | ||
948 | default: | ||
949 | break; | ||
950 | } | ||
951 | } | ||
952 | Adapter->LEDInfo.led_thread_running = BCM_LED_THREAD_DISABLED; | ||
953 | } | ||
954 | |||
955 | int InitLedSettings(PMINI_ADAPTER Adapter) | ||
956 | { | ||
957 | int Status = STATUS_SUCCESS; | ||
958 | BOOLEAN bEnableThread = TRUE; | ||
959 | UCHAR uiIndex = 0; | ||
960 | |||
961 | /*Initially set BitPolarity to normal polarity. The bit 8 of LED type | ||
962 | * is used to change the polarity of the LED.*/ | ||
963 | |||
964 | for(uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) { | ||
965 | Adapter->LEDInfo.LEDState[uiIndex].BitPolarity = 1; | ||
966 | } | ||
967 | |||
968 | /*Read the LED settings of CONFIG file and map it to GPIO numbers in EEPROM*/ | ||
969 | Status = ReadConfigFileStructure(Adapter, &bEnableThread); | ||
970 | if(STATUS_SUCCESS != Status) | ||
971 | { | ||
972 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL,"LED Thread: FAILED in ReadConfigFileStructure\n"); | ||
973 | return Status; | ||
974 | } | ||
975 | |||
976 | if(Adapter->LEDInfo.led_thread_running) | ||
977 | { | ||
978 | if(bEnableThread) | ||
979 | ; | ||
980 | else | ||
981 | { | ||
982 | Adapter->DriverState = DRIVER_HALT; | ||
983 | wake_up(&Adapter->LEDInfo.notify_led_event); | ||
984 | Adapter->LEDInfo.led_thread_running = BCM_LED_THREAD_DISABLED; | ||
985 | } | ||
986 | |||
987 | } | ||
988 | |||
989 | else if(bEnableThread) | ||
990 | { | ||
991 | /*Create secondary thread to handle the LEDs*/ | ||
992 | init_waitqueue_head(&Adapter->LEDInfo.notify_led_event); | ||
993 | init_waitqueue_head(&Adapter->LEDInfo.idleModeSyncEvent); | ||
994 | Adapter->LEDInfo.led_thread_running = BCM_LED_THREAD_RUNNING_ACTIVELY; | ||
995 | Adapter->LEDInfo.bIdle_led_off = FALSE; | ||
996 | Adapter->LEDInfo.led_cntrl_threadid = kthread_run((int (*)(void *)) | ||
997 | LEDControlThread, Adapter, "led_control_thread"); | ||
998 | if(IS_ERR(Adapter->LEDInfo.led_cntrl_threadid)) | ||
999 | { | ||
1000 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL, "Not able to spawn Kernel Thread\n"); | ||
1001 | Adapter->LEDInfo.led_thread_running = BCM_LED_THREAD_DISABLED; | ||
1002 | return PTR_ERR(Adapter->LEDInfo.led_cntrl_threadid); | ||
1003 | } | ||
1004 | } | ||
1005 | return Status; | ||
1006 | } | ||
diff --git a/drivers/staging/bcm/led_control.h b/drivers/staging/bcm/led_control.h new file mode 100644 index 00000000000..0711ac20f6f --- /dev/null +++ b/drivers/staging/bcm/led_control.h | |||
@@ -0,0 +1,106 @@ | |||
1 | #ifndef _LED_CONTROL_H | ||
2 | #define _LED_CONTROL_H | ||
3 | |||
4 | /*************************TYPE DEF**********************/ | ||
5 | #define NUM_OF_LEDS 4 | ||
6 | |||
7 | #define DSD_START_OFFSET 0x0200 | ||
8 | #define EEPROM_VERSION_OFFSET 0x020E | ||
9 | #define EEPROM_HW_PARAM_POINTER_ADDRESS 0x0218 | ||
10 | #define EEPROM_HW_PARAM_POINTER_ADDRRES_MAP5 0x0220 | ||
11 | #define GPIO_SECTION_START_OFFSET 0x03 | ||
12 | |||
13 | #define COMPATIBILITY_SECTION_LENGTH 42 | ||
14 | #define COMPATIBILITY_SECTION_LENGTH_MAP5 84 | ||
15 | |||
16 | |||
17 | #define EEPROM_MAP5_MAJORVERSION 5 | ||
18 | #define EEPROM_MAP5_MINORVERSION 0 | ||
19 | |||
20 | |||
21 | #define MAX_NUM_OF_BLINKS 10 | ||
22 | #define NUM_OF_GPIO_PINS 16 | ||
23 | |||
24 | #define DISABLE_GPIO_NUM 0xFF | ||
25 | #define EVENT_SIGNALED 1 | ||
26 | |||
27 | #define MAX_FILE_NAME_BUFFER_SIZE 100 | ||
28 | |||
29 | #define TURN_ON_LED(GPIO, index) do{ \ | ||
30 | UINT gpio_val = GPIO; \ | ||
31 | (Adapter->LEDInfo.LEDState[index].BitPolarity == 1) ? \ | ||
32 | wrmaltWithLock(Adapter,BCM_GPIO_OUTPUT_SET_REG, &gpio_val ,sizeof(gpio_val)) : \ | ||
33 | wrmaltWithLock(Adapter,BCM_GPIO_OUTPUT_CLR_REG, &gpio_val, sizeof(gpio_val)); \ | ||
34 | }while(0); | ||
35 | |||
36 | #define TURN_OFF_LED(GPIO, index) do { \ | ||
37 | UINT gpio_val = GPIO; \ | ||
38 | (Adapter->LEDInfo.LEDState[index].BitPolarity == 1) ? \ | ||
39 | wrmaltWithLock(Adapter,BCM_GPIO_OUTPUT_CLR_REG,&gpio_val ,sizeof(gpio_val)) : \ | ||
40 | wrmaltWithLock(Adapter,BCM_GPIO_OUTPUT_SET_REG,&gpio_val ,sizeof(gpio_val)); \ | ||
41 | }while(0); | ||
42 | |||
43 | #define B_ULONG32 unsigned long | ||
44 | |||
45 | /*******************************************************/ | ||
46 | |||
47 | |||
48 | typedef enum _LEDColors{ | ||
49 | RED_LED = 1, | ||
50 | BLUE_LED = 2, | ||
51 | YELLOW_LED = 3, | ||
52 | GREEN_LED = 4 | ||
53 | } LEDColors; /*Enumerated values of different LED types*/ | ||
54 | |||
55 | typedef enum LedEvents { | ||
56 | SHUTDOWN_EXIT = 0x00, | ||
57 | DRIVER_INIT = 0x1, | ||
58 | FW_DOWNLOAD = 0x2, | ||
59 | FW_DOWNLOAD_DONE = 0x4, | ||
60 | NO_NETWORK_ENTRY = 0x8, | ||
61 | NORMAL_OPERATION = 0x10, | ||
62 | LOWPOWER_MODE_ENTER = 0x20, | ||
63 | IDLEMODE_CONTINUE = 0x40, | ||
64 | IDLEMODE_EXIT = 0x80, | ||
65 | LED_THREAD_INACTIVE = 0x100, //Makes the LED thread Inactivce. It wil be equivallent to putting the thread on hold. | ||
66 | LED_THREAD_ACTIVE = 0x200 //Makes the LED Thread Active back. | ||
67 | } LedEventInfo_t; /*Enumerated values of different driver states*/ | ||
68 | |||
69 | #define DRIVER_HALT 0xff | ||
70 | |||
71 | |||
72 | /*Structure which stores the information of different LED types | ||
73 | * and corresponding LED state information of driver states*/ | ||
74 | typedef struct LedStateInfo_t | ||
75 | { | ||
76 | UCHAR LED_Type; /* specify GPIO number - use 0xFF if not used */ | ||
77 | UCHAR LED_On_State; /* Bits set or reset for different states */ | ||
78 | UCHAR LED_Blink_State; /* Bits set or reset for blinking LEDs for different states */ | ||
79 | UCHAR GPIO_Num; | ||
80 | UCHAR BitPolarity; /*To represent whether H/W is normal polarity or reverse | ||
81 | polarity*/ | ||
82 | }LEDStateInfo, *pLEDStateInfo; | ||
83 | |||
84 | |||
85 | typedef struct _LED_INFO_STRUCT | ||
86 | { | ||
87 | LEDStateInfo LEDState[NUM_OF_LEDS]; | ||
88 | BOOLEAN bIdleMode_tx_from_host; /*Variable to notify whether driver came out | ||
89 | from idlemode due to Host or target*/ | ||
90 | BOOLEAN bIdle_led_off; | ||
91 | wait_queue_head_t notify_led_event; | ||
92 | wait_queue_head_t idleModeSyncEvent; | ||
93 | struct task_struct *led_cntrl_threadid; | ||
94 | int led_thread_running; | ||
95 | BOOLEAN bLedInitDone; | ||
96 | |||
97 | } LED_INFO_STRUCT, *PLED_INFO_STRUCT; | ||
98 | //LED Thread state. | ||
99 | #define BCM_LED_THREAD_DISABLED 0 //LED Thread is not running. | ||
100 | #define BCM_LED_THREAD_RUNNING_ACTIVELY 1 //LED thread is running. | ||
101 | #define BCM_LED_THREAD_RUNNING_INACTIVELY 2 //LED thread has been put on hold | ||
102 | |||
103 | |||
104 | |||
105 | #endif | ||
106 | |||
diff --git a/drivers/staging/bcm/nvm.c b/drivers/staging/bcm/nvm.c new file mode 100644 index 00000000000..35ff4e761f7 --- /dev/null +++ b/drivers/staging/bcm/nvm.c | |||
@@ -0,0 +1,5614 @@ | |||
1 | #include "headers.h" | ||
2 | |||
3 | #define DWORD unsigned int | ||
4 | // Procedure: ReadEEPROMStatusRegister | ||
5 | // | ||
6 | // Description: Reads the standard EEPROM Status Register. | ||
7 | // | ||
8 | // Arguments: | ||
9 | // Adapter - ptr to Adapter object instance | ||
10 | // Returns: | ||
11 | // OSAL_STATUS_CODE | ||
12 | // | ||
13 | //----------------------------------------------------------------------------- | ||
14 | |||
15 | UCHAR ReadEEPROMStatusRegister( PMINI_ADAPTER Adapter ) | ||
16 | { | ||
17 | UCHAR uiData = 0; | ||
18 | DWORD dwRetries = MAX_EEPROM_RETRIES*RETRIES_PER_DELAY; | ||
19 | UINT uiStatus = 0; | ||
20 | UINT value = 0; | ||
21 | UINT value1 = 0; | ||
22 | |||
23 | /* Read the EEPROM status register */ | ||
24 | value = EEPROM_READ_STATUS_REGISTER ; | ||
25 | wrmalt( Adapter, EEPROM_CMDQ_SPI_REG, &value, sizeof(value)); | ||
26 | |||
27 | while ( dwRetries != 0 ) | ||
28 | { | ||
29 | value=0; | ||
30 | uiStatus = 0 ; | ||
31 | rdmalt( Adapter, EEPROM_SPI_Q_STATUS1_REG,&uiStatus, sizeof(uiStatus)); | ||
32 | if(Adapter->device_removed == TRUE) | ||
33 | { | ||
34 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Modem has got removed hence exiting...."); | ||
35 | break; | ||
36 | } | ||
37 | |||
38 | /* Wait for Avail bit to be set. */ | ||
39 | if ( ( uiStatus & EEPROM_READ_DATA_AVAIL) != 0 ) | ||
40 | { | ||
41 | /* Clear the Avail/Full bits - which ever is set. */ | ||
42 | value = uiStatus & (EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL); | ||
43 | wrmalt( Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value)); | ||
44 | |||
45 | value =0; | ||
46 | rdmalt(Adapter, EEPROM_READ_DATAQ_REG,&value, sizeof(value)); | ||
47 | uiData = (UCHAR)value; | ||
48 | |||
49 | break; | ||
50 | } | ||
51 | |||
52 | dwRetries-- ; | ||
53 | if ( dwRetries == 0 ) | ||
54 | { | ||
55 | rdmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG,&value, sizeof(value)); | ||
56 | rdmalt(Adapter, EEPROM_SPI_Q_STATUS_REG,&value1, sizeof(value1)); | ||
57 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"0x3004 = %x 0x3008 = %x, retries = %d failed.\n",value,value1, MAX_EEPROM_RETRIES*RETRIES_PER_DELAY); | ||
58 | return uiData; | ||
59 | } | ||
60 | if( !(dwRetries%RETRIES_PER_DELAY) ) | ||
61 | msleep(1); | ||
62 | uiStatus = 0 ; | ||
63 | } | ||
64 | return uiData; | ||
65 | } /* ReadEEPROMStatusRegister */ | ||
66 | |||
67 | //----------------------------------------------------------------------------- | ||
68 | // Procedure: ReadBeceemEEPROMBulk | ||
69 | // | ||
70 | // Description: This routine reads 16Byte data from EEPROM | ||
71 | // | ||
72 | // Arguments: | ||
73 | // Adapter - ptr to Adapter object instance | ||
74 | // dwAddress - EEPROM Offset to read the data from. | ||
75 | // pdwData - Pointer to double word where data needs to be stored in. // dwNumWords - Number of words. Valid values are 4 ONLY. | ||
76 | // | ||
77 | // Returns: | ||
78 | // OSAL_STATUS_CODE: | ||
79 | //----------------------------------------------------------------------------- | ||
80 | |||
81 | INT ReadBeceemEEPROMBulk( PMINI_ADAPTER Adapter, | ||
82 | DWORD dwAddress, | ||
83 | DWORD *pdwData, | ||
84 | DWORD dwNumWords | ||
85 | ) | ||
86 | { | ||
87 | DWORD dwIndex = 0; | ||
88 | DWORD dwRetries = MAX_EEPROM_RETRIES*RETRIES_PER_DELAY; | ||
89 | UINT uiStatus = 0; | ||
90 | UINT value= 0; | ||
91 | UINT value1 = 0; | ||
92 | UCHAR *pvalue; | ||
93 | |||
94 | /* Flush the read and cmd queue. */ | ||
95 | value=( EEPROM_READ_QUEUE_FLUSH | EEPROM_CMD_QUEUE_FLUSH ); | ||
96 | wrmalt( Adapter, SPI_FLUSH_REG, &value, sizeof(value) ); | ||
97 | value=0; | ||
98 | wrmalt( Adapter, SPI_FLUSH_REG, &value, sizeof(value)); | ||
99 | |||
100 | /* Clear the Avail/Full bits. */ | ||
101 | value=( EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL ); | ||
102 | wrmalt( Adapter, EEPROM_SPI_Q_STATUS1_REG,&value, sizeof(value)); | ||
103 | |||
104 | value= dwAddress | ( (dwNumWords == 4) ? EEPROM_16_BYTE_PAGE_READ : EEPROM_4_BYTE_PAGE_READ ); | ||
105 | wrmalt( Adapter, EEPROM_CMDQ_SPI_REG, &value, sizeof(value)); | ||
106 | |||
107 | while ( dwRetries != 0 ) | ||
108 | { | ||
109 | |||
110 | uiStatus = 0; | ||
111 | rdmalt( Adapter, EEPROM_SPI_Q_STATUS1_REG, &uiStatus, sizeof(uiStatus)); | ||
112 | if(Adapter->device_removed == TRUE) | ||
113 | { | ||
114 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Modem has got Removed.hence exiting from loop..."); | ||
115 | return -ENODEV; | ||
116 | } | ||
117 | |||
118 | /* If we are reading 16 bytes we want to be sure that the queue | ||
119 | * is full before we read. In the other cases we are ok if the | ||
120 | * queue has data available */ | ||
121 | if ( dwNumWords == 4 ) | ||
122 | { | ||
123 | if ( ( uiStatus & EEPROM_READ_DATA_FULL ) != 0 ) | ||
124 | { | ||
125 | /* Clear the Avail/Full bits - which ever is set. */ | ||
126 | value = ( uiStatus & (EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL) ) ; | ||
127 | wrmalt( Adapter, EEPROM_SPI_Q_STATUS1_REG,&value, sizeof(value)); | ||
128 | break; | ||
129 | } | ||
130 | } | ||
131 | else if ( dwNumWords == 1 ) | ||
132 | { | ||
133 | |||
134 | if ( ( uiStatus & EEPROM_READ_DATA_AVAIL ) != 0 ) | ||
135 | { | ||
136 | /* We just got Avail and we have to read 32bits so we | ||
137 | * need this sleep for Cardbus kind of devices. */ | ||
138 | if (Adapter->chip_id == 0xBECE0210 ) | ||
139 | udelay(800); | ||
140 | |||
141 | /* Clear the Avail/Full bits - which ever is set. */ | ||
142 | value=( uiStatus & (EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL) ); | ||
143 | wrmalt( Adapter, EEPROM_SPI_Q_STATUS1_REG,&value, sizeof(value)); | ||
144 | break; | ||
145 | } | ||
146 | } | ||
147 | |||
148 | uiStatus = 0; | ||
149 | |||
150 | dwRetries--; | ||
151 | if(dwRetries == 0) | ||
152 | { | ||
153 | value=0; | ||
154 | value1=0; | ||
155 | rdmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG,&value, sizeof(value)); | ||
156 | rdmalt(Adapter, EEPROM_SPI_Q_STATUS_REG,&value1, sizeof(value1)); | ||
157 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "dwNumWords %d 0x3004 = %x 0x3008 = %x retries = %d failed.\n", dwNumWords, value, value1, MAX_EEPROM_RETRIES*RETRIES_PER_DELAY); | ||
158 | return STATUS_FAILURE; | ||
159 | } | ||
160 | if( !(dwRetries%RETRIES_PER_DELAY) ) | ||
161 | msleep(1); | ||
162 | } | ||
163 | |||
164 | for ( dwIndex = 0; dwIndex < dwNumWords ; dwIndex++ ) | ||
165 | { | ||
166 | /* We get only a byte at a time - from LSB to MSB. We shift it into an integer. */ | ||
167 | pvalue = (PUCHAR)(pdwData + dwIndex); | ||
168 | |||
169 | value =0; | ||
170 | rdmalt(Adapter, EEPROM_READ_DATAQ_REG,&value, sizeof(value)); | ||
171 | |||
172 | pvalue[0] = value; | ||
173 | |||
174 | value = 0; | ||
175 | rdmalt(Adapter, EEPROM_READ_DATAQ_REG,&value, sizeof(value)); | ||
176 | |||
177 | pvalue[1] = value; | ||
178 | |||
179 | value =0; | ||
180 | rdmalt(Adapter, EEPROM_READ_DATAQ_REG,&value, sizeof(value)); | ||
181 | |||
182 | pvalue[2] = value; | ||
183 | |||
184 | value = 0; | ||
185 | rdmalt(Adapter, EEPROM_READ_DATAQ_REG,&value, sizeof(value)); | ||
186 | |||
187 | pvalue[3] = value; | ||
188 | } | ||
189 | |||
190 | return STATUS_SUCCESS; | ||
191 | } /* ReadBeceemEEPROMBulk() */ | ||
192 | |||
193 | //----------------------------------------------------------------------------- | ||
194 | // Procedure: ReadBeceemEEPROM | ||
195 | // | ||
196 | // Description: This routine reads 4 data from EEPROM. It uses 1 or 2 page | ||
197 | // reads to do this operation. | ||
198 | // | ||
199 | // Arguments: | ||
200 | // Adapter - ptr to Adapter object instance | ||
201 | // uiOffset - EEPROM Offset to read the data from. | ||
202 | // pBuffer - Pointer to word where data needs to be stored in. | ||
203 | // | ||
204 | // Returns: | ||
205 | // OSAL_STATUS_CODE: | ||
206 | //----------------------------------------------------------------------------- | ||
207 | |||
208 | INT ReadBeceemEEPROM( PMINI_ADAPTER Adapter, | ||
209 | DWORD uiOffset, | ||
210 | DWORD *pBuffer | ||
211 | ) | ||
212 | { | ||
213 | UINT uiData[8] = {0}; | ||
214 | UINT uiByteOffset = 0; | ||
215 | UINT uiTempOffset = 0; | ||
216 | |||
217 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL," ====> "); | ||
218 | |||
219 | uiTempOffset = uiOffset - (uiOffset % MAX_RW_SIZE); | ||
220 | uiByteOffset = uiOffset - uiTempOffset; | ||
221 | |||
222 | ReadBeceemEEPROMBulk(Adapter, uiTempOffset, (PUINT)&uiData[0], 4); | ||
223 | |||
224 | /* A word can overlap at most over 2 pages. In that case we read the | ||
225 | * next page too. */ | ||
226 | if ( uiByteOffset > 12 ) | ||
227 | { | ||
228 | ReadBeceemEEPROMBulk(Adapter, uiTempOffset + MAX_RW_SIZE, (PUINT)&uiData[4], 4); | ||
229 | } | ||
230 | |||
231 | OsalMemMove( (PUCHAR) pBuffer, ( ((PUCHAR)&uiData[0]) + uiByteOffset ), 4); | ||
232 | |||
233 | return STATUS_SUCCESS; | ||
234 | } /* ReadBeceemEEPROM() */ | ||
235 | |||
236 | |||
237 | #if 0 | ||
238 | //----------------------------------------------------------------------------- | ||
239 | // Procedure: IsEEPROMWriteDone | ||
240 | // | ||
241 | // Description: Reads the SPI status to see the status of previous write. | ||
242 | // | ||
243 | // Arguments: | ||
244 | // Adapter - ptr to Adapter object instance | ||
245 | // | ||
246 | // Returns: | ||
247 | // BOOLEAN - TRUE - write went through | ||
248 | // - FALSE - Write Failed. | ||
249 | //----------------------------------------------------------------------------- | ||
250 | |||
251 | BOOLEAN IsEEPROMWriteDone(PMINI_ADAPTER Adapter) | ||
252 | { | ||
253 | UINT uiRetries = 16; | ||
254 | //UINT uiStatus = 0; | ||
255 | UINT value; | ||
256 | |||
257 | //sleep for 1.2ms ..worst case EEPROM write can take up to 1.2ms. | ||
258 | mdelay(2); | ||
259 | |||
260 | value = 0; | ||
261 | rdmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value)); | ||
262 | |||
263 | while(((value >> 14) & 1) == 1) | ||
264 | { | ||
265 | // EEPROM_SPI_Q_STATUS1_REG will be cleared only if write back to that. | ||
266 | value = (0x1 << 14); | ||
267 | wrmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG,&value, sizeof(value)); | ||
268 | udelay(1000); | ||
269 | uiRetries--; | ||
270 | if(uiRetries == 0) | ||
271 | { | ||
272 | return FALSE; | ||
273 | } | ||
274 | value = 0; | ||
275 | rdmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value)); | ||
276 | } | ||
277 | return TRUE; | ||
278 | |||
279 | |||
280 | } | ||
281 | |||
282 | |||
283 | //----------------------------------------------------------------------------- | ||
284 | // Procedure: ReadBeceemEEPROMBulk | ||
285 | // | ||
286 | // Description: This routine reads 16Byte data from EEPROM | ||
287 | // | ||
288 | // Arguments: | ||
289 | // Adapter - ptr to Adapter object instance | ||
290 | // dwAddress - EEPROM Offset to read the data from. | ||
291 | // pdwData - Pointer to double word where data needs to be stored in. | ||
292 | // | ||
293 | // Returns: | ||
294 | // OSAL_STATUS_CODE: | ||
295 | //----------------------------------------------------------------------------- | ||
296 | |||
297 | INT ReadBeceemEEPROMBulk(PMINI_ADAPTER Adapter,DWORD dwAddress, DWORD *pdwData) | ||
298 | { | ||
299 | DWORD dwRetries = 16; | ||
300 | DWORD dwIndex = 0; | ||
301 | UINT value, tmpVal; | ||
302 | |||
303 | |||
304 | value = 0; | ||
305 | rdmalt (Adapter, 0x0f003008, &value, sizeof(value)); | ||
306 | |||
307 | //read 0x0f003020 untill bit 1 of 0x0f003008 is set. | ||
308 | while(((value >> 1) & 1) == 0) | ||
309 | { | ||
310 | |||
311 | rdmalt (Adapter, 0x0f003020, &tmpVal, sizeof(tmpVal)); | ||
312 | dwRetries--; | ||
313 | if(dwRetries == 0) | ||
314 | { | ||
315 | return -1; | ||
316 | } | ||
317 | value = 0; | ||
318 | rdmalt (Adapter, 0x0f003008, &value, sizeof(value)); | ||
319 | } | ||
320 | |||
321 | value = dwAddress | 0xfb000000; | ||
322 | wrmalt (Adapter, 0x0f003018, &value, sizeof(value)); | ||
323 | |||
324 | udelay(1000); | ||
325 | value = 0; | ||
326 | for(dwIndex = 0;dwIndex < 4 ; dwIndex++) | ||
327 | { | ||
328 | value = 0; | ||
329 | rdmalt (Adapter, 0x0f003020, &value, sizeof(value)); | ||
330 | pdwData[dwIndex] = value; | ||
331 | |||
332 | value = 0; | ||
333 | rdmalt (Adapter, 0x0f003020, &value, sizeof(value)); | ||
334 | pdwData[dwIndex] |= (value << 8); | ||
335 | |||
336 | value = 0; | ||
337 | rdmalt (Adapter, 0x0f003020, &value, sizeof(value)); | ||
338 | pdwData[dwIndex] |= (value << 16); | ||
339 | |||
340 | value = 0; | ||
341 | rdmalt (Adapter, 0x0f003020, &value, sizeof(value)); | ||
342 | pdwData[dwIndex] |= (value << 24); | ||
343 | |||
344 | } | ||
345 | return 0; | ||
346 | } | ||
347 | |||
348 | //----------------------------------------------------------------------------- | ||
349 | // Procedure: ReadBeceemEEPROM | ||
350 | // | ||
351 | // Description: This routine reads 4Byte data from EEPROM | ||
352 | // | ||
353 | // Arguments: | ||
354 | // Adapter - ptr to Adapter object instance | ||
355 | // dwAddress - EEPROM Offset to read the data from. | ||
356 | // pdwData - Pointer to double word where data needs to be stored in. | ||
357 | // | ||
358 | // Returns: | ||
359 | // OSAL_STATUS_CODE: | ||
360 | //----------------------------------------------------------------------------- | ||
361 | |||
362 | INT ReadBeceemEEPROM(PMINI_ADAPTER Adapter,DWORD dwAddress, DWORD *pdwData) | ||
363 | { | ||
364 | |||
365 | DWORD dwReadValue = 0; | ||
366 | DWORD dwRetries = 16, dwCompleteWord = 0; | ||
367 | UINT value, tmpVal; | ||
368 | |||
369 | rdmalt(Adapter, 0x0f003008, &value, sizeof(value)); | ||
370 | while (((value >> 1) & 1) == 0) { | ||
371 | rdmalt(Adapter, 0x0f003020, &tmpVal, sizeof(tmpVal)); | ||
372 | |||
373 | if (dwRetries == 0) { | ||
374 | return -1; | ||
375 | } | ||
376 | rdmalt(Adapter, 0x0f003008, &value, sizeof(value)); | ||
377 | } | ||
378 | |||
379 | |||
380 | //wrm (0x0f003018, 0xNbXXXXXX) // N is the number of bytes u want to read (0 means 1, f means 16, b is the opcode for page read) | ||
381 | // Follow it up by N executions of rdm(0x0f003020) to read the rxed bytes from rx queue. | ||
382 | dwAddress |= 0x3b000000; | ||
383 | wrmalt(Adapter, 0x0f003018,&dwAddress,4); | ||
384 | mdelay(10); | ||
385 | rdmalt(Adapter, 0x0f003020,&dwReadValue,4); | ||
386 | dwCompleteWord=dwReadValue; | ||
387 | rdmalt(Adapter, 0x0f003020,&dwReadValue,4); | ||
388 | dwCompleteWord|=(dwReadValue<<8); | ||
389 | rdmalt(Adapter, 0x0f003020,&dwReadValue,4); | ||
390 | dwCompleteWord|=(dwReadValue<<16); | ||
391 | rdmalt(Adapter, 0x0f003020,&dwReadValue,4); | ||
392 | dwCompleteWord|=(dwReadValue<<24); | ||
393 | |||
394 | *pdwData = dwCompleteWord; | ||
395 | |||
396 | return 0; | ||
397 | } | ||
398 | #endif | ||
399 | |||
400 | INT ReadMacAddressFromNVM(PMINI_ADAPTER Adapter) | ||
401 | { | ||
402 | INT Status=0, i; | ||
403 | unsigned char puMacAddr[6] = {0}; | ||
404 | INT AllZeroMac = 0; | ||
405 | INT AllFFMac = 0; | ||
406 | |||
407 | Status = BeceemNVMRead(Adapter, | ||
408 | (PUINT)&puMacAddr[0], | ||
409 | INIT_PARAMS_1_MACADDRESS_ADDRESS, | ||
410 | MAC_ADDRESS_SIZE); | ||
411 | |||
412 | if(Status != STATUS_SUCCESS) | ||
413 | { | ||
414 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Error in Reading the mac Addres with status :%d", Status); | ||
415 | return Status; | ||
416 | } | ||
417 | |||
418 | memcpy(Adapter->dev->dev_addr, puMacAddr, MAC_ADDRESS_SIZE); | ||
419 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Modem MAC Addr :"); | ||
420 | BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_PRINTK, 0, DBG_LVL_ALL,&Adapter->dev->dev_addr[0],MAC_ADDRESS_SIZE); | ||
421 | for(i=0;i<MAC_ADDRESS_SIZE;i++) | ||
422 | { | ||
423 | |||
424 | if(Adapter->dev->dev_addr[i] == 0x00) | ||
425 | AllZeroMac++; | ||
426 | if(Adapter->dev->dev_addr[i] == 0xFF) | ||
427 | AllFFMac++; | ||
428 | |||
429 | } | ||
430 | //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "\n"); | ||
431 | if(AllZeroMac == MAC_ADDRESS_SIZE) | ||
432 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Warning :: MAC Address has all 00's"); | ||
433 | if(AllFFMac == MAC_ADDRESS_SIZE) | ||
434 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Warning :: MAC Address has all FF's"); | ||
435 | |||
436 | return Status; | ||
437 | |||
438 | } | ||
439 | |||
440 | //----------------------------------------------------------------------------- | ||
441 | // Procedure: BeceemEEPROMBulkRead | ||
442 | // | ||
443 | // Description: Reads the EEPROM and returns the Data. | ||
444 | // | ||
445 | // Arguments: | ||
446 | // Adapter - ptr to Adapter object instance | ||
447 | // pBuffer - Buffer to store the data read from EEPROM | ||
448 | // uiOffset - Offset of EEPROM from where data should be read | ||
449 | // uiNumBytes - Number of bytes to be read from the EEPROM. | ||
450 | // | ||
451 | // Returns: | ||
452 | // OSAL_STATUS_SUCCESS - if EEPROM read is successfull. | ||
453 | // <FAILURE> - if failed. | ||
454 | //----------------------------------------------------------------------------- | ||
455 | |||
456 | INT BeceemEEPROMBulkRead( | ||
457 | PMINI_ADAPTER Adapter, | ||
458 | PUINT pBuffer, | ||
459 | UINT uiOffset, | ||
460 | UINT uiNumBytes) | ||
461 | { | ||
462 | UINT uiData[4] = {0}; | ||
463 | //UINT uiAddress = 0; | ||
464 | UINT uiBytesRemaining = uiNumBytes; | ||
465 | UINT uiIndex = 0; | ||
466 | UINT uiTempOffset = 0; | ||
467 | UINT uiExtraBytes = 0; | ||
468 | UINT uiFailureRetries = 0; | ||
469 | PUCHAR pcBuff = (PUCHAR)pBuffer; | ||
470 | |||
471 | |||
472 | if(uiOffset%MAX_RW_SIZE&& uiBytesRemaining) | ||
473 | { | ||
474 | uiTempOffset = uiOffset - (uiOffset%MAX_RW_SIZE); | ||
475 | uiExtraBytes = uiOffset-uiTempOffset; | ||
476 | ReadBeceemEEPROMBulk(Adapter,uiTempOffset,(PUINT)&uiData[0],4); | ||
477 | if(uiBytesRemaining >= (MAX_RW_SIZE - uiExtraBytes)) | ||
478 | { | ||
479 | OsalMemMove(pBuffer,(((PUCHAR)&uiData[0])+uiExtraBytes),MAX_RW_SIZE - uiExtraBytes); | ||
480 | |||
481 | uiBytesRemaining -= (MAX_RW_SIZE - uiExtraBytes); | ||
482 | uiIndex += (MAX_RW_SIZE - uiExtraBytes); | ||
483 | uiOffset += (MAX_RW_SIZE - uiExtraBytes); | ||
484 | } | ||
485 | else | ||
486 | { | ||
487 | OsalMemMove(pBuffer,(((PUCHAR)&uiData[0])+uiExtraBytes),uiBytesRemaining); | ||
488 | uiIndex += uiBytesRemaining; | ||
489 | uiOffset += uiBytesRemaining; | ||
490 | uiBytesRemaining = 0; | ||
491 | } | ||
492 | |||
493 | |||
494 | } | ||
495 | |||
496 | |||
497 | while(uiBytesRemaining && uiFailureRetries != 128) | ||
498 | { | ||
499 | if(Adapter->device_removed ) | ||
500 | { | ||
501 | return -1; | ||
502 | } | ||
503 | |||
504 | if(uiBytesRemaining >= MAX_RW_SIZE) | ||
505 | { | ||
506 | /* For the requests more than or equal to 16 bytes, use bulk | ||
507 | * read function to make the access faster. | ||
508 | * We read 4 Dwords of data */ | ||
509 | if(0 == ReadBeceemEEPROMBulk(Adapter,uiOffset,&uiData[0],4)) | ||
510 | { | ||
511 | OsalMemMove(pcBuff+uiIndex,&uiData[0],MAX_RW_SIZE); | ||
512 | uiOffset += MAX_RW_SIZE; | ||
513 | uiBytesRemaining -= MAX_RW_SIZE; | ||
514 | uiIndex += MAX_RW_SIZE; | ||
515 | } | ||
516 | else | ||
517 | { | ||
518 | uiFailureRetries++; | ||
519 | mdelay(3);//sleep for a while before retry... | ||
520 | } | ||
521 | } | ||
522 | else if(uiBytesRemaining >= 4) | ||
523 | { | ||
524 | if(0 == ReadBeceemEEPROM(Adapter,uiOffset,&uiData[0])) | ||
525 | { | ||
526 | OsalMemMove(pcBuff+uiIndex,&uiData[0],4); | ||
527 | uiOffset += 4; | ||
528 | uiBytesRemaining -= 4; | ||
529 | uiIndex +=4; | ||
530 | } | ||
531 | else | ||
532 | { | ||
533 | uiFailureRetries++; | ||
534 | mdelay(3);//sleep for a while before retry... | ||
535 | } | ||
536 | } | ||
537 | else | ||
538 | { // Handle the reads less than 4 bytes... | ||
539 | PUCHAR pCharBuff = (PUCHAR)pBuffer; | ||
540 | pCharBuff += uiIndex; | ||
541 | if(0 == ReadBeceemEEPROM(Adapter,uiOffset,&uiData[0])) | ||
542 | { | ||
543 | OsalMemMove(pCharBuff,&uiData[0],uiBytesRemaining);//copy only bytes requested. | ||
544 | uiBytesRemaining = 0; | ||
545 | } | ||
546 | else | ||
547 | { | ||
548 | uiFailureRetries++; | ||
549 | mdelay(3);//sleep for a while before retry... | ||
550 | } | ||
551 | } | ||
552 | |||
553 | } | ||
554 | |||
555 | return 0; | ||
556 | } | ||
557 | |||
558 | //----------------------------------------------------------------------------- | ||
559 | // Procedure: BeceemFlashBulkRead | ||
560 | // | ||
561 | // Description: Reads the FLASH and returns the Data. | ||
562 | // | ||
563 | // Arguments: | ||
564 | // Adapter - ptr to Adapter object instance | ||
565 | // pBuffer - Buffer to store the data read from FLASH | ||
566 | // uiOffset - Offset of FLASH from where data should be read | ||
567 | // uiNumBytes - Number of bytes to be read from the FLASH. | ||
568 | // | ||
569 | // Returns: | ||
570 | // OSAL_STATUS_SUCCESS - if FLASH read is successfull. | ||
571 | // <FAILURE> - if failed. | ||
572 | //----------------------------------------------------------------------------- | ||
573 | |||
574 | INT BeceemFlashBulkRead( | ||
575 | PMINI_ADAPTER Adapter, | ||
576 | PUINT pBuffer, | ||
577 | UINT uiOffset, | ||
578 | UINT uiNumBytes) | ||
579 | { | ||
580 | UINT uiIndex = 0; | ||
581 | UINT uiBytesToRead = uiNumBytes; | ||
582 | INT Status = 0; | ||
583 | UINT uiPartOffset = 0; | ||
584 | |||
585 | if(Adapter->device_removed ) | ||
586 | { | ||
587 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Device Got Removed "); | ||
588 | return -ENODEV; | ||
589 | } | ||
590 | |||
591 | //Adding flash Base address | ||
592 | // uiOffset = uiOffset + GetFlashBaseAddr(Adapter); | ||
593 | #if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS) | ||
594 | Status = bcmflash_raw_read((uiOffset/FLASH_PART_SIZE),(uiOffset % FLASH_PART_SIZE),( unsigned char *)pBuffer,uiNumBytes); | ||
595 | return Status; | ||
596 | #endif | ||
597 | |||
598 | Adapter->SelectedChip = RESET_CHIP_SELECT; | ||
599 | |||
600 | if(uiOffset % MAX_RW_SIZE) | ||
601 | { | ||
602 | BcmDoChipSelect(Adapter,uiOffset); | ||
603 | uiPartOffset = (uiOffset & (FLASH_PART_SIZE - 1)) + GetFlashBaseAddr(Adapter); | ||
604 | |||
605 | uiBytesToRead = MAX_RW_SIZE - (uiOffset%MAX_RW_SIZE); | ||
606 | uiBytesToRead = MIN(uiNumBytes,uiBytesToRead); | ||
607 | |||
608 | if(rdm(Adapter,uiPartOffset, (PCHAR)pBuffer+uiIndex,uiBytesToRead)) | ||
609 | { | ||
610 | Status = -1; | ||
611 | Adapter->SelectedChip = RESET_CHIP_SELECT; | ||
612 | return Status; | ||
613 | } | ||
614 | |||
615 | uiIndex += uiBytesToRead; | ||
616 | uiOffset += uiBytesToRead; | ||
617 | uiNumBytes -= uiBytesToRead; | ||
618 | } | ||
619 | |||
620 | while(uiNumBytes) | ||
621 | { | ||
622 | BcmDoChipSelect(Adapter,uiOffset); | ||
623 | uiPartOffset = (uiOffset & (FLASH_PART_SIZE - 1)) + GetFlashBaseAddr(Adapter); | ||
624 | |||
625 | uiBytesToRead = MIN(uiNumBytes,MAX_RW_SIZE); | ||
626 | |||
627 | if(rdm(Adapter,uiPartOffset, (PCHAR)pBuffer+uiIndex,uiBytesToRead)) | ||
628 | { | ||
629 | Status = -1; | ||
630 | break; | ||
631 | } | ||
632 | |||
633 | |||
634 | uiIndex += uiBytesToRead; | ||
635 | uiOffset += uiBytesToRead; | ||
636 | uiNumBytes -= uiBytesToRead; | ||
637 | |||
638 | } | ||
639 | Adapter->SelectedChip = RESET_CHIP_SELECT; | ||
640 | return Status; | ||
641 | } | ||
642 | |||
643 | //----------------------------------------------------------------------------- | ||
644 | // Procedure: BcmGetFlashSize | ||
645 | // | ||
646 | // Description: Finds the size of FLASH. | ||
647 | // | ||
648 | // Arguments: | ||
649 | // Adapter - ptr to Adapter object instance | ||
650 | // | ||
651 | // Returns: | ||
652 | // UINT - size of the FLASH Storage. | ||
653 | // | ||
654 | //----------------------------------------------------------------------------- | ||
655 | |||
656 | UINT BcmGetFlashSize(PMINI_ADAPTER Adapter) | ||
657 | { | ||
658 | #if 0 | ||
659 | if(Adapter->bDDRInitDone) | ||
660 | { | ||
661 | return rdm(Adapter,FLASH_CONTIGIOUS_START_ADDR_AFTER_INIT|FLASH_SIZE_ADDR); | ||
662 | } | ||
663 | |||
664 | return rdm(Adapter,FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT|FLASH_SIZE_ADDR); | ||
665 | #endif | ||
666 | if(IsFlash2x(Adapter)) | ||
667 | return (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER)); | ||
668 | else | ||
669 | return 32*1024; | ||
670 | |||
671 | |||
672 | } | ||
673 | |||
674 | //----------------------------------------------------------------------------- | ||
675 | // Procedure: BcmGetEEPROMSize | ||
676 | // | ||
677 | // Description: Finds the size of EEPROM. | ||
678 | // | ||
679 | // Arguments: | ||
680 | // Adapter - ptr to Adapter object instance | ||
681 | // | ||
682 | // Returns: | ||
683 | // UINT - size of the EEPROM Storage. | ||
684 | // | ||
685 | //----------------------------------------------------------------------------- | ||
686 | |||
687 | UINT BcmGetEEPROMSize(PMINI_ADAPTER Adapter) | ||
688 | { | ||
689 | UINT uiData = 0; | ||
690 | UINT uiIndex = 0; | ||
691 | |||
692 | // | ||
693 | // if EEPROM is present and already Calibrated,it will have | ||
694 | // 'BECM' string at 0th offset. | ||
695 | // To find the EEPROM size read the possible boundaries of the | ||
696 | // EEPROM like 4K,8K etc..accessing the EEPROM beyond its size will | ||
697 | // result in wrap around. So when we get the End of the EEPROM we will | ||
698 | // get 'BECM' string which is indeed at offset 0. | ||
699 | // | ||
700 | BeceemEEPROMBulkRead(Adapter,&uiData,0x0,4); | ||
701 | if(uiData == BECM) | ||
702 | { | ||
703 | for(uiIndex = 2;uiIndex <=256; uiIndex*=2) | ||
704 | { | ||
705 | BeceemEEPROMBulkRead(Adapter,&uiData,uiIndex*1024,4); | ||
706 | if(uiData == BECM) | ||
707 | { | ||
708 | return uiIndex*1024; | ||
709 | } | ||
710 | } | ||
711 | } | ||
712 | else | ||
713 | { | ||
714 | // | ||
715 | // EEPROM may not be present or not programmed | ||
716 | // | ||
717 | |||
718 | uiData = 0xBABEFACE; | ||
719 | if(0 == BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&uiData,0,4,TRUE)) | ||
720 | { | ||
721 | uiData = 0; | ||
722 | for(uiIndex = 2;uiIndex <=256; uiIndex*=2) | ||
723 | { | ||
724 | BeceemEEPROMBulkRead(Adapter,&uiData,uiIndex*1024,4); | ||
725 | if(uiData == 0xBABEFACE) | ||
726 | { | ||
727 | return uiIndex*1024; | ||
728 | } | ||
729 | } | ||
730 | } | ||
731 | |||
732 | } | ||
733 | return 0; | ||
734 | } | ||
735 | |||
736 | #if 0 | ||
737 | /***********************************************************************************/ | ||
738 | // | ||
739 | // WriteBeceemEEPROM: Writes 4 byte data to EEPROM offset. | ||
740 | // | ||
741 | // uiEEPROMOffset - Offset to be written to. | ||
742 | // uiData - Data to be written. | ||
743 | // | ||
744 | /***********************************************************************************/ | ||
745 | |||
746 | INT WriteBeceemEEPROM(PMINI_ADAPTER Adapter,UINT uiEEPROMOffset, UINT uiData) | ||
747 | { | ||
748 | INT Status = 0; | ||
749 | ULONG ulRdBk = 0; | ||
750 | ULONG ulRetryCount = 3; | ||
751 | UINT value; | ||
752 | |||
753 | if(uiEEPROMOffset > EEPROM_END) | ||
754 | { | ||
755 | |||
756 | return -1; | ||
757 | } | ||
758 | |||
759 | uiData = htonl(uiData); | ||
760 | while(ulRetryCount--) | ||
761 | { | ||
762 | value = 0x06000000; | ||
763 | wrmalt(Adapter, 0x0F003018,&value, sizeof(value));//flush the EEPROM FIFO. | ||
764 | wrmalt(Adapter, 0x0F00301C,&uiData, sizeof(uiData)); | ||
765 | value = 0x3A000000 | uiEEPROMOffset; | ||
766 | wrmalt(Adapter, 0x0F003018,&value, sizeof(value)); | ||
767 | __udelay(100000); | ||
768 | //read back and verify. | ||
769 | Status = ReadBeceemEEPROM(Adapter,uiEEPROMOffset,(UINT *)&ulRdBk); | ||
770 | if(Status == 0) | ||
771 | { | ||
772 | if(ulRdBk == uiData) | ||
773 | { | ||
774 | return Status; | ||
775 | } | ||
776 | else | ||
777 | { | ||
778 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "WriteBeceemEEPROM: Readback does not match\n"); | ||
779 | } | ||
780 | } | ||
781 | else | ||
782 | { | ||
783 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "WriteBeceemEEPROM: Readback failed\n"); | ||
784 | } | ||
785 | } | ||
786 | |||
787 | return 0; | ||
788 | } | ||
789 | #endif | ||
790 | |||
791 | //----------------------------------------------------------------------------- | ||
792 | // Procedure: FlashSectorErase | ||
793 | // | ||
794 | // Description: Finds the sector size of the FLASH. | ||
795 | // | ||
796 | // Arguments: | ||
797 | // Adapter - ptr to Adapter object instance | ||
798 | // addr - sector start address | ||
799 | // numOfSectors - number of sectors to be erased. | ||
800 | // | ||
801 | // Returns: | ||
802 | // OSAL_STATUS_CODE | ||
803 | // | ||
804 | //----------------------------------------------------------------------------- | ||
805 | |||
806 | |||
807 | INT FlashSectorErase(PMINI_ADAPTER Adapter, | ||
808 | UINT addr, | ||
809 | UINT numOfSectors) | ||
810 | { | ||
811 | UINT iIndex = 0, iRetries = 0; | ||
812 | UINT uiStatus = 0; | ||
813 | UINT value; | ||
814 | |||
815 | for(iIndex=0;iIndex<numOfSectors;iIndex++) | ||
816 | { | ||
817 | value = 0x06000000; | ||
818 | wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)); | ||
819 | |||
820 | value = (0xd8000000 | (addr & 0xFFFFFF)); | ||
821 | wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)); | ||
822 | iRetries = 0; | ||
823 | |||
824 | do | ||
825 | { | ||
826 | value = (FLASH_CMD_STATUS_REG_READ << 24); | ||
827 | if(wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) | ||
828 | { | ||
829 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Programing of FLASH_SPI_CMDQ_REG fails"); | ||
830 | return STATUS_FAILURE; | ||
831 | } | ||
832 | |||
833 | if(rdmalt(Adapter, FLASH_SPI_READQ_REG, &uiStatus, sizeof(uiStatus)) < 0 ) | ||
834 | { | ||
835 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Reading status of FLASH_SPI_READQ_REG fails"); | ||
836 | return STATUS_FAILURE; | ||
837 | } | ||
838 | iRetries++; | ||
839 | //After every try lets make the CPU free for 10 ms. generally time taken by the | ||
840 | //the sector erase cycle is 500 ms to 40000 msec. hence sleeping 10 ms | ||
841 | //won't hamper performance in any case. | ||
842 | msleep(10); | ||
843 | }while((uiStatus & 0x1) && (iRetries < 400)); | ||
844 | |||
845 | if(uiStatus & 0x1) | ||
846 | { | ||
847 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"iRetries crossing the limit of 80000\n"); | ||
848 | return STATUS_FAILURE; | ||
849 | } | ||
850 | |||
851 | addr += Adapter->uiSectorSize; | ||
852 | } | ||
853 | return 0; | ||
854 | } | ||
855 | //----------------------------------------------------------------------------- | ||
856 | // Procedure: flashByteWrite | ||
857 | // | ||
858 | // Description: Performs Byte by Byte write to flash | ||
859 | // | ||
860 | // Arguments: | ||
861 | // Adapter - ptr to Adapter object instance | ||
862 | // uiOffset - Offset of the flash where data needs to be written to. | ||
863 | // pData - Address of Data to be written. | ||
864 | // Returns: | ||
865 | // OSAL_STATUS_CODE | ||
866 | // | ||
867 | //----------------------------------------------------------------------------- | ||
868 | |||
869 | INT flashByteWrite( | ||
870 | PMINI_ADAPTER Adapter, | ||
871 | UINT uiOffset, | ||
872 | PVOID pData) | ||
873 | { | ||
874 | |||
875 | UINT uiStatus = 0; | ||
876 | INT iRetries = MAX_FLASH_RETRIES * FLASH_PER_RETRIES_DELAY; //3 | ||
877 | |||
878 | UINT value; | ||
879 | ULONG ulData = *(PUCHAR)pData; | ||
880 | |||
881 | // | ||
882 | // need not write 0xFF because write requires an erase and erase will | ||
883 | // make whole sector 0xFF. | ||
884 | // | ||
885 | |||
886 | if(0xFF == ulData) | ||
887 | { | ||
888 | return STATUS_SUCCESS; | ||
889 | } | ||
890 | |||
891 | // DumpDebug(NVM_RW,("flashWrite ====>\n")); | ||
892 | value = (FLASH_CMD_WRITE_ENABLE << 24); | ||
893 | if(wrmalt(Adapter, FLASH_SPI_CMDQ_REG,&value, sizeof(value)) < 0) | ||
894 | { | ||
895 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Write enable in FLASH_SPI_CMDQ_REG register fails"); | ||
896 | return STATUS_FAILURE; | ||
897 | } | ||
898 | if(wrm(Adapter,FLASH_SPI_WRITEQ_REG, (PCHAR)&ulData, 4) < 0 ) | ||
899 | { | ||
900 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"DATA Write on FLASH_SPI_WRITEQ_REG fails"); | ||
901 | return STATUS_FAILURE; | ||
902 | } | ||
903 | value = (0x02000000 | (uiOffset & 0xFFFFFF)); | ||
904 | if(wrmalt(Adapter, FLASH_SPI_CMDQ_REG,&value, sizeof(value)) < 0 ) | ||
905 | { | ||
906 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Programming of FLASH_SPI_CMDQ_REG fails"); | ||
907 | return STATUS_FAILURE; | ||
908 | } | ||
909 | |||
910 | //__udelay(950); | ||
911 | |||
912 | do | ||
913 | { | ||
914 | value = (FLASH_CMD_STATUS_REG_READ << 24); | ||
915 | if(wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) | ||
916 | { | ||
917 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Programing of FLASH_SPI_CMDQ_REG fails"); | ||
918 | return STATUS_FAILURE; | ||
919 | } | ||
920 | //__udelay(1); | ||
921 | if(rdmalt(Adapter, FLASH_SPI_READQ_REG, &uiStatus, sizeof(uiStatus)) < 0) | ||
922 | { | ||
923 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Reading status of FLASH_SPI_READQ_REG fails"); | ||
924 | return STATUS_FAILURE; | ||
925 | } | ||
926 | iRetries--; | ||
927 | if( iRetries && ((iRetries % FLASH_PER_RETRIES_DELAY) == 0)) | ||
928 | msleep(1); | ||
929 | |||
930 | }while((uiStatus & 0x1) && (iRetries >0) ); | ||
931 | |||
932 | if(uiStatus & 0x1) | ||
933 | { | ||
934 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Flash Write fails even after checking status for 200 times."); | ||
935 | return STATUS_FAILURE ; | ||
936 | } | ||
937 | |||
938 | return STATUS_SUCCESS; | ||
939 | } | ||
940 | |||
941 | |||
942 | |||
943 | //----------------------------------------------------------------------------- | ||
944 | // Procedure: flashWrite | ||
945 | // | ||
946 | // Description: Performs write to flash | ||
947 | // | ||
948 | // Arguments: | ||
949 | // Adapter - ptr to Adapter object instance | ||
950 | // uiOffset - Offset of the flash where data needs to be written to. | ||
951 | // pData - Address of Data to be written. | ||
952 | // Returns: | ||
953 | // OSAL_STATUS_CODE | ||
954 | // | ||
955 | //----------------------------------------------------------------------------- | ||
956 | |||
957 | INT flashWrite( | ||
958 | PMINI_ADAPTER Adapter, | ||
959 | UINT uiOffset, | ||
960 | PVOID pData) | ||
961 | |||
962 | { | ||
963 | //UINT uiStatus = 0; | ||
964 | //INT iRetries = 0; | ||
965 | //UINT uiReadBack = 0; | ||
966 | |||
967 | UINT uiStatus = 0; | ||
968 | INT iRetries = MAX_FLASH_RETRIES * FLASH_PER_RETRIES_DELAY; //3 | ||
969 | |||
970 | UINT value; | ||
971 | UINT uiErasePattern[4] = {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF}; | ||
972 | // | ||
973 | // need not write 0xFFFFFFFF because write requires an erase and erase will | ||
974 | // make whole sector 0xFFFFFFFF. | ||
975 | // | ||
976 | if (!OsalMemCompare(pData, uiErasePattern, MAX_RW_SIZE)) | ||
977 | { | ||
978 | return 0; | ||
979 | } | ||
980 | |||
981 | value = (FLASH_CMD_WRITE_ENABLE << 24); | ||
982 | |||
983 | if(wrmalt(Adapter, FLASH_SPI_CMDQ_REG,&value, sizeof(value)) < 0 ) | ||
984 | { | ||
985 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Write Enable of FLASH_SPI_CMDQ_REG fails"); | ||
986 | return STATUS_FAILURE; | ||
987 | } | ||
988 | if(wrm(Adapter, uiOffset, (PCHAR)pData, MAX_RW_SIZE) < 0) | ||
989 | { | ||
990 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Data write fails..."); | ||
991 | return STATUS_FAILURE; | ||
992 | } | ||
993 | |||
994 | //__udelay(950); | ||
995 | do | ||
996 | { | ||
997 | value = (FLASH_CMD_STATUS_REG_READ << 24); | ||
998 | if(wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) | ||
999 | { | ||
1000 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Programing of FLASH_SPI_CMDQ_REG fails"); | ||
1001 | return STATUS_FAILURE; | ||
1002 | } | ||
1003 | //__udelay(1); | ||
1004 | if(rdmalt(Adapter, FLASH_SPI_READQ_REG, &uiStatus, sizeof(uiStatus)) < 0 ) | ||
1005 | { | ||
1006 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Reading status of FLASH_SPI_READQ_REG fails"); | ||
1007 | return STATUS_FAILURE; | ||
1008 | } | ||
1009 | |||
1010 | iRetries--; | ||
1011 | //this will ensure that in there will be no changes in the current path. | ||
1012 | //currently one rdm/wrm takes 125 us. | ||
1013 | //Hence 125 *2 * FLASH_PER_RETRIES_DELAY > 3 ms(worst case delay) | ||
1014 | //Hence current implementation cycle will intoduce no delay in current path | ||
1015 | if(iRetries && ((iRetries % FLASH_PER_RETRIES_DELAY) == 0)) | ||
1016 | msleep(1); | ||
1017 | }while((uiStatus & 0x1) && (iRetries > 0)); | ||
1018 | |||
1019 | if(uiStatus & 0x1) | ||
1020 | { | ||
1021 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Flash Write fails even after checking status for 200 times."); | ||
1022 | return STATUS_FAILURE ; | ||
1023 | } | ||
1024 | |||
1025 | return STATUS_SUCCESS; | ||
1026 | } | ||
1027 | |||
1028 | //----------------------------------------------------------------------------- | ||
1029 | // Procedure: flashByteWriteStatus | ||
1030 | // | ||
1031 | // Description: Performs byte by byte write to flash with write done status check | ||
1032 | // | ||
1033 | // Arguments: | ||
1034 | // Adapter - ptr to Adapter object instance | ||
1035 | // uiOffset - Offset of the flash where data needs to be written to. | ||
1036 | // pData - Address of the Data to be written. | ||
1037 | // Returns: | ||
1038 | // OSAL_STATUS_CODE | ||
1039 | // | ||
1040 | //----------------------------------------------------------------------------- | ||
1041 | INT flashByteWriteStatus( | ||
1042 | PMINI_ADAPTER Adapter, | ||
1043 | UINT uiOffset, | ||
1044 | PVOID pData) | ||
1045 | { | ||
1046 | UINT uiStatus = 0; | ||
1047 | INT iRetries = MAX_FLASH_RETRIES * FLASH_PER_RETRIES_DELAY; //3 | ||
1048 | ULONG ulData = *(PUCHAR)pData; | ||
1049 | UINT value; | ||
1050 | |||
1051 | // | ||
1052 | // need not write 0xFFFFFFFF because write requires an erase and erase will | ||
1053 | // make whole sector 0xFFFFFFFF. | ||
1054 | // | ||
1055 | |||
1056 | if(0xFF == ulData) | ||
1057 | { | ||
1058 | return STATUS_SUCCESS; | ||
1059 | } | ||
1060 | |||
1061 | // DumpDebug(NVM_RW,("flashWrite ====>\n")); | ||
1062 | |||
1063 | value = (FLASH_CMD_WRITE_ENABLE << 24); | ||
1064 | if(wrmalt(Adapter, FLASH_SPI_CMDQ_REG,&value, sizeof(value)) < 0) | ||
1065 | { | ||
1066 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Write enable in FLASH_SPI_CMDQ_REG register fails"); | ||
1067 | return STATUS_SUCCESS; | ||
1068 | } | ||
1069 | if(wrm(Adapter,FLASH_SPI_WRITEQ_REG, (PCHAR)&ulData, 4) < 0) | ||
1070 | { | ||
1071 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"DATA Write on FLASH_SPI_WRITEQ_REG fails"); | ||
1072 | return STATUS_FAILURE; | ||
1073 | } | ||
1074 | value = (0x02000000 | (uiOffset & 0xFFFFFF)); | ||
1075 | if(wrmalt(Adapter, FLASH_SPI_CMDQ_REG,&value, sizeof(value)) < 0) | ||
1076 | { | ||
1077 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Programming of FLASH_SPI_CMDQ_REG fails"); | ||
1078 | return STATUS_FAILURE; | ||
1079 | } | ||
1080 | |||
1081 | //msleep(1); | ||
1082 | |||
1083 | do | ||
1084 | { | ||
1085 | value = (FLASH_CMD_STATUS_REG_READ << 24); | ||
1086 | if(wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) | ||
1087 | { | ||
1088 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Programing of FLASH_SPI_CMDQ_REG fails"); | ||
1089 | return STATUS_FAILURE; | ||
1090 | } | ||
1091 | //__udelay(1); | ||
1092 | if(rdmalt(Adapter, FLASH_SPI_READQ_REG, &uiStatus, sizeof(uiStatus)) < 0) | ||
1093 | { | ||
1094 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Reading status of FLASH_SPI_READQ_REG fails"); | ||
1095 | return STATUS_FAILURE; | ||
1096 | } | ||
1097 | |||
1098 | iRetries--; | ||
1099 | if( iRetries && ((iRetries % FLASH_PER_RETRIES_DELAY) == 0)) | ||
1100 | msleep(1); | ||
1101 | }while((uiStatus & 0x1) && (iRetries > 0)); | ||
1102 | |||
1103 | if(uiStatus & 0x1) | ||
1104 | { | ||
1105 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Flash Write fails even after checking status for 200 times."); | ||
1106 | return STATUS_FAILURE ; | ||
1107 | } | ||
1108 | |||
1109 | return STATUS_SUCCESS; | ||
1110 | |||
1111 | } | ||
1112 | //----------------------------------------------------------------------------- | ||
1113 | // Procedure: flashWriteStatus | ||
1114 | // | ||
1115 | // Description: Performs write to flash with write done status check | ||
1116 | // | ||
1117 | // Arguments: | ||
1118 | // Adapter - ptr to Adapter object instance | ||
1119 | // uiOffset - Offset of the flash where data needs to be written to. | ||
1120 | // pData - Address of the Data to be written. | ||
1121 | // Returns: | ||
1122 | // OSAL_STATUS_CODE | ||
1123 | // | ||
1124 | //----------------------------------------------------------------------------- | ||
1125 | |||
1126 | INT flashWriteStatus( | ||
1127 | PMINI_ADAPTER Adapter, | ||
1128 | UINT uiOffset, | ||
1129 | PVOID pData) | ||
1130 | { | ||
1131 | UINT uiStatus = 0; | ||
1132 | INT iRetries = MAX_FLASH_RETRIES * FLASH_PER_RETRIES_DELAY; //3 | ||
1133 | //UINT uiReadBack = 0; | ||
1134 | UINT value; | ||
1135 | UINT uiErasePattern[4] = {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF}; | ||
1136 | |||
1137 | // | ||
1138 | // need not write 0xFFFFFFFF because write requires an erase and erase will | ||
1139 | // make whole sector 0xFFFFFFFF. | ||
1140 | // | ||
1141 | if (!OsalMemCompare(pData,uiErasePattern,MAX_RW_SIZE)) | ||
1142 | { | ||
1143 | return 0; | ||
1144 | } | ||
1145 | |||
1146 | value = (FLASH_CMD_WRITE_ENABLE << 24); | ||
1147 | if(wrmalt(Adapter, FLASH_SPI_CMDQ_REG,&value, sizeof(value)) < 0) | ||
1148 | { | ||
1149 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Write Enable of FLASH_SPI_CMDQ_REG fails"); | ||
1150 | return STATUS_FAILURE; | ||
1151 | } | ||
1152 | if(wrm(Adapter, uiOffset, (PCHAR)pData, MAX_RW_SIZE) < 0) | ||
1153 | { | ||
1154 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Data write fails..."); | ||
1155 | return STATUS_FAILURE; | ||
1156 | } | ||
1157 | // __udelay(1); | ||
1158 | |||
1159 | do | ||
1160 | { | ||
1161 | value = (FLASH_CMD_STATUS_REG_READ << 24); | ||
1162 | if(wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) | ||
1163 | { | ||
1164 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Programing of FLASH_SPI_CMDQ_REG fails"); | ||
1165 | return STATUS_FAILURE; | ||
1166 | } | ||
1167 | //__udelay(1); | ||
1168 | if(rdmalt(Adapter, FLASH_SPI_READQ_REG, &uiStatus, sizeof(uiStatus)) < 0) | ||
1169 | { | ||
1170 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Reading status of FLASH_SPI_READQ_REG fails"); | ||
1171 | return STATUS_FAILURE; | ||
1172 | } | ||
1173 | iRetries--; | ||
1174 | //this will ensure that in there will be no changes in the current path. | ||
1175 | //currently one rdm/wrm takes 125 us. | ||
1176 | //Hence 125 *2 * FLASH_PER_RETRIES_DELAY >3 ms(worst case delay) | ||
1177 | //Hence current implementation cycle will intoduce no delay in current path | ||
1178 | if(iRetries && ((iRetries % FLASH_PER_RETRIES_DELAY) == 0)) | ||
1179 | msleep(1); | ||
1180 | }while((uiStatus & 0x1) && (iRetries >0)); | ||
1181 | |||
1182 | if(uiStatus & 0x1) | ||
1183 | { | ||
1184 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Flash Write fails even after checking status for 200 times."); | ||
1185 | return STATUS_FAILURE ; | ||
1186 | } | ||
1187 | |||
1188 | return STATUS_SUCCESS; | ||
1189 | } | ||
1190 | |||
1191 | //----------------------------------------------------------------------------- | ||
1192 | // Procedure: BcmRestoreBlockProtectStatus | ||
1193 | // | ||
1194 | // Description: Restores the original block protection status. | ||
1195 | // | ||
1196 | // Arguments: | ||
1197 | // Adapter - ptr to Adapter object instance | ||
1198 | // ulWriteStatus -Original status | ||
1199 | // Returns: | ||
1200 | // <VOID> | ||
1201 | // | ||
1202 | //----------------------------------------------------------------------------- | ||
1203 | |||
1204 | VOID BcmRestoreBlockProtectStatus(PMINI_ADAPTER Adapter,ULONG ulWriteStatus) | ||
1205 | { | ||
1206 | UINT value; | ||
1207 | value = (FLASH_CMD_WRITE_ENABLE<< 24); | ||
1208 | wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)); | ||
1209 | |||
1210 | udelay(20); | ||
1211 | value = (FLASH_CMD_STATUS_REG_WRITE<<24)|(ulWriteStatus << 16); | ||
1212 | wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)); | ||
1213 | udelay(20); | ||
1214 | } | ||
1215 | //----------------------------------------------------------------------------- | ||
1216 | // Procedure: BcmFlashUnProtectBlock | ||
1217 | // | ||
1218 | // Description: UnProtects appropriate blocks for writing. | ||
1219 | // | ||
1220 | // Arguments: | ||
1221 | // Adapter - ptr to Adapter object instance | ||
1222 | // uiOffset - Offset of the flash where data needs to be written to. This should be Sector aligned. | ||
1223 | // Returns: | ||
1224 | // ULONG - Status value before UnProtect. | ||
1225 | // | ||
1226 | //----------------------------------------------------------------------------- | ||
1227 | ULONG BcmFlashUnProtectBlock(PMINI_ADAPTER Adapter,UINT uiOffset, UINT uiLength) | ||
1228 | { | ||
1229 | ULONG ulStatus = 0; | ||
1230 | ULONG ulWriteStatus = 0; | ||
1231 | UINT value; | ||
1232 | uiOffset = uiOffset&0x000FFFFF; | ||
1233 | |||
1234 | // | ||
1235 | // Implemented only for 1MB Flash parts. | ||
1236 | // | ||
1237 | if(FLASH_PART_SST25VF080B == Adapter->ulFlashID) | ||
1238 | { | ||
1239 | // | ||
1240 | // Get Current BP status. | ||
1241 | // | ||
1242 | value = (FLASH_CMD_STATUS_REG_READ << 24); | ||
1243 | wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)); | ||
1244 | udelay(10); | ||
1245 | // | ||
1246 | // Read status will be WWXXYYZZ. We have to take only WW. | ||
1247 | // | ||
1248 | rdmalt(Adapter, FLASH_SPI_READQ_REG, (PUINT)&ulStatus, sizeof(ulStatus)); | ||
1249 | ulStatus >>= 24; | ||
1250 | ulWriteStatus = ulStatus; | ||
1251 | |||
1252 | // | ||
1253 | // Bits [5-2] give current block level protection status. | ||
1254 | // Bit5: BP3 - DONT CARE | ||
1255 | // BP2-BP0: 0 - NO PROTECTION, 1 - UPPER 1/16, 2 - UPPER 1/8, 3 - UPPER 1/4 | ||
1256 | // 4 - UPPER 1/2. 5 to 7 - ALL BLOCKS | ||
1257 | // | ||
1258 | |||
1259 | if(ulStatus) | ||
1260 | { | ||
1261 | if((uiOffset+uiLength) <= 0x80000) | ||
1262 | { | ||
1263 | // | ||
1264 | // Offset comes in lower half of 1MB. Protect the upper half. | ||
1265 | // Clear BP1 and BP0 and set BP2. | ||
1266 | // | ||
1267 | ulWriteStatus |= (0x4<<2); | ||
1268 | ulWriteStatus &= ~(0x3<<2); | ||
1269 | } | ||
1270 | else if((uiOffset+uiLength) <= 0xC0000) | ||
1271 | { | ||
1272 | // | ||
1273 | // Offset comes below Upper 1/4. Upper 1/4 can be protected. | ||
1274 | // Clear BP2 and set BP1 and BP0. | ||
1275 | // | ||
1276 | ulWriteStatus |= (0x3<<2); | ||
1277 | ulWriteStatus &= ~(0x1<<4); | ||
1278 | } | ||
1279 | else if((uiOffset+uiLength) <= 0xE0000) | ||
1280 | { | ||
1281 | // | ||
1282 | // Offset comes below Upper 1/8. Upper 1/8 can be protected. | ||
1283 | // Clear BP2 and BP0 and set BP1 | ||
1284 | // | ||
1285 | ulWriteStatus |= (0x1<<3); | ||
1286 | ulWriteStatus &= ~(0x5<<2); | ||
1287 | |||
1288 | } | ||
1289 | else if((uiOffset+uiLength) <= 0xF0000) | ||
1290 | { | ||
1291 | // | ||
1292 | // Offset comes below Upper 1/16. Only upper 1/16 can be protected. | ||
1293 | // Set BP0 and Clear BP2,BP1. | ||
1294 | // | ||
1295 | ulWriteStatus |= (0x1<<2); | ||
1296 | ulWriteStatus &= ~(0x3<<3); | ||
1297 | } | ||
1298 | else | ||
1299 | { | ||
1300 | // | ||
1301 | // Unblock all. | ||
1302 | // Clear BP2,BP1 and BP0. | ||
1303 | // | ||
1304 | ulWriteStatus &= ~(0x7<<2); | ||
1305 | } | ||
1306 | |||
1307 | value = (FLASH_CMD_WRITE_ENABLE<< 24); | ||
1308 | wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)); | ||
1309 | udelay(20); | ||
1310 | value = (FLASH_CMD_STATUS_REG_WRITE<<24)|(ulWriteStatus << 16); | ||
1311 | wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)); | ||
1312 | udelay(20); | ||
1313 | |||
1314 | } | ||
1315 | |||
1316 | } | ||
1317 | return ulStatus; | ||
1318 | } | ||
1319 | //----------------------------------------------------------------------------- | ||
1320 | // Procedure: BeceemFlashBulkWrite | ||
1321 | // | ||
1322 | // Description: Performs write to the flash | ||
1323 | // | ||
1324 | // Arguments: | ||
1325 | // Adapter - ptr to Adapter object instance | ||
1326 | // pBuffer - Data to be written. | ||
1327 | // uiOffset - Offset of the flash where data needs to be written to. | ||
1328 | // uiNumBytes - Number of bytes to be written. | ||
1329 | // bVerify - read verify flag. | ||
1330 | // Returns: | ||
1331 | // OSAL_STATUS_CODE | ||
1332 | // | ||
1333 | //----------------------------------------------------------------------------- | ||
1334 | |||
1335 | INT BeceemFlashBulkWrite( | ||
1336 | PMINI_ADAPTER Adapter, | ||
1337 | PUINT pBuffer, | ||
1338 | UINT uiOffset, | ||
1339 | UINT uiNumBytes, | ||
1340 | BOOLEAN bVerify) | ||
1341 | { | ||
1342 | PCHAR pTempBuff = NULL; | ||
1343 | PUCHAR pcBuffer = (PUCHAR)pBuffer; | ||
1344 | UINT uiIndex = 0; | ||
1345 | UINT uiOffsetFromSectStart = 0; | ||
1346 | UINT uiSectAlignAddr = 0; | ||
1347 | UINT uiCurrSectOffsetAddr = 0; | ||
1348 | UINT uiSectBoundary = 0; | ||
1349 | UINT uiNumSectTobeRead = 0; | ||
1350 | UCHAR ucReadBk[16] = {0}; | ||
1351 | ULONG ulStatus = 0; | ||
1352 | INT Status = STATUS_SUCCESS; | ||
1353 | UINT uiTemp = 0; | ||
1354 | UINT index = 0; | ||
1355 | UINT uiPartOffset = 0; | ||
1356 | #if 0 | ||
1357 | struct timeval tv1 = {0}; | ||
1358 | struct timeval tv2 = {0}; | ||
1359 | |||
1360 | struct timeval tr = {0}; | ||
1361 | struct timeval te = {0}; | ||
1362 | struct timeval tw = {0}; | ||
1363 | struct timeval twv = {0}; | ||
1364 | #endif | ||
1365 | |||
1366 | #if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS) | ||
1367 | Status = bcmflash_raw_write((uiOffset/FLASH_PART_SIZE),(uiOffset % FLASH_PART_SIZE),( unsigned char *)pBuffer,uiNumBytes); | ||
1368 | return Status; | ||
1369 | #endif | ||
1370 | |||
1371 | uiOffsetFromSectStart = uiOffset & ~(Adapter->uiSectorSize - 1); | ||
1372 | |||
1373 | //Adding flash Base address | ||
1374 | // uiOffset = uiOffset + GetFlashBaseAddr(Adapter); | ||
1375 | |||
1376 | uiSectAlignAddr = uiOffset & ~(Adapter->uiSectorSize - 1); | ||
1377 | uiCurrSectOffsetAddr = uiOffset & (Adapter->uiSectorSize - 1); | ||
1378 | uiSectBoundary = uiSectAlignAddr + Adapter->uiSectorSize; | ||
1379 | |||
1380 | //pTempBuff = OsalMemAlloc(MAX_SECTOR_SIZE,'!MVN'); | ||
1381 | pTempBuff = OsalMemAlloc(Adapter->uiSectorSize ,'!MVN'); | ||
1382 | if(NULL == pTempBuff) | ||
1383 | { | ||
1384 | goto BeceemFlashBulkWrite_EXIT; | ||
1385 | } | ||
1386 | // | ||
1387 | // check if the data to be written is overlapped accross sectors | ||
1388 | // | ||
1389 | if(uiOffset+uiNumBytes < uiSectBoundary) | ||
1390 | { | ||
1391 | uiNumSectTobeRead = 1; | ||
1392 | } | ||
1393 | else | ||
1394 | { | ||
1395 | // Number of sectors = Last sector start address/First sector start address | ||
1396 | uiNumSectTobeRead = (uiCurrSectOffsetAddr+uiNumBytes)/Adapter->uiSectorSize; | ||
1397 | if((uiCurrSectOffsetAddr+uiNumBytes)%Adapter->uiSectorSize) | ||
1398 | { | ||
1399 | uiNumSectTobeRead++; | ||
1400 | } | ||
1401 | } | ||
1402 | #if 1 | ||
1403 | //Check whether Requested sector is writable or not in case of flash2x write. But if write call is | ||
1404 | // for DSD calibration, allow it without checking of sector permission | ||
1405 | |||
1406 | if(IsFlash2x(Adapter) && (Adapter->bAllDSDWriteAllow == FALSE)) | ||
1407 | { | ||
1408 | index = 0; | ||
1409 | uiTemp = uiNumSectTobeRead ; | ||
1410 | while(uiTemp) | ||
1411 | { | ||
1412 | if(IsOffsetWritable(Adapter, uiOffsetFromSectStart + index * Adapter->uiSectorSize ) == FALSE) | ||
1413 | { | ||
1414 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Sector Starting at offset <0X%X> is not writable", | ||
1415 | (uiOffsetFromSectStart + index * Adapter->uiSectorSize)); | ||
1416 | Status = SECTOR_IS_NOT_WRITABLE; | ||
1417 | goto BeceemFlashBulkWrite_EXIT; | ||
1418 | } | ||
1419 | uiTemp = uiTemp - 1; | ||
1420 | index = index + 1 ; | ||
1421 | } | ||
1422 | } | ||
1423 | #endif | ||
1424 | Adapter->SelectedChip = RESET_CHIP_SELECT; | ||
1425 | while(uiNumSectTobeRead) | ||
1426 | { | ||
1427 | //do_gettimeofday(&tv1); | ||
1428 | //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "\nTime In start of write :%ld ms\n",(tv1.tv_sec *1000 + tv1.tv_usec /1000)); | ||
1429 | uiPartOffset = (uiSectAlignAddr & (FLASH_PART_SIZE - 1)) + GetFlashBaseAddr(Adapter); | ||
1430 | |||
1431 | BcmDoChipSelect(Adapter,uiSectAlignAddr); | ||
1432 | |||
1433 | if(0 != BeceemFlashBulkRead(Adapter, | ||
1434 | (PUINT)pTempBuff, | ||
1435 | uiOffsetFromSectStart, | ||
1436 | Adapter->uiSectorSize)) | ||
1437 | { | ||
1438 | Status = -1; | ||
1439 | goto BeceemFlashBulkWrite_EXIT; | ||
1440 | } | ||
1441 | |||
1442 | //do_gettimeofday(&tr); | ||
1443 | //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Total time taken by Read :%ld ms\n", (tr.tv_sec *1000 + tr.tv_usec/1000) - (tv1.tv_sec *1000 + tv1.tv_usec/1000)); | ||
1444 | |||
1445 | ulStatus = BcmFlashUnProtectBlock(Adapter,uiSectAlignAddr,Adapter->uiSectorSize); | ||
1446 | |||
1447 | |||
1448 | if(uiNumSectTobeRead > 1) | ||
1449 | { | ||
1450 | |||
1451 | OsalMemMove(&pTempBuff[uiCurrSectOffsetAddr],pcBuffer,uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr)); | ||
1452 | pcBuffer += ((uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr))); | ||
1453 | uiNumBytes -= (uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr)); | ||
1454 | } | ||
1455 | else | ||
1456 | { | ||
1457 | OsalMemMove(&pTempBuff[uiCurrSectOffsetAddr],pcBuffer,uiNumBytes); | ||
1458 | } | ||
1459 | |||
1460 | if(IsFlash2x(Adapter)) | ||
1461 | { | ||
1462 | SaveHeaderIfPresent(Adapter,(PUCHAR)pTempBuff,uiOffsetFromSectStart); | ||
1463 | } | ||
1464 | |||
1465 | FlashSectorErase(Adapter,uiPartOffset,1); | ||
1466 | //do_gettimeofday(&te); | ||
1467 | //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Total time taken by Erase :%ld ms\n", (te.tv_sec *1000 + te.tv_usec/1000) - (tr.tv_sec *1000 + tr.tv_usec/1000)); | ||
1468 | |||
1469 | for(uiIndex = 0; uiIndex < Adapter->uiSectorSize; uiIndex +=Adapter->ulFlashWriteSize) | ||
1470 | { | ||
1471 | if(Adapter->device_removed) | ||
1472 | { | ||
1473 | Status = -1; | ||
1474 | goto BeceemFlashBulkWrite_EXIT; | ||
1475 | } | ||
1476 | if(STATUS_SUCCESS != (*Adapter->fpFlashWrite)(Adapter,uiPartOffset+uiIndex,(&pTempBuff[uiIndex]))) | ||
1477 | { | ||
1478 | Status = -1; | ||
1479 | goto BeceemFlashBulkWrite_EXIT; | ||
1480 | } | ||
1481 | } | ||
1482 | |||
1483 | //do_gettimeofday(&tw); | ||
1484 | //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Total time taken in Write to Flash :%ld ms\n", (tw.tv_sec *1000 + tw.tv_usec/1000) - (te.tv_sec *1000 + te.tv_usec/1000)); | ||
1485 | for(uiIndex = 0;uiIndex < Adapter->uiSectorSize;uiIndex += MAX_RW_SIZE) | ||
1486 | { | ||
1487 | if(STATUS_SUCCESS == BeceemFlashBulkRead(Adapter,(PUINT)ucReadBk,uiOffsetFromSectStart+uiIndex,MAX_RW_SIZE)) | ||
1488 | { | ||
1489 | if(Adapter->ulFlashWriteSize == 1) | ||
1490 | { | ||
1491 | UINT uiReadIndex = 0; | ||
1492 | for(uiReadIndex = 0; uiReadIndex < 16; uiReadIndex++) | ||
1493 | { | ||
1494 | if(ucReadBk[uiReadIndex] != pTempBuff[uiIndex+uiReadIndex]) | ||
1495 | { | ||
1496 | if(STATUS_SUCCESS != (*Adapter->fpFlashWriteWithStatusCheck)(Adapter,uiPartOffset+uiIndex+uiReadIndex,&pTempBuff[uiIndex+uiReadIndex])) | ||
1497 | { | ||
1498 | Status = STATUS_FAILURE; | ||
1499 | goto BeceemFlashBulkWrite_EXIT; | ||
1500 | } | ||
1501 | } | ||
1502 | } | ||
1503 | } | ||
1504 | else | ||
1505 | { | ||
1506 | if(OsalMemCompare(ucReadBk,&pTempBuff[uiIndex],MAX_RW_SIZE)) | ||
1507 | { | ||
1508 | if(STATUS_SUCCESS != (*Adapter->fpFlashWriteWithStatusCheck)(Adapter,uiPartOffset+uiIndex,&pTempBuff[uiIndex])) | ||
1509 | { | ||
1510 | Status = STATUS_FAILURE; | ||
1511 | goto BeceemFlashBulkWrite_EXIT; | ||
1512 | } | ||
1513 | } | ||
1514 | } | ||
1515 | } | ||
1516 | } | ||
1517 | //do_gettimeofday(&twv); | ||
1518 | //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Total time taken in Write to Flash verification :%ld ms\n", (twv.tv_sec *1000 + twv.tv_usec/1000) - (tw.tv_sec *1000 + tw.tv_usec/1000)); | ||
1519 | |||
1520 | |||
1521 | if(ulStatus) | ||
1522 | { | ||
1523 | BcmRestoreBlockProtectStatus(Adapter,ulStatus); | ||
1524 | ulStatus = 0; | ||
1525 | } | ||
1526 | |||
1527 | uiCurrSectOffsetAddr = 0; | ||
1528 | uiSectAlignAddr = uiSectBoundary; | ||
1529 | uiSectBoundary += Adapter->uiSectorSize; | ||
1530 | uiOffsetFromSectStart += Adapter->uiSectorSize; | ||
1531 | uiNumSectTobeRead--; | ||
1532 | } | ||
1533 | //do_gettimeofday(&tv2); | ||
1534 | //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Time after Write :%ld ms\n",(tv2.tv_sec *1000 + tv2.tv_usec/1000)); | ||
1535 | //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Total time taken by in Write is :%ld ms\n", (tv2.tv_sec *1000 + tv2.tv_usec/1000) - (tv1.tv_sec *1000 + tv1.tv_usec/1000)); | ||
1536 | // | ||
1537 | // Cleanup. | ||
1538 | // | ||
1539 | BeceemFlashBulkWrite_EXIT: | ||
1540 | if(ulStatus) | ||
1541 | { | ||
1542 | BcmRestoreBlockProtectStatus(Adapter,ulStatus); | ||
1543 | } | ||
1544 | if(pTempBuff) | ||
1545 | { | ||
1546 | OsalMemFree(pTempBuff,Adapter->uiSectorSize); | ||
1547 | } | ||
1548 | |||
1549 | Adapter->SelectedChip = RESET_CHIP_SELECT; | ||
1550 | return Status; | ||
1551 | } | ||
1552 | |||
1553 | |||
1554 | //----------------------------------------------------------------------------- | ||
1555 | // Procedure: BeceemFlashBulkWriteStatus | ||
1556 | // | ||
1557 | // Description: Writes to Flash. Checks the SPI status after each write. | ||
1558 | // | ||
1559 | // Arguments: | ||
1560 | // Adapter - ptr to Adapter object instance | ||
1561 | // pBuffer - Data to be written. | ||
1562 | // uiOffset - Offset of the flash where data needs to be written to. | ||
1563 | // uiNumBytes - Number of bytes to be written. | ||
1564 | // bVerify - read verify flag. | ||
1565 | // Returns: | ||
1566 | // OSAL_STATUS_CODE | ||
1567 | // | ||
1568 | //----------------------------------------------------------------------------- | ||
1569 | |||
1570 | INT BeceemFlashBulkWriteStatus( | ||
1571 | PMINI_ADAPTER Adapter, | ||
1572 | PUINT pBuffer, | ||
1573 | UINT uiOffset, | ||
1574 | UINT uiNumBytes, | ||
1575 | BOOLEAN bVerify) | ||
1576 | { | ||
1577 | PCHAR pTempBuff = NULL; | ||
1578 | PUCHAR pcBuffer = (PUCHAR)pBuffer; | ||
1579 | UINT uiIndex = 0; | ||
1580 | UINT uiOffsetFromSectStart = 0; | ||
1581 | UINT uiSectAlignAddr = 0; | ||
1582 | UINT uiCurrSectOffsetAddr = 0; | ||
1583 | UINT uiSectBoundary = 0; | ||
1584 | UINT uiNumSectTobeRead = 0; | ||
1585 | UCHAR ucReadBk[16] = {0}; | ||
1586 | ULONG ulStatus = 0; | ||
1587 | UINT Status = STATUS_SUCCESS; | ||
1588 | UINT uiTemp = 0; | ||
1589 | UINT index = 0; | ||
1590 | UINT uiPartOffset = 0; | ||
1591 | |||
1592 | uiOffsetFromSectStart = uiOffset & ~(Adapter->uiSectorSize - 1); | ||
1593 | |||
1594 | //uiOffset += Adapter->ulFlashCalStart; | ||
1595 | //Adding flash Base address | ||
1596 | // uiOffset = uiOffset + GetFlashBaseAddr(Adapter); | ||
1597 | |||
1598 | uiSectAlignAddr = uiOffset & ~(Adapter->uiSectorSize - 1); | ||
1599 | uiCurrSectOffsetAddr = uiOffset & (Adapter->uiSectorSize - 1); | ||
1600 | uiSectBoundary = uiSectAlignAddr + Adapter->uiSectorSize; | ||
1601 | |||
1602 | |||
1603 | |||
1604 | // pTempBuff = OsalMemAlloc(MAX_SECTOR_SIZE,'!MVN'); | ||
1605 | pTempBuff = OsalMemAlloc(Adapter->uiSectorSize,'!MVN'); | ||
1606 | if(NULL == pTempBuff) | ||
1607 | { | ||
1608 | goto BeceemFlashBulkWriteStatus_EXIT; | ||
1609 | } | ||
1610 | // | ||
1611 | // check if the data to be written is overlapped accross sectors | ||
1612 | // | ||
1613 | if(uiOffset+uiNumBytes < uiSectBoundary) | ||
1614 | { | ||
1615 | uiNumSectTobeRead = 1; | ||
1616 | } | ||
1617 | else | ||
1618 | { | ||
1619 | // Number of sectors = Last sector start address/First sector start address | ||
1620 | uiNumSectTobeRead = (uiCurrSectOffsetAddr+uiNumBytes)/Adapter->uiSectorSize; | ||
1621 | if((uiCurrSectOffsetAddr+uiNumBytes)%Adapter->uiSectorSize) | ||
1622 | { | ||
1623 | uiNumSectTobeRead++; | ||
1624 | } | ||
1625 | } | ||
1626 | |||
1627 | if(IsFlash2x(Adapter) && (Adapter->bAllDSDWriteAllow == FALSE)) | ||
1628 | { | ||
1629 | index = 0; | ||
1630 | uiTemp = uiNumSectTobeRead ; | ||
1631 | while(uiTemp) | ||
1632 | { | ||
1633 | if(IsOffsetWritable(Adapter,uiOffsetFromSectStart + index * Adapter->uiSectorSize ) == FALSE) | ||
1634 | { | ||
1635 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Sector Starting at offset <0X%x> is not writable", | ||
1636 | (uiOffsetFromSectStart + index * Adapter->uiSectorSize)); | ||
1637 | Status = SECTOR_IS_NOT_WRITABLE; | ||
1638 | goto BeceemFlashBulkWriteStatus_EXIT; | ||
1639 | } | ||
1640 | uiTemp = uiTemp - 1; | ||
1641 | index = index + 1 ; | ||
1642 | } | ||
1643 | } | ||
1644 | |||
1645 | Adapter->SelectedChip = RESET_CHIP_SELECT; | ||
1646 | while(uiNumSectTobeRead) | ||
1647 | { | ||
1648 | uiPartOffset = (uiSectAlignAddr & (FLASH_PART_SIZE - 1)) + GetFlashBaseAddr(Adapter); | ||
1649 | |||
1650 | BcmDoChipSelect(Adapter,uiSectAlignAddr); | ||
1651 | if(0 != BeceemFlashBulkRead(Adapter, | ||
1652 | (PUINT)pTempBuff, | ||
1653 | uiOffsetFromSectStart, | ||
1654 | Adapter->uiSectorSize)) | ||
1655 | { | ||
1656 | Status = -1; | ||
1657 | goto BeceemFlashBulkWriteStatus_EXIT; | ||
1658 | } | ||
1659 | |||
1660 | ulStatus = BcmFlashUnProtectBlock(Adapter,uiOffsetFromSectStart,Adapter->uiSectorSize); | ||
1661 | |||
1662 | if(uiNumSectTobeRead > 1) | ||
1663 | { | ||
1664 | |||
1665 | OsalMemMove(&pTempBuff[uiCurrSectOffsetAddr],pcBuffer,uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr)); | ||
1666 | pcBuffer += ((uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr))); | ||
1667 | uiNumBytes -= (uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr)); | ||
1668 | } | ||
1669 | else | ||
1670 | { | ||
1671 | OsalMemMove(&pTempBuff[uiCurrSectOffsetAddr],pcBuffer,uiNumBytes); | ||
1672 | } | ||
1673 | |||
1674 | if(IsFlash2x(Adapter)) | ||
1675 | { | ||
1676 | SaveHeaderIfPresent(Adapter,(PUCHAR)pTempBuff,uiOffsetFromSectStart); | ||
1677 | } | ||
1678 | |||
1679 | FlashSectorErase(Adapter,uiPartOffset,1); | ||
1680 | |||
1681 | for(uiIndex = 0; uiIndex < Adapter->uiSectorSize; uiIndex +=Adapter->ulFlashWriteSize) | ||
1682 | |||
1683 | { | ||
1684 | if(Adapter->device_removed) | ||
1685 | { | ||
1686 | Status = -1; | ||
1687 | goto BeceemFlashBulkWriteStatus_EXIT; | ||
1688 | } | ||
1689 | |||
1690 | if(STATUS_SUCCESS != (*Adapter->fpFlashWriteWithStatusCheck)(Adapter,uiPartOffset+uiIndex,&pTempBuff[uiIndex])) | ||
1691 | { | ||
1692 | Status = -1; | ||
1693 | goto BeceemFlashBulkWriteStatus_EXIT; | ||
1694 | } | ||
1695 | } | ||
1696 | |||
1697 | if(bVerify) | ||
1698 | { | ||
1699 | for(uiIndex = 0;uiIndex < Adapter->uiSectorSize;uiIndex += MAX_RW_SIZE) | ||
1700 | { | ||
1701 | #if 0 | ||
1702 | if(0 == BeceemFlashBulkRead(Adapter,uiReadBk,uiOffsetFromSectStart+uiIndex + Adapter->ulFlashCalStart ,MAX_RW_SIZE)) | ||
1703 | { | ||
1704 | for(uiReadIndex = 0;uiReadIndex < 4; uiReadIndex++) | ||
1705 | { | ||
1706 | if(*((PUINT)&pTempBuff[uiIndex+uiReadIndex*4]) != uiReadBk[uiReadIndex]) | ||
1707 | { | ||
1708 | Status = -1; | ||
1709 | goto BeceemFlashBulkWriteStatus_EXIT; | ||
1710 | |||
1711 | } | ||
1712 | } | ||
1713 | |||
1714 | } | ||
1715 | #endif | ||
1716 | |||
1717 | if(STATUS_SUCCESS == BeceemFlashBulkRead(Adapter,(PUINT)ucReadBk,uiOffsetFromSectStart+uiIndex,MAX_RW_SIZE)) | ||
1718 | { | ||
1719 | if(OsalMemCompare(ucReadBk,&pTempBuff[uiIndex],MAX_RW_SIZE)) | ||
1720 | { | ||
1721 | Status = STATUS_FAILURE; | ||
1722 | goto BeceemFlashBulkWriteStatus_EXIT; | ||
1723 | } | ||
1724 | |||
1725 | } | ||
1726 | |||
1727 | } | ||
1728 | } | ||
1729 | |||
1730 | if(ulStatus) | ||
1731 | { | ||
1732 | BcmRestoreBlockProtectStatus(Adapter,ulStatus); | ||
1733 | ulStatus = 0; | ||
1734 | } | ||
1735 | |||
1736 | uiCurrSectOffsetAddr = 0; | ||
1737 | uiSectAlignAddr = uiSectBoundary; | ||
1738 | uiSectBoundary += Adapter->uiSectorSize; | ||
1739 | uiOffsetFromSectStart += Adapter->uiSectorSize; | ||
1740 | uiNumSectTobeRead--; | ||
1741 | } | ||
1742 | // | ||
1743 | // Cleanup. | ||
1744 | // | ||
1745 | BeceemFlashBulkWriteStatus_EXIT: | ||
1746 | if(ulStatus) | ||
1747 | { | ||
1748 | BcmRestoreBlockProtectStatus(Adapter,ulStatus); | ||
1749 | } | ||
1750 | if(pTempBuff) | ||
1751 | { | ||
1752 | OsalMemFree(pTempBuff,Adapter->uiSectorSize); | ||
1753 | } | ||
1754 | Adapter->SelectedChip = RESET_CHIP_SELECT; | ||
1755 | return Status; | ||
1756 | |||
1757 | } | ||
1758 | |||
1759 | //----------------------------------------------------------------------------- | ||
1760 | // Procedure: PropagateCalParamsFromEEPROMToMemory | ||
1761 | // | ||
1762 | // Description: Dumps the calibration section of EEPROM to DDR. | ||
1763 | // | ||
1764 | // Arguments: | ||
1765 | // Adapter - ptr to Adapter object instance | ||
1766 | // Returns: | ||
1767 | // OSAL_STATUS_CODE | ||
1768 | // | ||
1769 | //----------------------------------------------------------------------------- | ||
1770 | |||
1771 | |||
1772 | INT PropagateCalParamsFromEEPROMToMemory(PMINI_ADAPTER Adapter) | ||
1773 | { | ||
1774 | PCHAR pBuff = OsalMemAlloc(BUFFER_4K,'3MVN'); | ||
1775 | UINT uiEepromSize = 0; | ||
1776 | UINT uiIndex = 0; | ||
1777 | UINT uiBytesToCopy = 0; | ||
1778 | UINT uiCalStartAddr = EEPROM_CALPARAM_START; | ||
1779 | UINT uiMemoryLoc = EEPROM_CAL_DATA_INTERNAL_LOC; | ||
1780 | UINT value; | ||
1781 | INT Status = 0; | ||
1782 | if(pBuff == NULL) | ||
1783 | { | ||
1784 | return -1; | ||
1785 | } | ||
1786 | |||
1787 | if(0 != BeceemEEPROMBulkRead(Adapter,&uiEepromSize,EEPROM_SIZE_OFFSET,4)) | ||
1788 | { | ||
1789 | |||
1790 | OsalMemFree(pBuff,BUFFER_4K); | ||
1791 | return -1; | ||
1792 | } | ||
1793 | |||
1794 | uiEepromSize >>= 16; | ||
1795 | if(uiEepromSize > 1024*1024) | ||
1796 | { | ||
1797 | OsalMemFree(pBuff,BUFFER_4K); | ||
1798 | return -1; | ||
1799 | } | ||
1800 | |||
1801 | |||
1802 | uiBytesToCopy = MIN(BUFFER_4K,uiEepromSize); | ||
1803 | |||
1804 | while(uiBytesToCopy) | ||
1805 | { | ||
1806 | if(0 != BeceemEEPROMBulkRead(Adapter,(PUINT)pBuff,uiCalStartAddr,uiBytesToCopy)) | ||
1807 | { | ||
1808 | Status = -1; | ||
1809 | break; | ||
1810 | } | ||
1811 | wrm(Adapter,uiMemoryLoc,(PCHAR)(((PULONG)pBuff)+uiIndex),uiBytesToCopy); | ||
1812 | uiMemoryLoc += uiBytesToCopy; | ||
1813 | uiEepromSize -= uiBytesToCopy; | ||
1814 | uiCalStartAddr += uiBytesToCopy; | ||
1815 | uiIndex += uiBytesToCopy/4; | ||
1816 | uiBytesToCopy = MIN(BUFFER_4K,uiEepromSize); | ||
1817 | |||
1818 | } | ||
1819 | value = 0xbeadbead; | ||
1820 | wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC-4,&value, sizeof(value)); | ||
1821 | value = 0xbeadbead; | ||
1822 | wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC-8,&value, sizeof(value)); | ||
1823 | OsalMemFree(pBuff,MAX_RW_SIZE); | ||
1824 | |||
1825 | return Status; | ||
1826 | |||
1827 | } | ||
1828 | |||
1829 | //----------------------------------------------------------------------------- | ||
1830 | // Procedure: PropagateCalParamsFromFlashToMemory | ||
1831 | // | ||
1832 | // Description: Dumps the calibration section of EEPROM to DDR. | ||
1833 | // | ||
1834 | // Arguments: | ||
1835 | // Adapter - ptr to Adapter object instance | ||
1836 | // Returns: | ||
1837 | // OSAL_STATUS_CODE | ||
1838 | // | ||
1839 | //----------------------------------------------------------------------------- | ||
1840 | |||
1841 | INT PropagateCalParamsFromFlashToMemory(PMINI_ADAPTER Adapter) | ||
1842 | { | ||
1843 | PCHAR pBuff, pPtr; | ||
1844 | UINT uiEepromSize = 0; | ||
1845 | UINT uiBytesToCopy = 0; | ||
1846 | //UINT uiIndex = 0; | ||
1847 | UINT uiCalStartAddr = EEPROM_CALPARAM_START; | ||
1848 | UINT uiMemoryLoc = EEPROM_CAL_DATA_INTERNAL_LOC; | ||
1849 | UINT value; | ||
1850 | INT Status = 0; | ||
1851 | // | ||
1852 | // Write the signature first. This will ensure firmware does not access EEPROM. | ||
1853 | // | ||
1854 | value = 0xbeadbead; | ||
1855 | wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 4, &value, sizeof(value)); | ||
1856 | value = 0xbeadbead; | ||
1857 | wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 8, &value, sizeof(value)); | ||
1858 | |||
1859 | if(0 != BeceemNVMRead(Adapter,&uiEepromSize,EEPROM_SIZE_OFFSET, 4)) | ||
1860 | { | ||
1861 | return -1; | ||
1862 | } | ||
1863 | uiEepromSize = ntohl(uiEepromSize); | ||
1864 | uiEepromSize >>= 16; | ||
1865 | |||
1866 | // | ||
1867 | // subtract the auto init section size | ||
1868 | // | ||
1869 | uiEepromSize -= EEPROM_CALPARAM_START; | ||
1870 | |||
1871 | if(uiEepromSize > 1024*1024) | ||
1872 | { | ||
1873 | return -1; | ||
1874 | } | ||
1875 | |||
1876 | pBuff = OsalMemAlloc(uiEepromSize, 0); | ||
1877 | |||
1878 | if ( pBuff == NULL ) | ||
1879 | { | ||
1880 | return -1; | ||
1881 | } | ||
1882 | |||
1883 | if(0 != BeceemNVMRead(Adapter,(PUINT)pBuff,uiCalStartAddr, uiEepromSize)) | ||
1884 | { | ||
1885 | OsalMemFree(pBuff, 0); | ||
1886 | return -1; | ||
1887 | } | ||
1888 | |||
1889 | pPtr = pBuff; | ||
1890 | |||
1891 | uiBytesToCopy = MIN(BUFFER_4K,uiEepromSize); | ||
1892 | |||
1893 | while(uiBytesToCopy) | ||
1894 | { | ||
1895 | Status = wrm(Adapter,uiMemoryLoc,(PCHAR)pPtr,uiBytesToCopy); | ||
1896 | if(Status) | ||
1897 | { | ||
1898 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"wrm failed with status :%d",Status); | ||
1899 | break; | ||
1900 | } | ||
1901 | |||
1902 | pPtr += uiBytesToCopy; | ||
1903 | uiEepromSize -= uiBytesToCopy; | ||
1904 | uiMemoryLoc += uiBytesToCopy; | ||
1905 | uiBytesToCopy = MIN(BUFFER_4K,uiEepromSize); | ||
1906 | } | ||
1907 | |||
1908 | OsalMemFree(pBuff, 0); | ||
1909 | return Status; | ||
1910 | |||
1911 | } | ||
1912 | |||
1913 | //----------------------------------------------------------------------------- | ||
1914 | // Procedure: BeceemEEPROMReadBackandVerify | ||
1915 | // | ||
1916 | // Description: Read back the data written and verifies. | ||
1917 | // | ||
1918 | // Arguments: | ||
1919 | // Adapter - ptr to Adapter object instance | ||
1920 | // pBuffer - Data to be written. | ||
1921 | // uiOffset - Offset of the flash where data needs to be written to. | ||
1922 | // uiNumBytes - Number of bytes to be written. | ||
1923 | // Returns: | ||
1924 | // OSAL_STATUS_CODE | ||
1925 | // | ||
1926 | //----------------------------------------------------------------------------- | ||
1927 | |||
1928 | INT BeceemEEPROMReadBackandVerify( | ||
1929 | PMINI_ADAPTER Adapter, | ||
1930 | PUINT pBuffer, | ||
1931 | UINT uiOffset, | ||
1932 | UINT uiNumBytes) | ||
1933 | { | ||
1934 | UINT uiRdbk = 0; | ||
1935 | UINT uiIndex = 0; | ||
1936 | UINT uiData = 0; | ||
1937 | UINT auiData[4] = {0}; | ||
1938 | |||
1939 | while(uiNumBytes) | ||
1940 | { | ||
1941 | if(Adapter->device_removed ) | ||
1942 | { | ||
1943 | return -1; | ||
1944 | } | ||
1945 | |||
1946 | if(uiNumBytes >= MAX_RW_SIZE) | ||
1947 | {// for the requests more than or equal to MAX_RW_SIZE bytes, use bulk read function to make the access faster. | ||
1948 | BeceemEEPROMBulkRead(Adapter,&auiData[0],uiOffset,MAX_RW_SIZE); | ||
1949 | |||
1950 | if(OsalMemCompare(&pBuffer[uiIndex],&auiData[0],MAX_RW_SIZE)) | ||
1951 | { | ||
1952 | // re-write | ||
1953 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)(pBuffer+uiIndex),uiOffset,MAX_RW_SIZE,FALSE); | ||
1954 | mdelay(3); | ||
1955 | BeceemEEPROMBulkRead(Adapter,&auiData[0],uiOffset,MAX_RW_SIZE); | ||
1956 | |||
1957 | if(OsalMemCompare(&pBuffer[uiIndex],&auiData[0],MAX_RW_SIZE)) | ||
1958 | { | ||
1959 | return -1; | ||
1960 | } | ||
1961 | } | ||
1962 | uiOffset += MAX_RW_SIZE; | ||
1963 | uiNumBytes -= MAX_RW_SIZE; | ||
1964 | uiIndex += 4; | ||
1965 | |||
1966 | } | ||
1967 | else if(uiNumBytes >= 4) | ||
1968 | { | ||
1969 | BeceemEEPROMBulkRead(Adapter,&uiData,uiOffset,4); | ||
1970 | if(uiData != pBuffer[uiIndex]) | ||
1971 | { | ||
1972 | //re-write | ||
1973 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)(pBuffer+uiIndex),uiOffset,4,FALSE); | ||
1974 | mdelay(3); | ||
1975 | BeceemEEPROMBulkRead(Adapter,&uiData,uiOffset,4); | ||
1976 | if(uiData != pBuffer[uiIndex]) | ||
1977 | { | ||
1978 | return -1; | ||
1979 | } | ||
1980 | } | ||
1981 | uiOffset += 4; | ||
1982 | uiNumBytes -= 4; | ||
1983 | uiIndex++; | ||
1984 | |||
1985 | } | ||
1986 | else | ||
1987 | { // Handle the reads less than 4 bytes... | ||
1988 | uiData = 0; | ||
1989 | OsalMemMove(&uiData,((PUCHAR)pBuffer)+(uiIndex*sizeof(UINT)),uiNumBytes); | ||
1990 | BeceemEEPROMBulkRead(Adapter,&uiRdbk,uiOffset,4); | ||
1991 | |||
1992 | if(memcmp(&uiData, &uiRdbk, uiNumBytes)) | ||
1993 | return -1; | ||
1994 | |||
1995 | uiNumBytes = 0; | ||
1996 | } | ||
1997 | |||
1998 | } | ||
1999 | |||
2000 | return 0; | ||
2001 | } | ||
2002 | |||
2003 | VOID BcmSwapWord(UINT *ptr1) { | ||
2004 | |||
2005 | UINT tempval = (UINT)*ptr1; | ||
2006 | char *ptr2 = (char *)&tempval; | ||
2007 | char *ptr = (char *)ptr1; | ||
2008 | |||
2009 | ptr[0] = ptr2[3]; | ||
2010 | ptr[1] = ptr2[2]; | ||
2011 | ptr[2] = ptr2[1]; | ||
2012 | ptr[3] = ptr2[0]; | ||
2013 | } | ||
2014 | |||
2015 | //----------------------------------------------------------------------------- | ||
2016 | // Procedure: BeceemEEPROMWritePage | ||
2017 | // | ||
2018 | // Description: Performs page write (16bytes) to the EEPROM | ||
2019 | // | ||
2020 | // Arguments: | ||
2021 | // Adapter - ptr to Adapter object instance | ||
2022 | // uiData - Data to be written. | ||
2023 | // uiOffset - Offset of the EEPROM where data needs to be written to. | ||
2024 | // Returns: | ||
2025 | // OSAL_STATUS_CODE | ||
2026 | // | ||
2027 | //----------------------------------------------------------------------------- | ||
2028 | INT BeceemEEPROMWritePage( PMINI_ADAPTER Adapter, UINT uiData[], UINT uiOffset ) | ||
2029 | { | ||
2030 | UINT uiRetries = MAX_EEPROM_RETRIES*RETRIES_PER_DELAY; | ||
2031 | UINT uiStatus = 0; | ||
2032 | UCHAR uiEpromStatus = 0; | ||
2033 | UINT value =0 ; | ||
2034 | |||
2035 | /* Flush the Write/Read/Cmd queues. */ | ||
2036 | value = ( EEPROM_WRITE_QUEUE_FLUSH | EEPROM_CMD_QUEUE_FLUSH | EEPROM_READ_QUEUE_FLUSH ); | ||
2037 | wrmalt( Adapter, SPI_FLUSH_REG, &value, sizeof(value)); | ||
2038 | value = 0 ; | ||
2039 | wrmalt( Adapter, SPI_FLUSH_REG, &value, sizeof(value) ); | ||
2040 | |||
2041 | /* Clear the Empty/Avail/Full bits. After this it has been confirmed | ||
2042 | * that the bit was cleared by reading back the register. See NOTE below. | ||
2043 | * We also clear the Read queues as we do a EEPROM status register read | ||
2044 | * later. */ | ||
2045 | value = ( EEPROM_WRITE_QUEUE_EMPTY | EEPROM_WRITE_QUEUE_AVAIL | EEPROM_WRITE_QUEUE_FULL | EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL ) ; | ||
2046 | wrmalt( Adapter, EEPROM_SPI_Q_STATUS1_REG,&value, sizeof(value)); | ||
2047 | |||
2048 | /* Enable write */ | ||
2049 | value = EEPROM_WRITE_ENABLE ; | ||
2050 | wrmalt( Adapter, EEPROM_CMDQ_SPI_REG,&value, sizeof(value) ); | ||
2051 | |||
2052 | /* We can write back to back 8bits * 16 into the queue and as we have | ||
2053 | * checked for the queue to be empty we can write in a burst. */ | ||
2054 | |||
2055 | value = uiData[0]; | ||
2056 | BcmSwapWord(&value); | ||
2057 | wrm( Adapter, EEPROM_WRITE_DATAQ_REG, (PUCHAR)&value, 4); | ||
2058 | |||
2059 | value = uiData[1]; | ||
2060 | BcmSwapWord(&value); | ||
2061 | wrm( Adapter, EEPROM_WRITE_DATAQ_REG, (PUCHAR)&value, 4); | ||
2062 | |||
2063 | value = uiData[2]; | ||
2064 | BcmSwapWord(&value); | ||
2065 | wrm( Adapter, EEPROM_WRITE_DATAQ_REG, (PUCHAR)&value, 4); | ||
2066 | |||
2067 | value = uiData[3]; | ||
2068 | BcmSwapWord(&value); | ||
2069 | wrm( Adapter, EEPROM_WRITE_DATAQ_REG, (PUCHAR)&value, 4); | ||
2070 | |||
2071 | /* NOTE : After this write, on readback of EEPROM_SPI_Q_STATUS1_REG | ||
2072 | * shows that we see 7 for the EEPROM data write. Which means that | ||
2073 | * queue got full, also space is available as well as the queue is empty. | ||
2074 | * This may happen in sequence. */ | ||
2075 | value = EEPROM_16_BYTE_PAGE_WRITE | uiOffset ; | ||
2076 | wrmalt( Adapter, EEPROM_CMDQ_SPI_REG, &value, sizeof(value) ); | ||
2077 | |||
2078 | /* Ideally we should loop here without tries and eventually succeed. | ||
2079 | * What we are checking if the previous write has completed, and this | ||
2080 | * may take time. We should wait till the Empty bit is set. */ | ||
2081 | uiStatus = 0; | ||
2082 | rdmalt( Adapter, EEPROM_SPI_Q_STATUS1_REG,&uiStatus, sizeof(uiStatus)) ; | ||
2083 | while ( ( uiStatus & EEPROM_WRITE_QUEUE_EMPTY ) == 0 ) | ||
2084 | { | ||
2085 | uiRetries--; | ||
2086 | if ( uiRetries == 0 ) | ||
2087 | { | ||
2088 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "0x0f003004 = %x, %d retries failed.\n", uiStatus, MAX_EEPROM_RETRIES *RETRIES_PER_DELAY); | ||
2089 | return STATUS_FAILURE ; | ||
2090 | } | ||
2091 | |||
2092 | if( !(uiRetries%RETRIES_PER_DELAY) ) | ||
2093 | msleep(1); | ||
2094 | |||
2095 | uiStatus = 0; | ||
2096 | rdmalt( Adapter, EEPROM_SPI_Q_STATUS1_REG,&uiStatus, sizeof(uiStatus)) ; | ||
2097 | if(Adapter->device_removed == TRUE) | ||
2098 | { | ||
2099 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Modem got removed hence exiting from loop...."); | ||
2100 | return -ENODEV; | ||
2101 | } | ||
2102 | |||
2103 | } | ||
2104 | |||
2105 | if ( uiRetries != 0 ) | ||
2106 | { | ||
2107 | /* Clear the ones that are set - either, Empty/Full/Avail bits */ | ||
2108 | value = ( uiStatus & ( EEPROM_WRITE_QUEUE_EMPTY | EEPROM_WRITE_QUEUE_AVAIL | EEPROM_WRITE_QUEUE_FULL ) ); | ||
2109 | wrmalt( Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value)); | ||
2110 | } | ||
2111 | |||
2112 | /* Here we should check if the EEPROM status register is correct before | ||
2113 | * proceeding. Bit 0 in the EEPROM Status register should be 0 before | ||
2114 | * we proceed further. A 1 at Bit 0 indicates that the EEPROM is busy | ||
2115 | * with the previous write. Note also that issuing this read finally | ||
2116 | * means the previous write to the EEPROM has completed. */ | ||
2117 | uiRetries = MAX_EEPROM_RETRIES*RETRIES_PER_DELAY; | ||
2118 | uiEpromStatus = 0; | ||
2119 | while ( uiRetries != 0 ) | ||
2120 | { | ||
2121 | uiEpromStatus = ReadEEPROMStatusRegister( Adapter) ; | ||
2122 | if(Adapter->device_removed == TRUE) | ||
2123 | { | ||
2124 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Modem has got removed hence exiting from loop..."); | ||
2125 | return -ENODEV; | ||
2126 | } | ||
2127 | if ( ( EEPROM_STATUS_REG_WRITE_BUSY & uiEpromStatus ) == 0 ) | ||
2128 | { | ||
2129 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "EEPROM status register = %x tries = %d\n", uiEpromStatus, (MAX_EEPROM_RETRIES * RETRIES_PER_DELAY- uiRetries) ); | ||
2130 | return STATUS_SUCCESS ; | ||
2131 | } | ||
2132 | uiRetries--; | ||
2133 | if ( uiRetries == 0 ) | ||
2134 | { | ||
2135 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "0x0f003004 = %x, for EEPROM status read %d retries failed.\n", uiEpromStatus, MAX_EEPROM_RETRIES *RETRIES_PER_DELAY); | ||
2136 | return STATUS_FAILURE ; | ||
2137 | } | ||
2138 | uiEpromStatus = 0; | ||
2139 | if( !(uiRetries%RETRIES_PER_DELAY) ) | ||
2140 | msleep(1); | ||
2141 | } | ||
2142 | |||
2143 | return STATUS_SUCCESS ; | ||
2144 | } /* BeceemEEPROMWritePage */ | ||
2145 | |||
2146 | |||
2147 | //----------------------------------------------------------------------------- | ||
2148 | // Procedure: BeceemEEPROMBulkWrite | ||
2149 | // | ||
2150 | // Description: Performs write to the EEPROM | ||
2151 | // | ||
2152 | // Arguments: | ||
2153 | // Adapter - ptr to Adapter object instance | ||
2154 | // pBuffer - Data to be written. | ||
2155 | // uiOffset - Offset of the EEPROM where data needs to be written to. | ||
2156 | // uiNumBytes - Number of bytes to be written. | ||
2157 | // bVerify - read verify flag. | ||
2158 | // Returns: | ||
2159 | // OSAL_STATUS_CODE | ||
2160 | // | ||
2161 | //----------------------------------------------------------------------------- | ||
2162 | |||
2163 | INT BeceemEEPROMBulkWrite( | ||
2164 | PMINI_ADAPTER Adapter, | ||
2165 | PUCHAR pBuffer, | ||
2166 | UINT uiOffset, | ||
2167 | UINT uiNumBytes, | ||
2168 | BOOLEAN bVerify) | ||
2169 | { | ||
2170 | UINT uiBytesToCopy = uiNumBytes; | ||
2171 | //UINT uiRdbk = 0; | ||
2172 | UINT uiData[4] = {0}; | ||
2173 | UINT uiIndex = 0; | ||
2174 | UINT uiTempOffset = 0; | ||
2175 | UINT uiExtraBytes = 0; | ||
2176 | //PUINT puiBuffer = (PUINT)pBuffer; | ||
2177 | //INT value; | ||
2178 | |||
2179 | if(uiOffset%MAX_RW_SIZE && uiBytesToCopy) | ||
2180 | { | ||
2181 | uiTempOffset = uiOffset - (uiOffset%MAX_RW_SIZE); | ||
2182 | uiExtraBytes = uiOffset-uiTempOffset; | ||
2183 | |||
2184 | |||
2185 | BeceemEEPROMBulkRead(Adapter,&uiData[0],uiTempOffset,MAX_RW_SIZE); | ||
2186 | |||
2187 | if(uiBytesToCopy >= (16 -uiExtraBytes)) | ||
2188 | { | ||
2189 | OsalMemMove((((PUCHAR)&uiData[0])+uiExtraBytes),pBuffer,MAX_RW_SIZE- uiExtraBytes); | ||
2190 | |||
2191 | if ( STATUS_FAILURE == BeceemEEPROMWritePage( Adapter, uiData, uiTempOffset ) ) | ||
2192 | return STATUS_FAILURE; | ||
2193 | |||
2194 | uiBytesToCopy -= (MAX_RW_SIZE - uiExtraBytes); | ||
2195 | uiIndex += (MAX_RW_SIZE - uiExtraBytes); | ||
2196 | uiOffset += (MAX_RW_SIZE - uiExtraBytes); | ||
2197 | } | ||
2198 | else | ||
2199 | { | ||
2200 | OsalMemMove((((PUCHAR)&uiData[0])+uiExtraBytes),pBuffer,uiBytesToCopy); | ||
2201 | |||
2202 | if ( STATUS_FAILURE == BeceemEEPROMWritePage( Adapter, uiData, uiTempOffset ) ) | ||
2203 | return STATUS_FAILURE; | ||
2204 | |||
2205 | uiIndex += uiBytesToCopy; | ||
2206 | uiOffset += uiBytesToCopy; | ||
2207 | uiBytesToCopy = 0; | ||
2208 | } | ||
2209 | |||
2210 | |||
2211 | } | ||
2212 | |||
2213 | while(uiBytesToCopy) | ||
2214 | { | ||
2215 | if(Adapter->device_removed) | ||
2216 | { | ||
2217 | return -1; | ||
2218 | } | ||
2219 | |||
2220 | if(uiBytesToCopy >= MAX_RW_SIZE) | ||
2221 | { | ||
2222 | |||
2223 | if (STATUS_FAILURE == BeceemEEPROMWritePage( Adapter, (PUINT) &pBuffer[uiIndex], uiOffset ) ) | ||
2224 | return STATUS_FAILURE; | ||
2225 | |||
2226 | uiIndex += MAX_RW_SIZE; | ||
2227 | uiOffset += MAX_RW_SIZE; | ||
2228 | uiBytesToCopy -= MAX_RW_SIZE; | ||
2229 | } | ||
2230 | else | ||
2231 | { | ||
2232 | // | ||
2233 | // To program non 16byte aligned data, read 16byte and then update. | ||
2234 | // | ||
2235 | BeceemEEPROMBulkRead(Adapter,&uiData[0],uiOffset,16); | ||
2236 | OsalMemMove(&uiData[0],pBuffer+uiIndex,uiBytesToCopy); | ||
2237 | |||
2238 | |||
2239 | if ( STATUS_FAILURE == BeceemEEPROMWritePage( Adapter, uiData, uiOffset ) ) | ||
2240 | return STATUS_FAILURE; | ||
2241 | uiBytesToCopy = 0; | ||
2242 | } | ||
2243 | |||
2244 | } | ||
2245 | |||
2246 | return 0; | ||
2247 | } | ||
2248 | |||
2249 | //----------------------------------------------------------------------------- | ||
2250 | // Procedure: BeceemNVMRead | ||
2251 | // | ||
2252 | // Description: Reads n number of bytes from NVM. | ||
2253 | // | ||
2254 | // Arguments: | ||
2255 | // Adapter - ptr to Adapter object instance | ||
2256 | // pBuffer - Buffer to store the data read from NVM | ||
2257 | // uiOffset - Offset of NVM from where data should be read | ||
2258 | // uiNumBytes - Number of bytes to be read from the NVM. | ||
2259 | // | ||
2260 | // Returns: | ||
2261 | // OSAL_STATUS_SUCCESS - if NVM read is successfull. | ||
2262 | // <FAILURE> - if failed. | ||
2263 | //----------------------------------------------------------------------------- | ||
2264 | |||
2265 | INT BeceemNVMRead( | ||
2266 | PMINI_ADAPTER Adapter, | ||
2267 | PUINT pBuffer, | ||
2268 | UINT uiOffset, | ||
2269 | UINT uiNumBytes) | ||
2270 | { | ||
2271 | INT Status = 0; | ||
2272 | #if !defined(BCM_SHM_INTERFACE) || defined(FLASH_DIRECT_ACCESS) | ||
2273 | UINT uiTemp = 0, value; | ||
2274 | #endif | ||
2275 | |||
2276 | if(Adapter->eNVMType == NVM_FLASH) | ||
2277 | { | ||
2278 | if(Adapter->bFlashRawRead == FALSE) | ||
2279 | { | ||
2280 | if (IsSectionExistInVendorInfo(Adapter,Adapter->eActiveDSD)) | ||
2281 | return vendorextnReadSection(Adapter,(PUCHAR)pBuffer,Adapter->eActiveDSD,uiOffset,uiNumBytes); | ||
2282 | uiOffset = uiOffset+ Adapter->ulFlashCalStart ; | ||
2283 | } | ||
2284 | #if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS) | ||
2285 | Status = bcmflash_raw_read((uiOffset/FLASH_PART_SIZE),(uiOffset % FLASH_PART_SIZE),( unsigned char *)pBuffer,uiNumBytes); | ||
2286 | #else | ||
2287 | |||
2288 | rdmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp)); | ||
2289 | value = 0; | ||
2290 | wrmalt(Adapter, 0x0f000C80,&value, sizeof(value)); | ||
2291 | Status = BeceemFlashBulkRead(Adapter, | ||
2292 | pBuffer, | ||
2293 | uiOffset, | ||
2294 | uiNumBytes); | ||
2295 | wrmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp)); | ||
2296 | #endif | ||
2297 | } | ||
2298 | else if(Adapter->eNVMType == NVM_EEPROM) | ||
2299 | { | ||
2300 | Status = BeceemEEPROMBulkRead(Adapter, | ||
2301 | pBuffer, | ||
2302 | uiOffset, | ||
2303 | uiNumBytes); | ||
2304 | } | ||
2305 | else | ||
2306 | { | ||
2307 | Status = -1; | ||
2308 | } | ||
2309 | return Status; | ||
2310 | } | ||
2311 | |||
2312 | //----------------------------------------------------------------------------- | ||
2313 | // Procedure: BeceemNVMWrite | ||
2314 | // | ||
2315 | // Description: Writes n number of bytes to NVM. | ||
2316 | // | ||
2317 | // Arguments: | ||
2318 | // Adapter - ptr to Adapter object instance | ||
2319 | // pBuffer - Buffer contains the data to be written. | ||
2320 | // uiOffset - Offset of NVM where data to be written to. | ||
2321 | // uiNumBytes - Number of bytes to be written.. | ||
2322 | // | ||
2323 | // Returns: | ||
2324 | // OSAL_STATUS_SUCCESS - if NVM write is successfull. | ||
2325 | // <FAILURE> - if failed. | ||
2326 | //----------------------------------------------------------------------------- | ||
2327 | |||
2328 | INT BeceemNVMWrite( | ||
2329 | PMINI_ADAPTER Adapter, | ||
2330 | PUINT pBuffer, | ||
2331 | UINT uiOffset, | ||
2332 | UINT uiNumBytes, | ||
2333 | BOOLEAN bVerify) | ||
2334 | { | ||
2335 | INT Status = 0; | ||
2336 | UINT uiTemp = 0; | ||
2337 | UINT uiMemoryLoc = EEPROM_CAL_DATA_INTERNAL_LOC; | ||
2338 | UINT uiIndex = 0; | ||
2339 | #if !defined(BCM_SHM_INTERFACE) || defined(FLASH_DIRECT_ACCESS) | ||
2340 | UINT value; | ||
2341 | #endif | ||
2342 | UINT uiFlashOffset = 0; | ||
2343 | |||
2344 | if(Adapter->eNVMType == NVM_FLASH) | ||
2345 | { | ||
2346 | if (IsSectionExistInVendorInfo(Adapter,Adapter->eActiveDSD)) | ||
2347 | Status = vendorextnWriteSection(Adapter,(PUCHAR)pBuffer,Adapter->eActiveDSD,uiOffset,uiNumBytes,bVerify); | ||
2348 | else | ||
2349 | { | ||
2350 | uiFlashOffset = uiOffset + Adapter->ulFlashCalStart; | ||
2351 | |||
2352 | #if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS) | ||
2353 | Status = bcmflash_raw_write((uiFlashOffset/FLASH_PART_SIZE), (uiFlashOffset % FLASH_PART_SIZE), (unsigned char *)pBuffer,uiNumBytes); | ||
2354 | #else | ||
2355 | rdmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp)); | ||
2356 | value = 0; | ||
2357 | wrmalt(Adapter, 0x0f000C80, &value, sizeof(value)); | ||
2358 | |||
2359 | if(Adapter->bStatusWrite == TRUE) | ||
2360 | { | ||
2361 | Status = BeceemFlashBulkWriteStatus(Adapter, | ||
2362 | pBuffer, | ||
2363 | uiFlashOffset, | ||
2364 | uiNumBytes , | ||
2365 | bVerify); | ||
2366 | } | ||
2367 | else | ||
2368 | { | ||
2369 | |||
2370 | Status = BeceemFlashBulkWrite(Adapter, | ||
2371 | pBuffer, | ||
2372 | uiFlashOffset, | ||
2373 | uiNumBytes, | ||
2374 | bVerify); | ||
2375 | } | ||
2376 | #endif | ||
2377 | } | ||
2378 | |||
2379 | |||
2380 | if(uiOffset >= EEPROM_CALPARAM_START) | ||
2381 | { | ||
2382 | uiMemoryLoc += (uiOffset - EEPROM_CALPARAM_START); | ||
2383 | while(uiNumBytes) | ||
2384 | { | ||
2385 | if(uiNumBytes > BUFFER_4K) | ||
2386 | { | ||
2387 | wrm(Adapter,(uiMemoryLoc+uiIndex),(PCHAR)(pBuffer+(uiIndex/4)),BUFFER_4K); | ||
2388 | uiNumBytes -= BUFFER_4K; | ||
2389 | uiIndex += BUFFER_4K; | ||
2390 | } | ||
2391 | else | ||
2392 | { | ||
2393 | wrm(Adapter,uiMemoryLoc+uiIndex,(PCHAR)(pBuffer+(uiIndex/4)),uiNumBytes); | ||
2394 | uiNumBytes = 0; | ||
2395 | break; | ||
2396 | } | ||
2397 | } | ||
2398 | } | ||
2399 | else | ||
2400 | { | ||
2401 | if((uiOffset+uiNumBytes) > EEPROM_CALPARAM_START) | ||
2402 | { | ||
2403 | ULONG ulBytesTobeSkipped = 0; | ||
2404 | PUCHAR pcBuffer = (PUCHAR)pBuffer;// char pointer to take care of odd byte cases. | ||
2405 | uiNumBytes -= (EEPROM_CALPARAM_START - uiOffset); | ||
2406 | ulBytesTobeSkipped += (EEPROM_CALPARAM_START - uiOffset); | ||
2407 | uiOffset += (EEPROM_CALPARAM_START - uiOffset); | ||
2408 | while(uiNumBytes) | ||
2409 | { | ||
2410 | if(uiNumBytes > BUFFER_4K) | ||
2411 | { | ||
2412 | wrm(Adapter,uiMemoryLoc+uiIndex,(PCHAR )&pcBuffer[ulBytesTobeSkipped+uiIndex],BUFFER_4K); | ||
2413 | uiNumBytes -= BUFFER_4K; | ||
2414 | uiIndex += BUFFER_4K; | ||
2415 | } | ||
2416 | else | ||
2417 | { | ||
2418 | wrm(Adapter,uiMemoryLoc+uiIndex,(PCHAR)&pcBuffer[ulBytesTobeSkipped+uiIndex],uiNumBytes); | ||
2419 | uiNumBytes = 0; | ||
2420 | break; | ||
2421 | } | ||
2422 | } | ||
2423 | |||
2424 | } | ||
2425 | } | ||
2426 | |||
2427 | // restore the values. | ||
2428 | wrmalt(Adapter,0x0f000C80,&uiTemp, sizeof(uiTemp)); | ||
2429 | } | ||
2430 | else if(Adapter->eNVMType == NVM_EEPROM) | ||
2431 | { | ||
2432 | Status = BeceemEEPROMBulkWrite(Adapter, | ||
2433 | (PUCHAR)pBuffer, | ||
2434 | uiOffset, | ||
2435 | uiNumBytes, | ||
2436 | bVerify); | ||
2437 | if(bVerify) | ||
2438 | { | ||
2439 | Status = BeceemEEPROMReadBackandVerify(Adapter,(PUINT)pBuffer,uiOffset,uiNumBytes); | ||
2440 | } | ||
2441 | } | ||
2442 | else | ||
2443 | { | ||
2444 | Status = -1; | ||
2445 | } | ||
2446 | return Status; | ||
2447 | } | ||
2448 | |||
2449 | //----------------------------------------------------------------------------- | ||
2450 | // Procedure: BcmUpdateSectorSize | ||
2451 | // | ||
2452 | // Description: Updates the sector size to FLASH. | ||
2453 | // | ||
2454 | // Arguments: | ||
2455 | // Adapter - ptr to Adapter object instance | ||
2456 | // uiSectorSize - sector size | ||
2457 | // | ||
2458 | // Returns: | ||
2459 | // OSAL_STATUS_SUCCESS - if NVM write is successfull. | ||
2460 | // <FAILURE> - if failed. | ||
2461 | //----------------------------------------------------------------------------- | ||
2462 | |||
2463 | INT BcmUpdateSectorSize(PMINI_ADAPTER Adapter,UINT uiSectorSize) | ||
2464 | { | ||
2465 | INT Status = -1; | ||
2466 | FLASH_CS_INFO sFlashCsInfo = {0}; | ||
2467 | UINT uiTemp = 0; | ||
2468 | |||
2469 | UINT uiSectorSig = 0; | ||
2470 | UINT uiCurrentSectorSize = 0; | ||
2471 | |||
2472 | UINT value; | ||
2473 | |||
2474 | |||
2475 | |||
2476 | rdmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp)); | ||
2477 | value = 0; | ||
2478 | wrmalt(Adapter, 0x0f000C80,&value, sizeof(value)); | ||
2479 | |||
2480 | // | ||
2481 | // Before updating the sector size in the reserved area, check if already present. | ||
2482 | // | ||
2483 | BeceemFlashBulkRead(Adapter,(PUINT)&sFlashCsInfo,Adapter->ulFlashControlSectionStart,sizeof(sFlashCsInfo)); | ||
2484 | uiSectorSig = ntohl(sFlashCsInfo.FlashSectorSizeSig); | ||
2485 | uiCurrentSectorSize = ntohl(sFlashCsInfo.FlashSectorSize); | ||
2486 | |||
2487 | if(uiSectorSig == FLASH_SECTOR_SIZE_SIG) | ||
2488 | { | ||
2489 | |||
2490 | if((uiCurrentSectorSize <= MAX_SECTOR_SIZE) && (uiCurrentSectorSize >= MIN_SECTOR_SIZE)) | ||
2491 | { | ||
2492 | if(uiSectorSize == uiCurrentSectorSize) | ||
2493 | { | ||
2494 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Provided sector size is same as programmed in Flash"); | ||
2495 | Status = STATUS_SUCCESS; | ||
2496 | goto Restore ; | ||
2497 | } | ||
2498 | } | ||
2499 | } | ||
2500 | |||
2501 | if((uiSectorSize <= MAX_SECTOR_SIZE) && (uiSectorSize >= MIN_SECTOR_SIZE)) | ||
2502 | { | ||
2503 | |||
2504 | sFlashCsInfo.FlashSectorSize = htonl(uiSectorSize); | ||
2505 | sFlashCsInfo.FlashSectorSizeSig = htonl(FLASH_SECTOR_SIZE_SIG); | ||
2506 | |||
2507 | Status = BeceemFlashBulkWrite(Adapter, | ||
2508 | (PUINT)&sFlashCsInfo, | ||
2509 | Adapter->ulFlashControlSectionStart, | ||
2510 | sizeof(sFlashCsInfo), | ||
2511 | TRUE); | ||
2512 | |||
2513 | |||
2514 | } | ||
2515 | |||
2516 | Restore : | ||
2517 | // restore the values. | ||
2518 | wrmalt(Adapter, 0x0f000C80,&uiTemp, sizeof(uiTemp)); | ||
2519 | |||
2520 | |||
2521 | return Status; | ||
2522 | |||
2523 | } | ||
2524 | |||
2525 | //----------------------------------------------------------------------------- | ||
2526 | // Procedure: BcmGetFlashSectorSize | ||
2527 | // | ||
2528 | // Description: Finds the sector size of the FLASH. | ||
2529 | // | ||
2530 | // Arguments: | ||
2531 | // Adapter - ptr to Adapter object instance | ||
2532 | // | ||
2533 | // Returns: | ||
2534 | // UINT - sector size. | ||
2535 | // | ||
2536 | //----------------------------------------------------------------------------- | ||
2537 | |||
2538 | UINT BcmGetFlashSectorSize(PMINI_ADAPTER Adapter, UINT FlashSectorSizeSig, UINT FlashSectorSize) | ||
2539 | { | ||
2540 | UINT uiSectorSize = 0; | ||
2541 | UINT uiSectorSig = 0; | ||
2542 | |||
2543 | if(Adapter->bSectorSizeOverride && | ||
2544 | (Adapter->uiSectorSizeInCFG <= MAX_SECTOR_SIZE && | ||
2545 | Adapter->uiSectorSizeInCFG >= MIN_SECTOR_SIZE)) | ||
2546 | { | ||
2547 | Adapter->uiSectorSize = Adapter->uiSectorSizeInCFG; | ||
2548 | } | ||
2549 | else | ||
2550 | { | ||
2551 | |||
2552 | uiSectorSig = FlashSectorSizeSig; | ||
2553 | |||
2554 | if(uiSectorSig == FLASH_SECTOR_SIZE_SIG) | ||
2555 | { | ||
2556 | uiSectorSize = FlashSectorSize; | ||
2557 | // | ||
2558 | // If the sector size stored in the FLASH makes sense then use it. | ||
2559 | // | ||
2560 | if(uiSectorSize <= MAX_SECTOR_SIZE && uiSectorSize >= MIN_SECTOR_SIZE) | ||
2561 | { | ||
2562 | Adapter->uiSectorSize = uiSectorSize; | ||
2563 | } | ||
2564 | //No valid size in FLASH, check if Config file has it. | ||
2565 | else if(Adapter->uiSectorSizeInCFG <= MAX_SECTOR_SIZE && | ||
2566 | Adapter->uiSectorSizeInCFG >= MIN_SECTOR_SIZE) | ||
2567 | { | ||
2568 | Adapter->uiSectorSize = Adapter->uiSectorSizeInCFG; | ||
2569 | } | ||
2570 | // Init to Default, if none of the above works. | ||
2571 | else | ||
2572 | { | ||
2573 | Adapter->uiSectorSize = DEFAULT_SECTOR_SIZE; | ||
2574 | } | ||
2575 | |||
2576 | } | ||
2577 | else | ||
2578 | { | ||
2579 | if(Adapter->uiSectorSizeInCFG <= MAX_SECTOR_SIZE && | ||
2580 | Adapter->uiSectorSizeInCFG >= MIN_SECTOR_SIZE) | ||
2581 | { | ||
2582 | Adapter->uiSectorSize = Adapter->uiSectorSizeInCFG; | ||
2583 | } | ||
2584 | else | ||
2585 | { | ||
2586 | Adapter->uiSectorSize = DEFAULT_SECTOR_SIZE; | ||
2587 | } | ||
2588 | } | ||
2589 | } | ||
2590 | |||
2591 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Sector size :%x \n", Adapter->uiSectorSize); | ||
2592 | return Adapter->uiSectorSize; | ||
2593 | } | ||
2594 | |||
2595 | //----------------------------------------------------------------------------- | ||
2596 | // Procedure: BcmInitEEPROMQueues | ||
2597 | // | ||
2598 | // Description: Initialization of EEPROM queues. | ||
2599 | // | ||
2600 | // Arguments: | ||
2601 | // Adapter - ptr to Adapter object instance | ||
2602 | // | ||
2603 | // Returns: | ||
2604 | // <OSAL_STATUS_CODE> | ||
2605 | //----------------------------------------------------------------------------- | ||
2606 | |||
2607 | INT BcmInitEEPROMQueues(PMINI_ADAPTER Adapter) | ||
2608 | { | ||
2609 | UINT value = 0; | ||
2610 | /* CHIP Bug : Clear the Avail bits on the Read queue. The default | ||
2611 | * value on this register is supposed to be 0x00001102. | ||
2612 | * But we get 0x00001122. */ | ||
2613 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Fixing reset value on 0x0f003004 register\n" ); | ||
2614 | value = EEPROM_READ_DATA_AVAIL; | ||
2615 | wrmalt( Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value)); | ||
2616 | |||
2617 | /* Flush the all the EEPROM queues. */ | ||
2618 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, " Flushing the queues\n"); | ||
2619 | value =EEPROM_ALL_QUEUE_FLUSH ; | ||
2620 | wrmalt( Adapter, SPI_FLUSH_REG, &value, sizeof(value)); | ||
2621 | |||
2622 | value = 0; | ||
2623 | wrmalt( Adapter, SPI_FLUSH_REG, &value, sizeof(value) ); | ||
2624 | |||
2625 | /* Read the EEPROM Status Register. Just to see, no real purpose. */ | ||
2626 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "EEPROM Status register value = %x\n", ReadEEPROMStatusRegister(Adapter) ); | ||
2627 | |||
2628 | return STATUS_SUCCESS; | ||
2629 | } /* BcmInitEEPROMQueues() */ | ||
2630 | |||
2631 | //----------------------------------------------------------------------------- | ||
2632 | // Procedure: BcmInitNVM | ||
2633 | // | ||
2634 | // Description: Initialization of NVM, EEPROM size,FLASH size, sector size etc. | ||
2635 | // | ||
2636 | // Arguments: | ||
2637 | // Adapter - ptr to Adapter object instance | ||
2638 | // | ||
2639 | // Returns: | ||
2640 | // <OSAL_STATUS_CODE> | ||
2641 | //----------------------------------------------------------------------------- | ||
2642 | |||
2643 | INT BcmInitNVM(PMINI_ADAPTER ps_adapter) | ||
2644 | { | ||
2645 | #ifdef BCM_SHM_INTERFACE | ||
2646 | #ifdef FLASH_DIRECT_ACCESS | ||
2647 | unsigned int data,data1,data2 = 1; | ||
2648 | wrm(ps_adapter, PAD_SELECT_REGISTER, &data2, 4); | ||
2649 | data1 = rdm(ps_adapter,SYS_CFG,&data,4); | ||
2650 | data1 = rdm(ps_adapter,SYS_CFG,&data,4); | ||
2651 | data2 = (data | 0x80 | 0x8000); | ||
2652 | wrm(ps_adapter,SYS_CFG, &data2,4); // over-write as Flash boot mode | ||
2653 | #endif | ||
2654 | ps_adapter->eNVMType = NVM_FLASH; | ||
2655 | #else | ||
2656 | BcmValidateNvmType(ps_adapter); | ||
2657 | BcmInitEEPROMQueues(ps_adapter); | ||
2658 | #endif | ||
2659 | |||
2660 | if(ps_adapter->eNVMType == NVM_AUTODETECT) | ||
2661 | { | ||
2662 | ps_adapter->eNVMType = BcmGetNvmType(ps_adapter); | ||
2663 | if(ps_adapter->eNVMType == NVM_UNKNOWN) | ||
2664 | { | ||
2665 | BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_PRINTK, 0, 0, "NVM Type is unknown!!\n"); | ||
2666 | } | ||
2667 | } | ||
2668 | else if(ps_adapter->eNVMType == NVM_FLASH) | ||
2669 | { | ||
2670 | BcmGetFlashCSInfo(ps_adapter); | ||
2671 | } | ||
2672 | |||
2673 | BcmGetNvmSize(ps_adapter); | ||
2674 | |||
2675 | return STATUS_SUCCESS; | ||
2676 | } | ||
2677 | /***************************************************************************/ | ||
2678 | /*BcmGetNvmSize : set the EEPROM or flash size in Adapter. | ||
2679 | * | ||
2680 | *Input Parameter: | ||
2681 | * Adapter data structure | ||
2682 | *Return Value : | ||
2683 | * 0. means sucess; | ||
2684 | */ | ||
2685 | /***************************************************************************/ | ||
2686 | |||
2687 | INT BcmGetNvmSize(PMINI_ADAPTER Adapter) | ||
2688 | { | ||
2689 | if(Adapter->eNVMType == NVM_EEPROM) | ||
2690 | { | ||
2691 | Adapter->uiNVMDSDSize = BcmGetEEPROMSize(Adapter); | ||
2692 | } | ||
2693 | else if(Adapter->eNVMType == NVM_FLASH) | ||
2694 | { | ||
2695 | Adapter->uiNVMDSDSize = BcmGetFlashSize(Adapter); | ||
2696 | } | ||
2697 | return 0; | ||
2698 | } | ||
2699 | |||
2700 | //----------------------------------------------------------------------------- | ||
2701 | // Procedure: BcmValidateNvm | ||
2702 | // | ||
2703 | // Description: Validates the NVM Type option selected against the device | ||
2704 | // | ||
2705 | // Arguments: | ||
2706 | // Adapter - ptr to Adapter object instance | ||
2707 | // | ||
2708 | // Returns: | ||
2709 | // <VOID> | ||
2710 | //----------------------------------------------------------------------------- | ||
2711 | VOID BcmValidateNvmType(PMINI_ADAPTER Adapter) | ||
2712 | { | ||
2713 | |||
2714 | // | ||
2715 | // if forcing the FLASH through CFG file, we should ensure device really has a FLASH. | ||
2716 | // Accessing the FLASH address without the FLASH being present can cause hang/freeze etc. | ||
2717 | // So if NVM_FLASH is selected for older chipsets, change it to AUTODETECT where EEPROM is 1st choice. | ||
2718 | // | ||
2719 | |||
2720 | if(Adapter->eNVMType == NVM_FLASH && | ||
2721 | Adapter->chip_id < 0xBECE3300) | ||
2722 | { | ||
2723 | Adapter->eNVMType = NVM_AUTODETECT; | ||
2724 | } | ||
2725 | } | ||
2726 | //----------------------------------------------------------------------------- | ||
2727 | // Procedure: BcmReadFlashRDID | ||
2728 | // | ||
2729 | // Description: Reads ID from Serial Flash | ||
2730 | // | ||
2731 | // Arguments: | ||
2732 | // Adapter - ptr to Adapter object instance | ||
2733 | // | ||
2734 | // Returns: | ||
2735 | // Flash ID | ||
2736 | //----------------------------------------------------------------------------- | ||
2737 | ULONG BcmReadFlashRDID(PMINI_ADAPTER Adapter) | ||
2738 | { | ||
2739 | ULONG ulRDID = 0; | ||
2740 | UINT value; | ||
2741 | // | ||
2742 | // Read ID Instruction. | ||
2743 | // | ||
2744 | value = (FLASH_CMD_READ_ID<<24); | ||
2745 | wrmalt(Adapter, FLASH_SPI_CMDQ_REG,&value, sizeof(value)); | ||
2746 | |||
2747 | //Delay | ||
2748 | udelay(10); | ||
2749 | // | ||
2750 | // Read SPI READQ REG. The output will be WWXXYYZZ. | ||
2751 | // The ID is 3Bytes long and is WWXXYY. ZZ needs to be Ignored. | ||
2752 | // | ||
2753 | rdmalt(Adapter, FLASH_SPI_READQ_REG,(PUINT)&ulRDID, sizeof(ulRDID)); | ||
2754 | |||
2755 | return (ulRDID >>8); | ||
2756 | |||
2757 | |||
2758 | } | ||
2759 | |||
2760 | INT BcmAllocFlashCSStructure(PMINI_ADAPTER psAdapter) | ||
2761 | { | ||
2762 | if(psAdapter == NULL) | ||
2763 | { | ||
2764 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0, "Adapter structure point is NULL"); | ||
2765 | return -EINVAL; | ||
2766 | } | ||
2767 | psAdapter->psFlashCSInfo = (PFLASH_CS_INFO)kzalloc(sizeof(FLASH_CS_INFO), GFP_KERNEL); | ||
2768 | if(psAdapter->psFlashCSInfo == NULL) | ||
2769 | { | ||
2770 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0,"Can't Allocate memory for Flash 1.x"); | ||
2771 | return -ENOMEM; | ||
2772 | } | ||
2773 | |||
2774 | psAdapter->psFlash2xCSInfo = (PFLASH2X_CS_INFO)kzalloc(sizeof(FLASH2X_CS_INFO), GFP_KERNEL); | ||
2775 | if(psAdapter->psFlash2xCSInfo == NULL) | ||
2776 | { | ||
2777 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0,"Can't Allocate memory for Flash 2.x"); | ||
2778 | bcm_kfree(psAdapter->psFlashCSInfo); | ||
2779 | return -ENOMEM; | ||
2780 | } | ||
2781 | |||
2782 | psAdapter->psFlash2xVendorInfo = (PFLASH2X_VENDORSPECIFIC_INFO)kzalloc(sizeof(FLASH2X_VENDORSPECIFIC_INFO), GFP_KERNEL); | ||
2783 | if(psAdapter->psFlash2xVendorInfo == NULL) | ||
2784 | { | ||
2785 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0,"Can't Allocate Vendor Info Memory for Flash 2.x"); | ||
2786 | bcm_kfree(psAdapter->psFlashCSInfo); | ||
2787 | bcm_kfree(psAdapter->psFlash2xCSInfo); | ||
2788 | return -ENOMEM; | ||
2789 | } | ||
2790 | |||
2791 | return STATUS_SUCCESS; | ||
2792 | } | ||
2793 | |||
2794 | INT BcmDeAllocFlashCSStructure(PMINI_ADAPTER psAdapter) | ||
2795 | { | ||
2796 | if(psAdapter == NULL) | ||
2797 | { | ||
2798 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0," Adapter structure point is NULL"); | ||
2799 | return -EINVAL; | ||
2800 | } | ||
2801 | bcm_kfree(psAdapter->psFlashCSInfo); | ||
2802 | bcm_kfree(psAdapter->psFlash2xCSInfo); | ||
2803 | bcm_kfree(psAdapter->psFlash2xVendorInfo); | ||
2804 | return STATUS_SUCCESS ; | ||
2805 | } | ||
2806 | |||
2807 | INT BcmDumpFlash2XCSStructure(PFLASH2X_CS_INFO psFlash2xCSInfo,PMINI_ADAPTER Adapter) | ||
2808 | { | ||
2809 | UINT Index = 0; | ||
2810 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "**********************FLASH2X CS Structure *******************"); | ||
2811 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Signature is :%x", (psFlash2xCSInfo->MagicNumber)); | ||
2812 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Flash Major Version :%d", MAJOR_VERSION(psFlash2xCSInfo->FlashLayoutVersion)); | ||
2813 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Flash Minor Version :%d", MINOR_VERSION(psFlash2xCSInfo->FlashLayoutVersion)); | ||
2814 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, " ISOImageMajorVersion:0x%x", (psFlash2xCSInfo->ISOImageVersion)); | ||
2815 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "SCSIFirmwareMajorVersion :0x%x", (psFlash2xCSInfo->SCSIFirmwareVersion)); | ||
2816 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForPart1ISOImage :0x%x", (psFlash2xCSInfo->OffsetFromZeroForPart1ISOImage)); | ||
2817 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForScsiFirmware :0x%x", (psFlash2xCSInfo->OffsetFromZeroForScsiFirmware)); | ||
2818 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "SizeOfScsiFirmware :0x%x", (psFlash2xCSInfo->SizeOfScsiFirmware )); | ||
2819 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForPart2ISOImage :0x%x", (psFlash2xCSInfo->OffsetFromZeroForPart2ISOImage)); | ||
2820 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForDSDStart :0x%x", (psFlash2xCSInfo->OffsetFromZeroForDSDStart)); | ||
2821 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForDSDEnd :0x%x", (psFlash2xCSInfo->OffsetFromZeroForDSDEnd)); | ||
2822 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForVSAStart :0x%x", (psFlash2xCSInfo->OffsetFromZeroForVSAStart)); | ||
2823 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForVSAEnd :0x%x", (psFlash2xCSInfo->OffsetFromZeroForVSAEnd)); | ||
2824 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForControlSectionStart :0x%x", (psFlash2xCSInfo->OffsetFromZeroForControlSectionStart)); | ||
2825 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForControlSectionData :0x%x", (psFlash2xCSInfo->OffsetFromZeroForControlSectionData)); | ||
2826 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "CDLessInactivityTimeout :0x%x", (psFlash2xCSInfo->CDLessInactivityTimeout)); | ||
2827 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "NewImageSignature :0x%x", (psFlash2xCSInfo->NewImageSignature)); | ||
2828 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "FlashSectorSizeSig :0x%x", (psFlash2xCSInfo->FlashSectorSizeSig)); | ||
2829 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "FlashSectorSize :0x%x", (psFlash2xCSInfo->FlashSectorSize)); | ||
2830 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "FlashWriteSupportSize :0x%x", (psFlash2xCSInfo->FlashWriteSupportSize)); | ||
2831 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "TotalFlashSize :0x%X", (psFlash2xCSInfo->TotalFlashSize)); | ||
2832 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "FlashBaseAddr :0x%x", (psFlash2xCSInfo->FlashBaseAddr)); | ||
2833 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "FlashPartMaxSize :0x%x", (psFlash2xCSInfo->FlashPartMaxSize)); | ||
2834 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "IsCDLessDeviceBootSig :0x%x", (psFlash2xCSInfo->IsCDLessDeviceBootSig)); | ||
2835 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "MassStorageTimeout :0x%x", (psFlash2xCSInfo->MassStorageTimeout)); | ||
2836 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage1Part1Start :0x%x", (psFlash2xCSInfo->OffsetISOImage1Part1Start)); | ||
2837 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage1Part1End :0x%x", (psFlash2xCSInfo->OffsetISOImage1Part1End)); | ||
2838 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage1Part2Start :0x%x", (psFlash2xCSInfo->OffsetISOImage1Part2Start)); | ||
2839 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage1Part2End :0x%x", (psFlash2xCSInfo->OffsetISOImage1Part2End)); | ||
2840 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage1Part3Start :0x%x", (psFlash2xCSInfo->OffsetISOImage1Part3Start)); | ||
2841 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage1Part3End :0x%x", (psFlash2xCSInfo->OffsetISOImage1Part3End)); | ||
2842 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage2Part1Start :0x%x", (psFlash2xCSInfo->OffsetISOImage2Part1Start)); | ||
2843 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage2Part1End :0x%x", (psFlash2xCSInfo->OffsetISOImage2Part1End)); | ||
2844 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage2Part2Start :0x%x", (psFlash2xCSInfo->OffsetISOImage2Part2Start)); | ||
2845 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage2Part2End :0x%x", (psFlash2xCSInfo->OffsetISOImage2Part2End)); | ||
2846 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage2Part3Start :0x%x", (psFlash2xCSInfo->OffsetISOImage2Part3Start)); | ||
2847 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage2Part3End :0x%x", (psFlash2xCSInfo->OffsetISOImage2Part3End)); | ||
2848 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromDSDStartForDSDHeader :0x%x", (psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader)); | ||
2849 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForDSD1Start :0x%x", (psFlash2xCSInfo->OffsetFromZeroForDSD1Start)); | ||
2850 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForDSD1End :0x%x", (psFlash2xCSInfo->OffsetFromZeroForDSD1End)); | ||
2851 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForDSD2Start :0x%x", (psFlash2xCSInfo->OffsetFromZeroForDSD2Start)); | ||
2852 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForDSD2End :0x%x", (psFlash2xCSInfo->OffsetFromZeroForDSD2End)); | ||
2853 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForVSA1Start :0x%x", (psFlash2xCSInfo->OffsetFromZeroForVSA1Start)); | ||
2854 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForVSA1End :0x%x", (psFlash2xCSInfo->OffsetFromZeroForVSA1End)); | ||
2855 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForVSA2Start :0x%x", (psFlash2xCSInfo->OffsetFromZeroForVSA2Start)); | ||
2856 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForVSA2End :0x%x", (psFlash2xCSInfo->OffsetFromZeroForVSA2End)); | ||
2857 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Sector Access Bit Map is Defined as :"); | ||
2858 | for(Index =0; Index <(FLASH2X_TOTAL_SIZE/(DEFAULT_SECTOR_SIZE *16)); Index++) | ||
2859 | { | ||
2860 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "SectorAccessBitMap[%d] :0x%x", Index, | ||
2861 | (psFlash2xCSInfo->SectorAccessBitMap[Index])); | ||
2862 | } | ||
2863 | |||
2864 | return STATUS_SUCCESS; | ||
2865 | } | ||
2866 | |||
2867 | |||
2868 | INT ConvertEndianOf2XCSStructure(PFLASH2X_CS_INFO psFlash2xCSInfo) | ||
2869 | { | ||
2870 | UINT Index = 0; | ||
2871 | psFlash2xCSInfo->MagicNumber = ntohl(psFlash2xCSInfo->MagicNumber); | ||
2872 | psFlash2xCSInfo->FlashLayoutVersion= ntohl(psFlash2xCSInfo->FlashLayoutVersion); | ||
2873 | //psFlash2xCSInfo->FlashLayoutMinorVersion = ntohs(psFlash2xCSInfo->FlashLayoutMinorVersion); | ||
2874 | psFlash2xCSInfo->ISOImageVersion = ntohl(psFlash2xCSInfo->ISOImageVersion); | ||
2875 | psFlash2xCSInfo->SCSIFirmwareVersion =ntohl(psFlash2xCSInfo->SCSIFirmwareVersion); | ||
2876 | psFlash2xCSInfo->OffsetFromZeroForPart1ISOImage = ntohl(psFlash2xCSInfo->OffsetFromZeroForPart1ISOImage); | ||
2877 | psFlash2xCSInfo->OffsetFromZeroForScsiFirmware = ntohl(psFlash2xCSInfo->OffsetFromZeroForScsiFirmware); | ||
2878 | psFlash2xCSInfo->SizeOfScsiFirmware = ntohl(psFlash2xCSInfo->SizeOfScsiFirmware ); | ||
2879 | psFlash2xCSInfo->OffsetFromZeroForPart2ISOImage = ntohl(psFlash2xCSInfo->OffsetFromZeroForPart2ISOImage); | ||
2880 | psFlash2xCSInfo->OffsetFromZeroForDSDStart = ntohl(psFlash2xCSInfo->OffsetFromZeroForDSDStart); | ||
2881 | psFlash2xCSInfo->OffsetFromZeroForDSDEnd = ntohl(psFlash2xCSInfo->OffsetFromZeroForDSDEnd); | ||
2882 | psFlash2xCSInfo->OffsetFromZeroForVSAStart = ntohl(psFlash2xCSInfo->OffsetFromZeroForVSAStart); | ||
2883 | psFlash2xCSInfo->OffsetFromZeroForVSAEnd = ntohl(psFlash2xCSInfo->OffsetFromZeroForVSAEnd); | ||
2884 | psFlash2xCSInfo->OffsetFromZeroForControlSectionStart = ntohl(psFlash2xCSInfo->OffsetFromZeroForControlSectionStart); | ||
2885 | psFlash2xCSInfo->OffsetFromZeroForControlSectionData = ntohl(psFlash2xCSInfo->OffsetFromZeroForControlSectionData); | ||
2886 | psFlash2xCSInfo->CDLessInactivityTimeout = ntohl(psFlash2xCSInfo->CDLessInactivityTimeout); | ||
2887 | psFlash2xCSInfo->NewImageSignature = ntohl(psFlash2xCSInfo->NewImageSignature); | ||
2888 | psFlash2xCSInfo->FlashSectorSizeSig = ntohl(psFlash2xCSInfo->FlashSectorSizeSig); | ||
2889 | psFlash2xCSInfo->FlashSectorSize = ntohl(psFlash2xCSInfo->FlashSectorSize); | ||
2890 | psFlash2xCSInfo->FlashWriteSupportSize = ntohl(psFlash2xCSInfo->FlashWriteSupportSize); | ||
2891 | psFlash2xCSInfo->TotalFlashSize = ntohl(psFlash2xCSInfo->TotalFlashSize); | ||
2892 | psFlash2xCSInfo->FlashBaseAddr = ntohl(psFlash2xCSInfo->FlashBaseAddr); | ||
2893 | psFlash2xCSInfo->FlashPartMaxSize = ntohl(psFlash2xCSInfo->FlashPartMaxSize); | ||
2894 | psFlash2xCSInfo->IsCDLessDeviceBootSig = ntohl(psFlash2xCSInfo->IsCDLessDeviceBootSig); | ||
2895 | psFlash2xCSInfo->MassStorageTimeout = ntohl(psFlash2xCSInfo->MassStorageTimeout); | ||
2896 | psFlash2xCSInfo->OffsetISOImage1Part1Start = ntohl(psFlash2xCSInfo->OffsetISOImage1Part1Start); | ||
2897 | psFlash2xCSInfo->OffsetISOImage1Part1End = ntohl(psFlash2xCSInfo->OffsetISOImage1Part1End); | ||
2898 | psFlash2xCSInfo->OffsetISOImage1Part2Start = ntohl(psFlash2xCSInfo->OffsetISOImage1Part2Start); | ||
2899 | psFlash2xCSInfo->OffsetISOImage1Part2End = ntohl(psFlash2xCSInfo->OffsetISOImage1Part2End); | ||
2900 | psFlash2xCSInfo->OffsetISOImage1Part3Start = ntohl(psFlash2xCSInfo->OffsetISOImage1Part3Start); | ||
2901 | psFlash2xCSInfo->OffsetISOImage1Part3End = ntohl(psFlash2xCSInfo->OffsetISOImage1Part3End); | ||
2902 | psFlash2xCSInfo->OffsetISOImage2Part1Start = ntohl(psFlash2xCSInfo->OffsetISOImage2Part1Start); | ||
2903 | psFlash2xCSInfo->OffsetISOImage2Part1End = ntohl(psFlash2xCSInfo->OffsetISOImage2Part1End); | ||
2904 | psFlash2xCSInfo->OffsetISOImage2Part2Start = ntohl(psFlash2xCSInfo->OffsetISOImage2Part2Start); | ||
2905 | psFlash2xCSInfo->OffsetISOImage2Part2End = ntohl(psFlash2xCSInfo->OffsetISOImage2Part2End); | ||
2906 | psFlash2xCSInfo->OffsetISOImage2Part3Start = ntohl(psFlash2xCSInfo->OffsetISOImage2Part3Start); | ||
2907 | psFlash2xCSInfo->OffsetISOImage2Part3End = ntohl(psFlash2xCSInfo->OffsetISOImage2Part3End); | ||
2908 | psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader = ntohl(psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader); | ||
2909 | psFlash2xCSInfo->OffsetFromZeroForDSD1Start = ntohl(psFlash2xCSInfo->OffsetFromZeroForDSD1Start); | ||
2910 | psFlash2xCSInfo->OffsetFromZeroForDSD1End = ntohl(psFlash2xCSInfo->OffsetFromZeroForDSD1End); | ||
2911 | psFlash2xCSInfo->OffsetFromZeroForDSD2Start = ntohl(psFlash2xCSInfo->OffsetFromZeroForDSD2Start); | ||
2912 | psFlash2xCSInfo->OffsetFromZeroForDSD2End = ntohl(psFlash2xCSInfo->OffsetFromZeroForDSD2End); | ||
2913 | psFlash2xCSInfo->OffsetFromZeroForVSA1Start = ntohl(psFlash2xCSInfo->OffsetFromZeroForVSA1Start); | ||
2914 | psFlash2xCSInfo->OffsetFromZeroForVSA1End = ntohl(psFlash2xCSInfo->OffsetFromZeroForVSA1End); | ||
2915 | psFlash2xCSInfo->OffsetFromZeroForVSA2Start = ntohl(psFlash2xCSInfo->OffsetFromZeroForVSA2Start); | ||
2916 | psFlash2xCSInfo->OffsetFromZeroForVSA2End = ntohl(psFlash2xCSInfo->OffsetFromZeroForVSA2End); | ||
2917 | for(Index =0; Index <(FLASH2X_TOTAL_SIZE/(DEFAULT_SECTOR_SIZE *16)); Index++) | ||
2918 | { | ||
2919 | psFlash2xCSInfo->SectorAccessBitMap[Index] = ntohl(psFlash2xCSInfo->SectorAccessBitMap[Index]); | ||
2920 | } | ||
2921 | return STATUS_SUCCESS; | ||
2922 | } | ||
2923 | |||
2924 | INT ConvertEndianOfCSStructure(PFLASH_CS_INFO psFlashCSInfo) | ||
2925 | { | ||
2926 | //UINT Index = 0; | ||
2927 | psFlashCSInfo->MagicNumber =ntohl(psFlashCSInfo->MagicNumber); | ||
2928 | psFlashCSInfo->FlashLayoutVersion =ntohl(psFlashCSInfo->FlashLayoutVersion); | ||
2929 | psFlashCSInfo->ISOImageVersion = ntohl(psFlashCSInfo->ISOImageVersion); | ||
2930 | //won't convert according to old assumption | ||
2931 | psFlashCSInfo->SCSIFirmwareVersion =(psFlashCSInfo->SCSIFirmwareVersion); | ||
2932 | |||
2933 | psFlashCSInfo->OffsetFromZeroForPart1ISOImage = ntohl(psFlashCSInfo->OffsetFromZeroForPart1ISOImage); | ||
2934 | psFlashCSInfo->OffsetFromZeroForScsiFirmware = ntohl(psFlashCSInfo->OffsetFromZeroForScsiFirmware); | ||
2935 | psFlashCSInfo->SizeOfScsiFirmware = ntohl(psFlashCSInfo->SizeOfScsiFirmware ); | ||
2936 | psFlashCSInfo->OffsetFromZeroForPart2ISOImage = ntohl(psFlashCSInfo->OffsetFromZeroForPart2ISOImage); | ||
2937 | psFlashCSInfo->OffsetFromZeroForCalibrationStart = ntohl(psFlashCSInfo->OffsetFromZeroForCalibrationStart); | ||
2938 | psFlashCSInfo->OffsetFromZeroForCalibrationEnd = ntohl(psFlashCSInfo->OffsetFromZeroForCalibrationEnd); | ||
2939 | psFlashCSInfo->OffsetFromZeroForVSAStart = ntohl(psFlashCSInfo->OffsetFromZeroForVSAStart); | ||
2940 | psFlashCSInfo->OffsetFromZeroForVSAEnd = ntohl(psFlashCSInfo->OffsetFromZeroForVSAEnd); | ||
2941 | psFlashCSInfo->OffsetFromZeroForControlSectionStart = ntohl(psFlashCSInfo->OffsetFromZeroForControlSectionStart); | ||
2942 | psFlashCSInfo->OffsetFromZeroForControlSectionData = ntohl(psFlashCSInfo->OffsetFromZeroForControlSectionData); | ||
2943 | psFlashCSInfo->CDLessInactivityTimeout = ntohl(psFlashCSInfo->CDLessInactivityTimeout); | ||
2944 | psFlashCSInfo->NewImageSignature = ntohl(psFlashCSInfo->NewImageSignature); | ||
2945 | psFlashCSInfo->FlashSectorSizeSig = ntohl(psFlashCSInfo->FlashSectorSizeSig); | ||
2946 | psFlashCSInfo->FlashSectorSize = ntohl(psFlashCSInfo->FlashSectorSize); | ||
2947 | psFlashCSInfo->FlashWriteSupportSize = ntohl(psFlashCSInfo->FlashWriteSupportSize); | ||
2948 | psFlashCSInfo->TotalFlashSize = ntohl(psFlashCSInfo->TotalFlashSize); | ||
2949 | psFlashCSInfo->FlashBaseAddr = ntohl(psFlashCSInfo->FlashBaseAddr); | ||
2950 | psFlashCSInfo->FlashPartMaxSize = ntohl(psFlashCSInfo->FlashPartMaxSize); | ||
2951 | psFlashCSInfo->IsCDLessDeviceBootSig = ntohl(psFlashCSInfo->IsCDLessDeviceBootSig); | ||
2952 | psFlashCSInfo->MassStorageTimeout = ntohl(psFlashCSInfo->MassStorageTimeout); | ||
2953 | |||
2954 | return STATUS_SUCCESS; | ||
2955 | } | ||
2956 | |||
2957 | INT IsSectionExistInVendorInfo(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL section) | ||
2958 | { | ||
2959 | return ( Adapter->uiVendorExtnFlag && | ||
2960 | (Adapter->psFlash2xVendorInfo->VendorSection[section].AccessFlags & FLASH2X_SECTION_PRESENT) && | ||
2961 | (Adapter->psFlash2xVendorInfo->VendorSection[section].OffsetFromZeroForSectionStart != UNINIT_PTR_IN_CS) ); | ||
2962 | } | ||
2963 | |||
2964 | VOID UpdateVendorInfo(PMINI_ADAPTER Adapter) | ||
2965 | { | ||
2966 | B_UINT32 i = 0; | ||
2967 | UINT uiSizeSection = 0; | ||
2968 | |||
2969 | Adapter->uiVendorExtnFlag = FALSE; | ||
2970 | |||
2971 | for(i = 0;i < TOTAL_SECTIONS;i++) | ||
2972 | Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart = UNINIT_PTR_IN_CS; | ||
2973 | |||
2974 | if(STATUS_SUCCESS != vendorextnGetSectionInfo(Adapter, Adapter->psFlash2xVendorInfo)) | ||
2975 | return; | ||
2976 | |||
2977 | i = 0; | ||
2978 | while(i < TOTAL_SECTIONS) | ||
2979 | { | ||
2980 | if(!(Adapter->psFlash2xVendorInfo->VendorSection[i].AccessFlags & FLASH2X_SECTION_PRESENT)) | ||
2981 | { | ||
2982 | i++; | ||
2983 | continue; | ||
2984 | } | ||
2985 | |||
2986 | Adapter->uiVendorExtnFlag = TRUE; | ||
2987 | uiSizeSection = (Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionEnd - | ||
2988 | Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart); | ||
2989 | |||
2990 | switch(i) | ||
2991 | { | ||
2992 | case DSD0: | ||
2993 | if(( uiSizeSection >= (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER))) && | ||
2994 | (UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart)) | ||
2995 | Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDEnd = VENDOR_PTR_IN_CS; | ||
2996 | else | ||
2997 | Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDEnd = UNINIT_PTR_IN_CS; | ||
2998 | break; | ||
2999 | |||
3000 | case DSD1: | ||
3001 | if(( uiSizeSection >= (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER))) && | ||
3002 | (UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart)) | ||
3003 | Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1End = VENDOR_PTR_IN_CS; | ||
3004 | else | ||
3005 | Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1End = UNINIT_PTR_IN_CS; | ||
3006 | break; | ||
3007 | |||
3008 | case DSD2: | ||
3009 | if(( uiSizeSection >= (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER))) && | ||
3010 | (UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart)) | ||
3011 | Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2End = VENDOR_PTR_IN_CS; | ||
3012 | else | ||
3013 | Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2End = UNINIT_PTR_IN_CS; | ||
3014 | break; | ||
3015 | case VSA0: | ||
3016 | if(UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart) | ||
3017 | Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAEnd = VENDOR_PTR_IN_CS; | ||
3018 | else | ||
3019 | Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAEnd = UNINIT_PTR_IN_CS; | ||
3020 | break; | ||
3021 | |||
3022 | case VSA1: | ||
3023 | if(UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart) | ||
3024 | Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1End = VENDOR_PTR_IN_CS; | ||
3025 | else | ||
3026 | Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1End = UNINIT_PTR_IN_CS; | ||
3027 | break; | ||
3028 | case VSA2: | ||
3029 | if(UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart) | ||
3030 | Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2End = VENDOR_PTR_IN_CS; | ||
3031 | else | ||
3032 | Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2End = UNINIT_PTR_IN_CS; | ||
3033 | break; | ||
3034 | |||
3035 | default: | ||
3036 | break; | ||
3037 | } | ||
3038 | i++; | ||
3039 | } | ||
3040 | |||
3041 | } | ||
3042 | |||
3043 | //----------------------------------------------------------------------------- | ||
3044 | // Procedure: BcmGetFlashCSInfo | ||
3045 | // | ||
3046 | // Description: Reads control structure and gets Cal section addresses. | ||
3047 | // | ||
3048 | // Arguments: | ||
3049 | // Adapter - ptr to Adapter object instance | ||
3050 | // | ||
3051 | // Returns: | ||
3052 | // <VOID> | ||
3053 | //----------------------------------------------------------------------------- | ||
3054 | |||
3055 | INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter) | ||
3056 | { | ||
3057 | //FLASH_CS_INFO sFlashCsInfo = {0}; | ||
3058 | |||
3059 | #if !defined(BCM_SHM_INTERFACE) || defined(FLASH_DIRECT_ACCESS) | ||
3060 | UINT value; | ||
3061 | #endif | ||
3062 | UINT uiFlashLayoutMajorVersion; | ||
3063 | Adapter->uiFlashLayoutMinorVersion = 0; | ||
3064 | Adapter->uiFlashLayoutMajorVersion = 0; | ||
3065 | Adapter->ulFlashControlSectionStart = FLASH_CS_INFO_START_ADDR; | ||
3066 | |||
3067 | |||
3068 | Adapter->uiFlashBaseAdd = 0; | ||
3069 | Adapter->ulFlashCalStart = 0; | ||
3070 | memset(Adapter->psFlashCSInfo, 0 ,sizeof(FLASH_CS_INFO)); | ||
3071 | memset(Adapter->psFlash2xCSInfo, 0 ,sizeof(FLASH2X_CS_INFO)); | ||
3072 | |||
3073 | #ifndef BCM_SHM_INTERFACE | ||
3074 | if(!Adapter->bDDRInitDone) | ||
3075 | { | ||
3076 | { | ||
3077 | value = FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT; | ||
3078 | wrmalt(Adapter, 0xAF00A080, &value, sizeof(value)); | ||
3079 | } | ||
3080 | } | ||
3081 | |||
3082 | #endif | ||
3083 | |||
3084 | // Reading first 8 Bytes to get the Flash Layout | ||
3085 | // MagicNumber(4 bytes) +FlashLayoutMinorVersion(2 Bytes) +FlashLayoutMajorVersion(2 Bytes) | ||
3086 | BeceemFlashBulkRead(Adapter,(PUINT)Adapter->psFlashCSInfo,Adapter->ulFlashControlSectionStart,8); | ||
3087 | |||
3088 | Adapter->psFlashCSInfo->FlashLayoutVersion = ntohl(Adapter->psFlashCSInfo->FlashLayoutVersion); | ||
3089 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Flash Layout Version :%X", (Adapter->psFlashCSInfo->FlashLayoutVersion)); | ||
3090 | //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Flash Layout Minor Version :%d\n", ntohs(sFlashCsInfo.FlashLayoutMinorVersion)); | ||
3091 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Signature is :%x\n", ntohl(Adapter->psFlashCSInfo->MagicNumber)); | ||
3092 | |||
3093 | if(FLASH_CONTROL_STRUCT_SIGNATURE == ntohl(Adapter->psFlashCSInfo->MagicNumber)) | ||
3094 | { | ||
3095 | uiFlashLayoutMajorVersion = MAJOR_VERSION((Adapter->psFlashCSInfo->FlashLayoutVersion)); | ||
3096 | Adapter->uiFlashLayoutMinorVersion = MINOR_VERSION((Adapter->psFlashCSInfo->FlashLayoutVersion)); | ||
3097 | } | ||
3098 | else | ||
3099 | { | ||
3100 | Adapter->uiFlashLayoutMinorVersion = 0; | ||
3101 | uiFlashLayoutMajorVersion = 0; | ||
3102 | } | ||
3103 | |||
3104 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"FLASH LAYOUT MAJOR VERSION :%X", uiFlashLayoutMajorVersion); | ||
3105 | |||
3106 | if(uiFlashLayoutMajorVersion < FLASH_2X_MAJOR_NUMBER) | ||
3107 | { | ||
3108 | BeceemFlashBulkRead(Adapter,(PUINT)Adapter->psFlashCSInfo,Adapter->ulFlashControlSectionStart,sizeof(FLASH_CS_INFO)); | ||
3109 | ConvertEndianOfCSStructure(Adapter->psFlashCSInfo); | ||
3110 | Adapter->ulFlashCalStart = (Adapter->psFlashCSInfo->OffsetFromZeroForCalibrationStart); | ||
3111 | |||
3112 | if(!((Adapter->uiFlashLayoutMajorVersion == 1) && (Adapter->uiFlashLayoutMinorVersion == 1))) | ||
3113 | { | ||
3114 | Adapter->ulFlashControlSectionStart = Adapter->psFlashCSInfo->OffsetFromZeroForControlSectionStart; | ||
3115 | } | ||
3116 | |||
3117 | if((FLASH_CONTROL_STRUCT_SIGNATURE == (Adapter->psFlashCSInfo->MagicNumber)) && | ||
3118 | (SCSI_FIRMWARE_MINOR_VERSION <= MINOR_VERSION(Adapter->psFlashCSInfo->SCSIFirmwareVersion)) && | ||
3119 | (FLASH_SECTOR_SIZE_SIG == (Adapter->psFlashCSInfo->FlashSectorSizeSig)) && | ||
3120 | (BYTE_WRITE_SUPPORT == (Adapter->psFlashCSInfo->FlashWriteSupportSize))) | ||
3121 | { | ||
3122 | Adapter->ulFlashWriteSize = (Adapter->psFlashCSInfo->FlashWriteSupportSize); | ||
3123 | Adapter->fpFlashWrite = flashByteWrite; | ||
3124 | Adapter->fpFlashWriteWithStatusCheck = flashByteWriteStatus; | ||
3125 | } | ||
3126 | else | ||
3127 | { | ||
3128 | Adapter->ulFlashWriteSize = MAX_RW_SIZE; | ||
3129 | Adapter->fpFlashWrite = flashWrite; | ||
3130 | Adapter->fpFlashWriteWithStatusCheck = flashWriteStatus; | ||
3131 | } | ||
3132 | |||
3133 | BcmGetFlashSectorSize(Adapter, (Adapter->psFlashCSInfo->FlashSectorSizeSig), | ||
3134 | (Adapter->psFlashCSInfo->FlashSectorSize)); | ||
3135 | |||
3136 | |||
3137 | Adapter->uiFlashBaseAdd = Adapter->psFlashCSInfo->FlashBaseAddr & 0xFCFFFFFF; | ||
3138 | |||
3139 | |||
3140 | } | ||
3141 | else | ||
3142 | { | ||
3143 | if(BcmFlash2xBulkRead(Adapter,(PUINT)Adapter->psFlash2xCSInfo,NO_SECTION_VAL, | ||
3144 | Adapter->ulFlashControlSectionStart,sizeof(FLASH2X_CS_INFO))) | ||
3145 | { | ||
3146 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Unable to read CS structure \n"); | ||
3147 | return STATUS_FAILURE; | ||
3148 | } | ||
3149 | ConvertEndianOf2XCSStructure(Adapter->psFlash2xCSInfo); | ||
3150 | #ifndef BCM_SHM_INTERFACE | ||
3151 | BcmDumpFlash2XCSStructure(Adapter->psFlash2xCSInfo,Adapter); | ||
3152 | #endif | ||
3153 | if((FLASH_CONTROL_STRUCT_SIGNATURE == Adapter->psFlash2xCSInfo->MagicNumber) && | ||
3154 | (SCSI_FIRMWARE_MINOR_VERSION <= MINOR_VERSION(Adapter->psFlash2xCSInfo->SCSIFirmwareVersion)) && | ||
3155 | (FLASH_SECTOR_SIZE_SIG == Adapter->psFlash2xCSInfo->FlashSectorSizeSig) && | ||
3156 | (BYTE_WRITE_SUPPORT == Adapter->psFlash2xCSInfo->FlashWriteSupportSize)) | ||
3157 | { | ||
3158 | Adapter->ulFlashWriteSize = Adapter->psFlash2xCSInfo->FlashWriteSupportSize; | ||
3159 | Adapter->fpFlashWrite = flashByteWrite; | ||
3160 | Adapter->fpFlashWriteWithStatusCheck = flashByteWriteStatus; | ||
3161 | } | ||
3162 | else | ||
3163 | { | ||
3164 | Adapter->ulFlashWriteSize = MAX_RW_SIZE; | ||
3165 | Adapter->fpFlashWrite = flashWrite; | ||
3166 | Adapter->fpFlashWriteWithStatusCheck = flashWriteStatus; | ||
3167 | } | ||
3168 | |||
3169 | BcmGetFlashSectorSize(Adapter, Adapter->psFlash2xCSInfo->FlashSectorSizeSig, | ||
3170 | Adapter->psFlash2xCSInfo->FlashSectorSize); | ||
3171 | |||
3172 | UpdateVendorInfo(Adapter); | ||
3173 | |||
3174 | BcmGetActiveDSD(Adapter); | ||
3175 | BcmGetActiveISO(Adapter); | ||
3176 | Adapter->uiFlashBaseAdd = Adapter->psFlash2xCSInfo->FlashBaseAddr & 0xFCFFFFFF; | ||
3177 | Adapter->ulFlashControlSectionStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForControlSectionStart; | ||
3178 | |||
3179 | } | ||
3180 | /* | ||
3181 | Concerns: what if CS sector size does not match with this sector size ??? | ||
3182 | what is the indication of AccessBitMap in CS in flash 2.x ???? | ||
3183 | */ | ||
3184 | #ifndef BCM_SHM_INTERFACE | ||
3185 | Adapter->ulFlashID = BcmReadFlashRDID(Adapter); | ||
3186 | #endif | ||
3187 | |||
3188 | Adapter->uiFlashLayoutMajorVersion = uiFlashLayoutMajorVersion; | ||
3189 | |||
3190 | #if 0 | ||
3191 | if(FLASH_PART_SST25VF080B == Adapter->ulFlashID) | ||
3192 | { | ||
3193 | // | ||
3194 | // 1MB flash has been selected. we have to use 64K as sector size no matter what is kept in FLASH_CS. | ||
3195 | // | ||
3196 | Adapter->uiSectorSize = 0x10000; | ||
3197 | } | ||
3198 | #endif | ||
3199 | |||
3200 | return STATUS_SUCCESS ; | ||
3201 | } | ||
3202 | |||
3203 | |||
3204 | //----------------------------------------------------------------------------- | ||
3205 | // Procedure: BcmGetNvmType | ||
3206 | // | ||
3207 | // Description: Finds the type of NVM used. | ||
3208 | // | ||
3209 | // Arguments: | ||
3210 | // Adapter - ptr to Adapter object instance | ||
3211 | // | ||
3212 | // Returns: | ||
3213 | // NVM_TYPE | ||
3214 | // | ||
3215 | //----------------------------------------------------------------------------- | ||
3216 | |||
3217 | NVM_TYPE BcmGetNvmType(PMINI_ADAPTER Adapter) | ||
3218 | { | ||
3219 | UINT uiData = 0; | ||
3220 | |||
3221 | BeceemEEPROMBulkRead(Adapter,&uiData,0x0,4); | ||
3222 | if(uiData == BECM) | ||
3223 | { | ||
3224 | return NVM_EEPROM; | ||
3225 | } | ||
3226 | // | ||
3227 | // Read control struct and get cal addresses before accessing the flash | ||
3228 | // | ||
3229 | BcmGetFlashCSInfo(Adapter); | ||
3230 | |||
3231 | BeceemFlashBulkRead(Adapter,&uiData,0x0 + Adapter->ulFlashCalStart,4); | ||
3232 | if(uiData == BECM) | ||
3233 | { | ||
3234 | return NVM_FLASH; | ||
3235 | } | ||
3236 | // | ||
3237 | // even if there is no valid signature on EEPROM/FLASH find out if they really exist. | ||
3238 | // if exist select it. | ||
3239 | // | ||
3240 | if(BcmGetEEPROMSize(Adapter)) | ||
3241 | { | ||
3242 | return NVM_EEPROM; | ||
3243 | } | ||
3244 | |||
3245 | //TBD for Flash. | ||
3246 | |||
3247 | |||
3248 | return NVM_UNKNOWN; | ||
3249 | } | ||
3250 | |||
3251 | /** | ||
3252 | * BcmGetSectionValStartOffset - this will calculate the section's starting offset if section val is given | ||
3253 | * @Adapter : Drivers Private Data structure | ||
3254 | * @eFlashSectionVal : Flash secion value defined in enum FLASH2X_SECTION_VAL | ||
3255 | * | ||
3256 | * Return value:- | ||
3257 | * On success it return the start offset of the provided section val | ||
3258 | * On Failure -returns STATUS_FAILURE | ||
3259 | **/ | ||
3260 | |||
3261 | INT BcmGetSectionValStartOffset(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlashSectionVal) | ||
3262 | { | ||
3263 | /* | ||
3264 | * Considering all the section for which end offset can be calculated or directly given | ||
3265 | * in CS Structure. if matching case does not exist, return STATUS_FAILURE indicating section | ||
3266 | * endoffset can't be calculated or given in CS Stucture. | ||
3267 | */ | ||
3268 | |||
3269 | INT SectStartOffset = 0 ; | ||
3270 | |||
3271 | SectStartOffset = INVALID_OFFSET ; | ||
3272 | |||
3273 | if(IsSectionExistInVendorInfo(Adapter,eFlashSectionVal)) | ||
3274 | { | ||
3275 | return Adapter->psFlash2xVendorInfo->VendorSection[eFlashSectionVal].OffsetFromZeroForSectionStart; | ||
3276 | } | ||
3277 | |||
3278 | switch(eFlashSectionVal) | ||
3279 | { | ||
3280 | case ISO_IMAGE1 : | ||
3281 | if((Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start != UNINIT_PTR_IN_CS) && | ||
3282 | (IsNonCDLessDevice(Adapter) == FALSE)) | ||
3283 | SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start); | ||
3284 | break; | ||
3285 | case ISO_IMAGE2 : | ||
3286 | if((Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start != UNINIT_PTR_IN_CS) && | ||
3287 | (IsNonCDLessDevice(Adapter) == FALSE)) | ||
3288 | SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start); | ||
3289 | break; | ||
3290 | case DSD0 : | ||
3291 | if(Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDStart != UNINIT_PTR_IN_CS) | ||
3292 | SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDStart); | ||
3293 | break; | ||
3294 | case DSD1 : | ||
3295 | if(Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1Start != UNINIT_PTR_IN_CS) | ||
3296 | SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1Start); | ||
3297 | break; | ||
3298 | case DSD2 : | ||
3299 | if(Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2Start != UNINIT_PTR_IN_CS) | ||
3300 | SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2Start); | ||
3301 | break; | ||
3302 | case VSA0 : | ||
3303 | if(Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAStart != UNINIT_PTR_IN_CS) | ||
3304 | SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAStart); | ||
3305 | break; | ||
3306 | case VSA1 : | ||
3307 | if(Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1Start != UNINIT_PTR_IN_CS) | ||
3308 | SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1Start); | ||
3309 | break; | ||
3310 | case VSA2 : | ||
3311 | if(Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2Start != UNINIT_PTR_IN_CS) | ||
3312 | SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2Start); | ||
3313 | break; | ||
3314 | case SCSI : | ||
3315 | if(Adapter->psFlash2xCSInfo->OffsetFromZeroForScsiFirmware != UNINIT_PTR_IN_CS) | ||
3316 | SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForScsiFirmware); | ||
3317 | break; | ||
3318 | case CONTROL_SECTION : | ||
3319 | if(Adapter->psFlash2xCSInfo->OffsetFromZeroForControlSectionStart != UNINIT_PTR_IN_CS) | ||
3320 | SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForControlSectionStart); | ||
3321 | break; | ||
3322 | case ISO_IMAGE1_PART2 : | ||
3323 | if(Adapter->psFlash2xCSInfo->OffsetISOImage1Part2Start != UNINIT_PTR_IN_CS) | ||
3324 | SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2Start); | ||
3325 | break; | ||
3326 | case ISO_IMAGE1_PART3 : | ||
3327 | if(Adapter->psFlash2xCSInfo->OffsetISOImage1Part3Start != UNINIT_PTR_IN_CS) | ||
3328 | SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3Start); | ||
3329 | break; | ||
3330 | case ISO_IMAGE2_PART2 : | ||
3331 | if(Adapter->psFlash2xCSInfo->OffsetISOImage2Part2Start != UNINIT_PTR_IN_CS) | ||
3332 | SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2Start); | ||
3333 | break; | ||
3334 | case ISO_IMAGE2_PART3 : | ||
3335 | if(Adapter->psFlash2xCSInfo->OffsetISOImage2Part3Start != UNINIT_PTR_IN_CS) | ||
3336 | SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3Start); | ||
3337 | break; | ||
3338 | default : | ||
3339 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Section Does not exist in Flash 2.x"); | ||
3340 | SectStartOffset = INVALID_OFFSET; | ||
3341 | } | ||
3342 | return SectStartOffset; | ||
3343 | } | ||
3344 | |||
3345 | /** | ||
3346 | * BcmGetSectionValEndOffset - this will calculate the section's Ending offset if section val is given | ||
3347 | * @Adapter : Drivers Private Data structure | ||
3348 | * @eFlashSectionVal : Flash secion value defined in enum FLASH2X_SECTION_VAL | ||
3349 | * | ||
3350 | * Return value:- | ||
3351 | * On success it return the end offset of the provided section val | ||
3352 | * On Failure -returns STATUS_FAILURE | ||
3353 | **/ | ||
3354 | |||
3355 | INT BcmGetSectionValEndOffset(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal) | ||
3356 | { | ||
3357 | INT SectEndOffset = 0 ; | ||
3358 | SectEndOffset = INVALID_OFFSET; | ||
3359 | |||
3360 | if(IsSectionExistInVendorInfo(Adapter,eFlash2xSectionVal)) | ||
3361 | { | ||
3362 | return Adapter->psFlash2xVendorInfo->VendorSection[eFlash2xSectionVal].OffsetFromZeroForSectionEnd; | ||
3363 | } | ||
3364 | |||
3365 | switch(eFlash2xSectionVal) | ||
3366 | { | ||
3367 | case ISO_IMAGE1 : | ||
3368 | if((Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End!= UNINIT_PTR_IN_CS) && | ||
3369 | (IsNonCDLessDevice(Adapter) == FALSE)) | ||
3370 | SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End); | ||
3371 | break; | ||
3372 | case ISO_IMAGE2 : | ||
3373 | if((Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End!= UNINIT_PTR_IN_CS) && | ||
3374 | (IsNonCDLessDevice(Adapter) == FALSE)) | ||
3375 | SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End); | ||
3376 | break; | ||
3377 | case DSD0 : | ||
3378 | if(Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDEnd != UNINIT_PTR_IN_CS) | ||
3379 | SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDEnd); | ||
3380 | break; | ||
3381 | case DSD1 : | ||
3382 | if(Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1End != UNINIT_PTR_IN_CS) | ||
3383 | SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1End); | ||
3384 | break; | ||
3385 | case DSD2 : | ||
3386 | if(Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2End != UNINIT_PTR_IN_CS) | ||
3387 | SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2End); | ||
3388 | break; | ||
3389 | case VSA0 : | ||
3390 | if(Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAEnd != UNINIT_PTR_IN_CS) | ||
3391 | SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAEnd); | ||
3392 | break; | ||
3393 | case VSA1 : | ||
3394 | if(Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1End != UNINIT_PTR_IN_CS) | ||
3395 | SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1End); | ||
3396 | break; | ||
3397 | case VSA2 : | ||
3398 | if(Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2End != UNINIT_PTR_IN_CS) | ||
3399 | SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2End); | ||
3400 | break; | ||
3401 | case SCSI : | ||
3402 | if(Adapter->psFlash2xCSInfo->OffsetFromZeroForScsiFirmware != UNINIT_PTR_IN_CS) | ||
3403 | SectEndOffset = ((Adapter->psFlash2xCSInfo->OffsetFromZeroForScsiFirmware) + | ||
3404 | (Adapter->psFlash2xCSInfo->SizeOfScsiFirmware)); | ||
3405 | break; | ||
3406 | case CONTROL_SECTION : | ||
3407 | //Not Clear So Putting failure. confirm and fix it. | ||
3408 | SectEndOffset = STATUS_FAILURE; | ||
3409 | case ISO_IMAGE1_PART2 : | ||
3410 | if(Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End!= UNINIT_PTR_IN_CS) | ||
3411 | SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End); | ||
3412 | break; | ||
3413 | case ISO_IMAGE1_PART3 : | ||
3414 | if(Adapter->psFlash2xCSInfo->OffsetISOImage1Part3End!= UNINIT_PTR_IN_CS) | ||
3415 | SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3End); | ||
3416 | break; | ||
3417 | case ISO_IMAGE2_PART2 : | ||
3418 | if(Adapter->psFlash2xCSInfo->OffsetISOImage2Part2End != UNINIT_PTR_IN_CS) | ||
3419 | SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2End); | ||
3420 | break; | ||
3421 | case ISO_IMAGE2_PART3 : | ||
3422 | if(Adapter->psFlash2xCSInfo->OffsetISOImage2Part3End!= UNINIT_PTR_IN_CS) | ||
3423 | SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3End); | ||
3424 | break; | ||
3425 | |||
3426 | default : | ||
3427 | SectEndOffset = INVALID_OFFSET; | ||
3428 | } | ||
3429 | return SectEndOffset ; | ||
3430 | } | ||
3431 | |||
3432 | /* | ||
3433 | * BcmFlash2xBulkRead:- Read API for Flash Map 2.x . | ||
3434 | * @Adapter :Driver Private Data Structure | ||
3435 | * @pBuffer : Buffer where data has to be put after reading | ||
3436 | * @eFlashSectionVal :Flash Section Val defined in FLASH2X_SECTION_VAL | ||
3437 | * @uiOffsetWithinSectionVal :- Offset with in provided section | ||
3438 | * @uiNumBytes : Number of Bytes for Read | ||
3439 | * | ||
3440 | * Return value:- | ||
3441 | * return true on sucess and STATUS_FAILURE on fail. | ||
3442 | */ | ||
3443 | |||
3444 | INT BcmFlash2xBulkRead( | ||
3445 | PMINI_ADAPTER Adapter, | ||
3446 | PUINT pBuffer, | ||
3447 | FLASH2X_SECTION_VAL eFlash2xSectionVal, | ||
3448 | UINT uiOffsetWithinSectionVal, | ||
3449 | UINT uiNumBytes) | ||
3450 | { | ||
3451 | |||
3452 | INT Status = STATUS_SUCCESS; | ||
3453 | INT SectionStartOffset = 0; | ||
3454 | UINT uiAbsoluteOffset = 0 ; | ||
3455 | UINT uiTemp =0, value =0 ; | ||
3456 | if(Adapter == NULL) | ||
3457 | { | ||
3458 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Adapter structure is NULL"); | ||
3459 | return -EINVAL; | ||
3460 | } | ||
3461 | if(Adapter->device_removed ) | ||
3462 | { | ||
3463 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Device has been removed"); | ||
3464 | return -ENODEV; | ||
3465 | } | ||
3466 | |||
3467 | //NO_SECTION_VAL means absolute offset is given. | ||
3468 | if(eFlash2xSectionVal == NO_SECTION_VAL) | ||
3469 | SectionStartOffset = 0; | ||
3470 | else | ||
3471 | SectionStartOffset = BcmGetSectionValStartOffset(Adapter,eFlash2xSectionVal); | ||
3472 | |||
3473 | if(SectionStartOffset == STATUS_FAILURE ) | ||
3474 | { | ||
3475 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"This Section<%d> does not exixt in Flash 2.x Map ",eFlash2xSectionVal); | ||
3476 | return -EINVAL; | ||
3477 | } | ||
3478 | |||
3479 | if(IsSectionExistInVendorInfo(Adapter,eFlash2xSectionVal)) | ||
3480 | return vendorextnReadSection(Adapter,(PUCHAR)pBuffer, eFlash2xSectionVal, uiOffsetWithinSectionVal, uiNumBytes); | ||
3481 | |||
3482 | //calculating the absolute offset from FLASH; | ||
3483 | uiAbsoluteOffset = uiOffsetWithinSectionVal + SectionStartOffset; | ||
3484 | rdmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp)); | ||
3485 | value = 0; | ||
3486 | wrmalt(Adapter, 0x0f000C80,&value, sizeof(value)); | ||
3487 | |||
3488 | Status= BeceemFlashBulkRead(Adapter, pBuffer,uiAbsoluteOffset,uiNumBytes) ; | ||
3489 | |||
3490 | wrmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp)); | ||
3491 | if(Status) | ||
3492 | { | ||
3493 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Flash Read Failed with Status :%d", Status); | ||
3494 | return Status ; | ||
3495 | } | ||
3496 | |||
3497 | return Status; | ||
3498 | } | ||
3499 | |||
3500 | /* | ||
3501 | * BcmFlash2xBulkWrite :-API for Writing on the Flash Map 2.x. | ||
3502 | * @Adapter :Driver Private Data Structure | ||
3503 | * @pBuffer : Buffer From where data has to taken for writing | ||
3504 | * @eFlashSectionVal :Flash Section Val defined in FLASH2X_SECTION_VAL | ||
3505 | * @uiOffsetWithinSectionVal :- Offset with in provided section | ||
3506 | * @uiNumBytes : Number of Bytes for Write | ||
3507 | * | ||
3508 | * Return value:- | ||
3509 | * return true on sucess and STATUS_FAILURE on fail. | ||
3510 | * | ||
3511 | */ | ||
3512 | |||
3513 | INT BcmFlash2xBulkWrite( | ||
3514 | PMINI_ADAPTER Adapter, | ||
3515 | PUINT pBuffer, | ||
3516 | FLASH2X_SECTION_VAL eFlash2xSectVal, | ||
3517 | UINT uiOffset, | ||
3518 | UINT uiNumBytes, | ||
3519 | UINT bVerify) | ||
3520 | { | ||
3521 | |||
3522 | INT Status = STATUS_SUCCESS; | ||
3523 | UINT FlashSectValStartOffset = 0; | ||
3524 | UINT uiTemp = 0, value = 0; | ||
3525 | if(Adapter == NULL) | ||
3526 | { | ||
3527 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Adapter structure is NULL"); | ||
3528 | return -EINVAL; | ||
3529 | } | ||
3530 | if(Adapter->device_removed ) | ||
3531 | { | ||
3532 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Device has been removed"); | ||
3533 | return -ENODEV; | ||
3534 | } | ||
3535 | |||
3536 | //NO_SECTION_VAL means absolute offset is given. | ||
3537 | if(eFlash2xSectVal == NO_SECTION_VAL) | ||
3538 | FlashSectValStartOffset = 0; | ||
3539 | else | ||
3540 | FlashSectValStartOffset = BcmGetSectionValStartOffset(Adapter,eFlash2xSectVal); | ||
3541 | |||
3542 | if(FlashSectValStartOffset == STATUS_FAILURE ) | ||
3543 | { | ||
3544 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"This Section<%d> does not exixt in Flash Map 2.x",eFlash2xSectVal); | ||
3545 | return -EINVAL; | ||
3546 | } | ||
3547 | |||
3548 | if(IsSectionExistInVendorInfo(Adapter,eFlash2xSectVal)) | ||
3549 | return vendorextnWriteSection(Adapter, (PUCHAR)pBuffer, eFlash2xSectVal, uiOffset, uiNumBytes, bVerify); | ||
3550 | |||
3551 | //calculating the absolute offset from FLASH; | ||
3552 | uiOffset = uiOffset + FlashSectValStartOffset; | ||
3553 | |||
3554 | rdmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp)); | ||
3555 | value = 0; | ||
3556 | wrmalt(Adapter, 0x0f000C80,&value, sizeof(value)); | ||
3557 | |||
3558 | Status = BeceemFlashBulkWrite(Adapter, pBuffer,uiOffset,uiNumBytes,bVerify); | ||
3559 | |||
3560 | wrmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp)); | ||
3561 | if(Status) | ||
3562 | { | ||
3563 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Flash Write failed with Status :%d", Status); | ||
3564 | return Status ; | ||
3565 | } | ||
3566 | |||
3567 | return Status; | ||
3568 | |||
3569 | } | ||
3570 | |||
3571 | /** | ||
3572 | * ReadDSDHeader : Read the DSD map for the DSD Section val provided in Argument. | ||
3573 | * @Adapter : Beceem Private Data Structure | ||
3574 | * @psDSDHeader :Pointer of the buffer where header has to be read | ||
3575 | * @dsd :value of the Dyanmic DSD like DSD0 of DSD1 or DSD2 | ||
3576 | * | ||
3577 | * Return Value:- | ||
3578 | * if suceeds return STATUS_SUCCESS or negative error code. | ||
3579 | **/ | ||
3580 | INT ReadDSDHeader(PMINI_ADAPTER Adapter, PDSD_HEADER psDSDHeader, FLASH2X_SECTION_VAL dsd) | ||
3581 | { | ||
3582 | INT Status = STATUS_SUCCESS; | ||
3583 | |||
3584 | Status =BcmFlash2xBulkRead(Adapter, | ||
3585 | (PUINT)psDSDHeader, | ||
3586 | dsd, | ||
3587 | Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader, | ||
3588 | sizeof(DSD_HEADER)); | ||
3589 | if(Status == STATUS_SUCCESS) | ||
3590 | { | ||
3591 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "DSDImageMagicNumber :0X%x", ntohl(psDSDHeader->DSDImageMagicNumber)); | ||
3592 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "DSDImageSize :0X%x ",ntohl(psDSDHeader->DSDImageSize)); | ||
3593 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "DSDImageCRC :0X%x",ntohl(psDSDHeader->DSDImageCRC)); | ||
3594 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "DSDImagePriority :0X%x",ntohl(psDSDHeader->DSDImagePriority)); | ||
3595 | } | ||
3596 | else | ||
3597 | { | ||
3598 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"DSD Header read is failed with status :%d", Status); | ||
3599 | } | ||
3600 | |||
3601 | return Status; | ||
3602 | } | ||
3603 | |||
3604 | /** | ||
3605 | * BcmGetActiveDSD : Set the Active DSD in Adapter Structure which has to be dumped in DDR | ||
3606 | * @Adapter :-Drivers private Data Structure | ||
3607 | * | ||
3608 | * Return Value:- | ||
3609 | * Return STATUS_SUCESS if get sucess in setting the right DSD else negaive error code | ||
3610 | * | ||
3611 | **/ | ||
3612 | INT BcmGetActiveDSD(PMINI_ADAPTER Adapter) | ||
3613 | { | ||
3614 | FLASH2X_SECTION_VAL uiHighestPriDSD = 0 ; | ||
3615 | |||
3616 | uiHighestPriDSD = getHighestPriDSD(Adapter); | ||
3617 | Adapter->eActiveDSD = uiHighestPriDSD; | ||
3618 | |||
3619 | if(DSD0 == uiHighestPriDSD) | ||
3620 | Adapter->ulFlashCalStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDStart; | ||
3621 | if(DSD1 == uiHighestPriDSD) | ||
3622 | Adapter->ulFlashCalStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1Start; | ||
3623 | if(DSD2 == uiHighestPriDSD) | ||
3624 | Adapter->ulFlashCalStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2Start; | ||
3625 | if(Adapter->eActiveDSD) | ||
3626 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Active DSD :%d", Adapter->eActiveDSD); | ||
3627 | if(Adapter->eActiveDSD == 0) | ||
3628 | { | ||
3629 | //if No DSD gets Active, Make Active the DSD with WR permission | ||
3630 | if(IsSectionWritable(Adapter,DSD2)) | ||
3631 | { | ||
3632 | Adapter->eActiveDSD = DSD2; | ||
3633 | Adapter->ulFlashCalStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2Start; | ||
3634 | } | ||
3635 | else if(IsSectionWritable(Adapter,DSD1)) | ||
3636 | { | ||
3637 | Adapter->eActiveDSD = DSD1; | ||
3638 | Adapter->ulFlashCalStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1Start; | ||
3639 | } | ||
3640 | else if(IsSectionWritable(Adapter,DSD0)) | ||
3641 | { | ||
3642 | Adapter->eActiveDSD = DSD0; | ||
3643 | Adapter->ulFlashCalStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDStart; | ||
3644 | } | ||
3645 | } | ||
3646 | |||
3647 | return STATUS_SUCCESS; | ||
3648 | } | ||
3649 | |||
3650 | /** | ||
3651 | * ReadISOUnReservedBytes : Read the ISO map for the ISO Section val provided in Argument. | ||
3652 | * @Adapter : Driver Private Data Structure | ||
3653 | * @psISOHeader :Pointer of the location where header has to be read | ||
3654 | * @IsoImage :value of the Dyanmic ISO like ISO_IMAGE1 of ISO_IMAGE2 | ||
3655 | * | ||
3656 | * Return Value:- | ||
3657 | * if suceeds return STATUS_SUCCESS or negative error code. | ||
3658 | **/ | ||
3659 | |||
3660 | INT ReadISOHeader(PMINI_ADAPTER Adapter, PISO_HEADER psISOHeader, FLASH2X_SECTION_VAL IsoImage) | ||
3661 | { | ||
3662 | INT Status = STATUS_SUCCESS; | ||
3663 | |||
3664 | Status = BcmFlash2xBulkRead(Adapter, | ||
3665 | (PUINT)psISOHeader, | ||
3666 | IsoImage, | ||
3667 | 0, | ||
3668 | sizeof(ISO_HEADER)); | ||
3669 | |||
3670 | if(Status == STATUS_SUCCESS) | ||
3671 | { | ||
3672 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "ISOImageMagicNumber :0X%x", ntohl(psISOHeader->ISOImageMagicNumber)); | ||
3673 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "ISOImageSize :0X%x ",ntohl(psISOHeader->ISOImageSize)); | ||
3674 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "ISOImageCRC :0X%x",ntohl(psISOHeader->ISOImageCRC)); | ||
3675 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "ISOImagePriority :0X%x",ntohl(psISOHeader->ISOImagePriority)); | ||
3676 | } | ||
3677 | else | ||
3678 | { | ||
3679 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "ISO Header Read failed"); | ||
3680 | } | ||
3681 | return Status; | ||
3682 | } | ||
3683 | |||
3684 | /** | ||
3685 | * BcmGetActiveISO :- Set the Active ISO in Adapter Data Structue | ||
3686 | * @Adapter : Driver private Data Structure | ||
3687 | * | ||
3688 | * Return Value:- | ||
3689 | * Sucsess:- STATUS_SUCESS | ||
3690 | * Failure- : negative erro code | ||
3691 | * | ||
3692 | **/ | ||
3693 | |||
3694 | INT BcmGetActiveISO(PMINI_ADAPTER Adapter) | ||
3695 | { | ||
3696 | |||
3697 | INT HighestPriISO = 0 ; | ||
3698 | HighestPriISO = getHighestPriISO(Adapter); | ||
3699 | |||
3700 | Adapter->eActiveISO = HighestPriISO ; | ||
3701 | if(Adapter->eActiveISO == ISO_IMAGE2) | ||
3702 | Adapter->uiActiveISOOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start); | ||
3703 | else if(Adapter->eActiveISO == ISO_IMAGE1) | ||
3704 | Adapter->uiActiveISOOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start); | ||
3705 | |||
3706 | if(Adapter->eActiveISO) | ||
3707 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Active ISO :%x", Adapter->eActiveISO); | ||
3708 | |||
3709 | return STATUS_SUCCESS; | ||
3710 | } | ||
3711 | |||
3712 | /** | ||
3713 | * IsOffsetWritable :- it will tell the access permission of the sector having passed offset | ||
3714 | * @Adapter : Drivers Private Data Structure | ||
3715 | * @uiOffset : Offset provided in the Flash | ||
3716 | * | ||
3717 | * Return Value:- | ||
3718 | * Sucess:-TRUE , offset is writable | ||
3719 | * Failure:-FALSE, offset is RO | ||
3720 | * | ||
3721 | **/ | ||
3722 | B_UINT8 IsOffsetWritable(PMINI_ADAPTER Adapter, UINT uiOffset) | ||
3723 | { | ||
3724 | UINT uiSectorNum = 0; | ||
3725 | UINT uiWordOfSectorPermission =0; | ||
3726 | UINT uiBitofSectorePermission = 0; | ||
3727 | B_UINT32 permissionBits = 0; | ||
3728 | uiSectorNum = uiOffset/Adapter->uiSectorSize; | ||
3729 | |||
3730 | //calculating the word having this Sector Access permission from SectorAccessBitMap Array | ||
3731 | uiWordOfSectorPermission = Adapter->psFlash2xCSInfo->SectorAccessBitMap[uiSectorNum /16]; | ||
3732 | |||
3733 | //calculating the bit index inside the word for this sector | ||
3734 | uiBitofSectorePermission = 2*(15 - uiSectorNum %16); | ||
3735 | |||
3736 | //Setting Access permission | ||
3737 | permissionBits = uiWordOfSectorPermission & (0x3 << uiBitofSectorePermission) ; | ||
3738 | permissionBits = (permissionBits >> uiBitofSectorePermission) & 0x3; | ||
3739 | if(permissionBits == SECTOR_READWRITE_PERMISSION) | ||
3740 | return TRUE; | ||
3741 | else | ||
3742 | return FALSE; | ||
3743 | } | ||
3744 | |||
3745 | INT BcmDumpFlash2xSectionBitMap(PFLASH2X_BITMAP psFlash2xBitMap) | ||
3746 | { | ||
3747 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); | ||
3748 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "***************Flash 2.x Section Bitmap***************"); | ||
3749 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"ISO_IMAGE1 :0X%x", psFlash2xBitMap->ISO_IMAGE1); | ||
3750 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"ISO_IMAGE2 :0X%x", psFlash2xBitMap->ISO_IMAGE2); | ||
3751 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"DSD0 :0X%x", psFlash2xBitMap->DSD0); | ||
3752 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"DSD1 :0X%x", psFlash2xBitMap->DSD1); | ||
3753 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"DSD2 :0X%x", psFlash2xBitMap->DSD2); | ||
3754 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"VSA0 :0X%x", psFlash2xBitMap->VSA0); | ||
3755 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"VSA1 :0X%x", psFlash2xBitMap->VSA1); | ||
3756 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"VSA2 :0X%x", psFlash2xBitMap->VSA2); | ||
3757 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"SCSI :0X%x", psFlash2xBitMap->SCSI); | ||
3758 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"CONTROL_SECTION :0X%x", psFlash2xBitMap->CONTROL_SECTION); | ||
3759 | |||
3760 | return STATUS_SUCCESS; | ||
3761 | } | ||
3762 | |||
3763 | /** | ||
3764 | * BcmGetFlash2xSectionalBitMap :- It will provide the bit map of all the section present in Flash | ||
3765 | * 8bit has been assigned to every section. | ||
3766 | bit[0] :Section present or not | ||
3767 | bit[1] :section is valid or not | ||
3768 | bit[2] : Secton is read only or has write permission too. | ||
3769 | bit[3] : Active Section - | ||
3770 | bit[7...4] = Reserved . | ||
3771 | |||
3772 | @Adapter:-Driver private Data Structure | ||
3773 | * | ||
3774 | * Return value:- | ||
3775 | * Sucess:- STATUS_SUCESS | ||
3776 | * Failure:- negative error code | ||
3777 | **/ | ||
3778 | |||
3779 | INT BcmGetFlash2xSectionalBitMap(PMINI_ADAPTER Adapter, PFLASH2X_BITMAP psFlash2xBitMap) | ||
3780 | { | ||
3781 | |||
3782 | |||
3783 | PFLASH2X_CS_INFO psFlash2xCSInfo = Adapter->psFlash2xCSInfo; | ||
3784 | FLASH2X_SECTION_VAL uiHighestPriDSD = 0 ; | ||
3785 | FLASH2X_SECTION_VAL uiHighestPriISO= 0 ; | ||
3786 | BOOLEAN SetActiveDSDDone = FALSE ; | ||
3787 | BOOLEAN SetActiveISODone = FALSE ; | ||
3788 | |||
3789 | //For 1.x map all the section except DSD0 will be shown as not present | ||
3790 | //This part will be used by calibration tool to detect the number of DSD present in Flash. | ||
3791 | if(IsFlash2x(Adapter) == FALSE) | ||
3792 | { | ||
3793 | psFlash2xBitMap->ISO_IMAGE2 = 0; | ||
3794 | psFlash2xBitMap->ISO_IMAGE1 = 0; | ||
3795 | psFlash2xBitMap->DSD0 = FLASH2X_SECTION_VALID | FLASH2X_SECTION_ACT | FLASH2X_SECTION_PRESENT; //0xF; //0000(Reseved)1(Active)0(RW)1(valid)1(present) | ||
3796 | psFlash2xBitMap->DSD1 = 0 ; | ||
3797 | psFlash2xBitMap->DSD2 = 0 ; | ||
3798 | psFlash2xBitMap->VSA0 = 0 ; | ||
3799 | psFlash2xBitMap->VSA1 = 0 ; | ||
3800 | psFlash2xBitMap->VSA2 = 0 ; | ||
3801 | psFlash2xBitMap->CONTROL_SECTION = 0 ; | ||
3802 | psFlash2xBitMap->SCSI= 0 ; | ||
3803 | psFlash2xBitMap->Reserved0 = 0 ; | ||
3804 | psFlash2xBitMap->Reserved1 = 0 ; | ||
3805 | psFlash2xBitMap->Reserved2 = 0 ; | ||
3806 | return STATUS_SUCCESS ; | ||
3807 | |||
3808 | } | ||
3809 | |||
3810 | uiHighestPriDSD = getHighestPriDSD(Adapter); | ||
3811 | uiHighestPriISO = getHighestPriISO(Adapter); | ||
3812 | |||
3813 | /// | ||
3814 | // IS0 IMAGE 2 | ||
3815 | /// | ||
3816 | if((psFlash2xCSInfo->OffsetISOImage2Part1Start) != UNINIT_PTR_IN_CS) | ||
3817 | { | ||
3818 | //Setting the 0th Bit representing the Section is present or not. | ||
3819 | psFlash2xBitMap->ISO_IMAGE2= psFlash2xBitMap->ISO_IMAGE2 | FLASH2X_SECTION_PRESENT; | ||
3820 | |||
3821 | |||
3822 | if(ReadISOSignature(Adapter,ISO_IMAGE2)== ISO_IMAGE_MAGIC_NUMBER) | ||
3823 | psFlash2xBitMap->ISO_IMAGE2 |= FLASH2X_SECTION_VALID; | ||
3824 | |||
3825 | |||
3826 | //Calculation for extrating the Access permission | ||
3827 | if(IsSectionWritable(Adapter, ISO_IMAGE2) == FALSE) | ||
3828 | psFlash2xBitMap->ISO_IMAGE2 |= FLASH2X_SECTION_RO; | ||
3829 | |||
3830 | if(SetActiveISODone == FALSE && uiHighestPriISO == ISO_IMAGE2) | ||
3831 | { | ||
3832 | psFlash2xBitMap->ISO_IMAGE2 |= FLASH2X_SECTION_ACT ; | ||
3833 | SetActiveISODone = TRUE; | ||
3834 | } | ||
3835 | |||
3836 | } | ||
3837 | |||
3838 | /// | ||
3839 | // IS0 IMAGE 1 | ||
3840 | /// | ||
3841 | if((psFlash2xCSInfo->OffsetISOImage1Part1Start) != UNINIT_PTR_IN_CS) | ||
3842 | { | ||
3843 | //Setting the 0th Bit representing the Section is present or not. | ||
3844 | psFlash2xBitMap->ISO_IMAGE1 = psFlash2xBitMap->ISO_IMAGE1 | FLASH2X_SECTION_PRESENT; | ||
3845 | |||
3846 | if(ReadISOSignature(Adapter,ISO_IMAGE1) == ISO_IMAGE_MAGIC_NUMBER) | ||
3847 | psFlash2xBitMap->ISO_IMAGE1 |= FLASH2X_SECTION_VALID; | ||
3848 | |||
3849 | // Calculation for extrating the Access permission | ||
3850 | if(IsSectionWritable(Adapter, ISO_IMAGE1) == FALSE) | ||
3851 | psFlash2xBitMap->ISO_IMAGE1 |= FLASH2X_SECTION_RO; | ||
3852 | |||
3853 | if(SetActiveISODone == FALSE && uiHighestPriISO == ISO_IMAGE1) | ||
3854 | { | ||
3855 | psFlash2xBitMap->ISO_IMAGE1 |= FLASH2X_SECTION_ACT ; | ||
3856 | SetActiveISODone = TRUE; | ||
3857 | } | ||
3858 | } | ||
3859 | |||
3860 | |||
3861 | |||
3862 | /// | ||
3863 | // DSD2 | ||
3864 | /// | ||
3865 | if((psFlash2xCSInfo->OffsetFromZeroForDSD2Start) != UNINIT_PTR_IN_CS) | ||
3866 | { | ||
3867 | //Setting the 0th Bit representing the Section is present or not. | ||
3868 | psFlash2xBitMap->DSD2= psFlash2xBitMap->DSD2 | FLASH2X_SECTION_PRESENT; | ||
3869 | |||
3870 | if(ReadDSDSignature(Adapter,DSD2)== DSD_IMAGE_MAGIC_NUMBER) | ||
3871 | psFlash2xBitMap->DSD2 |= FLASH2X_SECTION_VALID; | ||
3872 | |||
3873 | //Calculation for extrating the Access permission | ||
3874 | if(IsSectionWritable(Adapter, DSD2) == FALSE) | ||
3875 | { | ||
3876 | psFlash2xBitMap->DSD2 |= FLASH2X_SECTION_RO; | ||
3877 | |||
3878 | } | ||
3879 | else | ||
3880 | { | ||
3881 | //Means section is writable | ||
3882 | if((SetActiveDSDDone == FALSE) && (uiHighestPriDSD == DSD2)) | ||
3883 | { | ||
3884 | psFlash2xBitMap->DSD2 |= FLASH2X_SECTION_ACT ; | ||
3885 | SetActiveDSDDone =TRUE ; | ||
3886 | } | ||
3887 | } | ||
3888 | } | ||
3889 | |||
3890 | /// | ||
3891 | // DSD 1 | ||
3892 | /// | ||
3893 | if((psFlash2xCSInfo->OffsetFromZeroForDSD1Start) != UNINIT_PTR_IN_CS) | ||
3894 | { | ||
3895 | //Setting the 0th Bit representing the Section is present or not. | ||
3896 | psFlash2xBitMap->DSD1= psFlash2xBitMap->DSD1 | FLASH2X_SECTION_PRESENT; | ||
3897 | |||
3898 | |||
3899 | if(ReadDSDSignature(Adapter,DSD1)== DSD_IMAGE_MAGIC_NUMBER) | ||
3900 | psFlash2xBitMap->DSD1 |= FLASH2X_SECTION_VALID; | ||
3901 | |||
3902 | //Calculation for extrating the Access permission | ||
3903 | if(IsSectionWritable(Adapter, DSD1) == FALSE) | ||
3904 | { | ||
3905 | psFlash2xBitMap->DSD1 |= FLASH2X_SECTION_RO; | ||
3906 | } | ||
3907 | else | ||
3908 | { | ||
3909 | //Means section is writable | ||
3910 | if((SetActiveDSDDone == FALSE) && (uiHighestPriDSD == DSD1)) | ||
3911 | { | ||
3912 | psFlash2xBitMap->DSD1 |= FLASH2X_SECTION_ACT ; | ||
3913 | SetActiveDSDDone =TRUE ; | ||
3914 | } | ||
3915 | } | ||
3916 | |||
3917 | } | ||
3918 | |||
3919 | /// | ||
3920 | //For DSD 0 | ||
3921 | // | ||
3922 | if((psFlash2xCSInfo->OffsetFromZeroForDSDStart) != UNINIT_PTR_IN_CS) | ||
3923 | { | ||
3924 | //Setting the 0th Bit representing the Section is present or not. | ||
3925 | psFlash2xBitMap->DSD0 = psFlash2xBitMap->DSD0 | FLASH2X_SECTION_PRESENT; | ||
3926 | |||
3927 | if(ReadDSDSignature(Adapter,DSD0) == DSD_IMAGE_MAGIC_NUMBER) | ||
3928 | psFlash2xBitMap->DSD0 |= FLASH2X_SECTION_VALID; | ||
3929 | |||
3930 | //Setting Access permission | ||
3931 | if(IsSectionWritable(Adapter, DSD0) == FALSE) | ||
3932 | { | ||
3933 | psFlash2xBitMap->DSD0 |= FLASH2X_SECTION_RO; | ||
3934 | } | ||
3935 | else | ||
3936 | { | ||
3937 | //Means section is writable | ||
3938 | if((SetActiveDSDDone == FALSE) &&(uiHighestPriDSD == DSD0)) | ||
3939 | { | ||
3940 | psFlash2xBitMap->DSD0 |= FLASH2X_SECTION_ACT ; | ||
3941 | SetActiveDSDDone =TRUE ; | ||
3942 | } | ||
3943 | } | ||
3944 | } | ||
3945 | |||
3946 | /// | ||
3947 | // VSA 0 | ||
3948 | /// | ||
3949 | if((psFlash2xCSInfo->OffsetFromZeroForVSAStart) != UNINIT_PTR_IN_CS) | ||
3950 | { | ||
3951 | //Setting the 0th Bit representing the Section is present or not. | ||
3952 | psFlash2xBitMap->VSA0= psFlash2xBitMap->VSA0 | FLASH2X_SECTION_PRESENT; | ||
3953 | |||
3954 | //Setting the Access Bit. Map is not defined hece setting it always valid | ||
3955 | psFlash2xBitMap->VSA0 |= FLASH2X_SECTION_VALID; | ||
3956 | |||
3957 | //Calculation for extrating the Access permission | ||
3958 | if(IsSectionWritable(Adapter, VSA0) == FALSE) | ||
3959 | psFlash2xBitMap->VSA0 |= FLASH2X_SECTION_RO; | ||
3960 | |||
3961 | //By Default section is Active | ||
3962 | psFlash2xBitMap->VSA0 |= FLASH2X_SECTION_ACT ; | ||
3963 | |||
3964 | } | ||
3965 | |||
3966 | |||
3967 | /// | ||
3968 | // VSA 1 | ||
3969 | /// | ||
3970 | |||
3971 | if((psFlash2xCSInfo->OffsetFromZeroForVSA1Start) != UNINIT_PTR_IN_CS) | ||
3972 | { | ||
3973 | //Setting the 0th Bit representing the Section is present or not. | ||
3974 | psFlash2xBitMap->VSA1= psFlash2xBitMap->VSA1 | FLASH2X_SECTION_PRESENT; | ||
3975 | |||
3976 | //Setting the Access Bit. Map is not defined hece setting it always valid | ||
3977 | psFlash2xBitMap->VSA1|= FLASH2X_SECTION_VALID; | ||
3978 | |||
3979 | //Checking For Access permission | ||
3980 | if(IsSectionWritable(Adapter, VSA1) == FALSE) | ||
3981 | psFlash2xBitMap->VSA1 |= FLASH2X_SECTION_RO; | ||
3982 | |||
3983 | //By Default section is Active | ||
3984 | psFlash2xBitMap->VSA1 |= FLASH2X_SECTION_ACT ; | ||
3985 | |||
3986 | } | ||
3987 | |||
3988 | |||
3989 | /// | ||
3990 | // VSA 2 | ||
3991 | /// | ||
3992 | |||
3993 | if((psFlash2xCSInfo->OffsetFromZeroForVSA2Start) != UNINIT_PTR_IN_CS) | ||
3994 | { | ||
3995 | //Setting the 0th Bit representing the Section is present or not. | ||
3996 | psFlash2xBitMap->VSA2= psFlash2xBitMap->VSA2 | FLASH2X_SECTION_PRESENT; | ||
3997 | |||
3998 | |||
3999 | //Setting the Access Bit. Map is not defined hece setting it always valid | ||
4000 | psFlash2xBitMap->VSA2 |= FLASH2X_SECTION_VALID; | ||
4001 | |||
4002 | //Checking For Access permission | ||
4003 | if(IsSectionWritable(Adapter, VSA2) == FALSE) | ||
4004 | psFlash2xBitMap->VSA2 |= FLASH2X_SECTION_RO; | ||
4005 | |||
4006 | //By Default section is Active | ||
4007 | psFlash2xBitMap->VSA2 |= FLASH2X_SECTION_ACT ; | ||
4008 | } | ||
4009 | |||
4010 | /// | ||
4011 | // SCSI Section | ||
4012 | /// | ||
4013 | if((psFlash2xCSInfo->OffsetFromZeroForScsiFirmware) != UNINIT_PTR_IN_CS) | ||
4014 | { | ||
4015 | //Setting the 0th Bit representing the Section is present or not. | ||
4016 | psFlash2xBitMap->SCSI= psFlash2xBitMap->SCSI | FLASH2X_SECTION_PRESENT; | ||
4017 | |||
4018 | |||
4019 | //Setting the Access Bit. Map is not defined hece setting it always valid | ||
4020 | psFlash2xBitMap->SCSI|= FLASH2X_SECTION_VALID; | ||
4021 | |||
4022 | //Checking For Access permission | ||
4023 | if(IsSectionWritable(Adapter, SCSI) == FALSE) | ||
4024 | psFlash2xBitMap->SCSI |= FLASH2X_SECTION_RO; | ||
4025 | |||
4026 | //By Default section is Active | ||
4027 | psFlash2xBitMap->SCSI |= FLASH2X_SECTION_ACT ; | ||
4028 | |||
4029 | } | ||
4030 | |||
4031 | |||
4032 | /// | ||
4033 | // Control Section | ||
4034 | /// | ||
4035 | if((psFlash2xCSInfo->OffsetFromZeroForControlSectionStart) != UNINIT_PTR_IN_CS) | ||
4036 | { | ||
4037 | //Setting the 0th Bit representing the Section is present or not. | ||
4038 | psFlash2xBitMap->CONTROL_SECTION = psFlash2xBitMap->CONTROL_SECTION | (FLASH2X_SECTION_PRESENT); | ||
4039 | |||
4040 | |||
4041 | //Setting the Access Bit. Map is not defined hece setting it always valid | ||
4042 | psFlash2xBitMap->CONTROL_SECTION |= FLASH2X_SECTION_VALID; | ||
4043 | |||
4044 | //Checking For Access permission | ||
4045 | if(IsSectionWritable(Adapter, CONTROL_SECTION) == FALSE) | ||
4046 | psFlash2xBitMap->CONTROL_SECTION |= FLASH2X_SECTION_RO; | ||
4047 | |||
4048 | //By Default section is Active | ||
4049 | psFlash2xBitMap->CONTROL_SECTION |= FLASH2X_SECTION_ACT ; | ||
4050 | |||
4051 | } | ||
4052 | |||
4053 | /// | ||
4054 | // For Reserved Sections | ||
4055 | /// | ||
4056 | psFlash2xBitMap->Reserved0 = 0; | ||
4057 | psFlash2xBitMap->Reserved0 = 0; | ||
4058 | psFlash2xBitMap->Reserved0 = 0; | ||
4059 | |||
4060 | BcmDumpFlash2xSectionBitMap(psFlash2xBitMap); | ||
4061 | |||
4062 | return STATUS_SUCCESS ; | ||
4063 | |||
4064 | } | ||
4065 | /** | ||
4066 | BcmSetActiveSection :- Set Active section is used to make priority field highest over other | ||
4067 | section of same type. | ||
4068 | |||
4069 | @Adapater :- Bcm Driver Private Data Structure | ||
4070 | @eFlash2xSectionVal :- Flash section val whose priority has to be made highest. | ||
4071 | |||
4072 | Return Value:- Make the priorit highest else return erorr code | ||
4073 | |||
4074 | **/ | ||
4075 | INT BcmSetActiveSection(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectVal) | ||
4076 | { | ||
4077 | INT SectImagePriority = 0; | ||
4078 | INT Status =STATUS_SUCCESS; | ||
4079 | |||
4080 | //DSD_HEADER sDSD = {0}; | ||
4081 | //ISO_HEADER sISO = {0}; | ||
4082 | INT HighestPriDSD = 0 ; | ||
4083 | INT HighestPriISO = 0; | ||
4084 | |||
4085 | |||
4086 | |||
4087 | Status = IsSectionWritable(Adapter,eFlash2xSectVal) ; | ||
4088 | if(Status != TRUE ) | ||
4089 | { | ||
4090 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Provided Section <%d> is not writable",eFlash2xSectVal); | ||
4091 | return STATUS_FAILURE; | ||
4092 | } | ||
4093 | |||
4094 | Adapter->bHeaderChangeAllowed = TRUE ; | ||
4095 | switch(eFlash2xSectVal) | ||
4096 | { | ||
4097 | case ISO_IMAGE1 : | ||
4098 | case ISO_IMAGE2 : | ||
4099 | if(ReadISOSignature(Adapter,eFlash2xSectVal)== ISO_IMAGE_MAGIC_NUMBER ) | ||
4100 | { | ||
4101 | HighestPriISO = getHighestPriISO(Adapter); | ||
4102 | |||
4103 | if(HighestPriISO == eFlash2xSectVal ) | ||
4104 | { | ||
4105 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Given ISO<%x> already has highest priority",eFlash2xSectVal ); | ||
4106 | Status = STATUS_SUCCESS ; | ||
4107 | break; | ||
4108 | } | ||
4109 | |||
4110 | SectImagePriority = ReadISOPriority(Adapter, HighestPriISO) + 1; | ||
4111 | |||
4112 | if((SectImagePriority <= 0) && IsSectionWritable(Adapter,HighestPriISO)) | ||
4113 | { | ||
4114 | // This is a SPECIAL Case which will only happen if the current highest priority ISO has priority value = 0x7FFFFFFF. | ||
4115 | // We will write 1 to the current Highest priority ISO And then shall increase the priority of the requested ISO | ||
4116 | // by user | ||
4117 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "SectImagePriority wraparound happend, eFlash2xSectVal: 0x%x\n",eFlash2xSectVal); | ||
4118 | SectImagePriority = htonl(0x1); | ||
4119 | Status = BcmFlash2xBulkWrite(Adapter, | ||
4120 | &SectImagePriority, | ||
4121 | HighestPriISO, | ||
4122 | 0 + FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImagePriority), | ||
4123 | SIGNATURE_SIZE, | ||
4124 | TRUE); | ||
4125 | |||
4126 | if(Status) | ||
4127 | { | ||
4128 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Priority has not been written properly"); | ||
4129 | Status = STATUS_FAILURE; | ||
4130 | break ; | ||
4131 | } | ||
4132 | |||
4133 | HighestPriISO = getHighestPriISO(Adapter); | ||
4134 | |||
4135 | if(HighestPriISO == eFlash2xSectVal ) | ||
4136 | { | ||
4137 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Given ISO<%x> already has highest priority",eFlash2xSectVal ); | ||
4138 | Status = STATUS_SUCCESS ; | ||
4139 | break; | ||
4140 | } | ||
4141 | |||
4142 | SectImagePriority = 2; | ||
4143 | } | ||
4144 | |||
4145 | |||
4146 | SectImagePriority = htonl(SectImagePriority); | ||
4147 | |||
4148 | Status = BcmFlash2xBulkWrite(Adapter, | ||
4149 | &SectImagePriority, | ||
4150 | eFlash2xSectVal, | ||
4151 | 0 + FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImagePriority), | ||
4152 | SIGNATURE_SIZE, | ||
4153 | TRUE); | ||
4154 | if(Status) | ||
4155 | { | ||
4156 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Priority has not been written properly"); | ||
4157 | break ; | ||
4158 | } | ||
4159 | } | ||
4160 | else | ||
4161 | { | ||
4162 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Signature is currupted. Hence can't increase the priority"); | ||
4163 | Status = STATUS_FAILURE ; | ||
4164 | break; | ||
4165 | } | ||
4166 | break; | ||
4167 | case DSD0 : | ||
4168 | case DSD1 : | ||
4169 | case DSD2 : | ||
4170 | if(ReadDSDSignature(Adapter,eFlash2xSectVal)== DSD_IMAGE_MAGIC_NUMBER) | ||
4171 | { | ||
4172 | HighestPriDSD = getHighestPriDSD(Adapter); | ||
4173 | |||
4174 | if((HighestPriDSD == eFlash2xSectVal)) | ||
4175 | { | ||
4176 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Given DSD<%x> already has highest priority", eFlash2xSectVal); | ||
4177 | Status = STATUS_SUCCESS ; | ||
4178 | break; | ||
4179 | } | ||
4180 | |||
4181 | SectImagePriority = ReadDSDPriority(Adapter, HighestPriDSD) + 1 ; | ||
4182 | if(SectImagePriority <= 0) | ||
4183 | { | ||
4184 | // This is a SPECIAL Case which will only happen if the current highest priority DSD has priority value = 0x7FFFFFFF. | ||
4185 | // We will write 1 to the current Highest priority DSD And then shall increase the priority of the requested DSD | ||
4186 | // by user | ||
4187 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, NVM_RW, DBG_LVL_ALL, "SectImagePriority wraparound happend, eFlash2xSectVal: 0x%x\n",eFlash2xSectVal); | ||
4188 | SectImagePriority = htonl(0x1); | ||
4189 | |||
4190 | Status = BcmFlash2xBulkWrite(Adapter, | ||
4191 | &SectImagePriority, | ||
4192 | HighestPriDSD, | ||
4193 | Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImagePriority), | ||
4194 | SIGNATURE_SIZE, | ||
4195 | TRUE); | ||
4196 | |||
4197 | if(Status) | ||
4198 | { | ||
4199 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Priority has not been written properly"); | ||
4200 | break ; | ||
4201 | } | ||
4202 | |||
4203 | HighestPriDSD = getHighestPriDSD(Adapter); | ||
4204 | |||
4205 | if((HighestPriDSD == eFlash2xSectVal)) | ||
4206 | { | ||
4207 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Made the DSD: %x highest by reducing priority of other\n", eFlash2xSectVal); | ||
4208 | Status = STATUS_SUCCESS ; | ||
4209 | break; | ||
4210 | } | ||
4211 | |||
4212 | SectImagePriority = htonl(0x2); | ||
4213 | Status = BcmFlash2xBulkWrite(Adapter, | ||
4214 | &SectImagePriority, | ||
4215 | HighestPriDSD, | ||
4216 | Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImagePriority), | ||
4217 | SIGNATURE_SIZE, | ||
4218 | TRUE); | ||
4219 | |||
4220 | if(Status) | ||
4221 | { | ||
4222 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Priority has not been written properly"); | ||
4223 | break ; | ||
4224 | } | ||
4225 | |||
4226 | HighestPriDSD = getHighestPriDSD(Adapter); | ||
4227 | |||
4228 | if((HighestPriDSD == eFlash2xSectVal)) | ||
4229 | { | ||
4230 | Status = STATUS_SUCCESS ; | ||
4231 | break; | ||
4232 | } | ||
4233 | SectImagePriority = 3 ; | ||
4234 | |||
4235 | } | ||
4236 | SectImagePriority = htonl(SectImagePriority); | ||
4237 | Status = BcmFlash2xBulkWrite(Adapter, | ||
4238 | &SectImagePriority, | ||
4239 | eFlash2xSectVal, | ||
4240 | Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImagePriority), | ||
4241 | SIGNATURE_SIZE , | ||
4242 | TRUE); | ||
4243 | if(Status) | ||
4244 | { | ||
4245 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Priority has not been written properly"); | ||
4246 | Status = STATUS_FAILURE ; | ||
4247 | break ; | ||
4248 | } | ||
4249 | } | ||
4250 | else | ||
4251 | { | ||
4252 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Signature is currupted. Hence can't increase the priority"); | ||
4253 | Status = STATUS_FAILURE ; | ||
4254 | break; | ||
4255 | } | ||
4256 | break; | ||
4257 | case VSA0 : | ||
4258 | case VSA1 : | ||
4259 | case VSA2 : | ||
4260 | //Has to be decided | ||
4261 | break ; | ||
4262 | default : | ||
4263 | Status = STATUS_FAILURE ; | ||
4264 | break; | ||
4265 | |||
4266 | } | ||
4267 | |||
4268 | Adapter->bHeaderChangeAllowed = FALSE ; | ||
4269 | return Status; | ||
4270 | |||
4271 | } | ||
4272 | |||
4273 | /** | ||
4274 | BcmCopyISO - Used only for copying the ISO section | ||
4275 | @Adapater :- Bcm Driver Private Data Structure | ||
4276 | @sCopySectStrut :- Section copy structure | ||
4277 | |||
4278 | Return value:- SUCCESS if copies successfully else negative error code | ||
4279 | |||
4280 | **/ | ||
4281 | INT BcmCopyISO(PMINI_ADAPTER Adapter, FLASH2X_COPY_SECTION sCopySectStrut) | ||
4282 | { | ||
4283 | |||
4284 | PCHAR Buff = NULL; | ||
4285 | FLASH2X_SECTION_VAL eISOReadPart = 0,eISOWritePart = 0; | ||
4286 | UINT uiReadOffsetWithinPart = 0, uiWriteOffsetWithinPart = 0; | ||
4287 | UINT uiTotalDataToCopy = 0; | ||
4288 | BOOLEAN IsThisHeaderSector = FALSE ; | ||
4289 | UINT sigOffset = 0; | ||
4290 | UINT ISOLength = 0; | ||
4291 | UINT Status = STATUS_SUCCESS; | ||
4292 | UINT SigBuff[MAX_RW_SIZE]; | ||
4293 | UINT i = 0; | ||
4294 | |||
4295 | if(ReadISOSignature(Adapter,sCopySectStrut.SrcSection) != ISO_IMAGE_MAGIC_NUMBER) | ||
4296 | { | ||
4297 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "error as Source ISO Section does not have valid signature"); | ||
4298 | return STATUS_FAILURE; | ||
4299 | } | ||
4300 | |||
4301 | Status = BcmFlash2xBulkRead(Adapter, | ||
4302 | &ISOLength, | ||
4303 | sCopySectStrut.SrcSection, | ||
4304 | 0 + FIELD_OFFSET_IN_HEADER(PISO_HEADER,ISOImageSize), | ||
4305 | 4); | ||
4306 | |||
4307 | if(Status) | ||
4308 | { | ||
4309 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Read failed while copying ISO\n"); | ||
4310 | return Status; | ||
4311 | } | ||
4312 | |||
4313 | ISOLength = htonl(ISOLength); | ||
4314 | |||
4315 | if(ISOLength % Adapter->uiSectorSize) | ||
4316 | { | ||
4317 | ISOLength = Adapter->uiSectorSize*(1 + ISOLength/Adapter->uiSectorSize); | ||
4318 | } | ||
4319 | |||
4320 | sigOffset = FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImageMagicNumber); | ||
4321 | |||
4322 | Buff = kzalloc(Adapter->uiSectorSize, GFP_KERNEL); | ||
4323 | |||
4324 | if(Buff == NULL) | ||
4325 | { | ||
4326 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Memory allocation failed for section size"); | ||
4327 | return -ENOMEM; | ||
4328 | } | ||
4329 | |||
4330 | if(sCopySectStrut.SrcSection ==ISO_IMAGE1 && sCopySectStrut.DstSection ==ISO_IMAGE2) | ||
4331 | { | ||
4332 | eISOReadPart = ISO_IMAGE1 ; | ||
4333 | eISOWritePart = ISO_IMAGE2 ; | ||
4334 | uiReadOffsetWithinPart = 0; | ||
4335 | uiWriteOffsetWithinPart = 0 ; | ||
4336 | |||
4337 | uiTotalDataToCopy =(Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End) - | ||
4338 | (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start)+ | ||
4339 | (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End) - | ||
4340 | (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2Start)+ | ||
4341 | (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3End) - | ||
4342 | (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3Start); | ||
4343 | |||
4344 | if(uiTotalDataToCopy < ISOLength) | ||
4345 | { | ||
4346 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"error as Source ISO Section does not have valid signature"); | ||
4347 | return STATUS_FAILURE; | ||
4348 | } | ||
4349 | |||
4350 | uiTotalDataToCopy =(Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End) - | ||
4351 | (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start)+ | ||
4352 | (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2End) - | ||
4353 | (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2Start)+ | ||
4354 | (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3End) - | ||
4355 | (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3Start); | ||
4356 | |||
4357 | if(uiTotalDataToCopy < ISOLength) | ||
4358 | { | ||
4359 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"error as Dest ISO Section does not have enough section size"); | ||
4360 | return STATUS_FAILURE; | ||
4361 | } | ||
4362 | |||
4363 | uiTotalDataToCopy = ISOLength; | ||
4364 | |||
4365 | CorruptISOSig(Adapter,ISO_IMAGE2); | ||
4366 | |||
4367 | while(uiTotalDataToCopy) | ||
4368 | { | ||
4369 | if(uiTotalDataToCopy == Adapter->uiSectorSize) | ||
4370 | { | ||
4371 | //Setting for write of first sector. First sector is assumed to be written in last | ||
4372 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Writing the signature sector"); | ||
4373 | eISOReadPart = ISO_IMAGE1 ; | ||
4374 | uiReadOffsetWithinPart = 0; | ||
4375 | eISOWritePart = ISO_IMAGE2; | ||
4376 | uiWriteOffsetWithinPart = 0 ; | ||
4377 | IsThisHeaderSector = TRUE ; | ||
4378 | |||
4379 | } | ||
4380 | else | ||
4381 | { | ||
4382 | uiReadOffsetWithinPart = uiReadOffsetWithinPart + Adapter->uiSectorSize ; | ||
4383 | uiWriteOffsetWithinPart = uiWriteOffsetWithinPart + Adapter->uiSectorSize ; | ||
4384 | |||
4385 | if((eISOReadPart == ISO_IMAGE1) && (uiReadOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End - Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start) )) | ||
4386 | { | ||
4387 | eISOReadPart = ISO_IMAGE1_PART2 ; | ||
4388 | uiReadOffsetWithinPart = 0; | ||
4389 | } | ||
4390 | if((eISOReadPart == ISO_IMAGE1_PART2) && (uiReadOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End - Adapter->psFlash2xCSInfo->OffsetISOImage1Part2Start))) | ||
4391 | { | ||
4392 | eISOReadPart = ISO_IMAGE1_PART3 ; | ||
4393 | uiReadOffsetWithinPart = 0; | ||
4394 | } | ||
4395 | if((eISOWritePart == ISO_IMAGE2) && (uiWriteOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End - Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start))) | ||
4396 | { | ||
4397 | eISOWritePart = ISO_IMAGE2_PART2 ; | ||
4398 | uiWriteOffsetWithinPart = 0; | ||
4399 | } | ||
4400 | if((eISOWritePart == ISO_IMAGE2_PART2) && (uiWriteOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2End - Adapter->psFlash2xCSInfo->OffsetISOImage2Part2Start))) | ||
4401 | { | ||
4402 | eISOWritePart = ISO_IMAGE2_PART3 ; | ||
4403 | uiWriteOffsetWithinPart = 0; | ||
4404 | } | ||
4405 | } | ||
4406 | |||
4407 | Status = BcmFlash2xBulkRead(Adapter, | ||
4408 | (PUINT)Buff, | ||
4409 | eISOReadPart, | ||
4410 | uiReadOffsetWithinPart, | ||
4411 | Adapter->uiSectorSize | ||
4412 | ); | ||
4413 | |||
4414 | if(Status) | ||
4415 | { | ||
4416 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Read failed while copying ISO: Part: %x, OffsetWithinPart: %x\n", eISOReadPart, uiReadOffsetWithinPart); | ||
4417 | break; | ||
4418 | } | ||
4419 | |||
4420 | if(IsThisHeaderSector == TRUE) | ||
4421 | { | ||
4422 | //If this is header sector write 0xFFFFFFFF at the sig time and in last write sig | ||
4423 | memcpy(SigBuff, Buff + sigOffset, MAX_RW_SIZE); | ||
4424 | |||
4425 | for(i = 0; i < MAX_RW_SIZE;i++) | ||
4426 | *(Buff + sigOffset + i) = 0xFF; | ||
4427 | } | ||
4428 | Adapter->bHeaderChangeAllowed = TRUE ; | ||
4429 | |||
4430 | Status = BcmFlash2xBulkWrite(Adapter, | ||
4431 | (PUINT)Buff, | ||
4432 | eISOWritePart, | ||
4433 | uiWriteOffsetWithinPart, | ||
4434 | Adapter->uiSectorSize, | ||
4435 | TRUE); | ||
4436 | if(Status) | ||
4437 | { | ||
4438 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Write failed while copying ISO: Part: %x, OffsetWithinPart: %x\n", eISOWritePart, uiWriteOffsetWithinPart); | ||
4439 | break; | ||
4440 | } | ||
4441 | |||
4442 | Adapter->bHeaderChangeAllowed = FALSE; | ||
4443 | |||
4444 | if(IsThisHeaderSector == TRUE) | ||
4445 | { | ||
4446 | WriteToFlashWithoutSectorErase(Adapter, | ||
4447 | SigBuff, | ||
4448 | eISOWritePart, | ||
4449 | sigOffset, | ||
4450 | MAX_RW_SIZE); | ||
4451 | IsThisHeaderSector = FALSE ; | ||
4452 | } | ||
4453 | //substracting the written Data | ||
4454 | uiTotalDataToCopy = uiTotalDataToCopy - Adapter->uiSectorSize ; | ||
4455 | } | ||
4456 | |||
4457 | |||
4458 | } | ||
4459 | |||
4460 | if(sCopySectStrut.SrcSection ==ISO_IMAGE2 && sCopySectStrut.DstSection ==ISO_IMAGE1) | ||
4461 | { | ||
4462 | eISOReadPart = ISO_IMAGE2 ; | ||
4463 | eISOWritePart = ISO_IMAGE1 ; | ||
4464 | uiReadOffsetWithinPart = 0; | ||
4465 | uiWriteOffsetWithinPart = 0 ; | ||
4466 | |||
4467 | uiTotalDataToCopy =(Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End) - | ||
4468 | (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start)+ | ||
4469 | (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2End) - | ||
4470 | (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2Start)+ | ||
4471 | (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3End) - | ||
4472 | (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3Start); | ||
4473 | |||
4474 | if(uiTotalDataToCopy < ISOLength) | ||
4475 | { | ||
4476 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"error as Source ISO Section does not have valid signature"); | ||
4477 | return STATUS_FAILURE; | ||
4478 | } | ||
4479 | |||
4480 | uiTotalDataToCopy =(Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End) - | ||
4481 | (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start)+ | ||
4482 | (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End) - | ||
4483 | (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2Start)+ | ||
4484 | (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3End) - | ||
4485 | (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3Start); | ||
4486 | |||
4487 | if(uiTotalDataToCopy < ISOLength) | ||
4488 | { | ||
4489 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"error as Dest ISO Section does not have enough section size"); | ||
4490 | return STATUS_FAILURE; | ||
4491 | } | ||
4492 | |||
4493 | uiTotalDataToCopy = ISOLength; | ||
4494 | |||
4495 | CorruptISOSig(Adapter,ISO_IMAGE1); | ||
4496 | |||
4497 | while(uiTotalDataToCopy) | ||
4498 | { | ||
4499 | if(uiTotalDataToCopy == Adapter->uiSectorSize) | ||
4500 | { | ||
4501 | //Setting for write of first sector. First sector is assumed to be written in last | ||
4502 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Writing the signature sector"); | ||
4503 | eISOReadPart = ISO_IMAGE2 ; | ||
4504 | uiReadOffsetWithinPart = 0; | ||
4505 | eISOWritePart = ISO_IMAGE1; | ||
4506 | uiWriteOffsetWithinPart = 0 ; | ||
4507 | IsThisHeaderSector = TRUE; | ||
4508 | |||
4509 | } | ||
4510 | else | ||
4511 | { | ||
4512 | uiReadOffsetWithinPart = uiReadOffsetWithinPart + Adapter->uiSectorSize ; | ||
4513 | uiWriteOffsetWithinPart = uiWriteOffsetWithinPart + Adapter->uiSectorSize ; | ||
4514 | |||
4515 | if((eISOReadPart == ISO_IMAGE2) && (uiReadOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End - Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start) )) | ||
4516 | { | ||
4517 | eISOReadPart = ISO_IMAGE2_PART2 ; | ||
4518 | uiReadOffsetWithinPart = 0; | ||
4519 | } | ||
4520 | if((eISOReadPart == ISO_IMAGE2_PART2) && (uiReadOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2End - Adapter->psFlash2xCSInfo->OffsetISOImage2Part2Start))) | ||
4521 | { | ||
4522 | eISOReadPart = ISO_IMAGE2_PART3 ; | ||
4523 | uiReadOffsetWithinPart = 0; | ||
4524 | } | ||
4525 | if((eISOWritePart == ISO_IMAGE1) && (uiWriteOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End - Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start))) | ||
4526 | { | ||
4527 | eISOWritePart = ISO_IMAGE1_PART2 ; | ||
4528 | uiWriteOffsetWithinPart = 0; | ||
4529 | } | ||
4530 | if((eISOWritePart == ISO_IMAGE1_PART2) && (uiWriteOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End - Adapter->psFlash2xCSInfo->OffsetISOImage1Part2Start))) | ||
4531 | { | ||
4532 | eISOWritePart = ISO_IMAGE1_PART3 ; | ||
4533 | uiWriteOffsetWithinPart = 0; | ||
4534 | } | ||
4535 | } | ||
4536 | |||
4537 | Status = BcmFlash2xBulkRead(Adapter, | ||
4538 | (PUINT)Buff, | ||
4539 | eISOReadPart, | ||
4540 | uiReadOffsetWithinPart, | ||
4541 | Adapter->uiSectorSize | ||
4542 | ); | ||
4543 | if(Status) | ||
4544 | { | ||
4545 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Read failed while copying ISO: Part: %x, OffsetWithinPart: %x\n", eISOReadPart, uiReadOffsetWithinPart); | ||
4546 | break; | ||
4547 | } | ||
4548 | |||
4549 | if(IsThisHeaderSector == TRUE) | ||
4550 | { | ||
4551 | //If this is header sector write 0xFFFFFFFF at the sig time and in last write sig | ||
4552 | memcpy(SigBuff, Buff + sigOffset, MAX_RW_SIZE); | ||
4553 | |||
4554 | for(i = 0; i < MAX_RW_SIZE;i++) | ||
4555 | *(Buff + sigOffset + i) = 0xFF; | ||
4556 | |||
4557 | } | ||
4558 | Adapter->bHeaderChangeAllowed = TRUE ; | ||
4559 | Status = BcmFlash2xBulkWrite(Adapter, | ||
4560 | (PUINT)Buff, | ||
4561 | eISOWritePart, | ||
4562 | uiWriteOffsetWithinPart, | ||
4563 | Adapter->uiSectorSize, | ||
4564 | TRUE); | ||
4565 | |||
4566 | if(Status) | ||
4567 | { | ||
4568 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Write failed while copying ISO: Part: %x, OffsetWithinPart: %x\n", eISOWritePart, uiWriteOffsetWithinPart); | ||
4569 | break; | ||
4570 | } | ||
4571 | |||
4572 | Adapter->bHeaderChangeAllowed = FALSE ; | ||
4573 | |||
4574 | if(IsThisHeaderSector == TRUE) | ||
4575 | { | ||
4576 | WriteToFlashWithoutSectorErase(Adapter, | ||
4577 | SigBuff, | ||
4578 | eISOWritePart, | ||
4579 | sigOffset, | ||
4580 | MAX_RW_SIZE); | ||
4581 | IsThisHeaderSector = FALSE ; | ||
4582 | } | ||
4583 | |||
4584 | //substracting the written Data | ||
4585 | uiTotalDataToCopy = uiTotalDataToCopy - Adapter->uiSectorSize ; | ||
4586 | } | ||
4587 | |||
4588 | |||
4589 | } | ||
4590 | |||
4591 | bcm_kfree(Buff); | ||
4592 | |||
4593 | return Status; | ||
4594 | } | ||
4595 | /** | ||
4596 | BcmFlash2xCorruptSig : this API is used to corrupt the written sig in Bcm Header present in flash section. | ||
4597 | It will corrupt the sig, if Section is writable, by making first bytes as zero. | ||
4598 | @Adapater :- Bcm Driver Private Data Structure | ||
4599 | @eFlash2xSectionVal :- Flash section val which has header | ||
4600 | |||
4601 | Return Value :- | ||
4602 | Sucess :- If Section is present and writable, corrupt the sig and return STATUS_SUCCESS | ||
4603 | Failure :-Return negative error code | ||
4604 | |||
4605 | |||
4606 | **/ | ||
4607 | INT BcmFlash2xCorruptSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal) | ||
4608 | { | ||
4609 | |||
4610 | INT Status = STATUS_SUCCESS ; | ||
4611 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Section Value :%x \n", eFlash2xSectionVal); | ||
4612 | |||
4613 | if((eFlash2xSectionVal == DSD0) || (eFlash2xSectionVal == DSD1) || (eFlash2xSectionVal == DSD2)) | ||
4614 | { | ||
4615 | Status = CorruptDSDSig(Adapter, eFlash2xSectionVal); | ||
4616 | } | ||
4617 | else if(eFlash2xSectionVal == ISO_IMAGE1 || eFlash2xSectionVal == ISO_IMAGE2) | ||
4618 | { | ||
4619 | Status = CorruptISOSig(Adapter, eFlash2xSectionVal); | ||
4620 | } | ||
4621 | else | ||
4622 | { | ||
4623 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Given Section <%d>does not have Header",eFlash2xSectionVal); | ||
4624 | return STATUS_SUCCESS; | ||
4625 | } | ||
4626 | return Status; | ||
4627 | } | ||
4628 | /** | ||
4629 | BcmFlash2xWriteSig :-this API is used to Write the sig if requested Section has | ||
4630 | header and Write Permission. | ||
4631 | @Adapater :- Bcm Driver Private Data Structure | ||
4632 | @eFlashSectionVal :- Flash section val which has header | ||
4633 | |||
4634 | Return Value :- | ||
4635 | Sucess :- If Section is present and writable write the sig and return STATUS_SUCCESS | ||
4636 | Failure :-Return negative error code | ||
4637 | |||
4638 | **/ | ||
4639 | INT BcmFlash2xWriteSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlashSectionVal) | ||
4640 | { | ||
4641 | |||
4642 | UINT uiSignature = 0 ; | ||
4643 | UINT uiOffset = 0; | ||
4644 | //DSD_HEADER dsdHeader = {0}; | ||
4645 | |||
4646 | if(Adapter->bSigCorrupted == FALSE) | ||
4647 | { | ||
4648 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Signature is not corrupted by driver, hence not restoring\n"); | ||
4649 | return STATUS_SUCCESS; | ||
4650 | } | ||
4651 | if(Adapter->bAllDSDWriteAllow == FALSE) | ||
4652 | { | ||
4653 | if(IsSectionWritable(Adapter,eFlashSectionVal) == FALSE) | ||
4654 | { | ||
4655 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Section is not Writable...Hence can't Write signature"); | ||
4656 | return SECTOR_IS_NOT_WRITABLE; | ||
4657 | } | ||
4658 | } | ||
4659 | if((eFlashSectionVal == DSD0) ||(eFlashSectionVal == DSD1) || (eFlashSectionVal == DSD2)) | ||
4660 | { | ||
4661 | uiSignature = htonl(DSD_IMAGE_MAGIC_NUMBER) ; | ||
4662 | uiOffset = Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader ; | ||
4663 | |||
4664 | uiOffset += FIELD_OFFSET_IN_HEADER(PDSD_HEADER,DSDImageMagicNumber); | ||
4665 | |||
4666 | if((ReadDSDSignature(Adapter,eFlashSectionVal) & 0xFF000000) != CORRUPTED_PATTERN) | ||
4667 | { | ||
4668 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Corrupted Pattern is not there. Hence won't write sig"); | ||
4669 | return STATUS_FAILURE; | ||
4670 | } | ||
4671 | |||
4672 | } | ||
4673 | else if((eFlashSectionVal == ISO_IMAGE1) || (eFlashSectionVal == ISO_IMAGE2)) | ||
4674 | { | ||
4675 | uiSignature = htonl(ISO_IMAGE_MAGIC_NUMBER); | ||
4676 | //uiOffset = 0; | ||
4677 | uiOffset = FIELD_OFFSET_IN_HEADER(PISO_HEADER,ISOImageMagicNumber); | ||
4678 | if((ReadISOSignature(Adapter,eFlashSectionVal) & 0xFF000000) != CORRUPTED_PATTERN) | ||
4679 | { | ||
4680 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Currupted Pattern is not there. Hence won't write sig"); | ||
4681 | return STATUS_FAILURE; | ||
4682 | } | ||
4683 | } | ||
4684 | else | ||
4685 | { | ||
4686 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"GIVEN SECTION< %d > IS NOT VALID FOR SIG WRITE...", eFlashSectionVal); | ||
4687 | return STATUS_FAILURE; | ||
4688 | } | ||
4689 | |||
4690 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Restoring the signature"); | ||
4691 | |||
4692 | |||
4693 | Adapter->bHeaderChangeAllowed = TRUE; | ||
4694 | Adapter->bSigCorrupted = FALSE; | ||
4695 | BcmFlash2xBulkWrite(Adapter, &uiSignature,eFlashSectionVal,uiOffset,SIGNATURE_SIZE,TRUE); | ||
4696 | Adapter->bHeaderChangeAllowed = FALSE; | ||
4697 | |||
4698 | |||
4699 | |||
4700 | return STATUS_SUCCESS; | ||
4701 | } | ||
4702 | /** | ||
4703 | validateFlash2xReadWrite :- This API is used to validate the user request for Read/Write. | ||
4704 | if requested Bytes goes beyond the Requested section, it reports error. | ||
4705 | @Adapater :- Bcm Driver Private Data Structure | ||
4706 | @psFlash2xReadWrite :-Flash2x Read/write structure pointer | ||
4707 | |||
4708 | Return values:-Return TRUE is request is valid else FALSE. | ||
4709 | |||
4710 | |||
4711 | **/ | ||
4712 | INT validateFlash2xReadWrite(PMINI_ADAPTER Adapter, PFLASH2X_READWRITE psFlash2xReadWrite) | ||
4713 | { | ||
4714 | UINT uiNumOfBytes = 0 ; | ||
4715 | UINT uiSectStartOffset = 0 ; | ||
4716 | UINT uiSectEndOffset = 0; | ||
4717 | uiNumOfBytes = psFlash2xReadWrite->numOfBytes; | ||
4718 | |||
4719 | if(IsSectionExistInFlash(Adapter,psFlash2xReadWrite->Section) != TRUE) | ||
4720 | { | ||
4721 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Section<%x> does not exixt in Flash",psFlash2xReadWrite->Section); | ||
4722 | return FALSE; | ||
4723 | } | ||
4724 | uiSectStartOffset = BcmGetSectionValStartOffset(Adapter,psFlash2xReadWrite->Section); | ||
4725 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Start offset :%x ,section :%d\n",uiSectStartOffset,psFlash2xReadWrite->Section); | ||
4726 | if((psFlash2xReadWrite->Section == ISO_IMAGE1) ||(psFlash2xReadWrite->Section == ISO_IMAGE2)) | ||
4727 | { | ||
4728 | if(psFlash2xReadWrite->Section == ISO_IMAGE1) | ||
4729 | { | ||
4730 | uiSectEndOffset = BcmGetSectionValEndOffset(Adapter,ISO_IMAGE1) - | ||
4731 | BcmGetSectionValStartOffset(Adapter,ISO_IMAGE1)+ | ||
4732 | BcmGetSectionValEndOffset(Adapter,ISO_IMAGE1_PART2) - | ||
4733 | BcmGetSectionValStartOffset(Adapter,ISO_IMAGE1_PART2)+ | ||
4734 | BcmGetSectionValEndOffset(Adapter,ISO_IMAGE1_PART3) - | ||
4735 | BcmGetSectionValStartOffset(Adapter,ISO_IMAGE1_PART3); | ||
4736 | } | ||
4737 | else if(psFlash2xReadWrite->Section == ISO_IMAGE2) | ||
4738 | { | ||
4739 | uiSectEndOffset = BcmGetSectionValEndOffset(Adapter,ISO_IMAGE2) - | ||
4740 | BcmGetSectionValStartOffset(Adapter,ISO_IMAGE2)+ | ||
4741 | BcmGetSectionValEndOffset(Adapter,ISO_IMAGE2_PART2) - | ||
4742 | BcmGetSectionValStartOffset(Adapter,ISO_IMAGE2_PART2)+ | ||
4743 | BcmGetSectionValEndOffset(Adapter,ISO_IMAGE2_PART3) - | ||
4744 | BcmGetSectionValStartOffset(Adapter,ISO_IMAGE2_PART3); | ||
4745 | |||
4746 | } | ||
4747 | |||
4748 | //since this uiSectEndoffset is the size of iso Image. hence for calculating the vitual endoffset | ||
4749 | //it should be added in startoffset. so that check done in last of this function can be valued. | ||
4750 | uiSectEndOffset = uiSectStartOffset + uiSectEndOffset ; | ||
4751 | |||
4752 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Total size of the ISO Image :%x",uiSectEndOffset); | ||
4753 | } | ||
4754 | else | ||
4755 | uiSectEndOffset = BcmGetSectionValEndOffset(Adapter,psFlash2xReadWrite->Section); | ||
4756 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "End offset :%x \n",uiSectEndOffset); | ||
4757 | |||
4758 | //Checking the boundary condition | ||
4759 | if((uiSectStartOffset + psFlash2xReadWrite->offset + uiNumOfBytes) <= uiSectEndOffset) | ||
4760 | return TRUE; | ||
4761 | else | ||
4762 | { | ||
4763 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Invalid Request...."); | ||
4764 | return FALSE; | ||
4765 | } | ||
4766 | |||
4767 | } | ||
4768 | |||
4769 | /** | ||
4770 | IsFlash2x :- check for Flash 2.x | ||
4771 | @Adapater :- Bcm Driver Private Data Structure | ||
4772 | |||
4773 | Return value:- | ||
4774 | return TRUE if flah2.x of hgher version else return false. | ||
4775 | **/ | ||
4776 | |||
4777 | INT IsFlash2x(PMINI_ADAPTER Adapter) | ||
4778 | { | ||
4779 | if(Adapter->uiFlashLayoutMajorVersion >= FLASH_2X_MAJOR_NUMBER) | ||
4780 | return TRUE ; | ||
4781 | else | ||
4782 | return FALSE; | ||
4783 | } | ||
4784 | /** | ||
4785 | GetFlashBaseAddr :- Calculate the Flash Base address | ||
4786 | @Adapater :- Bcm Driver Private Data Structure | ||
4787 | |||
4788 | Return Value:- | ||
4789 | Success :- Base Address of the Flash | ||
4790 | **/ | ||
4791 | |||
4792 | INT GetFlashBaseAddr(PMINI_ADAPTER Adapter) | ||
4793 | { | ||
4794 | |||
4795 | UINT uiBaseAddr = 0; | ||
4796 | |||
4797 | if(Adapter->bDDRInitDone) | ||
4798 | { | ||
4799 | /* | ||
4800 | For All Valid Flash Versions... except 1.1, take the value from FlashBaseAddr | ||
4801 | In case of Raw Read... use the default value | ||
4802 | */ | ||
4803 | if(Adapter->uiFlashLayoutMajorVersion && (Adapter->bFlashRawRead == FALSE) && | ||
4804 | !((Adapter->uiFlashLayoutMajorVersion == 1) && (Adapter->uiFlashLayoutMinorVersion == 1)) | ||
4805 | ) | ||
4806 | uiBaseAddr = Adapter->uiFlashBaseAdd ; | ||
4807 | else | ||
4808 | uiBaseAddr = FLASH_CONTIGIOUS_START_ADDR_AFTER_INIT; | ||
4809 | } | ||
4810 | else | ||
4811 | { | ||
4812 | /* | ||
4813 | For All Valid Flash Versions... except 1.1, take the value from FlashBaseAddr | ||
4814 | In case of Raw Read... use the default value | ||
4815 | */ | ||
4816 | if(Adapter->uiFlashLayoutMajorVersion && (Adapter->bFlashRawRead == FALSE) && | ||
4817 | !((Adapter->uiFlashLayoutMajorVersion == 1) && (Adapter->uiFlashLayoutMinorVersion == 1)) | ||
4818 | ) | ||
4819 | uiBaseAddr = Adapter->uiFlashBaseAdd | FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT; | ||
4820 | else | ||
4821 | uiBaseAddr = FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT; | ||
4822 | } | ||
4823 | |||
4824 | return uiBaseAddr ; | ||
4825 | } | ||
4826 | /** | ||
4827 | BcmCopySection :- This API is used to copy the One section in another. Both section should | ||
4828 | be contiuous and of same size. Hence this Will not be applicabe to copy ISO. | ||
4829 | |||
4830 | @Adapater :- Bcm Driver Private Data Structure | ||
4831 | @SrcSection :- Source section From where data has to be copied | ||
4832 | @DstSection :- Destination section to which data has to be copied | ||
4833 | @offset :- Offset from/to where data has to be copied from one section to another. | ||
4834 | @numOfBytes :- number of byes that has to be copyed from one section to another at given offset. | ||
4835 | in case of numofBytes equal zero complete section will be copied. | ||
4836 | |||
4837 | Return Values- | ||
4838 | Sucess : Return STATUS_SUCCESS | ||
4839 | Faillure :- return negative error code | ||
4840 | |||
4841 | **/ | ||
4842 | |||
4843 | INT BcmCopySection(PMINI_ADAPTER Adapter, | ||
4844 | FLASH2X_SECTION_VAL SrcSection, | ||
4845 | FLASH2X_SECTION_VAL DstSection, | ||
4846 | UINT offset, | ||
4847 | UINT numOfBytes) | ||
4848 | { | ||
4849 | UINT BuffSize = 0 ; | ||
4850 | UINT BytesToBeCopied = 0; | ||
4851 | PUCHAR pBuff = NULL ; | ||
4852 | INT Status = STATUS_SUCCESS ; | ||
4853 | if(SrcSection == DstSection) | ||
4854 | { | ||
4855 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Source and Destination should be different ...try again"); | ||
4856 | return -EINVAL; | ||
4857 | } | ||
4858 | if((SrcSection != DSD0) && (SrcSection != DSD1) && (SrcSection != DSD2)) | ||
4859 | { | ||
4860 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Source should be DSD subsection"); | ||
4861 | return -EINVAL; | ||
4862 | } | ||
4863 | if((DstSection != DSD0) && (DstSection != DSD1) && (DstSection != DSD2)) | ||
4864 | { | ||
4865 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Destination should be DSD subsection"); | ||
4866 | return -EINVAL; | ||
4867 | } | ||
4868 | |||
4869 | #if 0 | ||
4870 | else | ||
4871 | { | ||
4872 | if((SrcSection == VSA0) || (SrcSection == VSA1) || (SrcSection == VSA2)) | ||
4873 | { | ||
4874 | if((DstSection != VSA0) && (DstSection != VSA1) && (DstSection != VSA2)) | ||
4875 | { | ||
4876 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Source and Destion secton is not of same type"); | ||
4877 | return -EINVAL; | ||
4878 | } | ||
4879 | } | ||
4880 | |||
4881 | } | ||
4882 | #endif | ||
4883 | //if offset zero means have to copy complete secton | ||
4884 | |||
4885 | if(numOfBytes == 0) | ||
4886 | { | ||
4887 | numOfBytes = BcmGetSectionValEndOffset(Adapter,SrcSection) | ||
4888 | - BcmGetSectionValStartOffset(Adapter,SrcSection); | ||
4889 | |||
4890 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL," Section Size :0x%x",numOfBytes); | ||
4891 | } | ||
4892 | |||
4893 | if((offset + numOfBytes) > BcmGetSectionValEndOffset(Adapter,SrcSection) | ||
4894 | - BcmGetSectionValStartOffset(Adapter,SrcSection)) | ||
4895 | { | ||
4896 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0," Input parameters going beyond the section offS: %x numB: %x of Source Section\n", | ||
4897 | offset, numOfBytes); | ||
4898 | return -EINVAL; | ||
4899 | } | ||
4900 | |||
4901 | if((offset + numOfBytes) > BcmGetSectionValEndOffset(Adapter,DstSection) | ||
4902 | - BcmGetSectionValStartOffset(Adapter,DstSection)) | ||
4903 | { | ||
4904 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0," Input parameters going beyond the section offS: %x numB: %x of Destination Section\n", | ||
4905 | offset, numOfBytes); | ||
4906 | return -EINVAL; | ||
4907 | } | ||
4908 | |||
4909 | |||
4910 | if(numOfBytes > Adapter->uiSectorSize ) | ||
4911 | BuffSize = Adapter->uiSectorSize; | ||
4912 | else | ||
4913 | BuffSize = numOfBytes ; | ||
4914 | |||
4915 | pBuff = (PCHAR)kzalloc(BuffSize, GFP_KERNEL); | ||
4916 | if(pBuff == NULL) | ||
4917 | { | ||
4918 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Memory allocation failed.. "); | ||
4919 | return -ENOMEM; | ||
4920 | } | ||
4921 | |||
4922 | |||
4923 | BytesToBeCopied = Adapter->uiSectorSize ; | ||
4924 | if(offset % Adapter->uiSectorSize) | ||
4925 | BytesToBeCopied = Adapter->uiSectorSize - (offset % Adapter->uiSectorSize); | ||
4926 | if(BytesToBeCopied > numOfBytes) | ||
4927 | BytesToBeCopied = numOfBytes ; | ||
4928 | |||
4929 | |||
4930 | |||
4931 | Adapter->bHeaderChangeAllowed = TRUE; | ||
4932 | |||
4933 | do | ||
4934 | { | ||
4935 | Status = BcmFlash2xBulkRead(Adapter, (PUINT)pBuff, SrcSection , offset,BytesToBeCopied); | ||
4936 | if(Status) | ||
4937 | { | ||
4938 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Read failed at offset :%d for NOB :%d", SrcSection,BytesToBeCopied); | ||
4939 | break; | ||
4940 | } | ||
4941 | Status = BcmFlash2xBulkWrite(Adapter,(PUINT)pBuff,DstSection,offset,BytesToBeCopied,FALSE); | ||
4942 | if(Status) | ||
4943 | { | ||
4944 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Write failed at offset :%d for NOB :%d", DstSection,BytesToBeCopied); | ||
4945 | break; | ||
4946 | } | ||
4947 | offset = offset + BytesToBeCopied; | ||
4948 | numOfBytes = numOfBytes - BytesToBeCopied ; | ||
4949 | if(numOfBytes) | ||
4950 | { | ||
4951 | if(numOfBytes > Adapter->uiSectorSize ) | ||
4952 | BytesToBeCopied = Adapter->uiSectorSize; | ||
4953 | else | ||
4954 | BytesToBeCopied = numOfBytes; | ||
4955 | } | ||
4956 | }while(numOfBytes > 0) ; | ||
4957 | bcm_kfree(pBuff); | ||
4958 | Adapter->bHeaderChangeAllowed = FALSE ; | ||
4959 | return Status; | ||
4960 | } | ||
4961 | |||
4962 | /** | ||
4963 | SaveHeaderIfPresent :- This API is use to Protect the Header in case of Header Sector write | ||
4964 | @Adapater :- Bcm Driver Private Data Structure | ||
4965 | @pBuff :- Data buffer that has to be written in sector having the header map. | ||
4966 | @uiOffset :- Flash offset that has to be written. | ||
4967 | |||
4968 | Return value :- | ||
4969 | Sucess :- On sucess return STATUS_SUCCESS | ||
4970 | Faillure :- Return negative error code | ||
4971 | |||
4972 | **/ | ||
4973 | |||
4974 | INT SaveHeaderIfPresent(PMINI_ADAPTER Adapter, PUCHAR pBuff, UINT uiOffset) | ||
4975 | { | ||
4976 | UINT offsetToProtect = 0,HeaderSizeToProtect =0; | ||
4977 | BOOLEAN bHasHeader = FALSE ; | ||
4978 | PUCHAR pTempBuff =NULL; | ||
4979 | UINT uiSectAlignAddr = 0; | ||
4980 | UINT sig = 0; | ||
4981 | |||
4982 | #if 0 | ||
4983 | //if Chenges in Header is allowed, Return back | ||
4984 | if(Adapter->bHeaderChangeAllowed == TRUE) | ||
4985 | { | ||
4986 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Header Change is allowed"); | ||
4987 | return STATUS_SUCCESS ; | ||
4988 | } | ||
4989 | #endif | ||
4990 | //making the offset sector alligned | ||
4991 | uiSectAlignAddr = uiOffset & ~(Adapter->uiSectorSize - 1); | ||
4992 | |||
4993 | |||
4994 | if((uiSectAlignAddr == BcmGetSectionValEndOffset(Adapter,DSD2)- Adapter->uiSectorSize)|| | ||
4995 | (uiSectAlignAddr == BcmGetSectionValEndOffset(Adapter,DSD1)- Adapter->uiSectorSize)|| | ||
4996 | (uiSectAlignAddr == BcmGetSectionValEndOffset(Adapter,DSD0)- Adapter->uiSectorSize)) | ||
4997 | { | ||
4998 | |||
4999 | //offset from the sector boundry having the header map | ||
5000 | offsetToProtect = Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader % Adapter->uiSectorSize; | ||
5001 | HeaderSizeToProtect = sizeof(DSD_HEADER); | ||
5002 | bHasHeader = TRUE ; | ||
5003 | } | ||
5004 | |||
5005 | if(uiSectAlignAddr == BcmGetSectionValStartOffset(Adapter,ISO_IMAGE1) || | ||
5006 | uiSectAlignAddr == BcmGetSectionValStartOffset(Adapter,ISO_IMAGE2)) | ||
5007 | { | ||
5008 | offsetToProtect = 0; | ||
5009 | HeaderSizeToProtect = sizeof(ISO_HEADER); | ||
5010 | bHasHeader = TRUE; | ||
5011 | } | ||
5012 | //If Header is present overwrite passed buffer with this | ||
5013 | if(bHasHeader && (Adapter->bHeaderChangeAllowed == FALSE)) | ||
5014 | { | ||
5015 | pTempBuff = (PUCHAR)kzalloc(HeaderSizeToProtect, GFP_KERNEL); | ||
5016 | if(pTempBuff == NULL) | ||
5017 | { | ||
5018 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Memory allocation failed "); | ||
5019 | return -ENOMEM; | ||
5020 | } | ||
5021 | //Read header | ||
5022 | BeceemFlashBulkRead(Adapter,(PUINT)pTempBuff,(uiSectAlignAddr + offsetToProtect),HeaderSizeToProtect); | ||
5023 | BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,pTempBuff ,HeaderSizeToProtect); | ||
5024 | //Replace Buffer content with Header | ||
5025 | memcpy(pBuff +offsetToProtect,pTempBuff,HeaderSizeToProtect); | ||
5026 | |||
5027 | bcm_kfree(pTempBuff); | ||
5028 | } | ||
5029 | if(bHasHeader && Adapter->bSigCorrupted) | ||
5030 | { | ||
5031 | sig = *((PUINT)(pBuff + offsetToProtect + FIELD_OFFSET_IN_HEADER(PDSD_HEADER,DSDImageMagicNumber))); | ||
5032 | sig = ntohl(sig); | ||
5033 | if((sig & 0xFF000000) != CORRUPTED_PATTERN) | ||
5034 | { | ||
5035 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Desired pattern is not at sig offset. Hence won't restore"); | ||
5036 | Adapter->bSigCorrupted = FALSE; | ||
5037 | return STATUS_SUCCESS; | ||
5038 | } | ||
5039 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL," Corrupted sig is :%X", sig); | ||
5040 | *((PUINT)(pBuff + offsetToProtect + FIELD_OFFSET_IN_HEADER(PDSD_HEADER,DSDImageMagicNumber)))= htonl(DSD_IMAGE_MAGIC_NUMBER); | ||
5041 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Restoring the signature in Header Write only"); | ||
5042 | Adapter->bSigCorrupted = FALSE; | ||
5043 | } | ||
5044 | |||
5045 | return STATUS_SUCCESS ; | ||
5046 | } | ||
5047 | INT BcmMakeFlashCSActive(PMINI_ADAPTER Adapter, UINT offset) | ||
5048 | { | ||
5049 | UINT GPIOConfig = 0 ; | ||
5050 | |||
5051 | |||
5052 | if(Adapter->bFlashRawRead == FALSE) | ||
5053 | { | ||
5054 | //Applicable for Flash2.x | ||
5055 | if(IsFlash2x(Adapter) == FALSE) | ||
5056 | return STATUS_SUCCESS; | ||
5057 | } | ||
5058 | |||
5059 | if(offset/FLASH_PART_SIZE) | ||
5060 | { | ||
5061 | //bit[14..12] -> will select make Active CS1, CS2 or CS3 | ||
5062 | // Select CS1, CS2 and CS3 (CS0 is dedicated pin) | ||
5063 | rdmalt(Adapter,FLASH_GPIO_CONFIG_REG, &GPIOConfig, 4); | ||
5064 | GPIOConfig |= (7 << 12); | ||
5065 | wrmalt(Adapter,FLASH_GPIO_CONFIG_REG, &GPIOConfig, 4); | ||
5066 | } | ||
5067 | |||
5068 | return STATUS_SUCCESS ; | ||
5069 | } | ||
5070 | /** | ||
5071 | BcmDoChipSelect : This will selcet the appropriate chip for writing. | ||
5072 | @Adapater :- Bcm Driver Private Data Structure | ||
5073 | |||
5074 | OutPut:- | ||
5075 | Select the Appropriate chip and retrn status Sucess | ||
5076 | **/ | ||
5077 | INT BcmDoChipSelect(PMINI_ADAPTER Adapter, UINT offset) | ||
5078 | { | ||
5079 | UINT FlashConfig = 0; | ||
5080 | INT ChipNum = 0; | ||
5081 | UINT GPIOConfig = 0; | ||
5082 | UINT PartNum = 0; | ||
5083 | |||
5084 | ChipNum = offset / FLASH_PART_SIZE ; | ||
5085 | |||
5086 | // | ||
5087 | // Chip Select mapping to enable flash0. | ||
5088 | // To select flash 0, we have to OR with (0<<12). | ||
5089 | // ORing 0 will have no impact so not doing that part. | ||
5090 | // In future if Chip select value changes from 0 to non zero, | ||
5091 | // That needs be taken care with backward comaptibility. No worries for now. | ||
5092 | // | ||
5093 | |||
5094 | /* | ||
5095 | SelectedChip Variable is the selection that the host is 100% Sure the same as what the register will hold. This can be ONLY ensured | ||
5096 | if the Chip doesn't goes to low power mode while the flash operation is in progress (NVMRdmWrmLock is taken) | ||
5097 | Before every new Flash Write operation, we reset the variable. This is to ensure that after any wake-up from | ||
5098 | power down modes (Idle mode/shutdown mode), the values in the register will be different. | ||
5099 | */ | ||
5100 | |||
5101 | if(Adapter->SelectedChip == ChipNum) | ||
5102 | return STATUS_SUCCESS; | ||
5103 | |||
5104 | //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Selected Chip :%x", ChipNum); | ||
5105 | Adapter->SelectedChip = ChipNum ; | ||
5106 | |||
5107 | //bit[13..12] will select the appropriate chip | ||
5108 | rdmalt(Adapter,FLASH_CONFIG_REG, &FlashConfig, 4); | ||
5109 | rdmalt(Adapter,FLASH_GPIO_CONFIG_REG, &GPIOConfig, 4); | ||
5110 | |||
5111 | { | ||
5112 | switch(ChipNum) | ||
5113 | { | ||
5114 | case 0: | ||
5115 | PartNum = 0; | ||
5116 | break; | ||
5117 | case 1: | ||
5118 | PartNum = 3; | ||
5119 | GPIOConfig |= (0x4 << CHIP_SELECT_BIT12); | ||
5120 | break; | ||
5121 | case 2: | ||
5122 | PartNum = 1; | ||
5123 | GPIOConfig |= (0x1 << CHIP_SELECT_BIT12); | ||
5124 | break; | ||
5125 | case 3: | ||
5126 | PartNum = 2; | ||
5127 | GPIOConfig |= (0x2 << CHIP_SELECT_BIT12); | ||
5128 | break; | ||
5129 | } | ||
5130 | } | ||
5131 | /* In case the bits already written in the FLASH_CONFIG_REG is same as what the user desired, | ||
5132 | nothing to do... can return immediately. | ||
5133 | ASSUMPTION: FLASH_GPIO_CONFIG_REG will be in sync with FLASH_CONFIG_REG. | ||
5134 | Even if the chip goes to low power mode, it should wake with values in each register in sync with each other. | ||
5135 | These values are not written by host other than during CHIP_SELECT. | ||
5136 | */ | ||
5137 | if(PartNum == ((FlashConfig >> CHIP_SELECT_BIT12) & 0x3)) | ||
5138 | return STATUS_SUCCESS; | ||
5139 | |||
5140 | //clearing the bit[13..12] | ||
5141 | FlashConfig &= 0xFFFFCFFF; | ||
5142 | FlashConfig = (FlashConfig | (PartNum<<CHIP_SELECT_BIT12)); //00 | ||
5143 | |||
5144 | wrmalt(Adapter,FLASH_GPIO_CONFIG_REG, &GPIOConfig, 4); | ||
5145 | udelay(100); | ||
5146 | |||
5147 | wrmalt(Adapter,FLASH_CONFIG_REG, &FlashConfig, 4); | ||
5148 | udelay(100); | ||
5149 | |||
5150 | return STATUS_SUCCESS; | ||
5151 | |||
5152 | } | ||
5153 | INT ReadDSDSignature(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL dsd) | ||
5154 | { | ||
5155 | UINT uiDSDsig = 0; | ||
5156 | //UINT sigoffsetInMap = 0; | ||
5157 | //DSD_HEADER dsdHeader = {0}; | ||
5158 | |||
5159 | |||
5160 | //sigoffsetInMap =(PUCHAR)&(dsdHeader.DSDImageMagicNumber) -(PUCHAR)&dsdHeader; | ||
5161 | |||
5162 | if(dsd != DSD0 && dsd != DSD1 && dsd != DSD2) | ||
5163 | { | ||
5164 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"passed section value is not for DSDs"); | ||
5165 | return STATUS_FAILURE; | ||
5166 | } | ||
5167 | BcmFlash2xBulkRead(Adapter, | ||
5168 | &uiDSDsig, | ||
5169 | dsd, | ||
5170 | Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(PDSD_HEADER,DSDImageMagicNumber), | ||
5171 | SIGNATURE_SIZE); | ||
5172 | |||
5173 | uiDSDsig = ntohl(uiDSDsig); | ||
5174 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"DSD SIG :%x", uiDSDsig); | ||
5175 | |||
5176 | return uiDSDsig ; | ||
5177 | } | ||
5178 | INT ReadDSDPriority(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL dsd) | ||
5179 | { | ||
5180 | //UINT priOffsetInMap = 0 ; | ||
5181 | INT uiDSDPri = STATUS_FAILURE; | ||
5182 | //DSD_HEADER dsdHeader = {0}; | ||
5183 | //priOffsetInMap = (PUCHAR)&(dsdHeader.DSDImagePriority) -(PUCHAR)&dsdHeader; | ||
5184 | if(IsSectionWritable(Adapter,dsd)) | ||
5185 | { | ||
5186 | if(ReadDSDSignature(Adapter,dsd)== DSD_IMAGE_MAGIC_NUMBER) | ||
5187 | { | ||
5188 | BcmFlash2xBulkRead(Adapter, | ||
5189 | &uiDSDPri, | ||
5190 | dsd, | ||
5191 | Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader +FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImagePriority), | ||
5192 | 4); | ||
5193 | |||
5194 | uiDSDPri = ntohl(uiDSDPri); | ||
5195 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"DSD<%x> Priority :%x", dsd, uiDSDPri); | ||
5196 | |||
5197 | } | ||
5198 | } | ||
5199 | return uiDSDPri; | ||
5200 | } | ||
5201 | FLASH2X_SECTION_VAL getHighestPriDSD(PMINI_ADAPTER Adapter) | ||
5202 | { | ||
5203 | INT DSDHighestPri = STATUS_FAILURE; | ||
5204 | INT DsdPri= 0 ; | ||
5205 | FLASH2X_SECTION_VAL HighestPriDSD = 0 ; | ||
5206 | |||
5207 | if(IsSectionWritable(Adapter,DSD2)) | ||
5208 | { | ||
5209 | DSDHighestPri = ReadDSDPriority(Adapter,DSD2); | ||
5210 | HighestPriDSD = DSD2 ; | ||
5211 | } | ||
5212 | if(IsSectionWritable(Adapter,DSD1)) | ||
5213 | { | ||
5214 | DsdPri = ReadDSDPriority(Adapter,DSD1); | ||
5215 | if(DSDHighestPri < DsdPri) | ||
5216 | { | ||
5217 | DSDHighestPri = DsdPri ; | ||
5218 | HighestPriDSD = DSD1; | ||
5219 | } | ||
5220 | } | ||
5221 | if(IsSectionWritable(Adapter,DSD0)) | ||
5222 | { | ||
5223 | DsdPri = ReadDSDPriority(Adapter,DSD0); | ||
5224 | if(DSDHighestPri < DsdPri) | ||
5225 | { | ||
5226 | DSDHighestPri = DsdPri ; | ||
5227 | HighestPriDSD = DSD0; | ||
5228 | } | ||
5229 | } | ||
5230 | if(HighestPriDSD) | ||
5231 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Highest DSD :%x , and its Pri :%x", HighestPriDSD, DSDHighestPri); | ||
5232 | return HighestPriDSD ; | ||
5233 | } | ||
5234 | |||
5235 | INT ReadISOSignature(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL iso) | ||
5236 | { | ||
5237 | UINT uiISOsig = 0; | ||
5238 | //UINT sigoffsetInMap = 0; | ||
5239 | //ISO_HEADER ISOHeader = {0}; | ||
5240 | |||
5241 | |||
5242 | //sigoffsetInMap =(PUCHAR)&(ISOHeader.ISOImageMagicNumber) -(PUCHAR)&ISOHeader; | ||
5243 | |||
5244 | if(iso != ISO_IMAGE1 && iso != ISO_IMAGE2) | ||
5245 | { | ||
5246 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"passed section value is not for ISOs"); | ||
5247 | return STATUS_FAILURE; | ||
5248 | } | ||
5249 | BcmFlash2xBulkRead(Adapter, | ||
5250 | &uiISOsig, | ||
5251 | iso, | ||
5252 | 0 + FIELD_OFFSET_IN_HEADER(PISO_HEADER,ISOImageMagicNumber), | ||
5253 | SIGNATURE_SIZE); | ||
5254 | |||
5255 | uiISOsig = ntohl(uiISOsig); | ||
5256 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"ISO SIG :%x", uiISOsig); | ||
5257 | |||
5258 | return uiISOsig ; | ||
5259 | } | ||
5260 | INT ReadISOPriority(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL iso) | ||
5261 | { | ||
5262 | |||
5263 | INT ISOPri = STATUS_FAILURE; | ||
5264 | if(IsSectionWritable(Adapter,iso)) | ||
5265 | { | ||
5266 | if(ReadISOSignature(Adapter,iso)== ISO_IMAGE_MAGIC_NUMBER) | ||
5267 | { | ||
5268 | BcmFlash2xBulkRead(Adapter, | ||
5269 | &ISOPri, | ||
5270 | iso, | ||
5271 | 0 + FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImagePriority), | ||
5272 | 4); | ||
5273 | |||
5274 | ISOPri = ntohl(ISOPri); | ||
5275 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"ISO<%x> Priority :%x", iso, ISOPri); | ||
5276 | |||
5277 | } | ||
5278 | } | ||
5279 | return ISOPri; | ||
5280 | } | ||
5281 | FLASH2X_SECTION_VAL getHighestPriISO(PMINI_ADAPTER Adapter) | ||
5282 | { | ||
5283 | INT ISOHighestPri = STATUS_FAILURE; | ||
5284 | INT ISOPri= 0 ; | ||
5285 | FLASH2X_SECTION_VAL HighestPriISO = NO_SECTION_VAL ; | ||
5286 | |||
5287 | if(IsSectionWritable(Adapter,ISO_IMAGE2)) | ||
5288 | { | ||
5289 | ISOHighestPri = ReadISOPriority(Adapter,ISO_IMAGE2); | ||
5290 | HighestPriISO = ISO_IMAGE2 ; | ||
5291 | } | ||
5292 | if(IsSectionWritable(Adapter,ISO_IMAGE1)) | ||
5293 | { | ||
5294 | ISOPri = ReadISOPriority(Adapter,ISO_IMAGE1); | ||
5295 | if(ISOHighestPri < ISOPri) | ||
5296 | { | ||
5297 | ISOHighestPri = ISOPri ; | ||
5298 | HighestPriISO = ISO_IMAGE1; | ||
5299 | } | ||
5300 | } | ||
5301 | if(HighestPriISO) | ||
5302 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Highest ISO :%x and its Pri :%x",HighestPriISO,ISOHighestPri); | ||
5303 | return HighestPriISO ; | ||
5304 | } | ||
5305 | INT WriteToFlashWithoutSectorErase(PMINI_ADAPTER Adapter, | ||
5306 | PUINT pBuff, | ||
5307 | FLASH2X_SECTION_VAL eFlash2xSectionVal, | ||
5308 | UINT uiOffset, | ||
5309 | UINT uiNumBytes | ||
5310 | ) | ||
5311 | { | ||
5312 | #if !defined(BCM_SHM_INTERFACE) || defined(FLASH_DIRECT_ACCESS) | ||
5313 | UINT uiTemp = 0, value = 0 ; | ||
5314 | UINT i = 0; | ||
5315 | UINT uiPartOffset = 0; | ||
5316 | #endif | ||
5317 | UINT uiStartOffset = 0; | ||
5318 | //Adding section start address | ||
5319 | INT Status = STATUS_SUCCESS; | ||
5320 | PUCHAR pcBuff = (PUCHAR)pBuff; | ||
5321 | |||
5322 | if(uiNumBytes % Adapter->ulFlashWriteSize) | ||
5323 | { | ||
5324 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Writing without Sector Erase for non-FlashWriteSize number of bytes 0x%x\n", uiNumBytes); | ||
5325 | return STATUS_FAILURE; | ||
5326 | } | ||
5327 | |||
5328 | uiStartOffset = BcmGetSectionValStartOffset(Adapter,eFlash2xSectionVal); | ||
5329 | |||
5330 | if(IsSectionExistInVendorInfo(Adapter,eFlash2xSectionVal)) | ||
5331 | { | ||
5332 | return vendorextnWriteSectionWithoutErase(Adapter, pcBuff, eFlash2xSectionVal, uiOffset, uiNumBytes); | ||
5333 | } | ||
5334 | |||
5335 | uiOffset = uiOffset + uiStartOffset; | ||
5336 | |||
5337 | #if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS) | ||
5338 | Status = bcmflash_raw_writenoerase((uiOffset/FLASH_PART_SIZE),(uiOffset % FLASH_PART_SIZE), pcBuff,uiNumBytes); | ||
5339 | #else | ||
5340 | rdmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp)); | ||
5341 | value = 0; | ||
5342 | wrmalt(Adapter, 0x0f000C80,&value, sizeof(value)); | ||
5343 | |||
5344 | Adapter->SelectedChip = RESET_CHIP_SELECT; | ||
5345 | BcmDoChipSelect(Adapter,uiOffset); | ||
5346 | uiPartOffset = (uiOffset & (FLASH_PART_SIZE - 1)) + GetFlashBaseAddr(Adapter); | ||
5347 | |||
5348 | for(i = 0 ; i< uiNumBytes; i += Adapter->ulFlashWriteSize) | ||
5349 | { | ||
5350 | if(Adapter->ulFlashWriteSize == BYTE_WRITE_SUPPORT) | ||
5351 | Status = flashByteWrite(Adapter,uiPartOffset, pcBuff); | ||
5352 | else | ||
5353 | Status = flashWrite(Adapter,uiPartOffset, pcBuff); | ||
5354 | |||
5355 | if(Status != STATUS_SUCCESS) | ||
5356 | break; | ||
5357 | |||
5358 | pcBuff = pcBuff + Adapter->ulFlashWriteSize; | ||
5359 | uiPartOffset = uiPartOffset + Adapter->ulFlashWriteSize; | ||
5360 | } | ||
5361 | wrmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp)); | ||
5362 | Adapter->SelectedChip = RESET_CHIP_SELECT; | ||
5363 | #endif | ||
5364 | |||
5365 | return Status; | ||
5366 | } | ||
5367 | |||
5368 | #if 0 | ||
5369 | UINT getNumOfSubSectionWithWRPermisson(PMINI_ADAPTER Adapter, SECTION_TYPE secType) | ||
5370 | { | ||
5371 | |||
5372 | UINT numOfWRSubSec = 0; | ||
5373 | switch(secType) | ||
5374 | { | ||
5375 | case ISO : | ||
5376 | if(IsSectionWritable(Adapter,ISO_IMAGE1)) | ||
5377 | numOfWRSubSec = numOfWRSubSec + 1; | ||
5378 | if(IsSectionWritable(Adapter,ISO_IMAGE2)) | ||
5379 | numOfWRSubSec = numOfWRSubSec + 1; | ||
5380 | break; | ||
5381 | |||
5382 | case DSD : | ||
5383 | if(IsSectionWritable(Adapter,DSD2)) | ||
5384 | numOfWRSubSec = numOfWRSubSec + 1; | ||
5385 | if(IsSectionWritable(Adapter,DSD1)) | ||
5386 | numOfWRSubSec = numOfWRSubSec + 1; | ||
5387 | if(IsSectionWritable(Adapter,DSD0)) | ||
5388 | numOfWRSubSec = numOfWRSubSec + 1; | ||
5389 | break ; | ||
5390 | |||
5391 | case VSA : | ||
5392 | //for VSA Add code Here | ||
5393 | default : | ||
5394 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Invalid secton<%d> is passed", secType);\ | ||
5395 | numOfWRSubSec = 0; | ||
5396 | |||
5397 | } | ||
5398 | return numOfWRSubSec; | ||
5399 | } | ||
5400 | #endif | ||
5401 | BOOLEAN IsSectionExistInFlash(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL section) | ||
5402 | { | ||
5403 | |||
5404 | BOOLEAN SectionPresent = FALSE ; | ||
5405 | |||
5406 | switch(section) | ||
5407 | { | ||
5408 | |||
5409 | case ISO_IMAGE1 : | ||
5410 | if((Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start != UNINIT_PTR_IN_CS) && | ||
5411 | (IsNonCDLessDevice(Adapter) == FALSE)) | ||
5412 | SectionPresent = TRUE ; | ||
5413 | break; | ||
5414 | case ISO_IMAGE2 : | ||
5415 | if((Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start != UNINIT_PTR_IN_CS) && | ||
5416 | (IsNonCDLessDevice(Adapter) == FALSE)) | ||
5417 | SectionPresent = TRUE ; | ||
5418 | break; | ||
5419 | case DSD0 : | ||
5420 | if(Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDStart != UNINIT_PTR_IN_CS) | ||
5421 | SectionPresent = TRUE ; | ||
5422 | break; | ||
5423 | case DSD1 : | ||
5424 | if(Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1Start != UNINIT_PTR_IN_CS) | ||
5425 | SectionPresent = TRUE ; | ||
5426 | break; | ||
5427 | case DSD2 : | ||
5428 | if(Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2Start != UNINIT_PTR_IN_CS) | ||
5429 | SectionPresent = TRUE ; | ||
5430 | break; | ||
5431 | case VSA0 : | ||
5432 | if(Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAStart != UNINIT_PTR_IN_CS) | ||
5433 | SectionPresent = TRUE ; | ||
5434 | break; | ||
5435 | case VSA1 : | ||
5436 | if(Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1Start != UNINIT_PTR_IN_CS) | ||
5437 | SectionPresent = TRUE ; | ||
5438 | break; | ||
5439 | case VSA2 : | ||
5440 | if(Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2Start != UNINIT_PTR_IN_CS) | ||
5441 | SectionPresent = TRUE ; | ||
5442 | break; | ||
5443 | case SCSI : | ||
5444 | if(Adapter->psFlash2xCSInfo->OffsetFromZeroForScsiFirmware != UNINIT_PTR_IN_CS) | ||
5445 | SectionPresent = TRUE ; | ||
5446 | break; | ||
5447 | case CONTROL_SECTION : | ||
5448 | if(Adapter->psFlash2xCSInfo->OffsetFromZeroForControlSectionStart != UNINIT_PTR_IN_CS) | ||
5449 | SectionPresent = TRUE ; | ||
5450 | break; | ||
5451 | default : | ||
5452 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Section Does not exist in Flash 2.x"); | ||
5453 | SectionPresent = FALSE; | ||
5454 | } | ||
5455 | return SectionPresent ; | ||
5456 | } | ||
5457 | INT IsSectionWritable(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL Section) | ||
5458 | { | ||
5459 | INT offset = STATUS_FAILURE; | ||
5460 | INT Status = FALSE; | ||
5461 | if(IsSectionExistInFlash(Adapter,Section) == FALSE) | ||
5462 | { | ||
5463 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Section <%d> does not exixt", Section); | ||
5464 | return FALSE; | ||
5465 | } | ||
5466 | offset = BcmGetSectionValStartOffset(Adapter,Section); | ||
5467 | if(offset == INVALID_OFFSET) | ||
5468 | { | ||
5469 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Section<%d> does not exixt", Section); | ||
5470 | return FALSE; | ||
5471 | } | ||
5472 | |||
5473 | if(IsSectionExistInVendorInfo(Adapter,Section)) | ||
5474 | { | ||
5475 | return !(Adapter->psFlash2xVendorInfo->VendorSection[Section].AccessFlags & FLASH2X_SECTION_RO); | ||
5476 | } | ||
5477 | |||
5478 | Status = IsOffsetWritable(Adapter,offset); | ||
5479 | return Status ; | ||
5480 | } | ||
5481 | |||
5482 | INT CorruptDSDSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal) | ||
5483 | { | ||
5484 | |||
5485 | PUCHAR pBuff = 0 ; | ||
5486 | UINT sig = 0; | ||
5487 | UINT uiOffset = 0; | ||
5488 | UINT BlockStatus = 0; | ||
5489 | UINT uiSectAlignAddr = 0; | ||
5490 | |||
5491 | Adapter->bSigCorrupted = FALSE; | ||
5492 | |||
5493 | if(Adapter->bAllDSDWriteAllow == FALSE) | ||
5494 | { | ||
5495 | if(IsSectionWritable(Adapter,eFlash2xSectionVal) != TRUE) | ||
5496 | { | ||
5497 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Section is not Writable...Hence cant Corrupt signature"); | ||
5498 | return SECTOR_IS_NOT_WRITABLE; | ||
5499 | } | ||
5500 | } | ||
5501 | |||
5502 | pBuff = (PUCHAR)kzalloc(MAX_RW_SIZE, GFP_KERNEL); | ||
5503 | if(pBuff == NULL) | ||
5504 | { | ||
5505 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Can't allocate memorey"); | ||
5506 | return -ENOMEM ; | ||
5507 | } | ||
5508 | |||
5509 | uiOffset = Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER); | ||
5510 | uiOffset -= MAX_RW_SIZE ; | ||
5511 | |||
5512 | BcmFlash2xBulkRead(Adapter, (PUINT)pBuff,eFlash2xSectionVal,uiOffset,MAX_RW_SIZE); | ||
5513 | |||
5514 | |||
5515 | sig = *((PUINT)(pBuff +12)); | ||
5516 | sig =ntohl(sig); | ||
5517 | BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,pBuff,MAX_RW_SIZE); | ||
5518 | //Now corrupting the sig by corrupting 4th last Byte. | ||
5519 | *(pBuff + 12) = 0; | ||
5520 | |||
5521 | if(sig == DSD_IMAGE_MAGIC_NUMBER) | ||
5522 | { | ||
5523 | Adapter->bSigCorrupted = TRUE; | ||
5524 | if(Adapter->ulFlashWriteSize == BYTE_WRITE_SUPPORT) | ||
5525 | { | ||
5526 | uiSectAlignAddr = uiOffset & ~(Adapter->uiSectorSize -1); | ||
5527 | BlockStatus = BcmFlashUnProtectBlock(Adapter,uiSectAlignAddr,Adapter->uiSectorSize); | ||
5528 | |||
5529 | WriteToFlashWithoutSectorErase(Adapter,(PUINT)(pBuff + 12),eFlash2xSectionVal, | ||
5530 | (uiOffset + 12),BYTE_WRITE_SUPPORT); | ||
5531 | if(BlockStatus) | ||
5532 | { | ||
5533 | BcmRestoreBlockProtectStatus(Adapter,BlockStatus); | ||
5534 | BlockStatus = 0; | ||
5535 | } | ||
5536 | } | ||
5537 | else | ||
5538 | { | ||
5539 | WriteToFlashWithoutSectorErase(Adapter,(PUINT)pBuff,eFlash2xSectionVal, | ||
5540 | uiOffset ,MAX_RW_SIZE); | ||
5541 | } | ||
5542 | } | ||
5543 | else | ||
5544 | { | ||
5545 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"BCM Signature is not present in header"); | ||
5546 | bcm_kfree(pBuff); | ||
5547 | return STATUS_FAILURE; | ||
5548 | } | ||
5549 | |||
5550 | bcm_kfree(pBuff); | ||
5551 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Corrupted the signature"); | ||
5552 | return STATUS_SUCCESS ; | ||
5553 | } | ||
5554 | |||
5555 | INT CorruptISOSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal) | ||
5556 | { | ||
5557 | |||
5558 | PUCHAR pBuff = 0 ; | ||
5559 | UINT sig = 0; | ||
5560 | UINT uiOffset = 0; | ||
5561 | |||
5562 | Adapter->bSigCorrupted = FALSE; | ||
5563 | |||
5564 | if(IsSectionWritable(Adapter,eFlash2xSectionVal) != TRUE) | ||
5565 | { | ||
5566 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Section is not Writable...Hence cant Corrupt signature"); | ||
5567 | return SECTOR_IS_NOT_WRITABLE; | ||
5568 | } | ||
5569 | |||
5570 | pBuff = (PUCHAR)kzalloc(MAX_RW_SIZE, GFP_KERNEL); | ||
5571 | if(pBuff == NULL) | ||
5572 | { | ||
5573 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Can't allocate memorey"); | ||
5574 | return -ENOMEM ; | ||
5575 | } | ||
5576 | |||
5577 | uiOffset = 0; | ||
5578 | |||
5579 | BcmFlash2xBulkRead(Adapter, (PUINT)pBuff,eFlash2xSectionVal,uiOffset, MAX_RW_SIZE); | ||
5580 | |||
5581 | sig = *((PUINT)pBuff); | ||
5582 | sig =ntohl(sig); | ||
5583 | |||
5584 | //corrupt signature | ||
5585 | *pBuff = 0; | ||
5586 | |||
5587 | if(sig == ISO_IMAGE_MAGIC_NUMBER) | ||
5588 | { | ||
5589 | Adapter->bSigCorrupted = TRUE; | ||
5590 | WriteToFlashWithoutSectorErase(Adapter,(PUINT)pBuff,eFlash2xSectionVal, | ||
5591 | uiOffset ,Adapter->ulFlashWriteSize); | ||
5592 | } | ||
5593 | else | ||
5594 | { | ||
5595 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"BCM Signature is not present in header"); | ||
5596 | bcm_kfree(pBuff); | ||
5597 | return STATUS_FAILURE; | ||
5598 | } | ||
5599 | |||
5600 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Corrupted the signature"); | ||
5601 | BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,pBuff,MAX_RW_SIZE); | ||
5602 | |||
5603 | bcm_kfree(pBuff); | ||
5604 | return STATUS_SUCCESS ; | ||
5605 | } | ||
5606 | |||
5607 | BOOLEAN IsNonCDLessDevice(PMINI_ADAPTER Adapter) | ||
5608 | { | ||
5609 | if(Adapter->psFlash2xCSInfo->IsCDLessDeviceBootSig == NON_CDLESS_DEVICE_BOOT_SIG) | ||
5610 | return TRUE; | ||
5611 | else | ||
5612 | return FALSE ; | ||
5613 | } | ||
5614 | |||
diff --git a/drivers/staging/bcm/nvm.h b/drivers/staging/bcm/nvm.h new file mode 100644 index 00000000000..6ec6ca85b50 --- /dev/null +++ b/drivers/staging/bcm/nvm.h | |||
@@ -0,0 +1,489 @@ | |||
1 | /*************************************************************************************** | ||
2 | // | ||
3 | // Copyright (c) Beceem Communications Inc. | ||
4 | // | ||
5 | // Module Name: | ||
6 | // NVM.h | ||
7 | // | ||
8 | // Abstract: | ||
9 | // This file has the prototypes,preprocessors and definitions various NVM libraries. | ||
10 | // | ||
11 | // | ||
12 | // Revision History: | ||
13 | // Who When What | ||
14 | // -------- -------- ---------------------------------------------- | ||
15 | // Name Date Created/reviewed/modified | ||
16 | // | ||
17 | // Notes: | ||
18 | // | ||
19 | ****************************************************************************************/ | ||
20 | |||
21 | |||
22 | #ifndef _NVM_H_ | ||
23 | #define _NVM_H_ | ||
24 | |||
25 | typedef struct _FLASH_SECTOR_INFO | ||
26 | { | ||
27 | UINT uiSectorSig; | ||
28 | UINT uiSectorSize; | ||
29 | |||
30 | }FLASH_SECTOR_INFO,*PFLASH_SECTOR_INFO; | ||
31 | |||
32 | typedef struct _FLASH_CS_INFO | ||
33 | { | ||
34 | B_UINT32 MagicNumber; | ||
35 | // let the magic number be 0xBECE-F1A5 - F1A5 for "flas-h" | ||
36 | |||
37 | B_UINT32 FlashLayoutVersion ; | ||
38 | |||
39 | // ISO Image/Format/BuildTool versioning | ||
40 | B_UINT32 ISOImageVersion; | ||
41 | |||
42 | // SCSI/Flash BootLoader versioning | ||
43 | B_UINT32 SCSIFirmwareVersion; | ||
44 | |||
45 | |||
46 | B_UINT32 OffsetFromZeroForPart1ISOImage; | ||
47 | // typically 0 | ||
48 | |||
49 | B_UINT32 OffsetFromZeroForScsiFirmware; | ||
50 | //typically at 12MB | ||
51 | |||
52 | B_UINT32 SizeOfScsiFirmware ; | ||
53 | //size of the firmware - depends on binary size | ||
54 | |||
55 | B_UINT32 OffsetFromZeroForPart2ISOImage; | ||
56 | // typically at first Word Aligned offset 12MB + sizeOfScsiFirmware. | ||
57 | |||
58 | B_UINT32 OffsetFromZeroForCalibrationStart; | ||
59 | // typically at 15MB | ||
60 | |||
61 | B_UINT32 OffsetFromZeroForCalibrationEnd; | ||
62 | |||
63 | // VSA0 offsets | ||
64 | B_UINT32 OffsetFromZeroForVSAStart; | ||
65 | B_UINT32 OffsetFromZeroForVSAEnd; | ||
66 | |||
67 | // Control Section offsets | ||
68 | B_UINT32 OffsetFromZeroForControlSectionStart; | ||
69 | B_UINT32 OffsetFromZeroForControlSectionData; | ||
70 | |||
71 | // NO Data Activity timeout to switch from MSC to NW Mode | ||
72 | B_UINT32 CDLessInactivityTimeout; | ||
73 | |||
74 | // New ISO Image Signature | ||
75 | B_UINT32 NewImageSignature; | ||
76 | |||
77 | // Signature to validate the sector size. | ||
78 | B_UINT32 FlashSectorSizeSig; | ||
79 | |||
80 | // Sector Size | ||
81 | B_UINT32 FlashSectorSize; | ||
82 | |||
83 | // Write Size Support | ||
84 | B_UINT32 FlashWriteSupportSize; | ||
85 | |||
86 | // Total Flash Size | ||
87 | B_UINT32 TotalFlashSize; | ||
88 | |||
89 | // Flash Base Address for offset specified | ||
90 | B_UINT32 FlashBaseAddr; | ||
91 | |||
92 | // Flash Part Max Size | ||
93 | B_UINT32 FlashPartMaxSize; | ||
94 | |||
95 | // Is CDLess or Flash Bootloader | ||
96 | B_UINT32 IsCDLessDeviceBootSig; | ||
97 | |||
98 | // MSC Timeout after reset to switch from MSC to NW Mode | ||
99 | B_UINT32 MassStorageTimeout; | ||
100 | |||
101 | |||
102 | }FLASH_CS_INFO,*PFLASH_CS_INFO; | ||
103 | |||
104 | #define FLASH2X_TOTAL_SIZE (64*1024*1024) | ||
105 | #define DEFAULT_SECTOR_SIZE (64*1024) | ||
106 | |||
107 | typedef struct _FLASH_2X_CS_INFO | ||
108 | { | ||
109 | |||
110 | // magic number as 0xBECE-F1A5 - F1A5 for "flas-h" | ||
111 | B_UINT32 MagicNumber; | ||
112 | |||
113 | B_UINT32 FlashLayoutVersion ; | ||
114 | |||
115 | // ISO Image/Format/BuildTool versioning | ||
116 | B_UINT32 ISOImageVersion; | ||
117 | |||
118 | // SCSI/Flash BootLoader versioning | ||
119 | B_UINT32 SCSIFirmwareVersion; | ||
120 | |||
121 | // ISO Image1 Part1/SCSI Firmware/Flash Bootloader Start offset, size | ||
122 | B_UINT32 OffsetFromZeroForPart1ISOImage; | ||
123 | B_UINT32 OffsetFromZeroForScsiFirmware; | ||
124 | B_UINT32 SizeOfScsiFirmware ; | ||
125 | |||
126 | // ISO Image1 Part2 start offset | ||
127 | B_UINT32 OffsetFromZeroForPart2ISOImage; | ||
128 | |||
129 | |||
130 | // DSD0 offset | ||
131 | B_UINT32 OffsetFromZeroForDSDStart; | ||
132 | B_UINT32 OffsetFromZeroForDSDEnd; | ||
133 | |||
134 | // VSA0 offset | ||
135 | B_UINT32 OffsetFromZeroForVSAStart; | ||
136 | B_UINT32 OffsetFromZeroForVSAEnd; | ||
137 | |||
138 | // Control Section offset | ||
139 | B_UINT32 OffsetFromZeroForControlSectionStart; | ||
140 | B_UINT32 OffsetFromZeroForControlSectionData; | ||
141 | |||
142 | // NO Data Activity timeout to switch from MSC to NW Mode | ||
143 | B_UINT32 CDLessInactivityTimeout; | ||
144 | |||
145 | // New ISO Image Signature | ||
146 | B_UINT32 NewImageSignature; | ||
147 | |||
148 | B_UINT32 FlashSectorSizeSig; // Sector Size Signature | ||
149 | B_UINT32 FlashSectorSize; // Sector Size | ||
150 | B_UINT32 FlashWriteSupportSize; // Write Size Support | ||
151 | |||
152 | B_UINT32 TotalFlashSize; // Total Flash Size | ||
153 | |||
154 | // Flash Base Address for offset specified | ||
155 | B_UINT32 FlashBaseAddr; | ||
156 | B_UINT32 FlashPartMaxSize; // Flash Part Max Size | ||
157 | |||
158 | // Is CDLess or Flash Bootloader | ||
159 | B_UINT32 IsCDLessDeviceBootSig; | ||
160 | |||
161 | // MSC Timeout after reset to switch from MSC to NW Mode | ||
162 | B_UINT32 MassStorageTimeout; | ||
163 | |||
164 | /* Flash Map 2.0 Field */ | ||
165 | B_UINT32 OffsetISOImage1Part1Start; // ISO Image1 Part1 offset | ||
166 | B_UINT32 OffsetISOImage1Part1End; | ||
167 | B_UINT32 OffsetISOImage1Part2Start; // ISO Image1 Part2 offset | ||
168 | B_UINT32 OffsetISOImage1Part2End; | ||
169 | B_UINT32 OffsetISOImage1Part3Start; // ISO Image1 Part3 offset | ||
170 | B_UINT32 OffsetISOImage1Part3End; | ||
171 | |||
172 | B_UINT32 OffsetISOImage2Part1Start; // ISO Image2 Part1 offset | ||
173 | B_UINT32 OffsetISOImage2Part1End; | ||
174 | B_UINT32 OffsetISOImage2Part2Start; // ISO Image2 Part2 offset | ||
175 | B_UINT32 OffsetISOImage2Part2End; | ||
176 | B_UINT32 OffsetISOImage2Part3Start; // ISO Image2 Part3 offset | ||
177 | B_UINT32 OffsetISOImage2Part3End; | ||
178 | |||
179 | |||
180 | // DSD Header offset from start of DSD | ||
181 | B_UINT32 OffsetFromDSDStartForDSDHeader; | ||
182 | B_UINT32 OffsetFromZeroForDSD1Start; // DSD 1 offset | ||
183 | B_UINT32 OffsetFromZeroForDSD1End; | ||
184 | B_UINT32 OffsetFromZeroForDSD2Start; // DSD 2 offset | ||
185 | B_UINT32 OffsetFromZeroForDSD2End; | ||
186 | |||
187 | B_UINT32 OffsetFromZeroForVSA1Start; // VSA 1 offset | ||
188 | B_UINT32 OffsetFromZeroForVSA1End; | ||
189 | B_UINT32 OffsetFromZeroForVSA2Start; // VSA 2 offset | ||
190 | B_UINT32 OffsetFromZeroForVSA2End; | ||
191 | |||
192 | /* | ||
193 | * ACCESS_BITS_PER_SECTOR 2 | ||
194 | * ACCESS_RW 0 | ||
195 | * ACCESS_RO 1 | ||
196 | * ACCESS_RESVD 2 | ||
197 | * ACCESS_RESVD 3 | ||
198 | * */ | ||
199 | B_UINT32 SectorAccessBitMap[FLASH2X_TOTAL_SIZE/(DEFAULT_SECTOR_SIZE *16)]; | ||
200 | |||
201 | // All expansions to the control data structure should add here | ||
202 | |||
203 | }FLASH2X_CS_INFO,*PFLASH2X_CS_INFO; | ||
204 | |||
205 | typedef struct _VENDOR_SECTION_INFO | ||
206 | { | ||
207 | B_UINT32 OffsetFromZeroForSectionStart; | ||
208 | B_UINT32 OffsetFromZeroForSectionEnd; | ||
209 | B_UINT32 AccessFlags; | ||
210 | B_UINT32 Reserved[16]; | ||
211 | |||
212 | } VENDOR_SECTION_INFO, *PVENDOR_SECTION_INFO; | ||
213 | |||
214 | typedef struct _FLASH2X_VENDORSPECIFIC_INFO | ||
215 | { | ||
216 | VENDOR_SECTION_INFO VendorSection[TOTAL_SECTIONS]; | ||
217 | B_UINT32 Reserved[16]; | ||
218 | |||
219 | } FLASH2X_VENDORSPECIFIC_INFO, *PFLASH2X_VENDORSPECIFIC_INFO; | ||
220 | |||
221 | typedef struct _DSD_HEADER | ||
222 | { | ||
223 | B_UINT32 DSDImageSize; | ||
224 | B_UINT32 DSDImageCRC; | ||
225 | B_UINT32 DSDImagePriority; | ||
226 | //We should not consider right now. Reading reserve is worthless. | ||
227 | B_UINT32 Reserved[252]; // Resvd for DSD Header | ||
228 | B_UINT32 DSDImageMagicNumber; | ||
229 | |||
230 | }DSD_HEADER, *PDSD_HEADER; | ||
231 | |||
232 | typedef struct _ISO_HEADER | ||
233 | { | ||
234 | B_UINT32 ISOImageMagicNumber; | ||
235 | B_UINT32 ISOImageSize; | ||
236 | B_UINT32 ISOImageCRC; | ||
237 | B_UINT32 ISOImagePriority; | ||
238 | //We should not consider right now. Reading reserve is worthless. | ||
239 | B_UINT32 Reserved[60]; //Resvd for ISO Header extension | ||
240 | |||
241 | }ISO_HEADER, *PISO_HEADER; | ||
242 | |||
243 | #define EEPROM_BEGIN_CIS (0) | ||
244 | #define EEPROM_BEGIN_NON_CIS (0x200) | ||
245 | #define EEPROM_END (0x2000) | ||
246 | |||
247 | #define INIT_PARAMS_SIGNATURE (0x95a7a597) | ||
248 | |||
249 | #define MAX_INIT_PARAMS_LENGTH (2048) | ||
250 | |||
251 | |||
252 | #define MAC_ADDRESS_OFFSET 0x200 | ||
253 | |||
254 | |||
255 | #define INIT_PARAMS_1_SIGNATURE_ADDRESS EEPROM_BEGIN_NON_CIS | ||
256 | #define INIT_PARAMS_1_DATA_ADDRESS (INIT_PARAMS_1_SIGNATURE_ADDRESS+16) | ||
257 | #define INIT_PARAMS_1_MACADDRESS_ADDRESS (MAC_ADDRESS_OFFSET) | ||
258 | #define INIT_PARAMS_1_LENGTH_ADDRESS (INIT_PARAMS_1_SIGNATURE_ADDRESS+4) | ||
259 | |||
260 | #define INIT_PARAMS_2_SIGNATURE_ADDRESS (EEPROM_BEGIN_NON_CIS+2048+16) | ||
261 | #define INIT_PARAMS_2_DATA_ADDRESS (INIT_PARAMS_2_SIGNATURE_ADDRESS+16) | ||
262 | #define INIT_PARAMS_2_MACADDRESS_ADDRESS (INIT_PARAMS_2_SIGNATURE_ADDRESS+8) | ||
263 | #define INIT_PARAMS_2_LENGTH_ADDRESS (INIT_PARAMS_2_SIGNATURE_ADDRESS+4) | ||
264 | |||
265 | #define EEPROM_SPI_DEV_CONFIG_REG 0x0F003000 | ||
266 | #define EEPROM_SPI_Q_STATUS1_REG 0x0F003004 | ||
267 | #define EEPROM_SPI_Q_STATUS1_MASK_REG 0x0F00300C | ||
268 | |||
269 | #define EEPROM_SPI_Q_STATUS_REG 0x0F003008 | ||
270 | #define EEPROM_CMDQ_SPI_REG 0x0F003018 | ||
271 | #define EEPROM_WRITE_DATAQ_REG 0x0F00301C | ||
272 | #define EEPROM_READ_DATAQ_REG 0x0F003020 | ||
273 | #define SPI_FLUSH_REG 0x0F00304C | ||
274 | |||
275 | #define EEPROM_WRITE_ENABLE 0x06000000 | ||
276 | #define EEPROM_READ_STATUS_REGISTER 0x05000000 | ||
277 | #define EEPROM_16_BYTE_PAGE_WRITE 0xFA000000 | ||
278 | #define EEPROM_WRITE_QUEUE_EMPTY 0x00001000 | ||
279 | #define EEPROM_WRITE_QUEUE_AVAIL 0x00002000 | ||
280 | #define EEPROM_WRITE_QUEUE_FULL 0x00004000 | ||
281 | #define EEPROM_16_BYTE_PAGE_READ 0xFB000000 | ||
282 | #define EEPROM_4_BYTE_PAGE_READ 0x3B000000 | ||
283 | |||
284 | #define EEPROM_CMD_QUEUE_FLUSH 0x00000001 | ||
285 | #define EEPROM_WRITE_QUEUE_FLUSH 0x00000002 | ||
286 | #define EEPROM_READ_QUEUE_FLUSH 0x00000004 | ||
287 | #define EEPROM_ETH_QUEUE_FLUSH 0x00000008 | ||
288 | #define EEPROM_ALL_QUEUE_FLUSH 0x0000000f | ||
289 | #define EEPROM_READ_ENABLE 0x06000000 | ||
290 | #define EEPROM_16_BYTE_PAGE_WRITE 0xFA000000 | ||
291 | #define EEPROM_READ_DATA_FULL 0x00000010 | ||
292 | #define EEPROM_READ_DATA_AVAIL 0x00000020 | ||
293 | #define EEPROM_READ_QUEUE_EMPTY 0x00000002 | ||
294 | #define EEPROM_CMD_QUEUE_EMPTY 0x00000100 | ||
295 | #define EEPROM_CMD_QUEUE_AVAIL 0x00000200 | ||
296 | #define EEPROM_CMD_QUEUE_FULL 0x00000400 | ||
297 | |||
298 | /* Most EEPROM status register bit 0 indicates if the EEPROM is busy | ||
299 | * with a write if set 1. See the details of the EEPROM Status Register | ||
300 | * in the EEPROM data sheet. */ | ||
301 | #define EEPROM_STATUS_REG_WRITE_BUSY 0x00000001 | ||
302 | |||
303 | // We will have 1 mSec for every RETRIES_PER_DELAY count and have a max attempts of MAX_EEPROM_RETRIES | ||
304 | // This will give us 80 mSec minimum of delay = 80mSecs | ||
305 | #define MAX_EEPROM_RETRIES 80 | ||
306 | #define RETRIES_PER_DELAY 64 | ||
307 | |||
308 | |||
309 | #define MAX_RW_SIZE 0x10 | ||
310 | #define MAX_READ_SIZE 0x10 | ||
311 | #define MAX_SECTOR_SIZE (512*1024) | ||
312 | #define MIN_SECTOR_SIZE (1024) | ||
313 | #define FLASH_SECTOR_SIZE_OFFSET 0xEFFFC | ||
314 | #define FLASH_SECTOR_SIZE_SIG_OFFSET 0xEFFF8 | ||
315 | #define FLASH_SECTOR_SIZE_SIG 0xCAFEBABE | ||
316 | #define FLASH_CS_INFO_START_ADDR 0xFF0000 | ||
317 | #define FLASH_CONTROL_STRUCT_SIGNATURE 0xBECEF1A5 | ||
318 | #define SCSI_FIRMWARE_MAJOR_VERSION 0x1 | ||
319 | #define SCSI_FIRMWARE_MINOR_VERSION 0x5 | ||
320 | #define BYTE_WRITE_SUPPORT 0x1 | ||
321 | |||
322 | #define FLASH_AUTO_INIT_BASE_ADDR 0xF00000 | ||
323 | |||
324 | |||
325 | |||
326 | #ifdef BCM_SHM_INTERFACE | ||
327 | |||
328 | #define FLASH_ADDR_MASK 0x1F000000 | ||
329 | extern int bcmflash_raw_read(unsigned int flash_id, unsigned int offset, unsigned char *inbuf, unsigned int len); | ||
330 | extern int bcmflash_raw_write(unsigned int flash_id, unsigned int offset, unsigned char *outbuf, unsigned int len); | ||
331 | extern int bcmflash_raw_writenoerase(unsigned int flash_id, unsigned int offset, unsigned char *outbuf, unsigned int len); | ||
332 | |||
333 | |||
334 | #endif | ||
335 | |||
336 | #define FLASH_CONTIGIOUS_START_ADDR_AFTER_INIT 0x1C000000 | ||
337 | #define FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT 0x1F000000 | ||
338 | |||
339 | #define FLASH_CONTIGIOUS_START_ADDR_BCS350 0x08000000 | ||
340 | #define FLASH_CONTIGIOUS_END_ADDR_BCS350 0x08FFFFFF | ||
341 | |||
342 | |||
343 | |||
344 | #define FLASH_SIZE_ADDR 0xFFFFEC | ||
345 | |||
346 | #define FLASH_SPI_CMDQ_REG 0xAF003040 | ||
347 | #define FLASH_SPI_WRITEQ_REG 0xAF003044 | ||
348 | #define FLASH_SPI_READQ_REG 0xAF003048 | ||
349 | #define FLASH_CONFIG_REG 0xAF003050 | ||
350 | #define FLASH_GPIO_CONFIG_REG 0xAF000030 | ||
351 | |||
352 | #define FLASH_CMD_WRITE_ENABLE 0x06 | ||
353 | #define FLASH_CMD_READ_ENABLE 0x03 | ||
354 | #define FLASH_CMD_RESET_WRITE_ENABLE 0x04 | ||
355 | #define FLASH_CMD_STATUS_REG_READ 0x05 | ||
356 | #define FLASH_CMD_STATUS_REG_WRITE 0x01 | ||
357 | #define FLASH_CMD_READ_ID 0x9F | ||
358 | |||
359 | #define PAD_SELECT_REGISTER 0xAF000410 | ||
360 | |||
361 | #define FLASH_PART_SST25VF080B 0xBF258E | ||
362 | |||
363 | #define EEPROM_CAL_DATA_INTERNAL_LOC 0xbFB00008 | ||
364 | |||
365 | #define EEPROM_CALPARAM_START 0x200 | ||
366 | #define EEPROM_SIZE_OFFSET 524 | ||
367 | |||
368 | //As Read/Write time vaires from 1.5 to 3.0 ms. | ||
369 | //so After Ignoring the rdm/wrm time(that is dependent on many factor like interface etc.), | ||
370 | //here time calculated meets the worst case delay, 3.0 ms | ||
371 | #define MAX_FLASH_RETRIES 4 | ||
372 | #define FLASH_PER_RETRIES_DELAY 16 | ||
373 | |||
374 | |||
375 | #define EEPROM_MAX_CAL_AREA_SIZE 0xF0000 | ||
376 | |||
377 | |||
378 | |||
379 | #define BECM ntohl(0x4245434d) | ||
380 | |||
381 | #define FLASH_2X_MAJOR_NUMBER 0x2 | ||
382 | #define DSD_IMAGE_MAGIC_NUMBER 0xBECE0D5D | ||
383 | #define ISO_IMAGE_MAGIC_NUMBER 0xBECE0150 | ||
384 | #define NON_CDLESS_DEVICE_BOOT_SIG 0xBECEB007 | ||
385 | #define MINOR_VERSION(x) ((x >>16) & 0xFFFF) | ||
386 | #define MAJOR_VERSION(x) (x & 0xFFFF) | ||
387 | #define CORRUPTED_PATTERN 0x0 | ||
388 | #define UNINIT_PTR_IN_CS 0xBBBBDDDD | ||
389 | |||
390 | #define VENDOR_PTR_IN_CS 0xAAAACCCC | ||
391 | |||
392 | |||
393 | #define FLASH2X_SECTION_PRESENT 1<<0 | ||
394 | #define FLASH2X_SECTION_VALID 1<<1 | ||
395 | #define FLASH2X_SECTION_RO 1<<2 | ||
396 | #define FLASH2X_SECTION_ACT 1<<3 | ||
397 | #define SECTOR_IS_NOT_WRITABLE STATUS_FAILURE | ||
398 | #define INVALID_OFFSET STATUS_FAILURE | ||
399 | #define INVALID_SECTION STATUS_FAILURE | ||
400 | #define SECTOR_1K 1024 | ||
401 | #define SECTOR_64K (64 *SECTOR_1K) | ||
402 | #define SECTOR_128K (2 * SECTOR_64K) | ||
403 | #define SECTOR_256k (2 * SECTOR_128K) | ||
404 | #define SECTOR_512K (2 * SECTOR_256k) | ||
405 | #define FLASH_PART_SIZE (16 * 1024 * 1024) | ||
406 | #define RESET_CHIP_SELECT -1 | ||
407 | #define CHIP_SELECT_BIT12 12 | ||
408 | |||
409 | #define SECTOR_READWRITE_PERMISSION 0 | ||
410 | #define SECTOR_READONLY 1 | ||
411 | #define SIGNATURE_SIZE 4 | ||
412 | #define DEFAULT_BUFF_SIZE 0x10000 | ||
413 | |||
414 | |||
415 | #define FIELD_OFFSET_IN_HEADER(HeaderPointer,Field) ((PUCHAR)&((HeaderPointer)(NULL))->Field - (PUCHAR)(NULL)) | ||
416 | |||
417 | #if 0 | ||
418 | INT BeceemEEPROMBulkRead( | ||
419 | PMINI_ADAPTER Adapter, | ||
420 | PUINT pBuffer, | ||
421 | UINT uiOffset, | ||
422 | UINT uiNumBytes); | ||
423 | |||
424 | |||
425 | INT BeceemFlashBulkRead( | ||
426 | PMINI_ADAPTER Adapter, | ||
427 | PUINT pBuffer, | ||
428 | UINT uiOffset, | ||
429 | UINT uiNumBytes); | ||
430 | |||
431 | UINT BcmGetEEPROMSize(PMINI_ADAPTER Adapter); | ||
432 | |||
433 | UINT BcmGetFlashSize(PMINI_ADAPTER Adapter); | ||
434 | |||
435 | UINT BcmGetFlashSectorSize(PMINI_ADAPTER Adapter); | ||
436 | |||
437 | |||
438 | |||
439 | INT BeceemFlashBulkWrite( | ||
440 | PMINI_ADAPTER Adapter, | ||
441 | PUINT pBuffer, | ||
442 | UINT uiOffset, | ||
443 | UINT uiNumBytes, | ||
444 | BOOLEAN bVerify); | ||
445 | |||
446 | INT PropagateCalParamsFromFlashToMemory(PMINI_ADAPTER Adapter); | ||
447 | |||
448 | INT PropagateCalParamsFromEEPROMToMemory(PMINI_ADAPTER Adapter); | ||
449 | |||
450 | |||
451 | INT BeceemEEPROMBulkWrite( | ||
452 | PMINI_ADAPTER Adapter, | ||
453 | PUCHAR pBuffer, | ||
454 | UINT uiOffset, | ||
455 | UINT uiNumBytes, | ||
456 | BOOLEAN bVerify); | ||
457 | |||
458 | |||
459 | INT ReadBeceemEEPROM(PMINI_ADAPTER Adapter,UINT dwAddress, UINT *pdwData); | ||
460 | |||
461 | NVM_TYPE BcmGetNvmType(PMINI_ADAPTER Adapter); | ||
462 | |||
463 | INT BeceemNVMRead( | ||
464 | PMINI_ADAPTER Adapter, | ||
465 | PUINT pBuffer, | ||
466 | UINT uiOffset, | ||
467 | UINT uiNumBytes); | ||
468 | |||
469 | INT BeceemNVMWrite( | ||
470 | PMINI_ADAPTER Adapter, | ||
471 | PUINT pBuffer, | ||
472 | UINT uiOffset, | ||
473 | UINT uiNumBytes, | ||
474 | BOOLEAN bVerify); | ||
475 | |||
476 | INT ReadMacAddressFromEEPROM(PMINI_ADAPTER Adapter); | ||
477 | |||
478 | INT BcmUpdateSectorSize(PMINI_ADAPTER Adapter,UINT uiSectorSize); | ||
479 | |||
480 | INT BcmInitNVM(PMINI_ADAPTER Adapter); | ||
481 | |||
482 | VOID BcmValidateNvmType(PMINI_ADAPTER Adapter); | ||
483 | |||
484 | VOID BcmGetFlashCSInfo(PMINI_ADAPTER Adapter); | ||
485 | |||
486 | #endif | ||
487 | |||
488 | #endif | ||
489 | |||
diff --git a/drivers/staging/bcm/osal_misc.h b/drivers/staging/bcm/osal_misc.h new file mode 100644 index 00000000000..ff4adde17cd --- /dev/null +++ b/drivers/staging/bcm/osal_misc.h | |||
@@ -0,0 +1,49 @@ | |||
1 | /*++ | ||
2 | |||
3 | Copyright (c) Beceem Communications Inc. | ||
4 | |||
5 | Module Name: | ||
6 | OSAL_Misc.h | ||
7 | |||
8 | Abstract: | ||
9 | Provides the OS Abstracted macros to access: | ||
10 | Linked Lists | ||
11 | Dispatcher Objects(Events,Semaphores,Spin Locks and the like) | ||
12 | Files | ||
13 | |||
14 | |||
15 | Revision History: | ||
16 | Who When What | ||
17 | -------- -------- ---------------------------------------------- | ||
18 | Name Date Created/reviewed/modified | ||
19 | Rajeev 24/1/08 Created | ||
20 | Notes: | ||
21 | |||
22 | --*/ | ||
23 | #ifndef _OSAL_MISC_H_ | ||
24 | #define _OSAL_MISC_H_ | ||
25 | //OSAL Macros | ||
26 | //OSAL Primitives | ||
27 | typedef PUCHAR POSAL_NW_PACKET ; //Nw packets | ||
28 | |||
29 | |||
30 | #define OsalMemAlloc(n,t) kmalloc(n,GFP_KERNEL) | ||
31 | |||
32 | #define OsalMemFree(x,n) bcm_kfree(x) | ||
33 | |||
34 | #define OsalMemMove(dest, src, len) \ | ||
35 | { \ | ||
36 | memcpy(dest,src, len); \ | ||
37 | } | ||
38 | |||
39 | #define OsalZeroMemory(pDest, Len) \ | ||
40 | { \ | ||
41 | memset(pDest,0,Len); \ | ||
42 | } | ||
43 | |||
44 | //#define OsalMemSet(pSrc,Char,Len) memset(pSrc,Char,Len) | ||
45 | |||
46 | bool OsalMemCompare(void *dest, void *src, UINT len); | ||
47 | |||
48 | #endif | ||
49 | |||
diff --git a/drivers/staging/bcm/sort.c b/drivers/staging/bcm/sort.c new file mode 100644 index 00000000000..fc5d07aec3d --- /dev/null +++ b/drivers/staging/bcm/sort.c | |||
@@ -0,0 +1,63 @@ | |||
1 | #include "headers.h" | ||
2 | |||
3 | /* | ||
4 | * File Name: sort.c | ||
5 | * | ||
6 | * Author: Beceem Communications Pvt. Ltd | ||
7 | * | ||
8 | * Abstract: This file contains the routines sorting the classification rules. | ||
9 | * | ||
10 | * Copyright (c) 2007 Beceem Communications Pvt. Ltd | ||
11 | */ | ||
12 | |||
13 | VOID SortPackInfo(PMINI_ADAPTER Adapter) | ||
14 | { | ||
15 | UINT nIndex1; | ||
16 | UINT nIndex2; | ||
17 | |||
18 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "<======="); | ||
19 | |||
20 | for(nIndex1 = 0; nIndex1 < NO_OF_QUEUES -2 ; nIndex1++) | ||
21 | { | ||
22 | for(nIndex2 = nIndex1 + 1 ; nIndex2 < NO_OF_QUEUES -1 ; nIndex2++) | ||
23 | { | ||
24 | if(Adapter->PackInfo[nIndex1].bValid && Adapter->PackInfo[nIndex2].bValid) | ||
25 | { | ||
26 | if(Adapter->PackInfo[nIndex2].u8TrafficPriority < | ||
27 | Adapter->PackInfo[nIndex1].u8TrafficPriority) | ||
28 | { | ||
29 | PacketInfo stTemppackInfo = Adapter->PackInfo[nIndex2]; | ||
30 | Adapter->PackInfo[nIndex2] = Adapter->PackInfo[nIndex1]; | ||
31 | Adapter->PackInfo[nIndex1] = stTemppackInfo; | ||
32 | |||
33 | } | ||
34 | } | ||
35 | } | ||
36 | } | ||
37 | } | ||
38 | |||
39 | VOID SortClassifiers(PMINI_ADAPTER Adapter) | ||
40 | { | ||
41 | UINT nIndex1; | ||
42 | UINT nIndex2; | ||
43 | |||
44 | BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "<======="); | ||
45 | |||
46 | for(nIndex1 = 0; nIndex1 < MAX_CLASSIFIERS -1 ; nIndex1++) | ||
47 | { | ||
48 | for(nIndex2 = nIndex1 + 1 ; nIndex2 < MAX_CLASSIFIERS ; nIndex2++) | ||
49 | { | ||
50 | if(Adapter->astClassifierTable[nIndex1].bUsed && Adapter->astClassifierTable[nIndex2].bUsed) | ||
51 | { | ||
52 | if(Adapter->astClassifierTable[nIndex2].u8ClassifierRulePriority < | ||
53 | Adapter->astClassifierTable[nIndex1].u8ClassifierRulePriority) | ||
54 | { | ||
55 | S_CLASSIFIER_RULE stTempClassifierRule = Adapter->astClassifierTable[nIndex2]; | ||
56 | Adapter->astClassifierTable[nIndex2] = Adapter->astClassifierTable[nIndex1]; | ||
57 | Adapter->astClassifierTable[nIndex1] = stTempClassifierRule; | ||
58 | |||
59 | } | ||
60 | } | ||
61 | } | ||
62 | } | ||
63 | } | ||
diff --git a/drivers/staging/bcm/target_params.h b/drivers/staging/bcm/target_params.h new file mode 100644 index 00000000000..2d8b8a367b3 --- /dev/null +++ b/drivers/staging/bcm/target_params.h | |||
@@ -0,0 +1,81 @@ | |||
1 | #ifndef TARGET_PARAMS_H | ||
2 | #define TARGET_PARAMS_H | ||
3 | |||
4 | typedef struct _TARGET_PARAMS | ||
5 | { | ||
6 | B_UINT32 m_u32CfgVersion; | ||
7 | |||
8 | // Scanning Related Params | ||
9 | B_UINT32 m_u32CenterFrequency; | ||
10 | B_UINT32 m_u32BandAScan; | ||
11 | B_UINT32 m_u32BandBScan; | ||
12 | B_UINT32 m_u32BandCScan; | ||
13 | |||
14 | |||
15 | // QoS Params | ||
16 | B_UINT32 m_u32ErtpsOptions; | ||
17 | |||
18 | B_UINT32 m_u32PHSEnable; | ||
19 | |||
20 | |||
21 | // HO Params | ||
22 | B_UINT32 m_u32HoEnable; | ||
23 | |||
24 | B_UINT32 m_u32HoReserved1; | ||
25 | B_UINT32 m_u32HoReserved2; | ||
26 | // Power Control Params | ||
27 | |||
28 | B_UINT32 m_u32MimoEnable; | ||
29 | |||
30 | B_UINT32 m_u32SecurityEnable; | ||
31 | |||
32 | B_UINT32 m_u32PowerSavingModesEnable; //bit 1: 1 Idlemode enable; bit2: 1 Sleepmode Enable | ||
33 | /* PowerSaving Mode Options: | ||
34 | bit 0 = 1: CPE mode - to keep pcmcia if alive; | ||
35 | bit 1 = 1: CINR reporing in Idlemode Msg | ||
36 | bit 2 = 1: Default PSC Enable in sleepmode*/ | ||
37 | B_UINT32 m_u32PowerSavingModeOptions; | ||
38 | |||
39 | B_UINT32 m_u32ArqEnable; | ||
40 | |||
41 | // From Version #3, the HARQ section renamed as general | ||
42 | B_UINT32 m_u32HarqEnable; | ||
43 | // EEPROM Param Location | ||
44 | B_UINT32 m_u32EEPROMFlag; | ||
45 | // BINARY TYPE - 4th MSByte: Interface Type - 3rd MSByte: Vendor Type - 2nd MSByte | ||
46 | // Unused - LSByte | ||
47 | B_UINT32 m_u32Customize; | ||
48 | B_UINT32 m_u32ConfigBW; /* In Hz */ | ||
49 | B_UINT32 m_u32ShutDownInitThresholdTimer; | ||
50 | |||
51 | B_UINT32 m_u32RadioParameter; | ||
52 | B_UINT32 m_u32PhyParameter1; | ||
53 | B_UINT32 m_u32PhyParameter2; | ||
54 | B_UINT32 m_u32PhyParameter3; | ||
55 | |||
56 | B_UINT32 m_u32TestOptions; // in eval mode only; lower 16bits = basic cid for testing; then bit 16 is test cqich,bit 17 test init rang; bit 18 test periodic rang and bit 19 is test harq ack/nack | ||
57 | |||
58 | B_UINT32 m_u32MaxMACDataperDLFrame; | ||
59 | B_UINT32 m_u32MaxMACDataperULFrame; | ||
60 | |||
61 | B_UINT32 m_u32Corr2MacFlags; | ||
62 | |||
63 | //adding driver params. | ||
64 | B_UINT32 HostDrvrConfig1; | ||
65 | B_UINT32 HostDrvrConfig2; | ||
66 | B_UINT32 HostDrvrConfig3; | ||
67 | B_UINT32 HostDrvrConfig4; | ||
68 | B_UINT32 HostDrvrConfig5; | ||
69 | B_UINT32 HostDrvrConfig6; | ||
70 | B_UINT32 m_u32SegmentedPUSCenable; | ||
71 | |||
72 | // removed SHUT down related 'unused' params from here to sync 4.x and 5.x CFG files.. | ||
73 | |||
74 | //BAMC Related Parameters | ||
75 | //Bit 0-15 Band AMC signaling configuration: Bit 1 = 1 – Enable Band AMC signaling. | ||
76 | //bit 16-31 Band AMC Data configuration: Bit 16 = 1 – Band AMC 2x3 support. | ||
77 | B_UINT32 m_u32BandAMCEnable; | ||
78 | |||
79 | } stTargetParams,TARGET_PARAMS,*PTARGET_PARAMS, STARGETPARAMS, *PSTARGETPARAMS; | ||
80 | |||
81 | #endif | ||
diff --git a/drivers/staging/bcm/vendorspecificextn.c b/drivers/staging/bcm/vendorspecificextn.c new file mode 100644 index 00000000000..4178cd161da --- /dev/null +++ b/drivers/staging/bcm/vendorspecificextn.c | |||
@@ -0,0 +1,146 @@ | |||
1 | #include "headers.h" | ||
2 | //----------------------------------------------------------------------------- | ||
3 | // Procedure: vendorextnGetSectionInfo | ||
4 | // | ||
5 | // Description: Finds the type of NVM used. | ||
6 | // | ||
7 | // Arguments: | ||
8 | // Adapter - ptr to Adapter object instance | ||
9 | // pNVMType - ptr to NVM type. | ||
10 | // Returns: | ||
11 | // STATUS_SUCCESS/STATUS_FAILURE | ||
12 | // | ||
13 | //----------------------------------------------------------------------------- | ||
14 | INT vendorextnGetSectionInfo(PVOID pContext,PFLASH2X_VENDORSPECIFIC_INFO pVendorInfo) | ||
15 | { | ||
16 | return STATUS_FAILURE; | ||
17 | } | ||
18 | |||
19 | //----------------------------------------------------------------------------- | ||
20 | // Procedure: vendorextnInit | ||
21 | // | ||
22 | // Description: Initializing the vendor extension NVM interface | ||
23 | // | ||
24 | // Arguments: | ||
25 | // Adapter - Pointer to MINI Adapter Structure. | ||
26 | |||
27 | // Returns: | ||
28 | // STATUS_SUCCESS/STATUS_FAILURE | ||
29 | // | ||
30 | //----------------------------------------------------------------------------- | ||
31 | INT vendorextnInit(PMINI_ADAPTER Adapter) | ||
32 | { | ||
33 | return STATUS_SUCCESS; | ||
34 | } | ||
35 | |||
36 | //----------------------------------------------------------------------------- | ||
37 | // Procedure: vendorextnExit | ||
38 | // | ||
39 | // Description: Free the resource associated with vendor extension NVM interface | ||
40 | // | ||
41 | // Arguments: | ||
42 | // Adapter - Pointer to MINI Adapter Structure. | ||
43 | |||
44 | // Returns: | ||
45 | // STATUS_SUCCESS/STATUS_FAILURE | ||
46 | // | ||
47 | //----------------------------------------------------------------------------- | ||
48 | INT vendorextnExit(PMINI_ADAPTER Adapter) | ||
49 | { | ||
50 | return STATUS_SUCCESS; | ||
51 | } | ||
52 | |||
53 | //------------------------------------------------------------------------ | ||
54 | // Procedure: vendorextnIoctl | ||
55 | // | ||
56 | // Description: execute the vendor extension specific ioctl | ||
57 | // | ||
58 | //Arguments: | ||
59 | // Adapter -Beceem private Adapter Structure | ||
60 | // cmd -vendor extension specific Ioctl commad | ||
61 | // arg -input parameter sent by vendor | ||
62 | // | ||
63 | // Returns: | ||
64 | // CONTINUE_COMMON_PATH in case it is not meant to be processed by vendor ioctls | ||
65 | // STATUS_SUCCESS/STATUS_FAILURE as per the IOCTL return value | ||
66 | // | ||
67 | //-------------------------------------------------------------------------- | ||
68 | INT vendorextnIoctl(PMINI_ADAPTER Adapter, UINT cmd, ULONG arg) | ||
69 | { | ||
70 | return CONTINUE_COMMON_PATH; | ||
71 | } | ||
72 | |||
73 | |||
74 | |||
75 | //------------------------------------------------------------------ | ||
76 | // Procedure: vendorextnReadSection | ||
77 | // | ||
78 | // Description: Reads from a section of NVM | ||
79 | // | ||
80 | // Arguments: | ||
81 | // pContext - ptr to Adapter object instance | ||
82 | // pBuffer - Read the data from Vendor Area to this buffer | ||
83 | // SectionVal - Value of type of Section | ||
84 | // Offset - Read from the Offset of the Vendor Section. | ||
85 | // numOfBytes - Read numOfBytes from the Vendor section to Buffer | ||
86 | // | ||
87 | // Returns: | ||
88 | // STATUS_SUCCESS/STATUS_FAILURE | ||
89 | // | ||
90 | //------------------------------------------------------------------ | ||
91 | |||
92 | INT vendorextnReadSection(PVOID pContext, PUCHAR pBuffer, FLASH2X_SECTION_VAL SectionVal, | ||
93 | UINT offset, UINT numOfBytes) | ||
94 | { | ||
95 | return STATUS_FAILURE; | ||
96 | } | ||
97 | |||
98 | |||
99 | |||
100 | //------------------------------------------------------------------ | ||
101 | // Procedure: vendorextnWriteSection | ||
102 | // | ||
103 | // Description: Write to a Section of NVM | ||
104 | // | ||
105 | // Arguments: | ||
106 | // pContext - ptr to Adapter object instance | ||
107 | // pBuffer - Write the data provided in the buffer | ||
108 | // SectionVal - Value of type of Section | ||
109 | // Offset - Writes to the Offset of the Vendor Section. | ||
110 | // numOfBytes - Write num Bytes after reading from pBuffer. | ||
111 | // bVerify - the Buffer Written should be verified. | ||
112 | // | ||
113 | // Returns: | ||
114 | // STATUS_SUCCESS/STATUS_FAILURE | ||
115 | // | ||
116 | //------------------------------------------------------------------ | ||
117 | INT vendorextnWriteSection(PVOID pContext, PUCHAR pBuffer, FLASH2X_SECTION_VAL SectionVal, | ||
118 | UINT offset, UINT numOfBytes, BOOLEAN bVerify) | ||
119 | { | ||
120 | return STATUS_FAILURE; | ||
121 | } | ||
122 | |||
123 | |||
124 | |||
125 | //------------------------------------------------------------------ | ||
126 | // Procedure: vendorextnWriteSectionWithoutErase | ||
127 | // | ||
128 | // Description: Write to a Section of NVM without erasing the sector | ||
129 | // | ||
130 | // Arguments: | ||
131 | // pContext - ptr to Adapter object instance | ||
132 | // pBuffer - Write the data provided in the buffer | ||
133 | // SectionVal - Value of type of Section | ||
134 | // Offset - Writes to the Offset of the Vendor Section. | ||
135 | // numOfBytes - Write num Bytes after reading from pBuffer. | ||
136 | // | ||
137 | // Returns: | ||
138 | // STATUS_SUCCESS/STATUS_FAILURE | ||
139 | // | ||
140 | //------------------------------------------------------------------ | ||
141 | INT vendorextnWriteSectionWithoutErase(PVOID pContext, PUCHAR pBuffer, FLASH2X_SECTION_VAL SectionVal, | ||
142 | UINT offset, UINT numOfBytes) | ||
143 | { | ||
144 | return STATUS_FAILURE; | ||
145 | } | ||
146 | |||
diff --git a/drivers/staging/bcm/vendorspecificextn.h b/drivers/staging/bcm/vendorspecificextn.h new file mode 100644 index 00000000000..7ff14951f0c --- /dev/null +++ b/drivers/staging/bcm/vendorspecificextn.h | |||
@@ -0,0 +1,18 @@ | |||
1 | |||
2 | #ifndef __VENDOR_EXTN_NVM_H__ | ||
3 | #define __VENDOR_EXTN_NVM_H__ | ||
4 | |||
5 | #define CONTINUE_COMMON_PATH 0xFFFF | ||
6 | |||
7 | INT vendorextnGetSectionInfo(PVOID pContext,PFLASH2X_VENDORSPECIFIC_INFO pVendorInfo); | ||
8 | INT vendorextnExit(PMINI_ADAPTER Adapter); | ||
9 | INT vendorextnInit(PMINI_ADAPTER Adapter); | ||
10 | INT vendorextnIoctl(PMINI_ADAPTER Adapter, UINT cmd, ULONG arg); | ||
11 | INT vendorextnReadSection(PVOID pContext, PUCHAR pBuffer, FLASH2X_SECTION_VAL SectionVal, | ||
12 | UINT offset, UINT numOfBytes); | ||
13 | INT vendorextnWriteSection(PVOID pContext, PUCHAR pBuffer, FLASH2X_SECTION_VAL SectionVal, | ||
14 | UINT offset, UINT numOfBytes, BOOLEAN bVerify); | ||
15 | INT vendorextnWriteSectionWithoutErase(PVOID pContext, PUCHAR pBuffer, FLASH2X_SECTION_VAL SectionVal, | ||
16 | UINT offset, UINT numOfBytes); | ||
17 | |||
18 | #endif /* */ | ||