#include <linux/pci.h>
#include <linux/delay.h>
#include <linux/types.h>
#include <linux/completion.h>
#include <linux/semaphore.h>
#include <linux/spinlock.h>
#include <linux/workqueue.h>
#include "hinic_hw_if.h"
#include "hinic_hw_mgmt.h"
#include "hinic_hw_csr.h"
#include "hinic_hw_dev.h"
#include "hinic_hw_mbox.h"
#define HINIC_MBOX_INT_DST_FUNC_SHIFT …
#define HINIC_MBOX_INT_DST_AEQN_SHIFT …
#define HINIC_MBOX_INT_SRC_RESP_AEQN_SHIFT …
#define HINIC_MBOX_INT_STAT_DMA_SHIFT …
#define HINIC_MBOX_INT_TX_SIZE_SHIFT …
#define HINIC_MBOX_INT_STAT_DMA_SO_RO_SHIFT …
#define HINIC_MBOX_INT_WB_EN_SHIFT …
#define HINIC_MBOX_INT_DST_FUNC_MASK …
#define HINIC_MBOX_INT_DST_AEQN_MASK …
#define HINIC_MBOX_INT_SRC_RESP_AEQN_MASK …
#define HINIC_MBOX_INT_STAT_DMA_MASK …
#define HINIC_MBOX_INT_TX_SIZE_MASK …
#define HINIC_MBOX_INT_STAT_DMA_SO_RO_MASK …
#define HINIC_MBOX_INT_WB_EN_MASK …
#define HINIC_MBOX_INT_SET(val, field) …
enum hinic_mbox_tx_status { … };
#define HINIC_MBOX_CTRL_TRIGGER_AEQE_SHIFT …
#define HINIC_MBOX_CTRL_TX_STATUS_SHIFT …
#define HINIC_MBOX_CTRL_TRIGGER_AEQE_MASK …
#define HINIC_MBOX_CTRL_TX_STATUS_MASK …
#define HINIC_MBOX_CTRL_SET(val, field) …
#define HINIC_MBOX_HEADER_MSG_LEN_SHIFT …
#define HINIC_MBOX_HEADER_MODULE_SHIFT …
#define HINIC_MBOX_HEADER_SEG_LEN_SHIFT …
#define HINIC_MBOX_HEADER_NO_ACK_SHIFT …
#define HINIC_MBOX_HEADER_SEQID_SHIFT …
#define HINIC_MBOX_HEADER_LAST_SHIFT …
#define HINIC_MBOX_HEADER_DIRECTION_SHIFT …
#define HINIC_MBOX_HEADER_CMD_SHIFT …
#define HINIC_MBOX_HEADER_MSG_ID_SHIFT …
#define HINIC_MBOX_HEADER_STATUS_SHIFT …
#define HINIC_MBOX_HEADER_SRC_GLB_FUNC_IDX_SHIFT …
#define HINIC_MBOX_HEADER_MSG_LEN_MASK …
#define HINIC_MBOX_HEADER_MODULE_MASK …
#define HINIC_MBOX_HEADER_SEG_LEN_MASK …
#define HINIC_MBOX_HEADER_NO_ACK_MASK …
#define HINIC_MBOX_HEADER_SEQID_MASK …
#define HINIC_MBOX_HEADER_LAST_MASK …
#define HINIC_MBOX_HEADER_DIRECTION_MASK …
#define HINIC_MBOX_HEADER_CMD_MASK …
#define HINIC_MBOX_HEADER_MSG_ID_MASK …
#define HINIC_MBOX_HEADER_STATUS_MASK …
#define HINIC_MBOX_HEADER_SRC_GLB_FUNC_IDX_MASK …
#define HINIC_MBOX_HEADER_GET(val, field) …
#define HINIC_MBOX_HEADER_SET(val, field) …
#define MBOX_SEGLEN_MASK …
#define HINIC_MBOX_SEG_LEN …
#define HINIC_MBOX_COMP_TIME …
#define MBOX_MSG_POLLING_TIMEOUT …
#define HINIC_MBOX_DATA_SIZE …
#define MBOX_MAX_BUF_SZ …
#define MBOX_HEADER_SZ …
#define MBOX_INFO_SZ …
#define MBOX_SEG_LEN …
#define MBOX_SEG_LEN_ALIGN …
#define MBOX_WB_STATUS_LEN …
#define MBOX_WB_STATUS_ERRCODE_MASK …
#define MBOX_WB_STATUS_MASK …
#define MBOX_WB_ERROR_CODE_MASK …
#define MBOX_WB_STATUS_FINISHED_SUCCESS …
#define MBOX_WB_STATUS_NOT_FINISHED …
#define MBOX_STATUS_FINISHED(wb) …
#define MBOX_STATUS_SUCCESS(wb) …
#define MBOX_STATUS_ERRCODE(wb) …
#define SEQ_ID_START_VAL …
#define SEQ_ID_MAX_VAL …
#define NO_DMA_ATTRIBUTE_VAL …
#define HINIC_MBOX_RSP_AEQN …
#define HINIC_MBOX_RECV_AEQN …
#define MBOX_MSG_NO_DATA_LEN …
#define MBOX_BODY_FROM_HDR(header) …
#define MBOX_AREA(hwif) …
#define IS_PF_OR_PPF_SRC(src_func_idx) …
#define MBOX_MSG_ID_MASK …
#define MBOX_MSG_ID(func_to_func) …
#define MBOX_MSG_ID_INC(func_to_func_mbox) …
#define FUNC_ID_OFF_SET_8B …
#define HINIC_MAX_MSG_CNT_TO_PROCESS …
#define HINIC_QUEUE_MIN_DEPTH …
#define HINIC_QUEUE_MAX_DEPTH …
#define HINIC_MAX_RX_BUFFER_SIZE …
enum hinic_hwif_direction_type { … };
enum mbox_send_mod { … };
enum mbox_seg_type { … };
enum mbox_ordering_type { … };
enum mbox_write_back_type { … };
enum mbox_aeq_trig_type { … };
static bool check_func_id(struct hinic_hwdev *hwdev, u16 src_func_idx,
const void *buf_in, u16 in_size, u16 offset)
{ … }
bool hinic_mbox_check_func_id_8B(struct hinic_hwdev *hwdev, u16 func_idx,
void *buf_in, u16 in_size)
{ … }
int hinic_register_pf_mbox_cb(struct hinic_hwdev *hwdev,
enum hinic_mod_type mod,
hinic_pf_mbox_cb callback)
{ … }
int hinic_register_vf_mbox_cb(struct hinic_hwdev *hwdev,
enum hinic_mod_type mod,
hinic_vf_mbox_cb callback)
{ … }
void hinic_unregister_pf_mbox_cb(struct hinic_hwdev *hwdev,
enum hinic_mod_type mod)
{ … }
void hinic_unregister_vf_mbox_cb(struct hinic_hwdev *hwdev,
enum hinic_mod_type mod)
{ … }
static int recv_vf_mbox_handler(struct hinic_mbox_func_to_func *func_to_func,
struct hinic_recv_mbox *recv_mbox,
void *buf_out, u16 *out_size)
{ … }
static int
recv_pf_from_vf_mbox_handler(struct hinic_mbox_func_to_func *func_to_func,
struct hinic_recv_mbox *recv_mbox,
u16 src_func_idx, void *buf_out,
u16 *out_size)
{ … }
static bool check_mbox_seq_id_and_seg_len(struct hinic_recv_mbox *recv_mbox,
u8 seq_id, u8 seg_len)
{ … }
static void resp_mbox_handler(struct hinic_mbox_func_to_func *func_to_func,
struct hinic_recv_mbox *recv_mbox)
{ … }
static void recv_func_mbox_handler(struct hinic_mbox_func_to_func *func_to_func,
struct hinic_recv_mbox *recv_mbox,
u16 src_func_idx);
static void recv_func_mbox_work_handler(struct work_struct *work)
{ … }
static void recv_mbox_handler(struct hinic_mbox_func_to_func *func_to_func,
void *header, struct hinic_recv_mbox *recv_mbox)
{ … }
static int set_vf_mbox_random_id(struct hinic_hwdev *hwdev, u16 func_id)
{ … }
static void update_random_id_work_handler(struct work_struct *work)
{ … }
static bool check_vf_mbox_random_id(struct hinic_mbox_func_to_func *func_to_func,
u8 *header)
{ … }
static void hinic_mbox_func_aeqe_handler(void *handle, void *header, u8 size)
{ … }
static void hinic_mbox_self_aeqe_handler(void *handle, void *header, u8 size)
{ … }
static void clear_mbox_status(struct hinic_send_mbox *mbox)
{ … }
static void mbox_copy_header(struct hinic_hwdev *hwdev,
struct hinic_send_mbox *mbox, u64 *header)
{ … }
static void mbox_copy_send_data(struct hinic_hwdev *hwdev,
struct hinic_send_mbox *mbox, void *seg,
u16 seg_len)
{ … }
static void write_mbox_msg_attr(struct hinic_mbox_func_to_func *func_to_func,
u16 dst_func, u16 dst_aeqn, u16 seg_len,
int poll)
{ … }
static void dump_mox_reg(struct hinic_hwdev *hwdev)
{ … }
static u16 get_mbox_status(struct hinic_send_mbox *mbox)
{ … }
static int
wait_for_mbox_seg_completion(struct hinic_mbox_func_to_func *func_to_func,
int poll, u16 *wb_status)
{ … }
static int send_mbox_seg(struct hinic_mbox_func_to_func *func_to_func,
u64 header, u16 dst_func, void *seg, u16 seg_len,
int poll, void *msg_info)
{ … }
static int send_mbox_to_func(struct hinic_mbox_func_to_func *func_to_func,
enum hinic_mod_type mod, u16 cmd, void *msg,
u16 msg_len, u16 dst_func,
enum hinic_hwif_direction_type direction,
enum hinic_mbox_ack_type ack_type,
struct mbox_msg_info *msg_info)
{ … }
static void
response_for_recv_func_mbox(struct hinic_mbox_func_to_func *func_to_func,
struct hinic_recv_mbox *recv_mbox, int err,
u16 out_size, u16 src_func_idx)
{ … }
static void recv_func_mbox_handler(struct hinic_mbox_func_to_func *func_to_func,
struct hinic_recv_mbox *recv_mbox,
u16 src_func_idx)
{ … }
static void set_mbox_to_func_event(struct hinic_mbox_func_to_func *func_to_func,
enum mbox_event_state event_flag)
{ … }
static int mbox_resp_info_handler(struct hinic_mbox_func_to_func *func_to_func,
struct hinic_recv_mbox *mbox_for_resp,
enum hinic_mod_type mod, u16 cmd,
void *buf_out, u16 *out_size)
{ … }
int hinic_mbox_to_func(struct hinic_mbox_func_to_func *func_to_func,
enum hinic_mod_type mod, u16 cmd, u16 dst_func,
void *buf_in, u16 in_size, void *buf_out,
u16 *out_size, u32 timeout)
{ … }
static int mbox_func_params_valid(struct hinic_mbox_func_to_func *func_to_func,
void *buf_in, u16 in_size)
{ … }
int hinic_mbox_to_pf(struct hinic_hwdev *hwdev,
enum hinic_mod_type mod, u8 cmd, void *buf_in,
u16 in_size, void *buf_out, u16 *out_size, u32 timeout)
{ … }
int hinic_mbox_to_vf(struct hinic_hwdev *hwdev,
enum hinic_mod_type mod, u16 vf_id, u8 cmd, void *buf_in,
u16 in_size, void *buf_out, u16 *out_size, u32 timeout)
{ … }
static int init_mbox_info(struct hinic_recv_mbox *mbox_info)
{ … }
static void clean_mbox_info(struct hinic_recv_mbox *mbox_info)
{ … }
static int alloc_mbox_info(struct hinic_hwdev *hwdev,
struct hinic_recv_mbox *mbox_info)
{ … }
static void free_mbox_info(struct hinic_recv_mbox *mbox_info)
{ … }
static void prepare_send_mbox(struct hinic_mbox_func_to_func *func_to_func)
{ … }
static int alloc_mbox_wb_status(struct hinic_mbox_func_to_func *func_to_func)
{ … }
static void free_mbox_wb_status(struct hinic_mbox_func_to_func *func_to_func)
{ … }
bool hinic_mbox_check_cmd_valid(struct hinic_hwdev *hwdev,
struct vf_cmd_check_handle *cmd_handle,
u16 vf_id, u8 cmd, void *buf_in,
u16 in_size, u8 size)
{ … }
static bool hinic_cmdq_check_vf_ctxt(struct hinic_hwdev *hwdev,
struct hinic_cmdq_ctxt *cmdq_ctxt)
{ … }
static bool check_cmdq_ctxt(struct hinic_hwdev *hwdev, u16 func_idx,
void *buf_in, u16 in_size)
{ … }
#define HW_CTX_QPS_VALID(hw_ctxt) …
static bool hw_ctxt_qps_param_valid(struct hinic_cmd_hw_ioctxt *hw_ctxt)
{ … }
static bool check_hwctxt(struct hinic_hwdev *hwdev, u16 func_idx,
void *buf_in, u16 in_size)
{ … }
static bool check_set_wq_page_size(struct hinic_hwdev *hwdev, u16 func_idx,
void *buf_in, u16 in_size)
{ … }
static struct vf_cmd_check_handle hw_cmd_support_vf[] = …;
static int comm_pf_mbox_handler(void *handle, u16 vf_id, u8 cmd, void *buf_in,
u16 in_size, void *buf_out, u16 *out_size)
{ … }
int hinic_func_to_func_init(struct hinic_hwdev *hwdev)
{ … }
void hinic_func_to_func_free(struct hinic_hwdev *hwdev)
{ … }
int hinic_vf_mbox_random_id_init(struct hinic_hwdev *hwdev)
{ … }