diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-08-09 14:02:09 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-09-21 10:29:38 +0200 |
commit | bb80d9df8bac71eedee1a6787ca63aef972a7e48 (patch) | |
tree | 1b5cb9443c5ead5706c35afb618abbbd1592315e /freebsd/sys | |
parent | Update to FreeBSD head 2017-10-01 (diff) | |
download | rtems-libbsd-bb80d9df8bac71eedee1a6787ca63aef972a7e48.tar.bz2 |
Update to FreeBSD head 2017-12-01
Git mirror commit e724f51f811a4b2bd29447f8b85ab5c2f9b88266.
Update #3472.
Diffstat (limited to 'freebsd/sys')
849 files changed, 3980 insertions, 1610 deletions
diff --git a/freebsd/sys/arm/at91/at91_mci.c b/freebsd/sys/arm/at91/at91_mci.c index 206f782d..6f5ace83 100644 --- a/freebsd/sys/arm/at91/at91_mci.c +++ b/freebsd/sys/arm/at91/at91_mci.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2006 Bernd Walter. All rights reserved. * Copyright (c) 2006 M. Warner Losh. All rights reserved. * Copyright (c) 2010 Greg Ansley. All rights reserved. diff --git a/freebsd/sys/arm/at91/at91_mcireg.h b/freebsd/sys/arm/at91/at91_mcireg.h index b79582bd..eec67857 100644 --- a/freebsd/sys/arm/at91/at91_mcireg.h +++ b/freebsd/sys/arm/at91/at91_mcireg.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2006 Berndt Walter. All rights reserved. * Copyright (c) 2006 M. Warner Losh. All rights reserved. * diff --git a/freebsd/sys/arm/at91/at91_pdcreg.h b/freebsd/sys/arm/at91/at91_pdcreg.h index d15c22a7..88389e00 100644 --- a/freebsd/sys/arm/at91/at91_pdcreg.h +++ b/freebsd/sys/arm/at91/at91_pdcreg.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2006 M. Warner Losh. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/arm/at91/at91reg.h b/freebsd/sys/arm/at91/at91reg.h index 8dbf4d0b..f5791bd7 100644 --- a/freebsd/sys/arm/at91/at91reg.h +++ b/freebsd/sys/arm/at91/at91reg.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2009 Greg Ansley All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/arm/at91/at91var.h b/freebsd/sys/arm/at91/at91var.h index 46227a0d..84c898fb 100644 --- a/freebsd/sys/arm/at91/at91var.h +++ b/freebsd/sys/arm/at91/at91var.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2005 Olivier Houchard. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/arm/include/machine/cpufunc.h b/freebsd/sys/arm/include/machine/cpufunc.h index 18c57f7f..e3ada92b 100644 --- a/freebsd/sys/arm/include/machine/cpufunc.h +++ b/freebsd/sys/arm/include/machine/cpufunc.h @@ -1,6 +1,8 @@ /* $NetBSD: cpufunc.h,v 1.29 2003/09/06 09:08:35 rearnsha Exp $ */ /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 1997 Mark Brinicombe. * Copyright (c) 1997 Causality Limited * All rights reserved. diff --git a/freebsd/sys/arm/include/machine/in_cksum.h b/freebsd/sys/arm/include/machine/in_cksum.h index 72edfba9..d55b838b 100644 --- a/freebsd/sys/arm/include/machine/in_cksum.h +++ b/freebsd/sys/arm/include/machine/in_cksum.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * diff --git a/freebsd/sys/arm/lpc/if_lpe.c b/freebsd/sys/arm/lpc/if_lpe.c index d9c1e381..99016be3 100755 --- a/freebsd/sys/arm/lpc/if_lpe.c +++ b/freebsd/sys/arm/lpc/if_lpe.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2011 Jakub Wojciech Klama <jceel@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/arm/lpc/if_lpereg.h b/freebsd/sys/arm/lpc/if_lpereg.h index 8e1512be..a40bf8b5 100644 --- a/freebsd/sys/arm/lpc/if_lpereg.h +++ b/freebsd/sys/arm/lpc/if_lpereg.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2011 Jakub Wojciech Klama <jceel@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/arm/lpc/lpc_pwr.c b/freebsd/sys/arm/lpc/lpc_pwr.c index 70ffe902..dd1064c8 100755 --- a/freebsd/sys/arm/lpc/lpc_pwr.c +++ b/freebsd/sys/arm/lpc/lpc_pwr.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2011 Jakub Wojciech Klama <jceel@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/arm/lpc/lpcreg.h b/freebsd/sys/arm/lpc/lpcreg.h index b63dfbc5..d094e8f9 100644 --- a/freebsd/sys/arm/lpc/lpcreg.h +++ b/freebsd/sys/arm/lpc/lpcreg.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2011 Jakub Wojciech Klama <jceel@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/arm/lpc/lpcvar.h b/freebsd/sys/arm/lpc/lpcvar.h index ed05320c..dafbef08 100644 --- a/freebsd/sys/arm/lpc/lpcvar.h +++ b/freebsd/sys/arm/lpc/lpcvar.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2011 Jakub Wojciech Klama <jceel@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/arm/ti/am335x/am335x_prcm.c b/freebsd/sys/arm/ti/am335x/am335x_prcm.c index bc61c9f8..83faafbd 100644 --- a/freebsd/sys/arm/ti/am335x/am335x_prcm.c +++ b/freebsd/sys/arm/ti/am335x/am335x_prcm.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2012 Damjan Marion <dmarion@Freebsd.org> * All rights reserved. * diff --git a/freebsd/sys/arm/ti/am335x/am335x_scm.h b/freebsd/sys/arm/ti/am335x/am335x_scm.h index 6116be06..ff7af52f 100644 --- a/freebsd/sys/arm/ti/am335x/am335x_scm.h +++ b/freebsd/sys/arm/ti/am335x/am335x_scm.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2012 Oleksandr Tymoshenko <gonzo@freebsd.org> * All rights reserved. * diff --git a/freebsd/sys/arm/ti/am335x/am335x_usbss.c b/freebsd/sys/arm/ti/am335x/am335x_usbss.c index 8369171d..322bb43a 100644 --- a/freebsd/sys/arm/ti/am335x/am335x_usbss.c +++ b/freebsd/sys/arm/ti/am335x/am335x_usbss.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2013 Oleksandr Tymoshenko <gonzo@freebsd.org> * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/arm/ti/ti_cpuid.h b/freebsd/sys/arm/ti/ti_cpuid.h index 7a3fcd5e..b76e65e8 100644 --- a/freebsd/sys/arm/ti/ti_cpuid.h +++ b/freebsd/sys/arm/ti/ti_cpuid.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2011 * Ben Gray <ben.r.gray@gmail.com>. * All rights reserved. diff --git a/freebsd/sys/arm/ti/ti_prcm.c b/freebsd/sys/arm/ti/ti_prcm.c index b4dd03fb..0eac4dfd 100644 --- a/freebsd/sys/arm/ti/ti_prcm.c +++ b/freebsd/sys/arm/ti/ti_prcm.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> -/* +/*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 2010 * Ben Gray <ben.r.gray@gmail.com>. * All rights reserved. diff --git a/freebsd/sys/arm/ti/ti_prcm.h b/freebsd/sys/arm/ti/ti_prcm.h index 61b69607..6df39436 100644 --- a/freebsd/sys/arm/ti/ti_prcm.h +++ b/freebsd/sys/arm/ti/ti_prcm.h @@ -1,4 +1,6 @@ -/* +/*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 2010 * Ben Gray <ben.r.gray@gmail.com>. * All rights reserved. diff --git a/freebsd/sys/arm/ti/ti_scm.c b/freebsd/sys/arm/ti/ti_scm.c index 96b284c9..28eaf42a 100644 --- a/freebsd/sys/arm/ti/ti_scm.c +++ b/freebsd/sys/arm/ti/ti_scm.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> -/* +/*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 2010 * Ben Gray <ben.r.gray@gmail.com>. * All rights reserved. diff --git a/freebsd/sys/arm/ti/ti_scm.h b/freebsd/sys/arm/ti/ti_scm.h index 1342ddc6..f1df004e 100644 --- a/freebsd/sys/arm/ti/ti_scm.h +++ b/freebsd/sys/arm/ti/ti_scm.h @@ -1,4 +1,6 @@ -/* +/*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 2010 * Ben Gray <ben.r.gray@gmail.com>. * All rights reserved. diff --git a/freebsd/sys/arm/ti/ti_sdhci.c b/freebsd/sys/arm/ti/ti_sdhci.c index 58d178a0..c5d29cb6 100644 --- a/freebsd/sys/arm/ti/ti_sdhci.c +++ b/freebsd/sys/arm/ti/ti_sdhci.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2013 Ian Lepore <ian@freebsd.org> * Copyright (c) 2011 Ben Gray <ben.r.gray@gmail.com>. * All rights reserved. diff --git a/freebsd/sys/arm/ti/tivar.h b/freebsd/sys/arm/ti/tivar.h index 248ad901..ecc0a448 100644 --- a/freebsd/sys/arm/ti/tivar.h +++ b/freebsd/sys/arm/ti/tivar.h @@ -1,4 +1,6 @@ -/* +/*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 2010 * Ben Gray <ben.r.gray@gmail.com>. * All rights reserved. diff --git a/freebsd/sys/arm/xilinx/zy7_slcr.c b/freebsd/sys/arm/xilinx/zy7_slcr.c index 57b9ff72..79fccee5 100644 --- a/freebsd/sys/arm/xilinx/zy7_slcr.c +++ b/freebsd/sys/arm/xilinx/zy7_slcr.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2013 Thomas Skibo * All rights reserved. * diff --git a/freebsd/sys/arm/xilinx/zy7_slcr.h b/freebsd/sys/arm/xilinx/zy7_slcr.h index 3afec02a..d1e1641f 100644 --- a/freebsd/sys/arm/xilinx/zy7_slcr.h +++ b/freebsd/sys/arm/xilinx/zy7_slcr.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2013 Thomas Skibo * All rights reserved. * diff --git a/freebsd/sys/avr/include/machine/in_cksum.h b/freebsd/sys/avr/include/machine/in_cksum.h index 72edfba9..d55b838b 100644 --- a/freebsd/sys/avr/include/machine/in_cksum.h +++ b/freebsd/sys/avr/include/machine/in_cksum.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * diff --git a/freebsd/sys/bfin/include/machine/in_cksum.h b/freebsd/sys/bfin/include/machine/in_cksum.h index 72edfba9..d55b838b 100644 --- a/freebsd/sys/bfin/include/machine/in_cksum.h +++ b/freebsd/sys/bfin/include/machine/in_cksum.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * diff --git a/freebsd/sys/bsm/audit.h b/freebsd/sys/bsm/audit.h index 57edb5e4..adbaa46a 100644 --- a/freebsd/sys/bsm/audit.h +++ b/freebsd/sys/bsm/audit.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2005-2009 Apple Inc. * Copyright (c) 2016 Robert N. M. Watson * All rights reserved. diff --git a/freebsd/sys/bsm/audit_kevents.h b/freebsd/sys/bsm/audit_kevents.h index fb80c124..277e721d 100644 --- a/freebsd/sys/bsm/audit_kevents.h +++ b/freebsd/sys/bsm/audit_kevents.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2005-2009 Apple Inc. * All rights reserved. * diff --git a/freebsd/sys/cam/ata/ata_all.h b/freebsd/sys/cam/ata/ata_all.h index a279aa91..087d6820 100644 --- a/freebsd/sys/cam/ata/ata_all.h +++ b/freebsd/sys/cam/ata/ata_all.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2009 Alexander Motin <mav@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/cam/cam.c b/freebsd/sys/cam/cam.c index b6bc10d3..5d07bebf 100644 --- a/freebsd/sys/cam/cam.c +++ b/freebsd/sys/cam/cam.c @@ -3,6 +3,8 @@ /*- * Generic utility routines for the Common Access Method layer. * + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1997 Justin T. Gibbs. * All rights reserved. * @@ -237,29 +239,35 @@ cam_strmatch(const u_int8_t *str, const u_int8_t *pattern, int str_len) return (1); } else if (*pattern == '[') { int negate_range, ok; - uint8_t pc, sc; + uint8_t pc = UCHAR_MAX; + uint8_t sc; ok = 0; sc = *str++; str_len--; + pattern++; if ((negate_range = (*pattern == '^')) != 0) pattern++; - while (((pc = *pattern) != ']') && *pattern != '\0') { - pattern++; + while ((*pattern != ']') && *pattern != '\0') { if (*pattern == '-') { if (pattern[1] == '\0') /* Bad pattern */ return (1); if (sc >= pc && sc <= pattern[1]) ok = 1; - pattern += 2; - } else if (pc == sc) + pattern++; + } else if (*pattern == sc) ok = 1; + pc = *pattern; + pattern++; } if (ok == negate_range) return (1); + pattern++; } else if (*pattern == '?') { - /* NB: || *str == ' ' of the old code is a bug and was removed */ - /* if you add it back, keep this the last if before the naked else */ + /* + * NB: || *str == ' ' of the old code is a bug and was + * removed. If you add it back, keep this the last if + * before the naked else */ pattern++; str++; str_len--; @@ -271,6 +279,17 @@ cam_strmatch(const u_int8_t *str, const u_int8_t *pattern, int str_len) str_len--; } } + + /* '*' is allowed to match nothing, so gobble it */ + while (*pattern == '*') + pattern++; + + if ( *pattern != '\0') { + /* Pattern not fully consumed. Not a match */ + return (1); + } + + /* Eat trailing spaces, which get added by SAT */ while (str_len > 0 && *str == ' ') { str++; str_len--; diff --git a/freebsd/sys/cam/cam.h b/freebsd/sys/cam/cam.h index 4bd569be..4f9cddf3 100644 --- a/freebsd/sys/cam/cam.h +++ b/freebsd/sys/cam/cam.h @@ -1,6 +1,8 @@ /*- * Data structures and definitions for the CAM system. * + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1997 Justin T. Gibbs. * All rights reserved. * diff --git a/freebsd/sys/cam/cam_ccb.h b/freebsd/sys/cam/cam_ccb.h index 97560848..8e88b4a3 100644 --- a/freebsd/sys/cam/cam_ccb.h +++ b/freebsd/sys/cam/cam_ccb.h @@ -1,6 +1,8 @@ /*- * Data structures and definitions for CAM Control Blocks (CCBs). * + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1997, 1998 Justin T. Gibbs. * All rights reserved. * @@ -1039,11 +1041,14 @@ struct ccb_trans_settings_nvme u_int valid; /* Which fields to honor */ #define CTS_NVME_VALID_SPEC 0x01 #define CTS_NVME_VALID_CAPS 0x02 - u_int spec_major; /* Major version of spec supported */ - u_int spec_minor; /* Minor verison of spec supported */ - u_int spec_tiny; /* Tiny version of spec supported */ - u_int max_xfer; /* Max transfer size (0 -> unlimited */ - u_int caps; +#define CTS_NVME_VALID_LINK 0x04 + uint32_t spec; /* NVMe spec implemented -- same as vs register */ + uint32_t max_xfer; /* Max transfer size (0 -> unlimited */ + uint32_t caps; + uint8_t lanes; /* Number of PCIe lanes */ + uint8_t speed; /* PCIe generation for each lane */ + uint8_t max_lanes; /* Number of PCIe lanes */ + uint8_t max_speed; /* PCIe generation for each lane */ }; #include <cam/mmc/mmc_bus.h> diff --git a/freebsd/sys/cam/cam_debug.h b/freebsd/sys/cam/cam_debug.h index 7b619a29..b88c6b20 100644 --- a/freebsd/sys/cam/cam_debug.h +++ b/freebsd/sys/cam/cam_debug.h @@ -1,6 +1,8 @@ /*- * Macros for tracing/loging information in the CAM layer * + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1997 Justin T. Gibbs. * All rights reserved. * diff --git a/freebsd/sys/cam/cam_periph.h b/freebsd/sys/cam/cam_periph.h index 87f153c3..b7f0618e 100644 --- a/freebsd/sys/cam/cam_periph.h +++ b/freebsd/sys/cam/cam_periph.h @@ -1,6 +1,8 @@ /*- * Data structures and definitions for CAM peripheral ("type") drivers. * + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1997, 1998 Justin T. Gibbs. * All rights reserved. * diff --git a/freebsd/sys/cam/cam_sim.h b/freebsd/sys/cam/cam_sim.h index 4c4c8c58..95dedb08 100644 --- a/freebsd/sys/cam/cam_sim.h +++ b/freebsd/sys/cam/cam_sim.h @@ -1,6 +1,8 @@ /*- * Data structures and definitions for SCSI Interface Modules (SIMs). * + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1997 Justin T. Gibbs. * All rights reserved. * diff --git a/freebsd/sys/cam/cam_xpt.h b/freebsd/sys/cam/cam_xpt.h index 47fdbd74..8baec294 100644 --- a/freebsd/sys/cam/cam_xpt.h +++ b/freebsd/sys/cam/cam_xpt.h @@ -2,6 +2,8 @@ * Data structures and definitions for dealing with the * Common Access Method Transport (xpt) layer. * + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1997 Justin T. Gibbs. * All rights reserved. * diff --git a/freebsd/sys/cam/cam_xpt_sim.h b/freebsd/sys/cam/cam_xpt_sim.h index c3575deb..87b57217 100644 --- a/freebsd/sys/cam/cam_xpt_sim.h +++ b/freebsd/sys/cam/cam_xpt_sim.h @@ -2,6 +2,8 @@ * Data structures and definitions for dealing with the * Common Access Method Transport (xpt) layer. * + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1997 Justin T. Gibbs. * All rights reserved. * diff --git a/freebsd/sys/cam/nvme/nvme_all.h b/freebsd/sys/cam/nvme/nvme_all.h index b52b7a78..b2db4833 100644 --- a/freebsd/sys/cam/nvme/nvme_all.h +++ b/freebsd/sys/cam/nvme/nvme_all.h @@ -33,15 +33,14 @@ struct ccb_nvmeio; -#define NVME_REV_1 1 /* Supports NVMe 1.2 or earlier */ - void nvme_ns_cmd(struct ccb_nvmeio *nvmeio, uint8_t cmd, uint32_t nsid, uint32_t cdw10, uint32_t cdw11, uint32_t cdw12, uint32_t cdw13, uint32_t cdw14, uint32_t cdw15); int nvme_identify_match(caddr_t identbuffer, caddr_t table_entry); -void nvme_print_ident(const struct nvme_controller_data *, const struct nvme_namespace_data *); +struct sbuf; +void nvme_print_ident(const struct nvme_controller_data *, const struct nvme_namespace_data *, struct sbuf *); const char *nvme_op_string(const struct nvme_command *); const char *nvme_cmd_string(const struct nvme_command *, char *, size_t); const void *nvme_get_identify_cntrl(struct cam_periph *); diff --git a/freebsd/sys/cam/scsi/scsi_all.c b/freebsd/sys/cam/scsi/scsi_all.c index c13f5516..d344cc14 100644 --- a/freebsd/sys/cam/scsi/scsi_all.c +++ b/freebsd/sys/cam/scsi/scsi_all.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Implementation of Utility functions for all SCSI device types. * * Copyright (c) 1997, 1998, 1999 Justin T. Gibbs. diff --git a/freebsd/sys/crypto/sha1.c b/freebsd/sys/crypto/sha1.c index c21677ec..51eb8016 100644 --- a/freebsd/sys/crypto/sha1.c +++ b/freebsd/sys/crypto/sha1.c @@ -1,7 +1,9 @@ #include <machine/rtems-bsd-kernel-space.h> /* $KAME: sha1.c,v 1.5 2000/11/08 06:13:08 itojun Exp $ */ -/* +/*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/crypto/sha1.h b/freebsd/sys/crypto/sha1.h index c1bc1a3a..95c07682 100644 --- a/freebsd/sys/crypto/sha1.h +++ b/freebsd/sys/crypto/sha1.h @@ -1,7 +1,9 @@ /* $FreeBSD$ */ /* $KAME: sha1.h,v 1.5 2000/03/27 04:36:23 sumikawa Exp $ */ -/* +/*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/dev/bce/if_bce.c b/freebsd/sys/dev/bce/if_bce.c index 5901c472..a2e4c804 100644 --- a/freebsd/sys/dev/bce/if_bce.c +++ b/freebsd/sys/dev/bce/if_bce.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause + * * Copyright (c) 2006-2014 QLogic Corporation * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/bce/if_bcefw.h b/freebsd/sys/dev/bce/if_bcefw.h index cae01fea..4ba86701 100644 --- a/freebsd/sys/dev/bce/if_bcefw.h +++ b/freebsd/sys/dev/bce/if_bcefw.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause + * * Copyright (c) 2006-2014 QLogic Corporation * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/bce/if_bcereg.h b/freebsd/sys/dev/bce/if_bcereg.h index 2f166ead..d9bd23cc 100644 --- a/freebsd/sys/dev/bce/if_bcereg.h +++ b/freebsd/sys/dev/bce/if_bcereg.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2006-2014 QLogic Corporation * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/bfe/if_bfe.c b/freebsd/sys/dev/bfe/if_bfe.c index c0bd4b26..63825a99 100644 --- a/freebsd/sys/dev/bfe/if_bfe.c +++ b/freebsd/sys/dev/bfe/if_bfe.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2003 Stuart Walsh<stu@ipng.org.uk> * and Duncan Barclay<dmlb@dmlb.org> * diff --git a/freebsd/sys/dev/bfe/if_bfereg.h b/freebsd/sys/dev/bfe/if_bfereg.h index b50627ed..668d2604 100644 --- a/freebsd/sys/dev/bfe/if_bfereg.h +++ b/freebsd/sys/dev/bfe/if_bfereg.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2003 Stuart Walsh * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/bge/if_bge.c b/freebsd/sys/dev/bge/if_bge.c index fad66e1e..956ee52f 100644 --- a/freebsd/sys/dev/bge/if_bge.c +++ b/freebsd/sys/dev/bge/if_bge.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 2001 Wind River Systems * Copyright (c) 1997, 1998, 1999, 2001 * Bill Paul <wpaul@windriver.com>. All rights reserved. diff --git a/freebsd/sys/dev/bge/if_bgereg.h b/freebsd/sys/dev/bge/if_bgereg.h index 0cf9ca18..eb7686e7 100644 --- a/freebsd/sys/dev/bge/if_bgereg.h +++ b/freebsd/sys/dev/bge/if_bgereg.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 2001 Wind River Systems * Copyright (c) 1997, 1998, 1999, 2001 * Bill Paul <wpaul@windriver.com>. All rights reserved. diff --git a/freebsd/sys/dev/cadence/if_cgem.c b/freebsd/sys/dev/cadence/if_cgem.c index 4f4114cf..42fd4213 100644 --- a/freebsd/sys/dev/cadence/if_cgem.c +++ b/freebsd/sys/dev/cadence/if_cgem.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2012-2014 Thomas Skibo <thomasskibo@yahoo.com> * All rights reserved. * diff --git a/freebsd/sys/dev/cadence/if_cgem_hw.h b/freebsd/sys/dev/cadence/if_cgem_hw.h index 30fb6dd3..1569857d 100644 --- a/freebsd/sys/dev/cadence/if_cgem_hw.h +++ b/freebsd/sys/dev/cadence/if_cgem_hw.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2012-2013 Thomas Skibo * All rights reserved. * diff --git a/freebsd/sys/dev/dc/dcphy.c b/freebsd/sys/dev/dc/dcphy.c index 35ab0353..de8fec09 100644 --- a/freebsd/sys/dev/dc/dcphy.c +++ b/freebsd/sys/dev/dc/dcphy.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 1997, 1998, 1999 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved. * diff --git a/freebsd/sys/dev/dc/if_dc.c b/freebsd/sys/dev/dc/if_dc.c index a0efd5ba..3339b83d 100644 --- a/freebsd/sys/dev/dc/if_dc.c +++ b/freebsd/sys/dev/dc/if_dc.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 1997, 1998, 1999 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved. * diff --git a/freebsd/sys/dev/dc/if_dcreg.h b/freebsd/sys/dev/dc/if_dcreg.h index e290881f..9ae26cc6 100644 --- a/freebsd/sys/dev/dc/if_dcreg.h +++ b/freebsd/sys/dev/dc/if_dcreg.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 1997, 1998, 1999 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved. * diff --git a/freebsd/sys/dev/dc/pnphy.c b/freebsd/sys/dev/dc/pnphy.c index 9848b461..c6f191fa 100644 --- a/freebsd/sys/dev/dc/pnphy.c +++ b/freebsd/sys/dev/dc/pnphy.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /* + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 1997, 1998, 1999 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved. * diff --git a/freebsd/sys/dev/e1000/e1000_80003es2lan.c b/freebsd/sys/dev/e1000/e1000_80003es2lan.c index bd666441..50175d2a 100644 --- a/freebsd/sys/dev/e1000/e1000_80003es2lan.c +++ b/freebsd/sys/dev/e1000/e1000_80003es2lan.c @@ -1,6 +1,7 @@ #include <machine/rtems-bsd-kernel-space.h> /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_80003es2lan.h b/freebsd/sys/dev/e1000/e1000_80003es2lan.h index 89b15512..cbf0eafa 100644 --- a/freebsd/sys/dev/e1000/e1000_80003es2lan.h +++ b/freebsd/sys/dev/e1000/e1000_80003es2lan.h @@ -1,4 +1,5 @@ /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_82540.c b/freebsd/sys/dev/e1000/e1000_82540.c index e6311762..1243bdab 100644 --- a/freebsd/sys/dev/e1000/e1000_82540.c +++ b/freebsd/sys/dev/e1000/e1000_82540.c @@ -1,6 +1,7 @@ #include <machine/rtems-bsd-kernel-space.h> /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_82541.c b/freebsd/sys/dev/e1000/e1000_82541.c index 770b3b7b..b6830b98 100644 --- a/freebsd/sys/dev/e1000/e1000_82541.c +++ b/freebsd/sys/dev/e1000/e1000_82541.c @@ -1,6 +1,7 @@ #include <machine/rtems-bsd-kernel-space.h> /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_82541.h b/freebsd/sys/dev/e1000/e1000_82541.h index 7a01fd43..ce29548a 100644 --- a/freebsd/sys/dev/e1000/e1000_82541.h +++ b/freebsd/sys/dev/e1000/e1000_82541.h @@ -1,4 +1,5 @@ /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_82542.c b/freebsd/sys/dev/e1000/e1000_82542.c index a21fec73..7bbcaead 100644 --- a/freebsd/sys/dev/e1000/e1000_82542.c +++ b/freebsd/sys/dev/e1000/e1000_82542.c @@ -1,6 +1,7 @@ #include <machine/rtems-bsd-kernel-space.h> /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_82543.c b/freebsd/sys/dev/e1000/e1000_82543.c index 4930fc95..dbaa4a6e 100644 --- a/freebsd/sys/dev/e1000/e1000_82543.c +++ b/freebsd/sys/dev/e1000/e1000_82543.c @@ -1,6 +1,7 @@ #include <machine/rtems-bsd-kernel-space.h> /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_82543.h b/freebsd/sys/dev/e1000/e1000_82543.h index e8edda5d..98289524 100644 --- a/freebsd/sys/dev/e1000/e1000_82543.h +++ b/freebsd/sys/dev/e1000/e1000_82543.h @@ -1,4 +1,5 @@ /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_82571.c b/freebsd/sys/dev/e1000/e1000_82571.c index 2b72489a..fdef7284 100644 --- a/freebsd/sys/dev/e1000/e1000_82571.c +++ b/freebsd/sys/dev/e1000/e1000_82571.c @@ -1,6 +1,7 @@ #include <machine/rtems-bsd-kernel-space.h> /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_82571.h b/freebsd/sys/dev/e1000/e1000_82571.h index 8e5ca56a..a39f63c5 100644 --- a/freebsd/sys/dev/e1000/e1000_82571.h +++ b/freebsd/sys/dev/e1000/e1000_82571.h @@ -1,4 +1,5 @@ /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_82575.c b/freebsd/sys/dev/e1000/e1000_82575.c index ebf8371c..9958d98c 100644 --- a/freebsd/sys/dev/e1000/e1000_82575.c +++ b/freebsd/sys/dev/e1000/e1000_82575.c @@ -1,6 +1,7 @@ #include <machine/rtems-bsd-kernel-space.h> /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_82575.h b/freebsd/sys/dev/e1000/e1000_82575.h index f8179560..7e127ed7 100644 --- a/freebsd/sys/dev/e1000/e1000_82575.h +++ b/freebsd/sys/dev/e1000/e1000_82575.h @@ -1,4 +1,5 @@ /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_api.c b/freebsd/sys/dev/e1000/e1000_api.c index 829e7be0..393a22e2 100644 --- a/freebsd/sys/dev/e1000/e1000_api.c +++ b/freebsd/sys/dev/e1000/e1000_api.c @@ -1,6 +1,7 @@ #include <machine/rtems-bsd-kernel-space.h> /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_api.h b/freebsd/sys/dev/e1000/e1000_api.h index 074197bf..bf5f637c 100644 --- a/freebsd/sys/dev/e1000/e1000_api.h +++ b/freebsd/sys/dev/e1000/e1000_api.h @@ -1,4 +1,5 @@ /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_defines.h b/freebsd/sys/dev/e1000/e1000_defines.h index 4c2b0903..db7659e8 100644 --- a/freebsd/sys/dev/e1000/e1000_defines.h +++ b/freebsd/sys/dev/e1000/e1000_defines.h @@ -1,4 +1,5 @@ /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_hw.h b/freebsd/sys/dev/e1000/e1000_hw.h index e1464a7b..82e783fe 100644 --- a/freebsd/sys/dev/e1000/e1000_hw.h +++ b/freebsd/sys/dev/e1000/e1000_hw.h @@ -1,4 +1,5 @@ /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_i210.c b/freebsd/sys/dev/e1000/e1000_i210.c index 8f427b9a..5f09e4d2 100644 --- a/freebsd/sys/dev/e1000/e1000_i210.c +++ b/freebsd/sys/dev/e1000/e1000_i210.c @@ -1,6 +1,7 @@ #include <machine/rtems-bsd-kernel-space.h> /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_i210.h b/freebsd/sys/dev/e1000/e1000_i210.h index f940915b..c08a0dd7 100644 --- a/freebsd/sys/dev/e1000/e1000_i210.h +++ b/freebsd/sys/dev/e1000/e1000_i210.h @@ -1,4 +1,5 @@ /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_ich8lan.c b/freebsd/sys/dev/e1000/e1000_ich8lan.c index a620d126..b78b7283 100644 --- a/freebsd/sys/dev/e1000/e1000_ich8lan.c +++ b/freebsd/sys/dev/e1000/e1000_ich8lan.c @@ -1,6 +1,7 @@ #include <machine/rtems-bsd-kernel-space.h> /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_ich8lan.h b/freebsd/sys/dev/e1000/e1000_ich8lan.h index 6d812911..d61f4df8 100644 --- a/freebsd/sys/dev/e1000/e1000_ich8lan.h +++ b/freebsd/sys/dev/e1000/e1000_ich8lan.h @@ -1,4 +1,5 @@ /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_mac.c b/freebsd/sys/dev/e1000/e1000_mac.c index 2af37399..581659be 100644 --- a/freebsd/sys/dev/e1000/e1000_mac.c +++ b/freebsd/sys/dev/e1000/e1000_mac.c @@ -1,6 +1,7 @@ #include <machine/rtems-bsd-kernel-space.h> /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_mac.h b/freebsd/sys/dev/e1000/e1000_mac.h index ef9789bb..cb8da246 100644 --- a/freebsd/sys/dev/e1000/e1000_mac.h +++ b/freebsd/sys/dev/e1000/e1000_mac.h @@ -1,4 +1,5 @@ /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_manage.c b/freebsd/sys/dev/e1000/e1000_manage.c index 82456912..9f9ab336 100644 --- a/freebsd/sys/dev/e1000/e1000_manage.c +++ b/freebsd/sys/dev/e1000/e1000_manage.c @@ -1,6 +1,7 @@ #include <machine/rtems-bsd-kernel-space.h> /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_manage.h b/freebsd/sys/dev/e1000/e1000_manage.h index 303e99e3..2ef2e3a4 100644 --- a/freebsd/sys/dev/e1000/e1000_manage.h +++ b/freebsd/sys/dev/e1000/e1000_manage.h @@ -1,4 +1,5 @@ /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_mbx.c b/freebsd/sys/dev/e1000/e1000_mbx.c index 0c6bb2c2..dc1482da 100644 --- a/freebsd/sys/dev/e1000/e1000_mbx.c +++ b/freebsd/sys/dev/e1000/e1000_mbx.c @@ -1,6 +1,7 @@ #include <machine/rtems-bsd-kernel-space.h> /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_mbx.h b/freebsd/sys/dev/e1000/e1000_mbx.h index fadd8494..f0b21992 100644 --- a/freebsd/sys/dev/e1000/e1000_mbx.h +++ b/freebsd/sys/dev/e1000/e1000_mbx.h @@ -1,4 +1,5 @@ /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_nvm.c b/freebsd/sys/dev/e1000/e1000_nvm.c index a1e881ad..98cc0c98 100644 --- a/freebsd/sys/dev/e1000/e1000_nvm.c +++ b/freebsd/sys/dev/e1000/e1000_nvm.c @@ -1,6 +1,7 @@ #include <machine/rtems-bsd-kernel-space.h> /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_nvm.h b/freebsd/sys/dev/e1000/e1000_nvm.h index 64a4083e..4f40f9ae 100644 --- a/freebsd/sys/dev/e1000/e1000_nvm.h +++ b/freebsd/sys/dev/e1000/e1000_nvm.h @@ -1,4 +1,5 @@ /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_osdep.c b/freebsd/sys/dev/e1000/e1000_osdep.c index 45aae330..2e8dca62 100644 --- a/freebsd/sys/dev/e1000/e1000_osdep.c +++ b/freebsd/sys/dev/e1000/e1000_osdep.c @@ -1,6 +1,7 @@ #include <machine/rtems-bsd-kernel-space.h> /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_osdep.h b/freebsd/sys/dev/e1000/e1000_osdep.h index c7c23e58..d9f956f3 100644 --- a/freebsd/sys/dev/e1000/e1000_osdep.h +++ b/freebsd/sys/dev/e1000/e1000_osdep.h @@ -1,4 +1,5 @@ /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_phy.c b/freebsd/sys/dev/e1000/e1000_phy.c index 87753e19..c656a6f1 100644 --- a/freebsd/sys/dev/e1000/e1000_phy.c +++ b/freebsd/sys/dev/e1000/e1000_phy.c @@ -1,6 +1,7 @@ #include <machine/rtems-bsd-kernel-space.h> /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_phy.h b/freebsd/sys/dev/e1000/e1000_phy.h index d3d563f7..6d0687fc 100644 --- a/freebsd/sys/dev/e1000/e1000_phy.h +++ b/freebsd/sys/dev/e1000/e1000_phy.h @@ -1,4 +1,5 @@ /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_regs.h b/freebsd/sys/dev/e1000/e1000_regs.h index 37d70172..d9949817 100644 --- a/freebsd/sys/dev/e1000/e1000_regs.h +++ b/freebsd/sys/dev/e1000/e1000_regs.h @@ -1,4 +1,5 @@ /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_vf.c b/freebsd/sys/dev/e1000/e1000_vf.c index 0e46641e..26f266e6 100644 --- a/freebsd/sys/dev/e1000/e1000_vf.c +++ b/freebsd/sys/dev/e1000/e1000_vf.c @@ -1,6 +1,7 @@ #include <machine/rtems-bsd-kernel-space.h> /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/e1000_vf.h b/freebsd/sys/dev/e1000/e1000_vf.h index e6f834e7..9c76b632 100644 --- a/freebsd/sys/dev/e1000/e1000_vf.h +++ b/freebsd/sys/dev/e1000/e1000_vf.h @@ -1,4 +1,5 @@ /****************************************************************************** + SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2001-2015, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/e1000/if_em.c b/freebsd/sys/dev/e1000/if_em.c index dba6ef0a..07acaad9 100644 --- a/freebsd/sys/dev/e1000/if_em.c +++ b/freebsd/sys/dev/e1000/if_em.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause + * * Copyright (c) 2016 Matt Macy <mmacy@nextbsd.org> * All rights reserved. * @@ -1956,7 +1958,9 @@ em_if_msix_intr_assign(if_ctx_t ctx, int msix) rid = vector + 1; snprintf(buf, sizeof(buf), "txq%d", i); tx_que = &adapter->tx_queues[i]; - iflib_softirq_alloc_generic(ctx, rid, IFLIB_INTR_TX, tx_que, tx_que->me, buf); + iflib_softirq_alloc_generic(ctx, + &adapter->rx_queues[i % adapter->rx_num_queues].que_irq, + IFLIB_INTR_TX, tx_que, tx_que->me, buf); tx_que->msix = (vector % adapter->tx_num_queues); diff --git a/freebsd/sys/dev/e1000/if_em.h b/freebsd/sys/dev/e1000/if_em.h index b7599291..4f9d34b8 100644 --- a/freebsd/sys/dev/e1000/if_em.h +++ b/freebsd/sys/dev/e1000/if_em.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause + * * Copyright (c) 2016 Matt Macy <mmacy@nextbsd.org> * All rights reserved. * diff --git a/freebsd/sys/dev/evdev/evdev.c b/freebsd/sys/dev/evdev/evdev.c index b3c786a5..6c2976d7 100644 --- a/freebsd/sys/dev/evdev/evdev.c +++ b/freebsd/sys/dev/evdev/evdev.c @@ -52,6 +52,9 @@ #ifdef FEATURE FEATURE(evdev, "Input event devices support"); +#ifdef EVDEV_SUPPORT +FEATURE(evdev_support, "Evdev support in hybrid drivers"); +#endif #endif enum evdev_sparse_result @@ -70,12 +73,14 @@ int evdev_rcpt_mask = EVDEV_RCPT_HW_MOUSE | EVDEV_RCPT_HW_KBD; #endif /* __rtems__ */ int evdev_sysmouse_t_axis = 0; +#ifdef EVDEV_SUPPORT SYSCTL_NODE(_kern, OID_AUTO, evdev, CTLFLAG_RW, 0, "Evdev args"); SYSCTL_INT(_kern_evdev, OID_AUTO, rcpt_mask, CTLFLAG_RW, &evdev_rcpt_mask, 0, "Who is receiving events: bit0 - sysmouse, bit1 - kbdmux, " "bit2 - mouse hardware, bit3 - keyboard hardware"); SYSCTL_INT(_kern_evdev, OID_AUTO, sysmouse_t_axis, CTLFLAG_RW, &evdev_sysmouse_t_axis, 0, "Extract T-axis from 0-none, 1-ums, 2-psm"); +#endif static void evdev_start_repeat(struct evdev_dev *, uint16_t); static void evdev_stop_repeat(struct evdev_dev *); @@ -583,7 +588,8 @@ evdev_modify_event(struct evdev_dev *evdev, uint16_t type, uint16_t code, *value = KEY_EVENT_REPEAT; } else { /* Start/stop callout for evdev repeats */ - if (bit_test(evdev->ev_key_states, code) == !*value) { + if (bit_test(evdev->ev_key_states, code) == !*value && + !LIST_EMPTY(&evdev->ev_clients)) { if (*value == KEY_EVENT_DOWN) evdev_start_repeat(evdev, code); else @@ -638,8 +644,6 @@ evdev_sparse_event(struct evdev_dev *evdev, uint16_t type, uint16_t code, break; case EV_SND: - if (bit_test(evdev->ev_snd_states, code) == value) - return (EV_SKIP_EVENT); bit_change(evdev->ev_snd_states, code, value); break; @@ -817,7 +821,11 @@ evdev_inject_event(struct evdev_dev *evdev, uint16_t type, uint16_t code, case EV_ABS: case EV_SW: push: + if (evdev->ev_lock_type != EV_LOCK_INTERNAL) + EVDEV_LOCK(evdev); ret = evdev_push_event(evdev, type, code, value); + if (evdev->ev_lock_type != EV_LOCK_INTERNAL) + EVDEV_UNLOCK(evdev); break; default: diff --git a/freebsd/sys/dev/evdev/evdev.h b/freebsd/sys/dev/evdev/evdev.h index 946913c4..31f0c2c3 100644 --- a/freebsd/sys/dev/evdev/evdev.h +++ b/freebsd/sys/dev/evdev/evdev.h @@ -197,7 +197,7 @@ static __inline int evdev_push_snd(struct evdev_dev *evdev, uint16_t code, int32_t value) { - return (evdev_push_event(evdev, EV_SND, code, value != 0)); + return (evdev_push_event(evdev, EV_SND, code, value)); } static __inline int diff --git a/freebsd/sys/dev/evdev/evdev_utils.c b/freebsd/sys/dev/evdev/evdev_utils.c index caf81a46..9814ffeb 100644 --- a/freebsd/sys/dev/evdev/evdev_utils.c +++ b/freebsd/sys/dev/evdev/evdev_utils.c @@ -34,7 +34,9 @@ #include <sys/conf.h> #include <sys/kbio.h> #include <sys/kernel.h> +#include <sys/lock.h> #include <sys/malloc.h> +#include <sys/mutex.h> #include <sys/systm.h> #include <dev/evdev/evdev.h> @@ -64,7 +66,7 @@ static uint16_t evdev_usb_scancodes[256] = { KEY_PAUSE, KEY_INSERT, KEY_HOME, KEY_PAGEUP, KEY_DELETE, KEY_END, KEY_PAGEDOWN, KEY_RIGHT, KEY_LEFT, KEY_DOWN, KEY_UP, KEY_NUMLOCK, - KEY_SLASH, KEY_KPASTERISK, KEY_KPMINUS, KEY_KPPLUS, + KEY_KPSLASH, KEY_KPASTERISK, KEY_KPMINUS, KEY_KPPLUS, KEY_KPENTER, KEY_KP1, KEY_KP2, KEY_KP3, KEY_KP4, KEY_KP5, KEY_KP6, KEY_KP7, /* 0x60 - 0x7f */ @@ -131,7 +133,7 @@ static uint16_t evdev_at_set1_scancodes[] = { KEY_APOSTROPHE, KEY_GRAVE, KEY_LEFTSHIFT, KEY_BACKSLASH, KEY_Z, KEY_X, KEY_C, KEY_V, KEY_B, KEY_N, KEY_M, KEY_COMMA, - KEY_DOT, KEY_SLASH, KEY_RIGHTSHIFT, NONE, + KEY_DOT, KEY_SLASH, KEY_RIGHTSHIFT, KEY_KPASTERISK, KEY_LEFTALT, KEY_SPACE, KEY_CAPSLOCK, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, /* 0x40 - 0x5f */ @@ -140,7 +142,7 @@ static uint16_t evdev_at_set1_scancodes[] = { KEY_KP8, KEY_KP9, KEY_KPMINUS, KEY_KP4, KEY_KP5, KEY_KP6, KEY_KPPLUS, KEY_KP1, KEY_KP2, KEY_KP3, KEY_KP0, KEY_KPDOT, - NONE, NONE, NONE, KEY_F11, + NONE, NONE, KEY_102ND, KEY_F11, KEY_F12, NONE, NONE, NONE, NONE, NONE, NONE, NONE, /* 0x60 - 0x7f */ @@ -167,7 +169,7 @@ static uint16_t evdev_at_set1_scancodes[] = { NONE, NONE, NONE, NONE, NONE, NONE, KEY_VOLUMEDOWN, NONE, KEY_VOLUMEUP, NONE, KEY_HOMEPAGE, NONE, - NONE, KEY_KPASTERISK, NONE, KEY_SYSRQ, + NONE, KEY_KPSLASH, NONE, KEY_SYSRQ, KEY_RIGHTALT, NONE, NONE, NONE, NONE, NONE, NONE, NONE, /* 0x40 - 0x5f. 0xE0 prefixed */ @@ -316,19 +318,26 @@ evdev_ev_kbd_event(struct evdev_dev *evdev, void *softc, uint16_t type, leds |= 1 << i; else leds &= ~(1 << i); - if (leds != oleds) + if (leds != oleds) { + mtx_lock(&Giant); kbdd_ioctl(kbd, KDSETLED, (caddr_t)&leds); + mtx_unlock(&Giant); + } break; } } } else if (type == EV_REP && code == REP_DELAY) { delay[0] = value; delay[1] = kbd->kb_delay2; + mtx_lock(&Giant); kbdd_ioctl(kbd, KDSETREPEAT, (caddr_t)delay); + mtx_unlock(&Giant); } else if (type == EV_REP && code == REP_PERIOD) { delay[0] = kbd->kb_delay1; delay[1] = value; + mtx_lock(&Giant); kbdd_ioctl(kbd, KDSETREPEAT, (caddr_t)delay); + mtx_unlock(&Giant); } } diff --git a/freebsd/sys/dev/fdt/fdt_common.c b/freebsd/sys/dev/fdt/fdt_common.c index c8c777f1..26f73bc3 100644 --- a/freebsd/sys/dev/fdt/fdt_common.c +++ b/freebsd/sys/dev/fdt/fdt_common.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2009-2014 The FreeBSD Foundation * All rights reserved. * diff --git a/freebsd/sys/dev/fdt/fdt_common.h b/freebsd/sys/dev/fdt/fdt_common.h index 904d3e18..91522df5 100644 --- a/freebsd/sys/dev/fdt/fdt_common.h +++ b/freebsd/sys/dev/fdt/fdt_common.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2009-2010 The FreeBSD Foundation * All rights reserved. * diff --git a/freebsd/sys/dev/fdt/simplebus.c b/freebsd/sys/dev/fdt/simplebus.c index 9c85f751..54b17074 100644 --- a/freebsd/sys/dev/fdt/simplebus.c +++ b/freebsd/sys/dev/fdt/simplebus.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2013 Nathan Whitehorn * All rights reserved. * diff --git a/freebsd/sys/dev/ffec/if_ffec.c b/freebsd/sys/dev/ffec/if_ffec.c index 22b2cdfc..1d842286 100644 --- a/freebsd/sys/dev/ffec/if_ffec.c +++ b/freebsd/sys/dev/ffec/if_ffec.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2013 Ian Lepore <ian@freebsd.org> * Copyright (C) 2007-2008 Semihalf, Rafal Jaworowski * Copyright (C) 2006-2007 Semihalf, Piotr Kruszynski @@ -103,18 +105,21 @@ enum { FECTYPE_NONE, FECTYPE_GENERIC, FECTYPE_IMX53, - FECTYPE_IMX6, + FECTYPE_IMX6, /* imx6 and imx7 */ FECTYPE_MVF, }; /* * Flags that describe general differences between the FEC hardware in various - * SoCs. These are ORed into the FECTYPE enum values. + * SoCs. These are ORed into the FECTYPE enum values in the ofw_compat_data, so + * the low 8 bits are reserved for the type enum. In the softc, the type and + * flags are put into separate members, so that you don't need to mask the flags + * out of the type to compare it. */ -#define FECTYPE_MASK 0x0000ffff -#define FECFLAG_GBE (1 << 16) -#define FECFLAG_AVB (1 << 17) -#define FECFLAG_RACC (1 << 18) +#define FECTYPE_MASK 0x000000ff +#define FECFLAG_GBE (1 << 8) +#define FECFLAG_AVB (1 << 9) +#define FECFLAG_RACC (1 << 10) /* * Table of supported FDT compat strings and their associated FECTYPE values. @@ -122,12 +127,12 @@ enum { static struct ofw_compat_data compat_data[] = { {"fsl,imx51-fec", FECTYPE_GENERIC}, {"fsl,imx53-fec", FECTYPE_IMX53}, - {"fsl,imx6q-fec", FECTYPE_IMX6 | FECFLAG_GBE | FECFLAG_RACC}, - {"fsl,imx6ul-fec", FECTYPE_IMX6}, - {"fsl,mvf600-fec", FECTYPE_MVF | FECFLAG_RACC}, + {"fsl,imx6q-fec", FECTYPE_IMX6 | FECFLAG_RACC | FECFLAG_GBE }, + {"fsl,imx6ul-fec", FECTYPE_IMX6 | FECFLAG_RACC }, + {"fsl,imx7d-fec", FECTYPE_IMX6 | FECFLAG_RACC | FECFLAG_GBE | + FECFLAG_AVB }, + {"fsl,mvf600-fec", FECTYPE_MVF | FECFLAG_RACC }, {"fsl,mvf-fec", FECTYPE_MVF}, - {"fsl,imx7d-fec", FECTYPE_IMX6 | FECFLAG_GBE | FECFLAG_AVB | - FECFLAG_RACC}, {NULL, FECTYPE_NONE}, }; @@ -161,12 +166,12 @@ struct ffec_softc { int if_flags; struct mtx mtx; struct resource *irq_res[MAX_IRQ_COUNT]; - int irq_count; struct resource *mem_res; void * intr_cookie[MAX_IRQ_COUNT]; struct callout ffec_callout; mii_contype_t phy_conn_type; - uintptr_t fectype; + uint32_t fecflags; + uint8_t fectype; boolean_t link_is_up; boolean_t is_attached; boolean_t is_detaching; @@ -198,6 +203,13 @@ struct ffec_softc { int tx_ic_count; }; +static struct resource_spec irq_res_spec[MAX_IRQ_COUNT + 1] = { + { SYS_RES_IRQ, 0, RF_ACTIVE }, + { SYS_RES_IRQ, 1, RF_ACTIVE | RF_OPTIONAL }, + { SYS_RES_IRQ, 2, RF_ACTIVE | RF_OPTIONAL }, + RESOURCE_SPEC_END +}; + #define FFEC_LOCK(sc) mtx_lock(&(sc)->mtx) #define FFEC_UNLOCK(sc) mtx_unlock(&(sc)->mtx) #define FFEC_LOCK_INIT(sc) mtx_init(&(sc)->mtx, \ @@ -302,7 +314,7 @@ ffec_miigasket_setup(struct ffec_softc *sc) * We only need the gasket for MII and RMII connections on certain SoCs. */ - switch (sc->fectype & FECTYPE_MASK) + switch (sc->fectype) { case FECTYPE_IMX53: break; @@ -842,10 +854,10 @@ ffec_setup_rxbuf(struct ffec_softc *sc, int idx, struct mbuf * m) int error, nsegs; struct bus_dma_segment seg; - if ((sc->fectype & FECFLAG_RACC) == 0) { + if (!(sc->fecflags & FECFLAG_RACC)) { /* - * The RACC[SHIFT16] feature is not used. So, we need to leave - * at least ETHER_ALIGN bytes free at the beginning of the + * The RACC[SHIFT16] feature is not available. So, we need to + * leave at least ETHER_ALIGN bytes free at the beginning of the * buffer to allow the data to be re-aligned after receiving it * (by copying it backwards ETHER_ALIGN bytes in the same * buffer). We also have to ensure that the beginning of the @@ -905,23 +917,6 @@ ffec_rxfinish_onebuf(struct ffec_softc *sc, int len, uint32_t flags2) return; } - /* - * Unfortunately, the protocol headers need to be aligned on a 32-bit - * boundary for the upper layers. The hardware requires receive - * buffers to be 16-byte aligned. The ethernet header is 14 bytes, - * leaving the protocol header unaligned. We used m_adj() after - * allocating the buffer to leave empty space at the start of the - * buffer, now we'll use the alignment agnostic bcopy() routine to - * shuffle all the data backwards 2 bytes and adjust m_data. - * - * XXX imx6 hardware is able to do this 2-byte alignment by setting the - * SHIFT16 bit in the RACC register. Older hardware doesn't have that - * feature, but for them could we speed this up by copying just the - * protocol headers into their own small mbuf then chaining the cluster - * to it? That way we'd only need to copy like 64 bytes or whatever - * the biggest header is, instead of the whole 1530ish-byte frame. - */ - FFEC_UNLOCK(sc); bmap = &sc->rxbuf_map[sc->rx_idx]; @@ -940,8 +935,17 @@ ffec_rxfinish_onebuf(struct ffec_softc *sc, int len, uint32_t flags2) m->m_pkthdr.csum_data = 0xffff; } - if (sc->fectype & FECFLAG_RACC) { - /* We use the RACC[SHIFT16] feature */ + /* + * Align the protocol headers in the receive buffer on a 32-bit + * boundary. Newer hardware does the alignment for us. On hardware + * that doesn't support this feature, we have to copy-align the data. + * + * XXX for older hardware, could we speed this up by copying just the + * protocol headers into their own small mbuf then chaining the cluster + * to it? That way we'd only need to copy like 64 bytes or whatever the + * biggest header is, instead of the whole 1530ish-byte frame. + */ + if (sc->fecflags & FECFLAG_RACC) { m->m_data = mtod(m, uint8_t *) + 2; } else { uint8_t *dst, *src; @@ -1325,7 +1329,7 @@ ffec_init_locked(struct ffec_softc *sc) ffec_clear_stats(sc); WR4(sc, FEC_MIBC_REG, regval & ~FEC_MIBC_DIS); - if (sc->fectype & FECFLAG_RACC) { + if (sc->fecflags & FECFLAG_RACC) { /* * RACC - Receive Accelerator Function Configuration. */ @@ -1540,18 +1544,16 @@ ffec_detach(device_t dev) bus_dmamap_destroy(sc->txdesc_tag, sc->txdesc_map); } if (sc->txdesc_tag != NULL) - bus_dma_tag_destroy(sc->txdesc_tag); + bus_dma_tag_destroy(sc->txdesc_tag); /* Release bus resources. */ - for (irq = 0; irq < sc->irq_count; ++irq) { - if (sc->intr_cookie[irq]) + for (irq = 0; irq < MAX_IRQ_COUNT; ++irq) { + if (sc->intr_cookie[irq] != NULL) { bus_teardown_intr(dev, sc->irq_res[irq], sc->intr_cookie[irq]); - - if (sc->irq_res[irq] != NULL) - bus_release_resource(dev, SYS_RES_IRQ, 0, - sc->irq_res[irq]); + } } + bus_release_resources(dev, irq_res_spec, sc->irq_res); if (sc->mem_res != NULL) bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res); @@ -1712,10 +1714,11 @@ ffec_attach(device_t dev) struct ifnet *ifp = NULL; struct mbuf *m; void *dummy; + uintptr_t typeflags; phandle_t ofw_node; + uint32_t idx, mscr; int error, phynum, rid, irq; uint8_t eaddr[ETHER_ADDR_LEN]; - uint32_t idx, mscr; sc = device_get_softc(dev); sc->dev = dev; @@ -1726,7 +1729,17 @@ ffec_attach(device_t dev) * There are differences in the implementation and features of the FEC * hardware on different SoCs, so figure out what type we are. */ - sc->fectype = ofw_bus_search_compatible(dev, compat_data)->ocd_data; + typeflags = ofw_bus_search_compatible(dev, compat_data)->ocd_data; + sc->fectype = (uint8_t)(typeflags & FECTYPE_MASK); + sc->fecflags = (uint32_t)(typeflags & ~FECTYPE_MASK); + + if (sc->fecflags & FECFLAG_AVB) { + sc->rxbuf_align = 64; + sc->txbuf_align = 1; + } else { + sc->rxbuf_align = 16; + sc->txbuf_align = 16; + } if (sc->fectype & FECFLAG_AVB) { sc->rxbuf_align = 64; @@ -1768,17 +1781,10 @@ ffec_attach(device_t dev) error = ENOMEM; goto out; } - for (irq = 0; irq < MAX_IRQ_COUNT; ++irq) { - rid = irq; - sc->irq_res[irq] = bus_alloc_resource_any(dev, SYS_RES_IRQ, - &rid, RF_ACTIVE); - if (sc->irq_res[irq] == NULL) - break; - } - sc->irq_count = irq; - if (irq == 0) { - device_printf(dev, "could not allocate interrupt resources.\n"); - error = ENOMEM; + + error = bus_alloc_resources(dev, irq_res_spec, sc->irq_res); + if (error != 0) { + device_printf(dev, "could not allocate interrupt resources\n"); goto out; } @@ -1924,25 +1930,33 @@ ffec_attach(device_t dev) /* Try to get the MAC address from the hardware before resetting it. */ ffec_get_hwaddr(sc, eaddr); - /* Reset the hardware. Disables all interrupts. */ - if (sc->fectype & FECFLAG_AVB) - /* - * Avoid AXI bus issues due to a MAC reset, see Linux for more - * details. - */ + /* + * Reset the hardware. Disables all interrupts. + * + * When the FEC is connected to the AXI bus (indicated by AVB flag), a + * MAC reset while a bus transaction is pending can hang the bus. + * Instead of resetting, turn off the ENABLE bit, which allows the + * hardware to complete any in-progress transfers (appending a bad CRC + * to any partial packet) and release the AXI bus. This could probably + * be done unconditionally for all hardware variants, but that hasn't + * been tested. + */ + if (sc->fecflags & FECFLAG_AVB) WR4(sc, FEC_ECR_REG, 0); else WR4(sc, FEC_ECR_REG, FEC_ECR_RESET); /* Setup interrupt handler. */ - for (irq = 0; irq < sc->irq_count; ++irq) { - error = bus_setup_intr(dev, sc->irq_res[irq], - INTR_TYPE_NET | INTR_MPSAFE, NULL, ffec_intr, sc, - &sc->intr_cookie[irq]); - if (error != 0) { - device_printf(dev, - "could not setup interrupt handler.\n"); - goto out; + for (irq = 0; irq < MAX_IRQ_COUNT; ++irq) { + if (sc->irq_res[irq] != NULL) { + error = bus_setup_intr(dev, sc->irq_res[irq], + INTR_TYPE_NET | INTR_MPSAFE, NULL, ffec_intr, sc, + &sc->intr_cookie[irq]); + if (error != 0) { + device_printf(dev, + "could not setup interrupt handler.\n"); + goto out; + } } } @@ -2019,7 +2033,7 @@ ffec_attach(device_t dev) } error = mii_attach(dev, &sc->miibus, ifp, ffec_media_change, ffec_media_status, BMSR_DEFCAPMASK, phynum, MII_OFFSET_ANY, - (sc->fectype & FECTYPE_MVF) ? MIIF_FORCEANEG : 0); + (sc->fecflags & FECTYPE_MVF) ? MIIF_FORCEANEG : 0); if (error != 0) { device_printf(dev, "PHY attach failed\n"); goto out; diff --git a/freebsd/sys/dev/ffec/if_ffecreg.h b/freebsd/sys/dev/ffec/if_ffecreg.h index 9ec5b375..e2e7e816 100644 --- a/freebsd/sys/dev/ffec/if_ffecreg.h +++ b/freebsd/sys/dev/ffec/if_ffecreg.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2013 Ian Lepore <ian@freebsd.org> * All rights reserved. * diff --git a/freebsd/sys/dev/fxp/if_fxp.c b/freebsd/sys/dev/fxp/if_fxp.c index 20bdc988..ca933aa8 100644 --- a/freebsd/sys/dev/fxp/if_fxp.c +++ b/freebsd/sys/dev/fxp/if_fxp.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Copyright (c) 1995, David Greenman * Copyright (c) 2001 Jonathan Lemon <jlemon@freebsd.org> * All rights reserved. diff --git a/freebsd/sys/dev/fxp/if_fxpreg.h b/freebsd/sys/dev/fxp/if_fxpreg.h index 7ee85884..d1e6a45a 100644 --- a/freebsd/sys/dev/fxp/if_fxpreg.h +++ b/freebsd/sys/dev/fxp/if_fxpreg.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Copyright (c) 1995, David Greenman * Copyright (c) 2001 Jonathan Lemon <jlemon@freebsd.org> * All rights reserved. diff --git a/freebsd/sys/dev/fxp/if_fxpvar.h b/freebsd/sys/dev/fxp/if_fxpvar.h index 78200ce3..476a1a2c 100644 --- a/freebsd/sys/dev/fxp/if_fxpvar.h +++ b/freebsd/sys/dev/fxp/if_fxpvar.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1995, David Greenman * All rights reserved. * diff --git a/freebsd/sys/dev/fxp/rcvbundl.h b/freebsd/sys/dev/fxp/rcvbundl.h index dac793df..e49889f0 100644 --- a/freebsd/sys/dev/fxp/rcvbundl.h +++ b/freebsd/sys/dev/fxp/rcvbundl.h @@ -1,4 +1,6 @@ /*- +SPDX-License-Identifier: BSD-3-Clause + Copyright (c) 1999-2001, Intel Corporation All rights reserved. diff --git a/freebsd/sys/dev/gpio/gpiobus.c b/freebsd/sys/dev/gpio/gpiobus.c index bbe8fc6c..2b1899e6 100644 --- a/freebsd/sys/dev/gpio/gpiobus.c +++ b/freebsd/sys/dev/gpio/gpiobus.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2009 Oleksandr Tymoshenko <gonzo@freebsd.org> * All rights reserved. * diff --git a/freebsd/sys/dev/gpio/gpiobusvar.h b/freebsd/sys/dev/gpio/gpiobusvar.h index 9eee5a03..fbcfbb4e 100644 --- a/freebsd/sys/dev/gpio/gpiobusvar.h +++ b/freebsd/sys/dev/gpio/gpiobusvar.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2009 Oleksandr Tymoshenko <gonzo@freebsd.org> * All rights reserved. * diff --git a/freebsd/sys/dev/gpio/ofw_gpiobus.c b/freebsd/sys/dev/gpio/ofw_gpiobus.c index e76059f9..70495a2a 100644 --- a/freebsd/sys/dev/gpio/ofw_gpiobus.c +++ b/freebsd/sys/dev/gpio/ofw_gpiobus.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2009, Nathan Whitehorn <nwhitehorn@FreeBSD.org> * Copyright (c) 2013, Luiz Otavio O Souza <loos@FreeBSD.org> * Copyright (c) 2013 The FreeBSD Foundation diff --git a/freebsd/sys/dev/kbd/kbd.c b/freebsd/sys/dev/kbd/kbd.c index 3187e8bf..c7512e89 100644 --- a/freebsd/sys/dev/kbd/kbd.c +++ b/freebsd/sys/dev/kbd/kbd.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp> * All rights reserved. * diff --git a/freebsd/sys/dev/kbd/kbdreg.h b/freebsd/sys/dev/kbd/kbdreg.h index ff4a694b..5caafdda 100644 --- a/freebsd/sys/dev/kbd/kbdreg.h +++ b/freebsd/sys/dev/kbd/kbdreg.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp> * All rights reserved. * diff --git a/freebsd/sys/dev/kbd/kbdtables.h b/freebsd/sys/dev/kbd/kbdtables.h index 5ff744c0..c1c6defc 100644 --- a/freebsd/sys/dev/kbd/kbdtables.h +++ b/freebsd/sys/dev/kbd/kbdtables.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1992-1998 Sen Schmidt * All rights reserved. * diff --git a/freebsd/sys/dev/led/led.c b/freebsd/sys/dev/led/led.c index cb811ce9..70de95bb 100644 --- a/freebsd/sys/dev/led/led.c +++ b/freebsd/sys/dev/led/led.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: Beerware + * * ---------------------------------------------------------------------------- * "THE BEER-WARE LICENSE" (Revision 42): * <phk@FreeBSD.org> wrote this file. As long as you retain this notice you diff --git a/freebsd/sys/dev/mii/brgphy.c b/freebsd/sys/dev/mii/brgphy.c index d476960f..0566f616 100644 --- a/freebsd/sys/dev/mii/brgphy.c +++ b/freebsd/sys/dev/mii/brgphy.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 2000 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved. * diff --git a/freebsd/sys/dev/mii/brgphyreg.h b/freebsd/sys/dev/mii/brgphyreg.h index b3535d59..5cceb392 100644 --- a/freebsd/sys/dev/mii/brgphyreg.h +++ b/freebsd/sys/dev/mii/brgphyreg.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 2000 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved. * diff --git a/freebsd/sys/dev/mii/e1000phy.c b/freebsd/sys/dev/mii/e1000phy.c index ee62b6c6..ae5a3922 100644 --- a/freebsd/sys/dev/mii/e1000phy.c +++ b/freebsd/sys/dev/mii/e1000phy.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Principal Author: Parag Patel * Copyright (c) 2001 * All rights reserved. diff --git a/freebsd/sys/dev/mii/e1000phyreg.h b/freebsd/sys/dev/mii/e1000phyreg.h index e5d5cf96..04c396e5 100644 --- a/freebsd/sys/dev/mii/e1000phyreg.h +++ b/freebsd/sys/dev/mii/e1000phyreg.h @@ -31,6 +31,8 @@ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Derived by information released by Intel under the following license: * * Copyright (c) 1999 - 2001, Intel Corporation diff --git a/freebsd/sys/dev/mii/icsphy.c b/freebsd/sys/dev/mii/icsphy.c index e313afe1..bde90714 100755 --- a/freebsd/sys/dev/mii/icsphy.c +++ b/freebsd/sys/dev/mii/icsphy.c @@ -3,6 +3,8 @@ /* $NetBSD: icsphy.c,v 1.41 2006/11/16 21:24:07 christos Exp $ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc. * All rights reserved. * diff --git a/freebsd/sys/dev/mii/icsphyreg.h b/freebsd/sys/dev/mii/icsphyreg.h index d92d0b51..80ebbded 100644 --- a/freebsd/sys/dev/mii/icsphyreg.h +++ b/freebsd/sys/dev/mii/icsphyreg.h @@ -1,6 +1,8 @@ /* $NetBSD: icsphyreg.h,v 1.2 2003/07/01 22:46:08 msaitoh Exp $ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Copyright (c) 1998 The NetBSD Foundation, Inc. * All rights reserved. * diff --git a/freebsd/sys/dev/mii/mii.c b/freebsd/sys/dev/mii/mii.c index b7464bb6..2ed40543 100644 --- a/freebsd/sys/dev/mii/mii.c +++ b/freebsd/sys/dev/mii/mii.c @@ -3,6 +3,8 @@ /* $NetBSD: mii.c,v 1.12 1999/08/03 19:41:49 drochner Exp $ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Copyright (c) 1998 The NetBSD Foundation, Inc. * All rights reserved. * diff --git a/freebsd/sys/dev/mii/mii.h b/freebsd/sys/dev/mii/mii.h index fa1ec84e..11b2d117 100644 --- a/freebsd/sys/dev/mii/mii.h +++ b/freebsd/sys/dev/mii/mii.h @@ -1,6 +1,8 @@ /* $NetBSD: mii.h,v 1.18 2014/06/16 14:43:22 msaitoh Exp $ */ /*- + * SPDX-License-Identifier: BSD-2-Clause + * * Copyright (c) 1997 Manuel Bouyer. All rights reserved. * * Modification to match BSD/OS 3.0 MII interface by Jason R. Thorpe, diff --git a/freebsd/sys/dev/mii/mii_bitbang.c b/freebsd/sys/dev/mii/mii_bitbang.c index 784aa4d8..0fd3bb47 100644 --- a/freebsd/sys/dev/mii/mii_bitbang.c +++ b/freebsd/sys/dev/mii/mii_bitbang.c @@ -3,6 +3,8 @@ /* $NetBSD: mii_bitbang.c,v 1.12 2008/05/04 17:06:09 xtraeme Exp $ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Copyright (c) 1999 The NetBSD Foundation, Inc. * All rights reserved. * diff --git a/freebsd/sys/dev/mii/mii_bitbang.h b/freebsd/sys/dev/mii/mii_bitbang.h index 2bc74276..14e2c90f 100644 --- a/freebsd/sys/dev/mii/mii_bitbang.h +++ b/freebsd/sys/dev/mii/mii_bitbang.h @@ -1,6 +1,8 @@ /* $NetBSD: mii_bitbang.h,v 1.6 2009/05/12 14:31:27 cegger Exp $ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Copyright (c) 1999 The NetBSD Foundation, Inc. * All rights reserved. * diff --git a/freebsd/sys/dev/mii/mii_physubr.c b/freebsd/sys/dev/mii/mii_physubr.c index 864f9968..9ba68190 100644 --- a/freebsd/sys/dev/mii/mii_physubr.c +++ b/freebsd/sys/dev/mii/mii_physubr.c @@ -3,6 +3,8 @@ /* $NetBSD: mii_physubr.c,v 1.5 1999/08/03 19:41:49 drochner Exp $ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc. * All rights reserved. * diff --git a/freebsd/sys/dev/mii/miivar.h b/freebsd/sys/dev/mii/miivar.h index ef81bdb2..9def25c4 100644 --- a/freebsd/sys/dev/mii/miivar.h +++ b/freebsd/sys/dev/mii/miivar.h @@ -1,6 +1,8 @@ /* $NetBSD: miivar.h,v 1.8 1999/04/23 04:24:32 thorpej Exp $ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc. * All rights reserved. * diff --git a/freebsd/sys/dev/mii/rgephy.c b/freebsd/sys/dev/mii/rgephy.c index de8a2975..8a045a7d 100644 --- a/freebsd/sys/dev/mii/rgephy.c +++ b/freebsd/sys/dev/mii/rgephy.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 2003 * Bill Paul <wpaul@windriver.com>. All rights reserved. * diff --git a/freebsd/sys/dev/mii/rgephyreg.h b/freebsd/sys/dev/mii/rgephyreg.h index 35917daa..39efaee4 100644 --- a/freebsd/sys/dev/mii/rgephyreg.h +++ b/freebsd/sys/dev/mii/rgephyreg.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 2003 * Bill Paul <wpaul@windriver.com>. All rights reserved. * diff --git a/freebsd/sys/dev/mii/ukphy.c b/freebsd/sys/dev/mii/ukphy.c index c9c59b06..14e42fc9 100644 --- a/freebsd/sys/dev/mii/ukphy.c +++ b/freebsd/sys/dev/mii/ukphy.c @@ -3,6 +3,8 @@ /* $NetBSD: ukphy.c,v 1.2 1999/04/23 04:24:32 thorpej Exp $ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc. * All rights reserved. * diff --git a/freebsd/sys/dev/mii/ukphy_subr.c b/freebsd/sys/dev/mii/ukphy_subr.c index 06e1cc5f..b87717fb 100644 --- a/freebsd/sys/dev/mii/ukphy_subr.c +++ b/freebsd/sys/dev/mii/ukphy_subr.c @@ -3,6 +3,8 @@ /* $NetBSD: ukphy_subr.c,v 1.2 1998/11/05 04:08:02 thorpej Exp $ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Copyright (c) 1998 The NetBSD Foundation, Inc. * All rights reserved. * diff --git a/freebsd/sys/dev/mmc/bridge.h b/freebsd/sys/dev/mmc/bridge.h index b7d95ffc..7af811f1 100644 --- a/freebsd/sys/dev/mmc/bridge.h +++ b/freebsd/sys/dev/mmc/bridge.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2006 M. Warner Losh. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/mmc/mmc.c b/freebsd/sys/dev/mmc/mmc.c index 77934e86..32599383 100644 --- a/freebsd/sys/dev/mmc/mmc.c +++ b/freebsd/sys/dev/mmc/mmc.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2006 Bernd Walter. All rights reserved. * Copyright (c) 2006 M. Warner Losh. All rights reserved. * Copyright (c) 2017 Marius Strobl <marius@FreeBSD.org> diff --git a/freebsd/sys/dev/mmc/mmcbrvar.h b/freebsd/sys/dev/mmc/mmcbrvar.h index c70af92a..6e4bec70 100644 --- a/freebsd/sys/dev/mmc/mmcbrvar.h +++ b/freebsd/sys/dev/mmc/mmcbrvar.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2006 Bernd Walter. All rights reserved. * Copyright (c) 2006 M. Warner Losh. All rights reserved. * diff --git a/freebsd/sys/dev/mmc/mmcreg.h b/freebsd/sys/dev/mmc/mmcreg.h index 8120b69f..5f58ce3f 100644 --- a/freebsd/sys/dev/mmc/mmcreg.h +++ b/freebsd/sys/dev/mmc/mmcreg.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2006 M. Warner Losh. All rights reserved. * Copyright (c) 2017 Marius Strobl <marius@FreeBSD.org> * Copyright (c) 2015-2016 Ilya Bakulin <kibab@FreeBSD.org> diff --git a/freebsd/sys/dev/mmc/mmcsd.c b/freebsd/sys/dev/mmc/mmcsd.c index 45bd9c50..df29b544 100644 --- a/freebsd/sys/dev/mmc/mmcsd.c +++ b/freebsd/sys/dev/mmc/mmcsd.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2006 Bernd Walter. All rights reserved. * Copyright (c) 2006 M. Warner Losh. All rights reserved. * Copyright (c) 2017 Marius Strobl <marius@FreeBSD.org> @@ -554,7 +556,7 @@ mmcsd_attach(device_t dev) (ext_csd[EXT_CSD_ENH_START_ADDR + 1] << 8) + (ext_csd[EXT_CSD_ENH_START_ADDR + 2] << 16) + (ext_csd[EXT_CSD_ENH_START_ADDR + 3] << 24)) * - (sc->high_cap != 0 ? MMC_SECTOR_SIZE : 1); + (sc->high_cap == 0 ? MMC_SECTOR_SIZE : 1); } else if (bootverbose) device_printf(dev, "enhanced user data area spans entire device\n"); diff --git a/freebsd/sys/dev/mmc/mmcvar.h b/freebsd/sys/dev/mmc/mmcvar.h index d0f4e330..1604c306 100644 --- a/freebsd/sys/dev/mmc/mmcvar.h +++ b/freebsd/sys/dev/mmc/mmcvar.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2006 Bernd Walter. All rights reserved. * Copyright (c) 2006 M. Warner Losh. All rights reserved. * diff --git a/freebsd/sys/dev/nvme/nvme.h b/freebsd/sys/dev/nvme/nvme.h index d4fc131e..5d11f793 100644 --- a/freebsd/sys/dev/nvme/nvme.h +++ b/freebsd/sys/dev/nvme/nvme.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (C) 2012-2013 Intel Corporation * All rights reserved. * @@ -42,6 +44,13 @@ #define NVME_BIO_TEST _IOWR('n', 101, struct nvme_io_test) /* + * Macros to deal with NVME revisions, as defined VS register + */ +#define NVME_REV(x, y) (((x) << 16) | ((y) << 8)) +#define NVME_MAJOR(r) (((r) >> 16) & 0xffff) +#define NVME_MINOR(r) (((r) >> 8) & 0xff) + +/* * Use to mark a command to apply to all namespaces, or to retrieve global * log pages. */ @@ -1068,7 +1077,12 @@ uint32_t nvme_ns_get_stripesize(struct nvme_namespace *ns); int nvme_ns_bio_process(struct nvme_namespace *ns, struct bio *bp, nvme_cb_fn_t cb_fn); -/* Command building helper functions -- shared with CAM */ +/* + * Command building helper functions -- shared with CAM + * These functions assume allocator zeros out cmd structure + * CAM's xpt_get_ccb and the request allocator for nvme both + * do zero'd allocations. + */ static inline void nvme_ns_flush_cmd(struct nvme_command *cmd, uint32_t nsid) { @@ -1086,9 +1100,6 @@ void nvme_ns_rw_cmd(struct nvme_command *cmd, uint32_t rwcmd, uint32_t nsid, cmd->cdw10 = lba & 0xffffffffu; cmd->cdw11 = lba >> 32; cmd->cdw12 = count-1; - cmd->cdw13 = 0; - cmd->cdw14 = 0; - cmd->cdw15 = 0; } static inline diff --git a/freebsd/sys/dev/ofw/ofw_bus.h b/freebsd/sys/dev/ofw/ofw_bus.h index dff9a2b8..bfffcefa 100644 --- a/freebsd/sys/dev/ofw/ofw_bus.h +++ b/freebsd/sys/dev/ofw/ofw_bus.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001, 2003 by Thomas Moestl <tmm@FreeBSD.org> * Copyright (c) 2004 by Marius Strobl <marius@FreeBSD.org> * All rights reserved. diff --git a/freebsd/sys/dev/ofw/ofw_bus_subr.c b/freebsd/sys/dev/ofw/ofw_bus_subr.c index 418304a0..c655e668 100644 --- a/freebsd/sys/dev/ofw/ofw_bus_subr.c +++ b/freebsd/sys/dev/ofw/ofw_bus_subr.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 - 2003 by Thomas Moestl <tmm@FreeBSD.org>. * Copyright (c) 2005 Marius Strobl <marius@FreeBSD.org> * All rights reserved. diff --git a/freebsd/sys/dev/ofw/ofw_bus_subr.h b/freebsd/sys/dev/ofw/ofw_bus_subr.h index 4afd84e3..04f5a75b 100644 --- a/freebsd/sys/dev/ofw/ofw_bus_subr.h +++ b/freebsd/sys/dev/ofw/ofw_bus_subr.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2005 Marius Strobl <marius@FreeBSD.org> * All rights reserved. * @@ -63,7 +65,7 @@ struct intr_map_data_fdt { }; #endif -#define SIMPLEBUS_PNP_DESCR "Z:compat;P:private;" +#define SIMPLEBUS_PNP_DESCR "Z:compat;P:#;" #define SIMPLEBUS_PNP_INFO(t) \ MODULE_PNP_INFO(SIMPLEBUS_PNP_DESCR, simplebus, t, t, sizeof(t[0]), sizeof(t) / sizeof(t[0])); diff --git a/freebsd/sys/dev/ofw/ofw_fdt.c b/freebsd/sys/dev/ofw/ofw_fdt.c index 282c3667..7bdf447b 100644 --- a/freebsd/sys/dev/ofw/ofw_fdt.c +++ b/freebsd/sys/dev/ofw/ofw_fdt.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2009-2010 The FreeBSD Foundation * All rights reserved. * diff --git a/freebsd/sys/dev/ofw/ofw_pci.h b/freebsd/sys/dev/ofw/ofw_pci.h index eb60c5ba..fe4e8b1a 100644 --- a/freebsd/sys/dev/ofw/ofw_pci.h +++ b/freebsd/sys/dev/ofw/ofw_pci.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Copyright (c) 1999 The NetBSD Foundation, Inc. * All rights reserved. * diff --git a/freebsd/sys/dev/ofw/ofwvar.h b/freebsd/sys/dev/ofw/ofwvar.h index 38bf472b..559da72b 100644 --- a/freebsd/sys/dev/ofw/ofwvar.h +++ b/freebsd/sys/dev/ofw/ofwvar.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2005 Peter Grehan * Copyright (c) 2008 Nathan Whitehorn * All rights reserved. diff --git a/freebsd/sys/dev/ofw/openfirm.c b/freebsd/sys/dev/ofw/openfirm.c index 7132c419..406e8dd6 100644 --- a/freebsd/sys/dev/ofw/openfirm.c +++ b/freebsd/sys/dev/ofw/openfirm.c @@ -3,6 +3,8 @@ /* $NetBSD: Locore.c,v 1.7 2000/08/20 07:04:59 tsubai Exp $ */ /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (C) 1995, 1996 Wolfgang Solfrank. * Copyright (C) 1995, 1996 TooLs GmbH. * All rights reserved. @@ -210,6 +212,12 @@ OF_install(char *name, int prio) ofw_def_t *ofwp, **ofwpp; static int curr_prio = 0; + /* Allow OF layer to be uninstalled */ + if (name == NULL) { + ofw_def_impl = NULL; + return (FALSE); + } + /* * Try and locate the OFW kobj corresponding to the name. */ diff --git a/freebsd/sys/dev/ofw/openfirm.h b/freebsd/sys/dev/ofw/openfirm.h index 4e9fb29c..e1701164 100644 --- a/freebsd/sys/dev/ofw/openfirm.h +++ b/freebsd/sys/dev/ofw/openfirm.h @@ -1,6 +1,8 @@ /* $NetBSD: openfirm.h,v 1.1 1998/05/15 10:16:00 tsubai Exp $ */ /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (C) 1995, 1996 Wolfgang Solfrank. * Copyright (C) 1995, 1996 TooLs GmbH. * All rights reserved. diff --git a/freebsd/sys/dev/pci/pci.c b/freebsd/sys/dev/pci/pci.c index 69497d2c..e492846d 100644 --- a/freebsd/sys/dev/pci/pci.c +++ b/freebsd/sys/dev/pci/pci.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1997, Stefan Esser <se@freebsd.org> * Copyright (c) 2000, Michael Smith <msmith@freebsd.org> * Copyright (c) 2000, BSDi @@ -323,9 +325,9 @@ SYSCTL_NODE(_hw, OID_AUTO, pci, CTLFLAG_RD, 0, "PCI bus tuning parameters"); static int pci_enable_io_modes = 1; SYSCTL_INT(_hw_pci, OID_AUTO, enable_io_modes, CTLFLAG_RWTUN, &pci_enable_io_modes, 1, - "Enable I/O and memory bits in the config register. Some BIOSes do not\n\ -enable these bits correctly. We'd like to do this all the time, but there\n\ -are some peripherals that this causes problems with."); + "Enable I/O and memory bits in the config register. Some BIOSes do not" + " enable these bits correctly. We'd like to do this all the time, but" + " there are some peripherals that this causes problems with."); static int pci_do_realloc_bars = 0; SYSCTL_INT(_hw_pci, OID_AUTO, realloc_bars, CTLFLAG_RWTUN, @@ -336,10 +338,10 @@ SYSCTL_INT(_hw_pci, OID_AUTO, realloc_bars, CTLFLAG_RWTUN, static int pci_do_power_nodriver = 0; SYSCTL_INT(_hw_pci, OID_AUTO, do_power_nodriver, CTLFLAG_RWTUN, &pci_do_power_nodriver, 0, - "Place a function into D3 state when no driver attaches to it. 0 means\n\ -disable. 1 means conservatively place devices into D3 state. 2 means\n\ -aggressively place devices into D3 state. 3 means put absolutely everything\n\ -in D3 state."); + "Place a function into D3 state when no driver attaches to it. 0 means" + " disable. 1 means conservatively place devices into D3 state. 2 means" + " aggressively place devices into D3 state. 3 means put absolutely" + " everything in D3 state."); int pci_do_power_resume = 1; SYSCTL_INT(_hw_pci, OID_AUTO, do_power_resume, CTLFLAG_RWTUN, @@ -374,9 +376,10 @@ static int pci_usb_takeover = 1; static int pci_usb_takeover = 0; #endif SYSCTL_INT(_hw_pci, OID_AUTO, usb_early_takeover, CTLFLAG_RDTUN, - &pci_usb_takeover, 1, "Enable early takeover of USB controllers.\n\ -Disable this if you depend on BIOS emulation of USB devices, that is\n\ -you use USB devices (like keyboard or mouse) but do not load USB drivers"); + &pci_usb_takeover, 1, + "Enable early takeover of USB controllers. Disable this if you depend on" + " BIOS emulation of USB devices, that is you use USB devices (like" + " keyboard or mouse) but do not load USB drivers"); static int pci_clear_bars; SYSCTL_INT(_hw_pci, OID_AUTO, clear_bars, CTLFLAG_RDTUN, &pci_clear_bars, 0, diff --git a/freebsd/sys/dev/pci/pci_pci.c b/freebsd/sys/dev/pci/pci_pci.c index ed4c1b50..5585bd32 100644 --- a/freebsd/sys/dev/pci/pci_pci.c +++ b/freebsd/sys/dev/pci/pci_pci.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1994,1995 Stefan Esser, Wolfgang StanglMeier * Copyright (c) 2000 Michael Smith <msmith@freebsd.org> * Copyright (c) 2000 BSDi diff --git a/freebsd/sys/dev/pci/pci_private.h b/freebsd/sys/dev/pci/pci_private.h index 6c5a1677..dd254e66 100644 --- a/freebsd/sys/dev/pci/pci_private.h +++ b/freebsd/sys/dev/pci/pci_private.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1997, Stefan Esser <se@freebsd.org> * Copyright (c) 2000, Michael Smith <msmith@freebsd.org> * Copyright (c) 2000, BSDi diff --git a/freebsd/sys/dev/pci/pci_user.c b/freebsd/sys/dev/pci/pci_user.c index edad1847..6e1cc3ef 100644 --- a/freebsd/sys/dev/pci/pci_user.c +++ b/freebsd/sys/dev/pci/pci_user.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1997, Stefan Esser <se@freebsd.org> * All rights reserved. * diff --git a/freebsd/sys/dev/pci/pcib_private.h b/freebsd/sys/dev/pci/pcib_private.h index 5482e12d..5cda3a38 100644 --- a/freebsd/sys/dev/pci/pcib_private.h +++ b/freebsd/sys/dev/pci/pcib_private.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1994,1995 Stefan Esser, Wolfgang StanglMeier * Copyright (c) 2000 Michael Smith <msmith@freebsd.org> * Copyright (c) 2000 BSDi diff --git a/freebsd/sys/dev/pci/pcireg.h b/freebsd/sys/dev/pci/pcireg.h index b434b2e6..00589c4b 100644 --- a/freebsd/sys/dev/pci/pcireg.h +++ b/freebsd/sys/dev/pci/pcireg.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1997, Stefan Esser <se@freebsd.org> * All rights reserved. * diff --git a/freebsd/sys/dev/pci/pcivar.h b/freebsd/sys/dev/pci/pcivar.h index 4652715a..430e29db 100644 --- a/freebsd/sys/dev/pci/pcivar.h +++ b/freebsd/sys/dev/pci/pcivar.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1997, Stefan Esser <se@freebsd.org> * All rights reserved. * diff --git a/freebsd/sys/dev/re/if_re.c b/freebsd/sys/dev/re/if_re.c index 0a2cb648..c8bb6db7 100644 --- a/freebsd/sys/dev/re/if_re.c +++ b/freebsd/sys/dev/re/if_re.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 1997, 1998-2003 * Bill Paul <wpaul@windriver.com>. All rights reserved. * diff --git a/freebsd/sys/dev/rtwn/usb/rtwn_usb_attach.h b/freebsd/sys/dev/rtwn/usb/rtwn_usb_attach.h index ee6d9137..6bbdf5bc 100644 --- a/freebsd/sys/dev/rtwn/usb/rtwn_usb_attach.h +++ b/freebsd/sys/dev/rtwn/usb/rtwn_usb_attach.h @@ -137,6 +137,8 @@ static const STRUCT_USB_HOST_ID rtwn_devs[] = { RTWN_RTL8812AU_DEV(SENAO, EUB1200AC), RTWN_RTL8812AU_DEV(SITECOMEU, WLA7100), RTWN_RTL8812AU_DEV(TPLINK, T4U), + RTWN_RTL8812AU_DEV(TPLINK, T4UV2), + RTWN_RTL8812AU_DEV(TPLINK, T4UHV2), RTWN_RTL8812AU_DEV(TRENDNET, TEW805UB), RTWN_RTL8812AU_DEV(ZYXEL, NWD6605), #undef RTWN_RTL8812AU_DEV diff --git a/freebsd/sys/dev/sdhci/sdhci.c b/freebsd/sys/dev/sdhci/sdhci.c index 8d1fed8f..496e8fac 100644 --- a/freebsd/sys/dev/sdhci/sdhci.c +++ b/freebsd/sys/dev/sdhci/sdhci.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Alexander Motin <mav@FreeBSD.org> * Copyright (c) 2017 Marius Strobl <marius@FreeBSD.org> * All rights reserved. diff --git a/freebsd/sys/dev/sdhci/sdhci.h b/freebsd/sys/dev/sdhci/sdhci.h index ba66415f..f2a7a9b1 100644 --- a/freebsd/sys/dev/sdhci/sdhci.h +++ b/freebsd/sys/dev/sdhci/sdhci.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Alexander Motin <mav@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/dev/smc/if_smc.c b/freebsd/sys/dev/smc/if_smc.c index fd1a0960..6b087a85 100644 --- a/freebsd/sys/dev/smc/if_smc.c +++ b/freebsd/sys/dev/smc/if_smc.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Benno Rice. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/smc/if_smcreg.h b/freebsd/sys/dev/smc/if_smcreg.h index 4b939076..4642966f 100644 --- a/freebsd/sys/dev/smc/if_smcreg.h +++ b/freebsd/sys/dev/smc/if_smcreg.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2006 Benno Rice. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/smc/if_smcvar.h b/freebsd/sys/dev/smc/if_smcvar.h index fd42edbb..a58eb0df 100644 --- a/freebsd/sys/dev/smc/if_smcvar.h +++ b/freebsd/sys/dev/smc/if_smcvar.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Benno Rice. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/tsec/if_tsec.c b/freebsd/sys/dev/tsec/if_tsec.c index b7edc948..e07c21ce 100644 --- a/freebsd/sys/dev/tsec/if_tsec.c +++ b/freebsd/sys/dev/tsec/if_tsec.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (C) 2007-2008 Semihalf, Rafal Jaworowski * Copyright (C) 2006-2007 Semihalf, Piotr Kruszynski * All rights reserved. diff --git a/freebsd/sys/dev/tsec/if_tsec.h b/freebsd/sys/dev/tsec/if_tsec.h index c8dca3bf..2caa2619 100644 --- a/freebsd/sys/dev/tsec/if_tsec.h +++ b/freebsd/sys/dev/tsec/if_tsec.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (C) 2006-2007 Semihalf, Piotr Kruszynski * All rights reserved. * diff --git a/freebsd/sys/dev/tsec/if_tsec_fdt.c b/freebsd/sys/dev/tsec/if_tsec_fdt.c index 476a5bf9..01718194 100644 --- a/freebsd/sys/dev/tsec/if_tsec_fdt.c +++ b/freebsd/sys/dev/tsec/if_tsec_fdt.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (C) 2007-2008 Semihalf, Rafal Jaworowski * Copyright (C) 2006-2007 Semihalf, Piotr Kruszynski * All rights reserved. diff --git a/freebsd/sys/dev/tsec/if_tsecreg.h b/freebsd/sys/dev/tsec/if_tsecreg.h index 1994298c..18a81df7 100644 --- a/freebsd/sys/dev/tsec/if_tsecreg.h +++ b/freebsd/sys/dev/tsec/if_tsecreg.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (C) 2008-2009 Semihalf, Piotr Ziecik * Copyright (C) 2006-2007 Semihalf, Piotr Kruszynski * All rights reserved. diff --git a/freebsd/sys/dev/usb/controller/dwc_otg.c b/freebsd/sys/dev/usb/controller/dwc_otg.c index 421eb77f..abc23ac6 100644 --- a/freebsd/sys/dev/usb/controller/dwc_otg.c +++ b/freebsd/sys/dev/usb/controller/dwc_otg.c @@ -2,6 +2,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2015 Daisuke Aoyama. All rights reserved. * Copyright (c) 2012-2015 Hans Petter Selasky. All rights reserved. * Copyright (c) 2010-2011 Aleksandr Rybalko. All rights reserved. diff --git a/freebsd/sys/dev/usb/controller/dwc_otg.h b/freebsd/sys/dev/usb/controller/dwc_otg.h index 7f5ede48..2de0214f 100644 --- a/freebsd/sys/dev/usb/controller/dwc_otg.h +++ b/freebsd/sys/dev/usb/controller/dwc_otg.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2012 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/controller/dwc_otg_fdt.c b/freebsd/sys/dev/usb/controller/dwc_otg_fdt.c index 791d9890..1cf96f4c 100644 --- a/freebsd/sys/dev/usb/controller/dwc_otg_fdt.c +++ b/freebsd/sys/dev/usb/controller/dwc_otg_fdt.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2012 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/controller/dwc_otgreg.h b/freebsd/sys/dev/usb/controller/dwc_otgreg.h index 8b9538ae..3c50ca58 100644 --- a/freebsd/sys/dev/usb/controller/dwc_otgreg.h +++ b/freebsd/sys/dev/usb/controller/dwc_otgreg.h @@ -1,6 +1,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2010,2011 Aleksandr Rybalko. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/controller/ehci.c b/freebsd/sys/dev/usb/controller/ehci.c index 9de1491e..557698f6 100644 --- a/freebsd/sys/dev/usb/controller/ehci.c +++ b/freebsd/sys/dev/usb/controller/ehci.c @@ -2,6 +2,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * Copyright (c) 2004 The NetBSD Foundation, Inc. All rights reserved. * Copyright (c) 2004 Lennart Augustsson. All rights reserved. diff --git a/freebsd/sys/dev/usb/controller/ehci.h b/freebsd/sys/dev/usb/controller/ehci.h index dd20c0a5..3a5f6781 100644 --- a/freebsd/sys/dev/usb/controller/ehci.h +++ b/freebsd/sys/dev/usb/controller/ehci.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Copyright (c) 2001 The NetBSD Foundation, Inc. * All rights reserved. * diff --git a/freebsd/sys/dev/usb/controller/ehcireg.h b/freebsd/sys/dev/usb/controller/ehcireg.h index 2394b2c1..81939e20 100644 --- a/freebsd/sys/dev/usb/controller/ehcireg.h +++ b/freebsd/sys/dev/usb/controller/ehcireg.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Copyright (c) 2001 The NetBSD Foundation, Inc. * All rights reserved. * diff --git a/freebsd/sys/dev/usb/controller/musb_otg.c b/freebsd/sys/dev/usb/controller/musb_otg.c index 0f1953b6..16a3adef 100644 --- a/freebsd/sys/dev/usb/controller/musb_otg.c +++ b/freebsd/sys/dev/usb/controller/musb_otg.c @@ -2,6 +2,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/controller/musb_otg.h b/freebsd/sys/dev/usb/controller/musb_otg.h index 7fe19a7c..55ab7aa6 100644 --- a/freebsd/sys/dev/usb/controller/musb_otg.h +++ b/freebsd/sys/dev/usb/controller/musb_otg.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/controller/ohci.c b/freebsd/sys/dev/usb/controller/ohci.c index 9f0654e3..df1981cc 100644 --- a/freebsd/sys/dev/usb/controller/ohci.c +++ b/freebsd/sys/dev/usb/controller/ohci.c @@ -2,6 +2,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved. * Copyright (c) 1998 Lennart Augustsson. All rights reserved. diff --git a/freebsd/sys/dev/usb/controller/ohci.h b/freebsd/sys/dev/usb/controller/ohci.h index 69fc9a62..72e825ec 100755 --- a/freebsd/sys/dev/usb/controller/ohci.h +++ b/freebsd/sys/dev/usb/controller/ohci.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Copyright (c) 1998 The NetBSD Foundation, Inc. * All rights reserved. * diff --git a/freebsd/sys/dev/usb/controller/ohcireg.h b/freebsd/sys/dev/usb/controller/ohcireg.h index 7f14875c..c6ea4113 100644 --- a/freebsd/sys/dev/usb/controller/ohcireg.h +++ b/freebsd/sys/dev/usb/controller/ohcireg.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1998 The NetBSD Foundation, Inc. * All rights reserved. * diff --git a/freebsd/sys/dev/usb/controller/uhcireg.h b/freebsd/sys/dev/usb/controller/uhcireg.h index 95eae494..fa0e4eb9 100644 --- a/freebsd/sys/dev/usb/controller/uhcireg.h +++ b/freebsd/sys/dev/usb/controller/uhcireg.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1998 The NetBSD Foundation, Inc. * All rights reserved. * diff --git a/freebsd/sys/dev/usb/controller/usb_controller.c b/freebsd/sys/dev/usb/controller/usb_controller.c index 5f198aed..a2633d0d 100644 --- a/freebsd/sys/dev/usb/controller/usb_controller.c +++ b/freebsd/sys/dev/usb/controller/usb_controller.c @@ -2,6 +2,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/controller/xhcireg.h b/freebsd/sys/dev/usb/controller/xhcireg.h index 0e588ecb..b49bc09a 100644 --- a/freebsd/sys/dev/usb/controller/xhcireg.h +++ b/freebsd/sys/dev/usb/controller/xhcireg.h @@ -1,6 +1,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2010 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/input/atp.c b/freebsd/sys/dev/usb/input/atp.c index 17162411..d0fabe0d 100644 --- a/freebsd/sys/dev/usb/input/atp.c +++ b/freebsd/sys/dev/usb/input/atp.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2014 Rohit Grover * All rights reserved. * diff --git a/freebsd/sys/dev/usb/input/uep.c b/freebsd/sys/dev/usb/input/uep.c index d7af405f..701c8550 100644 --- a/freebsd/sys/dev/usb/input/uep.c +++ b/freebsd/sys/dev/usb/input/uep.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright 2010, Gleb Smirnoff <glebius@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/dev/usb/input/uhid.c b/freebsd/sys/dev/usb/input/uhid.c index 6de5944d..90761ab7 100644 --- a/freebsd/sys/dev/usb/input/uhid.c +++ b/freebsd/sys/dev/usb/input/uhid.c @@ -10,6 +10,8 @@ __FBSDID("$FreeBSD$"); /*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Copyright (c) 1998 The NetBSD Foundation, Inc. * All rights reserved. * diff --git a/freebsd/sys/dev/usb/input/ukbd.c b/freebsd/sys/dev/usb/input/ukbd.c index d473d1ea..9b1d28fc 100644 --- a/freebsd/sys/dev/usb/input/ukbd.c +++ b/freebsd/sys/dev/usb/input/ukbd.c @@ -5,6 +5,8 @@ __FBSDID("$FreeBSD$"); /*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Copyright (c) 1998 The NetBSD Foundation, Inc. * All rights reserved. * diff --git a/freebsd/sys/dev/usb/input/ums.c b/freebsd/sys/dev/usb/input/ums.c index 36c1d1b4..79bc2291 100644 --- a/freebsd/sys/dev/usb/input/ums.c +++ b/freebsd/sys/dev/usb/input/ums.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1998 The NetBSD Foundation, Inc. * All rights reserved. * @@ -298,7 +300,7 @@ ums_intr_callback(struct usb_xfer *xfer, usb_error_t error) if ((info->sc_flags & UMS_FLAG_T_AXIS) && (id == info->sc_iid_t)) { - dt -= hid_get_data(buf, len, &info->sc_loc_t); + dt += hid_get_data(buf, len, &info->sc_loc_t); /* T-axis is translated into button presses */ buttons_found |= (1UL << 5) | (1UL << 6); } @@ -334,10 +336,10 @@ ums_intr_callback(struct usb_xfer *xfer, usb_error_t error) /* translate T-axis into button presses until further */ if (dt > 0) { ums_put_queue(sc, 0, 0, 0, 0, buttons); - buttons |= 1UL << 5; + buttons |= 1UL << 6; } else if (dt < 0) { ums_put_queue(sc, 0, 0, 0, 0, buttons); - buttons |= 1UL << 6; + buttons |= 1UL << 5; } sc->sc_status.button = buttons; diff --git a/freebsd/sys/dev/usb/input/usb_rdesc.h b/freebsd/sys/dev/usb/input/usb_rdesc.h index 23ea620b..00eea122 100644 --- a/freebsd/sys/dev/usb/input/usb_rdesc.h +++ b/freebsd/sys/dev/usb/input/usb_rdesc.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2000 Nick Hibma <n_hibma@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/dev/usb/input/wsp.c b/freebsd/sys/dev/usb/input/wsp.c index d3eae491..0eb2c024 100644 --- a/freebsd/sys/dev/usb/input/wsp.c +++ b/freebsd/sys/dev/usb/input/wsp.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2012 Huang Wen Hui * All rights reserved. * diff --git a/freebsd/sys/dev/usb/net/if_aue.c b/freebsd/sys/dev/usb/net/if_aue.c index 06ccd8ce..69951b70 100644 --- a/freebsd/sys/dev/usb/net/if_aue.c +++ b/freebsd/sys/dev/usb/net/if_aue.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 1997, 1998, 1999, 2000 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved. * diff --git a/freebsd/sys/dev/usb/net/if_auereg.h b/freebsd/sys/dev/usb/net/if_auereg.h index 4d0843eb..dfbaac42 100644 --- a/freebsd/sys/dev/usb/net/if_auereg.h +++ b/freebsd/sys/dev/usb/net/if_auereg.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 1997, 1998, 1999 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved. * diff --git a/freebsd/sys/dev/usb/net/if_axe.c b/freebsd/sys/dev/usb/net/if_axe.c index 728f8e3d..b77292ba 100644 --- a/freebsd/sys/dev/usb/net/if_axe.c +++ b/freebsd/sys/dev/usb/net/if_axe.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 1997, 1998, 1999, 2000-2003 * Bill Paul <wpaul@windriver.com>. All rights reserved. * diff --git a/freebsd/sys/dev/usb/net/if_axereg.h b/freebsd/sys/dev/usb/net/if_axereg.h index 64cb2352..2654bbba 100644 --- a/freebsd/sys/dev/usb/net/if_axereg.h +++ b/freebsd/sys/dev/usb/net/if_axereg.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 1997, 1998, 1999, 2000-2003 * Bill Paul <wpaul@windriver.com>. All rights reserved. * diff --git a/freebsd/sys/dev/usb/net/if_axge.c b/freebsd/sys/dev/usb/net/if_axge.c index 4e6f05b5..fc602b88 100644 --- a/freebsd/sys/dev/usb/net/if_axge.c +++ b/freebsd/sys/dev/usb/net/if_axge.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2013-2014 Kevin Lo * All rights reserved. * diff --git a/freebsd/sys/dev/usb/net/if_axgereg.h b/freebsd/sys/dev/usb/net/if_axgereg.h index c073610f..542ea6d1 100644 --- a/freebsd/sys/dev/usb/net/if_axgereg.h +++ b/freebsd/sys/dev/usb/net/if_axgereg.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2013-2014 Kevin Lo * All rights reserved. * diff --git a/freebsd/sys/dev/usb/net/if_cdce.c b/freebsd/sys/dev/usb/net/if_cdce.c index 777113da..ececc5b3 100644 --- a/freebsd/sys/dev/usb/net/if_cdce.c +++ b/freebsd/sys/dev/usb/net/if_cdce.c @@ -3,6 +3,8 @@ /* $NetBSD: if_cdce.c,v 1.4 2004/10/24 12:50:54 augustss Exp $ */ /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 1997, 1998, 1999, 2000-2003 Bill Paul <wpaul@windriver.com> * Copyright (c) 2003-2005 Craig Boston * Copyright (c) 2004 Daniel Hartmeier diff --git a/freebsd/sys/dev/usb/net/if_cdcereg.h b/freebsd/sys/dev/usb/net/if_cdcereg.h index 1bc2d603..26d037c5 100644 --- a/freebsd/sys/dev/usb/net/if_cdcereg.h +++ b/freebsd/sys/dev/usb/net/if_cdcereg.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 2003-2005 Craig Boston * All rights reserved. * diff --git a/freebsd/sys/dev/usb/net/if_cue.c b/freebsd/sys/dev/usb/net/if_cue.c index d5152dd4..63846a01 100644 --- a/freebsd/sys/dev/usb/net/if_cue.c +++ b/freebsd/sys/dev/usb/net/if_cue.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 1997, 1998, 1999, 2000 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved. * diff --git a/freebsd/sys/dev/usb/net/if_cuereg.h b/freebsd/sys/dev/usb/net/if_cuereg.h index ff245c05..b5cccee4 100644 --- a/freebsd/sys/dev/usb/net/if_cuereg.h +++ b/freebsd/sys/dev/usb/net/if_cuereg.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 1997, 1998, 1999, 2000 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved. * diff --git a/freebsd/sys/dev/usb/net/if_ipheth.c b/freebsd/sys/dev/usb/net/if_ipheth.c index 2eaf88b8..bb56c294 100644 --- a/freebsd/sys/dev/usb/net/if_ipheth.c +++ b/freebsd/sys/dev/usb/net/if_ipheth.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2010 Hans Petter Selasky. All rights reserved. * Copyright (c) 2009 Diego Giagio. All rights reserved. * diff --git a/freebsd/sys/dev/usb/net/if_iphethvar.h b/freebsd/sys/dev/usb/net/if_iphethvar.h index 65b0c940..4f990189 100644 --- a/freebsd/sys/dev/usb/net/if_iphethvar.h +++ b/freebsd/sys/dev/usb/net/if_iphethvar.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2010 Hans Petter Selasky. All rights reserved. * Copyright (c) 2009 Diego Giagio. All rights reserved. * diff --git a/freebsd/sys/dev/usb/net/if_kue.c b/freebsd/sys/dev/usb/net/if_kue.c index 26e09459..255a83bb 100644 --- a/freebsd/sys/dev/usb/net/if_kue.c +++ b/freebsd/sys/dev/usb/net/if_kue.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 1997, 1998, 1999, 2000 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved. * diff --git a/freebsd/sys/dev/usb/net/if_kuefw.h b/freebsd/sys/dev/usb/net/if_kuefw.h index 2b055a92..8b799f01 100644 --- a/freebsd/sys/dev/usb/net/if_kuefw.h +++ b/freebsd/sys/dev/usb/net/if_kuefw.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 1997, 1998, 1999, 2000 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved. * diff --git a/freebsd/sys/dev/usb/net/if_kuereg.h b/freebsd/sys/dev/usb/net/if_kuereg.h index 16ad044d..2f5d7ccb 100644 --- a/freebsd/sys/dev/usb/net/if_kuereg.h +++ b/freebsd/sys/dev/usb/net/if_kuereg.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 1997, 1998, 1999, 2000 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved. * diff --git a/freebsd/sys/dev/usb/net/if_mos.c b/freebsd/sys/dev/usb/net/if_mos.c index 8cac9033..a25e9df6 100644 --- a/freebsd/sys/dev/usb/net/if_mos.c +++ b/freebsd/sys/dev/usb/net/if_mos.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: 0BSD AND BSD-4-Clause + * * Copyright (c) 2011 Rick van der Zwet <info@rickvanderzwet.nl> * * Permission to use, copy, modify, and distribute this software for any diff --git a/freebsd/sys/dev/usb/net/if_mosreg.h b/freebsd/sys/dev/usb/net/if_mosreg.h index c811d552..b8034feb 100644 --- a/freebsd/sys/dev/usb/net/if_mosreg.h +++ b/freebsd/sys/dev/usb/net/if_mosreg.h @@ -32,6 +32,8 @@ */ /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 1997, 1998, 1999, 2000-2003 * Bill Paul <wpaul@windriver.com>. All rights reserved. * diff --git a/freebsd/sys/dev/usb/net/if_rue.c b/freebsd/sys/dev/usb/net/if_rue.c index e816a190..7b062755 100644 --- a/freebsd/sys/dev/usb/net/if_rue.c +++ b/freebsd/sys/dev/usb/net/if_rue.c @@ -27,6 +27,8 @@ * SUCH DAMAGE. */ /*- + * SPDX-License-Identifier: BSD-4-Clause AND BSD-2-Clause-FreeBSD + * * Copyright (c) 1997, 1998, 1999, 2000 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved. * diff --git a/freebsd/sys/dev/usb/net/if_ruereg.h b/freebsd/sys/dev/usb/net/if_ruereg.h index c90a9692..688ee24e 100644 --- a/freebsd/sys/dev/usb/net/if_ruereg.h +++ b/freebsd/sys/dev/usb/net/if_ruereg.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001-2003, Shunsuke Akiyama <akiyama@FreeBSD.org>. * All rights reserved. * diff --git a/freebsd/sys/dev/usb/net/if_smsc.c b/freebsd/sys/dev/usb/net/if_smsc.c index 9c028b4e..88ecb618 100644 --- a/freebsd/sys/dev/usb/net/if_smsc.c +++ b/freebsd/sys/dev/usb/net/if_smsc.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2012 * Ben Gray <bgray@freebsd.org>. * All rights reserved. @@ -1570,8 +1572,9 @@ smsc_fdt_find_eth_node(phandle_t start) /* Traverse through entire tree to find usb ethernet nodes. */ for (node = OF_child(start); node != 0; node = OF_peer(node)) { - if (ofw_bus_node_is_compatible(node, "net,ethernet") && - ofw_bus_node_is_compatible(node, "usb,device")) + if ((ofw_bus_node_is_compatible(node, "net,ethernet") && + ofw_bus_node_is_compatible(node, "usb,device")) || + ofw_bus_node_is_compatible(node, "usb424,ec00")) return (node); child = smsc_fdt_find_eth_node(node); if (child != -1) @@ -1638,6 +1641,37 @@ smsc_fdt_find_eth_node_by_path(phandle_t start) return (-1); } +/* + * Look through known names that can contain mac address + * return 0 if valid MAC address has been found + */ +static int +smsc_fdt_read_mac_property(phandle_t node, unsigned char *mac) +{ + int len; + + /* Check if there is property */ + if ((len = OF_getproplen(node, "local-mac-address")) > 0) { + if (len != ETHER_ADDR_LEN) + return (EINVAL); + + OF_getprop(node, "local-mac-address", mac, + ETHER_ADDR_LEN); + return (0); + } + + if ((len = OF_getproplen(node, "mac-address")) > 0) { + if (len != ETHER_ADDR_LEN) + return (EINVAL); + + OF_getprop(node, "mac-address", mac, + ETHER_ADDR_LEN); + return (0); + } + + return (ENXIO); +} + /** * Get MAC address from FDT blob. Firmware or loader should fill * mac-address or local-mac-address property. Returns 0 if MAC address @@ -1647,37 +1681,22 @@ static int smsc_fdt_find_mac(unsigned char *mac) { phandle_t node, root; - int len; root = OF_finddevice("/"); node = smsc_fdt_find_eth_node(root); + if (node != -1) { + if (smsc_fdt_read_mac_property(node, mac) == 0) + return (0); + } + /* * If it's not FreeBSD FDT blob for RPi, try more * generic .../usb/hub/ethernet */ - if (node == -1) - node = smsc_fdt_find_eth_node_by_path(root); - - if (node != -1) { - /* Check if there is property */ - if ((len = OF_getproplen(node, "local-mac-address")) > 0) { - if (len != ETHER_ADDR_LEN) - return (EINVAL); - - OF_getprop(node, "local-mac-address", mac, - ETHER_ADDR_LEN); - return (0); - } + node = smsc_fdt_find_eth_node_by_path(root); - if ((len = OF_getproplen(node, "mac-address")) > 0) { - if (len != ETHER_ADDR_LEN) - return (EINVAL); - - OF_getprop(node, "mac-address", mac, - ETHER_ADDR_LEN); - return (0); - } - } + if (node != -1) + return smsc_fdt_read_mac_property(node, mac); return (ENXIO); } diff --git a/freebsd/sys/dev/usb/net/if_smscreg.h b/freebsd/sys/dev/usb/net/if_smscreg.h index 31a63828..5ad79b9e 100644 --- a/freebsd/sys/dev/usb/net/if_smscreg.h +++ b/freebsd/sys/dev/usb/net/if_smscreg.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2012 * Ben Gray <bgray@freebsd.org>. * All rights reserved. diff --git a/freebsd/sys/dev/usb/net/if_udav.c b/freebsd/sys/dev/usb/net/if_udav.c index b8393abc..21019265 100644 --- a/freebsd/sys/dev/usb/net/if_udav.c +++ b/freebsd/sys/dev/usb/net/if_udav.c @@ -4,6 +4,8 @@ /* $nabe: if_udav.c,v 1.3 2003/08/21 16:57:19 nabe Exp $ */ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2003 * Shingo WATANABE <nabe@nabechan.org>. All rights reserved. * diff --git a/freebsd/sys/dev/usb/net/if_udavreg.h b/freebsd/sys/dev/usb/net/if_udavreg.h index 7c35829b..d8927006 100644 --- a/freebsd/sys/dev/usb/net/if_udavreg.h +++ b/freebsd/sys/dev/usb/net/if_udavreg.h @@ -2,6 +2,8 @@ /* $nabe: if_udavreg.h,v 1.2 2003/08/21 16:26:40 nabe Exp $ */ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2003 * Shingo WATANABE <nabe@nabechan.org>. All rights reserved. * diff --git a/freebsd/sys/dev/usb/net/if_ure.c b/freebsd/sys/dev/usb/net/if_ure.c index 89ce723b..0e45a6c9 100644 --- a/freebsd/sys/dev/usb/net/if_ure.c +++ b/freebsd/sys/dev/usb/net/if_ure.c @@ -72,6 +72,7 @@ static const STRUCT_USB_HOST_ID ure_devs[] = { URE_DEV(LENOVO, RTL8153, 0), URE_DEV(REALTEK, RTL8152, URE_FLAG_8152), URE_DEV(REALTEK, RTL8153, 0), + URE_DEV(TPLINK, RTL8153, 0), #undef URE_DEV }; diff --git a/freebsd/sys/dev/usb/net/ruephy.c b/freebsd/sys/dev/usb/net/ruephy.c index af01d23b..d16bc8ae 100644 --- a/freebsd/sys/dev/usb/net/ruephy.c +++ b/freebsd/sys/dev/usb/net/ruephy.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001-2003, Shunsuke Akiyama <akiyama@FreeBSD.org>. * All rights reserved. * diff --git a/freebsd/sys/dev/usb/net/ruephyreg.h b/freebsd/sys/dev/usb/net/ruephyreg.h index 01d3cc17..38c508d5 100644 --- a/freebsd/sys/dev/usb/net/ruephyreg.h +++ b/freebsd/sys/dev/usb/net/ruephyreg.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001-2003, Shunsuke Akiyama <akiyama@FreeBSD.org>. * All rights reserved. * diff --git a/freebsd/sys/dev/usb/net/usb_ethernet.c b/freebsd/sys/dev/usb/net/usb_ethernet.c index 32c0fa22..842e7987 100644 --- a/freebsd/sys/dev/usb/net/usb_ethernet.c +++ b/freebsd/sys/dev/usb/net/usb_ethernet.c @@ -2,6 +2,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2009 Andrew Thompson (thompsa@FreeBSD.org) * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/net/usb_ethernet.h b/freebsd/sys/dev/usb/net/usb_ethernet.h index d22e5d9b..c7afc650 100644 --- a/freebsd/sys/dev/usb/net/usb_ethernet.h +++ b/freebsd/sys/dev/usb/net/usb_ethernet.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/quirk/usb_quirk.c b/freebsd/sys/dev/usb/quirk/usb_quirk.c index 3ea3f3c6..8c9e91cb 100644 --- a/freebsd/sys/dev/usb/quirk/usb_quirk.c +++ b/freebsd/sys/dev/usb/quirk/usb_quirk.c @@ -2,6 +2,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved. * Copyright (c) 1998 Lennart Augustsson. All rights reserved. * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. diff --git a/freebsd/sys/dev/usb/quirk/usb_quirk.h b/freebsd/sys/dev/usb/quirk/usb_quirk.h index bb9fe190..e7f2e02f 100644 --- a/freebsd/sys/dev/usb/quirk/usb_quirk.h +++ b/freebsd/sys/dev/usb/quirk/usb_quirk.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/serial/u3g.c b/freebsd/sys/dev/usb/serial/u3g.c index 3582b6d8..0f3933e6 100644 --- a/freebsd/sys/dev/usb/serial/u3g.c +++ b/freebsd/sys/dev/usb/serial/u3g.c @@ -238,6 +238,8 @@ static const STRUCT_USB_HOST_ID u3g_devs[] = { U3G_DEV(DLINK, DWR510, 0), U3G_DEV(DLINK, DWM157_CD, U3GINIT_SCSIEJECT), U3G_DEV(DLINK, DWM157, 0), + U3G_DEV(DLINK, DWM222_CD, U3GINIT_SCSIEJECT), + U3G_DEV(DLINK, DWM222, 0), U3G_DEV(DLINK3, DWM652, 0), U3G_DEV(HP, EV2200, 0), U3G_DEV(HP, HS2300, 0), diff --git a/freebsd/sys/dev/usb/serial/ubsa.c b/freebsd/sys/dev/usb/serial/ubsa.c index 61005fa0..8b6284f0 100644 --- a/freebsd/sys/dev/usb/serial/ubsa.c +++ b/freebsd/sys/dev/usb/serial/ubsa.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD AND BSD-2-Clause-NetBSD + * * Copyright (c) 2002, Alexander Kabaev <kan.FreeBSD.org>. * All rights reserved. * diff --git a/freebsd/sys/dev/usb/serial/ubser.c b/freebsd/sys/dev/usb/serial/ubser.c index 534c5e75..9fdb1d3a 100644 --- a/freebsd/sys/dev/usb/serial/ubser.c +++ b/freebsd/sys/dev/usb/serial/ubser.c @@ -10,6 +10,8 @@ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD AND BSD-2-Clause-NetBSD + * * Copyright (c) 2001-2002, Shunsuke Akiyama <akiyama@jp.FreeBSD.org>. * All rights reserved. * diff --git a/freebsd/sys/dev/usb/serial/uchcom.c b/freebsd/sys/dev/usb/serial/uchcom.c index 3bee03d9..1e741ccd 100644 --- a/freebsd/sys/dev/usb/serial/uchcom.c +++ b/freebsd/sys/dev/usb/serial/uchcom.c @@ -3,6 +3,8 @@ /* $NetBSD: uchcom.c,v 1.1 2007/09/03 17:57:37 tshiozak Exp $ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD AND BSD-2-Clause-NetBSD + * * Copyright (c) 2007, Takanori Watanabe * All rights reserved. * diff --git a/freebsd/sys/dev/usb/serial/ucycom.c b/freebsd/sys/dev/usb/serial/ucycom.c index 6f83d450..1166d36d 100644 --- a/freebsd/sys/dev/usb/serial/ucycom.c +++ b/freebsd/sys/dev/usb/serial/ucycom.c @@ -4,6 +4,8 @@ __FBSDID("$FreeBSD$"); /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2004 Dag-Erling Coïdan Smørgrav * All rights reserved. * diff --git a/freebsd/sys/dev/usb/serial/ufoma.c b/freebsd/sys/dev/usb/serial/ufoma.c index bcd70308..97ffea63 100644 --- a/freebsd/sys/dev/usb/serial/ufoma.c +++ b/freebsd/sys/dev/usb/serial/ufoma.c @@ -6,6 +6,8 @@ __FBSDID("$FreeBSD$"); #define UFOMA_HANDSFREE /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD AND BSD-2-Clause-NetBSD + * * Copyright (c) 2005, Takanori Watanabe * Copyright (c) 2003, M. Warner Losh <imp@FreeBSD.org>. * All rights reserved. diff --git a/freebsd/sys/dev/usb/serial/uftdi.c b/freebsd/sys/dev/usb/serial/uftdi.c index a40ee4f7..d07c055d 100644 --- a/freebsd/sys/dev/usb/serial/uftdi.c +++ b/freebsd/sys/dev/usb/serial/uftdi.c @@ -3,6 +3,8 @@ /* $NetBSD: uftdi.c,v 1.13 2002/09/23 05:51:23 simonb Exp $ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Copyright (c) 2000 The NetBSD Foundation, Inc. * All rights reserved. * diff --git a/freebsd/sys/dev/usb/serial/ugensa.c b/freebsd/sys/dev/usb/serial/ugensa.c index 15f6c9e3..2737227c 100644 --- a/freebsd/sys/dev/usb/serial/ugensa.c +++ b/freebsd/sys/dev/usb/serial/ugensa.c @@ -3,7 +3,9 @@ /* $FreeBSD$ */ /* $NetBSD: ugensa.c,v 1.9.2.1 2007/03/24 14:55:50 yamt Exp $ */ -/* +/*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Copyright (c) 2004, 2005 The NetBSD Foundation, Inc. * All rights reserved. * diff --git a/freebsd/sys/dev/usb/serial/uipaq.c b/freebsd/sys/dev/usb/serial/uipaq.c index b512b0e5..bf746295 100644 --- a/freebsd/sys/dev/usb/serial/uipaq.c +++ b/freebsd/sys/dev/usb/serial/uipaq.c @@ -3,7 +3,9 @@ /* $NetBSD: uipaq.c,v 1.4 2006/11/16 01:33:27 christos Exp $ */ /* $OpenBSD: uipaq.c,v 1.1 2005/06/17 23:50:33 deraadt Exp $ */ -/* +/*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Copyright (c) 2000-2005 The NetBSD Foundation, Inc. * All rights reserved. * diff --git a/freebsd/sys/dev/usb/serial/ulpt.c b/freebsd/sys/dev/usb/serial/ulpt.c index bd2d966a..c966e602 100644 --- a/freebsd/sys/dev/usb/serial/ulpt.c +++ b/freebsd/sys/dev/usb/serial/ulpt.c @@ -6,6 +6,8 @@ __FBSDID("$FreeBSD$"); /* $NetBSD: ulpt.c,v 1.60 2003/10/04 21:19:50 augustss Exp $ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Copyright (c) 1998, 2003 The NetBSD Foundation, Inc. * All rights reserved. * diff --git a/freebsd/sys/dev/usb/serial/umcs.c b/freebsd/sys/dev/usb/serial/umcs.c index 5d803e44..8f083ce3 100644 --- a/freebsd/sys/dev/usb/serial/umcs.c +++ b/freebsd/sys/dev/usb/serial/umcs.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2010 Lev Serebryakov <lev@FreeBSD.org>. * All rights reserved. * diff --git a/freebsd/sys/dev/usb/serial/umcs.h b/freebsd/sys/dev/usb/serial/umcs.h index 8ba57c13..288988c2 100644 --- a/freebsd/sys/dev/usb/serial/umcs.h +++ b/freebsd/sys/dev/usb/serial/umcs.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2010 Lev Serebryakov <lev@FreeBSD.org>. * All rights reserved. * diff --git a/freebsd/sys/dev/usb/serial/umct.c b/freebsd/sys/dev/usb/serial/umct.c index 5c00985d..e6877a36 100644 --- a/freebsd/sys/dev/usb/serial/umct.c +++ b/freebsd/sys/dev/usb/serial/umct.c @@ -4,6 +4,8 @@ __FBSDID("$FreeBSD$"); /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2003 Scott Long * All rights reserved. * diff --git a/freebsd/sys/dev/usb/serial/umodem.c b/freebsd/sys/dev/usb/serial/umodem.c index 2d36f125..c64600c8 100644 --- a/freebsd/sys/dev/usb/serial/umodem.c +++ b/freebsd/sys/dev/usb/serial/umodem.c @@ -6,6 +6,8 @@ __FBSDID("$FreeBSD$"); /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD AND BSD-2-Clause-NetBSD + * * Copyright (c) 2003, M. Warner Losh <imp@FreeBSD.org>. * All rights reserved. * diff --git a/freebsd/sys/dev/usb/serial/uplcom.c b/freebsd/sys/dev/usb/serial/uplcom.c index 7ec41e97..2b90e4d6 100644 --- a/freebsd/sys/dev/usb/serial/uplcom.c +++ b/freebsd/sys/dev/usb/serial/uplcom.c @@ -6,6 +6,8 @@ __FBSDID("$FreeBSD$"); /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD AND BSD-2-Clause-NetBSD + * * Copyright (c) 2001-2003, 2005 Shunsuke Akiyama <akiyama@jp.FreeBSD.org>. * All rights reserved. * diff --git a/freebsd/sys/dev/usb/serial/usb_serial.c b/freebsd/sys/dev/usb/serial/usb_serial.c index eb3adabd..46a18d63 100644 --- a/freebsd/sys/dev/usb/serial/usb_serial.c +++ b/freebsd/sys/dev/usb/serial/usb_serial.c @@ -3,6 +3,8 @@ /* $NetBSD: ucom.c,v 1.40 2001/11/13 06:24:54 lukem Exp $ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD AND BSD-2-Clause-NetBSD + * * Copyright (c) 2001-2003, 2005, 2008 * Shunsuke Akiyama <akiyama@jp.FreeBSD.org>. * All rights reserved. diff --git a/freebsd/sys/dev/usb/serial/usb_serial.h b/freebsd/sys/dev/usb/serial/usb_serial.h index 2c53f445..9a5e043e 100644 --- a/freebsd/sys/dev/usb/serial/usb_serial.h +++ b/freebsd/sys/dev/usb/serial/usb_serial.h @@ -2,6 +2,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD AND BSD-2-Clause-NetBSD + * * Copyright (c) 2001-2002, Shunsuke Akiyama <akiyama@jp.FreeBSD.org>. * All rights reserved. * diff --git a/freebsd/sys/dev/usb/serial/uvisor.c b/freebsd/sys/dev/usb/serial/uvisor.c index c749b415..18db98c7 100644 --- a/freebsd/sys/dev/usb/serial/uvisor.c +++ b/freebsd/sys/dev/usb/serial/uvisor.c @@ -16,6 +16,8 @@ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Copyright (c) 2000 The NetBSD Foundation, Inc. * All rights reserved. * diff --git a/freebsd/sys/dev/usb/serial/uvscom.c b/freebsd/sys/dev/usb/serial/uvscom.c index 04d92a41..f4cc6ee6 100644 --- a/freebsd/sys/dev/usb/serial/uvscom.c +++ b/freebsd/sys/dev/usb/serial/uvscom.c @@ -6,6 +6,8 @@ __FBSDID("$FreeBSD$"); /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001-2003, 2005 Shunsuke Akiyama <akiyama@jp.FreeBSD.org>. * All rights reserved. * diff --git a/freebsd/sys/dev/usb/storage/umass.c b/freebsd/sys/dev/usb/storage/umass.c index c99874e2..6b488cf7 100644 --- a/freebsd/sys/dev/usb/storage/umass.c +++ b/freebsd/sys/dev/usb/storage/umass.c @@ -4,6 +4,8 @@ __FBSDID("$FreeBSD$"); /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1999 MAEKAWA Masahide <bishop@rr.iij4u.or.jp>, * Nick Hibma <n_hibma@FreeBSD.org> * All rights reserved. diff --git a/freebsd/sys/dev/usb/ufm_ioctl.h b/freebsd/sys/dev/usb/ufm_ioctl.h index 5a233883..599d36d4 100644 --- a/freebsd/sys/dev/usb/ufm_ioctl.h +++ b/freebsd/sys/dev/usb/ufm_ioctl.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 M. Warner Losh * All rights reserved. * diff --git a/freebsd/sys/dev/usb/usb.h b/freebsd/sys/dev/usb/usb.h index 95b4f4ac..ff33cf00 100644 --- a/freebsd/sys/dev/usb/usb.h +++ b/freebsd/sys/dev/usb/usb.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved. * Copyright (c) 1998 Lennart Augustsson. All rights reserved. diff --git a/freebsd/sys/dev/usb/usb_bus.h b/freebsd/sys/dev/usb/usb_bus.h index 3ceeb1ef..710436c1 100644 --- a/freebsd/sys/dev/usb/usb_bus.h +++ b/freebsd/sys/dev/usb/usb_bus.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usb_busdma.c b/freebsd/sys/dev/usb/usb_busdma.c index 446e36e6..9a70c687 100644 --- a/freebsd/sys/dev/usb/usb_busdma.c +++ b/freebsd/sys/dev/usb/usb_busdma.c @@ -2,6 +2,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usb_busdma.h b/freebsd/sys/dev/usb/usb_busdma.h index 077bf8b8..d75e67ee 100644 --- a/freebsd/sys/dev/usb/usb_busdma.h +++ b/freebsd/sys/dev/usb/usb_busdma.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usb_cdc.h b/freebsd/sys/dev/usb/usb_cdc.h index 86f35170..d77c24bb 100644 --- a/freebsd/sys/dev/usb/usb_cdc.h +++ b/freebsd/sys/dev/usb/usb_cdc.h @@ -2,6 +2,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Copyright (c) 1998 The NetBSD Foundation, Inc. * All rights reserved. * diff --git a/freebsd/sys/dev/usb/usb_controller.h b/freebsd/sys/dev/usb/usb_controller.h index 6a2f6b03..59139e64 100644 --- a/freebsd/sys/dev/usb/usb_controller.h +++ b/freebsd/sys/dev/usb/usb_controller.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usb_core.c b/freebsd/sys/dev/usb/usb_core.c index 3d9daa26..09bfdb2b 100644 --- a/freebsd/sys/dev/usb/usb_core.c +++ b/freebsd/sys/dev/usb/usb_core.c @@ -2,6 +2,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usb_core.h b/freebsd/sys/dev/usb/usb_core.h index 9f52e65a..01018ca9 100644 --- a/freebsd/sys/dev/usb/usb_core.h +++ b/freebsd/sys/dev/usb/usb_core.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usb_debug.c b/freebsd/sys/dev/usb/usb_debug.c index 000319b1..e3a1474e 100644 --- a/freebsd/sys/dev/usb/usb_debug.c +++ b/freebsd/sys/dev/usb/usb_debug.c @@ -2,6 +2,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usb_debug.h b/freebsd/sys/dev/usb/usb_debug.h index e30f2c2c..87c0dcfe 100644 --- a/freebsd/sys/dev/usb/usb_debug.h +++ b/freebsd/sys/dev/usb/usb_debug.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usb_dev.c b/freebsd/sys/dev/usb/usb_dev.c index b0ad9aaf..2b244d80 100644 --- a/freebsd/sys/dev/usb/usb_dev.c +++ b/freebsd/sys/dev/usb/usb_dev.c @@ -2,6 +2,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2006-2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usb_dev.h b/freebsd/sys/dev/usb/usb_dev.h index f87ba53b..ae851153 100644 --- a/freebsd/sys/dev/usb/usb_dev.h +++ b/freebsd/sys/dev/usb/usb_dev.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usb_device.c b/freebsd/sys/dev/usb/usb_device.c index 6a193a75..861f6029 100644 --- a/freebsd/sys/dev/usb/usb_device.c +++ b/freebsd/sys/dev/usb/usb_device.c @@ -2,6 +2,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usb_device.h b/freebsd/sys/dev/usb/usb_device.h index 22e15606..1cf48ea1 100644 --- a/freebsd/sys/dev/usb/usb_device.h +++ b/freebsd/sys/dev/usb/usb_device.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usb_dynamic.c b/freebsd/sys/dev/usb/usb_dynamic.c index c2ca9af6..9eb835ad 100644 --- a/freebsd/sys/dev/usb/usb_dynamic.c +++ b/freebsd/sys/dev/usb/usb_dynamic.c @@ -2,6 +2,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usb_dynamic.h b/freebsd/sys/dev/usb/usb_dynamic.h index e52c46fb..2d46afc8 100644 --- a/freebsd/sys/dev/usb/usb_dynamic.h +++ b/freebsd/sys/dev/usb/usb_dynamic.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usb_endian.h b/freebsd/sys/dev/usb/usb_endian.h index 0bbcb9bf..59761767 100644 --- a/freebsd/sys/dev/usb/usb_endian.h +++ b/freebsd/sys/dev/usb/usb_endian.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ /* + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usb_error.c b/freebsd/sys/dev/usb/usb_error.c index 2cc49964..2c58c508 100644 --- a/freebsd/sys/dev/usb/usb_error.c +++ b/freebsd/sys/dev/usb/usb_error.c @@ -2,6 +2,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usb_freebsd.h b/freebsd/sys/dev/usb/usb_freebsd.h index bc5d2422..1eff3e14 100644 --- a/freebsd/sys/dev/usb/usb_freebsd.h +++ b/freebsd/sys/dev/usb/usb_freebsd.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usb_generic.c b/freebsd/sys/dev/usb/usb_generic.c index ae14bae3..29a27d53 100644 --- a/freebsd/sys/dev/usb/usb_generic.c +++ b/freebsd/sys/dev/usb/usb_generic.c @@ -2,6 +2,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usb_generic.h b/freebsd/sys/dev/usb/usb_generic.h index 835ec72a..d03f25cd 100644 --- a/freebsd/sys/dev/usb/usb_generic.h +++ b/freebsd/sys/dev/usb/usb_generic.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usb_handle_request.c b/freebsd/sys/dev/usb/usb_handle_request.c index c6b4db32..458d1fc1 100644 --- a/freebsd/sys/dev/usb/usb_handle_request.c +++ b/freebsd/sys/dev/usb/usb_handle_request.c @@ -2,6 +2,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usb_hid.c b/freebsd/sys/dev/usb/usb_hid.c index 5019aa1a..c2d93f3a 100644 --- a/freebsd/sys/dev/usb/usb_hid.c +++ b/freebsd/sys/dev/usb/usb_hid.c @@ -3,6 +3,8 @@ /* $FreeBSD$ */ /* $NetBSD: hid.c,v 1.17 2001/11/13 06:24:53 lukem Exp $ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Copyright (c) 1998 The NetBSD Foundation, Inc. * All rights reserved. * diff --git a/freebsd/sys/dev/usb/usb_hub.c b/freebsd/sys/dev/usb/usb_hub.c index 0eaeeb60..a0ad462f 100644 --- a/freebsd/sys/dev/usb/usb_hub.c +++ b/freebsd/sys/dev/usb/usb_hub.c @@ -2,6 +2,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved. * Copyright (c) 1998 Lennart Augustsson. All rights reserved. * Copyright (c) 2008-2010 Hans Petter Selasky. All rights reserved. diff --git a/freebsd/sys/dev/usb/usb_hub.h b/freebsd/sys/dev/usb/usb_hub.h index 16430d9b..3d4e0837 100644 --- a/freebsd/sys/dev/usb/usb_hub.h +++ b/freebsd/sys/dev/usb/usb_hub.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usb_ioctl.h b/freebsd/sys/dev/usb/usb_ioctl.h index 683f3e61..7cf90649 100644 --- a/freebsd/sys/dev/usb/usb_ioctl.h +++ b/freebsd/sys/dev/usb/usb_ioctl.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved. * Copyright (c) 1998 Lennart Augustsson. All rights reserved. diff --git a/freebsd/sys/dev/usb/usb_lookup.c b/freebsd/sys/dev/usb/usb_lookup.c index 533080ef..6f6a763f 100644 --- a/freebsd/sys/dev/usb/usb_lookup.c +++ b/freebsd/sys/dev/usb/usb_lookup.c @@ -2,6 +2,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usb_mbuf.c b/freebsd/sys/dev/usb/usb_mbuf.c index b1cc3276..62c14264 100644 --- a/freebsd/sys/dev/usb/usb_mbuf.c +++ b/freebsd/sys/dev/usb/usb_mbuf.c @@ -2,6 +2,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usb_mbuf.h b/freebsd/sys/dev/usb/usb_mbuf.h index 3b331ffc..2466e2e4 100644 --- a/freebsd/sys/dev/usb/usb_mbuf.h +++ b/freebsd/sys/dev/usb/usb_mbuf.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usb_msctest.c b/freebsd/sys/dev/usb/usb_msctest.c index f0eede28..d8d11eca 100644 --- a/freebsd/sys/dev/usb/usb_msctest.c +++ b/freebsd/sys/dev/usb/usb_msctest.c @@ -2,6 +2,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008,2011 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usb_msctest.h b/freebsd/sys/dev/usb/usb_msctest.h index d3f26c2b..6b5d3283 100644 --- a/freebsd/sys/dev/usb/usb_msctest.h +++ b/freebsd/sys/dev/usb/usb_msctest.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usb_parse.c b/freebsd/sys/dev/usb/usb_parse.c index 776e1f05..638aaf77 100644 --- a/freebsd/sys/dev/usb/usb_parse.c +++ b/freebsd/sys/dev/usb/usb_parse.c @@ -2,6 +2,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usb_pf.h b/freebsd/sys/dev/usb/usb_pf.h index 29fe6ebd..03f7ba98 100644 --- a/freebsd/sys/dev/usb/usb_pf.h +++ b/freebsd/sys/dev/usb/usb_pf.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1990, 1991, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/dev/usb/usb_process.c b/freebsd/sys/dev/usb/usb_process.c index 88f09804..6c4cc7ad 100644 --- a/freebsd/sys/dev/usb/usb_process.c +++ b/freebsd/sys/dev/usb/usb_process.c @@ -2,6 +2,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usb_process.h b/freebsd/sys/dev/usb/usb_process.h index dd20afd4..7be78917 100644 --- a/freebsd/sys/dev/usb/usb_process.h +++ b/freebsd/sys/dev/usb/usb_process.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usb_request.c b/freebsd/sys/dev/usb/usb_request.c index ef8ed3e6..6be241c2 100644 --- a/freebsd/sys/dev/usb/usb_request.c +++ b/freebsd/sys/dev/usb/usb_request.c @@ -2,6 +2,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved. * Copyright (c) 1998 Lennart Augustsson. All rights reserved. * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. diff --git a/freebsd/sys/dev/usb/usb_request.h b/freebsd/sys/dev/usb/usb_request.h index 9f0a4e64..7c653132 100644 --- a/freebsd/sys/dev/usb/usb_request.h +++ b/freebsd/sys/dev/usb/usb_request.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usb_transfer.c b/freebsd/sys/dev/usb/usb_transfer.c index ee80d9bb..7ea25337 100644 --- a/freebsd/sys/dev/usb/usb_transfer.c +++ b/freebsd/sys/dev/usb/usb_transfer.c @@ -2,6 +2,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usb_transfer.h b/freebsd/sys/dev/usb/usb_transfer.h index f035240b..da632a73 100644 --- a/freebsd/sys/dev/usb/usb_transfer.h +++ b/freebsd/sys/dev/usb/usb_transfer.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usb_util.c b/freebsd/sys/dev/usb/usb_util.c index 4d8c9c56..aa705751 100644 --- a/freebsd/sys/dev/usb/usb_util.c +++ b/freebsd/sys/dev/usb/usb_util.c @@ -2,6 +2,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usb_util.h b/freebsd/sys/dev/usb/usb_util.h index 7e52404f..87e54d35 100644 --- a/freebsd/sys/dev/usb/usb_util.h +++ b/freebsd/sys/dev/usb/usb_util.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usbdi.h b/freebsd/sys/dev/usb/usbdi.h index 6ad3e43e..2be8eef1 100644 --- a/freebsd/sys/dev/usb/usbdi.h +++ b/freebsd/sys/dev/usb/usbdi.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2009 Andrew Thompson * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usbdi_util.h b/freebsd/sys/dev/usb/usbdi_util.h index 1e450f8f..d0ee6f9d 100644 --- a/freebsd/sys/dev/usb/usbdi_util.h +++ b/freebsd/sys/dev/usb/usbdi_util.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2009 Andrew Thompson * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/dev/usb/usbhid.h b/freebsd/sys/dev/usb/usbhid.h index 31aa7ea4..8870e291 100644 --- a/freebsd/sys/dev/usb/usbhid.h +++ b/freebsd/sys/dev/usb/usbhid.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved. * Copyright (c) 1998 Lennart Augustsson. All rights reserved. diff --git a/freebsd/sys/dev/usb/wlan/if_rsu.c b/freebsd/sys/dev/usb/wlan/if_rsu.c index 2415d2f2..179de4e5 100644 --- a/freebsd/sys/dev/usb/wlan/if_rsu.c +++ b/freebsd/sys/dev/usb/wlan/if_rsu.c @@ -73,8 +73,11 @@ __FBSDID("$FreeBSD$"); #include <dev/usb/usbdi.h> #include <rtems/bsd/local/usbdevs.h> +#include <dev/rtwn/if_rtwn_ridx.h> /* XXX */ #include <dev/usb/wlan/if_rsureg.h> +#define RSU_RATE_IS_CCK RTWN_RATE_IS_CCK + #ifdef USB_DEBUG static int rsu_debug = 0; SYSCTL_NODE(_hw_usb, OID_AUTO, rsu, CTLFLAG_RW, 0, "USB rsu"); @@ -2387,44 +2390,6 @@ rsu_rx_frame(struct rsu_softc *sc, struct mbuf *m) rssi = rsu_hwrssi_to_rssi(sc, sc->sc_currssi); } - if (ieee80211_radiotap_active(ic)) { - struct rsu_rx_radiotap_header *tap = &sc->sc_rxtap; - - /* Map HW rate index to 802.11 rate. */ - tap->wr_flags = 0; /* TODO */ - tap->wr_tsft = rsu_get_tsf_high(sc); - if (le32toh(stat->tsf_low) > rsu_get_tsf_low(sc)) - tap->wr_tsft--; - tap->wr_tsft = (uint64_t)htole32(tap->wr_tsft) << 32; - tap->wr_tsft += stat->tsf_low; - - if (rate < 12) { - switch (rate) { - /* CCK. */ - case 0: tap->wr_rate = 2; break; - case 1: tap->wr_rate = 4; break; - case 2: tap->wr_rate = 11; break; - case 3: tap->wr_rate = 22; break; - /* OFDM. */ - case 4: tap->wr_rate = 12; break; - case 5: tap->wr_rate = 18; break; - case 6: tap->wr_rate = 24; break; - case 7: tap->wr_rate = 36; break; - case 8: tap->wr_rate = 48; break; - case 9: tap->wr_rate = 72; break; - case 10: tap->wr_rate = 96; break; - case 11: tap->wr_rate = 108; break; - } - } else { /* MCS0~15. */ - /* Bit 7 set means HT MCS instead of rate. */ - tap->wr_rate = 0x80 | (rate - 12); - } - - tap->wr_dbm_antsignal = rssi; - tap->wr_chan_freq = htole16(ic->ic_curchan->ic_freq); - tap->wr_chan_flags = htole16(ic->ic_curchan->ic_flags); - }; - /* Hardware does Rx TCP checksum offload. */ /* * This flag can be set for some other @@ -2470,65 +2435,34 @@ rsu_rx_frame(struct rsu_softc *sc, struct mbuf *m) rxs.c_nf = -96; /* Rate */ - if (!(rxdw3 & R92S_RXDW3_HTC)) { - switch (rate) { - /* CCK. */ - case 0: - rxs.c_rate = 2; - rxs.c_pktflags |= IEEE80211_RX_F_CCK; - break; - case 1: - rxs.c_rate = 4; - rxs.c_pktflags |= IEEE80211_RX_F_CCK; - break; - case 2: - rxs.c_rate = 11; + if (rate < 12) { + rxs.c_rate = ridx2rate[rate]; + if (RSU_RATE_IS_CCK(rate)) rxs.c_pktflags |= IEEE80211_RX_F_CCK; - break; - case 3: - rxs.c_rate = 22; - rxs.c_pktflags |= IEEE80211_RX_F_CCK; - break; - /* OFDM. */ - case 4: - rxs.c_rate = 12; - rxs.c_pktflags |= IEEE80211_RX_F_OFDM; - break; - case 5: - rxs.c_rate = 18; - rxs.c_pktflags |= IEEE80211_RX_F_OFDM; - break; - case 6: - rxs.c_rate = 24; - rxs.c_pktflags |= IEEE80211_RX_F_OFDM; - break; - case 7: - rxs.c_rate = 36; - rxs.c_pktflags |= IEEE80211_RX_F_OFDM; - break; - case 8: - rxs.c_rate = 48; - rxs.c_pktflags |= IEEE80211_RX_F_OFDM; - break; - case 9: - rxs.c_rate = 72; - rxs.c_pktflags |= IEEE80211_RX_F_OFDM; - break; - case 10: - rxs.c_rate = 96; - rxs.c_pktflags |= IEEE80211_RX_F_OFDM; - break; - case 11: - rxs.c_rate = 108; + else rxs.c_pktflags |= IEEE80211_RX_F_OFDM; - break; - } - } else if (rate >= 12) { /* MCS0~15. */ - /* Bit 7 set means HT MCS instead of rate. */ - rxs.c_rate = (rate - 12); + } else { + rxs.c_rate = IEEE80211_RATE_MCS | (rate - 12); rxs.c_pktflags |= IEEE80211_RX_F_HT; } + if (ieee80211_radiotap_active(ic)) { + struct rsu_rx_radiotap_header *tap = &sc->sc_rxtap; + + /* Map HW rate index to 802.11 rate. */ + tap->wr_flags = 0; /* TODO */ + tap->wr_tsft = rsu_get_tsf_high(sc); + if (le32toh(stat->tsf_low) > rsu_get_tsf_low(sc)) + tap->wr_tsft--; + tap->wr_tsft = (uint64_t)htole32(tap->wr_tsft) << 32; + tap->wr_tsft += stat->tsf_low; + + tap->wr_rate = rxs.c_rate; + tap->wr_dbm_antsignal = rssi; + tap->wr_chan_freq = htole16(ic->ic_curchan->ic_freq); + tap->wr_chan_flags = htole16(ic->ic_curchan->ic_flags); + }; + (void) ieee80211_add_rx_params(m, &rxs); /* Drop descriptor. */ diff --git a/freebsd/sys/dev/usb/wlan/if_uath.c b/freebsd/sys/dev/usb/wlan/if_uath.c index c4ebe5ed..e1aa5ec0 100644 --- a/freebsd/sys/dev/usb/wlan/if_uath.c +++ b/freebsd/sys/dev/usb/wlan/if_uath.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD AND 0BSD + * * Copyright (c) 2006 Sam Leffler, Errno Consulting * Copyright (c) 2008-2009 Weongyo Jeong <weongyo@freebsd.org> * All rights reserved. diff --git a/freebsd/sys/dev/usb/wlan/if_zydfw.h b/freebsd/sys/dev/usb/wlan/if_zydfw.h index 46f5c2ab..f18442e9 100644 --- a/freebsd/sys/dev/usb/wlan/if_zydfw.h +++ b/freebsd/sys/dev/usb/wlan/if_zydfw.h @@ -1,4 +1,6 @@ /* + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 2001, 2002, 2003,2004 ZyDAS Technology Corporation. * All rights reserved. * diff --git a/freebsd/sys/fs/devfs/devfs_int.h b/freebsd/sys/fs/devfs/devfs_int.h index 3a55a52e..e3991cbd 100644 --- a/freebsd/sys/fs/devfs/devfs_int.h +++ b/freebsd/sys/fs/devfs/devfs_int.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2005 Poul-Henning Kamp. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/fs/devfs/devfs_vnops.c b/freebsd/sys/fs/devfs/devfs_vnops.c index fcf69a1a..4a1c0675 100644 --- a/freebsd/sys/fs/devfs/devfs_vnops.c +++ b/freebsd/sys/fs/devfs/devfs_vnops.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2000-2004 * Poul-Henning Kamp. All rights reserved. * Copyright (c) 1989, 1992-1993, 1995 diff --git a/freebsd/sys/h8300/include/machine/in_cksum.h b/freebsd/sys/h8300/include/machine/in_cksum.h index 72edfba9..d55b838b 100644 --- a/freebsd/sys/h8300/include/machine/in_cksum.h +++ b/freebsd/sys/h8300/include/machine/in_cksum.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * diff --git a/freebsd/sys/i386/i386/in_cksum.c b/freebsd/sys/i386/i386/in_cksum.c index 6c8811be..601e82fe 100644 --- a/freebsd/sys/i386/i386/in_cksum.c +++ b/freebsd/sys/i386/i386/in_cksum.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * diff --git a/freebsd/sys/i386/include/machine/_bus.h b/freebsd/sys/i386/include/machine/_bus.h index 49bdd5a3..2f0b8422 100644 --- a/freebsd/sys/i386/include/machine/_bus.h +++ b/freebsd/sys/i386/include/machine/_bus.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2005 M. Warner Losh. * All rights reserved. * diff --git a/freebsd/sys/i386/include/machine/cpufunc.h b/freebsd/sys/i386/include/machine/cpufunc.h index a311cd1d..0147abe9 100644 --- a/freebsd/sys/i386/include/machine/cpufunc.h +++ b/freebsd/sys/i386/include/machine/cpufunc.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1993 The Regents of the University of California. * All rights reserved. * diff --git a/freebsd/sys/i386/include/machine/in_cksum.h b/freebsd/sys/i386/include/machine/in_cksum.h index 8816f3c8..360b324a 100644 --- a/freebsd/sys/i386/include/machine/in_cksum.h +++ b/freebsd/sys/i386/include/machine/in_cksum.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * diff --git a/freebsd/sys/i386/include/machine/intr_machdep.h b/freebsd/sys/i386/include/machine/intr_machdep.h index 5892d07c..06272209 100644 --- a/freebsd/sys/i386/include/machine/intr_machdep.h +++ b/freebsd/sys/i386/include/machine/intr_machdep.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2003 John Baldwin <jhb@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/i386/include/machine/md_var.h b/freebsd/sys/i386/include/machine/md_var.h index 2ca8c856..38d2a828 100644 --- a/freebsd/sys/i386/include/machine/md_var.h +++ b/freebsd/sys/i386/include/machine/md_var.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1995 Bruce D. Evans. * All rights reserved. * @@ -66,6 +68,8 @@ void init_AMD_Elan_sc520(void); vm_paddr_t kvtop(void *addr); void panicifcpuunsupported(void); void ppro_reenable_apic(void); +void set_fsbase(struct thread *td, uint32_t base); +void set_gsbase(struct thread *td, uint32_t base); void setidt(int idx, alias_for_inthand_t *func, int typ, int dpl, int selec); union savefpu *get_pcb_user_save_td(struct thread *td); union savefpu *get_pcb_user_save_pcb(struct pcb *pcb); diff --git a/freebsd/sys/isa/isavar.h b/freebsd/sys/isa/isavar.h index 740a114c..28d13505 100644 --- a/freebsd/sys/isa/isavar.h +++ b/freebsd/sys/isa/isavar.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1998 Doug Rabson * All rights reserved. * diff --git a/freebsd/sys/isa/pnpvar.h b/freebsd/sys/isa/pnpvar.h index 291c8130..1f77b1b2 100644 --- a/freebsd/sys/isa/pnpvar.h +++ b/freebsd/sys/isa/pnpvar.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1999 Doug Rabson * All rights reserved. * diff --git a/freebsd/sys/kern/init_main.c b/freebsd/sys/kern/init_main.c index f211b363..b8961ab6 100644 --- a/freebsd/sys/kern/init_main.c +++ b/freebsd/sys/kern/init_main.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 1995 Terrence R. Lambert * All rights reserved. * @@ -139,6 +141,11 @@ SET_DECLARE(sysinit_set, struct sysinit); struct sysinit **sysinit, **sysinit_end; struct sysinit **newsysinit, **newsysinit_end; +EVENTHANDLER_LIST_DECLARE(process_init); +EVENTHANDLER_LIST_DECLARE(thread_init); +EVENTHANDLER_LIST_DECLARE(process_ctor); +EVENTHANDLER_LIST_DECLARE(thread_ctor); + /* * Merge a new sysinit set into the current set, reallocating it if * necessary. This can only be called after malloc is running. @@ -444,6 +451,10 @@ proc0_init(void *dummy __unused) struct proc *p; struct thread *td; struct ucred *newcred; + struct uidinfo tmpuinfo; + struct loginclass tmplc = { + .lc_name = "", + }; vm_paddr_t pageablemem; int i; @@ -526,10 +537,17 @@ proc0_init(void *dummy __unused) /* Create credentials. */ newcred = crget(); newcred->cr_ngroups = 1; /* group 0 */ + /* A hack to prevent uifind from tripping over NULL pointers. */ + curthread->td_ucred = newcred; + tmpuinfo.ui_uid = 1; + newcred->cr_uidinfo = newcred->cr_ruidinfo = &tmpuinfo; newcred->cr_uidinfo = uifind(0); newcred->cr_ruidinfo = uifind(0); - newcred->cr_prison = &prison0; + newcred->cr_loginclass = &tmplc; newcred->cr_loginclass = loginclass_find("default"); + /* End hack. creds get properly set later with thread_cow_get_proc */ + curthread->td_ucred = NULL; + newcred->cr_prison = &prison0; proc_set_cred_init(p, newcred); #ifdef AUDIT audit_cred_kproc0(newcred); @@ -593,10 +611,10 @@ proc0_init(void *dummy __unused) * Call the init and ctor for the new thread and proc. We wait * to do this until all other structures are fairly sane. */ - EVENTHANDLER_INVOKE(process_init, p); - EVENTHANDLER_INVOKE(thread_init, td); - EVENTHANDLER_INVOKE(process_ctor, p); - EVENTHANDLER_INVOKE(thread_ctor, td); + EVENTHANDLER_DIRECT_INVOKE(process_init, p); + EVENTHANDLER_DIRECT_INVOKE(thread_init, td); + EVENTHANDLER_DIRECT_INVOKE(process_ctor, p); + EVENTHANDLER_DIRECT_INVOKE(thread_ctor, td); /* * Charge root for one process. @@ -803,7 +821,7 @@ start_init(void *dummy) * Otherwise, return via fork_trampoline() all the way * to user mode as init! */ - if ((error = sys_execve(td, &args)) == 0) { + if ((error = sys_execve(td, &args)) == EJUSTRETURN) { mtx_unlock(&Giant); return; } diff --git a/freebsd/sys/kern/kern_condvar.c b/freebsd/sys/kern/kern_condvar.c index 927a722c..399a699e 100644 --- a/freebsd/sys/kern/kern_condvar.c +++ b/freebsd/sys/kern/kern_condvar.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2000 Jake Burkholder <jake@freebsd.org>. * All rights reserved. * diff --git a/freebsd/sys/kern/kern_conf.c b/freebsd/sys/kern/kern_conf.c index 8ad8c7c5..f62e8e4d 100644 --- a/freebsd/sys/kern/kern_conf.c +++ b/freebsd/sys/kern/kern_conf.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1999-2002 Poul-Henning Kamp * All rights reserved. * diff --git a/freebsd/sys/kern/kern_event.c b/freebsd/sys/kern/kern_event.c index 2428182c..905ef23c 100644 --- a/freebsd/sys/kern/kern_event.c +++ b/freebsd/sys/kern/kern_event.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org> * Copyright 2004 John-Mark Gurney <jmg@FreeBSD.org> * Copyright (c) 2009 Apple, Inc. @@ -35,6 +37,10 @@ __FBSDID("$FreeBSD$"); #include <rtems/bsd/local/opt_ktrace.h> #include <rtems/bsd/local/opt_kqueue.h> +#ifdef COMPAT_FREEBSD11 +#define _WANT_FREEBSD11_KEVENT +#endif + #include <sys/param.h> #include <sys/systm.h> #include <sys/capsicum.h> @@ -123,7 +129,7 @@ static void kqueue_fo_release(int filt); struct g_kevent_args; static int kern_kevent_generic(struct thread *td, struct g_kevent_args *uap, - struct kevent_copyops *k_ops); + struct kevent_copyops *k_ops, const char *struct_name); #ifndef __rtems__ static fo_rdwr_t kqueue_read; @@ -444,16 +450,15 @@ filt_procattach(struct knote *kn) bool exiting, immediate; exiting = immediate = false; - p = pfind(kn->kn_id); - if (p == NULL && (kn->kn_sfflags & NOTE_EXIT)) { - p = zpfind(kn->kn_id); - exiting = true; - } else if (p != NULL && (p->p_flag & P_WEXIT)) { - exiting = true; - } - + if (kn->kn_sfflags & NOTE_EXIT) + p = pfind_any(kn->kn_id); + else + p = pfind(kn->kn_id); if (p == NULL) return (ESRCH); + if (p->p_flag & P_WEXIT) + exiting = true; + if ((error = p_cansee(curthread, p))) { PROC_UNLOCK(p); return (error); @@ -987,17 +992,6 @@ kqueue(void) } #endif /* __rtems__ */ -#ifdef KTRACE -static size_t -kev_iovlen(int n, u_int kgio, size_t kevent_size) -{ - - if (n < 0 || n >= kgio / kevent_size) - return (kgio); - return (n * kevent_size); -} -#endif - struct g_kevent_args { int fd; void *changelist; @@ -1034,22 +1028,18 @@ sys_kevent(struct thread *td, struct kevent_args *uap) .timeout = uap->timeout, }; - return (kern_kevent_generic(td, &gk_args, &k_ops)); + return (kern_kevent_generic(td, &gk_args, &k_ops, "kevent")); } static int kern_kevent_generic(struct thread *td, struct g_kevent_args *uap, - struct kevent_copyops *k_ops) + struct kevent_copyops *k_ops, const char *struct_name) { struct timespec ts, *tsp; - int error; #ifdef KTRACE - struct uio ktruio; - struct iovec ktriov; - struct uio *ktruioin = NULL; - struct uio *ktruioout = NULL; - u_int kgio; + struct kevent *eventlist = uap->eventlist; #endif + int error; if (uap->timeout != NULL) { error = copyin(uap->timeout, &ts, sizeof(ts)); @@ -1060,35 +1050,18 @@ kern_kevent_generic(struct thread *td, struct g_kevent_args *uap, tsp = NULL; #ifdef KTRACE - if (KTRPOINT(td, KTR_GENIO)) { - kgio = ktr_geniosize; - ktriov.iov_base = uap->changelist; - ktriov.iov_len = kev_iovlen(uap->nchanges, kgio, - k_ops->kevent_size); - ktruio = (struct uio){ .uio_iov = &ktriov, .uio_iovcnt = 1, - .uio_segflg = UIO_USERSPACE, .uio_rw = UIO_READ, - .uio_td = td }; - ktruioin = cloneuio(&ktruio); - ktriov.iov_base = uap->eventlist; - ktriov.iov_len = kev_iovlen(uap->nevents, kgio, - k_ops->kevent_size); - ktriov.iov_len = uap->nevents * k_ops->kevent_size; - ktruioout = cloneuio(&ktruio); - } + if (KTRPOINT(td, KTR_STRUCT_ARRAY)) + ktrstructarray(struct_name, UIO_USERSPACE, uap->changelist, + uap->nchanges, k_ops->kevent_size); #endif error = kern_kevent(td, uap->fd, uap->nchanges, uap->nevents, k_ops, tsp); #ifdef KTRACE - if (ktruioin != NULL) { - ktruioin->uio_resid = kev_iovlen(uap->nchanges, kgio, - k_ops->kevent_size); - ktrgenio(uap->fd, UIO_WRITE, ktruioin, 0); - ktruioout->uio_resid = kev_iovlen(td->td_retval[0], kgio, - k_ops->kevent_size); - ktrgenio(uap->fd, UIO_READ, ktruioout, error); - } + if (error == 0 && KTRPOINT(td, KTR_STRUCT_ARRAY)) + ktrstructarray(struct_name, UIO_USERSPACE, eventlist, + td->td_retval[0], k_ops->kevent_size); #endif return (error); @@ -1163,15 +1136,6 @@ kevent_copyin(void *arg, struct kevent *kevp, int count) } #ifdef COMPAT_FREEBSD11 -struct kevent_freebsd11 { - __uintptr_t ident; /* identifier for this event */ - short filter; /* filter for event */ - unsigned short flags; - unsigned int fflags; - __intptr_t data; - void *udata; /* opaque user data identifier */ -}; - static int kevent11_copyout(void *arg, struct kevent *kevp, int count) { @@ -1246,7 +1210,7 @@ freebsd11_kevent(struct thread *td, struct freebsd11_kevent_args *uap) .timeout = uap->timeout, }; - return (kern_kevent_generic(td, &gk_args, &k_ops)); + return (kern_kevent_generic(td, &gk_args, &k_ops, "kevent_freebsd11")); } #endif diff --git a/freebsd/sys/kern/kern_hhook.c b/freebsd/sys/kern/kern_hhook.c index af2dcf61..081f97e5 100644 --- a/freebsd/sys/kern/kern_hhook.c +++ b/freebsd/sys/kern/kern_hhook.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2010,2013 Lawrence Stewart <lstewart@freebsd.org> * Copyright (c) 2010 The FreeBSD Foundation * All rights reserved. diff --git a/freebsd/sys/kern/kern_intr.c b/freebsd/sys/kern/kern_intr.c index fbb5a1e9..aa896467 100644 --- a/freebsd/sys/kern/kern_intr.c +++ b/freebsd/sys/kern/kern_intr.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1997, Stefan Esser <se@freebsd.org> * All rights reserved. * diff --git a/freebsd/sys/kern/kern_khelp.c b/freebsd/sys/kern/kern_khelp.c index 7ff76467..6e4673ee 100644 --- a/freebsd/sys/kern/kern_khelp.c +++ b/freebsd/sys/kern/kern_khelp.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2010,2013 Lawrence Stewart <lstewart@freebsd.org> * Copyright (c) 2010 The FreeBSD Foundation * All rights reserved. diff --git a/freebsd/sys/kern/kern_linker.c b/freebsd/sys/kern/kern_linker.c index 1c81a61c..c19071a6 100644 --- a/freebsd/sys/kern/kern_linker.c +++ b/freebsd/sys/kern/kern_linker.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1997-2000 Doug Rabson * All rights reserved. * @@ -293,7 +295,7 @@ linker_file_sysuninit(linker_file_t lf) } static void -linker_file_register_sysctls(linker_file_t lf) +linker_file_register_sysctls(linker_file_t lf, bool enable) { struct sysctl_oid **start, **stop, **oidp; @@ -308,8 +310,34 @@ linker_file_register_sysctls(linker_file_t lf) sx_xunlock(&kld_sx); sysctl_wlock(); + for (oidp = start; oidp < stop; oidp++) { + if (enable) + sysctl_register_oid(*oidp); + else + sysctl_register_disabled_oid(*oidp); + } + sysctl_wunlock(); + sx_xlock(&kld_sx); +} + +static void +linker_file_enable_sysctls(linker_file_t lf) +{ + struct sysctl_oid **start, **stop, **oidp; + + KLD_DPF(FILE, + ("linker_file_enable_sysctls: enable SYSCTLs for %s\n", + lf->filename)); + + sx_assert(&kld_sx, SA_XLOCKED); + + if (linker_file_lookup_set(lf, "sysctl_set", &start, &stop, NULL) != 0) + return; + + sx_xunlock(&kld_sx); + sysctl_wlock(); for (oidp = start; oidp < stop; oidp++) - sysctl_register_oid(*oidp); + sysctl_enable_oid(*oidp); sysctl_wunlock(); sx_xlock(&kld_sx); } @@ -446,7 +474,7 @@ linker_load_file(const char *filename, linker_file_t *result) return (error); } modules = !TAILQ_EMPTY(&lf->modules); - linker_file_register_sysctls(lf); + linker_file_register_sysctls(lf, false); linker_file_sysinit(lf); lf->flags |= LINKER_FILE_LINKED; @@ -459,6 +487,7 @@ linker_load_file(const char *filename, linker_file_t *result) linker_file_unload(lf, LINKER_UNLOAD_FORCE); return (ENOEXEC); } + linker_file_enable_sysctls(lf); EVENTHANDLER_INVOKE(kld_load, lf); *result = lf; return (0); @@ -708,8 +737,8 @@ linker_file_unload(linker_file_t file, int flags) */ if (file->flags & LINKER_FILE_LINKED) { file->flags &= ~LINKER_FILE_LINKED; - linker_file_sysuninit(file); linker_file_unregister_sysctls(file); + linker_file_sysuninit(file); } TAILQ_REMOVE(&linker_files, file, link); @@ -1218,7 +1247,7 @@ out: int sys_kldstat(struct thread *td, struct kldstat_args *uap) { - struct kld_file_stat stat; + struct kld_file_stat *stat; int error, version; /* @@ -1231,10 +1260,12 @@ sys_kldstat(struct thread *td, struct kldstat_args *uap) version != sizeof(struct kld_file_stat)) return (EINVAL); - error = kern_kldstat(td, uap->fileid, &stat); - if (error != 0) - return (error); - return (copyout(&stat, uap->stat, version)); + stat = malloc(sizeof(*stat), M_TEMP, M_WAITOK | M_ZERO); + error = kern_kldstat(td, uap->fileid, stat); + if (error == 0) + error = copyout(stat, uap->stat, version); + free(stat, M_TEMP); + return (error); } int @@ -1658,7 +1689,7 @@ restart: if (linker_file_lookup_set(lf, "sysinit_set", &si_start, &si_stop, NULL) == 0) sysinit_add(si_start, si_stop); - linker_file_register_sysctls(lf); + linker_file_register_sysctls(lf, true); lf->flags |= LINKER_FILE_LINKED; continue; fail: diff --git a/freebsd/sys/kern/kern_mbuf.c b/freebsd/sys/kern/kern_mbuf.c index 472e0894..0f46259a 100644 --- a/freebsd/sys/kern/kern_mbuf.c +++ b/freebsd/sys/kern/kern_mbuf.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2004, 2005, * Bosko Milekic <bmilekic@FreeBSD.org>. All rights reserved. * @@ -522,7 +524,7 @@ mb_ctor_clust(void *mem, int size, void *arg, int how) #endif m = (struct mbuf *)arg; if (m != NULL) { - m->m_ext.ext_buf = (caddr_t)mem; + m->m_ext.ext_buf = (char *)mem; m->m_data = m->m_ext.ext_buf; m->m_flags |= M_EXT; m->m_ext.ext_free = NULL; @@ -694,29 +696,19 @@ mb_free_ext(struct mbuf *m) break; #ifndef __rtems__ case EXT_SFBUF: - sf_ext_free(m->m_ext.ext_arg1, m->m_ext.ext_arg2); - uma_zfree(zone_mbuf, mref); - break; - case EXT_SFBUF_NOCACHE: - sf_ext_free_nocache(m->m_ext.ext_arg1, - m->m_ext.ext_arg2); - uma_zfree(zone_mbuf, mref); - break; #endif /* __rtems__ */ case EXT_NET_DRV: case EXT_MOD_TYPE: case EXT_DISPOSABLE: - KASSERT(m->m_ext.ext_free != NULL, + KASSERT(mref->m_ext.ext_free != NULL, ("%s: ext_free not set", __func__)); - (*(m->m_ext.ext_free))(m, m->m_ext.ext_arg1, - m->m_ext.ext_arg2); + mref->m_ext.ext_free(mref); uma_zfree(zone_mbuf, mref); break; case EXT_EXTREF: KASSERT(m->m_ext.ext_free != NULL, ("%s: ext_free not set", __func__)); - (*(m->m_ext.ext_free))(m, m->m_ext.ext_arg1, - m->m_ext.ext_arg2); + m->m_ext.ext_free(m); break; default: KASSERT(m->m_ext.ext_type == 0, @@ -938,9 +930,8 @@ m_getm2(struct mbuf *m, int len, int how, short type, int flags) * Nothing. */ void -m_extadd(struct mbuf *mb, caddr_t buf, u_int size, - void (*freef)(struct mbuf *, void *, void *), void *arg1, void *arg2, - int flags, int type) +m_extadd(struct mbuf *mb, char *buf, u_int size, m_ext_free_t freef, + void *arg1, void *arg2, int flags, int type) { KASSERT(type != EXT_CLUSTER, ("%s: EXT_CLUSTER not allowed", __func__)); diff --git a/freebsd/sys/kern/kern_mib.c b/freebsd/sys/kern/kern_mib.c index 1f867dd4..4f520ef3 100644 --- a/freebsd/sys/kern/kern_mib.c +++ b/freebsd/sys/kern/kern_mib.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1989, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/kern/kern_module.c b/freebsd/sys/kern/kern_module.c index 28aa8b20..58a2f83a 100644 --- a/freebsd/sys/kern/kern_module.c +++ b/freebsd/sys/kern/kern_module.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1997 Doug Rabson * All rights reserved. * diff --git a/freebsd/sys/kern/kern_mtxpool.c b/freebsd/sys/kern/kern_mtxpool.c index 4b0329b0..7f6c4dce 100644 --- a/freebsd/sys/kern/kern_mtxpool.c +++ b/freebsd/sys/kern/kern_mtxpool.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 Matthew Dillon. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/kern/kern_osd.c b/freebsd/sys/kern/kern_osd.c index 96e7e5fd..b7fc945a 100644 --- a/freebsd/sys/kern/kern_osd.c +++ b/freebsd/sys/kern/kern_osd.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007 Pawel Jakub Dawidek <pjd@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/kern/kern_synch.c b/freebsd/sys/kern/kern_synch.c index 3dfa4164..d96954c7 100644 --- a/freebsd/sys/kern/kern_synch.c +++ b/freebsd/sys/kern/kern_synch.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1990, 1991, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. diff --git a/freebsd/sys/kern/kern_sysctl.c b/freebsd/sys/kern/kern_sysctl.c index e99a8bd6..02078a32 100644 --- a/freebsd/sys/kern/kern_sysctl.c +++ b/freebsd/sys/kern/kern_sysctl.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1989, 1993 * The Regents of the University of California. All rights reserved. * @@ -516,6 +518,37 @@ retry: } void +sysctl_register_disabled_oid(struct sysctl_oid *oidp) +{ + + /* + * Mark the leaf as dormant if it's not to be immediately enabled. + * We do not disable nodes as they can be shared between modules + * and it is always safe to access a node. + */ + KASSERT((oidp->oid_kind & CTLFLAG_DORMANT) == 0, + ("internal flag is set in oid_kind")); + if ((oidp->oid_kind & CTLTYPE) != CTLTYPE_NODE) + oidp->oid_kind |= CTLFLAG_DORMANT; + sysctl_register_oid(oidp); +} + +void +sysctl_enable_oid(struct sysctl_oid *oidp) +{ + + SYSCTL_ASSERT_WLOCKED(); + if ((oidp->oid_kind & CTLTYPE) == CTLTYPE_NODE) { + KASSERT((oidp->oid_kind & CTLFLAG_DORMANT) == 0, + ("sysctl node is marked as dormant")); + return; + } + KASSERT((oidp->oid_kind & CTLFLAG_DORMANT) != 0, + ("enabling already enabled sysctl oid")); + oidp->oid_kind &= ~CTLFLAG_DORMANT; +} + +void sysctl_unregister_oid(struct sysctl_oid *oidp) { struct sysctl_oid *p; @@ -1063,7 +1096,7 @@ sysctl_sysctl_next_ls(struct sysctl_oid_list *lsp, int *name, u_int namelen, *next = oidp->oid_number; *oidpp = oidp; - if (oidp->oid_kind & CTLFLAG_SKIP) + if ((oidp->oid_kind & (CTLFLAG_SKIP | CTLFLAG_DORMANT)) != 0) continue; if (!namelen) { @@ -1184,17 +1217,21 @@ sysctl_sysctl_name2oid(SYSCTL_HANDLER_ARGS) int error, oid[CTL_MAXNAME], len = 0; struct sysctl_oid *op = NULL; struct rm_priotracker tracker; + char buf[32]; if (!req->newlen) return (ENOENT); if (req->newlen >= MAXPATHLEN) /* XXX arbitrary, undocumented */ return (ENAMETOOLONG); - p = malloc(req->newlen+1, M_SYSCTL, M_WAITOK); + p = buf; + if (req->newlen >= sizeof(buf)) + p = malloc(req->newlen+1, M_SYSCTL, M_WAITOK); error = SYSCTL_IN(req, p, req->newlen); if (error) { - free(p, M_SYSCTL); + if (p != buf) + free(p, M_SYSCTL); return (error); } @@ -1204,7 +1241,8 @@ sysctl_sysctl_name2oid(SYSCTL_HANDLER_ARGS) error = name2oid(p, oid, &len, &op); SYSCTL_RUNLOCK(&tracker); - free(p, M_SYSCTL); + if (p != buf) + free(p, M_SYSCTL); if (error) return (error); @@ -1902,6 +1940,8 @@ sysctl_find_oid(int *name, u_int namelen, struct sysctl_oid **noid, } lsp = SYSCTL_CHILDREN(oid); } else if (indx == namelen) { + if ((oid->oid_kind & CTLFLAG_DORMANT) != 0) + return (ENOENT); *noid = oid; if (nindx != NULL) *nindx = indx; @@ -2105,12 +2145,11 @@ userland_sysctl(struct thread *td, int *name, u_int namelen, void *old, if (KTRPOINT(curthread, KTR_SYSCTL)) ktrsysctl(name, namelen); #endif - - if (req.oldptr && req.oldlen > PAGE_SIZE) { + memlocked = 0; + if (req.oldptr && req.oldlen > 4 * PAGE_SIZE) { memlocked = 1; sx_xlock(&sysctlmemlock); - } else - memlocked = 0; + } CURVNET_SET(TD_TO_VNET(td)); for (;;) { diff --git a/freebsd/sys/kern/kern_time.c b/freebsd/sys/kern/kern_time.c index 6e394310..61dc7c73 100644 --- a/freebsd/sys/kern/kern_time.c +++ b/freebsd/sys/kern/kern_time.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1989, 1993 * The Regents of the University of California. All rights reserved. * @@ -418,7 +420,7 @@ kern_clock_settime(struct thread *td, clockid_t clock_id, struct timespec *ats) if (ats->tv_nsec < 0 || ats->tv_nsec >= 1000000000 || ats->tv_sec < 0) return (EINVAL); - if (!allow_insane_settime && ats->tv_sec > 9999ULL * 366 * 24 * 60 * 60) + if (!allow_insane_settime && ats->tv_sec > 8000ULL * 365 * 24 * 60 * 60) return (EINVAL); /* XXX Don't convert nsec->usec and back */ TIMESPEC_TO_TIMEVAL(&atv, ats); diff --git a/freebsd/sys/kern/kern_timeout.c b/freebsd/sys/kern/kern_timeout.c index e1f6209d..d33c158a 100644 --- a/freebsd/sys/kern/kern_timeout.c +++ b/freebsd/sys/kern/kern_timeout.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1991, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. @@ -300,7 +302,7 @@ cc_cce_migrating(struct callout_cpu *cc, int direct) /* * Kernel low level callwheel initialization - * called on cpu0 during kernel startup. + * called on the BSP during kernel startup. */ #ifdef __rtems__ static void rtems_bsd_timeout_init_early(void *); @@ -357,7 +359,7 @@ callout_callwheel_init(void *dummy) * XXX: Clip callout to result of previous function of maxusers * maximum 384. This is still huge, but acceptable. */ - memset(CC_CPU(0), 0, sizeof(cc_cpu)); + memset(CC_CPU(curcpu), 0, sizeof(cc_cpu)); #ifndef __rtems__ ncallout = imin(16 + maxproc + maxfiles, 18508); TUNABLE_INT_FETCH("kern.ncallout", &ncallout); @@ -381,7 +383,7 @@ callout_callwheel_init(void *dummy) #endif /* __rtems__ */ /* - * Only cpu0 handles timeout(9) and receives a preallocation. + * Only BSP handles timeout(9) and receives a preallocation. * * XXX: Once all timeout(9) consumers are converted this can * be removed. @@ -427,7 +429,7 @@ callout_cpu_init(struct callout_cpu *cc, int cpu) snprintf(cc->cc_ktr_event_name, sizeof(cc->cc_ktr_event_name), "callwheel cpu %d", cpu); #ifndef __rtems__ - if (cc->cc_callout == NULL) /* Only cpu0 handles timeout(9) */ + if (cc->cc_callout == NULL) /* Only BSP handles timeout(9) */ return; #endif /* __rtems__ */ for (i = 0; i < ncallout; i++) { @@ -499,7 +501,7 @@ start_softclock(void *dummy) if (cpu == timeout_cpu) continue; cc = CC_CPU(cpu); - cc->cc_callout = NULL; /* Only cpu0 handles timeout(9). */ + cc->cc_callout = NULL; /* Only BSP handles timeout(9). */ callout_cpu_init(cc, cpu); snprintf(name, sizeof(name), "clock (%d)", cpu); ie = NULL; diff --git a/freebsd/sys/kern/kern_uuid.c b/freebsd/sys/kern/kern_uuid.c index 1ac19685..80290ccc 100644 --- a/freebsd/sys/kern/kern_uuid.c +++ b/freebsd/sys/kern/kern_uuid.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2002 Marcel Moolenaar * All rights reserved. * diff --git a/freebsd/sys/kern/subr_blist.c b/freebsd/sys/kern/subr_blist.c index 7f232e93..a7d78d86 100644 --- a/freebsd/sys/kern/subr_blist.c +++ b/freebsd/sys/kern/subr_blist.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1998 Matthew Dillon. All Rights Reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -110,6 +112,7 @@ __FBSDID("$FreeBSD$"); #include <sys/sbuf.h> #include <stdio.h> #include <string.h> +#include <stddef.h> #include <stdlib.h> #include <stdarg.h> #include <stdbool.h> @@ -139,7 +142,6 @@ static void blst_copy(blmeta_t *scan, daddr_t blk, daddr_t radix, static daddr_t blst_leaf_fill(blmeta_t *scan, daddr_t blk, int count); static daddr_t blst_meta_fill(blmeta_t *scan, daddr_t allocBlk, daddr_t count, u_daddr_t radix); -static daddr_t blst_radix_init(blmeta_t *scan, daddr_t radix, daddr_t count); #ifndef _KERNEL static void blst_radix_print(blmeta_t *scan, daddr_t blk, daddr_t radix, int tab); @@ -220,30 +222,70 @@ blist_t blist_create(daddr_t blocks, int flags) { blist_t bl; - daddr_t nodes, radix; + daddr_t i, last_block; + u_daddr_t nodes, radix, skip; + int digit; /* - * Calculate the radix field used for scanning. + * Calculate the radix and node count used for scanning. Find the last + * block that is followed by a terminator. */ + last_block = blocks - 1; radix = BLIST_BMAP_RADIX; while (radix < blocks) { + if (((last_block / radix + 1) & BLIST_META_MASK) != 0) + /* + * A terminator will be added. Update last_block to the + * position just before that terminator. + */ + last_block |= radix - 1; radix *= BLIST_META_RADIX; } - nodes = 1 + blst_radix_init(NULL, radix, blocks); - bl = malloc(sizeof(struct blist), M_SWAP, flags); + /* + * Count the meta-nodes in the expanded tree, including the final + * terminator, from the bottom level up to the root. + */ + nodes = (last_block >= blocks) ? 2 : 1; + last_block /= BLIST_BMAP_RADIX; + while (last_block > 0) { + nodes += last_block + 1; + last_block /= BLIST_META_RADIX; + } + bl = malloc(offsetof(struct blist, bl_root[nodes]), M_SWAP, flags | + M_ZERO); if (bl == NULL) return (NULL); bl->bl_blocks = blocks; bl->bl_radix = radix; bl->bl_cursor = 0; - bl->bl_root = malloc(nodes * sizeof(blmeta_t), M_SWAP, flags); - if (bl->bl_root == NULL) { - free(bl, M_SWAP); - return (NULL); + + /* + * Initialize the empty tree by filling in root values, then initialize + * just the terminators in the rest of the tree. + */ + bl->bl_root[0].bm_bighint = 0; + if (radix == BLIST_BMAP_RADIX) + bl->bl_root[0].u.bmu_bitmap = 0; + else + bl->bl_root[0].u.bmu_avail = 0; + last_block = blocks - 1; + i = 0; + while (radix > BLIST_BMAP_RADIX) { + radix /= BLIST_META_RADIX; + skip = radix_to_skip(radix); + digit = last_block / radix; + i += 1 + digit * skip; + if (digit != BLIST_META_MASK) { + /* + * Add a terminator. + */ + bl->bl_root[i + skip].bm_bighint = (daddr_t)-1; + bl->bl_root[i + skip].u.bmu_bitmap = 0; + } + last_block %= radix; } - blst_radix_init(bl->bl_root, radix, blocks); #if defined(BLIST_DEBUG) printf( @@ -263,7 +305,7 @@ blist_create(daddr_t blocks, int flags) void blist_destroy(blist_t bl) { - free(bl->bl_root, M_SWAP); + free(bl, M_SWAP); } @@ -1074,83 +1116,6 @@ blst_meta_fill(blmeta_t *scan, daddr_t allocBlk, daddr_t count, u_daddr_t radix) return (nblks); } -/* - * BLST_RADIX_INIT() - initialize radix tree - * - * Initialize our meta structures and bitmaps and calculate the exact - * amount of space required to manage 'count' blocks - this space may - * be considerably less than the calculated radix due to the large - * RADIX values we use. - */ -static daddr_t -blst_radix_init(blmeta_t *scan, daddr_t radix, daddr_t count) -{ - daddr_t i, memindex, next_skip, skip; - - memindex = 0; - - /* - * Leaf node - */ - - if (radix == BLIST_BMAP_RADIX) { - if (scan) { - scan->bm_bighint = 0; - scan->u.bmu_bitmap = 0; - } - return (memindex); - } - - /* - * Meta node. If allocating the entire object we can special - * case it. However, we need to figure out how much memory - * is required to manage 'count' blocks, so we continue on anyway. - */ - - if (scan) { - scan->bm_bighint = 0; - scan->u.bmu_avail = 0; - } - - skip = radix_to_skip(radix); - next_skip = skip / BLIST_META_RADIX; - radix /= BLIST_META_RADIX; - - for (i = 1; i < skip; i += next_skip) { - if (count >= radix) { - /* - * Allocate the entire object - */ - memindex = i + - blst_radix_init(((scan) ? &scan[i] : NULL), radix, - radix); - count -= radix; - } else if (count > 0) { - /* - * Allocate a partial object - */ - memindex = i + - blst_radix_init(((scan) ? &scan[i] : NULL), radix, - count); - count = 0; - } else { - /* - * Add terminator and break out. Make terminator bitmap - * zero to avoid a spanning leaf allocation that - * includes the terminator. - */ - if (scan) { - scan[i].bm_bighint = (daddr_t)-1; - scan[i].u.bmu_bitmap = 0; - } - break; - } - } - if (memindex < i) - memindex = i; - return (memindex); -} - #ifdef BLIST_DEBUG static void diff --git a/freebsd/sys/kern/subr_bufring.c b/freebsd/sys/kern/subr_bufring.c index 00b3a10a..30294de2 100644 --- a/freebsd/sys/kern/subr_bufring.c +++ b/freebsd/sys/kern/subr_bufring.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007, 2008 Kip Macy <kmacy@freebsd.org> * All rights reserved. * diff --git a/freebsd/sys/kern/subr_bus.c b/freebsd/sys/kern/subr_bus.c index fdc47ab5..09a459aa 100644 --- a/freebsd/sys/kern/subr_bus.c +++ b/freebsd/sys/kern/subr_bus.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1997,1998,2003 Doug Rabson * All rights reserved. * @@ -2977,6 +2979,9 @@ device_attach(device_t dev) else dev->state = DS_ATTACHED; dev->flags &= ~DF_DONENOMATCH; +#ifndef __rtems__ + EVENTHANDLER_INVOKE(device_attach, dev); +#endif /* __rtems__ */ devadded(dev); return (0); } @@ -3010,8 +3015,19 @@ device_detach(device_t dev) if (dev->state != DS_ATTACHED) return (0); - if ((error = DEVICE_DETACH(dev)) != 0) +#ifndef __rtems__ + EVENTHANDLER_INVOKE(device_detach, dev, EVHDEV_DETACH_BEGIN); +#endif /* __rtems__ */ + if ((error = DEVICE_DETACH(dev)) != 0) { +#ifndef __rtems__ + EVENTHANDLER_INVOKE(device_detach, dev, EVHDEV_DETACH_FAILED); +#endif /* __rtems__ */ return (error); + } else { +#ifndef __rtems__ + EVENTHANDLER_INVOKE(device_detach, dev, EVHDEV_DETACH_COMPLETE); +#endif /* __rtems__ */ + } devremoved(dev); if (!device_is_quiet(dev)) device_printf(dev, "detached\n"); diff --git a/freebsd/sys/kern/subr_counter.c b/freebsd/sys/kern/subr_counter.c index 685f5332..e4c98fae 100644 --- a/freebsd/sys/kern/subr_counter.c +++ b/freebsd/sys/kern/subr_counter.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2012 Gleb Smirnoff <glebius@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/kern/subr_eventhandler.c b/freebsd/sys/kern/subr_eventhandler.c index c373a7f2..92cd9726 100644 --- a/freebsd/sys/kern/subr_eventhandler.c +++ b/freebsd/sys/kern/subr_eventhandler.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1999 Michael Smith <msmith@freebsd.org> * All rights reserved. * @@ -40,7 +42,7 @@ __FBSDID("$FreeBSD$"); static MALLOC_DEFINE(M_EVENTHANDLER, "eventhandler", "Event handler records"); -/* List of 'slow' lists */ +/* List of all eventhandler lists */ static TAILQ_HEAD(, eventhandler_list) eventhandler_lists; static int eventhandler_lists_initted = 0; static struct mtx eventhandler_mutex; @@ -66,25 +68,11 @@ eventhandler_init(void *dummy __unused) SYSINIT(eventhandlers, SI_SUB_EVENTHANDLER, SI_ORDER_FIRST, eventhandler_init, NULL); -/* - * Insertion is O(n) due to the priority scan, but optimises to O(1) - * if all priorities are identical. - */ -static eventhandler_tag -eventhandler_register_internal(struct eventhandler_list *list, - const char *name, eventhandler_tag epn) +static struct eventhandler_list * +eventhandler_find_or_create_list(const char *name) { - struct eventhandler_list *new_list; - struct eventhandler_entry *ep; - - KASSERT(eventhandler_lists_initted, ("eventhandler registered too early")); - KASSERT(epn != NULL, ("%s: cannot register NULL event", __func__)); - - /* lock the eventhandler lists */ - mtx_lock(&eventhandler_mutex); + struct eventhandler_list *list, *new_list; - /* Do we need to find/create the (slow) list? */ - if (list == NULL) { /* look for a matching, existing list */ list = _eventhandler_find_list(name); @@ -92,8 +80,8 @@ eventhandler_register_internal(struct eventhandler_list *list, if (list == NULL) { mtx_unlock(&eventhandler_mutex); - new_list = malloc(sizeof(struct eventhandler_list) + - strlen(name) + 1, M_EVENTHANDLER, M_WAITOK); + new_list = malloc(sizeof(*new_list) + strlen(name) + 1, + M_EVENTHANDLER, M_WAITOK | M_ZERO); /* If someone else created it already, then use that one. */ mtx_lock(&eventhandler_mutex); @@ -103,21 +91,35 @@ eventhandler_register_internal(struct eventhandler_list *list, } else { CTR2(KTR_EVH, "%s: creating list \"%s\"", __func__, name); list = new_list; - list->el_flags = 0; - list->el_runcount = 0; - bzero(&list->el_lock, sizeof(list->el_lock)); - list->el_name = (char *)list + sizeof(struct eventhandler_list); + TAILQ_INIT(&list->el_entries); + mtx_init(&list->el_lock, name, "eventhandler list", MTX_DEF); + list->el_name = (char *)(list + 1); strcpy(list->el_name, name); TAILQ_INSERT_HEAD(&eventhandler_lists, list, el_link); } } + return (list); +} + +/* + * Insertion is O(n) due to the priority scan, but optimises to O(1) + * if all priorities are identical. + */ +static eventhandler_tag +eventhandler_register_internal(struct eventhandler_list *list, + const char *name, eventhandler_tag epn) +{ + struct eventhandler_entry *ep; + + KASSERT(eventhandler_lists_initted, ("eventhandler registered too early")); + KASSERT(epn != NULL, ("%s: cannot register NULL event", __func__)); + + /* Do we need to find/create the list? */ + if (list == NULL) { + mtx_lock(&eventhandler_mutex); + list = eventhandler_find_or_create_list(name); + mtx_unlock(&eventhandler_mutex); } - if (!(list->el_flags & EHL_INITTED)) { - TAILQ_INIT(&list->el_entries); - mtx_init(&list->el_lock, name, "eventhandler list", MTX_DEF); - atomic_store_rel_int(&list->el_flags, EHL_INITTED); - } - mtx_unlock(&eventhandler_mutex); KASSERT(epn->ee_priority != EHE_DEAD_PRIORITY, ("%s: handler for %s registered with dead priority", __func__, name)); @@ -182,8 +184,9 @@ vimage_eventhandler_register(struct eventhandler_list *list, const char *name, } #endif -void -eventhandler_deregister(struct eventhandler_list *list, eventhandler_tag tag) +static void +_eventhandler_deregister(struct eventhandler_list *list, eventhandler_tag tag, + bool wait) { struct eventhandler_entry *ep = tag; @@ -217,11 +220,26 @@ eventhandler_deregister(struct eventhandler_list *list, eventhandler_tag tag) ep->ee_priority = EHE_DEAD_PRIORITY; } } - while (list->el_runcount > 0) + while (wait && list->el_runcount > 0) mtx_sleep(list, &list->el_lock, 0, "evhrm", 0); EHL_UNLOCK(list); } +void +eventhandler_deregister(struct eventhandler_list *list, eventhandler_tag tag) +{ + + _eventhandler_deregister(list, tag, true); +} + +void +eventhandler_deregister_nowait(struct eventhandler_list *list, + eventhandler_tag tag) +{ + + _eventhandler_deregister(list, tag, false); +} + /* * Internal version for use when eventhandler list is already locked. */ @@ -280,3 +298,22 @@ eventhandler_prune_list(struct eventhandler_list *list) if (pruned > 0) wakeup(list); } + +/* + * Create (or get the existing) list so the pointer can be stored by + * EVENTHANDLER_LIST_DEFINE. + */ +struct eventhandler_list * +eventhandler_create_list(const char *name) +{ + struct eventhandler_list *list; + + KASSERT(eventhandler_lists_initted, + ("eventhandler list created too early")); + + mtx_lock(&eventhandler_mutex); + list = eventhandler_find_or_create_list(name); + mtx_unlock(&eventhandler_mutex); + + return (list); +} diff --git a/freebsd/sys/kern/subr_firmware.c b/freebsd/sys/kern/subr_firmware.c index f08a8692..cc8bb691 100644 --- a/freebsd/sys/kern/subr_firmware.c +++ b/freebsd/sys/kern/subr_firmware.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2005-2008, Sam Leffler <sam@errno.com> * All rights reserved. * diff --git a/freebsd/sys/kern/subr_hash.c b/freebsd/sys/kern/subr_hash.c index 193ad1be..488d8bcd 100644 --- a/freebsd/sys/kern/subr_hash.c +++ b/freebsd/sys/kern/subr_hash.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1991, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. diff --git a/freebsd/sys/kern/subr_hints.c b/freebsd/sys/kern/subr_hints.c index b19379c4..982059c3 100644 --- a/freebsd/sys/kern/subr_hints.c +++ b/freebsd/sys/kern/subr_hints.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2000,2001 Peter Wemm <peter@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/kern/subr_kobj.c b/freebsd/sys/kern/subr_kobj.c index 7436535e..a6a888d5 100644 --- a/freebsd/sys/kern/subr_kobj.c +++ b/freebsd/sys/kern/subr_kobj.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2000,2003 Doug Rabson * All rights reserved. * diff --git a/freebsd/sys/kern/subr_lock.c b/freebsd/sys/kern/subr_lock.c index 28991a9f..4f577b65 100644 --- a/freebsd/sys/kern/subr_lock.c +++ b/freebsd/sys/kern/subr_lock.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2006 John Baldwin <jhb@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/kern/subr_module.c b/freebsd/sys/kern/subr_module.c index 09cc3560..d8d42653 100644 --- a/freebsd/sys/kern/subr_module.c +++ b/freebsd/sys/kern/subr_module.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1998 Michael Smith * All rights reserved. * diff --git a/freebsd/sys/kern/subr_pcpu.c b/freebsd/sys/kern/subr_pcpu.c index 076c302c..1d230b68 100644 --- a/freebsd/sys/kern/subr_pcpu.c +++ b/freebsd/sys/kern/subr_pcpu.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001 Wind River Systems, Inc. * All rights reserved. * Written by: John Baldwin <jhb@FreeBSD.org> @@ -412,7 +414,7 @@ DB_SHOW_ALL_COMMAND(pcpu, db_show_cpu_all) int id; db_printf("Current CPU: %d\n\n", PCPU_GET(cpuid)); - for (id = 0; id <= mp_maxid; id++) { + CPU_FOREACH(id) { pc = pcpu_find(id); if (pc != NULL) { show_pcpu(pc); diff --git a/freebsd/sys/kern/subr_prf.c b/freebsd/sys/kern/subr_prf.c index 0380cfec..0405b369 100644 --- a/freebsd/sys/kern/subr_prf.c +++ b/freebsd/sys/kern/subr_prf.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1986, 1988, 1991, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. diff --git a/freebsd/sys/kern/subr_sbuf.c b/freebsd/sys/kern/subr_sbuf.c index 951cb50c..b51ed52c 100644 --- a/freebsd/sys/kern/subr_sbuf.c +++ b/freebsd/sys/kern/subr_sbuf.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2000-2008 Poul-Henning Kamp * Copyright (c) 2000-2008 Dag-Erling Coïdan Smørgrav * All rights reserved. diff --git a/freebsd/sys/kern/subr_sleepqueue.c b/freebsd/sys/kern/subr_sleepqueue.c index a8ffa7e8..fa33af86 100644 --- a/freebsd/sys/kern/subr_sleepqueue.c +++ b/freebsd/sys/kern/subr_sleepqueue.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2004 John Baldwin <jhb@FreeBSD.org> * Copyright (c) 2015 embedded brains GmbH <rtems@embedded-brains.de> * All rights reserved. @@ -102,7 +104,10 @@ __FBSDID("$FreeBSD$"); * Constants for the hash table of sleep queue chains. * SC_TABLESIZE must be a power of two for SC_MASK to work properly. */ -#define SC_TABLESIZE 256 /* Must be power of 2. */ +#ifndef SC_TABLESIZE +#define SC_TABLESIZE 256 +#endif +CTASSERT(powerof2(SC_TABLESIZE)); #define SC_MASK (SC_TABLESIZE - 1) #define SC_SHIFT 8 #define SC_HASH(wc) ((((uintptr_t)(wc) >> SC_SHIFT) ^ (uintptr_t)(wc)) & \ @@ -146,7 +151,7 @@ struct sleepqueue_chain { u_int sc_depth; /* Length of sc_queues. */ u_int sc_max_depth; /* Max length of sc_queues. */ #endif -}; +} __aligned(CACHE_LINE_SIZE); #ifdef SLEEPQUEUE_PROFILING u_int sleepq_max_depth; @@ -1463,7 +1468,7 @@ sleepq_sbuf_print_stacks(struct sbuf *sb, void *wchan, int queue, M_TEMP, M_WAITOK); for (stack_idx = 0; stack_idx < stacks_to_allocate; stack_idx++) - st[stack_idx] = stack_create(); + st[stack_idx] = stack_create(M_WAITOK); /* Where we will store the td name, tid, etc. */ td_infos = malloc(sizeof(struct sbuf *) * stacks_to_allocate, @@ -1735,7 +1740,7 @@ found: if (TAILQ_EMPTY(&sq->sq_blocked[i])) db_printf("\tempty\n"); else - TAILQ_FOREACH(td, &sq->sq_blocked[0], + TAILQ_FOREACH(td, &sq->sq_blocked[i], td_slpq) { db_printf("\t%p (tid %d, pid %d, \"%s\")\n", td, td->td_tid, td->td_proc->p_pid, diff --git a/freebsd/sys/kern/subr_taskqueue.c b/freebsd/sys/kern/subr_taskqueue.c index 74b9cf59..60057f78 100644 --- a/freebsd/sys/kern/subr_taskqueue.c +++ b/freebsd/sys/kern/subr_taskqueue.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2000 Doug Rabson * All rights reserved. * diff --git a/freebsd/sys/kern/subr_uio.c b/freebsd/sys/kern/subr_uio.c index 904ef1f4..4979bcf1 100644 --- a/freebsd/sys/kern/subr_uio.c +++ b/freebsd/sys/kern/subr_uio.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1991, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. diff --git a/freebsd/sys/kern/subr_unit.c b/freebsd/sys/kern/subr_unit.c index 1deeeb8b..426253dc 100644 --- a/freebsd/sys/kern/subr_unit.c +++ b/freebsd/sys/kern/subr_unit.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2004 Poul-Henning Kamp * All rights reserved. * @@ -368,6 +370,26 @@ delete_unrhdr(struct unrhdr *uh) Free(uh); } +void +clear_unrhdr(struct unrhdr *uh) +{ + struct unr *up, *uq; + + KASSERT(TAILQ_EMPTY(&uh->ppfree), + ("unrhdr has postponed item for free")); + TAILQ_FOREACH_SAFE(up, &uh->head, list, uq) { + if (up->ptr != uh) { + Free(up->ptr); + } + Free(up); + } + uh->busy = 0; + uh->alloc = 0; + init_unrhdr(uh, uh->low, uh->high, uh->mtx); + + check_unrhdr(uh, __LINE__); +} + static __inline int is_bitmap(struct unrhdr *uh, struct unr *up) { diff --git a/freebsd/sys/kern/sys_generic.c b/freebsd/sys/kern/sys_generic.c index 6b26dbeb..118b4c77 100644 --- a/freebsd/sys/kern/sys_generic.c +++ b/freebsd/sys/kern/sys_generic.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1989, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. diff --git a/freebsd/sys/kern/sys_pipe.c b/freebsd/sys/kern/sys_pipe.c index 08dd619a..cc5b123c 100755 --- a/freebsd/sys/kern/sys_pipe.c +++ b/freebsd/sys/kern/sys_pipe.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 1996 John S. Dyson * Copyright (c) 2012 Giovanni Trematerra * All rights reserved. diff --git a/freebsd/sys/kern/sys_socket.c b/freebsd/sys/kern/sys_socket.c index b3c9c56d..974f7eec 100644 --- a/freebsd/sys/kern/sys_socket.c +++ b/freebsd/sys/kern/sys_socket.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1990, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/kern/tty.c b/freebsd/sys/kern/tty.c index 7d8400c7..1350c1d9 100644 --- a/freebsd/sys/kern/tty.c +++ b/freebsd/sys/kern/tty.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/kern/tty_inq.c b/freebsd/sys/kern/tty_inq.c index 84980393..b470cb5a 100644 --- a/freebsd/sys/kern/tty_inq.c +++ b/freebsd/sys/kern/tty_inq.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/kern/tty_outq.c b/freebsd/sys/kern/tty_outq.c index f083641b..121e9975 100644 --- a/freebsd/sys/kern/tty_outq.c +++ b/freebsd/sys/kern/tty_outq.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/kern/tty_ttydisc.c b/freebsd/sys/kern/tty_ttydisc.c index 5ecb15ea..b94080fb 100644 --- a/freebsd/sys/kern/tty_ttydisc.c +++ b/freebsd/sys/kern/tty_ttydisc.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/kern/uipc_accf.c b/freebsd/sys/kern/uipc_accf.c index 8a0e14e3..64f59202 100644 --- a/freebsd/sys/kern/uipc_accf.c +++ b/freebsd/sys/kern/uipc_accf.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2000 Paycounter, Inc. * Copyright (c) 2005 Robert N. M. Watson * Author: Alfred Perlstein <alfred@paycounter.com>, <alfred@FreeBSD.org> diff --git a/freebsd/sys/kern/uipc_domain.c b/freebsd/sys/kern/uipc_domain.c index 93cc3d9a..90b6e971 100644 --- a/freebsd/sys/kern/uipc_domain.c +++ b/freebsd/sys/kern/uipc_domain.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/kern/uipc_mbuf.c b/freebsd/sys/kern/uipc_mbuf.c index abc30dd3..7bf531e0 100644 --- a/freebsd/sys/kern/uipc_mbuf.c +++ b/freebsd/sys/kern/uipc_mbuf.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1988, 1991, 1993 * The Regents of the University of California. All rights reserved. * @@ -190,7 +192,17 @@ mb_dupcl(struct mbuf *n, struct mbuf *m) KASSERT(m->m_flags & M_EXT, ("%s: M_EXT not set on %p", __func__, m)); KASSERT(!(n->m_flags & M_EXT), ("%s: M_EXT set on %p", __func__, n)); - n->m_ext = m->m_ext; + /* + * Cache access optimization. For most kinds of external + * storage we don't need full copy of m_ext, since the + * holder of the 'ext_count' is responsible to carry the + * free routine and its arguments. Exclusion is EXT_EXTREF, + * where 'ext_cnt' doesn't point into mbuf at all. + */ + if (m->m_ext.ext_type == EXT_EXTREF) + bcopy(&m->m_ext, &n->m_ext, sizeof(struct m_ext)); + else + bcopy(&m->m_ext, &n->m_ext, m_ext_copylen); n->m_flags |= M_EXT; n->m_flags |= m->m_flags & M_RDONLY; @@ -1441,62 +1453,59 @@ bad: struct mbuf * m_fragment(struct mbuf *m0, int how, int length) { - struct mbuf *m_new = NULL, *m_final = NULL; - int progress = 0; + struct mbuf *m_first, *m_last; + int divisor = 255, progress = 0, fraglen; if (!(m0->m_flags & M_PKTHDR)) return (m0); - if ((length == 0) || (length < -2)) + if (length == 0 || length < -2) return (m0); + if (length > MCLBYTES) + length = MCLBYTES; + if (length < 0 && divisor > MCLBYTES) + divisor = MCLBYTES; + if (length == -1) + length = 1 + (arc4random() % divisor); + if (length > 0) + fraglen = length; m_fixhdr(m0); /* Needed sanity check */ - m_final = m_getcl(how, MT_DATA, M_PKTHDR); - - if (m_final == NULL) + m_first = m_getcl(how, MT_DATA, M_PKTHDR); + if (m_first == NULL) goto nospace; - if (m_dup_pkthdr(m_final, m0, how) == 0) + if (m_dup_pkthdr(m_first, m0, how) == 0) goto nospace; - m_new = m_final; - - if (length == -1) - length = 1 + (arc4random() & 255); + m_last = m_first; while (progress < m0->m_pkthdr.len) { - int fraglen; - - if (length > 0) - fraglen = length; - else - fraglen = 1 + (arc4random() & 255); + if (length == -2) + fraglen = 1 + (arc4random() % divisor); if (fraglen > m0->m_pkthdr.len - progress) fraglen = m0->m_pkthdr.len - progress; - if (fraglen > MCLBYTES) - fraglen = MCLBYTES; - - if (m_new == NULL) { - m_new = m_getcl(how, MT_DATA, 0); + if (progress != 0) { + struct mbuf *m_new = m_getcl(how, MT_DATA, 0); if (m_new == NULL) goto nospace; + + m_last->m_next = m_new; + m_last = m_new; } - m_copydata(m0, progress, fraglen, mtod(m_new, caddr_t)); + m_copydata(m0, progress, fraglen, mtod(m_last, caddr_t)); progress += fraglen; - m_new->m_len = fraglen; - if (m_new != m_final) - m_cat(m_final, m_new); - m_new = NULL; + m_last->m_len = fraglen; } m_freem(m0); - m0 = m_final; + m0 = m_first; return (m0); nospace: - if (m_final) - m_freem(m_final); + if (m_first) + m_freem(m_first); /* Return the original chain on failure */ return (m0); } diff --git a/freebsd/sys/kern/uipc_mbuf2.c b/freebsd/sys/kern/uipc_mbuf2.c index bb2b27b0..7dd2840c 100644 --- a/freebsd/sys/kern/uipc_mbuf2.c +++ b/freebsd/sys/kern/uipc_mbuf2.c @@ -4,6 +4,8 @@ /* $NetBSD: uipc_mbuf.c,v 1.40 1999/04/01 00:23:25 thorpej Exp $ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1999 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/kern/uipc_sockbuf.c b/freebsd/sys/kern/uipc_sockbuf.c index 4ec7187c..0c4ace6b 100644 --- a/freebsd/sys/kern/uipc_sockbuf.c +++ b/freebsd/sys/kern/uipc_sockbuf.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1988, 1990, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/kern/uipc_socket.c b/freebsd/sys/kern/uipc_socket.c index 5e4fda56..43763026 100644 --- a/freebsd/sys/kern/uipc_socket.c +++ b/freebsd/sys/kern/uipc_socket.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1988, 1990, 1993 * The Regents of the University of California. * Copyright (c) 2004 The FreeBSD Foundation diff --git a/freebsd/sys/kern/uipc_syscalls.c b/freebsd/sys/kern/uipc_syscalls.c index 5a9a381f..f2aba363 100644 --- a/freebsd/sys/kern/uipc_syscalls.c +++ b/freebsd/sys/kern/uipc_syscalls.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1989, 1990, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/kern/uipc_usrreq.c b/freebsd/sys/kern/uipc_usrreq.c index 702ba1e4..9f7e545f 100644 --- a/freebsd/sys/kern/uipc_usrreq.c +++ b/freebsd/sys/kern/uipc_usrreq.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1989, 1991, 1993 * The Regents of the University of California. * Copyright (c) 2004-2009 Robert N. M. Watson @@ -1816,12 +1818,20 @@ unp_pcblist(SYSCTL_HANDLER_ARGS) if (unp->unp_addr != NULL) bcopy(unp->unp_addr, &xu->xu_addr, unp->unp_addr->sun_len); + else + bzero(&xu->xu_addr, sizeof(xu->xu_addr)); if (unp->unp_conn != NULL && unp->unp_conn->unp_addr != NULL) bcopy(unp->unp_conn->unp_addr, &xu->xu_caddr, unp->unp_conn->unp_addr->sun_len); - bcopy(unp, &xu->xu_unp, sizeof *unp); + else + bzero(&xu->xu_caddr, sizeof(xu->xu_caddr)); + xu->unp_vnode = unp->unp_vnode; + xu->unp_conn = unp->unp_conn; + xu->xu_firstref = LIST_FIRST(&unp->unp_refs); + xu->xu_nextref = LIST_NEXT(unp, unp_reflink); + xu->unp_gencnt = unp->unp_gencnt; sotoxsocket(unp->unp_socket, &xu->xu_socket); UNP_PCB_UNLOCK(unp); error = SYSCTL_OUT(req, xu, sizeof *xu); diff --git a/freebsd/sys/libkern/random.c b/freebsd/sys/libkern/random.c index efa9a70a..b8cb653a 100644 --- a/freebsd/sys/libkern/random.c +++ b/freebsd/sys/libkern/random.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * @@ -41,8 +43,7 @@ __FBSDID("$FreeBSD$"); static u_long randseed = 937186357; /* after srandom(1), NSHUFF counted */ void -srandom(seed) - u_long seed; +srandom(u_long seed) { int i; diff --git a/freebsd/sys/lm32/include/machine/in_cksum.h b/freebsd/sys/lm32/include/machine/in_cksum.h index 72edfba9..d55b838b 100644 --- a/freebsd/sys/lm32/include/machine/in_cksum.h +++ b/freebsd/sys/lm32/include/machine/in_cksum.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * diff --git a/freebsd/sys/m32c/include/machine/in_cksum.h b/freebsd/sys/m32c/include/machine/in_cksum.h index 72edfba9..d55b838b 100644 --- a/freebsd/sys/m32c/include/machine/in_cksum.h +++ b/freebsd/sys/m32c/include/machine/in_cksum.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * diff --git a/freebsd/sys/m32r/include/machine/in_cksum.h b/freebsd/sys/m32r/include/machine/in_cksum.h index 72edfba9..d55b838b 100644 --- a/freebsd/sys/m32r/include/machine/in_cksum.h +++ b/freebsd/sys/m32r/include/machine/in_cksum.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * diff --git a/freebsd/sys/m68k/include/machine/in_cksum.h b/freebsd/sys/m68k/include/machine/in_cksum.h index 72edfba9..d55b838b 100644 --- a/freebsd/sys/m68k/include/machine/in_cksum.h +++ b/freebsd/sys/m68k/include/machine/in_cksum.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * diff --git a/freebsd/sys/mips/include/machine/cpufunc.h b/freebsd/sys/mips/include/machine/cpufunc.h index d4150edd..a83d22bf 100644 --- a/freebsd/sys/mips/include/machine/cpufunc.h +++ b/freebsd/sys/mips/include/machine/cpufunc.h @@ -1,6 +1,8 @@ /* $OpenBSD: pio.h,v 1.2 1998/09/15 10:50:12 pefo Exp $ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD AND BSD-4-Clause + * * Copyright (c) 2002-2004 Juli Mallett. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/mips/include/machine/cpuregs.h b/freebsd/sys/mips/include/machine/cpuregs.h index ca86a1c5..b9978bd0 100644 --- a/freebsd/sys/mips/include/machine/cpuregs.h +++ b/freebsd/sys/mips/include/machine/cpuregs.h @@ -1,6 +1,8 @@ /* $NetBSD: cpuregs.h,v 1.70 2006/05/15 02:26:54 simonb Exp $ */ /* + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/mips/include/machine/in_cksum.h b/freebsd/sys/mips/include/machine/in_cksum.h index 72edfba9..d55b838b 100644 --- a/freebsd/sys/mips/include/machine/in_cksum.h +++ b/freebsd/sys/mips/include/machine/in_cksum.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * diff --git a/freebsd/sys/mips/mips/in_cksum.c b/freebsd/sys/mips/mips/in_cksum.c index 22e19d83..79aa23f9 100644 --- a/freebsd/sys/mips/mips/in_cksum.c +++ b/freebsd/sys/mips/mips/in_cksum.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 1988, 1992, 1993 * The Regents of the University of California. All rights reserved. * Copyright (c) 1996 diff --git a/freebsd/sys/net/bpf.c b/freebsd/sys/net/bpf.c index cd8d34d7..6fc6b435 100644 --- a/freebsd/sys/net/bpf.c +++ b/freebsd/sys/net/bpf.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1990, 1991, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/net/bpf.h b/freebsd/sys/net/bpf.h index e82ce184..d8eb7ff4 100644 --- a/freebsd/sys/net/bpf.h +++ b/freebsd/sys/net/bpf.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1990, 1991, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/net/bpf_buffer.c b/freebsd/sys/net/bpf_buffer.c index 88af8425..7a182a61 100644 --- a/freebsd/sys/net/bpf_buffer.c +++ b/freebsd/sys/net/bpf_buffer.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2007 Seccuris Inc. * All rights reserved. * diff --git a/freebsd/sys/net/bpf_buffer.h b/freebsd/sys/net/bpf_buffer.h index c1dc1f3a..b49eed96 100644 --- a/freebsd/sys/net/bpf_buffer.h +++ b/freebsd/sys/net/bpf_buffer.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007 Seccuris Inc. * All rights reserved. * diff --git a/freebsd/sys/net/bpf_filter.c b/freebsd/sys/net/bpf_filter.c index 8ca92300..4cd1f962 100644 --- a/freebsd/sys/net/bpf_filter.c +++ b/freebsd/sys/net/bpf_filter.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1990, 1991, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/net/bpf_jitter.c b/freebsd/sys/net/bpf_jitter.c index 0369cb72..ac3a6ddd 100644 --- a/freebsd/sys/net/bpf_jitter.c +++ b/freebsd/sys/net/bpf_jitter.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 2002-2003 NetGroup, Politecnico di Torino (Italy) * Copyright (C) 2005-2017 Jung-uk Kim <jkim@FreeBSD.org> * All rights reserved. diff --git a/freebsd/sys/net/bpf_jitter.h b/freebsd/sys/net/bpf_jitter.h index 479205ea..a7c7cd9f 100644 --- a/freebsd/sys/net/bpf_jitter.h +++ b/freebsd/sys/net/bpf_jitter.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 2002-2003 NetGroup, Politecnico di Torino (Italy) * Copyright (C) 2005-2009 Jung-uk Kim <jkim@FreeBSD.org> * All rights reserved. diff --git a/freebsd/sys/net/bpf_zerocopy.h b/freebsd/sys/net/bpf_zerocopy.h index a5709b86..c3598747 100644 --- a/freebsd/sys/net/bpf_zerocopy.h +++ b/freebsd/sys/net/bpf_zerocopy.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007 Seccuris Inc. * All rights reserved. * diff --git a/freebsd/sys/net/bpfdesc.h b/freebsd/sys/net/bpfdesc.h index 7c13f375..3d8e69ce 100644 --- a/freebsd/sys/net/bpfdesc.h +++ b/freebsd/sys/net/bpfdesc.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1990, 1991, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/net/bridgestp.c b/freebsd/sys/net/bridgestp.c index dfa2a9bf..472b9634 100644 --- a/freebsd/sys/net/bridgestp.c +++ b/freebsd/sys/net/bridgestp.c @@ -2,7 +2,9 @@ /* $NetBSD: bridgestp.c,v 1.5 2003/11/28 08:56:48 keihan Exp $ */ -/* +/*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Copyright (c) 2000 Jason L. Wright (jason@thought.net) * Copyright (c) 2006 Andrew Thompson (thompsa@FreeBSD.org) * All rights reserved. diff --git a/freebsd/sys/net/bridgestp.h b/freebsd/sys/net/bridgestp.h index cbb8d53c..48f6c9eb 100644 --- a/freebsd/sys/net/bridgestp.h +++ b/freebsd/sys/net/bridgestp.h @@ -1,6 +1,8 @@ /* $NetBSD: if_bridgevar.h,v 1.4 2003/07/08 07:13:50 itojun Exp $ */ -/* +/*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright 2001 Wasabi Systems, Inc. * All rights reserved. * @@ -35,7 +37,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -/* +/*- * Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net) * All rights reserved. * diff --git a/freebsd/sys/net/fddi.h b/freebsd/sys/net/fddi.h index 71e3b6fb..0badcc3c 100644 --- a/freebsd/sys/net/fddi.h +++ b/freebsd/sys/net/fddi.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. * Copyright (c) 1995 Matt Thomas (thomas@lkg.dec.com) diff --git a/freebsd/sys/net/firewire.h b/freebsd/sys/net/firewire.h index bab71a58..dd7d23e4 100644 --- a/freebsd/sys/net/firewire.h +++ b/freebsd/sys/net/firewire.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2004 Doug Rabson * All rights reserved. * diff --git a/freebsd/sys/net/ieee8023ad_lacp.c b/freebsd/sys/net/ieee8023ad_lacp.c index d3fb457e..1778193d 100644 --- a/freebsd/sys/net/ieee8023ad_lacp.c +++ b/freebsd/sys/net/ieee8023ad_lacp.c @@ -3,6 +3,8 @@ /* $NetBSD: ieee8023ad_lacp.c,v 1.3 2005/12/11 12:24:54 christos Exp $ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Copyright (c)2005 YAMAMOTO Takashi, * Copyright (c)2008 Andrew Thompson <thompsa@FreeBSD.org> * All rights reserved. diff --git a/freebsd/sys/net/ieee8023ad_lacp.h b/freebsd/sys/net/ieee8023ad_lacp.h index b26e2c92..5ae48ceb 100644 --- a/freebsd/sys/net/ieee8023ad_lacp.h +++ b/freebsd/sys/net/ieee8023ad_lacp.h @@ -1,6 +1,8 @@ /* $NetBSD: ieee8023ad_impl.h,v 1.2 2005/12/10 23:21:39 elad Exp $ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Copyright (c)2005 YAMAMOTO Takashi, * All rights reserved. * diff --git a/freebsd/sys/net/if.c b/freebsd/sys/net/if.c index 00505706..67252bd4 100644 --- a/freebsd/sys/net/if.c +++ b/freebsd/sys/net/if.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1980, 1986, 1993 * The Regents of the University of California. All rights reserved. * @@ -1710,7 +1712,7 @@ ifa_maintain_loopback_route(int cmd, const char *otype, struct ifaddr *ifa, bzero(&info, sizeof(info)); if (cmd != RTM_DELETE) info.rti_ifp = V_loif; - info.rti_flags = ifa->ifa_flags | RTF_HOST | RTF_STATIC; + info.rti_flags = ifa->ifa_flags | RTF_HOST | RTF_STATIC | RTF_PINNED; info.rti_info[RTAX_DST] = ia; info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&null_sdl; link_init_sdl(ifp, (struct sockaddr *)&null_sdl, ifp->if_type); diff --git a/freebsd/sys/net/if_arc.h b/freebsd/sys/net/if_arc.h index b2444e72..8bed38b8 100644 --- a/freebsd/sys/net/if_arc.h +++ b/freebsd/sys/net/if_arc.h @@ -2,6 +2,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/net/if_arcsubr.c b/freebsd/sys/net/if_arcsubr.c index c71dcb8e..171085ec 100644 --- a/freebsd/sys/net/if_arcsubr.c +++ b/freebsd/sys/net/if_arcsubr.c @@ -4,6 +4,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 1994, 1995 Ignatios Souvatzis * Copyright (c) 1982, 1989, 1993 * The Regents of the University of California. All rights reserved. diff --git a/freebsd/sys/net/if_arp.h b/freebsd/sys/net/if_arp.h index 82448026..1a66c89c 100644 --- a/freebsd/sys/net/if_arp.h +++ b/freebsd/sys/net/if_arp.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1986, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/net/if_bridge.c b/freebsd/sys/net/if_bridge.c index 3499f3db..d345c0f1 100644 --- a/freebsd/sys/net/if_bridge.c +++ b/freebsd/sys/net/if_bridge.c @@ -2,7 +2,9 @@ /* $NetBSD: if_bridge.c,v 1.31 2005/06/01 19:45:34 jdc Exp $ */ -/* +/*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright 2001 Wasabi Systems, Inc. * All rights reserved. * diff --git a/freebsd/sys/net/if_bridgevar.h b/freebsd/sys/net/if_bridgevar.h index 480c90af..84ff8d21 100644 --- a/freebsd/sys/net/if_bridgevar.h +++ b/freebsd/sys/net/if_bridgevar.h @@ -1,6 +1,8 @@ /* $NetBSD: if_bridgevar.h,v 1.4 2003/07/08 07:13:50 itojun Exp $ */ /* + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright 2001 Wasabi Systems, Inc. * All rights reserved. * diff --git a/freebsd/sys/net/if_clone.c b/freebsd/sys/net/if_clone.c index e7339423..99faa05f 100644 --- a/freebsd/sys/net/if_clone.c +++ b/freebsd/sys/net/if_clone.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2012 Gleb Smirnoff <glebius@FreeBSD.org> * Copyright (c) 1980, 1986, 1993 * The Regents of the University of California. All rights reserved. @@ -597,39 +599,21 @@ ifc_name2unit(const char *name, int *unit) return (0); } -int -ifc_alloc_unit(struct if_clone *ifc, int *unit) +static int +ifc_alloc_unit_specific(struct if_clone *ifc, int *unit) { char name[IFNAMSIZ]; - int wildcard; - wildcard = (*unit < 0); -retry: if (*unit > ifc->ifc_maxunit) return (ENOSPC); - if (*unit < 0) { - *unit = alloc_unr(ifc->ifc_unrhdr); - if (*unit == -1) - return (ENOSPC); - } else { - *unit = alloc_unr_specific(ifc->ifc_unrhdr, *unit); - if (*unit == -1) { - if (wildcard) { - (*unit)++; - goto retry; - } else - return (EEXIST); - } - } + + if (alloc_unr_specific(ifc->ifc_unrhdr, *unit) == -1) + return (EEXIST); snprintf(name, IFNAMSIZ, "%s%d", ifc->ifc_name, *unit); if (ifunit(name) != NULL) { free_unr(ifc->ifc_unrhdr, *unit); - if (wildcard) { - (*unit)++; - goto retry; - } else - return (EEXIST); + return (EEXIST); } IF_CLONE_ADDREF(ifc); @@ -637,6 +621,36 @@ retry: return (0); } +static int +ifc_alloc_unit_next(struct if_clone *ifc, int *unit) +{ + int error; + + *unit = alloc_unr(ifc->ifc_unrhdr); + if (*unit == -1) + return (ENOSPC); + + free_unr(ifc->ifc_unrhdr, *unit); + for (;;) { + error = ifc_alloc_unit_specific(ifc, unit); + if (error != EEXIST) + break; + + (*unit)++; + } + + return (error); +} + +int +ifc_alloc_unit(struct if_clone *ifc, int *unit) +{ + if (*unit < 0) + return (ifc_alloc_unit_next(ifc, unit)); + else + return (ifc_alloc_unit_specific(ifc, unit)); +} + void ifc_free_unit(struct if_clone *ifc, int unit) { diff --git a/freebsd/sys/net/if_clone.h b/freebsd/sys/net/if_clone.h index d55aba20..f26ab63b 100644 --- a/freebsd/sys/net/if_clone.h +++ b/freebsd/sys/net/if_clone.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1989, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/net/if_dead.c b/freebsd/sys/net/if_dead.c index 7626c604..552be13f 100644 --- a/freebsd/sys/net/if_dead.c +++ b/freebsd/sys/net/if_dead.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2009 Robert N. M. Watson * All rights reserved. * diff --git a/freebsd/sys/net/if_disc.c b/freebsd/sys/net/if_disc.c index 8daeee82..b3ff7ff8 100644 --- a/freebsd/sys/net/if_disc.c +++ b/freebsd/sys/net/if_disc.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/net/if_dl.h b/freebsd/sys/net/if_dl.h index 5c4f273f..50767325 100644 --- a/freebsd/sys/net/if_dl.h +++ b/freebsd/sys/net/if_dl.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/net/if_edsc.c b/freebsd/sys/net/if_edsc.c index 9a1398b2..6b5671c1 100644 --- a/freebsd/sys/net/if_edsc.c +++ b/freebsd/sys/net/if_edsc.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/net/if_enc.c b/freebsd/sys/net/if_enc.c index 5fc53b5e..34022795 100644 --- a/freebsd/sys/net/if_enc.c +++ b/freebsd/sys/net/if_enc.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2006 The FreeBSD Project. * Copyright (c) 2015 Andrey V. Elsukov <ae@FreeBSD.org> * All rights reserved. diff --git a/freebsd/sys/net/if_enc.h b/freebsd/sys/net/if_enc.h index 616c621f..758fff0a 100644 --- a/freebsd/sys/net/if_enc.h +++ b/freebsd/sys/net/if_enc.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 The FreeBSD Project. * All rights reserved. * diff --git a/freebsd/sys/net/if_epair.c b/freebsd/sys/net/if_epair.c index 2e1911d7..106c0a43 100644 --- a/freebsd/sys/net/if_epair.c +++ b/freebsd/sys/net/if_epair.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 The FreeBSD Foundation * Copyright (c) 2009-2010 Bjoern A. Zeeb <bz@FreeBSD.org> * All rights reserved. @@ -982,6 +984,17 @@ vnet_epair_uninit(const void *unused __unused) VNET_SYSUNINIT(vnet_epair_uninit, SI_SUB_INIT_IF, SI_ORDER_ANY, vnet_epair_uninit, NULL); +static void +epair_uninit(const void *unused __unused) +{ + netisr_unregister(&epair_nh); + epair_dpcpu_detach(); + if (bootverbose) + printf("%s unloaded.\n", epairname); +} +SYSUNINIT(epair_uninit, SI_SUB_INIT_IF, SI_ORDER_MIDDLE, + epair_uninit, NULL); + static int epair_modevent(module_t mod, int type, void *data) { @@ -1001,10 +1014,7 @@ epair_modevent(module_t mod, int type, void *data) printf("%s initialized.\n", epairname); break; case MOD_UNLOAD: - netisr_unregister(&epair_nh); - epair_dpcpu_detach(); - if (bootverbose) - printf("%s unloaded.\n", epairname); + /* Handled in epair_uninit() */ break; default: return (EOPNOTSUPP); diff --git a/freebsd/sys/net/if_ethersubr.c b/freebsd/sys/net/if_ethersubr.c index c0064fc6..9b927511 100644 --- a/freebsd/sys/net/if_ethersubr.c +++ b/freebsd/sys/net/if_ethersubr.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1989, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/net/if_fddisubr.c b/freebsd/sys/net/if_fddisubr.c index 5243f6cd..3c159a22 100644 --- a/freebsd/sys/net/if_fddisubr.c +++ b/freebsd/sys/net/if_fddisubr.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 1995, 1996 * Matt Thomas <matt@3am-software.com>. All rights reserved. * Copyright (c) 1982, 1989, 1993 diff --git a/freebsd/sys/net/if_fwsubr.c b/freebsd/sys/net/if_fwsubr.c index a31be7e1..f9552838 100644 --- a/freebsd/sys/net/if_fwsubr.c +++ b/freebsd/sys/net/if_fwsubr.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2004 Doug Rabson * Copyright (c) 1982, 1989, 1993 * The Regents of the University of California. All rights reserved. diff --git a/freebsd/sys/net/if_gif.c b/freebsd/sys/net/if_gif.c index e5e6cb5e..fdbccbb6 100644 --- a/freebsd/sys/net/if_gif.c +++ b/freebsd/sys/net/if_gif.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/net/if_gif.h b/freebsd/sys/net/if_gif.h index 28da85bd..556c2acc 100644 --- a/freebsd/sys/net/if_gif.h +++ b/freebsd/sys/net/if_gif.h @@ -2,6 +2,8 @@ /* $KAME: if_gif.h,v 1.17 2000/09/11 11:36:41 sumikawa Exp $ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/net/if_gre.c b/freebsd/sys/net/if_gre.c index a2129eaa..dd9ba8f3 100644 --- a/freebsd/sys/net/if_gre.c +++ b/freebsd/sys/net/if_gre.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1998 The NetBSD Foundation, Inc. * Copyright (c) 2014 Andrey V. Elsukov <ae@FreeBSD.org> * All rights reserved. diff --git a/freebsd/sys/net/if_gre.h b/freebsd/sys/net/if_gre.h index 8fb811cb..0eac9e9f 100644 --- a/freebsd/sys/net/if_gre.h +++ b/freebsd/sys/net/if_gre.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1998 The NetBSD Foundation, Inc. * Copyright (c) 2014 Andrey V. Elsukov <ae@FreeBSD.org> * All rights reserved diff --git a/freebsd/sys/net/if_iso88025subr.c b/freebsd/sys/net/if_iso88025subr.c index 7dbce8d3..cba09bf5 100644 --- a/freebsd/sys/net/if_iso88025subr.c +++ b/freebsd/sys/net/if_iso88025subr.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1998, Larry Lile * All rights reserved. * diff --git a/freebsd/sys/net/if_llatbl.c b/freebsd/sys/net/if_llatbl.c index c08218c6..d98153b9 100644 --- a/freebsd/sys/net/if_llatbl.c +++ b/freebsd/sys/net/if_llatbl.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> -/* +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2004 Luigi Rizzo, Alessandro Cerri. All rights reserved. * Copyright (c) 2004-2008 Qing Li. All rights reserved. * Copyright (c) 2008 Kip Macy. All rights reserved. diff --git a/freebsd/sys/net/if_llatbl.h b/freebsd/sys/net/if_llatbl.h index 5e89fea0..fcf93883 100644 --- a/freebsd/sys/net/if_llatbl.h +++ b/freebsd/sys/net/if_llatbl.h @@ -1,4 +1,6 @@ -/* +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2004 Luigi Rizzo, Alessandro Cerri. All rights reserved. * Copyright (c) 2004-2008 Qing Li. All rights reserved. * Copyright (c) 2008 Kip Macy. All rights reserved. diff --git a/freebsd/sys/net/if_llc.h b/freebsd/sys/net/if_llc.h index 7a959b9c..b1bd7686 100644 --- a/freebsd/sys/net/if_llc.h +++ b/freebsd/sys/net/if_llc.h @@ -1,6 +1,8 @@ /* $NetBSD: if_llc.h,v 1.12 1999/11/19 20:41:19 thorpej Exp $ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/net/if_loop.c b/freebsd/sys/net/if_loop.c index fd290b2d..bae46891 100644 --- a/freebsd/sys/net/if_loop.c +++ b/freebsd/sys/net/if_loop.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/net/if_media.c b/freebsd/sys/net/if_media.c index 4e39f656..cceb0079 100644 --- a/freebsd/sys/net/if_media.c +++ b/freebsd/sys/net/if_media.c @@ -4,6 +4,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 1997 * Jonathan Stone and Jason R. Thorpe. All rights reserved. * diff --git a/freebsd/sys/net/if_media.h b/freebsd/sys/net/if_media.h index d1080dd6..13621a10 100644 --- a/freebsd/sys/net/if_media.h +++ b/freebsd/sys/net/if_media.h @@ -2,6 +2,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 1997 * Jonathan Stone and Jason R. Thorpe. All rights reserved. * diff --git a/freebsd/sys/net/if_pflog.h b/freebsd/sys/net/if_pflog.h index 0faeb7d4..5ed341a8 100644 --- a/freebsd/sys/net/if_pflog.h +++ b/freebsd/sys/net/if_pflog.h @@ -1,5 +1,7 @@ /* $OpenBSD: if_pflog.h,v 1.13 2006/10/23 12:46:09 henning Exp $ */ -/* +/*- + * SPDX-License-Identifier: BSD-2-Clause + * * Copyright 2001 Niels Provos <provos@citi.umich.edu> * All rights reserved. * @@ -22,6 +24,8 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ */ #ifndef _NET_IF_PFLOG_H_ diff --git a/freebsd/sys/net/if_pfsync.h b/freebsd/sys/net/if_pfsync.h index 5c4ba631..3715fdb5 100644 --- a/freebsd/sys/net/if_pfsync.h +++ b/freebsd/sys/net/if_pfsync.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 Michael Shalayeff * All rights reserved. * diff --git a/freebsd/sys/net/if_stf.c b/freebsd/sys/net/if_stf.c index b29c5f93..2aab358c 100644 --- a/freebsd/sys/net/if_stf.c +++ b/freebsd/sys/net/if_stf.c @@ -4,6 +4,8 @@ /* $KAME: if_stf.c,v 1.73 2001/12/03 11:08:30 keiichi Exp $ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 2000 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/net/if_tap.c b/freebsd/sys/net/if_tap.c index ca499606..ce143f9f 100644 --- a/freebsd/sys/net/if_tap.c +++ b/freebsd/sys/net/if_tap.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (C) 1999-2000 by Maksim Yevmenkin <m_evmenkin@yahoo.com> * All rights reserved. * @@ -741,9 +743,10 @@ tapioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td switch (cmd) { case TAPSIFINFO: tapp = (struct tapinfo *)data; + if (ifp->if_type != tapp->type) + return (EPROTOTYPE); mtx_lock(&tp->tap_mtx); ifp->if_mtu = tapp->mtu; - ifp->if_type = tapp->type; ifp->if_baudrate = tapp->baudrate; mtx_unlock(&tp->tap_mtx); break; diff --git a/freebsd/sys/net/if_tap.h b/freebsd/sys/net/if_tap.h index 91feb2fe..34f44b38 100644 --- a/freebsd/sys/net/if_tap.h +++ b/freebsd/sys/net/if_tap.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (C) 1999-2000 by Maksim Yevmenkin <m_evmenkin@yahoo.com> * All rights reserved. * diff --git a/freebsd/sys/net/if_tapvar.h b/freebsd/sys/net/if_tapvar.h index 21bac505..f5cf9f3e 100644 --- a/freebsd/sys/net/if_tapvar.h +++ b/freebsd/sys/net/if_tapvar.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (C) 1999-2000 by Maksim Yevmenkin <m_evmenkin@yahoo.com> * All rights reserved. * diff --git a/freebsd/sys/net/if_tun.c b/freebsd/sys/net/if_tun.c index dc742b8f..598a5c14 100644 --- a/freebsd/sys/net/if_tun.c +++ b/freebsd/sys/net/if_tun.c @@ -686,9 +686,10 @@ tunioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, if (error) return (error); } + if (TUN2IFP(tp)->if_type != tunp->type) + return (EPROTOTYPE); mtx_lock(&tp->tun_mtx); TUN2IFP(tp)->if_mtu = tunp->mtu; - TUN2IFP(tp)->if_type = tunp->type; TUN2IFP(tp)->if_baudrate = tunp->baudrate; mtx_unlock(&tp->tun_mtx); break; diff --git a/freebsd/sys/net/if_types.h b/freebsd/sys/net/if_types.h index b9a752df..61c432ba 100644 --- a/freebsd/sys/net/if_types.h +++ b/freebsd/sys/net/if_types.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1989, 1993, 1994 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/net/if_var.h b/freebsd/sys/net/if_var.h index c2de24a7..e22beea7 100644 --- a/freebsd/sys/net/if_var.h +++ b/freebsd/sys/net/if_var.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1989, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/net/if_vlan_var.h b/freebsd/sys/net/if_vlan_var.h index 6b20d142..d27e5104 100644 --- a/freebsd/sys/net/if_vlan_var.h +++ b/freebsd/sys/net/if_vlan_var.h @@ -143,16 +143,16 @@ struct vlanreq { } while (0) #define VLAN_TRUNKDEV(_ifp) \ - (_ifp)->if_type == IFT_L2VLAN ? (*vlan_trunkdev_p)((_ifp)) : NULL + ((_ifp)->if_type == IFT_L2VLAN ? (*vlan_trunkdev_p)((_ifp)) : NULL) #define VLAN_TAG(_ifp, _vid) \ - (_ifp)->if_type == IFT_L2VLAN ? (*vlan_tag_p)((_ifp), (_vid)) : EINVAL + ((_ifp)->if_type == IFT_L2VLAN ? (*vlan_tag_p)((_ifp), (_vid)) : EINVAL) #define VLAN_COOKIE(_ifp) \ - (_ifp)->if_type == IFT_L2VLAN ? (*vlan_cookie_p)((_ifp)) : NULL + ((_ifp)->if_type == IFT_L2VLAN ? (*vlan_cookie_p)((_ifp)) : NULL) #define VLAN_SETCOOKIE(_ifp, _cookie) \ - (_ifp)->if_type == IFT_L2VLAN ? \ - (*vlan_setcookie_p)((_ifp), (_cookie)) : EINVAL + ((_ifp)->if_type == IFT_L2VLAN ? \ + (*vlan_setcookie_p)((_ifp), (_cookie)) : EINVAL) #define VLAN_DEVAT(_ifp, _vid) \ - (_ifp)->if_vlantrunk != NULL ? (*vlan_devat_p)((_ifp), (_vid)) : NULL + ((_ifp)->if_vlantrunk != NULL ? (*vlan_devat_p)((_ifp), (_vid)) : NULL) extern void (*vlan_trunk_cap_p)(struct ifnet *); extern struct ifnet *(*vlan_trunkdev_p)(struct ifnet *); diff --git a/freebsd/sys/net/iflib.h b/freebsd/sys/net/iflib.h index 7249686b..70992fdd 100644 --- a/freebsd/sys/net/iflib.h +++ b/freebsd/sys/net/iflib.h @@ -361,7 +361,7 @@ int iflib_irq_alloc(if_ctx_t, if_irq_t, int, driver_filter_t, void *filter_arg, int iflib_irq_alloc_generic(if_ctx_t ctx, if_irq_t irq, int rid, iflib_intr_type_t type, driver_filter_t *filter, void *filter_arg, int qid, char *name); -void iflib_softirq_alloc_generic(if_ctx_t ctx, int rid, iflib_intr_type_t type, void *arg, int qid, char *name); +void iflib_softirq_alloc_generic(if_ctx_t ctx, if_irq_t irq, iflib_intr_type_t type, void *arg, int qid, char *name); void iflib_irq_free(if_ctx_t ctx, if_irq_t irq); diff --git a/freebsd/sys/net/ifq.h b/freebsd/sys/net/ifq.h index 3969c6a0..bffb80c3 100644 --- a/freebsd/sys/net/ifq.h +++ b/freebsd/sys/net/ifq.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1989, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/net/iso88025.h b/freebsd/sys/net/iso88025.h index 11bd6ec4..78b2737f 100644 --- a/freebsd/sys/net/iso88025.h +++ b/freebsd/sys/net/iso88025.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1998, Larry Lile * All rights reserved. * diff --git a/freebsd/sys/net/netisr.c b/freebsd/sys/net/netisr.c index 5dffbfdc..8f2430eb 100644 --- a/freebsd/sys/net/netisr.c +++ b/freebsd/sys/net/netisr.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007-2009 Robert N. M. Watson * Copyright (c) 2010-2011 Juniper Networks, Inc. * All rights reserved. diff --git a/freebsd/sys/net/netisr.h b/freebsd/sys/net/netisr.h index b0e8e5ab..32d2aa83 100644 --- a/freebsd/sys/net/netisr.h +++ b/freebsd/sys/net/netisr.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007-2009 Robert N. M. Watson * Copyright (c) 2010-2011 Juniper Networks, Inc. * All rights reserved. diff --git a/freebsd/sys/net/netisr_internal.h b/freebsd/sys/net/netisr_internal.h index ac3ed0f2..af486075 100644 --- a/freebsd/sys/net/netisr_internal.h +++ b/freebsd/sys/net/netisr_internal.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007-2009 Robert N. M. Watson * Copyright (c) 2010-2011 Juniper Networks, Inc. * All rights reserved. diff --git a/freebsd/sys/net/pfil.c b/freebsd/sys/net/pfil.c index 3c7984c7..e29cd5e7 100644 --- a/freebsd/sys/net/pfil.c +++ b/freebsd/sys/net/pfil.c @@ -4,6 +4,8 @@ /* $NetBSD: pfil.c,v 1.20 2001/11/12 23:49:46 lukem Exp $ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1996 Matthew R. Green * All rights reserved. * diff --git a/freebsd/sys/net/pfil.h b/freebsd/sys/net/pfil.h index 64d7cf62..2243ad83 100644 --- a/freebsd/sys/net/pfil.h +++ b/freebsd/sys/net/pfil.h @@ -2,6 +2,8 @@ /* $NetBSD: pfil.h,v 1.22 2003/06/23 12:57:08 martin Exp $ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1996 Matthew R. Green * All rights reserved. * diff --git a/freebsd/sys/net/pfkeyv2.h b/freebsd/sys/net/pfkeyv2.h index c2cf568f..7bbdd577 100644 --- a/freebsd/sys/net/pfkeyv2.h +++ b/freebsd/sys/net/pfkeyv2.h @@ -2,6 +2,8 @@ /* $KAME: pfkeyv2.h,v 1.37 2003/09/06 05:15:43 itojun Exp $ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/net/pfvar.h b/freebsd/sys/net/pfvar.h index c5e8567f..4bc84d94 100644 --- a/freebsd/sys/net/pfvar.h +++ b/freebsd/sys/net/pfvar.h @@ -1,4 +1,6 @@ -/* +/*- + * SPDX-License-Identifier: BSD-2-Clause + * * Copyright (c) 2001 Daniel Hartmeier * All rights reserved. * diff --git a/freebsd/sys/net/radix.c b/freebsd/sys/net/radix.c index 6bca1a1f..bbfd5f65 100644 --- a/freebsd/sys/net/radix.c +++ b/freebsd/sys/net/radix.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1988, 1989, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/net/radix.h b/freebsd/sys/net/radix.h index f9c55164..05f0f490 100644 --- a/freebsd/sys/net/radix.h +++ b/freebsd/sys/net/radix.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1988, 1989, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/net/radix_mpath.c b/freebsd/sys/net/radix_mpath.c index cb61fa56..7eccd8f1 100644 --- a/freebsd/sys/net/radix_mpath.c +++ b/freebsd/sys/net/radix_mpath.c @@ -3,6 +3,8 @@ /* $KAME: radix_mpath.c,v 1.17 2004/11/08 10:29:39 itojun Exp $ */ /* + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 2001 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/net/radix_mpath.h b/freebsd/sys/net/radix_mpath.h index 2b0d442e..bb6a9087 100644 --- a/freebsd/sys/net/radix_mpath.h +++ b/freebsd/sys/net/radix_mpath.h @@ -1,6 +1,8 @@ /* $KAME: radix_mpath.h,v 1.10 2004/11/06 15:44:28 itojun Exp $ */ /* + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 2001 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/net/raw_cb.c b/freebsd/sys/net/raw_cb.c index dd893440..0c441e8c 100644 --- a/freebsd/sys/net/raw_cb.c +++ b/freebsd/sys/net/raw_cb.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1980, 1986, 1993 * The Regents of the University of California. * All rights reserved. diff --git a/freebsd/sys/net/raw_cb.h b/freebsd/sys/net/raw_cb.h index c2d002e6..bd5e08fc 100644 --- a/freebsd/sys/net/raw_cb.h +++ b/freebsd/sys/net/raw_cb.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1980, 1986, 1993 * The Regents of the University of California. * All rights reserved. diff --git a/freebsd/sys/net/raw_usrreq.c b/freebsd/sys/net/raw_usrreq.c index ff89cf5f..e8ad50cb 100644 --- a/freebsd/sys/net/raw_usrreq.c +++ b/freebsd/sys/net/raw_usrreq.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1980, 1986, 1993 * The Regents of the University of California. * All rights reserved. @@ -227,9 +229,10 @@ raw_usend(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, KASSERT(sotorawcb(so) != NULL, ("raw_usend: rp == NULL")); if ((flags & PRUS_OOB) || (control && control->m_len)) { - /* XXXRW: Should control also be freed here? */ if (m != NULL) m_freem(m); + if (control != NULL) + m_freem(control); return (EOPNOTSUPP); } diff --git a/freebsd/sys/net/route.c b/freebsd/sys/net/route.c index a6a19cb0..1be39753 100644 --- a/freebsd/sys/net/route.c +++ b/freebsd/sys/net/route.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1980, 1986, 1991, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/net/route.h b/freebsd/sys/net/route.h index ae052f19..8835433e 100644 --- a/freebsd/sys/net/route.h +++ b/freebsd/sys/net/route.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1980, 1986, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/net/rss_config.h b/freebsd/sys/net/rss_config.h index 2ab32a43..202dbef5 100644 --- a/freebsd/sys/net/rss_config.h +++ b/freebsd/sys/net/rss_config.h @@ -66,7 +66,6 @@ #define RSS_HASHTYPE_RSS_IPV6_EX (1 << 5) /* IPv6 2-tuple + ext hdrs */ #define RSS_HASHTYPE_RSS_TCP_IPV6_EX (1 << 6) /* TCPv6 4-tiple + ext hdrs */ #define RSS_HASHTYPE_RSS_UDP_IPV4 (1 << 7) /* IPv4 UDP 4-tuple */ -#define RSS_HASHTYPE_RSS_UDP_IPV4_EX (1 << 8) /* IPv4 UDP 4-tuple + ext hdrs */ #define RSS_HASHTYPE_RSS_UDP_IPV6 (1 << 9) /* IPv6 UDP 4-tuple */ #define RSS_HASHTYPE_RSS_UDP_IPV6_EX (1 << 10) /* IPv6 UDP 4-tuple + ext hdrs */ diff --git a/freebsd/sys/net/rtsock.c b/freebsd/sys/net/rtsock.c index 1f527cd3..fe608d70 100644 --- a/freebsd/sys/net/rtsock.c +++ b/freebsd/sys/net/rtsock.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1988, 1991, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/net/sff8472.h b/freebsd/sys/net/sff8472.h index 5c50ea46..e67aa7f6 100644 --- a/freebsd/sys/net/sff8472.h +++ b/freebsd/sys/net/sff8472.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2013 George V. Neville-Neil * All rights reserved. * diff --git a/freebsd/sys/net/slcompress.c b/freebsd/sys/net/slcompress.c index 7ad705fe..7d03497e 100644 --- a/freebsd/sys/net/slcompress.c +++ b/freebsd/sys/net/slcompress.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1989, 1993, 1994 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/net/slcompress.h b/freebsd/sys/net/slcompress.h index bd53c081..47526931 100644 --- a/freebsd/sys/net/slcompress.h +++ b/freebsd/sys/net/slcompress.h @@ -2,6 +2,8 @@ * Definitions for tcp compression routines. */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/net/vnet.h b/freebsd/sys/net/vnet.h index 4985d4bd..0ec00aad 100644 --- a/freebsd/sys/net/vnet.h +++ b/freebsd/sys/net/vnet.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2006-2009 University of Zagreb * Copyright (c) 2006-2009 FreeBSD Foundation * All rights reserved. diff --git a/freebsd/sys/net80211/_ieee80211.h b/freebsd/sys/net80211/_ieee80211.h index 9434f3a6..354362fc 100644 --- a/freebsd/sys/net80211/_ieee80211.h +++ b/freebsd/sys/net80211/_ieee80211.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 Atsushi Onoe * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting * All rights reserved. diff --git a/freebsd/sys/net80211/ieee80211.c b/freebsd/sys/net80211/ieee80211.c index bf6aa8dc..d914c2e4 100644 --- a/freebsd/sys/net80211/ieee80211.c +++ b/freebsd/sys/net80211/ieee80211.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 Atsushi Onoe * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting * All rights reserved. diff --git a/freebsd/sys/net80211/ieee80211.h b/freebsd/sys/net80211/ieee80211.h index 9fef8c44..db46b8f1 100644 --- a/freebsd/sys/net80211/ieee80211.h +++ b/freebsd/sys/net80211/ieee80211.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 Atsushi Onoe * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting * All rights reserved. diff --git a/freebsd/sys/net80211/ieee80211_acl.c b/freebsd/sys/net80211/ieee80211_acl.c index 703769b7..d1844b46 100644 --- a/freebsd/sys/net80211/ieee80211_acl.c +++ b/freebsd/sys/net80211/ieee80211_acl.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2004-2008 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_action.c b/freebsd/sys/net80211/ieee80211_action.c index 7fb26dff..8c5b8e41 100644 --- a/freebsd/sys/net80211/ieee80211_action.c +++ b/freebsd/sys/net80211/ieee80211_action.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2009 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_action.h b/freebsd/sys/net80211/ieee80211_action.h index 4ee2aff4..71d2e778 100644 --- a/freebsd/sys/net80211/ieee80211_action.h +++ b/freebsd/sys/net80211/ieee80211_action.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2009 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_adhoc.c b/freebsd/sys/net80211/ieee80211_adhoc.c index 9372226e..fdd02e46 100644 --- a/freebsd/sys/net80211/ieee80211_adhoc.c +++ b/freebsd/sys/net80211/ieee80211_adhoc.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007-2009 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_adhoc.h b/freebsd/sys/net80211/ieee80211_adhoc.h index d8e19e5e..fa5d168d 100644 --- a/freebsd/sys/net80211/ieee80211_adhoc.h +++ b/freebsd/sys/net80211/ieee80211_adhoc.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_ageq.c b/freebsd/sys/net80211/ieee80211_ageq.c index e161208c..c87ae2da 100644 --- a/freebsd/sys/net80211/ieee80211_ageq.c +++ b/freebsd/sys/net80211/ieee80211_ageq.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2009 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_ageq.h b/freebsd/sys/net80211/ieee80211_ageq.h index fdcf071a..81bd17b6 100644 --- a/freebsd/sys/net80211/ieee80211_ageq.h +++ b/freebsd/sys/net80211/ieee80211_ageq.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2009 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_alq.h b/freebsd/sys/net80211/ieee80211_alq.h index 7537e933..d57e6e9b 100644 --- a/freebsd/sys/net80211/ieee80211_alq.h +++ b/freebsd/sys/net80211/ieee80211_alq.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2011 Adrian Chadd, Xenion Lty Ltd * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_crypto.c b/freebsd/sys/net80211/ieee80211_crypto.c index 077e44f7..2e28538c 100644 --- a/freebsd/sys/net80211/ieee80211_crypto.c +++ b/freebsd/sys/net80211/ieee80211_crypto.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 Atsushi Onoe * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting * All rights reserved. diff --git a/freebsd/sys/net80211/ieee80211_crypto.h b/freebsd/sys/net80211/ieee80211_crypto.h index 3cbceec3..b732fe80 100644 --- a/freebsd/sys/net80211/ieee80211_crypto.h +++ b/freebsd/sys/net80211/ieee80211_crypto.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 Atsushi Onoe * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting * All rights reserved. diff --git a/freebsd/sys/net80211/ieee80211_crypto_ccmp.c b/freebsd/sys/net80211/ieee80211_crypto_ccmp.c index 017b5381..87836b22 100644 --- a/freebsd/sys/net80211/ieee80211_crypto_ccmp.c +++ b/freebsd/sys/net80211/ieee80211_crypto_ccmp.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_crypto_none.c b/freebsd/sys/net80211/ieee80211_crypto_none.c index 67815393..6f4d9b82 100644 --- a/freebsd/sys/net80211/ieee80211_crypto_none.c +++ b/freebsd/sys/net80211/ieee80211_crypto_none.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_crypto_tkip.c b/freebsd/sys/net80211/ieee80211_crypto_tkip.c index bf21056b..37cc0fe6 100644 --- a/freebsd/sys/net80211/ieee80211_crypto_tkip.c +++ b/freebsd/sys/net80211/ieee80211_crypto_tkip.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_crypto_wep.c b/freebsd/sys/net80211/ieee80211_crypto_wep.c index 8931436f..a091356a 100644 --- a/freebsd/sys/net80211/ieee80211_crypto_wep.c +++ b/freebsd/sys/net80211/ieee80211_crypto_wep.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_ddb.c b/freebsd/sys/net80211/ieee80211_ddb.c index c942c06d..5f676bb9 100644 --- a/freebsd/sys/net80211/ieee80211_ddb.c +++ b/freebsd/sys/net80211/ieee80211_ddb.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007-2009 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_dfs.c b/freebsd/sys/net80211/ieee80211_dfs.c index bb1efcb4..2c454516 100644 --- a/freebsd/sys/net80211/ieee80211_dfs.c +++ b/freebsd/sys/net80211/ieee80211_dfs.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_dfs.h b/freebsd/sys/net80211/ieee80211_dfs.h index a5688e3b..4bf580d7 100644 --- a/freebsd/sys/net80211/ieee80211_dfs.h +++ b/freebsd/sys/net80211/ieee80211_dfs.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_freebsd.c b/freebsd/sys/net80211/ieee80211_freebsd.c index e811955e..00430f77 100644 --- a/freebsd/sys/net80211/ieee80211_freebsd.c +++ b/freebsd/sys/net80211/ieee80211_freebsd.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2003-2009 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_freebsd.h b/freebsd/sys/net80211/ieee80211_freebsd.h index 2a0b7396..8395eb00 100644 --- a/freebsd/sys/net80211/ieee80211_freebsd.h +++ b/freebsd/sys/net80211/ieee80211_freebsd.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2003-2008 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_hostap.c b/freebsd/sys/net80211/ieee80211_hostap.c index 8fd4270a..0cc43748 100644 --- a/freebsd/sys/net80211/ieee80211_hostap.c +++ b/freebsd/sys/net80211/ieee80211_hostap.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_hostap.h b/freebsd/sys/net80211/ieee80211_hostap.h index e08c4a04..d3342eee 100644 --- a/freebsd/sys/net80211/ieee80211_hostap.h +++ b/freebsd/sys/net80211/ieee80211_hostap.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_ht.c b/freebsd/sys/net80211/ieee80211_ht.c index 77e254e6..21d85fb3 100644 --- a/freebsd/sys/net80211/ieee80211_ht.c +++ b/freebsd/sys/net80211/ieee80211_ht.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_ht.h b/freebsd/sys/net80211/ieee80211_ht.h index b85e1c9a..4e02cd32 100644 --- a/freebsd/sys/net80211/ieee80211_ht.h +++ b/freebsd/sys/net80211/ieee80211_ht.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_hwmp.c b/freebsd/sys/net80211/ieee80211_hwmp.c index 62c27e29..37beae83 100644 --- a/freebsd/sys/net80211/ieee80211_hwmp.c +++ b/freebsd/sys/net80211/ieee80211_hwmp.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2009 The FreeBSD Foundation * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_input.c b/freebsd/sys/net80211/ieee80211_input.c index 27f979e8..0afad260 100644 --- a/freebsd/sys/net80211/ieee80211_input.c +++ b/freebsd/sys/net80211/ieee80211_input.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 Atsushi Onoe * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting * All rights reserved. diff --git a/freebsd/sys/net80211/ieee80211_input.h b/freebsd/sys/net80211/ieee80211_input.h index cff07c68..2f3afc3b 100644 --- a/freebsd/sys/net80211/ieee80211_input.h +++ b/freebsd/sys/net80211/ieee80211_input.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007-2009 Sam Leffler, Errno Consulting * All rights reserved. * @@ -131,6 +133,38 @@ ishtinfooui(const uint8_t *frm) return frm[1] > 3 && le32dec(frm+2) == ((BCM_OUI_HTINFO<<24)|BCM_OUI); } +static __inline int +ieee80211_check_rxseq_amsdu(const struct ieee80211_rx_stats *rxs) +{ + + return (!! (rxs->c_pktflags & IEEE80211_RX_F_AMSDU)); +} + +/* + * Return 1 if the rxseq check should increment the sequence + * number. Return 0 if it's part of an AMSDU batch and it isn't + * the final frame in the decap'ed burst. + */ +static __inline int +ieee80211_check_rxseq_amsdu_more(const struct ieee80211_rx_stats *rxs) +{ + /* No state? ok */ + if (rxs == NULL) + return (1); + + /* State but no AMSDU set? ok */ + if ((rxs->c_pktflags & IEEE80211_RX_F_AMSDU) == 0) + return (1); + + /* State, AMSDU set, then _MORE means "don't inc yet" */ + if (rxs->c_pktflags & IEEE80211_RX_F_AMSDU_MORE) { + return (0); + } + + /* Both are set, so return ok */ + return (1); +} + /* * Check the current frame sequence number against the current TID * state and return whether it's in sequence or should be dropped. @@ -238,7 +272,20 @@ ieee80211_check_rxseq(struct ieee80211_node *ni, struct ieee80211_frame *wh, goto fail; ok: - ni->ni_rxseqs[tid] = rxseq; + /* + * Only bump the sequence number if it's the last frame + * in a batch. That way frames in the rest of the batch + * get included, and the last frame in the batch kicks + * it next. + */ + if (ieee80211_check_rxseq_amsdu_more(rxs)) { + ni->ni_rxseqs[tid] = rxseq; + if ((rxs != NULL) && ieee80211_check_rxseq_amsdu(rxs)) + IEEE80211_NODE_STAT(ni, rx_amsdu_more_end); + } else { + /* .. still waiting */ + IEEE80211_NODE_STAT(ni, rx_amsdu_more); + } return 1; diff --git a/freebsd/sys/net80211/ieee80211_ioctl.c b/freebsd/sys/net80211/ieee80211_ioctl.c index 68a0f9ae..c5f6721d 100644 --- a/freebsd/sys/net80211/ieee80211_ioctl.c +++ b/freebsd/sys/net80211/ieee80211_ioctl.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 Atsushi Onoe * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting * All rights reserved. diff --git a/freebsd/sys/net80211/ieee80211_ioctl.h b/freebsd/sys/net80211/ieee80211_ioctl.h index 7d472bc6..5021285b 100644 --- a/freebsd/sys/net80211/ieee80211_ioctl.h +++ b/freebsd/sys/net80211/ieee80211_ioctl.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 Atsushi Onoe * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting * All rights reserved. @@ -84,7 +86,11 @@ struct ieee80211_nodestats { uint32_t ns_tx_deauth_code; /* last deauth reason */ uint32_t ns_tx_disassoc; /* disassociations */ uint32_t ns_tx_disassoc_code; /* last disassociation reason */ - uint32_t ns_spare[8]; + + /* Hardware A-MSDU decode */ + uint32_t ns_rx_amsdu_more; /* RX decap A-MSDU, more coming from A-MSDU */ + uint32_t ns_rx_amsdu_more_end; /* RX decap A-MSDU (or any other frame), no more coming */ + uint32_t ns_spare[6]; }; /* diff --git a/freebsd/sys/net80211/ieee80211_mesh.c b/freebsd/sys/net80211/ieee80211_mesh.c index df2865f4..f747c214 100644 --- a/freebsd/sys/net80211/ieee80211_mesh.c +++ b/freebsd/sys/net80211/ieee80211_mesh.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2009 The FreeBSD Foundation * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_mesh.h b/freebsd/sys/net80211/ieee80211_mesh.h index 2253af00..89423bd8 100644 --- a/freebsd/sys/net80211/ieee80211_mesh.h +++ b/freebsd/sys/net80211/ieee80211_mesh.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2009 The FreeBSD Foundation * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_monitor.c b/freebsd/sys/net80211/ieee80211_monitor.c index 11559985..0c07ed7c 100644 --- a/freebsd/sys/net80211/ieee80211_monitor.c +++ b/freebsd/sys/net80211/ieee80211_monitor.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_monitor.h b/freebsd/sys/net80211/ieee80211_monitor.h index d7dd8e98..0a64d0be 100644 --- a/freebsd/sys/net80211/ieee80211_monitor.h +++ b/freebsd/sys/net80211/ieee80211_monitor.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_node.c b/freebsd/sys/net80211/ieee80211_node.c index d5eec26a..023fb128 100644 --- a/freebsd/sys/net80211/ieee80211_node.c +++ b/freebsd/sys/net80211/ieee80211_node.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 Atsushi Onoe * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting * All rights reserved. diff --git a/freebsd/sys/net80211/ieee80211_node.h b/freebsd/sys/net80211/ieee80211_node.h index 26c05567..3e21cdda 100644 --- a/freebsd/sys/net80211/ieee80211_node.h +++ b/freebsd/sys/net80211/ieee80211_node.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 Atsushi Onoe * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting * All rights reserved. diff --git a/freebsd/sys/net80211/ieee80211_output.c b/freebsd/sys/net80211/ieee80211_output.c index 93b4dc46..51a75af2 100644 --- a/freebsd/sys/net80211/ieee80211_output.c +++ b/freebsd/sys/net80211/ieee80211_output.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 Atsushi Onoe * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting * All rights reserved. diff --git a/freebsd/sys/net80211/ieee80211_phy.c b/freebsd/sys/net80211/ieee80211_phy.c index 1558257e..8088ec4c 100644 --- a/freebsd/sys/net80211/ieee80211_phy.c +++ b/freebsd/sys/net80211/ieee80211_phy.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_phy.h b/freebsd/sys/net80211/ieee80211_phy.h index 7970388b..1539e879 100644 --- a/freebsd/sys/net80211/ieee80211_phy.h +++ b/freebsd/sys/net80211/ieee80211_phy.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_power.c b/freebsd/sys/net80211/ieee80211_power.c index cd526855..68fede6c 100644 --- a/freebsd/sys/net80211/ieee80211_power.c +++ b/freebsd/sys/net80211/ieee80211_power.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_power.h b/freebsd/sys/net80211/ieee80211_power.h index d9bbaa58..f2c0050f 100644 --- a/freebsd/sys/net80211/ieee80211_power.h +++ b/freebsd/sys/net80211/ieee80211_power.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_proto.c b/freebsd/sys/net80211/ieee80211_proto.c index d9cbc3b5..73410d70 100644 --- a/freebsd/sys/net80211/ieee80211_proto.c +++ b/freebsd/sys/net80211/ieee80211_proto.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 Atsushi Onoe * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting * Copyright (c) 2012 IEEE diff --git a/freebsd/sys/net80211/ieee80211_proto.h b/freebsd/sys/net80211/ieee80211_proto.h index b9aef7cb..187f7018 100644 --- a/freebsd/sys/net80211/ieee80211_proto.h +++ b/freebsd/sys/net80211/ieee80211_proto.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 Atsushi Onoe * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting * All rights reserved. diff --git a/freebsd/sys/net80211/ieee80211_radiotap.c b/freebsd/sys/net80211/ieee80211_radiotap.c index e62be743..81746e4e 100644 --- a/freebsd/sys/net80211/ieee80211_radiotap.c +++ b/freebsd/sys/net80211/ieee80211_radiotap.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2009 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_radiotap.h b/freebsd/sys/net80211/ieee80211_radiotap.h index e42c6664..d4369e8e 100644 --- a/freebsd/sys/net80211/ieee80211_radiotap.h +++ b/freebsd/sys/net80211/ieee80211_radiotap.h @@ -2,6 +2,8 @@ /* $NetBSD: ieee80211_radiotap.h,v 1.16 2007/01/06 05:51:15 dyoung Exp $ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2003, 2004 David Young. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/net80211/ieee80211_ratectl.c b/freebsd/sys/net80211/ieee80211_ratectl.c index d12032df..25a2f208 100644 --- a/freebsd/sys/net80211/ieee80211_ratectl.c +++ b/freebsd/sys/net80211/ieee80211_ratectl.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2010 Rui Paulo <rpaulo@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_ratectl.h b/freebsd/sys/net80211/ieee80211_ratectl.h index ccb17ef6..d147421a 100644 --- a/freebsd/sys/net80211/ieee80211_ratectl.h +++ b/freebsd/sys/net80211/ieee80211_ratectl.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2010 Rui Paulo <rpaulo@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_ratectl_none.c b/freebsd/sys/net80211/ieee80211_ratectl_none.c index 2b4a9916..a758e9ee 100644 --- a/freebsd/sys/net80211/ieee80211_ratectl_none.c +++ b/freebsd/sys/net80211/ieee80211_ratectl_none.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2010 Bernhard Schmidt <bschmidt@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_regdomain.c b/freebsd/sys/net80211/ieee80211_regdomain.c index beda077c..f4a81de4 100644 --- a/freebsd/sys/net80211/ieee80211_regdomain.c +++ b/freebsd/sys/net80211/ieee80211_regdomain.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2005-2008 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_regdomain.h b/freebsd/sys/net80211/ieee80211_regdomain.h index cfb31463..e46ffa80 100644 --- a/freebsd/sys/net80211/ieee80211_regdomain.h +++ b/freebsd/sys/net80211/ieee80211_regdomain.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2005-2008 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_rssadapt.c b/freebsd/sys/net80211/ieee80211_rssadapt.c index 5d404fa1..f05af298 100644 --- a/freebsd/sys/net80211/ieee80211_rssadapt.c +++ b/freebsd/sys/net80211/ieee80211_rssadapt.c @@ -3,6 +3,8 @@ /* $FreeBSD$ */ /* $NetBSD: ieee80211_rssadapt.c,v 1.9 2005/02/26 22:45:09 perry Exp $ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2010 Rui Paulo <rpaulo@FreeBSD.org> * Copyright (c) 2003, 2004 David Young. All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_rssadapt.h b/freebsd/sys/net80211/ieee80211_rssadapt.h index ee1d2d90..74b64bea 100644 --- a/freebsd/sys/net80211/ieee80211_rssadapt.h +++ b/freebsd/sys/net80211/ieee80211_rssadapt.h @@ -1,6 +1,8 @@ /* $FreeBSD$ */ /* $NetBSD: ieee80211_rssadapt.h,v 1.4 2005/02/26 22:45:09 perry Exp $ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2003, 2004 David Young. All rights reserved. * * Redistribution and use in source and binary forms, with or diff --git a/freebsd/sys/net80211/ieee80211_scan.c b/freebsd/sys/net80211/ieee80211_scan.c index 1f3f95a5..9b58ff98 100644 --- a/freebsd/sys/net80211/ieee80211_scan.c +++ b/freebsd/sys/net80211/ieee80211_scan.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_scan.h b/freebsd/sys/net80211/ieee80211_scan.h index a3c873df..07d927cf 100644 --- a/freebsd/sys/net80211/ieee80211_scan.h +++ b/freebsd/sys/net80211/ieee80211_scan.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2005-2009 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_scan_sta.c b/freebsd/sys/net80211/ieee80211_scan_sta.c index 1a930bc3..ed069ed8 100644 --- a/freebsd/sys/net80211/ieee80211_scan_sta.c +++ b/freebsd/sys/net80211/ieee80211_scan_sta.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_sta.c b/freebsd/sys/net80211/ieee80211_sta.c index 8e0da623..1993f566 100644 --- a/freebsd/sys/net80211/ieee80211_sta.c +++ b/freebsd/sys/net80211/ieee80211_sta.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_sta.h b/freebsd/sys/net80211/ieee80211_sta.h index e97e181e..79c576d1 100644 --- a/freebsd/sys/net80211/ieee80211_sta.h +++ b/freebsd/sys/net80211/ieee80211_sta.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_superg.c b/freebsd/sys/net80211/ieee80211_superg.c index a9968b49..8c3cc719 100644 --- a/freebsd/sys/net80211/ieee80211_superg.c +++ b/freebsd/sys/net80211/ieee80211_superg.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_superg.h b/freebsd/sys/net80211/ieee80211_superg.h index 2c8a6a0b..4f77829f 100644 --- a/freebsd/sys/net80211/ieee80211_superg.h +++ b/freebsd/sys/net80211/ieee80211_superg.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2009 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_tdma.c b/freebsd/sys/net80211/ieee80211_tdma.c index d7c1269c..b18803fc 100644 --- a/freebsd/sys/net80211/ieee80211_tdma.c +++ b/freebsd/sys/net80211/ieee80211_tdma.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007-2009 Sam Leffler, Errno Consulting * Copyright (c) 2007-2009 Intel Corporation * All rights reserved. diff --git a/freebsd/sys/net80211/ieee80211_tdma.h b/freebsd/sys/net80211/ieee80211_tdma.h index 76b9ed1c..9b108e4b 100644 --- a/freebsd/sys/net80211/ieee80211_tdma.h +++ b/freebsd/sys/net80211/ieee80211_tdma.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007-2009 Sam Leffler, Errno Consulting * Copyright (c) 2007-2009 Intel Corporation * All rights reserved. diff --git a/freebsd/sys/net80211/ieee80211_var.h b/freebsd/sys/net80211/ieee80211_var.h index 1d806a92..ee17c806 100644 --- a/freebsd/sys/net80211/ieee80211_var.h +++ b/freebsd/sys/net80211/ieee80211_var.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 Atsushi Onoe * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting * All rights reserved. diff --git a/freebsd/sys/net80211/ieee80211_wds.c b/freebsd/sys/net80211/ieee80211_wds.c index 66ee0322..1bceacef 100644 --- a/freebsd/sys/net80211/ieee80211_wds.c +++ b/freebsd/sys/net80211/ieee80211_wds.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_wds.h b/freebsd/sys/net80211/ieee80211_wds.h index c34fb6ee..23f1a571 100644 --- a/freebsd/sys/net80211/ieee80211_wds.h +++ b/freebsd/sys/net80211/ieee80211_wds.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/net80211/ieee80211_xauth.c b/freebsd/sys/net80211/ieee80211_xauth.c index 5efce39a..742ed5bf 100644 --- a/freebsd/sys/net80211/ieee80211_xauth.c +++ b/freebsd/sys/net80211/ieee80211_xauth.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2004 Video54 Technologies, Inc. * Copyright (c) 2004-2008 Sam Leffler, Errno Consulting * All rights reserved. diff --git a/freebsd/sys/netinet/accf_data.c b/freebsd/sys/netinet/accf_data.c index ae91bfa6..a98ded36 100644 --- a/freebsd/sys/netinet/accf_data.c +++ b/freebsd/sys/netinet/accf_data.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2000 Alfred Perlstein <alfred@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/netinet/accf_dns.c b/freebsd/sys/netinet/accf_dns.c index 5d11a024..f0f5d1f8 100644 --- a/freebsd/sys/netinet/accf_dns.c +++ b/freebsd/sys/netinet/accf_dns.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> -/* +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (C) 2007 David Malone <dwmalone@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/netinet/accf_http.c b/freebsd/sys/netinet/accf_http.c index 65dc2621..f1c9c5b3 100644 --- a/freebsd/sys/netinet/accf_http.c +++ b/freebsd/sys/netinet/accf_http.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2000 Paycounter, Inc. * Author: Alfred Perlstein <alfred@paycounter.com>, <alfred@FreeBSD.org> * All rights reserved. diff --git a/freebsd/sys/netinet/cc/cc.c b/freebsd/sys/netinet/cc/cc.c index 26d6f329..dc919172 100644 --- a/freebsd/sys/netinet/cc/cc.c +++ b/freebsd/sys/netinet/cc/cc.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007-2008 * Swinburne University of Technology, Melbourne, Australia. * Copyright (c) 2009-2010 Lawrence Stewart <lstewart@freebsd.org> diff --git a/freebsd/sys/netinet/cc/cc_module.h b/freebsd/sys/netinet/cc/cc_module.h index 6da10df1..1daf915c 100644 --- a/freebsd/sys/netinet/cc/cc_module.h +++ b/freebsd/sys/netinet/cc/cc_module.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2009-2010 Lawrence Stewart <lstewart@freebsd.org> * All rights reserved. * diff --git a/freebsd/sys/netinet/cc/cc_newreno.c b/freebsd/sys/netinet/cc/cc_newreno.c index 474afcc9..58a6504a 100644 --- a/freebsd/sys/netinet/cc/cc_newreno.c +++ b/freebsd/sys/netinet/cc/cc_newreno.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994, 1995 * The Regents of the University of California. * Copyright (c) 2007-2008,2010 diff --git a/freebsd/sys/netinet/icmp6.h b/freebsd/sys/netinet/icmp6.h index d2e35e42..b0ae67fe 100644 --- a/freebsd/sys/netinet/icmp6.h +++ b/freebsd/sys/netinet/icmp6.h @@ -2,6 +2,8 @@ /* $KAME: icmp6.h,v 1.46 2001/04/27 15:09:48 itojun Exp $ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet/icmp_var.h b/freebsd/sys/netinet/icmp_var.h index 565c7d48..6b421f2d 100644 --- a/freebsd/sys/netinet/icmp_var.h +++ b/freebsd/sys/netinet/icmp_var.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/netinet/if_ether.c b/freebsd/sys/netinet/if_ether.c index bdb3b054..fbf6238f 100644 --- a/freebsd/sys/netinet/if_ether.c +++ b/freebsd/sys/netinet/if_ether.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1988, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/netinet/if_ether.h b/freebsd/sys/netinet/if_ether.h index b0bc30cf..028e45a7 100644 --- a/freebsd/sys/netinet/if_ether.h +++ b/freebsd/sys/netinet/if_ether.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/netinet/igmp.c b/freebsd/sys/netinet/igmp.c index 5575a803..cf319470 100644 --- a/freebsd/sys/netinet/igmp.c +++ b/freebsd/sys/netinet/igmp.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2007-2009 Bruce Simpson. * Copyright (c) 1988 Stephen Deering. * Copyright (c) 1992, 1993 diff --git a/freebsd/sys/netinet/igmp.h b/freebsd/sys/netinet/igmp.h index 9d19726a..873d6419 100644 --- a/freebsd/sys/netinet/igmp.h +++ b/freebsd/sys/netinet/igmp.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1988 Stephen Deering. * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. diff --git a/freebsd/sys/netinet/igmp_var.h b/freebsd/sys/netinet/igmp_var.h index c2401506..4f9db06c 100644 --- a/freebsd/sys/netinet/igmp_var.h +++ b/freebsd/sys/netinet/igmp_var.h @@ -1,4 +1,6 @@ -/*-a +/*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1988 Stephen Deering. * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. diff --git a/freebsd/sys/netinet/in.c b/freebsd/sys/netinet/in.c index 0b31ff7e..77ada362 100644 --- a/freebsd/sys/netinet/in.c +++ b/freebsd/sys/netinet/in.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1991, 1993 * The Regents of the University of California. All rights reserved. * Copyright (C) 2001 WIDE Project. All rights reserved. diff --git a/freebsd/sys/netinet/in_gif.c b/freebsd/sys/netinet/in_gif.c index e7439acf..d072161f 100644 --- a/freebsd/sys/netinet/in_gif.c +++ b/freebsd/sys/netinet/in_gif.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet/in_kdtrace.h b/freebsd/sys/netinet/in_kdtrace.h index 0825c7df..ba63a9a9 100644 --- a/freebsd/sys/netinet/in_kdtrace.h +++ b/freebsd/sys/netinet/in_kdtrace.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2013 Mark Johnston <markj@FreeBSD.org> * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/netinet/in_mcast.c b/freebsd/sys/netinet/in_mcast.c index 2ba4d9e8..41beed9b 100644 --- a/freebsd/sys/netinet/in_mcast.c +++ b/freebsd/sys/netinet/in_mcast.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2007-2009 Bruce Simpson. * Copyright (c) 2005 Robert N. M. Watson. * All rights reserved. diff --git a/freebsd/sys/netinet/in_pcb.c b/freebsd/sys/netinet/in_pcb.c index 44890e3f..2783a276 100644 --- a/freebsd/sys/netinet/in_pcb.c +++ b/freebsd/sys/netinet/in_pcb.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1991, 1993, 1995 * The Regents of the University of California. * Copyright (c) 2007-2009 Robert N. M. Watson diff --git a/freebsd/sys/netinet/in_pcb.h b/freebsd/sys/netinet/in_pcb.h index 059ea90c..574ab407 100644 --- a/freebsd/sys/netinet/in_pcb.h +++ b/freebsd/sys/netinet/in_pcb.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1990, 1993 * The Regents of the University of California. * Copyright (c) 2010-2011 Juniper Networks, Inc. diff --git a/freebsd/sys/netinet/in_proto.c b/freebsd/sys/netinet/in_proto.c index de2f2057..f1dec6c5 100644 --- a/freebsd/sys/netinet/in_proto.c +++ b/freebsd/sys/netinet/in_proto.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/netinet/in_systm.h b/freebsd/sys/netinet/in_systm.h index 573ee40d..44f4d4d5 100644 --- a/freebsd/sys/netinet/in_systm.h +++ b/freebsd/sys/netinet/in_systm.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/netinet/in_var.h b/freebsd/sys/netinet/in_var.h index b2a7d460..ff722fc9 100644 --- a/freebsd/sys/netinet/in_var.h +++ b/freebsd/sys/netinet/in_var.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1985, 1986, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/netinet/ip.h b/freebsd/sys/netinet/ip.h index 4d9d4888..6d902fe4 100644 --- a/freebsd/sys/netinet/ip.h +++ b/freebsd/sys/netinet/ip.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. * All rights reserved. diff --git a/freebsd/sys/netinet/ip6.h b/freebsd/sys/netinet/ip6.h index 40c4973c..a0dfcb0f 100644 --- a/freebsd/sys/netinet/ip6.h +++ b/freebsd/sys/netinet/ip6.h @@ -2,6 +2,8 @@ /* $KAME: ip6.h,v 1.18 2001/03/29 05:34:30 itojun Exp $ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet/ip_carp.c b/freebsd/sys/netinet/ip_carp.c index 8b09a8c3..70537cfb 100644 --- a/freebsd/sys/netinet/ip_carp.c +++ b/freebsd/sys/netinet/ip_carp.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2002 Michael Shalayeff. * Copyright (c) 2003 Ryan McBride. * Copyright (c) 2011 Gleb Smirnoff <glebius@FreeBSD.org> @@ -177,8 +179,8 @@ static int proto_reg[] = {-1, -1}; * Each softc has a lock sc_mtx. It is used to synchronise carp_input_c(), * callout-driven events and ioctl()s. * - * To traverse the list of softcs on an ifnet we use CIF_LOCK(), to - * traverse the global list we use the mutex carp_mtx. + * To traverse the list of softcs on an ifnet we use CIF_LOCK() or carp_sx. + * To traverse the global list we use the mutex carp_mtx. * * Known issues with locking: * @@ -288,7 +290,8 @@ SYSCTL_VNET_PCPUSTAT(_net_inet_carp, OID_AUTO, stats, struct carpstats, ++_i) #define IFNET_FOREACH_CARP(ifp, sc) \ - CIF_LOCK_ASSERT(ifp->if_carp); \ + KASSERT(mtx_owned(&ifp->if_carp->cif_mtx) || \ + sx_xlocked(&carp_sx), ("cif_vrs not locked")); \ TAILQ_FOREACH((sc), &(ifp)->if_carp->cif_vrs, sc_list) #define DEMOTE_ADVSKEW(sc) \ @@ -1564,6 +1567,8 @@ carp_alloc(struct ifnet *ifp) struct carp_softc *sc; struct carp_if *cif; + sx_assert(&carp_sx, SA_XLOCKED); + if ((cif = ifp->if_carp) == NULL) cif = carp_alloc_if(ifp); @@ -1753,11 +1758,9 @@ carp_ioctl(struct ifreq *ifr, u_long cmd, struct thread *td) } if (ifp->if_carp) { - CIF_LOCK(ifp->if_carp); IFNET_FOREACH_CARP(ifp, sc) if (sc->sc_vhid == carpr.carpr_vhid) break; - CIF_UNLOCK(ifp->if_carp); } if (sc == NULL) { sc = carp_alloc(ifp); @@ -1828,11 +1831,9 @@ carp_ioctl(struct ifreq *ifr, u_long cmd, struct thread *td) priveleged = (priv_check(td, PRIV_NETINET_CARP) == 0); if (carpr.carpr_vhid != 0) { - CIF_LOCK(ifp->if_carp); IFNET_FOREACH_CARP(ifp, sc) if (sc->sc_vhid == carpr.carpr_vhid) break; - CIF_UNLOCK(ifp->if_carp); if (sc == NULL) { error = ENOENT; break; @@ -1843,7 +1844,6 @@ carp_ioctl(struct ifreq *ifr, u_long cmd, struct thread *td) int i, count; count = 0; - CIF_LOCK(ifp->if_carp); IFNET_FOREACH_CARP(ifp, sc) count++; @@ -1865,7 +1865,6 @@ carp_ioctl(struct ifreq *ifr, u_long cmd, struct thread *td) } i++; } - CIF_UNLOCK(ifp->if_carp); } break; } @@ -1920,11 +1919,9 @@ carp_attach(struct ifaddr *ifa, int vhid) return (ENOPROTOOPT); } - CIF_LOCK(cif); IFNET_FOREACH_CARP(ifp, sc) if (sc->sc_vhid == vhid) break; - CIF_UNLOCK(cif); if (sc == NULL) { sx_xunlock(&carp_sx); return (ENOENT); diff --git a/freebsd/sys/netinet/ip_carp.h b/freebsd/sys/netinet/ip_carp.h index 9c6edf6d..fc591ac3 100644 --- a/freebsd/sys/netinet/ip_carp.h +++ b/freebsd/sys/netinet/ip_carp.h @@ -1,7 +1,9 @@ /* $FreeBSD$ */ /* $OpenBSD: ip_carp.h,v 1.8 2004/07/29 22:12:15 mcbride Exp $ */ -/* +/*- + * SPDX-License-Identifier: BSD-2-Clause + * * Copyright (c) 2002 Michael Shalayeff. All rights reserved. * Copyright (c) 2003 Ryan McBride. All rights reserved. * diff --git a/freebsd/sys/netinet/ip_divert.c b/freebsd/sys/netinet/ip_divert.c index 5d7b1635..53a0445e 100644 --- a/freebsd/sys/netinet/ip_divert.c +++ b/freebsd/sys/netinet/ip_divert.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1988, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/netinet/ip_divert.h b/freebsd/sys/netinet/ip_divert.h index b8bcf4fb..a426afec 100644 --- a/freebsd/sys/netinet/ip_divert.h +++ b/freebsd/sys/netinet/ip_divert.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2003 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/netinet/ip_dummynet.h b/freebsd/sys/netinet/ip_dummynet.h index 377b5b09..9d64b3e9 100644 --- a/freebsd/sys/netinet/ip_dummynet.h +++ b/freebsd/sys/netinet/ip_dummynet.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1998-2010 Luigi Rizzo, Universita` di Pisa * Portions Copyright (c) 2000 Akamba Corp. * All rights reserved diff --git a/freebsd/sys/netinet/ip_ecn.c b/freebsd/sys/netinet/ip_ecn.c index cc5fd9dd..921f1c16 100644 --- a/freebsd/sys/netinet/ip_ecn.c +++ b/freebsd/sys/netinet/ip_ecn.c @@ -3,6 +3,8 @@ /* $KAME: ip_ecn.c,v 1.12 2002/01/07 11:34:47 kjc Exp $ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1999 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet/ip_ecn.h b/freebsd/sys/netinet/ip_ecn.h index c5c1c4eb..eb49b5f1 100644 --- a/freebsd/sys/netinet/ip_ecn.h +++ b/freebsd/sys/netinet/ip_ecn.h @@ -2,6 +2,8 @@ /* $KAME: ip_ecn.h,v 1.8 2002/01/07 11:34:47 kjc Exp $ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1999 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet/ip_encap.c b/freebsd/sys/netinet/ip_encap.c index 0f6fa850..d0866b00 100644 --- a/freebsd/sys/netinet/ip_encap.c +++ b/freebsd/sys/netinet/ip_encap.c @@ -3,6 +3,8 @@ /* $KAME: ip_encap.c,v 1.41 2001/03/15 08:35:08 itojun Exp $ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet/ip_encap.h b/freebsd/sys/netinet/ip_encap.h index 0b8dbd6f..bbbee390 100644 --- a/freebsd/sys/netinet/ip_encap.h +++ b/freebsd/sys/netinet/ip_encap.h @@ -2,6 +2,8 @@ /* $KAME: ip_encap.h,v 1.7 2000/03/25 07:23:37 sumikawa Exp $ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet/ip_fastfwd.c b/freebsd/sys/netinet/ip_fastfwd.c index 823dee35..b8a56c31 100644 --- a/freebsd/sys/netinet/ip_fastfwd.c +++ b/freebsd/sys/netinet/ip_fastfwd.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2003 Andre Oppermann, Internet Business Solutions AG * All rights reserved. * diff --git a/freebsd/sys/netinet/ip_fw.h b/freebsd/sys/netinet/ip_fw.h index ddee5bf1..de938c75 100644 --- a/freebsd/sys/netinet/ip_fw.h +++ b/freebsd/sys/netinet/ip_fw.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2002-2009 Luigi Rizzo, Universita` di Pisa * * Redistribution and use in source and binary forms, with or without @@ -728,6 +730,8 @@ struct _ipfw_dyn_rule { #define ICMP_REJECT_RST 0x100 /* fake ICMP code (send a TCP RST) */ #define ICMP6_UNREACH_RST 0x100 /* fake ICMPv6 code (send a TCP RST) */ +#define ICMP_REJECT_ABORT 0x101 /* fake ICMP code (send an SCTP ABORT) */ +#define ICMP6_UNREACH_ABORT 0x101 /* fake ICMPv6 code (send an SCTP ABORT) */ /* * These are used for lookup tables. diff --git a/freebsd/sys/netinet/ip_gre.c b/freebsd/sys/netinet/ip_gre.c index 90c22032..673e23d5 100644 --- a/freebsd/sys/netinet/ip_gre.c +++ b/freebsd/sys/netinet/ip_gre.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Copyright (c) 1998 The NetBSD Foundation, Inc. * Copyright (c) 2014 Andrey V. Elsukov <ae@FreeBSD.org> * All rights reserved. diff --git a/freebsd/sys/netinet/ip_icmp.c b/freebsd/sys/netinet/ip_icmp.c index 4843efcd..b03fea56 100644 --- a/freebsd/sys/netinet/ip_icmp.c +++ b/freebsd/sys/netinet/ip_icmp.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1988, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/netinet/ip_icmp.h b/freebsd/sys/netinet/ip_icmp.h index 9ffec3b0..0303a095 100644 --- a/freebsd/sys/netinet/ip_icmp.h +++ b/freebsd/sys/netinet/ip_icmp.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/netinet/ip_id.c b/freebsd/sys/netinet/ip_id.c index fb7d7835..02bf2c5b 100644 --- a/freebsd/sys/netinet/ip_id.c +++ b/freebsd/sys/netinet/ip_id.c @@ -1,7 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> - /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Michael J. Silbersack. * All rights reserved. * diff --git a/freebsd/sys/netinet/ip_input.c b/freebsd/sys/netinet/ip_input.c index 437c281a..c1baebbb 100644 --- a/freebsd/sys/netinet/ip_input.c +++ b/freebsd/sys/netinet/ip_input.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1988, 1993 * The Regents of the University of California. All rights reserved. * @@ -1145,40 +1147,96 @@ void ip_savecontrol(struct inpcb *inp, struct mbuf **mp, struct ip *ip, struct mbuf *m) { + bool stamped; + stamped = false; if ((inp->inp_socket->so_options & SO_BINTIME) || CHECK_SO_CT(inp->inp_socket, SO_TS_BINTIME)) { - struct bintime bt; - - bintime(&bt); + struct bintime boottimebin, bt; + struct timespec ts1; + + if ((m->m_flags & (M_PKTHDR | M_TSTMP)) == (M_PKTHDR | + M_TSTMP)) { + mbuf_tstmp2timespec(m, &ts1); + timespec2bintime(&ts1, &bt); + getboottimebin(&boottimebin); + bintime_add(&bt, &boottimebin); + } else { + bintime(&bt); + } *mp = sbcreatecontrol((caddr_t)&bt, sizeof(bt), SCM_BINTIME, SOL_SOCKET); - if (*mp) + if (*mp != NULL) { mp = &(*mp)->m_next; + stamped = true; + } } if (CHECK_SO_CT(inp->inp_socket, SO_TS_REALTIME_MICRO)) { + struct bintime boottimebin, bt1; + struct timespec ts1;; struct timeval tv; - microtime(&tv); + if ((m->m_flags & (M_PKTHDR | M_TSTMP)) == (M_PKTHDR | + M_TSTMP)) { + mbuf_tstmp2timespec(m, &ts1); + timespec2bintime(&ts1, &bt1); + getboottimebin(&boottimebin); + bintime_add(&bt1, &boottimebin); + bintime2timeval(&bt1, &tv); + } else { + microtime(&tv); + } *mp = sbcreatecontrol((caddr_t)&tv, sizeof(tv), SCM_TIMESTAMP, SOL_SOCKET); - if (*mp) + if (*mp != NULL) { mp = &(*mp)->m_next; + stamped = true; + } } else if (CHECK_SO_CT(inp->inp_socket, SO_TS_REALTIME)) { - struct timespec ts; - - nanotime(&ts); + struct bintime boottimebin; + struct timespec ts, ts1; + + if ((m->m_flags & (M_PKTHDR | M_TSTMP)) == (M_PKTHDR | + M_TSTMP)) { + mbuf_tstmp2timespec(m, &ts); + getboottimebin(&boottimebin); + bintime2timespec(&boottimebin, &ts1); + timespecadd(&ts, &ts1, &ts); + } else { + nanotime(&ts); + } *mp = sbcreatecontrol((caddr_t)&ts, sizeof(ts), SCM_REALTIME, SOL_SOCKET); - if (*mp) + if (*mp != NULL) { mp = &(*mp)->m_next; + stamped = true; + } } else if (CHECK_SO_CT(inp->inp_socket, SO_TS_MONOTONIC)) { struct timespec ts; - nanouptime(&ts); + if ((m->m_flags & (M_PKTHDR | M_TSTMP)) == (M_PKTHDR | + M_TSTMP)) + mbuf_tstmp2timespec(m, &ts); + else + nanouptime(&ts); *mp = sbcreatecontrol((caddr_t)&ts, sizeof(ts), SCM_MONOTONIC, SOL_SOCKET); - if (*mp) + if (*mp != NULL) { + mp = &(*mp)->m_next; + stamped = true; + } + } + if (stamped && (m->m_flags & (M_PKTHDR | M_TSTMP)) == (M_PKTHDR | + M_TSTMP)) { + struct sock_timestamp_info sti; + + bzero(&sti, sizeof(sti)); + sti.st_info_flags = ST_INFO_HW; + if ((m->m_flags & M_TSTMP_HPREC) != 0) + sti.st_info_flags |= ST_INFO_HW_HPREC; + *mp = sbcreatecontrol((caddr_t)&sti, sizeof(sti), SCM_TIME_INFO, + SOL_SOCKET); + if (*mp != NULL) mp = &(*mp)->m_next; } if (inp->inp_flags & INP_RECVDSTADDR) { diff --git a/freebsd/sys/netinet/ip_mroute.c b/freebsd/sys/netinet/ip_mroute.c index d0d323e9..eba4af63 100644 --- a/freebsd/sys/netinet/ip_mroute.c +++ b/freebsd/sys/netinet/ip_mroute.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1989 Stephen Deering * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. diff --git a/freebsd/sys/netinet/ip_mroute.h b/freebsd/sys/netinet/ip_mroute.h index 66bb65c3..11329fd1 100644 --- a/freebsd/sys/netinet/ip_mroute.h +++ b/freebsd/sys/netinet/ip_mroute.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1989 Stephen Deering. * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. diff --git a/freebsd/sys/netinet/ip_options.c b/freebsd/sys/netinet/ip_options.c index 9d5310f1..d85aecf3 100644 --- a/freebsd/sys/netinet/ip_options.c +++ b/freebsd/sys/netinet/ip_options.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /* + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1988, 1993 * The Regents of the University of California. * Copyright (c) 2005 Andre Oppermann, Internet Business Solutions AG. diff --git a/freebsd/sys/netinet/ip_options.h b/freebsd/sys/netinet/ip_options.h index b7d2fb0a..3213d5f7 100644 --- a/freebsd/sys/netinet/ip_options.h +++ b/freebsd/sys/netinet/ip_options.h @@ -1,4 +1,6 @@ /* + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. * Copyright (c) 2005 Andre Oppermann, Internet Business Solutions AG. diff --git a/freebsd/sys/netinet/ip_output.c b/freebsd/sys/netinet/ip_output.c index d9a5c511..62110ed1 100644 --- a/freebsd/sys/netinet/ip_output.c +++ b/freebsd/sys/netinet/ip_output.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1988, 1990, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/netinet/ip_var.h b/freebsd/sys/netinet/ip_var.h index f7e58d18..9e7ee591 100644 --- a/freebsd/sys/netinet/ip_var.h +++ b/freebsd/sys/netinet/ip_var.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/netinet/libalias/alias.c b/freebsd/sys/netinet/libalias/alias.c index 35343c5f..2dd5b999 100644 --- a/freebsd/sys/netinet/libalias/alias.c +++ b/freebsd/sys/netinet/libalias/alias.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 Charles Mott <cm@linktel.net> * All rights reserved. * diff --git a/freebsd/sys/netinet/libalias/alias.h b/freebsd/sys/netinet/libalias/alias.h index b12b353a..0b8875ec 100644 --- a/freebsd/sys/netinet/libalias/alias.h +++ b/freebsd/sys/netinet/libalias/alias.h @@ -1,6 +1,8 @@ /* lint -save -library Flexelint comment for external headers */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 Charles Mott <cm@linktel.net> * All rights reserved. * diff --git a/freebsd/sys/netinet/libalias/alias_cuseeme.c b/freebsd/sys/netinet/libalias/alias_cuseeme.c index 1d3cfa54..1d62a696 100644 --- a/freebsd/sys/netinet/libalias/alias_cuseeme.c +++ b/freebsd/sys/netinet/libalias/alias_cuseeme.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org> * with the aid of code written by * Junichi SATOH <junichi@astec.co.jp> 1996, 1997. diff --git a/freebsd/sys/netinet/libalias/alias_db.c b/freebsd/sys/netinet/libalias/alias_db.c index 212b891d..38fcd597 100644 --- a/freebsd/sys/netinet/libalias/alias_db.c +++ b/freebsd/sys/netinet/libalias/alias_db.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 Charles Mott <cm@linktel.net> * All rights reserved. * diff --git a/freebsd/sys/netinet/libalias/alias_dummy.c b/freebsd/sys/netinet/libalias/alias_dummy.c index 8b5ba1eb..19f8430d 100644 --- a/freebsd/sys/netinet/libalias/alias_dummy.c +++ b/freebsd/sys/netinet/libalias/alias_dummy.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2005 Paolo Pisati <piso@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/netinet/libalias/alias_ftp.c b/freebsd/sys/netinet/libalias/alias_ftp.c index 2e1f4d3a..4a86139e 100644 --- a/freebsd/sys/netinet/libalias/alias_ftp.c +++ b/freebsd/sys/netinet/libalias/alias_ftp.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 Charles Mott <cm@linktel.net> * All rights reserved. * diff --git a/freebsd/sys/netinet/libalias/alias_irc.c b/freebsd/sys/netinet/libalias/alias_irc.c index 19bf0db1..1dbb9ddf 100644 --- a/freebsd/sys/netinet/libalias/alias_irc.c +++ b/freebsd/sys/netinet/libalias/alias_irc.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 Charles Mott <cm@linktel.net> * All rights reserved. * diff --git a/freebsd/sys/netinet/libalias/alias_local.h b/freebsd/sys/netinet/libalias/alias_local.h index e9e843c6..c2929425 100644 --- a/freebsd/sys/netinet/libalias/alias_local.h +++ b/freebsd/sys/netinet/libalias/alias_local.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 Charles Mott <cm@linktel.net> * All rights reserved. * diff --git a/freebsd/sys/netinet/libalias/alias_mod.c b/freebsd/sys/netinet/libalias/alias_mod.c index d57d9ca0..c9dbfc59 100644 --- a/freebsd/sys/netinet/libalias/alias_mod.c +++ b/freebsd/sys/netinet/libalias/alias_mod.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2005 Paolo Pisati <piso@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/netinet/libalias/alias_mod.h b/freebsd/sys/netinet/libalias/alias_mod.h index fd020c46..d57798f7 100644 --- a/freebsd/sys/netinet/libalias/alias_mod.h +++ b/freebsd/sys/netinet/libalias/alias_mod.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2005 Paolo Pisati <piso@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/netinet/libalias/alias_nbt.c b/freebsd/sys/netinet/libalias/alias_nbt.c index 9e3b8b00..3d200cd4 100644 --- a/freebsd/sys/netinet/libalias/alias_nbt.c +++ b/freebsd/sys/netinet/libalias/alias_nbt.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Written by Atsushi Murai <amurai@spec.co.jp> * Copyright (c) 1998, System Planning and Engineering Co. * All rights reserved. diff --git a/freebsd/sys/netinet/libalias/alias_proxy.c b/freebsd/sys/netinet/libalias/alias_proxy.c index 233d5154..b5af9153 100644 --- a/freebsd/sys/netinet/libalias/alias_proxy.c +++ b/freebsd/sys/netinet/libalias/alias_proxy.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 Charles Mott <cm@linktel.net> * All rights reserved. * diff --git a/freebsd/sys/netinet/libalias/alias_sctp.c b/freebsd/sys/netinet/libalias/alias_sctp.c index c3d76c3b..f7fda7bf 100644 --- a/freebsd/sys/netinet/libalias/alias_sctp.c +++ b/freebsd/sys/netinet/libalias/alias_sctp.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 * Swinburne University of Technology, Melbourne, Australia. * diff --git a/freebsd/sys/netinet/libalias/alias_sctp.h b/freebsd/sys/netinet/libalias/alias_sctp.h index 7bef6f8f..dc401ce9 100644 --- a/freebsd/sys/netinet/libalias/alias_sctp.h +++ b/freebsd/sys/netinet/libalias/alias_sctp.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 * Swinburne University of Technology, Melbourne, Australia. * diff --git a/freebsd/sys/netinet/libalias/alias_skinny.c b/freebsd/sys/netinet/libalias/alias_skinny.c index 49e80eeb..2cf235f2 100644 --- a/freebsd/sys/netinet/libalias/alias_skinny.c +++ b/freebsd/sys/netinet/libalias/alias_skinny.c @@ -3,6 +3,8 @@ /*- * alias_skinny.c * + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2002, 2003 MarcusCom, Inc. * All rights reserved. * diff --git a/freebsd/sys/netinet/libalias/alias_smedia.c b/freebsd/sys/netinet/libalias/alias_smedia.c index 93f93296..e2798845 100644 --- a/freebsd/sys/netinet/libalias/alias_smedia.c +++ b/freebsd/sys/netinet/libalias/alias_smedia.c @@ -1,8 +1,10 @@ #include <machine/rtems-bsd-kernel-space.h> -/* +/*- * alias_smedia.c * + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD AND BSD-2-Clause + * * Copyright (c) 2000 Whistle Communications, Inc. * All rights reserved. * diff --git a/freebsd/sys/netinet/libalias/alias_util.c b/freebsd/sys/netinet/libalias/alias_util.c index 622121ee..ea3b0f8f 100644 --- a/freebsd/sys/netinet/libalias/alias_util.c +++ b/freebsd/sys/netinet/libalias/alias_util.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 Charles Mott <cm@linktel.net> * All rights reserved. * diff --git a/freebsd/sys/netinet/pim.h b/freebsd/sys/netinet/pim.h index 7878f797..ec140cb3 100644 --- a/freebsd/sys/netinet/pim.h +++ b/freebsd/sys/netinet/pim.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1996-2000 * University of Southern California/Information Sciences Institute. * All rights reserved. diff --git a/freebsd/sys/netinet/pim_var.h b/freebsd/sys/netinet/pim_var.h index ae876c94..e6398a4d 100644 --- a/freebsd/sys/netinet/pim_var.h +++ b/freebsd/sys/netinet/pim_var.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1998-2000 * University of Southern California/Information Sciences Institute. * All rights reserved. diff --git a/freebsd/sys/netinet/raw_ip.c b/freebsd/sys/netinet/raw_ip.c index 689a2bc4..0ed185ae 100644 --- a/freebsd/sys/netinet/raw_ip.c +++ b/freebsd/sys/netinet/raw_ip.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1988, 1993 * The Regents of the University of California. * All rights reserved. diff --git a/freebsd/sys/netinet/sctp.h b/freebsd/sys/netinet/sctp.h index 578be4f6..5a86f108 100644 --- a/freebsd/sys/netinet/sctp.h +++ b/freebsd/sys/netinet/sctp.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. diff --git a/freebsd/sys/netinet/sctp_asconf.c b/freebsd/sys/netinet/sctp_asconf.c index 5f1c4e8f..d2d990e1 100644 --- a/freebsd/sys/netinet/sctp_asconf.c +++ b/freebsd/sys/netinet/sctp_asconf.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. diff --git a/freebsd/sys/netinet/sctp_asconf.h b/freebsd/sys/netinet/sctp_asconf.h index ed9160e1..2a372205 100644 --- a/freebsd/sys/netinet/sctp_asconf.h +++ b/freebsd/sys/netinet/sctp_asconf.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. diff --git a/freebsd/sys/netinet/sctp_auth.c b/freebsd/sys/netinet/sctp_auth.c index b6dfdaf8..d8fbcf6e 100644 --- a/freebsd/sys/netinet/sctp_auth.c +++ b/freebsd/sys/netinet/sctp_auth.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. @@ -1608,9 +1610,9 @@ sctp_zero_m(struct mbuf *m, uint32_t m_offset, uint32_t size) /* now use the rest of the mbuf chain */ while ((m_tmp != NULL) && (size > 0)) { data = mtod(m_tmp, uint8_t *)+m_offset; - if (size > (uint32_t)SCTP_BUF_LEN(m_tmp)) { - memset(data, 0, SCTP_BUF_LEN(m_tmp)); - size -= SCTP_BUF_LEN(m_tmp); + if (size > (uint32_t)(SCTP_BUF_LEN(m_tmp) - m_offset)) { + memset(data, 0, SCTP_BUF_LEN(m_tmp) - m_offset); + size -= SCTP_BUF_LEN(m_tmp) - m_offset; } else { memset(data, 0, size); size = 0; diff --git a/freebsd/sys/netinet/sctp_auth.h b/freebsd/sys/netinet/sctp_auth.h index 04fd6464..66990c30 100644 --- a/freebsd/sys/netinet/sctp_auth.h +++ b/freebsd/sys/netinet/sctp_auth.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. diff --git a/freebsd/sys/netinet/sctp_bsd_addr.c b/freebsd/sys/netinet/sctp_bsd_addr.c index b3cb2ce3..7e2ef189 100644 --- a/freebsd/sys/netinet/sctp_bsd_addr.c +++ b/freebsd/sys/netinet/sctp_bsd_addr.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. diff --git a/freebsd/sys/netinet/sctp_bsd_addr.h b/freebsd/sys/netinet/sctp_bsd_addr.h index 8c0383a5..f2191a9b 100644 --- a/freebsd/sys/netinet/sctp_bsd_addr.h +++ b/freebsd/sys/netinet/sctp_bsd_addr.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. diff --git a/freebsd/sys/netinet/sctp_cc_functions.c b/freebsd/sys/netinet/sctp_cc_functions.c index b153d325..e8d6a354 100644 --- a/freebsd/sys/netinet/sctp_cc_functions.c +++ b/freebsd/sys/netinet/sctp_cc_functions.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. diff --git a/freebsd/sys/netinet/sctp_constants.h b/freebsd/sys/netinet/sctp_constants.h index 56772b34..94378799 100644 --- a/freebsd/sys/netinet/sctp_constants.h +++ b/freebsd/sys/netinet/sctp_constants.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. @@ -97,10 +99,6 @@ __FBSDID("$FreeBSD$"); */ #define SCTP_DEFAULT_VRF_SIZE 4 -/* constants for rto calc */ -#define sctp_align_safe_nocopy 0 -#define sctp_align_unsafe_makecopy 1 - /* JRS - Values defined for the HTCP algorithm */ #define ALPHA_BASE (1<<7) /* 1.0 with shift << 7 */ #define BETA_MIN (1<<6) /* 0.5 with shift << 7 */ diff --git a/freebsd/sys/netinet/sctp_crc32.c b/freebsd/sys/netinet/sctp_crc32.c index 99aebe48..82e361e1 100644 --- a/freebsd/sys/netinet/sctp_crc32.c +++ b/freebsd/sys/netinet/sctp_crc32.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. diff --git a/freebsd/sys/netinet/sctp_crc32.h b/freebsd/sys/netinet/sctp_crc32.h index 7fe02f5c..adc38afc 100644 --- a/freebsd/sys/netinet/sctp_crc32.h +++ b/freebsd/sys/netinet/sctp_crc32.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. diff --git a/freebsd/sys/netinet/sctp_dtrace_declare.h b/freebsd/sys/netinet/sctp_dtrace_declare.h index c5c8f9ce..e4dc97fc 100644 --- a/freebsd/sys/netinet/sctp_dtrace_declare.h +++ b/freebsd/sys/netinet/sctp_dtrace_declare.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. * diff --git a/freebsd/sys/netinet/sctp_dtrace_define.h b/freebsd/sys/netinet/sctp_dtrace_define.h index 19f44da4..53451d20 100644 --- a/freebsd/sys/netinet/sctp_dtrace_define.h +++ b/freebsd/sys/netinet/sctp_dtrace_define.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. * diff --git a/freebsd/sys/netinet/sctp_header.h b/freebsd/sys/netinet/sctp_header.h index b650d930..685ed78a 100644 --- a/freebsd/sys/netinet/sctp_header.h +++ b/freebsd/sys/netinet/sctp_header.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. diff --git a/freebsd/sys/netinet/sctp_indata.c b/freebsd/sys/netinet/sctp_indata.c index c27dd485..c4522a39 100644 --- a/freebsd/sys/netinet/sctp_indata.c +++ b/freebsd/sys/netinet/sctp_indata.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. @@ -90,12 +92,14 @@ sctp_calc_rwnd(struct sctp_tcb *stcb, struct sctp_association *asoc) if (stcb->sctp_socket == NULL) { return (calc); } + KASSERT(asoc->cnt_on_reasm_queue > 0 || asoc->size_on_reasm_queue == 0, + ("size_on_reasm_queue is %u", asoc->size_on_reasm_queue)); + KASSERT(asoc->cnt_on_all_streams > 0 || asoc->size_on_all_streams == 0, + ("size_on_all_streams is %u", asoc->size_on_all_streams)); if (stcb->asoc.sb_cc == 0 && - asoc->size_on_reasm_queue == 0 && - asoc->size_on_all_streams == 0) { + asoc->cnt_on_reasm_queue == 0 && + asoc->cnt_on_all_streams == 0) { /* Full rwnd granted */ - KASSERT(asoc->cnt_on_reasm_queue == 0, ("cnt_on_reasm_queue is %u", asoc->cnt_on_reasm_queue)); - KASSERT(asoc->cnt_on_all_streams == 0, ("cnt_on_all_streams is %u", asoc->cnt_on_all_streams)); calc = max(SCTP_SB_LIMIT_RCV(stcb->sctp_socket), SCTP_MINIMAL_RWND); return (calc); } @@ -1247,6 +1251,19 @@ deliver_more: } done = (control->end_added) && (control->last_frag_seen); if (control->on_read_q == 0) { + if (!done) { + if (asoc->size_on_all_streams >= control->length) { + asoc->size_on_all_streams -= control->length; + } else { +#ifdef INVARIANTS + panic("size_on_all_streams = %u smaller than control length %u", asoc->size_on_all_streams, control->length); +#else + asoc->size_on_all_streams = 0; +#endif + } + strm->pd_api_started = 1; + control->pdapi_started = 1; + } sctp_add_to_readq(stcb->sctp_ep, stcb, control, &stcb->sctp_socket->so_rcv, control->end_added, @@ -1256,10 +1273,6 @@ deliver_more: if (done) { control = nctl; goto deliver_more; - } else { - /* We are now doing PD API */ - strm->pd_api_started = 1; - control->pdapi_started = 1; } } } @@ -1318,15 +1331,11 @@ sctp_add_chk_to_control(struct sctp_queued_to_read *control, } else if (control->on_strm_q == SCTP_ON_ORDERED) { /* Ordered */ TAILQ_REMOVE(&strm->inqueue, control, next_instrm); - if (asoc->size_on_all_streams >= control->length) { - asoc->size_on_all_streams -= control->length; - } else { -#ifdef INVARIANTS - panic("size_on_all_streams = %u smaller than control length %u", asoc->size_on_all_streams, control->length); -#else - asoc->size_on_all_streams = 0; -#endif - } + /* + * Don't need to decrement + * size_on_all_streams, since control is on + * the read queue. + */ sctp_ucount_decr(asoc->cnt_on_all_streams); control->on_strm_q = 0; #ifdef INVARIANTS @@ -2643,10 +2652,11 @@ sctp_process_data(struct mbuf **mm, int iphlen, int *offset, int length, struct sctp_association *asoc; int num_chunks = 0; /* number of control chunks processed */ int stop_proc = 0; - int chk_length, break_flag, last_chunk; + int break_flag, last_chunk; int abort_flag = 0, was_a_gap; struct mbuf *m; uint32_t highest_tsn; + uint16_t chk_length; /* set the rwnd */ sctp_set_rwnd(stcb, &stcb->asoc); @@ -2698,7 +2708,8 @@ sctp_process_data(struct mbuf **mm, int iphlen, int *offset, int length, } /* get pointer to the first chunk header */ ch = (struct sctp_chunkhdr *)sctp_m_getptr(m, *offset, - sizeof(struct sctp_chunkhdr), (uint8_t *)&chunk_buf); + sizeof(struct sctp_chunkhdr), + (uint8_t *)&chunk_buf); if (ch == NULL) { return (1); } @@ -2740,7 +2751,7 @@ sctp_process_data(struct mbuf **mm, int iphlen, int *offset, int length, } if ((ch->chunk_type == SCTP_DATA) || (ch->chunk_type == SCTP_IDATA)) { - int clen; + uint16_t clen; if (ch->chunk_type == SCTP_DATA) { clen = sizeof(struct sctp_data_chunk); @@ -2755,7 +2766,8 @@ sctp_process_data(struct mbuf **mm, int iphlen, int *offset, int length, struct mbuf *op_err; char msg[SCTP_DIAG_INFO_LEN]; - snprintf(msg, sizeof(msg), "DATA chunk of length %d", + snprintf(msg, sizeof(msg), "%s chunk of length %u", + ch->chunk_type == SCTP_DATA ? "DATA" : "I-DATA", chk_length); op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg); stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_20; @@ -2832,7 +2844,25 @@ sctp_process_data(struct mbuf **mm, int iphlen, int *offset, int length, return (2); } default: - /* unknown chunk type, use bit rules */ + /* + * Unknown chunk type: use bit rules after + * checking length + */ + if (chk_length < sizeof(struct sctp_chunkhdr)) { + /* + * Need to send an abort since we + * had a invalid chunk. + */ + struct mbuf *op_err; + char msg[SCTP_DIAG_INFO_LEN]; + + snprintf(msg, sizeof(msg), "Chunk of length %u", + chk_length); + op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg); + stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_20; + sctp_abort_an_association(inp, stcb, op_err, SCTP_SO_NOT_LOCKED); + return (2); + } if (ch->chunk_type & 0x40) { /* Add a error report to the queue */ struct mbuf *op_err; @@ -2868,7 +2898,8 @@ sctp_process_data(struct mbuf **mm, int iphlen, int *offset, int length, continue; } ch = (struct sctp_chunkhdr *)sctp_m_getptr(m, *offset, - sizeof(struct sctp_chunkhdr), (uint8_t *)&chunk_buf); + sizeof(struct sctp_chunkhdr), + (uint8_t *)&chunk_buf); if (ch == NULL) { *offset = length; stop_proc = 1; @@ -3060,7 +3091,6 @@ sctp_process_segment_range(struct sctp_tcb *stcb, struct sctp_tmit_chunk **p_tp1 &stcb->asoc, tp1->whoTo, &tp1->sent_rcv_time, - sctp_align_safe_nocopy, SCTP_RTT_FROM_DATA); *rto_ok = 0; } @@ -4032,7 +4062,6 @@ sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack, sctp_calculate_rto(stcb, asoc, tp1->whoTo, &tp1->sent_rcv_time, - sctp_align_safe_nocopy, SCTP_RTT_FROM_DATA); rto_ok = 0; } @@ -4638,7 +4667,6 @@ hopeless_peer: sctp_calculate_rto(stcb, asoc, tp1->whoTo, &tp1->sent_rcv_time, - sctp_align_safe_nocopy, SCTP_RTT_FROM_DATA); rto_ok = 0; } diff --git a/freebsd/sys/netinet/sctp_indata.h b/freebsd/sys/netinet/sctp_indata.h index badd269d..10b18d0b 100644 --- a/freebsd/sys/netinet/sctp_indata.h +++ b/freebsd/sys/netinet/sctp_indata.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. diff --git a/freebsd/sys/netinet/sctp_input.c b/freebsd/sys/netinet/sctp_input.c index 0871bdb8..9c552ff5 100644 --- a/freebsd/sys/netinet/sctp_input.c +++ b/freebsd/sys/netinet/sctp_input.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. @@ -519,7 +521,7 @@ sctp_process_init_ack(struct mbuf *m, int iphlen, int offset, asoc->primary_destination, SCTP_FROM_SCTP_INPUT + SCTP_LOC_3); /* calculate the RTO */ - net->RTO = sctp_calculate_rto(stcb, asoc, net, &asoc->time_entered, sctp_align_safe_nocopy, + net->RTO = sctp_calculate_rto(stcb, asoc, net, &asoc->time_entered, SCTP_RTT_FROM_NON_DATA); retval = sctp_send_cookie_echo(m, offset, stcb, net); if (retval < 0) { @@ -635,13 +637,21 @@ sctp_handle_heartbeat_ack(struct sctp_heartbeat_chunk *cp, r_net, SCTP_FROM_SCTP_INPUT + SCTP_LOC_4); sctp_timer_start(SCTP_TIMER_TYPE_HEARTBEAT, stcb->sctp_ep, stcb, r_net); } + if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_THRESHOLD_LOGGING) { + sctp_misc_ints(SCTP_THRESHOLD_CLEAR, + stcb->asoc.overall_error_count, + 0, + SCTP_FROM_SCTP_INPUT, + __LINE__); + } + stcb->asoc.overall_error_count = 0; old_error_counter = r_net->error_count; r_net->error_count = 0; r_net->hb_responded = 1; tv.tv_sec = cp->heartbeat.hb_info.time_value_1; tv.tv_usec = cp->heartbeat.hb_info.time_value_2; /* Now lets do a RTO with this */ - r_net->RTO = sctp_calculate_rto(stcb, &stcb->asoc, r_net, &tv, sctp_align_safe_nocopy, + r_net->RTO = sctp_calculate_rto(stcb, &stcb->asoc, r_net, &tv, SCTP_RTT_FROM_NON_DATA); if (!(r_net->dest_state & SCTP_ADDR_REACHABLE)) { r_net->dest_state |= SCTP_ADDR_REACHABLE; @@ -765,7 +775,8 @@ sctp_handle_nat_missing_state(struct sctp_tcb *stcb, } -static void +/* Returns 1 if the stcb was aborted, 0 otherwise */ +static int sctp_handle_abort(struct sctp_abort_chunk *abort, struct sctp_tcb *stcb, struct sctp_nets *net) { @@ -777,29 +788,29 @@ sctp_handle_abort(struct sctp_abort_chunk *abort, SCTPDBG(SCTP_DEBUG_INPUT2, "sctp_handle_abort: handling ABORT\n"); if (stcb == NULL) - return; + return (0); len = ntohs(abort->ch.chunk_length); - if (len > sizeof(struct sctp_chunkhdr)) { + if (len >= sizeof(struct sctp_chunkhdr) + sizeof(struct sctp_error_cause)) { /* * Need to check the cause codes for our two magic nat * aborts which don't kill the assoc necessarily. */ - struct sctp_gen_error_cause *cause; + struct sctp_error_cause *cause; - cause = (struct sctp_gen_error_cause *)(abort + 1); + cause = (struct sctp_error_cause *)(abort + 1); error = ntohs(cause->code); if (error == SCTP_CAUSE_NAT_COLLIDING_STATE) { SCTPDBG(SCTP_DEBUG_INPUT2, "Received Colliding state abort flags:%x\n", abort->ch.chunk_flags); if (sctp_handle_nat_colliding_state(stcb)) { - return; + return (0); } } else if (error == SCTP_CAUSE_NAT_MISSING_STATE) { SCTPDBG(SCTP_DEBUG_INPUT2, "Received missing state abort flags:%x\n", abort->ch.chunk_flags); if (sctp_handle_nat_missing_state(stcb, net)) { - return; + return (0); } } } else { @@ -834,6 +845,7 @@ sctp_handle_abort(struct sctp_abort_chunk *abort, SCTP_SOCKET_UNLOCK(so, 1); #endif SCTPDBG(SCTP_DEBUG_INPUT2, "sctp_handle_abort: finished\n"); + return (1); } static void @@ -1090,19 +1102,11 @@ sctp_handle_shutdown_ack(struct sctp_shutdown_ack_chunk *cp SCTP_UNUSED, #endif } -/* - * Skip past the param header and then we will find the chunk that caused the - * problem. There are two possibilities ASCONF or FWD-TSN other than that and - * our peer must be broken. - */ static void -sctp_process_unrecog_chunk(struct sctp_tcb *stcb, struct sctp_paramhdr *phdr, +sctp_process_unrecog_chunk(struct sctp_tcb *stcb, uint8_t chunk_type, struct sctp_nets *net) { - struct sctp_chunkhdr *chk; - - chk = (struct sctp_chunkhdr *)((caddr_t)phdr + sizeof(*phdr)); - switch (chk->chunk_type) { + switch (chunk_type) { case SCTP_ASCONF_ACK: case SCTP_ASCONF: sctp_asconf_cleanup(stcb, net); @@ -1113,8 +1117,8 @@ sctp_process_unrecog_chunk(struct sctp_tcb *stcb, struct sctp_paramhdr *phdr, break; default: SCTPDBG(SCTP_DEBUG_INPUT2, - "Peer does not support chunk type %d(%x)??\n", - chk->chunk_type, (uint32_t)chk->chunk_type); + "Peer does not support chunk type %d (0x%x).\n", + chunk_type, chunk_type); break; } } @@ -1126,12 +1130,9 @@ sctp_process_unrecog_chunk(struct sctp_tcb *stcb, struct sctp_paramhdr *phdr, * XXX: Is this the right thing to do? */ static void -sctp_process_unrecog_param(struct sctp_tcb *stcb, struct sctp_paramhdr *phdr) +sctp_process_unrecog_param(struct sctp_tcb *stcb, uint16_t parameter_type) { - struct sctp_paramhdr *pbad; - - pbad = phdr + 1; - switch (ntohs(pbad->param_type)) { + switch (parameter_type) { /* pr-sctp draft */ case SCTP_PRSCTP_SUPPORTED: stcb->asoc.prsctp_supported = 0; @@ -1156,63 +1157,69 @@ sctp_process_unrecog_param(struct sctp_tcb *stcb, struct sctp_paramhdr *phdr) break; default: SCTPDBG(SCTP_DEBUG_INPUT2, - "Peer does not support param type %d(%x)??\n", - pbad->param_type, (uint32_t)pbad->param_type); + "Peer does not support param type %d (0x%x)??\n", + parameter_type, parameter_type); break; } } static int sctp_handle_error(struct sctp_chunkhdr *ch, - struct sctp_tcb *stcb, struct sctp_nets *net) + struct sctp_tcb *stcb, struct sctp_nets *net, uint32_t limit) { - int chklen; - struct sctp_paramhdr *phdr; - uint16_t error, error_type; - uint16_t error_len; + struct sctp_error_cause *cause; struct sctp_association *asoc; - int adjust; + uint32_t remaining_length, adjust; + uint16_t code, cause_code, cause_length; #if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) struct socket *so; #endif /* parse through all of the errors and process */ asoc = &stcb->asoc; - phdr = (struct sctp_paramhdr *)((caddr_t)ch + + cause = (struct sctp_error_cause *)((caddr_t)ch + sizeof(struct sctp_chunkhdr)); - chklen = ntohs(ch->chunk_length) - sizeof(struct sctp_chunkhdr); - error = 0; - while ((size_t)chklen >= sizeof(struct sctp_paramhdr)) { + remaining_length = ntohs(ch->chunk_length); + if (remaining_length > limit) { + remaining_length = limit; + } + if (remaining_length >= sizeof(struct sctp_chunkhdr)) { + remaining_length -= sizeof(struct sctp_chunkhdr); + } else { + remaining_length = 0; + } + code = 0; + while (remaining_length >= sizeof(struct sctp_error_cause)) { /* Process an Error Cause */ - error_type = ntohs(phdr->param_type); - error_len = ntohs(phdr->param_length); - if ((error_len > chklen) || (error_len == 0)) { - /* invalid param length for this param */ - SCTPDBG(SCTP_DEBUG_INPUT1, "Bogus length in error param- chunk left:%d errorlen:%d\n", - chklen, error_len); + cause_code = ntohs(cause->code); + cause_length = ntohs(cause->length); + if ((cause_length > remaining_length) || (cause_length == 0)) { + /* Invalid cause length, possibly due to truncation. */ + SCTPDBG(SCTP_DEBUG_INPUT1, "Bogus length in cause - bytes left: %u cause length: %u\n", + remaining_length, cause_length); return (0); } - if (error == 0) { + if (code == 0) { /* report the first error cause */ - error = error_type; + code = cause_code; } - switch (error_type) { + switch (cause_code) { case SCTP_CAUSE_INVALID_STREAM: case SCTP_CAUSE_MISSING_PARAM: case SCTP_CAUSE_INVALID_PARAM: case SCTP_CAUSE_NO_USER_DATA: - SCTPDBG(SCTP_DEBUG_INPUT1, "Software error we got a %d back? We have a bug :/ (or do they?)\n", - error_type); + SCTPDBG(SCTP_DEBUG_INPUT1, "Software error we got a %u back? We have a bug :/ (or do they?)\n", + cause_code); break; case SCTP_CAUSE_NAT_COLLIDING_STATE: - SCTPDBG(SCTP_DEBUG_INPUT2, "Received Colliding state abort flags:%x\n", + SCTPDBG(SCTP_DEBUG_INPUT2, "Received Colliding state abort flags: %x\n", ch->chunk_flags); if (sctp_handle_nat_colliding_state(stcb)) { return (0); } break; case SCTP_CAUSE_NAT_MISSING_STATE: - SCTPDBG(SCTP_DEBUG_INPUT2, "Received missing state abort flags:%x\n", + SCTPDBG(SCTP_DEBUG_INPUT2, "Received missing state abort flags: %x\n", ch->chunk_flags); if (sctp_handle_nat_missing_state(stcb, net)) { return (0); @@ -1223,12 +1230,18 @@ sctp_handle_error(struct sctp_chunkhdr *ch, * We only act if we have echoed a cookie and are * waiting. */ - if (SCTP_GET_STATE(asoc) == SCTP_STATE_COOKIE_ECHOED) { - int *p; - - p = (int *)((caddr_t)phdr + sizeof(*phdr)); - /* Save the time doubled */ - asoc->cookie_preserve_req = ntohl(*p) << 1; + if ((cause_length >= sizeof(struct sctp_error_stale_cookie)) && + (SCTP_GET_STATE(asoc) == SCTP_STATE_COOKIE_ECHOED)) { + struct sctp_error_stale_cookie *stale_cookie; + + stale_cookie = (struct sctp_error_stale_cookie *)cause; + asoc->cookie_preserve_req = ntohl(stale_cookie->stale_time); + /* Double it to be more robust on RTX */ + if (asoc->cookie_preserve_req <= UINT32_MAX / 2) { + asoc->cookie_preserve_req *= 2; + } else { + asoc->cookie_preserve_req = UINT32_MAX; + } asoc->stale_cookie_count++; if (asoc->stale_cookie_count > asoc->max_init_times) { @@ -1271,10 +1284,21 @@ sctp_handle_error(struct sctp_chunkhdr *ch, */ break; case SCTP_CAUSE_UNRECOG_CHUNK: - sctp_process_unrecog_chunk(stcb, phdr, net); + if (cause_length >= sizeof(struct sctp_error_unrecognized_chunk)) { + struct sctp_error_unrecognized_chunk *unrec_chunk; + + unrec_chunk = (struct sctp_error_unrecognized_chunk *)cause; + sctp_process_unrecog_chunk(stcb, unrec_chunk->ch.chunk_type, net); + } break; case SCTP_CAUSE_UNRECOG_PARAM: - sctp_process_unrecog_param(stcb, phdr); + /* XXX: We only consider the first parameter */ + if (cause_length >= sizeof(struct sctp_error_cause) + sizeof(struct sctp_paramhdr)) { + struct sctp_paramhdr *unrec_parameter; + + unrec_parameter = (struct sctp_paramhdr *)(cause + 1); + sctp_process_unrecog_param(stcb, ntohs(unrec_parameter->param_type)); + } break; case SCTP_CAUSE_COOKIE_IN_SHUTDOWN: /* @@ -1291,8 +1315,8 @@ sctp_handle_error(struct sctp_chunkhdr *ch, * We should NOT get these here, but in a * ASCONF-ACK. */ - SCTPDBG(SCTP_DEBUG_INPUT2, "Peer sends ASCONF errors in a Operational Error?<%d>?\n", - error_type); + SCTPDBG(SCTP_DEBUG_INPUT2, "Peer sends ASCONF errors in a error cause with code %u.\n", + cause_code); break; case SCTP_CAUSE_OUT_OF_RESC: /* @@ -1304,15 +1328,19 @@ sctp_handle_error(struct sctp_chunkhdr *ch, */ break; default: - SCTPDBG(SCTP_DEBUG_INPUT1, "sctp_handle_error: unknown error type = 0x%xh\n", - error_type); + SCTPDBG(SCTP_DEBUG_INPUT1, "sctp_handle_error: unknown code 0x%x\n", + cause_code); break; } - adjust = SCTP_SIZE32(error_len); - chklen -= adjust; - phdr = (struct sctp_paramhdr *)((caddr_t)phdr + adjust); + adjust = SCTP_SIZE32(cause_length); + if (remaining_length >= adjust) { + remaining_length -= adjust; + } else { + remaining_length = 0; + } + cause = (struct sctp_error_cause *)((caddr_t)cause + adjust); } - sctp_ulp_notify(SCTP_NOTIFY_REMOTE_ERROR, stcb, error, ch, SCTP_SO_NOT_LOCKED); + sctp_ulp_notify(SCTP_NOTIFY_REMOTE_ERROR, stcb, code, ch, SCTP_SO_NOT_LOCKED); return (0); } @@ -1489,6 +1517,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, struct sctp_init_ack_chunk *initack_cp, initack_buf; struct sctp_nets *net; struct mbuf *op_err; + struct timeval old; int init_offset, initack_offset, i; int retval; int spec_flag = 0; @@ -1649,10 +1678,11 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, * since we did not send a HB make sure we don't * double things */ + old.tv_sec = cookie->time_entered.tv_sec; + old.tv_usec = cookie->time_entered.tv_usec; net->hb_responded = 1; net->RTO = sctp_calculate_rto(stcb, asoc, net, - &cookie->time_entered, - sctp_align_unsafe_makecopy, + &old, SCTP_RTT_FROM_NON_DATA); if (stcb->asoc.sctp_autoclose_ticks && @@ -2369,10 +2399,13 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset, } (void)SCTP_GETTIME_TIMEVAL(&stcb->asoc.time_entered); if ((netp != NULL) && (*netp != NULL)) { + struct timeval old; + /* calculate the RTT and set the encaps port */ + old.tv_sec = cookie->time_entered.tv_sec; + old.tv_usec = cookie->time_entered.tv_usec; (*netp)->RTO = sctp_calculate_rto(stcb, asoc, *netp, - &cookie->time_entered, sctp_align_unsafe_makecopy, - SCTP_RTT_FROM_NON_DATA); + &old, SCTP_RTT_FROM_NON_DATA); } /* respond with a COOKIE-ACK */ sctp_send_cookie_ack(stcb); @@ -2920,7 +2953,14 @@ sctp_handle_cookie_ack(struct sctp_cookie_ack_chunk *cp SCTP_UNUSED, return; } asoc = &stcb->asoc; - + if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_THRESHOLD_LOGGING) { + sctp_misc_ints(SCTP_THRESHOLD_CLEAR, + asoc->overall_error_count, + 0, + SCTP_FROM_SCTP_INPUT, + __LINE__); + } + asoc->overall_error_count = 0; sctp_stop_all_cookie_timers(stcb); /* process according to association state */ if (SCTP_GET_STATE(asoc) == SCTP_STATE_COOKIE_ECHOED) { @@ -2938,7 +2978,7 @@ sctp_handle_cookie_ack(struct sctp_cookie_ack_chunk *cp SCTP_UNUSED, SCTP_STAT_INCR_GAUGE32(sctps_currestab); if (asoc->overall_error_count == 0) { net->RTO = sctp_calculate_rto(stcb, asoc, net, - &asoc->time_entered, sctp_align_safe_nocopy, + &asoc->time_entered, SCTP_RTT_FROM_NON_DATA); } (void)SCTP_GETTIME_TIMEVAL(&asoc->time_entered); @@ -4504,7 +4544,7 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, char msg[SCTP_DIAG_INFO_LEN]; uint32_t vtag_in; int num_chunks = 0; /* number of control chunks processed */ - uint32_t chk_length; + uint32_t chk_length, contiguous; int ret; int abort_no_unlock = 0; int ecne_seen = 0; @@ -4515,7 +4555,6 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, * until we get into jumbo grams and such.. */ uint8_t chunk_buf[SCTP_CHUNK_BUFFER_SIZE]; - struct sctp_tcb *locked_tcb = stcb; int got_auth = 0; uint32_t auth_offset = 0, auth_len = 0; int auth_skipped = 0; @@ -4527,31 +4566,29 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, SCTPDBG(SCTP_DEBUG_INPUT1, "sctp_process_control: iphlen=%u, offset=%u, length=%u stcb:%p\n", iphlen, *offset, length, (void *)stcb); + if (stcb) { + SCTP_TCB_LOCK_ASSERT(stcb); + } /* validate chunk header length... */ if (ntohs(ch->chunk_length) < sizeof(*ch)) { SCTPDBG(SCTP_DEBUG_INPUT1, "Invalid header length %d\n", ntohs(ch->chunk_length)); - if (locked_tcb) { - SCTP_TCB_UNLOCK(locked_tcb); - } - return (NULL); + *offset = length; + return (stcb); } /* * validate the verification tag */ vtag_in = ntohl(sh->v_tag); - if (locked_tcb) { - SCTP_TCB_LOCK_ASSERT(locked_tcb); - } if (ch->chunk_type == SCTP_INITIATION) { SCTPDBG(SCTP_DEBUG_INPUT1, "Its an INIT of len:%d vtag:%x\n", ntohs(ch->chunk_length), vtag_in); if (vtag_in != 0) { /* protocol error- silently discard... */ SCTP_STAT_INCR(sctps_badvtag); - if (locked_tcb) { - SCTP_TCB_UNLOCK(locked_tcb); + if (stcb != NULL) { + SCTP_TCB_UNLOCK(stcb); } return (NULL); } @@ -4574,9 +4611,6 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, if (*offset >= length) { /* no more data left in the mbuf chain */ *offset = length; - if (locked_tcb) { - SCTP_TCB_UNLOCK(locked_tcb); - } return (NULL); } ch = (struct sctp_chunkhdr *)sctp_m_getptr(m, *offset, @@ -4585,10 +4619,7 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, if (ch == NULL) { /* Help */ *offset = length; - if (locked_tcb) { - SCTP_TCB_UNLOCK(locked_tcb); - } - return (NULL); + return (stcb); } if (ch->chunk_type == SCTP_COOKIE_ECHO) { goto process_control_chunks; @@ -4625,10 +4656,7 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, * sctp_findassociation_ep_asconf(). */ SCTP_INP_DECR_REF(inp); - } else { - locked_tcb = stcb; } - /* now go back and verify any auth chunk to be sure */ if (auth_skipped && (stcb != NULL)) { struct sctp_auth_chunk *auth; @@ -4642,10 +4670,7 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, auth_offset)) { /* auth HMAC failed so dump it */ *offset = length; - if (locked_tcb) { - SCTP_TCB_UNLOCK(locked_tcb); - } - return (NULL); + return (stcb); } else { /* remaining chunks are HMAC checked */ stcb->asoc.authenticated = 1; @@ -4661,9 +4686,6 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, mflowtype, mflowid, inp->fibnum, vrf_id, port); *offset = length; - if (locked_tcb) { - SCTP_TCB_UNLOCK(locked_tcb); - } return (NULL); } asoc = &stcb->asoc; @@ -4675,13 +4697,14 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, if ((((ch->chunk_flags & SCTP_HAD_NO_TCB) == 0) && (vtag_in == asoc->my_vtag)) || (((ch->chunk_flags & SCTP_HAD_NO_TCB) == SCTP_HAD_NO_TCB) && + (asoc->peer_vtag != htonl(0)) && (vtag_in == asoc->peer_vtag))) { /* this is valid */ } else { /* drop this packet... */ SCTP_STAT_INCR(sctps_badvtag); - if (locked_tcb) { - SCTP_TCB_UNLOCK(locked_tcb); + if (stcb != NULL) { + SCTP_TCB_UNLOCK(stcb); } return (NULL); } @@ -4694,8 +4717,8 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, * but it won't complete until the shutdown * is completed */ - if (locked_tcb) { - SCTP_TCB_UNLOCK(locked_tcb); + if (stcb != NULL) { + SCTP_TCB_UNLOCK(stcb); } snprintf(msg, sizeof(msg), "OOTB, %s:%d at %s", __FILE__, __LINE__, __func__); op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), @@ -4714,8 +4737,8 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, "invalid vtag: %xh, expect %xh\n", vtag_in, asoc->my_vtag); SCTP_STAT_INCR(sctps_badvtag); - if (locked_tcb) { - SCTP_TCB_UNLOCK(locked_tcb); + if (stcb != NULL) { + SCTP_TCB_UNLOCK(stcb); } *offset = length; return (NULL); @@ -4730,14 +4753,6 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, (ch->chunk_type == SCTP_HEARTBEAT_REQUEST)) && (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_COOKIE_ECHOED)) { /* implied cookie-ack.. we must have lost the ack */ - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_THRESHOLD_LOGGING) { - sctp_misc_ints(SCTP_THRESHOLD_CLEAR, - stcb->asoc.overall_error_count, - 0, - SCTP_FROM_SCTP_INPUT, - __LINE__); - } - stcb->asoc.overall_error_count = 0; sctp_handle_cookie_ack((struct sctp_cookie_ack_chunk *)ch, stcb, *netp); } @@ -4751,65 +4766,34 @@ process_control_chunks: if (chk_length < sizeof(*ch) || (*offset + (int)chk_length) > length) { *offset = length; - if (locked_tcb) { - SCTP_TCB_UNLOCK(locked_tcb); - } - return (NULL); + return (stcb); } SCTP_STAT_INCR_COUNTER64(sctps_incontrolchunks); /* - * INIT-ACK only gets the init ack "header" portion only - * because we don't have to process the peer's COOKIE. All - * others get a complete chunk. + * INIT and INIT-ACK only gets the init ack "header" portion + * only because we don't have to process the peer's COOKIE. + * All others get a complete chunk. */ - if ((ch->chunk_type == SCTP_INITIATION_ACK) || - (ch->chunk_type == SCTP_INITIATION)) { - /* get an init-ack chunk */ - ch = (struct sctp_chunkhdr *)sctp_m_getptr(m, *offset, - sizeof(struct sctp_init_ack_chunk), chunk_buf); - if (ch == NULL) { - *offset = length; - if (locked_tcb) { - SCTP_TCB_UNLOCK(locked_tcb); - } - return (NULL); - } - } else { - /* For cookies and all other chunks. */ - if (chk_length > sizeof(chunk_buf)) { - /* - * use just the size of the chunk buffer so - * the front part of our chunks fit in - * contiguous space up to the chunk buffer - * size (508 bytes). For chunks that need to - * get more than that they must use the - * sctp_m_getptr() function or other means - * (e.g. know how to parse mbuf chains). - * Cookies do this already. - */ - ch = (struct sctp_chunkhdr *)sctp_m_getptr(m, *offset, - (sizeof(chunk_buf) - 4), - chunk_buf); - if (ch == NULL) { - *offset = length; - if (locked_tcb) { - SCTP_TCB_UNLOCK(locked_tcb); - } - return (NULL); - } - } else { - /* We can fit it all */ - ch = (struct sctp_chunkhdr *)sctp_m_getptr(m, *offset, - chk_length, chunk_buf); - if (ch == NULL) { - SCTP_PRINTF("sctp_process_control: Can't get the all data....\n"); - *offset = length; - if (locked_tcb) { - SCTP_TCB_UNLOCK(locked_tcb); - } - return (NULL); - } + switch (ch->chunk_type) { + case SCTP_INITIATION: + contiguous = sizeof(struct sctp_init_chunk); + break; + case SCTP_INITIATION_ACK: + contiguous = sizeof(struct sctp_init_ack_chunk); + break; + default: + contiguous = min(chk_length, sizeof(chunk_buf)); + break; + } + ch = (struct sctp_chunkhdr *)sctp_m_getptr(m, *offset, + contiguous, + chunk_buf); + if (ch == NULL) { + *offset = length; + if (stcb != NULL) { + SCTP_TCB_UNLOCK(stcb); } + return (NULL); } num_chunks++; /* Save off the last place we got a control from */ @@ -4845,8 +4829,8 @@ process_control_chunks: (length - *offset > (int)SCTP_SIZE32(chk_length))) { /* RFC 4960 requires that no ABORT is sent */ *offset = length; - if (locked_tcb) { - SCTP_TCB_UNLOCK(locked_tcb); + if (stcb != NULL) { + SCTP_TCB_UNLOCK(stcb); } return (NULL); } @@ -4866,26 +4850,22 @@ process_control_chunks: mflowtype, mflowid, vrf_id, port); *offset = length; - if ((!abort_no_unlock) && (locked_tcb)) { - SCTP_TCB_UNLOCK(locked_tcb); + if ((!abort_no_unlock) && (stcb != NULL)) { + SCTP_TCB_UNLOCK(stcb); } return (NULL); break; case SCTP_PAD_CHUNK: break; case SCTP_INITIATION_ACK: - SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_INIT-ACK\n"); + SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_INIT_ACK\n"); if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) { /* We are not interested anymore */ - if ((stcb) && (stcb->asoc.total_output_queue_size)) { + if ((stcb != NULL) && (stcb->asoc.total_output_queue_size)) { ; } else { - if ((locked_tcb != NULL) && (locked_tcb != stcb)) { - /* Very unlikely */ - SCTP_TCB_UNLOCK(locked_tcb); - } *offset = length; - if (stcb) { + if (stcb != NULL) { #if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) so = SCTP_INP_SO(inp); atomic_add_int(&stcb->asoc.refcnt, 1); @@ -4907,12 +4887,9 @@ process_control_chunks: if ((num_chunks > 1) || (length - *offset > (int)SCTP_SIZE32(chk_length))) { *offset = length; - if (locked_tcb) { - SCTP_TCB_UNLOCK(locked_tcb); - } - return (NULL); + return (stcb); } - if ((netp) && (*netp)) { + if ((netp != NULL) && (*netp != NULL)) { ret = sctp_handle_init_ack(m, iphlen, *offset, src, dst, sh, (struct sctp_init_ack_chunk *)ch, @@ -4934,115 +4911,38 @@ process_control_chunks: if ((stcb != NULL) && (ret == 0)) { sctp_chunk_output(stcb->sctp_ep, stcb, SCTP_OUTPUT_FROM_CONTROL_PROC, SCTP_SO_NOT_LOCKED); } - if (locked_tcb) { - SCTP_TCB_UNLOCK(locked_tcb); - } - return (NULL); + return (stcb); break; case SCTP_SELECTIVE_ACK: - { - struct sctp_sack_chunk *sack; - int abort_now = 0; - uint32_t a_rwnd, cum_ack; - uint16_t num_seg, num_dup; - uint8_t flags; - int offset_seg, offset_dup; - - SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_SACK\n"); - SCTP_STAT_INCR(sctps_recvsacks); - if (stcb == NULL) { - SCTPDBG(SCTP_DEBUG_INDATA1, "No stcb when processing SACK chunk\n"); - break; - } - if (chk_length < sizeof(struct sctp_sack_chunk)) { - SCTPDBG(SCTP_DEBUG_INDATA1, "Bad size on SACK chunk, too small\n"); - break; - } - if (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_SHUTDOWN_ACK_SENT) { - /*- - * If we have sent a shutdown-ack, we will pay no - * attention to a sack sent in to us since - * we don't care anymore. - */ - break; - } - sack = (struct sctp_sack_chunk *)ch; - flags = ch->chunk_flags; - cum_ack = ntohl(sack->sack.cum_tsn_ack); - num_seg = ntohs(sack->sack.num_gap_ack_blks); - num_dup = ntohs(sack->sack.num_dup_tsns); - a_rwnd = (uint32_t)ntohl(sack->sack.a_rwnd); - if (sizeof(struct sctp_sack_chunk) + - num_seg * sizeof(struct sctp_gap_ack_block) + - num_dup * sizeof(uint32_t) != chk_length) { - SCTPDBG(SCTP_DEBUG_INDATA1, "Bad size of SACK chunk\n"); - break; - } - offset_seg = *offset + sizeof(struct sctp_sack_chunk); - offset_dup = offset_seg + num_seg * sizeof(struct sctp_gap_ack_block); - SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_SACK process cum_ack:%x num_seg:%d a_rwnd:%d\n", - cum_ack, num_seg, a_rwnd); - stcb->asoc.seen_a_sack_this_pkt = 1; - if ((stcb->asoc.pr_sctp_cnt == 0) && - (num_seg == 0) && - SCTP_TSN_GE(cum_ack, stcb->asoc.last_acked_seq) && - (stcb->asoc.saw_sack_with_frags == 0) && - (stcb->asoc.saw_sack_with_nr_frags == 0) && - (!TAILQ_EMPTY(&stcb->asoc.sent_queue)) - ) { - /* - * We have a SIMPLE sack having no - * prior segments and data on sent - * queue to be acked.. Use the - * faster path sack processing. We - * also allow window update sacks - * with no missing segments to go - * this way too. - */ - sctp_express_handle_sack(stcb, cum_ack, a_rwnd, &abort_now, ecne_seen); - } else { - if (netp && *netp) - sctp_handle_sack(m, offset_seg, offset_dup, stcb, - num_seg, 0, num_dup, &abort_now, flags, - cum_ack, a_rwnd, ecne_seen); - } - if (abort_now) { - /* ABORT signal from sack processing */ - *offset = length; - return (NULL); - } - if (TAILQ_EMPTY(&stcb->asoc.send_queue) && - TAILQ_EMPTY(&stcb->asoc.sent_queue) && - (stcb->asoc.stream_queue_cnt == 0)) { - sctp_ulp_notify(SCTP_NOTIFY_SENDER_DRY, stcb, 0, NULL, SCTP_SO_NOT_LOCKED); - } - } - break; - /* - * EY - nr_sack: If the received chunk is an - * nr_sack chunk - */ case SCTP_NR_SELECTIVE_ACK: { - struct sctp_nr_sack_chunk *nr_sack; int abort_now = 0; uint32_t a_rwnd, cum_ack; uint16_t num_seg, num_nr_seg, num_dup; uint8_t flags; int offset_seg, offset_dup; - SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_NR_SACK\n"); + SCTPDBG(SCTP_DEBUG_INPUT3, "%s\n", + ch->chunk_type == SCTP_SELECTIVE_ACK ? "SCTP_SACK" : "SCTP_NR_SACK"); SCTP_STAT_INCR(sctps_recvsacks); if (stcb == NULL) { - SCTPDBG(SCTP_DEBUG_INDATA1, "No stcb when processing NR-SACK chunk\n"); + SCTPDBG(SCTP_DEBUG_INDATA1, "No stcb when processing %s chunk\n", + (ch->chunk_type == SCTP_SELECTIVE_ACK) ? "SCTP_SACK" : "SCTP_NR_SACK"); break; } - if (stcb->asoc.nrsack_supported == 0) { - goto unknown_chunk; - } - if (chk_length < sizeof(struct sctp_nr_sack_chunk)) { - SCTPDBG(SCTP_DEBUG_INDATA1, "Bad size on NR-SACK chunk, too small\n"); - break; + if (ch->chunk_type == SCTP_SELECTIVE_ACK) { + if (chk_length < sizeof(struct sctp_sack_chunk)) { + SCTPDBG(SCTP_DEBUG_INDATA1, "Bad size on SACK chunk, too small\n"); + break; + } + } else { + if (stcb->asoc.nrsack_supported == 0) { + goto unknown_chunk; + } + if (chk_length < sizeof(struct sctp_nr_sack_chunk)) { + SCTPDBG(SCTP_DEBUG_INDATA1, "Bad size on NR_SACK chunk, too small\n"); + break; + } } if (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_SHUTDOWN_ACK_SENT) { /*- @@ -5052,22 +4952,44 @@ process_control_chunks: */ break; } - nr_sack = (struct sctp_nr_sack_chunk *)ch; flags = ch->chunk_flags; - cum_ack = ntohl(nr_sack->nr_sack.cum_tsn_ack); - num_seg = ntohs(nr_sack->nr_sack.num_gap_ack_blks); - num_nr_seg = ntohs(nr_sack->nr_sack.num_nr_gap_ack_blks); - num_dup = ntohs(nr_sack->nr_sack.num_dup_tsns); - a_rwnd = (uint32_t)ntohl(nr_sack->nr_sack.a_rwnd); - if (sizeof(struct sctp_nr_sack_chunk) + - (num_seg + num_nr_seg) * sizeof(struct sctp_gap_ack_block) + - num_dup * sizeof(uint32_t) != chk_length) { - SCTPDBG(SCTP_DEBUG_INDATA1, "Bad size of NR_SACK chunk\n"); - break; + if (ch->chunk_type == SCTP_SELECTIVE_ACK) { + struct sctp_sack_chunk *sack; + + sack = (struct sctp_sack_chunk *)ch; + cum_ack = ntohl(sack->sack.cum_tsn_ack); + num_seg = ntohs(sack->sack.num_gap_ack_blks); + num_nr_seg = 0; + num_dup = ntohs(sack->sack.num_dup_tsns); + a_rwnd = ntohl(sack->sack.a_rwnd); + if (sizeof(struct sctp_sack_chunk) + + num_seg * sizeof(struct sctp_gap_ack_block) + + num_dup * sizeof(uint32_t) != chk_length) { + SCTPDBG(SCTP_DEBUG_INDATA1, "Bad size of SACK chunk\n"); + break; + } + offset_seg = *offset + sizeof(struct sctp_sack_chunk); + offset_dup = offset_seg + num_seg * sizeof(struct sctp_gap_ack_block); + } else { + struct sctp_nr_sack_chunk *nr_sack; + + nr_sack = (struct sctp_nr_sack_chunk *)ch; + cum_ack = ntohl(nr_sack->nr_sack.cum_tsn_ack); + num_seg = ntohs(nr_sack->nr_sack.num_gap_ack_blks); + num_nr_seg = ntohs(nr_sack->nr_sack.num_nr_gap_ack_blks); + num_dup = ntohs(nr_sack->nr_sack.num_dup_tsns); + a_rwnd = ntohl(nr_sack->nr_sack.a_rwnd); + if (sizeof(struct sctp_nr_sack_chunk) + + (num_seg + num_nr_seg) * sizeof(struct sctp_gap_ack_block) + + num_dup * sizeof(uint32_t) != chk_length) { + SCTPDBG(SCTP_DEBUG_INDATA1, "Bad size of NR_SACK chunk\n"); + break; + } + offset_seg = *offset + sizeof(struct sctp_nr_sack_chunk); + offset_dup = offset_seg + (num_seg + num_nr_seg) * sizeof(struct sctp_gap_ack_block); } - offset_seg = *offset + sizeof(struct sctp_nr_sack_chunk); - offset_dup = offset_seg + num_seg * sizeof(struct sctp_gap_ack_block); - SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_NR_SACK process cum_ack:%x num_seg:%d a_rwnd:%d\n", + SCTPDBG(SCTP_DEBUG_INPUT3, "%s process cum_ack:%x num_seg:%d a_rwnd:%d\n", + (ch->chunk_type == SCTP_SELECTIVE_ACK) ? "SCTP_SACK" : "SCTP_NR_SACK", cum_ack, num_seg, a_rwnd); stcb->asoc.seen_a_sack_this_pkt = 1; if ((stcb->asoc.pr_sctp_cnt == 0) && @@ -5088,10 +5010,11 @@ process_control_chunks: sctp_express_handle_sack(stcb, cum_ack, a_rwnd, &abort_now, ecne_seen); } else { - if (netp && *netp) + if ((netp != NULL) && (*netp != NULL)) { sctp_handle_sack(m, offset_seg, offset_dup, stcb, num_seg, num_nr_seg, num_dup, &abort_now, flags, cum_ack, a_rwnd, ecne_seen); + } } if (abort_now) { /* ABORT signal from sack processing */ @@ -5103,71 +5026,51 @@ process_control_chunks: (stcb->asoc.stream_queue_cnt == 0)) { sctp_ulp_notify(SCTP_NOTIFY_SENDER_DRY, stcb, 0, NULL, SCTP_SO_NOT_LOCKED); } + break; } - break; - case SCTP_HEARTBEAT_REQUEST: SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_HEARTBEAT\n"); - if ((stcb) && netp && *netp) { + if ((stcb != NULL) && (netp != NULL) && (*netp != NULL)) { SCTP_STAT_INCR(sctps_recvheartbeat); sctp_send_heartbeat_ack(stcb, m, *offset, chk_length, *netp); - - /* He's alive so give him credit */ - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_THRESHOLD_LOGGING) { - sctp_misc_ints(SCTP_THRESHOLD_CLEAR, - stcb->asoc.overall_error_count, - 0, - SCTP_FROM_SCTP_INPUT, - __LINE__); - } - stcb->asoc.overall_error_count = 0; } break; case SCTP_HEARTBEAT_ACK: - SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_HEARTBEAT-ACK\n"); + SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_HEARTBEAT_ACK\n"); if ((stcb == NULL) || (chk_length != sizeof(struct sctp_heartbeat_chunk))) { /* Its not ours */ *offset = length; - if (locked_tcb) { - SCTP_TCB_UNLOCK(locked_tcb); - } - return (NULL); - } - /* He's alive so give him credit */ - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_THRESHOLD_LOGGING) { - sctp_misc_ints(SCTP_THRESHOLD_CLEAR, - stcb->asoc.overall_error_count, - 0, - SCTP_FROM_SCTP_INPUT, - __LINE__); + return (stcb); } - stcb->asoc.overall_error_count = 0; SCTP_STAT_INCR(sctps_recvheartbeatack); - if (netp && *netp) + if ((netp != NULL) && (*netp != NULL)) { sctp_handle_heartbeat_ack((struct sctp_heartbeat_chunk *)ch, stcb, *netp); + } break; case SCTP_ABORT_ASSOCIATION: SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_ABORT, stcb %p\n", (void *)stcb); - if ((stcb) && netp && *netp) - sctp_handle_abort((struct sctp_abort_chunk *)ch, - stcb, *netp); *offset = length; - return (NULL); + if ((stcb != NULL) && (netp != NULL) && (*netp != NULL)) { + if (sctp_handle_abort((struct sctp_abort_chunk *)ch, stcb, *netp)) { + return (NULL); + } else { + return (stcb); + } + } else { + return (NULL); + } break; case SCTP_SHUTDOWN: SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_SHUTDOWN, stcb %p\n", (void *)stcb); if ((stcb == NULL) || (chk_length != sizeof(struct sctp_shutdown_chunk))) { *offset = length; - if (locked_tcb) { - SCTP_TCB_UNLOCK(locked_tcb); - } - return (NULL); + return (stcb); } - if (netp && *netp) { + if ((netp != NULL) && (*netp != NULL)) { int abort_flag = 0; sctp_handle_shutdown((struct sctp_shutdown_chunk *)ch, @@ -5179,30 +5082,31 @@ process_control_chunks: } break; case SCTP_SHUTDOWN_ACK: - SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_SHUTDOWN-ACK, stcb %p\n", (void *)stcb); - if ((stcb) && (netp) && (*netp)) + SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_SHUTDOWN_ACK, stcb %p\n", (void *)stcb); + if ((stcb != NULL) && (netp != NULL) && (*netp != NULL)) { sctp_handle_shutdown_ack((struct sctp_shutdown_ack_chunk *)ch, stcb, *netp); + } *offset = length; return (NULL); break; - case SCTP_OPERATION_ERROR: - SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_OP-ERR\n"); - if ((stcb) && netp && *netp && sctp_handle_error(ch, stcb, *netp) < 0) { + SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_OP_ERR\n"); + if ((stcb != NULL) && (netp != NULL) && (*netp != NULL) && + sctp_handle_error(ch, stcb, *netp, contiguous) < 0) { *offset = length; return (NULL); } break; case SCTP_COOKIE_ECHO: SCTPDBG(SCTP_DEBUG_INPUT3, - "SCTP_COOKIE-ECHO, stcb %p\n", (void *)stcb); - if ((stcb) && (stcb->asoc.total_output_queue_size)) { + "SCTP_COOKIE_ECHO, stcb %p\n", (void *)stcb); + if ((stcb != NULL) && (stcb->asoc.total_output_queue_size > 0)) { ; } else { if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) { /* We are not interested anymore */ abend: - if (stcb) { + if (stcb != NULL) { SCTP_TCB_UNLOCK(stcb); } *offset = length; @@ -5250,7 +5154,7 @@ process_control_chunks: linp = inp; } - if (linp) { + if (linp != NULL) { SCTP_ASOC_CREATE_LOCK(linp); if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) || (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE)) { @@ -5258,7 +5162,10 @@ process_control_chunks: goto abend; } } - if (netp) { + if (netp != NULL) { + struct sctp_tcb *locked_stcb; + + locked_stcb = stcb; ret_buf = sctp_handle_cookie_echo(m, iphlen, *offset, @@ -5269,20 +5176,26 @@ process_control_chunks: auth_skipped, auth_offset, auth_len, - &locked_tcb, + &locked_stcb, mflowtype, mflowid, vrf_id, port); + if ((locked_stcb != NULL) && (locked_stcb != stcb)) { + SCTP_TCB_UNLOCK(locked_stcb); + } + if (stcb != NULL) { + SCTP_TCB_LOCK_ASSERT(stcb); + } } else { ret_buf = NULL; } - if (linp) { + if (linp != NULL) { SCTP_ASOC_CREATE_UNLOCK(linp); } if (ret_buf == NULL) { - if (locked_tcb) { - SCTP_TCB_UNLOCK(locked_tcb); + if (stcb != NULL) { + SCTP_TCB_UNLOCK(stcb); } SCTPDBG(SCTP_DEBUG_INPUT3, "GAK, null buffer\n"); @@ -5307,12 +5220,9 @@ process_control_chunks: } break; case SCTP_COOKIE_ACK: - SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_COOKIE-ACK, stcb %p\n", (void *)stcb); + SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_COOKIE_ACK, stcb %p\n", (void *)stcb); if ((stcb == NULL) || chk_length != sizeof(struct sctp_cookie_ack_chunk)) { - if (locked_tcb) { - SCTP_TCB_UNLOCK(locked_tcb); - } - return (NULL); + return (stcb); } if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) { /* We are not interested anymore */ @@ -5336,85 +5246,43 @@ process_control_chunks: return (NULL); } } - /* He's alive so give him credit */ - if ((stcb) && netp && *netp) { - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_THRESHOLD_LOGGING) { - sctp_misc_ints(SCTP_THRESHOLD_CLEAR, - stcb->asoc.overall_error_count, - 0, - SCTP_FROM_SCTP_INPUT, - __LINE__); - } - stcb->asoc.overall_error_count = 0; + if ((netp != NULL) && (*netp != NULL)) { sctp_handle_cookie_ack((struct sctp_cookie_ack_chunk *)ch, stcb, *netp); } break; case SCTP_ECN_ECHO: - SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_ECN-ECHO\n"); - /* He's alive so give him credit */ + SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_ECN_ECHO\n"); if ((stcb == NULL) || (chk_length != sizeof(struct sctp_ecne_chunk))) { /* Its not ours */ - if (locked_tcb) { - SCTP_TCB_UNLOCK(locked_tcb); - } *offset = length; - return (NULL); + return (stcb); } - if (stcb) { - if (stcb->asoc.ecn_supported == 0) { - goto unknown_chunk; - } - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_THRESHOLD_LOGGING) { - sctp_misc_ints(SCTP_THRESHOLD_CLEAR, - stcb->asoc.overall_error_count, - 0, - SCTP_FROM_SCTP_INPUT, - __LINE__); - } - stcb->asoc.overall_error_count = 0; - sctp_handle_ecn_echo((struct sctp_ecne_chunk *)ch, - stcb); - ecne_seen = 1; + if (stcb->asoc.ecn_supported == 0) { + goto unknown_chunk; } + sctp_handle_ecn_echo((struct sctp_ecne_chunk *)ch, stcb); + ecne_seen = 1; break; case SCTP_ECN_CWR: - SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_ECN-CWR\n"); - /* He's alive so give him credit */ + SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_ECN_CWR\n"); if ((stcb == NULL) || (chk_length != sizeof(struct sctp_cwr_chunk))) { - /* Its not ours */ - if (locked_tcb) { - SCTP_TCB_UNLOCK(locked_tcb); - } *offset = length; - return (NULL); + return (stcb); } - if (stcb) { - if (stcb->asoc.ecn_supported == 0) { - goto unknown_chunk; - } - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_THRESHOLD_LOGGING) { - sctp_misc_ints(SCTP_THRESHOLD_CLEAR, - stcb->asoc.overall_error_count, - 0, - SCTP_FROM_SCTP_INPUT, - __LINE__); - } - stcb->asoc.overall_error_count = 0; - sctp_handle_ecn_cwr((struct sctp_cwr_chunk *)ch, stcb, *netp); + if (stcb->asoc.ecn_supported == 0) { + goto unknown_chunk; } + sctp_handle_ecn_cwr((struct sctp_cwr_chunk *)ch, stcb, *netp); break; case SCTP_SHUTDOWN_COMPLETE: - SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_SHUTDOWN-COMPLETE, stcb %p\n", (void *)stcb); + SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_SHUTDOWN_COMPLETE, stcb %p\n", (void *)stcb); /* must be first and only chunk */ if ((num_chunks > 1) || (length - *offset > (int)SCTP_SIZE32(chk_length))) { *offset = length; - if (locked_tcb) { - SCTP_TCB_UNLOCK(locked_tcb); - } - return (NULL); + return (stcb); } - if ((stcb) && netp && *netp) { + if ((stcb != NULL) && (netp != NULL) && (*netp != NULL)) { sctp_handle_shutdown_complete((struct sctp_shutdown_complete_chunk *)ch, stcb, *netp); } @@ -5423,35 +5291,23 @@ process_control_chunks: break; case SCTP_ASCONF: SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_ASCONF\n"); - /* He's alive so give him credit */ - if (stcb) { + if (stcb != NULL) { if (stcb->asoc.asconf_supported == 0) { goto unknown_chunk; } - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_THRESHOLD_LOGGING) { - sctp_misc_ints(SCTP_THRESHOLD_CLEAR, - stcb->asoc.overall_error_count, - 0, - SCTP_FROM_SCTP_INPUT, - __LINE__); - } - stcb->asoc.overall_error_count = 0; sctp_handle_asconf(m, *offset, src, (struct sctp_asconf_chunk *)ch, stcb, asconf_cnt == 0); asconf_cnt++; } break; case SCTP_ASCONF_ACK: - SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_ASCONF-ACK\n"); + SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_ASCONF_ACK\n"); if (chk_length < sizeof(struct sctp_asconf_ack_chunk)) { /* Its not ours */ - if (locked_tcb) { - SCTP_TCB_UNLOCK(locked_tcb); - } *offset = length; - return (NULL); + return (stcb); } - if ((stcb) && netp && *netp) { + if ((stcb != NULL) && (netp != NULL) && (*netp != NULL)) { if (stcb->asoc.asconf_supported == 0) { goto unknown_chunk; } @@ -5472,30 +5328,18 @@ process_control_chunks: break; case SCTP_FORWARD_CUM_TSN: case SCTP_IFORWARD_CUM_TSN: - SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_FWD-TSN\n"); + SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_FWD_TSN\n"); if (chk_length < sizeof(struct sctp_forward_tsn_chunk)) { /* Its not ours */ - if (locked_tcb) { - SCTP_TCB_UNLOCK(locked_tcb); - } *offset = length; - return (NULL); + return (stcb); } - /* He's alive so give him credit */ - if (stcb) { + if (stcb != NULL) { int abort_flag = 0; if (stcb->asoc.prsctp_supported == 0) { goto unknown_chunk; } - stcb->asoc.overall_error_count = 0; - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_THRESHOLD_LOGGING) { - sctp_misc_ints(SCTP_THRESHOLD_CLEAR, - stcb->asoc.overall_error_count, - 0, - SCTP_FROM_SCTP_INPUT, - __LINE__); - } *fwd_tsn_seen = 1; if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) { /* We are not interested anymore */ @@ -5525,28 +5369,15 @@ process_control_chunks: if (abort_flag) { *offset = length; return (NULL); - } else { - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_THRESHOLD_LOGGING) { - sctp_misc_ints(SCTP_THRESHOLD_CLEAR, - stcb->asoc.overall_error_count, - 0, - SCTP_FROM_SCTP_INPUT, - __LINE__); - } - stcb->asoc.overall_error_count = 0; } - } break; case SCTP_STREAM_RESET: SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_STREAM_RESET\n"); if (((stcb == NULL) || (ch == NULL) || (chk_length < sizeof(struct sctp_stream_reset_tsn_req)))) { /* Its not ours */ - if (locked_tcb) { - SCTP_TCB_UNLOCK(locked_tcb); - } *offset = length; - return (NULL); + return (stcb); } if (stcb->asoc.reconfig_supported == 0) { goto unknown_chunk; @@ -5562,20 +5393,16 @@ process_control_chunks: /* re-get it all please */ if (chk_length < sizeof(struct sctp_pktdrop_chunk)) { /* Its not ours */ - if (locked_tcb) { - SCTP_TCB_UNLOCK(locked_tcb); - } *offset = length; - return (NULL); + return (stcb); } - if (ch && (stcb) && netp && (*netp)) { + if ((ch != NULL) && (stcb != NULL) && (netp != NULL) && (*netp != NULL)) { if (stcb->asoc.pktdrop_supported == 0) { goto unknown_chunk; } sctp_handle_packet_dropped((struct sctp_pktdrop_chunk *)ch, stcb, *netp, - min(chk_length, (sizeof(chunk_buf) - 4))); - + min(chk_length, contiguous)); } break; case SCTP_AUTHENTICATION: @@ -5597,11 +5424,8 @@ process_control_chunks: (chk_length > (sizeof(struct sctp_auth_chunk) + SCTP_AUTH_DIGEST_LEN_MAX))) { /* Its not ours */ - if (locked_tcb) { - SCTP_TCB_UNLOCK(locked_tcb); - } *offset = length; - return (NULL); + return (stcb); } if (got_auth == 1) { /* skip this chunk... it's already auth'd */ @@ -5666,15 +5490,12 @@ next_chunk: ch = (struct sctp_chunkhdr *)sctp_m_getptr(m, *offset, sizeof(struct sctp_chunkhdr), chunk_buf); if (ch == NULL) { - if (locked_tcb) { - SCTP_TCB_UNLOCK(locked_tcb); - } *offset = length; - return (NULL); + return (stcb); } } /* while */ - if (asconf_cnt > 0 && stcb != NULL) { + if ((asconf_cnt > 0) && (stcb != NULL)) { sctp_send_asconf_ack(stcb); } return (stcb); @@ -5952,14 +5773,6 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt * shows us the cookie-ack was lost. Imply it was * there. */ - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_THRESHOLD_LOGGING) { - sctp_misc_ints(SCTP_THRESHOLD_CLEAR, - stcb->asoc.overall_error_count, - 0, - SCTP_FROM_SCTP_INPUT, - __LINE__); - } - stcb->asoc.overall_error_count = 0; sctp_handle_cookie_ack((struct sctp_cookie_ack_chunk *)ch, stcb, net); break; case SCTP_STATE_COOKIE_WAIT: diff --git a/freebsd/sys/netinet/sctp_input.h b/freebsd/sys/netinet/sctp_input.h index 25df0f3b..ff0916e7 100644 --- a/freebsd/sys/netinet/sctp_input.h +++ b/freebsd/sys/netinet/sctp_input.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. diff --git a/freebsd/sys/netinet/sctp_lock_bsd.h b/freebsd/sys/netinet/sctp_lock_bsd.h index 96e35214..a92d5f2b 100644 --- a/freebsd/sys/netinet/sctp_lock_bsd.h +++ b/freebsd/sys/netinet/sctp_lock_bsd.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. diff --git a/freebsd/sys/netinet/sctp_os.h b/freebsd/sys/netinet/sctp_os.h index dc6049b6..57ab6d79 100644 --- a/freebsd/sys/netinet/sctp_os.h +++ b/freebsd/sys/netinet/sctp_os.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2006-2007, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. diff --git a/freebsd/sys/netinet/sctp_os_bsd.h b/freebsd/sys/netinet/sctp_os_bsd.h index 045ccc38..c9eaa069 100644 --- a/freebsd/sys/netinet/sctp_os_bsd.h +++ b/freebsd/sys/netinet/sctp_os_bsd.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2006-2007, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. diff --git a/freebsd/sys/netinet/sctp_output.c b/freebsd/sys/netinet/sctp_output.c index 2540b5b9..bc54ee96 100644 --- a/freebsd/sys/netinet/sctp_output.c +++ b/freebsd/sys/netinet/sctp_output.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. @@ -3467,32 +3469,35 @@ static int sctp_find_cmsg(int c_type, void *data, struct mbuf *control, size_t cpsize) { struct cmsghdr cmh; - int tlen, at, found; struct sctp_sndinfo sndinfo; struct sctp_prinfo prinfo; struct sctp_authinfo authinfo; + int tot_len, rem_len, cmsg_data_len, cmsg_data_off, off; + int found; - tlen = SCTP_BUF_LEN(control); - at = 0; - found = 0; /* * Independent of how many mbufs, find the c_type inside the control * structure and copy out the data. */ - while (at < tlen) { - if ((tlen - at) < (int)CMSG_ALIGN(sizeof(cmh))) { + found = 0; + tot_len = SCTP_BUF_LEN(control); + for (off = 0; off < tot_len; off += CMSG_ALIGN(cmh.cmsg_len)) { + rem_len = tot_len - off; + if (rem_len < (int)CMSG_ALIGN(sizeof(cmh))) { /* There is not enough room for one more. */ return (found); } - m_copydata(control, at, sizeof(cmh), (caddr_t)&cmh); + m_copydata(control, off, sizeof(cmh), (caddr_t)&cmh); if (cmh.cmsg_len < CMSG_ALIGN(sizeof(cmh))) { /* We dont't have a complete CMSG header. */ return (found); } - if (((int)cmh.cmsg_len + at) > tlen) { + if ((cmh.cmsg_len > INT_MAX) || ((int)cmh.cmsg_len > rem_len)) { /* We don't have the complete CMSG. */ return (found); } + cmsg_data_len = (int)cmh.cmsg_len - CMSG_ALIGN(sizeof(cmh)); + cmsg_data_off = off + CMSG_ALIGN(sizeof(cmh)); if ((cmh.cmsg_level == IPPROTO_SCTP) && ((c_type == cmh.cmsg_type) || ((c_type == SCTP_SNDRCV) && @@ -3500,11 +3505,14 @@ sctp_find_cmsg(int c_type, void *data, struct mbuf *control, size_t cpsize) (cmh.cmsg_type == SCTP_PRINFO) || (cmh.cmsg_type == SCTP_AUTHINFO))))) { if (c_type == cmh.cmsg_type) { - if ((size_t)(cmh.cmsg_len - CMSG_ALIGN(sizeof(cmh))) < cpsize) { + if (cpsize > INT_MAX) { + return (found); + } + if (cmsg_data_len < (int)cpsize) { return (found); } /* It is exactly what we want. Copy it out. */ - m_copydata(control, at + CMSG_ALIGN(sizeof(cmh)), (int)cpsize, (caddr_t)data); + m_copydata(control, cmsg_data_off, (int)cpsize, (caddr_t)data); return (1); } else { struct sctp_sndrcvinfo *sndrcvinfo; @@ -3518,10 +3526,10 @@ sctp_find_cmsg(int c_type, void *data, struct mbuf *control, size_t cpsize) } switch (cmh.cmsg_type) { case SCTP_SNDINFO: - if ((size_t)(cmh.cmsg_len - CMSG_ALIGN(sizeof(cmh))) < sizeof(struct sctp_sndinfo)) { + if (cmsg_data_len < (int)sizeof(struct sctp_sndinfo)) { return (found); } - m_copydata(control, at + CMSG_ALIGN(sizeof(cmh)), sizeof(struct sctp_sndinfo), (caddr_t)&sndinfo); + m_copydata(control, cmsg_data_off, sizeof(struct sctp_sndinfo), (caddr_t)&sndinfo); sndrcvinfo->sinfo_stream = sndinfo.snd_sid; sndrcvinfo->sinfo_flags = sndinfo.snd_flags; sndrcvinfo->sinfo_ppid = sndinfo.snd_ppid; @@ -3529,10 +3537,10 @@ sctp_find_cmsg(int c_type, void *data, struct mbuf *control, size_t cpsize) sndrcvinfo->sinfo_assoc_id = sndinfo.snd_assoc_id; break; case SCTP_PRINFO: - if ((size_t)(cmh.cmsg_len - CMSG_ALIGN(sizeof(cmh))) < sizeof(struct sctp_prinfo)) { + if (cmsg_data_len < (int)sizeof(struct sctp_prinfo)) { return (found); } - m_copydata(control, at + CMSG_ALIGN(sizeof(cmh)), sizeof(struct sctp_prinfo), (caddr_t)&prinfo); + m_copydata(control, cmsg_data_off, sizeof(struct sctp_prinfo), (caddr_t)&prinfo); if (prinfo.pr_policy != SCTP_PR_SCTP_NONE) { sndrcvinfo->sinfo_timetolive = prinfo.pr_value; } else { @@ -3541,10 +3549,10 @@ sctp_find_cmsg(int c_type, void *data, struct mbuf *control, size_t cpsize) sndrcvinfo->sinfo_flags |= prinfo.pr_policy; break; case SCTP_AUTHINFO: - if ((size_t)(cmh.cmsg_len - CMSG_ALIGN(sizeof(cmh))) < sizeof(struct sctp_authinfo)) { + if (cmsg_data_len < (int)sizeof(struct sctp_authinfo)) { return (found); } - m_copydata(control, at + CMSG_ALIGN(sizeof(cmh)), sizeof(struct sctp_authinfo), (caddr_t)&authinfo); + m_copydata(control, cmsg_data_off, sizeof(struct sctp_authinfo), (caddr_t)&authinfo); sndrcvinfo->sinfo_keynumber_valid = 1; sndrcvinfo->sinfo_keynumber = authinfo.auth_keynumber; break; @@ -3554,7 +3562,6 @@ sctp_find_cmsg(int c_type, void *data, struct mbuf *control, size_t cpsize) found = 1; } } - at += CMSG_ALIGN(cmh.cmsg_len); } return (found); } @@ -4270,12 +4277,8 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, /* free tempy routes */ RO_RTFREE(ro); } else { - /* - * PMTU check versus smallest asoc MTU goes - * here - */ - if ((ro->ro_rt != NULL) && - (net->ro._s_addr)) { + if ((ro->ro_rt != NULL) && (net->ro._s_addr) && + ((net->dest_state & SCTP_ADDR_NO_PMTUD) == 0)) { uint32_t mtu; mtu = SCTP_GATHER_MTU_FROM_ROUTE(net->ro._s_addr, &net->ro._l_addr.sa, ro->ro_rt); @@ -4632,8 +4635,8 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, } net->src_addr_selected = 0; } - if ((ro->ro_rt != NULL) && - (net->ro._s_addr)) { + if ((ro->ro_rt != NULL) && (net->ro._s_addr) && + ((net->dest_state & SCTP_ADDR_NO_PMTUD) == 0)) { uint32_t mtu; mtu = SCTP_GATHER_MTU_FROM_ROUTE(net->ro._s_addr, &net->ro._l_addr.sa, ro->ro_rt); @@ -5503,6 +5506,7 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct sctp_paramhdr *ph; union sctp_sockstore *over_addr; struct sctp_scoping scp; + struct timeval now; #ifdef INET struct sockaddr_in *dst4 = (struct sockaddr_in *)dst; struct sockaddr_in *src4 = (struct sockaddr_in *)src; @@ -5603,7 +5607,9 @@ do_a_abort: memset(&stc, 0, sizeof(struct sctp_state_cookie)); /* the time I built cookie */ - (void)SCTP_GETTIME_TIMEVAL(&stc.time_entered); + (void)SCTP_GETTIME_TIMEVAL(&now); + stc.time_entered.tv_sec = now.tv_sec; + stc.time_entered.tv_usec = now.tv_usec; /* populate any tie tags */ if (asoc != NULL) { diff --git a/freebsd/sys/netinet/sctp_output.h b/freebsd/sys/netinet/sctp_output.h index 0a5cf10b..e6222e3f 100644 --- a/freebsd/sys/netinet/sctp_output.h +++ b/freebsd/sys/netinet/sctp_output.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. diff --git a/freebsd/sys/netinet/sctp_pcb.c b/freebsd/sys/netinet/sctp_pcb.c index 46a91110..cf993d64 100644 --- a/freebsd/sys/netinet/sctp_pcb.c +++ b/freebsd/sys/netinet/sctp_pcb.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. @@ -2579,6 +2581,7 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id) /* number of streams to pre-open on a association */ m->pre_open_stream_count = SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default); + m->default_mtu = 0; /* Add adaptation cookie */ m->adaptation_layer_indicator = 0; m->adaptation_layer_indicator_provided = 0; @@ -3946,7 +3949,28 @@ sctp_add_remote_addr(struct sctp_tcb *stcb, struct sockaddr *newaddr, net, 0, stcb->asoc.vrf_id); - if (net->ro._s_addr != NULL) { + if (stcb->asoc.default_mtu > 0) { + net->mtu = stcb->asoc.default_mtu; + switch (net->ro._l_addr.sa.sa_family) { +#ifdef INET + case AF_INET: + net->mtu += SCTP_MIN_V4_OVERHEAD; + break; +#endif +#ifdef INET6 + case AF_INET6: + net->mtu += SCTP_MIN_OVERHEAD; + break; +#endif + default: + break; + } +#if defined(INET) || defined(INET6) + if (net->port) { + net->mtu += (uint32_t)sizeof(struct udphdr); + } +#endif + } else if (net->ro._s_addr != NULL) { uint32_t imtu, rmtu, hcmtu; net->src_addr_selected = 1; @@ -3970,19 +3994,42 @@ sctp_add_remote_addr(struct sctp_tcb *stcb, struct sockaddr *newaddr, } } if (net->mtu == 0) { - switch (newaddr->sa_family) { + if (stcb->asoc.default_mtu > 0) { + net->mtu = stcb->asoc.default_mtu; + switch (net->ro._l_addr.sa.sa_family) { #ifdef INET - case AF_INET: - net->mtu = SCTP_DEFAULT_MTU; - break; + case AF_INET: + net->mtu += SCTP_MIN_V4_OVERHEAD; + break; #endif #ifdef INET6 - case AF_INET6: - net->mtu = 1280; - break; + case AF_INET6: + net->mtu += SCTP_MIN_OVERHEAD; + break; #endif - default: - break; + default: + break; + } +#if defined(INET) || defined(INET6) + if (net->port) { + net->mtu += (uint32_t)sizeof(struct udphdr); + } +#endif + } else { + switch (newaddr->sa_family) { +#ifdef INET + case AF_INET: + net->mtu = SCTP_DEFAULT_MTU; + break; +#endif +#ifdef INET6 + case AF_INET6: + net->mtu = 1280; + break; +#endif + default: + break; + } } } #if defined(INET) || defined(INET6) diff --git a/freebsd/sys/netinet/sctp_pcb.h b/freebsd/sys/netinet/sctp_pcb.h index acc68311..3fc03399 100644 --- a/freebsd/sys/netinet/sctp_pcb.h +++ b/freebsd/sys/netinet/sctp_pcb.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. @@ -287,6 +289,7 @@ struct sctp_pcb { sctp_auth_chklist_t *local_auth_chunks; sctp_hmaclist_t *local_hmacs; uint16_t default_keyid; + uint32_t default_mtu; /* various thresholds */ /* Max times I will init at a guy */ diff --git a/freebsd/sys/netinet/sctp_peeloff.c b/freebsd/sys/netinet/sctp_peeloff.c index 3603e41a..ad96b88c 100644 --- a/freebsd/sys/netinet/sctp_peeloff.c +++ b/freebsd/sys/netinet/sctp_peeloff.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. diff --git a/freebsd/sys/netinet/sctp_peeloff.h b/freebsd/sys/netinet/sctp_peeloff.h index 00b87031..478b1995 100644 --- a/freebsd/sys/netinet/sctp_peeloff.h +++ b/freebsd/sys/netinet/sctp_peeloff.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. diff --git a/freebsd/sys/netinet/sctp_structs.h b/freebsd/sys/netinet/sctp_structs.h index f7371748..d60705b4 100644 --- a/freebsd/sys/netinet/sctp_structs.h +++ b/freebsd/sys/netinet/sctp_structs.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. @@ -1098,6 +1100,7 @@ struct sctp_association { uint32_t chunks_on_out_queue; /* total chunks floating around, * locked by send socket buffer */ uint32_t peers_adaptation; + uint32_t default_mtu; uint16_t peer_hmac_id; /* peer HMAC id to send */ /* diff --git a/freebsd/sys/netinet/sctp_sysctl.c b/freebsd/sys/netinet/sctp_sysctl.c index 52361602..8259140f 100644 --- a/freebsd/sys/netinet/sctp_sysctl.c +++ b/freebsd/sys/netinet/sctp_sysctl.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2007, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. diff --git a/freebsd/sys/netinet/sctp_sysctl.h b/freebsd/sys/netinet/sctp_sysctl.h index 959bd1e4..8187ae9e 100644 --- a/freebsd/sys/netinet/sctp_sysctl.h +++ b/freebsd/sys/netinet/sctp_sysctl.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2007, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. diff --git a/freebsd/sys/netinet/sctp_timer.c b/freebsd/sys/netinet/sctp_timer.c index ecadca5b..c0253840 100644 --- a/freebsd/sys/netinet/sctp_timer.c +++ b/freebsd/sys/netinet/sctp_timer.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. diff --git a/freebsd/sys/netinet/sctp_timer.h b/freebsd/sys/netinet/sctp_timer.h index 6d409cdc..d58fbaa9 100644 --- a/freebsd/sys/netinet/sctp_timer.h +++ b/freebsd/sys/netinet/sctp_timer.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. diff --git a/freebsd/sys/netinet/sctp_uio.h b/freebsd/sys/netinet/sctp_uio.h index daa6847d..93274a70 100644 --- a/freebsd/sys/netinet/sctp_uio.h +++ b/freebsd/sys/netinet/sctp_uio.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. diff --git a/freebsd/sys/netinet/sctp_usrreq.c b/freebsd/sys/netinet/sctp_usrreq.c index 6ab04456..05ddee01 100644 --- a/freebsd/sys/netinet/sctp_usrreq.c +++ b/freebsd/sys/netinet/sctp_usrreq.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. @@ -204,6 +206,10 @@ sctp_notify(struct sctp_inpcb *inp, #endif /* no need to unlock here, since the TCB is gone */ } else if (icmp_code == ICMP_UNREACH_NEEDFRAG) { + if ((net->dest_state & SCTP_ADDR_NO_PMTUD) == 0) { + SCTP_TCB_UNLOCK(stcb); + return; + } /* Find the next (smaller) MTU */ if (next_mtu == 0) { /* @@ -2414,7 +2420,7 @@ flags_out: #endif #ifdef INET6 case AF_INET6: - paddrp->spp_pathmtu -= SCTP_MIN_V4_OVERHEAD; + paddrp->spp_pathmtu -= SCTP_MIN_OVERHEAD; break; #endif default: @@ -2449,7 +2455,7 @@ flags_out: * value */ paddrp->spp_pathmaxrxt = stcb->asoc.def_net_failure; - paddrp->spp_pathmtu = 0; + paddrp->spp_pathmtu = stcb->asoc.default_mtu; if (stcb->asoc.default_dscp & 0x01) { paddrp->spp_dscp = stcb->asoc.default_dscp & 0xfc; paddrp->spp_flags |= SPP_DSCP; @@ -2496,8 +2502,7 @@ flags_out: paddrp->spp_flags |= SPP_IPV6_FLOWLABEL; } #endif - /* can't return this */ - paddrp->spp_pathmtu = 0; + paddrp->spp_pathmtu = inp->sctp_ep.default_mtu; if (sctp_is_feature_off(inp, SCTP_PCB_FLAGS_DONOT_HEARTBEAT)) { paddrp->spp_flags |= SPP_HB_ENABLE; @@ -5481,6 +5486,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, sctp_pathmtu_adjustment(stcb, net->mtu); } } + stcb->asoc.default_mtu = paddrp->spp_pathmtu; sctp_stcb_feature_on(inp, stcb, SCTP_PCB_FLAGS_DO_NOT_PMTUD); } if (paddrp->spp_flags & SPP_PMTUD_ENABLE) { @@ -5490,6 +5496,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, } net->dest_state &= ~SCTP_ADDR_NO_PMTUD; } + stcb->asoc.default_mtu = 0; sctp_stcb_feature_off(inp, stcb, SCTP_PCB_FLAGS_DO_NOT_PMTUD); } if (paddrp->spp_flags & SPP_DSCP) { @@ -5546,8 +5553,12 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, sctp_feature_on(inp, SCTP_PCB_FLAGS_DONOT_HEARTBEAT); } if (paddrp->spp_flags & SPP_PMTUD_ENABLE) { + inp->sctp_ep.default_mtu = 0; sctp_feature_off(inp, SCTP_PCB_FLAGS_DO_NOT_PMTUD); } else if (paddrp->spp_flags & SPP_PMTUD_DISABLE) { + if (paddrp->spp_pathmtu >= SCTP_SMALLEST_PMTU) { + inp->sctp_ep.default_mtu = paddrp->spp_pathmtu; + } sctp_feature_on(inp, SCTP_PCB_FLAGS_DO_NOT_PMTUD); } if (paddrp->spp_flags & SPP_DSCP) { diff --git a/freebsd/sys/netinet/sctp_var.h b/freebsd/sys/netinet/sctp_var.h index 9e149e68..84cbfc88 100644 --- a/freebsd/sys/netinet/sctp_var.h +++ b/freebsd/sys/netinet/sctp_var.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. diff --git a/freebsd/sys/netinet/sctputil.c b/freebsd/sys/netinet/sctputil.c index f8fd23f1..98c2a708 100644 --- a/freebsd/sys/netinet/sctputil.c +++ b/freebsd/sys/netinet/sctputil.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. @@ -1044,6 +1046,7 @@ sctp_init_asoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, asoc->initial_init_rto_max = inp->sctp_ep.initial_init_rto_max; asoc->initial_rto = inp->sctp_ep.initial_rto; + asoc->default_mtu = inp->sctp_ep.default_mtu; asoc->max_init_times = inp->sctp_ep.max_init_times; asoc->max_send_times = inp->sctp_ep.max_send_times; asoc->def_net_failure = inp->sctp_ep.def_net_failure; @@ -2424,8 +2427,8 @@ uint32_t sctp_calculate_rto(struct sctp_tcb *stcb, struct sctp_association *asoc, struct sctp_nets *net, - struct timeval *told, - int safe, int rtt_from_sack) + struct timeval *old, + int rtt_from_sack) { /*- * given an association and the starting time of the current RTT @@ -2434,19 +2437,8 @@ sctp_calculate_rto(struct sctp_tcb *stcb, int32_t rtt; /* RTT in ms */ uint32_t new_rto; int first_measure = 0; - struct timeval now, then, *old; - - /* Copy it out for sparc64 */ - if (safe == sctp_align_unsafe_makecopy) { - old = &then; - memcpy(&then, told, sizeof(struct timeval)); - } else if (safe == sctp_align_safe_nocopy) { - old = told; - } else { - /* error */ - SCTP_PRINTF("Huh, bad rto calc call\n"); - return (0); - } + struct timeval now; + /************************/ /* 1. calculate new RTT */ /************************/ @@ -4687,14 +4679,14 @@ sctp_release_pr_sctp_chunk(struct sctp_tcb *stcb, struct sctp_tmit_chunk *tp1, stcb->asoc.abandoned_sent[PR_SCTP_POLICY(tp1->flags)]++; stcb->asoc.strmout[sid].abandoned_sent[0]++; #if defined(SCTP_DETAILED_STR_STATS) - stcb->asoc.strmout[stream].abandoned_sent[PR_SCTP_POLICY(tp1->flags)]++; + stcb->asoc.strmout[sid].abandoned_sent[PR_SCTP_POLICY(tp1->flags)]++; #endif } else { stcb->asoc.abandoned_unsent[0]++; stcb->asoc.abandoned_unsent[PR_SCTP_POLICY(tp1->flags)]++; stcb->asoc.strmout[sid].abandoned_unsent[0]++; #if defined(SCTP_DETAILED_STR_STATS) - stcb->asoc.strmout[stream].abandoned_unsent[PR_SCTP_POLICY(tp1->flags)]++; + stcb->asoc.strmout[sid].abandoned_unsent[PR_SCTP_POLICY(tp1->flags)]++; #endif } do { diff --git a/freebsd/sys/netinet/sctputil.h b/freebsd/sys/netinet/sctputil.h index 97b33654..61d34591 100644 --- a/freebsd/sys/netinet/sctputil.h +++ b/freebsd/sys/netinet/sctputil.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. @@ -135,7 +137,7 @@ void uint32_t sctp_calculate_rto(struct sctp_tcb *, struct sctp_association *, - struct sctp_nets *, struct timeval *, int, int); + struct sctp_nets *, struct timeval *, int); uint32_t sctp_calculate_len(struct mbuf *); diff --git a/freebsd/sys/netinet/tcp_debug.c b/freebsd/sys/netinet/tcp_debug.c index 8835370b..0036b422 100644 --- a/freebsd/sys/netinet/tcp_debug.c +++ b/freebsd/sys/netinet/tcp_debug.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. * All rights reserved. diff --git a/freebsd/sys/netinet/tcp_debug.h b/freebsd/sys/netinet/tcp_debug.h index aa26c292..a51c15a4 100644 --- a/freebsd/sys/netinet/tcp_debug.h +++ b/freebsd/sys/netinet/tcp_debug.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/netinet/tcp_fsm.h b/freebsd/sys/netinet/tcp_fsm.h index ddb52084..dcc4a4e8 100644 --- a/freebsd/sys/netinet/tcp_fsm.h +++ b/freebsd/sys/netinet/tcp_fsm.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. * All rights reserved. diff --git a/freebsd/sys/netinet/tcp_hostcache.c b/freebsd/sys/netinet/tcp_hostcache.c index 0452f5db..d1de3f33 100644 --- a/freebsd/sys/netinet/tcp_hostcache.c +++ b/freebsd/sys/netinet/tcp_hostcache.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2002 Andre Oppermann, Internet Business Solutions AG * All rights reserved. * diff --git a/freebsd/sys/netinet/tcp_hostcache.h b/freebsd/sys/netinet/tcp_hostcache.h index 23a0c673..f4e1013a 100644 --- a/freebsd/sys/netinet/tcp_hostcache.h +++ b/freebsd/sys/netinet/tcp_hostcache.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2002 Andre Oppermann, Internet Business Solutions AG * All rights reserved. * diff --git a/freebsd/sys/netinet/tcp_input.c b/freebsd/sys/netinet/tcp_input.c index 663b8bc2..b172205d 100644 --- a/freebsd/sys/netinet/tcp_input.c +++ b/freebsd/sys/netinet/tcp_input.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994, 1995 * The Regents of the University of California. All rights reserved. * Copyright (c) 2007-2008,2010 @@ -147,7 +149,6 @@ SYSCTL_INT(_net_inet_tcp, OID_AUTO, delayed_ack, CTLFLAG_VNET | CTLFLAG_RW, "Delay ACK to try and piggyback it onto a data packet"); VNET_DEFINE(int, drop_synfin) = 0; -#define V_drop_synfin VNET(drop_synfin) SYSCTL_INT(_net_inet_tcp, OID_AUTO, drop_synfin, CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(drop_synfin), 0, "Drop TCP packets with SYN+FIN set"); @@ -158,7 +159,6 @@ SYSCTL_INT(_net_inet_tcp, OID_AUTO, rfc6675_pipe, CTLFLAG_VNET | CTLFLAG_RW, "Use calculated pipe/in-flight bytes per RFC 6675"); VNET_DEFINE(int, tcp_do_rfc3042) = 1; -#define V_tcp_do_rfc3042 VNET(tcp_do_rfc3042) SYSCTL_INT(_net_inet_tcp, OID_AUTO, rfc3042, CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(tcp_do_rfc3042), 0, "Enable RFC 3042 (Limited Transmit)"); @@ -196,13 +196,11 @@ SYSCTL_INT(_net_inet_tcp_ecn, OID_AUTO, maxretries, CTLFLAG_VNET | CTLFLAG_RW, "Max retries before giving up on ECN"); VNET_DEFINE(int, tcp_insecure_syn) = 0; -#define V_tcp_insecure_syn VNET(tcp_insecure_syn) SYSCTL_INT(_net_inet_tcp, OID_AUTO, insecure_syn, CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(tcp_insecure_syn), 0, "Follow RFC793 instead of RFC5961 criteria for accepting SYN packets"); VNET_DEFINE(int, tcp_insecure_rst) = 0; -#define V_tcp_insecure_rst VNET(tcp_insecure_rst) SYSCTL_INT(_net_inet_tcp, OID_AUTO, insecure_rst, CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(tcp_insecure_rst), 0, "Follow RFC793 instead of RFC5961 criteria for accepting RST packets"); @@ -213,19 +211,16 @@ SYSCTL_INT(_net_inet_tcp, TCPCTL_RECVSPACE, recvspace, CTLFLAG_VNET | CTLFLAG_RW &VNET_NAME(tcp_recvspace), 0, "Initial receive socket buffer size"); VNET_DEFINE(int, tcp_do_autorcvbuf) = 1; -#define V_tcp_do_autorcvbuf VNET(tcp_do_autorcvbuf) SYSCTL_INT(_net_inet_tcp, OID_AUTO, recvbuf_auto, CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(tcp_do_autorcvbuf), 0, "Enable automatic receive buffer sizing"); VNET_DEFINE(int, tcp_autorcvbuf_inc) = 16*1024; -#define V_tcp_autorcvbuf_inc VNET(tcp_autorcvbuf_inc) SYSCTL_INT(_net_inet_tcp, OID_AUTO, recvbuf_inc, CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(tcp_autorcvbuf_inc), 0, "Incrementor step size of automatic receive buffer"); VNET_DEFINE(int, tcp_autorcvbuf_max) = 2*1024*1024; -#define V_tcp_autorcvbuf_max VNET(tcp_autorcvbuf_max) SYSCTL_INT(_net_inet_tcp, OID_AUTO, recvbuf_max, CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(tcp_autorcvbuf_max), 0, "Max size of automatic receive buffer"); diff --git a/freebsd/sys/netinet/tcp_lro.c b/freebsd/sys/netinet/tcp_lro.c index 91d534f1..50481b50 100644 --- a/freebsd/sys/netinet/tcp_lro.c +++ b/freebsd/sys/netinet/tcp_lro.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007, Myricom Inc. * Copyright (c) 2008, Intel Corporation. * Copyright (c) 2012 The FreeBSD Foundation diff --git a/freebsd/sys/netinet/tcp_lro.h b/freebsd/sys/netinet/tcp_lro.h index e019cd1e..855f4ee4 100644 --- a/freebsd/sys/netinet/tcp_lro.h +++ b/freebsd/sys/netinet/tcp_lro.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2006, Myricom Inc. * Copyright (c) 2008, Intel Corporation. * Copyright (c) 2016 Mellanox Technologies. diff --git a/freebsd/sys/netinet/tcp_offload.c b/freebsd/sys/netinet/tcp_offload.c index 12882225..41302db1 100644 --- a/freebsd/sys/netinet/tcp_offload.c +++ b/freebsd/sys/netinet/tcp_offload.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2012 Chelsio Communications, Inc. * All rights reserved. * diff --git a/freebsd/sys/netinet/tcp_offload.h b/freebsd/sys/netinet/tcp_offload.h index a0523665..8485fa29 100644 --- a/freebsd/sys/netinet/tcp_offload.h +++ b/freebsd/sys/netinet/tcp_offload.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2012 Chelsio Communications, Inc. * All rights reserved. * diff --git a/freebsd/sys/netinet/tcp_output.c b/freebsd/sys/netinet/tcp_output.c index 30ec34de..1cb622ac 100644 --- a/freebsd/sys/netinet/tcp_output.c +++ b/freebsd/sys/netinet/tcp_output.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995 * The Regents of the University of California. All rights reserved. * @@ -104,7 +106,6 @@ SYSCTL_INT(_net_inet_tcp, OID_AUTO, path_mtu_discovery, CTLFLAG_VNET | CTLFLAG_R "Enable Path MTU Discovery"); VNET_DEFINE(int, tcp_do_tso) = 1; -#define V_tcp_do_tso VNET(tcp_do_tso) SYSCTL_INT(_net_inet_tcp, OID_AUTO, tso, CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(tcp_do_tso), 0, "Enable TCP Segmentation Offload"); @@ -115,19 +116,16 @@ SYSCTL_INT(_net_inet_tcp, TCPCTL_SENDSPACE, sendspace, CTLFLAG_VNET | CTLFLAG_RW &VNET_NAME(tcp_sendspace), 0, "Initial send socket buffer size"); VNET_DEFINE(int, tcp_do_autosndbuf) = 1; -#define V_tcp_do_autosndbuf VNET(tcp_do_autosndbuf) SYSCTL_INT(_net_inet_tcp, OID_AUTO, sendbuf_auto, CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(tcp_do_autosndbuf), 0, "Enable automatic send buffer sizing"); VNET_DEFINE(int, tcp_autosndbuf_inc) = 8*1024; -#define V_tcp_autosndbuf_inc VNET(tcp_autosndbuf_inc) SYSCTL_INT(_net_inet_tcp, OID_AUTO, sendbuf_inc, CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(tcp_autosndbuf_inc), 0, "Incrementor step size of automatic send buffer"); VNET_DEFINE(int, tcp_autosndbuf_max) = 2*1024*1024; -#define V_tcp_autosndbuf_max VNET(tcp_autosndbuf_max) SYSCTL_INT(_net_inet_tcp, OID_AUTO, sendbuf_max, CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(tcp_autosndbuf_max), 0, "Max size of automatic send buffer"); @@ -529,12 +527,12 @@ after_sack_rexmit: * XXXGL: should there be used sbused() or sbavail()? */ if (V_tcp_do_autosndbuf && so->so_snd.sb_flags & SB_AUTOSIZE) { - int autosndbuf_mod = 0; - if (V_tcp_sendbuf_auto_lowat) - autosndbuf_mod = so->so_snd.sb_lowat; + int lowat; - if ((tp->snd_wnd / 4 * 5) >= so->so_snd.sb_hiwat - autosndbuf_mod && - sbused(&so->so_snd) >= (so->so_snd.sb_hiwat / 8 * 7) - autosndbuf_mod && + lowat = V_tcp_sendbuf_auto_lowat ? so->so_snd.sb_lowat : 0; + if ((tp->snd_wnd / 4 * 5) >= so->so_snd.sb_hiwat - lowat && + sbused(&so->so_snd) >= + (so->so_snd.sb_hiwat / 8 * 7) - lowat && sbused(&so->so_snd) < V_tcp_autosndbuf_max && sendwin >= (sbused(&so->so_snd) - (tp->snd_nxt - tp->snd_una))) { diff --git a/freebsd/sys/netinet/tcp_reass.c b/freebsd/sys/netinet/tcp_reass.c index 4f944cab..dbb61299 100644 --- a/freebsd/sys/netinet/tcp_reass.c +++ b/freebsd/sys/netinet/tcp_reass.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994, 1995 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/netinet/tcp_sack.c b/freebsd/sys/netinet/tcp_sack.c index 00876890..91c032c8 100644 --- a/freebsd/sys/netinet/tcp_sack.c +++ b/freebsd/sys/netinet/tcp_sack.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994, 1995 * The Regents of the University of California. * All rights reserved. @@ -13,7 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -135,19 +137,16 @@ SYSCTL_INT(_net_inet_tcp_sack, OID_AUTO, enable, CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(tcp_do_sack), 0, "Enable/Disable TCP SACK support"); VNET_DEFINE(int, tcp_sack_maxholes) = 128; -#define V_tcp_sack_maxholes VNET(tcp_sack_maxholes) SYSCTL_INT(_net_inet_tcp_sack, OID_AUTO, maxholes, CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(tcp_sack_maxholes), 0, "Maximum number of TCP SACK holes allowed per connection"); VNET_DEFINE(int, tcp_sack_globalmaxholes) = 65536; -#define V_tcp_sack_globalmaxholes VNET(tcp_sack_globalmaxholes) SYSCTL_INT(_net_inet_tcp_sack, OID_AUTO, globalmaxholes, CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(tcp_sack_globalmaxholes), 0, "Global maximum number of TCP SACK holes"); VNET_DEFINE(int, tcp_sack_globalholes) = 0; -#define V_tcp_sack_globalholes VNET(tcp_sack_globalholes) SYSCTL_INT(_net_inet_tcp_sack, OID_AUTO, globalholes, CTLFLAG_VNET | CTLFLAG_RD, &VNET_NAME(tcp_sack_globalholes), 0, "Global number of TCP SACK holes currently allocated"); diff --git a/freebsd/sys/netinet/tcp_seq.h b/freebsd/sys/netinet/tcp_seq.h index cfc1ccf7..ee1e1bfd 100644 --- a/freebsd/sys/netinet/tcp_seq.h +++ b/freebsd/sys/netinet/tcp_seq.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1993, 1995 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/netinet/tcp_subr.c b/freebsd/sys/netinet/tcp_subr.c index dff41275..d9c0b57e 100644 --- a/freebsd/sys/netinet/tcp_subr.c +++ b/freebsd/sys/netinet/tcp_subr.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995 * The Regents of the University of California. All rights reserved. * @@ -1242,16 +1244,20 @@ tcp_respond(struct tcpcb *tp, void *ipgen, struct tcphdr *th, struct mbuf *m, if (flags & TH_RST) TCP_PROBE5(accept__refused, NULL, NULL, m, tp, nth); - TCP_PROBE5(send, NULL, tp, m, tp, nth); #ifdef INET6 - if (isipv6) - (void) ip6_output(m, NULL, NULL, 0, NULL, NULL, inp); + if (isipv6) { + TCP_PROBE5(send, NULL, tp, ip6, tp, nth); + (void)ip6_output(m, NULL, NULL, 0, NULL, NULL, inp); + } #endif /* INET6 */ #if defined(INET) && defined(INET6) else #endif #ifdef INET - (void) ip_output(m, NULL, NULL, 0, NULL, inp); + { + TCP_PROBE5(send, NULL, tp, ip, tp, nth); + (void)ip_output(m, NULL, NULL, 0, NULL, inp); + } #endif } diff --git a/freebsd/sys/netinet/tcp_syncache.c b/freebsd/sys/netinet/tcp_syncache.c index a30def41..0dc4a0a5 100644 --- a/freebsd/sys/netinet/tcp_syncache.c +++ b/freebsd/sys/netinet/tcp_syncache.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 McAfee, Inc. * Copyright (c) 2006,2013 Andre Oppermann, Internet Business Solutions AG * All rights reserved. @@ -1205,6 +1207,7 @@ syncache_tfo_expand(struct syncache *sc, struct socket **lsop, struct mbuf *m, TCPSTAT_INC(tcps_sc_aborted); atomic_subtract_int(pending_counter, 1); } else { + soisconnected(*lsop); inp = sotoinpcb(*lsop); tp = intotcpcb(inp); tp->t_flags |= TF_FASTOPEN; diff --git a/freebsd/sys/netinet/tcp_syncache.h b/freebsd/sys/netinet/tcp_syncache.h index 3932cab7..d9ebb65c 100644 --- a/freebsd/sys/netinet/tcp_syncache.h +++ b/freebsd/sys/netinet/tcp_syncache.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1993, 1994, 1995 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/netinet/tcp_timer.c b/freebsd/sys/netinet/tcp_timer.c index b4528801..a2f854d7 100644 --- a/freebsd/sys/netinet/tcp_timer.c +++ b/freebsd/sys/netinet/tcp_timer.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995 * The Regents of the University of California. All rights reserved. * @@ -143,16 +145,14 @@ SYSCTL_INT(_net_inet_tcp, OID_AUTO, rexmit_drop_options, CTLFLAG_RW, &tcp_rexmit_drop_options, 0, "Drop TCP options from 3rd and later retransmitted SYN"); -static VNET_DEFINE(int, tcp_pmtud_blackhole_detect); -#define V_tcp_pmtud_blackhole_detect VNET(tcp_pmtud_blackhole_detect) +VNET_DEFINE(int, tcp_pmtud_blackhole_detect); SYSCTL_INT(_net_inet_tcp, OID_AUTO, pmtud_blackhole_detection, CTLFLAG_RW|CTLFLAG_VNET, &VNET_NAME(tcp_pmtud_blackhole_detect), 0, "Path MTU Discovery Black Hole Detection Enabled"); #ifdef INET -static VNET_DEFINE(int, tcp_pmtud_blackhole_mss) = 1200; -#define V_tcp_pmtud_blackhole_mss VNET(tcp_pmtud_blackhole_mss) +VNET_DEFINE(int, tcp_pmtud_blackhole_mss) = 1200; SYSCTL_INT(_net_inet_tcp, OID_AUTO, pmtud_blackhole_mss, CTLFLAG_RW|CTLFLAG_VNET, &VNET_NAME(tcp_pmtud_blackhole_mss), 0, @@ -160,8 +160,7 @@ SYSCTL_INT(_net_inet_tcp, OID_AUTO, pmtud_blackhole_mss, #endif #ifdef INET6 -static VNET_DEFINE(int, tcp_v6pmtud_blackhole_mss) = 1220; -#define V_tcp_v6pmtud_blackhole_mss VNET(tcp_v6pmtud_blackhole_mss) +VNET_DEFINE(int, tcp_v6pmtud_blackhole_mss) = 1220; SYSCTL_INT(_net_inet_tcp, OID_AUTO, v6pmtud_blackhole_mss, CTLFLAG_RW|CTLFLAG_VNET, &VNET_NAME(tcp_v6pmtud_blackhole_mss), 0, diff --git a/freebsd/sys/netinet/tcp_timer.h b/freebsd/sys/netinet/tcp_timer.h index f14f929a..9a26c95d 100644 --- a/freebsd/sys/netinet/tcp_timer.h +++ b/freebsd/sys/netinet/tcp_timer.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. * @@ -198,6 +200,13 @@ extern int tcp_syn_backoff[]; extern int tcp_finwait2_timeout; extern int tcp_fast_finwait2_recycle; +VNET_DECLARE(int, tcp_pmtud_blackhole_detect); +#define V_tcp_pmtud_blackhole_detect VNET(tcp_pmtud_blackhole_detect) +VNET_DECLARE(int, tcp_pmtud_blackhole_mss); +#define V_tcp_pmtud_blackhole_mss VNET(tcp_pmtud_blackhole_mss) +VNET_DECLARE(int, tcp_v6pmtud_blackhole_mss); +#define V_tcp_v6pmtud_blackhole_mss VNET(tcp_v6pmtud_blackhole_mss) + int tcp_inpinfo_lock_add(struct inpcb *inp); void tcp_inpinfo_lock_del(struct inpcb *inp, struct tcpcb *tp); diff --git a/freebsd/sys/netinet/tcp_timewait.c b/freebsd/sys/netinet/tcp_timewait.c index 13105339..61263dfe 100644 --- a/freebsd/sys/netinet/tcp_timewait.c +++ b/freebsd/sys/netinet/tcp_timewait.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995 * The Regents of the University of California. All rights reserved. * @@ -49,6 +51,9 @@ __FBSDID("$FreeBSD$"); #include <sys/proc.h> #include <sys/socket.h> #include <sys/socketvar.h> +#ifndef INVARIANTS +#include <sys/syslog.h> +#endif #include <sys/protosw.h> #include <sys/random.h> @@ -711,10 +716,29 @@ tcp_tw_2msl_scan(int reuse) INP_WLOCK(inp); tw = intotw(inp); if (in_pcbrele_wlocked(inp)) { - KASSERT(tw == NULL, ("%s: held last inp " - "reference but tw not NULL", __func__)); - INP_INFO_RUNLOCK(&V_tcbinfo); - continue; + if (__predict_true(tw == NULL)) { + INP_INFO_RUNLOCK(&V_tcbinfo); + continue; + } else { + /* This should not happen as in TIMEWAIT + * state the inp should not be destroyed + * before its tcptw. If INVARIANTS is + * defined panic. + */ +#ifdef INVARIANTS + panic("%s: Panic before an infinite " + "loop: INP_TIMEWAIT && (INP_FREED " + "|| inp last reference) && tw != " + "NULL", __func__); +#else + log(LOG_ERR, "%s: Avoid an infinite " + "loop: INP_TIMEWAIT && (INP_FREED " + "|| inp last reference) && tw != " + "NULL", __func__); +#endif + INP_INFO_RUNLOCK(&V_tcbinfo); + break; + } } if (tw == NULL) { diff --git a/freebsd/sys/netinet/tcp_usrreq.c b/freebsd/sys/netinet/tcp_usrreq.c index 88cc3501..76c6d952 100644 --- a/freebsd/sys/netinet/tcp_usrreq.c +++ b/freebsd/sys/netinet/tcp_usrreq.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1988, 1993 * The Regents of the University of California. * Copyright (c) 2006-2007 Robert N. M. Watson diff --git a/freebsd/sys/netinet/tcp_var.h b/freebsd/sys/netinet/tcp_var.h index 967a5139..0bcb3dc6 100644 --- a/freebsd/sys/netinet/tcp_var.h +++ b/freebsd/sys/netinet/tcp_var.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1993, 1994, 1995 * The Regents of the University of California. All rights reserved. * @@ -201,12 +203,6 @@ struct tcpcb { #endif /* _KERNEL || _WANT_TCPCB */ #ifdef _KERNEL -/* - * Kernel variables for tcp. - */ -VNET_DECLARE(int, tcp_do_rfc1323); -#define V_tcp_do_rfc1323 VNET(tcp_do_rfc1323) - struct tcptemp { u_char tt_ipgen[40]; /* the size must be of max ip header, now IPv6 */ struct tcphdr tt_t; @@ -701,50 +697,83 @@ SYSCTL_DECL(_net_inet_tcp_sack); MALLOC_DECLARE(M_TCPLOG); #endif -VNET_DECLARE(struct inpcbhead, tcb); /* queue of active tcpcb's */ -VNET_DECLARE(struct inpcbinfo, tcbinfo); extern int tcp_log_in_vain; -VNET_DECLARE(int, tcp_mssdflt); /* XXX */ -VNET_DECLARE(int, tcp_minmss); + +/* + * Global TCP tunables shared between different stacks. + * Please keep the list sorted. + */ +VNET_DECLARE(int, drop_synfin); +VNET_DECLARE(int, path_mtu_discovery); +VNET_DECLARE(int, tcp_abc_l_var); +VNET_DECLARE(int, tcp_autorcvbuf_inc); +VNET_DECLARE(int, tcp_autorcvbuf_max); +VNET_DECLARE(int, tcp_autosndbuf_inc); +VNET_DECLARE(int, tcp_autosndbuf_max); VNET_DECLARE(int, tcp_delack_enabled); +VNET_DECLARE(int, tcp_do_autorcvbuf); +VNET_DECLARE(int, tcp_do_autosndbuf); +VNET_DECLARE(int, tcp_do_ecn); +VNET_DECLARE(int, tcp_do_rfc1323); +VNET_DECLARE(int, tcp_do_rfc3042); VNET_DECLARE(int, tcp_do_rfc3390); -VNET_DECLARE(int, tcp_initcwnd_segments); -VNET_DECLARE(int, tcp_sendspace); -VNET_DECLARE(int, tcp_recvspace); -VNET_DECLARE(int, path_mtu_discovery); VNET_DECLARE(int, tcp_do_rfc3465); -VNET_DECLARE(int, tcp_abc_l_var); -#define V_tcb VNET(tcb) -#define V_tcbinfo VNET(tcbinfo) -#define V_tcp_mssdflt VNET(tcp_mssdflt) -#define V_tcp_minmss VNET(tcp_minmss) -#define V_tcp_delack_enabled VNET(tcp_delack_enabled) -#define V_tcp_do_rfc3390 VNET(tcp_do_rfc3390) -#define V_tcp_initcwnd_segments VNET(tcp_initcwnd_segments) -#define V_tcp_sendspace VNET(tcp_sendspace) -#define V_tcp_recvspace VNET(tcp_recvspace) -#define V_path_mtu_discovery VNET(path_mtu_discovery) -#define V_tcp_do_rfc3465 VNET(tcp_do_rfc3465) -#define V_tcp_abc_l_var VNET(tcp_abc_l_var) - -VNET_DECLARE(int, tcp_do_sack); /* SACK enabled/disabled */ -VNET_DECLARE(int, tcp_sc_rst_sock_fail); /* RST on sock alloc failure */ -#define V_tcp_do_sack VNET(tcp_do_sack) -#define V_tcp_sc_rst_sock_fail VNET(tcp_sc_rst_sock_fail) - -VNET_DECLARE(int, tcp_do_ecn); /* TCP ECN enabled/disabled */ +VNET_DECLARE(int, tcp_do_rfc6675_pipe); +VNET_DECLARE(int, tcp_do_sack); +VNET_DECLARE(int, tcp_do_tso); VNET_DECLARE(int, tcp_ecn_maxretries); -#define V_tcp_do_ecn VNET(tcp_do_ecn) -#define V_tcp_ecn_maxretries VNET(tcp_ecn_maxretries) +VNET_DECLARE(int, tcp_initcwnd_segments); +VNET_DECLARE(int, tcp_insecure_rst); +VNET_DECLARE(int, tcp_insecure_syn); +VNET_DECLARE(int, tcp_minmss); +VNET_DECLARE(int, tcp_mssdflt); +VNET_DECLARE(int, tcp_recvspace); +VNET_DECLARE(int, tcp_sack_globalholes); +VNET_DECLARE(int, tcp_sack_globalmaxholes); +VNET_DECLARE(int, tcp_sack_maxholes); +VNET_DECLARE(int, tcp_sc_rst_sock_fail); +VNET_DECLARE(int, tcp_sendspace); +VNET_DECLARE(struct inpcbhead, tcb); +VNET_DECLARE(struct inpcbinfo, tcbinfo); + +#define V_drop_synfin VNET(drop_synfin) +#define V_path_mtu_discovery VNET(path_mtu_discovery) +#define V_tcb VNET(tcb) +#define V_tcbinfo VNET(tcbinfo) +#define V_tcp_abc_l_var VNET(tcp_abc_l_var) +#define V_tcp_autorcvbuf_inc VNET(tcp_autorcvbuf_inc) +#define V_tcp_autorcvbuf_max VNET(tcp_autorcvbuf_max) +#define V_tcp_autosndbuf_inc VNET(tcp_autosndbuf_inc) +#define V_tcp_autosndbuf_max VNET(tcp_autosndbuf_max) +#define V_tcp_delack_enabled VNET(tcp_delack_enabled) +#define V_tcp_do_autorcvbuf VNET(tcp_do_autorcvbuf) +#define V_tcp_do_autosndbuf VNET(tcp_do_autosndbuf) +#define V_tcp_do_ecn VNET(tcp_do_ecn) +#define V_tcp_do_rfc1323 VNET(tcp_do_rfc1323) +#define V_tcp_do_rfc3042 VNET(tcp_do_rfc3042) +#define V_tcp_do_rfc3390 VNET(tcp_do_rfc3390) +#define V_tcp_do_rfc3465 VNET(tcp_do_rfc3465) +#define V_tcp_do_rfc6675_pipe VNET(tcp_do_rfc6675_pipe) +#define V_tcp_do_sack VNET(tcp_do_sack) +#define V_tcp_do_tso VNET(tcp_do_tso) +#define V_tcp_ecn_maxretries VNET(tcp_ecn_maxretries) +#define V_tcp_initcwnd_segments VNET(tcp_initcwnd_segments) +#define V_tcp_insecure_rst VNET(tcp_insecure_rst) +#define V_tcp_insecure_syn VNET(tcp_insecure_syn) +#define V_tcp_minmss VNET(tcp_minmss) +#define V_tcp_mssdflt VNET(tcp_mssdflt) +#define V_tcp_recvspace VNET(tcp_recvspace) +#define V_tcp_sack_globalholes VNET(tcp_sack_globalholes) +#define V_tcp_sack_globalmaxholes VNET(tcp_sack_globalmaxholes) +#define V_tcp_sack_maxholes VNET(tcp_sack_maxholes) +#define V_tcp_sc_rst_sock_fail VNET(tcp_sc_rst_sock_fail) +#define V_tcp_sendspace VNET(tcp_sendspace) #ifdef TCP_HHOOK VNET_DECLARE(struct hhook_head *, tcp_hhh[HHOOK_TCP_LAST + 1]); #define V_tcp_hhh VNET(tcp_hhh) #endif -VNET_DECLARE(int, tcp_do_rfc6675_pipe); -#define V_tcp_do_rfc6675_pipe VNET(tcp_do_rfc6675_pipe) - int tcp_addoptions(struct tcpopt *, u_char *); int tcp_ccalgounload(struct cc_algo *unload_algo); struct tcpcb * diff --git a/freebsd/sys/netinet/tcpip.h b/freebsd/sys/netinet/tcpip.h index 45c1095a..f3ed5be9 100644 --- a/freebsd/sys/netinet/tcpip.h +++ b/freebsd/sys/netinet/tcpip.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/netinet/toecore.h b/freebsd/sys/netinet/toecore.h index 6ea98518..633984a6 100644 --- a/freebsd/sys/netinet/toecore.h +++ b/freebsd/sys/netinet/toecore.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2012 Chelsio Communications, Inc. * All rights reserved. * diff --git a/freebsd/sys/netinet/udp.h b/freebsd/sys/netinet/udp.h index 7b18df42..7c08135d 100644 --- a/freebsd/sys/netinet/udp.h +++ b/freebsd/sys/netinet/udp.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. * All rights reserved. diff --git a/freebsd/sys/netinet/udp_usrreq.c b/freebsd/sys/netinet/udp_usrreq.c index af6b564f..da2dbe98 100644 --- a/freebsd/sys/netinet/udp_usrreq.c +++ b/freebsd/sys/netinet/udp_usrreq.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995 * The Regents of the University of California. * Copyright (c) 2008 Robert N. M. Watson diff --git a/freebsd/sys/netinet/udp_var.h b/freebsd/sys/netinet/udp_var.h index e92ac961..01545582 100644 --- a/freebsd/sys/netinet/udp_var.h +++ b/freebsd/sys/netinet/udp_var.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1989, 1993 * The Regents of the University of California. * All rights reserved. diff --git a/freebsd/sys/netinet6/dest6.c b/freebsd/sys/netinet6/dest6.c index 8d2f79e4..1c9efc25 100644 --- a/freebsd/sys/netinet6/dest6.c +++ b/freebsd/sys/netinet6/dest6.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet6/frag6.c b/freebsd/sys/netinet6/frag6.c index ae209b60..1224aeaa 100644 --- a/freebsd/sys/netinet6/frag6.c +++ b/freebsd/sys/netinet6/frag6.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet6/icmp6.c b/freebsd/sys/netinet6/icmp6.c index 16b48490..fb537170 100644 --- a/freebsd/sys/netinet6/icmp6.c +++ b/freebsd/sys/netinet6/icmp6.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet6/in6.c b/freebsd/sys/netinet6/in6.c index d5c21396..2046043d 100644 --- a/freebsd/sys/netinet6/in6.c +++ b/freebsd/sys/netinet6/in6.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet6/in6_cksum.c b/freebsd/sys/netinet6/in6_cksum.c index be9e191e..b33d202c 100644 --- a/freebsd/sys/netinet6/in6_cksum.c +++ b/freebsd/sys/netinet6/in6_cksum.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet6/in6_gif.c b/freebsd/sys/netinet6/in6_gif.c index 70de4d0c..160a0929 100644 --- a/freebsd/sys/netinet6/in6_gif.c +++ b/freebsd/sys/netinet6/in6_gif.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet6/in6_ifattach.c b/freebsd/sys/netinet6/in6_ifattach.c index e572fad7..d89581e4 100644 --- a/freebsd/sys/netinet6/in6_ifattach.c +++ b/freebsd/sys/netinet6/in6_ifattach.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet6/in6_ifattach.h b/freebsd/sys/netinet6/in6_ifattach.h index a34530db..1e038fa8 100644 --- a/freebsd/sys/netinet6/in6_ifattach.h +++ b/freebsd/sys/netinet6/in6_ifattach.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet6/in6_mcast.c b/freebsd/sys/netinet6/in6_mcast.c index 5977a6fe..4119d1d9 100644 --- a/freebsd/sys/netinet6/in6_mcast.c +++ b/freebsd/sys/netinet6/in6_mcast.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> -/* +/*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2009 Bruce Simpson. * All rights reserved. * diff --git a/freebsd/sys/netinet6/in6_pcb.c b/freebsd/sys/netinet6/in6_pcb.c index 56142a1b..c9107260 100644 --- a/freebsd/sys/netinet6/in6_pcb.c +++ b/freebsd/sys/netinet6/in6_pcb.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * Copyright (c) 2010-2011 Juniper Networks, Inc. * All rights reserved. diff --git a/freebsd/sys/netinet6/in6_pcb.h b/freebsd/sys/netinet6/in6_pcb.h index f21230bc..2c6bcdc6 100644 --- a/freebsd/sys/netinet6/in6_pcb.h +++ b/freebsd/sys/netinet6/in6_pcb.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet6/in6_proto.c b/freebsd/sys/netinet6/in6_proto.c index f52a683e..55fbbe80 100644 --- a/freebsd/sys/netinet6/in6_proto.c +++ b/freebsd/sys/netinet6/in6_proto.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet6/in6_rmx.c b/freebsd/sys/netinet6/in6_rmx.c index d6d9efea..402d9e87 100644 --- a/freebsd/sys/netinet6/in6_rmx.c +++ b/freebsd/sys/netinet6/in6_rmx.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet6/in6_src.c b/freebsd/sys/netinet6/in6_src.c index bc6890dc..a13c1a06 100644 --- a/freebsd/sys/netinet6/in6_src.c +++ b/freebsd/sys/netinet6/in6_src.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet6/in6_var.h b/freebsd/sys/netinet6/in6_var.h index a3dac7f4..2e22d962 100644 --- a/freebsd/sys/netinet6/in6_var.h +++ b/freebsd/sys/netinet6/in6_var.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet6/ip6_ecn.h b/freebsd/sys/netinet6/ip6_ecn.h index 27d3f34d..dade6573 100644 --- a/freebsd/sys/netinet6/ip6_ecn.h +++ b/freebsd/sys/netinet6/ip6_ecn.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1999 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet6/ip6_fastfwd.c b/freebsd/sys/netinet6/ip6_fastfwd.c index 2f00c554..e11f612b 100644 --- a/freebsd/sys/netinet6/ip6_fastfwd.c +++ b/freebsd/sys/netinet6/ip6_fastfwd.c @@ -196,6 +196,16 @@ passin: in6_ifstat_inc(rcvif, ifs6_in_noroute); goto dropin; } + + /* + * Outgoing packet firewall processing. + */ + if (!PFIL_HOOKED(&V_inet6_pfil_hook)) + goto passout; + if (pfil_run_hooks(&V_inet6_pfil_hook, &m, nh.nh_ifp, PFIL_OUT, + NULL) != 0 || m == NULL) + goto dropout; + /* * We used slow path processing for packets with scoped addresses. * So, scope checks aren't needed here. @@ -208,14 +218,6 @@ passin: } /* - * Outgoing packet firewall processing. - */ - if (!PFIL_HOOKED(&V_inet6_pfil_hook)) - goto passout; - if (pfil_run_hooks(&V_inet6_pfil_hook, &m, nh.nh_ifp, PFIL_OUT, - NULL) != 0 || m == NULL) - goto dropout; - /* * If packet filter sets the M_FASTFWD_OURS flag, this means * that new destination or next hop is our local address. * So, we can just go back to ip6_input. diff --git a/freebsd/sys/netinet6/ip6_forward.c b/freebsd/sys/netinet6/ip6_forward.c index 542de6de..3364dd05 100644 --- a/freebsd/sys/netinet6/ip6_forward.c +++ b/freebsd/sys/netinet6/ip6_forward.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet6/ip6_id.c b/freebsd/sys/netinet6/ip6_id.c index 21a0bb51..cf0f3a4c 100644 --- a/freebsd/sys/netinet6/ip6_id.c +++ b/freebsd/sys/netinet6/ip6_id.c @@ -32,6 +32,8 @@ */ /*- + * SPDX-License-Identifier: BSD-4-Clause AND BSD-3-Clause + * * Copyright 1998 Niels Provos <provos@citi.umich.edu> * All rights reserved. * diff --git a/freebsd/sys/netinet6/ip6_input.c b/freebsd/sys/netinet6/ip6_input.c index 3d502674..c22f2015 100644 --- a/freebsd/sys/netinet6/ip6_input.c +++ b/freebsd/sys/netinet6/ip6_input.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * @@ -1223,43 +1225,97 @@ ip6_savecontrol_v4(struct inpcb *inp, struct mbuf *m, struct mbuf **mp, struct bintime bt; struct timespec ts; } t; + struct bintime boottimebin, bt1; + struct timespec ts1; + bool stamped; + stamped = false; switch (inp->inp_socket->so_ts_clock) { case SO_TS_REALTIME_MICRO: - microtime(&t.tv); + if ((m->m_flags & (M_PKTHDR | M_TSTMP)) == (M_PKTHDR | + M_TSTMP)) { + mbuf_tstmp2timespec(m, &ts1); + timespec2bintime(&ts1, &bt1); + getboottimebin(&boottimebin); + bintime_add(&bt1, &boottimebin); + bintime2timeval(&bt1, &t.tv); + } else { + microtime(&t.tv); + } *mp = sbcreatecontrol((caddr_t) &t.tv, sizeof(t.tv), SCM_TIMESTAMP, SOL_SOCKET); - if (*mp) + if (*mp != NULL) { mp = &(*mp)->m_next; + stamped = true; + } break; case SO_TS_BINTIME: - bintime(&t.bt); + if ((m->m_flags & (M_PKTHDR | M_TSTMP)) == (M_PKTHDR | + M_TSTMP)) { + mbuf_tstmp2timespec(m, &ts1); + timespec2bintime(&ts1, &t.bt); + getboottimebin(&boottimebin); + bintime_add(&t.bt, &boottimebin); + } else { + bintime(&t.bt); + } *mp = sbcreatecontrol((caddr_t)&t.bt, sizeof(t.bt), SCM_BINTIME, SOL_SOCKET); - if (*mp) + if (*mp != NULL) { mp = &(*mp)->m_next; + stamped = true; + } break; case SO_TS_REALTIME: - nanotime(&t.ts); + if ((m->m_flags & (M_PKTHDR | M_TSTMP)) == (M_PKTHDR | + M_TSTMP)) { + mbuf_tstmp2timespec(m, &t.ts); + getboottimebin(&boottimebin); + bintime2timespec(&boottimebin, &ts1); + timespecadd(&t.ts, &ts1, &t.ts); + } else { + nanotime(&t.ts); + } *mp = sbcreatecontrol((caddr_t)&t.ts, sizeof(t.ts), SCM_REALTIME, SOL_SOCKET); - if (*mp) + if (*mp != NULL) { mp = &(*mp)->m_next; + stamped = true; + } break; case SO_TS_MONOTONIC: - nanouptime(&t.ts); + if ((m->m_flags & (M_PKTHDR | M_TSTMP)) == (M_PKTHDR | + M_TSTMP)) + mbuf_tstmp2timespec(m, &t.ts); + else + nanouptime(&t.ts); *mp = sbcreatecontrol((caddr_t)&t.ts, sizeof(t.ts), SCM_MONOTONIC, SOL_SOCKET); - if (*mp) + if (*mp != NULL) { mp = &(*mp)->m_next; + stamped = true; + } break; default: panic("unknown (corrupted) so_ts_clock"); } + if (stamped && (m->m_flags & (M_PKTHDR | M_TSTMP)) == + (M_PKTHDR | M_TSTMP)) { + struct sock_timestamp_info sti; + + bzero(&sti, sizeof(sti)); + sti.st_info_flags = ST_INFO_HW; + if ((m->m_flags & M_TSTMP_HPREC) != 0) + sti.st_info_flags |= ST_INFO_HW_HPREC; + *mp = sbcreatecontrol((caddr_t)&sti, sizeof(sti), + SCM_TIME_INFO, SOL_SOCKET); + if (*mp != NULL) + mp = &(*mp)->m_next; + } } #endif diff --git a/freebsd/sys/netinet6/ip6_mroute.c b/freebsd/sys/netinet6/ip6_mroute.c index a1d71361..4959145d 100644 --- a/freebsd/sys/netinet6/ip6_mroute.c +++ b/freebsd/sys/netinet6/ip6_mroute.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet6/ip6_mroute.h b/freebsd/sys/netinet6/ip6_mroute.h index 51e1d496..40a85770 100644 --- a/freebsd/sys/netinet6/ip6_mroute.h +++ b/freebsd/sys/netinet6/ip6_mroute.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet6/ip6_output.c b/freebsd/sys/netinet6/ip6_output.c index d8ed24a9..8dd71077 100644 --- a/freebsd/sys/netinet6/ip6_output.c +++ b/freebsd/sys/netinet6/ip6_output.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet6/ip6_var.h b/freebsd/sys/netinet6/ip6_var.h index 65bf1e69..5c8997ca 100644 --- a/freebsd/sys/netinet6/ip6_var.h +++ b/freebsd/sys/netinet6/ip6_var.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet6/ip6protosw.h b/freebsd/sys/netinet6/ip6protosw.h index edfbd0ab..d978e330 100644 --- a/freebsd/sys/netinet6/ip6protosw.h +++ b/freebsd/sys/netinet6/ip6protosw.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet6/mld6.c b/freebsd/sys/netinet6/mld6.c index 37625990..26fb21f7 100644 --- a/freebsd/sys/netinet6/mld6.c +++ b/freebsd/sys/netinet6/mld6.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2009 Bruce Simpson. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/netinet6/mld6.h b/freebsd/sys/netinet6/mld6.h index 64d6b8d7..b426a2e2 100644 --- a/freebsd/sys/netinet6/mld6.h +++ b/freebsd/sys/netinet6/mld6.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2009 Bruce Simpson. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/netinet6/mld6_var.h b/freebsd/sys/netinet6/mld6_var.h index be7e9035..0aeac367 100644 --- a/freebsd/sys/netinet6/mld6_var.h +++ b/freebsd/sys/netinet6/mld6_var.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2009 Bruce Simpson. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/netinet6/nd6.c b/freebsd/sys/netinet6/nd6.c index b6368965..30672e23 100644 --- a/freebsd/sys/netinet6/nd6.c +++ b/freebsd/sys/netinet6/nd6.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet6/nd6.h b/freebsd/sys/netinet6/nd6.h index 243e9548..30990637 100644 --- a/freebsd/sys/netinet6/nd6.h +++ b/freebsd/sys/netinet6/nd6.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet6/nd6_nbr.c b/freebsd/sys/netinet6/nd6_nbr.c index f22d0ce7..5e55fc2b 100644 --- a/freebsd/sys/netinet6/nd6_nbr.c +++ b/freebsd/sys/netinet6/nd6_nbr.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet6/nd6_rtr.c b/freebsd/sys/netinet6/nd6_rtr.c index 7edd0925..47fc497e 100644 --- a/freebsd/sys/netinet6/nd6_rtr.c +++ b/freebsd/sys/netinet6/nd6_rtr.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet6/pim6.h b/freebsd/sys/netinet6/pim6.h index dec84cf2..45346e89 100644 --- a/freebsd/sys/netinet6/pim6.h +++ b/freebsd/sys/netinet6/pim6.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet6/pim6_var.h b/freebsd/sys/netinet6/pim6_var.h index 7f9262bb..7afe89b9 100644 --- a/freebsd/sys/netinet6/pim6_var.h +++ b/freebsd/sys/netinet6/pim6_var.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet6/raw_ip6.c b/freebsd/sys/netinet6/raw_ip6.c index 2bbd9864..743fe787 100644 --- a/freebsd/sys/netinet6/raw_ip6.c +++ b/freebsd/sys/netinet6/raw_ip6.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet6/raw_ip6.h b/freebsd/sys/netinet6/raw_ip6.h index 5eec5fff..e2dcac36 100644 --- a/freebsd/sys/netinet6/raw_ip6.h +++ b/freebsd/sys/netinet6/raw_ip6.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 2001 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet6/route6.c b/freebsd/sys/netinet6/route6.c index 061d0a67..7014daa6 100644 --- a/freebsd/sys/netinet6/route6.c +++ b/freebsd/sys/netinet6/route6.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet6/scope6.c b/freebsd/sys/netinet6/scope6.c index 3e8e7cef..a4c56769 100644 --- a/freebsd/sys/netinet6/scope6.c +++ b/freebsd/sys/netinet6/scope6.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 2000 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet6/scope6_var.h b/freebsd/sys/netinet6/scope6_var.h index e38d77a9..a2a9137d 100644 --- a/freebsd/sys/netinet6/scope6_var.h +++ b/freebsd/sys/netinet6/scope6_var.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 2000 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet6/sctp6_usrreq.c b/freebsd/sys/netinet6/sctp6_usrreq.c index 27fcaa99..619a30dc 100644 --- a/freebsd/sys/netinet6/sctp6_usrreq.c +++ b/freebsd/sys/netinet6/sctp6_usrreq.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. @@ -231,6 +233,10 @@ sctp6_notify(struct sctp_inpcb *inp, } break; case ICMP6_PACKET_TOO_BIG: + if ((net->dest_state & SCTP_ADDR_NO_PMTUD) == 0) { + SCTP_TCB_UNLOCK(stcb); + break; + } if (SCTP_OS_TIMER_PENDING(&net->pmtu_timer.timer)) { timer_stopped = 1; sctp_timer_stop(SCTP_TIMER_TYPE_PATHMTURAISE, inp, stcb, net, diff --git a/freebsd/sys/netinet6/sctp6_var.h b/freebsd/sys/netinet6/sctp6_var.h index a24ceba7..e3c4359a 100644 --- a/freebsd/sys/netinet6/sctp6_var.h +++ b/freebsd/sys/netinet6/sctp6_var.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. diff --git a/freebsd/sys/netinet6/send.h b/freebsd/sys/netinet6/send.h index 9795d142..6194f80e 100644 --- a/freebsd/sys/netinet6/send.h +++ b/freebsd/sys/netinet6/send.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2009-2010 Ana Kukec <anchie@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/netinet6/tcp6_var.h b/freebsd/sys/netinet6/tcp6_var.h index 1ef1eb95..00697695 100644 --- a/freebsd/sys/netinet6/tcp6_var.h +++ b/freebsd/sys/netinet6/tcp6_var.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netinet6/udp6_usrreq.c b/freebsd/sys/netinet6/udp6_usrreq.c index d00584ed..ae57ac79 100644 --- a/freebsd/sys/netinet6/udp6_usrreq.c +++ b/freebsd/sys/netinet6/udp6_usrreq.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * Copyright (c) 2010-2011 Juniper Networks, Inc. * Copyright (c) 2014 Kevin Lo diff --git a/freebsd/sys/netinet6/udp6_var.h b/freebsd/sys/netinet6/udp6_var.h index 8a2afa38..93e226d6 100644 --- a/freebsd/sys/netinet6/udp6_var.h +++ b/freebsd/sys/netinet6/udp6_var.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netipsec/ah.h b/freebsd/sys/netipsec/ah.h index 1ffeacdc..8c76dbc4 100644 --- a/freebsd/sys/netipsec/ah.h +++ b/freebsd/sys/netipsec/ah.h @@ -2,6 +2,8 @@ /* $KAME: ah.h,v 1.13 2000/10/18 21:28:00 itojun Exp $ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netipsec/esp.h b/freebsd/sys/netipsec/esp.h index 8eb09630..94612b87 100644 --- a/freebsd/sys/netipsec/esp.h +++ b/freebsd/sys/netipsec/esp.h @@ -2,6 +2,8 @@ /* $KAME: esp.h,v 1.16 2000/10/18 21:28:00 itojun Exp $ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netipsec/ipcomp.h b/freebsd/sys/netipsec/ipcomp.h index 47e9305e..f1ffdc9b 100644 --- a/freebsd/sys/netipsec/ipcomp.h +++ b/freebsd/sys/netipsec/ipcomp.h @@ -2,6 +2,8 @@ /* $KAME: ipcomp.h,v 1.8 2000/09/26 07:55:14 itojun Exp $ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1999 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netipsec/ipcomp_var.h b/freebsd/sys/netipsec/ipcomp_var.h index 5062c9dd..34bfb767 100644 --- a/freebsd/sys/netipsec/ipcomp_var.h +++ b/freebsd/sys/netipsec/ipcomp_var.h @@ -2,6 +2,8 @@ /* $KAME: ipcomp.h,v 1.8 2000/09/26 07:55:14 itojun Exp $ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1999 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netipsec/ipsec.c b/freebsd/sys/netipsec/ipsec.c index 79c9519c..4d75b51b 100644 --- a/freebsd/sys/netipsec/ipsec.c +++ b/freebsd/sys/netipsec/ipsec.c @@ -4,6 +4,8 @@ /* $KAME: ipsec.c,v 1.103 2001/05/24 07:14:18 sakane Exp $ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * @@ -151,6 +153,15 @@ sysctl_def_policy(SYSCTL_HANDLER_ARGS) * 0 take anything */ VNET_DEFINE(int, crypto_support) = CRYPTOCAP_F_HARDWARE | CRYPTOCAP_F_SOFTWARE; + +/* + * Use asynchronous mode to parallelize crypto jobs: + * + * 0 - disabled + * 1 - enabled + */ +VNET_DEFINE(int, async_crypto) = 0; + /* * TCP/UDP checksum handling policy for transport mode NAT-T (RFC3948) * @@ -197,6 +208,9 @@ SYSCTL_INT(_net_inet_ipsec, IPSECCTL_ECN, ecn, SYSCTL_INT(_net_inet_ipsec, OID_AUTO, crypto_support, CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(crypto_support), 0, "Crypto driver selection."); +SYSCTL_INT(_net_inet_ipsec, OID_AUTO, async_crypto, + CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(async_crypto), 0, + "Use asynchronous mode to parallelize crypto jobs."); SYSCTL_INT(_net_inet_ipsec, OID_AUTO, check_policy_history, CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(check_policy_history), 0, "Use strict check of inbound packets to security policy compliance."); diff --git a/freebsd/sys/netipsec/ipsec.h b/freebsd/sys/netipsec/ipsec.h index a61730ef..a1e27bbf 100644 --- a/freebsd/sys/netipsec/ipsec.h +++ b/freebsd/sys/netipsec/ipsec.h @@ -2,6 +2,8 @@ /* $KAME: ipsec.h,v 1.53 2001/11/20 08:32:38 itojun Exp $ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * @@ -283,6 +285,7 @@ VNET_DECLARE(int, ip4_ipsec_dfbit); VNET_DECLARE(int, ip4_ipsec_ecn); VNET_DECLARE(int, ip4_esp_randpad); VNET_DECLARE(int, crypto_support); +VNET_DECLARE(int, async_crypto); VNET_DECLARE(int, natt_cksum_policy); #define IPSECSTAT_INC(name) \ @@ -296,6 +299,7 @@ VNET_DECLARE(int, natt_cksum_policy); #define V_ip4_ipsec_ecn VNET(ip4_ipsec_ecn) #define V_ip4_esp_randpad VNET(ip4_esp_randpad) #define V_crypto_support VNET(crypto_support) +#define V_async_crypto VNET(async_crypto) #define V_natt_cksum_policy VNET(natt_cksum_policy) #define ipseclog(x) do { if (V_ipsec_debug) log x; } while (0) diff --git a/freebsd/sys/netipsec/ipsec6.h b/freebsd/sys/netipsec/ipsec6.h index 33aa30f3..6d44f989 100644 --- a/freebsd/sys/netipsec/ipsec6.h +++ b/freebsd/sys/netipsec/ipsec6.h @@ -2,6 +2,8 @@ /* $KAME: ipsec.h,v 1.44 2001/03/23 08:08:47 itojun Exp $ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netipsec/ipsec_mbuf.c b/freebsd/sys/netipsec/ipsec_mbuf.c index 80cb8fbc..66d53514 100644 --- a/freebsd/sys/netipsec/ipsec_mbuf.c +++ b/freebsd/sys/netipsec/ipsec_mbuf.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting * All rights reserved. * diff --git a/freebsd/sys/netipsec/ipsec_output.c b/freebsd/sys/netipsec/ipsec_output.c index ac9529d5..f5ee076c 100644 --- a/freebsd/sys/netipsec/ipsec_output.c +++ b/freebsd/sys/netipsec/ipsec_output.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting * Copyright (c) 2016 Andrey V. Elsukov <ae@FreeBSD.org> * All rights reserved. diff --git a/freebsd/sys/netipsec/key.c b/freebsd/sys/netipsec/key.c index ef5d8419..3652524c 100644 --- a/freebsd/sys/netipsec/key.c +++ b/freebsd/sys/netipsec/key.c @@ -4,6 +4,8 @@ /* $KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * @@ -5102,7 +5104,7 @@ key_updateaddresses(struct socket *so, struct mbuf *m, newsav->natt = NULL; newsav->sah = sah; newsav->state = SADB_SASTATE_MATURE; - error = key_setnatt(sav, mhp); + error = key_setnatt(newsav, mhp); if (error != 0) goto fail; @@ -6265,7 +6267,7 @@ key_getsizes_ah(const struct auth_hash *ah, int alg, u_int16_t* min, u_int16_t* max) { - *min = *max = ah->keysize; + *min = *max = ah->hashsize; if (ah->keysize == 0) { /* * Transform takes arbitrary key size but algorithm diff --git a/freebsd/sys/netipsec/key.h b/freebsd/sys/netipsec/key.h index a646832e..6c3e05c0 100644 --- a/freebsd/sys/netipsec/key.h +++ b/freebsd/sys/netipsec/key.h @@ -2,6 +2,8 @@ /* $KAME: key.h,v 1.21 2001/07/27 03:51:30 itojun Exp $ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netipsec/key_debug.c b/freebsd/sys/netipsec/key_debug.c index f71212b7..12cfe34e 100644 --- a/freebsd/sys/netipsec/key_debug.c +++ b/freebsd/sys/netipsec/key_debug.c @@ -4,6 +4,8 @@ /* $KAME: key_debug.c,v 1.26 2001/06/27 10:46:50 sakane Exp $ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netipsec/key_debug.h b/freebsd/sys/netipsec/key_debug.h index afb11cb1..a2dd57ed 100644 --- a/freebsd/sys/netipsec/key_debug.h +++ b/freebsd/sys/netipsec/key_debug.h @@ -2,6 +2,8 @@ /* $KAME: key_debug.h,v 1.10 2001/08/05 08:37:52 itojun Exp $ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netipsec/key_var.h b/freebsd/sys/netipsec/key_var.h index ecef2360..bd68645e 100644 --- a/freebsd/sys/netipsec/key_var.h +++ b/freebsd/sys/netipsec/key_var.h @@ -2,6 +2,8 @@ /* $KAME: key_var.h,v 1.11 2001/09/12 23:05:07 sakane Exp $ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netipsec/keydb.h b/freebsd/sys/netipsec/keydb.h index ab03abb1..19eae767 100644 --- a/freebsd/sys/netipsec/keydb.h +++ b/freebsd/sys/netipsec/keydb.h @@ -2,6 +2,8 @@ /* $KAME: keydb.h,v 1.14 2000/08/02 17:58:26 sakane Exp $ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netipsec/keysock.c b/freebsd/sys/netipsec/keysock.c index a7421af6..7ecd50b8 100644 --- a/freebsd/sys/netipsec/keysock.c +++ b/freebsd/sys/netipsec/keysock.c @@ -4,6 +4,8 @@ /* $KAME: keysock.c,v 1.25 2001/08/13 20:07:41 itojun Exp $ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netipsec/keysock.h b/freebsd/sys/netipsec/keysock.h index 8fbf4a02..30b68da6 100644 --- a/freebsd/sys/netipsec/keysock.h +++ b/freebsd/sys/netipsec/keysock.h @@ -2,6 +2,8 @@ /* $KAME: keysock.h,v 1.8 2000/03/27 05:11:06 sumikawa Exp $ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netipsec/xform_ah.c b/freebsd/sys/netipsec/xform_ah.c index 6e9baa1f..5667f78f 100644 --- a/freebsd/sys/netipsec/xform_ah.c +++ b/freebsd/sys/netipsec/xform_ah.c @@ -659,6 +659,8 @@ ah_input(struct mbuf *m, struct secasvar *sav, int skip, int protoff) /* Crypto operation descriptor. */ crp->crp_ilen = m->m_pkthdr.len; /* Total input length. */ crp->crp_flags = CRYPTO_F_IMBUF | CRYPTO_F_CBIFSYNC; + if (V_async_crypto) + crp->crp_flags |= CRYPTO_F_ASYNC | CRYPTO_F_ASYNC_KEEPORDER; crp->crp_buf = (caddr_t) m; crp->crp_callback = ah_input_cb; crp->crp_sid = cryptoid; @@ -1035,6 +1037,8 @@ ah_output(struct mbuf *m, struct secpolicy *sp, struct secasvar *sav, /* Crypto operation descriptor. */ crp->crp_ilen = m->m_pkthdr.len; /* Total input length. */ crp->crp_flags = CRYPTO_F_IMBUF | CRYPTO_F_CBIFSYNC; + if (V_async_crypto) + crp->crp_flags |= CRYPTO_F_ASYNC | CRYPTO_F_ASYNC_KEEPORDER; crp->crp_buf = (caddr_t) m; crp->crp_callback = ah_output_cb; crp->crp_sid = cryptoid; diff --git a/freebsd/sys/netipsec/xform_esp.c b/freebsd/sys/netipsec/xform_esp.c index 8310b799..8af95f7d 100644 --- a/freebsd/sys/netipsec/xform_esp.c +++ b/freebsd/sys/netipsec/xform_esp.c @@ -387,6 +387,8 @@ esp_input(struct mbuf *m, struct secasvar *sav, int skip, int protoff) /* Crypto operation descriptor */ crp->crp_ilen = m->m_pkthdr.len; /* Total input length */ crp->crp_flags = CRYPTO_F_IMBUF | CRYPTO_F_CBIFSYNC; + if (V_async_crypto) + crp->crp_flags |= CRYPTO_F_ASYNC | CRYPTO_F_ASYNC_KEEPORDER; crp->crp_buf = (caddr_t) m; crp->crp_callback = esp_input_cb; crp->crp_sid = cryptoid; @@ -843,6 +845,8 @@ esp_output(struct mbuf *m, struct secpolicy *sp, struct secasvar *sav, /* Crypto operation descriptor. */ crp->crp_ilen = m->m_pkthdr.len; /* Total input length. */ crp->crp_flags = CRYPTO_F_IMBUF | CRYPTO_F_CBIFSYNC; + if (V_async_crypto) + crp->crp_flags |= CRYPTO_F_ASYNC | CRYPTO_F_ASYNC_KEEPORDER; crp->crp_buf = (caddr_t) m; crp->crp_callback = esp_output_cb; crp->crp_opaque = (caddr_t) xd; diff --git a/freebsd/sys/netipsec/xform_ipcomp.c b/freebsd/sys/netipsec/xform_ipcomp.c index e79301b1..4764e609 100644 --- a/freebsd/sys/netipsec/xform_ipcomp.c +++ b/freebsd/sys/netipsec/xform_ipcomp.c @@ -4,6 +4,8 @@ /* $OpenBSD: ip_ipcomp.c,v 1.1 2001/07/05 12:08:52 jjbg Exp $ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001 Jean-Jacques Bernard-Gundol (jj@wabbitt.org) * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/netipsec/xform_tcp.c b/freebsd/sys/netipsec/xform_tcp.c index 3df5db3a..9310cf2c 100644 --- a/freebsd/sys/netipsec/xform_tcp.c +++ b/freebsd/sys/netipsec/xform_tcp.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2003 Bruce M. Simpson <bms@spc.org> * Copyright (c) 2016 Andrey V. Elsukov <ae@FreeBSD.org> * diff --git a/freebsd/sys/netpfil/pf/if_pfsync.c b/freebsd/sys/netpfil/pf/if_pfsync.c index 491ff3a7..2343adc2 100644 --- a/freebsd/sys/netpfil/pf/if_pfsync.c +++ b/freebsd/sys/netpfil/pf/if_pfsync.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: (BSD-2-Clause-FreeBSD AND ISC) + * * Copyright (c) 2002 Michael Shalayeff * Copyright (c) 2012 Gleb Smirnoff <glebius@FreeBSD.org> * All rights reserved. diff --git a/freebsd/sys/netpfil/pf/in4_cksum.c b/freebsd/sys/netpfil/pf/in4_cksum.c index 87993ac6..509c33cd 100644 --- a/freebsd/sys/netpfil/pf/in4_cksum.c +++ b/freebsd/sys/netpfil/pf/in4_cksum.c @@ -6,6 +6,8 @@ /* $NetBSD: in_cksum.c,v 1.13 1996/10/13 02:03:03 christos Exp $ */ /* + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (C) 1999 WIDE Project. * All rights reserved. * diff --git a/freebsd/sys/netpfil/pf/pf.c b/freebsd/sys/netpfil/pf/pf.c index ca46d16e..d94966b9 100644 --- a/freebsd/sys/netpfil/pf/pf.c +++ b/freebsd/sys/netpfil/pf/pf.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause + * * Copyright (c) 2001 Daniel Hartmeier * Copyright (c) 2002 - 2008 Henning Brauer * Copyright (c) 2012 Gleb Smirnoff <glebius@FreeBSD.org> diff --git a/freebsd/sys/netpfil/pf/pf.h b/freebsd/sys/netpfil/pf/pf.h index ac0e0fb9..333faea3 100644 --- a/freebsd/sys/netpfil/pf/pf.h +++ b/freebsd/sys/netpfil/pf/pf.h @@ -1,4 +1,6 @@ /* + * SPDX-License-Identifier: BSD-2-Clause + * * Copyright (c) 2001 Daniel Hartmeier * All rights reserved. * diff --git a/freebsd/sys/netpfil/pf/pf_altq.h b/freebsd/sys/netpfil/pf/pf_altq.h index 3efd4ff7..f6d578d3 100644 --- a/freebsd/sys/netpfil/pf/pf_altq.h +++ b/freebsd/sys/netpfil/pf/pf_altq.h @@ -1,4 +1,6 @@ -/* +/*- + * SPDX-License-Identifier: BSD-2-Clause + * * Copyright (c) 2001 Daniel Hartmeier * All rights reserved. * diff --git a/freebsd/sys/netpfil/pf/pf_if.c b/freebsd/sys/netpfil/pf/pf_if.c index 0ca6a019..e224e6a7 100644 --- a/freebsd/sys/netpfil/pf/pf_if.c +++ b/freebsd/sys/netpfil/pf/pf_if.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause + * * Copyright (c) 2001 Daniel Hartmeier * Copyright (c) 2003 Cedric Berger * Copyright (c) 2005 Henning Brauer <henning@openbsd.org> diff --git a/freebsd/sys/netpfil/pf/pf_ioctl.c b/freebsd/sys/netpfil/pf/pf_ioctl.c index e9ca8d95..98f190e7 100644 --- a/freebsd/sys/netpfil/pf/pf_ioctl.c +++ b/freebsd/sys/netpfil/pf/pf_ioctl.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause + * * Copyright (c) 2001 Daniel Hartmeier * Copyright (c) 2002,2003 Henning Brauer * Copyright (c) 2012 Gleb Smirnoff <glebius@FreeBSD.org> diff --git a/freebsd/sys/netpfil/pf/pf_lb.c b/freebsd/sys/netpfil/pf/pf_lb.c index abbf1c1e..7ce27a07 100644 --- a/freebsd/sys/netpfil/pf/pf_lb.c +++ b/freebsd/sys/netpfil/pf/pf_lb.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause + * * Copyright (c) 2001 Daniel Hartmeier * Copyright (c) 2002 - 2008 Henning Brauer * All rights reserved. diff --git a/freebsd/sys/netpfil/pf/pf_mtag.h b/freebsd/sys/netpfil/pf/pf_mtag.h index fd8554ae..67c79350 100644 --- a/freebsd/sys/netpfil/pf/pf_mtag.h +++ b/freebsd/sys/netpfil/pf/pf_mtag.h @@ -1,5 +1,7 @@ /* $FreeBSD$ */ -/* +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 Daniel Hartmeier * All rights reserved. * diff --git a/freebsd/sys/netpfil/pf/pf_norm.c b/freebsd/sys/netpfil/pf/pf_norm.c index 60733ae8..e3a00971 100644 --- a/freebsd/sys/netpfil/pf/pf_norm.c +++ b/freebsd/sys/netpfil/pf/pf_norm.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause + * * Copyright 2001 Niels Provos <provos@citi.umich.edu> * Copyright 2011 Alexander Bluhm <bluhm@openbsd.org> * All rights reserved. diff --git a/freebsd/sys/netpfil/pf/pf_ruleset.c b/freebsd/sys/netpfil/pf/pf_ruleset.c index b8428f7f..3cd74e1d 100644 --- a/freebsd/sys/netpfil/pf/pf_ruleset.c +++ b/freebsd/sys/netpfil/pf/pf_ruleset.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause + * * Copyright (c) 2001 Daniel Hartmeier * Copyright (c) 2002,2003 Henning Brauer * All rights reserved. diff --git a/freebsd/sys/netpfil/pf/pf_table.c b/freebsd/sys/netpfil/pf/pf_table.c index c655effa..68e24d22 100644 --- a/freebsd/sys/netpfil/pf/pf_table.c +++ b/freebsd/sys/netpfil/pf/pf_table.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2002 Cedric Berger * All rights reserved. * diff --git a/freebsd/sys/nios2/include/machine/in_cksum.h b/freebsd/sys/nios2/include/machine/in_cksum.h index 72edfba9..d55b838b 100644 --- a/freebsd/sys/nios2/include/machine/in_cksum.h +++ b/freebsd/sys/nios2/include/machine/in_cksum.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * diff --git a/freebsd/sys/opencrypto/crypto.c b/freebsd/sys/opencrypto/crypto.c index 57378e2f..2631ca5b 100644 --- a/freebsd/sys/opencrypto/crypto.c +++ b/freebsd/sys/opencrypto/crypto.c @@ -72,7 +72,9 @@ __FBSDID("$FreeBSD$"); #include <sys/malloc.h> #include <sys/proc.h> #include <sys/sdt.h> +#include <sys/smp.h> #include <sys/sysctl.h> +#include <sys/taskqueue.h> #include <ddb/ddb.h> @@ -137,26 +139,51 @@ static int crypto_drivers_num = 0; * operations. */ static int crp_sleep = 0; -static TAILQ_HEAD(,cryptop) crp_q; /* request queues */ +static TAILQ_HEAD(cryptop_q ,cryptop) crp_q; /* request queues */ static TAILQ_HEAD(,cryptkop) crp_kq; static struct mtx crypto_q_mtx; #define CRYPTO_Q_LOCK() mtx_lock(&crypto_q_mtx) #define CRYPTO_Q_UNLOCK() mtx_unlock(&crypto_q_mtx) /* - * There are two queues for processing completed crypto requests; one - * for the symmetric and one for the asymmetric ops. We only need one - * but have two to avoid type futzing (cryptop vs. cryptkop). A single - * mutex is used to lock access to both queues. Note that this lock - * must be separate from the lock on request queues to insure driver - * callbacks don't generate lock order reversals. + * Taskqueue used to dispatch the crypto requests + * that have the CRYPTO_F_ASYNC flag */ -static TAILQ_HEAD(,cryptop) crp_ret_q; /* callback queues */ -static TAILQ_HEAD(,cryptkop) crp_ret_kq; -static struct mtx crypto_ret_q_mtx; -#define CRYPTO_RETQ_LOCK() mtx_lock(&crypto_ret_q_mtx) -#define CRYPTO_RETQ_UNLOCK() mtx_unlock(&crypto_ret_q_mtx) -#define CRYPTO_RETQ_EMPTY() (TAILQ_EMPTY(&crp_ret_q) && TAILQ_EMPTY(&crp_ret_kq)) +static struct taskqueue *crypto_tq; + +/* + * Crypto seq numbers are operated on with modular arithmetic + */ +#define CRYPTO_SEQ_GT(a,b) ((int)((a)-(b)) > 0) + +struct crypto_ret_worker { + struct mtx crypto_ret_mtx; + + TAILQ_HEAD(,cryptop) crp_ordered_ret_q; /* ordered callback queue for symetric jobs */ + TAILQ_HEAD(,cryptop) crp_ret_q; /* callback queue for symetric jobs */ + TAILQ_HEAD(,cryptkop) crp_ret_kq; /* callback queue for asym jobs */ + + u_int32_t reorder_ops; /* total ordered sym jobs received */ + u_int32_t reorder_cur_seq; /* current sym job dispatched */ + + struct proc *cryptoretproc; +}; +static struct crypto_ret_worker *crypto_ret_workers = NULL; + +#define CRYPTO_RETW(i) (&crypto_ret_workers[i]) +#define CRYPTO_RETW_ID(w) ((w) - crypto_ret_workers) +#define FOREACH_CRYPTO_RETW(w) \ + for (w = crypto_ret_workers; w < crypto_ret_workers + crypto_workers_num; ++w) + +#define CRYPTO_RETW_LOCK(w) mtx_lock(&w->crypto_ret_mtx) +#define CRYPTO_RETW_UNLOCK(w) mtx_unlock(&w->crypto_ret_mtx) +#define CRYPTO_RETW_EMPTY(w) \ + (TAILQ_EMPTY(&w->crp_ret_q) && TAILQ_EMPTY(&w->crp_ret_kq) && TAILQ_EMPTY(&w->crp_ordered_ret_q)) + +static int crypto_workers_num = 0; +SYSCTL_INT(_kern, OID_AUTO, crypto_workers_num, CTLFLAG_RDTUN, + &crypto_workers_num, 0, + "Number of crypto workers used to dispatch crypto jobs"); static uma_zone_t cryptop_zone; static uma_zone_t cryptodesc_zone; @@ -174,11 +201,12 @@ MALLOC_DEFINE(M_CRYPTO_DATA, "crypto", "crypto session records"); static void crypto_proc(void); static struct proc *cryptoproc; -static void crypto_ret_proc(void); -static struct proc *cryptoretproc; +static void crypto_ret_proc(struct crypto_ret_worker *ret_worker); static void crypto_destroy(void); static int crypto_invoke(struct cryptocap *cap, struct cryptop *crp, int hint); static int crypto_kinvoke(struct cryptkop *krp, int flags); +static void crypto_task_invoke(void *ctx, int pending); +static void crypto_batch_enqueue(struct cryptop *crp); static struct cryptostats cryptostats; SYSCTL_STRUCT(_kern, OID_AUTO, crypto_stats, CTLFLAG_RW, &cryptostats, @@ -224,6 +252,7 @@ struct keybuf * get_keybuf(void) { static int crypto_init(void) { + struct crypto_ret_worker *ret_worker; int error; mtx_init(&crypto_drivers_mtx, "crypto", "crypto driver table", @@ -233,10 +262,6 @@ crypto_init(void) TAILQ_INIT(&crp_kq); mtx_init(&crypto_q_mtx, "crypto", "crypto op queues", MTX_DEF); - TAILQ_INIT(&crp_ret_q); - TAILQ_INIT(&crp_ret_kq); - mtx_init(&crypto_ret_q_mtx, "crypto", "crypto return queues", MTX_DEF); - cryptop_zone = uma_zcreate("cryptop", sizeof (struct cryptop), 0, 0, 0, 0, UMA_ALIGN_PTR, UMA_ZONE_ZINIT); @@ -258,6 +283,20 @@ crypto_init(void) goto bad; } + if (crypto_workers_num < 1 || crypto_workers_num > mp_ncpus) + crypto_workers_num = mp_ncpus; + + crypto_tq = taskqueue_create("crypto", M_WAITOK|M_ZERO, + taskqueue_thread_enqueue, &crypto_tq); + if (crypto_tq == NULL) { + printf("crypto init: cannot setup crypto taskqueue\n"); + error = ENOMEM; + goto bad; + } + + taskqueue_start_threads(&crypto_tq, crypto_workers_num, PRI_MIN_KERN, + "crypto"); + error = kproc_create((void (*)(void *)) crypto_proc, NULL, &cryptoproc, 0, 0, "crypto"); if (error) { @@ -266,15 +305,35 @@ crypto_init(void) goto bad; } - error = kproc_create((void (*)(void *)) crypto_ret_proc, NULL, - &cryptoretproc, 0, 0, "crypto returns"); - if (error) { - printf("crypto_init: cannot start cryptoret thread; error %d", - error); + crypto_ret_workers = malloc(crypto_workers_num * sizeof(struct crypto_ret_worker), + M_CRYPTO_DATA, M_NOWAIT|M_ZERO); + if (crypto_ret_workers == NULL) { + error = ENOMEM; + printf("crypto_init: cannot allocate ret workers\n"); goto bad; } - keybuf_init(); + + FOREACH_CRYPTO_RETW(ret_worker) { + TAILQ_INIT(&ret_worker->crp_ordered_ret_q); + TAILQ_INIT(&ret_worker->crp_ret_q); + TAILQ_INIT(&ret_worker->crp_ret_kq); + + ret_worker->reorder_ops = 0; + ret_worker->reorder_cur_seq = 0; + + mtx_init(&ret_worker->crypto_ret_mtx, "crypto", "crypto return queues", MTX_DEF); + + error = kproc_create((void (*)(void *)) crypto_ret_proc, ret_worker, + &ret_worker->cryptoretproc, 0, 0, "crypto returns %td", CRYPTO_RETW_ID(ret_worker)); + if (error) { + printf("crypto_init: cannot start cryptoret thread; error %d", + error); + goto bad; + } + } + + keybuf_init(); return 0; bad: @@ -315,12 +374,17 @@ crypto_terminate(struct proc **pp, void *q) static void crypto_destroy(void) { + struct crypto_ret_worker *ret_worker; + /* * Terminate any crypto threads. */ + if (crypto_tq != NULL) + taskqueue_drain_all(crypto_tq); CRYPTO_DRIVER_LOCK(); crypto_terminate(&cryptoproc, &crp_q); - crypto_terminate(&cryptoretproc, &crp_ret_q); + FOREACH_CRYPTO_RETW(ret_worker) + crypto_terminate(&ret_worker->cryptoretproc, &ret_worker->crp_ret_q); CRYPTO_DRIVER_UNLOCK(); /* XXX flush queues??? */ @@ -336,7 +400,11 @@ crypto_destroy(void) if (cryptop_zone != NULL) uma_zdestroy(cryptop_zone); mtx_destroy(&crypto_q_mtx); - mtx_destroy(&crypto_ret_q_mtx); + FOREACH_CRYPTO_RETW(ret_worker) + mtx_destroy(&ret_worker->crypto_ret_mtx); + free(crypto_ret_workers, M_CRYPTO_DATA); + if (crypto_tq != NULL) + taskqueue_free(crypto_tq); mtx_destroy(&crypto_drivers_mtx); } @@ -579,7 +647,7 @@ crypto_get_driverid(device_t dev, int flags) crypto_drivers[i].cc_dev = dev; crypto_drivers[i].cc_flags = flags; if (bootverbose) - printf("crypto: assign %s driver id %u, flags %u\n", + printf("crypto: assign %s driver id %u, flags 0x%x\n", device_get_nameunit(dev), i, flags); CRYPTO_DRIVER_UNLOCK(); @@ -835,9 +903,26 @@ crypto_dispatch(struct cryptop *crp) binuptime(&crp->crp_tstamp); #endif - hid = CRYPTO_SESID2HID(crp->crp_sid); + if (CRYPTOP_ASYNC(crp)) { + if (crp->crp_flags & CRYPTO_F_ASYNC_KEEPORDER) { + struct crypto_ret_worker *ret_worker; + + crp->crp_retw_id = crp->crp_sid % crypto_workers_num; + ret_worker = CRYPTO_RETW(crp->crp_retw_id); + + CRYPTO_RETW_LOCK(ret_worker); + crp->crp_seq = ret_worker->reorder_ops++; + CRYPTO_RETW_UNLOCK(ret_worker); + } + + TASK_INIT(&crp->crp_task, 0, crypto_task_invoke, crp); + taskqueue_enqueue(crypto_tq, &crp->crp_task); + return (0); + } if ((crp->crp_flags & CRYPTO_F_BATCH) == 0) { + hid = CRYPTO_SESID2HID(crp->crp_sid); + /* * Caller marked the request to be processed * immediately; dispatch it directly to the @@ -856,12 +941,19 @@ crypto_dispatch(struct cryptop *crp) */ } } + crypto_batch_enqueue(crp); + return 0; +} + +void +crypto_batch_enqueue(struct cryptop *crp) +{ + CRYPTO_Q_LOCK(); TAILQ_INSERT_TAIL(&crp_q, crp, crp_next); if (crp_sleep) wakeup_one(&crp_q); CRYPTO_Q_UNLOCK(); - return 0; } /* @@ -1042,6 +1134,23 @@ crypto_tstat(struct cryptotstat *ts, struct bintime *bt) } #endif +static void +crypto_task_invoke(void *ctx, int pending) +{ + struct cryptocap *cap; + struct cryptop *crp; + int hid, result; + + crp = (struct cryptop *)ctx; + + hid = CRYPTO_SESID2HID(crp->crp_sid); + cap = crypto_checkdriver(hid); + + result = crypto_invoke(cap, crp, 0); + if (result == ERESTART) + crypto_batch_enqueue(crp); +} + /* * Dispatch a crypto request to the appropriate crypto devices. */ @@ -1104,6 +1213,7 @@ crypto_freereq(struct cryptop *crp) #ifdef DIAGNOSTIC { struct cryptop *crp2; + struct crypto_ret_worker *ret_worker; CRYPTO_Q_LOCK(); TAILQ_FOREACH(crp2, &crp_q, crp_next) { @@ -1112,13 +1222,16 @@ crypto_freereq(struct cryptop *crp) crp)); } CRYPTO_Q_UNLOCK(); - CRYPTO_RETQ_LOCK(); - TAILQ_FOREACH(crp2, &crp_ret_q, crp_next) { - KASSERT(crp2 != crp, - ("Freeing cryptop from the return queue (%p).", - crp)); + + FOREACH_CRYPTO_RETW(ret_worker) { + CRYPTO_RETW_LOCK(ret_worker); + TAILQ_FOREACH(crp2, &ret_worker->crp_ret_q, crp_next) { + KASSERT(crp2 != crp, + ("Freeing cryptop from the return queue (%p).", + crp)); + } + CRYPTO_RETW_UNLOCK(ret_worker); } - CRYPTO_RETQ_UNLOCK(); } #endif @@ -1176,9 +1289,10 @@ crypto_done(struct cryptop *crp) * doing extraneous context switches; the latter is mostly * used with the software crypto driver. */ - if ((crp->crp_flags & CRYPTO_F_CBIMM) || + if (!CRYPTOP_ASYNC_KEEPORDER(crp) && + ((crp->crp_flags & CRYPTO_F_CBIMM) || ((crp->crp_flags & CRYPTO_F_CBIFSYNC) && - (CRYPTO_SESID2CAPS(crp->crp_sid) & CRYPTOCAP_F_SYNC))) { + (CRYPTO_SESID2CAPS(crp->crp_sid) & CRYPTOCAP_F_SYNC)))) { /* * Do the callback directly. This is ok when the * callback routine does very little (e.g. the @@ -1199,14 +1313,45 @@ crypto_done(struct cryptop *crp) #endif crp->crp_callback(crp); } else { + struct crypto_ret_worker *ret_worker; + bool wake; + + ret_worker = CRYPTO_RETW(crp->crp_retw_id); + wake = false; + /* * Normal case; queue the callback for the thread. */ - CRYPTO_RETQ_LOCK(); - if (CRYPTO_RETQ_EMPTY()) - wakeup_one(&crp_ret_q); /* shared wait channel */ - TAILQ_INSERT_TAIL(&crp_ret_q, crp, crp_next); - CRYPTO_RETQ_UNLOCK(); + CRYPTO_RETW_LOCK(ret_worker); + if (CRYPTOP_ASYNC_KEEPORDER(crp)) { + struct cryptop *tmp; + + TAILQ_FOREACH_REVERSE(tmp, &ret_worker->crp_ordered_ret_q, + cryptop_q, crp_next) { + if (CRYPTO_SEQ_GT(crp->crp_seq, tmp->crp_seq)) { + TAILQ_INSERT_AFTER(&ret_worker->crp_ordered_ret_q, + tmp, crp, crp_next); + break; + } + } + if (tmp == NULL) { + TAILQ_INSERT_HEAD(&ret_worker->crp_ordered_ret_q, + crp, crp_next); + } + + if (crp->crp_seq == ret_worker->reorder_cur_seq) + wake = true; + } + else { + if (CRYPTO_RETW_EMPTY(ret_worker)) + wake = true; + + TAILQ_INSERT_TAIL(&ret_worker->crp_ret_q, crp, crp_next); + } + + if (wake) + wakeup_one(&ret_worker->crp_ret_q); /* shared wait channel */ + CRYPTO_RETW_UNLOCK(ret_worker); } } @@ -1216,6 +1361,7 @@ crypto_done(struct cryptop *crp) void crypto_kdone(struct cryptkop *krp) { + struct crypto_ret_worker *ret_worker; struct cryptocap *cap; if (krp->krp_status != 0) @@ -1230,11 +1376,14 @@ crypto_kdone(struct cryptkop *krp) crypto_remove(cap); } CRYPTO_DRIVER_UNLOCK(); - CRYPTO_RETQ_LOCK(); - if (CRYPTO_RETQ_EMPTY()) - wakeup_one(&crp_ret_q); /* shared wait channel */ - TAILQ_INSERT_TAIL(&crp_ret_kq, krp, krp_next); - CRYPTO_RETQ_UNLOCK(); + + ret_worker = CRYPTO_RETW(0); + + CRYPTO_RETW_LOCK(ret_worker); + if (CRYPTO_RETW_EMPTY(ret_worker)) + wakeup_one(&ret_worker->crp_ret_q); /* shared wait channel */ + TAILQ_INSERT_TAIL(&ret_worker->crp_ret_kq, krp, krp_next); + CRYPTO_RETW_UNLOCK(ret_worker); } int @@ -1436,24 +1585,36 @@ crypto_proc(void) * callbacks typically are expensive and would slow interrupt handling. */ static void -crypto_ret_proc(void) +crypto_ret_proc(struct crypto_ret_worker *ret_worker) { struct cryptop *crpt; struct cryptkop *krpt; - CRYPTO_RETQ_LOCK(); + CRYPTO_RETW_LOCK(ret_worker); for (;;) { /* Harvest return q's for completed ops */ - crpt = TAILQ_FIRST(&crp_ret_q); - if (crpt != NULL) - TAILQ_REMOVE(&crp_ret_q, crpt, crp_next); + crpt = TAILQ_FIRST(&ret_worker->crp_ordered_ret_q); + if (crpt != NULL) { + if (crpt->crp_seq == ret_worker->reorder_cur_seq) { + TAILQ_REMOVE(&ret_worker->crp_ordered_ret_q, crpt, crp_next); + ret_worker->reorder_cur_seq++; + } else { + crpt = NULL; + } + } - krpt = TAILQ_FIRST(&crp_ret_kq); + if (crpt == NULL) { + crpt = TAILQ_FIRST(&ret_worker->crp_ret_q); + if (crpt != NULL) + TAILQ_REMOVE(&ret_worker->crp_ret_q, crpt, crp_next); + } + + krpt = TAILQ_FIRST(&ret_worker->crp_ret_kq); if (krpt != NULL) - TAILQ_REMOVE(&crp_ret_kq, krpt, krp_next); + TAILQ_REMOVE(&ret_worker->crp_ret_kq, krpt, krp_next); if (crpt != NULL || krpt != NULL) { - CRYPTO_RETQ_UNLOCK(); + CRYPTO_RETW_UNLOCK(ret_worker); /* * Run callbacks unlocked. */ @@ -1475,22 +1636,22 @@ crypto_ret_proc(void) } if (krpt != NULL) krpt->krp_callback(krpt); - CRYPTO_RETQ_LOCK(); + CRYPTO_RETW_LOCK(ret_worker); } else { /* * Nothing more to be processed. Sleep until we're * woken because there are more returns to process. */ - msleep(&crp_ret_q, &crypto_ret_q_mtx, PWAIT, + msleep(&ret_worker->crp_ret_q, &ret_worker->crypto_ret_mtx, PWAIT, "crypto_ret_wait", 0); - if (cryptoretproc == NULL) + if (ret_worker->cryptoretproc == NULL) break; cryptostats.cs_rets++; } } - CRYPTO_RETQ_UNLOCK(); + CRYPTO_RETW_UNLOCK(ret_worker); - crypto_finis(&crp_ret_q); + crypto_finis(&ret_worker->crp_ret_q); } #ifdef DDB @@ -1525,6 +1686,7 @@ db_show_drivers(void) DB_SHOW_COMMAND(crypto, db_show_crypto) { struct cryptop *crp; + struct crypto_ret_worker *ret_worker; db_show_drivers(); db_printf("\n"); @@ -1543,16 +1705,19 @@ DB_SHOW_COMMAND(crypto, db_show_crypto) , crp->crp_callback ); } - if (!TAILQ_EMPTY(&crp_ret_q)) { - db_printf("\n%4s %4s %4s %8s\n", - "HID", "Etype", "Flags", "Callback"); - TAILQ_FOREACH(crp, &crp_ret_q, crp_next) { - db_printf("%4u %4u %04x %8p\n" - , (int) CRYPTO_SESID2HID(crp->crp_sid) - , crp->crp_etype - , crp->crp_flags - , crp->crp_callback - ); + FOREACH_CRYPTO_RETW(ret_worker) { + db_printf("\n%8s %4s %4s %4s %8s\n", + "ret_worker", "HID", "Etype", "Flags", "Callback"); + if (!TAILQ_EMPTY(&ret_worker->crp_ret_q)) { + TAILQ_FOREACH(crp, &ret_worker->crp_ret_q, crp_next) { + db_printf("%8td %4u %4u %04x %8p\n" + , CRYPTO_RETW_ID(ret_worker) + , (int) CRYPTO_SESID2HID(crp->crp_sid) + , crp->crp_etype + , crp->crp_flags + , crp->crp_callback + ); + } } } } @@ -1560,6 +1725,7 @@ DB_SHOW_COMMAND(crypto, db_show_crypto) DB_SHOW_COMMAND(kcrypto, db_show_kcrypto) { struct cryptkop *krp; + struct crypto_ret_worker *ret_worker; db_show_drivers(); db_printf("\n"); @@ -1575,10 +1741,12 @@ DB_SHOW_COMMAND(kcrypto, db_show_kcrypto) , krp->krp_callback ); } - if (!TAILQ_EMPTY(&crp_ret_q)) { + + ret_worker = CRYPTO_RETW(0); + if (!TAILQ_EMPTY(&ret_worker->crp_ret_q)) { db_printf("%4s %5s %8s %4s %8s\n", "Op", "Status", "CRID", "HID", "Callback"); - TAILQ_FOREACH(krp, &crp_ret_kq, krp_next) { + TAILQ_FOREACH(krp, &ret_worker->crp_ret_kq, krp_next) { db_printf("%4u %5u %08x %4u %8p\n" , krp->krp_op , krp->krp_status diff --git a/freebsd/sys/opencrypto/cryptodev.h b/freebsd/sys/opencrypto/cryptodev.h index c42515a6..cfbda068 100644 --- a/freebsd/sys/opencrypto/cryptodev.h +++ b/freebsd/sys/opencrypto/cryptodev.h @@ -63,6 +63,7 @@ #define _CRYPTO_CRYPTO_H_ #include <sys/ioccom.h> +#include <sys/_task.h> /* Some initial values */ #define CRYPTO_DRIVERS_INITIAL 4 @@ -391,6 +392,8 @@ struct cryptodesc { struct cryptop { TAILQ_ENTRY(cryptop) crp_next; + struct task crp_task; + u_int64_t crp_sid; /* Session ID */ int crp_ilen; /* Input data total length */ int crp_olen; /* Result total length */ @@ -413,6 +416,14 @@ struct cryptop { #define CRYPTO_F_CBIMM 0x0010 /* Do callback immediately */ #define CRYPTO_F_DONE 0x0020 /* Operation completed */ #define CRYPTO_F_CBIFSYNC 0x0040 /* Do CBIMM if op is synchronous */ +#define CRYPTO_F_ASYNC 0x0080 /* Dispatch crypto jobs on several threads + * if op is synchronous + */ +#define CRYPTO_F_ASYNC_KEEPORDER 0x0100 /* + * Dispatch the crypto jobs in the same + * order there are submitted. Applied only + * if CRYPTO_F_ASYNC flags is set + */ caddr_t crp_buf; /* Data to be processed */ caddr_t crp_opaque; /* Opaque pointer, passed along */ @@ -421,8 +432,20 @@ struct cryptop { int (*crp_callback)(struct cryptop *); /* Callback function */ struct bintime crp_tstamp; /* performance time stamp */ + uint32_t crp_seq; /* used for ordered dispatch */ + uint32_t crp_retw_id; /* + * the return worker to be used, + * used for ordered dispatch + */ }; +#define CRYPTOP_ASYNC(crp) \ + (((crp)->crp_flags & CRYPTO_F_ASYNC) && \ + CRYPTO_SESID2CAPS((crp)->crp_sid) & CRYPTOCAP_F_SYNC) +#define CRYPTOP_ASYNC_KEEPORDER(crp) \ + (CRYPTOP_ASYNC(crp) && \ + (crp)->crp_flags & CRYPTO_F_ASYNC_KEEPORDER) + #define CRYPTO_BUF_CONTIG 0x0 #define CRYPTO_BUF_IOV 0x1 #define CRYPTO_BUF_MBUF 0x2 diff --git a/freebsd/sys/powerpc/include/machine/cpufunc.h b/freebsd/sys/powerpc/include/machine/cpufunc.h index c70a94d3..204c4801 100644 --- a/freebsd/sys/powerpc/include/machine/cpufunc.h +++ b/freebsd/sys/powerpc/include/machine/cpufunc.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1998 Doug Rabson * All rights reserved. * diff --git a/freebsd/sys/powerpc/include/machine/in_cksum.h b/freebsd/sys/powerpc/include/machine/in_cksum.h index 37bfb200..fd34e13d 100644 --- a/freebsd/sys/powerpc/include/machine/in_cksum.h +++ b/freebsd/sys/powerpc/include/machine/in_cksum.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * diff --git a/freebsd/sys/powerpc/include/machine/intr_machdep.h b/freebsd/sys/powerpc/include/machine/intr_machdep.h index 5fbf9ee0..6ece0fa8 100644 --- a/freebsd/sys/powerpc/include/machine/intr_machdep.h +++ b/freebsd/sys/powerpc/include/machine/intr_machdep.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (C) 2002 Benno Rice. * All rights reserved. * @@ -30,7 +32,7 @@ #define INTR_VECTORS 256 -#define MAX_PICS 16 +#define MAX_PICS 32 #define MAP_IRQ(node, pin) powerpc_get_irq(node, pin) /* @@ -46,7 +48,7 @@ driver_filter_t powerpc_ipi_handler; void intrcnt_add(const char *name, u_long **countp); -void powerpc_register_pic(device_t, uint32_t, u_int, u_int, u_int); +u_int powerpc_register_pic(device_t, uint32_t, u_int, u_int, u_int); u_int powerpc_get_irq(uint32_t, u_int); void powerpc_dispatch_intr(u_int, struct trapframe *); diff --git a/freebsd/sys/powerpc/include/machine/psl.h b/freebsd/sys/powerpc/include/machine/psl.h index bb4756f0..329120f4 100644 --- a/freebsd/sys/powerpc/include/machine/psl.h +++ b/freebsd/sys/powerpc/include/machine/psl.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (C) 1995, 1996 Wolfgang Solfrank. * Copyright (C) 1995, 1996 TooLs GmbH. * All rights reserved. @@ -45,15 +47,16 @@ #define PSL_FP 0x00002000UL /* floating point enable */ #define PSL_ME 0x00001000UL /* machine check enable */ #define PSL_FE0 0x00000800UL /* floating point interrupt mode 0 */ -#define PSL_BE 0x00000200UL /* branch trace enable */ #define PSL_FE1 0x00000100UL /* floating point interrupt mode 1 */ #define PSL_PMM 0x00000004UL /* performance monitor mark */ +#define PSL_RI 0x00000002UL /* recoverable interrupt */ /* Machine State Register - Book-E cores */ #ifdef __powerpc64__ #define PSL_CM 0x80000000UL /* Computation Mode (64-bit) */ #endif +#define PSL_GS 0x10000000UL /* Guest state */ #define PSL_UCLE 0x04000000UL /* User mode cache lock enable */ #define PSL_WE 0x00040000UL /* Wait state enable */ #define PSL_CE 0x00020000UL /* Critical interrupt enable */ @@ -72,10 +75,10 @@ #define PSL_POW 0x00040000UL /* power management */ #define PSL_ILE 0x00010000UL /* interrupt endian mode (1 == le) */ #define PSL_SE 0x00000400UL /* single-step trace enable */ +#define PSL_BE 0x00000200UL /* branch trace enable */ #define PSL_IP 0x00000040UL /* interrupt prefix - 601 only */ #define PSL_IR 0x00000020UL /* instruction address relocation */ #define PSL_DR 0x00000010UL /* data address relocation */ -#define PSL_RI 0x00000002UL /* recoverable interrupt */ #define PSL_LE 0x00000001UL /* endian mode (1 == le) */ /* diff --git a/freebsd/sys/powerpc/include/machine/spr.h b/freebsd/sys/powerpc/include/machine/spr.h index 5efdf961..3e479415 100644 --- a/freebsd/sys/powerpc/include/machine/spr.h +++ b/freebsd/sys/powerpc/include/machine/spr.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 The NetBSD Foundation, Inc. * All rights reserved. * @@ -210,6 +212,11 @@ #define EPCR_DMIUH 0x00400000 #define EPCR_PMGS 0x00200000 #define SPR_SPEFSCR 0x200 /* ..8 Signal Processing Engine FSCR. */ + +#define SPR_LPCR 0x13e /* Logical Partitioning Control */ +#define LPCR_LPES 0x008 /* Bit 60 */ +#define SPR_LPID 0x13f /* Logical Partitioning Control */ + #define SPR_IBAT0U 0x210 /* .68 Instruction BAT Reg 0 Upper */ #define SPR_IBAT0U 0x210 /* .6. Instruction BAT Reg 0 Upper */ #define SPR_IBAT0L 0x211 /* .6. Instruction BAT Reg 0 Lower */ @@ -745,6 +752,8 @@ #define SVR_P4040E 0x8208 #define SVR_P4080 0x8201 #define SVR_P4080E 0x8209 +#define SVR_P5010 0x8221 +#define SVR_P5010E 0x8229 #define SVR_P5020 0x8220 #define SVR_P5020E 0x8228 #define SVR_P5021 0x8205 diff --git a/freebsd/sys/powerpc/powerpc/in_cksum.c b/freebsd/sys/powerpc/powerpc/in_cksum.c index d73fed4e..ab25a651 100644 --- a/freebsd/sys/powerpc/powerpc/in_cksum.c +++ b/freebsd/sys/powerpc/powerpc/in_cksum.c @@ -4,6 +4,8 @@ /* $NetBSD: in_cksum.c,v 1.7 1997/09/02 13:18:15 thorpej Exp $ */ /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 1988, 1992, 1993 * The Regents of the University of California. All rights reserved. * Copyright (c) 1996 diff --git a/freebsd/sys/rpc/types.h b/freebsd/sys/rpc/types.h index 62b5aca1..e5d728d6 100644 --- a/freebsd/sys/rpc/types.h +++ b/freebsd/sys/rpc/types.h @@ -1,6 +1,8 @@ /* $NetBSD: types.h,v 1.13 2000/06/13 01:02:44 thorpej Exp $ */ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * diff --git a/freebsd/sys/security/audit/audit.h b/freebsd/sys/security/audit/audit.h index 12cda7b5..055194d3 100644 --- a/freebsd/sys/security/audit/audit.h +++ b/freebsd/sys/security/audit/audit.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1999-2005 Apple Inc. * Copyright (c) 2016-2017 Robert N. M. Watson * All rights reserved. diff --git a/freebsd/sys/sh/include/machine/in_cksum.h b/freebsd/sys/sh/include/machine/in_cksum.h index 72edfba9..d55b838b 100644 --- a/freebsd/sys/sh/include/machine/in_cksum.h +++ b/freebsd/sys/sh/include/machine/in_cksum.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * diff --git a/freebsd/sys/sparc/include/machine/in_cksum.h b/freebsd/sys/sparc/include/machine/in_cksum.h index 72edfba9..d55b838b 100644 --- a/freebsd/sys/sparc/include/machine/in_cksum.h +++ b/freebsd/sys/sparc/include/machine/in_cksum.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * diff --git a/freebsd/sys/sparc64/include/machine/asi.h b/freebsd/sys/sparc64/include/machine/asi.h index e5769c12..2a40eb89 100644 --- a/freebsd/sys/sparc64/include/machine/asi.h +++ b/freebsd/sys/sparc64/include/machine/asi.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/sparc64/include/machine/cpufunc.h b/freebsd/sys/sparc64/include/machine/cpufunc.h index abfbd1fd..934e6717 100644 --- a/freebsd/sys/sparc64/include/machine/cpufunc.h +++ b/freebsd/sys/sparc64/include/machine/cpufunc.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 Jake Burkholder. * All rights reserved. * diff --git a/freebsd/sys/sparc64/include/machine/in_cksum.h b/freebsd/sys/sparc64/include/machine/in_cksum.h index b13882e0..6f80d699 100644 --- a/freebsd/sys/sparc64/include/machine/in_cksum.h +++ b/freebsd/sys/sparc64/include/machine/in_cksum.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * diff --git a/freebsd/sys/sparc64/include/machine/pstate.h b/freebsd/sys/sparc64/include/machine/pstate.h index 4f536303..df3a25bd 100644 --- a/freebsd/sys/sparc64/include/machine/pstate.h +++ b/freebsd/sys/sparc64/include/machine/pstate.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 Jake Burkholder. * All rights reserved. * diff --git a/freebsd/sys/sparc64/sparc64/in_cksum.c b/freebsd/sys/sparc64/sparc64/in_cksum.c index bc8e5f62..58a19845 100644 --- a/freebsd/sys/sparc64/sparc64/in_cksum.c +++ b/freebsd/sys/sparc64/sparc64/in_cksum.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * diff --git a/freebsd/sys/sys/_bus_dma.h b/freebsd/sys/sys/_bus_dma.h index 91318d01..c2a17301 100644 --- a/freebsd/sys/sys/_bus_dma.h +++ b/freebsd/sys/sys/_bus_dma.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright 2006 John-Mark Gurney. * All rights reserved. * diff --git a/freebsd/sys/sys/_callout.h b/freebsd/sys/sys/_callout.h index 53df18e9..60b02f56 100644 --- a/freebsd/sys/sys/_callout.h +++ b/freebsd/sys/sys/_callout.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. diff --git a/freebsd/sys/sys/_lock.h b/freebsd/sys/sys/_lock.h index e92430c4..ae10254c 100644 --- a/freebsd/sys/sys/_lock.h +++ b/freebsd/sys/sys/_lock.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/sys/_lockmgr.h b/freebsd/sys/sys/_lockmgr.h index 0367ff1e..62e50df1 100644 --- a/freebsd/sys/sys/_lockmgr.h +++ b/freebsd/sys/sys/_lockmgr.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Attilio Rao <attilio@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/sys/_mutex.h b/freebsd/sys/sys/_mutex.h index 96f53238..5252aee1 100644 --- a/freebsd/sys/sys/_mutex.h +++ b/freebsd/sys/sys/_mutex.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/sys/_null.h b/freebsd/sys/sys/_null.h index 92706c6a..8fa5e424 100644 --- a/freebsd/sys/sys/_null.h +++ b/freebsd/sys/sys/_null.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2003 Marcel Moolenaar * All rights reserved. * diff --git a/freebsd/sys/sys/_pctrie.h b/freebsd/sys/sys/_pctrie.h index c6d13baa..d9a98a78 100644 --- a/freebsd/sys/sys/_pctrie.h +++ b/freebsd/sys/sys/_pctrie.h @@ -1,4 +1,6 @@ -/* +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2013 EMC Corp. * Copyright (c) 2011 Jeffrey Roberson <jeff@freebsd.org> * Copyright (c) 2008 Mayur Shardul <mayur.shardul@gmail.com> diff --git a/freebsd/sys/sys/_rmlock.h b/freebsd/sys/sys/_rmlock.h index adc2bc56..28e3cb34 100644 --- a/freebsd/sys/sys/_rmlock.h +++ b/freebsd/sys/sys/_rmlock.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2007 Stephan Uphoff <ups@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/sys/_rwlock.h b/freebsd/sys/sys/_rwlock.h index 029fb98b..318592d5 100644 --- a/freebsd/sys/sys/_rwlock.h +++ b/freebsd/sys/sys/_rwlock.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2006 John Baldwin <jhb@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/sys/_semaphore.h b/freebsd/sys/sys/_semaphore.h index 560076c8..b5c48251 100644 --- a/freebsd/sys/sys/_semaphore.h +++ b/freebsd/sys/sys/_semaphore.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2002 Alfred Perlstein <alfred@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/sys/_sx.h b/freebsd/sys/sys/_sx.h index b07ac47a..328a43a4 100644 --- a/freebsd/sys/sys/_sx.h +++ b/freebsd/sys/sys/_sx.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007 Attilio Rao <attilio@freebsd.org> * All rights reserved. * diff --git a/freebsd/sys/sys/_task.h b/freebsd/sys/sys/_task.h index d46659f4..392dc874 100644 --- a/freebsd/sys/sys/_task.h +++ b/freebsd/sys/sys/_task.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2000 Doug Rabson * All rights reserved. * diff --git a/freebsd/sys/sys/_unrhdr.h b/freebsd/sys/sys/_unrhdr.h index f3c25d16..65abe578 100644 --- a/freebsd/sys/sys/_unrhdr.h +++ b/freebsd/sys/sys/_unrhdr.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2004 Poul-Henning Kamp * All rights reserved. * diff --git a/freebsd/sys/sys/acl.h b/freebsd/sys/sys/acl.h index 9806a54a..196447a6 100644 --- a/freebsd/sys/sys/acl.h +++ b/freebsd/sys/sys/acl.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1999-2001 Robert N. M. Watson * Copyright (c) 2008 Edward Tomasz Napierała <trasz@FreeBSD.org> * All rights reserved. diff --git a/freebsd/sys/sys/aio.h b/freebsd/sys/sys/aio.h index ab6f766f..2843042b 100644 --- a/freebsd/sys/sys/aio.h +++ b/freebsd/sys/sys/aio.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1997 John S. Dyson. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -256,7 +258,7 @@ int aio_suspend(const struct aiocb * const[], int, const struct timespec *); */ int aio_mlock(struct aiocb *); -#ifdef __BSD_VISIBLE +#if __BSD_VISIBLE ssize_t aio_waitcomplete(struct aiocb **, struct timespec *); #endif diff --git a/freebsd/sys/sys/ata.h b/freebsd/sys/sys/ata.h index 4d3b3e7f..f8a332c3 100644 --- a/freebsd/sys/sys/ata.h +++ b/freebsd/sys/sys/ata.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2000 - 2008 Søren Schmidt <sos@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/sys/blist.h b/freebsd/sys/sys/blist.h index 486e04eb..22d834f7 100644 --- a/freebsd/sys/sys/blist.h +++ b/freebsd/sys/sys/blist.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1998 Matthew Dillon. All Rights Reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -82,7 +84,7 @@ typedef struct blist { daddr_t bl_blocks; /* area of coverage */ u_daddr_t bl_radix; /* coverage radix */ daddr_t bl_cursor; /* next-fit search starts at */ - blmeta_t *bl_root; /* root of radix tree */ + blmeta_t bl_root[1]; /* root of radix tree */ } *blist_t; #define BLIST_META_RADIX 16 diff --git a/freebsd/sys/sys/buf.h b/freebsd/sys/sys/buf.h index 5d4f0dc6..77acac5b 100644 --- a/freebsd/sys/sys/buf.h +++ b/freebsd/sys/sys/buf.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1989, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. diff --git a/freebsd/sys/sys/buf_ring.h b/freebsd/sys/sys/buf_ring.h index 3655775e..0b633238 100644 --- a/freebsd/sys/sys/buf_ring.h +++ b/freebsd/sys/sys/buf_ring.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007-2009 Kip Macy <kmacy@freebsd.org> * All rights reserved. * diff --git a/freebsd/sys/sys/bufobj.h b/freebsd/sys/sys/bufobj.h index 2dc440a6..fb3f0873 100644 --- a/freebsd/sys/sys/bufobj.h +++ b/freebsd/sys/sys/bufobj.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2004 Poul-Henning Kamp * All rights reserved. * diff --git a/freebsd/sys/sys/bus.h b/freebsd/sys/sys/bus.h index 626026dc..7a3f6b1a 100644 --- a/freebsd/sys/sys/bus.h +++ b/freebsd/sys/sys/bus.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1997,1998,2003 Doug Rabson * All rights reserved. * @@ -491,6 +493,7 @@ struct resource_spec { int rid; int flags; }; +#define RESOURCE_SPEC_END {-1, 0, 0} int bus_alloc_resources(device_t dev, struct resource_spec *rs, struct resource **res); @@ -632,7 +635,6 @@ struct sysctl_oid *devclass_get_sysctl_tree(devclass_t dc); /* * Access functions for device resources. */ - int resource_int_value(const char *name, int unit, const char *resname, int *result); int resource_long_value(const char *name, int unit, const char *resname, @@ -644,12 +646,6 @@ int resource_find_match(int *anchor, const char **name, int *unit, const char *resname, const char *value); int resource_find_dev(int *anchor, const char *name, int *unit, const char *resname, const char *value); -int resource_set_int(const char *name, int unit, const char *resname, - int value); -int resource_set_long(const char *name, int unit, const char *resname, - long value); -int resource_set_string(const char *name, int unit, const char *resname, - const char *value); int resource_unset_value(const char *name, int unit, const char *resname); /* diff --git a/freebsd/sys/sys/bus_dma.h b/freebsd/sys/sys/bus_dma.h index 04dbe0cb..c5799661 100644 --- a/freebsd/sys/sys/bus_dma.h +++ b/freebsd/sys/sys/bus_dma.h @@ -1,6 +1,8 @@ /* $NetBSD: bus.h,v 1.12 1997/10/01 08:25:15 fvdl Exp $ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. * All rights reserved. * diff --git a/freebsd/sys/sys/callout.h b/freebsd/sys/sys/callout.h index 68861957..a0b45d98 100644 --- a/freebsd/sys/sys/callout.h +++ b/freebsd/sys/sys/callout.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. diff --git a/freebsd/sys/sys/capability.h b/freebsd/sys/sys/capability.h index 3bdaf203..4b07c090 100644 --- a/freebsd/sys/sys/capability.h +++ b/freebsd/sys/sys/capability.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2014 Robert N. M. Watson * All rights reserved. * diff --git a/freebsd/sys/sys/caprights.h b/freebsd/sys/sys/caprights.h index eb8e454f..8698483c 100644 --- a/freebsd/sys/sys/caprights.h +++ b/freebsd/sys/sys/caprights.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2013 FreeBSD Foundation * All rights reserved. * diff --git a/freebsd/sys/sys/condvar.h b/freebsd/sys/sys/condvar.h index c4666694..cf3cc6ba 100644 --- a/freebsd/sys/sys/condvar.h +++ b/freebsd/sys/sys/condvar.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2000 Jake Burkholder <jake@freebsd.org>. * All rights reserved. * diff --git a/freebsd/sys/sys/conf.h b/freebsd/sys/sys/conf.h index 8bf6a3ed..7f240f68 100644 --- a/freebsd/sys/sys/conf.h +++ b/freebsd/sys/sys/conf.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * Copyright (c) 2000 @@ -364,26 +366,29 @@ struct dumperinfo { off_t mediaoffset; /* Initial offset in bytes. */ off_t mediasize; /* Space available in bytes. */ void *blockbuf; /* Buffer for padding shorter dump blocks */ + off_t dumpoff; /* Offset of ongoing kernel dump. */ struct kerneldumpcrypto *kdc; /* Kernel dump crypto. */ + struct kerneldumpgz *kdgz; /* Kernel dump compression. */ }; -int set_dumper(struct dumperinfo *di, const char *devname, struct thread *td, - uint8_t encrypt, const uint8_t *key, uint32_t encryptedkeysize, - const uint8_t *encryptedkey); -void dump_init_header(const struct dumperinfo *di, struct kerneldumpheader *kdh, - char *magic, uint32_t archver, uint64_t dumplen); -int dump_start(struct dumperinfo *di, struct kerneldumpheader *kdh, - off_t *dumplop); -int dump_finish(struct dumperinfo *di, struct kerneldumpheader *kdh, - off_t dumplo); -int dump_write(struct dumperinfo *, void *, vm_offset_t, off_t, size_t); -int doadump(boolean_t); #ifndef __rtems__ extern int dumping; /* system is dumping */ #else /* __rtems__ */ -#define dumping 0 +#define dumping 0 #endif /* __rtems__ */ +int doadump(boolean_t); +int set_dumper(struct dumperinfo *di, const char *devname, struct thread *td, + uint8_t compression, uint8_t encryption, const uint8_t *key, + uint32_t encryptedkeysize, const uint8_t *encryptedkey); + +int dump_start(struct dumperinfo *di, struct kerneldumpheader *kdh); +int dump_append(struct dumperinfo *, void *, vm_offset_t, size_t); +int dump_write(struct dumperinfo *, void *, vm_offset_t, off_t, size_t); +int dump_finish(struct dumperinfo *di, struct kerneldumpheader *kdh); +void dump_init_header(const struct dumperinfo *di, struct kerneldumpheader *kdh, + char *magic, uint32_t archver, uint64_t dumplen); + #endif /* _KERNEL */ #endif /* !_SYS_CONF_H_ */ diff --git a/freebsd/sys/sys/cons.h b/freebsd/sys/sys/cons.h index 78cba61e..aded0459 100644 --- a/freebsd/sys/sys/cons.h +++ b/freebsd/sys/sys/cons.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1988 University of Utah. * Copyright (c) 1991 The Regents of the University of California. * All rights reserved. diff --git a/freebsd/sys/sys/counter.h b/freebsd/sys/sys/counter.h index 5046d41d..418141a5 100644 --- a/freebsd/sys/sys/counter.h +++ b/freebsd/sys/sys/counter.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2012 Gleb Smirnoff <glebius@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/sys/cpu.h b/freebsd/sys/sys/cpu.h index f159e376..b3b745ab 100644 --- a/freebsd/sys/sys/cpu.h +++ b/freebsd/sys/sys/cpu.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2005-2007 Nate Lawson (SDG) * All rights reserved. * diff --git a/freebsd/sys/sys/ctype.h b/freebsd/sys/sys/ctype.h index 57b848b5..b2a1fa93 100644 --- a/freebsd/sys/sys/ctype.h +++ b/freebsd/sys/sys/ctype.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1988, 1991, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. diff --git a/freebsd/sys/sys/domain.h b/freebsd/sys/sys/domain.h index 64da7ed7..513d624b 100644 --- a/freebsd/sys/sys/domain.h +++ b/freebsd/sys/sys/domain.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/sys/eventhandler.h b/freebsd/sys/sys/eventhandler.h index b071c639..cc423752 100644 --- a/freebsd/sys/sys/eventhandler.h +++ b/freebsd/sys/sys/eventhandler.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1999 Michael Smith <msmith@freebsd.org> * All rights reserved. * @@ -51,8 +53,7 @@ struct eventhandler_entry_vimage { struct eventhandler_list { char *el_name; - int el_flags; -#define EHL_INITTED (1<<0) + int el_flags; /* Unused. */ u_int el_runcount; struct mtx el_lock; TAILQ_ENTRY(eventhandler_list) el_link; @@ -72,8 +73,6 @@ typedef struct eventhandler_entry *eventhandler_tag; struct eventhandler_entry *_ep; \ struct eventhandler_entry_ ## name *_t; \ \ - KASSERT((list)->el_flags & EHL_INITTED, \ - ("eventhandler_invoke: running non-inited list")); \ EHL_LOCK_ASSERT((list), MA_OWNED); \ (list)->el_runcount++; \ KASSERT((list)->el_runcount > 0, \ @@ -98,10 +97,41 @@ typedef struct eventhandler_entry *eventhandler_tag; } while (0) /* - * Slow handlers are entirely dynamic; lists are created - * when entries are added to them, and thus have no concept of "owner", - * - * Slow handlers need to be declared, but do not need to be defined. The + * You can optionally use the EVENTHANDLER_LIST and EVENTHANDLER_DIRECT macros + * to pre-define a symbol for the eventhandler list. This symbol can be used by + * EVENTHANDLER_DIRECT_INVOKE, which has the advantage of not needing to do a + * locked search of the global list of eventhandler lists. At least + * EVENTHANDLER_LIST_DEFINE must be be used for EVENTHANDLER_DIRECT_INVOKE to + * work. EVENTHANDLER_LIST_DECLARE is only needed if the call to + * EVENTHANDLER_DIRECT_INVOKE is in a different compilation unit from + * EVENTHANDLER_LIST_DEFINE. If the events are even relatively high frequency + * it is suggested that you directly define a list for them. + */ +#define EVENTHANDLER_LIST_DECLARE(name) \ +extern struct eventhandler_list *_eventhandler_list_ ## name \ + +#define EVENTHANDLER_LIST_DEFINE(name) \ +struct eventhandler_list *_eventhandler_list_ ## name ; \ +static void _ehl_init_ ## name (void * ctx __unused) \ +{ \ + _eventhandler_list_ ## name = eventhandler_create_list(#name); \ +} \ +SYSINIT(name ## _ehl_init, SI_SUB_EVENTHANDLER, SI_ORDER_ANY, \ + _ehl_init_ ## name, NULL); \ + struct __hack + +#define EVENTHANDLER_DIRECT_INVOKE(name, ...) do { \ + struct eventhandler_list *_el; \ + \ + _el = _eventhandler_list_ ## name ; \ + if (!TAILQ_EMPTY(&_el->el_entries)) { \ + EHL_LOCK(_el); \ + _EVENTHANDLER_INVOKE(name, _el , ## __VA_ARGS__); \ + } \ +} while (0) + +/* + * Event handlers need to be declared, but do not need to be defined. The * declaration must be in scope wherever the handler is to be invoked. */ #define EVENTHANDLER_DECLARE(name, type) \ @@ -141,14 +171,24 @@ do { \ if ((_el = eventhandler_find_list(#name)) != NULL) \ eventhandler_deregister(_el, tag); \ } while(0) - + +#define EVENTHANDLER_DEREGISTER_NOWAIT(name, tag) \ +do { \ + struct eventhandler_list *_el; \ + \ + if ((_el = eventhandler_find_list(#name)) != NULL) \ + eventhandler_deregister_nowait(_el, tag); \ +} while(0) eventhandler_tag eventhandler_register(struct eventhandler_list *list, const char *name, void *func, void *arg, int priority); void eventhandler_deregister(struct eventhandler_list *list, eventhandler_tag tag); +void eventhandler_deregister_nowait(struct eventhandler_list *list, + eventhandler_tag tag); struct eventhandler_list *eventhandler_find_list(const char *name); void eventhandler_prune_list(struct eventhandler_list *list); +struct eventhandler_list *eventhandler_create_list(const char *name); #ifdef VIMAGE typedef void (*vimage_iterator_func_t)(void *, ...); @@ -284,4 +324,15 @@ typedef void (*swapoff_fn)(void *, struct swdevt *); EVENTHANDLER_DECLARE(swapon, swapon_fn); EVENTHANDLER_DECLARE(swapoff, swapoff_fn); +/* newbus device events */ +enum evhdev_detach { + EVHDEV_DETACH_BEGIN, /* Before detach() is called */ + EVHDEV_DETACH_COMPLETE, /* After detach() returns 0 */ + EVHDEV_DETACH_FAILED /* After detach() returns err */ +}; +typedef void (*device_attach_fn)(void *, device_t); +typedef void (*device_detach_fn)(void *, device_t, enum evhdev_detach); +EVENTHANDLER_DECLARE(device_attach, device_attach_fn); +EVENTHANDLER_DECLARE(device_detach, device_detach_fn); + #endif /* _SYS_EVENTHANDLER_H_ */ diff --git a/freebsd/sys/sys/eventvar.h b/freebsd/sys/sys/eventvar.h index 335a6191..8afaa1aa 100644 --- a/freebsd/sys/sys/eventvar.h +++ b/freebsd/sys/sys/eventvar.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1999,2000 Jonathan Lemon <jlemon@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/sys/fail.h b/freebsd/sys/sys/fail.h index 34695bc8..41e07bae 100644 --- a/freebsd/sys/sys/fail.h +++ b/freebsd/sys/sys/fail.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2009 Isilon Inc http://www.isilon.com/ * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/sys/file.h b/freebsd/sys/sys/file.h index 2adbd0af..a566e69c 100644 --- a/freebsd/sys/sys/file.h +++ b/freebsd/sys/sys/file.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1989, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/sys/filedesc.h b/freebsd/sys/sys/filedesc.h index 457898ef..5a0b2db1 100644 --- a/freebsd/sys/sys/filedesc.h +++ b/freebsd/sys/sys/filedesc.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/sys/firmware.h b/freebsd/sys/sys/firmware.h index ce02831a..8a9b2cf2 100644 --- a/freebsd/sys/sys/firmware.h +++ b/freebsd/sys/sys/firmware.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2005, Sam Leffler <sam@errno.com> * All rights reserved. * diff --git a/freebsd/sys/sys/gpio.h b/freebsd/sys/sys/gpio.h index dbe55872..2505269d 100644 --- a/freebsd/sys/sys/gpio.h +++ b/freebsd/sys/sys/gpio.h @@ -1,6 +1,8 @@ /* $NetBSD: gpio.h,v 1.7 2009/09/25 20:27:50 mbalmer Exp $ */ /* $OpenBSD: gpio.h,v 1.7 2008/11/26 14:51:20 mbalmer Exp $ */ /*- + * SPDX-License-Identifier: (BSD-2-Clause-FreeBSD AND ISC) + * * Copyright (c) 2009, Oleksandr Tymoshenko <gonzo@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/sys/hash.h b/freebsd/sys/sys/hash.h index 8abf17bb..35e76ec7 100644 --- a/freebsd/sys/sys/hash.h +++ b/freebsd/sys/sys/hash.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 Tobias Weingartner * All rights reserved. * diff --git a/freebsd/sys/sys/hhook.h b/freebsd/sys/sys/hhook.h index 1d60dd3b..76c827e6 100644 --- a/freebsd/sys/sys/hhook.h +++ b/freebsd/sys/sys/hhook.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2010,2013 Lawrence Stewart <lstewart@freebsd.org> * Copyright (c) 2010 The FreeBSD Foundation * All rights reserved. diff --git a/freebsd/sys/sys/interrupt.h b/freebsd/sys/sys/interrupt.h index 44b769f2..7c9aad4d 100644 --- a/freebsd/sys/sys/interrupt.h +++ b/freebsd/sys/sys/interrupt.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1997, Stefan Esser <se@freebsd.org> * All rights reserved. * diff --git a/freebsd/sys/sys/jail.h b/freebsd/sys/sys/jail.h index bc9025cf..3bbbf5e0 100644 --- a/freebsd/sys/sys/jail.h +++ b/freebsd/sys/sys/jail.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1999 Poul-Henning Kamp. * Copyright (c) 2009 James Gritton. * All rights reserved. diff --git a/freebsd/sys/sys/kenv.h b/freebsd/sys/sys/kenv.h index 0a30ddb3..fd1ae31f 100644 --- a/freebsd/sys/sys/kenv.h +++ b/freebsd/sys/sys/kenv.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2002 Maxime Henrion <mux@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/sys/kernel.h b/freebsd/sys/sys/kernel.h index 051173f7..1cc03275 100644 --- a/freebsd/sys/sys/kernel.h +++ b/freebsd/sys/sys/kernel.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 1995 Terrence R. Lambert * All rights reserved. * diff --git a/freebsd/sys/sys/khelp.h b/freebsd/sys/sys/khelp.h index f542b148..54c4791d 100644 --- a/freebsd/sys/sys/khelp.h +++ b/freebsd/sys/sys/khelp.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2010 Lawrence Stewart <lstewart@freebsd.org> * Copyright (c) 2010 The FreeBSD Foundation * All rights reserved. diff --git a/freebsd/sys/sys/kobj.h b/freebsd/sys/sys/kobj.h index 862e79f0..5f8b2bb0 100644 --- a/freebsd/sys/sys/kobj.h +++ b/freebsd/sys/sys/kobj.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2000,2003 Doug Rabson * All rights reserved. * diff --git a/freebsd/sys/sys/kthread.h b/freebsd/sys/sys/kthread.h index b6304f52..e6f1fa41 100644 --- a/freebsd/sys/sys/kthread.h +++ b/freebsd/sys/sys/kthread.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1999 Peter Wemm <peter@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/sys/ktr.h b/freebsd/sys/sys/ktr.h index 07d7c45b..d9bd2bf6 100644 --- a/freebsd/sys/sys/ktr.h +++ b/freebsd/sys/sys/ktr.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1996 Berkeley Software Design, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/sys/ktr_class.h b/freebsd/sys/sys/ktr_class.h index 4bfc895b..9190ce27 100644 --- a/freebsd/sys/sys/ktr_class.h +++ b/freebsd/sys/sys/ktr_class.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1996 Berkeley Software Design, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/sys/libkern.h b/freebsd/sys/sys/libkern.h index ab47eeaa..4d043f5a 100644 --- a/freebsd/sys/sys/libkern.h +++ b/freebsd/sys/sys/libkern.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/sys/limits.h b/freebsd/sys/sys/limits.h index fdf98ba3..2de06c61 100644 --- a/freebsd/sys/sys/limits.h +++ b/freebsd/sys/sys/limits.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/sys/linker.h b/freebsd/sys/sys/linker.h index 330af02e..6d560574 100644 --- a/freebsd/sys/sys/linker.h +++ b/freebsd/sys/sys/linker.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1997-2000 Doug Rabson * All rights reserved. * diff --git a/freebsd/sys/sys/linker_set.h b/freebsd/sys/sys/linker_set.h index a310b066..7e33c93f 100755 --- a/freebsd/sys/sys/linker_set.h +++ b/freebsd/sys/sys/linker_set.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1999 John D. Polstra * Copyright (c) 1999,2001 Peter Wemm <peter@FreeBSD.org> * All rights reserved. @@ -104,10 +106,7 @@ RTEMS_BSD_DEFINE_RWSET_ITEM(set, sym, const void *) = &sym #endif /* __rtems__ */ #else /* !__GNUCLIKE___SECTION */ -#ifndef lint #error this file needs to be ported to your compiler -#endif /* lint */ -#define __MAKE_SET(set, sym) extern void const * const (__set_##set##_sym_##sym) #endif /* __GNUCLIKE___SECTION */ /* diff --git a/freebsd/sys/sys/lock_profile.h b/freebsd/sys/sys/lock_profile.h index bf73ca14..7c7edee4 100644 --- a/freebsd/sys/sys/lock_profile.h +++ b/freebsd/sys/sys/lock_profile.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2006 Kip Macy kmacy@FreeBSD.org * Copyright (c) 2006 Kris Kennaway kris@FreeBSD.org * Copyright (c) 2006 Dag-Erling Smorgrav des@des.no diff --git a/freebsd/sys/sys/lockmgr.h b/freebsd/sys/sys/lockmgr.h index 60749228..03ae6f9e 100644 --- a/freebsd/sys/sys/lockmgr.h +++ b/freebsd/sys/sys/lockmgr.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Attilio Rao <attilio@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/sys/lockstat.h b/freebsd/sys/sys/lockstat.h index 64745052..50747e89 100644 --- a/freebsd/sys/sys/lockstat.h +++ b/freebsd/sys/sys/lockstat.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008-2009 Stacey Son <sson@FreeBSD.org> * * Redistribution and use in source and binary forms, with or without diff --git a/freebsd/sys/sys/loginclass.h b/freebsd/sys/sys/loginclass.h index 6783123a..9bc14766 100644 --- a/freebsd/sys/sys/loginclass.h +++ b/freebsd/sys/sys/loginclass.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2011 The FreeBSD Foundation * All rights reserved. * diff --git a/freebsd/sys/sys/mac.h b/freebsd/sys/sys/mac.h index 0aa89608..bc12cb75 100644 --- a/freebsd/sys/sys/mac.h +++ b/freebsd/sys/sys/mac.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1999-2002 Robert N. M. Watson * Copyright (c) 2001-2005 Networks Associates Technology, Inc. * Copyright (c) 2005-2006 SPARTA, Inc. diff --git a/freebsd/sys/sys/malloc.h b/freebsd/sys/sys/malloc.h index c93439f3..c5ab6125 100644 --- a/freebsd/sys/sys/malloc.h +++ b/freebsd/sys/sys/malloc.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1987, 1993 * The Regents of the University of California. * Copyright (c) 2005, 2009 Robert N. M. Watson diff --git a/freebsd/sys/sys/mbuf.h b/freebsd/sys/sys/mbuf.h index ec98aaec..4a91b794 100644 --- a/freebsd/sys/sys/mbuf.h +++ b/freebsd/sys/sys/mbuf.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1988, 1993 * The Regents of the University of California. * All rights reserved. @@ -154,14 +156,20 @@ struct pkthdr { /* Layer crossing persistent information. */ uint32_t flowid; /* packet's 4-tuple system */ - uint64_t csum_flags; /* checksum and offload features */ + uint32_t csum_flags; /* checksum and offload features */ uint16_t fibnum; /* this packet should use this fib */ uint8_t cosqos; /* class/quality of service */ uint8_t rsstype; /* hash type */ - uint8_t l2hlen; /* layer 2 header length */ - uint8_t l3hlen; /* layer 3 header length */ - uint8_t l4hlen; /* layer 4 header length */ - uint8_t l5hlen; /* layer 5 header length */ + union { + uint64_t rcv_tstmp; /* timestamp in ns */ + struct { + uint8_t l2hlen; /* layer 2 hdr len */ + uint8_t l3hlen; /* layer 3 hdr len */ + uint8_t l4hlen; /* layer 4 hdr len */ + uint8_t l5hlen; /* layer 5 hdr len */ + uint32_t spare; + }; + }; union { uint8_t eight[8]; uint16_t sixteen[4]; @@ -197,17 +205,33 @@ struct pkthdr { * Compile-time assertions in uipc_mbuf.c test these values to ensure that * they are correct. */ +typedef void m_ext_free_t(struct mbuf *); struct m_ext { union { - volatile u_int ext_count; /* value of ref count info */ - volatile u_int *ext_cnt; /* pointer to ref count info */ + /* + * If EXT_FLAG_EMBREF is set, then we use refcount in the + * mbuf, the 'ext_count' member. Otherwise, we have a + * shadow copy and we use pointer 'ext_cnt'. The original + * mbuf is responsible to carry the pointer to free routine + * and its arguments. They aren't copied into shadows in + * mb_dupcl() to avoid dereferencing next cachelines. + */ + volatile u_int ext_count; + volatile u_int *ext_cnt; }; - caddr_t ext_buf; /* start of buffer */ + char *ext_buf; /* start of buffer */ uint32_t ext_size; /* size of buffer, for ext_free */ uint32_t ext_type:8, /* type of external storage */ ext_flags:24; /* external storage mbuf flags */ - void (*ext_free) /* free routine if not the usual */ - (struct mbuf *, void *, void *); + /* + * Fields below store the free context for the external storage. + * They are valid only in the refcount carrying mbuf, the one with + * EXT_FLAG_EMBREF flag, with exclusion for EXT_EXTREF type, where + * the free context is copied into all mbufs that use same external + * storage. + */ +#define m_ext_copylen offsetof(struct m_ext, ext_free) + m_ext_free_t *ext_free; /* free routine if not the usual */ void *ext_arg1; /* optional argument pointer */ void *ext_arg2; /* optional argument pointer */ }; @@ -277,6 +301,10 @@ struct mbuf { #define M_VLANTAG 0x00000080 /* ether_vtag is valid */ #define M_UNUSED_8 0x00000100 /* --available-- */ #define M_NOFREE 0x00000200 /* do not free mbuf, embedded in cluster */ +#define M_TSTMP 0x00000400 /* rcv_tstmp field is valid */ +#define M_TSTMP_HPREC 0x00000800 /* rcv_tstmp is high-prec, typically + hw-stamped on port (useful for IEEE 1588 + and 802.1AS) */ #define M_PROTO1 0x00001000 /* protocol-specific */ #define M_PROTO2 0x00002000 /* protocol-specific */ @@ -304,15 +332,15 @@ struct mbuf { * Flags preserved when copying m_pkthdr. */ #define M_COPYFLAGS \ - (M_PKTHDR|M_EOR|M_RDONLY|M_BCAST|M_MCAST|M_PROMISC|M_VLANTAG| \ - M_PROTOFLAGS) + (M_PKTHDR|M_EOR|M_RDONLY|M_BCAST|M_MCAST|M_PROMISC|M_VLANTAG|M_TSTMP| \ + M_TSTMP_HPREC|M_PROTOFLAGS) /* * Mbuf flag description for use with printf(9) %b identifier. */ #define M_FLAG_BITS \ "\20\1M_EXT\2M_PKTHDR\3M_EOR\4M_RDONLY\5M_BCAST\6M_MCAST" \ - "\7M_PROMISC\10M_VLANTAG" + "\7M_PROMISC\10M_VLANTAG\13M_TSTMP\14M_TSTMP_HPREC" #define M_FLAG_PROTOBITS \ "\15M_PROTO1\16M_PROTO2\17M_PROTO3\20M_PROTO4\21M_PROTO5" \ "\22M_PROTO6\23M_PROTO7\24M_PROTO8\25M_PROTO9\26M_PROTO10" \ @@ -412,9 +440,6 @@ struct mbuf { #define EXT_JUMBO16 5 /* jumbo cluster 16184 bytes */ #define EXT_PACKET 6 /* mbuf+cluster from packet zone */ #define EXT_MBUF 7 /* external mbuf reference */ -#ifndef __rtems__ -#define EXT_SFBUF_NOCACHE 8 /* sendfile(2)'s sf_buf not to be cached */ -#endif /* __rtems__ */ #define EXT_VENDOR1 224 /* for vendor-internal use */ #define EXT_VENDOR2 225 /* for vendor-internal use */ @@ -440,10 +465,10 @@ struct mbuf { #define EXT_FLAG_NOFREE 0x000010 /* don't free mbuf to pool, notyet */ -#define EXT_FLAG_VENDOR1 0x010000 /* for vendor-internal use */ -#define EXT_FLAG_VENDOR2 0x020000 /* for vendor-internal use */ -#define EXT_FLAG_VENDOR3 0x040000 /* for vendor-internal use */ -#define EXT_FLAG_VENDOR4 0x080000 /* for vendor-internal use */ +#define EXT_FLAG_VENDOR1 0x010000 /* These flags are vendor */ +#define EXT_FLAG_VENDOR2 0x020000 /* or submodule specific, */ +#define EXT_FLAG_VENDOR3 0x040000 /* not used by mbuf code. */ +#define EXT_FLAG_VENDOR4 0x080000 /* Set/read by submodule. */ #define EXT_FLAG_EXP1 0x100000 /* for experimental use */ #define EXT_FLAG_EXP2 0x200000 /* for experimental use */ @@ -460,12 +485,6 @@ struct mbuf { "\30EXT_FLAG_EXP4" /* - * External reference/free functions. - */ -void sf_ext_free(void *, void *); -void sf_ext_free_nocache(void *, void *); - -/* * Flags indicating checksum, segmentation and other offload work to be * done, or already done, by hardware or lower layers. It is split into * separate inbound and outbound flags. @@ -614,9 +633,8 @@ struct mbuf *m_devget(char *, int, int, struct ifnet *, void (*)(char *, caddr_t, u_int)); struct mbuf *m_dup(const struct mbuf *, int); int m_dup_pkthdr(struct mbuf *, const struct mbuf *, int); -void m_extadd(struct mbuf *, caddr_t, u_int, - void (*)(struct mbuf *, void *, void *), void *, void *, - int, int); +void m_extadd(struct mbuf *, char *, u_int, m_ext_free_t, + void *, void *, int, int); u_int m_fixhdr(struct mbuf *); struct mbuf *m_fragment(struct mbuf *, int, int); void m_freem(struct mbuf *); @@ -671,8 +689,8 @@ m_gettype(int size) * Associated an external reference counted buffer with an mbuf. */ static __inline void -m_extaddref(struct mbuf *m, caddr_t buf, u_int size, u_int *ref_cnt, - void (*freef)(struct mbuf *, void *, void *), void *arg1, void *arg2) +m_extaddref(struct mbuf *m, char *buf, u_int size, u_int *ref_cnt, + m_ext_free_t freef, void *arg1, void *arg2) { KASSERT(ref_cnt != NULL, ("%s: ref_cnt not provided", __func__)); @@ -869,7 +887,7 @@ m_extrefcnt(struct mbuf *m) #define MGETHDR(m, how, type) ((m) = m_gethdr((how), (type))) #define MCLGET(m, how) m_clget((m), (how)) #define MEXTADD(m, buf, size, free, arg1, arg2, flags, type) \ - m_extadd((m), (caddr_t)(buf), (size), (free), (arg1), (arg2), \ + m_extadd((m), (char *)(buf), (size), (free), (arg1), (arg2), \ (flags), (type)) #define m_getm(m, len, how, type) \ m_getm2((m), (len), (how), (type), M_PKTHDR) @@ -1345,5 +1363,17 @@ mbufq_concat(struct mbufq *mq_dst, struct mbufq *mq_src) mq_src->mq_len = 0; } +#ifdef _SYS_TIMESPEC_H_ +static inline void +mbuf_tstmp2timespec(struct mbuf *m, struct timespec *ts) +{ + + KASSERT((m->m_flags & M_PKTHDR) != 0, ("mbuf %p no M_PKTHDR", m)); + KASSERT((m->m_flags & M_TSTMP) != 0, ("mbuf %p no M_TSTMP", m)); + ts->tv_sec = m->m_pkthdr.rcv_tstmp / 1000000000; + ts->tv_nsec = m->m_pkthdr.rcv_tstmp % 1000000000; +} +#endif + #endif /* _KERNEL */ #endif /* !_SYS_MBUF_H_ */ diff --git a/freebsd/sys/sys/module.h b/freebsd/sys/sys/module.h index 75471611..eb8b03d8 100644 --- a/freebsd/sys/sys/module.h +++ b/freebsd/sys/sys/module.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1997 Doug Rabson * All rights reserved. * diff --git a/freebsd/sys/sys/module_khelp.h b/freebsd/sys/sys/module_khelp.h index 371e4c31..a6644027 100644 --- a/freebsd/sys/sys/module_khelp.h +++ b/freebsd/sys/sys/module_khelp.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2010 Lawrence Stewart <lstewart@freebsd.org> * Copyright (c) 2010 The FreeBSD Foundation * All rights reserved. diff --git a/freebsd/sys/sys/mount.h b/freebsd/sys/sys/mount.h index 152b2586..362c54e9 100644 --- a/freebsd/sys/sys/mount.h +++ b/freebsd/sys/sys/mount.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1989, 1991, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/sys/mqueue.h b/freebsd/sys/sys/mqueue.h index 36e89fa2..ca9fd13c 100644 --- a/freebsd/sys/sys/mqueue.h +++ b/freebsd/sys/sys/mqueue.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2005 David Xu <davidxu@freebsd.org> * All rights reserved. * diff --git a/freebsd/sys/sys/mutex.h b/freebsd/sys/sys/mutex.h index bd773b58..52587064 100644 --- a/freebsd/sys/sys/mutex.h +++ b/freebsd/sys/sys/mutex.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -68,15 +70,11 @@ * State bits kept in mutex->mtx_lock, for the DEFAULT lock type. None of this, * with the exception of MTX_UNOWNED, applies to spin locks. */ +#define MTX_UNOWNED 0x00000000 /* Cookie for free mutex */ #define MTX_RECURSED 0x00000001 /* lock recursed (for MTX_DEF only) */ #define MTX_CONTESTED 0x00000002 /* lock contested (for MTX_DEF only) */ -#define MTX_UNOWNED 0x00000004 /* Cookie for free mutex */ -#define MTX_FLAGMASK (MTX_RECURSED | MTX_CONTESTED | MTX_UNOWNED) - -/* - * Value stored in mutex->mtx_lock to denote a destroyed mutex. - */ -#define MTX_DESTROYED (MTX_CONTESTED | MTX_UNOWNED) +#define MTX_DESTROYED 0x00000004 /* lock destroyed */ +#define MTX_FLAGMASK (MTX_RECURSED | MTX_CONTESTED | MTX_DESTROYED) /* * Prototypes @@ -101,6 +99,7 @@ void _mtx_destroy(volatile uintptr_t *c); #endif /* __rtems__ */ void mtx_sysinit(void *arg); #ifndef __rtems__ +int _mtx_trylock_flags_int(struct mtx *m, int opts LOCK_FILE_LINE_ARG_DEF); int _mtx_trylock_flags_(volatile uintptr_t *c, int opts, const char *file, int line); #endif /* __rtems__ */ @@ -109,16 +108,20 @@ void mutex_init(void); #if LOCK_DEBUG > 0 void __mtx_lock_sleep(volatile uintptr_t *c, uintptr_t v, int opts, const char *file, int line); -void __mtx_unlock_sleep(volatile uintptr_t *c, int opts, const char *file, - int line); +void __mtx_unlock_sleep(volatile uintptr_t *c, uintptr_t v, int opts, + const char *file, int line); #else void __mtx_lock_sleep(volatile uintptr_t *c, uintptr_t v); -void __mtx_unlock_sleep(volatile uintptr_t *c); +void __mtx_unlock_sleep(volatile uintptr_t *c, uintptr_t v); #endif #ifdef SMP -void _mtx_lock_spin_cookie(volatile uintptr_t *c, uintptr_t v, uintptr_t tid, - int opts, const char *file, int line); +#if LOCK_DEBUG > 0 +void _mtx_lock_spin_cookie(volatile uintptr_t *c, uintptr_t v, int opts, + const char *file, int line); +#else +void _mtx_lock_spin_cookie(volatile uintptr_t *c, uintptr_t v); +#endif #endif void __mtx_lock_flags(volatile uintptr_t *c, int opts, const char *file, int line); @@ -150,11 +153,31 @@ void _mtx_assert(struct mtx *m, int what, const char *file, int line); #endif #ifndef __rtems__ void thread_lock_flags_(struct thread *, int, const char *, int); +#if LOCK_DEBUG > 0 +void _thread_lock(struct thread *td, int opts, const char *file, int line); +#else +void _thread_lock(struct thread *); +#endif +#if defined(LOCK_PROFILING) || defined(KLD_MODULE) #define thread_lock(tdp) \ thread_lock_flags_((tdp), 0, __FILE__, __LINE__) +#elif LOCK_DEBUG > 0 +#define thread_lock(tdp) \ + _thread_lock((tdp), 0, __FILE__, __LINE__) +#else +#define thread_lock(tdp) \ + _thread_lock((tdp)) +#endif + +#if LOCK_DEBUG > 0 #define thread_lock_flags(tdp, opt) \ thread_lock_flags_((tdp), (opt), __FILE__, __LINE__) +#else +#define thread_lock_flags(tdp, opt) \ + _thread_lock(tdp) +#endif + #define thread_unlock(tdp) \ mtx_unlock_spin((tdp)->td_lock) #else /* __rtems__ */ @@ -178,17 +201,22 @@ void thread_lock_flags_(struct thread *, int, const char *, int); #if LOCK_DEBUG > 0 #define _mtx_lock_sleep(m, v, o, f, l) \ __mtx_lock_sleep(&(m)->mtx_lock, v, o, f, l) -#define _mtx_unlock_sleep(m, o, f, l) \ - __mtx_unlock_sleep(&(m)->mtx_lock, o, f, l) +#define _mtx_unlock_sleep(m, v, o, f, l) \ + __mtx_unlock_sleep(&(m)->mtx_lock, v, o, f, l) #else #define _mtx_lock_sleep(m, v, o, f, l) \ __mtx_lock_sleep(&(m)->mtx_lock, v) -#define _mtx_unlock_sleep(m, o, f, l) \ - __mtx_unlock_sleep(&(m)->mtx_lock) +#define _mtx_unlock_sleep(m, v, o, f, l) \ + __mtx_unlock_sleep(&(m)->mtx_lock, v) #endif #ifdef SMP -#define _mtx_lock_spin(m, v, t, o, f, l) \ - _mtx_lock_spin_cookie(&(m)->mtx_lock, v, t, o, f, l) +#if LOCK_DEBUG > 0 +#define _mtx_lock_spin(m, v, o, f, l) \ + _mtx_lock_spin_cookie(&(m)->mtx_lock, v, o, f, l) +#else +#define _mtx_lock_spin(m, v, o, f, l) \ + _mtx_lock_spin_cookie(&(m)->mtx_lock, v) +#endif #endif #define _mtx_lock_flags(m, o, f, l) \ __mtx_lock_flags(&(m)->mtx_lock, o, f, l) @@ -225,6 +253,9 @@ void thread_lock_flags_(struct thread *, int, const char *, int); #define _mtx_release_lock_quick(mp) \ atomic_store_rel_ptr(&(mp)->mtx_lock, MTX_UNOWNED) +#define _mtx_release_lock_fetch(mp, vp) \ + atomic_fcmpset_rel_ptr(&(mp)->mtx_lock, (vp), MTX_UNOWNED) + /* * Full lock operations that are suitable to be inlined in non-debug * kernels. If the lock cannot be acquired or released trivially then @@ -253,11 +284,9 @@ void thread_lock_flags_(struct thread *, int, const char *, int); uintptr_t _v = MTX_UNOWNED; \ \ spinlock_enter(); \ - if (!_mtx_obtain_lock_fetch((mp), &_v, _tid)) \ - _mtx_lock_spin((mp), _v, _tid, (opts), (file), (line)); \ - else \ - LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(spin__acquire, \ - mp, 0, 0, file, line); \ + if (__predict_false(LOCKSTAT_PROFILE_ENABLED(spin__acquire) || \ + !_mtx_obtain_lock_fetch((mp), &_v, _tid))) \ + _mtx_lock_spin((mp), _v, (opts), (file), (line)); \ } while (0) #define __mtx_trylock_spin(mp, tid, opts, file, line) __extension__ ({ \ uintptr_t _tid = (uintptr_t)(tid); \ @@ -304,11 +333,11 @@ void thread_lock_flags_(struct thread *, int, const char *, int); /* Unlock a normal mutex. */ #define __mtx_unlock(mp, tid, opts, file, line) do { \ - uintptr_t _tid = (uintptr_t)(tid); \ + uintptr_t _v = (uintptr_t)(tid); \ \ if (__predict_false(LOCKSTAT_PROFILE_ENABLED(adaptive__release) ||\ - !_mtx_release_lock((mp), _tid))) \ - _mtx_unlock_sleep((mp), (opts), (file), (line)); \ + !_mtx_release_lock_fetch((mp), &_v))) \ + _mtx_unlock_sleep((mp), _v, (opts), (file), (line)); \ } while (0) /* diff --git a/freebsd/sys/sys/nlist_aout.h b/freebsd/sys/sys/nlist_aout.h index 79260ad6..0e1fa284 100644 --- a/freebsd/sys/sys/nlist_aout.h +++ b/freebsd/sys/sys/nlist_aout.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. diff --git a/freebsd/sys/sys/osd.h b/freebsd/sys/sys/osd.h index c838e97d..a9824184 100644 --- a/freebsd/sys/sys/osd.h +++ b/freebsd/sys/sys/osd.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007 Pawel Jakub Dawidek <pjd@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/sys/pciio.h b/freebsd/sys/sys/pciio.h index d70bfbcf..80d2019b 100644 --- a/freebsd/sys/sys/pciio.h +++ b/freebsd/sys/sys/pciio.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1997, Stefan Esser <se@FreeBSD.ORG> * Copyright (c) 1997, 1998, 1999, Kenneth D. Merry <ken@FreeBSD.ORG> * All rights reserved. diff --git a/freebsd/sys/sys/pcpu.h b/freebsd/sys/sys/pcpu.h index 4430cc87..bfa7f34d 100644 --- a/freebsd/sys/sys/pcpu.h +++ b/freebsd/sys/sys/pcpu.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2001 Wind River Systems, Inc. * All rights reserved. * Written by: John Baldwin <jhb@FreeBSD.org> diff --git a/freebsd/sys/sys/priv.h b/freebsd/sys/sys/priv.h index ec0943aa..52f1dbd2 100644 --- a/freebsd/sys/sys/priv.h +++ b/freebsd/sys/sys/priv.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2006 nCircle Network Security, Inc. * All rights reserved. * @@ -266,7 +268,7 @@ #define PRIV_VFS_GETFH 327 /* Can retrieve file handles. */ #define PRIV_VFS_GETQUOTA 328 /* getquota(). */ #define PRIV_VFS_LINK 329 /* bsd.hardlink_check_uid */ -#define PRIV_VFS_MKNOD_BAD 330 /* Can mknod() to mark bad inodes. */ +#define PRIV_VFS_MKNOD_BAD 330 /* Was: mknod() can mark bad inodes. */ #define PRIV_VFS_MKNOD_DEV 331 /* Can mknod() to create dev nodes. */ #define PRIV_VFS_MKNOD_WHT 332 /* Can mknod() to create whiteout. */ #define PRIV_VFS_MOUNT 333 /* Can mount(). */ diff --git a/freebsd/sys/sys/proc.h b/freebsd/sys/sys/proc.h index b28c19e6..7178c316 100644 --- a/freebsd/sys/sys/proc.h +++ b/freebsd/sys/sys/proc.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1986, 1989, 1991, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. @@ -1005,6 +1007,7 @@ extern struct proc *initproc, *pageproc; /* Process slots for init, pager. */ extern struct uma_zone *proc_zone; struct proc *pfind(pid_t); /* Find process by id. */ +struct proc *pfind_any(pid_t); /* Find (zombie) process by id. */ struct proc *pfind_locked(pid_t pid); struct pgrp *pgfind(pid_t); /* Find process group by id. */ struct proc *zpfind(pid_t); /* Find zombie process by id. */ diff --git a/freebsd/sys/sys/protosw.h b/freebsd/sys/sys/protosw.h index 33cc2074..096b5077 100644 --- a/freebsd/sys/sys/protosw.h +++ b/freebsd/sys/sys/protosw.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/sys/racct.h b/freebsd/sys/sys/racct.h index 9b8143f2..ec3322bd 100644 --- a/freebsd/sys/sys/racct.h +++ b/freebsd/sys/sys/racct.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2010 The FreeBSD Foundation * All rights reserved. * diff --git a/freebsd/sys/sys/random.h b/freebsd/sys/sys/random.h index 770a2f76..b022f5a3 100644 --- a/freebsd/sys/sys/random.h +++ b/freebsd/sys/sys/random.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2000-2015, 2017 Mark R. V. Murray * All rights reserved. * @@ -68,9 +70,9 @@ read_random(void *ptr, u_int n) #endif /* - * Note: if you add or remove members of random_entropy_source, remember to also update the - * KASSERT regarding what valid members are in random_harvest_internal(), and remember the - * strings in the static array random_source_descr[] in random_harvestq.c. + * Note: if you add or remove members of random_entropy_source, remember to + * also update the strings in the static array random_source_descr[] in + * random_harvestq.c. * * NOTE: complain loudly to markm@ or on the lists if this enum gets more than 32 * distinct values (0-31)! ENTROPYSOURCE may be == 32, but not > 32. @@ -91,7 +93,8 @@ enum random_entropy_source { RANDOM_UMA, /* Special!! UMA/SLAB Allocator */ RANDOM_ENVIRONMENTAL_END = RANDOM_UMA, /* Fast hardware random-number sources from here on. */ - RANDOM_PURE_OCTEON, + RANDOM_PURE_START, + RANDOM_PURE_OCTEON = RANDOM_PURE_START, RANDOM_PURE_SAFE, RANDOM_PURE_GLXSB, RANDOM_PURE_UBSEC, @@ -105,6 +108,7 @@ enum random_entropy_source { }; #define RANDOM_HARVEST_EVERYTHING_MASK ((1 << (RANDOM_ENVIRONMENTAL_END + 1)) - 1) +#define RANDOM_HARVEST_PURE_MASK (((1 << ENTROPYSOURCE) - 1) & (-1UL << RANDOM_PURE_START)) #define RANDOM_LEGACY_BOOT_ENTROPY_MODULE "/boot/entropy" #define RANDOM_CACHED_BOOT_ENTROPY_MODULE "boot_entropy_cache" @@ -114,10 +118,14 @@ enum random_entropy_source { void random_harvest_queue(const void *, u_int, u_int, enum random_entropy_source); void random_harvest_fast(const void *, u_int, u_int, enum random_entropy_source); void random_harvest_direct(const void *, u_int, u_int, enum random_entropy_source); +void random_harvest_register_source(enum random_entropy_source); +void random_harvest_deregister_source(enum random_entropy_source); #else #define random_harvest_queue(a, b, c, d) do {} while (0) #define random_harvest_fast(a, b, c, d) do {} while (0) #define random_harvest_direct(a, b, c, d) do {} while (0) +#define random_harvest_register_source(a) do {} while (0) +#define random_harvest_deregister_source(a) do {} while (0) #endif #if defined(RANDOM_ENABLE_UMA) diff --git a/freebsd/sys/sys/reboot.h b/freebsd/sys/sys/reboot.h index ec2a5705..d0dff609 100644 --- a/freebsd/sys/sys/reboot.h +++ b/freebsd/sys/sys/reboot.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1988, 1993, 1994 * The Regents of the University of California. All rights reserved. * @@ -60,6 +62,7 @@ #define RB_RESERVED2 0x80000 /* reserved for internal use of boot blocks */ #define RB_PAUSE 0x100000 /* pause after each output line during probe */ #define RB_REROOT 0x200000 /* unmount the rootfs and mount it again */ +#define RB_POWERCYCLE 0x400000 /* Power cycle if possible */ #define RB_MULTIPLE 0x20000000 /* use multiple consoles */ #define RB_BOOTINFO 0x80000000 /* have `struct bootinfo *' arg */ diff --git a/freebsd/sys/sys/refcount.h b/freebsd/sys/sys/refcount.h index ea846f8c..e6b26ce4 100644 --- a/freebsd/sys/sys/refcount.h +++ b/freebsd/sys/sys/refcount.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2005 John Baldwin <jhb@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/sys/resourcevar.h b/freebsd/sys/sys/resourcevar.h index d3c50830..b84bc432 100644 --- a/freebsd/sys/sys/resourcevar.h +++ b/freebsd/sys/sys/resourcevar.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/sys/rmlock.h b/freebsd/sys/sys/rmlock.h index c14dcb15..1dd2740c 100644 --- a/freebsd/sys/sys/rmlock.h +++ b/freebsd/sys/sys/rmlock.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 2007 Stephan Uphoff <ups@FreeBSD.org> * All rights reserved. * @@ -120,35 +122,21 @@ void _rm_assert(const struct rmlock *rm, int what, const char *file, struct rm_args { struct rmlock *ra_rm; const char *ra_desc; + int ra_flags; }; -struct rm_args_flags { - struct rmlock *ra_rm; - const char *ra_desc; - int ra_opts; -}; - -#define RM_SYSINIT(name, rm, desc) \ +#define RM_SYSINIT_FLAGS(name, rm, desc, flags) \ static struct rm_args name##_args = { \ (rm), \ (desc), \ + (flags), \ }; \ SYSINIT(name##_rm_sysinit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \ rm_sysinit, &name##_args); \ SYSUNINIT(name##_rm_sysuninit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \ rm_destroy, (rm)) - -#define RM_SYSINIT_FLAGS(name, rm, desc, opts) \ - static struct rm_args name##_args = { \ - (rm), \ - (desc), \ - (opts), \ - }; \ - SYSINIT(name##_rm_sysinit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \ - rm_sysinit_flags, &name##_args); \ - SYSUNINIT(name##_rm_sysuninit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \ - rm_destroy, (rm)) +#define RM_SYSINIT(name, rm, desc) RM_SYSINIT_FLAGS(name, rm, desc, 0) #if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) #define RA_LOCKED LA_LOCKED diff --git a/freebsd/sys/sys/rtprio.h b/freebsd/sys/sys/rtprio.h index 7ffdb732..52915603 100644 --- a/freebsd/sys/sys/rtprio.h +++ b/freebsd/sys/sys/rtprio.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (c) 1994, Henrik Vestergaard Draboel * All rights reserved. * diff --git a/freebsd/sys/sys/runq.h b/freebsd/sys/sys/runq.h index 50c00eb6..0e3113b1 100644 --- a/freebsd/sys/sys/runq.h +++ b/freebsd/sys/sys/runq.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 Jake Burkholder <jake@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/sys/rwlock.h b/freebsd/sys/sys/rwlock.h index 8c1f8e6d..531f10d2 100644 --- a/freebsd/sys/sys/rwlock.h +++ b/freebsd/sys/sys/rwlock.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2006 John Baldwin <jhb@FreeBSD.org> * All rights reserved. * @@ -95,6 +97,9 @@ #define _rw_write_unlock(rw, tid) \ atomic_cmpset_rel_ptr(&(rw)->rw_lock, (tid), RW_UNLOCKED) +#define _rw_write_unlock_fetch(rw, tid) \ + atomic_fcmpset_rel_ptr(&(rw)->rw_lock, (tid), RW_UNLOCKED) + /* * Full lock operations that are suitable to be inlined in non-debug * kernels. If the lock cannot be acquired or released trivially then @@ -109,16 +114,16 @@ \ if (__predict_false(LOCKSTAT_PROFILE_ENABLED(rw__acquire) || \ !_rw_write_lock_fetch((rw), &_v, _tid))) \ - _rw_wlock_hard((rw), _v, _tid, (file), (line)); \ + _rw_wlock_hard((rw), _v, (file), (line)); \ } while (0) /* Release a write lock. */ #define __rw_wunlock(rw, tid, file, line) do { \ - uintptr_t _tid = (uintptr_t)(tid); \ + uintptr_t _v = (uintptr_t)(tid); \ \ if (__predict_false(LOCKSTAT_PROFILE_ENABLED(rw__release) || \ - !_rw_write_unlock((rw), _tid))) \ - _rw_wunlock_hard((rw), _tid, (file), (line)); \ + !_rw_write_unlock_fetch((rw), &_v))) \ + _rw_wunlock_hard((rw), _v, (file), (line)); \ } while (0) #endif /* __rtems__ */ @@ -134,16 +139,22 @@ void rw_sysinit(void *arg); void rw_sysinit_flags(void *arg); int _rw_wowned(const volatile uintptr_t *c); void _rw_wlock_cookie(volatile uintptr_t *c, const char *file, int line); +int __rw_try_wlock_int(struct rwlock *rw LOCK_FILE_LINE_ARG_DEF); int __rw_try_wlock(volatile uintptr_t *c, const char *file, int line); void _rw_wunlock_cookie(volatile uintptr_t *c, const char *file, int line); +void __rw_rlock_int(struct rwlock *rw LOCK_FILE_LINE_ARG_DEF); void __rw_rlock(volatile uintptr_t *c, const char *file, int line); +int __rw_try_rlock_int(struct rwlock *rw LOCK_FILE_LINE_ARG_DEF); int __rw_try_rlock(volatile uintptr_t *c, const char *file, int line); +void _rw_runlock_cookie_int(struct rwlock *rw LOCK_FILE_LINE_ARG_DEF); void _rw_runlock_cookie(volatile uintptr_t *c, const char *file, int line); -void __rw_wlock_hard(volatile uintptr_t *c, uintptr_t v, uintptr_t tid, - const char *file, int line); -void __rw_wunlock_hard(volatile uintptr_t *c, uintptr_t tid, - const char *file, int line); +void __rw_wlock_hard(volatile uintptr_t *c, uintptr_t v + LOCK_FILE_LINE_ARG_DEF); +void __rw_wunlock_hard(volatile uintptr_t *c, uintptr_t v + LOCK_FILE_LINE_ARG_DEF); +int __rw_try_upgrade_int(struct rwlock *rw LOCK_FILE_LINE_ARG_DEF); int __rw_try_upgrade(volatile uintptr_t *c, const char *file, int line); +void __rw_downgrade_int(struct rwlock *rw LOCK_FILE_LINE_ARG_DEF); void __rw_downgrade(volatile uintptr_t *c, const char *file, int line); #if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) void __rw_assert(const volatile uintptr_t *c, int what, const char *file, @@ -190,20 +201,38 @@ void _rw_assert(const struct rwlock *rw, int what, const char *file, __rw_try_wlock(&(rw)->rw_lock, f, l) #define _rw_wunlock(rw, f, l) \ _rw_wunlock_cookie(&(rw)->rw_lock, f, l) -#define _rw_rlock(rw, f, l) \ - __rw_rlock(&(rw)->rw_lock, f, l) #define _rw_try_rlock(rw, f, l) \ __rw_try_rlock(&(rw)->rw_lock, f, l) +#if LOCK_DEBUG > 0 +#define _rw_rlock(rw, f, l) \ + __rw_rlock(&(rw)->rw_lock, f, l) #define _rw_runlock(rw, f, l) \ _rw_runlock_cookie(&(rw)->rw_lock, f, l) -#define _rw_wlock_hard(rw, v, t, f, l) \ - __rw_wlock_hard(&(rw)->rw_lock, v, t, f, l) -#define _rw_wunlock_hard(rw, t, f, l) \ - __rw_wunlock_hard(&(rw)->rw_lock, t, f, l) +#else +#define _rw_rlock(rw, f, l) \ + __rw_rlock_int((struct rwlock *)rw) +#define _rw_runlock(rw, f, l) \ + _rw_runlock_cookie_int((struct rwlock *)rw) +#endif +#if LOCK_DEBUG > 0 +#define _rw_wlock_hard(rw, v, f, l) \ + __rw_wlock_hard(&(rw)->rw_lock, v, f, l) +#define _rw_wunlock_hard(rw, v, f, l) \ + __rw_wunlock_hard(&(rw)->rw_lock, v, f, l) #define _rw_try_upgrade(rw, f, l) \ __rw_try_upgrade(&(rw)->rw_lock, f, l) #define _rw_downgrade(rw, f, l) \ __rw_downgrade(&(rw)->rw_lock, f, l) +#else +#define _rw_wlock_hard(rw, v, f, l) \ + __rw_wlock_hard(&(rw)->rw_lock, v) +#define _rw_wunlock_hard(rw, v, f, l) \ + __rw_wunlock_hard(&(rw)->rw_lock, v) +#define _rw_try_upgrade(rw, f, l) \ + __rw_try_upgrade_int(rw) +#define _rw_downgrade(rw, f, l) \ + __rw_downgrade_int(rw) +#endif #if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) #define _rw_assert(rw, w, f, l) \ __rw_assert(&(rw)->rw_lock, w, f, l) @@ -248,35 +277,21 @@ void _rw_assert(const struct rwlock *rw, int what, const char *file, struct rw_args { void *ra_rw; const char *ra_desc; -}; - -struct rw_args_flags { - void *ra_rw; - const char *ra_desc; int ra_flags; }; -#define RW_SYSINIT(name, rw, desc) \ +#define RW_SYSINIT_FLAGS(name, rw, desc, flags) \ static struct rw_args name##_args = { \ (rw), \ (desc), \ + (flags), \ }; \ SYSINIT(name##_rw_sysinit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \ rw_sysinit, &name##_args); \ SYSUNINIT(name##_rw_sysuninit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \ _rw_destroy, __DEVOLATILE(void *, &(rw)->rw_lock)) - -#define RW_SYSINIT_FLAGS(name, rw, desc, flags) \ - static struct rw_args_flags name##_args = { \ - (rw), \ - (desc), \ - (flags), \ - }; \ - SYSINIT(name##_rw_sysinit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \ - rw_sysinit_flags, &name##_args); \ - SYSUNINIT(name##_rw_sysuninit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \ - _rw_destroy, __DEVOLATILE(void *, &(rw)->rw_lock)) +#define RW_SYSINIT(name, rw, desc) RW_SYSINIT_FLAGS(name, rw, desc, 0) /* * Options passed to rw_init_flags(). diff --git a/freebsd/sys/sys/sbuf.h b/freebsd/sys/sys/sbuf.h index d0f908be..8e958cbe 100644 --- a/freebsd/sys/sys/sbuf.h +++ b/freebsd/sys/sys/sbuf.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2000-2008 Poul-Henning Kamp * Copyright (c) 2000-2008 Dag-Erling Coïdan Smørgrav * All rights reserved. diff --git a/freebsd/sys/sys/sdt.h b/freebsd/sys/sys/sdt.h index c680ea85..424a0e3a 100644 --- a/freebsd/sys/sys/sdt.h +++ b/freebsd/sys/sys/sdt.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright 2006-2008 John Birrell <jb@FreeBSD.org> * * Redistribution and use in source and binary forms, with or without @@ -80,13 +82,14 @@ #include <sys/cdefs.h> #include <sys/linker_set.h> +extern volatile bool sdt_probes_enabled; + #ifndef KDTRACE_HOOKS #define SDT_PROVIDER_DEFINE(prov) #define SDT_PROVIDER_DECLARE(prov) #define SDT_PROBE_DEFINE(prov, mod, func, name) #define SDT_PROBE_DECLARE(prov, mod, func, name) -#define SDT_PROBE_ENABLED(prov, mod, func, name) 0 #define SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4) #define SDT_PROBE_ARGTYPE(prov, mod, func, name, num, type, xtype) @@ -161,14 +164,13 @@ SET_DECLARE(sdt_argtypes_set, struct sdt_argtype); #define SDT_PROBE_DECLARE(prov, mod, func, name) \ extern struct sdt_probe sdt_##prov##_##mod##_##func##_##name[1] -#define SDT_PROBE_ENABLED(prov, mod, func, name) \ - __predict_false((sdt_##prov##_##mod##_##func##_##name->id)) - #define SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4) do { \ - if (__predict_false(sdt_##prov##_##mod##_##func##_##name->id)) \ + if (__predict_false(sdt_probes_enabled)) { \ + if (__predict_false(sdt_##prov##_##mod##_##func##_##name->id)) \ (*sdt_probe_func)(sdt_##prov##_##mod##_##func##_##name->id, \ (uintptr_t) arg0, (uintptr_t) arg1, (uintptr_t) arg2, \ (uintptr_t) arg3, (uintptr_t) arg4); \ + } \ } while (0) #define SDT_PROBE_ARGTYPE(prov, mod, func, name, num, type, xtype) \ diff --git a/freebsd/sys/sys/selinfo.h b/freebsd/sys/sys/selinfo.h index 85de231e..c5f3ad6b 100644 --- a/freebsd/sys/sys/selinfo.h +++ b/freebsd/sys/sys/selinfo.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/sys/serial.h b/freebsd/sys/sys/serial.h index 1a149a96..3293ebda 100644 --- a/freebsd/sys/sys/serial.h +++ b/freebsd/sys/sys/serial.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2004 Poul-Henning Kamp * All rights reserved. * diff --git a/freebsd/sys/sys/sf_buf.h b/freebsd/sys/sys/sf_buf.h index 6aebe430..08f1d9d7 100644 --- a/freebsd/sys/sys/sf_buf.h +++ b/freebsd/sys/sys/sf_buf.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2014 Gleb Smirnoff <glebius@FreeBSD.org> * Copyright (c) 2003-2004 Alan L. Cox <alc@cs.rice.edu> * All rights reserved. diff --git a/freebsd/sys/sys/sigio.h b/freebsd/sys/sys/sigio.h index e941ae96..6730f48a 100644 --- a/freebsd/sys/sys/sigio.h +++ b/freebsd/sys/sys/sigio.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/sys/signalvar.h b/freebsd/sys/sys/signalvar.h index 22f9ef4a..8735e3a0 100644 --- a/freebsd/sys/sys/signalvar.h +++ b/freebsd/sys/sys/signalvar.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/sys/sleepqueue.h b/freebsd/sys/sys/sleepqueue.h index 30a18933..07530e3b 100644 --- a/freebsd/sys/sys/sleepqueue.h +++ b/freebsd/sys/sys/sleepqueue.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2004 John Baldwin <jhb@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/sys/slicer.h b/freebsd/sys/sys/slicer.h index 53f680d8..1565ecce 100644 --- a/freebsd/sys/sys/slicer.h +++ b/freebsd/sys/sys/slicer.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2012 Semihalf. * All rights reserved. * diff --git a/freebsd/sys/sys/smp.h b/freebsd/sys/sys/smp.h index 9253304f..f1950fa2 100644 --- a/freebsd/sys/sys/smp.h +++ b/freebsd/sys/sys/smp.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: Beerware + * * ---------------------------------------------------------------------------- * "THE BEER-WARE LICENSE" (Revision 42): * <phk@FreeBSD.org> wrote this file. As long as you retain this notice you diff --git a/freebsd/sys/sys/sockbuf.h b/freebsd/sys/sys/sockbuf.h index c9cb4dd7..91a30b6f 100644 --- a/freebsd/sys/sys/sockbuf.h +++ b/freebsd/sys/sys/sockbuf.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1990, 1993 * The Regents of the University of California. All rights reserved. * @@ -32,15 +34,9 @@ */ #ifndef _SYS_SOCKBUF_H_ #define _SYS_SOCKBUF_H_ -#include <sys/_lock.h> -#include <sys/_mutex.h> -#include <sys/_sx.h> -#include <sys/_task.h> - -#define SB_MAX (2*1024*1024) /* default for max chars in sockbuf */ /* - * Constants for sb_flags field of struct sockbuf. + * Constants for sb_flags field of struct sockbuf/xsockbuf. */ #define SB_WAIT 0x04 /* someone is waiting for data/space */ #define SB_SEL 0x08 /* someone is selecting */ @@ -59,24 +55,20 @@ #define SBS_CANTRCVMORE 0x0020 /* can't receive more data from peer */ #define SBS_RCVATMARK 0x0040 /* at mark on input */ +#if defined(_KERNEL) || defined(_WANT_SOCKET) +#include <sys/_lock.h> +#include <sys/_mutex.h> +#include <sys/_sx.h> +#include <sys/_task.h> + +#define SB_MAX (2*1024*1024) /* default for max chars in sockbuf */ + struct mbuf; struct sockaddr; struct socket; struct thread; struct selinfo; -struct xsockbuf { - u_int sb_cc; - u_int sb_hiwat; - u_int sb_mbcnt; - u_int sb_mcnt; - u_int sb_ccnt; - u_int sb_mbmax; - int sb_lowat; - int sb_timeo; - short sb_flags; -}; - /* * Variables for socket buffering. * @@ -115,6 +107,7 @@ struct sockbuf { #endif /* __rtems__ */ }; +#endif /* defined(_KERNEL) || defined(_WANT_SOCKET) */ #ifdef _KERNEL /* @@ -176,7 +169,6 @@ struct mbuf * sbsndptr(struct sockbuf *sb, u_int off, u_int len, u_int *moff); struct mbuf * sbsndmbuf(struct sockbuf *sb, u_int off, u_int *moff); -void sbtoxsockbuf(struct sockbuf *sb, struct xsockbuf *xsb); int sbwait(struct sockbuf *sb); int sblock(struct sockbuf *sb, int flags); void sbunlock(struct sockbuf *sb); diff --git a/freebsd/sys/sys/socketvar.h b/freebsd/sys/sys/socketvar.h index 0c5b95ec..d58ac2ea 100644 --- a/freebsd/sys/sys/socketvar.h +++ b/freebsd/sys/sys/socketvar.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1990, 1993 * The Regents of the University of California. All rights reserved. * @@ -34,6 +36,12 @@ #ifndef _SYS_SOCKETVAR_H_ #define _SYS_SOCKETVAR_H_ +/* + * Socket generation count type. Also used in xinpcb, xtcpcb, xunpcb. + */ +typedef uint64_t so_gen_t; + +#if defined(_KERNEL) || defined(_WANT_SOCKET) #include <sys/queue.h> /* for TAILQ macros */ #include <sys/selinfo.h> /* for struct selinfo */ #include <sys/_lock.h> @@ -41,7 +49,6 @@ #include <sys/osd.h> #include <sys/_sx.h> #include <sys/sockbuf.h> -#include <sys/sockstate.h> #ifdef _KERNEL #include <sys/caprights.h> #include <sys/sockopt.h> @@ -55,7 +62,6 @@ struct vnet; * handle on protocol and pointer to protocol * private data and error information. */ -typedef uint64_t so_gen_t; typedef int so_upcall_t(struct socket *, void *, int); struct socket; @@ -167,6 +173,39 @@ struct socket { }; }; }; +#endif /* defined(_KERNEL) || defined(_WANT_SOCKET) */ + +/* + * Socket state bits. + * + * Historically, this bits were all kept in the so_state field. For + * locking reasons, they are now in multiple fields, as they are + * locked differently. so_state maintains basic socket state protected + * by the socket lock. so_qstate holds information about the socket + * accept queues. Each socket buffer also has a state field holding + * information relevant to that socket buffer (can't send, rcv). Many + * fields will be read without locks to improve performance and avoid + * lock order issues. However, this approach must be used with caution. + */ +#define SS_NOFDREF 0x0001 /* no file table ref any more */ +#define SS_ISCONNECTED 0x0002 /* socket connected to a peer */ +#define SS_ISCONNECTING 0x0004 /* in process of connecting to peer */ +#define SS_ISDISCONNECTING 0x0008 /* in process of disconnecting */ +#define SS_NBIO 0x0100 /* non-blocking ops */ +#define SS_ASYNC 0x0200 /* async i/o notify */ +#define SS_ISCONFIRMING 0x0400 /* deciding to accept connection req */ +#define SS_ISDISCONNECTED 0x2000 /* socket disconnected from peer */ + +/* + * Protocols can mark a socket as SS_PROTOREF to indicate that, following + * pru_detach, they still want the socket to persist, and will free it + * themselves when they are done. Protocols should only ever call sofree() + * following setting this flag in pru_detach(), and never otherwise, as + * sofree() bypasses socket reference counting. + */ +#define SS_PROTOREF 0x4000 /* strong protocol reference */ + +#ifdef _KERNEL #define SOCK_MTX(so) &(so)->so_lock #define SOCK_LOCK(so) mtx_lock(&(so)->so_lock) @@ -194,32 +233,6 @@ struct socket { } while (0) /* - * Externalized form of struct socket used by the sysctl(3) interface. - */ -struct xsocket { - size_t xso_len; /* length of this structure */ - struct socket *xso_so; /* makes a convenient handle sometimes */ - short so_type; - short so_options; - short so_linger; - short so_state; - caddr_t so_pcb; /* another convenient handle */ - int xso_protocol; - int xso_family; - u_int so_qlen; - u_int so_incqlen; - u_int so_qlimit; - short so_timeo; - u_short so_error; - pid_t so_pgid; - u_long so_oobmark; - struct xsockbuf so_rcv, so_snd; - uid_t so_uid; /* XXX */ -}; - -#ifdef _KERNEL - -/* * Macros for sockets and socket buffering. */ @@ -424,7 +437,6 @@ int sosend_generic(struct socket *so, struct sockaddr *addr, struct uio *uio, struct mbuf *top, struct mbuf *control, int flags, struct thread *td); int soshutdown(struct socket *so, int how); -void sotoxsocket(struct socket *so, struct xsocket *xso); void soupcall_clear(struct socket *, int); void soupcall_set(struct socket *, int, so_upcall_t, void *); void solisten_upcall_set(struct socket *, so_upcall_t, void *); @@ -437,6 +449,14 @@ void sowakeup_aio(struct socket *so, struct sockbuf *sb); void solisten_wakeup(struct socket *); int selsocket(struct socket *so, int events, struct timeval *tv, struct thread *td); +void soisconnected(struct socket *so); +void soisconnecting(struct socket *so); +void soisdisconnected(struct socket *so); +void soisdisconnecting(struct socket *so); +void socantrcvmore(struct socket *so); +void socantrcvmore_locked(struct socket *so); +void socantsendmore(struct socket *so); +void socantsendmore_locked(struct socket *so); /* * Accept filter functions (duh). @@ -453,4 +473,58 @@ int accept_filt_generic_mod_event(module_t mod, int event, void *data); #endif /* _KERNEL */ +/* + * Structure to export socket from kernel to utilities, via sysctl(3). + */ +struct xsocket { + size_t xso_len; /* length of this structure */ + union { + void *xso_so; /* kernel address of struct socket */ + int64_t ph_so; + }; + union { + void *so_pcb; /* kernel address of struct inpcb */ + int64_t ph_pcb; + }; + uint64_t so_oobmark; + int64_t so_spare64[8]; + int32_t xso_protocol; + int32_t xso_family; + uint32_t so_qlen; + uint32_t so_incqlen; + uint32_t so_qlimit; + pid_t so_pgid; + uid_t so_uid; + int32_t so_spare32[8]; + int16_t so_type; + int16_t so_options; + int16_t so_linger; + int16_t so_state; + int16_t so_timeo; + uint16_t so_error; + struct xsockbuf { + uint32_t sb_cc; + uint32_t sb_hiwat; + uint32_t sb_mbcnt; + uint32_t sb_mcnt; + uint32_t sb_ccnt; + uint32_t sb_mbmax; + int32_t sb_lowat; + int32_t sb_timeo; + int16_t sb_flags; + } so_rcv, so_snd; +}; + +#ifdef _KERNEL +void sotoxsocket(struct socket *so, struct xsocket *xso); +void sbtoxsockbuf(struct sockbuf *sb, struct xsockbuf *xsb); +#endif + +/* + * Socket buffer state bits. Exported via libprocstat(3). + */ +#define SBS_CANTSENDMORE 0x0010 /* can't send more data to peer */ +#define SBS_CANTRCVMORE 0x0020 /* can't receive more data from peer */ +#define SBS_RCVATMARK 0x0040 /* at mark on input */ + #endif /* !_SYS_SOCKETVAR_H_ */ diff --git a/freebsd/sys/sys/sockopt.h b/freebsd/sys/sys/sockopt.h index 029e5b4a..7f19ecf8 100644 --- a/freebsd/sys/sys/sockopt.h +++ b/freebsd/sys/sys/sockopt.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1990, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/sys/stddef.h b/freebsd/sys/sys/stddef.h index 9b6ac537..76aabd86 100644 --- a/freebsd/sys/sys/stddef.h +++ b/freebsd/sys/sys/stddef.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2002 Maxime Henrion <mux@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/sys/stdint.h b/freebsd/sys/sys/stdint.h index 4c41ec14..98915f72 100644 --- a/freebsd/sys/sys/stdint.h +++ b/freebsd/sys/sys/stdint.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/sys/sx.h b/freebsd/sys/sys/sx.h index 0c95df16..33143057 100644 --- a/freebsd/sys/sys/sx.h +++ b/freebsd/sys/sys/sx.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007 Attilio Rao <attilio@freebsd.org> * Copyright (c) 2001 Jason Evans <jasone@freebsd.org> * All rights reserved. @@ -43,10 +45,10 @@ #endif #ifdef __rtems__ -#define SX_NOINLINE 1 -#define _sx_slock _bsd__sx_xlock -#define sx_try_slock_ _bsd_sx_try_xlock_ -#define _sx_sunlock _bsd__sx_xunlock +#define SX_NOINLINE 1 +#define sx_try_xlock_ _bsd_sx_try_slock_int +#define sx_try_xlock_int _bsd_sx_try_slock_int +#define _sx_sunlock _bsd__sx_sunlock_int #endif /* __rtems__ */ /* * In general, the sx locks and rwlocks use very similar algorithms. @@ -107,18 +109,45 @@ void sx_sysinit(void *arg); #define sx_init(sx, desc) sx_init_flags((sx), (desc), 0) void sx_init_flags(struct sx *sx, const char *description, int opts); void sx_destroy(struct sx *sx); +int sx_try_slock_int(struct sx *sx LOCK_FILE_LINE_ARG_DEF); +#ifndef __rtems__ int sx_try_slock_(struct sx *sx, const char *file, int line); +int sx_try_xlock_int(struct sx *sx LOCK_FILE_LINE_ARG_DEF); int sx_try_xlock_(struct sx *sx, const char *file, int line); +#endif /* __rtems__ */ +int sx_try_upgrade_int(struct sx *sx LOCK_FILE_LINE_ARG_DEF); +#ifndef __rtems__ int sx_try_upgrade_(struct sx *sx, const char *file, int line); +#endif /* __rtems__ */ +void sx_downgrade_int(struct sx *sx LOCK_FILE_LINE_ARG_DEF); +#ifndef __rtems__ void sx_downgrade_(struct sx *sx, const char *file, int line); +#endif /* __rtems__ */ +int _sx_slock_int(struct sx *sx, int opts LOCK_FILE_LINE_ARG_DEF); +#ifndef __rtems__ int _sx_slock(struct sx *sx, int opts, const char *file, int line); int _sx_xlock(struct sx *sx, int opts, const char *file, int line); +#else /* __rtems__ */ +#if (LOCK_DEBUG > 0) +#define _sx_xlock(sx, opts, file, line) \ + _bsd__sx_slock_int(sx, opts, file, line) +#else +#define _sx_xlock(sx, opts, file, line) _bsd__sx_slock_int(sx, opts) +#endif +#endif /* __rtems__ */ +void _sx_sunlock_int(struct sx *sx LOCK_FILE_LINE_ARG_DEF); +#ifndef __rtems__ void _sx_sunlock(struct sx *sx, const char *file, int line); void _sx_xunlock(struct sx *sx, const char *file, int line); -int _sx_xlock_hard(struct sx *sx, uintptr_t v, uintptr_t tid, int opts, - const char *file, int line); -void _sx_xunlock_hard(struct sx *sx, uintptr_t tid, const char *file, int - line); +int _sx_xlock_hard(struct sx *sx, uintptr_t x, int opts LOCK_FILE_LINE_ARG_DEF); +void _sx_xunlock_hard(struct sx *sx, uintptr_t x LOCK_FILE_LINE_ARG_DEF); +#else /* __rtems__ */ +#if (LOCK_DEBUG > 0) +#define _sx_xunlock(sx, file, line) _bsd__sx_sunlock_int(sx, file, line) +#else +#define _sx_xunlock(sx, file, line) _bsd__sx_sunlock_int(sx) +#endif +#endif /* __rtems__ */ #if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) void _sx_assert(const struct sx *sx, int what, const char *file, int line); #endif @@ -164,7 +193,7 @@ __sx_xlock(struct sx *sx, struct thread *td, int opts, const char *file, if (__predict_false(LOCKSTAT_PROFILE_ENABLED(sx__acquire) || !atomic_fcmpset_acq_ptr(&sx->sx_lock, &v, tid))) - error = _sx_xlock_hard(sx, v, tid, opts, file, line); + error = _sx_xlock_hard(sx, v, opts); return (error); } @@ -173,11 +202,11 @@ __sx_xlock(struct sx *sx, struct thread *td, int opts, const char *file, static __inline void __sx_xunlock(struct sx *sx, struct thread *td, const char *file, int line) { - uintptr_t tid = (uintptr_t)td; + uintptr_t x = (uintptr_t)td; if (__predict_false(LOCKSTAT_PROFILE_ENABLED(sx__release) || - !atomic_cmpset_rel_ptr(&sx->sx_lock, tid, SX_LOCK_UNLOCKED))) - _sx_xunlock_hard(sx, tid, file, line); + !atomic_fcmpset_rel_ptr(&sx->sx_lock, &x, SX_LOCK_UNLOCKED))) + _sx_xunlock_hard(sx, x); } #endif #endif /* __rtems__ */ @@ -203,6 +232,7 @@ __sx_xunlock(struct sx *sx, struct thread *td, const char *file, int line) #define sx_xunlock_(sx, file, line) \ __sx_xunlock((sx), curthread, (file), (line)) #endif /* LOCK_DEBUG > 0 || SX_NOINLINE */ +#if (LOCK_DEBUG > 0) #define sx_slock_(sx, file, line) \ (void)_sx_slock((sx), 0, (file), (line)) #define sx_slock_sig_(sx, file, line) \ @@ -213,6 +243,18 @@ __sx_xunlock(struct sx *sx, struct thread *td, const char *file, int line) #define sx_try_xlock(sx) sx_try_xlock_((sx), LOCK_FILE, LOCK_LINE) #define sx_try_upgrade(sx) sx_try_upgrade_((sx), LOCK_FILE, LOCK_LINE) #define sx_downgrade(sx) sx_downgrade_((sx), LOCK_FILE, LOCK_LINE) +#else +#define sx_slock_(sx, file, line) \ + (void)_sx_slock_int((sx), 0) +#define sx_slock_sig_(sx, file, line) \ + _sx_slock_int((sx), SX_INTERRUPTIBLE) +#define sx_sunlock_(sx, file, line) \ + _sx_sunlock_int((sx)) +#define sx_try_slock(sx) sx_try_slock_int((sx)) +#define sx_try_xlock(sx) sx_try_xlock_int((sx)) +#define sx_try_upgrade(sx) sx_try_upgrade_int((sx)) +#define sx_downgrade(sx) sx_downgrade_int((sx)) +#endif #ifdef INVARIANTS #define sx_assert_(sx, what, file, line) \ _sx_assert((sx), (what), (file), (line)) @@ -240,9 +282,6 @@ __sx_xunlock(struct sx *sx, struct thread *td, const char *file, int line) #define sx_xlocked(sx) \ (((sx)->sx_lock & ~(SX_LOCK_FLAGMASK & ~SX_LOCK_SHARED)) == \ (uintptr_t)curthread) -#else /* __rtems__ */ -int sx_xlocked(struct sx *sx); -#endif /* __rtems__ */ #define sx_unlock_(sx, file, line) do { \ if (sx_xlocked(sx)) \ @@ -252,6 +291,14 @@ int sx_xlocked(struct sx *sx); } while (0) #define sx_unlock(sx) sx_unlock_((sx), LOCK_FILE, LOCK_LINE) +#else /* __rtems__ */ +int sx_xlocked(struct sx *sx); +#if (LOCK_DEBUG > 0) +#define sx_unlock(sx) _sx_sunlock_int((sx), LOCK_FILE, LOCK_LINE) +#else +#define sx_unlock(sx) _sx_sunlock_int((sx)) +#endif +#endif /* __rtems__ */ #define sx_sleep(chan, sx, pri, wmesg, timo) \ _sleep((chan), &(sx)->lock_object, (pri), (wmesg), \ diff --git a/freebsd/sys/sys/sysctl.h b/freebsd/sys/sys/sysctl.h index 71da475b..874d226f 100644 --- a/freebsd/sys/sys/sysctl.h +++ b/freebsd/sys/sys/sysctl.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * @@ -83,6 +85,7 @@ struct ctlname { #define CTLFLAG_RD 0x80000000 /* Allow reads of variable */ #define CTLFLAG_WR 0x40000000 /* Allow writes to the variable */ #define CTLFLAG_RW (CTLFLAG_RD|CTLFLAG_WR) +#define CTLFLAG_DORMANT 0x20000000 /* This sysctl is not active yet */ #define CTLFLAG_ANYBODY 0x10000000 /* All users can set this var */ #define CTLFLAG_SECURE 0x08000000 /* Permit set only if securelevel<=0 */ #define CTLFLAG_PRISON 0x04000000 /* Prisoned roots can fiddle */ @@ -144,7 +147,7 @@ struct ctlname { #define REQ_WIRED 2 /* definitions for sysctl_req 'flags' member */ -#if defined(__amd64__) || defined(__powerpc64__) ||\ +#if defined(__aarch64__) || defined(__amd64__) || defined(__powerpc64__) ||\ (defined(__mips__) && defined(__mips_n64)) #define SCTL_MASK32 1 /* 32 bit emulation */ #endif @@ -223,6 +226,8 @@ int sysctl_dpcpu_quad(SYSCTL_HANDLER_ARGS); * These functions are used to add/remove an oid from the mib. */ void sysctl_register_oid(struct sysctl_oid *oidp); +void sysctl_register_disabled_oid(struct sysctl_oid *oidp); +void sysctl_enable_oid(struct sysctl_oid *oidp); void sysctl_unregister_oid(struct sysctl_oid *oidp); /* Declare a static oid to allow child oids to be added to it. */ diff --git a/freebsd/sys/sys/syslog.h b/freebsd/sys/sys/syslog.h index f31cfb97..071b6842 100644 --- a/freebsd/sys/sys/syslog.h +++ b/freebsd/sys/sys/syslog.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1988, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/sys/systm.h b/freebsd/sys/sys/systm.h index 92be461b..e89719b8 100644 --- a/freebsd/sys/sys/systm.h +++ b/freebsd/sys/sys/systm.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1988, 1991, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. @@ -38,10 +40,10 @@ #ifndef _SYS_SYSTM_H_ #define _SYS_SYSTM_H_ +#include <sys/cdefs.h> #include <machine/atomic.h> #include <machine/cpufunc.h> #include <sys/callout.h> -#include <sys/cdefs.h> #include <sys/queue.h> #include <sys/stdint.h> /* for people using printf mainly */ #ifdef __rtems__ @@ -596,6 +598,7 @@ struct unrhdr; struct unrhdr *new_unrhdr(int low, int high, struct mtx *mutex); void init_unrhdr(struct unrhdr *uh, int low, int high, struct mtx *mutex); void delete_unrhdr(struct unrhdr *uh); +void clear_unrhdr(struct unrhdr *uh); void clean_unrhdr(struct unrhdr *uh); void clean_unrhdrl(struct unrhdr *uh); int alloc_unr(struct unrhdr *uh); diff --git a/freebsd/sys/sys/taskqueue.h b/freebsd/sys/sys/taskqueue.h index b5091d32..7ba9e268 100644 --- a/freebsd/sys/sys/taskqueue.h +++ b/freebsd/sys/sys/taskqueue.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2000 Doug Rabson * All rights reserved. * diff --git a/freebsd/sys/sys/timeet.h b/freebsd/sys/sys/timeet.h index 3d50e51d..dc43337d 100644 --- a/freebsd/sys/sys/timeet.h +++ b/freebsd/sys/sys/timeet.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2010-2013 Alexander Motin <mav@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/sys/tree.h b/freebsd/sys/sys/tree.h index c9df686f..539afb42 100644 --- a/freebsd/sys/sys/tree.h +++ b/freebsd/sys/sys/tree.h @@ -3,6 +3,8 @@ /* $FreeBSD$ */ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright 2002 Niels Provos <provos@citi.umich.edu> * All rights reserved. * diff --git a/freebsd/sys/sys/tty.h b/freebsd/sys/sys/tty.h index c37d0bf3..92ad89a6 100644 --- a/freebsd/sys/sys/tty.h +++ b/freebsd/sys/sys/tty.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/sys/ttydevsw.h b/freebsd/sys/sys/ttydevsw.h index 98bebca7..b189335c 100644 --- a/freebsd/sys/sys/ttydevsw.h +++ b/freebsd/sys/sys/ttydevsw.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/sys/ttydisc.h b/freebsd/sys/sys/ttydisc.h index 74a1a0ed..2ab0c05c 100644 --- a/freebsd/sys/sys/ttydisc.h +++ b/freebsd/sys/sys/ttydisc.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/sys/ttyhook.h b/freebsd/sys/sys/ttyhook.h index 2a6d0887..0697a488 100644 --- a/freebsd/sys/sys/ttyhook.h +++ b/freebsd/sys/sys/ttyhook.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/sys/ttyqueue.h b/freebsd/sys/sys/ttyqueue.h index c8d85d62..c1ddaa42 100644 --- a/freebsd/sys/sys/ttyqueue.h +++ b/freebsd/sys/sys/ttyqueue.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org> * All rights reserved. * diff --git a/freebsd/sys/sys/ucred.h b/freebsd/sys/sys/ucred.h index bf5d99d8..37a93357 100644 --- a/freebsd/sys/sys/ucred.h +++ b/freebsd/sys/sys/ucred.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/sys/un.h b/freebsd/sys/sys/un.h index 27d6a499..f83652e0 100644 --- a/freebsd/sys/sys/un.h +++ b/freebsd/sys/sys/un.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/sys/unpcb.h b/freebsd/sys/sys/unpcb.h index 76bc63a9..1ab3457d 100644 --- a/freebsd/sys/sys/unpcb.h +++ b/freebsd/sys/sys/unpcb.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1989, 1993 * The Regents of the University of California. All rights reserved. * @@ -33,6 +35,9 @@ #ifndef _SYS_UNPCB_H_ #define _SYS_UNPCB_H_ +typedef uint64_t unp_gen_t; + +#if defined(_KERNEL) || defined(_WANT_UNPCB) #include <sys/queue.h> #include <sys/ucred.h> @@ -61,7 +66,6 @@ * so that changes in the sockbuf may be computed to modify * back pressure on the sender accordingly. */ -typedef u_quad_t unp_gen_t; LIST_HEAD(unp_head, unpcb); struct unpcb { @@ -78,8 +82,6 @@ struct unpcb { struct unp_head unp_refs; /* referencing socket linked list */ LIST_ENTRY(unpcb) unp_reflink; /* link in unp_refs list */ struct sockaddr_un *unp_addr; /* bound address of socket */ - int reserved1; - int reserved2; unp_gen_t unp_gencnt; /* generation count of this instance */ short unp_flags; /* flags */ short unp_gcflag; /* Garbage collector flags. */ @@ -120,32 +122,50 @@ struct unpcb { #define sotounpcb(so) ((struct unpcb *)((so)->so_pcb)) -/* Hack alert -- this structure depends on <sys/socketvar.h>. */ +#endif /* _KERNEL || _WANT_UNPCB */ + +/* + * UNPCB structure exported to user-land via sysctl(3). + * + * Fields prefixed with "xu_" are unique to the export structure, and fields + * with "unp_" or other prefixes match corresponding fields of 'struct unpcb'. + * + * Legend: + * (s) - used by userland utilities in src + * (p) - used by utilities in ports + * (3) - is known to be used by third party software not in ports + * (n) - no known usage + * + * Evil hack: declare only if sys/socketvar.h have been included. + */ #ifdef _SYS_SOCKETVAR_H_ struct xunpcb { - size_t xu_len; /* length of this structure */ - struct unpcb *xu_unpp; /* to help netstat, fstat */ - struct unpcb xu_unp; /* our information */ + size_t xu_len; /* length of this structure */ + void *xu_unpp; /* to help netstat, fstat */ + void *unp_vnode; /* (s) */ + void *unp_conn; /* (s) */ + void *xu_firstref; /* (s) */ + void *xu_nextref; /* (s) */ + unp_gen_t unp_gencnt; /* (s) */ + int64_t xu_spare64[8]; + int32_t xu_spare32[8]; union { - struct sockaddr_un xuu_addr; /* our bound address */ + struct sockaddr_un xu_addr; /* our bound address */ char xu_dummy1[256]; - } xu_au; -#define xu_addr xu_au.xuu_addr + }; union { - struct sockaddr_un xuu_caddr; /* their bound address */ + struct sockaddr_un xu_caddr; /* their bound address */ char xu_dummy2[256]; - } xu_cau; -#define xu_caddr xu_cau.xuu_caddr - struct xsocket xu_socket; - u_quad_t xu_alignment_hack; -}; + }; + struct xsocket xu_socket; +} __aligned(8); struct xunpgen { size_t xug_len; u_int xug_count; unp_gen_t xug_gen; so_gen_t xug_sogen; -}; +} __aligned(8);; #endif /* _SYS_SOCKETVAR_H_ */ #endif /* _SYS_UNPCB_H_ */ diff --git a/freebsd/sys/sys/user.h b/freebsd/sys/sys/user.h index 9fdb9dd6..f6aa2b3f 100644 --- a/freebsd/sys/sys/user.h +++ b/freebsd/sys/sys/user.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1989, 1991, 1993 * The Regents of the University of California. * Copyright (c) 2007 Robert N. M. Watson diff --git a/freebsd/sys/sys/uuid.h b/freebsd/sys/sys/uuid.h index 97971fd7..e60af218 100644 --- a/freebsd/sys/sys/uuid.h +++ b/freebsd/sys/sys/uuid.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2002 Marcel Moolenaar * All rights reserved. * diff --git a/freebsd/sys/sys/vmmeter.h b/freebsd/sys/sys/vmmeter.h index bc536f71..33d96b26 100644 --- a/freebsd/sys/sys/vmmeter.h +++ b/freebsd/sys/sys/vmmeter.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. * @@ -41,20 +43,23 @@ /* Systemwide totals computed every five seconds. */ struct vmtotal { - int16_t t_rq; /* length of the run queue */ - int16_t t_dw; /* jobs in ``disk wait'' (neg priority) */ - int16_t t_pw; /* jobs in page wait */ - int16_t t_sl; /* jobs sleeping in core */ - int16_t t_sw; /* swapped out runnable/short block jobs */ - int32_t t_vm; /* total virtual memory */ - int32_t t_avm; /* active virtual memory */ - int32_t t_rm; /* total real memory in use */ - int32_t t_arm; /* active real memory */ - int32_t t_vmshr; /* shared virtual memory */ - int32_t t_avmshr; /* active shared virtual memory */ - int32_t t_rmshr; /* shared real memory */ - int32_t t_armshr; /* active shared real memory */ - int32_t t_free; /* free memory pages */ + uint64_t t_vm; /* total virtual memory */ + uint64_t t_avm; /* active virtual memory */ + uint64_t t_rm; /* total real memory in use */ + uint64_t t_arm; /* active real memory */ + uint64_t t_vmshr; /* shared virtual memory */ + uint64_t t_avmshr; /* active shared virtual memory */ + uint64_t t_rmshr; /* shared real memory */ + uint64_t t_armshr; /* active shared real memory */ + uint64_t t_free; /* free memory pages */ + int16_t t_rq; /* length of the run queue */ + int16_t t_dw; /* jobs in ``disk wait'' (neg + priority) */ + int16_t t_pw; /* jobs in page wait */ + int16_t t_sl; /* jobs sleeping in core */ + int16_t t_sw; /* swapped out runnable/short + block jobs */ + uint16_t t_pad[3]; }; #if defined(_KERNEL) || defined(_WANT_VMMETER) @@ -131,7 +136,6 @@ struct vmmeter { u_int v_free_reserved; /* (c) pages reserved for deadlock */ u_int v_free_target; /* (c) pages desired free */ u_int v_free_min; /* (c) pages desired free */ - u_int v_free_count; /* (f) pages free */ u_int v_inactive_target; /* (c) pages desired inactive */ u_int v_pageout_free_min; /* (c) min pages reserved for kernel */ u_int v_interrupt_free_min; /* (c) reserved pages for int code */ @@ -141,6 +145,7 @@ struct vmmeter { u_int v_inactive_count VMMETER_ALIGNED; /* (a) pages inactive */ u_int v_laundry_count VMMETER_ALIGNED; /* (a) pages eligible for laundering */ + u_int v_free_count VMMETER_ALIGNED; /* (f) pages free */ }; #endif /* _KERNEL || _WANT_VMMETER */ @@ -208,10 +213,10 @@ vm_paging_target(void) * Returns TRUE if the pagedaemon needs to be woken up. */ static inline int -vm_paging_needed(void) +vm_paging_needed(u_int free_count) { - return (vm_cnt.v_free_count < vm_pageout_wakeup_thresh); + return (free_count < vm_pageout_wakeup_thresh); } /* diff --git a/freebsd/sys/sys/vnode.h b/freebsd/sys/sys/vnode.h index 0c533063..ac6f4f4e 100644 --- a/freebsd/sys/sys/vnode.h +++ b/freebsd/sys/sys/vnode.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/sys/watchdog.h b/freebsd/sys/sys/watchdog.h index 92c47dee..1b85ce7a 100644 --- a/freebsd/sys/sys/watchdog.h +++ b/freebsd/sys/sys/watchdog.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2003 Poul-Henning Kamp * Copyright (c) 2013 iXsystems.com, * author: Alfred Perlstein <alfred@freebsd.org> diff --git a/freebsd/sys/v850/include/machine/in_cksum.h b/freebsd/sys/v850/include/machine/in_cksum.h index 72edfba9..d55b838b 100644 --- a/freebsd/sys/v850/include/machine/in_cksum.h +++ b/freebsd/sys/v850/include/machine/in_cksum.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * diff --git a/freebsd/sys/vm/uma.h b/freebsd/sys/vm/uma.h index 3781fc8a..6fbe6588 100644 --- a/freebsd/sys/vm/uma.h +++ b/freebsd/sys/vm/uma.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2002, 2003, 2004, 2005 Jeffrey Roberson <jeff@FreeBSD.org> * Copyright (c) 2004, 2005 Bosko Milekic <bmilekic@FreeBSD.org> * All rights reserved. @@ -366,6 +368,11 @@ uma_zfree(uma_zone_t zone, void *item) } /* + * Wait until the specified zone can allocate an item. + */ +void uma_zwait(uma_zone_t zone); + +/* * XXX The rest of the prototypes in this header are h0h0 magic for the VM. * If you think you need to use it for a normal zone you're probably incorrect. */ @@ -603,14 +610,13 @@ void uma_zone_set_freef(uma_zone_t zone, uma_free freef); */ #ifndef __rtems__ #define UMA_SLAB_BOOT 0x01 /* Slab alloced from boot pages */ -#define UMA_SLAB_KMEM 0x02 /* Slab alloced from kmem_map */ #endif /* __rtems__ */ #define UMA_SLAB_KERNEL 0x04 /* Slab alloced from kernel_map */ #ifndef __rtems__ #define UMA_SLAB_PRIV 0x08 /* Slab alloced from priv allocator */ #define UMA_SLAB_OFFP 0x10 /* Slab is managed separately */ #define UMA_SLAB_MALLOC 0x20 /* Slab is a large malloc slab */ -/* 0x40 and 0x80 are available */ +/* 0x02, 0x40 and 0x80 are available */ #endif /* __rtems__ */ /* diff --git a/freebsd/sys/vm/uma_core.c b/freebsd/sys/vm/uma_core.c index c40e682d..3d4abec0 100644 --- a/freebsd/sys/vm/uma_core.c +++ b/freebsd/sys/vm/uma_core.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2002-2005, 2009, 2013 Jeffrey Roberson <jeff@FreeBSD.org> * Copyright (c) 2004, 2005 Bosko Milekic <bmilekic@FreeBSD.org> * Copyright (c) 2004-2006 Robert N. M. Watson @@ -91,6 +93,8 @@ __FBSDID("$FreeBSD$"); #include <ddb/ddb.h> #ifdef __rtems__ + #include <rtems/bsd/bsd.h> + #ifdef RTEMS_SMP #include <rtems/score/smp.h> @@ -168,6 +172,10 @@ static struct mtx uma_boot_pages_mtx; static struct sx uma_drain_lock; +/* kmem soft limit. */ +static unsigned long uma_kmem_limit; +static volatile unsigned long uma_kmem_total; + #ifndef __rtems__ /* Is the VM done starting up? */ static int booted = 0; @@ -320,6 +328,22 @@ static int zone_warnings = 1; SYSCTL_INT(_vm, OID_AUTO, zone_warnings, CTLFLAG_RWTUN, &zone_warnings, 0, "Warn when UMA zones becomes full"); +/* Adjust bytes under management by UMA. */ +static inline void +uma_total_dec(unsigned long size) +{ + + atomic_subtract_long(&uma_kmem_total, size); +} + +static inline void +uma_total_inc(unsigned long size) +{ + + if (atomic_fetchadd_long(&uma_kmem_total, size) > uma_kmem_limit) + uma_reclaim_wakeup(); +} + /* * This routine checks to see whether or not it's safe to enable buckets. */ @@ -872,6 +896,7 @@ keg_free_slab(uma_keg_t keg, uma_slab_t slab, int start) if (keg->uk_flags & UMA_ZONE_OFFPAGE) zone_free_item(keg->uk_slabzone, slab, NULL, SKIP_NONE); keg->uk_freef(mem, PAGE_SIZE * keg->uk_ppera, flags); + uma_total_dec(PAGE_SIZE * keg->uk_ppera); } /* @@ -978,6 +1003,7 @@ keg_alloc_slab(uma_keg_t keg, uma_zone_t zone, int wait) { uma_alloc allocf; uma_slab_t slab; + unsigned long size; uint8_t *mem; uint8_t flags; int i; @@ -988,6 +1014,7 @@ keg_alloc_slab(uma_keg_t keg, uma_zone_t zone, int wait) allocf = keg->uk_allocf; KEG_UNLOCK(keg); + size = keg->uk_ppera * PAGE_SIZE; if (keg->uk_flags & UMA_ZONE_OFFPAGE) { slab = zone_alloc_item(keg->uk_slabzone, NULL, wait); @@ -1011,13 +1038,14 @@ keg_alloc_slab(uma_keg_t keg, uma_zone_t zone, int wait) wait |= M_NODUMP; /* zone is passed for legacy reasons. */ - mem = allocf(zone, keg->uk_ppera * PAGE_SIZE, &flags, wait); + mem = allocf(zone, size, &flags, wait); if (mem == NULL) { if (keg->uk_flags & UMA_ZONE_OFFPAGE) zone_free_item(keg->uk_slabzone, slab, NULL, SKIP_NONE); slab = NULL; goto out; } + uma_total_inc(size); /* Point the slab into the allocated memory */ if (!(keg->uk_flags & UMA_ZONE_OFFPAGE)) @@ -1125,8 +1153,8 @@ page_alloc(uma_zone_t zone, vm_size_t bytes, uint8_t *pflag, int wait) void *p; /* Returned page */ #ifndef __rtems__ - *pflag = UMA_SLAB_KMEM; - p = (void *) kmem_malloc(kmem_arena, bytes, wait); + *pflag = UMA_SLAB_KERNEL; + p = (void *) kmem_malloc(kernel_arena, bytes, wait); #else /* __rtems__ */ *pflag = 0; p = rtems_bsd_page_alloc(bytes, wait); @@ -1162,7 +1190,9 @@ noobj_alloc(uma_zone_t zone, vm_size_t bytes, uint8_t *flags, int wait) npages = howmany(bytes, PAGE_SIZE); while (npages > 0) { p = vm_page_alloc(NULL, 0, VM_ALLOC_INTERRUPT | - VM_ALLOC_WIRED | VM_ALLOC_NOOBJ); + VM_ALLOC_WIRED | VM_ALLOC_NOOBJ | + ((wait & M_WAITOK) != 0 ? VM_ALLOC_WAITOK : + VM_ALLOC_NOWAIT)); if (p != NULL) { /* * Since the page does not belong to an object, its @@ -1172,11 +1202,6 @@ noobj_alloc(uma_zone_t zone, vm_size_t bytes, uint8_t *flags, int wait) npages--; continue; } - if (wait & M_WAITOK) { - VM_WAIT; - continue; - } - /* * Page allocation failed, free intermediate pages and * exit. @@ -1217,9 +1242,7 @@ page_free(void *mem, vm_size_t size, uint8_t flags) #ifndef __rtems__ struct vmem *vmem; - if (flags & UMA_SLAB_KMEM) - vmem = kmem_arena; - else if (flags & UMA_SLAB_KERNEL) + if (flags & UMA_SLAB_KERNEL) vmem = kernel_arena; else panic("UMA: page_free used with invalid flags %x", flags); @@ -1855,6 +1878,8 @@ rtems_bsd_uma_startup(void *unused) { (void) unused; + uma_kmem_limit = (rtems_bsd_get_allocator_domain_size( + RTEMS_BSD_ALLOCATOR_DOMAIN_PAGE) / 4) * 3; sx_init_flags(&uma_drain_lock, "umadrain", SX_RECURSE); uma_startup(NULL, 0); } @@ -2128,6 +2153,15 @@ uma_zdestroy(uma_zone_t zone) sx_sunlock(&uma_drain_lock); } +void +uma_zwait(uma_zone_t zone) +{ + void *item; + + item = uma_zalloc_arg(zone, NULL, M_WAITOK); + uma_zfree(zone, item); +} + /* See uma.h */ void * uma_zalloc_arg(uma_zone_t zone, void *udata, int flags) @@ -3245,33 +3279,35 @@ uma_reclaim(void) sx_xunlock(&uma_drain_lock); } -static int uma_reclaim_needed; +static volatile int uma_reclaim_needed; void uma_reclaim_wakeup(void) { - uma_reclaim_needed = 1; - wakeup(&uma_reclaim_needed); + if (atomic_fetchadd_int(&uma_reclaim_needed, 1) == 0) + wakeup(uma_reclaim); } void uma_reclaim_worker(void *arg __unused) { - sx_xlock(&uma_drain_lock); for (;;) { - sx_sleep(&uma_reclaim_needed, &uma_drain_lock, PVM, - "umarcl", 0); - if (uma_reclaim_needed) { - uma_reclaim_needed = 0; + sx_xlock(&uma_drain_lock); + while (uma_reclaim_needed == 0) + sx_sleep(uma_reclaim, &uma_drain_lock, PVM, "umarcl", + hz); #ifndef __rtems__ - sx_xunlock(&uma_drain_lock); - EVENTHANDLER_INVOKE(vm_lowmem, VM_LOW_KMEM); - sx_xlock(&uma_drain_lock); + sx_xunlock(&uma_drain_lock); + EVENTHANDLER_INVOKE(vm_lowmem, VM_LOW_KMEM); + sx_xlock(&uma_drain_lock); #endif /* __rtems__ */ - uma_reclaim_locked(true); - } + uma_reclaim_locked(true); + atomic_set_int(&uma_reclaim_needed, 0); + sx_xunlock(&uma_drain_lock); + /* Don't fire more than once per-second. */ + pause("umarclslp", hz); } } @@ -3310,6 +3346,7 @@ uma_large_malloc(vm_size_t size, int wait) slab->us_data = mem; slab->us_flags = flags | UMA_SLAB_MALLOC; slab->us_size = size; + uma_total_inc(size); } else { zone_free_item(slabzone, slab, NULL, SKIP_NONE); } @@ -3322,6 +3359,7 @@ uma_large_free(uma_slab_t slab) { page_free(slab->us_data, slab->us_size, slab->us_flags); + uma_total_dec(slab->us_size); zone_free_item(slabzone, slab, NULL, SKIP_NONE); } #endif /* __rtems__ */ @@ -3338,6 +3376,27 @@ uma_zero_item(void *item, uma_zone_t zone) bzero(item, zone->uz_size); } +unsigned long +uma_limit(void) +{ + + return (uma_kmem_limit); +} + +void +uma_set_limit(unsigned long limit) +{ + + uma_kmem_limit = limit; +} + +unsigned long +uma_size(void) +{ + + return uma_kmem_total; +} + void uma_print_stats(void) { diff --git a/freebsd/sys/vm/uma_dbg.c b/freebsd/sys/vm/uma_dbg.c index b7e9c266..9f7fac68 100644 --- a/freebsd/sys/vm/uma_dbg.c +++ b/freebsd/sys/vm/uma_dbg.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2002, 2003, 2004, 2005 Jeffrey Roberson <jeff@FreeBSD.org> * Copyright (c) 2004, 2005 Bosko Milekic <bmilekic@FreeBSD.org> * All rights reserved. diff --git a/freebsd/sys/vm/uma_dbg.h b/freebsd/sys/vm/uma_dbg.h index e3c9df02..c47273b6 100644 --- a/freebsd/sys/vm/uma_dbg.h +++ b/freebsd/sys/vm/uma_dbg.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2002, 2003, 2004, 2005 Jeffrey Roberson <jeff@FreeBSD.org> * Copyright (c) 2004, 2005 Bosko Milekic <bmilekic@FreeBSD.org> * All rights reserved. diff --git a/freebsd/sys/vm/uma_int.h b/freebsd/sys/vm/uma_int.h index df40efcd..592e79d7 100644 --- a/freebsd/sys/vm/uma_int.h +++ b/freebsd/sys/vm/uma_int.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2002-2005, 2009, 2013 Jeffrey Roberson <jeff@FreeBSD.org> * Copyright (c) 2004, 2005 Bosko Milekic <bmilekic@FreeBSD.org> * All rights reserved. @@ -438,6 +440,13 @@ vsetslab(vm_offset_t va, uma_slab_t slab) void *uma_small_alloc(uma_zone_t zone, vm_size_t bytes, uint8_t *pflag, int wait); void uma_small_free(void *mem, vm_size_t size, uint8_t flags); + +/* Set a global soft limit on UMA managed memory. */ +void uma_set_limit(unsigned long limit); +unsigned long uma_limit(void); + +/* Return the amount of memory managed by UMA. */ +unsigned long uma_size(void); #endif /* _KERNEL */ #endif /* VM_UMA_INT_H */ diff --git a/freebsd/sys/vm/vm.h b/freebsd/sys/vm/vm.h index d0945a3d..f674fc56 100644 --- a/freebsd/sys/vm/vm.h +++ b/freebsd/sys/vm/vm.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: (BSD-3-Clause AND MIT-CMU) + * * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/freebsd/sys/vm/vm_extern.h b/freebsd/sys/vm/vm_extern.h index 63248e64..c92933ca 100644 --- a/freebsd/sys/vm/vm_extern.h +++ b/freebsd/sys/vm/vm_extern.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * @@ -71,7 +73,6 @@ void kmem_init(vm_offset_t, vm_offset_t); void kmem_init_zero_region(void); void kmeminit(void); -void swapout_procs(int); int kernacc(void *, int, int); int useracc(void *, int, int); int vm_fault(vm_map_t, vm_offset_t, vm_prot_t, int); diff --git a/freebsd/sys/x86/include/machine/bus.h b/freebsd/sys/x86/include/machine/bus.h index 91de8cb2..041ab156 100644 --- a/freebsd/sys/x86/include/machine/bus.h +++ b/freebsd/sys/x86/include/machine/bus.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-3-Clause AND BSD-2-Clause-NetBSDE + * * Copyright (c) KATO Takenori, 1999. * * All rights reserved. Unpublished rights reserved under the copyright @@ -101,9 +103,7 @@ #include <machine/cpufunc.h> #ifndef __GNUCLIKE_ASM -# ifndef lint -# error "no assembler code for your compiler" -# endif +#error "no assembler code for your compiler" #endif /* diff --git a/freebsd/sys/x86/include/machine/pci_cfgreg.h b/freebsd/sys/x86/include/machine/pci_cfgreg.h index 733b91c4..8083eb0e 100644 --- a/freebsd/sys/x86/include/machine/pci_cfgreg.h +++ b/freebsd/sys/x86/include/machine/pci_cfgreg.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1997, Stefan Esser <se@freebsd.org> * All rights reserved. * diff --git a/freebsd/sys/x86/pci/pci_bus.c b/freebsd/sys/x86/pci/pci_bus.c index c08e115e..8d37bdcd 100644 --- a/freebsd/sys/x86/pci/pci_bus.c +++ b/freebsd/sys/x86/pci/pci_bus.c @@ -1,6 +1,8 @@ #include <machine/rtems-bsd-kernel-space.h> /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 1997, Stefan Esser <se@freebsd.org> * All rights reserved. * |