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