1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /* Copyright(c) 2007-2022 Intel Corporation */
3 #ifndef ADF_PFVF_UTILS_H
4 #define ADF_PFVF_UTILS_H
5 
6 #include <linux/types.h>
7 #include "adf_pfvf_msg.h"
8 
9 /* How long to wait for far side to acknowledge receipt */
10 #define ADF_PFVF_MSG_ACK_DELAY_US 4
11 #define ADF_PFVF_MSG_ACK_MAX_DELAY_US (1 * USEC_PER_SEC)
12 
13 u8 adf_pfvf_calc_blkmsg_crc(u8 const *buf, u8 buf_len);
14 
15 struct pfvf_field_format {
16 	u8 offset;
17 	u32 mask;
18 };
19 
20 struct pfvf_csr_format {
21 	struct pfvf_field_format type;
22 	struct pfvf_field_format data;
23 };
24 
25 u32 adf_pfvf_csr_msg_of(struct adf_accel_dev *accel_dev,
26 			struct pfvf_message msg,
27 			const struct pfvf_csr_format *fmt);
28 struct pfvf_message adf_pfvf_message_of(struct adf_accel_dev *accel_dev,
29 					u32 raw_msg,
30 					const struct pfvf_csr_format *fmt);
31 
32 static inline struct resource *
33 adf_get_pmisc_base(struct adf_accel_dev *accel_dev)
34 {
35 	struct adf_hw_device_data *hw_data = accel_dev->hw_device;
36 	struct adf_bar *pmisc;
37 
38 	pmisc = &GET_BARS(accel_dev)[hw_data->get_misc_bar_id(hw_data)];
39 
40 	return pmisc->virt_addr;
41 }
42 
43 #endif /* ADF_PFVF_UTILS_H */
44