1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2019 Marvell International Ltd.
5 #ifndef __OTX2_MBOX_H__
6 #define __OTX2_MBOX_H__
11 #include <rte_ether.h>
12 #include <rte_spinlock.h>
14 #include <otx2_common.h>
16 #define SZ_64K (64ULL * 1024ULL)
17 #define SZ_1K (1ULL * 1024ULL)
18 #define MBOX_SIZE SZ_64K
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
31 #if MBOX_UP_TX_SIZE + MBOX_UP_TX_START != MBOX_SIZE
32 # error "Incorrect mailbox area sizes"
35 #define INTR_MASK(pfvfs) ((pfvfs < 64) ? (BIT_ULL(pfvfs) - 1) : (~0ull))
37 #define MBOX_RSP_TIMEOUT 3000 /* Time to wait for mbox response in ms */
39 #define MBOX_MSG_ALIGN 16 /* Align mbox msg start to 16bytes */
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 */
51 /* Device memory does not support unaligned access, instruct compiler to
52 * not optimize the memory access when working with mailbox memory.
54 #define __otx2_io volatile
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 */
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;
78 /* Header which precedes all mbox messages */
80 uint64_t __otx2_io msg_size; /* Total msgs size embedded */
81 uint16_t __otx2_io num_msgs; /* No of msgs embedded */
84 /* Header which precedes every msg and is also part of it */
86 uint16_t __otx2_io pcifunc; /* Who's sending this msg */
87 uint16_t __otx2_io id; /* Mbox message ID */
88 #define OTX2_MBOX_REQ_SIG (0xdead)
89 #define OTX2_MBOX_RSP_SIG (0xbeef)
90 /* Signature, for validating corrupted msgs */
91 uint16_t __otx2_io sig;
92 #define OTX2_MBOX_VERSION (0x0002)
93 /* Version of msg's structure for this ID */
94 uint16_t __otx2_io ver;
95 /* Offset of next msg within mailbox region */
96 uint16_t __otx2_io next_msgoff;
97 int __otx2_io rc; /* Msg processed response code */
100 /* Mailbox message types */
101 #define MBOX_MSG_MASK 0xFFFF
102 #define MBOX_MSG_INVALID 0xFFFE
103 #define MBOX_MSG_MAX 0xFFFF
105 #define MBOX_MESSAGES \
106 /* Generic mbox IDs (range 0x000 - 0x1FF) */ \
107 M(READY, 0x001, ready, msg_req, ready_msg_rsp) \
108 M(ATTACH_RESOURCES, 0x002, attach_resources, rsrc_attach_req, msg_rsp)\
109 M(DETACH_RESOURCES, 0x003, detach_resources, rsrc_detach_req, msg_rsp)\
110 M(FREE_RSRC_CNT, 0x004, free_rsrc_cnt, msg_req, free_rsrcs_rsp) \
111 M(MSIX_OFFSET, 0x005, msix_offset, msg_req, msix_offset_rsp) \
112 M(VF_FLR, 0x006, vf_flr, msg_req, msg_rsp) \
113 M(PTP_OP, 0x007, ptp_op, ptp_req, ptp_rsp) \
114 M(GET_HW_CAP, 0x008, get_hw_cap, msg_req, get_hw_cap_rsp) \
115 M(NDC_SYNC_OP, 0x009, ndc_sync_op, ndc_sync_op, msg_rsp) \
116 /* CGX mbox IDs (range 0x200 - 0x3FF) */ \
117 M(CGX_START_RXTX, 0x200, cgx_start_rxtx, msg_req, msg_rsp) \
118 M(CGX_STOP_RXTX, 0x201, cgx_stop_rxtx, msg_req, msg_rsp) \
119 M(CGX_STATS, 0x202, cgx_stats, msg_req, cgx_stats_rsp) \
120 M(CGX_MAC_ADDR_SET, 0x203, cgx_mac_addr_set, cgx_mac_addr_set_or_get,\
121 cgx_mac_addr_set_or_get) \
122 M(CGX_MAC_ADDR_GET, 0x204, cgx_mac_addr_get, cgx_mac_addr_set_or_get,\
123 cgx_mac_addr_set_or_get) \
124 M(CGX_PROMISC_ENABLE, 0x205, cgx_promisc_enable, msg_req, msg_rsp) \
125 M(CGX_PROMISC_DISABLE, 0x206, cgx_promisc_disable, msg_req, msg_rsp) \
126 M(CGX_START_LINKEVENTS, 0x207, cgx_start_linkevents, msg_req, msg_rsp) \
127 M(CGX_STOP_LINKEVENTS, 0x208, cgx_stop_linkevents, msg_req, msg_rsp) \
128 M(CGX_GET_LINKINFO, 0x209, cgx_get_linkinfo, msg_req, cgx_link_info_msg)\
129 M(CGX_INTLBK_ENABLE, 0x20A, cgx_intlbk_enable, msg_req, msg_rsp) \
130 M(CGX_INTLBK_DISABLE, 0x20B, cgx_intlbk_disable, msg_req, msg_rsp) \
131 M(CGX_PTP_RX_ENABLE, 0x20C, cgx_ptp_rx_enable, msg_req, msg_rsp) \
132 M(CGX_PTP_RX_DISABLE, 0x20D, cgx_ptp_rx_disable, msg_req, msg_rsp) \
133 M(CGX_CFG_PAUSE_FRM, 0x20E, cgx_cfg_pause_frm, cgx_pause_frm_cfg, \
135 M(CGX_FW_DATA_GET, 0x20F, cgx_get_aux_link_info, msg_req, cgx_fw_data) \
136 M(CGX_FEC_SET, 0x210, cgx_set_fec_param, fec_mode, fec_mode) \
137 M(CGX_MAC_ADDR_ADD, 0x211, cgx_mac_addr_add, cgx_mac_addr_add_req, \
138 cgx_mac_addr_add_rsp) \
139 M(CGX_MAC_ADDR_DEL, 0x212, cgx_mac_addr_del, cgx_mac_addr_del_req, \
141 M(CGX_MAC_MAX_ENTRIES_GET, 0x213, cgx_mac_max_entries_get, msg_req, \
142 cgx_max_dmac_entries_get_rsp) \
143 M(CGX_SET_LINK_STATE, 0x214, cgx_set_link_state, \
144 cgx_set_link_state_msg, msg_rsp) \
145 M(CGX_GET_PHY_MOD_TYPE, 0x215, cgx_get_phy_mod_type, msg_req, \
147 M(CGX_SET_PHY_MOD_TYPE, 0x216, cgx_set_phy_mod_type, cgx_phy_mod_type, \
149 M(CGX_FEC_STATS, 0x217, cgx_fec_stats, msg_req, cgx_fec_stats_rsp) \
150 M(CGX_SET_LINK_MODE, 0x218, cgx_set_link_mode, cgx_set_link_mode_req,\
151 cgx_set_link_mode_rsp) \
152 /* NPA mbox IDs (range 0x400 - 0x5FF) */ \
153 M(NPA_LF_ALLOC, 0x400, npa_lf_alloc, npa_lf_alloc_req, \
155 M(NPA_LF_FREE, 0x401, npa_lf_free, msg_req, msg_rsp) \
156 M(NPA_AQ_ENQ, 0x402, npa_aq_enq, npa_aq_enq_req, npa_aq_enq_rsp)\
157 M(NPA_HWCTX_DISABLE, 0x403, npa_hwctx_disable, hwctx_disable_req, msg_rsp)\
158 /* SSO/SSOW mbox IDs (range 0x600 - 0x7FF) */ \
159 M(SSO_LF_ALLOC, 0x600, sso_lf_alloc, sso_lf_alloc_req, \
161 M(SSO_LF_FREE, 0x601, sso_lf_free, sso_lf_free_req, msg_rsp) \
162 M(SSOW_LF_ALLOC, 0x602, ssow_lf_alloc, ssow_lf_alloc_req, msg_rsp)\
163 M(SSOW_LF_FREE, 0x603, ssow_lf_free, ssow_lf_free_req, msg_rsp) \
164 M(SSO_HW_SETCONFIG, 0x604, sso_hw_setconfig, sso_hw_setconfig, \
166 M(SSO_GRP_SET_PRIORITY, 0x605, sso_grp_set_priority, sso_grp_priority, \
168 M(SSO_GRP_GET_PRIORITY, 0x606, sso_grp_get_priority, sso_info_req, \
170 M(SSO_WS_CACHE_INV, 0x607, sso_ws_cache_inv, msg_req, msg_rsp) \
171 M(SSO_GRP_QOS_CONFIG, 0x608, sso_grp_qos_config, sso_grp_qos_cfg, \
173 M(SSO_GRP_GET_STATS, 0x609, sso_grp_get_stats, sso_info_req, \
175 M(SSO_HWS_GET_STATS, 0x610, sso_hws_get_stats, sso_info_req, \
177 /* TIM mbox IDs (range 0x800 - 0x9FF) */ \
178 M(TIM_LF_ALLOC, 0x800, tim_lf_alloc, tim_lf_alloc_req, \
180 M(TIM_LF_FREE, 0x801, tim_lf_free, tim_ring_req, msg_rsp) \
181 M(TIM_CONFIG_RING, 0x802, tim_config_ring, tim_config_req, msg_rsp)\
182 M(TIM_ENABLE_RING, 0x803, tim_enable_ring, tim_ring_req, \
184 M(TIM_DISABLE_RING, 0x804, tim_disable_ring, tim_ring_req, msg_rsp) \
185 /* CPT mbox IDs (range 0xA00 - 0xBFF) */ \
186 M(CPT_LF_ALLOC, 0xA00, cpt_lf_alloc, cpt_lf_alloc_req_msg, \
187 cpt_lf_alloc_rsp_msg) \
188 M(CPT_LF_FREE, 0xA01, cpt_lf_free, msg_req, msg_rsp) \
189 M(CPT_RD_WR_REGISTER, 0xA02, cpt_rd_wr_register, cpt_rd_wr_reg_msg, \
191 M(CPT_SET_CRYPTO_GRP, 0xA03, cpt_set_crypto_grp, \
192 cpt_set_crypto_grp_req_msg, \
194 M(CPT_INLINE_IPSEC_CFG, 0xA04, cpt_inline_ipsec_cfg, \
195 cpt_inline_ipsec_cfg_msg, msg_rsp) \
196 /* NPC mbox IDs (range 0x6000 - 0x7FFF) */ \
197 M(NPC_MCAM_ALLOC_ENTRY, 0x6000, npc_mcam_alloc_entry, \
198 npc_mcam_alloc_entry_req, \
199 npc_mcam_alloc_entry_rsp) \
200 M(NPC_MCAM_FREE_ENTRY, 0x6001, npc_mcam_free_entry, \
201 npc_mcam_free_entry_req, msg_rsp) \
202 M(NPC_MCAM_WRITE_ENTRY, 0x6002, npc_mcam_write_entry, \
203 npc_mcam_write_entry_req, msg_rsp) \
204 M(NPC_MCAM_ENA_ENTRY, 0x6003, npc_mcam_ena_entry, \
205 npc_mcam_ena_dis_entry_req, msg_rsp) \
206 M(NPC_MCAM_DIS_ENTRY, 0x6004, npc_mcam_dis_entry, \
207 npc_mcam_ena_dis_entry_req, msg_rsp) \
208 M(NPC_MCAM_SHIFT_ENTRY, 0x6005, npc_mcam_shift_entry, \
209 npc_mcam_shift_entry_req, \
210 npc_mcam_shift_entry_rsp) \
211 M(NPC_MCAM_ALLOC_COUNTER, 0x6006, npc_mcam_alloc_counter, \
212 npc_mcam_alloc_counter_req, \
213 npc_mcam_alloc_counter_rsp) \
214 M(NPC_MCAM_FREE_COUNTER, 0x6007, npc_mcam_free_counter, \
215 npc_mcam_oper_counter_req, \
217 M(NPC_MCAM_UNMAP_COUNTER, 0x6008, npc_mcam_unmap_counter, \
218 npc_mcam_unmap_counter_req, \
220 M(NPC_MCAM_CLEAR_COUNTER, 0x6009, npc_mcam_clear_counter, \
221 npc_mcam_oper_counter_req, \
223 M(NPC_MCAM_COUNTER_STATS, 0x600a, npc_mcam_counter_stats, \
224 npc_mcam_oper_counter_req, \
225 npc_mcam_oper_counter_rsp) \
226 M(NPC_MCAM_ALLOC_AND_WRITE_ENTRY, 0x600b, npc_mcam_alloc_and_write_entry,\
227 npc_mcam_alloc_and_write_entry_req, \
228 npc_mcam_alloc_and_write_entry_rsp) \
229 M(NPC_GET_KEX_CFG, 0x600c, npc_get_kex_cfg, msg_req, \
230 npc_get_kex_cfg_rsp) \
231 M(NPC_INSTALL_FLOW, 0x600d, npc_install_flow, \
232 npc_install_flow_req, \
233 npc_install_flow_rsp) \
234 M(NPC_DELETE_FLOW, 0x600e, npc_delete_flow, \
235 npc_delete_flow_req, msg_rsp) \
236 M(NPC_MCAM_READ_ENTRY, 0x600f, npc_mcam_read_entry, \
237 npc_mcam_read_entry_req, \
238 npc_mcam_read_entry_rsp) \
239 /* NIX mbox IDs (range 0x8000 - 0xFFFF) */ \
240 M(NIX_LF_ALLOC, 0x8000, nix_lf_alloc, nix_lf_alloc_req, \
242 M(NIX_LF_FREE, 0x8001, nix_lf_free, nix_lf_free_req, msg_rsp) \
243 M(NIX_AQ_ENQ, 0x8002, nix_aq_enq, nix_aq_enq_req, \
245 M(NIX_HWCTX_DISABLE, 0x8003, nix_hwctx_disable, hwctx_disable_req, \
247 M(NIX_TXSCH_ALLOC, 0x8004, nix_txsch_alloc, nix_txsch_alloc_req, \
248 nix_txsch_alloc_rsp) \
249 M(NIX_TXSCH_FREE, 0x8005, nix_txsch_free, nix_txsch_free_req, \
251 M(NIX_TXSCHQ_CFG, 0x8006, nix_txschq_cfg, nix_txschq_config, \
253 M(NIX_STATS_RST, 0x8007, nix_stats_rst, msg_req, msg_rsp) \
254 M(NIX_VTAG_CFG, 0x8008, nix_vtag_cfg, nix_vtag_config, msg_rsp) \
255 M(NIX_RSS_FLOWKEY_CFG, 0x8009, nix_rss_flowkey_cfg, \
256 nix_rss_flowkey_cfg, \
257 nix_rss_flowkey_cfg_rsp) \
258 M(NIX_SET_MAC_ADDR, 0x800a, nix_set_mac_addr, nix_set_mac_addr, \
260 M(NIX_SET_RX_MODE, 0x800b, nix_set_rx_mode, nix_rx_mode, msg_rsp) \
261 M(NIX_SET_HW_FRS, 0x800c, nix_set_hw_frs, nix_frs_cfg, msg_rsp) \
262 M(NIX_LF_START_RX, 0x800d, nix_lf_start_rx, msg_req, msg_rsp) \
263 M(NIX_LF_STOP_RX, 0x800e, nix_lf_stop_rx, msg_req, msg_rsp) \
264 M(NIX_MARK_FORMAT_CFG, 0x800f, nix_mark_format_cfg, \
265 nix_mark_format_cfg, \
266 nix_mark_format_cfg_rsp) \
267 M(NIX_SET_RX_CFG, 0x8010, nix_set_rx_cfg, nix_rx_cfg, msg_rsp) \
268 M(NIX_LSO_FORMAT_CFG, 0x8011, nix_lso_format_cfg, nix_lso_format_cfg, \
269 nix_lso_format_cfg_rsp) \
270 M(NIX_LF_PTP_TX_ENABLE, 0x8013, nix_lf_ptp_tx_enable, msg_req, \
272 M(NIX_LF_PTP_TX_DISABLE, 0x8014, nix_lf_ptp_tx_disable, msg_req, \
274 M(NIX_SET_VLAN_TPID, 0x8015, nix_set_vlan_tpid, nix_set_vlan_tpid, \
276 M(NIX_BP_ENABLE, 0x8016, nix_bp_enable, nix_bp_cfg_req, \
278 M(NIX_BP_DISABLE, 0x8017, nix_bp_disable, nix_bp_cfg_req, msg_rsp)\
279 M(NIX_GET_MAC_ADDR, 0x8018, nix_get_mac_addr, msg_req, \
280 nix_get_mac_addr_rsp) \
281 M(NIX_INLINE_IPSEC_CFG, 0x8019, nix_inline_ipsec_cfg, \
282 nix_inline_ipsec_cfg, msg_rsp) \
283 M(NIX_INLINE_IPSEC_LF_CFG, \
284 0x801a, nix_inline_ipsec_lf_cfg, \
285 nix_inline_ipsec_lf_cfg, msg_rsp)
287 /* Messages initiated by AF (range 0xC00 - 0xDFF) */
288 #define MBOX_UP_CGX_MESSAGES \
289 M(CGX_LINK_EVENT, 0xC00, cgx_link_event, cgx_link_info_msg, \
291 M(CGX_PTP_RX_INFO, 0xC01, cgx_ptp_rx_info, cgx_ptp_rx_info_msg, \
295 #define M(_name, _id, _1, _2, _3) MBOX_MSG_ ## _name = _id,
301 /* Mailbox message formats */
303 #define RVU_DEFAULT_PF_FUNC 0xFFFF
305 /* Generic request msg used for those mbox messages which
306 * don't send any data in the request.
309 struct mbox_msghdr hdr;
312 /* Generic response msg used a ack or response for those mbox
313 * messages which doesn't have a specific rsp msg format.
316 struct mbox_msghdr hdr;
319 /* RVU mailbox error codes
323 RVU_INVALID_VF_ID = -256,
326 struct ready_msg_rsp {
327 struct mbox_msghdr hdr;
328 uint16_t __otx2_io sclk_feq; /* SCLK frequency */
329 uint16_t __otx2_io rclk_freq; /* RCLK frequency */
332 /* Structure for requesting resource provisioning.
333 * 'modify' flag to be used when either requesting more
334 * or detach partial of a certain resource type.
335 * Rest of the fields specify how many of what type to
338 struct rsrc_attach_req {
339 struct mbox_msghdr hdr;
340 uint8_t __otx2_io modify:1;
341 uint8_t __otx2_io npalf:1;
342 uint8_t __otx2_io nixlf:1;
343 uint16_t __otx2_io sso;
344 uint16_t __otx2_io ssow;
345 uint16_t __otx2_io timlfs;
346 uint16_t __otx2_io cptlfs;
349 /* Structure for relinquishing resources.
350 * 'partial' flag to be used when relinquishing all resources
351 * but only of a certain type. If not set, all resources of all
352 * types provisioned to the RVU function will be detached.
354 struct rsrc_detach_req {
355 struct mbox_msghdr hdr;
356 uint8_t __otx2_io partial:1;
357 uint8_t __otx2_io npalf:1;
358 uint8_t __otx2_io nixlf:1;
359 uint8_t __otx2_io sso:1;
360 uint8_t __otx2_io ssow:1;
361 uint8_t __otx2_io timlfs:1;
362 uint8_t __otx2_io cptlfs:1;
365 /* NIX Transmit schedulers */
366 #define NIX_TXSCH_LVL_SMQ 0x0
367 #define NIX_TXSCH_LVL_MDQ 0x0
368 #define NIX_TXSCH_LVL_TL4 0x1
369 #define NIX_TXSCH_LVL_TL3 0x2
370 #define NIX_TXSCH_LVL_TL2 0x3
371 #define NIX_TXSCH_LVL_TL1 0x4
372 #define NIX_TXSCH_LVL_CNT 0x5
375 * Number of resources available to the caller.
376 * In reply to MBOX_MSG_FREE_RSRC_CNT.
378 struct free_rsrcs_rsp {
379 struct mbox_msghdr hdr;
380 uint16_t __otx2_io schq[NIX_TXSCH_LVL_CNT];
381 uint16_t __otx2_io sso;
382 uint16_t __otx2_io tim;
383 uint16_t __otx2_io ssow;
384 uint16_t __otx2_io cpt;
385 uint8_t __otx2_io npa;
386 uint8_t __otx2_io nix;
389 #define MSIX_VECTOR_INVALID 0xFFFF
390 #define MAX_RVU_BLKLF_CNT 256
392 struct msix_offset_rsp {
393 struct mbox_msghdr hdr;
394 uint16_t __otx2_io npa_msixoff;
395 uint16_t __otx2_io nix_msixoff;
396 uint8_t __otx2_io sso;
397 uint8_t __otx2_io ssow;
398 uint8_t __otx2_io timlfs;
399 uint8_t __otx2_io cptlfs;
400 uint16_t __otx2_io sso_msixoff[MAX_RVU_BLKLF_CNT];
401 uint16_t __otx2_io ssow_msixoff[MAX_RVU_BLKLF_CNT];
402 uint16_t __otx2_io timlf_msixoff[MAX_RVU_BLKLF_CNT];
403 uint16_t __otx2_io cptlf_msixoff[MAX_RVU_BLKLF_CNT];
406 /* CGX mbox message formats */
408 struct cgx_stats_rsp {
409 struct mbox_msghdr hdr;
410 #define CGX_RX_STATS_COUNT 13
411 #define CGX_TX_STATS_COUNT 18
412 uint64_t __otx2_io rx_stats[CGX_RX_STATS_COUNT];
413 uint64_t __otx2_io tx_stats[CGX_TX_STATS_COUNT];
416 struct cgx_fec_stats_rsp {
417 struct mbox_msghdr hdr;
418 uint64_t __otx2_io fec_corr_blks;
419 uint64_t __otx2_io fec_uncorr_blks;
421 /* Structure for requesting the operation for
422 * setting/getting mac address in the CGX interface
424 struct cgx_mac_addr_set_or_get {
425 struct mbox_msghdr hdr;
426 uint8_t __otx2_io mac_addr[RTE_ETHER_ADDR_LEN];
429 /* Structure for requesting the operation to
430 * add DMAC filter entry into CGX interface
432 struct cgx_mac_addr_add_req {
433 struct mbox_msghdr hdr;
434 uint8_t __otx2_io mac_addr[RTE_ETHER_ADDR_LEN];
437 /* Structure for response against the operation to
438 * add DMAC filter entry into CGX interface
440 struct cgx_mac_addr_add_rsp {
441 struct mbox_msghdr hdr;
442 uint8_t __otx2_io index;
445 /* Structure for requesting the operation to
446 * delete DMAC filter entry from CGX interface
448 struct cgx_mac_addr_del_req {
449 struct mbox_msghdr hdr;
450 uint8_t __otx2_io index;
453 /* Structure for response against the operation to
454 * get maximum supported DMAC filter entries
456 struct cgx_max_dmac_entries_get_rsp {
457 struct mbox_msghdr hdr;
458 uint8_t __otx2_io max_dmac_filters;
461 struct cgx_link_user_info {
462 uint64_t __otx2_io link_up:1;
463 uint64_t __otx2_io full_duplex:1;
464 uint64_t __otx2_io lmac_type_id:4;
465 uint64_t __otx2_io speed:20; /* speed in Mbps */
466 uint64_t __otx2_io an:1; /* AN supported or not */
467 uint64_t __otx2_io fec:2; /* FEC type if enabled else 0 */
468 uint64_t __otx2_io port:8;
469 #define LMACTYPE_STR_LEN 16
470 char lmac_type[LMACTYPE_STR_LEN];
473 struct cgx_link_info_msg {
474 struct mbox_msghdr hdr;
475 struct cgx_link_user_info link_info;
478 struct cgx_ptp_rx_info_msg {
479 struct mbox_msghdr hdr;
480 uint8_t __otx2_io ptp_en;
483 struct cgx_pause_frm_cfg {
484 struct mbox_msghdr hdr;
485 uint8_t __otx2_io set;
486 /* set = 1 if the request is to config pause frames */
487 /* set = 0 if the request is to fetch pause frames config */
488 uint8_t __otx2_io rx_pause;
489 uint8_t __otx2_io tx_pause;
492 struct sfp_eeprom_s {
493 #define SFP_EEPROM_SIZE 256
494 uint16_t __otx2_io sff_id;
495 uint8_t __otx2_io buf[SFP_EEPROM_SIZE];
496 uint64_t __otx2_io reserved;
506 uint64_t __otx2_io can_change_mod_type : 1;
507 uint64_t __otx2_io mod_type : 1;
510 struct cgx_lmac_fwdata_s {
511 uint16_t __otx2_io rw_valid;
512 uint64_t __otx2_io supported_fec;
513 uint64_t __otx2_io supported_an;
514 uint64_t __otx2_io supported_link_modes;
515 /* Only applicable if AN is supported */
516 uint64_t __otx2_io advertised_fec;
517 uint64_t __otx2_io advertised_link_modes;
518 /* Only applicable if SFP/QSFP slot is present */
519 struct sfp_eeprom_s sfp_eeprom;
521 #define LMAC_FWDATA_RESERVED_MEM 1023
522 uint64_t __otx2_io reserved[LMAC_FWDATA_RESERVED_MEM];
526 struct mbox_msghdr hdr;
527 struct cgx_lmac_fwdata_s fwdata;
531 struct mbox_msghdr hdr;
535 struct cgx_set_link_state_msg {
536 struct mbox_msghdr hdr;
537 uint8_t __otx2_io enable;
540 struct cgx_phy_mod_type {
541 struct mbox_msghdr hdr;
545 struct cgx_set_link_mode_args {
546 uint32_t __otx2_io speed;
547 uint8_t __otx2_io duplex;
548 uint8_t __otx2_io an;
549 uint8_t __otx2_io ports;
550 uint64_t __otx2_io mode;
553 struct cgx_set_link_mode_req {
554 struct mbox_msghdr hdr;
555 struct cgx_set_link_mode_args args;
558 struct cgx_set_link_mode_rsp {
559 struct mbox_msghdr hdr;
560 int __otx2_io status;
562 /* NPA mbox message formats */
564 /* NPA mailbox error codes
568 NPA_AF_ERR_PARAM = -301,
569 NPA_AF_ERR_AQ_FULL = -302,
570 NPA_AF_ERR_AQ_ENQUEUE = -303,
571 NPA_AF_ERR_AF_LF_INVALID = -304,
572 NPA_AF_ERR_AF_LF_ALLOC = -305,
573 NPA_AF_ERR_LF_RESET = -306,
576 #define NPA_AURA_SZ_0 0
577 #define NPA_AURA_SZ_128 1
578 #define NPA_AURA_SZ_256 2
579 #define NPA_AURA_SZ_512 3
580 #define NPA_AURA_SZ_1K 4
581 #define NPA_AURA_SZ_2K 5
582 #define NPA_AURA_SZ_4K 6
583 #define NPA_AURA_SZ_8K 7
584 #define NPA_AURA_SZ_16K 8
585 #define NPA_AURA_SZ_32K 9
586 #define NPA_AURA_SZ_64K 10
587 #define NPA_AURA_SZ_128K 11
588 #define NPA_AURA_SZ_256K 12
589 #define NPA_AURA_SZ_512K 13
590 #define NPA_AURA_SZ_1M 14
591 #define NPA_AURA_SZ_MAX 15
593 /* For NPA LF context alloc and init */
594 struct npa_lf_alloc_req {
595 struct mbox_msghdr hdr;
597 int __otx2_io aura_sz; /* No of auras. See NPA_AURA_SZ_* */
598 uint32_t __otx2_io nr_pools; /* No of pools */
599 uint64_t __otx2_io way_mask;
602 struct npa_lf_alloc_rsp {
603 struct mbox_msghdr hdr;
604 uint32_t __otx2_io stack_pg_ptrs; /* No of ptrs per stack page */
605 uint32_t __otx2_io stack_pg_bytes; /* Size of stack page */
606 uint16_t __otx2_io qints; /* NPA_AF_CONST::QINTS */
609 /* NPA AQ enqueue msg */
610 struct npa_aq_enq_req {
611 struct mbox_msghdr hdr;
612 uint32_t __otx2_io aura_id;
613 uint8_t __otx2_io ctype;
614 uint8_t __otx2_io op;
616 /* Valid when op == WRITE/INIT and ctype == AURA.
617 * LF fills the pool_id in aura.pool_addr. AF will translate
618 * the pool_id to pool context pointer.
620 __otx2_io struct npa_aura_s aura;
621 /* Valid when op == WRITE/INIT and ctype == POOL */
622 __otx2_io struct npa_pool_s pool;
624 /* Mask data when op == WRITE (1=write, 0=don't write) */
626 /* Valid when op == WRITE and ctype == AURA */
627 __otx2_io struct npa_aura_s aura_mask;
628 /* Valid when op == WRITE and ctype == POOL */
629 __otx2_io struct npa_pool_s pool_mask;
633 struct npa_aq_enq_rsp {
634 struct mbox_msghdr hdr;
636 /* Valid when op == READ and ctype == AURA */
637 __otx2_io struct npa_aura_s aura;
638 /* Valid when op == READ and ctype == POOL */
639 __otx2_io struct npa_pool_s pool;
643 /* Disable all contexts of type 'ctype' */
644 struct hwctx_disable_req {
645 struct mbox_msghdr hdr;
646 uint8_t __otx2_io ctype;
649 /* NIX mbox message formats */
651 /* NIX mailbox error codes
655 NIX_AF_ERR_PARAM = -401,
656 NIX_AF_ERR_AQ_FULL = -402,
657 NIX_AF_ERR_AQ_ENQUEUE = -403,
658 NIX_AF_ERR_AF_LF_INVALID = -404,
659 NIX_AF_ERR_AF_LF_ALLOC = -405,
660 NIX_AF_ERR_TLX_ALLOC_FAIL = -406,
661 NIX_AF_ERR_TLX_INVALID = -407,
662 NIX_AF_ERR_RSS_SIZE_INVALID = -408,
663 NIX_AF_ERR_RSS_GRPS_INVALID = -409,
664 NIX_AF_ERR_FRS_INVALID = -410,
665 NIX_AF_ERR_RX_LINK_INVALID = -411,
666 NIX_AF_INVAL_TXSCHQ_CFG = -412,
667 NIX_AF_SMQ_FLUSH_FAILED = -413,
668 NIX_AF_ERR_LF_RESET = -414,
669 NIX_AF_ERR_RSS_NOSPC_FIELD = -415,
670 NIX_AF_ERR_RSS_NOSPC_ALGO = -416,
671 NIX_AF_ERR_MARK_CFG_FAIL = -417,
672 NIX_AF_ERR_LSO_CFG_FAIL = -418,
673 NIX_AF_INVAL_NPA_PF_FUNC = -419,
674 NIX_AF_INVAL_SSO_PF_FUNC = -420,
675 NIX_AF_ERR_TX_VTAG_NOSPC = -421,
678 /* For NIX LF context alloc and init */
679 struct nix_lf_alloc_req {
680 struct mbox_msghdr hdr;
682 uint32_t __otx2_io rq_cnt; /* No of receive queues */
683 uint32_t __otx2_io sq_cnt; /* No of send queues */
684 uint32_t __otx2_io cq_cnt; /* No of completion queues */
685 uint8_t __otx2_io xqe_sz;
686 uint16_t __otx2_io rss_sz;
687 uint8_t __otx2_io rss_grps;
688 uint16_t __otx2_io npa_func;
689 /* RVU_DEFAULT_PF_FUNC == default pf_func associated with lf */
690 uint16_t __otx2_io sso_func;
691 uint64_t __otx2_io rx_cfg; /* See NIX_AF_LF(0..127)_RX_CFG */
692 uint64_t __otx2_io way_mask;
695 struct nix_lf_alloc_rsp {
696 struct mbox_msghdr hdr;
697 uint16_t __otx2_io sqb_size;
698 uint16_t __otx2_io rx_chan_base;
699 uint16_t __otx2_io tx_chan_base;
700 uint8_t __otx2_io rx_chan_cnt; /* Total number of RX channels */
701 uint8_t __otx2_io tx_chan_cnt; /* Total number of TX channels */
702 uint8_t __otx2_io lso_tsov4_idx;
703 uint8_t __otx2_io lso_tsov6_idx;
704 uint8_t __otx2_io mac_addr[RTE_ETHER_ADDR_LEN];
705 uint8_t __otx2_io lf_rx_stats; /* NIX_AF_CONST1::LF_RX_STATS */
706 uint8_t __otx2_io lf_tx_stats; /* NIX_AF_CONST1::LF_TX_STATS */
707 uint16_t __otx2_io cints; /* NIX_AF_CONST2::CINTS */
708 uint16_t __otx2_io qints; /* NIX_AF_CONST2::QINTS */
711 struct nix_lf_free_req {
712 struct mbox_msghdr hdr;
713 #define NIX_LF_DISABLE_FLOWS 0x1
714 uint64_t __otx2_io flags;
717 /* NIX AQ enqueue msg */
718 struct nix_aq_enq_req {
719 struct mbox_msghdr hdr;
720 uint32_t __otx2_io qidx;
721 uint8_t __otx2_io ctype;
722 uint8_t __otx2_io op;
724 /* Valid when op == WRITE/INIT and ctype == NIX_AQ_CTYPE_RQ */
725 __otx2_io struct nix_rq_ctx_s rq;
726 /* Valid when op == WRITE/INIT and ctype == NIX_AQ_CTYPE_SQ */
727 __otx2_io struct nix_sq_ctx_s sq;
728 /* Valid when op == WRITE/INIT and ctype == NIX_AQ_CTYPE_CQ */
729 __otx2_io struct nix_cq_ctx_s cq;
730 /* Valid when op == WRITE/INIT and ctype == NIX_AQ_CTYPE_RSS */
731 __otx2_io struct nix_rsse_s rss;
732 /* Valid when op == WRITE/INIT and ctype == NIX_AQ_CTYPE_MCE */
733 __otx2_io struct nix_rx_mce_s mce;
735 /* Mask data when op == WRITE (1=write, 0=don't write) */
737 /* Valid when op == WRITE and ctype == NIX_AQ_CTYPE_RQ */
738 __otx2_io struct nix_rq_ctx_s rq_mask;
739 /* Valid when op == WRITE and ctype == NIX_AQ_CTYPE_SQ */
740 __otx2_io struct nix_sq_ctx_s sq_mask;
741 /* Valid when op == WRITE and ctype == NIX_AQ_CTYPE_CQ */
742 __otx2_io struct nix_cq_ctx_s cq_mask;
743 /* Valid when op == WRITE and ctype == NIX_AQ_CTYPE_RSS */
744 __otx2_io struct nix_rsse_s rss_mask;
745 /* Valid when op == WRITE and ctype == NIX_AQ_CTYPE_MCE */
746 __otx2_io struct nix_rx_mce_s mce_mask;
750 struct nix_aq_enq_rsp {
751 struct mbox_msghdr hdr;
753 __otx2_io struct nix_rq_ctx_s rq;
754 __otx2_io struct nix_sq_ctx_s sq;
755 __otx2_io struct nix_cq_ctx_s cq;
756 __otx2_io struct nix_rsse_s rss;
757 __otx2_io struct nix_rx_mce_s mce;
761 /* Tx scheduler/shaper mailbox messages */
763 #define MAX_TXSCHQ_PER_FUNC 128
765 struct nix_txsch_alloc_req {
766 struct mbox_msghdr hdr;
767 /* Scheduler queue count request at each level */
768 uint16_t __otx2_io schq_contig[NIX_TXSCH_LVL_CNT]; /* Contig. queues */
769 uint16_t __otx2_io schq[NIX_TXSCH_LVL_CNT]; /* Non-Contig. queues */
772 struct nix_txsch_alloc_rsp {
773 struct mbox_msghdr hdr;
774 /* Scheduler queue count allocated at each level */
775 uint16_t __otx2_io schq_contig[NIX_TXSCH_LVL_CNT]; /* Contig. queues */
776 uint16_t __otx2_io schq[NIX_TXSCH_LVL_CNT]; /* Non-Contig. queues */
777 /* Scheduler queue list allocated at each level */
779 schq_contig_list[NIX_TXSCH_LVL_CNT][MAX_TXSCHQ_PER_FUNC];
780 uint16_t __otx2_io schq_list[NIX_TXSCH_LVL_CNT][MAX_TXSCHQ_PER_FUNC];
781 /* Traffic aggregation scheduler level */
782 uint8_t __otx2_io aggr_level;
783 /* Aggregation lvl's RR_PRIO config */
784 uint8_t __otx2_io aggr_lvl_rr_prio;
785 /* LINKX_CFG CSRs mapped to TL3 or TL2's index ? */
786 uint8_t __otx2_io link_cfg_lvl;
789 struct nix_txsch_free_req {
790 struct mbox_msghdr hdr;
791 #define TXSCHQ_FREE_ALL BIT_ULL(0)
792 uint16_t __otx2_io flags;
793 /* Scheduler queue level to be freed */
794 uint16_t __otx2_io schq_lvl;
795 /* List of scheduler queues to be freed */
796 uint16_t __otx2_io schq;
799 struct nix_txschq_config {
800 struct mbox_msghdr hdr;
801 uint8_t __otx2_io lvl; /* SMQ/MDQ/TL4/TL3/TL2/TL1 */
802 #define TXSCHQ_IDX_SHIFT 16
803 #define TXSCHQ_IDX_MASK (BIT_ULL(10) - 1)
804 #define TXSCHQ_IDX(reg, shift) (((reg) >> (shift)) & TXSCHQ_IDX_MASK)
805 uint8_t __otx2_io num_regs;
806 #define MAX_REGS_PER_MBOX_MSG 20
807 uint64_t __otx2_io reg[MAX_REGS_PER_MBOX_MSG];
808 uint64_t __otx2_io regval[MAX_REGS_PER_MBOX_MSG];
811 struct nix_vtag_config {
812 struct mbox_msghdr hdr;
813 /* '0' for 4 octet VTAG, '1' for 8 octet VTAG */
814 uint8_t __otx2_io vtag_size;
815 /* cfg_type is '0' for tx vlan cfg
816 * cfg_type is '1' for rx vlan cfg
818 uint8_t __otx2_io cfg_type;
820 /* Valid when cfg_type is '0' */
822 uint64_t __otx2_io vtag0;
823 uint64_t __otx2_io vtag1;
825 /* cfg_vtag0 & cfg_vtag1 fields are valid
826 * when free_vtag0 & free_vtag1 are '0's.
828 /* cfg_vtag0 = 1 to configure vtag0 */
829 uint8_t __otx2_io cfg_vtag0 :1;
830 /* cfg_vtag1 = 1 to configure vtag1 */
831 uint8_t __otx2_io cfg_vtag1 :1;
833 /* vtag0_idx & vtag1_idx are only valid when
834 * both cfg_vtag0 & cfg_vtag1 are '0's,
835 * these fields are used along with free_vtag0
836 * & free_vtag1 to free the nix lf's tx_vlan
839 * Denotes the indices of tx_vtag def registers
840 * that needs to be cleared and freed.
842 int __otx2_io vtag0_idx;
843 int __otx2_io vtag1_idx;
845 /* Free_vtag0 & free_vtag1 fields are valid
846 * when cfg_vtag0 & cfg_vtag1 are '0's.
848 /* Free_vtag0 = 1 clears vtag0 configuration
849 * vtag0_idx denotes the index to be cleared.
851 uint8_t __otx2_io free_vtag0 :1;
852 /* Free_vtag1 = 1 clears vtag1 configuration
853 * vtag1_idx denotes the index to be cleared.
855 uint8_t __otx2_io free_vtag1 :1;
858 /* Valid when cfg_type is '1' */
860 /* Rx vtag type index, valid values are in 0..7 range */
861 uint8_t __otx2_io vtag_type;
863 uint8_t __otx2_io strip_vtag :1;
864 /* Rx vtag capture */
865 uint8_t __otx2_io capture_vtag :1;
870 struct nix_vtag_config_rsp {
871 struct mbox_msghdr hdr;
872 /* Indices of tx_vtag def registers used to configure
873 * tx vtag0 & vtag1 headers, these indices are valid
874 * when nix_vtag_config mbox requested for vtag0 and/
875 * or vtag1 configuration.
877 int __otx2_io vtag0_idx;
878 int __otx2_io vtag1_idx;
881 struct nix_rss_flowkey_cfg {
882 struct mbox_msghdr hdr;
883 int __otx2_io mcam_index; /* MCAM entry index to modify */
884 uint32_t __otx2_io flowkey_cfg; /* Flowkey types selected */
885 #define FLOW_KEY_TYPE_PORT BIT(0)
886 #define FLOW_KEY_TYPE_IPV4 BIT(1)
887 #define FLOW_KEY_TYPE_IPV6 BIT(2)
888 #define FLOW_KEY_TYPE_TCP BIT(3)
889 #define FLOW_KEY_TYPE_UDP BIT(4)
890 #define FLOW_KEY_TYPE_SCTP BIT(5)
891 #define FLOW_KEY_TYPE_NVGRE BIT(6)
892 #define FLOW_KEY_TYPE_VXLAN BIT(7)
893 #define FLOW_KEY_TYPE_GENEVE BIT(8)
894 #define FLOW_KEY_TYPE_ETH_DMAC BIT(9)
895 #define FLOW_KEY_TYPE_IPV6_EXT BIT(10)
896 #define FLOW_KEY_TYPE_GTPU BIT(11)
897 #define FLOW_KEY_TYPE_INNR_IPV4 BIT(12)
898 #define FLOW_KEY_TYPE_INNR_IPV6 BIT(13)
899 #define FLOW_KEY_TYPE_INNR_TCP BIT(14)
900 #define FLOW_KEY_TYPE_INNR_UDP BIT(15)
901 #define FLOW_KEY_TYPE_INNR_SCTP BIT(16)
902 #define FLOW_KEY_TYPE_INNR_ETH_DMAC BIT(17)
903 uint8_t group; /* RSS context or group */
906 struct nix_rss_flowkey_cfg_rsp {
907 struct mbox_msghdr hdr;
908 uint8_t __otx2_io alg_idx; /* Selected algo index */
911 struct nix_set_mac_addr {
912 struct mbox_msghdr hdr;
913 uint8_t __otx2_io mac_addr[RTE_ETHER_ADDR_LEN];
916 struct nix_get_mac_addr_rsp {
917 struct mbox_msghdr hdr;
918 uint8_t __otx2_io mac_addr[RTE_ETHER_ADDR_LEN];
921 struct nix_mark_format_cfg {
922 struct mbox_msghdr hdr;
923 uint8_t __otx2_io offset;
924 uint8_t __otx2_io y_mask;
925 uint8_t __otx2_io y_val;
926 uint8_t __otx2_io r_mask;
927 uint8_t __otx2_io r_val;
930 struct nix_mark_format_cfg_rsp {
931 struct mbox_msghdr hdr;
932 uint8_t __otx2_io mark_format_idx;
935 struct nix_lso_format_cfg {
936 struct mbox_msghdr hdr;
937 uint64_t __otx2_io field_mask;
938 uint64_t __otx2_io fields[NIX_LSO_FIELD_MAX];
941 struct nix_lso_format_cfg_rsp {
942 struct mbox_msghdr hdr;
943 uint8_t __otx2_io lso_format_idx;
947 struct mbox_msghdr hdr;
948 #define NIX_RX_MODE_UCAST BIT(0)
949 #define NIX_RX_MODE_PROMISC BIT(1)
950 #define NIX_RX_MODE_ALLMULTI BIT(2)
951 uint16_t __otx2_io mode;
955 struct mbox_msghdr hdr;
956 #define NIX_RX_OL3_VERIFY BIT(0)
957 #define NIX_RX_OL4_VERIFY BIT(1)
958 uint8_t __otx2_io len_verify; /* Outer L3/L4 len check */
959 #define NIX_RX_CSUM_OL4_VERIFY BIT(0)
960 uint8_t __otx2_io csum_verify; /* Outer L4 checksum verification */
964 struct mbox_msghdr hdr;
965 uint8_t __otx2_io update_smq; /* Update SMQ's min/max lens */
966 uint8_t __otx2_io update_minlen; /* Set minlen also */
967 uint8_t __otx2_io sdp_link; /* Set SDP RX link */
968 uint16_t __otx2_io maxlen;
969 uint16_t __otx2_io minlen;
972 struct nix_set_vlan_tpid {
973 struct mbox_msghdr hdr;
974 #define NIX_VLAN_TYPE_INNER 0
975 #define NIX_VLAN_TYPE_OUTER 1
976 uint8_t __otx2_io vlan_type;
977 uint16_t __otx2_io tpid;
980 struct nix_bp_cfg_req {
981 struct mbox_msghdr hdr;
982 uint16_t __otx2_io chan_base; /* Starting channel number */
983 uint8_t __otx2_io chan_cnt; /* Number of channels */
984 uint8_t __otx2_io bpid_per_chan;
985 /* bpid_per_chan = 0 assigns single bp id for range of channels */
986 /* bpid_per_chan = 1 assigns separate bp id for each channel */
989 /* PF can be mapped to either CGX or LBK interface,
990 * so maximum 64 channels are possible.
992 #define NIX_MAX_CHAN 64
993 struct nix_bp_cfg_rsp {
994 struct mbox_msghdr hdr;
995 /* Channel and bpid mapping */
996 uint16_t __otx2_io chan_bpid[NIX_MAX_CHAN];
997 /* Number of channel for which bpids are assigned */
998 uint8_t __otx2_io chan_cnt;
1001 /* Global NIX inline IPSec configuration */
1002 struct nix_inline_ipsec_cfg {
1003 struct mbox_msghdr hdr;
1004 uint32_t __otx2_io cpt_credit;
1006 uint8_t __otx2_io egrp;
1007 uint8_t __otx2_io opcode;
1010 uint16_t __otx2_io cpt_pf_func;
1011 uint8_t __otx2_io cpt_slot;
1013 uint8_t __otx2_io enable;
1016 /* Per NIX LF inline IPSec configuration */
1017 struct nix_inline_ipsec_lf_cfg {
1018 struct mbox_msghdr hdr;
1019 uint64_t __otx2_io sa_base_addr;
1021 uint32_t __otx2_io tag_const;
1022 uint16_t __otx2_io lenm1_max;
1023 uint8_t __otx2_io sa_pow2_size;
1024 uint8_t __otx2_io tt;
1027 uint32_t __otx2_io sa_idx_max;
1028 uint8_t __otx2_io sa_idx_w;
1030 uint8_t __otx2_io enable;
1033 /* SSO mailbox error codes
1036 enum sso_af_status {
1037 SSO_AF_ERR_PARAM = -501,
1038 SSO_AF_ERR_LF_INVALID = -502,
1039 SSO_AF_ERR_AF_LF_ALLOC = -503,
1040 SSO_AF_ERR_GRP_EBUSY = -504,
1041 SSO_AF_INVAL_NPA_PF_FUNC = -505,
1044 struct sso_lf_alloc_req {
1045 struct mbox_msghdr hdr;
1047 uint16_t __otx2_io hwgrps;
1050 struct sso_lf_alloc_rsp {
1051 struct mbox_msghdr hdr;
1052 uint32_t __otx2_io xaq_buf_size;
1053 uint32_t __otx2_io xaq_wq_entries;
1054 uint32_t __otx2_io in_unit_entries;
1055 uint16_t __otx2_io hwgrps;
1058 struct sso_lf_free_req {
1059 struct mbox_msghdr hdr;
1061 uint16_t __otx2_io hwgrps;
1064 /* SSOW mailbox error codes
1067 enum ssow_af_status {
1068 SSOW_AF_ERR_PARAM = -601,
1069 SSOW_AF_ERR_LF_INVALID = -602,
1070 SSOW_AF_ERR_AF_LF_ALLOC = -603,
1073 struct ssow_lf_alloc_req {
1074 struct mbox_msghdr hdr;
1076 uint16_t __otx2_io hws;
1079 struct ssow_lf_free_req {
1080 struct mbox_msghdr hdr;
1082 uint16_t __otx2_io hws;
1085 struct sso_hw_setconfig {
1086 struct mbox_msghdr hdr;
1087 uint32_t __otx2_io npa_aura_id;
1088 uint16_t __otx2_io npa_pf_func;
1089 uint16_t __otx2_io hwgrps;
1092 struct sso_info_req {
1093 struct mbox_msghdr hdr;
1095 uint16_t __otx2_io grp;
1096 uint16_t __otx2_io hws;
1100 struct sso_grp_priority {
1101 struct mbox_msghdr hdr;
1102 uint16_t __otx2_io grp;
1103 uint8_t __otx2_io priority;
1104 uint8_t __otx2_io affinity;
1105 uint8_t __otx2_io weight;
1108 struct sso_grp_qos_cfg {
1109 struct mbox_msghdr hdr;
1110 uint16_t __otx2_io grp;
1111 uint32_t __otx2_io xaq_limit;
1112 uint16_t __otx2_io taq_thr;
1113 uint16_t __otx2_io iaq_thr;
1116 struct sso_grp_stats {
1117 struct mbox_msghdr hdr;
1118 uint16_t __otx2_io grp;
1119 uint64_t __otx2_io ws_pc;
1120 uint64_t __otx2_io ext_pc;
1121 uint64_t __otx2_io wa_pc;
1122 uint64_t __otx2_io ts_pc;
1123 uint64_t __otx2_io ds_pc;
1124 uint64_t __otx2_io dq_pc;
1125 uint64_t __otx2_io aw_status;
1126 uint64_t __otx2_io page_cnt;
1129 struct sso_hws_stats {
1130 struct mbox_msghdr hdr;
1131 uint16_t __otx2_io hws;
1132 uint64_t __otx2_io arbitration;
1135 /* CPT mailbox error codes
1138 enum cpt_af_status {
1139 CPT_AF_ERR_PARAM = -901,
1140 CPT_AF_ERR_GRP_INVALID = -902,
1141 CPT_AF_ERR_LF_INVALID = -903,
1142 CPT_AF_ERR_ACCESS_DENIED = -904,
1143 CPT_AF_ERR_SSO_PF_FUNC_INVALID = -905,
1144 CPT_AF_ERR_NIX_PF_FUNC_INVALID = -906,
1145 CPT_AF_ERR_INLINE_IPSEC_INB_ENA = -907,
1146 CPT_AF_ERR_INLINE_IPSEC_OUT_ENA = -908
1149 /* CPT mbox message formats */
1151 struct cpt_rd_wr_reg_msg {
1152 struct mbox_msghdr hdr;
1153 uint64_t __otx2_io reg_offset;
1154 uint64_t __otx2_io *ret_val;
1155 uint64_t __otx2_io val;
1156 uint8_t __otx2_io is_write;
1159 struct cpt_set_crypto_grp_req_msg {
1160 struct mbox_msghdr hdr;
1161 uint8_t __otx2_io crypto_eng_grp;
1164 struct cpt_lf_alloc_req_msg {
1165 struct mbox_msghdr hdr;
1166 uint16_t __otx2_io nix_pf_func;
1167 uint16_t __otx2_io sso_pf_func;
1170 struct cpt_lf_alloc_rsp_msg {
1171 struct mbox_msghdr hdr;
1172 uint8_t __otx2_io crypto_eng_grp;
1175 #define CPT_INLINE_INBOUND 0
1176 #define CPT_INLINE_OUTBOUND 1
1178 struct cpt_inline_ipsec_cfg_msg {
1179 struct mbox_msghdr hdr;
1180 uint8_t __otx2_io enable;
1181 uint8_t __otx2_io slot;
1182 uint8_t __otx2_io dir;
1183 uint16_t __otx2_io sso_pf_func; /* Inbound path SSO_PF_FUNC */
1184 uint16_t __otx2_io nix_pf_func; /* Outbound path NIX_PF_FUNC */
1187 /* NPC mbox message structs */
1189 #define NPC_MCAM_ENTRY_INVALID 0xFFFF
1190 #define NPC_MCAM_INVALID_MAP 0xFFFF
1192 /* NPC mailbox error codes
1195 enum npc_af_status {
1196 NPC_MCAM_INVALID_REQ = -701,
1197 NPC_MCAM_ALLOC_DENIED = -702,
1198 NPC_MCAM_ALLOC_FAILED = -703,
1199 NPC_MCAM_PERM_DENIED = -704,
1202 struct npc_mcam_alloc_entry_req {
1203 struct mbox_msghdr hdr;
1204 #define NPC_MAX_NONCONTIG_ENTRIES 256
1205 uint8_t __otx2_io contig; /* Contiguous entries ? */
1206 #define NPC_MCAM_ANY_PRIO 0
1207 #define NPC_MCAM_LOWER_PRIO 1
1208 #define NPC_MCAM_HIGHER_PRIO 2
1209 uint8_t __otx2_io priority; /* Lower or higher w.r.t ref_entry */
1210 uint16_t __otx2_io ref_entry;
1211 uint16_t __otx2_io count; /* Number of entries requested */
1214 struct npc_mcam_alloc_entry_rsp {
1215 struct mbox_msghdr hdr;
1216 /* Entry alloc'ed or start index if contiguous.
1217 * Invalid in case of non-contiguous.
1219 uint16_t __otx2_io entry;
1220 uint16_t __otx2_io count; /* Number of entries allocated */
1221 uint16_t __otx2_io free_count; /* Number of entries available */
1222 uint16_t __otx2_io entry_list[NPC_MAX_NONCONTIG_ENTRIES];
1225 struct npc_mcam_free_entry_req {
1226 struct mbox_msghdr hdr;
1227 uint16_t __otx2_io entry; /* Entry index to be freed */
1228 uint8_t __otx2_io all; /* Free all entries alloc'ed to this PFVF */
1232 #define NPC_MAX_KWS_IN_KEY 7 /* Number of keywords in max key width */
1233 uint64_t __otx2_io kw[NPC_MAX_KWS_IN_KEY];
1234 uint64_t __otx2_io kw_mask[NPC_MAX_KWS_IN_KEY];
1235 uint64_t __otx2_io action;
1236 uint64_t __otx2_io vtag_action;
1239 struct npc_mcam_write_entry_req {
1240 struct mbox_msghdr hdr;
1241 struct mcam_entry entry_data;
1242 uint16_t __otx2_io entry; /* MCAM entry to write this match key */
1243 uint16_t __otx2_io cntr; /* Counter for this MCAM entry */
1244 uint8_t __otx2_io intf; /* Rx or Tx interface */
1245 uint8_t __otx2_io enable_entry;/* Enable this MCAM entry ? */
1246 uint8_t __otx2_io set_cntr; /* Set counter for this entry ? */
1249 /* Enable/Disable a given entry */
1250 struct npc_mcam_ena_dis_entry_req {
1251 struct mbox_msghdr hdr;
1252 uint16_t __otx2_io entry;
1255 struct npc_mcam_shift_entry_req {
1256 struct mbox_msghdr hdr;
1257 #define NPC_MCAM_MAX_SHIFTS 64
1258 uint16_t __otx2_io curr_entry[NPC_MCAM_MAX_SHIFTS];
1259 uint16_t __otx2_io new_entry[NPC_MCAM_MAX_SHIFTS];
1260 uint16_t __otx2_io shift_count; /* Number of entries to shift */
1263 struct npc_mcam_shift_entry_rsp {
1264 struct mbox_msghdr hdr;
1265 /* Index in 'curr_entry', not entry itself */
1266 uint16_t __otx2_io failed_entry_idx;
1269 struct npc_mcam_alloc_counter_req {
1270 struct mbox_msghdr hdr;
1271 uint8_t __otx2_io contig; /* Contiguous counters ? */
1272 #define NPC_MAX_NONCONTIG_COUNTERS 64
1273 uint16_t __otx2_io count; /* Number of counters requested */
1276 struct npc_mcam_alloc_counter_rsp {
1277 struct mbox_msghdr hdr;
1278 /* Counter alloc'ed or start idx if contiguous.
1279 * Invalid incase of non-contiguous.
1281 uint16_t __otx2_io cntr;
1282 uint16_t __otx2_io count; /* Number of counters allocated */
1283 uint16_t __otx2_io cntr_list[NPC_MAX_NONCONTIG_COUNTERS];
1286 struct npc_mcam_oper_counter_req {
1287 struct mbox_msghdr hdr;
1288 uint16_t __otx2_io cntr; /* Free a counter or clear/fetch it's stats */
1291 struct npc_mcam_oper_counter_rsp {
1292 struct mbox_msghdr hdr;
1293 /* valid only while fetching counter's stats */
1294 uint64_t __otx2_io stat;
1297 struct npc_mcam_unmap_counter_req {
1298 struct mbox_msghdr hdr;
1299 uint16_t __otx2_io cntr;
1300 uint16_t __otx2_io entry; /* Entry and counter to be unmapped */
1301 uint8_t __otx2_io all; /* Unmap all entries using this counter ? */
1304 struct npc_mcam_alloc_and_write_entry_req {
1305 struct mbox_msghdr hdr;
1306 struct mcam_entry entry_data;
1307 uint16_t __otx2_io ref_entry;
1308 uint8_t __otx2_io priority; /* Lower or higher w.r.t ref_entry */
1309 uint8_t __otx2_io intf; /* Rx or Tx interface */
1310 uint8_t __otx2_io enable_entry;/* Enable this MCAM entry ? */
1311 uint8_t __otx2_io alloc_cntr; /* Allocate counter and map ? */
1314 struct npc_mcam_alloc_and_write_entry_rsp {
1315 struct mbox_msghdr hdr;
1316 uint16_t __otx2_io entry;
1317 uint16_t __otx2_io cntr;
1320 struct npc_get_kex_cfg_rsp {
1321 struct mbox_msghdr hdr;
1322 uint64_t __otx2_io rx_keyx_cfg; /* NPC_AF_INTF(0)_KEX_CFG */
1323 uint64_t __otx2_io tx_keyx_cfg; /* NPC_AF_INTF(1)_KEX_CFG */
1324 #define NPC_MAX_INTF 2
1325 #define NPC_MAX_LID 8
1326 #define NPC_MAX_LT 16
1327 #define NPC_MAX_LD 2
1328 #define NPC_MAX_LFL 16
1329 /* NPC_AF_KEX_LDATA(0..1)_FLAGS_CFG */
1330 uint64_t __otx2_io kex_ld_flags[NPC_MAX_LD];
1331 /* NPC_AF_INTF(0..1)_LID(0..7)_LT(0..15)_LD(0..1)_CFG */
1333 intf_lid_lt_ld[NPC_MAX_INTF][NPC_MAX_LID][NPC_MAX_LT][NPC_MAX_LD];
1334 /* NPC_AF_INTF(0..1)_LDATA(0..1)_FLAGS(0..15)_CFG */
1336 intf_ld_flags[NPC_MAX_INTF][NPC_MAX_LD][NPC_MAX_LFL];
1337 #define MKEX_NAME_LEN 128
1338 uint8_t __otx2_io mkex_pfl_name[MKEX_NAME_LEN];
1341 enum header_fields {
1355 NPC_HEADER_FIELDS_MAX,
1359 unsigned char __otx2_io dmac[6];
1360 unsigned char __otx2_io smac[6];
1361 uint16_t __otx2_io etype;
1362 uint16_t __otx2_io vlan_etype;
1363 uint16_t __otx2_io vlan_tci;
1365 uint32_t __otx2_io ip4src;
1366 uint32_t __otx2_io ip6src[4];
1369 uint32_t __otx2_io ip4dst;
1370 uint32_t __otx2_io ip6dst[4];
1372 uint8_t __otx2_io tos;
1373 uint8_t __otx2_io ip_ver;
1374 uint8_t __otx2_io ip_proto;
1375 uint8_t __otx2_io tc;
1376 uint16_t __otx2_io sport;
1377 uint16_t __otx2_io dport;
1380 struct npc_install_flow_req {
1381 struct mbox_msghdr hdr;
1382 struct flow_msg packet;
1383 struct flow_msg mask;
1384 uint64_t __otx2_io features;
1385 uint16_t __otx2_io entry;
1386 uint16_t __otx2_io channel;
1387 uint8_t __otx2_io intf;
1388 uint8_t __otx2_io set_cntr;
1389 uint8_t __otx2_io default_rule;
1390 /* Overwrite(0) or append(1) flow to default rule? */
1391 uint8_t __otx2_io append;
1392 uint16_t __otx2_io vf;
1394 uint32_t __otx2_io index;
1395 uint16_t __otx2_io match_id;
1396 uint8_t __otx2_io flow_key_alg;
1397 uint8_t __otx2_io op;
1399 uint8_t __otx2_io vtag0_type;
1400 uint8_t __otx2_io vtag0_valid;
1401 uint8_t __otx2_io vtag1_type;
1402 uint8_t __otx2_io vtag1_valid;
1404 /* vtag tx action */
1405 uint16_t __otx2_io vtag0_def;
1406 uint8_t __otx2_io vtag0_op;
1407 uint16_t __otx2_io vtag1_def;
1408 uint8_t __otx2_io vtag1_op;
1411 struct npc_install_flow_rsp {
1412 struct mbox_msghdr hdr;
1413 /* Negative if no counter else counter number */
1414 int __otx2_io counter;
1417 struct npc_delete_flow_req {
1418 struct mbox_msghdr hdr;
1419 uint16_t __otx2_io entry;
1420 uint16_t __otx2_io start;/*Disable range of entries */
1421 uint16_t __otx2_io end;
1422 uint8_t __otx2_io all; /* PF + VFs */
1425 struct npc_mcam_read_entry_req {
1426 struct mbox_msghdr hdr;
1427 /* MCAM entry to read */
1428 uint16_t __otx2_io entry;
1431 struct npc_mcam_read_entry_rsp {
1432 struct mbox_msghdr hdr;
1433 struct mcam_entry entry_data;
1434 uint8_t __otx2_io intf;
1435 uint8_t __otx2_io enable;
1438 /* TIM mailbox error codes
1441 enum tim_af_status {
1442 TIM_AF_NO_RINGS_LEFT = -801,
1443 TIM_AF_INVALID_NPA_PF_FUNC = -802,
1444 TIM_AF_INVALID_SSO_PF_FUNC = -803,
1445 TIM_AF_RING_STILL_RUNNING = -804,
1446 TIM_AF_LF_INVALID = -805,
1447 TIM_AF_CSIZE_NOT_ALIGNED = -806,
1448 TIM_AF_CSIZE_TOO_SMALL = -807,
1449 TIM_AF_CSIZE_TOO_BIG = -808,
1450 TIM_AF_INTERVAL_TOO_SMALL = -809,
1451 TIM_AF_INVALID_BIG_ENDIAN_VALUE = -810,
1452 TIM_AF_INVALID_CLOCK_SOURCE = -811,
1453 TIM_AF_GPIO_CLK_SRC_NOT_ENABLED = -812,
1454 TIM_AF_INVALID_BSIZE = -813,
1455 TIM_AF_INVALID_ENABLE_PERIODIC = -814,
1456 TIM_AF_INVALID_ENABLE_DONTFREE = -815,
1457 TIM_AF_ENA_DONTFRE_NSET_PERIODIC = -816,
1458 TIM_AF_RING_ALREADY_DISABLED = -817,
1462 TIM_CLK_SRCS_TENNS = 0,
1463 TIM_CLK_SRCS_GPIO = 1,
1464 TIM_CLK_SRCS_GTI = 2,
1465 TIM_CLK_SRCS_PTP = 3,
1466 TIM_CLK_SRSC_INVALID,
1469 enum tim_gpio_edge {
1470 TIM_GPIO_NO_EDGE = 0,
1471 TIM_GPIO_LTOH_TRANS = 1,
1472 TIM_GPIO_HTOL_TRANS = 2,
1473 TIM_GPIO_BOTH_TRANS = 3,
1478 PTP_OP_ADJFINE = 0, /* adjfine(req.scaled_ppm); */
1479 PTP_OP_GET_CLOCK = 1, /* rsp.clk = get_clock() */
1483 struct mbox_msghdr hdr;
1484 uint8_t __otx2_io op;
1485 int64_t __otx2_io scaled_ppm;
1486 uint8_t __otx2_io is_pmu;
1490 struct mbox_msghdr hdr;
1491 uint64_t __otx2_io clk;
1492 uint64_t __otx2_io tsc;
1495 struct get_hw_cap_rsp {
1496 struct mbox_msghdr hdr;
1497 /* Schq mapping fixed or flexible */
1498 uint8_t __otx2_io nix_fixed_txschq_mapping;
1499 uint8_t __otx2_io nix_shaping; /* Is shaping and coloring supported */
1502 struct ndc_sync_op {
1503 struct mbox_msghdr hdr;
1504 uint8_t __otx2_io nix_lf_tx_sync;
1505 uint8_t __otx2_io nix_lf_rx_sync;
1506 uint8_t __otx2_io npa_lf_sync;
1509 struct tim_lf_alloc_req {
1510 struct mbox_msghdr hdr;
1511 uint16_t __otx2_io ring;
1512 uint16_t __otx2_io npa_pf_func;
1513 uint16_t __otx2_io sso_pf_func;
1516 struct tim_ring_req {
1517 struct mbox_msghdr hdr;
1518 uint16_t __otx2_io ring;
1521 struct tim_config_req {
1522 struct mbox_msghdr hdr;
1523 uint16_t __otx2_io ring;
1524 uint8_t __otx2_io bigendian;
1525 uint8_t __otx2_io clocksource;
1526 uint8_t __otx2_io enableperiodic;
1527 uint8_t __otx2_io enabledontfreebuffer;
1528 uint32_t __otx2_io bucketsize;
1529 uint32_t __otx2_io chunksize;
1530 uint32_t __otx2_io interval;
1533 struct tim_lf_alloc_rsp {
1534 struct mbox_msghdr hdr;
1535 uint64_t __otx2_io tenns_clk;
1538 struct tim_enable_rsp {
1539 struct mbox_msghdr hdr;
1540 uint64_t __otx2_io timestarted;
1541 uint32_t __otx2_io currentbucket;
1544 const char *otx2_mbox_id2name(uint16_t id);
1545 int otx2_mbox_id2size(uint16_t id);
1546 void otx2_mbox_reset(struct otx2_mbox *mbox, int devid);
1547 int otx2_mbox_init(struct otx2_mbox *mbox, uintptr_t hwbase,
1548 uintptr_t reg_base, int direction, int ndevs);
1549 void otx2_mbox_fini(struct otx2_mbox *mbox);
1550 void otx2_mbox_msg_send(struct otx2_mbox *mbox, int devid);
1551 int otx2_mbox_wait_for_rsp(struct otx2_mbox *mbox, int devid);
1552 int otx2_mbox_wait_for_rsp_tmo(struct otx2_mbox *mbox, int devid, uint32_t tmo);
1553 int otx2_mbox_get_rsp(struct otx2_mbox *mbox, int devid, void **msg);
1554 int otx2_mbox_get_rsp_tmo(struct otx2_mbox *mbox, int devid, void **msg,
1556 int otx2_mbox_get_availmem(struct otx2_mbox *mbox, int devid);
1557 struct mbox_msghdr *otx2_mbox_alloc_msg_rsp(struct otx2_mbox *mbox, int devid,
1558 int size, int size_rsp);
1560 static inline struct mbox_msghdr *
1561 otx2_mbox_alloc_msg(struct otx2_mbox *mbox, int devid, int size)
1563 return otx2_mbox_alloc_msg_rsp(mbox, devid, size, 0);
1567 otx2_mbox_req_init(uint16_t mbox_id, void *msghdr)
1569 struct mbox_msghdr *hdr = msghdr;
1571 hdr->sig = OTX2_MBOX_REQ_SIG;
1572 hdr->ver = OTX2_MBOX_VERSION;
1578 otx2_mbox_rsp_init(uint16_t mbox_id, void *msghdr)
1580 struct mbox_msghdr *hdr = msghdr;
1582 hdr->sig = OTX2_MBOX_RSP_SIG;
1583 hdr->rc = -ETIMEDOUT;
1588 otx2_mbox_nonempty(struct otx2_mbox *mbox, int devid)
1590 struct otx2_mbox_dev *mdev = &mbox->dev[devid];
1593 rte_spinlock_lock(&mdev->mbox_lock);
1594 ret = mdev->num_msgs != 0;
1595 rte_spinlock_unlock(&mdev->mbox_lock);
1601 otx2_mbox_process(struct otx2_mbox *mbox)
1603 otx2_mbox_msg_send(mbox, 0);
1604 return otx2_mbox_get_rsp(mbox, 0, NULL);
1608 otx2_mbox_process_msg(struct otx2_mbox *mbox, void **msg)
1610 otx2_mbox_msg_send(mbox, 0);
1611 return otx2_mbox_get_rsp(mbox, 0, msg);
1615 otx2_mbox_process_tmo(struct otx2_mbox *mbox, uint32_t tmo)
1617 otx2_mbox_msg_send(mbox, 0);
1618 return otx2_mbox_get_rsp_tmo(mbox, 0, NULL, tmo);
1622 otx2_mbox_process_msg_tmo(struct otx2_mbox *mbox, void **msg, uint32_t tmo)
1624 otx2_mbox_msg_send(mbox, 0);
1625 return otx2_mbox_get_rsp_tmo(mbox, 0, msg, tmo);
1628 int otx2_send_ready_msg(struct otx2_mbox *mbox, uint16_t *pf_func /* out */);
1629 int otx2_reply_invalid_msg(struct otx2_mbox *mbox, int devid, uint16_t pf_func,
1632 #define M(_name, _id, _fn_name, _req_type, _rsp_type) \
1633 static inline struct _req_type \
1634 *otx2_mbox_alloc_msg_ ## _fn_name(struct otx2_mbox *mbox) \
1636 struct _req_type *req; \
1638 req = (struct _req_type *)otx2_mbox_alloc_msg_rsp( \
1639 mbox, 0, sizeof(struct _req_type), \
1640 sizeof(struct _rsp_type)); \
1644 req->hdr.sig = OTX2_MBOX_REQ_SIG; \
1645 req->hdr.id = _id; \
1646 otx2_mbox_dbg("id=0x%x (%s)", \
1647 req->hdr.id, otx2_mbox_id2name(req->hdr.id)); \
1654 /* This is required for copy operations from device memory which do not work on
1655 * addresses which are unaligned to 16B. This is because of specific
1656 * optimizations to libc memcpy.
1658 static inline volatile void *
1659 otx2_mbox_memcpy(volatile void *d, const volatile void *s, size_t l)
1661 const volatile uint8_t *sb;
1662 volatile uint8_t *db;
1667 db = (volatile uint8_t *)d;
1668 sb = (const volatile uint8_t *)s;
1669 for (i = 0; i < l; i++)
1674 /* This is required for memory operations from device memory which do not
1675 * work on addresses which are unaligned to 16B. This is because of specific
1676 * optimizations to libc memset.
1679 otx2_mbox_memset(volatile void *d, uint8_t val, size_t l)
1681 volatile uint8_t *db;
1686 db = (volatile uint8_t *)d;
1687 for (i = 0; i < l; i++)
1691 #endif /* __OTX2_MBOX_H__ */