Lines Matching refs:rs
344 struct krndsource *rs;
421 LIST_FOREACH(rs, &E->sources, list)
422 rs->state = percpu_alloc(sizeof(struct rndsource_cpu));
1770 * rndsource_setcb(rs, get, getarg)
1772 * Set the request callback for the entropy source rs, if it can
1776 rndsource_setcb(struct krndsource *rs, void (*get)(size_t, void *),
1780 rs->get = get;
1781 rs->getarg = getarg;
1785 * rnd_attach_source(rs, name, type, flags)
1787 * Attach the entropy source rs. Must be done after
1791 rnd_attach_source(struct krndsource *rs, const char *name, uint32_t type,
1816 KASSERT(!ISSET(flags, RND_FLAG_HASCB) || rs->get != NULL);
1819 memset(rs->name, 0, sizeof(rs->name)); /* paranoia */
1820 strlcpy(rs->name, name, sizeof(rs->name));
1821 memset(&rs->time_delta, 0, sizeof(rs->time_delta));
1822 memset(&rs->value_delta, 0, sizeof(rs->value_delta));
1823 rs->total = 0;
1824 rs->type = type;
1825 rs->flags = flags;
1827 rs->state = percpu_alloc(sizeof(struct rndsource_cpu));
1833 LIST_INSERT_HEAD(&E->sources, rs, list);
1840 (*rs->get)(ENTROPY_CAPACITY, rs->getarg);
1850 * rnd_detach_source(rs)
1852 * Detach the entropy source rs. May sleep waiting for users to
1856 rnd_detach_source(struct krndsource *rs)
1864 LIST_REMOVE(rs, list);
1875 LIST_REMOVE(rs, list);
1879 percpu_free(rs->state, sizeof(struct rndsource_cpu));
1972 struct krndsource *rs;
1994 LIST_FOREACH(rs, &E->sources, list) {
1996 if (!ISSET(rs->flags, RND_FLAG_HASCB))
2003 if (ISSET(rs->flags, RND_FLAG_NO_COLLECT))
2009 (*rs->get)(nbytes, rs->getarg);
2050 rnd_dt_estimate(struct krndsource *rs, uint32_t t)
2057 rc = percpu_getref(rs->state);
2074 percpu_putref(rs->state);
2079 * rnd_add_uint32(rs, value)
2090 rnd_add_uint32(struct krndsource *rs, uint32_t value)
2094 rnd_add_data_internal(rs, &value, sizeof value, 0, intr_p);
2098 _rnd_add_uint32(struct krndsource *rs, uint32_t value)
2102 rnd_add_data_internal(rs, &value, sizeof value, 0, intr_p);
2106 _rnd_add_uint64(struct krndsource *rs, uint64_t value)
2110 rnd_add_data_internal(rs, &value, sizeof value, 0, intr_p);
2114 * rnd_add_data(rs, buf, len, entropybits)
2121 * rs MAY but SHOULD NOT be NULL. If rs is NULL, MUST NOT be
2124 * If rs is non-NULL, MAY but SHOULD NOT be called from interrupt
2135 rnd_add_data(struct krndsource *rs, const void *buf, uint32_t len,
2145 if (rs == NULL) {
2152 rs ? rs->name : "(anonymous)", entropybits, len);
2160 rnd_add_data_internal(rs, buf, len, entropybits, intr_p);
2164 * rnd_add_data_intr(rs, buf, len, entropybits)
2173 rnd_add_data_intr(struct krndsource *rs, const void *buf, uint32_t len,
2178 rnd_add_data_internal(rs, buf, len, entropybits, intr_p);
2182 * rnd_add_data_internal(rs, buf, len, entropybits, intr_p)
2192 rnd_add_data_internal(struct krndsource *rs, const void *buf, uint32_t len,
2200 rs ? rs->name : "(anonymous)", entropybits, len);
2211 flags = atomic_load_relaxed(&rs->flags);
2230 rnd_add_data_1(rs, buf, len, entropybits, /*count*/false,
2245 count = rnd_dt_estimate(rs, extra);
2249 rnd_add_data_1(rs, &extra, sizeof extra, 0, count,
2266 * rnd_add_data_1(rs, buf, len, entropybits, count, flag)
2273 rnd_add_data_1(struct krndsource *rs, const void *buf, uint32_t len,
2297 rs->total = add_sat(rs->total, entropybits);
2300 rs->time_delta.insamples =
2301 add_sat(rs->time_delta.insamples, 1);
2304 rs->value_delta.insamples =
2305 add_sat(rs->value_delta.insamples, 1);
2310 struct rndsource_cpu *rc = percpu_getref(rs->state);
2324 percpu_putref(rs->state);
2330 * rnd_add_data_sync(rs, buf, len, entropybits)
2336 rnd_add_data_sync(struct krndsource *rs, const void *buf, uint32_t len,
2340 rnd_add_data(rs, buf, len, entropybits);
2344 * rndsource_entropybits(rs)
2347 * been contributed via rs so far. Approximate if other CPUs may
2351 rndsource_entropybits(struct krndsource *rs)
2353 unsigned nbits = rs->total;
2357 percpu_foreach(rs->state, rndsource_entropybits_cpu, &nbits);
2373 * rndsource_to_user(rs, urs)
2375 * Copy a description of rs out to urs for userland.
2378 rndsource_to_user(struct krndsource *rs, rndsource_t *urs)
2387 CTASSERT(sizeof(urs->name) == sizeof(rs->name));
2388 strlcpy(urs->name, rs->name, sizeof(urs->name));
2389 urs->total = rndsource_entropybits(rs);
2390 urs->type = rs->type;
2391 urs->flags = atomic_load_relaxed(&rs->flags);
2395 * rndsource_to_user_est(rs, urse)
2397 * Copy a description of rs and estimation statistics out to urse
2401 rndsource_to_user_est(struct krndsource *rs, rndsource_est_t *urse)
2411 rndsource_to_user(rs, &urse->rt);
2414 urse->dt_samples = rs->time_delta.insamples;
2416 urse->dv_samples = rs->value_delta.insamples;
2418 percpu_foreach(rs->state, rndsource_to_user_est_cpu, urse);
2485 struct krndsource *rs;
2601 LIST_FOREACH(rs, &E->sources, list) {
2605 while (i < stat->count && rs != NULL) {
2607 rndsource_to_user(rs, &stat->source[i++]);
2609 rs = LIST_NEXT(rs, list);
2637 LIST_FOREACH(rs, &E->sources, list) {
2641 while (i < estat->count && rs != NULL) {
2643 rndsource_to_user_est(rs, &estat->source[i++]);
2645 rs = LIST_NEXT(rs, list);
2655 const size_t n = sizeof(rs->name);
2657 CTASSERT(sizeof(rs->name) == sizeof(nstat->name));
2669 LIST_FOREACH(rs, &E->sources, list) {
2670 if (strncmp(rs->name, nstat->name, n) == 0)
2673 if (rs != NULL) {
2675 rndsource_to_user(rs, &nstat->source);
2686 const size_t n = sizeof(rs->name);
2688 CTASSERT(sizeof(rs->name) == sizeof(enstat->name));
2700 LIST_FOREACH(rs, &E->sources, list) {
2701 if (strncmp(rs->name, enstat->name, n) == 0)
2704 if (rs != NULL) {
2706 rndsource_to_user_est(rs, &enstat->source);
2717 const size_t n = sizeof(rs->name);
2722 CTASSERT(sizeof(rs->name) == sizeof(rndctl->name));
2732 LIST_FOREACH(rs, &E->sources, list) {
2734 if (rs->type != rndctl->type)
2737 if (strncmp(rs->name, rndctl->name, n) != 0)
2740 flags = rs->flags & ~rndctl->mask;
2742 if ((rs->flags & resetflags) == 0 &&
2745 if ((rs->flags ^ flags) & resetflags)
2747 atomic_store_relaxed(&rs->flags, flags);