qed.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725
  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_H
  33. #define _QED_H
  34. #include <linux/types.h>
  35. #include <linux/io.h>
  36. #include <linux/delay.h>
  37. #include <linux/firmware.h>
  38. #include <linux/interrupt.h>
  39. #include <linux/list.h>
  40. #include <linux/mutex.h>
  41. #include <linux/pci.h>
  42. #include <linux/slab.h>
  43. #include <linux/string.h>
  44. #include <linux/workqueue.h>
  45. #include <linux/zlib.h>
  46. #include <linux/hashtable.h>
  47. #include <linux/qed/qed_if.h>
  48. #include "qed_debug.h"
  49. #include "qed_hsi.h"
  50. extern const struct qed_common_ops qed_common_ops_pass;
  51. #define DRV_MODULE_VERSION "8.10.10.20"
  52. #define MAX_HWFNS_PER_DEVICE (4)
  53. #define NAME_SIZE 16
  54. #define VER_SIZE 16
  55. #define QED_WFQ_UNIT 100
  56. #define ISCSI_BDQ_ID(_port_id) (_port_id)
  57. #define FCOE_BDQ_ID(_port_id) ((_port_id) + 2)
  58. #define QED_WID_SIZE (1024)
  59. #define QED_PF_DEMS_SIZE (4)
  60. /* cau states */
  61. enum qed_coalescing_mode {
  62. QED_COAL_MODE_DISABLE,
  63. QED_COAL_MODE_ENABLE
  64. };
  65. struct qed_eth_cb_ops;
  66. struct qed_dev_info;
  67. union qed_mcp_protocol_stats;
  68. enum qed_mcp_protocol_type;
  69. /* helpers */
  70. static inline u32 qed_db_addr(u32 cid, u32 DEMS)
  71. {
  72. u32 db_addr = FIELD_VALUE(DB_LEGACY_ADDR_DEMS, DEMS) |
  73. (cid * QED_PF_DEMS_SIZE);
  74. return db_addr;
  75. }
  76. static inline u32 qed_db_addr_vf(u32 cid, u32 DEMS)
  77. {
  78. u32 db_addr = FIELD_VALUE(DB_LEGACY_ADDR_DEMS, DEMS) |
  79. FIELD_VALUE(DB_LEGACY_ADDR_ICID, cid);
  80. return db_addr;
  81. }
  82. #define ALIGNED_TYPE_SIZE(type_name, p_hwfn) \
  83. ((sizeof(type_name) + (u32)(1 << (p_hwfn->cdev->cache_shift)) - 1) & \
  84. ~((1 << (p_hwfn->cdev->cache_shift)) - 1))
  85. #define for_each_hwfn(cdev, i) for (i = 0; i < cdev->num_hwfns; i++)
  86. #define D_TRINE(val, cond1, cond2, true1, true2, def) \
  87. (val == (cond1) ? true1 : \
  88. (val == (cond2) ? true2 : def))
  89. /* forward */
  90. struct qed_ptt_pool;
  91. struct qed_spq;
  92. struct qed_sb_info;
  93. struct qed_sb_attn_info;
  94. struct qed_cxt_mngr;
  95. struct qed_sb_sp_info;
  96. struct qed_ll2_info;
  97. struct qed_mcp_info;
  98. struct qed_rt_data {
  99. u32 *init_val;
  100. bool *b_valid;
  101. };
  102. enum qed_tunn_mode {
  103. QED_MODE_L2GENEVE_TUNN,
  104. QED_MODE_IPGENEVE_TUNN,
  105. QED_MODE_L2GRE_TUNN,
  106. QED_MODE_IPGRE_TUNN,
  107. QED_MODE_VXLAN_TUNN,
  108. };
  109. enum qed_tunn_clss {
  110. QED_TUNN_CLSS_MAC_VLAN,
  111. QED_TUNN_CLSS_MAC_VNI,
  112. QED_TUNN_CLSS_INNER_MAC_VLAN,
  113. QED_TUNN_CLSS_INNER_MAC_VNI,
  114. MAX_QED_TUNN_CLSS,
  115. };
  116. struct qed_tunn_start_params {
  117. unsigned long tunn_mode;
  118. u16 vxlan_udp_port;
  119. u16 geneve_udp_port;
  120. u8 update_vxlan_udp_port;
  121. u8 update_geneve_udp_port;
  122. u8 tunn_clss_vxlan;
  123. u8 tunn_clss_l2geneve;
  124. u8 tunn_clss_ipgeneve;
  125. u8 tunn_clss_l2gre;
  126. u8 tunn_clss_ipgre;
  127. };
  128. struct qed_tunn_update_params {
  129. unsigned long tunn_mode_update_mask;
  130. unsigned long tunn_mode;
  131. u16 vxlan_udp_port;
  132. u16 geneve_udp_port;
  133. u8 update_rx_pf_clss;
  134. u8 update_tx_pf_clss;
  135. u8 update_vxlan_udp_port;
  136. u8 update_geneve_udp_port;
  137. u8 tunn_clss_vxlan;
  138. u8 tunn_clss_l2geneve;
  139. u8 tunn_clss_ipgeneve;
  140. u8 tunn_clss_l2gre;
  141. u8 tunn_clss_ipgre;
  142. };
  143. /* The PCI personality is not quite synonymous to protocol ID:
  144. * 1. All personalities need CORE connections
  145. * 2. The Ethernet personality may support also the RoCE protocol
  146. */
  147. enum qed_pci_personality {
  148. QED_PCI_ETH,
  149. QED_PCI_FCOE,
  150. QED_PCI_ISCSI,
  151. QED_PCI_ETH_ROCE,
  152. QED_PCI_DEFAULT /* default in shmem */
  153. };
  154. /* All VFs are symmetric, all counters are PF + all VFs */
  155. struct qed_qm_iids {
  156. u32 cids;
  157. u32 vf_cids;
  158. u32 tids;
  159. };
  160. /* HW / FW resources, output of features supported below, most information
  161. * is received from MFW.
  162. */
  163. enum qed_resources {
  164. QED_SB,
  165. QED_L2_QUEUE,
  166. QED_VPORT,
  167. QED_RSS_ENG,
  168. QED_PQ,
  169. QED_RL,
  170. QED_MAC,
  171. QED_VLAN,
  172. QED_RDMA_CNQ_RAM,
  173. QED_ILT,
  174. QED_LL2_QUEUE,
  175. QED_CMDQS_CQS,
  176. QED_RDMA_STATS_QUEUE,
  177. QED_MAX_RESC,
  178. };
  179. enum QED_FEATURE {
  180. QED_PF_L2_QUE,
  181. QED_VF,
  182. QED_RDMA_CNQ,
  183. QED_VF_L2_QUE,
  184. QED_FCOE_CQ,
  185. QED_MAX_FEATURES,
  186. };
  187. enum QED_PORT_MODE {
  188. QED_PORT_MODE_DE_2X40G,
  189. QED_PORT_MODE_DE_2X50G,
  190. QED_PORT_MODE_DE_1X100G,
  191. QED_PORT_MODE_DE_4X10G_F,
  192. QED_PORT_MODE_DE_4X10G_E,
  193. QED_PORT_MODE_DE_4X20G,
  194. QED_PORT_MODE_DE_1X40G,
  195. QED_PORT_MODE_DE_2X25G,
  196. QED_PORT_MODE_DE_1X25G
  197. };
  198. enum qed_dev_cap {
  199. QED_DEV_CAP_ETH,
  200. QED_DEV_CAP_FCOE,
  201. QED_DEV_CAP_ISCSI,
  202. QED_DEV_CAP_ROCE,
  203. };
  204. enum qed_wol_support {
  205. QED_WOL_SUPPORT_NONE,
  206. QED_WOL_SUPPORT_PME,
  207. };
  208. struct qed_hw_info {
  209. /* PCI personality */
  210. enum qed_pci_personality personality;
  211. /* Resource Allocation scheme results */
  212. u32 resc_start[QED_MAX_RESC];
  213. u32 resc_num[QED_MAX_RESC];
  214. u32 feat_num[QED_MAX_FEATURES];
  215. #define RESC_START(_p_hwfn, resc) ((_p_hwfn)->hw_info.resc_start[resc])
  216. #define RESC_NUM(_p_hwfn, resc) ((_p_hwfn)->hw_info.resc_num[resc])
  217. #define RESC_END(_p_hwfn, resc) (RESC_START(_p_hwfn, resc) + \
  218. RESC_NUM(_p_hwfn, resc))
  219. #define FEAT_NUM(_p_hwfn, resc) ((_p_hwfn)->hw_info.feat_num[resc])
  220. u8 num_tc;
  221. u8 offload_tc;
  222. u8 non_offload_tc;
  223. u32 concrete_fid;
  224. u16 opaque_fid;
  225. u16 ovlan;
  226. u32 part_num[4];
  227. unsigned char hw_mac_addr[ETH_ALEN];
  228. u64 node_wwn;
  229. u64 port_wwn;
  230. u16 num_fcoe_conns;
  231. struct qed_igu_info *p_igu_info;
  232. u32 port_mode;
  233. u32 hw_mode;
  234. unsigned long device_capabilities;
  235. u16 mtu;
  236. enum qed_wol_support b_wol_support;
  237. };
  238. /* maximun size of read/write commands (HW limit) */
  239. #define DMAE_MAX_RW_SIZE 0x2000
  240. struct qed_dmae_info {
  241. /* Mutex for synchronizing access to functions */
  242. struct mutex mutex;
  243. u8 channel;
  244. dma_addr_t completion_word_phys_addr;
  245. /* The memory location where the DMAE writes the completion
  246. * value when an operation is finished on this context.
  247. */
  248. u32 *p_completion_word;
  249. dma_addr_t intermediate_buffer_phys_addr;
  250. /* An intermediate buffer for DMAE operations that use virtual
  251. * addresses - data is DMA'd to/from this buffer and then
  252. * memcpy'd to/from the virtual address
  253. */
  254. u32 *p_intermediate_buffer;
  255. dma_addr_t dmae_cmd_phys_addr;
  256. struct dmae_cmd *p_dmae_cmd;
  257. };
  258. struct qed_wfq_data {
  259. /* when feature is configured for at least 1 vport */
  260. u32 min_speed;
  261. bool configured;
  262. };
  263. struct qed_qm_info {
  264. struct init_qm_pq_params *qm_pq_params;
  265. struct init_qm_vport_params *qm_vport_params;
  266. struct init_qm_port_params *qm_port_params;
  267. u16 start_pq;
  268. u8 start_vport;
  269. u8 pure_lb_pq;
  270. u8 offload_pq;
  271. u8 pure_ack_pq;
  272. u8 ooo_pq;
  273. u8 vf_queues_offset;
  274. u16 num_pqs;
  275. u16 num_vf_pqs;
  276. u8 num_vports;
  277. u8 max_phys_tcs_per_port;
  278. bool pf_rl_en;
  279. bool pf_wfq_en;
  280. bool vport_rl_en;
  281. bool vport_wfq_en;
  282. u8 pf_wfq;
  283. u32 pf_rl;
  284. struct qed_wfq_data *wfq_data;
  285. u8 num_pf_rls;
  286. };
  287. struct storm_stats {
  288. u32 address;
  289. u32 len;
  290. };
  291. struct qed_storm_stats {
  292. struct storm_stats mstats;
  293. struct storm_stats pstats;
  294. struct storm_stats tstats;
  295. struct storm_stats ustats;
  296. };
  297. struct qed_fw_data {
  298. struct fw_ver_info *fw_ver_info;
  299. const u8 *modes_tree_buf;
  300. union init_op *init_ops;
  301. const u32 *arr_data;
  302. u32 init_ops_size;
  303. };
  304. struct qed_simd_fp_handler {
  305. void *token;
  306. void (*func)(void *);
  307. };
  308. struct qed_hwfn {
  309. struct qed_dev *cdev;
  310. u8 my_id; /* ID inside the PF */
  311. #define IS_LEAD_HWFN(edev) (!((edev)->my_id))
  312. u8 rel_pf_id; /* Relative to engine*/
  313. u8 abs_pf_id;
  314. #define QED_PATH_ID(_p_hwfn) ((_p_hwfn)->abs_pf_id & 1)
  315. u8 port_id;
  316. bool b_active;
  317. u32 dp_module;
  318. u8 dp_level;
  319. char name[NAME_SIZE];
  320. bool first_on_engine;
  321. bool hw_init_done;
  322. u8 num_funcs_on_engine;
  323. u8 enabled_func_idx;
  324. /* BAR access */
  325. void __iomem *regview;
  326. void __iomem *doorbells;
  327. u64 db_phys_addr;
  328. unsigned long db_size;
  329. /* PTT pool */
  330. struct qed_ptt_pool *p_ptt_pool;
  331. /* HW info */
  332. struct qed_hw_info hw_info;
  333. /* rt_array (for init-tool) */
  334. struct qed_rt_data rt_data;
  335. /* SPQ */
  336. struct qed_spq *p_spq;
  337. /* EQ */
  338. struct qed_eq *p_eq;
  339. /* Consolidate Q*/
  340. struct qed_consq *p_consq;
  341. /* Slow-Path definitions */
  342. struct tasklet_struct *sp_dpc;
  343. bool b_sp_dpc_enabled;
  344. struct qed_ptt *p_main_ptt;
  345. struct qed_ptt *p_dpc_ptt;
  346. struct qed_sb_sp_info *p_sp_sb;
  347. struct qed_sb_attn_info *p_sb_attn;
  348. /* Protocol related */
  349. bool using_ll2;
  350. struct qed_ll2_info *p_ll2_info;
  351. struct qed_ooo_info *p_ooo_info;
  352. struct qed_rdma_info *p_rdma_info;
  353. struct qed_iscsi_info *p_iscsi_info;
  354. struct qed_fcoe_info *p_fcoe_info;
  355. struct qed_pf_params pf_params;
  356. bool b_rdma_enabled_in_prs;
  357. u32 rdma_prs_search_reg;
  358. /* Array of sb_info of all status blocks */
  359. struct qed_sb_info *sbs_info[MAX_SB_PER_PF_MIMD];
  360. u16 num_sbs;
  361. struct qed_cxt_mngr *p_cxt_mngr;
  362. /* Flag indicating whether interrupts are enabled or not*/
  363. bool b_int_enabled;
  364. bool b_int_requested;
  365. /* True if the driver requests for the link */
  366. bool b_drv_link_init;
  367. struct qed_vf_iov *vf_iov_info;
  368. struct qed_pf_iov *pf_iov_info;
  369. struct qed_mcp_info *mcp_info;
  370. struct qed_dcbx_info *p_dcbx_info;
  371. struct qed_dmae_info dmae_info;
  372. /* QM init */
  373. struct qed_qm_info qm_info;
  374. struct qed_storm_stats storm_stats;
  375. /* Buffer for unzipping firmware data */
  376. void *unzip_buf;
  377. struct dbg_tools_data dbg_info;
  378. /* PWM region specific data */
  379. u32 dpi_size;
  380. u32 dpi_count;
  381. /* This is used to calculate the doorbell address */
  382. u32 dpi_start_offset;
  383. /* If one of the following is set then EDPM shouldn't be used */
  384. u8 dcbx_no_edpm;
  385. u8 db_bar_no_edpm;
  386. /* p_ptp_ptt is valid for leading HWFN only */
  387. struct qed_ptt *p_ptp_ptt;
  388. struct qed_simd_fp_handler simd_proto_handler[64];
  389. #ifdef CONFIG_QED_SRIOV
  390. struct workqueue_struct *iov_wq;
  391. struct delayed_work iov_task;
  392. unsigned long iov_task_flags;
  393. #endif
  394. struct z_stream_s *stream;
  395. struct qed_roce_ll2_info *ll2;
  396. };
  397. struct pci_params {
  398. int pm_cap;
  399. unsigned long mem_start;
  400. unsigned long mem_end;
  401. unsigned int irq;
  402. u8 pf_num;
  403. };
  404. struct qed_int_param {
  405. u32 int_mode;
  406. u8 num_vectors;
  407. u8 min_msix_cnt; /* for minimal functionality */
  408. };
  409. struct qed_int_params {
  410. struct qed_int_param in;
  411. struct qed_int_param out;
  412. struct msix_entry *msix_table;
  413. bool fp_initialized;
  414. u8 fp_msix_base;
  415. u8 fp_msix_cnt;
  416. u8 rdma_msix_base;
  417. u8 rdma_msix_cnt;
  418. };
  419. struct qed_dbg_feature {
  420. struct dentry *dentry;
  421. u8 *dump_buf;
  422. u32 buf_size;
  423. u32 dumped_dwords;
  424. };
  425. struct qed_dbg_params {
  426. struct qed_dbg_feature features[DBG_FEATURE_NUM];
  427. u8 engine_for_debug;
  428. bool print_data;
  429. };
  430. struct qed_dev {
  431. u32 dp_module;
  432. u8 dp_level;
  433. char name[NAME_SIZE];
  434. u8 type;
  435. #define QED_DEV_TYPE_BB (0 << 0)
  436. #define QED_DEV_TYPE_AH BIT(0)
  437. /* Translate type/revision combo into the proper conditions */
  438. #define QED_IS_BB(dev) ((dev)->type == QED_DEV_TYPE_BB)
  439. #define QED_IS_BB_A0(dev) (QED_IS_BB(dev) && \
  440. CHIP_REV_IS_A0(dev))
  441. #define QED_IS_BB_B0(dev) (QED_IS_BB(dev) && \
  442. CHIP_REV_IS_B0(dev))
  443. #define QED_IS_AH(dev) ((dev)->type == QED_DEV_TYPE_AH)
  444. #define QED_IS_K2(dev) QED_IS_AH(dev)
  445. #define QED_GET_TYPE(dev) (QED_IS_BB_A0(dev) ? CHIP_BB_A0 : \
  446. QED_IS_BB_B0(dev) ? CHIP_BB_B0 : CHIP_K2)
  447. u16 vendor_id;
  448. u16 device_id;
  449. u16 chip_num;
  450. #define CHIP_NUM_MASK 0xffff
  451. #define CHIP_NUM_SHIFT 16
  452. u16 chip_rev;
  453. #define CHIP_REV_MASK 0xf
  454. #define CHIP_REV_SHIFT 12
  455. #define CHIP_REV_IS_A0(_cdev) (!(_cdev)->chip_rev)
  456. #define CHIP_REV_IS_B0(_cdev) ((_cdev)->chip_rev == 1)
  457. u16 chip_metal;
  458. #define CHIP_METAL_MASK 0xff
  459. #define CHIP_METAL_SHIFT 4
  460. u16 chip_bond_id;
  461. #define CHIP_BOND_ID_MASK 0xf
  462. #define CHIP_BOND_ID_SHIFT 0
  463. u8 num_engines;
  464. u8 num_ports_in_engines;
  465. u8 num_funcs_in_port;
  466. u8 path_id;
  467. enum qed_mf_mode mf_mode;
  468. #define IS_MF_DEFAULT(_p_hwfn) (((_p_hwfn)->cdev)->mf_mode == QED_MF_DEFAULT)
  469. #define IS_MF_SI(_p_hwfn) (((_p_hwfn)->cdev)->mf_mode == QED_MF_NPAR)
  470. #define IS_MF_SD(_p_hwfn) (((_p_hwfn)->cdev)->mf_mode == QED_MF_OVLAN)
  471. int pcie_width;
  472. int pcie_speed;
  473. u8 ver_str[VER_SIZE];
  474. /* Add MF related configuration */
  475. u8 mcp_rev;
  476. u8 boot_mode;
  477. /* WoL related configurations */
  478. u8 wol_config;
  479. u8 wol_mac[ETH_ALEN];
  480. u32 int_mode;
  481. enum qed_coalescing_mode int_coalescing_mode;
  482. u16 rx_coalesce_usecs;
  483. u16 tx_coalesce_usecs;
  484. /* Start Bar offset of first hwfn */
  485. void __iomem *regview;
  486. void __iomem *doorbells;
  487. u64 db_phys_addr;
  488. unsigned long db_size;
  489. /* PCI */
  490. u8 cache_shift;
  491. /* Init */
  492. const struct iro *iro_arr;
  493. #define IRO (p_hwfn->cdev->iro_arr)
  494. /* HW functions */
  495. u8 num_hwfns;
  496. struct qed_hwfn hwfns[MAX_HWFNS_PER_DEVICE];
  497. /* SRIOV */
  498. struct qed_hw_sriov_info *p_iov_info;
  499. #define IS_QED_SRIOV(cdev) (!!(cdev)->p_iov_info)
  500. unsigned long tunn_mode;
  501. bool b_is_vf;
  502. u32 drv_type;
  503. struct qed_eth_stats *reset_stats;
  504. struct qed_fw_data *fw_data;
  505. u32 mcp_nvm_resp;
  506. /* Linux specific here */
  507. struct qede_dev *edev;
  508. struct pci_dev *pdev;
  509. u32 flags;
  510. #define QED_FLAG_STORAGE_STARTED (BIT(0))
  511. int msg_enable;
  512. struct pci_params pci_params;
  513. struct qed_int_params int_params;
  514. u8 protocol;
  515. #define IS_QED_ETH_IF(cdev) ((cdev)->protocol == QED_PROTOCOL_ETH)
  516. #define IS_QED_FCOE_IF(cdev) ((cdev)->protocol == QED_PROTOCOL_FCOE)
  517. /* Callbacks to protocol driver */
  518. union {
  519. struct qed_common_cb_ops *common;
  520. struct qed_eth_cb_ops *eth;
  521. struct qed_fcoe_cb_ops *fcoe;
  522. struct qed_iscsi_cb_ops *iscsi;
  523. } protocol_ops;
  524. void *ops_cookie;
  525. struct qed_dbg_params dbg_params;
  526. #ifdef CONFIG_QED_LL2
  527. struct qed_cb_ll2_info *ll2;
  528. u8 ll2_mac_address[ETH_ALEN];
  529. #endif
  530. DECLARE_HASHTABLE(connections, 10);
  531. const struct firmware *firmware;
  532. u32 rdma_max_sge;
  533. u32 rdma_max_inline;
  534. u32 rdma_max_srq_sge;
  535. };
  536. #define NUM_OF_VFS(dev) MAX_NUM_VFS_BB
  537. #define NUM_OF_L2_QUEUES(dev) MAX_NUM_L2_QUEUES_BB
  538. #define NUM_OF_SBS(dev) MAX_SB_PER_PATH_BB
  539. #define NUM_OF_ENG_PFS(dev) MAX_NUM_PFS_BB
  540. /**
  541. * @brief qed_concrete_to_sw_fid - get the sw function id from
  542. * the concrete value.
  543. *
  544. * @param concrete_fid
  545. *
  546. * @return inline u8
  547. */
  548. static inline u8 qed_concrete_to_sw_fid(struct qed_dev *cdev,
  549. u32 concrete_fid)
  550. {
  551. u8 vfid = GET_FIELD(concrete_fid, PXP_CONCRETE_FID_VFID);
  552. u8 pfid = GET_FIELD(concrete_fid, PXP_CONCRETE_FID_PFID);
  553. u8 vf_valid = GET_FIELD(concrete_fid,
  554. PXP_CONCRETE_FID_VFVALID);
  555. u8 sw_fid;
  556. if (vf_valid)
  557. sw_fid = vfid + MAX_NUM_PFS;
  558. else
  559. sw_fid = pfid;
  560. return sw_fid;
  561. }
  562. #define PURE_LB_TC 8
  563. #define OOO_LB_TC 9
  564. int qed_configure_vport_wfq(struct qed_dev *cdev, u16 vp_id, u32 rate);
  565. void qed_configure_vp_wfq_on_link_change(struct qed_dev *cdev,
  566. struct qed_ptt *p_ptt,
  567. u32 min_pf_rate);
  568. void qed_clean_wfq_db(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
  569. #define QED_LEADING_HWFN(dev) (&dev->hwfns[0])
  570. /* Other Linux specific common definitions */
  571. #define DP_NAME(cdev) ((cdev)->name)
  572. #define REG_ADDR(cdev, offset) (void __iomem *)((u8 __iomem *)\
  573. (cdev->regview) + \
  574. (offset))
  575. #define REG_RD(cdev, offset) readl(REG_ADDR(cdev, offset))
  576. #define REG_WR(cdev, offset, val) writel((u32)val, REG_ADDR(cdev, offset))
  577. #define REG_WR16(cdev, offset, val) writew((u16)val, REG_ADDR(cdev, offset))
  578. #define DOORBELL(cdev, db_addr, val) \
  579. writel((u32)val, (void __iomem *)((u8 __iomem *)\
  580. (cdev->doorbells) + (db_addr)))
  581. /* Prototypes */
  582. int qed_fill_dev_info(struct qed_dev *cdev,
  583. struct qed_dev_info *dev_info);
  584. void qed_link_update(struct qed_hwfn *hwfn);
  585. u32 qed_unzip_data(struct qed_hwfn *p_hwfn,
  586. u32 input_len, u8 *input_buf,
  587. u32 max_size, u8 *unzip_buf);
  588. void qed_get_protocol_stats(struct qed_dev *cdev,
  589. enum qed_mcp_protocol_type type,
  590. union qed_mcp_protocol_stats *stats);
  591. int qed_slowpath_irq_req(struct qed_hwfn *hwfn);
  592. #endif /* _QED_H */