cxgb4.h 54 KB

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