4588a2936597dde7e82e06dac5a04804fb781504
[dpdk.git] / drivers / net / octeontx_ep / otx_ep_common.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2021 Marvell.
3  */
4 #ifndef _OTX_EP_COMMON_H_
5 #define _OTX_EP_COMMON_H_
6
7 #define OTX_EP_MAX_RINGS_PER_VF        (8)
8 #define OTX_EP_CFG_IO_QUEUES        OTX_EP_MAX_RINGS_PER_VF
9 #define OTX_EP_64BYTE_INSTR         (64)
10 #define OTX_EP_MIN_IQ_DESCRIPTORS   (128)
11 #define OTX_EP_MIN_OQ_DESCRIPTORS   (128)
12 #define OTX_EP_MAX_IQ_DESCRIPTORS   (8192)
13 #define OTX_EP_MAX_OQ_DESCRIPTORS   (8192)
14 #define OTX_EP_OQ_BUF_SIZE          (2048)
15 #define OTX_EP_MIN_RX_BUF_SIZE      (64)
16
17 #define OTX_EP_OQ_INFOPTR_MODE      (0)
18 #define OTX_EP_OQ_REFIL_THRESHOLD   (16)
19
20 #define otx_ep_info(fmt, args...)                               \
21         rte_log(RTE_LOG_INFO, otx_net_ep_logtype,               \
22                 "%s():%u " fmt "\n",                            \
23                 __func__, __LINE__, ##args)
24
25 #define otx_ep_err(fmt, args...)                                \
26         rte_log(RTE_LOG_ERR, otx_net_ep_logtype,                \
27                 "%s():%u " fmt "\n",                            \
28                 __func__, __LINE__, ##args)
29
30 #define otx_ep_dbg(fmt, args...)                                \
31         rte_log(RTE_LOG_DEBUG, otx_net_ep_logtype,              \
32                 "%s():%u " fmt "\n",                            \
33                 __func__, __LINE__, ##args)
34
35 #define otx_ep_write64(value, base_addr, reg_off) \
36         {\
37         typeof(value) val = (value); \
38         typeof(reg_off) off = (reg_off); \
39         otx_ep_dbg("octeon_write_csr64: reg: 0x%08lx val: 0x%016llx\n", \
40                    (unsigned long)off, (unsigned long long)val); \
41         rte_write64(val, ((base_addr) + off)); \
42         }
43
44 struct otx_ep_device;
45
46 /* Structure to define the configuration attributes for each Input queue. */
47 struct otx_ep_iq_config {
48         /* Max number of IQs available */
49         uint16_t max_iqs;
50
51         /* Command size - 32 or 64 bytes */
52         uint16_t instr_type;
53
54         /* Pending list size, usually set to the sum of the size of all IQs */
55         uint32_t pending_list_size;
56 };
57
58 /* Structure to define the configuration attributes for each Output queue. */
59 struct otx_ep_oq_config {
60         /* Max number of OQs available */
61         uint16_t max_oqs;
62
63         /* If set, the Output queue uses info-pointer mode. (Default: 1 ) */
64         uint16_t info_ptr;
65
66         /** The number of buffers that were consumed during packet processing by
67          *  the driver on this Output queue before the driver attempts to
68          *  replenish the descriptor ring with new buffers.
69          */
70         uint32_t refill_threshold;
71 };
72
73 /* Structure to define the configuration. */
74 struct otx_ep_config {
75         /* Input Queue attributes. */
76         struct otx_ep_iq_config iq;
77
78         /* Output Queue attributes. */
79         struct otx_ep_oq_config oq;
80
81         /* Num of desc for IQ rings */
82         uint32_t num_iqdef_descs;
83
84         /* Num of desc for OQ rings */
85         uint32_t num_oqdef_descs;
86
87         /* OQ buffer size */
88         uint32_t oqdef_buf_size;
89 };
90
91 /* SRIOV information */
92 struct otx_ep_sriov_info {
93         /* Number of rings assigned to VF */
94         uint32_t rings_per_vf;
95
96         /* Number of VF devices enabled */
97         uint32_t num_vfs;
98 };
99
100 /* Required functions for each VF device */
101 struct otx_ep_fn_list {
102         void (*setup_device_regs)(struct otx_ep_device *otx_ep);
103 };
104
105 /* OTX_EP EP VF device data structure */
106 struct otx_ep_device {
107         /* PCI device pointer */
108         struct rte_pci_device *pdev;
109
110         uint16_t chip_id;
111
112         struct rte_eth_dev *eth_dev;
113
114         int port_id;
115
116         /* Memory mapped h/w address */
117         uint8_t *hw_addr;
118
119         struct otx_ep_fn_list fn_list;
120
121         uint32_t max_tx_queues;
122
123         uint32_t max_rx_queues;
124
125         /* SR-IOV info */
126         struct otx_ep_sriov_info sriov_info;
127
128         /* Device configuration */
129         const struct otx_ep_config *conf;
130
131         uint64_t rx_offloads;
132
133         uint64_t tx_offloads;
134 };
135
136 #define OTX_EP_MAX_PKT_SZ 64000U
137 #define OTX_EP_MAX_MAC_ADDRS 1
138
139 extern int otx_net_ep_logtype;
140 #endif  /* _OTX_EP_COMMON_H_ */