1 /* SPDX-License-Identifier: GPL-2.0 or Linux-OpenIB */
2 /* Copyright (c) 2015 - 2021 Intel Corporation */
3 #ifndef IRDMA_OSDEP_H
4 #define IRDMA_OSDEP_H
5 
6 #include <linux/pci.h>
7 #include <linux/bitfield.h>
8 #include <crypto/hash.h>
9 #include <rdma/ib_verbs.h>
10 
11 #define STATS_TIMER_DELAY	60000
12 
13 struct irdma_dma_info {
14 	dma_addr_t *dmaaddrs;
15 };
16 
17 struct irdma_dma_mem {
18 	void *va;
19 	dma_addr_t pa;
20 	u32 size;
21 } __packed;
22 
23 struct irdma_virt_mem {
24 	void *va;
25 	u32 size;
26 } __packed;
27 
28 struct irdma_sc_vsi;
29 struct irdma_sc_dev;
30 struct irdma_sc_qp;
31 struct irdma_puda_buf;
32 struct irdma_puda_cmpl_info;
33 struct irdma_update_sds_info;
34 struct irdma_hmc_fcn_info;
35 struct irdma_manage_vf_pble_info;
36 struct irdma_hw;
37 struct irdma_pci_f;
38 
39 struct ib_device *to_ibdev(struct irdma_sc_dev *dev);
40 u8 __iomem *irdma_get_hw_addr(void *dev);
41 void irdma_ieq_mpa_crc_ae(struct irdma_sc_dev *dev, struct irdma_sc_qp *qp);
42 enum irdma_status_code irdma_vf_wait_vchnl_resp(struct irdma_sc_dev *dev);
43 bool irdma_vf_clear_to_send(struct irdma_sc_dev *dev);
44 void irdma_add_dev_ref(struct irdma_sc_dev *dev);
45 void irdma_put_dev_ref(struct irdma_sc_dev *dev);
46 enum irdma_status_code irdma_ieq_check_mpacrc(struct shash_desc *desc,
47 					      void *addr, u32 len, u32 val);
48 struct irdma_sc_qp *irdma_ieq_get_qp(struct irdma_sc_dev *dev,
49 				     struct irdma_puda_buf *buf);
50 void irdma_send_ieq_ack(struct irdma_sc_qp *qp);
51 void irdma_ieq_update_tcpip_info(struct irdma_puda_buf *buf, u16 len,
52 				 u32 seqnum);
53 void irdma_free_hash_desc(struct shash_desc *hash_desc);
54 enum irdma_status_code irdma_init_hash_desc(struct shash_desc **hash_desc);
55 enum irdma_status_code
56 irdma_puda_get_tcpip_info(struct irdma_puda_cmpl_info *info,
57 			  struct irdma_puda_buf *buf);
58 enum irdma_status_code irdma_cqp_sds_cmd(struct irdma_sc_dev *dev,
59 					 struct irdma_update_sds_info *info);
60 enum irdma_status_code
61 irdma_cqp_manage_hmc_fcn_cmd(struct irdma_sc_dev *dev,
62 			     struct irdma_hmc_fcn_info *hmcfcninfo,
63 			     u16 *pmf_idx);
64 enum irdma_status_code
65 irdma_cqp_query_fpm_val_cmd(struct irdma_sc_dev *dev,
66 			    struct irdma_dma_mem *val_mem, u8 hmc_fn_id);
67 enum irdma_status_code
68 irdma_cqp_commit_fpm_val_cmd(struct irdma_sc_dev *dev,
69 			     struct irdma_dma_mem *val_mem, u8 hmc_fn_id);
70 enum irdma_status_code irdma_alloc_query_fpm_buf(struct irdma_sc_dev *dev,
71 						 struct irdma_dma_mem *mem);
72 void *irdma_remove_cqp_head(struct irdma_sc_dev *dev);
73 void irdma_term_modify_qp(struct irdma_sc_qp *qp, u8 next_state, u8 term,
74 			  u8 term_len);
75 void irdma_terminate_done(struct irdma_sc_qp *qp, int timeout_occurred);
76 void irdma_terminate_start_timer(struct irdma_sc_qp *qp);
77 void irdma_terminate_del_timer(struct irdma_sc_qp *qp);
78 void irdma_hw_stats_start_timer(struct irdma_sc_vsi *vsi);
79 void irdma_hw_stats_stop_timer(struct irdma_sc_vsi *vsi);
80 void wr32(struct irdma_hw *hw, u32 reg, u32 val);
81 u32 rd32(struct irdma_hw *hw, u32 reg);
82 u64 rd64(struct irdma_hw *hw, u32 reg);
83 enum irdma_status_code irdma_map_vm_page_list(struct irdma_hw *hw, void *va,
84 					      dma_addr_t *pg_dma, u32 pg_cnt);
85 void irdma_unmap_vm_page_list(struct irdma_hw *hw, dma_addr_t *pg_dma, u32 pg_cnt);
86 #endif /* IRDMA_OSDEP_H */
87