Adapter.h 12 KB

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