The NetBSD Project

CVS log for src/sys/arch/mips/cavium/dev/octeon_rnm.c

[BACK] Up to [cvs.NetBSD.org] / src / sys / arch / mips / cavium / dev

Request diff between arbitrary revisions


Keyword substitution: kv
Default branch: MAIN


Revision 1.17: download - view: text, markup, annotated - select for diffs
Thu Jan 30 02:15:50 2025 UTC (13 days, 5 hours ago) by gutteridge
Branches: MAIN
CVS tags: HEAD
Diff to: previous 1.16: preferred, colored
Changes since revision 1.16: +5 -5 lines
octeon_rnm.c: minor code formatting and grammar tweaks (NFC)

Revision 1.2.4.3: download - view: text, markup, annotated - select for diffs
Sun Jul 30 11:41:48 2023 UTC (18 months, 2 weeks ago) by martin
Branches: netbsd-9
CVS tags: netbsd-9-4-RELEASE
Diff to: previous 1.2.4.2: preferred, colored; branchpoint 1.2: preferred, colored; next MAIN 1.3: preferred, colored
Changes since revision 1.2.4.2: +5 -4 lines
Pull up following revision(s) (requested by gutteridge in ticket #256):

	sys/arch/mips/cavium/dev/octeon_rnm.c: revision 1.16 (patch)

octrnm(4): Raise delay on startup.

According to CN50XX-HRM-V0.99E and CN78XX-HM-0.99E:
    The entropy is provided by the jitter of 125 of 128 free-running
    oscillators XORed into a 128-bit LFSR.  The LFSR accumulates entropy
    over 81 cycles, after which it is fed into a SHA-1 engine.
    [...]
    The SHA-1 engine runs once every 81 cycles.
    [...]
    The hardware produces new 64-bit random number every 81 cycles.

The last sentence means that we only need to wait 81 cycles _between_
consecutive SHA-1 outputs (which isn't relevant anyway because we
reconfigure it into raw mode later), but the first two quotes might
mean that we need to wait 81+81 cycles for the _first_ output to be
produced on boot when running the self-test.

Now, in this case, the self-test is run with the LFSR unhooked, by
clearing the RNM_CTL_STATUS[ENT_EN] bit, so that SHA-1 is computed
from a known input -- this is really just paranoia to make sure that
_some_ functions of the device (which is conjured out of thin air at
a fixed virtual address, with no firmware bindings to guide us)
behave as we expect.

And it's not clear if it really does take 81+81 cycles for the first
SHA-1 output to appear when the LFSR isn't feeding into it anyway.

But experimentally, delay of 81+81 cycles seems to work whereas a
delay of only 81 cycles crashes.
PR kern/57280

Revision 1.15.4.1: download - view: text, markup, annotated - select for diffs
Sun Jul 30 11:39:33 2023 UTC (18 months, 2 weeks ago) by martin
Branches: netbsd-10
CVS tags: netbsd-10-1-RELEASE, netbsd-10-0-RELEASE, netbsd-10-0-RC6, netbsd-10-0-RC5, netbsd-10-0-RC4, netbsd-10-0-RC3, netbsd-10-0-RC2, netbsd-10-0-RC1
Diff to: previous 1.15: preferred, colored; next MAIN 1.16: preferred, colored
Changes since revision 1.15: +5 -4 lines
Pull up following revision(s) (requested by gutteridge in ticket #256):

	sys/arch/mips/cavium/dev/octeon_rnm.c: revision 1.16

octrnm(4): Raise delay on startup.

According to CN50XX-HRM-V0.99E and CN78XX-HM-0.99E:
    The entropy is provided by the jitter of 125 of 128 free-running
    oscillators XORed into a 128-bit LFSR.  The LFSR accumulates entropy
    over 81 cycles, after which it is fed into a SHA-1 engine.
    [...]
    The SHA-1 engine runs once every 81 cycles.
    [...]
    The hardware produces new 64-bit random number every 81 cycles.

The last sentence means that we only need to wait 81 cycles _between_
consecutive SHA-1 outputs (which isn't relevant anyway because we
reconfigure it into raw mode later), but the first two quotes might
mean that we need to wait 81+81 cycles for the _first_ output to be
produced on boot when running the self-test.

Now, in this case, the self-test is run with the LFSR unhooked, by
clearing the RNM_CTL_STATUS[ENT_EN] bit, so that SHA-1 is computed
from a known input -- this is really just paranoia to make sure that
_some_ functions of the device (which is conjured out of thin air at
a fixed virtual address, with no firmware bindings to guide us)
behave as we expect.

And it's not clear if it really does take 81+81 cycles for the first
SHA-1 output to appear when the LFSR isn't feeding into it anyway.

But experimentally, delay of 81+81 cycles seems to work whereas a
delay of only 81 cycles crashes.
PR kern/57280

Revision 1.16: download - view: text, markup, annotated - select for diffs
Tue Mar 21 22:07:29 2023 UTC (22 months, 3 weeks ago) by riastradh
Branches: MAIN
CVS tags: thorpej-ifq-base, thorpej-ifq, thorpej-altq-separation-base, thorpej-altq-separation, perseant-exfatfs-base-20240630, perseant-exfatfs-base, perseant-exfatfs
Diff to: previous 1.15: preferred, colored
Changes since revision 1.15: +5 -4 lines
octrnm(4): Raise delay on startup.

According to CN50XX-HRM-V0.99E and CN78XX-HM-0.99E:

   The entropy is provided by the jitter of 125 of 128 free-running
   oscillators XORed into a 128-bit LFSR.  The LFSR accumulates entropy
   over 81 cycles, after which it is fed into a SHA-1 engine.
   [...]
   The SHA-1 engine runs once every 81 cycles.
   [...]
   The hardware produces new 64-bit random number every 81 cycles.

The last sentence means that we only need to wait 81 cycles _between_
consecutive SHA-1 outputs (which isn't relevant anyway because we
reconfigure it into raw mode later), but the first two quotes might
mean that we need to wait 81+81 cycles for the _first_ output to be
produced on boot when running the self-test.

Now, in this case, the self-test is run with the LFSR unhooked, by
clearing the RNM_CTL_STATUS[ENT_EN] bit, so that SHA-1 is computed
from a known input -- this is really just paranoia to make sure that
_some_ functions of the device (which is conjured out of thin air at
a fixed virtual address, with no firmware bindings to guide us)
behave as we expect.

And it's not clear if it really does take 81+81 cycles for the first
SHA-1 output to appear when the LFSR isn't feeding into it anyway.
But experimentally, delay of 81+81 cycles seems to work whereas a
delay of only 81 cycles crashes.

PR kern/57280

XXX pullup-10
XXX pullup-9

Revision 1.15: download - view: text, markup, annotated - select for diffs
Sat Mar 19 11:55:03 2022 UTC (2 years, 10 months ago) by riastradh
Branches: MAIN
CVS tags: netbsd-10-base, bouyer-sunxi-drm-base, bouyer-sunxi-drm
Branch point for: netbsd-10
Diff to: previous 1.14: preferred, colored
Changes since revision 1.14: +4 -14 lines
rnd(9): Omit needless locks in various HWRNG drivers.

Now that the rnd(9) API guarantees serial callbacks, we can simplify
everything a bit more.

(Some drivers like hifn(4) and sun8icrypto(4) still use locks to
coordinate with other parts of the driver to submit requests to and
process responses from the device.)

Revision 1.14: download - view: text, markup, annotated - select for diffs
Sat Mar 19 11:37:05 2022 UTC (2 years, 10 months ago) by riastradh
Branches: MAIN
Diff to: previous 1.13: preferred, colored
Changes since revision 1.13: +3 -3 lines
rnd(9): Adjust IPL of locks used by rndsource callbacks.

These no longer ever run from hard interrupt context or with a spin
lock held, so there is no longer any need to have them at IPL_VM to
block hard interrupts.  Instead, lower them to IPL_SOFTSERIAL.

Revision 1.13: download - view: text, markup, annotated - select for diffs
Tue Dec 28 13:22:43 2021 UTC (3 years, 1 month ago) by riastradh
Branches: MAIN
Diff to: previous 1.12: preferred, colored
Changes since revision 1.12: +4 -5 lines
sys: Use preempt_point and preempt_needed, not open-coded versions.

Revision 1.12: download - view: text, markup, annotated - select for diffs
Thu Jun 18 13:52:08 2020 UTC (4 years, 7 months ago) by simonb
Branches: MAIN
CVS tags: thorpej-i2c-spi-conf2-base, thorpej-i2c-spi-conf2, thorpej-i2c-spi-conf-base, thorpej-i2c-spi-conf, thorpej-futex2-base, thorpej-futex2, thorpej-futex-base, thorpej-futex, thorpej-cfargs2-base, thorpej-cfargs2, thorpej-cfargs-base, thorpej-cfargs, cjep_sun2x-base1, cjep_sun2x-base, cjep_sun2x, cjep_staticlib_x-base1, cjep_staticlib_x-base, cjep_staticlib_x
Diff to: previous 1.11: preferred, colored
Changes since revision 1.11: +8 -12 lines
General code cleanup:
 - use generic macros for building IO and IOBDMA addresses instead
   of many different variations of the same theme.
 - use #define's for CVMSEG addresses instead of magic numbers.
 - use __BIT/__BITS/__SHIFTIN/__SHIFTOUT in most places, instead of
   foo_SHIFT defines or (worse) shifting by magic numbers.

No functional changes.

Revision 1.11: download - view: text, markup, annotated - select for diffs
Mon Jun 8 01:17:05 2020 UTC (4 years, 8 months ago) by simonb
Branches: MAIN
Diff to: previous 1.10: preferred, colored
Changes since revision 1.10: +3 -3 lines
Fix tyop in a comment.  Thanks riastradh@.

Revision 1.10: download - view: text, markup, annotated - select for diffs
Fri Jun 5 09:18:35 2020 UTC (4 years, 8 months ago) by simonb
Branches: MAIN
Diff to: previous 1.9: preferred, colored
Changes since revision 1.9: +4 -4 lines
Rework CVMSEG LM usage a litte:
 - remove unused LM slots
 - use #defines for defining the size of CVMSEG LM users

XXX: Need to dynamically set CVMMEMCTL[LMEMSZ] during startup so we can
     both adapt to any future increase in CVMSEG LM usage and not waste
     any more L2 that we need to.
XXX: Still need to move general IOBDMA conf to a different (new?) header.

Revision 1.9: download - view: text, markup, annotated - select for diffs
Sun May 31 06:27:06 2020 UTC (4 years, 8 months ago) by simonb
Branches: MAIN
Diff to: previous 1.8: preferred, colored
Changes since revision 1.8: +46 -46 lines
Rename all Cavium Octeon device driver functions, structs etc from
"octeon_foo" to "octfoo", except "octeon_eth" becomes "cnmac".

Revision 1.8: download - view: text, markup, annotated - select for diffs
Sun May 31 04:56:35 2020 UTC (4 years, 8 months ago) by simonb
Branches: MAIN
Diff to: previous 1.7: preferred, colored
Changes since revision 1.7: +3 -3 lines
Clean up Cavium Octeon device names.  Rename devices from "octeon_foo"
to "octfoo" - this follows the naming conventions used by many other
MIPS CPUs.

Revision 1.7: download - view: text, markup, annotated - select for diffs
Sat May 30 03:12:52 2020 UTC (4 years, 8 months ago) by simonb
Branches: MAIN
Diff to: previous 1.6: preferred, colored
Changes since revision 1.6: +18 -16 lines
CN70XX iobdma limit appears to be 128 words, so gather that many samples
as a time.
Gather the full 512 bytes of samples and process in a single call to
rnd_add_data_sync() - about 10% faster than 4 calls to rnd_add_data_sync().
Put sample buffer in the softc to save some stack usage.

Revision 1.2.4.2: download - view: text, markup, annotated - select for diffs
Tue May 19 17:39:04 2020 UTC (4 years, 8 months ago) by martin
Branches: netbsd-9
CVS tags: netbsd-9-3-RELEASE, netbsd-9-2-RELEASE, netbsd-9-1-RELEASE
Diff to: previous 1.2.4.1: preferred, colored; branchpoint 1.2: preferred, colored
Changes since revision 1.2.4.1: +3 -3 lines
Apply patch, requested by simonb in ticket #918:

the updated octeon_rnm(4) driver fails a bogus randomness
test in the netbsd-9 rnd(9) driver for RND_TYPE_RNG type devices so
uses the RND_TYPE_UNKNOWN type.  This approach is used by other drivers
on the netbsd-9 branch.

Revision 1.2.4.1: download - view: text, markup, annotated - select for diffs
Tue May 19 17:35:50 2020 UTC (4 years, 8 months ago) by martin
Branches: netbsd-9
Diff to: previous 1.2: preferred, colored
Changes since revision 1.2: +287 -90 lines
Pull up following revision(s) (requested by simonb in ticket #918):

	sys/arch/mips/cavium/dev/octeon_rnm.c: revision 1.3
	sys/arch/mips/cavium/dev/octeon_rnm.c: revision 1.4
	sys/arch/mips/cavium/dev/octeon_rnm.c: revision 1.5
	sys/arch/mips/cavium/dev/octeon_rnm.c: revision 1.6 (+ patch)
	sys/arch/mips/cavium/dev/octeon_rnmreg.h: revision 1.2
	sys/arch/mips/cavium/dev/octeon_rnmreg.h: revision 1.3
	sys/arch/mips/cavium/octeonvar.h: revision 1.7

Add a few more bits.
XXX convert to __BITS.
--
If bus_space_map fails, just don't attach the driver instead of panicing.
Check RNG built in self test, don't attach if that fails too.
--
Oceton RNG/RNM driver modernisation to fit new entropy world order by
riastradh@, with some tweaks to get working in RNG mode.
XXX TODO: work out how to get raw entropy mode working.
--
Rework octeon_rnm(4) random number generator driver.
- Do a little on-line self-test for fun.
- Draw raw samples from the ring oscillators.
- Draw substantially more samples:
  =3D> early RO samples seem to have considerably lower entropy
  =3D> consecutive RO samples are not independent
- Make sure to use rnd_add_data_sync in the callback.
  =3D> not technically needed in HEAD, but would be needed for pullup
--
Adjust entropy estimate for the Octeon.
We are hedging in serial and in parallel, and more conservative than
the Linux driver from Cavium seems to be, so although I don't know
exactly what the thermal jitter of the device is, this seems like a
reasonable compromise.

Revision 1.6: download - view: text, markup, annotated - select for diffs
Mon May 18 16:05:09 2020 UTC (4 years, 8 months ago) by riastradh
Branches: MAIN
Diff to: previous 1.5: preferred, colored
Changes since revision 1.5: +29 -18 lines
Adjust entropy estimate for the Octeon.

We are hedging in serial and in parallel, and more conservative than
the Linux driver from Cavium seems to be, so although I don't know
exactly what the thermal jitter of the device is, this seems like a
reasonable compromise.

Revision 1.5: download - view: text, markup, annotated - select for diffs
Wed May 13 21:09:02 2020 UTC (4 years, 9 months ago) by riastradh
Branches: MAIN
Diff to: previous 1.4: preferred, colored
Changes since revision 1.4: +255 -59 lines
Rework octeon_rnm(4) random number generator driver.

- Do a little on-line self-test for fun.
- Draw raw samples from the ring oscillators.
- Draw substantially more samples:
  => early RO samples seem to have considerably lower entropy
  => consecutive RO samples are not independent
- Make sure to use rnd_add_data_sync in the callback.
  => not technically needed in HEAD, but would be needed for pullup

Revision 1.4: download - view: text, markup, annotated - select for diffs
Tue May 12 14:04:50 2020 UTC (4 years, 9 months ago) by simonb
Branches: MAIN
Diff to: previous 1.3: preferred, colored
Changes since revision 1.3: +59 -78 lines
Oceton RNG/RNM driver modernisation to fit new entropy world order by
riastradh@, with some tweaks to get working in RNG mode.

XXX TODO: work out how to get raw entropy mode working.

Revision 1.3: download - view: text, markup, annotated - select for diffs
Tue May 12 10:37:10 2020 UTC (4 years, 9 months ago) by simonb
Branches: MAIN
Diff to: previous 1.2: preferred, colored
Changes since revision 1.2: +16 -7 lines
If bus_space_map fails, just don't attach the driver instead of panicing.
Check RNG built in self test, don't attach if that fails too.

Revision 1.1.22.1: download - view: text, markup, annotated - select for diffs
Mon Jun 10 22:06:29 2019 UTC (5 years, 8 months ago) by christos
Branches: phil-wifi
Diff to: previous 1.1: preferred, colored; next MAIN 1.2: preferred, colored
Changes since revision 1.1: +2 -3 lines
Sync with HEAD

Revision 1.1.20.1: download - view: text, markup, annotated - select for diffs
Fri Jan 18 08:50:19 2019 UTC (6 years ago) by pgoyette
Branches: pgoyette-compat
CVS tags: pgoyette-compat-merge-20190127
Diff to: previous 1.1: preferred, colored; next MAIN 1.2: preferred, colored
Changes since revision 1.1: +2 -3 lines
Synch with HEAD

Revision 1.2: download - view: text, markup, annotated - select for diffs
Tue Jan 8 19:41:09 2019 UTC (6 years, 1 month ago) by jdolecek
Branches: MAIN
CVS tags: phil-wifi-20200421, phil-wifi-20200411, phil-wifi-20200406, phil-wifi-20191119, phil-wifi-20190609, pgoyette-compat-20190127, pgoyette-compat-20190118, netbsd-9-base, netbsd-9-0-RELEASE, netbsd-9-0-RC2, netbsd-9-0-RC1, isaki-audio2-base, isaki-audio2, is-mlppp-base, is-mlppp, bouyer-xenpvh-base2, bouyer-xenpvh-base1, bouyer-xenpvh-base, bouyer-xenpvh, ad-namecache-base3, ad-namecache-base2, ad-namecache-base1, ad-namecache-base, ad-namecache
Branch point for: netbsd-9
Diff to: previous 1.1: preferred, colored
Changes since revision 1.1: +2 -3 lines
no need to include <machine/param.h> if <sys/param.h> already included

Revision 1.1.18.2: download - view: text, markup, annotated - select for diffs
Sun Dec 3 11:36:27 2017 UTC (7 years, 2 months ago) by jdolecek
Branches: tls-maxphys
Diff to: previous 1.1.18.1: preferred, colored; branchpoint 1.1: preferred, colored; next MAIN 1.2: preferred, colored
Changes since revision 1.1.18.1: +197 -0 lines
update from HEAD

Revision 1.1.2.2: download - view: text, markup, annotated - select for diffs
Sat Jun 6 14:40:01 2015 UTC (9 years, 8 months ago) by skrll
Branches: nick-nhusb
Diff to: previous 1.1.2.1: preferred, colored; branchpoint 1.1: preferred, colored; next MAIN 1.2: preferred, colored
Changes since revision 1.1.2.1: +197 -0 lines
Sync with HEAD

Revision 1.1.18.1
Wed Apr 29 08:32:01 2015 UTC (9 years, 9 months ago) by jdolecek
Branches: tls-maxphys
FILE REMOVED
Changes since revision 1.1: +0 -197 lines
file octeon_rnm.c was added on branch tls-maxphys on 2017-12-03 11:36:27 +0000

Revision 1.1.2.1
Wed Apr 29 08:32:01 2015 UTC (9 years, 9 months ago) by skrll
Branches: nick-nhusb
FILE REMOVED
Changes since revision 1.1: +0 -197 lines
file octeon_rnm.c was added on branch nick-nhusb on 2015-06-06 14:40:01 +0000

Revision 1.1: download - view: text, markup, annotated - select for diffs
Wed Apr 29 08:32:01 2015 UTC (9 years, 9 months ago) by hikaru
Branches: MAIN
CVS tags: tls-maxphys-base-20171202, prg-localcount2-base3, prg-localcount2-base2, prg-localcount2-base1, prg-localcount2-base, prg-localcount2, phil-wifi-base, pgoyette-localcount-base, pgoyette-localcount-20170426, pgoyette-localcount-20170320, pgoyette-localcount-20170107, pgoyette-localcount-20161104, pgoyette-localcount-20160806, pgoyette-localcount-20160726, pgoyette-localcount, pgoyette-compat-base, pgoyette-compat-1226, pgoyette-compat-1126, pgoyette-compat-1020, pgoyette-compat-0930, pgoyette-compat-0906, pgoyette-compat-0728, pgoyette-compat-0625, pgoyette-compat-0521, pgoyette-compat-0502, pgoyette-compat-0422, pgoyette-compat-0415, pgoyette-compat-0407, pgoyette-compat-0330, pgoyette-compat-0322, pgoyette-compat-0315, perseant-stdc-iso10646-base, perseant-stdc-iso10646, nick-nhusb-base-20170825, nick-nhusb-base-20170204, nick-nhusb-base-20161204, nick-nhusb-base-20161004, nick-nhusb-base-20160907, nick-nhusb-base-20160529, nick-nhusb-base-20160422, nick-nhusb-base-20160319, nick-nhusb-base-20151226, nick-nhusb-base-20150921, nick-nhusb-base-20150606, netbsd-8-base, netbsd-8-3-RELEASE, netbsd-8-2-RELEASE, netbsd-8-1-RELEASE, netbsd-8-1-RC1, netbsd-8-0-RELEASE, netbsd-8-0-RC2, netbsd-8-0-RC1, netbsd-8, matt-nb8-mediatek-base, matt-nb8-mediatek, localcount-20160914, jdolecek-ncq-base, jdolecek-ncq, bouyer-socketcan-base1, bouyer-socketcan-base, bouyer-socketcan
Branch point for: tls-maxphys, phil-wifi, pgoyette-compat, nick-nhusb
Initial import of Cavium Octeon and Octeon Plus SoC and
specifically Ubiquiti Networks EdgeRouter LITE support.
Currently the ethernet and uart are worked.
This support was contributed by Internet Initiative Japan Inc.

Diff request

This form allows you to request diffs between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.

Log view options

CVSweb <webmaster@jp.NetBSD.org>