MCPcopy Create free account
hub / github.com/F-Stack/f-stack / xlp_rsa_init

Function xlp_rsa_init

freebsd/mips/nlm/dev/sec/nlmrsa.c:136–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134#endif
135
136static int
137xlp_rsa_init(struct xlp_rsa_softc *sc, int node)
138{
139 struct xlp_rsa_command *cmd = NULL;
140 uint32_t fbvc, dstvc, endsel, regval;
141 struct nlm_fmn_msg m;
142 int err, ret, i;
143 uint64_t base;
144
145 /* Register interrupt handler for the RSA/ECC CMS messages */
146 if (register_msgring_handler(sc->rsaecc_vc_start,
147 sc->rsaecc_vc_end, nlm_xlprsaecc_msgring_handler, sc) != 0) {
148 err = -1;
149 printf("Couldn't register rsa/ecc msgring handler\n");
150 goto errout;
151 }
152 fbvc = nlm_cpuid() * 4 + XLPGE_FB_VC;
153 /* Do the CMS credit initialization */
154 /* Currently it is configured by default to 50 when kernel comes up */
155
156#if BYTE_ORDER == LITTLE_ENDIAN
157 for (i = 0; i < nitems(nlm_rsa_ucode_data); i++)
158 nlm_rsa_ucode_data[i] = htobe64(nlm_rsa_ucode_data[i]);
159#endif
160 for (dstvc = sc->rsaecc_vc_start; dstvc <= sc->rsaecc_vc_end; dstvc++) {
161 cmd = malloc(sizeof(struct xlp_rsa_command), M_DEVBUF,
162 M_NOWAIT | M_ZERO);
163 KASSERT(cmd != NULL, ("%s:cmd is NULL\n", __func__));
164 cmd->rsasrc = contigmalloc(sizeof(nlm_rsa_ucode_data),
165 M_DEVBUF,
166 (M_WAITOK | M_ZERO),
167 0UL /* low address */, -1UL /* high address */,
168 XLP_L2L3_CACHELINE_SIZE /* alignment */,
169 0UL /* boundary */);
170 KASSERT(cmd->rsasrc != NULL,
171 ("%s:cmd->rsasrc is NULL\n", __func__));
172 memcpy(cmd->rsasrc, nlm_rsa_ucode_data,
173 sizeof(nlm_rsa_ucode_data));
174 m.msg[0] = nlm_crypto_form_rsa_ecc_fmn_entry0(1, 0x70, 0,
175 vtophys(cmd->rsasrc));
176 m.msg[1] = nlm_crypto_form_rsa_ecc_fmn_entry1(0, 1, fbvc,
177 vtophys(cmd->rsasrc));
178 /* Software scratch pad */
179 m.msg[2] = (uintptr_t)cmd;
180 m.msg[3] = 0;
181
182 ret = nlm_fmn_msgsend(dstvc, 3, FMN_SWCODE_RSA, &m);
183 if (ret != 0) {
184 err = -1;
185 printf("%s: msgsnd failed (%x)\n", __func__, ret);
186 goto errout;
187 }
188 }
189 /* Configure so that all VCs send request to all RSA pipes */
190 base = nlm_get_rsa_regbase(node);
191 if (nlm_is_xlp3xx()) {
192 endsel = 1;
193 regval = 0xFFFF;

Callers 1

xlp_rsa_attachFunction · 0.85

Calls 11

register_msgring_handlerFunction · 0.85
nlm_cpuidFunction · 0.85
mallocFunction · 0.85
contigmallocFunction · 0.85
nlm_fmn_msgsendFunction · 0.85
nlm_is_xlp3xxFunction · 0.85
xlp_free_cmd_paramsFunction · 0.70
printfFunction · 0.50
memcpyFunction · 0.50

Tested by

no test coverage detected