common/cnxk: swap ZUC-256 key
[dpdk.git] / drivers / common / cnxk / roc_ree.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2021 Marvell.
3  */
4
5 #ifndef _ROC_REE_H_
6 #define _ROC_REE_H_
7
8 #include "roc_api.h"
9
10 #define REE_MAX_LFS            36
11 #define REE_MAX_QUEUES_PER_VF  36
12 #define REE_MAX_MATCHES_PER_VF 254
13
14 #define REE_MAX_PAYLOAD_SIZE (1 << 14)
15
16 #define REE_NON_INC_PROG 0
17 #define REE_INC_PROG     1
18
19 #define REE_MOD_INC(i, l) ((i) == (l - 1) ? (i) = 0 : (i)++)
20
21 /**
22  * Device vf data
23  */
24 struct roc_ree_vf {
25         struct plt_pci_device *pci_dev;
26         struct dev *dev;
27         /**< Base class */
28         uint16_t max_queues;
29         /**< Max queues supported */
30         uint8_t nb_queues;
31         /**< Number of regex queues attached */
32         uint16_t max_matches;
33         /**<  Max matches supported*/
34         uint16_t lf_msixoff[REE_MAX_LFS];
35         /**< MSI-X offsets */
36         uint8_t block_address;
37         /**< REE Block Address */
38         uint8_t err_intr_registered : 1;
39         /**< Are error interrupts registered? */
40
41 #define ROC_REE_MEM_SZ (6 * 1024)
42         uint8_t reserved[ROC_REE_MEM_SZ] __plt_cache_aligned;
43 } __plt_cache_aligned;
44
45 struct roc_ree_rid {
46         uintptr_t rid;
47         /** Request id of a ree operation */
48         uint64_t user_id;
49         /* Client data */
50         /**< IOVA address of the pattern to be matched. */
51 };
52
53 struct roc_ree_pending_queue {
54         uint64_t pending_count;
55         /** Pending requests count */
56         struct roc_ree_rid *rid_queue;
57         /** Array of pending requests */
58         uint16_t enq_tail;
59         /** Tail of queue to be used for enqueue */
60         uint16_t deq_head;
61         /** Head of queue to be used for dequeue */
62 };
63
64 struct roc_ree_qp {
65         uint32_t id;
66         /**< Queue pair id */
67         uintptr_t base;
68         /**< Base address where BAR is mapped */
69         struct roc_ree_pending_queue pend_q;
70         /**< Pending queue */
71         rte_iova_t iq_dma_addr;
72         /**< Instruction queue address */
73         uint32_t roc_regexdev_jobid;
74         /**< Job ID */
75         uint32_t write_offset;
76         /**< write offset */
77 };
78
79 union roc_ree_inst {
80         uint64_t u[8];
81         struct {
82                 uint64_t doneint : 1;
83                 uint64_t reserved_1_3 : 3;
84                 uint64_t dg : 1;
85                 uint64_t reserved_5_7 : 3;
86                 uint64_t ooj : 1;
87                 uint64_t reserved_9_15 : 7;
88                 uint64_t reserved_16_63 : 48;
89                 uint64_t inp_ptr_addr : 64;
90                 uint64_t inp_ptr_ctl : 64;
91                 uint64_t res_ptr_addr : 64;
92                 uint64_t wq_ptr : 64;
93                 uint64_t tag : 32;
94                 uint64_t tt : 2;
95                 uint64_t ggrp : 10;
96                 uint64_t reserved_364_383 : 20;
97                 uint64_t reserved_384_391 : 8;
98                 uint64_t ree_job_id : 24;
99                 uint64_t ree_job_ctrl : 16;
100                 uint64_t ree_job_length : 15;
101                 uint64_t reserved_447_447 : 1;
102                 uint64_t ree_job_subset_id_0 : 16;
103                 uint64_t ree_job_subset_id_1 : 16;
104                 uint64_t ree_job_subset_id_2 : 16;
105                 uint64_t ree_job_subset_id_3 : 16;
106         } cn98xx;
107 };
108
109 int __roc_api roc_ree_dev_init(struct roc_ree_vf *vf);
110 int __roc_api roc_ree_dev_fini(struct roc_ree_vf *vf);
111 int __roc_api roc_ree_queues_attach(struct roc_ree_vf *vf, uint8_t nb_queues);
112 int __roc_api roc_ree_queues_detach(struct roc_ree_vf *vf);
113 int __roc_api roc_ree_msix_offsets_get(struct roc_ree_vf *vf);
114 int __roc_api roc_ree_config_lf(struct roc_ree_vf *vf, uint8_t lf, uint8_t pri,
115                                 uint32_t size);
116 int __roc_api roc_ree_af_reg_read(struct roc_ree_vf *vf, uint64_t reg,
117                                   uint64_t *val);
118 int __roc_api roc_ree_af_reg_write(struct roc_ree_vf *vf, uint64_t reg,
119                                    uint64_t val);
120 int __roc_api roc_ree_rule_db_get(struct roc_ree_vf *vf, char *rule_db,
121                                   uint32_t rule_db_len, char *rule_dbi,
122                                   uint32_t rule_dbi_len);
123 int __roc_api roc_ree_rule_db_len_get(struct roc_ree_vf *vf,
124                                       uint32_t *rule_db_len,
125                                       uint32_t *rule_dbi_len);
126 int __roc_api roc_ree_rule_db_prog(struct roc_ree_vf *vf, const char *rule_db,
127                                    uint32_t rule_db_len, const char *rule_dbi,
128                                    uint32_t rule_dbi_len);
129 uintptr_t __roc_api roc_ree_qp_get_base(struct roc_ree_vf *vf, uint16_t qp_id);
130 void __roc_api roc_ree_err_intr_unregister(struct roc_ree_vf *vf);
131 int __roc_api roc_ree_err_intr_register(struct roc_ree_vf *vf);
132 int __roc_api roc_ree_iq_enable(struct roc_ree_vf *vf,
133                                 const struct roc_ree_qp *qp, uint8_t pri,
134                                 uint32_t size_div128);
135 void __roc_api roc_ree_iq_disable(struct roc_ree_qp *qp);
136
137 #endif /* _ROC_REE_H_ */