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_PF_SEND_ERR 0x1
9 #define HINIC_MBOX_PF_BUSY_ACTIVE_FW 0x2
10 #define HINIC_MBOX_VF_CMD_ERROR 0x3
12 /* PFs do not support enable SR-IOV cap when PFs use PMD, VFs just receive
13 * mailbox message from PFs. The max number of PFs is 16, so the max number
14 * of mailbox buffer for functions is also 16.
16 #define HINIC_MAX_FUNCTIONS 16
17 #define HINIC_MAX_PF_FUNCS 16
19 #define HINIC_MGMT_CMD_UNSUPPORTED 0xFF
21 #define HINIC_SEQ_ID_MAX_VAL 42
22 #define HINIC_MSG_SEG_LEN 48
24 enum hinic_mbox_ack_type {
29 struct mbox_msg_info {
31 u8 status; /*can only use 6 bit*/
34 struct hinic_recv_mbox {
37 enum hinic_mod_type mod;
40 enum hinic_mbox_ack_type ack_type;
41 struct mbox_msg_info msg_info;
45 struct hinic_send_mbox {
47 volatile u64 *wb_status;
52 enum mbox_event_state {
58 struct hinic_mbox_func_to_func {
59 struct hinic_hwdev *hwdev;
61 pthread_mutex_t mbox_send_mutex;
62 pthread_mutex_t msg_send_mutex;
64 struct hinic_send_mbox send_mbox;
66 struct hinic_recv_mbox mbox_resp[HINIC_MAX_FUNCTIONS];
67 struct hinic_recv_mbox mbox_send[HINIC_MAX_FUNCTIONS];
69 struct hinic_eq *ack_aeq;
70 struct hinic_eq *recv_aeq;
73 enum mbox_event_state event_flag;
74 spinlock_t mbox_lock; /* lock for mbox event flag */
78 * mbox function prototypes
80 int hinic_comm_func_to_func_init(struct hinic_hwdev *hwdev);
81 void hinic_comm_func_to_func_free(struct hinic_hwdev *hwdev);
82 int hinic_mbox_func_aeqe_handler(void *handle, u8 *header,
83 u8 size, void *param);
84 int hinic_mbox_to_pf(struct hinic_hwdev *hwdev, enum hinic_mod_type mod, u8 cmd,
85 void *buf_in, u16 in_size,
86 void *buf_out, u16 *out_size, u32 timeout);
87 int hinic_mbox_to_pf_no_ack(struct hinic_hwdev *hwdev, enum hinic_mod_type mod,
88 u8 cmd, void *buf_in, u16 in_size);
90 #endif /* _HINIC_PMD_MBOX_H_ */