1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Cavium, Inc
10 #include <rte_spinlock.h>
12 /* Macros for Mail Box Communication */
14 #define LIO_MBOX_DATA_MAX 32
16 #define LIO_VF_ACTIVE 0x1
17 #define LIO_VF_FLR_REQUEST 0x2
18 #define LIO_CORES_CRASHED 0x3
20 /* Macro for Read acknowledgment */
21 #define LIO_PFVFACK 0xffffffffffffffff
22 #define LIO_PFVFSIG 0x1122334455667788
23 #define LIO_PFVFERR 0xDEADDEADDEADDEAD
25 enum lio_mbox_cmd_status {
26 LIO_MBOX_STATUS_SUCCESS = 0,
27 LIO_MBOX_STATUS_FAILED = 1,
28 LIO_MBOX_STATUS_BUSY = 2
31 enum lio_mbox_message_type {
36 union lio_mbox_message {
40 uint16_t resp_needed : 1;
47 typedef void (*lio_mbox_callback)(void *, void *, void *);
50 union lio_mbox_message msg;
51 uint64_t data[LIO_MBOX_DATA_MAX];
60 LIO_MBOX_STATE_IDLE = 1,
61 LIO_MBOX_STATE_REQ_RECEIVING = 2,
62 LIO_MBOX_STATE_REQ_RECEIVED = 4,
63 LIO_MBOX_STATE_RES_PENDING = 8,
64 LIO_MBOX_STATE_RES_RECEIVING = 16,
65 LIO_MBOX_STATE_RES_RECEIVED = 16,
66 LIO_MBOX_STATE_ERROR = 32
70 /* A spinlock to protect access to this q_mbox. */
73 struct lio_device *lio_dev;
77 enum lio_mbox_state state;
79 /* SLI_MAC_PF_MBOX_INT for PF, SLI_PKT_MBOX_INT for VF. */
82 /* SLI_PKT_PF_VF_MBOX_SIG(0) for PF,
83 * SLI_PKT_PF_VF_MBOX_SIG(1) for VF.
87 /* SLI_PKT_PF_VF_MBOX_SIG(1) for PF,
88 * SLI_PKT_PF_VF_MBOX_SIG(0) for VF.
92 struct lio_mbox_cmd mbox_req;
94 struct lio_mbox_cmd mbox_resp;
98 int lio_mbox_read(struct lio_mbox *mbox);
99 int lio_mbox_write(struct lio_device *lio_dev,
100 struct lio_mbox_cmd *mbox_cmd);
101 int lio_mbox_process_message(struct lio_mbox *mbox);
102 #endif /* _LIO_MBOX_H_ */