xref: /dpdk/drivers/vdpa/ifc/base/ifcvf_osdep.h (revision fd51012de5369679e807be1d6a81d63ef15015ce)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2018 Intel Corporation
3  */
4 
5 #ifndef _IFCVF_OSDEP_H_
6 #define _IFCVF_OSDEP_H_
7 
8 #include <stdint.h>
9 
10 #include <rte_cycles.h>
11 #include <rte_pci.h>
12 #include <bus_pci_driver.h>
13 #include <rte_log.h>
14 #include <rte_io.h>
15 
16 extern int ifcvf_vdpa_logtype;
17 #define RTE_LOGTYPE_IFCVF_VDPA ifcvf_vdpa_logtype
18 
19 #define WARNINGOUT(S, ...)      RTE_LOG(WARNING, IFCVF_VDPA, S, ##__VA_ARGS__)
20 #define DEBUGOUT(S, ...)        RTE_LOG(DEBUG, IFCVF_VDPA, S, ##__VA_ARGS__)
21 #define STATIC                  static
22 
23 #define msec_delay(x)	rte_delay_us_sleep(1000 * (x))
24 
25 #define IFCVF_READ_REG8(reg)		rte_read8(reg)
26 #define IFCVF_WRITE_REG8(val, reg)	rte_write8((val), (reg))
27 #define IFCVF_READ_REG16(reg)		rte_read16(reg)
28 #define IFCVF_WRITE_REG16(val, reg)	rte_write16((val), (reg))
29 #define IFCVF_READ_REG32(reg)		rte_read32(reg)
30 #define IFCVF_WRITE_REG32(val, reg)	rte_write32((val), (reg))
31 
32 typedef struct rte_pci_device PCI_DEV;
33 
34 #define PCI_READ_CONFIG_BYTE(dev, val, where) \
35 	rte_pci_read_config(dev, val, 1, where)
36 
37 #define PCI_READ_CONFIG_DWORD(dev, val, where) \
38 	rte_pci_read_config(dev, val, 4, where)
39 
40 #define PCI_CAPABILITY_LIST RTE_PCI_CAPABILITY_LIST
41 #define PCI_CAP_ID_VNDR RTE_PCI_CAP_ID_VNDR
42 
43 typedef uint8_t    u8;
44 typedef int8_t     s8;
45 typedef uint16_t   u16;
46 typedef int16_t    s16;
47 typedef uint32_t   u32;
48 typedef int32_t    s32;
49 typedef int64_t    s64;
50 typedef uint64_t   u64;
51 
52 static inline int
53 PCI_READ_CONFIG_RANGE(PCI_DEV *dev, uint32_t *val, int size, int where)
54 {
55 	return rte_pci_read_config(dev, val, size, where);
56 }
57 
58 #endif /* _IFCVF_OSDEP_H_ */
59