1
2
3
4#ifndef __ADAPTER_H__
5#define __ADAPTER_H__
6
7#define MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES 256
8#include "Debug.h"
9
10struct bcm_leader {
11 USHORT Vcid;
12 USHORT PLength;
13 UCHAR Status;
14 UCHAR Unused[3];
15} __packed;
16
17struct bcm_packettosend {
18 struct bcm_leader Leader;
19 UCHAR ucPayload;
20} __packed;
21
22struct bcm_control_packet {
23 PVOID ControlBuff;
24 UINT ControlBuffLen;
25 struct bcm_control_packet *next;
26} __packed;
27
28struct bcm_link_request {
29 struct bcm_leader Leader;
30 UCHAR szData[4];
31} __packed;
32
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
37
38union u_ip_address {
39 struct {
40 ULONG ulIpv4Addr[MAX_IP_RANGE_LENGTH];
41 ULONG ulIpv4Mask[MAX_IP_RANGE_LENGTH];
42 };
43 struct {
44 ULONG ulIpv6Addr[MAX_IP_RANGE_LENGTH * 4];
45 ULONG ulIpv6Mask[MAX_IP_RANGE_LENGTH * 4];
46 };
47 struct {
48 UCHAR ucIpv4Address[MAX_IP_RANGE_LENGTH * IP_LENGTH_OF_ADDRESS];
49 UCHAR ucIpv4Mask[MAX_IP_RANGE_LENGTH * IP_LENGTH_OF_ADDRESS];
50 };
51 struct {
52 UCHAR ucIpv6Address[MAX_IP_RANGE_LENGTH * IPV6_ADDRESS_SIZEINBYTES];
53 UCHAR ucIpv6Mask[MAX_IP_RANGE_LENGTH * IPV6_ADDRESS_SIZEINBYTES];
54 };
55};
56
57struct bcm_hdr_suppression_contextinfo {
58 UCHAR ucaHdrSuppressionInBuf[MAX_PHS_LENGTHS];
59 UCHAR ucaHdrSuppressionOutBuf[MAX_PHS_LENGTHS + PHSI_LEN];
60};
61
62struct bcm_classifier_rule {
63 ULONG ulSFID;
64 UCHAR ucReserved[2];
65 B_UINT16 uiClassifierRuleIndex;
66 bool bUsed;
67 USHORT usVCID_Value;
68 B_UINT8 u8ClassifierRulePriority;
69 union u_ip_address stSrcIpAddress;
70 UCHAR ucIPSourceAddressLength;
71
72 union u_ip_address stDestIpAddress;
73 UCHAR ucIPDestinationAddressLength;
74 UCHAR ucIPTypeOfServiceLength;
75 UCHAR ucTosLow;
76 UCHAR ucTosHigh;
77 UCHAR ucTosMask;
78
79 UCHAR ucProtocolLength;
80 UCHAR ucProtocol[MAX_PROTOCOL_LENGTH];
81 USHORT usSrcPortRangeLo[MAX_PORT_RANGE];
82 USHORT usSrcPortRangeHi[MAX_PORT_RANGE];
83 UCHAR ucSrcPortRangeLength;
84
85 USHORT usDestPortRangeLo[MAX_PORT_RANGE];
86 USHORT usDestPortRangeHi[MAX_PORT_RANGE];
87 UCHAR ucDestPortRangeLength;
88
89 bool bProtocolValid;
90 bool bTOSValid;
91 bool bDestIpValid;
92 bool bSrcIpValid;
93
94
95 UCHAR ucDirection;
96 bool bIpv6Protocol;
97 UINT32 u32PHSRuleID;
98 struct bcm_phs_rule sPhsRule;
99 UCHAR u8AssociatedPHSI;
100
101
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;
113};
114
115struct bcm_fragmented_packet_info {
116 bool bUsed;
117 ULONG ulSrcIpAddress;
118 USHORT usIpIdentification;
119 struct bcm_classifier_rule *pstMatchedClassifierEntry;
120 bool bOutOfOrderFragment;
121};
122
123struct bcm_packet_info {
124
125 ULONG ulSFID;
126 USHORT usVCID_Value;
127 UINT uiThreshold;
128
129 B_UINT8 u8TrafficPriority;
130
131 bool bValid;
132 bool bActive;
133 bool bActivateRequestSent;
134
135 B_UINT8 u8QueueType;
136
137 UINT uiMaxBucketSize;
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;
161
162 union {
163 struct {
164 struct sk_buff *FirstTxQueue;
165 struct sk_buff *LastTxQueue;
166 };
167 struct {
168 struct sk_buff *ControlHead;
169 struct sk_buff *ControlTail;
170 };
171 };
172
173 bool bProtocolValid;
174 bool bTOSValid;
175 bool bDestIpValid;
176 bool bSrcIpValid;
177
178 bool bActiveSet;
179 bool bAdmittedSet;
180 bool bAuthorizedSet;
181 bool bClassifierPriority;
182 UCHAR ucServiceClassName[MAX_CLASS_NAME_LENGTH];
183 bool 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;
191};
192
193struct 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 bool MacTracingEnabled;
200 bool bApplicationToExit;
201 struct bcm_mibs_dropped_cntrl_msg stDroppedAppCntrlMsgs;
202 ULONG RxCntrlMsgBitMask;
203};
204
205struct bcm_targetdsx_buffer {
206 ULONG ulTargetDsxBuffer;
207 B_UINT16 tid;
208 bool valid;
209};
210
211typedef int (*FP_FLASH_WRITE)(struct bcm_mini_adapter *, UINT, PVOID);
212
213typedef int (*FP_FLASH_WRITE_STATUS)(struct bcm_mini_adapter *, UINT, PVOID);
214
215
216
217
218struct 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 bool AppCtrlQueueOverFlow;
225 atomic_t CurrentApplicationCount;
226 atomic_t RegisteredApplicationCount;
227 bool LinkUpStatus;
228 bool 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;
237
238
239
240
241 atomic_t TotalPacketCount;
242 atomic_t TxPktAvail;
243
244
245 atomic_t CurrNumFreeTxDesc;
246
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 bool TransferMode;
253
254
255 bool bETHCSEnabled;
256 ULONG BEBucketSize;
257 ULONG rtPSBucketSize;
258 UCHAR LinkStatus;
259 bool AutoLinkUp;
260 bool AutoSyncup;
261
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 bool fw_download_done;
268
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;
276
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 bool bFlashBoot;
284 bool bBinDownloaded;
285 bool bCfgDownloaded;
286 bool bSyncUpRequestSent;
287 USHORT usBestEffortQueueIndex;
288 wait_queue_head_t ioctl_fw_dnld_wait_queue;
289 bool waiting_to_fw_download_done;
290 pid_t fw_download_process_pid;
291 struct bcm_target_params *pstargetparams;
292 bool device_removed;
293 bool DeviceAccess;
294 bool bIsAutoCorrectEnabled;
295 bool bDDRInitDone;
296 int DDRSetting;
297 ULONG ulPowerSaveMode;
298 spinlock_t txtransmitlock;
299 B_UINT8 txtransmit_running;
300
301 struct task_struct *control_packet_handler;
302
303 struct task_struct *transmit_packet_thread;
304
305
306 struct bcm_led_info LEDInfo;
307
308
309 enum bcm_led_events DriverState;
310
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 bool IdleMode;
328 bool bDregRequestSentInIdleMode;
329 bool bTriedToWakeUpFromlowPowerMode;
330 bool bShutStatus;
331 bool bWakeUpDevice;
332 unsigned int usIdleModePattern;
333
334 bool 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 bool AutoFirmDld;
341 bool bMipsConfig;
342 bool 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 bool bSectorSizeOverride;
352 bool bStatusWrite;
353 UINT uiNVMDSDSize;
354 UINT uiVendorExtnFlag;
355
356
357
358 UINT ulFlashCalStart;
359 ULONG ulFlashControlSectionStart;
360 ULONG ulFlashWriteSize;
361 ULONG ulFlashID;
362 FP_FLASH_WRITE fpFlashWrite;
363 FP_FLASH_WRITE_STATUS fpFlashWriteWithStatusCheck;
364
365 struct semaphore NVMRdmWrmLock;
366 struct device *pstCreatedClassDevice;
367
368
369 struct bcm_flash2x_cs_info *psFlash2xCSInfo;
370 struct bcm_flash_cs_info *psFlashCSInfo;
371 struct bcm_flash2x_vendor_info *psFlash2xVendorInfo;
372 UINT uiFlashBaseAdd;
373 UINT uiActiveISOOffset;
374 enum bcm_flash2x_section_val eActiveISO;
375 enum bcm_flash2x_section_val eActiveDSD;
376 UINT uiActiveDSDOffsetAtFwDld;
377 UINT uiFlashLayoutMajorVersion;
378 UINT uiFlashLayoutMinorVersion;
379 bool bAllDSDWriteAllow;
380 bool bSigCorrupted;
381
382 bool bHeaderChangeAllowed;
383 int SelectedChip;
384 bool bEndPointHalted;
385
386 bool bFlashRawRead;
387 bool bPreparingForLowPowerMode;
388 bool bDoSuspend;
389 UINT syscfgBefFwDld;
390 bool StopAllXaction;
391 UINT32 liTimeSinceLastNetEntry;
392 struct semaphore LowPowerModeSync;
393 ULONG liDrainCalculated;
394 UINT gpioBitMap;
395 struct bcm_debug_state stDebugState;
396};
397
398#define GET_BCM_ADAPTER(net_dev) netdev_priv(net_dev)
399
400struct bcm_eth_header {
401 UCHAR au8DestinationAddress[6];
402 UCHAR au8SourceAddress[6];
403 USHORT u16Etype;
404} __packed;
405
406struct bcm_firmware_info {
407 void __user *pvMappedFirmwareAddress;
408 ULONG u32FirmwareLength;
409 ULONG u32StartingAddress;
410} __packed;
411
412
413extern struct net_device *gblpnetdev;
414
415struct bcm_ddr_setting {
416 UINT ulRegAddress;
417 UINT ulRegValue;
418};
419int InitAdapter(struct bcm_mini_adapter *psAdapter);
420
421
422
423
424
425
426#define BCM_REQUEST_READ 0x2
427#define BCM_REQUEST_WRITE 0x1
428#define EP2_MPS_REG 0x0F0110A0
429#define EP2_MPS 0x40
430
431#define EP2_CFG_REG 0x0F0110A8
432#define EP2_CFG_INT 0x27
433#define EP2_CFG_BULK 0x25
434
435#define EP4_MPS_REG 0x0F0110F0
436#define EP4_MPS 0x8C
437
438#define EP4_CFG_REG 0x0F0110F8
439
440#define ISO_MPS_REG 0x0F0110C8
441#define ISO_MPS 0x00000000
442
443#define EP1 0
444#define EP2 1
445#define EP3 2
446#define EP4 3
447#define EP5 4
448#define EP6 5
449
450enum bcm_einterface_setting {
451 DEFAULT_SETTING_0 = 0,
452 ALTERNATE_SETTING_1 = 1,
453};
454
455#endif
456