]> git.proxmox.com Git - ceph.git/blob - ceph/src/seastar/dpdk/drivers/net/liquidio/base/lio_mbox.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / seastar / dpdk / drivers / net / liquidio / base / lio_mbox.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Cavium, Inc
3 */
4
5 #ifndef _LIO_MBOX_H_
6 #define _LIO_MBOX_H_
7
8 #include <stdint.h>
9
10 #include <rte_spinlock.h>
11
12 /* Macros for Mail Box Communication */
13
14 #define LIO_MBOX_DATA_MAX 32
15
16 #define LIO_VF_ACTIVE 0x1
17 #define LIO_VF_FLR_REQUEST 0x2
18 #define LIO_CORES_CRASHED 0x3
19
20 /* Macro for Read acknowledgment */
21 #define LIO_PFVFACK 0xffffffffffffffff
22 #define LIO_PFVFSIG 0x1122334455667788
23 #define LIO_PFVFERR 0xDEADDEADDEADDEAD
24
25 enum lio_mbox_cmd_status {
26 LIO_MBOX_STATUS_SUCCESS = 0,
27 LIO_MBOX_STATUS_FAILED = 1,
28 LIO_MBOX_STATUS_BUSY = 2
29 };
30
31 enum lio_mbox_message_type {
32 LIO_MBOX_REQUEST = 0,
33 LIO_MBOX_RESPONSE = 1
34 };
35
36 union lio_mbox_message {
37 uint64_t mbox_msg64;
38 struct {
39 uint16_t type : 1;
40 uint16_t resp_needed : 1;
41 uint16_t cmd : 6;
42 uint16_t len : 8;
43 uint8_t params[6];
44 } s;
45 };
46
47 typedef void (*lio_mbox_callback)(void *, void *, void *);
48
49 struct lio_mbox_cmd {
50 union lio_mbox_message msg;
51 uint64_t data[LIO_MBOX_DATA_MAX];
52 uint32_t q_no;
53 uint32_t recv_len;
54 uint32_t recv_status;
55 lio_mbox_callback fn;
56 void *fn_arg;
57 };
58
59 enum lio_mbox_state {
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
67 };
68
69 struct lio_mbox {
70 /* A spinlock to protect access to this q_mbox. */
71 rte_spinlock_t lock;
72
73 struct lio_device *lio_dev;
74
75 uint32_t q_no;
76
77 enum lio_mbox_state state;
78
79 /* SLI_MAC_PF_MBOX_INT for PF, SLI_PKT_MBOX_INT for VF. */
80 void *mbox_int_reg;
81
82 /* SLI_PKT_PF_VF_MBOX_SIG(0) for PF,
83 * SLI_PKT_PF_VF_MBOX_SIG(1) for VF.
84 */
85 void *mbox_write_reg;
86
87 /* SLI_PKT_PF_VF_MBOX_SIG(1) for PF,
88 * SLI_PKT_PF_VF_MBOX_SIG(0) for VF.
89 */
90 void *mbox_read_reg;
91
92 struct lio_mbox_cmd mbox_req;
93
94 struct lio_mbox_cmd mbox_resp;
95
96 };
97
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_ */