qed.h 15 KB

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