cxgb4.h 63 KB

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