xref: /dpdk/drivers/crypto/octeontx/otx_cryptodev_mbox.h (revision 7be78d027918dbc846e502780faf94d5acdf5f75)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2018 Cavium, Inc
3  */
4 
5 #ifndef _OTX_CRYPTODEV_MBOX_H_
6 #define _OTX_CRYPTODEV_MBOX_H_
7 
8 #include <rte_byteorder.h>
9 #include <rte_common.h>
10 
11 #include "cpt_common.h"
12 #include "cpt_pmd_logs.h"
13 
14 #include "otx_cryptodev_hw_access.h"
15 
16 #define OTX_CPT_MBOX_MSG_TIMEOUT    2000 /* In Milli Seconds */
17 
18 /* CPT mailbox structure */
19 struct cpt_mbox {
20 	/** Message type MBOX[0] */
21 	uint64_t msg;
22 	/** Data         MBOX[1] */
23 	uint64_t data;
24 };
25 
26 /* CPT PF types */
27 enum otx_cpt_pf_type {
28 	OTX_CPT_PF_TYPE_INVALID = 0,
29 	OTX_CPT_PF_TYPE_AE = 2,
30 	OTX_CPT_PF_TYPE_SE,
31 };
32 
33 /* CPT VF types */
34 enum otx_cpt_vf_type {
35 	OTX_CPT_VF_TYPE_AE = 1,
36 	OTX_CPT_VF_TYPE_SE,
37 	OTX_CPT_VF_TYPE_INVALID,
38 };
39 
40 /* PF-VF message opcodes */
41 enum otx_cpt_mbox_opcode {
42 	OTX_CPT_MSG_VF_UP = 1,
43 	OTX_CPT_MSG_VF_DOWN,
44 	OTX_CPT_MSG_READY,
45 	OTX_CPT_MSG_QLEN,
46 	OTX_CPT_MSG_QBIND_GRP,
47 	OTX_CPT_MSG_VQ_PRIORITY,
48 	OTX_CPT_MSG_PF_TYPE,
49 	OTX_CPT_MBOX_MSG_TYPE_ACK,
50 	OTX_CPT_MBOX_MSG_TYPE_NACK
51 };
52 
53 typedef union {
54 	uint64_t u64;
55 	struct {
56 #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
57 		uint32_t chip_id;
58 		uint8_t vfid;
59 		uint8_t reserved[3];
60 #else
61 		uint8_t reserved[3];
62 		uint8_t vfid;
63 		uint32_t chip_id;
64 #endif
65 	} s;
66 } otx_cpt_chipid_vfid_t;
67 
68 /* Poll handler to handle mailbox messages from VFs */
69 void
70 otx_cpt_handle_mbox_intr(struct cpt_vf *cptvf);
71 
72 /*
73  * Checks if VF is able to communicate with PF
74  * and also gets the CPT number this VF is associated to.
75  */
76 int
77 otx_cpt_check_pf_ready(struct cpt_vf *cptvf);
78 
79 /*
80  * Communicate to PF to get VF type
81  */
82 int
83 otx_cpt_get_dev_type(struct cpt_vf *cptvf);
84 
85 /*
86  * Communicate VQs size to PF to program CPT(0)_PF_Q(0-15)_CTL of the VF.
87  * Must be ACKed.
88  */
89 int
90 otx_cpt_send_vq_size_msg(struct cpt_vf *cptvf);
91 
92 /*
93  * Communicate VF group required to PF and get the VQ binded to that group
94  */
95 int
96 otx_cpt_send_vf_grp_msg(struct cpt_vf *cptvf, uint32_t group);
97 
98 /*
99  * Communicate to PF that VF is UP and running
100  */
101 int
102 otx_cpt_send_vf_up(struct cpt_vf *cptvf);
103 
104 /*
105  * Communicate to PF that VF is DOWN and running
106  */
107 int
108 otx_cpt_send_vf_down(struct cpt_vf *cptvf);
109 
110 #endif /* _OTX_CRYPTODEV_MBOX_H_ */
111