From b4e8a16d440068fd1e5d5202888687708e220754 Mon Sep 17 00:00:00 2001 From: purplerain Date: Thu, 8 Feb 2024 01:46:44 +0000 Subject: [PATCH] sync with OpenBSD -current --- gnu/llvm/lld/ELF/Arch/RISCV.cpp | 6 +- gnu/llvm/lld/ELF/InputSection.h | 4 +- lib/libz/compress.3 | 38 +- lib/libz/gzguts.h | 37 +- lib/libz/zlib.h | 27 +- sbin/pfctl/pfctl_parser.c | 28 +- share/zoneinfo/Makefile | 8 +- share/zoneinfo/datfiles/zonenow.tab | 303 ++++++++++++++ sys/dev/fdt/sxiccmu.c | 118 +++++- sys/dev/fdt/sxiccmu_clocks.h | 164 ++++++++ sys/dev/fdt/sximmc.c | 14 +- sys/dev/fdt/sxipio.c | 12 +- sys/dev/fdt/sxipio_pins.h | 597 ++++++++++++++++++++++++++++ sys/dev/fdt/sxisyscon.c | 5 +- sys/lib/libz/zlib.h | 27 +- sys/net/route.c | 34 +- sys/net80211/ieee80211_proto.c | 4 +- sys/netinet/in_pcb.c | 22 +- sys/netinet6/in6.h | 4 +- sys/netinet6/in6_pcb.c | 22 +- sys/netinet6/in6_src.c | 50 +-- sys/netinet6/ip6_forward.c | 22 +- sys/netinet6/ip6_output.c | 17 +- sys/netinet6/ip6_var.h | 4 +- usr.sbin/ntpd/ntp.c | 4 +- 25 files changed, 1362 insertions(+), 209 deletions(-) create mode 100644 share/zoneinfo/datfiles/zonenow.tab diff --git a/gnu/llvm/lld/ELF/Arch/RISCV.cpp b/gnu/llvm/lld/ELF/Arch/RISCV.cpp index b0864b517..4811d50ad 100644 --- a/gnu/llvm/lld/ELF/Arch/RISCV.cpp +++ b/gnu/llvm/lld/ELF/Arch/RISCV.cpp @@ -621,7 +621,7 @@ static bool relax(InputSection &sec) { // iteration. DenseMap valueDelta; ArrayRef sa = ArrayRef(aux.anchors); - uint32_t delta = 0; + uint64_t delta = 0; for (auto [i, r] : llvm::enumerate(sec.relocs())) { for (; sa.size() && sa[0].offset <= r.offset; sa = sa.slice(1)) if (!sa[0].end) @@ -688,8 +688,8 @@ static bool relax(InputSection &sec) { a.d->value -= delta - valueDelta.find(a.d)->second; } // Inform assignAddresses that the size has changed. - if (!isUInt<16>(delta)) - fatal("section size decrease is too large"); + if (!isUInt<32>(delta)) + fatal("section size decrease is too large: " + Twine(delta)); sec.bytesDropped = delta; return changed; } diff --git a/gnu/llvm/lld/ELF/InputSection.h b/gnu/llvm/lld/ELF/InputSection.h index 356ccda2d..143384b3b 100644 --- a/gnu/llvm/lld/ELF/InputSection.h +++ b/gnu/llvm/lld/ELF/InputSection.h @@ -137,7 +137,7 @@ public: // Used by --optimize-bb-jumps and RISC-V linker relaxation temporarily to // indicate the number of bytes which is not counted in the size. This should // be reset to zero after uses. - uint16_t bytesDropped = 0; + uint32_t bytesDropped = 0; mutable bool compressed = false; @@ -401,7 +401,7 @@ private: template void copyShtGroup(uint8_t *buf); }; -static_assert(sizeof(InputSection) <= 152, "InputSection is too big"); +static_assert(sizeof(InputSection) <= 160, "InputSection is too big"); class SyntheticSection : public InputSection { public: diff --git a/lib/libz/compress.3 b/lib/libz/compress.3 index 96db2af96..73d21d573 100644 --- a/lib/libz/compress.3 +++ b/lib/libz/compress.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: compress.3,v 1.26 2024/01/20 11:16:27 tb Exp $ +.\" $OpenBSD: compress.3,v 1.27 2024/02/07 20:51:38 tb Exp $ .\" .\" Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler .\" @@ -23,7 +23,7 @@ .\" .\" This page corresponds to zlib version 1.2.3 .\" -.Dd $Mdocdate: January 20 2024 $ +.Dd $Mdocdate: February 7 2024 $ .Dt COMPRESS 3 .Os .Sh NAME @@ -1127,33 +1127,41 @@ for normal data; .Dv Z_FILTERED for data produced by a filter .Pq or predictor ; -.Dv Z_HUFFMAN_ONLY -to force Huffman encoding only -.Pq no string match , -or .Dv Z_RLE to limit match distances to one -.Pq run-length encoding . +.Pq run-length encoding , +or +.Dv Z_HUFFMAN_ONLY +to force Huffman encoding only +.Pq no string match . Filtered data consists mostly of small values with a -somewhat random distribution. +somewhat random distribution, +as produced by the PNG filters. In this case, the compression algorithm is tuned to compress them better. The effect of .Dv Z_FILTERED -is to force more Huffman coding and less string matching; -it is somewhat intermediate between +is to force more Huffman coding and less string matching than the default; +it is intermediate between .Dv Z_DEFAULT_STRATEGY and .Dv Z_HUFFMAN_ONLY . .Dv Z_RLE -is designed to be almost as fast as +is almost as fast as .Dv Z_HUFFMAN_ONLY , -but gives better compression for PNG image data. +but should give better compression for PNG image data than Huffman only. +The degree of string matching from most to none is: +.Dv Z_DEFAULT_STRATEGY , +.Dv Z_FILTERED , +.Dv Z_RLE , +then +.Dv Z_HUFFMAN . The .Fa strategy -parameter only affects the compression ratio but not the correctness of the -compressed output, even if it is not set appropriately. +parameter affects the compression ratio but never the correctness of the +compressed output, even if it is not set optimally for the given data. .Dv Z_FIXED -prevents the use of dynamic Huffman codes, +uses the default string matching, +but prevents the use of dynamic Huffman codes, allowing for a simpler decoder for special applications. .Pp .Fn deflateInit2 diff --git a/lib/libz/gzguts.h b/lib/libz/gzguts.h index eba72085b..074ec84ec 100644 --- a/lib/libz/gzguts.h +++ b/lib/libz/gzguts.h @@ -25,8 +25,8 @@ # include #endif -#ifndef _POSIX_SOURCE -# define _POSIX_SOURCE +#ifndef _POSIX_C_SOURCE +# define _POSIX_C_SOURCE 200112L #endif #include @@ -72,33 +72,28 @@ #endif #ifndef HAVE_VSNPRINTF -# ifdef MSDOS +# if !defined(NO_vsnprintf) && \ + (defined(MSDOS) || defined(__TURBOC__) || defined(__SASC) || \ + defined(VMS) || defined(__OS400) || defined(__MVS__)) /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), but for now we just assume it doesn't. */ # define NO_vsnprintf # endif -# ifdef __TURBOC__ -# define NO_vsnprintf -# endif # ifdef WIN32 /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ -# if !defined(vsnprintf) && !defined(NO_vsnprintf) -# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 ) -# define vsnprintf _vsnprintf +# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 ) +# ifndef vsnprintf +# define vsnprintf _vsnprintf # endif # endif -# endif -# ifdef __SASC -# define NO_vsnprintf -# endif -# ifdef VMS -# define NO_vsnprintf -# endif -# ifdef __OS400__ -# define NO_vsnprintf -# endif -# ifdef __MVS__ -# define NO_vsnprintf +# elif !defined(__STDC_VERSION__) || __STDC_VERSION__-0 < 199901L +/* Otherwise if C89/90, assume no C99 snprintf() or vsnprintf() */ +# ifndef NO_snprintf +# define NO_snprintf +# endif +# ifndef NO_vsnprintf +# define NO_vsnprintf +# endif # endif #endif diff --git a/lib/libz/zlib.h b/lib/libz/zlib.h index a4e83a59d..6fed1b3bf 100644 --- a/lib/libz/zlib.h +++ b/lib/libz/zlib.h @@ -587,18 +587,21 @@ ZEXTERN int ZEXPORT deflateInit2(z_streamp strm, The strategy parameter is used to tune the compression algorithm. Use the value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a - filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no - string match), or Z_RLE to limit match distances to one (run-length - encoding). Filtered data consists mostly of small values with a somewhat - random distribution. In this case, the compression algorithm is tuned to - compress them better. The effect of Z_FILTERED is to force more Huffman - coding and less string matching; it is somewhat intermediate between - Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as - fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The - strategy parameter only affects the compression ratio but not the - correctness of the compressed output even if it is not set appropriately. - Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler - decoder for special applications. + filter (or predictor), Z_RLE to limit match distances to one (run-length + encoding), or Z_HUFFMAN_ONLY to force Huffman encoding only (no string + matching). Filtered data consists mostly of small values with a somewhat + random distribution, as produced by the PNG filters. In this case, the + compression algorithm is tuned to compress them better. The effect of + Z_FILTERED is to force more Huffman coding and less string matching than the + default; it is intermediate between Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. + Z_RLE is almost as fast as Z_HUFFMAN_ONLY, but should give better + compression for PNG image data than Huffman only. The degree of string + matching from most to none is: Z_DEFAULT_STRATEGY, Z_FILTERED, Z_RLE, then + Z_HUFFMAN. The strategy parameter affects the compression ratio but never + the correctness of the compressed output, even if it is not set optimally + for the given data. Z_FIXED uses the default string matching, but prevents + the use of dynamic Huffman codes, allowing for a simpler decoder for special + applications. deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid diff --git a/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c index 220b00070..57bab4b56 100644 --- a/sbin/pfctl/pfctl_parser.c +++ b/sbin/pfctl/pfctl_parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfctl_parser.c,v 1.349 2023/10/26 16:26:01 deraadt Exp $ */ +/* $OpenBSD: pfctl_parser.c,v 1.350 2024/02/07 23:53:44 jsg Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -720,17 +720,23 @@ print_rule(struct pf_rule *r, const char *anchor_call, int opts) if (verbose) printf("@%d ", r->nr); - if (r->action > PF_MATCH) - printf("action(%d)", r->action); - else if (anchor_call[0]) { - p = strrchr(anchor_call, '/'); - if (p ? p[1] == '_' : anchor_call[0] == '_') - printf("%s", anchortypes[r->action]); + if (anchor_call[0]) { + if (r->action >= nitems(anchortypes)) { + printf("anchor(%d)", r->action); + } else { + p = strrchr(anchor_call, '/'); + if (p ? p[1] == '_' : anchor_call[0] == '_') + printf("%s", anchortypes[r->action]); + else + printf("%s \"%s\"", anchortypes[r->action], + anchor_call); + } + } else { + if (r->action >= nitems(actiontypes)) + printf("action(%d)", r->action); else - printf("%s \"%s\"", anchortypes[r->action], - anchor_call); - } else - printf("%s", actiontypes[r->action]); + printf("%s", actiontypes[r->action]); + } if (r->action == PF_DROP) { if (r->rule_flag & PFRULE_RETURN) printf(" return"); diff --git a/share/zoneinfo/Makefile b/share/zoneinfo/Makefile index 515a3658e..e77782007 100644 --- a/share/zoneinfo/Makefile +++ b/share/zoneinfo/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.18 2023/11/18 07:18:07 anton Exp $ +# $OpenBSD: Makefile,v 1.19 2024/02/07 21:24:58 millert Exp $ # DATAFORM selects the data format. OpenBSD always uses "main" # Available formats represent essentially the same data, albeit @@ -82,11 +82,11 @@ TZDATA_TEXT= leapseconds tzdata.zi TDATA= africa antarctica asia australasia \ europe northamerica southamerica etcetera factory \ backward -TABDATA= iso3166.tab zone.tab zone1970.tab $(TZDATA_TEXT) +TABDATA= iso3166.tab zone.tab zone1970.tab zonenow.tab $(TZDATA_TEXT) DATA= $(TDATA) $(TABDATA) DSTDATA_ZI_DEPS= ziguard.awk $(TDATA) -ZIC= zic +ZIC= zic $(ZFLAGS) all: leapseconds tzdata.zi @@ -149,6 +149,8 @@ realinstall: ${DATA} ${REDO} ${DESTDIR}/usr/share/zoneinfo ${INSTALL} -c -o root -g bin -m 644 ${.CURDIR}/datfiles/zone1970.tab \ ${DESTDIR}/usr/share/zoneinfo + ${INSTALL} -c -o root -g bin -m 644 ${.CURDIR}/datfiles/zonenow.tab \ + ${DESTDIR}/usr/share/zoneinfo clean: rm -f leapseconds *.zi diff --git a/share/zoneinfo/datfiles/zonenow.tab b/share/zoneinfo/datfiles/zonenow.tab new file mode 100644 index 000000000..b6f291095 --- /dev/null +++ b/share/zoneinfo/datfiles/zonenow.tab @@ -0,0 +1,303 @@ +# tzdb timezone descriptions, for users who do not care about old timestamps +# +# This file is in the public domain. +# +# From Paul Eggert (2023-12-18): +# This file contains a table where each row stands for a timezone +# where civil timestamps are predicted to agree from now on. +# This file is like zone1970.tab (see zone1970.tab's coments), +# but with the following changes: +# +# 1. Each timezone corresponds to a set of clocks that are planned +# to agree from now on. This is a larger set of clocks than in +# zone1970.tab, where each timezone's clocks must agree from 1970 on. +# 2. The first column is irrelevant and ignored. +# 3. The table is sorted in a different way: +# first by standard time UTC offset; +# then, if DST is used, by daylight saving UTC offset; +# then by time zone abbreviation. +# 4. Every timezone has a nonempty comments column, with wording +# distinguishing the timezone only from other timezones with the +# same UTC offset at some point during the year. +# +# The format of this table is experimental, and may change in future versions. +# +# This table is intended as an aid for users, to help them select timezones +# appropriate for their practical needs. It is not intended to take or +# endorse any position on legal or territorial claims. +# +#XX coordinates TZ comments +# +# -11 - SST +XX -1416-17042 Pacific/Pago_Pago Midway; Samoa ("SST") +# +# -11 +XX -1901-16955 Pacific/Niue Niue +# +# -10 - HST +XX +211825-1575130 Pacific/Honolulu Hawaii ("HST") +# +# -10 +XX -1732-14934 Pacific/Tahiti Tahiti; Cook Islands +# +# -10/-09 - HST / HDT (North America DST) +XX +515248-1763929 America/Adak western Aleutians in Alaska ("HST/HDT") +# +# -09:30 +XX -0900-13930 Pacific/Marquesas Marquesas +# +# -09 +XX -2308-13457 Pacific/Gambier Gambier +# +# -09/-08 - AKST/AKDT (North America DST) +XX +611305-1495401 America/Anchorage most of Alaska ("AKST/AKDT") +# +# -08 +XX -2504-13005 Pacific/Pitcairn Pitcairn +# +# -08/-07 - PST/PDT (North America DST) +XX +340308-1181434 America/Los_Angeles Pacific ("PST/PDT") - US & Canada; Mexico near US border +# +# -07 - MST +XX +332654-1120424 America/Phoenix Mountain Standard ("MST") - Arizona; western Mexico; Yukon +# +# -07/-06 - MST/MDT (North America DST) +XX +394421-1045903 America/Denver Mountain ("MST/MDT") - US & Canada; Mexico near US border +# +# -06 +XX -0054-08936 Pacific/Galapagos Galápagos +# +# -06 - CST +XX +1924-09909 America/Mexico_City Central Standard ("CST") - Saskatchewan; central Mexico; Central America +# +# -06/-05 (Chile DST) +XX -2709-10926 Pacific/Easter Easter Island +# +# -06/-05 - CST/CDT (North America DST) +XX +415100-0873900 America/Chicago Central ("CST/CDT") - US & Canada; Mexico near US border +# +# -05 +XX -1203-07703 America/Lima eastern South America +# +# -05 - EST +XX +175805-0764736 America/Jamaica Eastern Standard ("EST") - Caymans; Jamaica; eastern Mexico; Panama +# +# -05/-04 - CST/CDT (Cuba DST) +XX +2308-08222 America/Havana Cuba +# +# -05/-04 - EST/EDT (North America DST) +XX +404251-0740023 America/New_York Eastern ("EST/EDT") - US & Canada +# +# -04 +XX +1030-06656 America/Caracas western South America +# +# -04 - AST +XX +1828-06954 America/Santo_Domingo Atlantic Standard ("AST") - eastern Caribbean +# +# -04/-03 (Chile DST) +XX -3327-07040 America/Santiago most of Chile +# +# -04/-03 (Paraguay DST) +XX -2516-05740 America/Asuncion Paraguay +# +# -04/-03 - AST/ADT (North America DST) +XX +4439-06336 America/Halifax Atlantic ("AST/ADT") - Canada; Bermuda +# +# -03:30/-02:30 - NST/NDT (North America DST) +XX +4734-05243 America/St_Johns Newfoundland ("NST/NDT") +# +# -03 +XX -2332-04637 America/Sao_Paulo eastern South America +# +# -03/-02 (North America DST) +XX +4703-05620 America/Miquelon St Pierre & Miquelon +# +# -02 +XX -0351-03225 America/Noronha Fernando de Noronha; South Georgia +# +# -02/-01 (EU DST) +XX +6411-05144 America/Nuuk most of Greenland +# +# -01 +XX +1455-02331 Atlantic/Cape_Verde Cape Verde +# +# -01/+00 (EU DST) +XX +3744-02540 Atlantic/Azores Azores +# -01/+00 (EU DST) until 2024-03-31; then -02/-01 (EU DST) +XX +7029-02158 America/Scoresbysund Ittoqqortoormiit +# +# +00 - GMT +XX +0519-00402 Africa/Abidjan far western Africa; Iceland ("GMT") +# +# +00/+01 - GMT/BST (EU DST) +XX +513030-0000731 Europe/London United Kingdom ("GMT/BST") +# +# +00/+01 - WET/WEST (EU DST) +XX +3843-00908 Europe/Lisbon western Europe ("WET/WEST") +# +# +00/+02 - Troll DST +XX -720041+0023206 Antarctica/Troll Troll Station in Antarctica +# +# +01 - CET +XX +3647+00303 Africa/Algiers Algeria, Tunisia ("CET") +# +# +01 - WAT +XX +0627+00324 Africa/Lagos western Africa ("WAT") +# +# +01/+00 - IST/GMT (EU DST in reverse) +XX +5320-00615 Europe/Dublin Ireland ("IST/GMT") +# +# +01/+00 - (Morocco DST) +XX +3339-00735 Africa/Casablanca Morocco +# +# +01/+02 - CET/CEST (EU DST) +XX +4852+00220 Europe/Paris central Europe ("CET/CEST") +# +# +02 - CAT +XX -2558+03235 Africa/Maputo central Africa ("CAT") +# +# +02 - EET +XX +3254+01311 Africa/Tripoli Libya; Kaliningrad ("EET") +# +# +02 - SAST +XX -2615+02800 Africa/Johannesburg southern Africa ("SAST") +# +# +02/+03 - EET/EEST (EU DST) +XX +3758+02343 Europe/Athens eastern Europe ("EET/EEST") +# +# +02/+03 - EET/EEST (Egypt DST) +XX +3003+03115 Africa/Cairo Egypt +# +# +02/+03 - EET/EEST (Lebanon DST) +XX +3353+03530 Asia/Beirut Lebanon +# +# +02/+03 - EET/EEST (Moldova DST) +XX +4700+02850 Europe/Chisinau Moldova +# +# +02/+03 - EET/EEST (Palestine DST) +XX +3130+03428 Asia/Gaza Palestine +# +# +02/+03 - IST/IDT (Israel DST) +XX +314650+0351326 Asia/Jerusalem Israel +# +# +03 +XX +4101+02858 Europe/Istanbul Near East; Belarus +# +# +03 - EAT +XX -0117+03649 Africa/Nairobi eastern Africa ("EAT") +# +# +03 - MSK +XX +554521+0373704 Europe/Moscow Moscow ("MSK") +# +# +03:30 +XX +3540+05126 Asia/Tehran Iran +# +# +04 +XX +2518+05518 Asia/Dubai Russia; Caucasus; Persian Gulf; Seychelles; Réunion +# +# +04:30 +XX +3431+06912 Asia/Kabul Afghanistan +# +# +05 +XX +4120+06918 Asia/Tashkent Russia; west Kazakhstan; Tajikistan; Turkmenistan; Uzbekistan; Maldives +# +# +05 - PKT +XX +2452+06703 Asia/Karachi Pakistan ("PKT") +# +# +05:30 +XX +0656+07951 Asia/Colombo Sri Lanka +# +# +05:30 - IST +XX +2232+08822 Asia/Kolkata India ("IST") +# +# +05:45 +XX +2743+08519 Asia/Kathmandu Nepal +# +# +06 +XX +2343+09025 Asia/Dhaka Russia; Kyrgyzstan; Bhutan; Bangladesh; Chagos +# +06 until 2024-03-01; then +05 +XX +4315+07657 Asia/Almaty Kazakhstan (except western areas) +# +# +06:30 +XX +1647+09610 Asia/Yangon Myanmar; Cocos +# +# +07 +XX +1345+10031 Asia/Bangkok Russia; Indochina; Christmas Island +# +# +07 - WIB +XX -0610+10648 Asia/Jakarta Indonesia ("WIB") +# +# +08 +XX +0117+10351 Asia/Singapore Russia; Brunei; Malaysia; Singapore +# +# +08 - AWST +XX -3157+11551 Australia/Perth Western Australia ("AWST") +# +# +08 - CST +XX +3114+12128 Asia/Shanghai China ("CST") +# +# +08 - HKT +XX +2217+11409 Asia/Hong_Kong Hong Kong ("HKT") +# +# +08 - PHT +XX +1435+12100 Asia/Manila Philippines ("PHT") +# +# +08 - WITA +XX -0507+11924 Asia/Makassar Indonesia ("WITA") +# +# +08:45 +XX -3143+12852 Australia/Eucla Eucla +# +# +09 +XX +5203+11328 Asia/Chita Russia; Palau; East Timor +# +# +09 - JST +XX +353916+1394441 Asia/Tokyo Japan ("JST") +# +# +09 - KST +XX +3733+12658 Asia/Seoul Korea ("KST") +# +# +09 - WIT +XX -0232+14042 Asia/Jayapura Indonesia ("WIT") +# +# +09:30 - ACST +XX -1228+13050 Australia/Darwin Northern Territory ("ACST") +# +# +09:30/+10:30 - ACST/ACDT (Australia DST) +XX -3455+13835 Australia/Adelaide South Australia ("ACST/ACDT") +# +# +10 +XX +4310+13156 Asia/Vladivostok Russia; Yap; Chuuk; Papua New Guinea; Dumont d'Urville +# +# +10 - AEST +XX -2728+15302 Australia/Brisbane Queensland ("AEST") +# +# +10 - ChST +XX +1328+14445 Pacific/Guam Mariana Islands ("ChST") +# +# +10/+11 - AEST/AEDT (Australia DST) +XX -3352+15113 Australia/Sydney southeast Australia ("AEST/AEDT") +# +# +10:30/+11 +XX -3133+15905 Australia/Lord_Howe Lord Howe Island +# +# +11 +XX -0613+15534 Pacific/Bougainville Russia; Kosrae; Bougainville; Solomons +# +# +11/+12 (Australia DST) +XX -2903+16758 Pacific/Norfolk Norfolk Island +# +# +12 +XX +5301+15839 Asia/Kamchatka Russia; Tuvalu; Fiji; etc. +# +# +12/+13 (New Zealand DST) +XX -3652+17446 Pacific/Auckland New Zealand ("NZST/NZDT") +# +# +12:45/+13:45 (Chatham DST) +XX -4357-17633 Pacific/Chatham Chatham Islands +# +# +13 +XX -210800-1751200 Pacific/Tongatapu Kanton; Tokelau; Samoa (western); Tonga +# +# +14 +XX +0152-15720 Pacific/Kiritimati Kiritimati diff --git a/sys/dev/fdt/sxiccmu.c b/sys/dev/fdt/sxiccmu.c index f482a7320..5a5273048 100644 --- a/sys/dev/fdt/sxiccmu.c +++ b/sys/dev/fdt/sxiccmu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sxiccmu.c,v 1.34 2024/02/02 12:01:49 kettenis Exp $ */ +/* $OpenBSD: sxiccmu.c,v 1.35 2024/02/07 22:00:38 uaa Exp $ */ /* * Copyright (c) 2007,2009 Dale Rahn * Copyright (c) 2013 Artturi Alm @@ -106,6 +106,9 @@ uint32_t sxiccmu_h3_r_get_frequency(struct sxiccmu_softc *, uint32_t); uint32_t sxiccmu_h6_get_frequency(struct sxiccmu_softc *, uint32_t); int sxiccmu_h6_set_frequency(struct sxiccmu_softc *, uint32_t, uint32_t); uint32_t sxiccmu_h6_r_get_frequency(struct sxiccmu_softc *, uint32_t); +uint32_t sxiccmu_h616_get_frequency(struct sxiccmu_softc *, uint32_t); +int sxiccmu_h616_set_frequency(struct sxiccmu_softc *, uint32_t, uint32_t); +uint32_t sxiccmu_h616_r_get_frequency(struct sxiccmu_softc *, uint32_t); uint32_t sxiccmu_r40_get_frequency(struct sxiccmu_softc *, uint32_t); int sxiccmu_r40_set_frequency(struct sxiccmu_softc *, uint32_t, uint32_t); uint32_t sxiccmu_v3s_get_frequency(struct sxiccmu_softc *, uint32_t); @@ -152,7 +155,9 @@ sxiccmu_match(struct device *parent, void *match, void *aux) OF_is_compatible(node, "allwinner,sun50i-a64-r-ccu") || OF_is_compatible(node, "allwinner,sun50i-h5-ccu") || OF_is_compatible(node, "allwinner,sun50i-h6-ccu") || - OF_is_compatible(node, "allwinner,sun50i-h6-r-ccu")); + OF_is_compatible(node, "allwinner,sun50i-h6-r-ccu") || + OF_is_compatible(node, "allwinner,sun50i-h616-ccu") || + OF_is_compatible(node, "allwinner,sun50i-h616-r-ccu")); } void @@ -287,6 +292,22 @@ sxiccmu_attach(struct device *parent, struct device *self, void *aux) sc->sc_nresets = nitems(sun50i_h6_r_resets); sc->sc_get_frequency = sxiccmu_h6_r_get_frequency; sc->sc_set_frequency = sxiccmu_nop_set_frequency; + } else if (OF_is_compatible(node, "allwinner,sun50i-h616-ccu")) { + KASSERT(faa->fa_nreg > 0); + sc->sc_gates = sun50i_h616_gates; + sc->sc_ngates = nitems(sun50i_h616_gates); + sc->sc_resets = sun50i_h616_resets; + sc->sc_nresets = nitems(sun50i_h616_resets); + sc->sc_get_frequency = sxiccmu_h616_get_frequency; + sc->sc_set_frequency = sxiccmu_h616_set_frequency; + } else if (OF_is_compatible(node, "allwinner,sun50i-h616-r-ccu")) { + KASSERT(faa->fa_nreg > 0); + sc->sc_gates = sun50i_h616_r_gates; + sc->sc_ngates = nitems(sun50i_h616_r_gates); + sc->sc_resets = sun50i_h616_r_resets; + sc->sc_nresets = nitems(sun50i_h616_r_resets); + sc->sc_get_frequency = sxiccmu_h616_r_get_frequency; + sc->sc_set_frequency = sxiccmu_nop_set_frequency; } else { for (node = OF_child(node); node; node = OF_peer(node)) sxiccmu_attach_clock(sc, node, faa->fa_nreg); @@ -1400,7 +1421,6 @@ sxiccmu_h6_get_frequency(struct sxiccmu_softc *sc, uint32_t idx) case H6_CLK_APB2: /* XXX Controlled by a MUX. */ return 24000000; - break; } printf("%s: 0x%08x\n", __func__, idx); @@ -1414,7 +1434,52 @@ sxiccmu_h6_r_get_frequency(struct sxiccmu_softc *sc, uint32_t idx) case H6_R_CLK_APB2: /* XXX Controlled by a MUX. */ return 24000000; - break; + } + + printf("%s: 0x%08x\n", __func__, idx); + return 0; +} + +/* Allwinner H616 */ +#define H616_AHB3_CFG_REG 0x051c +#define H616_AHB3_CLK_FACTOR_N(x) (((x) >> 8) & 0x3) +#define H616_AHB3_CLK_FACTOR_M(x) (((x) >> 0) & 0x3) + +uint32_t +sxiccmu_h616_get_frequency(struct sxiccmu_softc *sc, uint32_t idx) +{ + uint32_t reg, m, n; + uint32_t freq; + + switch (idx) { + case H616_CLK_PLL_PERIPH0: + /* Not hardcoded, but recommended. */ + return 600000000; + case H616_CLK_PLL_PERIPH0_2X: + return sxiccmu_h616_get_frequency(sc, H616_CLK_PLL_PERIPH0) * 2; + case H616_CLK_AHB3: + reg = SXIREAD4(sc, H616_AHB3_CFG_REG); + /* assume PLL_PERIPH0 source */ + freq = sxiccmu_h616_get_frequency(sc, H616_CLK_PLL_PERIPH0); + m = H616_AHB3_CLK_FACTOR_M(reg) + 1; + n = 1 << H616_AHB3_CLK_FACTOR_N(reg); + return freq / (m * n); + case H616_CLK_APB2: + /* XXX Controlled by a MUX. */ + return 24000000; + } + + printf("%s: 0x%08x\n", __func__, idx); + return 0; +} + +uint32_t +sxiccmu_h616_r_get_frequency(struct sxiccmu_softc *sc, uint32_t idx) +{ + switch (idx) { + case H616_R_CLK_APB2: + /* XXX Controlled by a MUX. */ + return 24000000; } printf("%s: 0x%08x\n", __func__, idx); @@ -1864,9 +1929,8 @@ sxiccmu_h3_set_frequency(struct sxiccmu_softc *sc, uint32_t idx, uint32_t freq) int sxiccmu_h6_mmc_set_frequency(struct sxiccmu_softc *sc, bus_size_t offset, - uint32_t freq) + uint32_t freq, uint32_t parent_freq) { - uint32_t parent_freq; uint32_t reg, m, n; uint32_t clk_src; @@ -1882,8 +1946,6 @@ sxiccmu_h6_mmc_set_frequency(struct sxiccmu_softc *sc, bus_size_t offset, case 52000000: n = 0, m = 0; clk_src = H6_SMHC_CLK_SRC_SEL_PLL_PERIPH0_2X; - parent_freq = - sxiccmu_h6_get_frequency(sc, H6_CLK_PLL_PERIPH0_2X); while ((parent_freq / (1 << n) / 16) > freq) n++; while ((parent_freq / (1 << n) / (m + 1)) > freq) @@ -1908,13 +1970,47 @@ sxiccmu_h6_mmc_set_frequency(struct sxiccmu_softc *sc, bus_size_t offset, int sxiccmu_h6_set_frequency(struct sxiccmu_softc *sc, uint32_t idx, uint32_t freq) { + uint32_t parent_freq; + + parent_freq = sxiccmu_h6_get_frequency(sc, H6_CLK_PLL_PERIPH0_2X); + switch (idx) { case H6_CLK_MMC0: - return sxiccmu_h6_mmc_set_frequency(sc, H6_SMHC0_CLK_REG, freq); + return sxiccmu_h6_mmc_set_frequency(sc, H6_SMHC0_CLK_REG, + freq, parent_freq); case H6_CLK_MMC1: - return sxiccmu_h6_mmc_set_frequency(sc, H6_SMHC1_CLK_REG, freq); + return sxiccmu_h6_mmc_set_frequency(sc, H6_SMHC1_CLK_REG, + freq, parent_freq); case H6_CLK_MMC2: - return sxiccmu_h6_mmc_set_frequency(sc, H6_SMHC2_CLK_REG, freq); + return sxiccmu_h6_mmc_set_frequency(sc, H6_SMHC2_CLK_REG, + freq, parent_freq); + } + + printf("%s: 0x%08x\n", __func__, idx); + return -1; +} + +#define H616_SMHC0_CLK_REG 0x0830 +#define H616_SMHC1_CLK_REG 0x0834 +#define H616_SMHC2_CLK_REG 0x0838 + +int +sxiccmu_h616_set_frequency(struct sxiccmu_softc *sc, uint32_t idx, uint32_t freq) +{ + uint32_t parent_freq; + + parent_freq = sxiccmu_h616_get_frequency(sc, H616_CLK_PLL_PERIPH0_2X); + + switch (idx) { + case H616_CLK_MMC0: + return sxiccmu_h6_mmc_set_frequency(sc, H616_SMHC0_CLK_REG, + freq, parent_freq); + case H616_CLK_MMC1: + return sxiccmu_h6_mmc_set_frequency(sc, H616_SMHC1_CLK_REG, + freq, parent_freq); + case H616_CLK_MMC2: + return sxiccmu_h6_mmc_set_frequency(sc, H616_SMHC2_CLK_REG, + freq, parent_freq); } printf("%s: 0x%08x\n", __func__, idx); diff --git a/sys/dev/fdt/sxiccmu_clocks.h b/sys/dev/fdt/sxiccmu_clocks.h index f8b4a85fd..bda6855fe 100644 --- a/sys/dev/fdt/sxiccmu_clocks.h +++ b/sys/dev/fdt/sxiccmu_clocks.h @@ -516,6 +516,100 @@ const struct sxiccmu_ccu_bit sun50i_h6_r_gates[] = { [H6_R_CLK_APB2_RSB] = { 0x01bc, 0, H6_R_CLK_APB2 }, }; +/* H616 */ + +#define H616_CLK_PLL_PERIPH0 4 +#define H616_CLK_PLL_PERIPH0_2X 5 +#define H616_CLK_AHB3 25 +#define H616_CLK_APB1 26 +#define H616_CLK_APB2 27 +#define H616_CLK_MMC0 60 +#define H616_CLK_MMC1 61 +#define H616_CLK_MMC2 62 +#define H616_CLK_BUS_MMC0 63 +#define H616_CLK_BUS_MMC1 64 +#define H616_CLK_BUS_MMC2 65 +#define H616_CLK_BUS_UART0 66 +#define H616_CLK_BUS_UART1 67 +#define H616_CLK_BUS_UART2 68 +#define H616_CLK_BUS_UART3 69 +#define H616_CLK_BUS_UART4 70 +#define H616_CLK_BUS_UART5 71 +#define H616_CLK_BUS_I2C0 72 +#define H616_CLK_BUS_I2C1 73 +#define H616_CLK_BUS_I2C2 74 +#define H616_CLK_BUS_I2C3 75 +#define H616_CLK_BUS_I2C4 76 +#define H616_CLK_BUS_EMAC0 82 +#define H616_CLK_BUS_EMAC1 83 +#define H616_CLK_USB_OHCI0 96 +#define H616_CLK_USB_PHY0 97 +#define H616_CLK_USB_OHCI1 98 +#define H616_CLK_USB_PHY1 99 +#define H616_CLK_USB_OHCI2 100 +#define H616_CLK_USB_PHY2 101 +#define H616_CLK_USB_OHCI3 102 +#define H616_CLK_USB_PHY3 103 +#define H616_CLK_BUS_OHCI0 104 +#define H616_CLK_BUS_OHCI1 105 +#define H616_CLK_BUS_OHCI2 106 +#define H616_CLK_BUS_OHCI3 107 +#define H616_CLK_BUS_EHCI0 108 +#define H616_CLK_BUS_EHCI1 109 +#define H616_CLK_BUS_EHCI2 110 +#define H616_CLK_BUS_EHCI3 111 + +struct sxiccmu_ccu_bit sun50i_h616_gates[] = { + [H616_CLK_PLL_PERIPH0] = { 0x0020, 31 }, + [H616_CLK_APB1] = { 0xffff, 0xff }, + [H616_CLK_MMC0] = { 0x0830, 31 }, + [H616_CLK_MMC1] = { 0x0834, 31 }, + [H616_CLK_MMC2] = { 0x0838, 31 }, + [H616_CLK_BUS_MMC0] = { 0x084c, 0 }, + [H616_CLK_BUS_MMC1] = { 0x084c, 1 }, + [H616_CLK_BUS_MMC2] = { 0x084c, 2 }, + [H616_CLK_BUS_UART0] = { 0x090c, 0, H616_CLK_APB2 }, + [H616_CLK_BUS_UART1] = { 0x090c, 1, H616_CLK_APB2 }, + [H616_CLK_BUS_UART2] = { 0x090c, 2, H616_CLK_APB2 }, + [H616_CLK_BUS_UART3] = { 0x090c, 3, H616_CLK_APB2 }, + [H616_CLK_BUS_UART4] = { 0x090c, 4, H616_CLK_APB2 }, + [H616_CLK_BUS_UART5] = { 0x090c, 5, H616_CLK_APB2 }, + [H616_CLK_BUS_I2C0] = { 0x091c, 0, H616_CLK_APB2 }, + [H616_CLK_BUS_I2C1] = { 0x091c, 1, H616_CLK_APB2 }, + [H616_CLK_BUS_I2C2] = { 0x091c, 2, H616_CLK_APB2 }, + [H616_CLK_BUS_I2C3] = { 0x091c, 3, H616_CLK_APB2 }, + [H616_CLK_BUS_I2C4] = { 0x091c, 4, H616_CLK_APB2 }, + [H616_CLK_BUS_EMAC0] = { 0x097c, 0, H616_CLK_AHB3 }, + [H616_CLK_BUS_EMAC1] = { 0x097c, 1, H616_CLK_AHB3 }, + [H616_CLK_USB_OHCI0] = { 0x0a70, 31 }, + [H616_CLK_USB_PHY0] = { 0x0a70, 29 }, + [H616_CLK_USB_OHCI1] = { 0x0a74, 31 }, + [H616_CLK_USB_PHY1] = { 0x0a74, 29 }, + [H616_CLK_USB_OHCI2] = { 0x0a78, 31 }, + [H616_CLK_USB_PHY2] = { 0x0a78, 29 }, + [H616_CLK_USB_OHCI3] = { 0x0a7c, 31 }, + [H616_CLK_USB_PHY3] = { 0x0a7c, 29 }, + [H616_CLK_BUS_OHCI0] = { 0x0a8c, 0 }, + [H616_CLK_BUS_OHCI1] = { 0x0a8c, 1 }, + [H616_CLK_BUS_OHCI2] = { 0x0a8c, 2 }, + [H616_CLK_BUS_OHCI3] = { 0x0a8c, 3 }, + [H616_CLK_BUS_EHCI0] = { 0x0a8c, 4 }, + [H616_CLK_BUS_EHCI1] = { 0x0a8c, 5 }, + [H616_CLK_BUS_EHCI2] = { 0x0a8c, 6 }, + [H616_CLK_BUS_EHCI3] = { 0x0a8c, 7 }, +}; + +#define H616_R_CLK_APB1 2 +#define H616_R_CLK_APB2 3 +#define H616_R_CLK_APB2_I2C 8 +#define H616_R_CLK_APB2_RSB 13 + +struct sxiccmu_ccu_bit sun50i_h616_r_gates[] = { + [H616_R_CLK_APB1] = { 0xffff, 0xff }, + [H616_R_CLK_APB2_I2C] = { 0x019c, 0, H616_R_CLK_APB2 }, + [H616_R_CLK_APB2_RSB] = { 0x01bc, 0, H616_R_CLK_APB2 }, +}; + /* R40 */ #define R40_CLK_PLL_PERIPH0 11 @@ -963,6 +1057,76 @@ const struct sxiccmu_ccu_bit sun50i_h6_r_resets[] = { [H6_R_RST_APB2_RSB] = { 0x01bc, 16 }, }; +/* H616 */ + +#define H616_RST_BUS_MMC0 14 +#define H616_RST_BUS_MMC1 15 +#define H616_RST_BUS_MMC2 16 +#define H616_RST_BUS_UART0 17 +#define H616_RST_BUS_UART1 18 +#define H616_RST_BUS_UART2 19 +#define H616_RST_BUS_UART3 20 +#define H616_RST_BUS_UART4 21 +#define H616_RST_BUS_UART5 22 +#define H616_RST_BUS_I2C0 23 +#define H616_RST_BUS_I2C1 24 +#define H616_RST_BUS_I2C2 25 +#define H616_RST_BUS_I2C3 26 +#define H616_RST_BUS_I2C4 27 +#define H616_RST_BUS_EMAC0 30 +#define H616_RST_BUS_EMAC1 31 +#define H616_RST_USB_PHY0 38 +#define H616_RST_USB_PHY1 39 +#define H616_RST_USB_PHY2 40 +#define H616_RST_USB_PHY3 41 +#define H616_RST_BUS_OHCI0 42 +#define H616_RST_BUS_OHCI1 43 +#define H616_RST_BUS_OHCI2 44 +#define H616_RST_BUS_OHCI3 45 +#define H616_RST_BUS_EHCI0 46 +#define H616_RST_BUS_EHCI1 47 +#define H616_RST_BUS_EHCI2 48 +#define H616_RST_BUS_EHCI3 49 + +struct sxiccmu_ccu_bit sun50i_h616_resets[] = { + [H616_RST_BUS_MMC0] = { 0x084c, 16 }, + [H616_RST_BUS_MMC1] = { 0x084c, 17 }, + [H616_RST_BUS_MMC2] = { 0x084c, 18 }, + [H616_RST_BUS_UART0] = { 0x090c, 16 }, + [H616_RST_BUS_UART1] = { 0x090c, 17 }, + [H616_RST_BUS_UART2] = { 0x090c, 18 }, + [H616_RST_BUS_UART3] = { 0x090c, 19 }, + [H616_RST_BUS_UART4] = { 0x090c, 20 }, + [H616_RST_BUS_UART5] = { 0x090c, 21 }, + [H616_RST_BUS_I2C0] = { 0x091c, 16 }, + [H616_RST_BUS_I2C1] = { 0x091c, 17 }, + [H616_RST_BUS_I2C2] = { 0x091c, 18 }, + [H616_RST_BUS_I2C3] = { 0x091c, 19 }, + [H616_RST_BUS_I2C4] = { 0x091c, 20 }, + [H616_RST_BUS_EMAC0] = { 0x097c, 16 }, + [H616_RST_BUS_EMAC1] = { 0x097c, 17 }, + [H616_RST_USB_PHY0] = { 0x0a70, 30 }, + [H616_RST_USB_PHY1] = { 0x0a74, 30 }, + [H616_RST_USB_PHY2] = { 0x0a78, 30 }, + [H616_RST_USB_PHY3] = { 0x0a7c, 30 }, + [H616_RST_BUS_OHCI0] = { 0x0a8c, 16 }, + [H616_RST_BUS_OHCI1] = { 0x0a8c, 17 }, + [H616_RST_BUS_OHCI2] = { 0x0a8c, 18 }, + [H616_RST_BUS_OHCI3] = { 0x0a8c, 19 }, + [H616_RST_BUS_EHCI0] = { 0x0a8c, 20 }, + [H616_RST_BUS_EHCI1] = { 0x0a8c, 21 }, + [H616_RST_BUS_EHCI2] = { 0x0a8c, 22 }, + [H616_RST_BUS_EHCI3] = { 0x0a8c, 23 }, +}; + +#define H616_R_RST_APB2_I2C 4 +#define H616_R_RST_APB2_RSB 7 + +struct sxiccmu_ccu_bit sun50i_h616_r_resets[] = { + [H616_R_RST_APB2_I2C] = { 0x019c, 16 }, + [H616_R_RST_APB2_RSB] = { 0x01bc, 16 }, +}; + /* R40 */ #define R40_RST_USB_PHY0 0 diff --git a/sys/dev/fdt/sximmc.c b/sys/dev/fdt/sximmc.c index d90c36c60..2ab7fbe37 100644 --- a/sys/dev/fdt/sximmc.c +++ b/sys/dev/fdt/sximmc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sximmc.c,v 1.13 2024/02/02 12:02:26 kettenis Exp $ */ +/* $OpenBSD: sximmc.c,v 1.14 2024/02/07 22:35:08 kettenis Exp $ */ /* $NetBSD: awin_mmc.c,v 1.23 2015/11/14 10:32:40 bouyer Exp $ */ /*- @@ -299,9 +299,10 @@ sximmc_match(struct device *parent, void *match, void *aux) OF_is_compatible(faa->fa_node, "allwinner,sun7i-a20-mmc") || OF_is_compatible(faa->fa_node, "allwinner,sun9i-a80-mmc") || OF_is_compatible(faa->fa_node, "allwinner,sun20i-d1-mmc") || - OF_is_compatible(faa->fa_node, "allwinner,sun20i-d1-emmc") || OF_is_compatible(faa->fa_node, "allwinner,sun50i-a64-mmc") || - OF_is_compatible(faa->fa_node, "allwinner,sun50i-a64-emmc")); + OF_is_compatible(faa->fa_node, "allwinner,sun50i-a64-emmc") || + OF_is_compatible(faa->fa_node, "allwinner,sun50i-a100-mmc") || + OF_is_compatible(faa->fa_node, "allwinner,sun50i-a100-emmc")); } int @@ -398,7 +399,8 @@ sximmc_attach(struct device *parent, struct device *self, void *aux) sc->sc_dma_ftrglevel = SXIMMC_DMA_FTRGLEVEL_A20; if (OF_is_compatible(faa->fa_node, "allwinner,sun20i-d1-mmc") || - OF_is_compatible(faa->fa_node, "allwinner,sun20i-d1-emmc")) + OF_is_compatible(faa->fa_node, "allwinner,sun50i-a100-mmc") || + OF_is_compatible(faa->fa_node, "allwinner,sun50i-a100-emmc")) sc->sc_idma_shift = 2; if (sc->sc_use_dma) { @@ -451,8 +453,8 @@ sximmc_attach(struct device *parent, struct device *self, void *aux) if (OF_is_compatible(sc->sc_node, "allwinner,sun4i-a10-mmc") || OF_is_compatible(sc->sc_node, "allwinner,sun20i-d1-mmc") || - OF_is_compatible(sc->sc_node, "allwinner,sun20i-d1-emmc") || - OF_is_compatible(sc->sc_node, "allwinner,sun50i-a64-emmc")) { + OF_is_compatible(sc->sc_node, "allwinner,sun50i-a64-emmc") || + OF_is_compatible(sc->sc_node, "allwinner,sun50i-a100-emmc")) { saa.max_seg = 0x2000; } else { saa.max_seg = 0x10000; diff --git a/sys/dev/fdt/sxipio.c b/sys/dev/fdt/sxipio.c index 9d0d575b3..00a6c897c 100644 --- a/sys/dev/fdt/sxipio.c +++ b/sys/dev/fdt/sxipio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sxipio.c,v 1.17 2023/10/13 15:41:25 kettenis Exp $ */ +/* $OpenBSD: sxipio.c,v 1.19 2024/02/08 00:00:16 jsg Exp $ */ /* * Copyright (c) 2010 Miodrag Vallat. * Copyright (c) 2013 Artturi Alm @@ -206,6 +206,14 @@ const struct sxipio_pins sxipio_pins[] = { "allwinner,sun50i-h6-r-pinctrl", sun50i_h6_r_pins, nitems(sun50i_h6_r_pins) }, + { + "allwinner,sun50i-h616-pinctrl", + sun50i_h616_pins, nitems(sun50i_h616_pins) + }, + { + "allwinner,sun50i-h616-r-pinctrl", + sun50i_h616_r_pins, nitems(sun50i_h616_r_pins) + }, }; int @@ -354,7 +362,7 @@ sxipio_pinctrl(uint32_t phandle, void *cookie) if (strcmp(func, sc->sc_pins[i].funcs[j].name) == 0) break; } - if (j > nitems(sc->sc_pins[i].funcs)) + if (j >= nitems(sc->sc_pins[i].funcs)) goto err; group = sc->sc_pins[i].name[1] - 'A'; diff --git a/sys/dev/fdt/sxipio_pins.h b/sys/dev/fdt/sxipio_pins.h index 361b6923c..492518c5a 100644 --- a/sys/dev/fdt/sxipio_pins.h +++ b/sys/dev/fdt/sxipio_pins.h @@ -11299,3 +11299,600 @@ const struct sxipio_pin sun50i_h6_r_pins[] = { { "irq", 6 }, } }, }; + +const struct sxipio_pin sun50i_h616_pins[] = { + { SXIPIO_PIN(A, 0), { + { "emac1", 2 }, + } }, + { SXIPIO_PIN(A, 1), { + { "emac1", 2 }, + } }, + { SXIPIO_PIN(A, 2), { + { "emac1", 2 }, + } }, + { SXIPIO_PIN(A, 3), { + { "emac1", 2 }, + } }, + { SXIPIO_PIN(A, 4), { + { "emac1", 2 }, + } }, + { SXIPIO_PIN(A, 5), { + { "emac1", 2 }, + } }, + { SXIPIO_PIN(A, 6), { + { "emac1", 2 }, + } }, + { SXIPIO_PIN(A, 7), { + { "emac1", 2 }, + } }, + { SXIPIO_PIN(A, 8), { + { "emac1", 2 }, + } }, + { SXIPIO_PIN(A, 9), { + { "emac1", 2 }, + } }, + { SXIPIO_PIN(A, 10), { + { "i2c3", 2 }, + } }, + { SXIPIO_PIN(A, 11), { + { "i2c3", 2 }, + } }, + { SXIPIO_PIN(A, 12), { + { "pwm5", 2 }, + } }, + { SXIPIO_PIN(C, 0), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "nand0", 2 }, + { "mmc2", 3 }, + { "spi0", 4 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(C, 1), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "nand0", 2 }, + { "mmc2", 3 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(C, 2), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "nand0", 2 }, + { "spi0", 4 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(C, 3), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "nand0", 2 }, + { "spi0", 4 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(C, 4), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "nand0", 2 }, + { "spi0", 4 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(C, 5), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "nand0", 2 }, + { "mmc2", 3 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(C, 6), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "nand0", 2 }, + { "mmc2", 3 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(C, 7), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "nand0", 2 }, + { "spi0", 4 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(C, 8), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "nand0", 2 }, + { "mmc2", 3 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(C, 9), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "nand0", 2 }, + { "mmc2", 3 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(C, 10), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "nand0", 2 }, + { "mmc2", 3 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(C, 11), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "nand0", 2 }, + { "mmc2", 3 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(C, 12), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "nand0", 2 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(C, 13), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "nand0", 2 }, + { "mmc2", 3 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(C, 14), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "nand0", 2 }, + { "mmc2", 3 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(C, 15), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "nand0", 2 }, + { "mmc2", 3 }, + { "spi0", 4 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(C, 16), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "nand0", 2 }, + { "mmc2", 3 }, + { "spi0", 4 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(F, 0), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "mmc0", 2 }, + { "jtag", 3 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(F, 1), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "mmc0", 2 }, + { "jtag", 3 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(F, 2), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "mmc0", 2 }, + { "uart0", 3 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(F, 3), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "mmc0", 2 }, + { "jtag", 3 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(F, 4), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "mmc0", 2 }, + { "uart0", 3 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(F, 5), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "mmc0", 2 }, + { "jtag", 3 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(F, 6), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(G, 0), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "mmc1", 2 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(G, 1), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "mmc1", 2 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(G, 2), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "mmc1", 2 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(G, 3), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "mmc1", 2 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(G, 4), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "mmc1", 2 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(G, 5), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "mmc1", 2 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(G, 6), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "uart1", 2 }, + { "jtag", 4 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(G, 7), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "uart1", 2 }, + { "jtag", 4 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(G, 8), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "uart1", 2 }, + { "clock", 3 }, + { "jtag", 4 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(G, 9), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "uart1", 2 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(G, 10), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "i2s2", 2 }, + { "clock", 3 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(G, 11), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "i2s2", 2 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(G, 12), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "i2s2", 2 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(G, 13), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "i2s2", 2 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(G, 14), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "i2s2", 2 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(G, 15), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "uart2", 2 }, + { "i2c4", 5 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(G, 16), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "uart2", 2 }, + { "i2c4", 5 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(G, 17), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "uart2", 2 }, + { "i2c3", 5 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(G, 18), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "uart2", 2 }, + { "i2c3", 5 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(G, 19), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "pwm1", 4 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(H, 0), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "uart0", 2 }, + { "pwm3", 4 }, + { "i2c1", 5 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(H, 1), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "uart0", 2 }, + { "pwm4", 4 }, + { "i2c1", 5 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(H, 2), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "uart5", 2 }, + { "spdif", 3 }, + { "pwm2", 4 }, + { "i2c2", 5 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(H, 3), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "uart5", 2 }, + { "pwm1", 4 }, + { "i2c2", 5 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(H, 4), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "spdif", 3 }, + { "i2c3", 5 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(H, 5), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "uart2", 2 }, + { "i2s3", 3 }, + { "spi1", 4 }, + { "i2c3", 5 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(H, 6), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "uart2", 2 }, + { "i2s3", 3 }, + { "spi1", 4 }, + { "i2c4", 5 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(H, 7), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "uart2", 2 }, + { "i2s3", 3 }, + { "spi1", 4 }, + { "i2c4", 5 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(H, 8), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "uart2", 2 }, + { "i2s3_dout0", 3 }, + { "spi1", 4 }, + { "i2s3_din1", 5 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(H, 9), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "i2s3_din0", 3 }, + { "spi1", 4 }, + { "i2s3_dout1", 5 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(H, 10), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "ir_rx", 3 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(I, 0), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "emac0", 2 }, + { "dmic", 3 }, + { "i2s0", 4 }, + { "hdmi", 5 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(I, 1), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "emac0", 2 }, + { "dmic", 3 }, + { "i2s0", 4 }, + { "hdmi", 5 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(I, 2), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "emac0", 2 }, + { "dmic", 3 }, + { "i2s0", 4 }, + { "hdmi", 5 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(I, 3), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "emac0", 2 }, + { "dmic", 3 }, + { "i2s0_dout0", 4 }, + { "i2s0_din1", 5 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(I, 4), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "emac0", 2 }, + { "dmic", 3 }, + { "i2s0_din0", 4 }, + { "i2s0_dout1", 5 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(I, 5), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "emac0", 2 }, + { "uart2", 3 }, + { "ts0", 4 }, + { "i2c0", 5 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(I, 6), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "emac0", 2 }, + { "uart2", 3 }, + { "ts0", 4 }, + { "i2c0", 5 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(I, 7), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "emac0", 2 }, + { "uart2", 3 }, + { "ts0", 4 }, + { "i2c1", 5 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(I, 8), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "emac0", 2 }, + { "uart2", 3 }, + { "ts0", 4 }, + { "i2c1", 5 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(I, 9), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "emac0", 2 }, + { "uart3", 3 }, + { "ts0", 4 }, + { "i2c2", 5 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(I, 10), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "emac0", 2 }, + { "uart3", 3 }, + { "ts0", 4 }, + { "i2c2", 5 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(I, 11), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "emac0", 2 }, + { "uart3", 3 }, + { "ts0", 4 }, + { "pwm1", 5 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(I, 12), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "emac0", 2 }, + { "uart3", 3 }, + { "ts0", 4 }, + { "pwm2", 5 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(I, 13), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "emac0", 2 }, + { "uart4", 3 }, + { "ts0", 4 }, + { "pwm3", 5 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(I, 14), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "emac0", 2 }, + { "uart4", 3 }, + { "ts0", 4 }, + { "pwm4", 5 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(I, 15), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "emac0", 2 }, + { "uart4", 3 }, + { "ts0", 4 }, + { "clock", 5 }, + { "irq", 6 }, + } }, + { SXIPIO_PIN(I, 16), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "emac0", 2 }, + { "uart4", 3 }, + { "ts0", 4 }, + { "clock", 5 }, + { "irq", 6 }, + } }, +}; + +const struct sxipio_pin sun50i_h616_r_pins[] = { + { SXIPIO_PIN(L, 0), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "s_rsb", 2 }, + { "s_i2c", 3 }, + } }, + { SXIPIO_PIN(L, 1), { + { "gpio_in", 0 }, + { "gpio_out", 1 }, + { "s_rsb", 2 }, + { "s_i2c", 3 }, + } }, +}; diff --git a/sys/dev/fdt/sxisyscon.c b/sys/dev/fdt/sxisyscon.c index 9d5470244..abb8fed32 100644 --- a/sys/dev/fdt/sxisyscon.c +++ b/sys/dev/fdt/sxisyscon.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sxisyscon.c,v 1.2 2021/10/24 17:52:27 mpi Exp $ */ +/* $OpenBSD: sxisyscon.c,v 1.3 2024/02/07 22:00:38 uaa Exp $ */ /* * Copyright (c) 2019 Mark Kettenis * @@ -52,7 +52,8 @@ sxisyscon_match(struct device *parent, void *match, void *aux) if (OF_is_compatible(node, "allwinner,sun8i-h3-system-control") || OF_is_compatible(node, "allwinner,sun50i-a64-system-control") || OF_is_compatible(node, "allwinner,sun50i-h5-system-control") || - OF_is_compatible(node, "allwinner,sun50i-h6-system-control")) + OF_is_compatible(node, "allwinner,sun50i-h6-system-control") || + OF_is_compatible(node, "allwinner,sun50i-h616-system-control")) return 10; /* Must beat syscon(4). */ return 0; diff --git a/sys/lib/libz/zlib.h b/sys/lib/libz/zlib.h index c61b37bcf..2844c3e17 100644 --- a/sys/lib/libz/zlib.h +++ b/sys/lib/libz/zlib.h @@ -587,18 +587,21 @@ ZEXTERN int ZEXPORT deflateInit2(z_streamp strm, The strategy parameter is used to tune the compression algorithm. Use the value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a - filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no - string match), or Z_RLE to limit match distances to one (run-length - encoding). Filtered data consists mostly of small values with a somewhat - random distribution. In this case, the compression algorithm is tuned to - compress them better. The effect of Z_FILTERED is to force more Huffman - coding and less string matching; it is somewhat intermediate between - Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as - fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The - strategy parameter only affects the compression ratio but not the - correctness of the compressed output even if it is not set appropriately. - Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler - decoder for special applications. + filter (or predictor), Z_RLE to limit match distances to one (run-length + encoding), or Z_HUFFMAN_ONLY to force Huffman encoding only (no string + matching). Filtered data consists mostly of small values with a somewhat + random distribution, as produced by the PNG filters. In this case, the + compression algorithm is tuned to compress them better. The effect of + Z_FILTERED is to force more Huffman coding and less string matching than the + default; it is intermediate between Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. + Z_RLE is almost as fast as Z_HUFFMAN_ONLY, but should give better + compression for PNG image data than Huffman only. The degree of string + matching from most to none is: Z_DEFAULT_STRATEGY, Z_FILTERED, Z_RLE, then + Z_HUFFMAN. The strategy parameter affects the compression ratio but never + the correctness of the compressed output, even if it is not set optimally + for the given data. Z_FIXED uses the default string matching, but prevents + the use of dynamic Huffman codes, allowing for a simpler decoder for special + applications. deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid diff --git a/sys/net/route.c b/sys/net/route.c index adb371985..ae8867da4 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.428 2024/02/05 23:16:39 bluhm Exp $ */ +/* $OpenBSD: route.c,v 1.430 2024/02/07 23:52:20 bluhm Exp $ */ /* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */ /* @@ -230,6 +230,38 @@ route_cache(struct route *ro, struct in_addr addr, u_int rtableid) satosin(&ro->ro_dst)->sin_addr = addr; } +#ifdef INET6 +void +route6_cache(struct route_in6 *ro, const struct in6_addr *addr, + u_int rtableid) +{ + u_long gen; + + gen = atomic_load_long(&rtgeneration); + membar_consumer(); + + if (rtisvalid(ro->ro_rt) && + ro->ro_generation == gen && + ro->ro_tableid == rtableid && + ro->ro_dst.sin6_family == AF_INET6 && + IN6_ARE_ADDR_EQUAL(&ro->ro_dst.sin6_addr, addr)) { + ip6stat_inc(ip6s_rtcachehit); + return; + } + + ip6stat_inc(ip6s_rtcachemiss); + rtfree(ro->ro_rt); + ro->ro_rt = NULL; + ro->ro_generation = gen; + ro->ro_tableid = rtableid; + + memset(&ro->ro_dst, 0, sizeof(ro->ro_dst)); + ro->ro_dst.sin6_family = AF_INET6; + ro->ro_dst.sin6_len = sizeof(struct sockaddr_in6); + ro->ro_dst.sin6_addr = *addr; +} +#endif + /* * Returns 1 if the (cached) ``rt'' entry is still valid, 0 otherwise. */ diff --git a/sys/net80211/ieee80211_proto.c b/sys/net80211/ieee80211_proto.c index 7f8175d15..3d8d649c8 100644 --- a/sys/net80211/ieee80211_proto.c +++ b/sys/net80211/ieee80211_proto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_proto.c,v 1.108 2022/03/14 15:07:24 stsp Exp $ */ +/* $OpenBSD: ieee80211_proto.c,v 1.109 2024/02/08 00:05:46 jsg Exp $ */ /* $NetBSD: ieee80211_proto.c,v 1.8 2004/04/30 23:58:20 dyoung Exp $ */ /*- @@ -861,7 +861,7 @@ ieee80211_try_another_bss(struct ieee80211com *ic) /* Should not happen but seriously, don't try the same AP again. */ if (memcmp(selbs->ni_macaddr, ic->ic_bss->ni_macaddr, - IEEE80211_NWID_LEN) == 0) + IEEE80211_ADDR_LEN) == 0) return; if (ifp->if_flags & IFF_DEBUG) diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index fd6417eea..456135a72 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in_pcb.c,v 1.289 2024/02/02 15:39:23 bluhm Exp $ */ +/* $OpenBSD: in_pcb.c,v 1.290 2024/02/07 23:40:40 bluhm Exp $ */ /* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */ /* @@ -916,24 +916,10 @@ in_pcbrtentry(struct inpcb *inp) ro = &inp->inp_route; - /* check if route is still valid */ - if (!rtisvalid(ro->ro_rt)) { - rtfree(ro->ro_rt); - ro->ro_rt = NULL; - } - - /* - * No route yet, so try to acquire one. - */ + if (inp->inp_faddr.s_addr == INADDR_ANY) + return (NULL); + route_cache(ro, inp->inp_faddr, inp->inp_rtableid); if (ro->ro_rt == NULL) { - memset(ro, 0, sizeof(struct route)); - - if (inp->inp_faddr.s_addr == INADDR_ANY) - return (NULL); - ro->ro_dst.sa_family = AF_INET; - ro->ro_dst.sa_len = sizeof(struct sockaddr_in); - satosin(&ro->ro_dst)->sin_addr = inp->inp_faddr; - ro->ro_tableid = inp->inp_rtableid; ro->ro_rt = rtalloc_mpath(&ro->ro_dst, &inp->inp_laddr.s_addr, ro->ro_tableid); } diff --git a/sys/netinet6/in6.h b/sys/netinet6/in6.h index 909166c7a..771f26c9c 100644 --- a/sys/netinet6/in6.h +++ b/sys/netinet6/in6.h @@ -1,4 +1,4 @@ -/* $OpenBSD: in6.h,v 1.113 2024/01/31 14:56:43 bluhm Exp $ */ +/* $OpenBSD: in6.h,v 1.114 2024/02/07 23:40:40 bluhm Exp $ */ /* $KAME: in6.h,v 1.83 2001/03/29 02:55:07 jinmei Exp $ */ /* @@ -428,6 +428,8 @@ int in6_mask2len(struct in6_addr *, u_char *); int in6_nam2sin6(const struct mbuf *, struct sockaddr_in6 **); int in6_sa2sin6(struct sockaddr *, struct sockaddr_in6 **); +void route6_cache(struct route_in6 *, const struct in6_addr *, u_int); + struct ip6_pktopts; struct ip6_moptions; diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c index d447beb83..0be0c4587 100644 --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_pcb.c,v 1.134 2024/01/31 12:27:57 bluhm Exp $ */ +/* $OpenBSD: in6_pcb.c,v 1.135 2024/02/07 23:40:40 bluhm Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -566,24 +566,10 @@ in6_pcbrtentry(struct inpcb *inp) { struct route_in6 *ro = &inp->inp_route6; - /* check if route is still valid */ - if (!rtisvalid(ro->ro_rt)) { - rtfree(ro->ro_rt); - ro->ro_rt = NULL; - } - - /* - * No route yet, so try to acquire one. - */ + if (IN6_IS_ADDR_UNSPECIFIED(&inp->inp_faddr6)) + return (NULL); + route6_cache(ro, &inp->inp_faddr6, inp->inp_rtableid); if (ro->ro_rt == NULL) { - memset(ro, 0, sizeof(struct route_in6)); - - if (IN6_IS_ADDR_UNSPECIFIED(&inp->inp_faddr6)) - return (NULL); - ro->ro_dst.sin6_family = AF_INET6; - ro->ro_dst.sin6_len = sizeof(struct sockaddr_in6); - ro->ro_dst.sin6_addr = inp->inp_faddr6; - ro->ro_tableid = inp->inp_rtableid; ro->ro_rt = rtalloc_mpath(sin6tosa(&ro->ro_dst), &inp->inp_laddr6.s6_addr32[0], ro->ro_tableid); } diff --git a/sys/netinet6/in6_src.c b/sys/netinet6/in6_src.c index 2c989ec15..78205a08d 100644 --- a/sys/netinet6/in6_src.c +++ b/sys/netinet6/in6_src.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_src.c,v 1.91 2024/01/09 19:57:01 bluhm Exp $ */ +/* $OpenBSD: in6_src.c,v 1.92 2024/02/07 23:40:40 bluhm Exp $ */ /* $KAME: in6_src.c,v 1.36 2001/02/06 04:08:17 itojun Exp $ */ /* @@ -82,7 +82,7 @@ #include #include -int in6_selectif(struct sockaddr_in6 *, struct ip6_pktopts *, +int in6_selectif(const struct in6_addr *, struct ip6_pktopts *, struct ip6_moptions *, struct route_in6 *, struct ifnet **, u_int); /* @@ -118,7 +118,7 @@ in6_pcbselsrc(const struct in6_addr **in6src, struct sockaddr_in6 *dstsock, struct sockaddr_in6 sa6; /* get the outgoing interface */ - error = in6_selectif(dstsock, opts, mopts, ro, &ifp, rtableid); + error = in6_selectif(dst, opts, mopts, ro, &ifp, rtableid); if (error) return (error); @@ -179,22 +179,8 @@ in6_pcbselsrc(const struct in6_addr **in6src, struct sockaddr_in6 *dstsock, * If route is known or can be allocated now, * our src addr is taken from the i/f, else punt. */ - if (!rtisvalid(ro->ro_rt) || (ro->ro_tableid != rtableid) || - !IN6_ARE_ADDR_EQUAL(&ro->ro_dst.sin6_addr, dst)) { - rtfree(ro->ro_rt); - ro->ro_rt = NULL; - } + route6_cache(ro, dst, rtableid); if (ro->ro_rt == NULL) { - struct sockaddr_in6 *sa6; - - /* No route yet, so try to acquire one */ - bzero(&ro->ro_dst, sizeof(struct sockaddr_in6)); - ro->ro_tableid = rtableid; - sa6 = &ro->ro_dst; - sa6->sin6_family = AF_INET6; - sa6->sin6_len = sizeof(struct sockaddr_in6); - sa6->sin6_addr = *dst; - sa6->sin6_scope_id = dstsock->sin6_scope_id; ro->ro_rt = rtalloc(sin6tosa(&ro->ro_dst), RT_RESOLVE, ro->ro_tableid); } @@ -312,35 +298,17 @@ in6_selectsrc(const struct in6_addr **in6src, struct sockaddr_in6 *dstsock, } struct rtentry * -in6_selectroute(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts, +in6_selectroute(const struct in6_addr *dst, struct ip6_pktopts *opts, struct route_in6 *ro, unsigned int rtableid) { - struct in6_addr *dst; - - dst = &dstsock->sin6_addr; - /* * Use a cached route if it exists and is valid, else try to allocate * a new one. */ if (ro) { - if (rtisvalid(ro->ro_rt)) - KASSERT(sin6tosa(&ro->ro_dst)->sa_family == AF_INET6); - if (!rtisvalid(ro->ro_rt) || - !IN6_ARE_ADDR_EQUAL(&ro->ro_dst.sin6_addr, dst)) { - rtfree(ro->ro_rt); - ro->ro_rt = NULL; - } + route6_cache(ro, dst, rtableid); if (ro->ro_rt == NULL) { - struct sockaddr_in6 *sa6; - /* No route yet, so try to acquire one */ - bzero(&ro->ro_dst, sizeof(struct sockaddr_in6)); - ro->ro_tableid = rtableid; - sa6 = &ro->ro_dst; - *sa6 = *dstsock; - sa6->sin6_scope_id = 0; - ro->ro_tableid = rtableid; ro->ro_rt = rtalloc_mpath(sin6tosa(&ro->ro_dst), NULL, ro->ro_tableid); } @@ -369,7 +337,7 @@ in6_selectroute(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts, } int -in6_selectif(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts, +in6_selectif(const struct in6_addr *dst, struct ip6_pktopts *opts, struct ip6_moptions *mopts, struct route_in6 *ro, struct ifnet **retifp, u_int rtableid) { @@ -387,11 +355,11 @@ in6_selectif(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts, * If the destination address is a multicast address and the outgoing * interface for the address is specified by the caller, use it. */ - if (IN6_IS_ADDR_MULTICAST(&dstsock->sin6_addr) && + if (IN6_IS_ADDR_MULTICAST(dst) && mopts != NULL && (*retifp = if_get(mopts->im6o_ifidx)) != NULL) return (0); - rt = in6_selectroute(dstsock, opts, ro, rtableid); + rt = in6_selectroute(dst, opts, ro, rtableid); if (rt == NULL) return (EHOSTUNREACH); diff --git a/sys/netinet6/ip6_forward.c b/sys/netinet6/ip6_forward.c index 7de1e0ec7..54b7615f5 100644 --- a/sys/netinet6/ip6_forward.c +++ b/sys/netinet6/ip6_forward.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_forward.c,v 1.112 2023/07/07 08:05:02 bluhm Exp $ */ +/* $OpenBSD: ip6_forward.c,v 1.113 2024/02/07 23:40:40 bluhm Exp $ */ /* $KAME: ip6_forward.c,v 1.75 2001/06/29 12:42:13 jinmei Exp $ */ /* @@ -85,7 +85,7 @@ void ip6_forward(struct mbuf *m, struct rtentry *rt, int srcrt) { struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *); - struct sockaddr_in6 *sin6; + struct sockaddr *dst; struct route_in6 ro; struct ifnet *ifp = NULL; int error = 0, type = 0, code = 0, destmtu = 0; @@ -165,15 +165,12 @@ reroute: } #endif /* IPSEC */ - memset(&ro, 0, sizeof(ro)); - sin6 = &ro.ro_dst; - sin6->sin6_family = AF_INET6; - sin6->sin6_len = sizeof(*sin6); - sin6->sin6_addr = ip6->ip6_dst; - + ro.ro_rt = NULL; + route6_cache(&ro, &ip6->ip6_dst, m->m_pkthdr.ph_rtableid); + dst = sin6tosa(&ro.ro_dst); if (!rtisvalid(rt)) { rtfree(rt); - rt = rtalloc_mpath(sin6tosa(sin6), &ip6->ip6_src.s6_addr32[0], + rt = rtalloc_mpath(dst, &ip6->ip6_src.s6_addr32[0], m->m_pkthdr.ph_rtableid); if (rt == NULL) { ip6stat_inc(ip6s_noroute); @@ -185,6 +182,7 @@ reroute: goto out; } } + ro.ro_rt = rt; /* * Scope check: if a packet can't be delivered to its destination @@ -226,8 +224,6 @@ reroute: */ if (tdb != NULL) { /* Callee frees mbuf */ - ro.ro_rt = rt; - ro.ro_tableid = m->m_pkthdr.ph_rtableid; error = ip6_output_ipsec_send(tdb, m, &ro, 0, 1); rt = ro.ro_rt; if (error) @@ -237,7 +233,7 @@ reroute: #endif /* IPSEC */ if (rt->rt_flags & RTF_GATEWAY) - sin6 = satosin6(rt->rt_gateway); + dst = rt->rt_gateway; /* * If we are to forward the packet using the same interface @@ -319,7 +315,7 @@ reroute: } #endif - error = if_output_tso(ifp, &m, sin6tosa(sin6), rt, ifp->if_mtu); + error = if_output_tso(ifp, &m, dst, rt, ifp->if_mtu); if (error) ip6stat_inc(ip6s_cantforward); else if (m == NULL) diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index f3da1972a..3efd26129 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_output.c,v 1.284 2024/01/31 12:27:57 bluhm Exp $ */ +/* $OpenBSD: ip6_output.c,v 1.285 2024/02/07 23:40:40 bluhm Exp $ */ /* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */ /* @@ -169,7 +169,7 @@ ip6_output(struct mbuf *m, struct ip6_pktopts *opt, struct route_in6 *ro, int hlen, tlen; struct route_in6 ip6route; struct rtentry *rt = NULL; - struct sockaddr_in6 *dst, dstsock; + struct sockaddr_in6 *dst; int error = 0; u_long mtu; int dontfrag; @@ -442,13 +442,7 @@ reroute: } #endif /* IPSEC */ - bzero(&dstsock, sizeof(dstsock)); - dstsock.sin6_family = AF_INET6; - dstsock.sin6_addr = ip6->ip6_dst; - dstsock.sin6_len = sizeof(dstsock); - ro->ro_tableid = m->m_pkthdr.ph_rtableid; - - if (IN6_IS_ADDR_MULTICAST(&dstsock.sin6_addr)) { + if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) { struct in6_pktinfo *pi = NULL; /* @@ -463,7 +457,8 @@ reroute: } if (ifp == NULL) { - rt = in6_selectroute(&dstsock, opt, ro, ro->ro_tableid); + rt = in6_selectroute(&ip6->ip6_dst, opt, ro, + m->m_pkthdr.ph_rtableid); if (rt == NULL) { ip6stat_inc(ip6s_noroute); error = EHOSTUNREACH; @@ -485,7 +480,7 @@ reroute: goto bad; } } else { - *dst = dstsock; + route6_cache(ro, &ip6->ip6_dst, m->m_pkthdr.ph_rtableid); } if (rt && (rt->rt_flags & RTF_GATEWAY) && diff --git a/sys/netinet6/ip6_var.h b/sys/netinet6/ip6_var.h index 06d6ce757..f23287b6f 100644 --- a/sys/netinet6/ip6_var.h +++ b/sys/netinet6/ip6_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_var.h,v 1.111 2024/02/05 23:16:39 bluhm Exp $ */ +/* $OpenBSD: ip6_var.h,v 1.112 2024/02/07 23:40:40 bluhm Exp $ */ /* $KAME: ip6_var.h,v 1.33 2000/06/11 14:59:20 jinmei Exp $ */ /* @@ -369,7 +369,7 @@ int in6_pcbselsrc(const struct in6_addr **, struct sockaddr_in6 *, struct inpcb *, struct ip6_pktopts *); int in6_selectsrc(const struct in6_addr **, struct sockaddr_in6 *, struct ip6_moptions *, unsigned int); -struct rtentry *in6_selectroute(struct sockaddr_in6 *, struct ip6_pktopts *, +struct rtentry *in6_selectroute(const struct in6_addr *, struct ip6_pktopts *, struct route_in6 *, unsigned int rtableid); u_int32_t ip6_randomflowlabel(void); diff --git a/usr.sbin/ntpd/ntp.c b/usr.sbin/ntpd/ntp.c index 6037c82ec..a0984e943 100644 --- a/usr.sbin/ntpd/ntp.c +++ b/usr.sbin/ntpd/ntp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntp.c,v 1.172 2023/12/20 15:36:36 otto Exp $ */ +/* $OpenBSD: ntp.c,v 1.173 2024/02/08 00:15:53 jsg Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -534,7 +534,7 @@ inpool(struct sockaddr_storage *a, return 1; } else if (memcmp(&((struct sockaddr_in6 *)a)->sin6_addr, &((struct sockaddr_in6 *)&old[i])->sin6_addr, - sizeof(struct sockaddr_in6)) == 0) { + sizeof(struct in6_addr)) == 0) { return 1; } }