cxgb4.h 61 KB

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