Debian Codegraph @

drivers/net/ethernet/marvell/octeontx2/af/mbox.h

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Marvell RVU Admin Function driver
3 *
4 * Copyright (C) 2018 Marvell.
5 *
6 */
7
8 #ifndef MBOX_H
9 #define MBOX_H
10
11 #include <linux/etherdevice.h>
12 #include <linux/sizes.h>
13 #include <linux/ethtool.h>
14
15 #include "rvu_struct.h"
16 #include "common.h"
17 #include "cn20k/struct.h"
18
19 #define MBOX_SIZE SZ_64K
20
21 #define MBOX_DOWN_MSG 1
22 #define MBOX_UP_MSG 2
23
24 /* AF/PF: PF initiated, PF/VF VF initiated */
25 #define MBOX_DOWN_RX_START 0
26 #define MBOX_DOWN_RX_SIZE (46 * SZ_1K)
27 #define MBOX_DOWN_TX_START (MBOX_DOWN_RX_START + MBOX_DOWN_RX_SIZE)
28 #define MBOX_DOWN_TX_SIZE (16 * SZ_1K)
29 /* AF/PF: AF initiated, PF/VF PF initiated */
30 #define MBOX_UP_RX_START (MBOX_DOWN_TX_START + MBOX_DOWN_TX_SIZE)
31 #define MBOX_UP_RX_SIZE SZ_1K
32 #define MBOX_UP_TX_START (MBOX_UP_RX_START + MBOX_UP_RX_SIZE)
33 #define MBOX_UP_TX_SIZE SZ_1K
34
35 #if MBOX_UP_TX_SIZE + MBOX_UP_TX_START != MBOX_SIZE
36 # error "incorrect mailbox area sizes"
37 #endif
38
39 #define INTR_MASK(pfvfs) ((pfvfs < 64) ? (BIT_ULL(pfvfs) - 1) : (~0ull))
40
41 #define MBOX_RSP_TIMEOUT 6000 /* Time(ms) to wait for mbox response */
42
43 #define MBOX_MSG_ALIGN 16 /* Align mbox msg start to 16bytes */
44
45 /* Mailbox directions */
46 #define MBOX_DIR_AFPF 0 /* AF replies to PF */
47 #define MBOX_DIR_PFAF 1 /* PF sends messages to AF */
48 #define MBOX_DIR_PFVF 2 /* PF replies to VF */
49 #define MBOX_DIR_VFPF 3 /* VF sends messages to PF */
50 #define MBOX_DIR_AFPF_UP 4 /* AF sends messages to PF */
51 #define MBOX_DIR_PFAF_UP 5 /* PF replies to AF */
52 #define MBOX_DIR_PFVF_UP 6 /* PF sends messages to VF */
53 #define MBOX_DIR_VFPF_UP 7 /* VF replies to PF */
54
55 enum {
56 NPC_MCAM_KEY_X1 = 0,
57 NPC_MCAM_KEY_DYN = NPC_MCAM_KEY_X1,
58 NPC_MCAM_KEY_X2,
59 NPC_MCAM_KEY_X4,
60 NPC_MCAM_KEY_MAX,
61 };
62
63 enum {
64 TYPE_AFVF,
65 TYPE_AFPF,
66 };
67
68 struct otx2_mbox_dev {
69 void *mbase; /* This dev's mbox region */
70 void *hwbase;
71 spinlock_t mbox_lock;
72 u16 msg_size; /* Total msg size to be sent */
73 u16 rsp_size; /* Total rsp size to be sure the reply is ok */
74 u16 num_msgs; /* No of msgs sent or waiting for response */
75 u16 msgs_acked; /* No of msgs for which response is received */
76 };
77
78 struct otx2_mbox {
79 struct pci_dev *pdev;
80 void *hwbase; /* Mbox region advertised by HW */
81 void *reg_base;/* CSR base for this dev */
82 u64 trigger; /* Trigger mbox notification */
83 u16 tr_shift; /* Mbox trigger shift */
84 u64 rx_start; /* Offset of Rx region in mbox memory */
85 u64 tx_start; /* Offset of Tx region in mbox memory */
86 u16 rx_size; /* Size of Rx region */
87 u16 tx_size; /* Size of Tx region */
88 u16 ndevs; /* The number of peers */
89 struct otx2_mbox_dev *dev;
90 };
91
92 /* Header which precedes all mbox messages */
93 struct mbox_hdr {
94 u64 msg_size; /* Total msgs size embedded */
95 u16 num_msgs; /* No of msgs embedded */
96 u16 opt_msg;
97 u8 sig;
98 };
99
100 /* Header which precedes every msg and is also part of it */
101 struct mbox_msghdr {
102 u16 pcifunc; /* Who's sending this msg */
103 u16 id; /* Mbox message ID */
104 #define OTX2_MBOX_REQ_SIG (0xdead)
105 #define OTX2_MBOX_RSP_SIG (0xbeef)
106 u16 sig; /* Signature, for validating corrupted msgs */
107 #define OTX2_MBOX_VERSION (0x000a)
108 u16 ver; /* Version of msg's structure for this ID */
109 u16 next_msgoff; /* Offset of next msg within mailbox region */
110 int rc; /* Msg process'ed response code */
111 };
112
113 void otx2_mbox_reset(struct otx2_mbox *mbox, int devid);
114 void __otx2_mbox_reset(struct otx2_mbox *mbox, int devid);
115 void otx2_mbox_destroy(struct otx2_mbox *mbox);
116 int otx2_mbox_init(struct otx2_mbox *mbox, void __force *hwbase,
117 struct pci_dev *pdev, void __force *reg_base,
118 int direction, int ndevs);
119
120 int otx2_mbox_regions_init(struct otx2_mbox *mbox, void __force **hwbase,
121 struct pci_dev *pdev, void __force *reg_base,
122 int direction, int ndevs, unsigned long *bmap);
123 void otx2_mbox_msg_send(struct otx2_mbox *mbox, int devid);
124 void otx2_mbox_msg_send_up(struct otx2_mbox *mbox, int devid);
125 int otx2_mbox_wait_for_rsp(struct otx2_mbox *mbox, int devid);
126 int otx2_mbox_busy_poll_for_rsp(struct otx2_mbox *mbox, int devid);
127 struct mbox_msghdr *otx2_mbox_alloc_msg_rsp(struct otx2_mbox *mbox, int devid,
128 int size, int size_rsp);
129 struct mbox_msghdr *otx2_mbox_get_rsp(struct otx2_mbox *mbox, int devid,
130 struct mbox_msghdr *msg);
131 int otx2_mbox_check_rsp_msgs(struct otx2_mbox *mbox, int devid);
132 int otx2_reply_invalid_msg(struct otx2_mbox *mbox, int devid,
133 u16 pcifunc, u16 id);
134 bool otx2_mbox_nonempty(struct otx2_mbox *mbox, int devid);
135 const char *otx2_mbox_id2name(u16 id);
136 static inline struct mbox_msghdr *otx2_mbox_alloc_msg(struct otx2_mbox *mbox,
137 int devid, int size)
138 {
139 return otx2_mbox_alloc_msg_rsp(mbox, devid, size, 0);
140 }
141
142 bool otx2_mbox_wait_for_zero(struct otx2_mbox *mbox, int devid);
143
144 /* Mailbox message types */
145 #define MBOX_MSG_MASK 0xFFFF
146 #define MBOX_MSG_INVALID 0xFFFE
147 #define MBOX_MSG_MAX 0xFFFF
148
149 #define MBOX_MESSAGES \
150 /* Generic mbox IDs (range 0x000 - 0x1FF) */ \
151 M(READY, 0x001, ready, msg_req, ready_msg_rsp) \
152 M(ATTACH_RESOURCES, 0x002, attach_resources, rsrc_attach, msg_rsp) \
153 M(DETACH_RESOURCES, 0x003, detach_resources, rsrc_detach, msg_rsp) \
154 M(FREE_RSRC_CNT, 0x004, free_rsrc_cnt, msg_req, free_rsrcs_rsp) \
155 M(MSIX_OFFSET, 0x005, msix_offset, msg_req, msix_offset_rsp) \
156 M(VF_FLR, 0x006, vf_flr, msg_req, msg_rsp) \
157 M(PTP_OP, 0x007, ptp_op, ptp_req, ptp_rsp) \
158 M(GET_HW_CAP, 0x008, get_hw_cap, msg_req, get_hw_cap_rsp) \
159 M(NDC_SYNC_OP, 0x009, ndc_sync_op, ndc_sync_op, msg_rsp) \
160 M(LMTST_TBL_SETUP, 0x00a, lmtst_tbl_setup, lmtst_tbl_setup_req, \
161 msg_rsp) \
162 M(SET_VF_PERM, 0x00b, set_vf_perm, set_vf_perm, msg_rsp) \
163 M(PTP_GET_CAP, 0x00c, ptp_get_cap, msg_req, ptp_get_cap_rsp) \
164 M(GET_REP_CNT, 0x00d, get_rep_cnt, msg_req, get_rep_cnt_rsp) \
165 M(ESW_CFG, 0x00e, esw_cfg, esw_cfg_req, msg_rsp) \
166 M(REP_EVENT_NOTIFY, 0x00f, rep_event_notify, rep_event, msg_rsp) \
167 /* CGX mbox IDs (range 0x200 - 0x3FF) */ \
168 M(CGX_START_RXTX, 0x200, cgx_start_rxtx, msg_req, msg_rsp) \
169 M(CGX_STOP_RXTX, 0x201, cgx_stop_rxtx, msg_req, msg_rsp) \
170 M(CGX_STATS, 0x202, cgx_stats, msg_req, cgx_stats_rsp) \
171 M(CGX_MAC_ADDR_SET, 0x203, cgx_mac_addr_set, cgx_mac_addr_set_or_get, \
172 cgx_mac_addr_set_or_get) \
173 M(CGX_MAC_ADDR_GET, 0x204, cgx_mac_addr_get, cgx_mac_addr_set_or_get, \
174 cgx_mac_addr_set_or_get) \
175 M(CGX_PROMISC_ENABLE, 0x205, cgx_promisc_enable, msg_req, msg_rsp) \
176 M(CGX_PROMISC_DISABLE, 0x206, cgx_promisc_disable, msg_req, msg_rsp) \
177 M(CGX_START_LINKEVENTS, 0x207, cgx_start_linkevents, msg_req, msg_rsp) \
178 M(CGX_STOP_LINKEVENTS, 0x208, cgx_stop_linkevents, msg_req, msg_rsp) \
179 M(CGX_GET_LINKINFO, 0x209, cgx_get_linkinfo, msg_req, cgx_link_info_msg) \
180 M(CGX_INTLBK_ENABLE, 0x20A, cgx_intlbk_enable, msg_req, msg_rsp) \
181 M(CGX_INTLBK_DISABLE, 0x20B, cgx_intlbk_disable, msg_req, msg_rsp) \
182 M(CGX_PTP_RX_ENABLE, 0x20C, cgx_ptp_rx_enable, msg_req, msg_rsp) \
183 M(CGX_PTP_RX_DISABLE, 0x20D, cgx_ptp_rx_disable, msg_req, msg_rsp) \
184 M(CGX_CFG_PAUSE_FRM, 0x20E, cgx_cfg_pause_frm, cgx_pause_frm_cfg, \
185 cgx_pause_frm_cfg) \
186 M(CGX_FW_DATA_GET, 0x20F, cgx_get_aux_link_info, msg_req, cgx_fw_data) \
187 M(CGX_FEC_SET, 0x210, cgx_set_fec_param, fec_mode, fec_mode) \
188 M(CGX_MAC_ADDR_ADD, 0x211, cgx_mac_addr_add, cgx_mac_addr_add_req, \
189 cgx_mac_addr_add_rsp) \
190 M(CGX_MAC_ADDR_DEL, 0x212, cgx_mac_addr_del, cgx_mac_addr_del_req, \
191 msg_rsp) \
192 M(CGX_MAC_MAX_ENTRIES_GET, 0x213, cgx_mac_max_entries_get, msg_req, \
193 cgx_max_dmac_entries_get_rsp) \
194 M(CGX_FEC_STATS, 0x217, cgx_fec_stats, msg_req, cgx_fec_stats_rsp) \
195 M(CGX_SET_LINK_MODE, 0x218, cgx_set_link_mode, cgx_set_link_mode_req,\
196 cgx_set_link_mode_rsp) \
197 M(CGX_GET_PHY_FEC_STATS, 0x219, cgx_get_phy_fec_stats, msg_req, msg_rsp) \
198 M(CGX_STATS_RST, 0x21A, cgx_stats_rst, msg_req, msg_rsp) \
199 M(CGX_FEATURES_GET, 0x21B, cgx_features_get, msg_req, \
200 cgx_features_info_msg) \
201 M(RPM_STATS, 0x21C, rpm_stats, msg_req, rpm_stats_rsp) \
202 M(CGX_MAC_ADDR_RESET, 0x21D, cgx_mac_addr_reset, cgx_mac_addr_reset_req, \
203 msg_rsp) \
204 M(CGX_MAC_ADDR_UPDATE, 0x21E, cgx_mac_addr_update, cgx_mac_addr_update_req, \
205 cgx_mac_addr_update_rsp) \
206 M(CGX_PRIO_FLOW_CTRL_CFG, 0x21F, cgx_prio_flow_ctrl_cfg, cgx_pfc_cfg, \
207 cgx_pfc_rsp) \
208 /* NPA mbox IDs (range 0x400 - 0x5FF) */ \
209 M(NPA_LF_ALLOC, 0x400, npa_lf_alloc, \
210 npa_lf_alloc_req, npa_lf_alloc_rsp) \
211 M(NPA_LF_FREE, 0x401, npa_lf_free, msg_req, msg_rsp) \
212 M(NPA_AQ_ENQ, 0x402, npa_aq_enq, npa_aq_enq_req, npa_aq_enq_rsp) \
213 M(NPA_HWCTX_DISABLE, 0x403, npa_hwctx_disable, hwctx_disable_req, msg_rsp)\
214 M(NPA_CN20K_AQ_ENQ, 0x404, npa_cn20k_aq_enq, npa_cn20k_aq_enq_req, \
215 npa_cn20k_aq_enq_rsp) \
216 /* SSO/SSOW mbox IDs (range 0x600 - 0x7FF) */ \
217 /* TIM mbox IDs (range 0x800 - 0x9FF) */ \
218 /* CPT mbox IDs (range 0xA00 - 0xBFF) */ \
219 M(CPT_LF_ALLOC, 0xA00, cpt_lf_alloc, cpt_lf_alloc_req_msg, \
220 msg_rsp) \
221 M(CPT_LF_FREE, 0xA01, cpt_lf_free, msg_req, msg_rsp) \
222 M(CPT_RD_WR_REGISTER, 0xA02, cpt_rd_wr_register, cpt_rd_wr_reg_msg, \
223 cpt_rd_wr_reg_msg) \
224 M(CPT_INLINE_IPSEC_CFG, 0xA04, cpt_inline_ipsec_cfg, \
225 cpt_inline_ipsec_cfg_msg, msg_rsp) \
226 M(CPT_STATS, 0xA05, cpt_sts, cpt_sts_req, cpt_sts_rsp) \
227 M(CPT_RXC_TIME_CFG, 0xA06, cpt_rxc_time_cfg, cpt_rxc_time_cfg_req, \
228 msg_rsp) \
229 M(CPT_CTX_CACHE_SYNC, 0xA07, cpt_ctx_cache_sync, msg_req, msg_rsp) \
230 M(CPT_LF_RESET, 0xA08, cpt_lf_reset, cpt_lf_rst_req, msg_rsp) \
231 M(CPT_FLT_ENG_INFO, 0xA09, cpt_flt_eng_info, cpt_flt_eng_info_req, \
232 cpt_flt_eng_info_rsp) \
233 /* SDP mbox IDs (range 0x1000 - 0x11FF) */ \
234 M(SET_SDP_CHAN_INFO, 0x1000, set_sdp_chan_info, sdp_chan_info_msg, msg_rsp) \
235 M(GET_SDP_CHAN_INFO, 0x1001, get_sdp_chan_info, msg_req, sdp_get_chan_info_msg) \
236 /* NPC mbox IDs (range 0x6000 - 0x7FFF) */ \
237 M(NPC_MCAM_ALLOC_ENTRY, 0x6000, npc_mcam_alloc_entry, npc_mcam_alloc_entry_req,\
238 npc_mcam_alloc_entry_rsp) \
239 M(NPC_MCAM_FREE_ENTRY, 0x6001, npc_mcam_free_entry, \
240 npc_mcam_free_entry_req, msg_rsp) \
241 M(NPC_MCAM_WRITE_ENTRY, 0x6002, npc_mcam_write_entry, \
242 npc_mcam_write_entry_req, msg_rsp) \
243 M(NPC_MCAM_ENA_ENTRY, 0x6003, npc_mcam_ena_entry, \
244 npc_mcam_ena_dis_entry_req, msg_rsp) \
245 M(NPC_MCAM_DIS_ENTRY, 0x6004, npc_mcam_dis_entry, \
246 npc_mcam_ena_dis_entry_req, msg_rsp) \
247 M(NPC_MCAM_SHIFT_ENTRY, 0x6005, npc_mcam_shift_entry, npc_mcam_shift_entry_req,\
248 npc_mcam_shift_entry_rsp) \
249 M(NPC_MCAM_ALLOC_COUNTER, 0x6006, npc_mcam_alloc_counter, \
250 npc_mcam_alloc_counter_req, \
251 npc_mcam_alloc_counter_rsp) \
252 M(NPC_MCAM_FREE_COUNTER, 0x6007, npc_mcam_free_counter, \
253 npc_mcam_oper_counter_req, msg_rsp) \
254 M(NPC_MCAM_UNMAP_COUNTER, 0x6008, npc_mcam_unmap_counter, \
255 npc_mcam_unmap_counter_req, msg_rsp) \
256 M(NPC_MCAM_CLEAR_COUNTER, 0x6009, npc_mcam_clear_counter, \
257 npc_mcam_oper_counter_req, msg_rsp) \
258 M(NPC_MCAM_COUNTER_STATS, 0x600a, npc_mcam_counter_stats, \
259 npc_mcam_oper_counter_req, \
260 npc_mcam_oper_counter_rsp) \
261 M(NPC_MCAM_ALLOC_AND_WRITE_ENTRY, 0x600b, npc_mcam_alloc_and_write_entry, \
262 npc_mcam_alloc_and_write_entry_req, \
263 npc_mcam_alloc_and_write_entry_rsp) \
264 M(NPC_GET_KEX_CFG, 0x600c, npc_get_kex_cfg, \
265 msg_req, npc_get_kex_cfg_rsp) \
266 M(NPC_INSTALL_FLOW, 0x600d, npc_install_flow, \
267 npc_install_flow_req, npc_install_flow_rsp) \
268 M(NPC_DELETE_FLOW, 0x600e, npc_delete_flow, \
269 npc_delete_flow_req, npc_delete_flow_rsp) \
270 M(NPC_MCAM_READ_ENTRY, 0x600f, npc_mcam_read_entry, \
271 npc_mcam_read_entry_req, \
272 npc_mcam_read_entry_rsp) \
273 M(NPC_SET_PKIND, 0x6010, npc_set_pkind, \
274 npc_set_pkind, msg_rsp) \
275 M(NPC_MCAM_READ_BASE_RULE, 0x6011, npc_read_base_steer_rule, \
276 msg_req, npc_mcam_read_base_rule_rsp) \
277 M(NPC_MCAM_GET_STATS, 0x6012, npc_mcam_entry_stats, \
278 npc_mcam_get_stats_req, \
279 npc_mcam_get_stats_rsp) \
280 M(NPC_GET_FIELD_HASH_INFO, 0x6013, npc_get_field_hash_info, \
281 npc_get_field_hash_info_req, \
282 npc_get_field_hash_info_rsp) \
283 M(NPC_GET_FIELD_STATUS, 0x6014, npc_get_field_status, \
284 npc_get_field_status_req, \
285 npc_get_field_status_rsp) \
286 M(NPC_MCAM_DEFRAG, 0x6016, npc_defrag, \
287 msg_req, \
288 msg_rsp) \
289 M(NPC_CN20K_GET_KEX_CFG, 0x6017, npc_cn20k_get_kex_cfg, \
290 msg_req, npc_cn20k_get_kex_cfg_rsp) \
291 M(NPC_CN20K_MCAM_GET_FREE_COUNT, 0x6018, npc_cn20k_get_fcnt, \
292 msg_req, npc_cn20k_get_fcnt_rsp) \
293 M(NPC_CN20K_MCAM_WRITE_ENTRY, 0x6019, npc_cn20k_mcam_write_entry, \
294 npc_cn20k_mcam_write_entry_req, msg_rsp) \
295 M(NPC_CN20K_MCAM_ALLOC_AND_WRITE_ENTRY, 0x601a, npc_cn20k_mcam_alloc_and_write_entry, \
296 npc_cn20k_mcam_alloc_and_write_entry_req, \
297 npc_mcam_alloc_and_write_entry_rsp) \
298 M(NPC_CN20K_MCAM_READ_ENTRY, 0x601b, npc_cn20k_mcam_read_entry, \
299 npc_mcam_read_entry_req, \
300 npc_cn20k_mcam_read_entry_rsp) \
301 M(NPC_CN20K_MCAM_READ_BASE_RULE, 0x601c, npc_cn20k_read_base_steer_rule, \
302 msg_req, npc_cn20k_mcam_read_base_rule_rsp) \
303 M(NPC_MCAM_GET_NUM_KWS, 0x601d, npc_get_num_kws, \
304 npc_get_num_kws_req, \
305 npc_get_num_kws_rsp) \
306 M(NPC_MCAM_GET_DFT_RL_IDXS, 0x601e, npc_get_dft_rl_idxs, \
307 msg_req, \
308 npc_get_dft_rl_idxs_rsp)\
309 M(NPC_MCAM_GET_NPC_PFL_INFO, 0x601f, npc_get_pfl_info, \
310 msg_req, \
311 npc_get_pfl_info_rsp) \
312 /* NIX mbox IDs (range 0x8000 - 0xFFFF) */ \
313 M(NIX_LF_ALLOC, 0x8000, nix_lf_alloc, \
314 nix_lf_alloc_req, nix_lf_alloc_rsp) \
315 M(NIX_LF_FREE, 0x8001, nix_lf_free, nix_lf_free_req, msg_rsp) \
316 M(NIX_AQ_ENQ, 0x8002, nix_aq_enq, nix_aq_enq_req, nix_aq_enq_rsp) \
317 M(NIX_HWCTX_DISABLE, 0x8003, nix_hwctx_disable, \
318 hwctx_disable_req, msg_rsp) \
319 M(NIX_TXSCH_ALLOC, 0x8004, nix_txsch_alloc, \
320 nix_txsch_alloc_req, nix_txsch_alloc_rsp) \
321 M(NIX_TXSCH_FREE, 0x8005, nix_txsch_free, nix_txsch_free_req, msg_rsp) \
322 M(NIX_TXSCHQ_CFG, 0x8006, nix_txschq_cfg, nix_txschq_config, \
323 nix_txschq_config) \
324 M(NIX_STATS_RST, 0x8007, nix_stats_rst, msg_req, msg_rsp) \
325 M(NIX_VTAG_CFG, 0x8008, nix_vtag_cfg, nix_vtag_config, \
326 nix_vtag_config_rsp) \
327 M(NIX_RSS_FLOWKEY_CFG, 0x8009, nix_rss_flowkey_cfg, \
328 nix_rss_flowkey_cfg, \
329 nix_rss_flowkey_cfg_rsp) \
330 M(NIX_SET_MAC_ADDR, 0x800a, nix_set_mac_addr, nix_set_mac_addr, msg_rsp) \
331 M(NIX_SET_RX_MODE, 0x800b, nix_set_rx_mode, nix_rx_mode, msg_rsp) \
332 M(NIX_SET_HW_FRS, 0x800c, nix_set_hw_frs, nix_frs_cfg, msg_rsp) \
333 M(NIX_LF_START_RX, 0x800d, nix_lf_start_rx, msg_req, msg_rsp) \
334 M(NIX_LF_STOP_RX, 0x800e, nix_lf_stop_rx, msg_req, msg_rsp) \
335 M(NIX_MARK_FORMAT_CFG, 0x800f, nix_mark_format_cfg, \
336 nix_mark_format_cfg, \
337 nix_mark_format_cfg_rsp) \
338 M(NIX_SET_RX_CFG, 0x8010, nix_set_rx_cfg, nix_rx_cfg, msg_rsp) \
339 M(NIX_LSO_FORMAT_CFG, 0x8011, nix_lso_format_cfg, \
340 nix_lso_format_cfg, \
341 nix_lso_format_cfg_rsp) \
342 M(NIX_LF_PTP_TX_ENABLE, 0x8013, nix_lf_ptp_tx_enable, msg_req, msg_rsp) \
343 M(NIX_LF_PTP_TX_DISABLE, 0x8014, nix_lf_ptp_tx_disable, msg_req, msg_rsp) \
344 M(NIX_BP_ENABLE, 0x8016, nix_bp_enable, nix_bp_cfg_req, \
345 nix_bp_cfg_rsp) \
346 M(NIX_BP_DISABLE, 0x8017, nix_bp_disable, nix_bp_cfg_req, msg_rsp) \
347 M(NIX_GET_MAC_ADDR, 0x8018, nix_get_mac_addr, msg_req, nix_get_mac_addr_rsp) \
348 M(NIX_INLINE_IPSEC_CFG, 0x8019, nix_inline_ipsec_cfg, \
349 nix_inline_ipsec_cfg, msg_rsp) \
350 M(NIX_INLINE_IPSEC_LF_CFG, 0x801a, nix_inline_ipsec_lf_cfg, \
351 nix_inline_ipsec_lf_cfg, msg_rsp) \
352 M(NIX_CN10K_AQ_ENQ, 0x801b, nix_cn10k_aq_enq, nix_cn10k_aq_enq_req, \
353 nix_cn10k_aq_enq_rsp) \
354 M(NIX_GET_HW_INFO, 0x801c, nix_get_hw_info, msg_req, nix_hw_info) \
355 M(NIX_BANDPROF_ALLOC, 0x801d, nix_bandprof_alloc, nix_bandprof_alloc_req, \
356 nix_bandprof_alloc_rsp) \
357 M(NIX_BANDPROF_FREE, 0x801e, nix_bandprof_free, nix_bandprof_free_req, \
358 msg_rsp) \
359 M(NIX_BANDPROF_GET_HWINFO, 0x801f, nix_bandprof_get_hwinfo, msg_req, \
360 nix_bandprof_get_hwinfo_rsp) \
361 M(NIX_CPT_BP_ENABLE, 0x8020, nix_cpt_bp_enable, nix_bp_cfg_req, \
362 nix_bp_cfg_rsp) \
363 M(NIX_CPT_BP_DISABLE, 0x8021, nix_cpt_bp_disable, nix_bp_cfg_req, \
364 msg_rsp) \
365 M(NIX_READ_INLINE_IPSEC_CFG, 0x8023, nix_read_inline_ipsec_cfg, \
366 msg_req, nix_inline_ipsec_cfg) \
367 M(NIX_MCAST_GRP_CREATE, 0x802b, nix_mcast_grp_create, nix_mcast_grp_create_req, \
368 nix_mcast_grp_create_rsp) \
369 M(NIX_MCAST_GRP_DESTROY, 0x802c, nix_mcast_grp_destroy, nix_mcast_grp_destroy_req, \
370 msg_rsp) \
371 M(NIX_MCAST_GRP_UPDATE, 0x802d, nix_mcast_grp_update, \
372 nix_mcast_grp_update_req, \
373 nix_mcast_grp_update_rsp) \
374 M(NIX_LF_STATS, 0x802e, nix_lf_stats, nix_stats_req, nix_stats_rsp) \
375 M(NIX_CN20K_AQ_ENQ, 0x802f, nix_cn20k_aq_enq, nix_cn20k_aq_enq_req, \
376 nix_cn20k_aq_enq_rsp) \
377 /* MCS mbox IDs (range 0xA000 - 0xBFFF) */ \
378 M(MCS_ALLOC_RESOURCES, 0xa000, mcs_alloc_resources, mcs_alloc_rsrc_req, \
379 mcs_alloc_rsrc_rsp) \
380 M(MCS_FREE_RESOURCES, 0xa001, mcs_free_resources, mcs_free_rsrc_req, msg_rsp) \
381 M(MCS_FLOWID_ENTRY_WRITE, 0xa002, mcs_flowid_entry_write, mcs_flowid_entry_write_req, \
382 msg_rsp) \
383 M(MCS_SECY_PLCY_WRITE, 0xa003, mcs_secy_plcy_write, mcs_secy_plcy_write_req, \
384 msg_rsp) \
385 M(MCS_RX_SC_CAM_WRITE, 0xa004, mcs_rx_sc_cam_write, mcs_rx_sc_cam_write_req, \
386 msg_rsp) \
387 M(MCS_SA_PLCY_WRITE, 0xa005, mcs_sa_plcy_write, mcs_sa_plcy_write_req, \
388 msg_rsp) \
389 M(MCS_TX_SC_SA_MAP_WRITE, 0xa006, mcs_tx_sc_sa_map_write, mcs_tx_sc_sa_map, \
390 msg_rsp) \
391 M(MCS_RX_SC_SA_MAP_WRITE, 0xa007, mcs_rx_sc_sa_map_write, mcs_rx_sc_sa_map, \
392 msg_rsp) \
393 M(MCS_FLOWID_ENA_ENTRY, 0xa008, mcs_flowid_ena_entry, mcs_flowid_ena_dis_entry, \
394 msg_rsp) \
395 M(MCS_PN_TABLE_WRITE, 0xa009, mcs_pn_table_write, mcs_pn_table_write_req, \
396 msg_rsp) \
397 M(MCS_SET_ACTIVE_LMAC, 0xa00a, mcs_set_active_lmac, mcs_set_active_lmac, \
398 msg_rsp) \
399 M(MCS_GET_HW_INFO, 0xa00b, mcs_get_hw_info, msg_req, mcs_hw_info) \
400 M(MCS_GET_FLOWID_STATS, 0xa00c, mcs_get_flowid_stats, mcs_stats_req, \
401 mcs_flowid_stats) \
402 M(MCS_GET_SECY_STATS, 0xa00d, mcs_get_secy_stats, mcs_stats_req, \
403 mcs_secy_stats) \
404 M(MCS_GET_SC_STATS, 0xa00e, mcs_get_sc_stats, mcs_stats_req, mcs_sc_stats) \
405 M(MCS_GET_SA_STATS, 0xa00f, mcs_get_sa_stats, mcs_stats_req, mcs_sa_stats) \
406 M(MCS_GET_PORT_STATS, 0xa010, mcs_get_port_stats, mcs_stats_req, \
407 mcs_port_stats) \
408 M(MCS_CLEAR_STATS, 0xa011, mcs_clear_stats, mcs_clear_stats, msg_rsp) \
409 M(MCS_INTR_CFG, 0xa012, mcs_intr_cfg, mcs_intr_cfg, msg_rsp) \
410 M(MCS_SET_LMAC_MODE, 0xa013, mcs_set_lmac_mode, mcs_set_lmac_mode, msg_rsp) \
411 M(MCS_SET_PN_THRESHOLD, 0xa014, mcs_set_pn_threshold, mcs_set_pn_threshold, \
412 msg_rsp) \
413 M(MCS_ALLOC_CTRL_PKT_RULE, 0xa015, mcs_alloc_ctrl_pkt_rule, \
414 mcs_alloc_ctrl_pkt_rule_req, \
415 mcs_alloc_ctrl_pkt_rule_rsp) \
416 M(MCS_FREE_CTRL_PKT_RULE, 0xa016, mcs_free_ctrl_pkt_rule, \
417 mcs_free_ctrl_pkt_rule_req, msg_rsp) \
418 M(MCS_CTRL_PKT_RULE_WRITE, 0xa017, mcs_ctrl_pkt_rule_write, \
419 mcs_ctrl_pkt_rule_write_req, msg_rsp) \
420 M(MCS_PORT_RESET, 0xa018, mcs_port_reset, mcs_port_reset_req, msg_rsp) \
421 M(MCS_PORT_CFG_SET, 0xa019, mcs_port_cfg_set, mcs_port_cfg_set_req, msg_rsp)\
422 M(MCS_PORT_CFG_GET, 0xa020, mcs_port_cfg_get, mcs_port_cfg_get_req, \
423 mcs_port_cfg_get_rsp) \
424 M(MCS_CUSTOM_TAG_CFG_GET, 0xa021, mcs_custom_tag_cfg_get, \
425 mcs_custom_tag_cfg_get_req, \
426 mcs_custom_tag_cfg_get_rsp)
427
428 /* Messages initiated by AF (range 0xC00 - 0xEFF) */
429 #define MBOX_UP_CGX_MESSAGES \
430 M(CGX_LINK_EVENT, 0xC00, cgx_link_event, cgx_link_info_msg, msg_rsp)
431
432 #define MBOX_UP_CPT_MESSAGES \
433 M(CPT_INST_LMTST, 0xD00, cpt_inst_lmtst, cpt_inst_lmtst_req, msg_rsp)
434
435 #define MBOX_UP_MCS_MESSAGES \
436 M(MCS_INTR_NOTIFY, 0xE00, mcs_intr_notify, mcs_intr_info, msg_rsp)
437
438 #define MBOX_UP_REP_MESSAGES \
439 M(REP_EVENT_UP_NOTIFY, 0xEF0, rep_event_up_notify, rep_event, msg_rsp) \
440
441 enum {
442 #define M(_name, _id, _1, _2, _3) MBOX_MSG_ ## _name = _id,
443 MBOX_MESSAGES
444 MBOX_UP_CGX_MESSAGES
445 MBOX_UP_CPT_MESSAGES
446 MBOX_UP_MCS_MESSAGES
447 MBOX_UP_REP_MESSAGES
448 #undef M
449 };
450
451 /* Mailbox message formats */
452
453 #define RVU_DEFAULT_PF_FUNC 0xFFFF
454
455 /* Generic request msg used for those mbox messages which
456 * don't send any data in the request.
457 */
458 struct msg_req {
459 struct mbox_msghdr hdr;
460 };
461
462 /* Generic response msg used an ack or response for those mbox
463 * messages which don't have a specific rsp msg format.
464 */
465 struct msg_rsp {
466 struct mbox_msghdr hdr;
467 };
468
469 /* RVU mailbox error codes
470 * Range 256 - 300.
471 */
472 enum rvu_af_status {
473 RVU_INVALID_VF_ID = -256,
474 };
475
476 struct ready_msg_rsp {
477 struct mbox_msghdr hdr;
478 u16 sclk_freq; /* SCLK frequency (in MHz) */
479 u16 rclk_freq; /* RCLK frequency (in MHz) */
480 };
481
482 /* Structure for requesting resource provisioning.
483 * 'modify' flag to be used when either requesting more
484 * or to detach partial of a certain resource type.
485 * Rest of the fields specify how many of what type to
486 * be attached.
487 * To request LFs from two blocks of same type this mailbox
488 * can be sent twice as below:
489 * struct rsrc_attach *attach;
490 * .. Allocate memory for message ..
491 * attach->cptlfs = 3; <3 LFs from CPT0>
492 * .. Send message ..
493 * .. Allocate memory for message ..
494 * attach->modify = 1;
495 * attach->cpt_blkaddr = BLKADDR_CPT1;
496 * attach->cptlfs = 2; <2 LFs from CPT1>
497 * .. Send message ..
498 */
499 struct rsrc_attach {
500 struct mbox_msghdr hdr;
501 u8 modify:1;
502 u8 npalf:1;
503 u8 nixlf:1;
504 u16 sso;
505 u16 ssow;
506 u16 timlfs;
507 u16 cptlfs;
508 int cpt_blkaddr; /* BLKADDR_CPT0/BLKADDR_CPT1 or 0 for BLKADDR_CPT0 */
509 };
510
511 /* Structure for relinquishing resources.
512 * 'partial' flag to be used when relinquishing all resources
513 * but only of a certain type. If not set, all resources of all
514 * types provisioned to the RVU function will be detached.
515 */
516 struct rsrc_detach {
517 struct mbox_msghdr hdr;
518 u8 partial:1;
519 u8 npalf:1;
520 u8 nixlf:1;
521 u8 sso:1;
522 u8 ssow:1;
523 u8 timlfs:1;
524 u8 cptlfs:1;
525 };
526
527 /* Number of resources available to the caller.
528 * In reply to MBOX_MSG_FREE_RSRC_CNT.
529 */
530 struct free_rsrcs_rsp {
531 struct mbox_msghdr hdr;
532 u16 schq[NIX_TXSCH_LVL_CNT];
533 u16 sso;
534 u16 tim;
535 u16 ssow;
536 u16 cpt;
537 u8 npa;
538 u8 nix;
539 u16 schq_nix1[NIX_TXSCH_LVL_CNT];
540 u8 nix1;
541 u8 cpt1;
542 u8 ree0;
543 u8 ree1;
544 };
545
546 #define MSIX_VECTOR_INVALID 0xFFFF
547 #define MAX_RVU_BLKLF_CNT 256
548
549 struct msix_offset_rsp {
550 struct mbox_msghdr hdr;
551 u16 npa_msixoff;
552 u16 nix_msixoff;
553 u16 sso;
554 u16 ssow;
555 u16 timlfs;
556 u16 cptlfs;
557 u16 sso_msixoff[MAX_RVU_BLKLF_CNT];
558 u16 ssow_msixoff[MAX_RVU_BLKLF_CNT];
559 u16 timlf_msixoff[MAX_RVU_BLKLF_CNT];
560 u16 cptlf_msixoff[MAX_RVU_BLKLF_CNT];
561 u16 cpt1_lfs;
562 u16 ree0_lfs;
563 u16 ree1_lfs;
564 u16 cpt1_lf_msixoff[MAX_RVU_BLKLF_CNT];
565 u16 ree0_lf_msixoff[MAX_RVU_BLKLF_CNT];
566 u16 ree1_lf_msixoff[MAX_RVU_BLKLF_CNT];
567 };
568
569 struct get_hw_cap_rsp {
570 struct mbox_msghdr hdr;
571 u8 nix_fixed_txschq_mapping; /* Schq mapping fixed or flexible */
572 u8 nix_shaping; /* Is shaping and coloring supported */
573 u8 npc_hash_extract; /* Is hash extract supported */
574 #define HW_CAP_MACSEC BIT_ULL(1)
575 u64 hw_caps;
576 };
577
578 /* CGX mbox message formats */
579
580 struct cgx_stats_rsp {
581 struct mbox_msghdr hdr;
582 #define CGX_RX_STATS_COUNT 9
583 #define CGX_TX_STATS_COUNT 18
584 u64 rx_stats[CGX_RX_STATS_COUNT];
585 u64 tx_stats[CGX_TX_STATS_COUNT];
586 };
587
588 struct cgx_fec_stats_rsp {
589 struct mbox_msghdr hdr;
590 u64 fec_corr_blks;
591 u64 fec_uncorr_blks;
592 };
593 /* Structure for requesting the operation for
594 * setting/getting mac address in the CGX interface
595 */
596 struct cgx_mac_addr_set_or_get {
597 struct mbox_msghdr hdr;
598 u8 mac_addr[ETH_ALEN];
599 u32 index;
600 };
601
602 /* Structure for requesting the operation to
603 * add DMAC filter entry into CGX interface
604 */
605 struct cgx_mac_addr_add_req {
606 struct mbox_msghdr hdr;
607 u8 mac_addr[ETH_ALEN];
608 };
609
610 /* Structure for response against the operation to
611 * add DMAC filter entry into CGX interface
612 */
613 struct cgx_mac_addr_add_rsp {
614 struct mbox_msghdr hdr;
615 u32 index;
616 };
617
618 /* Structure for requesting the operation to
619 * delete DMAC filter entry from CGX interface
620 */
621 struct cgx_mac_addr_del_req {
622 struct mbox_msghdr hdr;
623 u32 index;
624 };
625
626 /* Structure for response against the operation to
627 * get maximum supported DMAC filter entries
628 */
629 struct cgx_max_dmac_entries_get_rsp {
630 struct mbox_msghdr hdr;
631 u32 max_dmac_filters;
632 };
633
634 struct cgx_link_user_info {
635 uint64_t link_up:1;
636 uint64_t full_duplex:1;
637 uint64_t lmac_type_id:4;
638 uint64_t speed:20; /* speed in Mbps */
639 uint64_t an:1; /* AN supported or not */
640 uint64_t fec:2; /* FEC type if enabled else 0 */
641 #define LMACTYPE_STR_LEN 16
642 char lmac_type[LMACTYPE_STR_LEN];
643 };
644
645 struct cgx_link_info_msg {
646 struct mbox_msghdr hdr;
647 struct cgx_link_user_info link_info;
648 };
649
650 struct cgx_pause_frm_cfg {
651 struct mbox_msghdr hdr;
652 u8 set;
653 /* set = 1 if the request is to config pause frames */
654 /* set = 0 if the request is to fetch pause frames config */
655 u8 rx_pause;
656 u8 tx_pause;
657 };
658
659 enum fec_type {
660 OTX2_FEC_NONE,
661 OTX2_FEC_BASER,
662 OTX2_FEC_RS,
663 OTX2_FEC_STATS_CNT = 2,
664 OTX2_FEC_OFF,
665 };
666
667 struct fec_mode {
668 struct mbox_msghdr hdr;
669 int fec;
670 };
671
672 struct sfp_eeprom_s {
673 #define SFP_EEPROM_SIZE 256
674 u16 sff_id;
675 u8 buf[SFP_EEPROM_SIZE];
676 u64 reserved;
677 };
678
679 struct phy_s {
680 struct {
681 u64 can_change_mod_type:1;
682 u64 mod_type:1;
683 u64 has_fec_stats:1;
684 } misc;
685 struct fec_stats_s {
686 u32 rsfec_corr_cws;
687 u32 rsfec_uncorr_cws;
688 u32 brfec_corr_blks;
689 u32 brfec_uncorr_blks;
690 } fec_stats;
691 };
692
693 struct cgx_lmac_fwdata_s {
694 u16 rw_valid;
695 u64 supported_fec;
696 u64 supported_an;
697 u64 supported_link_modes;
698 /* only applicable if AN is supported */
699 u64 advertised_fec;
700 u64 advertised_link_modes_own:1; /* CGX_CMD_OWN */
701 u64 advertised_link_modes:63;
702 /* Only applicable if SFP/QSFP slot is present */
703 struct sfp_eeprom_s sfp_eeprom;
704 struct phy_s phy;
705 u32 lmac_type;
706 u32 portm_idx;
707 u64 mgmt_port:1;
708 u64 advertised_an:1;
709 u64 port;
710 #define LMAC_FWDATA_RESERVED_MEM 1018
711 u64 reserved[LMAC_FWDATA_RESERVED_MEM];
712 };
713
714 struct cgx_fw_data {
715 struct mbox_msghdr hdr;
716 struct cgx_lmac_fwdata_s fwdata;
717 };
718
719 struct cgx_set_link_mode_args {
720 u32 speed;
721 u8 duplex;
722 u8 an;
723 u8 mode_baseidx;
724 u8 multimode;
725 u64 mode;
726 __ETHTOOL_DECLARE_LINK_MODE_MASK(advertising);
727 };
728
729 struct cgx_set_link_mode_req {
730 struct mbox_msghdr hdr;
731 struct cgx_set_link_mode_args args;
732 };
733
734 struct cgx_set_link_mode_rsp {
735 struct mbox_msghdr hdr;
736 int status;
737 };
738
739 struct cgx_mac_addr_reset_req {
740 struct mbox_msghdr hdr;
741 u32 index;
742 };
743
744 struct cgx_mac_addr_update_req {
745 struct mbox_msghdr hdr;
746 u8 mac_addr[ETH_ALEN];
747 u32 index;
748 };
749
750 struct cgx_mac_addr_update_rsp {
751 struct mbox_msghdr hdr;
752 u32 index;
753 };
754
755 #define RVU_LMAC_FEAT_FC BIT_ULL(0) /* pause frames */
756 #define RVU_LMAC_FEAT_HIGIG2 BIT_ULL(1)
757 /* flow control from physical link higig2 messages */
758 #define RVU_LMAC_FEAT_PTP BIT_ULL(2) /* precison time protocol */
759 #define RVU_LMAC_FEAT_DMACF BIT_ULL(3) /* DMAC FILTER */
760 #define RVU_MAC_VERSION BIT_ULL(4)
761 #define RVU_MAC_CGX BIT_ULL(5)
762 #define RVU_MAC_RPM BIT_ULL(6)
763
764 struct cgx_features_info_msg {
765 struct mbox_msghdr hdr;
766 u64 lmac_features;
767 };
768
769 struct rpm_stats_rsp {
770 struct mbox_msghdr hdr;
771 #define RPM_RX_STATS_COUNT 43
772 #define RPM_TX_STATS_COUNT 34
773 u64 rx_stats[RPM_RX_STATS_COUNT];
774 u64 tx_stats[RPM_TX_STATS_COUNT];
775 };
776
777 struct cgx_pfc_cfg {
778 struct mbox_msghdr hdr;
779 u8 rx_pause;
780 u8 tx_pause;
781 u16 pfc_en; /* bitmap indicating pfc enabled traffic classes */
782 };
783
784 struct cgx_pfc_rsp {
785 struct mbox_msghdr hdr;
786 u8 rx_pause;
787 u8 tx_pause;
788 };
789
790 /* NPA mbox message formats */
791
792 struct npc_set_pkind {
793 struct mbox_msghdr hdr;
794 #define OTX2_PRIV_FLAGS_DEFAULT BIT_ULL(0)
795 #define OTX2_PRIV_FLAGS_CUSTOM BIT_ULL(63)
796 u64 mode;
797 #define PKIND_TX BIT_ULL(0)
798 #define PKIND_RX BIT_ULL(1)
799 u8 dir;
800 u8 pkind; /* valid only in case custom flag */
801 u8 var_len_off; /* Offset of custom header length field.
802 * Valid only for pkind NPC_RX_CUSTOM_PRE_L2_PKIND
803 */
804 u8 var_len_off_mask; /* Mask for length with in offset */
805 u8 shift_dir; /* shift direction to get length of the header at var_len_off */
806 };
807
808 /* NPA mbox message formats */
809
810 /* NPA mailbox error codes
811 * Range 301 - 400.
812 */
813 enum npa_af_status {
814 NPA_AF_ERR_PARAM = -301,
815 NPA_AF_ERR_AQ_FULL = -302,
816 NPA_AF_ERR_AQ_ENQUEUE = -303,
817 NPA_AF_ERR_AF_LF_INVALID = -304,
818 NPA_AF_ERR_AF_LF_ALLOC = -305,
819 NPA_AF_ERR_LF_RESET = -306,
820 };
821
822 /* For NPA LF context alloc and init */
823 struct npa_lf_alloc_req {
824 struct mbox_msghdr hdr;
825 int node;
826 int aura_sz; /* No of auras */
827 u32 nr_pools; /* No of pools */
828 u64 way_mask;
829 };
830
831 struct npa_lf_alloc_rsp {
832 struct mbox_msghdr hdr;
833 u32 stack_pg_ptrs; /* No of ptrs per stack page */
834 u32 stack_pg_bytes; /* Size of stack page */
835 u16 qints; /* NPA_AF_CONST::QINTS */
836 u8 cache_lines; /*BATCH ALLOC DMA */
837 };
838
839 /* NPA AQ enqueue msg */
840 struct npa_aq_enq_req {
841 struct mbox_msghdr hdr;
842 u32 aura_id;
843 u8 ctype;
844 u8 op;
845 union {
846 /* Valid when op == WRITE/INIT and ctype == AURA.
847 * LF fills the pool_id in aura.pool_addr. AF will translate
848 * the pool_id to pool context pointer.
849 */
850 struct npa_aura_s aura;
851 /* Valid when op == WRITE/INIT and ctype == POOL */
852 struct npa_pool_s pool;
853 };
854 /* Mask data when op == WRITE (1=write, 0=don't write) */
855 union {
856 /* Valid when op == WRITE and ctype == AURA */
857 struct npa_aura_s aura_mask;
858 /* Valid when op == WRITE and ctype == POOL */
859 struct npa_pool_s pool_mask;
860 };
861 };
862
863 struct npa_aq_enq_rsp {
864 struct mbox_msghdr hdr;
865 union {
866 /* Valid when op == READ and ctype == AURA */
867 struct npa_aura_s aura;
868 /* Valid when op == READ and ctype == POOL */
869 struct npa_pool_s pool;
870 };
871 };
872
873 struct npa_cn20k_aq_enq_req {
874 struct mbox_msghdr hdr;
875 u32 aura_id;
876 u8 ctype;
877 u8 op;
878 union {
879 /* Valid when op == WRITE/INIT and ctype == AURA.
880 * LF fills the pool_id in aura.pool_addr. AF will translate
881 * the pool_id to pool context pointer.
882 */
883 struct npa_cn20k_aura_s aura;
884 /* Valid when op == WRITE/INIT and ctype == POOL */
885 struct npa_cn20k_pool_s pool;
886 };
887 /* Mask data when op == WRITE (1=write, 0=don't write) */
888 union {
889 /* Valid when op == WRITE and ctype == AURA */
890 struct npa_cn20k_aura_s aura_mask;
891 /* Valid when op == WRITE and ctype == POOL */
892 struct npa_cn20k_pool_s pool_mask;
893 };
894 };
895
896 struct npa_cn20k_aq_enq_rsp {
897 struct mbox_msghdr hdr;
898 union {
899 /* Valid when op == READ and ctype == AURA */
900 struct npa_cn20k_aura_s aura;
901 /* Valid when op == READ and ctype == POOL */
902 struct npa_cn20k_pool_s pool;
903 };
904 };
905
906 /* Disable all contexts of type 'ctype' */
907 struct hwctx_disable_req {
908 struct mbox_msghdr hdr;
909 u8 ctype;
910 };
911
912 /* NIX mbox message formats */
913
914 /* NIX mailbox error codes
915 * Range 401 - 500.
916 */
917 enum nix_af_status {
918 NIX_AF_ERR_PARAM = -401,
919 NIX_AF_ERR_AQ_FULL = -402,
920 NIX_AF_ERR_AQ_ENQUEUE = -403,
921 NIX_AF_ERR_AF_LF_INVALID = -404,
922 NIX_AF_ERR_AF_LF_ALLOC = -405,
923 NIX_AF_ERR_TLX_ALLOC_FAIL = -406,
924 NIX_AF_ERR_TLX_INVALID = -407,
925 NIX_AF_ERR_RSS_SIZE_INVALID = -408,
926 NIX_AF_ERR_RSS_GRPS_INVALID = -409,
927 NIX_AF_ERR_FRS_INVALID = -410,
928 NIX_AF_ERR_RX_LINK_INVALID = -411,
929 NIX_AF_INVAL_TXSCHQ_CFG = -412,
930 NIX_AF_SMQ_FLUSH_FAILED = -413,
931 NIX_AF_ERR_LF_RESET = -414,
932 NIX_AF_ERR_RSS_NOSPC_FIELD = -415,
933 NIX_AF_ERR_RSS_NOSPC_ALGO = -416,
934 NIX_AF_ERR_MARK_CFG_FAIL = -417,
935 NIX_AF_ERR_LSO_CFG_FAIL = -418,
936 NIX_AF_INVAL_NPA_PF_FUNC = -419,
937 NIX_AF_INVAL_SSO_PF_FUNC = -420,
938 NIX_AF_ERR_TX_VTAG_NOSPC = -421,
939 NIX_AF_ERR_RX_VTAG_INUSE = -422,
940 NIX_AF_ERR_PTP_CONFIG_FAIL = -423,
941 NIX_AF_ERR_NPC_KEY_NOT_SUPP = -424,
942 NIX_AF_ERR_INVALID_NIXBLK = -425,
943 NIX_AF_ERR_INVALID_BANDPROF = -426,
944 NIX_AF_ERR_IPOLICER_NOTSUPP = -427,
945 NIX_AF_ERR_BANDPROF_INVAL_REQ = -428,
946 NIX_AF_ERR_CQ_CTX_WRITE_ERR = -429,
947 NIX_AF_ERR_AQ_CTX_RETRY_WRITE = -430,
948 NIX_AF_ERR_LINK_CREDITS = -431,
949 NIX_AF_ERR_INVALID_BPID = -434,
950 NIX_AF_ERR_INVALID_BPID_REQ = -435,
951 NIX_AF_ERR_INVALID_MCAST_GRP = -436,
952 NIX_AF_ERR_INVALID_MCAST_DEL_REQ = -437,
953 NIX_AF_ERR_NON_CONTIG_MCE_LIST = -438,
954 };
955
956 /* For NIX RX vtag action */
957 enum nix_rx_vtag0_type {
958 NIX_AF_LFX_RX_VTAG_TYPE0, /* reserved for rx vlan offload */
959 NIX_AF_LFX_RX_VTAG_TYPE1,
960 NIX_AF_LFX_RX_VTAG_TYPE2,
961 NIX_AF_LFX_RX_VTAG_TYPE3,
962 NIX_AF_LFX_RX_VTAG_TYPE4,
963 NIX_AF_LFX_RX_VTAG_TYPE5,
964 NIX_AF_LFX_RX_VTAG_TYPE6,
965 NIX_AF_LFX_RX_VTAG_TYPE7,
966 };
967
968 /* For NIX LF context alloc and init */
969 struct nix_lf_alloc_req {
970 struct mbox_msghdr hdr;
971 int node;
972 u32 rq_cnt; /* No of receive queues */
973 u32 sq_cnt; /* No of send queues */
974 u32 cq_cnt; /* No of completion queues */
975 u8 xqe_sz;
976 u16 rss_sz;
977 u8 rss_grps;
978 u16 npa_func;
979 u16 sso_func;
980 u64 rx_cfg; /* See NIX_AF_LF(0..127)_RX_CFG */
981 u64 way_mask;
982 #define NIX_LF_RSS_TAG_LSB_AS_ADDER BIT_ULL(0)
983 #define NIX_LF_LBK_BLK_SEL BIT_ULL(1)
984 u64 flags;
985 };
986
987 struct nix_lf_alloc_rsp {
988 struct mbox_msghdr hdr;
989 u16 sqb_size;
990 u16 rx_chan_base;
991 u16 tx_chan_base;
992 u8 rx_chan_cnt; /* total number of RX channels */
993 u8 tx_chan_cnt; /* total number of TX channels */
994 u8 lso_tsov4_idx;
995 u8 lso_tsov6_idx;
996 u8 mac_addr[ETH_ALEN];
997 u8 lf_rx_stats; /* NIX_AF_CONST1::LF_RX_STATS */
998 u8 lf_tx_stats; /* NIX_AF_CONST1::LF_TX_STATS */
999 u16 cints; /* NIX_AF_CONST2::CINTS */
1000 u16 qints; /* NIX_AF_CONST2::QINTS */
1001 u8 cgx_links; /* No. of CGX links present in HW */
1002 u8 lbk_links; /* No. of LBK links present in HW */
1003 u8 sdp_links; /* No. of SDP links present in HW */
1004 u8 tx_link; /* Transmit channel link number */
1005 };
1006
1007 struct nix_lf_free_req {
1008 struct mbox_msghdr hdr;
1009 #define NIX_LF_DISABLE_FLOWS BIT_ULL(0)
1010 #define NIX_LF_DONT_FREE_TX_VTAG BIT_ULL(1)
1011 #define NIX_LF_DONT_FREE_DFT_IDXS BIT_ULL(2)
1012 u64 flags;
1013 };
1014
1015 /* CN20K NIX AQ enqueue msg */
1016 struct nix_cn20k_aq_enq_req {
1017 struct mbox_msghdr hdr;
1018 u32 qidx;
1019 u8 ctype;
1020 u8 op;
1021 union {
1022 struct nix_cn20k_rq_ctx_s rq;
1023 struct nix_cn20k_sq_ctx_s sq;
1024 struct nix_cn20k_cq_ctx_s cq;
1025 struct nix_rsse_s rss;
1026 struct nix_rx_mce_s mce;
1027 struct nix_bandprof_s prof;
1028 };
1029 union {
1030 struct nix_cn20k_rq_ctx_s rq_mask;
1031 struct nix_cn20k_sq_ctx_s sq_mask;
1032 struct nix_cn20k_cq_ctx_s cq_mask;
1033 struct nix_rsse_s rss_mask;
1034 struct nix_rx_mce_s mce_mask;
1035 struct nix_bandprof_s prof_mask;
1036 };
1037 };
1038
1039 struct nix_cn20k_aq_enq_rsp {
1040 struct mbox_msghdr hdr;
1041 union {
1042 struct nix_cn20k_rq_ctx_s rq;
1043 struct nix_cn20k_sq_ctx_s sq;
1044 struct nix_cn20k_cq_ctx_s cq;
1045 struct nix_rsse_s rss;
1046 struct nix_rx_mce_s mce;
1047 struct nix_bandprof_s prof;
1048 };
1049 };
1050
1051 /* CN10K NIX AQ enqueue msg */
1052 struct nix_cn10k_aq_enq_req {
1053 struct mbox_msghdr hdr;
1054 u32 qidx;
1055 u8 ctype;
1056 u8 op;
1057 union {
1058 struct nix_cn10k_rq_ctx_s rq;
1059 struct nix_cn10k_sq_ctx_s sq;
1060 struct nix_cq_ctx_s cq;
1061 struct nix_rsse_s rss;
1062 struct nix_rx_mce_s mce;
1063 struct nix_bandprof_s prof;
1064 };
1065 union {
1066 struct nix_cn10k_rq_ctx_s rq_mask;
1067 struct nix_cn10k_sq_ctx_s sq_mask;
1068 struct nix_cq_ctx_s cq_mask;
1069 struct nix_rsse_s rss_mask;
1070 struct nix_rx_mce_s mce_mask;
1071 struct nix_bandprof_s prof_mask;
1072 };
1073 };
1074
1075 struct nix_cn10k_aq_enq_rsp {
1076 struct mbox_msghdr hdr;
1077 union {
1078 struct nix_cn10k_rq_ctx_s rq;
1079 struct nix_cn10k_sq_ctx_s sq;
1080 struct nix_cq_ctx_s cq;
1081 struct nix_rsse_s rss;
1082 struct nix_rx_mce_s mce;
1083 struct nix_bandprof_s prof;
1084 };
1085 };
1086
1087 /* NIX AQ enqueue msg */
1088 struct nix_aq_enq_req {
1089 struct mbox_msghdr hdr;
1090 u32 qidx;
1091 u8 ctype;
1092 u8 op;
1093 union {
1094 struct nix_rq_ctx_s rq;
1095 struct nix_sq_ctx_s sq;
1096 struct nix_cq_ctx_s cq;
1097 struct nix_rsse_s rss;
1098 struct nix_rx_mce_s mce;
1099 struct nix_bandprof_s prof;
1100 };
1101 union {
1102 struct nix_rq_ctx_s rq_mask;
1103 struct nix_sq_ctx_s sq_mask;
1104 struct nix_cq_ctx_s cq_mask;
1105 struct nix_rsse_s rss_mask;
1106 struct nix_rx_mce_s mce_mask;
1107 struct nix_bandprof_s prof_mask;
1108 };
1109 };
1110
1111 struct nix_aq_enq_rsp {
1112 struct mbox_msghdr hdr;
1113 union {
1114 struct nix_rq_ctx_s rq;
1115 struct nix_sq_ctx_s sq;
1116 struct nix_cq_ctx_s cq;
1117 struct nix_rsse_s rss;
1118 struct nix_rx_mce_s mce;
1119 struct nix_bandprof_s prof;
1120 };
1121 };
1122
1123 /* Tx scheduler/shaper mailbox messages */
1124
1125 #define MAX_TXSCHQ_PER_FUNC 128
1126
1127 struct nix_txsch_alloc_req {
1128 struct mbox_msghdr hdr;
1129 /* Scheduler queue count request at each level */
1130 u16 schq_contig[NIX_TXSCH_LVL_CNT]; /* No of contiguous queues */
1131 u16 schq[NIX_TXSCH_LVL_CNT]; /* No of non-contiguous queues */
1132 };
1133
1134 struct nix_txsch_alloc_rsp {
1135 struct mbox_msghdr hdr;
1136 /* Scheduler queue count allocated at each level */
1137 u16 schq_contig[NIX_TXSCH_LVL_CNT];
1138 u16 schq[NIX_TXSCH_LVL_CNT];
1139 /* Scheduler queue list allocated at each level */
1140 u16 schq_contig_list[NIX_TXSCH_LVL_CNT][MAX_TXSCHQ_PER_FUNC];
1141 u16 schq_list[NIX_TXSCH_LVL_CNT][MAX_TXSCHQ_PER_FUNC];
1142 u8 aggr_level; /* Traffic aggregation scheduler level */
1143 u8 aggr_lvl_rr_prio; /* Aggregation lvl's RR_PRIO config */
1144 u8 link_cfg_lvl; /* LINKX_CFG CSRs mapped to TL3 or TL2's index ? */
1145 };
1146
1147 struct nix_txsch_free_req {
1148 struct mbox_msghdr hdr;
1149 #define TXSCHQ_FREE_ALL BIT_ULL(0)
1150 u16 flags;
1151 /* Scheduler queue level to be freed */
1152 u16 schq_lvl;
1153 /* List of scheduler queues to be freed */
1154 u16 schq;
1155 };
1156
1157 struct nix_txschq_config {
1158 struct mbox_msghdr hdr;
1159 u8 lvl; /* SMQ/MDQ/TL4/TL3/TL2/TL1 */
1160 u8 read;
1161 #define TXSCHQ_IDX_SHIFT 16
1162 #define TXSCHQ_IDX_MASK (BIT_ULL(10) - 1)
1163 #define TXSCHQ_IDX(reg, shift) (((reg) >> (shift)) & TXSCHQ_IDX_MASK)
1164 u8 num_regs;
1165 #define MAX_REGS_PER_MBOX_MSG 20
1166 u64 reg[MAX_REGS_PER_MBOX_MSG];
1167 u64 regval[MAX_REGS_PER_MBOX_MSG];
1168 /* All 0's => overwrite with new value */
1169 u64 regval_mask[MAX_REGS_PER_MBOX_MSG];
1170 };
1171
1172 struct nix_vtag_config {
1173 struct mbox_msghdr hdr;
1174 /* '0' for 4 octet VTAG, '1' for 8 octet VTAG */
1175 u8 vtag_size;
1176 /* cfg_type is '0' for tx vlan cfg
1177 * cfg_type is '1' for rx vlan cfg
1178 */
1179 u8 cfg_type;
1180 union {
1181 /* valid when cfg_type is '0' */
1182 struct {
1183 u64 vtag0;
1184 u64 vtag1;
1185
1186 /* cfg_vtag0 & cfg_vtag1 fields are valid
1187 * when free_vtag0 & free_vtag1 are '0's.
1188 */
1189 /* cfg_vtag0 = 1 to configure vtag0 */
1190 u8 cfg_vtag0 :1;
1191 /* cfg_vtag1 = 1 to configure vtag1 */
1192 u8 cfg_vtag1 :1;
1193
1194 /* vtag0_idx & vtag1_idx are only valid when
1195 * both cfg_vtag0 & cfg_vtag1 are '0's,
1196 * these fields are used along with free_vtag0
1197 * & free_vtag1 to free the nix lf's tx_vlan
1198 * configuration.
1199 *
1200 * Denotes the indices of tx_vtag def registers
1201 * that needs to be cleared and freed.
1202 */
1203 int vtag0_idx;
1204 int vtag1_idx;
1205
1206 /* free_vtag0 & free_vtag1 fields are valid
1207 * when cfg_vtag0 & cfg_vtag1 are '0's.
1208 */
1209 /* free_vtag0 = 1 clears vtag0 configuration
1210 * vtag0_idx denotes the index to be cleared.
1211 */
1212 u8 free_vtag0 :1;
1213 /* free_vtag1 = 1 clears vtag1 configuration
1214 * vtag1_idx denotes the index to be cleared.
1215 */
1216 u8 free_vtag1 :1;
1217 } tx;
1218
1219 /* valid when cfg_type is '1' */
1220 struct {
1221 /* rx vtag type index, valid values are in 0..7 range */
1222 u8 vtag_type;
1223 /* rx vtag strip */
1224 u8 strip_vtag :1;
1225 /* rx vtag capture */
1226 u8 capture_vtag :1;
1227 } rx;
1228 };
1229 };
1230
1231 struct nix_vtag_config_rsp {
1232 struct mbox_msghdr hdr;
1233 int vtag0_idx;
1234 int vtag1_idx;
1235 /* Indices of tx_vtag def registers used to configure
1236 * tx vtag0 & vtag1 headers, these indices are valid
1237 * when nix_vtag_config mbox requested for vtag0 and/
1238 * or vtag1 configuration.
1239 */
1240 };
1241
1242 #define NIX_FLOW_KEY_TYPE_L3_L4_MASK (~(0xf << 28))
1243
1244 struct nix_rss_flowkey_cfg {
1245 struct mbox_msghdr hdr;
1246 int mcam_index; /* MCAM entry index to modify */
1247 #define NIX_FLOW_KEY_TYPE_PORT BIT(0)
1248 #define NIX_FLOW_KEY_TYPE_IPV4 BIT(1)
1249 #define NIX_FLOW_KEY_TYPE_IPV6 BIT(2)
1250 #define NIX_FLOW_KEY_TYPE_TCP BIT(3)
1251 #define NIX_FLOW_KEY_TYPE_UDP BIT(4)
1252 #define NIX_FLOW_KEY_TYPE_SCTP BIT(5)
1253 #define NIX_FLOW_KEY_TYPE_NVGRE BIT(6)
1254 #define NIX_FLOW_KEY_TYPE_VXLAN BIT(7)
1255 #define NIX_FLOW_KEY_TYPE_GENEVE BIT(8)
1256 #define NIX_FLOW_KEY_TYPE_ETH_DMAC BIT(9)
1257 #define NIX_FLOW_KEY_TYPE_IPV6_EXT BIT(10)
1258 #define NIX_FLOW_KEY_TYPE_GTPU BIT(11)
1259 #define NIX_FLOW_KEY_TYPE_INNR_IPV4 BIT(12)
1260 #define NIX_FLOW_KEY_TYPE_INNR_IPV6 BIT(13)
1261 #define NIX_FLOW_KEY_TYPE_INNR_TCP BIT(14)
1262 #define NIX_FLOW_KEY_TYPE_INNR_UDP BIT(15)
1263 #define NIX_FLOW_KEY_TYPE_INNR_SCTP BIT(16)
1264 #define NIX_FLOW_KEY_TYPE_INNR_ETH_DMAC BIT(17)
1265 #define NIX_FLOW_KEY_TYPE_CUSTOM0 BIT(19)
1266 #define NIX_FLOW_KEY_TYPE_VLAN BIT(20)
1267 #define NIX_FLOW_KEY_TYPE_IPV4_PROTO BIT(21)
1268 #define NIX_FLOW_KEY_TYPE_AH BIT(22)
1269 #define NIX_FLOW_KEY_TYPE_ESP BIT(23)
1270 #define NIX_FLOW_KEY_TYPE_L4_DST_ONLY BIT(28)
1271 #define NIX_FLOW_KEY_TYPE_L4_SRC_ONLY BIT(29)
1272 #define NIX_FLOW_KEY_TYPE_L3_DST_ONLY BIT(30)
1273 #define NIX_FLOW_KEY_TYPE_L3_SRC_ONLY BIT(31)
1274 u32 flowkey_cfg; /* Flowkey types selected */
1275 u8 group; /* RSS context or group */
1276 };
1277
1278 struct nix_rss_flowkey_cfg_rsp {
1279 struct mbox_msghdr hdr;
1280 u8 alg_idx; /* Selected algo index */
1281 };
1282
1283 struct nix_set_mac_addr {
1284 struct mbox_msghdr hdr;
1285 u8 mac_addr[ETH_ALEN]; /* MAC address to be set for this pcifunc */
1286 };
1287
1288 struct nix_get_mac_addr_rsp {
1289 struct mbox_msghdr hdr;
1290 u8 mac_addr[ETH_ALEN];
1291 };
1292
1293 struct nix_mark_format_cfg {
1294 struct mbox_msghdr hdr;
1295 u8 offset;
1296 u8 y_mask;
1297 u8 y_val;
1298 u8 r_mask;
1299 u8 r_val;
1300 };
1301
1302 struct nix_mark_format_cfg_rsp {
1303 struct mbox_msghdr hdr;
1304 u8 mark_format_idx;
1305 };
1306
1307 struct nix_rx_mode {
1308 struct mbox_msghdr hdr;
1309 #define NIX_RX_MODE_UCAST BIT(0)
1310 #define NIX_RX_MODE_PROMISC BIT(1)
1311 #define NIX_RX_MODE_ALLMULTI BIT(2)
1312 #define NIX_RX_MODE_USE_MCE BIT(3)
1313 u16 mode;
1314 };
1315
1316 struct nix_rx_cfg {
1317 struct mbox_msghdr hdr;
1318 #define NIX_RX_OL3_VERIFY BIT(0)
1319 #define NIX_RX_OL4_VERIFY BIT(1)
1320 #define NIX_RX_DROP_RE BIT(2)
1321 u8 len_verify; /* Outer L3/L4 len check */
1322 #define NIX_RX_CSUM_OL4_VERIFY BIT(0)
1323 u8 csum_verify; /* Outer L4 checksum verification */
1324 };
1325
1326 struct nix_frs_cfg {
1327 struct mbox_msghdr hdr;
1328 u8 update_smq; /* Update SMQ's min/max lens */
1329 u8 update_minlen; /* Set minlen also */
1330 u8 sdp_link; /* Set SDP RX link */
1331 u16 maxlen;
1332 u16 minlen;
1333 };
1334
1335 struct nix_lso_format_cfg {
1336 struct mbox_msghdr hdr;
1337 u64 field_mask;
1338 #define NIX_LSO_FIELD_MAX 8
1339 u64 fields[NIX_LSO_FIELD_MAX];
1340 };
1341
1342 struct nix_lso_format_cfg_rsp {
1343 struct mbox_msghdr hdr;
1344 u8 lso_format_idx;
1345 };
1346
1347 struct nix_bp_cfg_req {
1348 struct mbox_msghdr hdr;
1349 u16 chan_base; /* Starting channel number */
1350 u8 chan_cnt; /* Number of channels */
1351 u8 bpid_per_chan;
1352 /* bpid_per_chan = 0 assigns single bp id for range of channels */
1353 /* bpid_per_chan = 1 assigns separate bp id for each channel */
1354 };
1355
1356 /* Maximum channels any single NIX interface can have */
1357 #define NIX_MAX_BPID_CHAN 256
1358 struct nix_bp_cfg_rsp {
1359 struct mbox_msghdr hdr;
1360 u16 chan_bpid[NIX_MAX_BPID_CHAN]; /* Channel and bpid mapping */
1361 u8 chan_cnt; /* Number of channel for which bpids are assigned */
1362 };
1363
1364 struct nix_mcast_grp_create_req {
1365 struct mbox_msghdr hdr;
1366 #define NIX_MCAST_INGRESS 0
1367 #define NIX_MCAST_EGRESS 1
1368 u8 dir;
1369 u8 reserved[11];
1370 /* Reserving few bytes for future requirement */
1371 };
1372
1373 struct nix_mcast_grp_create_rsp {
1374 struct mbox_msghdr hdr;
1375 /* This mcast_grp_idx should be passed during MCAM
1376 * write entry for multicast. AF will identify the
1377 * corresponding multicast table index associated
1378 * with the group id and program the same to MCAM entry.
1379 * This group id is also needed during group delete
1380 * and update request.
1381 */
1382 u32 mcast_grp_idx;
1383 };
1384
1385 struct nix_mcast_grp_destroy_req {
1386 struct mbox_msghdr hdr;
1387 /* Group id returned by nix_mcast_grp_create_rsp */
1388 u32 mcast_grp_idx;
1389 /* If AF is requesting for destroy, then set
1390 * it to '1'. Otherwise keep it to '0'
1391 */
1392 u8 is_af;
1393 };
1394
1395 struct nix_mcast_grp_update_req {
1396 struct mbox_msghdr hdr;
1397 /* Group id returned by nix_mcast_grp_create_rsp */
1398 u32 mcast_grp_idx;
1399 /* Number of multicast/mirror entries requested */
1400 u32 num_mce_entry;
1401 #define NIX_MCE_ENTRY_MAX 64
1402 #define NIX_RX_RQ 0
1403 #define NIX_RX_RSS 1
1404 /* Receive queue or RSS index within pf_func */
1405 u32 rq_rss_index[NIX_MCE_ENTRY_MAX];
1406 /* pcifunc is required for both ingress and egress multicast */
1407 u16 pcifunc[NIX_MCE_ENTRY_MAX];
1408 /* channel is required for egress multicast */
1409 u16 channel[NIX_MCE_ENTRY_MAX];
1410 #define NIX_MCAST_OP_ADD_ENTRY 0
1411 #define NIX_MCAST_OP_DEL_ENTRY 1
1412 /* Destination type. 0:Receive queue, 1:RSS*/
1413 u8 dest_type[NIX_MCE_ENTRY_MAX];
1414 u8 op;
1415 /* If AF is requesting for update, then set
1416 * it to '1'. Otherwise keep it to '0'
1417 */
1418 u8 is_af;
1419 };
1420
1421 struct nix_mcast_grp_update_rsp {
1422 struct mbox_msghdr hdr;
1423 u32 mce_start_index;
1424 };
1425
1426 /* Global NIX inline IPSec configuration */
1427 struct nix_inline_ipsec_cfg {
1428 struct mbox_msghdr hdr;
1429 u32 cpt_credit;
1430 struct {
1431 u8 egrp;
1432 u16 opcode;
1433 u16 param1;
1434 u16 param2;
1435 } gen_cfg;
1436 struct {
1437 u16 cpt_pf_func;
1438 u8 cpt_slot;
1439 } inst_qsel;
1440 u8 enable;
1441 u16 bpid;
1442 u32 credit_th;
1443 };
1444
1445 /* Per NIX LF inline IPSec configuration */
1446 struct nix_inline_ipsec_lf_cfg {
1447 struct mbox_msghdr hdr;
1448 u64 sa_base_addr;
1449 struct {
1450 u32 tag_const;
1451 u16 lenm1_max;
1452 u8 sa_pow2_size;
1453 u8 tt;
1454 } ipsec_cfg0;
1455 struct {
1456 u32 sa_idx_max;
1457 u8 sa_idx_w;
1458 } ipsec_cfg1;
1459 u8 enable;
1460 };
1461
1462 struct nix_hw_info {
1463 struct mbox_msghdr hdr;
1464 u16 rsvs16;
1465 u16 max_mtu;
1466 u16 min_mtu;
1467 u32 rpm_dwrr_mtu;
1468 u32 sdp_dwrr_mtu;
1469 u32 lbk_dwrr_mtu;
1470 u32 rsvd32[1];
1471 u64 rsvd[15]; /* Add reserved fields for future expansion */
1472 };
1473
1474 struct nix_bandprof_alloc_req {
1475 struct mbox_msghdr hdr;
1476 /* Count of profiles needed per layer */
1477 u16 prof_count[BAND_PROF_NUM_LAYERS];
1478 };
1479
1480 struct nix_bandprof_alloc_rsp {
1481 struct mbox_msghdr hdr;
1482 u16 prof_count[BAND_PROF_NUM_LAYERS];
1483
1484 /* There is no need to allocate morethan 1 bandwidth profile
1485 * per RQ of a PF_FUNC's NIXLF. So limit the maximum
1486 * profiles to 64 per PF_FUNC.
1487 */
1488 #define MAX_BANDPROF_PER_PFFUNC 64
1489 u16 prof_idx[BAND_PROF_NUM_LAYERS][MAX_BANDPROF_PER_PFFUNC];
1490 };
1491
1492 struct nix_bandprof_free_req {
1493 struct mbox_msghdr hdr;
1494 u8 free_all;
1495 u16 prof_count[BAND_PROF_NUM_LAYERS];
1496 u16 prof_idx[BAND_PROF_NUM_LAYERS][MAX_BANDPROF_PER_PFFUNC];
1497 };
1498
1499 struct nix_bandprof_get_hwinfo_rsp {
1500 struct mbox_msghdr hdr;
1501 u16 prof_count[BAND_PROF_NUM_LAYERS];
1502 u32 policer_timeunit;
1503 };
1504
1505 struct nix_stats_req {
1506 struct mbox_msghdr hdr;
1507 u8 reset;
1508 u16 pcifunc;
1509 u64 rsvd;
1510 };
1511
1512 struct nix_stats_rsp {
1513 struct mbox_msghdr hdr;
1514 u16 pcifunc;
1515 struct {
1516 u64 octs;
1517 u64 ucast;
1518 u64 bcast;
1519 u64 mcast;
1520 u64 drop;
1521 u64 drop_octs;
1522 u64 drop_mcast;
1523 u64 drop_bcast;
1524 u64 err;
1525 u64 rsvd[5];
1526 } rx;
1527 struct {
1528 u64 ucast;
1529 u64 bcast;
1530 u64 mcast;
1531 u64 drop;
1532 u64 octs;
1533 } tx;
1534 };
1535
1536 /* NPC mbox message structs */
1537
1538 #define NPC_MCAM_ENTRY_INVALID 0xFFFF
1539 #define NPC_MCAM_INVALID_MAP 0xFFFF
1540
1541 /* NPC mailbox error codes
1542 * Range 701 - 800.
1543 */
1544 enum npc_af_status {
1545 NPC_MCAM_INVALID_REQ = -701,
1546 NPC_MCAM_ALLOC_DENIED = -702,
1547 NPC_MCAM_ALLOC_FAILED = -703,
1548 NPC_MCAM_PERM_DENIED = -704,
1549 NPC_FLOW_INTF_INVALID = -707,
1550 NPC_FLOW_CHAN_INVALID = -708,
1551 NPC_FLOW_NO_NIXLF = -709,
1552 NPC_FLOW_NOT_SUPPORTED = -710,
1553 NPC_FLOW_VF_PERM_DENIED = -711,
1554 NPC_FLOW_VF_NOT_INIT = -712,
1555 NPC_FLOW_VF_OVERLAP = -713,
1556 };
1557
1558 struct npc_mcam_alloc_entry_req {
1559 struct mbox_msghdr hdr;
1560 #define NPC_MAX_NONCONTIG_ENTRIES 256
1561 u8 contig; /* Contiguous entries ? */
1562 #define NPC_MCAM_ANY_PRIO 0
1563 #define NPC_MCAM_LOWER_PRIO 1
1564 #define NPC_MCAM_HIGHER_PRIO 2
1565 u8 ref_prio; /* Lower or higher w.r.t ref_entry */
1566 u16 ref_entry;
1567 u16 count; /* Number of entries requested */
1568 u8 kw_type; /* entry key type, valid for cn20k */
1569 u8 virt; /* Request virtual index */
1570 };
1571
1572 struct npc_mcam_alloc_entry_rsp {
1573 struct mbox_msghdr hdr;
1574 u16 entry; /* Entry allocated or start index if contiguous.
1575 * Invalid incase of non-contiguous.
1576 */
1577 u16 count; /* Number of entries allocated */
1578 u16 free_count; /* Number of entries available */
1579 u16 entry_list[NPC_MAX_NONCONTIG_ENTRIES];
1580 };
1581
1582 struct npc_mcam_free_entry_req {
1583 struct mbox_msghdr hdr;
1584 u16 entry; /* Entry index to be freed */
1585 u8 all; /* If all entries allocated to this PFVF to be freed */
1586 };
1587
1588 struct mcam_entry_mdata {
1589 u64 *kw;
1590 u64 *kw_mask;
1591 u64 *action;
1592 u64 *vtag_action;
1593 u8 max_kw;
1594 };
1595
1596 enum npc_kws_in_key_sz {
1597 NPC_KWS_IN_KEY_SZ_7 = 7,
1598 NPC_KWS_IN_KEY_SZ_8 = 8,
1599 NPC_KWS_IN_KEY_SZ_MAX,
1600 };
1601
1602 struct mcam_entry {
1603 u64 kw[NPC_KWS_IN_KEY_SZ_7];
1604 u64 kw_mask[NPC_KWS_IN_KEY_SZ_7];
1605 u64 action;
1606 u64 vtag_action;
1607 };
1608
1609 struct cn20k_mcam_entry {
1610 u64 kw[NPC_KWS_IN_KEY_SZ_8];
1611 u64 kw_mask[NPC_KWS_IN_KEY_SZ_8];
1612 u64 action;
1613 u64 vtag_action;
1614 u64 action2;
1615 };
1616
1617 struct npc_cn20k_mcam_write_entry_req {
1618 struct mbox_msghdr hdr;
1619 struct cn20k_mcam_entry entry_data;
1620 u16 entry; /* MCAM entry to write this match key */
1621 u16 cntr; /* Counter for this MCAM entry */
1622 u8 intf; /* Rx or Tx interface */
1623 u8 enable_entry;/* Enable this MCAM entry ? */
1624 u8 hw_prio; /* hardware priority, valid for cn20k */
1625 u8 req_kw_type; /* Type of kw which should be written */
1626 u64 reserved; /* reserved for future use */
1627 };
1628
1629 struct npc_mcam_write_entry_req {
1630 struct mbox_msghdr hdr;
1631 struct mcam_entry entry_data;
1632 u16 entry; /* MCAM entry to write this match key */
1633 u16 cntr; /* Counter for this MCAM entry */
1634 u8 intf; /* Rx or Tx interface */
1635 u8 enable_entry;/* Enable this MCAM entry ? */
1636 u8 set_cntr; /* Set counter for this entry ? */
1637 u8 hw_prio; /* hardware priority, valid for cn20k */
1638 u64 reserved; /* reserved for future use */
1639 };
1640
1641 /* Enable/Disable a given entry */
1642 struct npc_mcam_ena_dis_entry_req {
1643 struct mbox_msghdr hdr;
1644 u16 entry;
1645 };
1646
1647 struct npc_mcam_shift_entry_req {
1648 struct mbox_msghdr hdr;
1649 #define NPC_MCAM_MAX_SHIFTS 64
1650 u16 curr_entry[NPC_MCAM_MAX_SHIFTS];
1651 u16 new_entry[NPC_MCAM_MAX_SHIFTS];
1652 u16 shift_count; /* Number of entries to shift */
1653 };
1654
1655 struct npc_mcam_shift_entry_rsp {
1656 struct mbox_msghdr hdr;
1657 u16 failed_entry_idx; /* Index in 'curr_entry', not entry itself */
1658 };
1659
1660 struct npc_mcam_alloc_counter_req {
1661 struct mbox_msghdr hdr;
1662 u8 contig; /* Contiguous counters ? */
1663 #define NPC_MAX_NONCONTIG_COUNTERS 64
1664 u16 count; /* Number of counters requested */
1665 };
1666
1667 struct npc_mcam_alloc_counter_rsp {
1668 struct mbox_msghdr hdr;
1669 u16 cntr; /* Counter allocated or start index if contiguous.
1670 * Invalid incase of non-contiguous.
1671 */
1672 u16 count; /* Number of counters allocated */
1673 u16 cntr_list[NPC_MAX_NONCONTIG_COUNTERS];
1674 };
1675
1676 struct npc_mcam_oper_counter_req {
1677 struct mbox_msghdr hdr;
1678 u16 cntr; /* Free a counter or clear/fetch it's stats */
1679 };
1680
1681 struct npc_mcam_oper_counter_rsp {
1682 struct mbox_msghdr hdr;
1683 u64 stat; /* valid only while fetching counter's stats */
1684 };
1685
1686 struct npc_mcam_unmap_counter_req {
1687 struct mbox_msghdr hdr;
1688 u16 cntr;
1689 u16 entry; /* Entry and counter to be unmapped */
1690 u8 all; /* Unmap all entries using this counter ? */
1691 };
1692
1693 struct npc_mcam_alloc_and_write_entry_req {
1694 struct mbox_msghdr hdr;
1695 struct mcam_entry entry_data;
1696 u16 ref_entry;
1697 u8 ref_prio; /* Lower or higher w.r.t ref_entry */
1698 u8 intf; /* Rx or Tx interface */
1699 u8 enable_entry;/* Enable this MCAM entry ? */
1700 u8 alloc_cntr; /* Allocate counter and map ? */
1701 };
1702
1703 struct npc_cn20k_mcam_alloc_and_write_entry_req {
1704 struct mbox_msghdr hdr;
1705 struct cn20k_mcam_entry entry_data;
1706 u16 ref_entry;
1707 u8 ref_prio; /* Lower or higher w.r.t ref_entry */
1708 u8 intf; /* Rx or Tx interface */
1709 u8 enable_entry;/* Enable this MCAM entry ? */
1710 u8 hw_prio; /* hardware priority, valid for cn20k */
1711 u8 virt; /* Allocate virtual index */
1712 u8 req_kw_type; /* Key type to be written */
1713 u16 reserved[4]; /* reserved for future use */
1714 };
1715
1716 struct npc_cn20k_mcam_read_entry_rsp {
1717 struct mbox_msghdr hdr;
1718 struct cn20k_mcam_entry entry_data;
1719 u8 intf;
1720 u8 enable;
1721 u8 hw_prio; /* valid for cn20k */
1722 };
1723
1724 struct npc_cn20k_mcam_read_base_rule_rsp {
1725 struct mbox_msghdr hdr;
1726 struct cn20k_mcam_entry entry;
1727 };
1728
1729 struct npc_mcam_alloc_and_write_entry_rsp {
1730 struct mbox_msghdr hdr;
1731 u16 entry;
1732 u16 cntr;
1733 };
1734
1735 struct npc_get_kex_cfg_rsp {
1736 struct mbox_msghdr hdr;
1737 u64 rx_keyx_cfg; /* NPC_AF_INTF(0)_KEX_CFG */
1738 u64 tx_keyx_cfg; /* NPC_AF_INTF(1)_KEX_CFG */
1739 #define NPC_MAX_INTF 2
1740 #define NPC_MAX_LID 8
1741 #define NPC_MAX_LT 16
1742 #define NPC_MAX_LD 2
1743 #define NPC_MAX_LFL 16
1744 /* NPC_AF_KEX_LDATA(0..1)_FLAGS_CFG */
1745 u64 kex_ld_flags[NPC_MAX_LD];
1746 /* NPC_AF_INTF(0..1)_LID(0..7)_LT(0..15)_LD(0..1)_CFG */
1747 u64 intf_lid_lt_ld[NPC_MAX_INTF][NPC_MAX_LID][NPC_MAX_LT][NPC_MAX_LD];
1748 /* NPC_AF_INTF(0..1)_LDATA(0..1)_FLAGS(0..15)_CFG */
1749 u64 intf_ld_flags[NPC_MAX_INTF][NPC_MAX_LD][NPC_MAX_LFL];
1750 #define MKEX_NAME_LEN 128
1751 u8 mkex_pfl_name[MKEX_NAME_LEN];
1752 };
1753
1754 struct npc_cn20k_get_kex_cfg_rsp {
1755 struct mbox_msghdr hdr;
1756 u64 rx_keyx_cfg; /* NPC_AF_INTF(0)_KEX_CFG */
1757 u64 tx_keyx_cfg; /* NPC_AF_INTF(1)_KEX_CFG */
1758 #define NPC_MAX_EXTRACTOR 24
1759 /* MKEX Extractor data */
1760 u64 intf_extr_lid[NPC_MAX_INTF][NPC_MAX_EXTRACTOR];
1761 /* KEX configuration per extractor */
1762 u64 intf_extr_lt[NPC_MAX_INTF][NPC_MAX_EXTRACTOR][NPC_MAX_LT];
1763 #define MKEX_NAME_LEN 128
1764 u8 mkex_pfl_name[MKEX_NAME_LEN];
1765 };
1766
1767 struct ptp_get_cap_rsp {
1768 struct mbox_msghdr hdr;
1769 #define PTP_CAP_HW_ATOMIC_UPDATE BIT_ULL(0)
1770 u64 cap;
1771 };
1772
1773 struct get_rep_cnt_rsp {
1774 struct mbox_msghdr hdr;
1775 u16 rep_cnt;
1776 u16 rep_pf_map[64];
1777 u64 rsvd;
1778 };
1779
1780 struct esw_cfg_req {
1781 struct mbox_msghdr hdr;
1782 u8 ena;
1783 u64 rsvd;
1784 };
1785
1786 struct rep_evt_data {
1787 u8 port_state;
1788 u8 vf_state;
1789 u16 rx_mode;
1790 u16 rx_flags;
1791 u16 mtu;
1792 u8 mac[ETH_ALEN];
1793 u64 rsvd[5];
1794 };
1795
1796 struct rep_event {
1797 struct mbox_msghdr hdr;
1798 u16 pcifunc;
1799 #define RVU_EVENT_PORT_STATE BIT_ULL(0)
1800 #define RVU_EVENT_PFVF_STATE BIT_ULL(1)
1801 #define RVU_EVENT_MTU_CHANGE BIT_ULL(2)
1802 #define RVU_EVENT_RX_MODE_CHANGE BIT_ULL(3)
1803 #define RVU_EVENT_MAC_ADDR_CHANGE BIT_ULL(4)
1804 u16 event;
1805 struct rep_evt_data evt_data;
1806 };
1807
1808 struct flow_msg {
1809 unsigned char dmac[6];
1810 unsigned char smac[6];
1811 __be16 etype;
1812 __be16 vlan_etype;
1813 __be16 vlan_tci;
1814 union {
1815 __be32 ip4src;
1816 __be32 ip6src[4];
1817 };
1818 union {
1819 __be32 ip4dst;
1820 __be32 ip6dst[4];
1821 };
1822 union {
1823 __be32 spi;
1824 };
1825
1826 u8 tos;
1827 u8 ip_ver;
1828 u8 ip_proto;
1829 u8 tc;
1830 __be16 sport;
1831 __be16 dport;
1832 union {
1833 u8 ip_flag;
1834 u8 next_header;
1835 };
1836 __be16 vlan_itci;
1837 #define OTX2_FLOWER_MASK_MPLS_LB GENMASK(31, 12)
1838 #define OTX2_FLOWER_MASK_MPLS_TC GENMASK(11, 9)
1839 #define OTX2_FLOWER_MASK_MPLS_BOS BIT(8)
1840 #define OTX2_FLOWER_MASK_MPLS_TTL GENMASK(7, 0)
1841 #define OTX2_FLOWER_MASK_MPLS_NON_TTL GENMASK(31, 8)
1842 u32 mpls_lse[4];
1843 u8 icmp_type;
1844 u8 icmp_code;
1845 __be16 tcp_flags;
1846 u16 sq_id;
1847 };
1848
1849 struct npc_install_flow_req {
1850 struct mbox_msghdr hdr;
1851 struct flow_msg packet;
1852 struct flow_msg mask;
1853 u64 features;
1854 u16 entry;
1855 u16 channel;
1856 u16 chan_mask;
1857 u8 intf;
1858 u8 set_cntr; /* If counter is available set counter for this entry ? */
1859 u8 default_rule;
1860 u8 append; /* overwrite(0) or append(1) flow to default rule? */
1861 u16 vf;
1862 /* action */
1863 u32 index;
1864 u16 match_id;
1865 u8 flow_key_alg;
1866 u8 op;
1867 /* vtag rx action */
1868 u8 vtag0_type;
1869 u8 vtag0_valid;
1870 u8 vtag1_type;
1871 u8 vtag1_valid;
1872 /* vtag tx action */
1873 u16 vtag0_def;
1874 u8 vtag0_op;
1875 u16 vtag1_def;
1876 u8 vtag1_op;
1877 /* old counter value */
1878 u16 cntr_val;
1879 u8 hw_prio;
1880 u8 req_kw_type; /* Key type to be written */
1881 u8 alloc_entry; /* only for cn20k */
1882 /* For now use any priority, once AF driver is changed to
1883 * allocate least priority entry instead of mid zone then make
1884 * NPC_MCAM_LEAST_PRIO as 3
1885 */
1886 #define NPC_MCAM_LEAST_PRIO NPC_MCAM_ANY_PRIO
1887 u16 ref_prio;
1888 u16 ref_entry;
1889 };
1890
1891 struct npc_install_flow_rsp {
1892 struct mbox_msghdr hdr;
1893 int counter; /* negative if no counter else counter number */
1894 u16 entry;
1895 u8 kw_type;
1896 };
1897
1898 struct npc_get_num_kws_req {
1899 struct mbox_msghdr hdr;
1900 struct npc_install_flow_req fl;
1901 u32 rsvd[4];
1902 };
1903
1904 struct npc_get_num_kws_rsp {
1905 struct mbox_msghdr hdr;
1906 int kws;
1907 u32 rsvd[4];
1908 };
1909
1910 struct npc_get_dft_rl_idxs_rsp {
1911 struct mbox_msghdr hdr;
1912 u16 bcast;
1913 u16 mcast;
1914 u16 promisc;
1915 u16 ucast;
1916 u16 vf_ucast;
1917 u16 rsvd[7];
1918 };
1919
1920 struct npc_get_pfl_info_rsp {
1921 struct mbox_msghdr hdr;
1922 u16 x4_slots;
1923 u8 kw_type;
1924 u8 rsvd1[3];
1925 u32 rsvd2[4];
1926 };
1927
1928 struct npc_delete_flow_req {
1929 struct mbox_msghdr hdr;
1930 u16 entry;
1931 u16 start;/*Disable range of entries */
1932 u16 end;
1933 u8 all; /* PF + VFs */
1934 };
1935
1936 struct npc_delete_flow_rsp {
1937 struct mbox_msghdr hdr;
1938 u16 cntr_val;
1939 };
1940
1941 struct npc_mcam_read_entry_req {
1942 struct mbox_msghdr hdr;
1943 u16 entry; /* MCAM entry to read */
1944 };
1945
1946 struct npc_mcam_read_entry_rsp {
1947 struct mbox_msghdr hdr;
1948 struct mcam_entry entry_data;
1949 u8 intf;
1950 u8 enable;
1951 u8 hw_prio; /* valid for cn20k */
1952 };
1953
1954 /* Available entries to use */
1955 struct npc_cn20k_get_fcnt_rsp {
1956 struct mbox_msghdr hdr;
1957 int free_x2;
1958 int free_x4;
1959 int free_subbanks;
1960 };
1961
1962 struct npc_mcam_read_base_rule_rsp {
1963 struct mbox_msghdr hdr;
1964 struct mcam_entry entry;
1965 };
1966
1967 struct npc_mcam_get_stats_req {
1968 struct mbox_msghdr hdr;
1969 u16 entry; /* mcam entry */
1970 };
1971
1972 struct npc_mcam_get_stats_rsp {
1973 struct mbox_msghdr hdr;
1974 u64 stat; /* counter stats */
1975 u8 stat_ena; /* enabled */
1976 };
1977
1978 struct npc_get_field_hash_info_req {
1979 struct mbox_msghdr hdr;
1980 u8 intf;
1981 };
1982
1983 struct npc_get_field_hash_info_rsp {
1984 struct mbox_msghdr hdr;
1985 u64 secret_key[3];
1986 #define NPC_MAX_HASH 2
1987 #define NPC_MAX_HASH_MASK 2
1988 /* NPC_AF_INTF(0..1)_HASH(0..1)_MASK(0..1) */
1989 u64 hash_mask[NPC_MAX_INTF][NPC_MAX_HASH][NPC_MAX_HASH_MASK];
1990 /* NPC_AF_INTF(0..1)_HASH(0..1)_RESULT_CTRL */
1991 u64 hash_ctrl[NPC_MAX_INTF][NPC_MAX_HASH];
1992 };
1993
1994 enum ptp_op {
1995 PTP_OP_ADJFINE = 0,
1996 PTP_OP_GET_CLOCK = 1,
1997 PTP_OP_GET_TSTMP = 2,
1998 PTP_OP_SET_THRESH = 3,
1999 PTP_OP_PPS_ON = 4,
2000 PTP_OP_ADJTIME = 5,
2001 PTP_OP_SET_CLOCK = 6,
2002 };
2003
2004 struct ptp_req {
2005 struct mbox_msghdr hdr;
2006 u8 op;
2007 s64 scaled_ppm;
2008 u64 thresh;
2009 u64 period;
2010 int pps_on;
2011 s64 delta;
2012 u64 clk;
2013 };
2014
2015 struct ptp_rsp {
2016 struct mbox_msghdr hdr;
2017 u64 clk;
2018 u64 tsc;
2019 };
2020
2021 struct npc_get_field_status_req {
2022 struct mbox_msghdr hdr;
2023 u8 intf;
2024 u8 field;
2025 };
2026
2027 struct npc_get_field_status_rsp {
2028 struct mbox_msghdr hdr;
2029 u8 enable;
2030 };
2031
2032 struct set_vf_perm {
2033 struct mbox_msghdr hdr;
2034 u16 vf;
2035 #define RESET_VF_PERM BIT_ULL(0)
2036 #define VF_TRUSTED BIT_ULL(1)
2037 u64 flags;
2038 };
2039
2040 struct lmtst_tbl_setup_req {
2041 struct mbox_msghdr hdr;
2042 u64 dis_sched_early_comp :1;
2043 u64 sch_ena :1;
2044 u64 dis_line_pref :1;
2045 u64 ssow_pf_func :13;
2046 u16 base_pcifunc;
2047 u8 use_local_lmt_region;
2048 u64 lmt_iova;
2049 u64 rsvd[4];
2050 };
2051
2052 struct ndc_sync_op {
2053 struct mbox_msghdr hdr;
2054 u8 nix_lf_tx_sync;
2055 u8 nix_lf_rx_sync;
2056 u8 npa_lf_sync;
2057 };
2058
2059 /* CPT mailbox error codes
2060 * Range 901 - 1000.
2061 */
2062 enum cpt_af_status {
2063 CPT_AF_ERR_PARAM = -901,
2064 CPT_AF_ERR_GRP_INVALID = -902,
2065 CPT_AF_ERR_LF_INVALID = -903,
2066 CPT_AF_ERR_ACCESS_DENIED = -904,
2067 CPT_AF_ERR_SSO_PF_FUNC_INVALID = -905,
2068 CPT_AF_ERR_NIX_PF_FUNC_INVALID = -906,
2069 CPT_AF_ERR_INLINE_IPSEC_INB_ENA = -907,
2070 CPT_AF_ERR_INLINE_IPSEC_OUT_ENA = -908
2071 };
2072
2073 /* CPT mbox message formats */
2074 struct cpt_rd_wr_reg_msg {
2075 struct mbox_msghdr hdr;
2076 u64 reg_offset;
2077 u64 *ret_val;
2078 u64 val;
2079 u8 is_write;
2080 int blkaddr;
2081 };
2082
2083 struct cpt_lf_alloc_req_msg {
2084 struct mbox_msghdr hdr;
2085 u16 nix_pf_func;
2086 u16 sso_pf_func;
2087 u16 eng_grpmsk;
2088 u8 blkaddr;
2089 u8 ctx_ilen_valid : 1;
2090 u8 ctx_ilen : 7;
2091 };
2092
2093 #define CPT_INLINE_INBOUND 0
2094 #define CPT_INLINE_OUTBOUND 1
2095
2096 /* Mailbox message request format for CPT IPsec
2097 * inline inbound and outbound configuration.
2098 */
2099 struct cpt_inline_ipsec_cfg_msg {
2100 struct mbox_msghdr hdr;
2101 u8 enable;
2102 u8 slot;
2103 u8 dir;
2104 u8 sso_pf_func_ovrd;
2105 u16 sso_pf_func; /* inbound path SSO_PF_FUNC */
2106 u16 nix_pf_func; /* outbound path NIX_PF_FUNC */
2107 };
2108
2109 /* Mailbox message request and response format for CPT stats. */
2110 struct cpt_sts_req {
2111 struct mbox_msghdr hdr;
2112 u8 blkaddr;
2113 };
2114
2115 struct cpt_sts_rsp {
2116 struct mbox_msghdr hdr;
2117 u64 inst_req_pc;
2118 u64 inst_lat_pc;
2119 u64 rd_req_pc;
2120 u64 rd_lat_pc;
2121 u64 rd_uc_pc;
2122 u64 active_cycles_pc;
2123 u64 ctx_mis_pc;
2124 u64 ctx_hit_pc;
2125 u64 ctx_aop_pc;
2126 u64 ctx_aop_lat_pc;
2127 u64 ctx_ifetch_pc;
2128 u64 ctx_ifetch_lat_pc;
2129 u64 ctx_ffetch_pc;
2130 u64 ctx_ffetch_lat_pc;
2131 u64 ctx_wback_pc;
2132 u64 ctx_wback_lat_pc;
2133 u64 ctx_psh_pc;
2134 u64 ctx_psh_lat_pc;
2135 u64 ctx_err;
2136 u64 ctx_enc_id;
2137 u64 ctx_flush_timer;
2138 u64 rxc_time;
2139 u64 rxc_time_cfg;
2140 u64 rxc_active_sts;
2141 u64 rxc_zombie_sts;
2142 u64 busy_sts_ae;
2143 u64 free_sts_ae;
2144 u64 busy_sts_se;
2145 u64 free_sts_se;
2146 u64 busy_sts_ie;
2147 u64 free_sts_ie;
2148 u64 exe_err_info;
2149 u64 cptclk_cnt;
2150 u64 diag;
2151 u64 rxc_dfrg;
2152 u64 x2p_link_cfg0;
2153 u64 x2p_link_cfg1;
2154 };
2155
2156 /* Mailbox message request format to configure reassembly timeout. */
2157 struct cpt_rxc_time_cfg_req {
2158 struct mbox_msghdr hdr;
2159 int blkaddr;
2160 u32 step;
2161 u16 zombie_thres;
2162 u16 zombie_limit;
2163 u16 active_thres;
2164 u16 active_limit;
2165 };
2166
2167 /* Mailbox message request format to request for CPT_INST_S lmtst. */
2168 struct cpt_inst_lmtst_req {
2169 struct mbox_msghdr hdr;
2170 u64 inst[8];
2171 u64 rsvd;
2172 };
2173
2174 /* Mailbox message format to request for CPT LF reset */
2175 struct cpt_lf_rst_req {
2176 struct mbox_msghdr hdr;
2177 u32 slot;
2178 u32 rsvd;
2179 };
2180
2181 /* Mailbox message format to request for CPT faulted engines */
2182 struct cpt_flt_eng_info_req {
2183 struct mbox_msghdr hdr;
2184 int blkaddr;
2185 bool reset;
2186 u32 rsvd;
2187 };
2188
2189 struct cpt_flt_eng_info_rsp {
2190 struct mbox_msghdr hdr;
2191 #define CPT_AF_MAX_FLT_INT_VECS 3
2192 u64 flt_eng_map[CPT_AF_MAX_FLT_INT_VECS];
2193 u64 rcvrd_eng_map[CPT_AF_MAX_FLT_INT_VECS];
2194 u64 rsvd;
2195 };
2196
2197 struct sdp_node_info {
2198 /* Node to which this PF belons to */
2199 u8 node_id;
2200 u8 max_vfs;
2201 u8 num_pf_rings;
2202 u8 pf_srn;
2203 #define SDP_MAX_VFS 128
2204 u8 vf_rings[SDP_MAX_VFS];
2205 };
2206
2207 struct sdp_chan_info_msg {
2208 struct mbox_msghdr hdr;
2209 struct sdp_node_info info;
2210 };
2211
2212 struct sdp_get_chan_info_msg {
2213 struct mbox_msghdr hdr;
2214 u16 chan_base;
2215 u16 num_chan;
2216 };
2217
2218 /* CGX mailbox error codes
2219 * Range 1101 - 1200.
2220 */
2221 enum cgx_af_status {
2222 LMAC_AF_ERR_INVALID_PARAM = -1101,
2223 LMAC_AF_ERR_PF_NOT_MAPPED = -1102,
2224 LMAC_AF_ERR_PERM_DENIED = -1103,
2225 LMAC_AF_ERR_PFC_ENADIS_PERM_DENIED = -1104,
2226 LMAC_AF_ERR_8023PAUSE_ENADIS_PERM_DENIED = -1105,
2227 LMAC_AF_ERR_CMD_TIMEOUT = -1106,
2228 LMAC_AF_ERR_FIRMWARE_DATA_NOT_MAPPED = -1107,
2229 LMAC_AF_ERR_EXACT_MATCH_TBL_ADD_FAILED = -1108,
2230 LMAC_AF_ERR_EXACT_MATCH_TBL_DEL_FAILED = -1109,
2231 LMAC_AF_ERR_EXACT_MATCH_TBL_LOOK_UP_FAILED = -1110,
2232 };
2233
2234 enum mcs_direction {
2235 MCS_RX,
2236 MCS_TX,
2237 };
2238
2239 enum mcs_rsrc_type {
2240 MCS_RSRC_TYPE_FLOWID,
2241 MCS_RSRC_TYPE_SECY,
2242 MCS_RSRC_TYPE_SC,
2243 MCS_RSRC_TYPE_SA,
2244 };
2245
2246 struct mcs_alloc_rsrc_req {
2247 struct mbox_msghdr hdr;
2248 u8 rsrc_type;
2249 u8 rsrc_cnt; /* Resources count */
2250 u8 mcs_id; /* MCS block ID */
2251 u8 dir; /* Macsec ingress or egress side */
2252 u8 all; /* Allocate all resource type one each */
2253 u64 rsvd;
2254 };
2255
2256 struct mcs_alloc_rsrc_rsp {
2257 struct mbox_msghdr hdr;
2258 u8 flow_ids[128]; /* Index of reserved entries */
2259 u8 secy_ids[128];
2260 u8 sc_ids[128];
2261 u8 sa_ids[256];
2262 u8 rsrc_type;
2263 u8 rsrc_cnt; /* No of entries reserved */
2264 u8 mcs_id;
2265 u8 dir;
2266 u8 all;
2267 u8 rsvd[256]; /* reserved fields for future expansion */
2268 };
2269
2270 struct mcs_free_rsrc_req {
2271 struct mbox_msghdr hdr;
2272 u8 rsrc_id; /* Index of the entry to be freed */
2273 u8 rsrc_type;
2274 u8 mcs_id;
2275 u8 dir;
2276 u8 all; /* Free all the cam resources */
2277 u64 rsvd;
2278 };
2279
2280 struct mcs_flowid_entry_write_req {
2281 struct mbox_msghdr hdr;
2282 u64 data[4];
2283 u64 mask[4];
2284 u64 sci; /* CNF10K-B for tx_secy_mem_map */
2285 u8 flow_id;
2286 u8 secy_id; /* secyid for which flowid is mapped */
2287 u8 sc_id; /* Valid if dir = MCS_TX, SC_CAM id mapped to flowid */
2288 u8 ena; /* Enable tcam entry */
2289 u8 ctrl_pkt;
2290 u8 mcs_id;
2291 u8 dir;
2292 u64 rsvd;
2293 };
2294
2295 struct mcs_secy_plcy_write_req {
2296 struct mbox_msghdr hdr;
2297 u64 plcy;
2298 u8 secy_id;
2299 u8 mcs_id;
2300 u8 dir;
2301 u64 rsvd;
2302 };
2303
2304 /* RX SC_CAM mapping */
2305 struct mcs_rx_sc_cam_write_req {
2306 struct mbox_msghdr hdr;
2307 u64 sci; /* SCI */
2308 u64 secy_id; /* secy index mapped to SC */
2309 u8 sc_id; /* SC CAM entry index */
2310 u8 mcs_id;
2311 u64 rsvd;
2312 };
2313
2314 struct mcs_sa_plcy_write_req {
2315 struct mbox_msghdr hdr;
2316 u64 plcy[2][9]; /* Support 2 SA policy */
2317 u8 sa_index[2];
2318 u8 sa_cnt;
2319 u8 mcs_id;
2320 u8 dir;
2321 u64 rsvd;
2322 };
2323
2324 struct mcs_tx_sc_sa_map {
2325 struct mbox_msghdr hdr;
2326 u8 sa_index0;
2327 u8 sa_index1;
2328 u8 rekey_ena;
2329 u8 sa_index0_vld;
2330 u8 sa_index1_vld;
2331 u8 tx_sa_active;
2332 u64 sectag_sci;
2333 u8 sc_id; /* used as index for SA_MEM_MAP */
2334 u8 mcs_id;
2335 u64 rsvd;
2336 };
2337
2338 struct mcs_rx_sc_sa_map {
2339 struct mbox_msghdr hdr;
2340 u8 sa_index;
2341 u8 sa_in_use;
2342 u8 sc_id;
2343 u8 an; /* value range 0-3, sc_id + an used as index SA_MEM_MAP */
2344 u8 mcs_id;
2345 u64 rsvd;
2346 };
2347
2348 struct mcs_flowid_ena_dis_entry {
2349 struct mbox_msghdr hdr;
2350 u8 flow_id;
2351 u8 ena;
2352 u8 mcs_id;
2353 u8 dir;
2354 u64 rsvd;
2355 };
2356
2357 struct mcs_pn_table_write_req {
2358 struct mbox_msghdr hdr;
2359 u64 next_pn;
2360 u8 pn_id;
2361 u8 mcs_id;
2362 u8 dir;
2363 u64 rsvd;
2364 };
2365
2366 struct mcs_hw_info {
2367 struct mbox_msghdr hdr;
2368 u8 num_mcs_blks; /* Number of MCS blocks */
2369 u8 tcam_entries; /* RX/TX Tcam entries per mcs block */
2370 u8 secy_entries; /* RX/TX SECY entries per mcs block */
2371 u8 sc_entries; /* RX/TX SC CAM entries per mcs block */
2372 u16 sa_entries; /* PN table entries = SA entries */
2373 u64 rsvd[16];
2374 };
2375
2376 struct mcs_set_active_lmac {
2377 struct mbox_msghdr hdr;
2378 u32 lmac_bmap; /* bitmap of active lmac per mcs block */
2379 u8 mcs_id;
2380 u16 chan_base; /* MCS channel base */
2381 u64 rsvd;
2382 };
2383
2384 struct mcs_set_lmac_mode {
2385 struct mbox_msghdr hdr;
2386 u8 mode; /* 1:Bypass 0:Operational */
2387 u8 lmac_id;
2388 u8 mcs_id;
2389 u64 rsvd;
2390 };
2391
2392 struct mcs_port_reset_req {
2393 struct mbox_msghdr hdr;
2394 u8 reset;
2395 u8 mcs_id;
2396 u8 port_id;
2397 u64 rsvd;
2398 };
2399
2400 struct mcs_port_cfg_set_req {
2401 struct mbox_msghdr hdr;
2402 u8 cstm_tag_rel_mode_sel;
2403 u8 custom_hdr_enb;
2404 u8 fifo_skid;
2405 u8 port_mode;
2406 u8 port_id;
2407 u8 mcs_id;
2408 u64 rsvd;
2409 };
2410
2411 struct mcs_port_cfg_get_req {
2412 struct mbox_msghdr hdr;
2413 u8 port_id;
2414 u8 mcs_id;
2415 u64 rsvd;
2416 };
2417
2418 struct mcs_port_cfg_get_rsp {
2419 struct mbox_msghdr hdr;
2420 u8 cstm_tag_rel_mode_sel;
2421 u8 custom_hdr_enb;
2422 u8 fifo_skid;
2423 u8 port_mode;
2424 u8 port_id;
2425 u8 mcs_id;
2426 u64 rsvd;
2427 };
2428
2429 struct mcs_custom_tag_cfg_get_req {
2430 struct mbox_msghdr hdr;
2431 u8 mcs_id;
2432 u8 dir;
2433 u64 rsvd;
2434 };
2435
2436 struct mcs_custom_tag_cfg_get_rsp {
2437 struct mbox_msghdr hdr;
2438 u16 cstm_etype[8];
2439 u8 cstm_indx[8];
2440 u8 cstm_etype_en;
2441 u8 mcs_id;
2442 u8 dir;
2443 u64 rsvd;
2444 };
2445
2446 /* MCS mailbox error codes
2447 * Range 1201 - 1300.
2448 */
2449 enum mcs_af_status {
2450 MCS_AF_ERR_INVALID_MCSID = -1201,
2451 MCS_AF_ERR_NOT_MAPPED = -1202,
2452 };
2453
2454 struct mcs_set_pn_threshold {
2455 struct mbox_msghdr hdr;
2456 u64 threshold;
2457 u8 xpn; /* '1' for setting xpn threshold */
2458 u8 mcs_id;
2459 u8 dir;
2460 u64 rsvd;
2461 };
2462
2463 enum mcs_ctrl_pkt_rulew_type {
2464 MCS_CTRL_PKT_RULE_TYPE_ETH,
2465 MCS_CTRL_PKT_RULE_TYPE_DA,
2466 MCS_CTRL_PKT_RULE_TYPE_RANGE,
2467 MCS_CTRL_PKT_RULE_TYPE_COMBO,
2468 MCS_CTRL_PKT_RULE_TYPE_MAC,
2469 };
2470
2471 struct mcs_alloc_ctrl_pkt_rule_req {
2472 struct mbox_msghdr hdr;
2473 u8 rule_type;
2474 u8 mcs_id; /* MCS block ID */
2475 u8 dir; /* Macsec ingress or egress side */
2476 u64 rsvd;
2477 };
2478
2479 struct mcs_alloc_ctrl_pkt_rule_rsp {
2480 struct mbox_msghdr hdr;
2481 u8 rule_idx;
2482 u8 rule_type;
2483 u8 mcs_id;
2484 u8 dir;
2485 u64 rsvd;
2486 };
2487
2488 struct mcs_free_ctrl_pkt_rule_req {
2489 struct mbox_msghdr hdr;
2490 u8 rule_idx;
2491 u8 rule_type;
2492 u8 mcs_id;
2493 u8 dir;
2494 u8 all;
2495 u64 rsvd;
2496 };
2497
2498 struct mcs_ctrl_pkt_rule_write_req {
2499 struct mbox_msghdr hdr;
2500 u64 data0;
2501 u64 data1;
2502 u64 data2;
2503 u8 rule_idx;
2504 u8 rule_type;
2505 u8 mcs_id;
2506 u8 dir;
2507 u64 rsvd;
2508 };
2509
2510 struct mcs_stats_req {
2511 struct mbox_msghdr hdr;
2512 u8 id;
2513 u8 mcs_id;
2514 u8 dir;
2515 u64 rsvd;
2516 };
2517
2518 struct mcs_flowid_stats {
2519 struct mbox_msghdr hdr;
2520 u64 tcam_hit_cnt;
2521 u64 rsvd;
2522 };
2523
2524 struct mcs_secy_stats {
2525 struct mbox_msghdr hdr;
2526 u64 ctl_pkt_bcast_cnt;
2527 u64 ctl_pkt_mcast_cnt;
2528 u64 ctl_pkt_ucast_cnt;
2529 u64 ctl_octet_cnt;
2530 u64 unctl_pkt_bcast_cnt;
2531 u64 unctl_pkt_mcast_cnt;
2532 u64 unctl_pkt_ucast_cnt;
2533 u64 unctl_octet_cnt;
2534 /* Valid only for RX */
2535 u64 octet_decrypted_cnt;
2536 u64 octet_validated_cnt;
2537 u64 pkt_port_disabled_cnt;
2538 u64 pkt_badtag_cnt;
2539 u64 pkt_nosa_cnt;
2540 u64 pkt_nosaerror_cnt;
2541 u64 pkt_tagged_ctl_cnt;
2542 u64 pkt_untaged_cnt;
2543 u64 pkt_ctl_cnt; /* CN10K-B */
2544 u64 pkt_notag_cnt; /* CNF10K-B */
2545 /* Valid only for TX */
2546 u64 octet_encrypted_cnt;
2547 u64 octet_protected_cnt;
2548 u64 pkt_noactivesa_cnt;
2549 u64 pkt_toolong_cnt;
2550 u64 pkt_untagged_cnt;
2551 u64 rsvd[4];
2552 };
2553
2554 struct mcs_port_stats {
2555 struct mbox_msghdr hdr;
2556 u64 tcam_miss_cnt;
2557 u64 parser_err_cnt;
2558 u64 preempt_err_cnt; /* CNF10K-B */
2559 u64 sectag_insert_err_cnt;
2560 u64 rsvd[4];
2561 };
2562
2563 /* Only for CN10K-B */
2564 struct mcs_sa_stats {
2565 struct mbox_msghdr hdr;
2566 /* RX */
2567 u64 pkt_invalid_cnt;
2568 u64 pkt_nosaerror_cnt;
2569 u64 pkt_notvalid_cnt;
2570 u64 pkt_ok_cnt;
2571 u64 pkt_nosa_cnt;
2572 /* TX */
2573 u64 pkt_encrypt_cnt;
2574 u64 pkt_protected_cnt;
2575 u64 rsvd[4];
2576 };
2577
2578 struct mcs_sc_stats {
2579 struct mbox_msghdr hdr;
2580 /* RX */
2581 u64 hit_cnt;
2582 u64 pkt_invalid_cnt;
2583 u64 pkt_late_cnt;
2584 u64 pkt_notvalid_cnt;
2585 u64 pkt_unchecked_cnt;
2586 u64 pkt_delay_cnt; /* CNF10K-B */
2587 u64 pkt_ok_cnt; /* CNF10K-B */
2588 u64 octet_decrypt_cnt; /* CN10K-B */
2589 u64 octet_validate_cnt; /* CN10K-B */
2590 /* TX */
2591 u64 pkt_encrypt_cnt;
2592 u64 pkt_protected_cnt;
2593 u64 octet_encrypt_cnt; /* CN10K-B */
2594 u64 octet_protected_cnt; /* CN10K-B */
2595 u64 rsvd[4];
2596 };
2597
2598 struct mcs_clear_stats {
2599 struct mbox_msghdr hdr;
2600 #define MCS_FLOWID_STATS 0
2601 #define MCS_SECY_STATS 1
2602 #define MCS_SC_STATS 2
2603 #define MCS_SA_STATS 3
2604 #define MCS_PORT_STATS 4
2605 u8 type; /* FLOWID, SECY, SC, SA, PORT */
2606 u8 id; /* type = PORT, If id = FF(invalid) port no is derived from pcifunc */
2607 u8 mcs_id;
2608 u8 dir;
2609 u8 all; /* All resources stats mapped to PF are cleared */
2610 };
2611
2612 struct mcs_intr_cfg {
2613 struct mbox_msghdr hdr;
2614 #define MCS_CPM_RX_SECTAG_V_EQ1_INT BIT_ULL(0)
2615 #define MCS_CPM_RX_SECTAG_E_EQ0_C_EQ1_INT BIT_ULL(1)
2616 #define MCS_CPM_RX_SECTAG_SL_GTE48_INT BIT_ULL(2)
2617 #define MCS_CPM_RX_SECTAG_ES_EQ1_SC_EQ1_INT BIT_ULL(3)
2618 #define MCS_CPM_RX_SECTAG_SC_EQ1_SCB_EQ1_INT BIT_ULL(4)
2619 #define MCS_CPM_RX_PACKET_XPN_EQ0_INT BIT_ULL(5)
2620 #define MCS_CPM_RX_PN_THRESH_REACHED_INT BIT_ULL(6)
2621 #define MCS_CPM_TX_PACKET_XPN_EQ0_INT BIT_ULL(7)
2622 #define MCS_CPM_TX_PN_THRESH_REACHED_INT BIT_ULL(8)
2623 #define MCS_CPM_TX_SA_NOT_VALID_INT BIT_ULL(9)
2624 #define MCS_BBE_RX_DFIFO_OVERFLOW_INT BIT_ULL(10)
2625 #define MCS_BBE_RX_PLFIFO_OVERFLOW_INT BIT_ULL(11)
2626 #define MCS_BBE_TX_DFIFO_OVERFLOW_INT BIT_ULL(12)
2627 #define MCS_BBE_TX_PLFIFO_OVERFLOW_INT BIT_ULL(13)
2628 #define MCS_PAB_RX_CHAN_OVERFLOW_INT BIT_ULL(14)
2629 #define MCS_PAB_TX_CHAN_OVERFLOW_INT BIT_ULL(15)
2630 u64 intr_mask; /* Interrupt enable mask */
2631 u8 mcs_id;
2632 u8 lmac_id;
2633 u64 rsvd;
2634 };
2635
2636 struct mcs_intr_info {
2637 struct mbox_msghdr hdr;
2638 u64 intr_mask;
2639 int sa_id;
2640 u8 mcs_id;
2641 u8 lmac_id;
2642 u64 rsvd;
2643 };
2644
2645 #endif /* MBOX_H */