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