cxgb4.h 62 KB

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