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