1
2
3
4
5#ifndef __OTX2_CPTPF_UCODE_H
6#define __OTX2_CPTPF_UCODE_H
7
8#include <linux/pci.h>
9#include <linux/types.h>
10#include <linux/module.h>
11#include "otx2_cpt_hw_types.h"
12#include "otx2_cpt_common.h"
13
14
15
16
17
18#define OTX2_CPT_MAX_ETYPES_PER_GRP 2
19
20
21#define OTX2_CPT_UCODE_SIGN_LEN 256
22
23
24#define OTX2_CPT_UCODE_VER_STR_SZ 44
25
26
27#define OTX2_CPT_MAX_ENGINES 144
28
29#define OTX2_CPT_ENGS_BITMASK_LEN BITS_TO_LONGS(OTX2_CPT_MAX_ENGINES)
30
31#define OTX2_CPT_UCODE_SZ (64 * 1024)
32
33
34enum otx2_cpt_ucode_type {
35 OTX2_CPT_AE_UC_TYPE = 1,
36 OTX2_CPT_SE_UC_TYPE1 = 20,
37 OTX2_CPT_SE_UC_TYPE2 = 21,
38 OTX2_CPT_SE_UC_TYPE3 = 22,
39
40
41
42 OTX2_CPT_IE_UC_TYPE1 = 30,
43 OTX2_CPT_IE_UC_TYPE2 = 31,
44 OTX2_CPT_IE_UC_TYPE3 = 32,
45
46
47
48};
49
50struct otx2_cpt_bitmap {
51 unsigned long bits[OTX2_CPT_ENGS_BITMASK_LEN];
52 int size;
53};
54
55struct otx2_cpt_engines {
56 int type;
57 int count;
58};
59
60
61struct otx2_cpt_ucode_ver_num {
62 u8 nn;
63 u8 xx;
64 u8 yy;
65 u8 zz;
66};
67
68struct otx2_cpt_ucode_hdr {
69 struct otx2_cpt_ucode_ver_num ver_num;
70 u8 ver_str[OTX2_CPT_UCODE_VER_STR_SZ];
71 __be32 code_length;
72 u32 padding[3];
73};
74
75struct otx2_cpt_ucode {
76 u8 ver_str[OTX2_CPT_UCODE_VER_STR_SZ];
77
78
79
80 struct otx2_cpt_ucode_ver_num ver_num;
81 char filename[OTX2_CPT_NAME_LENGTH];
82 dma_addr_t dma;
83 void *va;
84 u32 size;
85 int type;
86};
87
88struct otx2_cpt_uc_info_t {
89 struct list_head list;
90 struct otx2_cpt_ucode ucode;
91 const struct firmware *fw;
92};
93
94
95struct otx2_cpt_engs_available {
96 int max_se_cnt;
97 int max_ie_cnt;
98 int max_ae_cnt;
99 int se_cnt;
100 int ie_cnt;
101 int ae_cnt;
102};
103
104
105struct otx2_cpt_engs_rsvd {
106 int type;
107 int count;
108 int offset;
109 unsigned long *bmap;
110 struct otx2_cpt_ucode *ucode;
111};
112
113struct otx2_cpt_mirror_info {
114 int is_ena;
115
116
117
118 int idx;
119
120
121
122
123 int ref_count;
124
125
126
127
128};
129
130struct otx2_cpt_eng_grp_info {
131 struct otx2_cpt_eng_grps *g;
132
133 struct otx2_cpt_engs_rsvd engs[OTX2_CPT_MAX_ETYPES_PER_GRP];
134
135 struct otx2_cpt_ucode ucode[OTX2_CPT_MAX_ETYPES_PER_GRP];
136
137 struct otx2_cpt_mirror_info mirror;
138 int idx;
139 bool is_enabled;
140
141
142
143};
144
145struct otx2_cpt_eng_grps {
146 struct otx2_cpt_eng_grp_info grp[OTX2_CPT_MAX_ENGINE_GROUPS];
147 struct otx2_cpt_engs_available avail;
148 void *obj;
149 int engs_num;
150 u8 eng_ref_cnt[OTX2_CPT_MAX_ENGINES];
151 bool is_grps_created;
152};
153struct otx2_cptpf_dev;
154int otx2_cpt_init_eng_grps(struct pci_dev *pdev,
155 struct otx2_cpt_eng_grps *eng_grps);
156void otx2_cpt_cleanup_eng_grps(struct pci_dev *pdev,
157 struct otx2_cpt_eng_grps *eng_grps);
158int otx2_cpt_create_eng_grps(struct otx2_cptpf_dev *cptpf,
159 struct otx2_cpt_eng_grps *eng_grps);
160int otx2_cpt_disable_all_cores(struct otx2_cptpf_dev *cptpf);
161int otx2_cpt_get_eng_grp(struct otx2_cpt_eng_grps *eng_grps, int eng_type);
162int otx2_cpt_discover_eng_capabilities(struct otx2_cptpf_dev *cptpf);
163
164#endif
165