summaryrefslogtreecommitdiff
path: root/drivers/staging/bcm/Adapter.h
blob: ade2b0d67974343d7f96dea144bb918b28a628ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
/***********************************
*	Adapter.h
************************************/
#ifndef	__ADAPTER_H__
#define	__ADAPTER_H__

#define MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES 256
#include "Debug.h"

struct _LEADER {
	USHORT	Vcid;
	USHORT	PLength;
	UCHAR	Status;
	UCHAR	Unused[3];
} __packed;
typedef struct _LEADER LEADER, *PLEADER;

struct _PACKETTOSEND {
	LEADER	Leader;
	UCHAR	ucPayload;
} __packed;
typedef struct _PACKETTOSEND PACKETTOSEND, *PPACKETTOSEND;

struct _CONTROL_PACKET {
	PVOID	ControlBuff;
	UINT	ControlBuffLen;
	struct _CONTROL_PACKET *next;
} __packed;
typedef struct _CONTROL_PACKET CONTROL_PACKET, *PCONTROL_PACKET;

struct link_request {
	LEADER	Leader;
	UCHAR	szData[4];
} __packed;
typedef struct link_request LINK_REQUEST, *PLINK_REQUEST;

/* classification extension is added */
typedef struct _ADD_CONNECTION {
	ULONG	SrcIpAddressCount;
	ULONG	SrcIpAddress[MAX_CONNECTIONS];
	ULONG	SrcIpMask[MAX_CONNECTIONS];

	ULONG	DestIpAddressCount;
	ULONG	DestIpAddress[MAX_CONNECTIONS];
	ULONG	DestIpMask[MAX_CONNECTIONS];

	USHORT	SrcPortBegin;
	USHORT	SrcPortEnd;

	USHORT	DestPortBegin;
	USHORT	DestPortEnd;

	UCHAR	SrcTOS;
	UCHAR	SrcProtocol;
} ADD_CONNECTION, *PADD_CONNECTION;

typedef struct _CLASSIFICATION_RULE {
	UCHAR	ucIPSrcAddrLen;
	UCHAR	ucIPSrcAddr[32];
	UCHAR	ucIPDestAddrLen;
	UCHAR	ucIPDestAddr[32];
	UCHAR	ucSrcPortRangeLen;
	UCHAR	ucSrcPortRange[4];
	UCHAR	ucDestPortRangeLen;
	UCHAR	ucDestPortRange[4];
	USHORT	usVcid;
} CLASSIFICATION_RULE, *PCLASSIFICATION_RULE;

typedef struct _CLASSIFICATION_ONLY {
	USHORT	usVcid;
	ULONG	DestIpAddress;
	ULONG	DestIpMask;
	USHORT	usPortLo;
	USHORT	usPortHi;
	BOOLEAN	bIpVersion;
	UCHAR	ucDestinationAddress[16];
} CLASSIFICATION_ONLY, *PCLASSIFICATION_ONLY;

#define MAX_IP_RANGE_LENGTH 4
#define MAX_PORT_RANGE 4
#define MAX_PROTOCOL_LENGTH   32
#define IPV6_ADDRESS_SIZEINBYTES 0x10

typedef union _U_IP_ADDRESS {
	struct {
		ULONG ulIpv4Addr[MAX_IP_RANGE_LENGTH]; /* Source Ip Address Range */
		ULONG ulIpv4Mask[MAX_IP_RANGE_LENGTH]; /* Source Ip Mask Address Range */
	};
	struct {
		ULONG ulIpv6Addr[MAX_IP_RANGE_LENGTH * 4]; /* Source Ip Address Range */
		ULONG ulIpv6Mask[MAX_IP_RANGE_LENGTH * 4]; /* Source Ip Mask Address Range */
	};
	struct {
		UCHAR ucIpv4Address[MAX_IP_RANGE_LENGTH * IP_LENGTH_OF_ADDRESS];
		UCHAR ucIpv4Mask[MAX_IP_RANGE_LENGTH * IP_LENGTH_OF_ADDRESS];
	};
	struct {
		UCHAR ucIpv6Address[MAX_IP_RANGE_LENGTH * IPV6_ADDRESS_SIZEINBYTES];
		UCHAR ucIpv6Mask[MAX_IP_RANGE_LENGTH * IPV6_ADDRESS_SIZEINBYTES];
	};
} U_IP_ADDRESS;
struct _packet_info;

typedef struct _S_HDR_SUPRESSION_CONTEXTINFO {
	UCHAR ucaHdrSupressionInBuf[MAX_PHS_LENGTHS]; /* Intermediate buffer to accumulate pkt Header for PHS */
	UCHAR ucaHdrSupressionOutBuf[MAX_PHS_LENGTHS + PHSI_LEN]; /* Intermediate buffer containing pkt Header after PHS */
} S_HDR_SUPRESSION_CONTEXTINFO;

typedef struct _S_CLASSIFIER_RULE {
	ULONG		ulSFID;
	UCHAR		ucReserved[2];
	B_UINT16	uiClassifierRuleIndex;
	BOOLEAN		bUsed;
	USHORT		usVCID_Value;
	B_UINT8		u8ClassifierRulePriority; /* This field detemines the Classifier Priority */
	U_IP_ADDRESS	stSrcIpAddress;
	UCHAR		ucIPSourceAddressLength; /* Ip Source Address Length */

	U_IP_ADDRESS	stDestIpAddress;
	UCHAR		ucIPDestinationAddressLength; /* Ip Destination Address Length */
	UCHAR		ucIPTypeOfServiceLength; /* Type of service Length */
	UCHAR		ucTosLow; /* Tos Low */
	UCHAR		ucTosHigh; /* Tos High */
	UCHAR		ucTosMask; /* Tos Mask */

	UCHAR		ucProtocolLength; /* protocol Length */
	UCHAR		ucProtocol[MAX_PROTOCOL_LENGTH]; /* protocol Length */
	USHORT		usSrcPortRangeLo[MAX_PORT_RANGE];
	USHORT		usSrcPortRangeHi[MAX_PORT_RANGE];
	UCHAR		ucSrcPortRangeLength;

	USHORT		usDestPortRangeLo[MAX_PORT_RANGE];
	USHORT		usDestPortRangeHi[MAX_PORT_RANGE];
	UCHAR		ucDestPortRangeLength;

	BOOLEAN		bProtocolValid;
	BOOLEAN		bTOSValid;
	BOOLEAN		bDestIpValid;
	BOOLEAN		bSrcIpValid;

	/* For IPv6 Addressing */
	UCHAR		ucDirection;
	BOOLEAN		bIpv6Protocol;
	UINT32		u32PHSRuleID;
	S_PHS_RULE	sPhsRule;
	UCHAR		u8AssociatedPHSI;

	/* Classification fields for ETH CS */
	UCHAR		ucEthCSSrcMACLen;
	UCHAR		au8EThCSSrcMAC[MAC_ADDRESS_SIZE];
	UCHAR		au8EThCSSrcMACMask[MAC_ADDRESS_SIZE];
	UCHAR		ucEthCSDestMACLen;
	UCHAR		au8EThCSDestMAC[MAC_ADDRESS_SIZE];
	UCHAR		au8EThCSDestMACMask[MAC_ADDRESS_SIZE];
	UCHAR		ucEtherTypeLen;
	UCHAR		au8EthCSEtherType[NUM_ETHERTYPE_BYTES];
	UCHAR		usUserPriority[2];
	USHORT		usVLANID;
	USHORT		usValidityBitMap;
} S_CLASSIFIER_RULE;
/* typedef struct _S_CLASSIFIER_RULE S_CLASSIFIER_RULE; */

typedef struct _S_FRAGMENTED_PACKET_INFO {
	BOOLEAN			bUsed;
	ULONG			ulSrcIpAddress;
	USHORT			usIpIdentification;
	S_CLASSIFIER_RULE	*pstMatchedClassifierEntry;
	BOOLEAN			bOutOfOrderFragment;
} S_FRAGMENTED_PACKET_INFO, *PS_FRAGMENTED_PACKET_INFO;

struct _packet_info {
	/* classification extension Rule */
	ULONG		ulSFID;
	USHORT		usVCID_Value;
	UINT		uiThreshold;
	/* This field determines the priority of the SF Queues */
	B_UINT8		u8TrafficPriority;

	BOOLEAN		bValid;
	BOOLEAN		bActive;
	BOOLEAN		bActivateRequestSent;

	B_UINT8		u8QueueType; /* BE or rtPS */

	UINT		uiMaxBucketSize; /* maximum size of the bucket for the queue */
	UINT		uiCurrentQueueDepthOnTarget;
	UINT		uiCurrentBytesOnHost;
	UINT		uiCurrentPacketsOnHost;
	UINT		uiDroppedCountBytes;
	UINT		uiDroppedCountPackets;
	UINT		uiSentBytes;
	UINT		uiSentPackets;
	UINT		uiCurrentDrainRate;
	UINT		uiThisPeriodSentBytes;
	LARGE_INTEGER	liDrainCalculated;
	UINT		uiCurrentTokenCount;
	LARGE_INTEGER	liLastUpdateTokenAt;
	UINT		uiMaxAllowedRate;
	UINT		NumOfPacketsSent;
	UCHAR		ucDirection;
	USHORT		usCID;
	S_MIBS_EXTSERVICEFLOW_PARAMETERS	stMibsExtServiceFlowTable;
	UINT		uiCurrentRxRate;
	UINT		uiThisPeriodRxBytes;
	UINT		uiTotalRxBytes;
	UINT		uiTotalTxBytes;
	UINT		uiPendedLast;
	UCHAR		ucIpVersion;

	union {
		struct {
			struct sk_buff *FirstTxQueue;
			struct sk_buff *LastTxQueue;
		};
		struct {
			struct sk_buff *ControlHead;
			struct sk_buff *ControlTail;
		};
	};

	BOOLEAN		bProtocolValid;
	BOOLEAN		bTOSValid;
	BOOLEAN		bDestIpValid;
	BOOLEAN		bSrcIpValid;

	BOOLEAN		bActiveSet;
	BOOLEAN		bAdmittedSet;
	BOOLEAN		bAuthorizedSet;
	BOOLEAN		bClassifierPriority;
	UCHAR		ucServiceClassName[MAX_CLASS_NAME_LENGTH];
	BOOLEAN		bHeaderSuppressionEnabled;
	spinlock_t	SFQueueLock;
	void		*pstSFIndication;
	struct timeval	stLastUpdateTokenAt;
	atomic_t	uiPerSFTxResourceCount;
	UINT		uiMaxLatency;
	UCHAR		bIPCSSupport;
	UCHAR		bEthCSSupport;
};
typedef struct _packet_info PacketInfo;

typedef struct _PER_TARANG_DATA {
	struct _PER_TARANG_DATA	*next;
	struct _MINI_ADAPTER	*Adapter;
	struct sk_buff		*RxAppControlHead;
	struct sk_buff		*RxAppControlTail;
	int			AppCtrlQueueLen;
	BOOLEAN			MacTracingEnabled;
	BOOLEAN			bApplicationToExit;
	S_MIBS_DROPPED_APP_CNTRL_MESSAGES	stDroppedAppCntrlMsgs;
	ULONG			RxCntrlMsgBitMask;
} PER_TARANG_DATA, *PPER_TARANG_DATA;

struct bcm_targetdsx_buffer {
	ULONG		ulTargetDsxBuffer;
	B_UINT16	tid;
	BOOLEAN		valid;
};

typedef int (*FP_FLASH_WRITE)(struct _MINI_ADAPTER *, UINT, PVOID);

typedef int (*FP_FLASH_WRITE_STATUS)(struct _MINI_ADAPTER *, UINT, PVOID);

/*
 * Driver adapter data structure
 */
struct _MINI_ADAPTER {
	struct _MINI_ADAPTER	*next;
	struct net_device	*dev;
	u32			msg_enable;
	CHAR			*caDsxReqResp;
	atomic_t		ApplicationRunning;
	BOOLEAN			AppCtrlQueueOverFlow;
	atomic_t		CurrentApplicationCount;
	atomic_t		RegisteredApplicationCount;
	BOOLEAN			LinkUpStatus;
	BOOLEAN			TimerActive;
	u32			StatisticsPointer;
	struct sk_buff		*RxControlHead;
	struct sk_buff		*RxControlTail;
	struct semaphore	RxAppControlQueuelock;
	struct semaphore	fw_download_sema;
	PPER_TARANG_DATA	pTarangs;
	spinlock_t		control_queue_lock;
	wait_queue_head_t	process_read_wait_queue;

	/* the pointer to the first packet we have queued in send
	 * deserialized miniport support variables
	 */
	atomic_t		TotalPacketCount;
	atomic_t		TxPktAvail;

	/* this to keep track of the Tx and Rx MailBox Registers. */
	atomic_t		CurrNumFreeTxDesc;
	/* to keep track the no of byte received */
	USHORT			PrevNumRecvDescs;
	USHORT			CurrNumRecvDescs;
	UINT			u32TotalDSD;
	PacketInfo		PackInfo[NO_OF_QUEUES];
	S_CLASSIFIER_RULE	astClassifierTable[MAX_CLASSIFIERS];
	BOOLEAN			TransferMode;

	/*************** qos ******************/
	BOOLEAN			bETHCSEnabled;
	ULONG			BEBucketSize;
	ULONG			rtPSBucketSize;
	UCHAR			LinkStatus;
	BOOLEAN			AutoLinkUp;
	BOOLEAN			AutoSyncup;

	int			major;
	int			minor;
	wait_queue_head_t	tx_packet_wait_queue;
	wait_queue_head_t	process_rx_cntrlpkt;
	atomic_t		process_waiting;
	BOOLEAN			fw_download_done;

	char			*txctlpacket[MAX_CNTRL_PKTS];
	atomic_t		cntrlpktCnt ;
	atomic_t		index_app_read_cntrlpkt;
	atomic_t		index_wr_txcntrlpkt;
	atomic_t		index_rd_txcntrlpkt;
	UINT			index_datpkt;
	struct semaphore	rdmwrmsync;

	struct bcm_targetdsx_buffer	astTargetDsxBuffer[MAX_TARGET_DSX_BUFFERS];
	ULONG			ulFreeTargetBufferCnt;
	ULONG			ulCurrentTargetBuffer;
	ULONG			ulTotalTargetBuffersAvailable;
	unsigned long		chip_id;
	wait_queue_head_t	lowpower_mode_wait_queue;
	BOOLEAN			bFlashBoot;
	BOOLEAN			bBinDownloaded;
	BOOLEAN			bCfgDownloaded;
	BOOLEAN			bSyncUpRequestSent;
	USHORT			usBestEffortQueueIndex;
	wait_queue_head_t	ioctl_fw_dnld_wait_queue;
	BOOLEAN			waiting_to_fw_download_done;
	pid_t			fw_download_process_pid;
	PSTARGETPARAMS		pstargetparams;
	BOOLEAN			device_removed;
	BOOLEAN			DeviceAccess;
	BOOLEAN			bIsAutoCorrectEnabled;
	BOOLEAN			bDDRInitDone;
	int			DDRSetting;
	ULONG			ulPowerSaveMode;
	spinlock_t		txtransmitlock;
	B_UINT8			txtransmit_running;
	/* Thread for control packet handling */
	struct task_struct	*control_packet_handler;
	/* thread for transmitting packets. */
	struct task_struct	*transmit_packet_thread;

	/* LED Related Structures */
	LED_INFO_STRUCT		LEDInfo;

	/* Driver State for LED Blinking */
	LedEventInfo_t		DriverState;
	/* Interface Specific */
	PVOID			pvInterfaceAdapter;
	int (*bcm_file_download)(PVOID,
				struct file *,
				unsigned int);
	int (*bcm_file_readback_from_chip)(PVOID,
					struct file *,
					unsigned int);
	int (*interface_rdm)(PVOID,
			UINT,
			PVOID,
			int);
	int (*interface_wrm)(PVOID,
			UINT,
			PVOID,
			int);
	int (*interface_transmit)(PVOID, PVOID , UINT);
	BOOLEAN			IdleMode;
	BOOLEAN			bDregRequestSentInIdleMode;
	BOOLEAN			bTriedToWakeUpFromlowPowerMode;
	BOOLEAN			bShutStatus;
	BOOLEAN			bWakeUpDevice;
	unsigned int		usIdleModePattern;
	/* BOOLEAN			bTriedToWakeUpFromShutdown; */
	BOOLEAN			bLinkDownRequested;
	int			downloadDDR;
	PHS_DEVICE_EXTENSION	stBCMPhsContext;
	S_HDR_SUPRESSION_CONTEXTINFO stPhsTxContextInfo;
	uint8_t			ucaPHSPktRestoreBuf[2048];
	uint8_t			bPHSEnabled;
	BOOLEAN			AutoFirmDld;
	BOOLEAN			bMipsConfig;
	BOOLEAN			bDPLLConfig;
	UINT32			aTxPktSizeHist[MIBS_MAX_HIST_ENTRIES];
	UINT32			aRxPktSizeHist[MIBS_MAX_HIST_ENTRIES];
	S_FRAGMENTED_PACKET_INFO astFragmentedPktClassifierTable[MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES];
	atomic_t		uiMBupdate;
	UINT32			PmuMode;
	NVM_TYPE		eNVMType;
	UINT			uiSectorSize;
	UINT			uiSectorSizeInCFG;
	BOOLEAN			bSectorSizeOverride;
	BOOLEAN			bStatusWrite;
	UINT			uiNVMDSDSize;
	UINT			uiVendorExtnFlag;
	/* it will always represent chosen DSD at any point of time.
	 * Generally it is Active DSD but in case of NVM RD/WR it might be different.
	 */
	UINT			ulFlashCalStart;
	ULONG			ulFlashControlSectionStart;
	ULONG			ulFlashWriteSize;
	ULONG			ulFlashID;
	FP_FLASH_WRITE		fpFlashWrite;
	FP_FLASH_WRITE_STATUS	fpFlashWriteWithStatusCheck;

	struct semaphore	NVMRdmWrmLock;
	struct device		*pstCreatedClassDevice;

	/*	BOOLEAN				InterfaceUpStatus; */
	PFLASH2X_CS_INFO	psFlash2xCSInfo;
	PFLASH_CS_INFO		psFlashCSInfo;
	PFLASH2X_VENDORSPECIFIC_INFO psFlash2xVendorInfo;
	UINT			uiFlashBaseAdd; /* Flash start address */
	UINT			uiActiveISOOffset; /* Active ISO offset chosen before f/w download */
	FLASH2X_SECTION_VAL	eActiveISO; /* Active ISO section val */
	FLASH2X_SECTION_VAL	eActiveDSD;	/* Active DSD val chosen before f/w download */
	UINT			uiActiveDSDOffsetAtFwDld;  /* For accessing Active DSD chosen before f/w download */
	UINT			uiFlashLayoutMajorVersion;
	UINT			uiFlashLayoutMinorVersion;
	BOOLEAN			bAllDSDWriteAllow;
	BOOLEAN			bSigCorrupted;
	/* this should be set who so ever want to change the Headers. after Wrtie it should be reset immediately. */
	BOOLEAN			bHeaderChangeAllowed;
	int			SelectedChip;
	BOOLEAN			bEndPointHalted;
	/* while bFlashRawRead will be true, Driver  ignore map lay out and consider flash as of without any map. */
	BOOLEAN			bFlashRawRead;
	BOOLEAN			bPreparingForLowPowerMode;
	BOOLEAN			bDoSuspend;
	UINT			syscfgBefFwDld;
	BOOLEAN			StopAllXaction;
	UINT32			liTimeSinceLastNetEntry; /* Used to Support extended CAPI requirements from */
	struct semaphore	LowPowerModeSync;
	ULONG			liDrainCalculated;
	UINT			gpioBitMap;
	S_BCM_DEBUG_STATE	stDebugState;
};
typedef struct _MINI_ADAPTER MINI_ADAPTER, *PMINI_ADAPTER;

#define GET_BCM_ADAPTER(net_dev) netdev_priv(net_dev)

struct bcm_eth_header {
	UCHAR	au8DestinationAddress[6];
	UCHAR	au8SourceAddress[6];
	USHORT	u16Etype;
} __packed;

struct bcm_firmware_info {
	void	__user *pvMappedFirmwareAddress;
	ULONG	u32FirmwareLength;
	ULONG	u32StartingAddress;
} __packed;

/* holds the value of net_device structure.. */
extern struct net_device *gblpnetdev;

typedef LINK_REQUEST CONTROL_MESSAGE;

struct bcm_ddr_setting {
	UINT ulRegAddress;
	UINT ulRegValue;
};
int InitAdapter(PMINI_ADAPTER psAdapter);

/* =====================================================================
 * Beceem vendor request codes for EP0
 * =====================================================================
 */

#define BCM_REQUEST_READ	0x2
#define BCM_REQUEST_WRITE	0x1
#define EP2_MPS_REG		0x0F0110A0
#define EP2_MPS			0x40

#define EP2_CFG_REG	0x0F0110A8
#define EP2_CFG_INT	0x27
#define EP2_CFG_BULK	0x25

#define EP4_MPS_REG	0x0F0110F0
#define EP4_MPS		0x8C

#define EP4_CFG_REG	0x0F0110F8

#define ISO_MPS_REG	0x0F0110C8
#define ISO_MPS		0x00000000

#define EP1 0
#define EP2 1
#define EP3 2
#define EP4 3
#define EP5 4
#define EP6 5

enum bcm_einterface_setting {
	DEFAULT_SETTING_0  = 0,
	ALTERNATE_SETTING_1 = 1,
};

#endif	/* __ADAPTER_H__ */