xref: /dpdk/drivers/crypto/octeontx/otx_cryptodev_mbox.h (revision 14ad4f01845331a0ae98c681efa3086eeed3343a)
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 #define OTX_CPT_MBOX_MSG_TYPE_REQ	0
19 #define OTX_CPT_MBOX_MSG_TYPE_ACK	1
20 #define OTX_CPT_MBOX_MSG_TYPE_NACK	2
21 #define OTX_CPT_MBOX_MSG_TYPE_NOP	3
22 
23 /* CPT mailbox structure */
24 struct cpt_mbox {
25 	/** Message type MBOX[0] */
26 	uint64_t msg;
27 	/** Data         MBOX[1] */
28 	uint64_t data;
29 };
30 
31 typedef enum {
32 	OTX_CPT_MSG_VF_UP = 1,
33 	OTX_CPT_MSG_VF_DOWN,
34 	OTX_CPT_MSG_READY,
35 	OTX_CPT_MSG_QLEN,
36 	OTX_CPT_MSG_QBIND_GRP,
37 	OTX_CPT_MSG_VQ_PRIORITY,
38 	OTX_CPT_MSG_PF_TYPE,
39 } otx_cpt_mbox_opcode_t;
40 
41 typedef union {
42 	uint64_t u64;
43 	struct {
44 #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
45 		uint32_t chip_id;
46 		uint8_t vfid;
47 		uint8_t reserved[3];
48 #else
49 		uint8_t reserved[3];
50 		uint8_t vfid;
51 		uint32_t chip_id;
52 #endif
53 	} s;
54 } otx_cpt_chipid_vfid_t;
55 
56 /* Poll handler to handle mailbox messages from VFs */
57 void
58 otx_cpt_handle_mbox_intr(struct cpt_vf *cptvf);
59 
60 /*
61  * Checks if VF is able to comminicate with PF
62  * and also gets the CPT number this VF is associated to.
63  */
64 int
65 otx_cpt_check_pf_ready(struct cpt_vf *cptvf);
66 
67 /*
68  * Communicate VQs size to PF to program CPT(0)_PF_Q(0-15)_CTL of the VF.
69  * Must be ACKed.
70  */
71 int
72 otx_cpt_send_vq_size_msg(struct cpt_vf *cptvf);
73 
74 /*
75  * Communicate VF group required to PF and get the VQ binded to that group
76  */
77 int
78 otx_cpt_send_vf_grp_msg(struct cpt_vf *cptvf, uint32_t group);
79 
80 /*
81  * Communicate to PF that VF is UP and running
82  */
83 int
84 otx_cpt_send_vf_up(struct cpt_vf *cptvf);
85 
86 /*
87  * Communicate to PF that VF is DOWN and running
88  */
89 int
90 otx_cpt_send_vf_down(struct cpt_vf *cptvf);
91 
92 #endif /* _OTX_CRYPTODEV_MBOX_H_ */
93