1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Huawei Technologies Co., Ltd
5 #ifndef _HINIC_PMD_MBOX_H_
6 #define _HINIC_PMD_MBOX_H_
8 #define HINIC_MBOX_RECV_AEQN 0
9 #define HINIC_MBOX_RSP_AEQN 2
11 #define HINIC_MBOX_PF_SEND_ERR 0x1
12 #define HINIC_MBOX_PF_BUSY_ACTIVE_FW 0x2
13 #define HINIC_MBOX_VF_CMD_ERROR 0x3
15 /* PFs do not support enable SR-IOV cap when PFs use PMD, VFs just receive
16 * mailbox message from PFs. The max number of PFs is 16, so the max number
17 * of mailbox buffer for functions is also 16.
19 #define HINIC_MAX_FUNCTIONS 16
20 #define HINIC_MAX_PF_FUNCS 16
22 #define HINIC_MGMT_CMD_UNSUPPORTED 0xFF
24 #define HINIC_SEQ_ID_MAX_VAL 42
25 #define HINIC_MSG_SEG_LEN 48
27 enum hinic_mbox_ack_type {
32 struct mbox_msg_info {
34 u8 status; /*can only use 6 bit*/
37 struct hinic_recv_mbox {
40 enum hinic_mod_type mod;
43 enum hinic_mbox_ack_type ack_type;
44 struct mbox_msg_info msg_info;
48 struct hinic_send_mbox {
50 volatile u64 *wb_status;
55 enum mbox_event_state {
61 struct hinic_mbox_func_to_func {
62 struct hinic_hwdev *hwdev;
64 pthread_mutex_t mbox_send_mutex;
65 pthread_mutex_t msg_send_mutex;
67 struct hinic_send_mbox send_mbox;
69 struct hinic_recv_mbox mbox_resp[HINIC_MAX_FUNCTIONS];
70 struct hinic_recv_mbox mbox_send[HINIC_MAX_FUNCTIONS];
72 struct hinic_eq *rsp_aeq;
73 struct hinic_eq *recv_aeq;
76 enum mbox_event_state event_flag;
77 spinlock_t mbox_lock; /* lock for mbox event flag */
81 * mbox function prototypes
83 int hinic_comm_func_to_func_init(struct hinic_hwdev *hwdev);
84 void hinic_comm_func_to_func_free(struct hinic_hwdev *hwdev);
85 int hinic_mbox_func_aeqe_handler(void *handle, u8 *header,
86 u8 size, void *param);
87 int hinic_mbox_to_pf(struct hinic_hwdev *hwdev, enum hinic_mod_type mod, u8 cmd,
88 void *buf_in, u16 in_size,
89 void *buf_out, u16 *out_size, u32 timeout);
90 int hinic_mbox_to_pf_no_ack(struct hinic_hwdev *hwdev, enum hinic_mod_type mod,
91 u8 cmd, void *buf_in, u16 in_size);
93 #endif /* _HINIC_PMD_MBOX_H_ */