4 * Copyright(c) 2017 Cavium, Inc.. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Cavium, Inc. nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 #include <rte_spinlock.h>
41 /* Macros for Mail Box Communication */
43 #define LIO_MBOX_DATA_MAX 32
45 #define LIO_VF_ACTIVE 0x1
46 #define LIO_VF_FLR_REQUEST 0x2
47 #define LIO_CORES_CRASHED 0x3
49 /* Macro for Read acknowledgment */
50 #define LIO_PFVFACK 0xffffffffffffffff
51 #define LIO_PFVFSIG 0x1122334455667788
52 #define LIO_PFVFERR 0xDEADDEADDEADDEAD
54 enum lio_mbox_cmd_status {
55 LIO_MBOX_STATUS_SUCCESS = 0,
56 LIO_MBOX_STATUS_FAILED = 1,
57 LIO_MBOX_STATUS_BUSY = 2
60 enum lio_mbox_message_type {
65 union lio_mbox_message {
69 uint16_t resp_needed : 1;
76 typedef void (*lio_mbox_callback)(void *, void *, void *);
79 union lio_mbox_message msg;
80 uint64_t data[LIO_MBOX_DATA_MAX];
89 LIO_MBOX_STATE_IDLE = 1,
90 LIO_MBOX_STATE_REQ_RECEIVING = 2,
91 LIO_MBOX_STATE_REQ_RECEIVED = 4,
92 LIO_MBOX_STATE_RES_PENDING = 8,
93 LIO_MBOX_STATE_RES_RECEIVING = 16,
94 LIO_MBOX_STATE_RES_RECEIVED = 16,
95 LIO_MBOX_STATE_ERROR = 32
99 /* A spinlock to protect access to this q_mbox. */
102 struct lio_device *lio_dev;
106 enum lio_mbox_state state;
108 /* SLI_MAC_PF_MBOX_INT for PF, SLI_PKT_MBOX_INT for VF. */
111 /* SLI_PKT_PF_VF_MBOX_SIG(0) for PF,
112 * SLI_PKT_PF_VF_MBOX_SIG(1) for VF.
114 void *mbox_write_reg;
116 /* SLI_PKT_PF_VF_MBOX_SIG(1) for PF,
117 * SLI_PKT_PF_VF_MBOX_SIG(0) for VF.
121 struct lio_mbox_cmd mbox_req;
123 struct lio_mbox_cmd mbox_resp;
127 int lio_mbox_read(struct lio_mbox *mbox);
128 int lio_mbox_write(struct lio_device *lio_dev,
129 struct lio_mbox_cmd *mbox_cmd);
130 int lio_mbox_process_message(struct lio_mbox *mbox);
131 #endif /* _LIO_MBOX_H_ */