cxgb4.h 56 KB

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