Linux Audio

Check our new training course

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