5d66caebd5e7f7b5ba17f71cc86c91021e931e65
[dpdk.git] / drivers / common / octeontx2 / otx2_mbox.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2019 Marvell International Ltd.
3  */
4
5 #ifndef __OTX2_MBOX_H__
6 #define __OTX2_MBOX_H__
7
8 #include <errno.h>
9 #include <stdbool.h>
10
11 #include <rte_ether.h>
12 #include <rte_spinlock.h>
13
14 #include <otx2_common.h>
15
16 #define SZ_64K                  (64ULL * 1024ULL)
17 #define SZ_1K                   (1ULL * 1024ULL)
18 #define MBOX_SIZE               SZ_64K
19
20 /* AF/PF: PF initiated, PF/VF VF initiated */
21 #define MBOX_DOWN_RX_START      0
22 #define MBOX_DOWN_RX_SIZE       (46 * SZ_1K)
23 #define MBOX_DOWN_TX_START      (MBOX_DOWN_RX_START + MBOX_DOWN_RX_SIZE)
24 #define MBOX_DOWN_TX_SIZE       (16 * SZ_1K)
25 /* AF/PF: AF initiated, PF/VF PF initiated */
26 #define MBOX_UP_RX_START        (MBOX_DOWN_TX_START + MBOX_DOWN_TX_SIZE)
27 #define MBOX_UP_RX_SIZE         SZ_1K
28 #define MBOX_UP_TX_START        (MBOX_UP_RX_START + MBOX_UP_RX_SIZE)
29 #define MBOX_UP_TX_SIZE         SZ_1K
30
31 #if MBOX_UP_TX_SIZE + MBOX_UP_TX_START != MBOX_SIZE
32 # error "Incorrect mailbox area sizes"
33 #endif
34
35 #define INTR_MASK(pfvfs) ((pfvfs < 64) ? (BIT_ULL(pfvfs) - 1) : (~0ull))
36
37 #define MBOX_RSP_TIMEOUT        3000 /* Time to wait for mbox response in ms */
38
39 #define MBOX_MSG_ALIGN          16  /* Align mbox msg start to 16bytes */
40
41 /* Mailbox directions */
42 #define MBOX_DIR_AFPF           0  /* AF replies to PF */
43 #define MBOX_DIR_PFAF           1  /* PF sends messages to AF */
44 #define MBOX_DIR_PFVF           2  /* PF replies to VF */
45 #define MBOX_DIR_VFPF           3  /* VF sends messages to PF */
46 #define MBOX_DIR_AFPF_UP        4  /* AF sends messages to PF */
47 #define MBOX_DIR_PFAF_UP        5  /* PF replies to AF */
48 #define MBOX_DIR_PFVF_UP        6  /* PF sends messages to VF */
49 #define MBOX_DIR_VFPF_UP        7  /* VF replies to PF */
50
51 /* Device memory does not support unaligned access, instruct compiler to
52  * not optimize the memory access when working with mailbox memory.
53  */
54 #define __otx2_io volatile
55
56 struct otx2_mbox_dev {
57         void        *mbase;   /* This dev's mbox region */
58         rte_spinlock_t  mbox_lock;
59         uint16_t     msg_size; /* Total msg size to be sent */
60         uint16_t     rsp_size; /* Total rsp size to be sure the reply is ok */
61         uint16_t     num_msgs; /* No of msgs sent or waiting for response */
62         uint16_t     msgs_acked; /* No of msgs for which response is received */
63 };
64
65 struct otx2_mbox {
66         uintptr_t hwbase;  /* Mbox region advertised by HW */
67         uintptr_t reg_base;/* CSR base for this dev */
68         uint64_t trigger;  /* Trigger mbox notification */
69         uint16_t tr_shift; /* Mbox trigger shift */
70         uint64_t rx_start; /* Offset of Rx region in mbox memory */
71         uint64_t tx_start; /* Offset of Tx region in mbox memory */
72         uint16_t rx_size;  /* Size of Rx region */
73         uint16_t tx_size;  /* Size of Tx region */
74         uint16_t ndevs;    /* The number of peers */
75         struct otx2_mbox_dev *dev;
76         uint64_t intr_offset; /* Offset to interrupt register */
77 };
78
79 /* Header which precedes all mbox messages */
80 struct mbox_hdr {
81         uint64_t __otx2_io msg_size;   /* Total msgs size embedded */
82         uint16_t __otx2_io num_msgs;   /* No of msgs embedded */
83 };
84
85 /* Header which precedes every msg and is also part of it */
86 struct mbox_msghdr {
87         uint16_t __otx2_io pcifunc; /* Who's sending this msg */
88         uint16_t __otx2_io id;      /* Mbox message ID */
89 #define OTX2_MBOX_REQ_SIG (0xdead)
90 #define OTX2_MBOX_RSP_SIG (0xbeef)
91         /* Signature, for validating corrupted msgs */
92         uint16_t __otx2_io sig;
93 #define OTX2_MBOX_VERSION (0x0009)
94         /* Version of msg's structure for this ID */
95         uint16_t __otx2_io ver;
96         /* Offset of next msg within mailbox region */
97         uint16_t __otx2_io next_msgoff;
98         int __otx2_io rc; /* Msg processed response code */
99 };
100
101 /* Mailbox message types */
102 #define MBOX_MSG_MASK                           0xFFFF
103 #define MBOX_MSG_INVALID                        0xFFFE
104 #define MBOX_MSG_MAX                            0xFFFF
105
106 #define MBOX_MESSAGES                                                   \
107 /* Generic mbox IDs (range 0x000 - 0x1FF) */                            \
108 M(READY,                0x001, ready, msg_req, ready_msg_rsp)           \
109 M(ATTACH_RESOURCES,     0x002, attach_resources, rsrc_attach_req, msg_rsp)\
110 M(DETACH_RESOURCES,     0x003, detach_resources, rsrc_detach_req, msg_rsp)\
111 M(FREE_RSRC_CNT,        0x004, free_rsrc_cnt, msg_req, free_rsrcs_rsp)  \
112 M(MSIX_OFFSET,          0x005, msix_offset, msg_req, msix_offset_rsp)   \
113 M(VF_FLR,               0x006, vf_flr, msg_req, msg_rsp)                \
114 M(PTP_OP,               0x007, ptp_op, ptp_req, ptp_rsp)                \
115 M(GET_HW_CAP,           0x008, get_hw_cap, msg_req, get_hw_cap_rsp)     \
116 M(NDC_SYNC_OP,          0x009, ndc_sync_op, ndc_sync_op, msg_rsp)       \
117 /* CGX mbox IDs (range 0x200 - 0x3FF) */                                \
118 M(CGX_START_RXTX,       0x200, cgx_start_rxtx, msg_req, msg_rsp)        \
119 M(CGX_STOP_RXTX,        0x201, cgx_stop_rxtx, msg_req, msg_rsp)         \
120 M(CGX_STATS,            0x202, cgx_stats, msg_req, cgx_stats_rsp)       \
121 M(CGX_MAC_ADDR_SET,     0x203, cgx_mac_addr_set, cgx_mac_addr_set_or_get,\
122                                 cgx_mac_addr_set_or_get)                \
123 M(CGX_MAC_ADDR_GET,     0x204, cgx_mac_addr_get, cgx_mac_addr_set_or_get,\
124                                 cgx_mac_addr_set_or_get)                \
125 M(CGX_PROMISC_ENABLE,   0x205, cgx_promisc_enable, msg_req, msg_rsp)    \
126 M(CGX_PROMISC_DISABLE,  0x206, cgx_promisc_disable, msg_req, msg_rsp)   \
127 M(CGX_START_LINKEVENTS, 0x207, cgx_start_linkevents, msg_req, msg_rsp)  \
128 M(CGX_STOP_LINKEVENTS,  0x208, cgx_stop_linkevents, msg_req, msg_rsp)   \
129 M(CGX_GET_LINKINFO,     0x209, cgx_get_linkinfo, msg_req, cgx_link_info_msg)\
130 M(CGX_INTLBK_ENABLE,    0x20A, cgx_intlbk_enable, msg_req, msg_rsp)     \
131 M(CGX_INTLBK_DISABLE,   0x20B, cgx_intlbk_disable, msg_req, msg_rsp)    \
132 M(CGX_PTP_RX_ENABLE,    0x20C, cgx_ptp_rx_enable, msg_req, msg_rsp)     \
133 M(CGX_PTP_RX_DISABLE,   0x20D, cgx_ptp_rx_disable, msg_req, msg_rsp)    \
134 M(CGX_CFG_PAUSE_FRM,    0x20E, cgx_cfg_pause_frm, cgx_pause_frm_cfg,    \
135                                 cgx_pause_frm_cfg)                      \
136 M(CGX_FW_DATA_GET,      0x20F, cgx_get_aux_link_info, msg_req, cgx_fw_data) \
137 M(CGX_FEC_SET,          0x210, cgx_set_fec_param, fec_mode, fec_mode) \
138 M(CGX_MAC_ADDR_ADD,     0x211, cgx_mac_addr_add, cgx_mac_addr_add_req,  \
139                                 cgx_mac_addr_add_rsp)                   \
140 M(CGX_MAC_ADDR_DEL,     0x212, cgx_mac_addr_del, cgx_mac_addr_del_req,  \
141                                 msg_rsp)                                \
142 M(CGX_MAC_MAX_ENTRIES_GET, 0x213, cgx_mac_max_entries_get, msg_req,     \
143                                  cgx_max_dmac_entries_get_rsp)          \
144 M(CGX_SET_LINK_STATE,   0x214, cgx_set_link_state,              \
145                         cgx_set_link_state_msg, msg_rsp)                \
146 M(CGX_GET_PHY_MOD_TYPE, 0x215, cgx_get_phy_mod_type, msg_req,           \
147                                 cgx_phy_mod_type)                       \
148 M(CGX_SET_PHY_MOD_TYPE, 0x216, cgx_set_phy_mod_type, cgx_phy_mod_type,  \
149                                 msg_rsp)                                \
150 M(CGX_FEC_STATS,        0x217, cgx_fec_stats, msg_req, cgx_fec_stats_rsp) \
151 M(CGX_SET_LINK_MODE,    0x218, cgx_set_link_mode, cgx_set_link_mode_req,\
152                                cgx_set_link_mode_rsp)                   \
153 M(CGX_GET_PHY_FEC_STATS, 0x219, cgx_get_phy_fec_stats, msg_req, msg_rsp) \
154 M(CGX_STATS_RST,        0x21A, cgx_stats_rst, msg_req, msg_rsp)         \
155 /* NPA mbox IDs (range 0x400 - 0x5FF) */                                \
156 M(NPA_LF_ALLOC,         0x400, npa_lf_alloc, npa_lf_alloc_req,          \
157                                 npa_lf_alloc_rsp)                       \
158 M(NPA_LF_FREE,          0x401, npa_lf_free, msg_req, msg_rsp)           \
159 M(NPA_AQ_ENQ,           0x402, npa_aq_enq, npa_aq_enq_req, npa_aq_enq_rsp)\
160 M(NPA_HWCTX_DISABLE,    0x403, npa_hwctx_disable, hwctx_disable_req, msg_rsp)\
161 /* SSO/SSOW mbox IDs (range 0x600 - 0x7FF) */                           \
162 M(SSO_LF_ALLOC,         0x600, sso_lf_alloc, sso_lf_alloc_req,          \
163                                 sso_lf_alloc_rsp)                       \
164 M(SSO_LF_FREE,          0x601, sso_lf_free, sso_lf_free_req, msg_rsp)   \
165 M(SSOW_LF_ALLOC,        0x602, ssow_lf_alloc, ssow_lf_alloc_req, msg_rsp)\
166 M(SSOW_LF_FREE,         0x603, ssow_lf_free, ssow_lf_free_req, msg_rsp) \
167 M(SSO_HW_SETCONFIG,     0x604, sso_hw_setconfig, sso_hw_setconfig,      \
168                                 msg_rsp)                                \
169 M(SSO_GRP_SET_PRIORITY, 0x605, sso_grp_set_priority, sso_grp_priority,  \
170                                 msg_rsp)                                \
171 M(SSO_GRP_GET_PRIORITY, 0x606, sso_grp_get_priority, sso_info_req,      \
172                                 sso_grp_priority)                       \
173 M(SSO_WS_CACHE_INV,     0x607, sso_ws_cache_inv, msg_req, msg_rsp)      \
174 M(SSO_GRP_QOS_CONFIG,   0x608, sso_grp_qos_config, sso_grp_qos_cfg,     \
175                                 msg_rsp)                                \
176 M(SSO_GRP_GET_STATS,    0x609, sso_grp_get_stats, sso_info_req,         \
177                                 sso_grp_stats)                          \
178 M(SSO_HWS_GET_STATS,    0x610, sso_hws_get_stats, sso_info_req,         \
179                                 sso_hws_stats)                          \
180 /* TIM mbox IDs (range 0x800 - 0x9FF) */                                \
181 M(TIM_LF_ALLOC,         0x800, tim_lf_alloc, tim_lf_alloc_req,          \
182                                 tim_lf_alloc_rsp)                       \
183 M(TIM_LF_FREE,          0x801, tim_lf_free, tim_ring_req, msg_rsp)      \
184 M(TIM_CONFIG_RING,      0x802, tim_config_ring, tim_config_req, msg_rsp)\
185 M(TIM_ENABLE_RING,      0x803, tim_enable_ring, tim_ring_req,           \
186                                 tim_enable_rsp)                         \
187 M(TIM_DISABLE_RING,     0x804, tim_disable_ring, tim_ring_req, msg_rsp) \
188 /* CPT mbox IDs (range 0xA00 - 0xBFF) */                                \
189 M(CPT_LF_ALLOC,         0xA00, cpt_lf_alloc, cpt_lf_alloc_req_msg,      \
190                                cpt_lf_alloc_rsp_msg)                    \
191 M(CPT_LF_FREE,          0xA01, cpt_lf_free, msg_req, msg_rsp)           \
192 M(CPT_RD_WR_REGISTER,   0xA02, cpt_rd_wr_register, cpt_rd_wr_reg_msg,   \
193                                cpt_rd_wr_reg_msg)                       \
194 M(CPT_SET_CRYPTO_GRP,   0xA03, cpt_set_crypto_grp,                      \
195                                cpt_set_crypto_grp_req_msg,              \
196                                msg_rsp)                                 \
197 M(CPT_INLINE_IPSEC_CFG, 0xA04, cpt_inline_ipsec_cfg,                    \
198                                cpt_inline_ipsec_cfg_msg, msg_rsp)       \
199 M(CPT_RX_INLINE_LF_CFG, 0xBFE, cpt_rx_inline_lf_cfg,                    \
200                                cpt_rx_inline_lf_cfg_msg, msg_rsp)       \
201 M(CPT_GET_CAPS,         0xBFD, cpt_caps_get, msg_req, cpt_caps_rsp_msg) \
202 /* NPC mbox IDs (range 0x6000 - 0x7FFF) */                              \
203 M(NPC_MCAM_ALLOC_ENTRY, 0x6000, npc_mcam_alloc_entry,                   \
204                                 npc_mcam_alloc_entry_req,               \
205                                 npc_mcam_alloc_entry_rsp)               \
206 M(NPC_MCAM_FREE_ENTRY,  0x6001, npc_mcam_free_entry,                    \
207                                 npc_mcam_free_entry_req, msg_rsp)       \
208 M(NPC_MCAM_WRITE_ENTRY, 0x6002, npc_mcam_write_entry,                   \
209                                 npc_mcam_write_entry_req, msg_rsp)      \
210 M(NPC_MCAM_ENA_ENTRY,   0x6003, npc_mcam_ena_entry,                     \
211                                 npc_mcam_ena_dis_entry_req, msg_rsp)    \
212 M(NPC_MCAM_DIS_ENTRY,   0x6004, npc_mcam_dis_entry,                     \
213                                 npc_mcam_ena_dis_entry_req, msg_rsp)    \
214 M(NPC_MCAM_SHIFT_ENTRY, 0x6005, npc_mcam_shift_entry,                   \
215                                 npc_mcam_shift_entry_req,               \
216                                 npc_mcam_shift_entry_rsp)               \
217 M(NPC_MCAM_ALLOC_COUNTER,       0x6006, npc_mcam_alloc_counter,         \
218                                 npc_mcam_alloc_counter_req,             \
219                                 npc_mcam_alloc_counter_rsp)             \
220 M(NPC_MCAM_FREE_COUNTER,        0x6007, npc_mcam_free_counter,          \
221                                 npc_mcam_oper_counter_req,              \
222                                 msg_rsp)                                \
223 M(NPC_MCAM_UNMAP_COUNTER,       0x6008, npc_mcam_unmap_counter,         \
224                                 npc_mcam_unmap_counter_req,             \
225                                 msg_rsp)                                \
226 M(NPC_MCAM_CLEAR_COUNTER,       0x6009, npc_mcam_clear_counter,         \
227                                 npc_mcam_oper_counter_req,              \
228                                 msg_rsp)                                \
229 M(NPC_MCAM_COUNTER_STATS,       0x600a, npc_mcam_counter_stats,         \
230                                 npc_mcam_oper_counter_req,              \
231                                 npc_mcam_oper_counter_rsp)              \
232 M(NPC_MCAM_ALLOC_AND_WRITE_ENTRY, 0x600b, npc_mcam_alloc_and_write_entry,\
233                                 npc_mcam_alloc_and_write_entry_req,     \
234                                 npc_mcam_alloc_and_write_entry_rsp)     \
235 M(NPC_GET_KEX_CFG,        0x600c, npc_get_kex_cfg, msg_req,             \
236                                 npc_get_kex_cfg_rsp)                    \
237 M(NPC_INSTALL_FLOW,       0x600d, npc_install_flow,                     \
238                                   npc_install_flow_req,                 \
239                                   npc_install_flow_rsp)                 \
240 M(NPC_DELETE_FLOW,        0x600e, npc_delete_flow,                      \
241                                   npc_delete_flow_req, msg_rsp)         \
242 M(NPC_MCAM_READ_ENTRY,    0x600f, npc_mcam_read_entry,                  \
243                                   npc_mcam_read_entry_req,              \
244                                   npc_mcam_read_entry_rsp)              \
245 M(NPC_SET_PKIND,          0x6010, npc_set_pkind,                        \
246                                   npc_set_pkind,                        \
247                                   msg_rsp)                              \
248 M(NPC_MCAM_READ_BASE_RULE, 0x6011, npc_read_base_steer_rule, msg_req,   \
249                                    npc_mcam_read_base_rule_rsp)         \
250 /* NIX mbox IDs (range 0x8000 - 0xFFFF) */                              \
251 M(NIX_LF_ALLOC,         0x8000, nix_lf_alloc, nix_lf_alloc_req,         \
252                                 nix_lf_alloc_rsp)                       \
253 M(NIX_LF_FREE,          0x8001, nix_lf_free, nix_lf_free_req, msg_rsp)  \
254 M(NIX_AQ_ENQ,           0x8002, nix_aq_enq, nix_aq_enq_req,             \
255                                 nix_aq_enq_rsp)                         \
256 M(NIX_HWCTX_DISABLE,    0x8003, nix_hwctx_disable, hwctx_disable_req,   \
257                                 msg_rsp)                                \
258 M(NIX_TXSCH_ALLOC,      0x8004, nix_txsch_alloc, nix_txsch_alloc_req,   \
259                                 nix_txsch_alloc_rsp)                    \
260 M(NIX_TXSCH_FREE,       0x8005, nix_txsch_free, nix_txsch_free_req,     \
261                                 msg_rsp)                                \
262 M(NIX_TXSCHQ_CFG,       0x8006, nix_txschq_cfg, nix_txschq_config,      \
263                                 nix_txschq_config)                      \
264 M(NIX_STATS_RST,        0x8007, nix_stats_rst, msg_req, msg_rsp)        \
265 M(NIX_VTAG_CFG,         0x8008, nix_vtag_cfg, nix_vtag_config, msg_rsp) \
266 M(NIX_RSS_FLOWKEY_CFG,  0x8009, nix_rss_flowkey_cfg,                    \
267                                 nix_rss_flowkey_cfg,                    \
268                                 nix_rss_flowkey_cfg_rsp)                \
269 M(NIX_SET_MAC_ADDR,     0x800a, nix_set_mac_addr, nix_set_mac_addr,     \
270                                 msg_rsp)                                \
271 M(NIX_SET_RX_MODE,      0x800b, nix_set_rx_mode, nix_rx_mode, msg_rsp)  \
272 M(NIX_SET_HW_FRS,       0x800c, nix_set_hw_frs, nix_frs_cfg, msg_rsp)   \
273 M(NIX_LF_START_RX,      0x800d, nix_lf_start_rx, msg_req, msg_rsp)      \
274 M(NIX_LF_STOP_RX,       0x800e, nix_lf_stop_rx, msg_req, msg_rsp)       \
275 M(NIX_MARK_FORMAT_CFG,  0x800f, nix_mark_format_cfg,                    \
276                                 nix_mark_format_cfg,                    \
277                                 nix_mark_format_cfg_rsp)                \
278 M(NIX_SET_RX_CFG,       0x8010, nix_set_rx_cfg, nix_rx_cfg, msg_rsp)    \
279 M(NIX_LSO_FORMAT_CFG,   0x8011, nix_lso_format_cfg, nix_lso_format_cfg, \
280                                 nix_lso_format_cfg_rsp)                 \
281 M(NIX_LF_PTP_TX_ENABLE, 0x8013, nix_lf_ptp_tx_enable, msg_req,          \
282                                 msg_rsp)                                \
283 M(NIX_LF_PTP_TX_DISABLE,        0x8014, nix_lf_ptp_tx_disable, msg_req, \
284                                 msg_rsp)                                \
285 M(NIX_SET_VLAN_TPID,    0x8015, nix_set_vlan_tpid, nix_set_vlan_tpid,   \
286                                 msg_rsp)                                \
287 M(NIX_BP_ENABLE,        0x8016, nix_bp_enable, nix_bp_cfg_req,          \
288                                 nix_bp_cfg_rsp)                         \
289 M(NIX_BP_DISABLE,       0x8017, nix_bp_disable, nix_bp_cfg_req, msg_rsp)\
290 M(NIX_GET_MAC_ADDR,     0x8018, nix_get_mac_addr, msg_req,              \
291                                 nix_get_mac_addr_rsp)                   \
292 M(NIX_INLINE_IPSEC_CFG, 0x8019, nix_inline_ipsec_cfg,                   \
293                                 nix_inline_ipsec_cfg, msg_rsp)          \
294 M(NIX_INLINE_IPSEC_LF_CFG,                                              \
295                         0x801a, nix_inline_ipsec_lf_cfg,                \
296                                 nix_inline_ipsec_lf_cfg, msg_rsp)
297
298 /* Messages initiated by AF (range 0xC00 - 0xDFF) */
299 #define MBOX_UP_CGX_MESSAGES                                            \
300 M(CGX_LINK_EVENT,       0xC00, cgx_link_event, cgx_link_info_msg,       \
301                                 msg_rsp)                                \
302 M(CGX_PTP_RX_INFO,      0xC01, cgx_ptp_rx_info, cgx_ptp_rx_info_msg,    \
303                                 msg_rsp)
304
305 enum {
306 #define M(_name, _id, _1, _2, _3) MBOX_MSG_ ## _name = _id,
307 MBOX_MESSAGES
308 MBOX_UP_CGX_MESSAGES
309 #undef M
310 };
311
312 /* Mailbox message formats */
313
314 #define RVU_DEFAULT_PF_FUNC     0xFFFF
315
316 /* Generic request msg used for those mbox messages which
317  * don't send any data in the request.
318  */
319 struct msg_req {
320         struct mbox_msghdr hdr;
321 };
322
323 /* Generic response msg used a ack or response for those mbox
324  * messages which doesn't have a specific rsp msg format.
325  */
326 struct msg_rsp {
327         struct mbox_msghdr hdr;
328 };
329
330 /* RVU mailbox error codes
331  * Range 256 - 300.
332  */
333 enum rvu_af_status {
334         RVU_INVALID_VF_ID           = -256,
335 };
336
337 struct ready_msg_rsp {
338         struct mbox_msghdr hdr;
339         uint16_t __otx2_io sclk_feq; /* SCLK frequency */
340         uint16_t __otx2_io rclk_freq; /* RCLK frequency */
341 };
342
343 /* Struct to set pkind */
344 struct npc_set_pkind {
345         struct mbox_msghdr hdr;
346 #define OTX2_PRIV_FLAGS_DEFAULT  BIT_ULL(0)
347 #define OTX2_PRIV_FLAGS_EDSA     BIT_ULL(1)
348 #define OTX2_PRIV_FLAGS_HIGIG    BIT_ULL(2)
349 #define OTX2_PRIV_FLAGS_LEN_90B  BIT_ULL(3)
350 #define OTX2_PRIV_FLAGS_CUSTOM   BIT_ULL(63)
351         uint64_t __otx2_io mode;
352 #define PKIND_TX                BIT_ULL(0)
353 #define PKIND_RX                BIT_ULL(1)
354         uint8_t __otx2_io dir;
355         uint8_t __otx2_io pkind; /* valid only in case custom flag */
356 };
357
358 /* Structure for requesting resource provisioning.
359  * 'modify' flag to be used when either requesting more
360  * or to detach partial of a certain resource type.
361  * Rest of the fields specify how many of what type to
362  * be attached.
363  * To request LFs from two blocks of same type this mailbox
364  * can be sent twice as below:
365  *      struct rsrc_attach *attach;
366  *       .. Allocate memory for message ..
367  *       attach->cptlfs = 3; <3 LFs from CPT0>
368  *       .. Send message ..
369  *       .. Allocate memory for message ..
370  *       attach->modify = 1;
371  *       attach->cpt_blkaddr = BLKADDR_CPT1;
372  *       attach->cptlfs = 2; <2 LFs from CPT1>
373  *       .. Send message ..
374  */
375 struct rsrc_attach_req {
376         struct mbox_msghdr hdr;
377         uint8_t __otx2_io modify:1;
378         uint8_t __otx2_io npalf:1;
379         uint8_t __otx2_io nixlf:1;
380         uint16_t __otx2_io sso;
381         uint16_t __otx2_io ssow;
382         uint16_t __otx2_io timlfs;
383         uint16_t __otx2_io cptlfs;
384         uint16_t __otx2_io reelfs;
385         /* BLKADDR_CPT0/BLKADDR_CPT1 or 0 for BLKADDR_CPT0 */
386         int __otx2_io cpt_blkaddr;
387         /* BLKADDR_REE0/BLKADDR_REE1 or 0 for BLKADDR_REE0 */
388         int __otx2_io ree_blkaddr;
389 };
390
391 /* Structure for relinquishing resources.
392  * 'partial' flag to be used when relinquishing all resources
393  * but only of a certain type. If not set, all resources of all
394  * types provisioned to the RVU function will be detached.
395  */
396 struct rsrc_detach_req {
397         struct mbox_msghdr hdr;
398         uint8_t __otx2_io partial:1;
399         uint8_t __otx2_io npalf:1;
400         uint8_t __otx2_io nixlf:1;
401         uint8_t __otx2_io sso:1;
402         uint8_t __otx2_io ssow:1;
403         uint8_t __otx2_io timlfs:1;
404         uint8_t __otx2_io cptlfs:1;
405         uint8_t __otx2_io reelfs:1;
406 };
407
408 /* NIX Transmit schedulers */
409 #define NIX_TXSCH_LVL_SMQ 0x0
410 #define NIX_TXSCH_LVL_MDQ 0x0
411 #define NIX_TXSCH_LVL_TL4 0x1
412 #define NIX_TXSCH_LVL_TL3 0x2
413 #define NIX_TXSCH_LVL_TL2 0x3
414 #define NIX_TXSCH_LVL_TL1 0x4
415 #define NIX_TXSCH_LVL_CNT 0x5
416
417 /*
418  * Number of resources available to the caller.
419  * In reply to MBOX_MSG_FREE_RSRC_CNT.
420  */
421 struct free_rsrcs_rsp {
422         struct mbox_msghdr hdr;
423         uint16_t __otx2_io schq[NIX_TXSCH_LVL_CNT];
424         uint16_t __otx2_io sso;
425         uint16_t __otx2_io tim;
426         uint16_t __otx2_io ssow;
427         uint16_t __otx2_io cpt;
428         uint8_t __otx2_io npa;
429         uint8_t __otx2_io nix;
430         uint16_t  __otx2_io schq_nix1[NIX_TXSCH_LVL_CNT];
431         uint8_t  __otx2_io nix1;
432         uint8_t  __otx2_io cpt1;
433         uint8_t  __otx2_io ree0;
434         uint8_t  __otx2_io ree1;
435 };
436
437 #define MSIX_VECTOR_INVALID     0xFFFF
438 #define MAX_RVU_BLKLF_CNT       256
439
440 struct msix_offset_rsp {
441         struct mbox_msghdr hdr;
442         uint16_t __otx2_io npa_msixoff;
443         uint16_t __otx2_io nix_msixoff;
444         uint8_t __otx2_io sso;
445         uint8_t __otx2_io ssow;
446         uint8_t __otx2_io timlfs;
447         uint8_t __otx2_io cptlfs;
448         uint16_t __otx2_io sso_msixoff[MAX_RVU_BLKLF_CNT];
449         uint16_t __otx2_io ssow_msixoff[MAX_RVU_BLKLF_CNT];
450         uint16_t __otx2_io timlf_msixoff[MAX_RVU_BLKLF_CNT];
451         uint16_t __otx2_io cptlf_msixoff[MAX_RVU_BLKLF_CNT];
452         uint8_t __otx2_io cpt1_lfs;
453         uint8_t __otx2_io ree0_lfs;
454         uint8_t __otx2_io ree1_lfs;
455         uint16_t __otx2_io cpt1_lf_msixoff[MAX_RVU_BLKLF_CNT];
456         uint16_t __otx2_io ree0_lf_msixoff[MAX_RVU_BLKLF_CNT];
457         uint16_t __otx2_io ree1_lf_msixoff[MAX_RVU_BLKLF_CNT];
458
459 };
460
461 /* CGX mbox message formats */
462
463 struct cgx_stats_rsp {
464         struct mbox_msghdr hdr;
465 #define CGX_RX_STATS_COUNT      13
466 #define CGX_TX_STATS_COUNT      18
467         uint64_t __otx2_io rx_stats[CGX_RX_STATS_COUNT];
468         uint64_t __otx2_io tx_stats[CGX_TX_STATS_COUNT];
469 };
470
471 struct cgx_fec_stats_rsp {
472         struct mbox_msghdr hdr;
473         uint64_t __otx2_io fec_corr_blks;
474         uint64_t __otx2_io fec_uncorr_blks;
475 };
476 /* Structure for requesting the operation for
477  * setting/getting mac address in the CGX interface
478  */
479 struct cgx_mac_addr_set_or_get {
480         struct mbox_msghdr hdr;
481         uint8_t __otx2_io mac_addr[RTE_ETHER_ADDR_LEN];
482 };
483
484 /* Structure for requesting the operation to
485  * add DMAC filter entry into CGX interface
486  */
487 struct cgx_mac_addr_add_req {
488         struct mbox_msghdr hdr;
489         uint8_t __otx2_io mac_addr[RTE_ETHER_ADDR_LEN];
490 };
491
492 /* Structure for response against the operation to
493  * add DMAC filter entry into CGX interface
494  */
495 struct cgx_mac_addr_add_rsp {
496         struct mbox_msghdr hdr;
497         uint8_t __otx2_io index;
498 };
499
500 /* Structure for requesting the operation to
501  * delete DMAC filter entry from CGX interface
502  */
503 struct cgx_mac_addr_del_req {
504         struct mbox_msghdr hdr;
505         uint8_t __otx2_io index;
506 };
507
508 /* Structure for response against the operation to
509  * get maximum supported DMAC filter entries
510  */
511 struct cgx_max_dmac_entries_get_rsp {
512         struct mbox_msghdr hdr;
513         uint8_t __otx2_io max_dmac_filters;
514 };
515
516 struct cgx_link_user_info {
517         uint64_t __otx2_io link_up:1;
518         uint64_t __otx2_io full_duplex:1;
519         uint64_t __otx2_io lmac_type_id:4;
520         uint64_t __otx2_io speed:20; /* speed in Mbps */
521         uint64_t __otx2_io an:1; /* AN supported or not */
522         uint64_t __otx2_io fec:2; /* FEC type if enabled else 0 */
523         uint64_t __otx2_io port:8;
524 #define LMACTYPE_STR_LEN 16
525         char lmac_type[LMACTYPE_STR_LEN];
526 };
527
528 struct cgx_link_info_msg {
529         struct mbox_msghdr hdr;
530         struct cgx_link_user_info link_info;
531 };
532
533 struct cgx_ptp_rx_info_msg {
534         struct mbox_msghdr hdr;
535         uint8_t __otx2_io ptp_en;
536 };
537
538 struct cgx_pause_frm_cfg {
539         struct mbox_msghdr hdr;
540         uint8_t __otx2_io set;
541         /* set = 1 if the request is to config pause frames */
542         /* set = 0 if the request is to fetch pause frames config */
543         uint8_t __otx2_io rx_pause;
544         uint8_t __otx2_io tx_pause;
545 };
546
547 struct sfp_eeprom_s {
548 #define SFP_EEPROM_SIZE 256
549         uint16_t __otx2_io sff_id;
550         uint8_t __otx2_io buf[SFP_EEPROM_SIZE];
551         uint64_t __otx2_io reserved;
552 };
553
554 enum fec_type {
555         OTX2_FEC_NONE,
556         OTX2_FEC_BASER,
557         OTX2_FEC_RS,
558 };
559
560 struct phy_s {
561         uint64_t __otx2_io can_change_mod_type : 1;
562         uint64_t __otx2_io mod_type            : 1;
563 };
564
565 struct cgx_lmac_fwdata_s {
566         uint16_t __otx2_io rw_valid;
567         uint64_t __otx2_io supported_fec;
568         uint64_t __otx2_io supported_an;
569         uint64_t __otx2_io supported_link_modes;
570         /* Only applicable if AN is supported */
571         uint64_t __otx2_io advertised_fec;
572         uint64_t __otx2_io advertised_link_modes;
573         /* Only applicable if SFP/QSFP slot is present */
574         struct sfp_eeprom_s sfp_eeprom;
575         struct phy_s phy;
576 #define LMAC_FWDATA_RESERVED_MEM 1023
577         uint64_t __otx2_io reserved[LMAC_FWDATA_RESERVED_MEM];
578 };
579
580 struct cgx_fw_data {
581         struct mbox_msghdr hdr;
582         struct cgx_lmac_fwdata_s fwdata;
583 };
584
585 struct fec_mode {
586         struct mbox_msghdr hdr;
587         int __otx2_io fec;
588 };
589
590 struct cgx_set_link_state_msg {
591         struct mbox_msghdr hdr;
592         uint8_t __otx2_io enable;
593 };
594
595 struct cgx_phy_mod_type {
596         struct mbox_msghdr hdr;
597         int __otx2_io mod;
598 };
599
600 struct cgx_set_link_mode_args {
601         uint32_t __otx2_io speed;
602         uint8_t __otx2_io duplex;
603         uint8_t __otx2_io an;
604         uint8_t __otx2_io ports;
605         uint64_t __otx2_io mode;
606 };
607
608 struct cgx_set_link_mode_req {
609         struct mbox_msghdr hdr;
610         struct cgx_set_link_mode_args args;
611 };
612
613 struct cgx_set_link_mode_rsp {
614         struct mbox_msghdr hdr;
615         int __otx2_io status;
616 };
617 /* NPA mbox message formats */
618
619 /* NPA mailbox error codes
620  * Range 301 - 400.
621  */
622 enum npa_af_status {
623         NPA_AF_ERR_PARAM            = -301,
624         NPA_AF_ERR_AQ_FULL          = -302,
625         NPA_AF_ERR_AQ_ENQUEUE       = -303,
626         NPA_AF_ERR_AF_LF_INVALID    = -304,
627         NPA_AF_ERR_AF_LF_ALLOC      = -305,
628         NPA_AF_ERR_LF_RESET         = -306,
629 };
630
631 #define NPA_AURA_SZ_0           0
632 #define NPA_AURA_SZ_128         1
633 #define NPA_AURA_SZ_256         2
634 #define NPA_AURA_SZ_512         3
635 #define NPA_AURA_SZ_1K          4
636 #define NPA_AURA_SZ_2K          5
637 #define NPA_AURA_SZ_4K          6
638 #define NPA_AURA_SZ_8K          7
639 #define NPA_AURA_SZ_16K         8
640 #define NPA_AURA_SZ_32K         9
641 #define NPA_AURA_SZ_64K         10
642 #define NPA_AURA_SZ_128K        11
643 #define NPA_AURA_SZ_256K        12
644 #define NPA_AURA_SZ_512K        13
645 #define NPA_AURA_SZ_1M          14
646 #define NPA_AURA_SZ_MAX         15
647
648 /* For NPA LF context alloc and init */
649 struct npa_lf_alloc_req {
650         struct mbox_msghdr hdr;
651         int __otx2_io node;
652         int __otx2_io aura_sz; /* No of auras. See NPA_AURA_SZ_* */
653         uint32_t __otx2_io nr_pools; /* No of pools */
654         uint64_t __otx2_io way_mask;
655 };
656
657 struct npa_lf_alloc_rsp {
658         struct mbox_msghdr hdr;
659         uint32_t __otx2_io stack_pg_ptrs;  /* No of ptrs per stack page */
660         uint32_t __otx2_io stack_pg_bytes; /* Size of stack page */
661         uint16_t __otx2_io qints; /* NPA_AF_CONST::QINTS */
662 };
663
664 /* NPA AQ enqueue msg */
665 struct npa_aq_enq_req {
666         struct mbox_msghdr hdr;
667         uint32_t __otx2_io aura_id;
668         uint8_t __otx2_io ctype;
669         uint8_t __otx2_io op;
670         union {
671                 /* Valid when op == WRITE/INIT and ctype == AURA.
672                  * LF fills the pool_id in aura.pool_addr. AF will translate
673                  * the pool_id to pool context pointer.
674                  */
675                 __otx2_io struct npa_aura_s aura;
676                 /* Valid when op == WRITE/INIT and ctype == POOL */
677                 __otx2_io struct npa_pool_s pool;
678         };
679         /* Mask data when op == WRITE (1=write, 0=don't write) */
680         union {
681                 /* Valid when op == WRITE and ctype == AURA */
682                 __otx2_io struct npa_aura_s aura_mask;
683                 /* Valid when op == WRITE and ctype == POOL */
684                 __otx2_io struct npa_pool_s pool_mask;
685         };
686 };
687
688 struct npa_aq_enq_rsp {
689         struct mbox_msghdr hdr;
690         union {
691                 /* Valid when op == READ and ctype == AURA */
692                 __otx2_io struct npa_aura_s aura;
693                 /* Valid when op == READ and ctype == POOL */
694                 __otx2_io struct npa_pool_s pool;
695         };
696 };
697
698 /* Disable all contexts of type 'ctype' */
699 struct hwctx_disable_req {
700         struct mbox_msghdr hdr;
701         uint8_t __otx2_io ctype;
702 };
703
704 /* NIX mbox message formats */
705
706 /* NIX mailbox error codes
707  * Range 401 - 500.
708  */
709 enum nix_af_status {
710         NIX_AF_ERR_PARAM            = -401,
711         NIX_AF_ERR_AQ_FULL          = -402,
712         NIX_AF_ERR_AQ_ENQUEUE       = -403,
713         NIX_AF_ERR_AF_LF_INVALID    = -404,
714         NIX_AF_ERR_AF_LF_ALLOC      = -405,
715         NIX_AF_ERR_TLX_ALLOC_FAIL   = -406,
716         NIX_AF_ERR_TLX_INVALID      = -407,
717         NIX_AF_ERR_RSS_SIZE_INVALID = -408,
718         NIX_AF_ERR_RSS_GRPS_INVALID = -409,
719         NIX_AF_ERR_FRS_INVALID      = -410,
720         NIX_AF_ERR_RX_LINK_INVALID  = -411,
721         NIX_AF_INVAL_TXSCHQ_CFG     = -412,
722         NIX_AF_SMQ_FLUSH_FAILED     = -413,
723         NIX_AF_ERR_LF_RESET         = -414,
724         NIX_AF_ERR_RSS_NOSPC_FIELD  = -415,
725         NIX_AF_ERR_RSS_NOSPC_ALGO   = -416,
726         NIX_AF_ERR_MARK_CFG_FAIL    = -417,
727         NIX_AF_ERR_LSO_CFG_FAIL     = -418,
728         NIX_AF_INVAL_NPA_PF_FUNC    = -419,
729         NIX_AF_INVAL_SSO_PF_FUNC    = -420,
730         NIX_AF_ERR_TX_VTAG_NOSPC    = -421,
731         NIX_AF_ERR_RX_VTAG_INUSE    = -422,
732         NIX_AF_ERR_PTP_CONFIG_FAIL  = -423,
733 };
734
735 /* For NIX LF context alloc and init */
736 struct nix_lf_alloc_req {
737         struct mbox_msghdr hdr;
738         int __otx2_io node;
739         uint32_t __otx2_io rq_cnt;   /* No of receive queues */
740         uint32_t __otx2_io sq_cnt;   /* No of send queues */
741         uint32_t __otx2_io cq_cnt;   /* No of completion queues */
742         uint8_t __otx2_io xqe_sz;
743         uint16_t __otx2_io rss_sz;
744         uint8_t __otx2_io rss_grps;
745         uint16_t __otx2_io npa_func;
746         /* RVU_DEFAULT_PF_FUNC == default pf_func associated with lf */
747         uint16_t __otx2_io sso_func;
748         uint64_t __otx2_io rx_cfg;   /* See NIX_AF_LF(0..127)_RX_CFG */
749         uint64_t __otx2_io way_mask;
750 #define NIX_LF_RSS_TAG_LSB_AS_ADDER BIT_ULL(0)
751         uint64_t flags;
752 };
753
754 struct nix_lf_alloc_rsp {
755         struct mbox_msghdr hdr;
756         uint16_t __otx2_io sqb_size;
757         uint16_t __otx2_io rx_chan_base;
758         uint16_t __otx2_io tx_chan_base;
759         uint8_t __otx2_io rx_chan_cnt; /* Total number of RX channels */
760         uint8_t __otx2_io tx_chan_cnt; /* Total number of TX channels */
761         uint8_t __otx2_io lso_tsov4_idx;
762         uint8_t __otx2_io lso_tsov6_idx;
763         uint8_t __otx2_io mac_addr[RTE_ETHER_ADDR_LEN];
764         uint8_t __otx2_io lf_rx_stats; /* NIX_AF_CONST1::LF_RX_STATS */
765         uint8_t __otx2_io lf_tx_stats; /* NIX_AF_CONST1::LF_TX_STATS */
766         uint16_t __otx2_io cints; /* NIX_AF_CONST2::CINTS */
767         uint16_t __otx2_io qints; /* NIX_AF_CONST2::QINTS */
768         uint8_t __otx2_io hw_rx_tstamp_en; /*set if rx timestamping enabled */
769         uint8_t __otx2_io cgx_links;  /* No. of CGX links present in HW */
770         uint8_t __otx2_io lbk_links;  /* No. of LBK links present in HW */
771         uint8_t __otx2_io sdp_links;  /* No. of SDP links present in HW */
772         uint8_t __otx2_io tx_link;    /* Transmit channel link number */
773 };
774
775 struct nix_lf_free_req {
776         struct mbox_msghdr hdr;
777 #define NIX_LF_DISABLE_FLOWS            BIT_ULL(0)
778 #define NIX_LF_DONT_FREE_TX_VTAG        BIT_ULL(1)
779         uint64_t __otx2_io flags;
780 };
781
782 /* NIX AQ enqueue msg */
783 struct nix_aq_enq_req {
784         struct mbox_msghdr hdr;
785         uint32_t __otx2_io qidx;
786         uint8_t __otx2_io ctype;
787         uint8_t __otx2_io op;
788         union {
789                 /* Valid when op == WRITE/INIT and ctype == NIX_AQ_CTYPE_RQ */
790                 __otx2_io struct nix_rq_ctx_s rq;
791                 /* Valid when op == WRITE/INIT and ctype == NIX_AQ_CTYPE_SQ */
792                 __otx2_io struct nix_sq_ctx_s sq;
793                 /* Valid when op == WRITE/INIT and ctype == NIX_AQ_CTYPE_CQ */
794                 __otx2_io struct nix_cq_ctx_s cq;
795                 /* Valid when op == WRITE/INIT and ctype == NIX_AQ_CTYPE_RSS */
796                 __otx2_io struct nix_rsse_s rss;
797                 /* Valid when op == WRITE/INIT and ctype == NIX_AQ_CTYPE_MCE */
798                 __otx2_io struct nix_rx_mce_s mce;
799         };
800         /* Mask data when op == WRITE (1=write, 0=don't write) */
801         union {
802                 /* Valid when op == WRITE and ctype == NIX_AQ_CTYPE_RQ */
803                 __otx2_io struct nix_rq_ctx_s rq_mask;
804                 /* Valid when op == WRITE and ctype == NIX_AQ_CTYPE_SQ */
805                 __otx2_io struct nix_sq_ctx_s sq_mask;
806                 /* Valid when op == WRITE and ctype == NIX_AQ_CTYPE_CQ */
807                 __otx2_io struct nix_cq_ctx_s cq_mask;
808                 /* Valid when op == WRITE and ctype == NIX_AQ_CTYPE_RSS */
809                 __otx2_io struct nix_rsse_s rss_mask;
810                 /* Valid when op == WRITE and ctype == NIX_AQ_CTYPE_MCE */
811                 __otx2_io struct nix_rx_mce_s mce_mask;
812         };
813 };
814
815 struct nix_aq_enq_rsp {
816         struct mbox_msghdr hdr;
817         union {
818                 __otx2_io struct nix_rq_ctx_s rq;
819                 __otx2_io struct nix_sq_ctx_s sq;
820                 __otx2_io struct nix_cq_ctx_s cq;
821                 __otx2_io struct nix_rsse_s   rss;
822                 __otx2_io struct nix_rx_mce_s mce;
823         };
824 };
825
826 /* Tx scheduler/shaper mailbox messages */
827
828 #define MAX_TXSCHQ_PER_FUNC     128
829
830 struct nix_txsch_alloc_req {
831         struct mbox_msghdr hdr;
832         /* Scheduler queue count request at each level */
833         uint16_t __otx2_io schq_contig[NIX_TXSCH_LVL_CNT]; /* Contig. queues */
834         uint16_t __otx2_io schq[NIX_TXSCH_LVL_CNT]; /* Non-Contig. queues */
835 };
836
837 struct nix_txsch_alloc_rsp {
838         struct mbox_msghdr hdr;
839         /* Scheduler queue count allocated at each level */
840         uint16_t __otx2_io schq_contig[NIX_TXSCH_LVL_CNT]; /* Contig. queues */
841         uint16_t __otx2_io schq[NIX_TXSCH_LVL_CNT]; /* Non-Contig. queues */
842         /* Scheduler queue list allocated at each level */
843         uint16_t __otx2_io
844                 schq_contig_list[NIX_TXSCH_LVL_CNT][MAX_TXSCHQ_PER_FUNC];
845         uint16_t __otx2_io schq_list[NIX_TXSCH_LVL_CNT][MAX_TXSCHQ_PER_FUNC];
846         /* Traffic aggregation scheduler level */
847         uint8_t  __otx2_io aggr_level;
848         /* Aggregation lvl's RR_PRIO config */
849         uint8_t  __otx2_io aggr_lvl_rr_prio;
850         /* LINKX_CFG CSRs mapped to TL3 or TL2's index ? */
851         uint8_t  __otx2_io link_cfg_lvl;
852 };
853
854 struct nix_txsch_free_req {
855         struct mbox_msghdr hdr;
856 #define TXSCHQ_FREE_ALL BIT_ULL(0)
857         uint16_t __otx2_io flags;
858         /* Scheduler queue level to be freed */
859         uint16_t __otx2_io schq_lvl;
860         /* List of scheduler queues to be freed */
861         uint16_t __otx2_io schq;
862 };
863
864 struct nix_txschq_config {
865         struct mbox_msghdr hdr;
866         uint8_t __otx2_io lvl; /* SMQ/MDQ/TL4/TL3/TL2/TL1 */
867         uint8_t __otx2_io read;
868 #define TXSCHQ_IDX_SHIFT 16
869 #define TXSCHQ_IDX_MASK (BIT_ULL(10) - 1)
870 #define TXSCHQ_IDX(reg, shift) (((reg) >> (shift)) & TXSCHQ_IDX_MASK)
871         uint8_t __otx2_io num_regs;
872 #define MAX_REGS_PER_MBOX_MSG 20
873         uint64_t __otx2_io reg[MAX_REGS_PER_MBOX_MSG];
874         uint64_t __otx2_io regval[MAX_REGS_PER_MBOX_MSG];
875         /* All 0's => overwrite with new value */
876         uint64_t __otx2_io regval_mask[MAX_REGS_PER_MBOX_MSG];
877 };
878
879 struct nix_vtag_config {
880         struct mbox_msghdr hdr;
881         /* '0' for 4 octet VTAG, '1' for 8 octet VTAG */
882         uint8_t __otx2_io vtag_size;
883         /* cfg_type is '0' for tx vlan cfg
884          * cfg_type is '1' for rx vlan cfg
885          */
886         uint8_t __otx2_io cfg_type;
887         union {
888                 /* Valid when cfg_type is '0' */
889                 struct {
890                         uint64_t __otx2_io vtag0;
891                         uint64_t __otx2_io vtag1;
892
893                         /* cfg_vtag0 & cfg_vtag1 fields are valid
894                          * when free_vtag0 & free_vtag1 are '0's.
895                          */
896                         /* cfg_vtag0 = 1 to configure vtag0 */
897                         uint8_t __otx2_io cfg_vtag0 :1;
898                         /* cfg_vtag1 = 1 to configure vtag1 */
899                         uint8_t __otx2_io cfg_vtag1 :1;
900
901                         /* vtag0_idx & vtag1_idx are only valid when
902                          * both cfg_vtag0 & cfg_vtag1 are '0's,
903                          * these fields are used along with free_vtag0
904                          * & free_vtag1 to free the nix lf's tx_vlan
905                          * configuration.
906                          *
907                          * Denotes the indices of tx_vtag def registers
908                          * that needs to be cleared and freed.
909                          */
910                         int __otx2_io vtag0_idx;
911                         int __otx2_io vtag1_idx;
912
913                         /* Free_vtag0 & free_vtag1 fields are valid
914                          * when cfg_vtag0 & cfg_vtag1 are '0's.
915                          */
916                         /* Free_vtag0 = 1 clears vtag0 configuration
917                          * vtag0_idx denotes the index to be cleared.
918                          */
919                         uint8_t __otx2_io free_vtag0 :1;
920                         /* Free_vtag1 = 1 clears vtag1 configuration
921                          * vtag1_idx denotes the index to be cleared.
922                          */
923                         uint8_t __otx2_io free_vtag1 :1;
924                 } tx;
925
926                 /* Valid when cfg_type is '1' */
927                 struct {
928                         /* Rx vtag type index, valid values are in 0..7 range */
929                         uint8_t __otx2_io vtag_type;
930                         /* Rx vtag strip */
931                         uint8_t __otx2_io strip_vtag :1;
932                         /* Rx vtag capture */
933                         uint8_t __otx2_io capture_vtag :1;
934                 } rx;
935         };
936 };
937
938 struct nix_vtag_config_rsp {
939         struct mbox_msghdr hdr;
940         /* Indices of tx_vtag def registers used to configure
941          * tx vtag0 & vtag1 headers, these indices are valid
942          * when nix_vtag_config mbox requested for vtag0 and/
943          * or vtag1 configuration.
944          */
945         int __otx2_io vtag0_idx;
946         int __otx2_io vtag1_idx;
947 };
948
949 struct nix_rss_flowkey_cfg {
950         struct mbox_msghdr hdr;
951         int __otx2_io mcam_index;  /* MCAM entry index to modify */
952         uint32_t __otx2_io flowkey_cfg; /* Flowkey types selected */
953 #define FLOW_KEY_TYPE_PORT     BIT(0)
954 #define FLOW_KEY_TYPE_IPV4     BIT(1)
955 #define FLOW_KEY_TYPE_IPV6     BIT(2)
956 #define FLOW_KEY_TYPE_TCP      BIT(3)
957 #define FLOW_KEY_TYPE_UDP      BIT(4)
958 #define FLOW_KEY_TYPE_SCTP     BIT(5)
959 #define FLOW_KEY_TYPE_NVGRE    BIT(6)
960 #define FLOW_KEY_TYPE_VXLAN    BIT(7)
961 #define FLOW_KEY_TYPE_GENEVE   BIT(8)
962 #define FLOW_KEY_TYPE_ETH_DMAC BIT(9)
963 #define FLOW_KEY_TYPE_IPV6_EXT BIT(10)
964 #define FLOW_KEY_TYPE_GTPU       BIT(11)
965 #define FLOW_KEY_TYPE_INNR_IPV4     BIT(12)
966 #define FLOW_KEY_TYPE_INNR_IPV6     BIT(13)
967 #define FLOW_KEY_TYPE_INNR_TCP      BIT(14)
968 #define FLOW_KEY_TYPE_INNR_UDP      BIT(15)
969 #define FLOW_KEY_TYPE_INNR_SCTP     BIT(16)
970 #define FLOW_KEY_TYPE_INNR_ETH_DMAC BIT(17)
971 #define FLOW_KEY_TYPE_CH_LEN_90B        BIT(18)
972 #define FLOW_KEY_TYPE_L4_DST BIT(28)
973 #define FLOW_KEY_TYPE_L4_SRC BIT(29)
974 #define FLOW_KEY_TYPE_L3_DST BIT(30)
975 #define FLOW_KEY_TYPE_L3_SRC BIT(31)
976         uint8_t __otx2_io group;       /* RSS context or group */
977 };
978
979 struct nix_rss_flowkey_cfg_rsp {
980         struct mbox_msghdr hdr;
981         uint8_t __otx2_io alg_idx; /* Selected algo index */
982 };
983
984 struct nix_set_mac_addr {
985         struct mbox_msghdr hdr;
986         uint8_t __otx2_io mac_addr[RTE_ETHER_ADDR_LEN];
987 };
988
989 struct nix_get_mac_addr_rsp {
990         struct mbox_msghdr hdr;
991         uint8_t __otx2_io mac_addr[RTE_ETHER_ADDR_LEN];
992 };
993
994 struct nix_mark_format_cfg {
995         struct mbox_msghdr hdr;
996         uint8_t __otx2_io offset;
997         uint8_t __otx2_io y_mask;
998         uint8_t __otx2_io y_val;
999         uint8_t __otx2_io r_mask;
1000         uint8_t __otx2_io r_val;
1001 };
1002
1003 struct nix_mark_format_cfg_rsp {
1004         struct mbox_msghdr hdr;
1005         uint8_t __otx2_io mark_format_idx;
1006 };
1007
1008 struct nix_lso_format_cfg {
1009         struct mbox_msghdr hdr;
1010         uint64_t __otx2_io field_mask;
1011         uint64_t __otx2_io fields[NIX_LSO_FIELD_MAX];
1012 };
1013
1014 struct nix_lso_format_cfg_rsp {
1015         struct mbox_msghdr hdr;
1016         uint8_t __otx2_io lso_format_idx;
1017 };
1018
1019 struct nix_rx_mode {
1020         struct mbox_msghdr hdr;
1021 #define NIX_RX_MODE_UCAST    BIT(0)
1022 #define NIX_RX_MODE_PROMISC  BIT(1)
1023 #define NIX_RX_MODE_ALLMULTI BIT(2)
1024         uint16_t __otx2_io mode;
1025 };
1026
1027 struct nix_rx_cfg {
1028         struct mbox_msghdr hdr;
1029 #define NIX_RX_OL3_VERIFY   BIT(0)
1030 #define NIX_RX_OL4_VERIFY   BIT(1)
1031         uint8_t __otx2_io len_verify; /* Outer L3/L4 len check */
1032 #define NIX_RX_CSUM_OL4_VERIFY  BIT(0)
1033         uint8_t __otx2_io csum_verify; /* Outer L4 checksum verification */
1034 };
1035
1036 struct nix_frs_cfg {
1037         struct mbox_msghdr hdr;
1038         uint8_t __otx2_io update_smq;    /* Update SMQ's min/max lens */
1039         uint8_t __otx2_io update_minlen; /* Set minlen also */
1040         uint8_t __otx2_io sdp_link;      /* Set SDP RX link */
1041         uint16_t __otx2_io maxlen;
1042         uint16_t __otx2_io minlen;
1043 };
1044
1045 struct nix_set_vlan_tpid {
1046         struct mbox_msghdr hdr;
1047 #define NIX_VLAN_TYPE_INNER 0
1048 #define NIX_VLAN_TYPE_OUTER 1
1049         uint8_t __otx2_io vlan_type;
1050         uint16_t __otx2_io tpid;
1051 };
1052
1053 struct nix_bp_cfg_req {
1054         struct mbox_msghdr hdr;
1055         uint16_t __otx2_io chan_base; /* Starting channel number */
1056         uint8_t __otx2_io chan_cnt; /* Number of channels */
1057         uint8_t __otx2_io bpid_per_chan;
1058         /* bpid_per_chan = 0  assigns single bp id for range of channels */
1059         /* bpid_per_chan = 1 assigns separate bp id for each channel */
1060 };
1061
1062 /* PF can be mapped to either CGX or LBK interface,
1063  * so maximum 64 channels are possible.
1064  */
1065 #define NIX_MAX_CHAN    64
1066 struct nix_bp_cfg_rsp {
1067         struct mbox_msghdr hdr;
1068         /* Channel and bpid mapping */
1069         uint16_t __otx2_io chan_bpid[NIX_MAX_CHAN];
1070         /* Number of channel for which bpids are assigned */
1071         uint8_t __otx2_io chan_cnt;
1072 };
1073
1074 /* Global NIX inline IPSec configuration */
1075 struct nix_inline_ipsec_cfg {
1076         struct mbox_msghdr hdr;
1077         uint32_t __otx2_io cpt_credit;
1078         struct {
1079                 uint8_t __otx2_io egrp;
1080                 uint8_t __otx2_io opcode;
1081         } gen_cfg;
1082         struct {
1083                 uint16_t __otx2_io cpt_pf_func;
1084                 uint8_t __otx2_io cpt_slot;
1085         } inst_qsel;
1086         uint8_t __otx2_io enable;
1087 };
1088
1089 /* Per NIX LF inline IPSec configuration */
1090 struct nix_inline_ipsec_lf_cfg {
1091         struct mbox_msghdr hdr;
1092         uint64_t __otx2_io sa_base_addr;
1093         struct {
1094                 uint32_t __otx2_io tag_const;
1095                 uint16_t __otx2_io lenm1_max;
1096                 uint8_t __otx2_io sa_pow2_size;
1097                 uint8_t __otx2_io tt;
1098         } ipsec_cfg0;
1099         struct {
1100                 uint32_t __otx2_io sa_idx_max;
1101                 uint8_t __otx2_io sa_idx_w;
1102         } ipsec_cfg1;
1103         uint8_t __otx2_io enable;
1104 };
1105
1106 /* SSO mailbox error codes
1107  * Range 501 - 600.
1108  */
1109 enum sso_af_status {
1110         SSO_AF_ERR_PARAM        = -501,
1111         SSO_AF_ERR_LF_INVALID   = -502,
1112         SSO_AF_ERR_AF_LF_ALLOC  = -503,
1113         SSO_AF_ERR_GRP_EBUSY    = -504,
1114         SSO_AF_INVAL_NPA_PF_FUNC = -505,
1115 };
1116
1117 struct sso_lf_alloc_req {
1118         struct mbox_msghdr hdr;
1119         int __otx2_io node;
1120         uint16_t __otx2_io hwgrps;
1121 };
1122
1123 struct sso_lf_alloc_rsp {
1124         struct mbox_msghdr hdr;
1125         uint32_t __otx2_io xaq_buf_size;
1126         uint32_t __otx2_io xaq_wq_entries;
1127         uint32_t __otx2_io in_unit_entries;
1128         uint16_t __otx2_io hwgrps;
1129 };
1130
1131 struct sso_lf_free_req {
1132         struct mbox_msghdr hdr;
1133         int __otx2_io node;
1134         uint16_t __otx2_io hwgrps;
1135 };
1136
1137 /* SSOW mailbox error codes
1138  * Range 601 - 700.
1139  */
1140 enum ssow_af_status {
1141         SSOW_AF_ERR_PARAM       = -601,
1142         SSOW_AF_ERR_LF_INVALID  = -602,
1143         SSOW_AF_ERR_AF_LF_ALLOC = -603,
1144 };
1145
1146 struct ssow_lf_alloc_req {
1147         struct mbox_msghdr hdr;
1148         int __otx2_io node;
1149         uint16_t __otx2_io hws;
1150 };
1151
1152 struct ssow_lf_free_req {
1153         struct mbox_msghdr hdr;
1154         int __otx2_io node;
1155         uint16_t __otx2_io hws;
1156 };
1157
1158 struct sso_hw_setconfig {
1159         struct mbox_msghdr hdr;
1160         uint32_t __otx2_io npa_aura_id;
1161         uint16_t __otx2_io npa_pf_func;
1162         uint16_t __otx2_io hwgrps;
1163 };
1164
1165 struct sso_info_req {
1166         struct mbox_msghdr hdr;
1167         union {
1168                 uint16_t __otx2_io grp;
1169                 uint16_t __otx2_io hws;
1170         };
1171 };
1172
1173 struct sso_grp_priority {
1174         struct mbox_msghdr hdr;
1175         uint16_t __otx2_io grp;
1176         uint8_t __otx2_io priority;
1177         uint8_t __otx2_io affinity;
1178         uint8_t __otx2_io weight;
1179 };
1180
1181 struct sso_grp_qos_cfg {
1182         struct mbox_msghdr hdr;
1183         uint16_t __otx2_io grp;
1184         uint32_t __otx2_io xaq_limit;
1185         uint16_t __otx2_io taq_thr;
1186         uint16_t __otx2_io iaq_thr;
1187 };
1188
1189 struct sso_grp_stats {
1190         struct mbox_msghdr hdr;
1191         uint16_t __otx2_io grp;
1192         uint64_t __otx2_io ws_pc;
1193         uint64_t __otx2_io ext_pc;
1194         uint64_t __otx2_io wa_pc;
1195         uint64_t __otx2_io ts_pc;
1196         uint64_t __otx2_io ds_pc;
1197         uint64_t __otx2_io dq_pc;
1198         uint64_t __otx2_io aw_status;
1199         uint64_t __otx2_io page_cnt;
1200 };
1201
1202 struct sso_hws_stats {
1203         struct mbox_msghdr hdr;
1204         uint16_t __otx2_io hws;
1205         uint64_t __otx2_io arbitration;
1206 };
1207
1208 /* CPT mailbox error codes
1209  * Range 901 - 1000.
1210  */
1211 enum cpt_af_status {
1212         CPT_AF_ERR_PARAM                = -901,
1213         CPT_AF_ERR_GRP_INVALID          = -902,
1214         CPT_AF_ERR_LF_INVALID           = -903,
1215         CPT_AF_ERR_ACCESS_DENIED        = -904,
1216         CPT_AF_ERR_SSO_PF_FUNC_INVALID  = -905,
1217         CPT_AF_ERR_NIX_PF_FUNC_INVALID  = -906,
1218         CPT_AF_ERR_INLINE_IPSEC_INB_ENA = -907,
1219         CPT_AF_ERR_INLINE_IPSEC_OUT_ENA = -908
1220 };
1221
1222 /* CPT mbox message formats */
1223
1224 struct cpt_rd_wr_reg_msg {
1225         struct mbox_msghdr hdr;
1226         uint64_t __otx2_io reg_offset;
1227         uint64_t __otx2_io *ret_val;
1228         uint64_t __otx2_io val;
1229         uint8_t __otx2_io is_write;
1230 };
1231
1232 struct cpt_set_crypto_grp_req_msg {
1233         struct mbox_msghdr hdr;
1234         uint8_t __otx2_io crypto_eng_grp;
1235 };
1236
1237 struct cpt_lf_alloc_req_msg {
1238         struct mbox_msghdr hdr;
1239         uint16_t __otx2_io nix_pf_func;
1240         uint16_t __otx2_io sso_pf_func;
1241 };
1242
1243 struct cpt_lf_alloc_rsp_msg {
1244         struct mbox_msghdr hdr;
1245         uint8_t __otx2_io crypto_eng_grp;
1246 };
1247
1248 #define CPT_INLINE_INBOUND      0
1249 #define CPT_INLINE_OUTBOUND     1
1250
1251 struct cpt_inline_ipsec_cfg_msg {
1252         struct mbox_msghdr hdr;
1253         uint8_t __otx2_io enable;
1254         uint8_t __otx2_io slot;
1255         uint8_t __otx2_io dir;
1256         uint16_t __otx2_io sso_pf_func; /* Inbound path SSO_PF_FUNC */
1257         uint16_t __otx2_io nix_pf_func; /* Outbound path NIX_PF_FUNC */
1258 };
1259
1260 struct cpt_rx_inline_lf_cfg_msg {
1261         struct mbox_msghdr hdr;
1262         uint16_t __otx2_io sso_pf_func;
1263 };
1264
1265 enum cpt_eng_type {
1266         CPT_ENG_TYPE_AE = 1,
1267         CPT_ENG_TYPE_SE = 2,
1268         CPT_ENG_TYPE_IE = 3,
1269         CPT_MAX_ENG_TYPES,
1270 };
1271
1272 /* CPT HW capabilities */
1273 union cpt_eng_caps {
1274         uint64_t __otx2_io u;
1275         struct {
1276                 uint64_t __otx2_io reserved_0_4:5;
1277                 uint64_t __otx2_io mul:1;
1278                 uint64_t __otx2_io sha1_sha2:1;
1279                 uint64_t __otx2_io chacha20:1;
1280                 uint64_t __otx2_io zuc_snow3g:1;
1281                 uint64_t __otx2_io sha3:1;
1282                 uint64_t __otx2_io aes:1;
1283                 uint64_t __otx2_io kasumi:1;
1284                 uint64_t __otx2_io des:1;
1285                 uint64_t __otx2_io crc:1;
1286                 uint64_t __otx2_io reserved_14_63:50;
1287         };
1288 };
1289
1290 struct cpt_caps_rsp_msg {
1291         struct mbox_msghdr hdr;
1292         uint16_t __otx2_io cpt_pf_drv_version;
1293         uint8_t __otx2_io cpt_revision;
1294         union cpt_eng_caps eng_caps[CPT_MAX_ENG_TYPES];
1295 };
1296
1297 /* NPC mbox message structs */
1298
1299 #define NPC_MCAM_ENTRY_INVALID  0xFFFF
1300 #define NPC_MCAM_INVALID_MAP    0xFFFF
1301
1302 /* NPC mailbox error codes
1303  * Range 701 - 800.
1304  */
1305 enum npc_af_status {
1306         NPC_MCAM_INVALID_REQ    = -701,
1307         NPC_MCAM_ALLOC_DENIED   = -702,
1308         NPC_MCAM_ALLOC_FAILED   = -703,
1309         NPC_MCAM_PERM_DENIED    = -704,
1310         NPC_AF_ERR_HIGIG_CONFIG_FAIL    = -705,
1311 };
1312
1313 struct npc_mcam_alloc_entry_req {
1314         struct mbox_msghdr hdr;
1315 #define NPC_MAX_NONCONTIG_ENTRIES       256
1316         uint8_t __otx2_io contig;   /* Contiguous entries ? */
1317 #define NPC_MCAM_ANY_PRIO               0
1318 #define NPC_MCAM_LOWER_PRIO             1
1319 #define NPC_MCAM_HIGHER_PRIO            2
1320         uint8_t __otx2_io priority; /* Lower or higher w.r.t ref_entry */
1321         uint16_t __otx2_io ref_entry;
1322         uint16_t __otx2_io count;    /* Number of entries requested */
1323 };
1324
1325 struct npc_mcam_alloc_entry_rsp {
1326         struct mbox_msghdr hdr;
1327         /* Entry alloc'ed or start index if contiguous.
1328          * Invalid in case of non-contiguous.
1329          */
1330         uint16_t __otx2_io entry;
1331         uint16_t __otx2_io count; /* Number of entries allocated */
1332         uint16_t __otx2_io free_count; /* Number of entries available */
1333         uint16_t __otx2_io entry_list[NPC_MAX_NONCONTIG_ENTRIES];
1334 };
1335
1336 struct npc_mcam_free_entry_req {
1337         struct mbox_msghdr hdr;
1338         uint16_t __otx2_io entry; /* Entry index to be freed */
1339         uint8_t __otx2_io all;   /* Free all entries alloc'ed to this PFVF */
1340 };
1341
1342 struct mcam_entry {
1343 #define NPC_MAX_KWS_IN_KEY      7 /* Number of keywords in max key width */
1344         uint64_t __otx2_io kw[NPC_MAX_KWS_IN_KEY];
1345         uint64_t __otx2_io kw_mask[NPC_MAX_KWS_IN_KEY];
1346         uint64_t __otx2_io action;
1347         uint64_t __otx2_io vtag_action;
1348 };
1349
1350 struct npc_mcam_write_entry_req {
1351         struct mbox_msghdr hdr;
1352         struct mcam_entry entry_data;
1353         uint16_t __otx2_io entry; /* MCAM entry to write this match key */
1354         uint16_t __otx2_io cntr;         /* Counter for this MCAM entry */
1355         uint8_t __otx2_io intf;  /* Rx or Tx interface */
1356         uint8_t __otx2_io enable_entry;/* Enable this MCAM entry ? */
1357         uint8_t __otx2_io set_cntr;    /* Set counter for this entry ? */
1358 };
1359
1360 /* Enable/Disable a given entry */
1361 struct npc_mcam_ena_dis_entry_req {
1362         struct mbox_msghdr hdr;
1363         uint16_t __otx2_io entry;
1364 };
1365
1366 struct npc_mcam_shift_entry_req {
1367         struct mbox_msghdr hdr;
1368 #define NPC_MCAM_MAX_SHIFTS     64
1369         uint16_t __otx2_io curr_entry[NPC_MCAM_MAX_SHIFTS];
1370         uint16_t __otx2_io new_entry[NPC_MCAM_MAX_SHIFTS];
1371         uint16_t __otx2_io shift_count; /* Number of entries to shift */
1372 };
1373
1374 struct npc_mcam_shift_entry_rsp {
1375         struct mbox_msghdr hdr;
1376         /* Index in 'curr_entry', not entry itself */
1377         uint16_t __otx2_io failed_entry_idx;
1378 };
1379
1380 struct npc_mcam_alloc_counter_req {
1381         struct mbox_msghdr hdr;
1382         uint8_t __otx2_io contig;       /* Contiguous counters ? */
1383 #define NPC_MAX_NONCONTIG_COUNTERS 64
1384         uint16_t __otx2_io count;       /* Number of counters requested */
1385 };
1386
1387 struct npc_mcam_alloc_counter_rsp {
1388         struct mbox_msghdr hdr;
1389         /* Counter alloc'ed or start idx if contiguous.
1390          * Invalid incase of non-contiguous.
1391          */
1392         uint16_t __otx2_io cntr;
1393         uint16_t __otx2_io count; /* Number of counters allocated */
1394         uint16_t __otx2_io cntr_list[NPC_MAX_NONCONTIG_COUNTERS];
1395 };
1396
1397 struct npc_mcam_oper_counter_req {
1398         struct mbox_msghdr hdr;
1399         uint16_t __otx2_io cntr; /* Free a counter or clear/fetch it's stats */
1400 };
1401
1402 struct npc_mcam_oper_counter_rsp {
1403         struct mbox_msghdr hdr;
1404         /* valid only while fetching counter's stats */
1405         uint64_t __otx2_io stat;
1406 };
1407
1408 struct npc_mcam_unmap_counter_req {
1409         struct mbox_msghdr hdr;
1410         uint16_t __otx2_io cntr;
1411         uint16_t __otx2_io entry; /* Entry and counter to be unmapped */
1412         uint8_t __otx2_io all;   /* Unmap all entries using this counter ? */
1413 };
1414
1415 struct npc_mcam_alloc_and_write_entry_req {
1416         struct mbox_msghdr hdr;
1417         struct mcam_entry entry_data;
1418         uint16_t __otx2_io ref_entry;
1419         uint8_t __otx2_io priority;    /* Lower or higher w.r.t ref_entry */
1420         uint8_t __otx2_io intf;  /* Rx or Tx interface */
1421         uint8_t __otx2_io enable_entry;/* Enable this MCAM entry ? */
1422         uint8_t __otx2_io alloc_cntr;  /* Allocate counter and map ? */
1423 };
1424
1425 struct npc_mcam_alloc_and_write_entry_rsp {
1426         struct mbox_msghdr hdr;
1427         uint16_t __otx2_io entry;
1428         uint16_t __otx2_io cntr;
1429 };
1430
1431 struct npc_get_kex_cfg_rsp {
1432         struct mbox_msghdr hdr;
1433         uint64_t __otx2_io rx_keyx_cfg;   /* NPC_AF_INTF(0)_KEX_CFG */
1434         uint64_t __otx2_io tx_keyx_cfg;   /* NPC_AF_INTF(1)_KEX_CFG */
1435 #define NPC_MAX_INTF    2
1436 #define NPC_MAX_LID     8
1437 #define NPC_MAX_LT      16
1438 #define NPC_MAX_LD      2
1439 #define NPC_MAX_LFL     16
1440         /* NPC_AF_KEX_LDATA(0..1)_FLAGS_CFG */
1441         uint64_t __otx2_io kex_ld_flags[NPC_MAX_LD];
1442         /* NPC_AF_INTF(0..1)_LID(0..7)_LT(0..15)_LD(0..1)_CFG */
1443         uint64_t __otx2_io
1444         intf_lid_lt_ld[NPC_MAX_INTF][NPC_MAX_LID][NPC_MAX_LT][NPC_MAX_LD];
1445         /* NPC_AF_INTF(0..1)_LDATA(0..1)_FLAGS(0..15)_CFG */
1446         uint64_t __otx2_io
1447         intf_ld_flags[NPC_MAX_INTF][NPC_MAX_LD][NPC_MAX_LFL];
1448 #define MKEX_NAME_LEN 128
1449         uint8_t __otx2_io mkex_pfl_name[MKEX_NAME_LEN];
1450 };
1451
1452 enum header_fields {
1453         NPC_DMAC,
1454         NPC_SMAC,
1455         NPC_ETYPE,
1456         NPC_OUTER_VID,
1457         NPC_TOS,
1458         NPC_SIP_IPV4,
1459         NPC_DIP_IPV4,
1460         NPC_SIP_IPV6,
1461         NPC_DIP_IPV6,
1462         NPC_SPORT_TCP,
1463         NPC_DPORT_TCP,
1464         NPC_SPORT_UDP,
1465         NPC_DPORT_UDP,
1466         NPC_FDSA_VAL,
1467         NPC_HEADER_FIELDS_MAX,
1468 };
1469
1470 struct flow_msg {
1471         unsigned char __otx2_io dmac[6];
1472         unsigned char __otx2_io smac[6];
1473         uint16_t __otx2_io etype;
1474         uint16_t __otx2_io vlan_etype;
1475         uint16_t __otx2_io vlan_tci;
1476         union {
1477                 uint32_t __otx2_io ip4src;
1478                 uint32_t __otx2_io ip6src[4];
1479         };
1480         union {
1481                 uint32_t __otx2_io ip4dst;
1482                 uint32_t __otx2_io ip6dst[4];
1483         };
1484         uint8_t __otx2_io tos;
1485         uint8_t __otx2_io ip_ver;
1486         uint8_t __otx2_io ip_proto;
1487         uint8_t __otx2_io tc;
1488         uint16_t __otx2_io sport;
1489         uint16_t __otx2_io dport;
1490 };
1491
1492 struct npc_install_flow_req {
1493         struct mbox_msghdr hdr;
1494         struct flow_msg packet;
1495         struct flow_msg mask;
1496         uint64_t __otx2_io features;
1497         uint16_t __otx2_io entry;
1498         uint16_t __otx2_io channel;
1499         uint8_t __otx2_io intf;
1500         uint8_t __otx2_io set_cntr;
1501         uint8_t __otx2_io default_rule;
1502         /* Overwrite(0) or append(1) flow to default rule? */
1503         uint8_t __otx2_io append;
1504         uint16_t __otx2_io vf;
1505         /* action */
1506         uint32_t __otx2_io index;
1507         uint16_t __otx2_io match_id;
1508         uint8_t __otx2_io flow_key_alg;
1509         uint8_t __otx2_io op;
1510         /* vtag action */
1511         uint8_t __otx2_io vtag0_type;
1512         uint8_t __otx2_io vtag0_valid;
1513         uint8_t __otx2_io vtag1_type;
1514         uint8_t __otx2_io vtag1_valid;
1515
1516         /* vtag tx action */
1517         uint16_t __otx2_io vtag0_def;
1518         uint8_t  __otx2_io vtag0_op;
1519         uint16_t __otx2_io vtag1_def;
1520         uint8_t  __otx2_io vtag1_op;
1521 };
1522
1523 struct npc_install_flow_rsp {
1524         struct mbox_msghdr hdr;
1525         /* Negative if no counter else counter number */
1526         int __otx2_io counter;
1527 };
1528
1529 struct npc_delete_flow_req {
1530         struct mbox_msghdr hdr;
1531         uint16_t __otx2_io entry;
1532         uint16_t __otx2_io start;/*Disable range of entries */
1533         uint16_t __otx2_io end;
1534         uint8_t __otx2_io all; /* PF + VFs */
1535 };
1536
1537 struct npc_mcam_read_entry_req {
1538         struct mbox_msghdr hdr;
1539         /* MCAM entry to read */
1540         uint16_t __otx2_io entry;
1541 };
1542
1543 struct npc_mcam_read_entry_rsp {
1544         struct mbox_msghdr hdr;
1545         struct mcam_entry entry_data;
1546         uint8_t __otx2_io intf;
1547         uint8_t __otx2_io enable;
1548 };
1549
1550 struct npc_mcam_read_base_rule_rsp {
1551         struct mbox_msghdr hdr;
1552         struct mcam_entry entry_data;
1553 };
1554
1555 /* TIM mailbox error codes
1556  * Range 801 - 900.
1557  */
1558 enum tim_af_status {
1559         TIM_AF_NO_RINGS_LEFT                    = -801,
1560         TIM_AF_INVALID_NPA_PF_FUNC              = -802,
1561         TIM_AF_INVALID_SSO_PF_FUNC              = -803,
1562         TIM_AF_RING_STILL_RUNNING               = -804,
1563         TIM_AF_LF_INVALID                       = -805,
1564         TIM_AF_CSIZE_NOT_ALIGNED                = -806,
1565         TIM_AF_CSIZE_TOO_SMALL                  = -807,
1566         TIM_AF_CSIZE_TOO_BIG                    = -808,
1567         TIM_AF_INTERVAL_TOO_SMALL               = -809,
1568         TIM_AF_INVALID_BIG_ENDIAN_VALUE         = -810,
1569         TIM_AF_INVALID_CLOCK_SOURCE             = -811,
1570         TIM_AF_GPIO_CLK_SRC_NOT_ENABLED         = -812,
1571         TIM_AF_INVALID_BSIZE                    = -813,
1572         TIM_AF_INVALID_ENABLE_PERIODIC          = -814,
1573         TIM_AF_INVALID_ENABLE_DONTFREE          = -815,
1574         TIM_AF_ENA_DONTFRE_NSET_PERIODIC        = -816,
1575         TIM_AF_RING_ALREADY_DISABLED            = -817,
1576 };
1577
1578 enum tim_clk_srcs {
1579         TIM_CLK_SRCS_TENNS      = 0,
1580         TIM_CLK_SRCS_GPIO       = 1,
1581         TIM_CLK_SRCS_GTI        = 2,
1582         TIM_CLK_SRCS_PTP        = 3,
1583         TIM_CLK_SRSC_INVALID,
1584 };
1585
1586 enum tim_gpio_edge {
1587         TIM_GPIO_NO_EDGE                = 0,
1588         TIM_GPIO_LTOH_TRANS             = 1,
1589         TIM_GPIO_HTOL_TRANS             = 2,
1590         TIM_GPIO_BOTH_TRANS             = 3,
1591         TIM_GPIO_INVALID,
1592 };
1593
1594 enum ptp_op {
1595         PTP_OP_ADJFINE = 0, /* adjfine(req.scaled_ppm); */
1596         PTP_OP_GET_CLOCK = 1, /* rsp.clk = get_clock() */
1597 };
1598
1599 struct ptp_req {
1600         struct mbox_msghdr hdr;
1601         uint8_t __otx2_io op;
1602         int64_t __otx2_io scaled_ppm;
1603         uint8_t __otx2_io is_pmu;
1604 };
1605
1606 struct ptp_rsp {
1607         struct mbox_msghdr hdr;
1608         uint64_t __otx2_io clk;
1609         uint64_t __otx2_io tsc;
1610 };
1611
1612 struct get_hw_cap_rsp {
1613         struct mbox_msghdr hdr;
1614         /* Schq mapping fixed or flexible */
1615         uint8_t __otx2_io nix_fixed_txschq_mapping;
1616         uint8_t __otx2_io nix_shaping; /* Is shaping and coloring supported */
1617 };
1618
1619 struct ndc_sync_op {
1620         struct mbox_msghdr hdr;
1621         uint8_t __otx2_io nix_lf_tx_sync;
1622         uint8_t __otx2_io nix_lf_rx_sync;
1623         uint8_t __otx2_io npa_lf_sync;
1624 };
1625
1626 struct tim_lf_alloc_req {
1627         struct mbox_msghdr hdr;
1628         uint16_t __otx2_io ring;
1629         uint16_t __otx2_io npa_pf_func;
1630         uint16_t __otx2_io sso_pf_func;
1631 };
1632
1633 struct tim_ring_req {
1634         struct mbox_msghdr hdr;
1635         uint16_t __otx2_io ring;
1636 };
1637
1638 struct tim_config_req {
1639         struct mbox_msghdr hdr;
1640         uint16_t __otx2_io ring;
1641         uint8_t __otx2_io bigendian;
1642         uint8_t __otx2_io clocksource;
1643         uint8_t __otx2_io enableperiodic;
1644         uint8_t __otx2_io enabledontfreebuffer;
1645         uint32_t __otx2_io bucketsize;
1646         uint32_t __otx2_io chunksize;
1647         uint32_t __otx2_io interval;
1648 };
1649
1650 struct tim_lf_alloc_rsp {
1651         struct mbox_msghdr hdr;
1652         uint64_t __otx2_io tenns_clk;
1653 };
1654
1655 struct tim_enable_rsp {
1656         struct mbox_msghdr hdr;
1657         uint64_t __otx2_io timestarted;
1658         uint32_t __otx2_io currentbucket;
1659 };
1660
1661 __rte_internal
1662 const char *otx2_mbox_id2name(uint16_t id);
1663 int otx2_mbox_id2size(uint16_t id);
1664 void otx2_mbox_reset(struct otx2_mbox *mbox, int devid);
1665 int otx2_mbox_init(struct otx2_mbox *mbox, uintptr_t hwbase, uintptr_t reg_base,
1666                    int direction, int ndevsi, uint64_t intr_offset);
1667 void otx2_mbox_fini(struct otx2_mbox *mbox);
1668 __rte_internal
1669 void otx2_mbox_msg_send(struct otx2_mbox *mbox, int devid);
1670 __rte_internal
1671 int otx2_mbox_wait_for_rsp(struct otx2_mbox *mbox, int devid);
1672 int otx2_mbox_wait_for_rsp_tmo(struct otx2_mbox *mbox, int devid, uint32_t tmo);
1673 __rte_internal
1674 int otx2_mbox_get_rsp(struct otx2_mbox *mbox, int devid, void **msg);
1675 __rte_internal
1676 int otx2_mbox_get_rsp_tmo(struct otx2_mbox *mbox, int devid, void **msg,
1677                           uint32_t tmo);
1678 int otx2_mbox_get_availmem(struct otx2_mbox *mbox, int devid);
1679 __rte_internal
1680 struct mbox_msghdr *otx2_mbox_alloc_msg_rsp(struct otx2_mbox *mbox, int devid,
1681                                             int size, int size_rsp);
1682
1683 static inline struct mbox_msghdr *
1684 otx2_mbox_alloc_msg(struct otx2_mbox *mbox, int devid, int size)
1685 {
1686         return otx2_mbox_alloc_msg_rsp(mbox, devid, size, 0);
1687 }
1688
1689 static inline void
1690 otx2_mbox_req_init(uint16_t mbox_id, void *msghdr)
1691 {
1692         struct mbox_msghdr *hdr = msghdr;
1693
1694         hdr->sig = OTX2_MBOX_REQ_SIG;
1695         hdr->ver = OTX2_MBOX_VERSION;
1696         hdr->id = mbox_id;
1697         hdr->pcifunc = 0;
1698 }
1699
1700 static inline void
1701 otx2_mbox_rsp_init(uint16_t mbox_id, void *msghdr)
1702 {
1703         struct mbox_msghdr *hdr = msghdr;
1704
1705         hdr->sig = OTX2_MBOX_RSP_SIG;
1706         hdr->rc = -ETIMEDOUT;
1707         hdr->id = mbox_id;
1708 }
1709
1710 static inline bool
1711 otx2_mbox_nonempty(struct otx2_mbox *mbox, int devid)
1712 {
1713         struct otx2_mbox_dev *mdev = &mbox->dev[devid];
1714         bool ret;
1715
1716         rte_spinlock_lock(&mdev->mbox_lock);
1717         ret = mdev->num_msgs != 0;
1718         rte_spinlock_unlock(&mdev->mbox_lock);
1719
1720         return ret;
1721 }
1722
1723 static inline int
1724 otx2_mbox_process(struct otx2_mbox *mbox)
1725 {
1726         otx2_mbox_msg_send(mbox, 0);
1727         return otx2_mbox_get_rsp(mbox, 0, NULL);
1728 }
1729
1730 static inline int
1731 otx2_mbox_process_msg(struct otx2_mbox *mbox, void **msg)
1732 {
1733         otx2_mbox_msg_send(mbox, 0);
1734         return otx2_mbox_get_rsp(mbox, 0, msg);
1735 }
1736
1737 static inline int
1738 otx2_mbox_process_tmo(struct otx2_mbox *mbox, uint32_t tmo)
1739 {
1740         otx2_mbox_msg_send(mbox, 0);
1741         return otx2_mbox_get_rsp_tmo(mbox, 0, NULL, tmo);
1742 }
1743
1744 static inline int
1745 otx2_mbox_process_msg_tmo(struct otx2_mbox *mbox, void **msg, uint32_t tmo)
1746 {
1747         otx2_mbox_msg_send(mbox, 0);
1748         return otx2_mbox_get_rsp_tmo(mbox, 0, msg, tmo);
1749 }
1750
1751 int otx2_send_ready_msg(struct otx2_mbox *mbox, uint16_t *pf_func /* out */);
1752 int otx2_reply_invalid_msg(struct otx2_mbox *mbox, int devid, uint16_t pf_func,
1753                         uint16_t id);
1754
1755 #define M(_name, _id, _fn_name, _req_type, _rsp_type)                   \
1756 static inline struct _req_type                                          \
1757 *otx2_mbox_alloc_msg_ ## _fn_name(struct otx2_mbox *mbox)               \
1758 {                                                                       \
1759         struct _req_type *req;                                          \
1760                                                                         \
1761         req = (struct _req_type *)otx2_mbox_alloc_msg_rsp(              \
1762                 mbox, 0, sizeof(struct _req_type),                      \
1763                 sizeof(struct _rsp_type));                              \
1764         if (!req)                                                       \
1765                 return NULL;                                            \
1766                                                                         \
1767         req->hdr.sig = OTX2_MBOX_REQ_SIG;                               \
1768         req->hdr.id = _id;                                              \
1769         otx2_mbox_dbg("id=0x%x (%s)",                                   \
1770                         req->hdr.id, otx2_mbox_id2name(req->hdr.id));   \
1771         return req;                                                     \
1772 }
1773
1774 MBOX_MESSAGES
1775 #undef M
1776
1777 /* This is required for copy operations from device memory which do not work on
1778  * addresses which are unaligned to 16B. This is because of specific
1779  * optimizations to libc memcpy.
1780  */
1781 static inline volatile void *
1782 otx2_mbox_memcpy(volatile void *d, const volatile void *s, size_t l)
1783 {
1784         const volatile uint8_t *sb;
1785         volatile uint8_t *db;
1786         size_t i;
1787
1788         if (!d || !s)
1789                 return NULL;
1790         db = (volatile uint8_t *)d;
1791         sb = (const volatile uint8_t *)s;
1792         for (i = 0; i < l; i++)
1793                 db[i] = sb[i];
1794         return d;
1795 }
1796
1797 /* This is required for memory operations from device memory which do not
1798  * work on addresses which are unaligned to 16B. This is because of specific
1799  * optimizations to libc memset.
1800  */
1801 static inline void
1802 otx2_mbox_memset(volatile void *d, uint8_t val, size_t l)
1803 {
1804         volatile uint8_t *db;
1805         size_t i = 0;
1806
1807         if (!d || !l)
1808                 return;
1809         db = (volatile uint8_t *)d;
1810         for (i = 0; i < l; i++)
1811                 db[i] = val;
1812 }
1813
1814 #endif /* __OTX2_MBOX_H__ */