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_CORES_CRASHED 0x3
48 /* Macro for Read acknowledgment */
49 #define LIO_PFVFACK 0xffffffffffffffff
50 #define LIO_PFVFSIG 0x1122334455667788
51 #define LIO_PFVFERR 0xDEADDEADDEADDEAD
53 enum lio_mbox_cmd_status {
54 LIO_MBOX_STATUS_SUCCESS = 0,
55 LIO_MBOX_STATUS_FAILED = 1,
56 LIO_MBOX_STATUS_BUSY = 2
59 enum lio_mbox_message_type {
64 union lio_mbox_message {
68 uint16_t resp_needed : 1;
75 typedef void (*lio_mbox_callback)(void *, void *, void *);
78 union lio_mbox_message msg;
79 uint64_t data[LIO_MBOX_DATA_MAX];
88 LIO_MBOX_STATE_IDLE = 1,
89 LIO_MBOX_STATE_REQ_RECEIVING = 2,
90 LIO_MBOX_STATE_REQ_RECEIVED = 4,
91 LIO_MBOX_STATE_RES_PENDING = 8,
92 LIO_MBOX_STATE_RES_RECEIVING = 16,
93 LIO_MBOX_STATE_RES_RECEIVED = 16,
94 LIO_MBOX_STATE_ERROR = 32
98 /* A spinlock to protect access to this q_mbox. */
101 struct lio_device *lio_dev;
105 enum lio_mbox_state state;
107 /* SLI_MAC_PF_MBOX_INT for PF, SLI_PKT_MBOX_INT for VF. */
110 /* SLI_PKT_PF_VF_MBOX_SIG(0) for PF,
111 * SLI_PKT_PF_VF_MBOX_SIG(1) for VF.
113 void *mbox_write_reg;
115 /* SLI_PKT_PF_VF_MBOX_SIG(1) for PF,
116 * SLI_PKT_PF_VF_MBOX_SIG(0) for VF.
120 struct lio_mbox_cmd mbox_req;
122 struct lio_mbox_cmd mbox_resp;
126 int lio_mbox_read(struct lio_mbox *mbox);
127 int lio_mbox_write(struct lio_device *lio_dev,
128 struct lio_mbox_cmd *mbox_cmd);
129 int lio_mbox_process_message(struct lio_mbox *mbox);
130 #endif /* _LIO_MBOX_H_ */