Lines Matching +full:rs +full:-
1 // SPDX-License-Identifier: GPL-2.0
103 kfree(ws->errlocs); in free_ws()
104 kfree(ws->c); in free_ws()
108 static struct wspace *alloc_ws(struct rs_codec *rs) in alloc_ws() argument
110 int nroots = rs->nroots; in alloc_ws()
112 int nn = rs->nn; in alloc_ws()
118 ws->c = kmalloc_array(2 * (nn + nroots), in alloc_ws()
120 if (!ws->c) in alloc_ws()
123 ws->r = ws->c + nn; in alloc_ws()
124 ws->s = ws->r + nn; in alloc_ws()
125 ws->corr = ws->s + nroots; in alloc_ws()
127 ws->errlocs = kmalloc_array(nn + nroots, sizeof(int), GFP_KERNEL); in alloc_ws()
128 if (!ws->errlocs) in alloc_ws()
131 ws->derrlocs = ws->errlocs + nn; in alloc_ws()
151 static int get_rcw_we(struct rs_control *rs, struct wspace *ws, in get_rcw_we() argument
154 int nroots = rs->codec->nroots; in get_rcw_we()
155 int *derrlocs = ws->derrlocs; in get_rcw_we()
156 int *errlocs = ws->errlocs; in get_rcw_we()
157 int dlen = len - nroots; in get_rcw_we()
158 int nn = rs->codec->nn; in get_rcw_we()
159 uint16_t *c = ws->c; in get_rcw_we()
160 uint16_t *r = ws->r; in get_rcw_we()
170 encode_rs16(rs, c, dlen, c + dlen, 0); in get_rcw_we()
232 struct rs_codec *rs = rsc->codec; in compute_syndrome() local
233 uint16_t *alpha_to = rs->alpha_to; in compute_syndrome()
234 uint16_t *index_of = rs->index_of; in compute_syndrome()
235 int nroots = rs->nroots; in compute_syndrome()
236 int prim = rs->prim; in compute_syndrome()
237 int fcr = rs->fcr; in compute_syndrome()
248 alpha_to[rs_modnn(rs, index_of[syn[i]] in compute_syndrome()
256 syn[i] = rs->index_of[syn[i]]; in compute_syndrome()
260 static void test_uc(struct rs_control *rs, int len, int errs, in test_uc() argument
264 int dlen = len - rs->codec->nroots; in test_uc()
265 int *derrlocs = ws->derrlocs; in test_uc()
266 int *errlocs = ws->errlocs; in test_uc()
267 uint16_t *corr = ws->corr; in test_uc()
268 uint16_t *c = ws->c; in test_uc()
269 uint16_t *r = ws->r; in test_uc()
270 uint16_t *s = ws->s; in test_uc()
275 nerrs = get_rcw_we(rs, ws, len, errs, eras); in test_uc()
279 derrs = decode_rs16(rs, r, r + dlen, dlen, in test_uc()
284 compute_syndrome(rs, r, len, s); in test_uc()
285 derrs = decode_rs16(rs, NULL, NULL, dlen, in test_uc()
290 derrs = decode_rs16(rs, r, r + dlen, dlen, in test_uc()
298 stat->irv++; in test_uc()
303 stat->wepos++; in test_uc()
308 stat->dwrong++; in test_uc()
310 stat->nwords += trials; in test_uc()
313 static int ex_rs_helper(struct rs_control *rs, struct wspace *ws, in ex_rs_helper() argument
319 "Testing in-place interface..." in ex_rs_helper()
323 int nroots = rs->codec->nroots; in ex_rs_helper()
330 for (eras = 0; eras <= nroots - 2 * errs; eras++) in ex_rs_helper()
331 test_uc(rs, len, errs, eras, trials, &stat, ws, method); in ex_rs_helper()
349 static int exercise_rs(struct rs_control *rs, struct wspace *ws, in exercise_rs() argument
360 retval |= ex_rs_helper(rs, ws, len, trials, i); in exercise_rs()
366 static void test_bc(struct rs_control *rs, int len, int errs, in test_bc() argument
370 int nroots = rs->codec->nroots; in test_bc()
371 int dlen = len - nroots; in test_bc()
372 int *derrlocs = ws->derrlocs; in test_bc()
373 uint16_t *corr = ws->corr; in test_bc()
374 uint16_t *r = ws->r; in test_bc()
378 get_rcw_we(rs, ws, len, errs, eras); in test_bc()
379 derrs = decode_rs16(rs, r, r + dlen, dlen, in test_bc()
384 stat->rsuccess++; in test_bc()
396 encode_rs16(rs, r, dlen, corr, 0); in test_bc()
399 stat->noncw++; in test_bc()
401 stat->rfail++; in test_bc()
404 stat->nwords += trials; in test_bc()
407 static int exercise_rs_bc(struct rs_control *rs, struct wspace *ws, in exercise_rs_bc() argument
411 int nroots = rs->codec->nroots; in exercise_rs_bc()
418 eras = nroots - 2 * errs + 1; in exercise_rs_bc()
422 cutoff = nroots <= len - errs ? nroots : len - errs; in exercise_rs_bc()
424 test_bc(rs, len, errs, eras, trials, &stat, ws); in exercise_rs_bc()
444 int nn = (1 << e->symsize) - 1; in run_exercise()
445 int kk = nn - e->nroots; in run_exercise()
447 int retval = -ENOMEM; in run_exercise()
448 int max_pad = kk - 1; in run_exercise()
449 int prev_pad = -1; in run_exercise()
453 rsc = init_rs(e->symsize, e->genpoly, e->fcs, e->prim, e->nroots); in run_exercise()
457 ws = alloc_ws(rsc->codec); in run_exercise()
464 int len = nn - pad; in run_exercise()
472 len, kk - pad, nn + 1); in run_exercise()
475 retval |= exercise_rs(rsc, ws, len, e->ntrials); in run_exercise()
477 retval |= exercise_rs_bc(rsc, ws, len, e->ntrials); in run_exercise()
496 return -ENOMEM; in test_rslib_init()
506 return -EAGAIN; /* Fail will directly unload the module */ in test_rslib_init()
518 MODULE_DESCRIPTION("Reed-Solomon library test");