qed_if.h 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329
  1. /* QLogic qed NIC Driver
  2. * Copyright (c) 2015-2017 QLogic Corporation
  3. *
  4. * This software is available to you under a choice of one of two
  5. * licenses. You may choose to be licensed under the terms of the GNU
  6. * General Public License (GPL) Version 2, available from the file
  7. * COPYING in the main directory of this source tree, or the
  8. * OpenIB.org BSD license below:
  9. *
  10. * Redistribution and use in source and binary forms, with or
  11. * without modification, are permitted provided that the following
  12. * conditions are met:
  13. *
  14. * - Redistributions of source code must retain the above
  15. * copyright notice, this list of conditions and the following
  16. * disclaimer.
  17. *
  18. * - Redistributions in binary form must reproduce the above
  19. * copyright notice, this list of conditions and the following
  20. * disclaimer in the documentation and /or other materials
  21. * provided with the distribution.
  22. *
  23. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  27. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  28. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  29. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  30. * SOFTWARE.
  31. */
  32. #ifndef _QED_IF_H
  33. #define _QED_IF_H
  34. #include <linux/types.h>
  35. #include <linux/interrupt.h>
  36. #include <linux/netdevice.h>
  37. #include <linux/pci.h>
  38. #include <linux/skbuff.h>
  39. #include <linux/types.h>
  40. #include <asm/byteorder.h>
  41. #include <linux/io.h>
  42. #include <linux/compiler.h>
  43. #include <linux/kernel.h>
  44. #include <linux/list.h>
  45. #include <linux/slab.h>
  46. #include <linux/qed/common_hsi.h>
  47. #include <linux/qed/qed_chain.h>
  48. enum dcbx_protocol_type {
  49. DCBX_PROTOCOL_ISCSI,
  50. DCBX_PROTOCOL_FCOE,
  51. DCBX_PROTOCOL_ROCE,
  52. DCBX_PROTOCOL_ROCE_V2,
  53. DCBX_PROTOCOL_ETH,
  54. DCBX_MAX_PROTOCOL_TYPE
  55. };
  56. #define QED_ROCE_PROTOCOL_INDEX (3)
  57. #define QED_LLDP_CHASSIS_ID_STAT_LEN 4
  58. #define QED_LLDP_PORT_ID_STAT_LEN 4
  59. #define QED_DCBX_MAX_APP_PROTOCOL 32
  60. #define QED_MAX_PFC_PRIORITIES 8
  61. #define QED_DCBX_DSCP_SIZE 64
  62. struct qed_dcbx_lldp_remote {
  63. u32 peer_chassis_id[QED_LLDP_CHASSIS_ID_STAT_LEN];
  64. u32 peer_port_id[QED_LLDP_PORT_ID_STAT_LEN];
  65. bool enable_rx;
  66. bool enable_tx;
  67. u32 tx_interval;
  68. u32 max_credit;
  69. };
  70. struct qed_dcbx_lldp_local {
  71. u32 local_chassis_id[QED_LLDP_CHASSIS_ID_STAT_LEN];
  72. u32 local_port_id[QED_LLDP_PORT_ID_STAT_LEN];
  73. };
  74. struct qed_dcbx_app_prio {
  75. u8 roce;
  76. u8 roce_v2;
  77. u8 fcoe;
  78. u8 iscsi;
  79. u8 eth;
  80. };
  81. struct qed_dbcx_pfc_params {
  82. bool willing;
  83. bool enabled;
  84. u8 prio[QED_MAX_PFC_PRIORITIES];
  85. u8 max_tc;
  86. };
  87. enum qed_dcbx_sf_ieee_type {
  88. QED_DCBX_SF_IEEE_ETHTYPE,
  89. QED_DCBX_SF_IEEE_TCP_PORT,
  90. QED_DCBX_SF_IEEE_UDP_PORT,
  91. QED_DCBX_SF_IEEE_TCP_UDP_PORT
  92. };
  93. struct qed_app_entry {
  94. bool ethtype;
  95. enum qed_dcbx_sf_ieee_type sf_ieee;
  96. bool enabled;
  97. u8 prio;
  98. u16 proto_id;
  99. enum dcbx_protocol_type proto_type;
  100. };
  101. struct qed_dcbx_params {
  102. struct qed_app_entry app_entry[QED_DCBX_MAX_APP_PROTOCOL];
  103. u16 num_app_entries;
  104. bool app_willing;
  105. bool app_valid;
  106. bool app_error;
  107. bool ets_willing;
  108. bool ets_enabled;
  109. bool ets_cbs;
  110. bool valid;
  111. u8 ets_pri_tc_tbl[QED_MAX_PFC_PRIORITIES];
  112. u8 ets_tc_bw_tbl[QED_MAX_PFC_PRIORITIES];
  113. u8 ets_tc_tsa_tbl[QED_MAX_PFC_PRIORITIES];
  114. struct qed_dbcx_pfc_params pfc;
  115. u8 max_ets_tc;
  116. };
  117. struct qed_dcbx_admin_params {
  118. struct qed_dcbx_params params;
  119. bool valid;
  120. };
  121. struct qed_dcbx_remote_params {
  122. struct qed_dcbx_params params;
  123. bool valid;
  124. };
  125. struct qed_dcbx_operational_params {
  126. struct qed_dcbx_app_prio app_prio;
  127. struct qed_dcbx_params params;
  128. bool valid;
  129. bool enabled;
  130. bool ieee;
  131. bool cee;
  132. bool local;
  133. u32 err;
  134. };
  135. struct qed_dcbx_get {
  136. struct qed_dcbx_operational_params operational;
  137. struct qed_dcbx_lldp_remote lldp_remote;
  138. struct qed_dcbx_lldp_local lldp_local;
  139. struct qed_dcbx_remote_params remote;
  140. struct qed_dcbx_admin_params local;
  141. };
  142. enum qed_nvm_images {
  143. QED_NVM_IMAGE_ISCSI_CFG,
  144. QED_NVM_IMAGE_FCOE_CFG,
  145. QED_NVM_IMAGE_NVM_CFG1,
  146. QED_NVM_IMAGE_DEFAULT_CFG,
  147. QED_NVM_IMAGE_NVM_META,
  148. };
  149. struct qed_link_eee_params {
  150. u32 tx_lpi_timer;
  151. #define QED_EEE_1G_ADV BIT(0)
  152. #define QED_EEE_10G_ADV BIT(1)
  153. /* Capabilities are represented using QED_EEE_*_ADV values */
  154. u8 adv_caps;
  155. u8 lp_adv_caps;
  156. bool enable;
  157. bool tx_lpi_enable;
  158. };
  159. enum qed_led_mode {
  160. QED_LED_MODE_OFF,
  161. QED_LED_MODE_ON,
  162. QED_LED_MODE_RESTORE
  163. };
  164. struct qed_mfw_tlv_eth {
  165. u16 lso_maxoff_size;
  166. bool lso_maxoff_size_set;
  167. u16 lso_minseg_size;
  168. bool lso_minseg_size_set;
  169. u8 prom_mode;
  170. bool prom_mode_set;
  171. u16 tx_descr_size;
  172. bool tx_descr_size_set;
  173. u16 rx_descr_size;
  174. bool rx_descr_size_set;
  175. u16 netq_count;
  176. bool netq_count_set;
  177. u32 tcp4_offloads;
  178. bool tcp4_offloads_set;
  179. u32 tcp6_offloads;
  180. bool tcp6_offloads_set;
  181. u16 tx_descr_qdepth;
  182. bool tx_descr_qdepth_set;
  183. u16 rx_descr_qdepth;
  184. bool rx_descr_qdepth_set;
  185. u8 iov_offload;
  186. #define QED_MFW_TLV_IOV_OFFLOAD_NONE (0)
  187. #define QED_MFW_TLV_IOV_OFFLOAD_MULTIQUEUE (1)
  188. #define QED_MFW_TLV_IOV_OFFLOAD_VEB (2)
  189. #define QED_MFW_TLV_IOV_OFFLOAD_VEPA (3)
  190. bool iov_offload_set;
  191. u8 txqs_empty;
  192. bool txqs_empty_set;
  193. u8 rxqs_empty;
  194. bool rxqs_empty_set;
  195. u8 num_txqs_full;
  196. bool num_txqs_full_set;
  197. u8 num_rxqs_full;
  198. bool num_rxqs_full_set;
  199. };
  200. #define QED_MFW_TLV_TIME_SIZE 14
  201. struct qed_mfw_tlv_time {
  202. bool b_set;
  203. u8 month;
  204. u8 day;
  205. u8 hour;
  206. u8 min;
  207. u16 msec;
  208. u16 usec;
  209. };
  210. struct qed_mfw_tlv_fcoe {
  211. u8 scsi_timeout;
  212. bool scsi_timeout_set;
  213. u32 rt_tov;
  214. bool rt_tov_set;
  215. u32 ra_tov;
  216. bool ra_tov_set;
  217. u32 ed_tov;
  218. bool ed_tov_set;
  219. u32 cr_tov;
  220. bool cr_tov_set;
  221. u8 boot_type;
  222. bool boot_type_set;
  223. u8 npiv_state;
  224. bool npiv_state_set;
  225. u32 num_npiv_ids;
  226. bool num_npiv_ids_set;
  227. u8 switch_name[8];
  228. bool switch_name_set;
  229. u16 switch_portnum;
  230. bool switch_portnum_set;
  231. u8 switch_portid[3];
  232. bool switch_portid_set;
  233. u8 vendor_name[8];
  234. bool vendor_name_set;
  235. u8 switch_model[8];
  236. bool switch_model_set;
  237. u8 switch_fw_version[8];
  238. bool switch_fw_version_set;
  239. u8 qos_pri;
  240. bool qos_pri_set;
  241. u8 port_alias[3];
  242. bool port_alias_set;
  243. u8 port_state;
  244. #define QED_MFW_TLV_PORT_STATE_OFFLINE (0)
  245. #define QED_MFW_TLV_PORT_STATE_LOOP (1)
  246. #define QED_MFW_TLV_PORT_STATE_P2P (2)
  247. #define QED_MFW_TLV_PORT_STATE_FABRIC (3)
  248. bool port_state_set;
  249. u16 fip_tx_descr_size;
  250. bool fip_tx_descr_size_set;
  251. u16 fip_rx_descr_size;
  252. bool fip_rx_descr_size_set;
  253. u16 link_failures;
  254. bool link_failures_set;
  255. u8 fcoe_boot_progress;
  256. bool fcoe_boot_progress_set;
  257. u64 rx_bcast;
  258. bool rx_bcast_set;
  259. u64 tx_bcast;
  260. bool tx_bcast_set;
  261. u16 fcoe_txq_depth;
  262. bool fcoe_txq_depth_set;
  263. u16 fcoe_rxq_depth;
  264. bool fcoe_rxq_depth_set;
  265. u64 fcoe_rx_frames;
  266. bool fcoe_rx_frames_set;
  267. u64 fcoe_rx_bytes;
  268. bool fcoe_rx_bytes_set;
  269. u64 fcoe_tx_frames;
  270. bool fcoe_tx_frames_set;
  271. u64 fcoe_tx_bytes;
  272. bool fcoe_tx_bytes_set;
  273. u16 crc_count;
  274. bool crc_count_set;
  275. u32 crc_err_src_fcid[5];
  276. bool crc_err_src_fcid_set[5];
  277. struct qed_mfw_tlv_time crc_err[5];
  278. u16 losync_err;
  279. bool losync_err_set;
  280. u16 losig_err;
  281. bool losig_err_set;
  282. u16 primtive_err;
  283. bool primtive_err_set;
  284. u16 disparity_err;
  285. bool disparity_err_set;
  286. u16 code_violation_err;
  287. bool code_violation_err_set;
  288. u32 flogi_param[4];
  289. bool flogi_param_set[4];
  290. struct qed_mfw_tlv_time flogi_tstamp;
  291. u32 flogi_acc_param[4];
  292. bool flogi_acc_param_set[4];
  293. struct qed_mfw_tlv_time flogi_acc_tstamp;
  294. u32 flogi_rjt;
  295. bool flogi_rjt_set;
  296. struct qed_mfw_tlv_time flogi_rjt_tstamp;
  297. u32 fdiscs;
  298. bool fdiscs_set;
  299. u8 fdisc_acc;
  300. bool fdisc_acc_set;
  301. u8 fdisc_rjt;
  302. bool fdisc_rjt_set;
  303. u8 plogi;
  304. bool plogi_set;
  305. u8 plogi_acc;
  306. bool plogi_acc_set;
  307. u8 plogi_rjt;
  308. bool plogi_rjt_set;
  309. u32 plogi_dst_fcid[5];
  310. bool plogi_dst_fcid_set[5];
  311. struct qed_mfw_tlv_time plogi_tstamp[5];
  312. u32 plogi_acc_src_fcid[5];
  313. bool plogi_acc_src_fcid_set[5];
  314. struct qed_mfw_tlv_time plogi_acc_tstamp[5];
  315. u8 tx_plogos;
  316. bool tx_plogos_set;
  317. u8 plogo_acc;
  318. bool plogo_acc_set;
  319. u8 plogo_rjt;
  320. bool plogo_rjt_set;
  321. u32 plogo_src_fcid[5];
  322. bool plogo_src_fcid_set[5];
  323. struct qed_mfw_tlv_time plogo_tstamp[5];
  324. u8 rx_logos;
  325. bool rx_logos_set;
  326. u8 tx_accs;
  327. bool tx_accs_set;
  328. u8 tx_prlis;
  329. bool tx_prlis_set;
  330. u8 rx_accs;
  331. bool rx_accs_set;
  332. u8 tx_abts;
  333. bool tx_abts_set;
  334. u8 rx_abts_acc;
  335. bool rx_abts_acc_set;
  336. u8 rx_abts_rjt;
  337. bool rx_abts_rjt_set;
  338. u32 abts_dst_fcid[5];
  339. bool abts_dst_fcid_set[5];
  340. struct qed_mfw_tlv_time abts_tstamp[5];
  341. u8 rx_rscn;
  342. bool rx_rscn_set;
  343. u32 rx_rscn_nport[4];
  344. bool rx_rscn_nport_set[4];
  345. u8 tx_lun_rst;
  346. bool tx_lun_rst_set;
  347. u8 abort_task_sets;
  348. bool abort_task_sets_set;
  349. u8 tx_tprlos;
  350. bool tx_tprlos_set;
  351. u8 tx_nos;
  352. bool tx_nos_set;
  353. u8 rx_nos;
  354. bool rx_nos_set;
  355. u8 ols;
  356. bool ols_set;
  357. u8 lr;
  358. bool lr_set;
  359. u8 lrr;
  360. bool lrr_set;
  361. u8 tx_lip;
  362. bool tx_lip_set;
  363. u8 rx_lip;
  364. bool rx_lip_set;
  365. u8 eofa;
  366. bool eofa_set;
  367. u8 eofni;
  368. bool eofni_set;
  369. u8 scsi_chks;
  370. bool scsi_chks_set;
  371. u8 scsi_cond_met;
  372. bool scsi_cond_met_set;
  373. u8 scsi_busy;
  374. bool scsi_busy_set;
  375. u8 scsi_inter;
  376. bool scsi_inter_set;
  377. u8 scsi_inter_cond_met;
  378. bool scsi_inter_cond_met_set;
  379. u8 scsi_rsv_conflicts;
  380. bool scsi_rsv_conflicts_set;
  381. u8 scsi_tsk_full;
  382. bool scsi_tsk_full_set;
  383. u8 scsi_aca_active;
  384. bool scsi_aca_active_set;
  385. u8 scsi_tsk_abort;
  386. bool scsi_tsk_abort_set;
  387. u32 scsi_rx_chk[5];
  388. bool scsi_rx_chk_set[5];
  389. struct qed_mfw_tlv_time scsi_chk_tstamp[5];
  390. };
  391. struct qed_mfw_tlv_iscsi {
  392. u8 target_llmnr;
  393. bool target_llmnr_set;
  394. u8 header_digest;
  395. bool header_digest_set;
  396. u8 data_digest;
  397. bool data_digest_set;
  398. u8 auth_method;
  399. #define QED_MFW_TLV_AUTH_METHOD_NONE (1)
  400. #define QED_MFW_TLV_AUTH_METHOD_CHAP (2)
  401. #define QED_MFW_TLV_AUTH_METHOD_MUTUAL_CHAP (3)
  402. bool auth_method_set;
  403. u16 boot_taget_portal;
  404. bool boot_taget_portal_set;
  405. u16 frame_size;
  406. bool frame_size_set;
  407. u16 tx_desc_size;
  408. bool tx_desc_size_set;
  409. u16 rx_desc_size;
  410. bool rx_desc_size_set;
  411. u8 boot_progress;
  412. bool boot_progress_set;
  413. u16 tx_desc_qdepth;
  414. bool tx_desc_qdepth_set;
  415. u16 rx_desc_qdepth;
  416. bool rx_desc_qdepth_set;
  417. u64 rx_frames;
  418. bool rx_frames_set;
  419. u64 rx_bytes;
  420. bool rx_bytes_set;
  421. u64 tx_frames;
  422. bool tx_frames_set;
  423. u64 tx_bytes;
  424. bool tx_bytes_set;
  425. };
  426. #define DIRECT_REG_WR(reg_addr, val) writel((u32)val, \
  427. (void __iomem *)(reg_addr))
  428. #define DIRECT_REG_RD(reg_addr) readl((void __iomem *)(reg_addr))
  429. #define QED_COALESCE_MAX 0x1FF
  430. #define QED_DEFAULT_RX_USECS 12
  431. #define QED_DEFAULT_TX_USECS 48
  432. /* forward */
  433. struct qed_dev;
  434. struct qed_eth_pf_params {
  435. /* The following parameters are used during HW-init
  436. * and these parameters need to be passed as arguments
  437. * to update_pf_params routine invoked before slowpath start
  438. */
  439. u16 num_cons;
  440. /* per-VF number of CIDs */
  441. u8 num_vf_cons;
  442. #define ETH_PF_PARAMS_VF_CONS_DEFAULT (32)
  443. /* To enable arfs, previous to HW-init a positive number needs to be
  444. * set [as filters require allocated searcher ILT memory].
  445. * This will set the maximal number of configured steering-filters.
  446. */
  447. u32 num_arfs_filters;
  448. };
  449. struct qed_fcoe_pf_params {
  450. /* The following parameters are used during protocol-init */
  451. u64 glbl_q_params_addr;
  452. u64 bdq_pbl_base_addr[2];
  453. /* The following parameters are used during HW-init
  454. * and these parameters need to be passed as arguments
  455. * to update_pf_params routine invoked before slowpath start
  456. */
  457. u16 num_cons;
  458. u16 num_tasks;
  459. /* The following parameters are used during protocol-init */
  460. u16 sq_num_pbl_pages;
  461. u16 cq_num_entries;
  462. u16 cmdq_num_entries;
  463. u16 rq_buffer_log_size;
  464. u16 mtu;
  465. u16 dummy_icid;
  466. u16 bdq_xoff_threshold[2];
  467. u16 bdq_xon_threshold[2];
  468. u16 rq_buffer_size;
  469. u8 num_cqs; /* num of global CQs */
  470. u8 log_page_size;
  471. u8 gl_rq_pi;
  472. u8 gl_cmd_pi;
  473. u8 debug_mode;
  474. u8 is_target;
  475. u8 bdq_pbl_num_entries[2];
  476. };
  477. /* Most of the the parameters below are described in the FW iSCSI / TCP HSI */
  478. struct qed_iscsi_pf_params {
  479. u64 glbl_q_params_addr;
  480. u64 bdq_pbl_base_addr[3];
  481. u16 cq_num_entries;
  482. u16 cmdq_num_entries;
  483. u32 two_msl_timer;
  484. u16 tx_sws_timer;
  485. /* The following parameters are used during HW-init
  486. * and these parameters need to be passed as arguments
  487. * to update_pf_params routine invoked before slowpath start
  488. */
  489. u16 num_cons;
  490. u16 num_tasks;
  491. /* The following parameters are used during protocol-init */
  492. u16 half_way_close_timeout;
  493. u16 bdq_xoff_threshold[3];
  494. u16 bdq_xon_threshold[3];
  495. u16 cmdq_xoff_threshold;
  496. u16 cmdq_xon_threshold;
  497. u16 rq_buffer_size;
  498. u8 num_sq_pages_in_ring;
  499. u8 num_r2tq_pages_in_ring;
  500. u8 num_uhq_pages_in_ring;
  501. u8 num_queues;
  502. u8 log_page_size;
  503. u8 rqe_log_size;
  504. u8 max_fin_rt;
  505. u8 gl_rq_pi;
  506. u8 gl_cmd_pi;
  507. u8 debug_mode;
  508. u8 ll2_ooo_queue_id;
  509. u8 is_target;
  510. u8 is_soc_en;
  511. u8 soc_num_of_blocks_log;
  512. u8 bdq_pbl_num_entries[3];
  513. };
  514. struct qed_rdma_pf_params {
  515. /* Supplied to QED during resource allocation (may affect the ILT and
  516. * the doorbell BAR).
  517. */
  518. u32 min_dpis; /* number of requested DPIs */
  519. u32 num_qps; /* number of requested Queue Pairs */
  520. u32 num_srqs; /* number of requested SRQ */
  521. u8 roce_edpm_mode; /* see QED_ROCE_EDPM_MODE_ENABLE */
  522. u8 gl_pi; /* protocol index */
  523. /* Will allocate rate limiters to be used with QPs */
  524. u8 enable_dcqcn;
  525. };
  526. struct qed_pf_params {
  527. struct qed_eth_pf_params eth_pf_params;
  528. struct qed_fcoe_pf_params fcoe_pf_params;
  529. struct qed_iscsi_pf_params iscsi_pf_params;
  530. struct qed_rdma_pf_params rdma_pf_params;
  531. };
  532. enum qed_int_mode {
  533. QED_INT_MODE_INTA,
  534. QED_INT_MODE_MSIX,
  535. QED_INT_MODE_MSI,
  536. QED_INT_MODE_POLL,
  537. };
  538. struct qed_sb_info {
  539. struct status_block_e4 *sb_virt;
  540. dma_addr_t sb_phys;
  541. u32 sb_ack; /* Last given ack */
  542. u16 igu_sb_id;
  543. void __iomem *igu_addr;
  544. u8 flags;
  545. #define QED_SB_INFO_INIT 0x1
  546. #define QED_SB_INFO_SETUP 0x2
  547. struct qed_dev *cdev;
  548. };
  549. enum qed_dev_type {
  550. QED_DEV_TYPE_BB,
  551. QED_DEV_TYPE_AH,
  552. };
  553. struct qed_dev_info {
  554. unsigned long pci_mem_start;
  555. unsigned long pci_mem_end;
  556. unsigned int pci_irq;
  557. u8 num_hwfns;
  558. u8 hw_mac[ETH_ALEN];
  559. /* FW version */
  560. u16 fw_major;
  561. u16 fw_minor;
  562. u16 fw_rev;
  563. u16 fw_eng;
  564. /* MFW version */
  565. u32 mfw_rev;
  566. #define QED_MFW_VERSION_0_MASK 0x000000FF
  567. #define QED_MFW_VERSION_0_OFFSET 0
  568. #define QED_MFW_VERSION_1_MASK 0x0000FF00
  569. #define QED_MFW_VERSION_1_OFFSET 8
  570. #define QED_MFW_VERSION_2_MASK 0x00FF0000
  571. #define QED_MFW_VERSION_2_OFFSET 16
  572. #define QED_MFW_VERSION_3_MASK 0xFF000000
  573. #define QED_MFW_VERSION_3_OFFSET 24
  574. u32 flash_size;
  575. bool b_inter_pf_switch;
  576. bool tx_switching;
  577. bool rdma_supported;
  578. u16 mtu;
  579. bool wol_support;
  580. /* MBI version */
  581. u32 mbi_version;
  582. #define QED_MBI_VERSION_0_MASK 0x000000FF
  583. #define QED_MBI_VERSION_0_OFFSET 0
  584. #define QED_MBI_VERSION_1_MASK 0x0000FF00
  585. #define QED_MBI_VERSION_1_OFFSET 8
  586. #define QED_MBI_VERSION_2_MASK 0x00FF0000
  587. #define QED_MBI_VERSION_2_OFFSET 16
  588. enum qed_dev_type dev_type;
  589. /* Output parameters for qede */
  590. bool vxlan_enable;
  591. bool gre_enable;
  592. bool geneve_enable;
  593. u8 abs_pf_id;
  594. };
  595. enum qed_sb_type {
  596. QED_SB_TYPE_L2_QUEUE,
  597. QED_SB_TYPE_CNQ,
  598. QED_SB_TYPE_STORAGE,
  599. };
  600. enum qed_protocol {
  601. QED_PROTOCOL_ETH,
  602. QED_PROTOCOL_ISCSI,
  603. QED_PROTOCOL_FCOE,
  604. };
  605. enum qed_link_mode_bits {
  606. QED_LM_FIBRE_BIT = BIT(0),
  607. QED_LM_Autoneg_BIT = BIT(1),
  608. QED_LM_Asym_Pause_BIT = BIT(2),
  609. QED_LM_Pause_BIT = BIT(3),
  610. QED_LM_1000baseT_Half_BIT = BIT(4),
  611. QED_LM_1000baseT_Full_BIT = BIT(5),
  612. QED_LM_10000baseKR_Full_BIT = BIT(6),
  613. QED_LM_25000baseKR_Full_BIT = BIT(7),
  614. QED_LM_40000baseLR4_Full_BIT = BIT(8),
  615. QED_LM_50000baseKR2_Full_BIT = BIT(9),
  616. QED_LM_100000baseKR4_Full_BIT = BIT(10),
  617. QED_LM_COUNT = 11
  618. };
  619. struct qed_link_params {
  620. bool link_up;
  621. #define QED_LINK_OVERRIDE_SPEED_AUTONEG BIT(0)
  622. #define QED_LINK_OVERRIDE_SPEED_ADV_SPEEDS BIT(1)
  623. #define QED_LINK_OVERRIDE_SPEED_FORCED_SPEED BIT(2)
  624. #define QED_LINK_OVERRIDE_PAUSE_CONFIG BIT(3)
  625. #define QED_LINK_OVERRIDE_LOOPBACK_MODE BIT(4)
  626. #define QED_LINK_OVERRIDE_EEE_CONFIG BIT(5)
  627. u32 override_flags;
  628. bool autoneg;
  629. u32 adv_speeds;
  630. u32 forced_speed;
  631. #define QED_LINK_PAUSE_AUTONEG_ENABLE BIT(0)
  632. #define QED_LINK_PAUSE_RX_ENABLE BIT(1)
  633. #define QED_LINK_PAUSE_TX_ENABLE BIT(2)
  634. u32 pause_config;
  635. #define QED_LINK_LOOPBACK_NONE BIT(0)
  636. #define QED_LINK_LOOPBACK_INT_PHY BIT(1)
  637. #define QED_LINK_LOOPBACK_EXT_PHY BIT(2)
  638. #define QED_LINK_LOOPBACK_EXT BIT(3)
  639. #define QED_LINK_LOOPBACK_MAC BIT(4)
  640. u32 loopback_mode;
  641. struct qed_link_eee_params eee;
  642. };
  643. struct qed_link_output {
  644. bool link_up;
  645. /* In QED_LM_* defs */
  646. u32 supported_caps;
  647. u32 advertised_caps;
  648. u32 lp_caps;
  649. u32 speed; /* In Mb/s */
  650. u8 duplex; /* In DUPLEX defs */
  651. u8 port; /* In PORT defs */
  652. bool autoneg;
  653. u32 pause_config;
  654. /* EEE - capability & param */
  655. bool eee_supported;
  656. bool eee_active;
  657. u8 sup_caps;
  658. struct qed_link_eee_params eee;
  659. };
  660. struct qed_probe_params {
  661. enum qed_protocol protocol;
  662. u32 dp_module;
  663. u8 dp_level;
  664. bool is_vf;
  665. };
  666. #define QED_DRV_VER_STR_SIZE 12
  667. struct qed_slowpath_params {
  668. u32 int_mode;
  669. u8 drv_major;
  670. u8 drv_minor;
  671. u8 drv_rev;
  672. u8 drv_eng;
  673. u8 name[QED_DRV_VER_STR_SIZE];
  674. };
  675. #define ILT_PAGE_SIZE_TCFC 0x8000 /* 32KB */
  676. struct qed_int_info {
  677. struct msix_entry *msix;
  678. u8 msix_cnt;
  679. /* This should be updated by the protocol driver */
  680. u8 used_cnt;
  681. };
  682. struct qed_generic_tlvs {
  683. #define QED_TLV_IP_CSUM BIT(0)
  684. #define QED_TLV_LSO BIT(1)
  685. u16 feat_flags;
  686. #define QED_TLV_MAC_COUNT 3
  687. u8 mac[QED_TLV_MAC_COUNT][ETH_ALEN];
  688. };
  689. #define QED_I2C_DEV_ADDR_A0 0xA0
  690. #define QED_I2C_DEV_ADDR_A2 0xA2
  691. #define QED_NVM_SIGNATURE 0x12435687
  692. enum qed_nvm_flash_cmd {
  693. QED_NVM_FLASH_CMD_FILE_DATA = 0x2,
  694. QED_NVM_FLASH_CMD_FILE_START = 0x3,
  695. QED_NVM_FLASH_CMD_NVM_CHANGE = 0x4,
  696. QED_NVM_FLASH_CMD_NVM_MAX,
  697. };
  698. struct qed_common_cb_ops {
  699. void (*arfs_filter_op)(void *dev, void *fltr, u8 fw_rc);
  700. void (*link_update)(void *dev,
  701. struct qed_link_output *link);
  702. void (*dcbx_aen)(void *dev, struct qed_dcbx_get *get, u32 mib_type);
  703. void (*get_generic_tlv_data)(void *dev, struct qed_generic_tlvs *data);
  704. void (*get_protocol_tlv_data)(void *dev, void *data);
  705. };
  706. struct qed_selftest_ops {
  707. /**
  708. * @brief selftest_interrupt - Perform interrupt test
  709. *
  710. * @param cdev
  711. *
  712. * @return 0 on success, error otherwise.
  713. */
  714. int (*selftest_interrupt)(struct qed_dev *cdev);
  715. /**
  716. * @brief selftest_memory - Perform memory test
  717. *
  718. * @param cdev
  719. *
  720. * @return 0 on success, error otherwise.
  721. */
  722. int (*selftest_memory)(struct qed_dev *cdev);
  723. /**
  724. * @brief selftest_register - Perform register test
  725. *
  726. * @param cdev
  727. *
  728. * @return 0 on success, error otherwise.
  729. */
  730. int (*selftest_register)(struct qed_dev *cdev);
  731. /**
  732. * @brief selftest_clock - Perform clock test
  733. *
  734. * @param cdev
  735. *
  736. * @return 0 on success, error otherwise.
  737. */
  738. int (*selftest_clock)(struct qed_dev *cdev);
  739. /**
  740. * @brief selftest_nvram - Perform nvram test
  741. *
  742. * @param cdev
  743. *
  744. * @return 0 on success, error otherwise.
  745. */
  746. int (*selftest_nvram) (struct qed_dev *cdev);
  747. };
  748. struct qed_common_ops {
  749. struct qed_selftest_ops *selftest;
  750. struct qed_dev* (*probe)(struct pci_dev *dev,
  751. struct qed_probe_params *params);
  752. void (*remove)(struct qed_dev *cdev);
  753. int (*set_power_state)(struct qed_dev *cdev,
  754. pci_power_t state);
  755. void (*set_name) (struct qed_dev *cdev, char name[]);
  756. /* Client drivers need to make this call before slowpath_start.
  757. * PF params required for the call before slowpath_start is
  758. * documented within the qed_pf_params structure definition.
  759. */
  760. void (*update_pf_params)(struct qed_dev *cdev,
  761. struct qed_pf_params *params);
  762. int (*slowpath_start)(struct qed_dev *cdev,
  763. struct qed_slowpath_params *params);
  764. int (*slowpath_stop)(struct qed_dev *cdev);
  765. /* Requests to use `cnt' interrupts for fastpath.
  766. * upon success, returns number of interrupts allocated for fastpath.
  767. */
  768. int (*set_fp_int)(struct qed_dev *cdev,
  769. u16 cnt);
  770. /* Fills `info' with pointers required for utilizing interrupts */
  771. int (*get_fp_int)(struct qed_dev *cdev,
  772. struct qed_int_info *info);
  773. u32 (*sb_init)(struct qed_dev *cdev,
  774. struct qed_sb_info *sb_info,
  775. void *sb_virt_addr,
  776. dma_addr_t sb_phy_addr,
  777. u16 sb_id,
  778. enum qed_sb_type type);
  779. u32 (*sb_release)(struct qed_dev *cdev,
  780. struct qed_sb_info *sb_info,
  781. u16 sb_id);
  782. void (*simd_handler_config)(struct qed_dev *cdev,
  783. void *token,
  784. int index,
  785. void (*handler)(void *));
  786. void (*simd_handler_clean)(struct qed_dev *cdev,
  787. int index);
  788. int (*dbg_grc)(struct qed_dev *cdev,
  789. void *buffer, u32 *num_dumped_bytes);
  790. int (*dbg_grc_size)(struct qed_dev *cdev);
  791. int (*dbg_all_data) (struct qed_dev *cdev, void *buffer);
  792. int (*dbg_all_data_size) (struct qed_dev *cdev);
  793. /**
  794. * @brief can_link_change - can the instance change the link or not
  795. *
  796. * @param cdev
  797. *
  798. * @return true if link-change is allowed, false otherwise.
  799. */
  800. bool (*can_link_change)(struct qed_dev *cdev);
  801. /**
  802. * @brief set_link - set links according to params
  803. *
  804. * @param cdev
  805. * @param params - values used to override the default link configuration
  806. *
  807. * @return 0 on success, error otherwise.
  808. */
  809. int (*set_link)(struct qed_dev *cdev,
  810. struct qed_link_params *params);
  811. /**
  812. * @brief get_link - returns the current link state.
  813. *
  814. * @param cdev
  815. * @param if_link - structure to be filled with current link configuration.
  816. */
  817. void (*get_link)(struct qed_dev *cdev,
  818. struct qed_link_output *if_link);
  819. /**
  820. * @brief - drains chip in case Tx completions fail to arrive due to pause.
  821. *
  822. * @param cdev
  823. */
  824. int (*drain)(struct qed_dev *cdev);
  825. /**
  826. * @brief update_msglvl - update module debug level
  827. *
  828. * @param cdev
  829. * @param dp_module
  830. * @param dp_level
  831. */
  832. void (*update_msglvl)(struct qed_dev *cdev,
  833. u32 dp_module,
  834. u8 dp_level);
  835. int (*chain_alloc)(struct qed_dev *cdev,
  836. enum qed_chain_use_mode intended_use,
  837. enum qed_chain_mode mode,
  838. enum qed_chain_cnt_type cnt_type,
  839. u32 num_elems,
  840. size_t elem_size,
  841. struct qed_chain *p_chain,
  842. struct qed_chain_ext_pbl *ext_pbl);
  843. void (*chain_free)(struct qed_dev *cdev,
  844. struct qed_chain *p_chain);
  845. /**
  846. * @brief nvm_flash - Flash nvm data.
  847. *
  848. * @param cdev
  849. * @param name - file containing the data
  850. *
  851. * @return 0 on success, error otherwise.
  852. */
  853. int (*nvm_flash)(struct qed_dev *cdev, const char *name);
  854. /**
  855. * @brief nvm_get_image - reads an entire image from nvram
  856. *
  857. * @param cdev
  858. * @param type - type of the request nvram image
  859. * @param buf - preallocated buffer to fill with the image
  860. * @param len - length of the allocated buffer
  861. *
  862. * @return 0 on success, error otherwise
  863. */
  864. int (*nvm_get_image)(struct qed_dev *cdev,
  865. enum qed_nvm_images type, u8 *buf, u16 len);
  866. /**
  867. * @brief set_coalesce - Configure Rx coalesce value in usec
  868. *
  869. * @param cdev
  870. * @param rx_coal - Rx coalesce value in usec
  871. * @param tx_coal - Tx coalesce value in usec
  872. * @param qid - Queue index
  873. * @param sb_id - Status Block Id
  874. *
  875. * @return 0 on success, error otherwise.
  876. */
  877. int (*set_coalesce)(struct qed_dev *cdev,
  878. u16 rx_coal, u16 tx_coal, void *handle);
  879. /**
  880. * @brief set_led - Configure LED mode
  881. *
  882. * @param cdev
  883. * @param mode - LED mode
  884. *
  885. * @return 0 on success, error otherwise.
  886. */
  887. int (*set_led)(struct qed_dev *cdev,
  888. enum qed_led_mode mode);
  889. /**
  890. * @brief update_drv_state - API to inform the change in the driver state.
  891. *
  892. * @param cdev
  893. * @param active
  894. *
  895. */
  896. int (*update_drv_state)(struct qed_dev *cdev, bool active);
  897. /**
  898. * @brief update_mac - API to inform the change in the mac address
  899. *
  900. * @param cdev
  901. * @param mac
  902. *
  903. */
  904. int (*update_mac)(struct qed_dev *cdev, u8 *mac);
  905. /**
  906. * @brief update_mtu - API to inform the change in the mtu
  907. *
  908. * @param cdev
  909. * @param mtu
  910. *
  911. */
  912. int (*update_mtu)(struct qed_dev *cdev, u16 mtu);
  913. /**
  914. * @brief update_wol - update of changes in the WoL configuration
  915. *
  916. * @param cdev
  917. * @param enabled - true iff WoL should be enabled.
  918. */
  919. int (*update_wol) (struct qed_dev *cdev, bool enabled);
  920. /**
  921. * @brief read_module_eeprom
  922. *
  923. * @param cdev
  924. * @param buf - buffer
  925. * @param dev_addr - PHY device memory region
  926. * @param offset - offset into eeprom contents to be read
  927. * @param len - buffer length, i.e., max bytes to be read
  928. */
  929. int (*read_module_eeprom)(struct qed_dev *cdev,
  930. char *buf, u8 dev_addr, u32 offset, u32 len);
  931. };
  932. #define MASK_FIELD(_name, _value) \
  933. ((_value) &= (_name ## _MASK))
  934. #define FIELD_VALUE(_name, _value) \
  935. ((_value & _name ## _MASK) << _name ## _SHIFT)
  936. #define SET_FIELD(value, name, flag) \
  937. do { \
  938. (value) &= ~(name ## _MASK << name ## _SHIFT); \
  939. (value) |= (((u64)flag) << (name ## _SHIFT)); \
  940. } while (0)
  941. #define GET_FIELD(value, name) \
  942. (((value) >> (name ## _SHIFT)) & name ## _MASK)
  943. /* Debug print definitions */
  944. #define DP_ERR(cdev, fmt, ...) \
  945. do { \
  946. pr_err("[%s:%d(%s)]" fmt, \
  947. __func__, __LINE__, \
  948. DP_NAME(cdev) ? DP_NAME(cdev) : "", \
  949. ## __VA_ARGS__); \
  950. } while (0)
  951. #define DP_NOTICE(cdev, fmt, ...) \
  952. do { \
  953. if (unlikely((cdev)->dp_level <= QED_LEVEL_NOTICE)) { \
  954. pr_notice("[%s:%d(%s)]" fmt, \
  955. __func__, __LINE__, \
  956. DP_NAME(cdev) ? DP_NAME(cdev) : "", \
  957. ## __VA_ARGS__); \
  958. \
  959. } \
  960. } while (0)
  961. #define DP_INFO(cdev, fmt, ...) \
  962. do { \
  963. if (unlikely((cdev)->dp_level <= QED_LEVEL_INFO)) { \
  964. pr_notice("[%s:%d(%s)]" fmt, \
  965. __func__, __LINE__, \
  966. DP_NAME(cdev) ? DP_NAME(cdev) : "", \
  967. ## __VA_ARGS__); \
  968. } \
  969. } while (0)
  970. #define DP_VERBOSE(cdev, module, fmt, ...) \
  971. do { \
  972. if (unlikely(((cdev)->dp_level <= QED_LEVEL_VERBOSE) && \
  973. ((cdev)->dp_module & module))) { \
  974. pr_notice("[%s:%d(%s)]" fmt, \
  975. __func__, __LINE__, \
  976. DP_NAME(cdev) ? DP_NAME(cdev) : "", \
  977. ## __VA_ARGS__); \
  978. } \
  979. } while (0)
  980. enum DP_LEVEL {
  981. QED_LEVEL_VERBOSE = 0x0,
  982. QED_LEVEL_INFO = 0x1,
  983. QED_LEVEL_NOTICE = 0x2,
  984. QED_LEVEL_ERR = 0x3,
  985. };
  986. #define QED_LOG_LEVEL_SHIFT (30)
  987. #define QED_LOG_VERBOSE_MASK (0x3fffffff)
  988. #define QED_LOG_INFO_MASK (0x40000000)
  989. #define QED_LOG_NOTICE_MASK (0x80000000)
  990. enum DP_MODULE {
  991. QED_MSG_SPQ = 0x10000,
  992. QED_MSG_STATS = 0x20000,
  993. QED_MSG_DCB = 0x40000,
  994. QED_MSG_IOV = 0x80000,
  995. QED_MSG_SP = 0x100000,
  996. QED_MSG_STORAGE = 0x200000,
  997. QED_MSG_CXT = 0x800000,
  998. QED_MSG_LL2 = 0x1000000,
  999. QED_MSG_ILT = 0x2000000,
  1000. QED_MSG_RDMA = 0x4000000,
  1001. QED_MSG_DEBUG = 0x8000000,
  1002. /* to be added...up to 0x8000000 */
  1003. };
  1004. enum qed_mf_mode {
  1005. QED_MF_DEFAULT,
  1006. QED_MF_OVLAN,
  1007. QED_MF_NPAR,
  1008. };
  1009. struct qed_eth_stats_common {
  1010. u64 no_buff_discards;
  1011. u64 packet_too_big_discard;
  1012. u64 ttl0_discard;
  1013. u64 rx_ucast_bytes;
  1014. u64 rx_mcast_bytes;
  1015. u64 rx_bcast_bytes;
  1016. u64 rx_ucast_pkts;
  1017. u64 rx_mcast_pkts;
  1018. u64 rx_bcast_pkts;
  1019. u64 mftag_filter_discards;
  1020. u64 mac_filter_discards;
  1021. u64 gft_filter_drop;
  1022. u64 tx_ucast_bytes;
  1023. u64 tx_mcast_bytes;
  1024. u64 tx_bcast_bytes;
  1025. u64 tx_ucast_pkts;
  1026. u64 tx_mcast_pkts;
  1027. u64 tx_bcast_pkts;
  1028. u64 tx_err_drop_pkts;
  1029. u64 tpa_coalesced_pkts;
  1030. u64 tpa_coalesced_events;
  1031. u64 tpa_aborts_num;
  1032. u64 tpa_not_coalesced_pkts;
  1033. u64 tpa_coalesced_bytes;
  1034. /* port */
  1035. u64 rx_64_byte_packets;
  1036. u64 rx_65_to_127_byte_packets;
  1037. u64 rx_128_to_255_byte_packets;
  1038. u64 rx_256_to_511_byte_packets;
  1039. u64 rx_512_to_1023_byte_packets;
  1040. u64 rx_1024_to_1518_byte_packets;
  1041. u64 rx_crc_errors;
  1042. u64 rx_mac_crtl_frames;
  1043. u64 rx_pause_frames;
  1044. u64 rx_pfc_frames;
  1045. u64 rx_align_errors;
  1046. u64 rx_carrier_errors;
  1047. u64 rx_oversize_packets;
  1048. u64 rx_jabbers;
  1049. u64 rx_undersize_packets;
  1050. u64 rx_fragments;
  1051. u64 tx_64_byte_packets;
  1052. u64 tx_65_to_127_byte_packets;
  1053. u64 tx_128_to_255_byte_packets;
  1054. u64 tx_256_to_511_byte_packets;
  1055. u64 tx_512_to_1023_byte_packets;
  1056. u64 tx_1024_to_1518_byte_packets;
  1057. u64 tx_pause_frames;
  1058. u64 tx_pfc_frames;
  1059. u64 brb_truncates;
  1060. u64 brb_discards;
  1061. u64 rx_mac_bytes;
  1062. u64 rx_mac_uc_packets;
  1063. u64 rx_mac_mc_packets;
  1064. u64 rx_mac_bc_packets;
  1065. u64 rx_mac_frames_ok;
  1066. u64 tx_mac_bytes;
  1067. u64 tx_mac_uc_packets;
  1068. u64 tx_mac_mc_packets;
  1069. u64 tx_mac_bc_packets;
  1070. u64 tx_mac_ctrl_frames;
  1071. u64 link_change_count;
  1072. };
  1073. struct qed_eth_stats_bb {
  1074. u64 rx_1519_to_1522_byte_packets;
  1075. u64 rx_1519_to_2047_byte_packets;
  1076. u64 rx_2048_to_4095_byte_packets;
  1077. u64 rx_4096_to_9216_byte_packets;
  1078. u64 rx_9217_to_16383_byte_packets;
  1079. u64 tx_1519_to_2047_byte_packets;
  1080. u64 tx_2048_to_4095_byte_packets;
  1081. u64 tx_4096_to_9216_byte_packets;
  1082. u64 tx_9217_to_16383_byte_packets;
  1083. u64 tx_lpi_entry_count;
  1084. u64 tx_total_collisions;
  1085. };
  1086. struct qed_eth_stats_ah {
  1087. u64 rx_1519_to_max_byte_packets;
  1088. u64 tx_1519_to_max_byte_packets;
  1089. };
  1090. struct qed_eth_stats {
  1091. struct qed_eth_stats_common common;
  1092. union {
  1093. struct qed_eth_stats_bb bb;
  1094. struct qed_eth_stats_ah ah;
  1095. };
  1096. };
  1097. #define QED_SB_IDX 0x0002
  1098. #define RX_PI 0
  1099. #define TX_PI(tc) (RX_PI + 1 + tc)
  1100. struct qed_sb_cnt_info {
  1101. /* Original, current, and free SBs for PF */
  1102. int orig;
  1103. int cnt;
  1104. int free_cnt;
  1105. /* Original, current and free SBS for child VFs */
  1106. int iov_orig;
  1107. int iov_cnt;
  1108. int free_cnt_iov;
  1109. };
  1110. static inline u16 qed_sb_update_sb_idx(struct qed_sb_info *sb_info)
  1111. {
  1112. u32 prod = 0;
  1113. u16 rc = 0;
  1114. prod = le32_to_cpu(sb_info->sb_virt->prod_index) &
  1115. STATUS_BLOCK_E4_PROD_INDEX_MASK;
  1116. if (sb_info->sb_ack != prod) {
  1117. sb_info->sb_ack = prod;
  1118. rc |= QED_SB_IDX;
  1119. }
  1120. /* Let SB update */
  1121. mmiowb();
  1122. return rc;
  1123. }
  1124. /**
  1125. *
  1126. * @brief This function creates an update command for interrupts that is
  1127. * written to the IGU.
  1128. *
  1129. * @param sb_info - This is the structure allocated and
  1130. * initialized per status block. Assumption is
  1131. * that it was initialized using qed_sb_init
  1132. * @param int_cmd - Enable/Disable/Nop
  1133. * @param upd_flg - whether igu consumer should be
  1134. * updated.
  1135. *
  1136. * @return inline void
  1137. */
  1138. static inline void qed_sb_ack(struct qed_sb_info *sb_info,
  1139. enum igu_int_cmd int_cmd,
  1140. u8 upd_flg)
  1141. {
  1142. struct igu_prod_cons_update igu_ack = { 0 };
  1143. igu_ack.sb_id_and_flags =
  1144. ((sb_info->sb_ack << IGU_PROD_CONS_UPDATE_SB_INDEX_SHIFT) |
  1145. (upd_flg << IGU_PROD_CONS_UPDATE_UPDATE_FLAG_SHIFT) |
  1146. (int_cmd << IGU_PROD_CONS_UPDATE_ENABLE_INT_SHIFT) |
  1147. (IGU_SEG_ACCESS_REG <<
  1148. IGU_PROD_CONS_UPDATE_SEGMENT_ACCESS_SHIFT));
  1149. DIRECT_REG_WR(sb_info->igu_addr, igu_ack.sb_id_and_flags);
  1150. /* Both segments (interrupts & acks) are written to same place address;
  1151. * Need to guarantee all commands will be received (in-order) by HW.
  1152. */
  1153. mmiowb();
  1154. barrier();
  1155. }
  1156. static inline void __internal_ram_wr(void *p_hwfn,
  1157. void __iomem *addr,
  1158. int size,
  1159. u32 *data)
  1160. {
  1161. unsigned int i;
  1162. for (i = 0; i < size / sizeof(*data); i++)
  1163. DIRECT_REG_WR(&((u32 __iomem *)addr)[i], data[i]);
  1164. }
  1165. static inline void internal_ram_wr(void __iomem *addr,
  1166. int size,
  1167. u32 *data)
  1168. {
  1169. __internal_ram_wr(NULL, addr, size, data);
  1170. }
  1171. enum qed_rss_caps {
  1172. QED_RSS_IPV4 = 0x1,
  1173. QED_RSS_IPV6 = 0x2,
  1174. QED_RSS_IPV4_TCP = 0x4,
  1175. QED_RSS_IPV6_TCP = 0x8,
  1176. QED_RSS_IPV4_UDP = 0x10,
  1177. QED_RSS_IPV6_UDP = 0x20,
  1178. };
  1179. #define QED_RSS_IND_TABLE_SIZE 128
  1180. #define QED_RSS_KEY_SIZE 10 /* size in 32b chunks */
  1181. #endif