cxgb4.h 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676
  1. /*
  2. * This file is part of the Chelsio T4 Ethernet driver for Linux.
  3. *
  4. * Copyright (c) 2003-2016 Chelsio Communications, Inc. All rights reserved.
  5. *
  6. * This software is available to you under a choice of one of two
  7. * licenses. You may choose to be licensed under the terms of the GNU
  8. * General Public License (GPL) Version 2, available from the file
  9. * COPYING in the main directory of this source tree, or the
  10. * OpenIB.org BSD license below:
  11. *
  12. * Redistribution and use in source and binary forms, with or
  13. * without modification, are permitted provided that the following
  14. * conditions are met:
  15. *
  16. * - Redistributions of source code must retain the above
  17. * copyright notice, this list of conditions and the following
  18. * disclaimer.
  19. *
  20. * - Redistributions in binary form must reproduce the above
  21. * copyright notice, this list of conditions and the following
  22. * disclaimer in the documentation and/or other materials
  23. * provided with the distribution.
  24. *
  25. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  26. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  27. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  28. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  29. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  30. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  31. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  32. * SOFTWARE.
  33. */
  34. #ifndef __CXGB4_H__
  35. #define __CXGB4_H__
  36. #include "t4_hw.h"
  37. #include <linux/bitops.h>
  38. #include <linux/cache.h>
  39. #include <linux/interrupt.h>
  40. #include <linux/list.h>
  41. #include <linux/netdevice.h>
  42. #include <linux/pci.h>
  43. #include <linux/spinlock.h>
  44. #include <linux/timer.h>
  45. #include <linux/vmalloc.h>
  46. #include <linux/etherdevice.h>
  47. #include <linux/net_tstamp.h>
  48. #include <asm/io.h>
  49. #include "t4_chip_type.h"
  50. #include "cxgb4_uld.h"
  51. #define CH_WARN(adap, fmt, ...) dev_warn(adap->pdev_dev, fmt, ## __VA_ARGS__)
  52. extern struct list_head adapter_list;
  53. extern struct mutex uld_mutex;
  54. enum {
  55. MAX_NPORTS = 4, /* max # of ports */
  56. SERNUM_LEN = 24, /* Serial # length */
  57. EC_LEN = 16, /* E/C length */
  58. ID_LEN = 16, /* ID length */
  59. PN_LEN = 16, /* Part Number length */
  60. MACADDR_LEN = 12, /* MAC Address length */
  61. };
  62. enum {
  63. T4_REGMAP_SIZE = (160 * 1024),
  64. T5_REGMAP_SIZE = (332 * 1024),
  65. };
  66. enum {
  67. MEM_EDC0,
  68. MEM_EDC1,
  69. MEM_MC,
  70. MEM_MC0 = MEM_MC,
  71. MEM_MC1
  72. };
  73. enum {
  74. MEMWIN0_APERTURE = 2048,
  75. MEMWIN0_BASE = 0x1b800,
  76. MEMWIN1_APERTURE = 32768,
  77. MEMWIN1_BASE = 0x28000,
  78. MEMWIN1_BASE_T5 = 0x52000,
  79. MEMWIN2_APERTURE = 65536,
  80. MEMWIN2_BASE = 0x30000,
  81. MEMWIN2_APERTURE_T5 = 131072,
  82. MEMWIN2_BASE_T5 = 0x60000,
  83. };
  84. enum dev_master {
  85. MASTER_CANT,
  86. MASTER_MAY,
  87. MASTER_MUST
  88. };
  89. enum dev_state {
  90. DEV_STATE_UNINIT,
  91. DEV_STATE_INIT,
  92. DEV_STATE_ERR
  93. };
  94. enum {
  95. PAUSE_RX = 1 << 0,
  96. PAUSE_TX = 1 << 1,
  97. PAUSE_AUTONEG = 1 << 2
  98. };
  99. struct port_stats {
  100. u64 tx_octets; /* total # of octets in good frames */
  101. u64 tx_frames; /* all good frames */
  102. u64 tx_bcast_frames; /* all broadcast frames */
  103. u64 tx_mcast_frames; /* all multicast frames */
  104. u64 tx_ucast_frames; /* all unicast frames */
  105. u64 tx_error_frames; /* all error frames */
  106. u64 tx_frames_64; /* # of Tx frames in a particular range */
  107. u64 tx_frames_65_127;
  108. u64 tx_frames_128_255;
  109. u64 tx_frames_256_511;
  110. u64 tx_frames_512_1023;
  111. u64 tx_frames_1024_1518;
  112. u64 tx_frames_1519_max;
  113. u64 tx_drop; /* # of dropped Tx frames */
  114. u64 tx_pause; /* # of transmitted pause frames */
  115. u64 tx_ppp0; /* # of transmitted PPP prio 0 frames */
  116. u64 tx_ppp1; /* # of transmitted PPP prio 1 frames */
  117. u64 tx_ppp2; /* # of transmitted PPP prio 2 frames */
  118. u64 tx_ppp3; /* # of transmitted PPP prio 3 frames */
  119. u64 tx_ppp4; /* # of transmitted PPP prio 4 frames */
  120. u64 tx_ppp5; /* # of transmitted PPP prio 5 frames */
  121. u64 tx_ppp6; /* # of transmitted PPP prio 6 frames */
  122. u64 tx_ppp7; /* # of transmitted PPP prio 7 frames */
  123. u64 rx_octets; /* total # of octets in good frames */
  124. u64 rx_frames; /* all good frames */
  125. u64 rx_bcast_frames; /* all broadcast frames */
  126. u64 rx_mcast_frames; /* all multicast frames */
  127. u64 rx_ucast_frames; /* all unicast frames */
  128. u64 rx_too_long; /* # of frames exceeding MTU */
  129. u64 rx_jabber; /* # of jabber frames */
  130. u64 rx_fcs_err; /* # of received frames with bad FCS */
  131. u64 rx_len_err; /* # of received frames with length error */
  132. u64 rx_symbol_err; /* symbol errors */
  133. u64 rx_runt; /* # of short frames */
  134. u64 rx_frames_64; /* # of Rx frames in a particular range */
  135. u64 rx_frames_65_127;
  136. u64 rx_frames_128_255;
  137. u64 rx_frames_256_511;
  138. u64 rx_frames_512_1023;
  139. u64 rx_frames_1024_1518;
  140. u64 rx_frames_1519_max;
  141. u64 rx_pause; /* # of received pause frames */
  142. u64 rx_ppp0; /* # of received PPP prio 0 frames */
  143. u64 rx_ppp1; /* # of received PPP prio 1 frames */
  144. u64 rx_ppp2; /* # of received PPP prio 2 frames */
  145. u64 rx_ppp3; /* # of received PPP prio 3 frames */
  146. u64 rx_ppp4; /* # of received PPP prio 4 frames */
  147. u64 rx_ppp5; /* # of received PPP prio 5 frames */
  148. u64 rx_ppp6; /* # of received PPP prio 6 frames */
  149. u64 rx_ppp7; /* # of received PPP prio 7 frames */
  150. u64 rx_ovflow0; /* drops due to buffer-group 0 overflows */
  151. u64 rx_ovflow1; /* drops due to buffer-group 1 overflows */
  152. u64 rx_ovflow2; /* drops due to buffer-group 2 overflows */
  153. u64 rx_ovflow3; /* drops due to buffer-group 3 overflows */
  154. u64 rx_trunc0; /* buffer-group 0 truncated packets */
  155. u64 rx_trunc1; /* buffer-group 1 truncated packets */
  156. u64 rx_trunc2; /* buffer-group 2 truncated packets */
  157. u64 rx_trunc3; /* buffer-group 3 truncated packets */
  158. };
  159. struct lb_port_stats {
  160. u64 octets;
  161. u64 frames;
  162. u64 bcast_frames;
  163. u64 mcast_frames;
  164. u64 ucast_frames;
  165. u64 error_frames;
  166. u64 frames_64;
  167. u64 frames_65_127;
  168. u64 frames_128_255;
  169. u64 frames_256_511;
  170. u64 frames_512_1023;
  171. u64 frames_1024_1518;
  172. u64 frames_1519_max;
  173. u64 drop;
  174. u64 ovflow0;
  175. u64 ovflow1;
  176. u64 ovflow2;
  177. u64 ovflow3;
  178. u64 trunc0;
  179. u64 trunc1;
  180. u64 trunc2;
  181. u64 trunc3;
  182. };
  183. struct tp_tcp_stats {
  184. u32 tcp_out_rsts;
  185. u64 tcp_in_segs;
  186. u64 tcp_out_segs;
  187. u64 tcp_retrans_segs;
  188. };
  189. struct tp_usm_stats {
  190. u32 frames;
  191. u32 drops;
  192. u64 octets;
  193. };
  194. struct tp_fcoe_stats {
  195. u32 frames_ddp;
  196. u32 frames_drop;
  197. u64 octets_ddp;
  198. };
  199. struct tp_err_stats {
  200. u32 mac_in_errs[4];
  201. u32 hdr_in_errs[4];
  202. u32 tcp_in_errs[4];
  203. u32 tnl_cong_drops[4];
  204. u32 ofld_chan_drops[4];
  205. u32 tnl_tx_drops[4];
  206. u32 ofld_vlan_drops[4];
  207. u32 tcp6_in_errs[4];
  208. u32 ofld_no_neigh;
  209. u32 ofld_cong_defer;
  210. };
  211. struct tp_cpl_stats {
  212. u32 req[4];
  213. u32 rsp[4];
  214. };
  215. struct tp_rdma_stats {
  216. u32 rqe_dfr_pkt;
  217. u32 rqe_dfr_mod;
  218. };
  219. struct sge_params {
  220. u32 hps; /* host page size for our PF/VF */
  221. u32 eq_qpp; /* egress queues/page for our PF/VF */
  222. u32 iq_qpp; /* egress queues/page for our PF/VF */
  223. };
  224. struct tp_params {
  225. unsigned int tre; /* log2 of core clocks per TP tick */
  226. unsigned int la_mask; /* what events are recorded by TP LA */
  227. unsigned short tx_modq_map; /* TX modulation scheduler queue to */
  228. /* channel map */
  229. uint32_t dack_re; /* DACK timer resolution */
  230. unsigned short tx_modq[NCHAN]; /* channel to modulation queue map */
  231. u32 vlan_pri_map; /* cached TP_VLAN_PRI_MAP */
  232. u32 ingress_config; /* cached TP_INGRESS_CONFIG */
  233. /* TP_VLAN_PRI_MAP Compressed Filter Tuple field offsets. This is a
  234. * subset of the set of fields which may be present in the Compressed
  235. * Filter Tuple portion of filters and TCP TCB connections. The
  236. * fields which are present are controlled by the TP_VLAN_PRI_MAP.
  237. * Since a variable number of fields may or may not be present, their
  238. * shifted field positions within the Compressed Filter Tuple may
  239. * vary, or not even be present if the field isn't selected in
  240. * TP_VLAN_PRI_MAP. Since some of these fields are needed in various
  241. * places we store their offsets here, or a -1 if the field isn't
  242. * present.
  243. */
  244. int vlan_shift;
  245. int vnic_shift;
  246. int port_shift;
  247. int protocol_shift;
  248. };
  249. struct vpd_params {
  250. unsigned int cclk;
  251. u8 ec[EC_LEN + 1];
  252. u8 sn[SERNUM_LEN + 1];
  253. u8 id[ID_LEN + 1];
  254. u8 pn[PN_LEN + 1];
  255. u8 na[MACADDR_LEN + 1];
  256. };
  257. struct pci_params {
  258. unsigned char speed;
  259. unsigned char width;
  260. };
  261. struct devlog_params {
  262. u32 memtype; /* which memory (EDC0, EDC1, MC) */
  263. u32 start; /* start of log in firmware memory */
  264. u32 size; /* size of log */
  265. };
  266. /* Stores chip specific parameters */
  267. struct arch_specific_params {
  268. u8 nchan;
  269. u8 pm_stats_cnt;
  270. u8 cng_ch_bits_log; /* congestion channel map bits width */
  271. u16 mps_rplc_size;
  272. u16 vfcount;
  273. u32 sge_fl_db;
  274. u16 mps_tcam_size;
  275. };
  276. struct adapter_params {
  277. struct sge_params sge;
  278. struct tp_params tp;
  279. struct vpd_params vpd;
  280. struct pci_params pci;
  281. struct devlog_params devlog;
  282. enum pcie_memwin drv_memwin;
  283. unsigned int cim_la_size;
  284. unsigned int sf_size; /* serial flash size in bytes */
  285. unsigned int sf_nsec; /* # of flash sectors */
  286. unsigned int sf_fw_start; /* start of FW image in flash */
  287. unsigned int fw_vers;
  288. unsigned int bs_vers; /* bootstrap version */
  289. unsigned int tp_vers;
  290. unsigned int er_vers; /* expansion ROM version */
  291. u8 api_vers[7];
  292. unsigned short mtus[NMTUS];
  293. unsigned short a_wnd[NCCTRL_WIN];
  294. unsigned short b_wnd[NCCTRL_WIN];
  295. unsigned char nports; /* # of ethernet ports */
  296. unsigned char portvec;
  297. enum chip_type chip; /* chip code */
  298. struct arch_specific_params arch; /* chip specific params */
  299. unsigned char offload;
  300. unsigned char crypto; /* HW capability for crypto */
  301. unsigned char bypass;
  302. unsigned int ofldq_wr_cred;
  303. bool ulptx_memwrite_dsgl; /* use of T5 DSGL allowed */
  304. unsigned int nsched_cls; /* number of traffic classes */
  305. unsigned int max_ordird_qp; /* Max read depth per RDMA QP */
  306. unsigned int max_ird_adapter; /* Max read depth per adapter */
  307. bool fr_nsmr_tpte_wr_support; /* FW support for FR_NSMR_TPTE_WR */
  308. };
  309. /* State needed to monitor the forward progress of SGE Ingress DMA activities
  310. * and possible hangs.
  311. */
  312. struct sge_idma_monitor_state {
  313. unsigned int idma_1s_thresh; /* 1s threshold in Core Clock ticks */
  314. unsigned int idma_stalled[2]; /* synthesized stalled timers in HZ */
  315. unsigned int idma_state[2]; /* IDMA Hang detect state */
  316. unsigned int idma_qid[2]; /* IDMA Hung Ingress Queue ID */
  317. unsigned int idma_warn[2]; /* time to warning in HZ */
  318. };
  319. /* Firmware Mailbox Command/Reply log. All values are in Host-Endian format.
  320. * The access and execute times are signed in order to accommodate negative
  321. * error returns.
  322. */
  323. struct mbox_cmd {
  324. u64 cmd[MBOX_LEN / 8]; /* a Firmware Mailbox Command/Reply */
  325. u64 timestamp; /* OS-dependent timestamp */
  326. u32 seqno; /* sequence number */
  327. s16 access; /* time (ms) to access mailbox */
  328. s16 execute; /* time (ms) to execute */
  329. };
  330. struct mbox_cmd_log {
  331. unsigned int size; /* number of entries in the log */
  332. unsigned int cursor; /* next position in the log to write */
  333. u32 seqno; /* next sequence number */
  334. /* variable length mailbox command log starts here */
  335. };
  336. /* Given a pointer to a Firmware Mailbox Command Log and a log entry index,
  337. * return a pointer to the specified entry.
  338. */
  339. static inline struct mbox_cmd *mbox_cmd_log_entry(struct mbox_cmd_log *log,
  340. unsigned int entry_idx)
  341. {
  342. return &((struct mbox_cmd *)&(log)[1])[entry_idx];
  343. }
  344. #include "t4fw_api.h"
  345. #define FW_VERSION(chip) ( \
  346. FW_HDR_FW_VER_MAJOR_G(chip##FW_VERSION_MAJOR) | \
  347. FW_HDR_FW_VER_MINOR_G(chip##FW_VERSION_MINOR) | \
  348. FW_HDR_FW_VER_MICRO_G(chip##FW_VERSION_MICRO) | \
  349. FW_HDR_FW_VER_BUILD_G(chip##FW_VERSION_BUILD))
  350. #define FW_INTFVER(chip, intf) (FW_HDR_INTFVER_##intf)
  351. struct fw_info {
  352. u8 chip;
  353. char *fs_name;
  354. char *fw_mod_name;
  355. struct fw_hdr fw_hdr;
  356. };
  357. struct trace_params {
  358. u32 data[TRACE_LEN / 4];
  359. u32 mask[TRACE_LEN / 4];
  360. unsigned short snap_len;
  361. unsigned short min_len;
  362. unsigned char skip_ofst;
  363. unsigned char skip_len;
  364. unsigned char invert;
  365. unsigned char port;
  366. };
  367. struct link_config {
  368. unsigned short supported; /* link capabilities */
  369. unsigned short advertising; /* advertised capabilities */
  370. unsigned short lp_advertising; /* peer advertised capabilities */
  371. unsigned int requested_speed; /* speed user has requested */
  372. unsigned int speed; /* actual link speed */
  373. unsigned char requested_fc; /* flow control user has requested */
  374. unsigned char fc; /* actual link flow control */
  375. unsigned char autoneg; /* autonegotiating? */
  376. unsigned char link_ok; /* link up? */
  377. unsigned char link_down_rc; /* link down reason */
  378. };
  379. #define FW_LEN16(fw_struct) FW_CMD_LEN16_V(sizeof(fw_struct) / 16)
  380. enum {
  381. MAX_ETH_QSETS = 32, /* # of Ethernet Tx/Rx queue sets */
  382. MAX_OFLD_QSETS = 16, /* # of offload Tx, iscsi Rx queue sets */
  383. MAX_CTRL_QUEUES = NCHAN, /* # of control Tx queues */
  384. };
  385. enum {
  386. MAX_TXQ_ENTRIES = 16384,
  387. MAX_CTRL_TXQ_ENTRIES = 1024,
  388. MAX_RSPQ_ENTRIES = 16384,
  389. MAX_RX_BUFFERS = 16384,
  390. MIN_TXQ_ENTRIES = 32,
  391. MIN_CTRL_TXQ_ENTRIES = 32,
  392. MIN_RSPQ_ENTRIES = 128,
  393. MIN_FL_ENTRIES = 16
  394. };
  395. enum {
  396. INGQ_EXTRAS = 2, /* firmware event queue and */
  397. /* forwarded interrupts */
  398. MAX_INGQ = MAX_ETH_QSETS + INGQ_EXTRAS,
  399. };
  400. struct adapter;
  401. struct sge_rspq;
  402. #include "cxgb4_dcb.h"
  403. #ifdef CONFIG_CHELSIO_T4_FCOE
  404. #include "cxgb4_fcoe.h"
  405. #endif /* CONFIG_CHELSIO_T4_FCOE */
  406. struct port_info {
  407. struct adapter *adapter;
  408. u16 viid;
  409. s16 xact_addr_filt; /* index of exact MAC address filter */
  410. u16 rss_size; /* size of VI's RSS table slice */
  411. s8 mdio_addr;
  412. enum fw_port_type port_type;
  413. u8 mod_type;
  414. u8 port_id;
  415. u8 tx_chan;
  416. u8 lport; /* associated offload logical port */
  417. u8 nqsets; /* # of qsets */
  418. u8 first_qset; /* index of first qset */
  419. u8 rss_mode;
  420. struct link_config link_cfg;
  421. u16 *rss;
  422. struct port_stats stats_base;
  423. #ifdef CONFIG_CHELSIO_T4_DCB
  424. struct port_dcb_info dcb; /* Data Center Bridging support */
  425. #endif
  426. #ifdef CONFIG_CHELSIO_T4_FCOE
  427. struct cxgb_fcoe fcoe;
  428. #endif /* CONFIG_CHELSIO_T4_FCOE */
  429. bool rxtstamp; /* Enable TS */
  430. struct hwtstamp_config tstamp_config;
  431. struct sched_table *sched_tbl;
  432. };
  433. struct dentry;
  434. struct work_struct;
  435. enum { /* adapter flags */
  436. FULL_INIT_DONE = (1 << 0),
  437. DEV_ENABLED = (1 << 1),
  438. USING_MSI = (1 << 2),
  439. USING_MSIX = (1 << 3),
  440. FW_OK = (1 << 4),
  441. RSS_TNLALLLOOKUP = (1 << 5),
  442. USING_SOFT_PARAMS = (1 << 6),
  443. MASTER_PF = (1 << 7),
  444. FW_OFLD_CONN = (1 << 9),
  445. };
  446. enum {
  447. ULP_CRYPTO_LOOKASIDE = 1 << 0,
  448. };
  449. struct rx_sw_desc;
  450. struct sge_fl { /* SGE free-buffer queue state */
  451. unsigned int avail; /* # of available Rx buffers */
  452. unsigned int pend_cred; /* new buffers since last FL DB ring */
  453. unsigned int cidx; /* consumer index */
  454. unsigned int pidx; /* producer index */
  455. unsigned long alloc_failed; /* # of times buffer allocation failed */
  456. unsigned long large_alloc_failed;
  457. unsigned long mapping_err; /* # of RX Buffer DMA Mapping failures */
  458. unsigned long low; /* # of times momentarily starving */
  459. unsigned long starving;
  460. /* RO fields */
  461. unsigned int cntxt_id; /* SGE context id for the free list */
  462. unsigned int size; /* capacity of free list */
  463. struct rx_sw_desc *sdesc; /* address of SW Rx descriptor ring */
  464. __be64 *desc; /* address of HW Rx descriptor ring */
  465. dma_addr_t addr; /* bus address of HW ring start */
  466. void __iomem *bar2_addr; /* address of BAR2 Queue registers */
  467. unsigned int bar2_qid; /* Queue ID for BAR2 Queue registers */
  468. };
  469. /* A packet gather list */
  470. struct pkt_gl {
  471. u64 sgetstamp; /* SGE Time Stamp for Ingress Packet */
  472. struct page_frag frags[MAX_SKB_FRAGS];
  473. void *va; /* virtual address of first byte */
  474. unsigned int nfrags; /* # of fragments */
  475. unsigned int tot_len; /* total length of fragments */
  476. };
  477. typedef int (*rspq_handler_t)(struct sge_rspq *q, const __be64 *rsp,
  478. const struct pkt_gl *gl);
  479. typedef void (*rspq_flush_handler_t)(struct sge_rspq *q);
  480. /* LRO related declarations for ULD */
  481. struct t4_lro_mgr {
  482. #define MAX_LRO_SESSIONS 64
  483. u8 lro_session_cnt; /* # of sessions to aggregate */
  484. unsigned long lro_pkts; /* # of LRO super packets */
  485. unsigned long lro_merged; /* # of wire packets merged by LRO */
  486. struct sk_buff_head lroq; /* list of aggregated sessions */
  487. };
  488. struct sge_rspq { /* state for an SGE response queue */
  489. struct napi_struct napi;
  490. const __be64 *cur_desc; /* current descriptor in queue */
  491. unsigned int cidx; /* consumer index */
  492. u8 gen; /* current generation bit */
  493. u8 intr_params; /* interrupt holdoff parameters */
  494. u8 next_intr_params; /* holdoff params for next interrupt */
  495. u8 adaptive_rx;
  496. u8 pktcnt_idx; /* interrupt packet threshold */
  497. u8 uld; /* ULD handling this queue */
  498. u8 idx; /* queue index within its group */
  499. int offset; /* offset into current Rx buffer */
  500. u16 cntxt_id; /* SGE context id for the response q */
  501. u16 abs_id; /* absolute SGE id for the response q */
  502. __be64 *desc; /* address of HW response ring */
  503. dma_addr_t phys_addr; /* physical address of the ring */
  504. void __iomem *bar2_addr; /* address of BAR2 Queue registers */
  505. unsigned int bar2_qid; /* Queue ID for BAR2 Queue registers */
  506. unsigned int iqe_len; /* entry size */
  507. unsigned int size; /* capacity of response queue */
  508. struct adapter *adap;
  509. struct net_device *netdev; /* associated net device */
  510. rspq_handler_t handler;
  511. rspq_flush_handler_t flush_handler;
  512. struct t4_lro_mgr lro_mgr;
  513. #ifdef CONFIG_NET_RX_BUSY_POLL
  514. #define CXGB_POLL_STATE_IDLE 0
  515. #define CXGB_POLL_STATE_NAPI BIT(0) /* NAPI owns this poll */
  516. #define CXGB_POLL_STATE_POLL BIT(1) /* poll owns this poll */
  517. #define CXGB_POLL_STATE_NAPI_YIELD BIT(2) /* NAPI yielded this poll */
  518. #define CXGB_POLL_STATE_POLL_YIELD BIT(3) /* poll yielded this poll */
  519. #define CXGB_POLL_YIELD (CXGB_POLL_STATE_NAPI_YIELD | \
  520. CXGB_POLL_STATE_POLL_YIELD)
  521. #define CXGB_POLL_LOCKED (CXGB_POLL_STATE_NAPI | \
  522. CXGB_POLL_STATE_POLL)
  523. #define CXGB_POLL_USER_PEND (CXGB_POLL_STATE_POLL | \
  524. CXGB_POLL_STATE_POLL_YIELD)
  525. unsigned int bpoll_state;
  526. spinlock_t bpoll_lock; /* lock for busy poll */
  527. #endif /* CONFIG_NET_RX_BUSY_POLL */
  528. };
  529. struct sge_eth_stats { /* Ethernet queue statistics */
  530. unsigned long pkts; /* # of ethernet packets */
  531. unsigned long lro_pkts; /* # of LRO super packets */
  532. unsigned long lro_merged; /* # of wire packets merged by LRO */
  533. unsigned long rx_cso; /* # of Rx checksum offloads */
  534. unsigned long vlan_ex; /* # of Rx VLAN extractions */
  535. unsigned long rx_drops; /* # of packets dropped due to no mem */
  536. };
  537. struct sge_eth_rxq { /* SW Ethernet Rx queue */
  538. struct sge_rspq rspq;
  539. struct sge_fl fl;
  540. struct sge_eth_stats stats;
  541. } ____cacheline_aligned_in_smp;
  542. struct sge_ofld_stats { /* offload queue statistics */
  543. unsigned long pkts; /* # of packets */
  544. unsigned long imm; /* # of immediate-data packets */
  545. unsigned long an; /* # of asynchronous notifications */
  546. unsigned long nomem; /* # of responses deferred due to no mem */
  547. };
  548. struct sge_ofld_rxq { /* SW offload Rx queue */
  549. struct sge_rspq rspq;
  550. struct sge_fl fl;
  551. struct sge_ofld_stats stats;
  552. } ____cacheline_aligned_in_smp;
  553. struct tx_desc {
  554. __be64 flit[8];
  555. };
  556. struct tx_sw_desc;
  557. struct sge_txq {
  558. unsigned int in_use; /* # of in-use Tx descriptors */
  559. unsigned int q_type; /* Q type Eth/Ctrl/Ofld */
  560. unsigned int size; /* # of descriptors */
  561. unsigned int cidx; /* SW consumer index */
  562. unsigned int pidx; /* producer index */
  563. unsigned long stops; /* # of times q has been stopped */
  564. unsigned long restarts; /* # of queue restarts */
  565. unsigned int cntxt_id; /* SGE context id for the Tx q */
  566. struct tx_desc *desc; /* address of HW Tx descriptor ring */
  567. struct tx_sw_desc *sdesc; /* address of SW Tx descriptor ring */
  568. struct sge_qstat *stat; /* queue status entry */
  569. dma_addr_t phys_addr; /* physical address of the ring */
  570. spinlock_t db_lock;
  571. int db_disabled;
  572. unsigned short db_pidx;
  573. unsigned short db_pidx_inc;
  574. void __iomem *bar2_addr; /* address of BAR2 Queue registers */
  575. unsigned int bar2_qid; /* Queue ID for BAR2 Queue registers */
  576. };
  577. struct sge_eth_txq { /* state for an SGE Ethernet Tx queue */
  578. struct sge_txq q;
  579. struct netdev_queue *txq; /* associated netdev TX queue */
  580. #ifdef CONFIG_CHELSIO_T4_DCB
  581. u8 dcb_prio; /* DCB Priority bound to queue */
  582. #endif
  583. unsigned long tso; /* # of TSO requests */
  584. unsigned long tx_cso; /* # of Tx checksum offloads */
  585. unsigned long vlan_ins; /* # of Tx VLAN insertions */
  586. unsigned long mapping_err; /* # of I/O MMU packet mapping errors */
  587. } ____cacheline_aligned_in_smp;
  588. struct sge_uld_txq { /* state for an SGE offload Tx queue */
  589. struct sge_txq q;
  590. struct adapter *adap;
  591. struct sk_buff_head sendq; /* list of backpressured packets */
  592. struct tasklet_struct qresume_tsk; /* restarts the queue */
  593. bool service_ofldq_running; /* service_ofldq() is processing sendq */
  594. u8 full; /* the Tx ring is full */
  595. unsigned long mapping_err; /* # of I/O MMU packet mapping errors */
  596. } ____cacheline_aligned_in_smp;
  597. struct sge_ctrl_txq { /* state for an SGE control Tx queue */
  598. struct sge_txq q;
  599. struct adapter *adap;
  600. struct sk_buff_head sendq; /* list of backpressured packets */
  601. struct tasklet_struct qresume_tsk; /* restarts the queue */
  602. u8 full; /* the Tx ring is full */
  603. } ____cacheline_aligned_in_smp;
  604. struct sge_uld_rxq_info {
  605. char name[IFNAMSIZ]; /* name of ULD driver */
  606. struct sge_ofld_rxq *uldrxq; /* Rxq's for ULD */
  607. u16 *msix_tbl; /* msix_tbl for uld */
  608. u16 *rspq_id; /* response queue id's of rxq */
  609. u16 nrxq; /* # of ingress uld queues */
  610. u16 nciq; /* # of completion queues */
  611. u8 uld; /* uld type */
  612. };
  613. struct sge_uld_txq_info {
  614. struct sge_uld_txq *uldtxq; /* Txq's for ULD */
  615. atomic_t users; /* num users */
  616. u16 ntxq; /* # of egress uld queues */
  617. };
  618. struct sge {
  619. struct sge_eth_txq ethtxq[MAX_ETH_QSETS];
  620. struct sge_ctrl_txq ctrlq[MAX_CTRL_QUEUES];
  621. struct sge_eth_rxq ethrxq[MAX_ETH_QSETS];
  622. struct sge_rspq fw_evtq ____cacheline_aligned_in_smp;
  623. struct sge_uld_rxq_info **uld_rxq_info;
  624. struct sge_uld_txq_info **uld_txq_info;
  625. struct sge_rspq intrq ____cacheline_aligned_in_smp;
  626. spinlock_t intrq_lock;
  627. u16 max_ethqsets; /* # of available Ethernet queue sets */
  628. u16 ethqsets; /* # of active Ethernet queue sets */
  629. u16 ethtxq_rover; /* Tx queue to clean up next */
  630. u16 ofldqsets; /* # of active ofld queue sets */
  631. u16 nqs_per_uld; /* # of Rx queues per ULD */
  632. u16 timer_val[SGE_NTIMERS];
  633. u8 counter_val[SGE_NCOUNTERS];
  634. u32 fl_pg_order; /* large page allocation size */
  635. u32 stat_len; /* length of status page at ring end */
  636. u32 pktshift; /* padding between CPL & packet data */
  637. u32 fl_align; /* response queue message alignment */
  638. u32 fl_starve_thres; /* Free List starvation threshold */
  639. struct sge_idma_monitor_state idma_monitor;
  640. unsigned int egr_start;
  641. unsigned int egr_sz;
  642. unsigned int ingr_start;
  643. unsigned int ingr_sz;
  644. void **egr_map; /* qid->queue egress queue map */
  645. struct sge_rspq **ingr_map; /* qid->queue ingress queue map */
  646. unsigned long *starving_fl;
  647. unsigned long *txq_maperr;
  648. unsigned long *blocked_fl;
  649. struct timer_list rx_timer; /* refills starving FLs */
  650. struct timer_list tx_timer; /* checks Tx queues */
  651. };
  652. #define for_each_ethrxq(sge, i) for (i = 0; i < (sge)->ethqsets; i++)
  653. #define for_each_ofldtxq(sge, i) for (i = 0; i < (sge)->ofldqsets; i++)
  654. struct l2t_data;
  655. #ifdef CONFIG_PCI_IOV
  656. /* T4 supports SRIOV on PF0-3 and T5 on PF0-7. However, the Serial
  657. * Configuration initialization for T5 only has SR-IOV functionality enabled
  658. * on PF0-3 in order to simplify everything.
  659. */
  660. #define NUM_OF_PF_WITH_SRIOV 4
  661. #endif
  662. struct doorbell_stats {
  663. u32 db_drop;
  664. u32 db_empty;
  665. u32 db_full;
  666. };
  667. struct hash_mac_addr {
  668. struct list_head list;
  669. u8 addr[ETH_ALEN];
  670. };
  671. struct uld_msix_bmap {
  672. unsigned long *msix_bmap;
  673. unsigned int mapsize;
  674. spinlock_t lock; /* lock for acquiring bitmap */
  675. };
  676. struct uld_msix_info {
  677. unsigned short vec;
  678. char desc[IFNAMSIZ + 10];
  679. unsigned int idx;
  680. };
  681. struct vf_info {
  682. unsigned char vf_mac_addr[ETH_ALEN];
  683. bool pf_set_mac;
  684. };
  685. struct adapter {
  686. void __iomem *regs;
  687. void __iomem *bar2;
  688. u32 t4_bar0;
  689. struct pci_dev *pdev;
  690. struct device *pdev_dev;
  691. const char *name;
  692. unsigned int mbox;
  693. unsigned int pf;
  694. unsigned int flags;
  695. unsigned int adap_idx;
  696. enum chip_type chip;
  697. int msg_enable;
  698. struct adapter_params params;
  699. struct cxgb4_virt_res vres;
  700. unsigned int swintr;
  701. struct {
  702. unsigned short vec;
  703. char desc[IFNAMSIZ + 10];
  704. } msix_info[MAX_INGQ + 1];
  705. struct uld_msix_info *msix_info_ulds; /* msix info for uld's */
  706. struct uld_msix_bmap msix_bmap_ulds; /* msix bitmap for all uld */
  707. int msi_idx;
  708. struct doorbell_stats db_stats;
  709. struct sge sge;
  710. struct net_device *port[MAX_NPORTS];
  711. u8 chan_map[NCHAN]; /* channel -> port map */
  712. struct vf_info *vfinfo;
  713. u8 num_vfs;
  714. u32 filter_mode;
  715. unsigned int l2t_start;
  716. unsigned int l2t_end;
  717. struct l2t_data *l2t;
  718. unsigned int clipt_start;
  719. unsigned int clipt_end;
  720. struct clip_tbl *clipt;
  721. struct cxgb4_uld_info *uld;
  722. void *uld_handle[CXGB4_ULD_MAX];
  723. unsigned int num_uld;
  724. unsigned int num_ofld_uld;
  725. struct list_head list_node;
  726. struct list_head rcu_node;
  727. struct list_head mac_hlist; /* list of MAC addresses in MPS Hash */
  728. void *iscsi_ppm;
  729. struct tid_info tids;
  730. void **tid_release_head;
  731. spinlock_t tid_release_lock;
  732. struct workqueue_struct *workq;
  733. struct work_struct tid_release_task;
  734. struct work_struct db_full_task;
  735. struct work_struct db_drop_task;
  736. bool tid_release_task_busy;
  737. /* support for mailbox command/reply logging */
  738. #define T4_OS_LOG_MBOX_CMDS 256
  739. struct mbox_cmd_log *mbox_log;
  740. struct mutex uld_mutex;
  741. struct dentry *debugfs_root;
  742. bool use_bd; /* Use SGE Back Door intfc for reading SGE Contexts */
  743. bool trace_rss; /* 1 implies that different RSS flit per filter is
  744. * used per filter else if 0 default RSS flit is
  745. * used for all 4 filters.
  746. */
  747. spinlock_t stats_lock;
  748. spinlock_t win0_lock ____cacheline_aligned_in_smp;
  749. /* TC u32 offload */
  750. struct cxgb4_tc_u32_table *tc_u32;
  751. };
  752. /* Support for "sched-class" command to allow a TX Scheduling Class to be
  753. * programmed with various parameters.
  754. */
  755. struct ch_sched_params {
  756. s8 type; /* packet or flow */
  757. union {
  758. struct {
  759. s8 level; /* scheduler hierarchy level */
  760. s8 mode; /* per-class or per-flow */
  761. s8 rateunit; /* bit or packet rate */
  762. s8 ratemode; /* %port relative or kbps absolute */
  763. s8 channel; /* scheduler channel [0..N] */
  764. s8 class; /* scheduler class [0..N] */
  765. s32 minrate; /* minimum rate */
  766. s32 maxrate; /* maximum rate */
  767. s16 weight; /* percent weight */
  768. s16 pktsize; /* average packet size */
  769. } params;
  770. } u;
  771. };
  772. enum {
  773. SCHED_CLASS_TYPE_PACKET = 0, /* class type */
  774. };
  775. enum {
  776. SCHED_CLASS_LEVEL_CL_RL = 0, /* class rate limiter */
  777. };
  778. enum {
  779. SCHED_CLASS_MODE_CLASS = 0, /* per-class scheduling */
  780. };
  781. enum {
  782. SCHED_CLASS_RATEUNIT_BITS = 0, /* bit rate scheduling */
  783. };
  784. enum {
  785. SCHED_CLASS_RATEMODE_ABS = 1, /* Kb/s */
  786. };
  787. /* Support for "sched_queue" command to allow one or more NIC TX Queues
  788. * to be bound to a TX Scheduling Class.
  789. */
  790. struct ch_sched_queue {
  791. s8 queue; /* queue index */
  792. s8 class; /* class index */
  793. };
  794. /* Defined bit width of user definable filter tuples
  795. */
  796. #define ETHTYPE_BITWIDTH 16
  797. #define FRAG_BITWIDTH 1
  798. #define MACIDX_BITWIDTH 9
  799. #define FCOE_BITWIDTH 1
  800. #define IPORT_BITWIDTH 3
  801. #define MATCHTYPE_BITWIDTH 3
  802. #define PROTO_BITWIDTH 8
  803. #define TOS_BITWIDTH 8
  804. #define PF_BITWIDTH 8
  805. #define VF_BITWIDTH 8
  806. #define IVLAN_BITWIDTH 16
  807. #define OVLAN_BITWIDTH 16
  808. /* Filter matching rules. These consist of a set of ingress packet field
  809. * (value, mask) tuples. The associated ingress packet field matches the
  810. * tuple when ((field & mask) == value). (Thus a wildcard "don't care" field
  811. * rule can be constructed by specifying a tuple of (0, 0).) A filter rule
  812. * matches an ingress packet when all of the individual individual field
  813. * matching rules are true.
  814. *
  815. * Partial field masks are always valid, however, while it may be easy to
  816. * understand their meanings for some fields (e.g. IP address to match a
  817. * subnet), for others making sensible partial masks is less intuitive (e.g.
  818. * MPS match type) ...
  819. *
  820. * Most of the following data structures are modeled on T4 capabilities.
  821. * Drivers for earlier chips use the subsets which make sense for those chips.
  822. * We really need to come up with a hardware-independent mechanism to
  823. * represent hardware filter capabilities ...
  824. */
  825. struct ch_filter_tuple {
  826. /* Compressed header matching field rules. The TP_VLAN_PRI_MAP
  827. * register selects which of these fields will participate in the
  828. * filter match rules -- up to a maximum of 36 bits. Because
  829. * TP_VLAN_PRI_MAP is a global register, all filters must use the same
  830. * set of fields.
  831. */
  832. uint32_t ethtype:ETHTYPE_BITWIDTH; /* Ethernet type */
  833. uint32_t frag:FRAG_BITWIDTH; /* IP fragmentation header */
  834. uint32_t ivlan_vld:1; /* inner VLAN valid */
  835. uint32_t ovlan_vld:1; /* outer VLAN valid */
  836. uint32_t pfvf_vld:1; /* PF/VF valid */
  837. uint32_t macidx:MACIDX_BITWIDTH; /* exact match MAC index */
  838. uint32_t fcoe:FCOE_BITWIDTH; /* FCoE packet */
  839. uint32_t iport:IPORT_BITWIDTH; /* ingress port */
  840. uint32_t matchtype:MATCHTYPE_BITWIDTH; /* MPS match type */
  841. uint32_t proto:PROTO_BITWIDTH; /* protocol type */
  842. uint32_t tos:TOS_BITWIDTH; /* TOS/Traffic Type */
  843. uint32_t pf:PF_BITWIDTH; /* PCI-E PF ID */
  844. uint32_t vf:VF_BITWIDTH; /* PCI-E VF ID */
  845. uint32_t ivlan:IVLAN_BITWIDTH; /* inner VLAN */
  846. uint32_t ovlan:OVLAN_BITWIDTH; /* outer VLAN */
  847. /* Uncompressed header matching field rules. These are always
  848. * available for field rules.
  849. */
  850. uint8_t lip[16]; /* local IP address (IPv4 in [3:0]) */
  851. uint8_t fip[16]; /* foreign IP address (IPv4 in [3:0]) */
  852. uint16_t lport; /* local port */
  853. uint16_t fport; /* foreign port */
  854. };
  855. /* A filter ioctl command.
  856. */
  857. struct ch_filter_specification {
  858. /* Administrative fields for filter.
  859. */
  860. uint32_t hitcnts:1; /* count filter hits in TCB */
  861. uint32_t prio:1; /* filter has priority over active/server */
  862. /* Fundamental filter typing. This is the one element of filter
  863. * matching that doesn't exist as a (value, mask) tuple.
  864. */
  865. uint32_t type:1; /* 0 => IPv4, 1 => IPv6 */
  866. /* Packet dispatch information. Ingress packets which match the
  867. * filter rules will be dropped, passed to the host or switched back
  868. * out as egress packets.
  869. */
  870. uint32_t action:2; /* drop, pass, switch */
  871. uint32_t rpttid:1; /* report TID in RSS hash field */
  872. uint32_t dirsteer:1; /* 0 => RSS, 1 => steer to iq */
  873. uint32_t iq:10; /* ingress queue */
  874. uint32_t maskhash:1; /* dirsteer=0: store RSS hash in TCB */
  875. uint32_t dirsteerhash:1;/* dirsteer=1: 0 => TCB contains RSS hash */
  876. /* 1 => TCB contains IQ ID */
  877. /* Switch proxy/rewrite fields. An ingress packet which matches a
  878. * filter with "switch" set will be looped back out as an egress
  879. * packet -- potentially with some Ethernet header rewriting.
  880. */
  881. uint32_t eport:2; /* egress port to switch packet out */
  882. uint32_t newdmac:1; /* rewrite destination MAC address */
  883. uint32_t newsmac:1; /* rewrite source MAC address */
  884. uint32_t newvlan:2; /* rewrite VLAN Tag */
  885. uint8_t dmac[ETH_ALEN]; /* new destination MAC address */
  886. uint8_t smac[ETH_ALEN]; /* new source MAC address */
  887. uint16_t vlan; /* VLAN Tag to insert */
  888. /* Filter rule value/mask pairs.
  889. */
  890. struct ch_filter_tuple val;
  891. struct ch_filter_tuple mask;
  892. };
  893. enum {
  894. FILTER_PASS = 0, /* default */
  895. FILTER_DROP,
  896. FILTER_SWITCH
  897. };
  898. enum {
  899. VLAN_NOCHANGE = 0, /* default */
  900. VLAN_REMOVE,
  901. VLAN_INSERT,
  902. VLAN_REWRITE
  903. };
  904. /* Host shadow copy of ingress filter entry. This is in host native format
  905. * and doesn't match the ordering or bit order, etc. of the hardware of the
  906. * firmware command. The use of bit-field structure elements is purely to
  907. * remind ourselves of the field size limitations and save memory in the case
  908. * where the filter table is large.
  909. */
  910. struct filter_entry {
  911. /* Administrative fields for filter. */
  912. u32 valid:1; /* filter allocated and valid */
  913. u32 locked:1; /* filter is administratively locked */
  914. u32 pending:1; /* filter action is pending firmware reply */
  915. u32 smtidx:8; /* Source MAC Table index for smac */
  916. struct filter_ctx *ctx; /* Caller's completion hook */
  917. struct l2t_entry *l2t; /* Layer Two Table entry for dmac */
  918. struct net_device *dev; /* Associated net device */
  919. u32 tid; /* This will store the actual tid */
  920. /* The filter itself. Most of this is a straight copy of information
  921. * provided by the extended ioctl(). Some fields are translated to
  922. * internal forms -- for instance the Ingress Queue ID passed in from
  923. * the ioctl() is translated into the Absolute Ingress Queue ID.
  924. */
  925. struct ch_filter_specification fs;
  926. };
  927. static inline int is_offload(const struct adapter *adap)
  928. {
  929. return adap->params.offload;
  930. }
  931. static inline int is_pci_uld(const struct adapter *adap)
  932. {
  933. return adap->params.crypto;
  934. }
  935. static inline int is_uld(const struct adapter *adap)
  936. {
  937. return (adap->params.offload || adap->params.crypto);
  938. }
  939. static inline u32 t4_read_reg(struct adapter *adap, u32 reg_addr)
  940. {
  941. return readl(adap->regs + reg_addr);
  942. }
  943. static inline void t4_write_reg(struct adapter *adap, u32 reg_addr, u32 val)
  944. {
  945. writel(val, adap->regs + reg_addr);
  946. }
  947. #ifndef readq
  948. static inline u64 readq(const volatile void __iomem *addr)
  949. {
  950. return readl(addr) + ((u64)readl(addr + 4) << 32);
  951. }
  952. static inline void writeq(u64 val, volatile void __iomem *addr)
  953. {
  954. writel(val, addr);
  955. writel(val >> 32, addr + 4);
  956. }
  957. #endif
  958. static inline u64 t4_read_reg64(struct adapter *adap, u32 reg_addr)
  959. {
  960. return readq(adap->regs + reg_addr);
  961. }
  962. static inline void t4_write_reg64(struct adapter *adap, u32 reg_addr, u64 val)
  963. {
  964. writeq(val, adap->regs + reg_addr);
  965. }
  966. /**
  967. * t4_set_hw_addr - store a port's MAC address in SW
  968. * @adapter: the adapter
  969. * @port_idx: the port index
  970. * @hw_addr: the Ethernet address
  971. *
  972. * Store the Ethernet address of the given port in SW. Called by the common
  973. * code when it retrieves a port's Ethernet address from EEPROM.
  974. */
  975. static inline void t4_set_hw_addr(struct adapter *adapter, int port_idx,
  976. u8 hw_addr[])
  977. {
  978. ether_addr_copy(adapter->port[port_idx]->dev_addr, hw_addr);
  979. ether_addr_copy(adapter->port[port_idx]->perm_addr, hw_addr);
  980. }
  981. /**
  982. * netdev2pinfo - return the port_info structure associated with a net_device
  983. * @dev: the netdev
  984. *
  985. * Return the struct port_info associated with a net_device
  986. */
  987. static inline struct port_info *netdev2pinfo(const struct net_device *dev)
  988. {
  989. return netdev_priv(dev);
  990. }
  991. /**
  992. * adap2pinfo - return the port_info of a port
  993. * @adap: the adapter
  994. * @idx: the port index
  995. *
  996. * Return the port_info structure for the port of the given index.
  997. */
  998. static inline struct port_info *adap2pinfo(struct adapter *adap, int idx)
  999. {
  1000. return netdev_priv(adap->port[idx]);
  1001. }
  1002. /**
  1003. * netdev2adap - return the adapter structure associated with a net_device
  1004. * @dev: the netdev
  1005. *
  1006. * Return the struct adapter associated with a net_device
  1007. */
  1008. static inline struct adapter *netdev2adap(const struct net_device *dev)
  1009. {
  1010. return netdev2pinfo(dev)->adapter;
  1011. }
  1012. #ifdef CONFIG_NET_RX_BUSY_POLL
  1013. static inline void cxgb_busy_poll_init_lock(struct sge_rspq *q)
  1014. {
  1015. spin_lock_init(&q->bpoll_lock);
  1016. q->bpoll_state = CXGB_POLL_STATE_IDLE;
  1017. }
  1018. static inline bool cxgb_poll_lock_napi(struct sge_rspq *q)
  1019. {
  1020. bool rc = true;
  1021. spin_lock(&q->bpoll_lock);
  1022. if (q->bpoll_state & CXGB_POLL_LOCKED) {
  1023. q->bpoll_state |= CXGB_POLL_STATE_NAPI_YIELD;
  1024. rc = false;
  1025. } else {
  1026. q->bpoll_state = CXGB_POLL_STATE_NAPI;
  1027. }
  1028. spin_unlock(&q->bpoll_lock);
  1029. return rc;
  1030. }
  1031. static inline bool cxgb_poll_unlock_napi(struct sge_rspq *q)
  1032. {
  1033. bool rc = false;
  1034. spin_lock(&q->bpoll_lock);
  1035. if (q->bpoll_state & CXGB_POLL_STATE_POLL_YIELD)
  1036. rc = true;
  1037. q->bpoll_state = CXGB_POLL_STATE_IDLE;
  1038. spin_unlock(&q->bpoll_lock);
  1039. return rc;
  1040. }
  1041. static inline bool cxgb_poll_lock_poll(struct sge_rspq *q)
  1042. {
  1043. bool rc = true;
  1044. spin_lock_bh(&q->bpoll_lock);
  1045. if (q->bpoll_state & CXGB_POLL_LOCKED) {
  1046. q->bpoll_state |= CXGB_POLL_STATE_POLL_YIELD;
  1047. rc = false;
  1048. } else {
  1049. q->bpoll_state |= CXGB_POLL_STATE_POLL;
  1050. }
  1051. spin_unlock_bh(&q->bpoll_lock);
  1052. return rc;
  1053. }
  1054. static inline bool cxgb_poll_unlock_poll(struct sge_rspq *q)
  1055. {
  1056. bool rc = false;
  1057. spin_lock_bh(&q->bpoll_lock);
  1058. if (q->bpoll_state & CXGB_POLL_STATE_POLL_YIELD)
  1059. rc = true;
  1060. q->bpoll_state = CXGB_POLL_STATE_IDLE;
  1061. spin_unlock_bh(&q->bpoll_lock);
  1062. return rc;
  1063. }
  1064. static inline bool cxgb_poll_busy_polling(struct sge_rspq *q)
  1065. {
  1066. return q->bpoll_state & CXGB_POLL_USER_PEND;
  1067. }
  1068. #else
  1069. static inline void cxgb_busy_poll_init_lock(struct sge_rspq *q)
  1070. {
  1071. }
  1072. static inline bool cxgb_poll_lock_napi(struct sge_rspq *q)
  1073. {
  1074. return true;
  1075. }
  1076. static inline bool cxgb_poll_unlock_napi(struct sge_rspq *q)
  1077. {
  1078. return false;
  1079. }
  1080. static inline bool cxgb_poll_lock_poll(struct sge_rspq *q)
  1081. {
  1082. return false;
  1083. }
  1084. static inline bool cxgb_poll_unlock_poll(struct sge_rspq *q)
  1085. {
  1086. return false;
  1087. }
  1088. static inline bool cxgb_poll_busy_polling(struct sge_rspq *q)
  1089. {
  1090. return false;
  1091. }
  1092. #endif /* CONFIG_NET_RX_BUSY_POLL */
  1093. /* Return a version number to identify the type of adapter. The scheme is:
  1094. * - bits 0..9: chip version
  1095. * - bits 10..15: chip revision
  1096. * - bits 16..23: register dump version
  1097. */
  1098. static inline unsigned int mk_adap_vers(struct adapter *ap)
  1099. {
  1100. return CHELSIO_CHIP_VERSION(ap->params.chip) |
  1101. (CHELSIO_CHIP_RELEASE(ap->params.chip) << 10) | (1 << 16);
  1102. }
  1103. /* Return a queue's interrupt hold-off time in us. 0 means no timer. */
  1104. static inline unsigned int qtimer_val(const struct adapter *adap,
  1105. const struct sge_rspq *q)
  1106. {
  1107. unsigned int idx = q->intr_params >> 1;
  1108. return idx < SGE_NTIMERS ? adap->sge.timer_val[idx] : 0;
  1109. }
  1110. /* driver version & name used for ethtool_drvinfo */
  1111. extern char cxgb4_driver_name[];
  1112. extern const char cxgb4_driver_version[];
  1113. void t4_os_portmod_changed(const struct adapter *adap, int port_id);
  1114. void t4_os_link_changed(struct adapter *adap, int port_id, int link_stat);
  1115. void *t4_alloc_mem(size_t size);
  1116. void t4_free_sge_resources(struct adapter *adap);
  1117. void t4_free_ofld_rxqs(struct adapter *adap, int n, struct sge_ofld_rxq *q);
  1118. irq_handler_t t4_intr_handler(struct adapter *adap);
  1119. netdev_tx_t t4_eth_xmit(struct sk_buff *skb, struct net_device *dev);
  1120. int t4_ethrx_handler(struct sge_rspq *q, const __be64 *rsp,
  1121. const struct pkt_gl *gl);
  1122. int t4_mgmt_tx(struct adapter *adap, struct sk_buff *skb);
  1123. int t4_ofld_send(struct adapter *adap, struct sk_buff *skb);
  1124. int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
  1125. struct net_device *dev, int intr_idx,
  1126. struct sge_fl *fl, rspq_handler_t hnd,
  1127. rspq_flush_handler_t flush_handler, int cong);
  1128. int t4_sge_alloc_eth_txq(struct adapter *adap, struct sge_eth_txq *txq,
  1129. struct net_device *dev, struct netdev_queue *netdevq,
  1130. unsigned int iqid);
  1131. int t4_sge_alloc_ctrl_txq(struct adapter *adap, struct sge_ctrl_txq *txq,
  1132. struct net_device *dev, unsigned int iqid,
  1133. unsigned int cmplqid);
  1134. int t4_sge_mod_ctrl_txq(struct adapter *adap, unsigned int eqid,
  1135. unsigned int cmplqid);
  1136. int t4_sge_alloc_uld_txq(struct adapter *adap, struct sge_uld_txq *txq,
  1137. struct net_device *dev, unsigned int iqid,
  1138. unsigned int uld_type);
  1139. irqreturn_t t4_sge_intr_msix(int irq, void *cookie);
  1140. int t4_sge_init(struct adapter *adap);
  1141. void t4_sge_start(struct adapter *adap);
  1142. void t4_sge_stop(struct adapter *adap);
  1143. int cxgb_busy_poll(struct napi_struct *napi);
  1144. void cxgb4_set_ethtool_ops(struct net_device *netdev);
  1145. int cxgb4_write_rss(const struct port_info *pi, const u16 *queues);
  1146. extern int dbfifo_int_thresh;
  1147. #define for_each_port(adapter, iter) \
  1148. for (iter = 0; iter < (adapter)->params.nports; ++iter)
  1149. static inline int is_bypass(struct adapter *adap)
  1150. {
  1151. return adap->params.bypass;
  1152. }
  1153. static inline int is_bypass_device(int device)
  1154. {
  1155. /* this should be set based upon device capabilities */
  1156. switch (device) {
  1157. case 0x440b:
  1158. case 0x440c:
  1159. return 1;
  1160. default:
  1161. return 0;
  1162. }
  1163. }
  1164. static inline int is_10gbt_device(int device)
  1165. {
  1166. /* this should be set based upon device capabilities */
  1167. switch (device) {
  1168. case 0x4409:
  1169. case 0x4486:
  1170. return 1;
  1171. default:
  1172. return 0;
  1173. }
  1174. }
  1175. static inline unsigned int core_ticks_per_usec(const struct adapter *adap)
  1176. {
  1177. return adap->params.vpd.cclk / 1000;
  1178. }
  1179. static inline unsigned int us_to_core_ticks(const struct adapter *adap,
  1180. unsigned int us)
  1181. {
  1182. return (us * adap->params.vpd.cclk) / 1000;
  1183. }
  1184. static inline unsigned int core_ticks_to_us(const struct adapter *adapter,
  1185. unsigned int ticks)
  1186. {
  1187. /* add Core Clock / 2 to round ticks to nearest uS */
  1188. return ((ticks * 1000 + adapter->params.vpd.cclk/2) /
  1189. adapter->params.vpd.cclk);
  1190. }
  1191. void t4_set_reg_field(struct adapter *adap, unsigned int addr, u32 mask,
  1192. u32 val);
  1193. int t4_wr_mbox_meat_timeout(struct adapter *adap, int mbox, const void *cmd,
  1194. int size, void *rpl, bool sleep_ok, int timeout);
  1195. int t4_wr_mbox_meat(struct adapter *adap, int mbox, const void *cmd, int size,
  1196. void *rpl, bool sleep_ok);
  1197. static inline int t4_wr_mbox_timeout(struct adapter *adap, int mbox,
  1198. const void *cmd, int size, void *rpl,
  1199. int timeout)
  1200. {
  1201. return t4_wr_mbox_meat_timeout(adap, mbox, cmd, size, rpl, true,
  1202. timeout);
  1203. }
  1204. static inline int t4_wr_mbox(struct adapter *adap, int mbox, const void *cmd,
  1205. int size, void *rpl)
  1206. {
  1207. return t4_wr_mbox_meat(adap, mbox, cmd, size, rpl, true);
  1208. }
  1209. static inline int t4_wr_mbox_ns(struct adapter *adap, int mbox, const void *cmd,
  1210. int size, void *rpl)
  1211. {
  1212. return t4_wr_mbox_meat(adap, mbox, cmd, size, rpl, false);
  1213. }
  1214. /**
  1215. * hash_mac_addr - return the hash value of a MAC address
  1216. * @addr: the 48-bit Ethernet MAC address
  1217. *
  1218. * Hashes a MAC address according to the hash function used by HW inexact
  1219. * (hash) address matching.
  1220. */
  1221. static inline int hash_mac_addr(const u8 *addr)
  1222. {
  1223. u32 a = ((u32)addr[0] << 16) | ((u32)addr[1] << 8) | addr[2];
  1224. u32 b = ((u32)addr[3] << 16) | ((u32)addr[4] << 8) | addr[5];
  1225. a ^= b;
  1226. a ^= (a >> 12);
  1227. a ^= (a >> 6);
  1228. return a & 0x3f;
  1229. }
  1230. int cxgb4_set_rspq_intr_params(struct sge_rspq *q, unsigned int us,
  1231. unsigned int cnt);
  1232. static inline void init_rspq(struct adapter *adap, struct sge_rspq *q,
  1233. unsigned int us, unsigned int cnt,
  1234. unsigned int size, unsigned int iqe_size)
  1235. {
  1236. q->adap = adap;
  1237. cxgb4_set_rspq_intr_params(q, us, cnt);
  1238. q->iqe_len = iqe_size;
  1239. q->size = size;
  1240. }
  1241. void t4_write_indirect(struct adapter *adap, unsigned int addr_reg,
  1242. unsigned int data_reg, const u32 *vals,
  1243. unsigned int nregs, unsigned int start_idx);
  1244. void t4_read_indirect(struct adapter *adap, unsigned int addr_reg,
  1245. unsigned int data_reg, u32 *vals, unsigned int nregs,
  1246. unsigned int start_idx);
  1247. void t4_hw_pci_read_cfg4(struct adapter *adapter, int reg, u32 *val);
  1248. struct fw_filter_wr;
  1249. void t4_intr_enable(struct adapter *adapter);
  1250. void t4_intr_disable(struct adapter *adapter);
  1251. int t4_slow_intr_handler(struct adapter *adapter);
  1252. int t4_wait_dev_ready(void __iomem *regs);
  1253. int t4_link_l1cfg(struct adapter *adap, unsigned int mbox, unsigned int port,
  1254. struct link_config *lc);
  1255. int t4_restart_aneg(struct adapter *adap, unsigned int mbox, unsigned int port);
  1256. u32 t4_read_pcie_cfg4(struct adapter *adap, int reg);
  1257. u32 t4_get_util_window(struct adapter *adap);
  1258. void t4_setup_memwin(struct adapter *adap, u32 memwin_base, u32 window);
  1259. #define T4_MEMORY_WRITE 0
  1260. #define T4_MEMORY_READ 1
  1261. int t4_memory_rw(struct adapter *adap, int win, int mtype, u32 addr, u32 len,
  1262. void *buf, int dir);
  1263. static inline int t4_memory_write(struct adapter *adap, int mtype, u32 addr,
  1264. u32 len, __be32 *buf)
  1265. {
  1266. return t4_memory_rw(adap, 0, mtype, addr, len, buf, 0);
  1267. }
  1268. unsigned int t4_get_regs_len(struct adapter *adapter);
  1269. void t4_get_regs(struct adapter *adap, void *buf, size_t buf_size);
  1270. int t4_seeprom_wp(struct adapter *adapter, bool enable);
  1271. int t4_get_raw_vpd_params(struct adapter *adapter, struct vpd_params *p);
  1272. int t4_get_vpd_params(struct adapter *adapter, struct vpd_params *p);
  1273. int t4_read_flash(struct adapter *adapter, unsigned int addr,
  1274. unsigned int nwords, u32 *data, int byte_oriented);
  1275. int t4_load_fw(struct adapter *adapter, const u8 *fw_data, unsigned int size);
  1276. int t4_load_phy_fw(struct adapter *adap,
  1277. int win, spinlock_t *lock,
  1278. int (*phy_fw_version)(const u8 *, size_t),
  1279. const u8 *phy_fw_data, size_t phy_fw_size);
  1280. int t4_phy_fw_ver(struct adapter *adap, int *phy_fw_ver);
  1281. int t4_fwcache(struct adapter *adap, enum fw_params_param_dev_fwcache op);
  1282. int t4_fw_upgrade(struct adapter *adap, unsigned int mbox,
  1283. const u8 *fw_data, unsigned int size, int force);
  1284. int t4_fl_pkt_align(struct adapter *adap);
  1285. unsigned int t4_flash_cfg_addr(struct adapter *adapter);
  1286. int t4_check_fw_version(struct adapter *adap);
  1287. int t4_get_fw_version(struct adapter *adapter, u32 *vers);
  1288. int t4_get_bs_version(struct adapter *adapter, u32 *vers);
  1289. int t4_get_tp_version(struct adapter *adapter, u32 *vers);
  1290. int t4_get_exprom_version(struct adapter *adapter, u32 *vers);
  1291. int t4_prep_fw(struct adapter *adap, struct fw_info *fw_info,
  1292. const u8 *fw_data, unsigned int fw_size,
  1293. struct fw_hdr *card_fw, enum dev_state state, int *reset);
  1294. int t4_prep_adapter(struct adapter *adapter);
  1295. enum t4_bar2_qtype { T4_BAR2_QTYPE_EGRESS, T4_BAR2_QTYPE_INGRESS };
  1296. int t4_bar2_sge_qregs(struct adapter *adapter,
  1297. unsigned int qid,
  1298. enum t4_bar2_qtype qtype,
  1299. int user,
  1300. u64 *pbar2_qoffset,
  1301. unsigned int *pbar2_qid);
  1302. unsigned int qtimer_val(const struct adapter *adap,
  1303. const struct sge_rspq *q);
  1304. int t4_init_devlog_params(struct adapter *adapter);
  1305. int t4_init_sge_params(struct adapter *adapter);
  1306. int t4_init_tp_params(struct adapter *adap);
  1307. int t4_filter_field_shift(const struct adapter *adap, int filter_sel);
  1308. int t4_init_rss_mode(struct adapter *adap, int mbox);
  1309. int t4_init_portinfo(struct port_info *pi, int mbox,
  1310. int port, int pf, int vf, u8 mac[]);
  1311. int t4_port_init(struct adapter *adap, int mbox, int pf, int vf);
  1312. void t4_fatal_err(struct adapter *adapter);
  1313. int t4_config_rss_range(struct adapter *adapter, int mbox, unsigned int viid,
  1314. int start, int n, const u16 *rspq, unsigned int nrspq);
  1315. int t4_config_glbl_rss(struct adapter *adapter, int mbox, unsigned int mode,
  1316. unsigned int flags);
  1317. int t4_config_vi_rss(struct adapter *adapter, int mbox, unsigned int viid,
  1318. unsigned int flags, unsigned int defq);
  1319. int t4_read_rss(struct adapter *adapter, u16 *entries);
  1320. void t4_read_rss_key(struct adapter *adapter, u32 *key);
  1321. void t4_write_rss_key(struct adapter *adap, const u32 *key, int idx);
  1322. void t4_read_rss_pf_config(struct adapter *adapter, unsigned int index,
  1323. u32 *valp);
  1324. void t4_read_rss_vf_config(struct adapter *adapter, unsigned int index,
  1325. u32 *vfl, u32 *vfh);
  1326. u32 t4_read_rss_pf_map(struct adapter *adapter);
  1327. u32 t4_read_rss_pf_mask(struct adapter *adapter);
  1328. unsigned int t4_get_mps_bg_map(struct adapter *adapter, int idx);
  1329. void t4_pmtx_get_stats(struct adapter *adap, u32 cnt[], u64 cycles[]);
  1330. void t4_pmrx_get_stats(struct adapter *adap, u32 cnt[], u64 cycles[]);
  1331. int t4_read_cim_ibq(struct adapter *adap, unsigned int qid, u32 *data,
  1332. size_t n);
  1333. int t4_read_cim_obq(struct adapter *adap, unsigned int qid, u32 *data,
  1334. size_t n);
  1335. int t4_cim_read(struct adapter *adap, unsigned int addr, unsigned int n,
  1336. unsigned int *valp);
  1337. int t4_cim_write(struct adapter *adap, unsigned int addr, unsigned int n,
  1338. const unsigned int *valp);
  1339. int t4_cim_read_la(struct adapter *adap, u32 *la_buf, unsigned int *wrptr);
  1340. void t4_cim_read_pif_la(struct adapter *adap, u32 *pif_req, u32 *pif_rsp,
  1341. unsigned int *pif_req_wrptr,
  1342. unsigned int *pif_rsp_wrptr);
  1343. void t4_cim_read_ma_la(struct adapter *adap, u32 *ma_req, u32 *ma_rsp);
  1344. void t4_read_cimq_cfg(struct adapter *adap, u16 *base, u16 *size, u16 *thres);
  1345. const char *t4_get_port_type_description(enum fw_port_type port_type);
  1346. void t4_get_port_stats(struct adapter *adap, int idx, struct port_stats *p);
  1347. void t4_get_port_stats_offset(struct adapter *adap, int idx,
  1348. struct port_stats *stats,
  1349. struct port_stats *offset);
  1350. void t4_get_lb_stats(struct adapter *adap, int idx, struct lb_port_stats *p);
  1351. void t4_read_mtu_tbl(struct adapter *adap, u16 *mtus, u8 *mtu_log);
  1352. void t4_read_cong_tbl(struct adapter *adap, u16 incr[NMTUS][NCCTRL_WIN]);
  1353. void t4_tp_wr_bits_indirect(struct adapter *adap, unsigned int addr,
  1354. unsigned int mask, unsigned int val);
  1355. void t4_tp_read_la(struct adapter *adap, u64 *la_buf, unsigned int *wrptr);
  1356. void t4_tp_get_err_stats(struct adapter *adap, struct tp_err_stats *st);
  1357. void t4_tp_get_cpl_stats(struct adapter *adap, struct tp_cpl_stats *st);
  1358. void t4_tp_get_rdma_stats(struct adapter *adap, struct tp_rdma_stats *st);
  1359. void t4_get_usm_stats(struct adapter *adap, struct tp_usm_stats *st);
  1360. void t4_tp_get_tcp_stats(struct adapter *adap, struct tp_tcp_stats *v4,
  1361. struct tp_tcp_stats *v6);
  1362. void t4_get_fcoe_stats(struct adapter *adap, unsigned int idx,
  1363. struct tp_fcoe_stats *st);
  1364. void t4_load_mtus(struct adapter *adap, const unsigned short *mtus,
  1365. const unsigned short *alpha, const unsigned short *beta);
  1366. void t4_ulprx_read_la(struct adapter *adap, u32 *la_buf);
  1367. void t4_get_chan_txrate(struct adapter *adap, u64 *nic_rate, u64 *ofld_rate);
  1368. void t4_mk_filtdelwr(unsigned int ftid, struct fw_filter_wr *wr, int qid);
  1369. void t4_wol_magic_enable(struct adapter *adap, unsigned int port,
  1370. const u8 *addr);
  1371. int t4_wol_pat_enable(struct adapter *adap, unsigned int port, unsigned int map,
  1372. u64 mask0, u64 mask1, unsigned int crc, bool enable);
  1373. int t4_fw_hello(struct adapter *adap, unsigned int mbox, unsigned int evt_mbox,
  1374. enum dev_master master, enum dev_state *state);
  1375. int t4_fw_bye(struct adapter *adap, unsigned int mbox);
  1376. int t4_early_init(struct adapter *adap, unsigned int mbox);
  1377. int t4_fw_reset(struct adapter *adap, unsigned int mbox, int reset);
  1378. int t4_fixup_host_params(struct adapter *adap, unsigned int page_size,
  1379. unsigned int cache_line_size);
  1380. int t4_fw_initialize(struct adapter *adap, unsigned int mbox);
  1381. int t4_query_params(struct adapter *adap, unsigned int mbox, unsigned int pf,
  1382. unsigned int vf, unsigned int nparams, const u32 *params,
  1383. u32 *val);
  1384. int t4_query_params_rw(struct adapter *adap, unsigned int mbox, unsigned int pf,
  1385. unsigned int vf, unsigned int nparams, const u32 *params,
  1386. u32 *val, int rw);
  1387. int t4_set_params_timeout(struct adapter *adap, unsigned int mbox,
  1388. unsigned int pf, unsigned int vf,
  1389. unsigned int nparams, const u32 *params,
  1390. const u32 *val, int timeout);
  1391. int t4_set_params(struct adapter *adap, unsigned int mbox, unsigned int pf,
  1392. unsigned int vf, unsigned int nparams, const u32 *params,
  1393. const u32 *val);
  1394. int t4_cfg_pfvf(struct adapter *adap, unsigned int mbox, unsigned int pf,
  1395. unsigned int vf, unsigned int txq, unsigned int txq_eth_ctrl,
  1396. unsigned int rxqi, unsigned int rxq, unsigned int tc,
  1397. unsigned int vi, unsigned int cmask, unsigned int pmask,
  1398. unsigned int nexact, unsigned int rcaps, unsigned int wxcaps);
  1399. int t4_alloc_vi(struct adapter *adap, unsigned int mbox, unsigned int port,
  1400. unsigned int pf, unsigned int vf, unsigned int nmac, u8 *mac,
  1401. unsigned int *rss_size);
  1402. int t4_free_vi(struct adapter *adap, unsigned int mbox,
  1403. unsigned int pf, unsigned int vf,
  1404. unsigned int viid);
  1405. int t4_set_rxmode(struct adapter *adap, unsigned int mbox, unsigned int viid,
  1406. int mtu, int promisc, int all_multi, int bcast, int vlanex,
  1407. bool sleep_ok);
  1408. int t4_alloc_mac_filt(struct adapter *adap, unsigned int mbox,
  1409. unsigned int viid, bool free, unsigned int naddr,
  1410. const u8 **addr, u16 *idx, u64 *hash, bool sleep_ok);
  1411. int t4_free_mac_filt(struct adapter *adap, unsigned int mbox,
  1412. unsigned int viid, unsigned int naddr,
  1413. const u8 **addr, bool sleep_ok);
  1414. int t4_change_mac(struct adapter *adap, unsigned int mbox, unsigned int viid,
  1415. int idx, const u8 *addr, bool persist, bool add_smt);
  1416. int t4_set_addr_hash(struct adapter *adap, unsigned int mbox, unsigned int viid,
  1417. bool ucast, u64 vec, bool sleep_ok);
  1418. int t4_enable_vi_params(struct adapter *adap, unsigned int mbox,
  1419. unsigned int viid, bool rx_en, bool tx_en, bool dcb_en);
  1420. int t4_enable_vi(struct adapter *adap, unsigned int mbox, unsigned int viid,
  1421. bool rx_en, bool tx_en);
  1422. int t4_identify_port(struct adapter *adap, unsigned int mbox, unsigned int viid,
  1423. unsigned int nblinks);
  1424. int t4_mdio_rd(struct adapter *adap, unsigned int mbox, unsigned int phy_addr,
  1425. unsigned int mmd, unsigned int reg, u16 *valp);
  1426. int t4_mdio_wr(struct adapter *adap, unsigned int mbox, unsigned int phy_addr,
  1427. unsigned int mmd, unsigned int reg, u16 val);
  1428. int t4_iq_stop(struct adapter *adap, unsigned int mbox, unsigned int pf,
  1429. unsigned int vf, unsigned int iqtype, unsigned int iqid,
  1430. unsigned int fl0id, unsigned int fl1id);
  1431. int t4_iq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
  1432. unsigned int vf, unsigned int iqtype, unsigned int iqid,
  1433. unsigned int fl0id, unsigned int fl1id);
  1434. int t4_eth_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
  1435. unsigned int vf, unsigned int eqid);
  1436. int t4_ctrl_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
  1437. unsigned int vf, unsigned int eqid);
  1438. int t4_ofld_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
  1439. unsigned int vf, unsigned int eqid);
  1440. int t4_sge_ctxt_flush(struct adapter *adap, unsigned int mbox);
  1441. void t4_handle_get_port_info(struct port_info *pi, const __be64 *rpl);
  1442. int t4_handle_fw_rpl(struct adapter *adap, const __be64 *rpl);
  1443. void t4_db_full(struct adapter *adapter);
  1444. void t4_db_dropped(struct adapter *adapter);
  1445. int t4_set_trace_filter(struct adapter *adapter, const struct trace_params *tp,
  1446. int filter_index, int enable);
  1447. void t4_get_trace_filter(struct adapter *adapter, struct trace_params *tp,
  1448. int filter_index, int *enabled);
  1449. int t4_fwaddrspace_write(struct adapter *adap, unsigned int mbox,
  1450. u32 addr, u32 val);
  1451. int t4_sched_params(struct adapter *adapter, int type, int level, int mode,
  1452. int rateunit, int ratemode, int channel, int class,
  1453. int minrate, int maxrate, int weight, int pktsize);
  1454. void t4_sge_decode_idma_state(struct adapter *adapter, int state);
  1455. void t4_free_mem(void *addr);
  1456. void t4_idma_monitor_init(struct adapter *adapter,
  1457. struct sge_idma_monitor_state *idma);
  1458. void t4_idma_monitor(struct adapter *adapter,
  1459. struct sge_idma_monitor_state *idma,
  1460. int hz, int ticks);
  1461. int t4_set_vf_mac_acl(struct adapter *adapter, unsigned int vf,
  1462. unsigned int naddr, u8 *addr);
  1463. void t4_uld_mem_free(struct adapter *adap);
  1464. int t4_uld_mem_alloc(struct adapter *adap);
  1465. void t4_uld_clean_up(struct adapter *adap);
  1466. void t4_register_netevent_notifier(void);
  1467. void free_rspq_fl(struct adapter *adap, struct sge_rspq *rq, struct sge_fl *fl);
  1468. void free_tx_desc(struct adapter *adap, struct sge_txq *q,
  1469. unsigned int n, bool unmap);
  1470. void free_txq(struct adapter *adap, struct sge_txq *q);
  1471. #endif /* __CXGB4_H__ */