x86/xen: resume timer irqs early
[linux/fpc-iii.git] / drivers / staging / bcm / Adapter.h
blob1d8bf08b5bfd4e946a892ddc358dfd18387e2aab
1 /***********************************
2 * Adapter.h
3 ************************************/
4 #ifndef __ADAPTER_H__
5 #define __ADAPTER_H__
7 #define MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES 256
8 #include "Debug.h"
10 struct bcm_leader {
11 USHORT Vcid;
12 USHORT PLength;
13 UCHAR Status;
14 UCHAR Unused[3];
15 } __packed;
17 struct bcm_packettosend {
18 struct bcm_leader Leader;
19 UCHAR ucPayload;
20 } __packed;
22 struct bcm_control_packet {
23 PVOID ControlBuff;
24 UINT ControlBuffLen;
25 struct bcm_control_packet *next;
26 } __packed;
28 struct bcm_link_request {
29 struct bcm_leader Leader;
30 UCHAR szData[4];
31 } __packed;
33 #define MAX_IP_RANGE_LENGTH 4
34 #define MAX_PORT_RANGE 4
35 #define MAX_PROTOCOL_LENGTH 32
36 #define IPV6_ADDRESS_SIZEINBYTES 0x10
38 typedef union _U_IP_ADDRESS {
39 struct {
40 ULONG ulIpv4Addr[MAX_IP_RANGE_LENGTH]; /* Source Ip Address Range */
41 ULONG ulIpv4Mask[MAX_IP_RANGE_LENGTH]; /* Source Ip Mask Address Range */
43 struct {
44 ULONG ulIpv6Addr[MAX_IP_RANGE_LENGTH * 4]; /* Source Ip Address Range */
45 ULONG ulIpv6Mask[MAX_IP_RANGE_LENGTH * 4]; /* Source Ip Mask Address Range */
47 struct {
48 UCHAR ucIpv4Address[MAX_IP_RANGE_LENGTH * IP_LENGTH_OF_ADDRESS];
49 UCHAR ucIpv4Mask[MAX_IP_RANGE_LENGTH * IP_LENGTH_OF_ADDRESS];
51 struct {
52 UCHAR ucIpv6Address[MAX_IP_RANGE_LENGTH * IPV6_ADDRESS_SIZEINBYTES];
53 UCHAR ucIpv6Mask[MAX_IP_RANGE_LENGTH * IPV6_ADDRESS_SIZEINBYTES];
55 } U_IP_ADDRESS;
57 struct bcm_hdr_suppression_contextinfo {
58 UCHAR ucaHdrSuppressionInBuf[MAX_PHS_LENGTHS]; /* Intermediate buffer to accumulate pkt Header for PHS */
59 UCHAR ucaHdrSuppressionOutBuf[MAX_PHS_LENGTHS + PHSI_LEN]; /* Intermediate buffer containing pkt Header after PHS */
62 struct bcm_classifier_rule {
63 ULONG ulSFID;
64 UCHAR ucReserved[2];
65 B_UINT16 uiClassifierRuleIndex;
66 BOOLEAN bUsed;
67 USHORT usVCID_Value;
68 B_UINT8 u8ClassifierRulePriority; /* This field detemines the Classifier Priority */
69 U_IP_ADDRESS stSrcIpAddress;
70 UCHAR ucIPSourceAddressLength; /* Ip Source Address Length */
72 U_IP_ADDRESS stDestIpAddress;
73 UCHAR ucIPDestinationAddressLength; /* Ip Destination Address Length */
74 UCHAR ucIPTypeOfServiceLength; /* Type of service Length */
75 UCHAR ucTosLow; /* Tos Low */
76 UCHAR ucTosHigh; /* Tos High */
77 UCHAR ucTosMask; /* Tos Mask */
79 UCHAR ucProtocolLength; /* protocol Length */
80 UCHAR ucProtocol[MAX_PROTOCOL_LENGTH]; /* protocol Length */
81 USHORT usSrcPortRangeLo[MAX_PORT_RANGE];
82 USHORT usSrcPortRangeHi[MAX_PORT_RANGE];
83 UCHAR ucSrcPortRangeLength;
85 USHORT usDestPortRangeLo[MAX_PORT_RANGE];
86 USHORT usDestPortRangeHi[MAX_PORT_RANGE];
87 UCHAR ucDestPortRangeLength;
89 BOOLEAN bProtocolValid;
90 BOOLEAN bTOSValid;
91 BOOLEAN bDestIpValid;
92 BOOLEAN bSrcIpValid;
94 /* For IPv6 Addressing */
95 UCHAR ucDirection;
96 BOOLEAN bIpv6Protocol;
97 UINT32 u32PHSRuleID;
98 struct bcm_phs_rule sPhsRule;
99 UCHAR u8AssociatedPHSI;
101 /* Classification fields for ETH CS */
102 UCHAR ucEthCSSrcMACLen;
103 UCHAR au8EThCSSrcMAC[MAC_ADDRESS_SIZE];
104 UCHAR au8EThCSSrcMACMask[MAC_ADDRESS_SIZE];
105 UCHAR ucEthCSDestMACLen;
106 UCHAR au8EThCSDestMAC[MAC_ADDRESS_SIZE];
107 UCHAR au8EThCSDestMACMask[MAC_ADDRESS_SIZE];
108 UCHAR ucEtherTypeLen;
109 UCHAR au8EthCSEtherType[NUM_ETHERTYPE_BYTES];
110 UCHAR usUserPriority[2];
111 USHORT usVLANID;
112 USHORT usValidityBitMap;
115 struct bcm_fragmented_packet_info {
116 BOOLEAN bUsed;
117 ULONG ulSrcIpAddress;
118 USHORT usIpIdentification;
119 struct bcm_classifier_rule *pstMatchedClassifierEntry;
120 BOOLEAN bOutOfOrderFragment;
123 struct bcm_packet_info {
124 /* classification extension Rule */
125 ULONG ulSFID;
126 USHORT usVCID_Value;
127 UINT uiThreshold;
128 /* This field determines the priority of the SF Queues */
129 B_UINT8 u8TrafficPriority;
131 BOOLEAN bValid;
132 BOOLEAN bActive;
133 BOOLEAN bActivateRequestSent;
135 B_UINT8 u8QueueType; /* BE or rtPS */
137 UINT uiMaxBucketSize; /* maximum size of the bucket for the queue */
138 UINT uiCurrentQueueDepthOnTarget;
139 UINT uiCurrentBytesOnHost;
140 UINT uiCurrentPacketsOnHost;
141 UINT uiDroppedCountBytes;
142 UINT uiDroppedCountPackets;
143 UINT uiSentBytes;
144 UINT uiSentPackets;
145 UINT uiCurrentDrainRate;
146 UINT uiThisPeriodSentBytes;
147 LARGE_INTEGER liDrainCalculated;
148 UINT uiCurrentTokenCount;
149 LARGE_INTEGER liLastUpdateTokenAt;
150 UINT uiMaxAllowedRate;
151 UINT NumOfPacketsSent;
152 UCHAR ucDirection;
153 USHORT usCID;
154 struct bcm_mibs_parameters stMibsExtServiceFlowTable;
155 UINT uiCurrentRxRate;
156 UINT uiThisPeriodRxBytes;
157 UINT uiTotalRxBytes;
158 UINT uiTotalTxBytes;
159 UINT uiPendedLast;
160 UCHAR ucIpVersion;
162 union {
163 struct {
164 struct sk_buff *FirstTxQueue;
165 struct sk_buff *LastTxQueue;
167 struct {
168 struct sk_buff *ControlHead;
169 struct sk_buff *ControlTail;
173 BOOLEAN bProtocolValid;
174 BOOLEAN bTOSValid;
175 BOOLEAN bDestIpValid;
176 BOOLEAN bSrcIpValid;
178 BOOLEAN bActiveSet;
179 BOOLEAN bAdmittedSet;
180 BOOLEAN bAuthorizedSet;
181 BOOLEAN bClassifierPriority;
182 UCHAR ucServiceClassName[MAX_CLASS_NAME_LENGTH];
183 BOOLEAN bHeaderSuppressionEnabled;
184 spinlock_t SFQueueLock;
185 void *pstSFIndication;
186 struct timeval stLastUpdateTokenAt;
187 atomic_t uiPerSFTxResourceCount;
188 UINT uiMaxLatency;
189 UCHAR bIPCSSupport;
190 UCHAR bEthCSSupport;
193 struct bcm_tarang_data {
194 struct bcm_tarang_data *next;
195 struct bcm_mini_adapter *Adapter;
196 struct sk_buff *RxAppControlHead;
197 struct sk_buff *RxAppControlTail;
198 int AppCtrlQueueLen;
199 BOOLEAN MacTracingEnabled;
200 BOOLEAN bApplicationToExit;
201 struct bcm_mibs_dropped_cntrl_msg stDroppedAppCntrlMsgs;
202 ULONG RxCntrlMsgBitMask;
205 struct bcm_targetdsx_buffer {
206 ULONG ulTargetDsxBuffer;
207 B_UINT16 tid;
208 BOOLEAN valid;
211 typedef int (*FP_FLASH_WRITE)(struct bcm_mini_adapter *, UINT, PVOID);
213 typedef int (*FP_FLASH_WRITE_STATUS)(struct bcm_mini_adapter *, UINT, PVOID);
216 * Driver adapter data structure
218 struct bcm_mini_adapter {
219 struct bcm_mini_adapter *next;
220 struct net_device *dev;
221 u32 msg_enable;
222 CHAR *caDsxReqResp;
223 atomic_t ApplicationRunning;
224 BOOLEAN AppCtrlQueueOverFlow;
225 atomic_t CurrentApplicationCount;
226 atomic_t RegisteredApplicationCount;
227 BOOLEAN LinkUpStatus;
228 BOOLEAN TimerActive;
229 u32 StatisticsPointer;
230 struct sk_buff *RxControlHead;
231 struct sk_buff *RxControlTail;
232 struct semaphore RxAppControlQueuelock;
233 struct semaphore fw_download_sema;
234 struct bcm_tarang_data *pTarangs;
235 spinlock_t control_queue_lock;
236 wait_queue_head_t process_read_wait_queue;
238 /* the pointer to the first packet we have queued in send
239 * deserialized miniport support variables
241 atomic_t TotalPacketCount;
242 atomic_t TxPktAvail;
244 /* this to keep track of the Tx and Rx MailBox Registers. */
245 atomic_t CurrNumFreeTxDesc;
246 /* to keep track the no of byte received */
247 USHORT PrevNumRecvDescs;
248 USHORT CurrNumRecvDescs;
249 UINT u32TotalDSD;
250 struct bcm_packet_info PackInfo[NO_OF_QUEUES];
251 struct bcm_classifier_rule astClassifierTable[MAX_CLASSIFIERS];
252 BOOLEAN TransferMode;
254 /*************** qos ******************/
255 BOOLEAN bETHCSEnabled;
256 ULONG BEBucketSize;
257 ULONG rtPSBucketSize;
258 UCHAR LinkStatus;
259 BOOLEAN AutoLinkUp;
260 BOOLEAN AutoSyncup;
262 int major;
263 int minor;
264 wait_queue_head_t tx_packet_wait_queue;
265 wait_queue_head_t process_rx_cntrlpkt;
266 atomic_t process_waiting;
267 BOOLEAN fw_download_done;
269 char *txctlpacket[MAX_CNTRL_PKTS];
270 atomic_t cntrlpktCnt ;
271 atomic_t index_app_read_cntrlpkt;
272 atomic_t index_wr_txcntrlpkt;
273 atomic_t index_rd_txcntrlpkt;
274 UINT index_datpkt;
275 struct semaphore rdmwrmsync;
277 struct bcm_targetdsx_buffer astTargetDsxBuffer[MAX_TARGET_DSX_BUFFERS];
278 ULONG ulFreeTargetBufferCnt;
279 ULONG ulCurrentTargetBuffer;
280 ULONG ulTotalTargetBuffersAvailable;
281 unsigned long chip_id;
282 wait_queue_head_t lowpower_mode_wait_queue;
283 BOOLEAN bFlashBoot;
284 BOOLEAN bBinDownloaded;
285 BOOLEAN bCfgDownloaded;
286 BOOLEAN bSyncUpRequestSent;
287 USHORT usBestEffortQueueIndex;
288 wait_queue_head_t ioctl_fw_dnld_wait_queue;
289 BOOLEAN waiting_to_fw_download_done;
290 pid_t fw_download_process_pid;
291 struct bcm_target_params *pstargetparams;
292 BOOLEAN device_removed;
293 BOOLEAN DeviceAccess;
294 BOOLEAN bIsAutoCorrectEnabled;
295 BOOLEAN bDDRInitDone;
296 int DDRSetting;
297 ULONG ulPowerSaveMode;
298 spinlock_t txtransmitlock;
299 B_UINT8 txtransmit_running;
300 /* Thread for control packet handling */
301 struct task_struct *control_packet_handler;
302 /* thread for transmitting packets. */
303 struct task_struct *transmit_packet_thread;
305 /* LED Related Structures */
306 struct bcm_led_info LEDInfo;
308 /* Driver State for LED Blinking */
309 enum bcm_led_events DriverState;
310 /* Interface Specific */
311 PVOID pvInterfaceAdapter;
312 int (*bcm_file_download)(PVOID,
313 struct file *,
314 unsigned int);
315 int (*bcm_file_readback_from_chip)(PVOID,
316 struct file *,
317 unsigned int);
318 int (*interface_rdm)(PVOID,
319 UINT,
320 PVOID,
321 int);
322 int (*interface_wrm)(PVOID,
323 UINT,
324 PVOID,
325 int);
326 int (*interface_transmit)(PVOID, PVOID , UINT);
327 BOOLEAN IdleMode;
328 BOOLEAN bDregRequestSentInIdleMode;
329 BOOLEAN bTriedToWakeUpFromlowPowerMode;
330 BOOLEAN bShutStatus;
331 BOOLEAN bWakeUpDevice;
332 unsigned int usIdleModePattern;
333 /* BOOLEAN bTriedToWakeUpFromShutdown; */
334 BOOLEAN bLinkDownRequested;
335 int downloadDDR;
336 struct bcm_phs_extension stBCMPhsContext;
337 struct bcm_hdr_suppression_contextinfo stPhsTxContextInfo;
338 uint8_t ucaPHSPktRestoreBuf[2048];
339 uint8_t bPHSEnabled;
340 BOOLEAN AutoFirmDld;
341 BOOLEAN bMipsConfig;
342 BOOLEAN bDPLLConfig;
343 UINT32 aTxPktSizeHist[MIBS_MAX_HIST_ENTRIES];
344 UINT32 aRxPktSizeHist[MIBS_MAX_HIST_ENTRIES];
345 struct bcm_fragmented_packet_info astFragmentedPktClassifierTable[MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES];
346 atomic_t uiMBupdate;
347 UINT32 PmuMode;
348 enum bcm_nvm_type eNVMType;
349 UINT uiSectorSize;
350 UINT uiSectorSizeInCFG;
351 BOOLEAN bSectorSizeOverride;
352 BOOLEAN bStatusWrite;
353 UINT uiNVMDSDSize;
354 UINT uiVendorExtnFlag;
355 /* it will always represent chosen DSD at any point of time.
356 * Generally it is Active DSD but in case of NVM RD/WR it might be different.
358 UINT ulFlashCalStart;
359 ULONG ulFlashControlSectionStart;
360 ULONG ulFlashWriteSize;
361 ULONG ulFlashID;
362 FP_FLASH_WRITE fpFlashWrite;
363 FP_FLASH_WRITE_STATUS fpFlashWriteWithStatusCheck;
365 struct semaphore NVMRdmWrmLock;
366 struct device *pstCreatedClassDevice;
368 /* BOOLEAN InterfaceUpStatus; */
369 struct bcm_flash2x_cs_info *psFlash2xCSInfo;
370 struct bcm_flash_cs_info *psFlashCSInfo;
371 struct bcm_flash2x_vendor_info *psFlash2xVendorInfo;
372 UINT uiFlashBaseAdd; /* Flash start address */
373 UINT uiActiveISOOffset; /* Active ISO offset chosen before f/w download */
374 enum bcm_flash2x_section_val eActiveISO; /* Active ISO section val */
375 enum bcm_flash2x_section_val eActiveDSD; /* Active DSD val chosen before f/w download */
376 UINT uiActiveDSDOffsetAtFwDld; /* For accessing Active DSD chosen before f/w download */
377 UINT uiFlashLayoutMajorVersion;
378 UINT uiFlashLayoutMinorVersion;
379 BOOLEAN bAllDSDWriteAllow;
380 BOOLEAN bSigCorrupted;
381 /* this should be set who so ever want to change the Headers. after Wrtie it should be reset immediately. */
382 BOOLEAN bHeaderChangeAllowed;
383 int SelectedChip;
384 BOOLEAN bEndPointHalted;
385 /* while bFlashRawRead will be true, Driver ignore map lay out and consider flash as of without any map. */
386 BOOLEAN bFlashRawRead;
387 BOOLEAN bPreparingForLowPowerMode;
388 BOOLEAN bDoSuspend;
389 UINT syscfgBefFwDld;
390 BOOLEAN StopAllXaction;
391 UINT32 liTimeSinceLastNetEntry; /* Used to Support extended CAPI requirements from */
392 struct semaphore LowPowerModeSync;
393 ULONG liDrainCalculated;
394 UINT gpioBitMap;
395 struct bcm_debug_state stDebugState;
398 #define GET_BCM_ADAPTER(net_dev) netdev_priv(net_dev)
400 struct bcm_eth_header {
401 UCHAR au8DestinationAddress[6];
402 UCHAR au8SourceAddress[6];
403 USHORT u16Etype;
404 } __packed;
406 struct bcm_firmware_info {
407 void __user *pvMappedFirmwareAddress;
408 ULONG u32FirmwareLength;
409 ULONG u32StartingAddress;
410 } __packed;
412 /* holds the value of net_device structure.. */
413 extern struct net_device *gblpnetdev;
415 struct bcm_ddr_setting {
416 UINT ulRegAddress;
417 UINT ulRegValue;
419 int InitAdapter(struct bcm_mini_adapter *psAdapter);
421 /* =====================================================================
422 * Beceem vendor request codes for EP0
423 * =====================================================================
426 #define BCM_REQUEST_READ 0x2
427 #define BCM_REQUEST_WRITE 0x1
428 #define EP2_MPS_REG 0x0F0110A0
429 #define EP2_MPS 0x40
431 #define EP2_CFG_REG 0x0F0110A8
432 #define EP2_CFG_INT 0x27
433 #define EP2_CFG_BULK 0x25
435 #define EP4_MPS_REG 0x0F0110F0
436 #define EP4_MPS 0x8C
438 #define EP4_CFG_REG 0x0F0110F8
440 #define ISO_MPS_REG 0x0F0110C8
441 #define ISO_MPS 0x00000000
443 #define EP1 0
444 #define EP2 1
445 #define EP3 2
446 #define EP4 3
447 #define EP5 4
448 #define EP6 5
450 enum bcm_einterface_setting {
451 DEFAULT_SETTING_0 = 0,
452 ALTERNATE_SETTING_1 = 1,
455 #endif /* __ADAPTER_H__ */