git: f0a0420dfd36 - main - powerof2: replace loops with fls or ilog2

2024-06-12 Thread Doug Moore
The branch main has been updated by dougm:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=f0a0420dfd36ae90f86cc9bfb1342b8862b8c9ec

commit f0a0420dfd36ae90f86cc9bfb1342b8862b8c9ec
Author: Doug Moore 
AuthorDate: 2024-06-12 09:26:42 +
Commit: Doug Moore 
CommitDate: 2024-06-12 10:00:48 +

powerof2: replace loops with fls or ilog2

In several places, a loop tests for powers of two, or iterates through
powers of two.  In those places, replace the loop with an invocation
of fls or ilog2 without changing the meaning of the code.

Reviewed by:alc, markj, kib, np, erj, avg (previous version)
Differential Revision:  https://reviews.freebsd.org/D45494
---
 sys/dev/aic7xxx/aic79xx.c   |  3 +--
 sys/dev/cxgb/cxgb_sge.c |  7 ++-
 sys/dev/cxgbe/t4_sge.c  |  4 +---
 sys/dev/irdma/irdma_ctrl.c  | 16 +---
 sys/dev/mlx5/mlx5_en/mlx5_en_main.c |  4 +---
 sys/netpfil/ipfw/ip_fw_table.c  | 10 +-
 6 files changed, 11 insertions(+), 33 deletions(-)

diff --git a/sys/dev/aic7xxx/aic79xx.c b/sys/dev/aic7xxx/aic79xx.c
index 0c4b615c5b24..ab68c3d8b088 100644
--- a/sys/dev/aic7xxx/aic79xx.c
+++ b/sys/dev/aic7xxx/aic79xx.c
@@ -8593,8 +8593,7 @@ ahd_loadseq(struct ahd_softc *ahd)
if (sg_prefetch_align == 0)
sg_prefetch_align = 8;
/* Round down to the nearest power of 2. */
-   while (powerof2(sg_prefetch_align) == 0)
-   sg_prefetch_align--;
+   sg_prefetch_align = 1 << ilog2(sg_prefetch_align);
 
cacheline_mask = sg_prefetch_align - 1;
 
diff --git a/sys/dev/cxgb/cxgb_sge.c b/sys/dev/cxgb/cxgb_sge.c
index f57494065aec..0c5be9dd6614 100644
--- a/sys/dev/cxgb/cxgb_sge.c
+++ b/sys/dev/cxgb/cxgb_sge.c
@@ -553,9 +553,7 @@ t3_sge_prep(adapter_t *adap, struct sge_params *p)
nqsets *= adap->params.nports;
 
fl_q_size = min(nmbclusters/(3*nqsets), FL_Q_SIZE);
-
-   while (!powerof2(fl_q_size))
-   fl_q_size--;
+   fl_q_size = 1 << ilog2(fl_q_size);
 
use_16k = cxgb_use_16k_clusters != -1 ? cxgb_use_16k_clusters :
is_offload(adap);
@@ -567,8 +565,7 @@ t3_sge_prep(adapter_t *adap, struct sge_params *p)
jumbo_q_size = min(nmbjumbo9/(3*nqsets), JUMBO_Q_SIZE);
jumbo_buf_size = MJUM9BYTES;
}
-   while (!powerof2(jumbo_q_size))
-   jumbo_q_size--;
+   jumbo_q_size = 1 << ilog2(jumbo_q_size);
 
if (fl_q_size < (FL_Q_SIZE / 4) || jumbo_q_size < (JUMBO_Q_SIZE / 2))
device_printf(adap->dev,
diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c
index e1705ae063e2..505f2d1bf677 100644
--- a/sys/dev/cxgbe/t4_sge.c
+++ b/sys/dev/cxgbe/t4_sge.c
@@ -4220,9 +4220,7 @@ qsize_to_fthresh(int qsize)
 {
u_int fthresh;
 
-   while (!powerof2(qsize))
-   qsize++;
-   fthresh = ilog2(qsize);
+   fthresh = qsize == 0 ? 0 : fls(qsize - 1);
if (fthresh > X_CIDXFLUSHTHRESH_128)
fthresh = X_CIDXFLUSHTHRESH_128;
 
diff --git a/sys/dev/irdma/irdma_ctrl.c b/sys/dev/irdma/irdma_ctrl.c
index dc42b15392c5..6078ac43815e 100644
--- a/sys/dev/irdma/irdma_ctrl.c
+++ b/sys/dev/irdma/irdma_ctrl.c
@@ -4909,7 +4909,7 @@ irdma_cfg_fpm_val(struct irdma_sc_dev *dev, u32 qp_count)
struct irdma_virt_mem virt_mem;
u32 i, mem_size;
u32 qpwanted, mrwanted, pblewanted;
-   u32 powerof2, hte;
+   u32 hte;
u32 sd_needed;
u32 sd_diff;
u32 loop_count = 0;
@@ -4938,12 +4938,8 @@ irdma_cfg_fpm_val(struct irdma_sc_dev *dev, u32 qp_count)
hmc_info->sd_table.sd_cnt, max_sds);
 
qpwanted = min(qp_count, hmc_info->hmc_obj[IRDMA_HMC_IW_QP].max_cnt);
-
-   powerof2 = 1;
-   while (powerof2 <= qpwanted)
-   powerof2 *= 2;
-   powerof2 /= 2;
-   qpwanted = powerof2;
+   if (qpwanted != 0)
+   qpwanted = 1 << ilog2(qpwanted);
 
mrwanted = hmc_info->hmc_obj[IRDMA_HMC_IW_MR].max_cnt;
pblewanted = hmc_info->hmc_obj[IRDMA_HMC_IW_PBLE].max_cnt;
@@ -4986,11 +4982,9 @@ irdma_cfg_fpm_val(struct irdma_sc_dev *dev, u32 qp_count)
hmc_info->hmc_obj[IRDMA_HMC_IW_MR].cnt = mrwanted;
 
hte = round_up(qpwanted + 
hmc_info->hmc_obj[IRDMA_HMC_IW_FSIMC].cnt, 512);
-   powerof2 = 1;
-   while (powerof2 < hte)
-   powerof2 *= 2;
+   hte = hte == 0 ? 1 : 1 << fls(hte - 1);
hmc_info->hmc_obj[IRDMA_HMC_IW_HTE].cnt =
-   powerof2 * hmc_fpm_misc->ht_multiplier;
+   hte * hmc_fpm_misc->ht_multiplier;
if (dev->hw_attrs.uk_attrs.hw_rev == IRDMA_GEN_1)
cfg_fpm_value_gen_1(dev, hmc_info, qpwanted);
else
diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c 
b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
index 962705e6d258..4d9d1048448b 100644
--- a/s

git: b8a496dfb6df - main - lib: Remove __ARM_ARCH checks that are always true

2024-06-12 Thread Andrew Turner
The branch main has been updated by andrew:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=b8a496dfb6df7b86e014d0d4476cd75850e060c1

commit b8a496dfb6df7b86e014d0d4476cd75850e060c1
Author: Andrew Turner 
AuthorDate: 2024-06-12 11:49:05 +
Commit: Andrew Turner 
CommitDate: 2024-06-12 11:49:05 +

lib: Remove __ARM_ARCH checks that are always true

Reviewed by:imp
Differential Revision:  https://reviews.freebsd.org/D45559
---
 lib/libc/arm/aeabi/aeabi_vfp.h | 2 +-
 lib/libc/arm/gen/_setjmp.S | 8 
 lib/libc/arm/gen/setjmp.S  | 4 ++--
 lib/libsys/arm/__vdso_gettc.c  | 7 ---
 lib/msun/arm/fenv.c| 6 +-
 5 files changed, 8 insertions(+), 19 deletions(-)

diff --git a/lib/libc/arm/aeabi/aeabi_vfp.h b/lib/libc/arm/aeabi/aeabi_vfp.h
index f87f9acfd0a2..3b70fe06fab3 100644
--- a/lib/libc/arm/aeabi/aeabi_vfp.h
+++ b/lib/libc/arm/aeabi/aeabi_vfp.h
@@ -65,7 +65,7 @@
  * C Helper macros
  */
 
-#if __ARM_ARCH >= 6 && !defined(SOFTFLOAT_FOR_GCC)
+#if !defined(SOFTFLOAT_FOR_GCC)
 /*
  * Generate a function that will either call into the VFP implementation,
  * or the soft float version for a given __aeabi_* helper. The function
diff --git a/lib/libc/arm/gen/_setjmp.S b/lib/libc/arm/gen/_setjmp.S
index 19b8b6b07059..9e655d2e9e2e 100644
--- a/lib/libc/arm/gen/_setjmp.S
+++ b/lib/libc/arm/gen/_setjmp.S
@@ -58,12 +58,12 @@
 ENTRY(_setjmp)
ldr r1, .L_setjmp_magic
 
-#if !defined(_STANDALONE) && __ARM_ARCH >= 6 && !defined(SOFTFLOAT_FOR_GCC)
+#if !defined(_STANDALONE) && !defined(SOFTFLOAT_FOR_GCC)
add r2, r0, #(_JB_REG_D8 * 4)
vstmia  r2, {d8-d15}
vmrsr2, fpscr
str r2, [r0, #(_JB_REG_FPSCR * 4)]
-#endif /* !_STANDALONE && __ARM_ARCH >= 6 */
+#endif /* !_STANDALONE && !SOFTFLOAT_FOR_GCC */
 
str r1, [r0]
 
@@ -91,12 +91,12 @@ ENTRY(_longjmp)
teq ip, r2  /* magic correct? */
bne botch   /*   no, botch */
 
-#if !defined(_STANDALONE) && __ARM_ARCH >= 6 && !defined(SOFTFLOAT_FOR_GCC)
+#if !defined(_STANDALONE) && !defined(SOFTFLOAT_FOR_GCC)
add ip, r0, #(_JB_REG_D8 * 4)
vldmia  ip, {d8-d15}
ldr ip, [r0, #(_JB_REG_FPSCR * 4)]
vmsrfpscr, ip
-#endif /* !_STANDALONE && __ARM_ARCH >= 6 */
+#endif /* !_STANDALONE && !SOFTFLOAT_FOR_GCC */
 
add r0, r0, #(_JB_REG_R4 * 4)
/* Restore integer registers */
diff --git a/lib/libc/arm/gen/setjmp.S b/lib/libc/arm/gen/setjmp.S
index 5a6c899e2b23..e7f8b788e878 100644
--- a/lib/libc/arm/gen/setjmp.S
+++ b/lib/libc/arm/gen/setjmp.S
@@ -61,7 +61,7 @@ ENTRY(setjmp)
 
ldr r1, .Lsetjmp_magic
 
-#if __ARM_ARCH >= 6 && !defined(SOFTFLOAT_FOR_GCC)
+#if !defined(SOFTFLOAT_FOR_GCC)
add r2, r0, #(_JB_REG_D8 * 4)
vstmia  r2, {d8-d15}
vmrsr2, fpscr
@@ -102,7 +102,7 @@ ENTRY(__longjmp)
bl  PIC_SYM(_C_LABEL(sigprocmask), PLT)
ldmfd   sp!, {r0-r2, r14}
 
-#if __ARM_ARCH >= 6 && !defined(SOFTFLOAT_FOR_GCC)
+#if !defined(SOFTFLOAT_FOR_GCC)
add ip, r0, #(_JB_REG_D8 * 4)
vldmia  ip, {d8-d15}
ldr ip, [r0, #(_JB_REG_FPSCR * 4)]
diff --git a/lib/libsys/arm/__vdso_gettc.c b/lib/libsys/arm/__vdso_gettc.c
index ea70dec35cd8..cb4bdec1e8ef 100644
--- a/lib/libsys/arm/__vdso_gettc.c
+++ b/lib/libsys/arm/__vdso_gettc.c
@@ -37,7 +37,6 @@
 #include 
 #include "libc_private.h"
 
-#if __ARM_ARCH >= 6
 static inline uint64_t
 cp15_cntvct_get(void)
 {
@@ -55,7 +54,6 @@ cp15_cntpct_get(void)
__asm __volatile("mrrc\tp15, 0, %Q0, %R0, c14" : "=r" (reg));
return (reg);
 }
-#endif
 
 #pragma weak __vdso_gettc
 int
@@ -64,7 +62,6 @@ __vdso_gettc(const struct vdso_timehands *th, u_int *tc)
 
if (th->th_algo != VDSO_TH_ALGO_ARM_GENTIM)
return (ENOSYS);
-#if __ARM_ARCH >= 6
/*
 * Userspace gettimeofday() is only enabled on ARMv7 CPUs, but
 * libc is compiled for ARMv6.  Due to clang issues, .arch
@@ -73,10 +70,6 @@ __vdso_gettc(const struct vdso_timehands *th, u_int *tc)
__asm __volatile(".word\t0xf57ff06f" : : : "memory"); /* isb */
*tc = th->th_physical == 0 ? cp15_cntvct_get() : cp15_cntpct_get();
return (0);
-#else
-   *tc = 0;
-   return (ENOSYS);
-#endif
 }
 
 #pragma weak __vdso_gettimekeep
diff --git a/lib/msun/arm/fenv.c b/lib/msun/arm/fenv.c
index 9f172d5fd7c9..05b3adb05f81 100644
--- a/lib/msun/arm/fenv.c
+++ b/lib/msun/arm/fenv.c
@@ -32,10 +32,6 @@
 
 #include 
 
-#if __ARM_ARCH >= 6
-#define FENV_ARMv6
-#endif
-
 /* When SOFTFP_ABI is defined we are using the softfp ABI. */
 #if defined(__VFP_FP__) && !defined(__ARM_PCS_VFP)
 #define SOFTFP_ABI
@@ -52,7 +48,7 @@ const fenv_t __fe_dfl_env = 0;
 
 
 /* If this is a non-mangled softfp version special processing is required */
-#if defined(FENV_MANGLE) || !defined(SOFTFP_ABI) || !defined(FENV_ARMv6)
+#if defined(FENV_MA

git: bbdf32d94c2f - main - nanobsd: Remove pre-armv6 support

2024-06-12 Thread Andrew Turner
The branch main has been updated by andrew:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=bbdf32d94c2f746b914aa87b1104b579426d8100

commit bbdf32d94c2f746b914aa87b1104b579426d8100
Author: Andrew Turner 
AuthorDate: 2024-06-12 11:49:13 +
Commit: Andrew Turner 
CommitDate: 2024-06-12 11:49:13 +

nanobsd: Remove pre-armv6 support

Remove support for pre-armv6 from nanobsd. It was removed from FreeBSD
in 2020.

Reviewed by:imp, emaste
Sponsored by:   Arm Ltd
Differential Revision:  https://reviews.freebsd.org/D45560
---
 tools/tools/nanobsd/embedded/common | 4 
 1 file changed, 4 deletions(-)

diff --git a/tools/tools/nanobsd/embedded/common 
b/tools/tools/nanobsd/embedded/common
index bcb1061df629..4f5eac7806f2 100644
--- a/tools/tools/nanobsd/embedded/common
+++ b/tools/tools/nanobsd/embedded/common
@@ -51,7 +51,6 @@
 # o documentation for how to run the qemu images
 # o msdos mtools fallback
 # o special boot for !x86 !arm platforms
-# o qemu image for arm
 # o qemu image for aarch64
 # o qemu image for armv6/armv7
 # o easy support for different image / vm formats
@@ -503,9 +502,6 @@ std_amd64 ( ) {
std_i386
 }
 
-std_arm ( ) {
-}
-
 std_armv6 ( ) {
 }
 



git: 62cb671705eb - main - riscv: include ahci device to GENERIC.

2024-06-12 Thread Ruslan Bukin
The branch main has been updated by br:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=62cb671705eb561d5a56c1c2dd2aff2ef984d035

commit 62cb671705eb561d5a56c1c2dd2aff2ef984d035
Author: Ruslan Bukin 
AuthorDate: 2024-06-12 12:36:05 +
Commit: Ruslan Bukin 
CommitDate: 2024-06-12 12:40:50 +

riscv: include ahci device to GENERIC.

This is needed for bhyve guest VM.

Reviewed by:mhorne
Sponsored by:   UKRI
Differential Revision:  https://reviews.freebsd.org/D45497
---
 sys/riscv/conf/GENERIC | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sys/riscv/conf/GENERIC b/sys/riscv/conf/GENERIC
index 52edc01b5c89..ce9038cee4a9 100644
--- a/sys/riscv/conf/GENERIC
+++ b/sys/riscv/conf/GENERIC
@@ -93,6 +93,7 @@ deviceriscv_syscon
 device pci
 
 # Block devices
+device ahci
 device scbus
 device da
 



git: a7ae78caaa17 - main - cdefs: Add __writeonly to mark write only vars

2024-06-12 Thread Andrew Turner
The branch main has been updated by andrew:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=a7ae78caaa17ff840da844c1dcaa780d194c9e20

commit a7ae78caaa17ff840da844c1dcaa780d194c9e20
Author: Andrew Turner 
AuthorDate: 2024-06-12 13:04:13 +
Commit: Andrew Turner 
CommitDate: 2024-06-12 13:04:13 +

cdefs: Add __writeonly to mark write only vars

When a variable in write only and can't be removed, e.g. for API
reasons, it is useful to document this fact similar to __diagused
and __witness_used.

Add __writeonly to tell the compiler and anyone looking at the code
that this variable is expected to only be written to, and to not
raise and error.

Reviewed by:imp, kib
Sponsored by:   Arm Ltd
Differential Revision:  https://reviews.freebsd.org/D45561
---
 sys/sys/cdefs.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h
index 037dfa55f923..c3268791787f 100644
--- a/sys/sys/cdefs.h
+++ b/sys/sys/cdefs.h
@@ -180,6 +180,7 @@
 #define__aligned(x)__attribute__((__aligned__(x)))
 #define__section(x)__attribute__((__section__(x)))
 #endif
+#define__writeonly __unused
 #if __GNUC_PREREQ__(4, 3) || __has_attribute(__alloc_size__)
 #define__alloc_size(x) __attribute__((__alloc_size__(x)))
 #define__alloc_size2(n, x) __attribute__((__alloc_size__(n, x)))



git: 19782e5bef34 - main - ibcore: Mark write-only variables

2024-06-12 Thread Andrew Turner
The branch main has been updated by andrew:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=19782e5bef3403a6ed65d46653f2e70f81dced37

commit 19782e5bef3403a6ed65d46653f2e70f81dced37
Author: Andrew Turner 
AuthorDate: 2024-06-12 13:04:45 +
Commit: Andrew Turner 
CommitDate: 2024-06-12 13:04:45 +

ibcore: Mark write-only variables

Some LinuxKPI lock macros pass need a flags field passed in. This is
written to but never read from so gcc complains.

Fix this by marking the flags variables as unused to quieten the
compiler.

Reviewed by:brooks (earlier version), kib
Sponsored by:   Arm Ltd
Differential Revision:  https://reviews.freebsd.org/D45303
---
 sys/ofed/drivers/infiniband/core/ib_cache.c | 16 
 sys/ofed/drivers/infiniband/core/ib_cm.c|  4 ++--
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/sys/ofed/drivers/infiniband/core/ib_cache.c 
b/sys/ofed/drivers/infiniband/core/ib_cache.c
index b170f2b637f9..d2cc680796ef 100644
--- a/sys/ofed/drivers/infiniband/core/ib_cache.c
+++ b/sys/ofed/drivers/infiniband/core/ib_cache.c
@@ -465,7 +465,7 @@ static int _ib_cache_gid_table_find(struct ib_device 
*ib_dev,
struct ib_gid_table *table;
u8 p;
int local_index;
-   unsigned long flags;
+   unsigned long flags __writeonly;
 
for (p = 0; p < ib_dev->phys_port_cnt; p++) {
table = ports_table[p];
@@ -514,7 +514,7 @@ int ib_find_cached_gid_by_port(struct ib_device *ib_dev,
unsigned long mask = GID_ATTR_FIND_MASK_GID |
 GID_ATTR_FIND_MASK_GID_TYPE;
struct ib_gid_attr val = {.ndev = ndev, .gid_type = gid_type};
-   unsigned long flags;
+   unsigned long flags __writeonly;
 
if (!rdma_is_port_valid(ib_dev, port))
return -ENOENT;
@@ -570,7 +570,7 @@ static int ib_cache_gid_find_by_filter(struct ib_device 
*ib_dev,
struct ib_gid_table **ports_table = ib_dev->cache.gid_cache;
struct ib_gid_table *table;
unsigned int i;
-   unsigned long flags;
+   unsigned long flags __writeonly;
bool found = false;
 
if (!ports_table)
@@ -879,7 +879,7 @@ int ib_get_cached_gid(struct ib_device *device,
  struct ib_gid_attr *gid_attr)
 {
int res;
-   unsigned long flags;
+   unsigned long flags __writeonly;
struct ib_gid_table **ports_table = device->cache.gid_cache;
struct ib_gid_table *table = ports_table[port_num - 
rdma_start_port(device)];
 
@@ -929,7 +929,7 @@ int ib_get_cached_pkey(struct ib_device *device,
   u16  *pkey)
 {
struct ib_pkey_cache *cache;
-   unsigned long flags;
+   unsigned long flags __writeonly;
int ret = 0;
 
if (!rdma_is_port_valid(device, port_num))
@@ -956,7 +956,7 @@ int ib_find_cached_pkey(struct ib_device *device,
u16  *index)
 {
struct ib_pkey_cache *cache;
-   unsigned long flags;
+   unsigned long flags __writeonly;
int i;
int ret = -ENOENT;
int partial_ix = -1;
@@ -997,7 +997,7 @@ int ib_find_exact_cached_pkey(struct ib_device *device,
  u16  *index)
 {
struct ib_pkey_cache *cache;
-   unsigned long flags;
+   unsigned long flags __writeonly;
int i;
int ret = -ENOENT;
 
@@ -1027,7 +1027,7 @@ int ib_get_cached_lmc(struct ib_device *device,
  u8port_num,
  u8*lmc)
 {
-   unsigned long flags;
+   unsigned long flags __writeonly;
int ret = 0;
 
if (!rdma_is_port_valid(device, port_num))
diff --git a/sys/ofed/drivers/infiniband/core/ib_cm.c 
b/sys/ofed/drivers/infiniband/core/ib_cm.c
index 3ee17a847720..7ace287b1c88 100644
--- a/sys/ofed/drivers/infiniband/core/ib_cm.c
+++ b/sys/ofed/drivers/infiniband/core/ib_cm.c
@@ -4057,7 +4057,7 @@ static void cm_add_one(struct ib_device *ib_device)
struct ib_port_modify port_modify = {
.set_port_cap_mask = IB_PORT_CM_SUP
};
-   unsigned long flags;
+   unsigned long flags __writeonly;
int ret;
int count = 0;
u8 i;
@@ -4150,7 +4150,7 @@ static void cm_remove_one(struct ib_device *ib_device, 
void *client_data)
struct ib_port_modify port_modify = {
.clr_port_cap_mask = IB_PORT_CM_SUP
};
-   unsigned long flags;
+   unsigned long flags __writeonly;
int i;
 
if (!cm_dev)



git: 4eec584d79c1 - main - arm64: Clear td_frame when returning to userspace

2024-06-12 Thread Andrew Turner
The branch main has been updated by andrew:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=4eec584d79c1e8375d863c7eec7229ac7ec3f13b

commit 4eec584d79c1e8375d863c7eec7229ac7ec3f13b
Author: Andrew Turner 
AuthorDate: 2024-06-12 13:08:13 +
Commit: Andrew Turner 
CommitDate: 2024-06-12 13:08:13 +

arm64: Clear td_frame when returning to userspace

When returning from an exception to userspace clear the saved td_frame.
On the next exception this should point to the frame, however this is
not guaranteed.

To ensure the trap frame pointer is either valid or NULL clear it
before returning to userspace in the EL0 synchronous exception handler.

Reviewed by:kib, markj
Sponsored by:   Arm Ltd
Differential Revision:  https://reviews.freebsd.org/D44807
---
 sys/arm64/arm64/exception.S | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sys/arm64/arm64/exception.S b/sys/arm64/arm64/exception.S
index 662684588e0c..3dff834e27a2 100644
--- a/sys/arm64/arm64/exception.S
+++ b/sys/arm64/arm64/exception.S
@@ -252,9 +252,11 @@ ENTRY(handle_el0_sync)
KMSAN_ENTER
ldr x0, [x18, #PC_CURTHREAD]
mov x1, sp
+   mov x22, x0
str x1, [x0, #TD_FRAME]
bl  do_el0_sync
do_ast
+   str xzr, [x22, #TD_FRAME]
KMSAN_LEAVE
restore_registers 0
ERET



git: a30149b2a9c6 - main - arm64: Create a version of vfp_save_state for cpu_switch

2024-06-12 Thread Andrew Turner
The branch main has been updated by andrew:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=a30149b2a9c6ac5280523eea9570e5b5e5f1fdf8

commit a30149b2a9c6ac5280523eea9570e5b5e5f1fdf8
Author: Andrew Turner 
AuthorDate: 2024-06-12 13:09:14 +
Commit: Andrew Turner 
CommitDate: 2024-06-12 13:09:14 +

arm64: Create a version of vfp_save_state for cpu_switch

This will be used when we add SVE support to reduce the registers
needed to be saved on context switch.

Reviewed by:imp
Sponsored by:   Arm Ltd
Differential Revision:  https://reviews.freebsd.org/D43305
---
 sys/arm64/arm64/swtch.S | 4 +---
 sys/arm64/arm64/vfp.c   | 8 
 sys/arm64/include/vfp.h | 1 +
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/sys/arm64/arm64/swtch.S b/sys/arm64/arm64/swtch.S
index ca00d473fd47..6af70ca839a0 100644
--- a/sys/arm64/arm64/swtch.S
+++ b/sys/arm64/arm64/swtch.S
@@ -148,9 +148,7 @@ ENTRY(cpu_switch)
mov x21, x2
 
 #ifdef VFP
-   /* Load the pcb address */
-   mov x1, x4
-   bl  vfp_save_state
+   bl  vfp_save_state_switch
mov x0, x20
 #else
mov x0, x1
diff --git a/sys/arm64/arm64/vfp.c b/sys/arm64/arm64/vfp.c
index f35cd960702b..c65108a83399 100644
--- a/sys/arm64/arm64/vfp.c
+++ b/sys/arm64/arm64/vfp.c
@@ -216,6 +216,14 @@ vfp_save_state_savectx(struct pcb *pcb)
vfp_save_state_common(curthread, pcb);
 }
 
+void
+vfp_save_state_switch(struct thread *td)
+{
+   KASSERT(td != NULL, ("NULL vfp thread"));
+
+   vfp_save_state_common(td, td->td_pcb);
+}
+
 /*
  * Update the VFP state for a forked process or new thread. The PCB will
  * have been copied from the old thread.
diff --git a/sys/arm64/include/vfp.h b/sys/arm64/include/vfp.h
index 7f4c86e7737d..47d068d6050c 100644
--- a/sys/arm64/include/vfp.h
+++ b/sys/arm64/include/vfp.h
@@ -79,6 +79,7 @@ void  vfp_reset_state(struct thread *, struct pcb *);
 void   vfp_restore_state(void);
 void   vfp_save_state(struct thread *, struct pcb *);
 void   vfp_save_state_savectx(struct pcb *);
+void   vfp_save_state_switch(struct thread *);
 
 struct fpu_kern_ctx;
 



git: a87e584f6c9d - stable/14 - LinuxKPI: add kvmemdup()

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/14 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=a87e584f6c9d1fbe6bb47e588628aae4331c9967

commit a87e584f6c9d1fbe6bb47e588628aae4331c9967
Author: Bjoern A. Zeeb 
AuthorDate: 2024-05-13 17:43:25 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 13:57:24 +

LinuxKPI: add kvmemdup()

Add kvmemdup() as a variant of kmemdup().  While currently it could
just call kmemdup() we duplicate the code and use kvmalloc() in case
someone will change the implementation of kvmalloc/kvfree in slab.h.
This is used by an updated wireless driver.

Sponsored by:   The FreeBSD Foundation
Reviewed by:emaste
Differential Revision: https://reviews.freebsd.org/D45181

(cherry picked from commit 8e4b8e9d807aa379d2a1c3aaac2537ba7d6bf0bf)
---
 sys/compat/linuxkpi/common/include/linux/string.h | 12 
 1 file changed, 12 insertions(+)

diff --git a/sys/compat/linuxkpi/common/include/linux/string.h 
b/sys/compat/linuxkpi/common/include/linux/string.h
index 06dcdbd97663..9302c95e8636 100644
--- a/sys/compat/linuxkpi/common/include/linux/string.h
+++ b/sys/compat/linuxkpi/common/include/linux/string.h
@@ -97,6 +97,18 @@ kmemdup(const void *src, size_t len, gfp_t gfp)
return (dst);
 }
 
+/* See slab.h for kvmalloc/kvfree(). */
+static inline void *
+kvmemdup(const void *src, size_t len, gfp_t gfp)
+{
+   void *dst;
+
+   dst = kvmalloc(len, gfp);
+   if (dst != NULL)
+   memcpy(dst, src, len);
+   return (dst);
+}
+
 static inline char *
 strndup_user(const char __user *ustr, long n)
 {



git: 787b33636194 - stable/14 - net80211: fix IEEE80211_FHT_BITS

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/14 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=787b33636194106e7908eded32f5d9b43b533dc2

commit 787b33636194106e7908eded32f5d9b43b533dc2
Author: Bjoern A. Zeeb 
AuthorDate: 2024-05-31 21:48:49 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 13:57:17 +

net80211: fix IEEE80211_FHT_BITS

AMPDU_RX was added as a second AMPDU_TX, LDPC_TX and LDPC_RX missing;
correct and add missing.
Makes ddb output (and other debugging) look more correct.

Sponsored by:   The FreeBSD Foundation
Reviewed by:adrian
Differential Revision: https://reviews.freebsd.org/D45505

(cherry picked from commit 5bbf4b6291863452acfb5a7fc76f227848841cac)
---
 sys/net80211/ieee80211_var.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/net80211/ieee80211_var.h b/sys/net80211/ieee80211_var.h
index 4c9cdcbfccd9..d41fb1e6559c 100644
--- a/sys/net80211/ieee80211_var.h
+++ b/sys/net80211/ieee80211_var.h
@@ -722,7 +722,7 @@ MALLOC_DECLARE(M_80211_VAP);
 
 #defineIEEE80211_FHT_BITS \
"\20\1NONHT_PR" \
-   "\23GF\24HT\25AMPDU_TX\26AMPDU_TX" \
+   "\21LDPC_TX\22LDPC_RX\23GF\24HT\25AMPDU_TX\26AMPDU_RX" \
"\27AMSDU_TX\30AMSDU_RX\31USEHT40\32PUREN\33SHORTGI20\34SHORTGI40" \
"\35HTCOMPAT\36RIFS\37STBC_TX\40STBC_RX"
 



git: c8cf6a7706a0 - stable/14 - LinuxKPI: add FIELD_PREP_CONST()

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/14 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=c8cf6a7706a090a821fdbc77d5b9b0a6474c8473

commit c8cf6a7706a090a821fdbc77d5b9b0a6474c8473
Author: Bjoern A. Zeeb 
AuthorDate: 2024-05-13 17:40:26 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 13:57:37 +

LinuxKPI: add FIELD_PREP_CONST()

Add FIELD_PREP_CONST() like FIELD_PREP() without any extra checks likely
expected on this version in Linux.  This is called by an updated wireless
driver.

Sposnored by:   The FreeBSD Foundation
MFC after:  3 days
Differential Revision: https://reviews.freebsd.org/D45180

(cherry picked from commit bb025df257386c5d1087b652e8ed951bceb89862)
---
 sys/compat/linuxkpi/common/include/linux/bitfield.h | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/bitfield.h 
b/sys/compat/linuxkpi/common/include/linux/bitfield.h
index a2020d247489..8a91b0663f37 100644
--- a/sys/compat/linuxkpi/common/include/linux/bitfield.h
+++ b/sys/compat/linuxkpi/common/include/linux/bitfield.h
@@ -1,7 +1,7 @@
 /*-
  * SPDX-License-Identifier: BSD-2-Clause
  *
- * Copyright (c) 2020 The FreeBSD Foundation
+ * Copyright (c) 2020-2024 The FreeBSD Foundation
  *
  * This software was developed by Björn Zeeb under sponsorship from
  * the FreeBSD Foundation.
@@ -131,6 +131,10 @@ _uX_replace_bits(8)
 #defineFIELD_PREP(_mask, _value)   
\
(((typeof(_mask))(_value) << __bf_shf(_mask)) & (_mask))
 
+/* Likely would need extra sanity checks compared to FIELD_PREP()? */
+#defineFIELD_PREP_CONST(_mask, _value) 
\
+   (((typeof(_mask))(_value) << __bf_shf(_mask)) & (_mask))
+
 #defineFIELD_GET(_mask, _value)
\
((typeof(_mask))(((_value) & (_mask)) >> __bf_shf(_mask)))
 



git: 0c2b2e5bd99a - stable/14 - iwn(4): correct debug message: "not" to "no"

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/14 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=0c2b2e5bd99a993ff33ed148c6cd3c53d2c02216

commit 0c2b2e5bd99a993ff33ed148c6cd3c53d2c02216
Author: Bjoern A. Zeeb 
AuthorDate: 2024-06-05 22:01:06 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 13:56:52 +

iwn(4): correct debug message: "not" to "no"

Sponosred by:   The FreeBSD Foundation

(cherry picked from commit 9e012a9da5df131b64c2dfd7d9b6645af4ccef0f)
---
 sys/dev/iwn/if_iwn.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/dev/iwn/if_iwn.c b/sys/dev/iwn/if_iwn.c
index 3b1d879914b6..d2d44d93f948 100644
--- a/sys/dev/iwn/if_iwn.c
+++ b/sys/dev/iwn/if_iwn.c
@@ -7532,7 +7532,7 @@ iwn_addba_request(struct ieee80211_node *ni, struct 
ieee80211_tx_ampdu *tap,
break;
}
if (qid == sc->ntxqs) {
-   DPRINTF(sc, IWN_DEBUG_XMIT, "%s: not free aggregation queue\n",
+   DPRINTF(sc, IWN_DEBUG_XMIT, "%s: no free aggregation queue\n",
__func__);
return 0;
}



git: 4ed728875b89 - stable/14 - fwget: update wireless IDs for rtw88/89, ath1xk, mt76 and add iwlwifi

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/14 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=4ed728875b89bbb05885b5dd7a606f70acd1524d

commit 4ed728875b89bbb05885b5dd7a606f70acd1524d
Author: Bjoern A. Zeeb 
AuthorDate: 2024-04-23 01:10:07 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 13:57:00 +

fwget: update wireless IDs for rtw88/89, ath1xk, mt76 and add iwlwifi

Update and add (new) PCI IDs for Realtek rtw88/89, Mediatek 7996/7925,
QCA ath1xk, and add Intel iwlwifi IDs.

Rather than using a package per driver add fine(r) grained flavors
even though it is a lot more likely to break in certain cases.

For Intel we need a great level of detail to match PCI IDs so also pass
the full pciconf -l line to into the pci_* files as "$2" to have access
to these.

This lines up with ports commit 80f50c9eb66d.

Sponsored by:   The FreeBSD Foundation
Reviewed by:manu (earlier version)
Differential Revision: https://reviews.freebsd.org/D44918

(cherry picked from commit d33f5a0afa54be7f18775f6506f015c7f79a6a5f)
---
 usr.sbin/fwget/pci/Makefile |   1 +
 usr.sbin/fwget/pci/pci  |   2 +-
 usr.sbin/fwget/pci/pci_network_intel| 437 
 usr.sbin/fwget/pci/pci_network_mediatek |  53 ++--
 usr.sbin/fwget/pci/pci_network_qca  |  62 +++--
 usr.sbin/fwget/pci/pci_network_realtek  |  46 +++-
 6 files changed, 539 insertions(+), 62 deletions(-)

diff --git a/usr.sbin/fwget/pci/Makefile b/usr.sbin/fwget/pci/Makefile
index 66b3901e4a91..6c500dae6df6 100644
--- a/usr.sbin/fwget/pci/Makefile
+++ b/usr.sbin/fwget/pci/Makefile
@@ -1,6 +1,7 @@
 PACKAGE=   fwget
 
 SCRIPTS=pci \
+   pci_network_intel \
pci_network_mediatek \
pci_network_qca \
pci_network_realtek \
diff --git a/usr.sbin/fwget/pci/pci b/usr.sbin/fwget/pci/pci
index 6a66049842e2..fbdfa0001c5c 100644
--- a/usr.sbin/fwget/pci/pci
+++ b/usr.sbin/fwget/pci/pci
@@ -107,7 +107,7 @@ pci_search_packages()
fi
. ${LIBEXEC_PATH}/pci_${class}_${vendor}
 
-   pci_${class}_${vendor} ${device}
+   pci_${class}_${vendor} ${device} "${fulldevice}"
done
IFS=${oldifs}
 }
diff --git a/usr.sbin/fwget/pci/pci_network_intel 
b/usr.sbin/fwget/pci/pci_network_intel
new file mode 100644
index ..cf8c52075db3
--- /dev/null
+++ b/usr.sbin/fwget/pci/pci_network_intel
@@ -0,0 +1,437 @@
+#-
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# Copyright (c) 2024 The FreeBSD Foundation
+#
+# This software was developed by Björn Zeeb
+# under sponsorship from the FreeBSD Foundation.
+#
+
+# Some iwlwifi chipsets are detected by other means and we cannot replicate
+# the full logic here.
+# Currently we also filter out all those which do have a wildcard device ID
+# as well as all for those which exists no firmware (yet).
+
+# iwlwifi (dynamic)
+pci_network_intel_iwlwifi()
+{
+
+   local idstr=$(echo $2 | sed 's,.*\ device=\(0x[0-9a-z]*\) 
subvendor=\(0x[0-9a-z]*\) subdevice=\(0x[0-9a-z]*\),\1/\2/\3,')
+
+   case "${idstr}" in
+
+   # The case pattern table below is generated by a script also helping
+   # to generate the flavor/firmware Makefile definitions for ports.
+   # { sys/contrib/dev/iwlwifi/zzz_fw_ports_fwget.sh }
+   ### >>>
+
+   # 7000
+   0x08b1/*/0x4a6c) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+   0x08b1/*/0x4a6e) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+   0x08b1/*/0x4a70) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+   0x08b1/*/0x4c60) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+   0x08b1/*/0x4c70) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+   0x08b1/*/0x402a) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+   0x08b1/*/0x406a) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+   0x08b1/*/0x446a) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+   0x08b1/*/0x486e) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+   0x08b1/*/0x4020) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+   0x08b1/*/0x4060) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+   0x08b1/*/0x4062) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+   0x08b1/*/0x4070) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+   0x08b1/*/0x4072) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+   0x08b1/*/0x4160) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+   0x08b1/*/0x4162) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+   0x08b1/*/0x4170) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+   0x08b1/*/0x4420) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+   0x08b1/*/0x4460) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+   0x08b1/*/0x4462) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+   0x08b1/*/

git: 7ad7453748e2 - stable/14 - LinuxKPI: 802.11: change teardown order to avoid iwlwifi firmware crashes

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/14 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=7ad7453748e2adafa1e1a3e44b02fc852d4c5301

commit 7ad7453748e2adafa1e1a3e44b02fc852d4c5301
Author: Bjoern A. Zeeb 
AuthorDate: 2024-05-22 02:24:51 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 13:58:36 +

LinuxKPI: 802.11: change teardown order to avoid iwlwifi firmware crashes

While the previous order worked well for iwlwifi 22000 and later chipsets
(AXxxx, BE200), earlier chipsets had trouble and ran into firmware crashes.
Change the teardown order to avoid these problems.  The inline comments
in lkpi_sta_run_to_init() (and lkpi_disassoc()) try to document the new
order and also the old problems we were seeing (too early sta removal or
silent non-removal) leading to follow-up problems.

There is a possible further problem still lingering but a lot harder to
trigger (see comment in review) and likely related to some other doings
so we'll track it separately.

Sponsored by:   The FreeBSD Foundation
PR: 275255
Tested with:AX210, 8265 (bz); 9260 (Bakul Shah)
Differential Revision: https://reviews.freebsd.org/D45293

(cherry picked from commit 5a4d24610fc6143ac1d570fe2b5160e8ae893c2c)
---
 sys/compat/linuxkpi/common/src/linux_80211.c | 84 ++--
 1 file changed, 55 insertions(+), 29 deletions(-)

diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c 
b/sys/compat/linuxkpi/common/src/linux_80211.c
index 758db287d613..32b0287db65c 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -994,33 +994,37 @@ lkpi_hw_conf_idle(struct ieee80211_hw *hw, bool new)
}
 }
 
-static void
+static enum ieee80211_bss_changed
 lkpi_disassoc(struct ieee80211_sta *sta, struct ieee80211_vif *vif,
 struct lkpi_hw *lhw)
 {
+   enum ieee80211_bss_changed changed;
+
+   changed = 0;
sta->aid = 0;
if (vif->cfg.assoc) {
-   struct ieee80211_hw *hw;
-   enum ieee80211_bss_changed changed;
 
lhw->update_mc = true;
lkpi_update_mcast_filter(lhw->ic, true);
 
-   changed = 0;
vif->cfg.assoc = false;
vif->cfg.aid = 0;
changed |= BSS_CHANGED_ASSOC;
-   /*
-* This will remove the sta from firmware for iwlwifi.
-* So confusing that they use state and flags and ... ^%$%#%$^.
-*/
IMPROVE();
-   hw = LHW_TO_HW(lhw);
-   lkpi_80211_mo_bss_info_changed(hw, vif, &vif->bss_conf,
-   changed);
 
-   lkpi_hw_conf_idle(hw, true);
+   /*
+* Executing the bss_info_changed(BSS_CHANGED_ASSOC) with
+* assoc = false right away here will remove the sta from
+* firmware for iwlwifi.
+* We no longer do this but only return the BSS_CHNAGED value.
+* The caller is responsible for removing the sta gong to
+* IEEE80211_STA_NOTEXIST and then executing the
+* bss_info_changed() update.
+* See lkpi_sta_run_to_init() for more detailed comment.
+*/
}
+
+   return (changed);
 }
 
 static void
@@ -1460,6 +1464,8 @@ lkpi_sta_auth_to_scan(struct ieee80211vap *vap, enum 
ieee80211_state nstate, int
lkpi_80211_mo_unassign_vif_chanctx(hw, vif, &vif->bss_conf, 
&vif->chanctx_conf);
/* NB: vif->chanctx_conf is NULL now. */
 
+   lkpi_hw_conf_idle(hw, true);
+
/* Remove chan ctx. */
lkpi_80211_mo_remove_chanctx(hw, conf);
lchanctx = CHANCTX_CONF_TO_LCHANCTX(conf);
@@ -1743,16 +1749,11 @@ _lkpi_sta_assoc_to_down(struct ieee80211vap *vap, enum 
ieee80211_state nstate, i
goto out;
}
 
-   lkpi_lsta_dump(lsta, ni, __func__, __LINE__);
+   /* See comment in lkpi_sta_run_to_init(). */
+   bss_changed = 0;
+   bss_changed |= lkpi_disassoc(sta, vif, lhw);
 
-   /* Update bss info (bss_info_changed) (assoc, aid, ..). */
-   /*
-* We need to do this now, before sta changes to IEEE80211_STA_NOTEXIST
-* as otherwise drivers (iwlwifi at least) will silently not remove
-* the sta from the firmware and when we will add a new one trigger
-* a fw assert.
-*/
-   lkpi_disassoc(sta, vif, lhw);
+   lkpi_lsta_dump(lsta, ni, __func__, __LINE__);
 
/* Adjust sta and change state (from NONE) to NOTEXIST. */
KASSERT(lsta != NULL, ("%s: ni %p lsta is NULL\n", __func__, ni));
@@ -1769,7 +1770,6 @@ _lkpi_sta_assoc_to_down(struct ieee80211vap *vap, enum 
ieee80211_state nstate, i
lkpi_lsta_dump(lsta, ni, __func__, __LINE__);   /* sta no longer save 
to use. */
 
IMPROVE("Any 

git: 323db2cbbb99 - stable/14 - LinuxKPI: 802.11: rename chanctx_conf for consistency

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/14 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=323db2cbbb99d0ad0175d4187aaec1d966761d94

commit 323db2cbbb99d0ad0175d4187aaec1d966761d94
Author: Bjoern A. Zeeb 
AuthorDate: 2024-05-13 21:03:31 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 13:58:56 +

LinuxKPI: 802.11: rename chanctx_conf for consistency

We used to call the struct ieee80211_chanctx_conf variable "conf"
in some places but that becomes confusing with bss_conf and other
"conf" bits.  On the vif it is already called chanctx_conf thus also
rename it on the internal struct lkpi_chanctx and for our variables
in the implementation.

This should not have any external visibility.
No functional changes intended.

Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45185

(cherry picked from commit d1af434d99941d32a09c48fb3ef77ef83e203d29)
---
 sys/compat/linuxkpi/common/src/linux_80211.c | 88 ++--
 sys/compat/linuxkpi/common/src/linux_80211.h |  6 +-
 2 files changed, 47 insertions(+), 47 deletions(-)

diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c 
b/sys/compat/linuxkpi/common/src/linux_80211.c
index 32b0287db65c..1943c6efd4d8 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -1079,7 +1079,7 @@ lkpi_sta_scan_to_auth(struct ieee80211vap *vap, enum 
ieee80211_state nstate, int
 {
struct linuxkpi_ieee80211_channel *chan;
struct lkpi_chanctx *lchanctx;
-   struct ieee80211_chanctx_conf *conf;
+   struct ieee80211_chanctx_conf *chanctx_conf;
struct lkpi_hw *lhw;
struct ieee80211_hw *hw;
struct lkpi_vif *lvif;
@@ -1145,54 +1145,54 @@ lkpi_sta_scan_to_auth(struct ieee80211vap *vap, enum 
ieee80211_state nstate, int
 
/* Add chanctx (or if exists, change it). */
if (vif->chanctx_conf != NULL) {
-   conf = vif->chanctx_conf;
-   lchanctx = CHANCTX_CONF_TO_LCHANCTX(conf);
+   chanctx_conf = vif->chanctx_conf;
+   lchanctx = CHANCTX_CONF_TO_LCHANCTX(chanctx_conf);
IMPROVE("diff changes for changed, working on live copy, rcu");
} else {
/* Keep separate alloc as in Linux this is rcu managed? */
lchanctx = malloc(sizeof(*lchanctx) + hw->chanctx_data_size,
M_LKPI80211, M_WAITOK | M_ZERO);
-   conf = &lchanctx->conf;
+   chanctx_conf = &lchanctx->chanctx_conf;
}
 
-   conf->rx_chains_dynamic = 1;
-   conf->rx_chains_static = 1;
-   conf->radar_enabled =
+   chanctx_conf->rx_chains_dynamic = 1;
+   chanctx_conf->rx_chains_static = 1;
+   chanctx_conf->radar_enabled =
(chan->flags & IEEE80211_CHAN_RADAR) ? true : false;
-   conf->def.chan = chan;
-   conf->def.width = NL80211_CHAN_WIDTH_20_NOHT;
-   conf->def.center_freq1 = chan->center_freq;
-   conf->def.center_freq2 = 0;
+   chanctx_conf->def.chan = chan;
+   chanctx_conf->def.width = NL80211_CHAN_WIDTH_20_NOHT;
+   chanctx_conf->def.center_freq1 = chan->center_freq;
+   chanctx_conf->def.center_freq2 = 0;
IMPROVE("Check vht_cap from band not just chan?");
KASSERT(ni->ni_chan != NULL && ni->ni_chan != IEEE80211_CHAN_ANYC,
   ("%s:%d: ni %p ni_chan %p\n", __func__, __LINE__, ni, ni->ni_chan));
 #ifdef LKPI_80211_HT
if (IEEE80211_IS_CHAN_HT(ni->ni_chan)) {
if (IEEE80211_IS_CHAN_HT40(ni->ni_chan)) {
-   conf->def.width = NL80211_CHAN_WIDTH_40;
+   chanctx_conf->def.width = NL80211_CHAN_WIDTH_40;
} else
-   conf->def.width = NL80211_CHAN_WIDTH_20;
+   chanctx_conf->def.width = NL80211_CHAN_WIDTH_20;
}
 #endif
 #ifdef LKPI_80211_VHT
if (IEEE80211_IS_CHAN_VHT(ni->ni_chan)) {
 #ifdef __notyet__
if (IEEE80211_IS_CHAN_VHT80P80(ni->ni_chan)) {
-   conf->def.width = NL80211_CHAN_WIDTH_80P80;
-   conf->def.center_freq2 = 0; /* XXX */
+   chanctx_conf->def.width = NL80211_CHAN_WIDTH_80P80;
+   chanctx_conf->def.center_freq2 = 0; /* XXX */
} else
 #endif
if (IEEE80211_IS_CHAN_VHT160(ni->ni_chan))
-   conf->def.width = NL80211_CHAN_WIDTH_160;
+   chanctx_conf->def.width = NL80211_CHAN_WIDTH_160;
else if (IEEE80211_IS_CHAN_VHT80(ni->ni_chan))
-   conf->def.width = NL80211_CHAN_WIDTH_80;
+   chanctx_conf->def.width = NL80211_CHAN_WIDTH_80;
}
 #endif
/* Responder ... */
-   conf->min_def.chan = chan;
-   conf->min_def.width = NL80211_CHAN_WIDTH_20_NOHT;
-   conf->min_def.center_fre

git: 29f9003cbbb3 - stable/14 - LinuxKPI: 802.11: initalize lsta to NULL in linuxkpi_ieee80211_rx()

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/14 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=29f9003cbbb3874fdbb02b99069868d00bcdff5a

commit 29f9003cbbb3874fdbb02b99069868d00bcdff5a
Author: Bjoern A. Zeeb 
AuthorDate: 2024-06-05 22:35:00 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 13:59:11 +

LinuxKPI: 802.11: initalize lsta to NULL in linuxkpi_ieee80211_rx()

The logic following this new assignment in some cases may not set lsta
but the later tracing is checking for it to be != NULL.
With lsta not initialized that check may not hold up and later we would
dereference lsta->state and possibly panic.

Sponsored by:   The FreeBSD Foundation
Reviewed by:emaste
Differential Revision: https://reviews.freebsd.org/D45507

(cherry picked from commit 582469016aed4fac3a7ead24dc31000edbb7e823)
---
 sys/compat/linuxkpi/common/src/linux_80211.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c 
b/sys/compat/linuxkpi/common/src/linux_80211.c
index ecacb74f01f3..6c96f1541488 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -5055,6 +5055,7 @@ no_trace_beacons:
goto err;
}
 
+   lsta = NULL;
if (sta != NULL) {
lsta = STA_TO_LSTA(sta);
ni = ieee80211_ref_node(lsta->ni);



git: e0ac61759dea - stable/14 - LinuxKPI: 802.11: Fix definition of IEEE80211_HT_CAP_RX_STBC

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/14 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=e0ac61759dea2d572a078ab018ca5d3ead912f0b

commit e0ac61759dea2d572a078ab018ca5d3ead912f0b
Author: Bjoern A. Zeeb 
AuthorDate: 2024-06-05 21:57:45 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 13:59:20 +

LinuxKPI: 802.11: Fix definition of IEEE80211_HT_CAP_RX_STBC

IEEE80211_HT_CAP_RX_STBC was set to 0x100 instead of 0x300.
Correct to get the expected behavior.

Sponsored by:   The FreeBSD Foundation
Fixes:  b0f73768220e9 LinuxKPI: 802.11 header updates
Reviewed by:adrian
Differential Revision: https://reviews.freebsd.org/D45506

(cherry picked from commit 3e0915b7b6857afdbd283f2d448906e6a032ee07)
---
 sys/compat/linuxkpi/common/include/linux/ieee80211.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/ieee80211.h 
b/sys/compat/linuxkpi/common/include/linux/ieee80211.h
index 2000e7480ff8..0fd90e921c77 100644
--- a/sys/compat/linuxkpi/common/include/linux/ieee80211.h
+++ b/sys/compat/linuxkpi/common/include/linux/ieee80211.h
@@ -263,7 +263,7 @@ enum ieee80211_ac_numbers {
 #defineIEEE80211_HT_CAP_SGI_20 0x0020  /* 
IEEE80211_HTCAP_SHORTGI20 */
 #defineIEEE80211_HT_CAP_SGI_40 0x0040  /* 
IEEE80211_HTCAP_SHORTGI40 */
 #defineIEEE80211_HT_CAP_TX_STBC0x0080  /* 
IEEE80211_HTCAP_TXSTBC */
-#defineIEEE80211_HT_CAP_RX_STBC0x0100  /* 
IEEE80211_HTCAP_RXSTBC */
+#defineIEEE80211_HT_CAP_RX_STBC0x0300  /* 
IEEE80211_HTCAP_RXSTBC */
 #defineIEEE80211_HT_CAP_RX_STBC_SHIFT  8   /* 
IEEE80211_HTCAP_RXSTBC_S */
 #defineIEEE80211_HT_CAP_MAX_AMSDU  0x0800  /* 
IEEE80211_HTCAP_MAXAMSDU */
 #defineIEEE80211_HT_CAP_DSSSCCK40  0x1000  /* 
IEEE80211_HTCAP_DSSSCCK40 */



git: 49f29c4183d9 - stable/14 - LinuxKPI: 802.11: lock MO tx/wake_tx_queue() downcalls

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/14 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=49f29c4183d93afd2724509362daaf41b16eca5d

commit 49f29c4183d93afd2724509362daaf41b16eca5d
Author: Bjoern A. Zeeb 
AuthorDate: 2024-02-18 21:07:08 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 13:59:04 +

LinuxKPI: 802.11: lock MO tx/wake_tx_queue() downcalls

Lock the two TX MO downcalls into driver/firmware in
lkpi_80211_txq_tx_one() to make sure they cannot happen in the
middle of other (net80211 triggered) updates calling down into
the driver/firmware.

Sponsored by:   The FreeBSD Foundation (commit)
Reviewed by:cc
Differential Revision: https://reviews.freebsd.org/D43966

(cherry picked from commit 45bce6fa306fc3a211949f63c9bbb7932fe5a3bd)
---
 sys/compat/linuxkpi/common/src/linux_80211.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c 
b/sys/compat/linuxkpi/common/src/linux_80211.c
index 1943c6efd4d8..ecacb74f01f3 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -3770,7 +3770,9 @@ lkpi_80211_txq_tx_one(struct lkpi_sta *lsta, struct mbuf 
*m)
ltxq->txq.tid, ac, skb->priority, skb->qmap);
 #endif
LKPI_80211_LTXQ_UNLOCK(ltxq);
+   LKPI_80211_LHW_LOCK(lhw);
lkpi_80211_mo_wake_tx_queue(hw, txq);
+   LKPI_80211_LHW_UNLOCK(lhw);
return;
 
 ops_tx:
@@ -3783,7 +3785,9 @@ ops_tx:
 #endif
memset(&control, 0, sizeof(control));
control.sta = sta;
+   LKPI_80211_LHW_LOCK(lhw);
lkpi_80211_mo_tx(hw, &control, skb);
+   LKPI_80211_LHW_UNLOCK(lhw);
 }
 
 static void



git: 04131cf0765d - stable/14 - LinuxKPI: remove extern from function declarations

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/14 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=04131cf0765de5d3c3ae2f4bd1b49bb7db230c06

commit 04131cf0765de5d3c3ae2f4bd1b49bb7db230c06
Author: Bjoern A. Zeeb 
AuthorDate: 2024-05-27 19:49:45 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 13:57:51 +

LinuxKPI: remove extern from function declarations

Sponsored by:   The FreeBSD Foundation
Reviewed by:emaste (earlier version, found another two)
Differential Revision: https://reviews.freebsd.org/D45386

(cherry picked from commit ecd1d1f1dac49c7ecbf1e7c5ffc64356c2851efd)
---
 sys/compat/linuxkpi/common/include/linux/gfp.h | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/gfp.h 
b/sys/compat/linuxkpi/common/include/linux/gfp.h
index 2fcc0dc05f29..e5dd2e44b0fa 100644
--- a/sys/compat/linuxkpi/common/include/linux/gfp.h
+++ b/sys/compat/linuxkpi/common/include/linux/gfp.h
@@ -90,15 +90,15 @@ struct page_frag_cache {
  *
  * NOTE: This function only works for pages allocated by the kernel.
  */
-extern void *linux_page_address(struct page *);
+void *linux_page_address(struct page *);
 
 #definepage_address(page) linux_page_address(page)
 
 /*
  * Page management for unmapped pages:
  */
-extern struct page *linux_alloc_pages(gfp_t flags, unsigned int order);
-extern void linux_free_pages(struct page *page, unsigned int order);
+struct page *linux_alloc_pages(gfp_t flags, unsigned int order);
+void linux_free_pages(struct page *page, unsigned int order);
 void *linuxkpi_page_frag_alloc(struct page_frag_cache *, size_t, gfp_t);
 void linuxkpi_page_frag_free(void *);
 void linuxkpi__page_frag_cache_drain(struct page *, size_t);
@@ -147,8 +147,8 @@ dev_alloc_pages(unsigned int order)
 /*
  * Page management for mapped pages:
  */
-extern vm_offset_t linux_alloc_kmem(gfp_t flags, unsigned int order);
-extern void linux_free_kmem(vm_offset_t, unsigned int order);
+vm_offset_t linux_alloc_kmem(gfp_t flags, unsigned int order);
+void linux_free_kmem(vm_offset_t, unsigned int order);
 
 static inline vm_offset_t
 get_zeroed_page(gfp_t flags)



git: eef52bbe9cb4 - stable/14 - LinuxKPI: 802.11: fix for_each_sta_active_link()

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/14 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=eef52bbe9cb44616116fab65f9bbf16d1e2d43ef

commit eef52bbe9cb44616116fab65f9bbf16d1e2d43ef
Author: Bjoern A. Zeeb 
AuthorDate: 2024-05-21 21:58:47 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 13:58:30 +

LinuxKPI: 802.11: fix for_each_sta_active_link()

Likely a c&p error from for_each_vif_active_link() to
for_each_sta_active_link().
We are checking the nitems on the vif instead of the sta in this macro.
Function wise there is no difference as the arrays are the same size
but for correctness fix this.

Sponsored by:   The FreeBSD Foundation

(cherry picked from commit 69b6c4a6ec6654978628ccd48edce46f00ac3e96)
---
 sys/compat/linuxkpi/common/include/net/mac80211.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/compat/linuxkpi/common/include/net/mac80211.h 
b/sys/compat/linuxkpi/common/include/net/mac80211.h
index fc9d7829dae3..6a477ae5c32a 100644
--- a/sys/compat/linuxkpi/common/include/net/mac80211.h
+++ b/sys/compat/linuxkpi/common/include/net/mac80211.h
@@ -1253,7 +1253,7 @@ ieee80211_hw_restart_disconnect(struct ieee80211_vif *vif)
(_link = rcu_dereference((_vif)->link_conf[_linkid])) )
 
 #definefor_each_sta_active_link(_vif, _sta, _linksta, _linkid) 
\
-for (_linkid = 0; _linkid < nitems((_vif)->link_conf); _linkid++)  \
+for (_linkid = 0; _linkid < nitems((_sta)->link); _linkid++)   \
if ( ((_vif)->active_links == 0 /* no MLO */ || \
((_vif)->active_links & BIT(_linkid)) != 0) &&  \
(_linksta = link_sta_dereference_protected((_sta), (_linkid))) )



git: 9e36362f6a87 - stable/14 - LinuxKPI: 802.11: close race lkpi_sta_scan_to_auth()/(*iv_update_bss)()

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/14 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=9e36362f6a871215c269edb43b87daba55b495e5

commit 9e36362f6a871215c269edb43b87daba55b495e5
Author: Bjoern A. Zeeb 
AuthorDate: 2024-02-18 20:57:51 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 13:59:32 +

LinuxKPI: 802.11: close race lkpi_sta_scan_to_auth()/(*iv_update_bss)()

We have to unlock the net80211 ic lock in order to be able to call
sleepable downcalls to the driver/firmware; a 2nd thread may go through
net80211::join1() and (*iv_update_bss)() after we checked and unlocked.
Re-check status at the end of the function under the ic lock so that we
do not accidentally set lvif_bss_synched to true again despite it no
longer being true.

This should fix a race where we lost the (*iv_update_bss)() state
during startup where one SCAN->AUTH is followed by a (then) AUTH->AUTH
and lkpi_sta_a_to_a() did the wrong thing.

Once we re-consider net80211 state and allowing a second join
on a different node or iv_bss update without previously tearing down
the older node we can likely undo a lot of these extra checks and
workarounds.

Sponsored by:   The FreeBSD Foundation (updated version)
Tested by:  emaste (on and off)
Reviewd by: cc
Differential Revision: https://reviews.freebsd.org/D43967

(cherry picked from commit 105b9df26ee0286f3a5a7d191075e068dee1c4a2)
---
 sys/compat/linuxkpi/common/src/linux_80211.c | 66 +++-
 1 file changed, 46 insertions(+), 20 deletions(-)

diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c 
b/sys/compat/linuxkpi/common/src/linux_80211.c
index 6c96f1541488..728103778e4e 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -1276,25 +1276,6 @@ lkpi_sta_scan_to_auth(struct ieee80211vap *vap, enum 
ieee80211_state nstate, int
lsta = ni->ni_drv_data;
 
LKPI_80211_LVIF_LOCK(lvif);
-   /* Re-check given (*iv_update_bss) could have happened. */
-   /* XXX-BZ KASSERT later? or deal as error? */
-   if (lvif->lvif_bss_synched || lvif->lvif_bss != NULL)
-   ic_printf(vap->iv_ic, "%s:%d: lvif %p vap %p iv_bss %p lvif_bss 
%p "
-   "lvif_bss->ni %p synched %d, ni %p lsta %p\n", __func__, 
__LINE__,
-   lvif, vap, vap->iv_bss, lvif->lvif_bss,
-   (lvif->lvif_bss != NULL) ? lvif->lvif_bss->ni : NULL,
-   lvif->lvif_bss_synched, ni, lsta);
-
-   /*
-* Reference the ni for this cache of lsta/ni on lvif->lvif_bss
-* essentially out lsta version of the iv_bss.
-* Do NOT use iv_bss here anymore as that may have diverged from our
-* function local ni already and would lead to inconsistencies.
-*/
-   ieee80211_ref_node(ni);
-   lvif->lvif_bss = lsta;
-   lvif->lvif_bss_synched = true;
-
/* Insert the [l]sta into the list of known stations. */
TAILQ_INSERT_TAIL(&lvif->lsta_head, lsta, lsta_entry);
LKPI_80211_LVIF_UNLOCK(lvif);
@@ -1343,11 +1324,56 @@ lkpi_sta_scan_to_auth(struct ieee80211vap *vap, enum 
ieee80211_state nstate, int
 * (ideally we'd do that on a callback for something else ...)
 */
 
+   LKPI_80211_LHW_UNLOCK(lhw);
+   IEEE80211_LOCK(vap->iv_ic);
+
+   LKPI_80211_LVIF_LOCK(lvif);
+   /* Re-check given (*iv_update_bss) could have happened while we were 
unlocked. */
+   if (lvif->lvif_bss_synched || lvif->lvif_bss != NULL ||
+   lsta->ni != vap->iv_bss)
+   ic_printf(vap->iv_ic, "%s:%d: lvif %p vap %p iv_bss %p lvif_bss 
%p "
+   "lvif_bss->ni %p synched %d, ni %p lsta %p\n", __func__, 
__LINE__,
+   lvif, vap, vap->iv_bss, lvif->lvif_bss,
+   (lvif->lvif_bss != NULL) ? lvif->lvif_bss->ni : NULL,
+   lvif->lvif_bss_synched, ni, lsta);
+
+   /*
+* Reference the "ni" for caching the lsta/ni in lvif->lvif_bss.
+* Given we cache lsta we use lsta->ni instead of ni here (even though
+* lsta->ni == ni) to be distinct from the rest of the code where we do
+* assume that ni == vap->iv_bss which it may or may not be.
+* So do NOT use iv_bss here anymore as that may have diverged from our
+* function local ni already while ic was unlocked and would lead to
+* inconsistencies.  Go and see if we lost a race and do not update
+* lvif_bss_synched in that case.
+*/
+   ieee80211_ref_node(lsta->ni);
+   lvif->lvif_bss = lsta;
+   if (lsta->ni == vap->iv_bss) {
+   lvif->lvif_bss_synched = true;
+   } else {
+   /* Set to un-synched no matter what. */
+   lvif->lvif_bss_synched = false;
+   /*
+* We do not error as someone has to take us down.
+   

git: 31c476da2d94 - stable/14 - LinuxKPI: pm: add SET_SYSTEM_SLEEP_PM_OPS() and device_can_wakeup()

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/14 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=31c476da2d944c3776186e73f8db56c57ba89b8d

commit 31c476da2d944c3776186e73f8db56c57ba89b8d
Author: Bjoern A. Zeeb 
AuthorDate: 2024-04-06 21:15:16 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 13:57:44 +

LinuxKPI: pm: add SET_SYSTEM_SLEEP_PM_OPS() and device_can_wakeup()

Add the SET_SYSTEM_SLEEP_PM_OPS() by factoring some other macro code
out in order to set the suspend/resume functions when the struct is
already given.  Such is the case in iwlwifi d3.

Also add an initial implementation of device_can_wakeup().  Though
this is likely all we need we have no way of setting the flag for it
yet so leave a pr_debug() and a comment there as well.  Until we want
to support WoWLAN this is likely not needed for wireless.
Doing it the proper way checking a bool in 'struct dev_pm_info' would
change 'struct device' and with that 'struct pci_dev' and break the
KBI.  In favour of mergeability this version does not implement the
full functionality yet.

Both help to make an updated iwlwifi d3 compile.

Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45358

(cherry picked from commit 3753988c5d22393fbdefb6aa16b5a5a699d05642)
---
 sys/compat/linuxkpi/common/include/linux/pm.h | 30 +++
 sys/compat/linuxkpi/common/src/linux_compat.c | 18 
 2 files changed, 35 insertions(+), 13 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/pm.h 
b/sys/compat/linuxkpi/common/include/linux/pm.h
index 871c7b587864..c8d943027909 100644
--- a/sys/compat/linuxkpi/common/include/linux/pm.h
+++ b/sys/compat/linuxkpi/common/include/linux/pm.h
@@ -1,7 +1,7 @@
 /*-
  * SPDX-License-Identifier: BSD-2-Clause
  *
- * Copyright (c) 2020 The FreeBSD Foundation
+ * Copyright (c) 2020-2024 The FreeBSD Foundation
  *
  * This software was developed by Björn Zeeb under sponsorship from
  * the FreeBSD Foundation.
@@ -58,25 +58,26 @@ struct dev_pm_info {
 IS_ENABLED(CONFIG_PM_SLEEP) ? (_p) : NULL
 
 #ifdef CONFIG_PM_SLEEP
+#define__SET_PM_OPS(_suspendfunc, _resumefunc) \
+   .suspend= _suspendfunc, \
+   .resume = _resumefunc,  \
+   .freeze = _suspendfunc, \
+   .thaw   = _resumefunc,  \
+   .poweroff   = _suspendfunc, \
+   .restore= _resumefunc,  \
+
 #defineSIMPLE_DEV_PM_OPS(_name, _suspendfunc, _resumefunc) \
 const struct dev_pm_ops _name = {  \
-   .suspend= _suspendfunc, \
-   .resume = _resumefunc,  \
-   .freeze = _suspendfunc, \
-   .thaw   = _resumefunc,  \
-   .poweroff   = _suspendfunc, \
-   .restore= _resumefunc,  \
+   __SET_PM_OPS(_suspendfunc, _resumefunc) \
 }
 
 #defineDEFINE_SIMPLE_DEV_PM_OPS(_name, _suspendfunc, _resumefunc) \
 const struct dev_pm_ops _name = {  \
-   .suspend= _suspendfunc, \
-   .resume = _resumefunc,  \
-   .freeze = _suspendfunc, \
-   .thaw   = _resumefunc,  \
-   .poweroff   = _suspendfunc, \
-   .restore= _resumefunc,  \
+   __SET_PM_OPS(_suspendfunc, _resumefunc) \
 }
+
+#defineSET_SYSTEM_SLEEP_PM_OPS(_suspendfunc, _resumefunc)  \
+   __SET_PM_OPS(_suspendfunc, _resumefunc)
 #else
 #defineSIMPLE_DEV_PM_OPS(_name, _suspendfunc, _resumefunc) \
 const struct dev_pm_ops _name = {  \
@@ -86,6 +87,9 @@ const struct dev_pm_ops _name = { 
\
 }
 #endif
 
+bool linuxkpi_device_can_wakeup(struct device *);
+#definedevice_can_wakeup(_dev) linuxkpi_device_can_wakeup(_dev)
+
 static inline void
 pm_wakeup_event(struct device *dev __unused, unsigned int x __unused)
 {
diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c 
b/sys/compat/linuxkpi/common/src/linux_compat.c
index b0691eb0f79a..894e233042e3 100644
--- a/sys/compat/linuxkpi/common/src/linux_compat.c
+++ b/sys/compat/linuxkpi/common/src/linux_compat.c
@@ -2592,6 +2592,24 @@ io_mapping_create_wc(resource_size_t base, unsigned long 
size)
return (io_mapping_init_wc(mapping, base, size));
 }
 
+/* We likely want a linuxkpi_device.c at some point. */
+bool
+device_can_wakeup(struct device *dev)
+{
+
+   if (dev == NULL)
+   return (false);
+   /*
+* XXX-BZ iwlwifi queries it as part of enabling WoWLAN.
+* Normally this would be based on a bool in dev->power.

git: 537b2e7d48ca - stable/14 - LinuxKPI: 802.11: use net80211 IEEE80211_HTCAP_* definitions

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/14 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=537b2e7d48cab6a5eb8dcb0d1474ecee72e95b93

commit 537b2e7d48cab6a5eb8dcb0d1474ecee72e95b93
Author: Bjoern A. Zeeb 
AuthorDate: 2024-06-07 23:57:04 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 13:59:28 +

LinuxKPI: 802.11: use net80211 IEEE80211_HTCAP_* definitions

Rather than using the values and leaving net80211 names in a comment
define the LinuxKPI IEEE80211_HT_CAP_* to the net80211 IEEE80211_HTCAP_*
names.  That way errors like the one fixed in 3e0915b7b685 are less
likely to happen.

Sponsored by:   The FreeBSD Foundation

(cherry picked from commit 63a327b954a38ecd46934a2911321f3ea3d500b3)
---
 .../linuxkpi/common/include/linux/ieee80211.h  | 26 +++---
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/ieee80211.h 
b/sys/compat/linuxkpi/common/include/linux/ieee80211.h
index 0fd90e921c77..aa1a0a4f3c5f 100644
--- a/sys/compat/linuxkpi/common/include/linux/ieee80211.h
+++ b/sys/compat/linuxkpi/common/include/linux/ieee80211.h
@@ -254,20 +254,20 @@ enum ieee80211_ac_numbers {
 #defineIEEE80211_WMM_IE_STA_QOSINFO_SP_ALL 0xf
 
 
-/* XXX net80211 calls these IEEE80211_HTCAP_* */
-#defineIEEE80211_HT_CAP_LDPC_CODING0x0001  /* 
IEEE80211_HTCAP_LDPC */
-#defineIEEE80211_HT_CAP_SUP_WIDTH_20_400x0002  /* 
IEEE80211_HTCAP_CHWIDTH40 */
-#defineIEEE80211_HT_CAP_SM_PS  0x000c  /* 
IEEE80211_HTCAP_SMPS */
+/* Define the LinuxKPI names directly to the net80211 ones. */
+#defineIEEE80211_HT_CAP_LDPC_CODINGIEEE80211_HTCAP_LDPC
+#defineIEEE80211_HT_CAP_SUP_WIDTH_20_40
IEEE80211_HTCAP_CHWIDTH40
+#defineIEEE80211_HT_CAP_SM_PS  IEEE80211_HTCAP_SMPS
 #defineIEEE80211_HT_CAP_SM_PS_SHIFT2
-#defineIEEE80211_HT_CAP_GRN_FLD0x0010  /* 
IEEE80211_HTCAP_GREENFIELD */
-#defineIEEE80211_HT_CAP_SGI_20 0x0020  /* 
IEEE80211_HTCAP_SHORTGI20 */
-#defineIEEE80211_HT_CAP_SGI_40 0x0040  /* 
IEEE80211_HTCAP_SHORTGI40 */
-#defineIEEE80211_HT_CAP_TX_STBC0x0080  /* 
IEEE80211_HTCAP_TXSTBC */
-#defineIEEE80211_HT_CAP_RX_STBC0x0300  /* 
IEEE80211_HTCAP_RXSTBC */
-#defineIEEE80211_HT_CAP_RX_STBC_SHIFT  8   /* 
IEEE80211_HTCAP_RXSTBC_S */
-#defineIEEE80211_HT_CAP_MAX_AMSDU  0x0800  /* 
IEEE80211_HTCAP_MAXAMSDU */
-#defineIEEE80211_HT_CAP_DSSSCCK40  0x1000  /* 
IEEE80211_HTCAP_DSSSCCK40 */
-#defineIEEE80211_HT_CAP_LSIG_TXOP_PROT 0x8000  /* 
IEEE80211_HTCAP_LSIGTXOPPROT */
+#defineIEEE80211_HT_CAP_GRN_FLD
IEEE80211_HTCAP_GREENFIELD
+#defineIEEE80211_HT_CAP_SGI_20 
IEEE80211_HTCAP_SHORTGI20
+#defineIEEE80211_HT_CAP_SGI_40 
IEEE80211_HTCAP_SHORTGI40
+#defineIEEE80211_HT_CAP_TX_STBCIEEE80211_HTCAP_TXSTBC
+#defineIEEE80211_HT_CAP_RX_STBCIEEE80211_HTCAP_RXSTBC
+#defineIEEE80211_HT_CAP_RX_STBC_SHIFT  IEEE80211_HTCAP_RXSTBC_S
+#defineIEEE80211_HT_CAP_MAX_AMSDU  IEEE80211_HTCAP_MAXAMSDU
+#defineIEEE80211_HT_CAP_DSSSCCK40  
IEEE80211_HTCAP_DSSSCCK40
+#defineIEEE80211_HT_CAP_LSIG_TXOP_PROT 
IEEE80211_HTCAP_LSIGTXOPPROT
 
 #defineIEEE80211_HT_MCS_TX_DEFINED 0x0001
 #defineIEEE80211_HT_MCS_TX_RX_DIFF 0x0002



git: 2ab1b827d49f - stable/14 - LinuxKPI: 802.11: make sure we can send DISASSOC or DEAUTH frames

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/14 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=2ab1b827d49f473e30a91382d2ce03e268af45c5

commit 2ab1b827d49f473e30a91382d2ce03e268af45c5
Author: Bjoern A. Zeeb 
AuthorDate: 2024-06-05 22:54:36 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 13:59:46 +

LinuxKPI: 802.11: make sure we can send DISASSOC or DEAUTH frames

The "Invalid TXQ" error from iwlwifi seems to be triggered by a
frame being sent for a sta which is no longer known to the driver/fw.

While we make sure to trigger the sending of the frame in net80211
early enough (by calling (*iv_newstate)() early on rather than at
the end), TX in LinuxKPI is run in a deferred task.  When we drop the
net80211 ic lock again and re-acquire the LHW lock the packet may not
yet have made it to the driver.
Work around this between the (ic and lhw) locks by making sure
(a) no new packets get queued after we return from (*iv_newstate)(),
and (b) the TX task has run or gets cancelled and we manually push
any remaining packets out (or let lsta_free() clean them up).
The disabled packet queuing now also needs to be re-enabled in
scan_to_auth() in case an lsta is staying in service or gets re-used.

Also make sure that any following lkpi_wake_tx_queues() calls no
longer ignore queues which have not seen a prior dequeue.
This former workaround "feature" (ltxq->seen_dequeue) should be
fully garbage collected in a later change on its own.

Sponsored by:   The FreeBSD Foundation
PR: 274382
Tested by:  emaste, lwhsu, thj, rkoberman at gmail.com
Accepted by:adrian
Differential Revision: https://reviews.freebsd.org/D45508

(cherry picked from commit 886653492945f7e945eb9bdaf5bc2ae26df96236)
---
 sys/compat/linuxkpi/common/src/linux_80211.c | 95 +---
 1 file changed, 86 insertions(+), 9 deletions(-)

diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c 
b/sys/compat/linuxkpi/common/src/linux_80211.c
index 728103778e4e..ca8db481347e 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -146,6 +146,7 @@ const struct cfg80211_ops linuxkpi_mac80211cfgops = {
 static struct lkpi_sta *lkpi_find_lsta_by_ni(struct lkpi_vif *,
 struct ieee80211_node *);
 #endif
+static void lkpi_80211_txq_tx_one(struct lkpi_sta *, struct mbuf *);
 static void lkpi_80211_txq_task(void *, int);
 static void lkpi_80211_lhw_rxq_task(void *, int);
 static void lkpi_ieee80211_free_skb_mbuf(void *);
@@ -1062,6 +1063,51 @@ lkpi_wake_tx_queues(struct ieee80211_hw *hw, struct 
ieee80211_sta *sta,
}
 }
 
+/*
+ * On the way down from RUN -> ASSOC -> AUTH we may send a DISASSOC or DEAUTH
+ * packet.  The problem is that the state machine functions tend to hold the
+ * LHW lock which will prevent lkpi_80211_txq_tx_one() from sending the packet.
+ * We call this after dropping the ic lock and before acquiring the LHW lock.
+ * we make sure no further packets are queued and if they are queued the task
+ * will finish or be cancelled.  At the end if a packet is left we manually
+ * send it.  scan_to_auth() would re-enable sending if the lsta would be
+ * re-used.
+ */
+static void
+lkpi_80211_flush_tx(struct lkpi_hw *lhw, struct lkpi_sta *lsta)
+{
+   struct mbufq mq;
+   struct mbuf *m;
+   int len;
+
+   LKPI_80211_LHW_UNLOCK_ASSERT(lhw);
+
+   /* Do not accept any new packets until scan_to_auth or lsta_free(). */
+   LKPI_80211_LSTA_TXQ_LOCK(lsta);
+   lsta->txq_ready = false;
+   LKPI_80211_LSTA_TXQ_UNLOCK(lsta);
+
+   while (taskqueue_cancel(taskqueue_thread, &lsta->txq_task, NULL) != 0)
+   taskqueue_drain(taskqueue_thread, &lsta->txq_task);
+
+   LKPI_80211_LSTA_TXQ_LOCK(lsta);
+   len = mbufq_len(&lsta->txq);
+   if (len <= 0) {
+   LKPI_80211_LSTA_TXQ_UNLOCK(lsta);
+   return;
+   }
+
+   mbufq_init(&mq, IFQ_MAXLEN);
+   mbufq_concat(&mq, &lsta->txq);
+   LKPI_80211_LSTA_TXQ_UNLOCK(lsta);
+
+   m = mbufq_dequeue(&mq);
+   while (m != NULL) {
+   lkpi_80211_txq_tx_one(lsta, m);
+   m = mbufq_dequeue(&mq);
+   }
+}
+
 /* -- 
*/
 
 static int
@@ -1275,6 +1321,14 @@ lkpi_sta_scan_to_auth(struct ieee80211vap *vap, enum 
ieee80211_state nstate, int
__func__, ni, ni->ni_drv_data));
lsta = ni->ni_drv_data;
 
+   /*
+* Make sure in case the sta did not change and we re-add it,
+* that we can tx again.
+*/
+   LKPI_80211_LSTA_TXQ_LOCK(lsta);
+   lsta->txq_ready = true;
+   LKPI_80211_LSTA_TXQ_UNLOCK(lsta);
+
LKPI_80211_LVIF_LOCK(lvif);
/* Insert the [l]sta into the list of known stations. */
TAILQ_INSERT_TAIL(&lvif->lsta_head, lsta, lsta_entr

git: 8a9f0fa42b1c - main - ifconfig: Fix default netmask calculation

2024-06-12 Thread Michael Gmelin
The branch main has been updated by grembo:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=8a9f0fa42b1c6cffd45459bb552e138083b00369

commit 8a9f0fa42b1c6cffd45459bb552e138083b00369
Author: Michael Gmelin 
AuthorDate: 2024-06-12 16:11:52 +
Commit: Michael Gmelin 
CommitDate: 2024-06-12 18:10:13 +

ifconfig: Fix default netmask calculation

Reported by:phk
Reviewed by:emaste, kp
MFC after:  3 days
Differential Revision:  https://reviews.freebsd.org/D45570
---
 sbin/ifconfig/af_inet.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sbin/ifconfig/af_inet.c b/sbin/ifconfig/af_inet.c
index 5e3084165b33..e21956cfc4fd 100644
--- a/sbin/ifconfig/af_inet.c
+++ b/sbin/ifconfig/af_inet.c
@@ -440,7 +440,7 @@ in_exec_nl(if_ctx *ctx, unsigned long action, void *data)
 static void
 in_setdefaultmask_nl(void)
 {
-struct in_px *px = sintab_nl[ADDR];
+   struct in_px *px = sintab_nl[ADDR];
 
in_addr_t i = ntohl(px->addr.s_addr);
 
@@ -451,11 +451,11 @@ in_setdefaultmask_nl(void)
 * we should return an error rather than warning.
 */
if (IN_CLASSA(i))
-   px->plen = IN_CLASSA_NSHIFT;
+   px->plen = 32 - IN_CLASSA_NSHIFT;
else if (IN_CLASSB(i))
-   px->plen = IN_CLASSB_NSHIFT;
+   px->plen = 32 - IN_CLASSB_NSHIFT;
else
-   px->plen = IN_CLASSC_NSHIFT;
+   px->plen = 32 - IN_CLASSC_NSHIFT;
px->maskset = true;
 }
 #endif



git: 4cb9d580269b - stable/13 - bsdinstall: update comment related to pkg

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/13 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=4cb9d580269b866a6fbf69826efcd156be538826

commit 4cb9d580269b866a6fbf69826efcd156be538826
Author: Bjoern A. Zeeb 
AuthorDate: 2024-04-25 14:47:30 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 16:56:20 +

bsdinstall: update comment related to pkg

pkg_add has been gone since 2013(?).  Refer to pkg(8) instead.

Sponsored by:   The FreeBSD Foundation
Reviewed by:jrtc27
Differential Revision: https://reviews.freebsd.org/D44946

(cherry picked from commit ad31d4764255c0848f1f0fa10760d16b5a2922aa)
---
 usr.sbin/bsdinstall/scripts/docsinstall | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/usr.sbin/bsdinstall/scripts/docsinstall 
b/usr.sbin/bsdinstall/scripts/docsinstall
index 92d1743b5ddc..77d311c9ca16 100755
--- a/usr.sbin/bsdinstall/scripts/docsinstall
+++ b/usr.sbin/bsdinstall/scripts/docsinstall
@@ -148,7 +148,7 @@ f_mustberoot_init
 dialog_menu_main || f_die
 f_dialog_menutag_fetch selected
 
-# Let pkg_add be able to use name servers
+# Let pkg(8) be able to use name servers
 f_quietly cp -f $BSDINSTALL_TMPETC/resolv.conf $BSDINSTALL_CHROOT/etc/
 
 #



git: 8e64a7ec0b5d - stable/13 - net80211: amrr_init: change order of commands

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/13 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=8e64a7ec0b5d8a9b788ec36e9a17d896f7ebcd59

commit 8e64a7ec0b5d8a9b788ec36e9a17d896f7ebcd59
Author: Bjoern A. Zeeb 
AuthorDate: 2024-02-05 14:48:08 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 16:56:26 +

net80211: amrr_init: change order of commands

First run the KASSERT before trying to do the free operation.
Better for reporting and debugging.
Add a guard setting the value to NULL afterwards.  NULL pointers
are a lot easier to test for.

Reviewed by:cc
Differential Revision: https://reviews.freebsd.org/D43751

(cherry picked from commit cd9fee3d2c370e81109505c2abfd381af952e9b3)
---
 sys/net80211/ieee80211_amrr.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/net80211/ieee80211_amrr.c b/sys/net80211/ieee80211_amrr.c
index 7248af0edccf..461554d75ea1 100644
--- a/sys/net80211/ieee80211_amrr.c
+++ b/sys/net80211/ieee80211_amrr.c
@@ -132,8 +132,9 @@ amrr_init(struct ieee80211vap *vap)
 static void
 amrr_deinit(struct ieee80211vap *vap)
 {
-   IEEE80211_FREE(vap->iv_rs, M_80211_RATECTL);
KASSERT(nrefs > 0, ("imbalanced attach/detach"));
+   IEEE80211_FREE(vap->iv_rs, M_80211_RATECTL);
+   vap->iv_rs = NULL;  /* guard */
nrefs--;/* XXX locking */
 }
 



git: 7ced40667656 - stable/13 - net80211: fix IEEE80211_FHT_BITS

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/13 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=7ced406676562da38b5c2ae1f5cd5ba90fc5e012

commit 7ced406676562da38b5c2ae1f5cd5ba90fc5e012
Author: Bjoern A. Zeeb 
AuthorDate: 2024-05-31 21:48:49 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 16:56:36 +

net80211: fix IEEE80211_FHT_BITS

AMPDU_RX was added as a second AMPDU_TX, LDPC_TX and LDPC_RX missing;
correct and add missing.
Makes ddb output (and other debugging) look more correct.

Sponsored by:   The FreeBSD Foundation
Reviewed by:adrian
Differential Revision: https://reviews.freebsd.org/D45505

(cherry picked from commit 5bbf4b6291863452acfb5a7fc76f227848841cac)
---
 sys/net80211/ieee80211_var.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/net80211/ieee80211_var.h b/sys/net80211/ieee80211_var.h
index aa99ccefd248..393c703c29df 100644
--- a/sys/net80211/ieee80211_var.h
+++ b/sys/net80211/ieee80211_var.h
@@ -722,7 +722,7 @@ MALLOC_DECLARE(M_80211_VAP);
 
 #defineIEEE80211_FHT_BITS \
"\20\1NONHT_PR" \
-   "\23GF\24HT\25AMPDU_TX\26AMPDU_TX" \
+   "\21LDPC_TX\22LDPC_RX\23GF\24HT\25AMPDU_TX\26AMPDU_RX" \
"\27AMSDU_TX\30AMSDU_RX\31USEHT40\32PUREN\33SHORTGI20\34SHORTGI40" \
"\35HTCOMPAT\36RIFS\37STBC_TX\40STBC_RX"
 



git: 999d1558b1d8 - stable/13 - iwn(4): correct debug message: "not" to "no"

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/13 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=999d1558b1d831038b257de49a1f77178c962086

commit 999d1558b1d831038b257de49a1f77178c962086
Author: Bjoern A. Zeeb 
AuthorDate: 2024-06-05 22:01:06 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 16:56:43 +

iwn(4): correct debug message: "not" to "no"

Sponosred by:   The FreeBSD Foundation

(cherry picked from commit 9e012a9da5df131b64c2dfd7d9b6645af4ccef0f)
---
 sys/dev/iwn/if_iwn.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/dev/iwn/if_iwn.c b/sys/dev/iwn/if_iwn.c
index 2cbde90782be..4091bf135ae1 100644
--- a/sys/dev/iwn/if_iwn.c
+++ b/sys/dev/iwn/if_iwn.c
@@ -7520,7 +7520,7 @@ iwn_addba_request(struct ieee80211_node *ni, struct 
ieee80211_tx_ampdu *tap,
break;
}
if (qid == sc->ntxqs) {
-   DPRINTF(sc, IWN_DEBUG_XMIT, "%s: not free aggregation queue\n",
+   DPRINTF(sc, IWN_DEBUG_XMIT, "%s: no free aggregation queue\n",
__func__);
return 0;
}



git: 98cf07160021 - stable/13 - LinuxKPI: add PCI_VENDOR_ID_ITTIM

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/13 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=98cf071600217600d33a033063e71f41553dc6e2

commit 98cf071600217600d33a033063e71f41553dc6e2
Author: Bjoern A. Zeeb 
AuthorDate: 2024-04-02 09:40:42 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 16:56:48 +

LinuxKPI: add PCI_VENDOR_ID_ITTIM

Add PCI_VENDOR_ID_ITTIM as needed by mt76.

Sponsored by:   The FreeBSD Foundation

(cherry picked from commit ce707e674f7941c0743e72193c433fcf554a82b5)
---
 sys/compat/linuxkpi/common/include/linux/pci_ids.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sys/compat/linuxkpi/common/include/linux/pci_ids.h 
b/sys/compat/linuxkpi/common/include/linux/pci_ids.h
index f23cd7d6a124..b52ecc525db6 100644
--- a/sys/compat/linuxkpi/common/include/linux/pci_ids.h
+++ b/sys/compat/linuxkpi/common/include/linux/pci_ids.h
@@ -51,6 +51,7 @@
 #definePCI_VENDOR_ID_HP0x103c
 #definePCI_VENDOR_ID_IBM   0x1014
 #definePCI_VENDOR_ID_INTEL 0x8086
+#definePCI_VENDOR_ID_ITTIM 0x0b48
 #definePCI_VENDOR_ID_MEDIATEK  0x14c3
 #definePCI_VENDOR_ID_MELLANOX  0x15b3
 #definePCI_VENDOR_ID_QCOM  0x17cb



git: f1146027f1d9 - stable/13 - LinuxKPI: add further constants to pci.h

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/13 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=f1146027f1d9c476e53e1ef9afb0e5f9d3bf41c0

commit f1146027f1d9c476e53e1ef9afb0e5f9d3bf41c0
Author: Bjoern A. Zeeb 
AuthorDate: 2024-03-31 17:26:29 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 16:56:53 +

LinuxKPI: add further constants to pci.h

Updated wireless drivers require more knowledge about PCI (BAR) bits.

Sponsored by:   The FreeBSD Foundation
Reviewed by:jhb
Differential Revision: https://reviews.freebsd.org/D44573

(cherry picked from commit a1cdddcf1596d258ce0b01b156dfd9921bd60e08)
---
 sys/compat/linuxkpi/common/include/linux/pci.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h 
b/sys/compat/linuxkpi/common/include/linux/pci.h
index d8ab851435f5..5e859e1a65c5 100644
--- a/sys/compat/linuxkpi/common/include/linux/pci.h
+++ b/sys/compat/linuxkpi/common/include/linux/pci.h
@@ -107,6 +107,8 @@ 
MODULE_PNP_INFO("U32:vendor;U32:device;V32:subvendor;V32:subdevice",\
 #defineto_pci_dev(n)   container_of(n, struct pci_dev, dev)
 
 #definePCI_STD_NUM_BARS6
+#definePCI_BASE_ADDRESS_0  PCIR_BARS
+#definePCI_BASE_ADDRESS_MEM_TYPE_64PCIM_BAR_MEM_64
 #definePCI_VENDOR_ID   PCIR_VENDOR
 #definePCI_DEVICE_ID   PCIR_DEVICE
 #definePCI_COMMAND PCIR_COMMAND



git: 25878310adcb - stable/13 - LinuxKPI: implement memzero_explicit()

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/13 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=25878310adcbb361b31bc89b34f744c0c5a29bb1

commit 25878310adcbb361b31bc89b34f744c0c5a29bb1
Author: Bjoern A. Zeeb 
AuthorDate: 2024-04-02 09:30:49 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 16:57:01 +

LinuxKPI: implement memzero_explicit()

Sponsored by:   The FreeBSD Foundation
Reviewed by:emaste
Differential Revision: https://reviews.freebsd.org/D44586

(cherry picked from commit 218b2ccf8cc90698487515c681f3e3453b0dcead)
---
 sys/compat/linuxkpi/common/include/linux/string.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/sys/compat/linuxkpi/common/include/linux/string.h 
b/sys/compat/linuxkpi/common/include/linux/string.h
index f745c2f6d343..06dcdbd97663 100644
--- a/sys/compat/linuxkpi/common/include/linux/string.h
+++ b/sys/compat/linuxkpi/common/include/linux/string.h
@@ -273,4 +273,11 @@ memcpy_and_pad(void *dst, size_t dstlen, const void *src, 
size_t len, int ch)
memset(_ptr + _o, _c, sizeof(*(ptr)) - _o); \
 })
 
+static inline void
+memzero_explicit(void *p, size_t s)
+{
+   memset(p, 0, s);
+   __asm__ __volatile__("": :"r"(p) :"memory");
+}
+
 #endif /* _LINUXKPI_LINUX_STRING_H_ */



git: 8d796198774d - stable/13 - LinuxKPI: add BITS_TO_BYTES()

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/13 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=8d796198774d0908f7a1328fa7257b37ed665a35

commit 8d796198774d0908f7a1328fa7257b37ed665a35
Author: Bjoern A. Zeeb 
AuthorDate: 2024-04-02 23:48:05 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 16:57:06 +

LinuxKPI: add BITS_TO_BYTES()

Just like BITS_TO_LONG() ... used in rtw89.

Sponsored by:   The FreeBSD Foundation
Reviewed by:emaste
Differential Revision: https://reviews.freebsd.org/D44603

(cherry picked from commit f674f016c03d49e14f1c651ed088a6f2d01a62ee)
---
 sys/compat/linuxkpi/common/include/linux/bitops.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sys/compat/linuxkpi/common/include/linux/bitops.h 
b/sys/compat/linuxkpi/common/include/linux/bitops.h
index 58677631b604..1415d5224084 100644
--- a/sys/compat/linuxkpi/common/include/linux/bitops.h
+++ b/sys/compat/linuxkpi/common/include/linux/bitops.h
@@ -54,6 +54,7 @@
 #defineGENMASK_ULL(h, l)   (((~0ULL) >> (BITS_PER_LONG_LONG - (h) 
- 1)) & ((~0ULL) << (l)))
 #defineBITS_PER_BYTE   8
 #defineBITS_PER_TYPE(t)(sizeof(t) * BITS_PER_BYTE)
+#defineBITS_TO_BYTES(n)howmany((n), BITS_PER_BYTE)
 
 #definehweight8(x) bitcount((uint8_t)(x))
 #definehweight16(x)bitcount16(x)



git: 425edb6fc2d5 - stable/13 - LinuxKPI: sk_buff: implement skb_queue_splice_tail_init()

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/13 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=425edb6fc2d5e1fcc38e8e194639980d1115b511

commit 425edb6fc2d5e1fcc38e8e194639980d1115b511
Author: Bjoern A. Zeeb 
AuthorDate: 2024-04-02 09:17:31 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 16:57:25 +

LinuxKPI: sk_buff: implement skb_queue_splice_tail_init()

Implement skb_queue_splice_tail_init() and SKB_DATA_ALIGN() as
needed by the mt76 wireless driver.

Sponsord by:The FreeBD Foundation
Reviewed by:emaste
Differential Revision: https://reviews.freebsd.org/D44590

(cherry picked from commit 3d3ec17825a124f0119d76c4d2523d73012fa226)
---
 sys/compat/linuxkpi/common/include/linux/skbuff.h | 19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/skbuff.h 
b/sys/compat/linuxkpi/common/include/linux/skbuff.h
index 02190a29e241..ee3f427aa6e9 100644
--- a/sys/compat/linuxkpi/common/include/linux/skbuff.h
+++ b/sys/compat/linuxkpi/common/include/linux/skbuff.h
@@ -89,6 +89,7 @@ struct skb_shared_hwtstamps {
 };
 
 #defineNET_SKB_PAD max(CACHE_LINE_SIZE, 32)
+#defineSKB_DATA_ALIGN(_x)  roundup2(_x, CACHE_LINE_SIZE)
 
 struct sk_buff_head {
/* XXX TODO */
@@ -824,7 +825,7 @@ skb_mark_not_on_list(struct sk_buff *skb)
 }
 
 static inline void
-___skb_queue_splice_init(const struct sk_buff_head *from,
+___skb_queue_splice(const struct sk_buff_head *from,
 struct sk_buff *p, struct sk_buff *n)
 {
struct sk_buff *b, *e;
@@ -847,7 +848,21 @@ skb_queue_splice_init(struct sk_buff_head *from, struct 
sk_buff_head *to)
if (skb_queue_empty(from))
return;
 
-   ___skb_queue_splice_init(from, (struct sk_buff *)to, to->next);
+   ___skb_queue_splice(from, (struct sk_buff *)to, to->next);
+   to->qlen += from->qlen;
+   __skb_queue_head_init(from);
+}
+
+static inline void
+skb_queue_splice_tail_init(struct sk_buff_head *from, struct sk_buff_head *to)
+{
+
+   SKB_TRACE2(from, to);
+
+   if (skb_queue_empty(from))
+   return;
+
+   ___skb_queue_splice(from, to->prev, (struct sk_buff *)to);
to->qlen += from->qlen;
__skb_queue_head_init(from);
 }



git: d5edaf3cf216 - stable/13 - LinuxKPI: add dev_alloc_pages()

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/13 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=d5edaf3cf216c5e682a8664e5abb4fc5a01e3fdf

commit d5edaf3cf216c5e682a8664e5abb4fc5a01e3fdf
Author: Bjoern A. Zeeb 
AuthorDate: 2024-04-02 09:44:29 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 16:57:13 +

LinuxKPI: add dev_alloc_pages()

Add dev_alloc_pages() though it seems a weird KPI, not passing a dev
despite its name.  Used by updated wireless driver.

Sponsored by:   The FreeBSD Foundation
Reviewed by:emaste
Differential Revision: https://reviews.freebsd.org/D44588

(cherry picked from commit 738c02ba24c66391870067602f1c9c030d5c5e5d)
---
 sys/compat/linuxkpi/common/include/linux/gfp.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/sys/compat/linuxkpi/common/include/linux/gfp.h 
b/sys/compat/linuxkpi/common/include/linux/gfp.h
index c5de09e896de..2fcc0dc05f29 100644
--- a/sys/compat/linuxkpi/common/include/linux/gfp.h
+++ b/sys/compat/linuxkpi/common/include/linux/gfp.h
@@ -138,6 +138,12 @@ __free_page(struct page *page)
linux_free_pages(page, 0);
 }
 
+static inline struct page *
+dev_alloc_pages(unsigned int order)
+{
+   return (linux_alloc_pages(GFP_ATOMIC, order));
+}
+
 /*
  * Page management for mapped pages:
  */



git: 4d9e8a65d031 - stable/13 - LinuxKPI: napi_schedule() requires return value, implement napi_is_scheduled()

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/13 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=4d9e8a65d0318efbd3bc6b427c1580cd3c8200a4

commit 4d9e8a65d0318efbd3bc6b427c1580cd3c8200a4
Author: Bjoern A. Zeeb 
AuthorDate: 2024-03-31 17:27:45 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 16:57:33 +

LinuxKPI: napi_schedule() requires return value, implement 
napi_is_scheduled()

A newer version of iwlwifi requires a return value from napi_schedule();
unclear if the function always should have been bool. Add the bool to test
based on the napi_schedule_prep() result.

Also add napi_is_scheduled() for rtw89.

Sponsored by:   The FreeBSD Foundation
Reviewed by:emaste (previous version)
Differential Revision:  https://reviews.freebsd.org/D44591

(cherry picked from commit 21761f2ede4ebad13e78112b9409c1f20f946781)
---
 sys/compat/linuxkpi/common/include/linux/netdevice.h | 9 -
 sys/compat/linuxkpi/common/src/linux_netdev.c| 8 ++--
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/netdevice.h 
b/sys/compat/linuxkpi/common/include/linux/netdevice.h
index 02734585bf63..12ff307b3ce4 100644
--- a/sys/compat/linuxkpi/common/include/linux/netdevice.h
+++ b/sys/compat/linuxkpi/common/include/linux/netdevice.h
@@ -233,7 +233,7 @@ void linuxkpi_netif_napi_add(struct net_device *, struct 
napi_struct *,
 void linuxkpi_netif_napi_del(struct napi_struct *);
 bool linuxkpi_napi_schedule_prep(struct napi_struct *);
 void linuxkpi___napi_schedule(struct napi_struct *);
-void linuxkpi_napi_schedule(struct napi_struct *);
+bool linuxkpi_napi_schedule(struct napi_struct *);
 void linuxkpi_napi_reschedule(struct napi_struct *);
 bool linuxkpi_napi_complete_done(struct napi_struct *, int);
 bool linuxkpi_napi_complete(struct napi_struct *);
@@ -275,6 +275,13 @@ netif_napi_add_tx(struct net_device *dev, struct 
napi_struct *napi,
netif_napi_add(dev, napi, napi_poll);
 }
 
+static inline bool
+napi_is_scheduled(struct napi_struct *napi)
+{
+
+   return (test_bit(LKPI_NAPI_FLAG_IS_SCHEDULED, &napi->state));
+}
+
 /* -- 
*/
 
 static inline void
diff --git a/sys/compat/linuxkpi/common/src/linux_netdev.c 
b/sys/compat/linuxkpi/common/src/linux_netdev.c
index 61ebcdbf7a39..61342395f03c 100644
--- a/sys/compat/linuxkpi/common/src/linux_netdev.c
+++ b/sys/compat/linuxkpi/common/src/linux_netdev.c
@@ -185,7 +185,7 @@ linuxkpi___napi_schedule(struct napi_struct *napi)
}
 }
 
-void
+bool
 linuxkpi_napi_schedule(struct napi_struct *napi)
 {
 
@@ -195,8 +195,12 @@ linuxkpi_napi_schedule(struct napi_struct *napi)
 * iwlwifi calls this sequence instead of napi_schedule()
 * to be able to test the prep result.
 */
-   if (napi_schedule_prep(napi))
+   if (napi_schedule_prep(napi)) {
__napi_schedule(napi);
+   return (true);
+   }
+
+   return (false);
 }
 
 void



git: e262be127d20 - stable/13 - LinuxKPI: add devm_kfree()

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/13 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=e262be127d20b193701b1bd127e2f157ace9d2ab

commit e262be127d20b193701b1bd127e2f157ace9d2ab
Author: Bjoern A. Zeeb 
AuthorDate: 2024-04-02 09:45:43 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 16:57:40 +

LinuxKPI: add devm_kfree()

mt76 calls devm_kfree() directly, so alias it to our
lkpi_devm_kmalloc_release() function.

Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D44589

(cherry picked from commit 170c2e0e2bb1b2d9a7661ba729f8264381c9d9d7)
---
 sys/compat/linuxkpi/common/include/linux/device.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sys/compat/linuxkpi/common/include/linux/device.h 
b/sys/compat/linuxkpi/common/include/linux/device.h
index 7742750339d9..c20afda0d209 100644
--- a/sys/compat/linuxkpi/common/include/linux/device.h
+++ b/sys/compat/linuxkpi/common/include/linux/device.h
@@ -257,6 +257,7 @@ int lkpi_devres_destroy(struct device *, 
void(*release)(struct device *, void *)
 void lkpi_devres_release_free_list(struct device *);
 void lkpi_devres_unlink(struct device *, void *);
 void lkpi_devm_kmalloc_release(struct device *, void *);
+#definedevm_kfree(_d, _p)  lkpi_devm_kmalloc_release(_d, 
_p)
 
 static inline const char *
 dev_driver_string(const struct device *dev)



git: 0f87cc98f926 - stable/13 - LinuxKPI: add __counted_by() and __nonstring

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/13 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=0f87cc98f92691957a253b78a5b6fba5f1824ea9

commit 0f87cc98f92691957a253b78a5b6fba5f1824ea9
Author: Bjoern A. Zeeb 
AuthorDate: 2024-04-02 09:41:54 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 16:57:46 +

LinuxKPI: add __counted_by() and __nonstring

Add checks for __counted_by(_x) and __nonstring as and depending
on compiler support enable the attribute/feature.

This is needed to make mtk76 and ath1xk drivers compile.

Sposnored by:   The FreeBSD Foundation
Reviewed by:emaste, dim
Differential Revision: https://reviews.freebsd.org/D44587

(cherry picked from commit 2a8c50592f7fce8bceedf004f674a5a9eae0fd46)
---
 sys/compat/linuxkpi/common/include/linux/compiler.h | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/sys/compat/linuxkpi/common/include/linux/compiler.h 
b/sys/compat/linuxkpi/common/include/linux/compiler.h
index 22300e73652d..94595b2e8c50 100644
--- a/sys/compat/linuxkpi/common/include/linux/compiler.h
+++ b/sys/compat/linuxkpi/common/include/linux/compiler.h
@@ -66,6 +66,17 @@
 #definecacheline_aligned_in_smp__aligned(CACHE_LINE_SIZE)
 #definefallthrough /* FALLTHROUGH */ do { } 
while(0)
 
+#if __has_attribute(__nonstring__)
+#define__nonstring __attribute__((__nonstring__))
+#else
+#define__nonstring
+#endif
+#if __has_attribute(__counted_by__)
+#define__counted_by(_x)
__attribute__((__counted_by__(_x)))
+#else
+#define__counted_by(_x)
+#endif
+
 #definelikely(x)   __builtin_expect(!!(x), 1)
 #defineunlikely(x) __builtin_expect(!!(x), 0)
 #define typeof(x)  __typeof(x)



git: c503386b189f - stable/13 - LinuxKPI: utsname.h add missing SPDX-License-Identifier

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/13 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=c503386b189f2335bf1f4ee1597b6d7af1a87375

commit c503386b189f2335bf1f4ee1597b6d7af1a87375
Author: Bjoern A. Zeeb 
AuthorDate: 2024-04-19 18:23:12 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 16:57:51 +

LinuxKPI: utsname.h add missing SPDX-License-Identifier

Reported by:markj (2023-05-24; sorry took me a while)

(cherry picked from commit 563c72e2137cb8cb9eb0eabf78319e8fe9c8aedd)
---
 sys/compat/linuxkpi/common/include/linux/utsname.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sys/compat/linuxkpi/common/include/linux/utsname.h 
b/sys/compat/linuxkpi/common/include/linux/utsname.h
index e6c52f8a5020..3239801ca17b 100644
--- a/sys/compat/linuxkpi/common/include/linux/utsname.h
+++ b/sys/compat/linuxkpi/common/include/linux/utsname.h
@@ -1,4 +1,6 @@
 /*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
  * Copyright (c) 2023 Bjoern A. Zeeb
  *
  * Redistribution and use in source and binary forms, with or without



git: 395833f4ea8f - stable/13 - LinuxKPI: add kvmemdup()

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/13 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=395833f4ea8f4852f47ca1473baf99239331379e

commit 395833f4ea8f4852f47ca1473baf99239331379e
Author: Bjoern A. Zeeb 
AuthorDate: 2024-05-13 17:43:25 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 16:57:56 +

LinuxKPI: add kvmemdup()

Add kvmemdup() as a variant of kmemdup().  While currently it could
just call kmemdup() we duplicate the code and use kvmalloc() in case
someone will change the implementation of kvmalloc/kvfree in slab.h.
This is used by an updated wireless driver.

Sponsored by:   The FreeBSD Foundation
Reviewed by:emaste
Differential Revision: https://reviews.freebsd.org/D45181

(cherry picked from commit 8e4b8e9d807aa379d2a1c3aaac2537ba7d6bf0bf)
---
 sys/compat/linuxkpi/common/include/linux/string.h | 12 
 1 file changed, 12 insertions(+)

diff --git a/sys/compat/linuxkpi/common/include/linux/string.h 
b/sys/compat/linuxkpi/common/include/linux/string.h
index 06dcdbd97663..9302c95e8636 100644
--- a/sys/compat/linuxkpi/common/include/linux/string.h
+++ b/sys/compat/linuxkpi/common/include/linux/string.h
@@ -97,6 +97,18 @@ kmemdup(const void *src, size_t len, gfp_t gfp)
return (dst);
 }
 
+/* See slab.h for kvmalloc/kvfree(). */
+static inline void *
+kvmemdup(const void *src, size_t len, gfp_t gfp)
+{
+   void *dst;
+
+   dst = kvmalloc(len, gfp);
+   if (dst != NULL)
+   memcpy(dst, src, len);
+   return (dst);
+}
+
 static inline char *
 strndup_user(const char __user *ustr, long n)
 {



git: 33929383594a - stable/13 - LinuxKPI: add FIELD_PREP_CONST()

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/13 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=33929383594abc079f8269e2837b49f265260909

commit 33929383594abc079f8269e2837b49f265260909
Author: Bjoern A. Zeeb 
AuthorDate: 2024-05-13 17:40:26 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 16:58:01 +

LinuxKPI: add FIELD_PREP_CONST()

Add FIELD_PREP_CONST() like FIELD_PREP() without any extra checks likely
expected on this version in Linux.  This is called by an updated wireless
driver.

Sposnored by:   The FreeBSD Foundation
Reviewed by:emaste
Differential Revision: https://reviews.freebsd.org/D45180

(cherry picked from commit bb025df257386c5d1087b652e8ed951bceb89862)
---
 sys/compat/linuxkpi/common/include/linux/bitfield.h | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/bitfield.h 
b/sys/compat/linuxkpi/common/include/linux/bitfield.h
index a2020d247489..8a91b0663f37 100644
--- a/sys/compat/linuxkpi/common/include/linux/bitfield.h
+++ b/sys/compat/linuxkpi/common/include/linux/bitfield.h
@@ -1,7 +1,7 @@
 /*-
  * SPDX-License-Identifier: BSD-2-Clause
  *
- * Copyright (c) 2020 The FreeBSD Foundation
+ * Copyright (c) 2020-2024 The FreeBSD Foundation
  *
  * This software was developed by Björn Zeeb under sponsorship from
  * the FreeBSD Foundation.
@@ -131,6 +131,10 @@ _uX_replace_bits(8)
 #defineFIELD_PREP(_mask, _value)   
\
(((typeof(_mask))(_value) << __bf_shf(_mask)) & (_mask))
 
+/* Likely would need extra sanity checks compared to FIELD_PREP()? */
+#defineFIELD_PREP_CONST(_mask, _value) 
\
+   (((typeof(_mask))(_value) << __bf_shf(_mask)) & (_mask))
+
 #defineFIELD_GET(_mask, _value)
\
((typeof(_mask))(((_value) & (_mask)) >> __bf_shf(_mask)))
 



git: 323d4a20bd20 - stable/13 - LinuxKPI: remove extern from function declarations

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/13 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=323d4a20bd202463b2da29b7d7d1957671c66619

commit 323d4a20bd202463b2da29b7d7d1957671c66619
Author: Bjoern A. Zeeb 
AuthorDate: 2024-05-27 19:49:45 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 16:58:06 +

LinuxKPI: remove extern from function declarations

Sponsored by:   The FreeBSD Foundation
Reviewed by:emaste (earlier version, found another two)
Differential Revision: https://reviews.freebsd.org/D45386

(cherry picked from commit ecd1d1f1dac49c7ecbf1e7c5ffc64356c2851efd)
---
 sys/compat/linuxkpi/common/include/linux/gfp.h | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/gfp.h 
b/sys/compat/linuxkpi/common/include/linux/gfp.h
index 2fcc0dc05f29..e5dd2e44b0fa 100644
--- a/sys/compat/linuxkpi/common/include/linux/gfp.h
+++ b/sys/compat/linuxkpi/common/include/linux/gfp.h
@@ -90,15 +90,15 @@ struct page_frag_cache {
  *
  * NOTE: This function only works for pages allocated by the kernel.
  */
-extern void *linux_page_address(struct page *);
+void *linux_page_address(struct page *);
 
 #definepage_address(page) linux_page_address(page)
 
 /*
  * Page management for unmapped pages:
  */
-extern struct page *linux_alloc_pages(gfp_t flags, unsigned int order);
-extern void linux_free_pages(struct page *page, unsigned int order);
+struct page *linux_alloc_pages(gfp_t flags, unsigned int order);
+void linux_free_pages(struct page *page, unsigned int order);
 void *linuxkpi_page_frag_alloc(struct page_frag_cache *, size_t, gfp_t);
 void linuxkpi_page_frag_free(void *);
 void linuxkpi__page_frag_cache_drain(struct page *, size_t);
@@ -147,8 +147,8 @@ dev_alloc_pages(unsigned int order)
 /*
  * Page management for mapped pages:
  */
-extern vm_offset_t linux_alloc_kmem(gfp_t flags, unsigned int order);
-extern void linux_free_kmem(vm_offset_t, unsigned int order);
+vm_offset_t linux_alloc_kmem(gfp_t flags, unsigned int order);
+void linux_free_kmem(vm_offset_t, unsigned int order);
 
 static inline vm_offset_t
 get_zeroed_page(gfp_t flags)



git: 947dfe1e01f3 - stable/13 - LinuxKPI: pm: add SET_SYSTEM_SLEEP_PM_OPS() and device_can_wakeup()

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/13 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=947dfe1e01f31819b2a37c1400731ac367bacebe

commit 947dfe1e01f31819b2a37c1400731ac367bacebe
Author: Bjoern A. Zeeb 
AuthorDate: 2024-04-06 21:15:16 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 16:58:11 +

LinuxKPI: pm: add SET_SYSTEM_SLEEP_PM_OPS() and device_can_wakeup()

Add the SET_SYSTEM_SLEEP_PM_OPS() by factoring some other macro code
out in order to set the suspend/resume functions when the struct is
already given.  Such is the case in iwlwifi d3.

Also add an initial implementation of device_can_wakeup().  Though
this is likely all we need we have no way of setting the flag for it
yet so leave a pr_debug() and a comment there as well.  Until we want
to support WoWLAN this is likely not needed for wireless.
Doing it the proper way checking a bool in 'struct dev_pm_info' would
change 'struct device' and with that 'struct pci_dev' and break the
KBI.  In favour of mergeability this version does not implement the
full functionality yet.

Both help to make an updated iwlwifi d3 compile.

Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45358

(cherry picked from commit 3753988c5d22393fbdefb6aa16b5a5a699d05642)
---
 sys/compat/linuxkpi/common/include/linux/pm.h | 30 +++
 sys/compat/linuxkpi/common/src/linux_compat.c | 18 
 2 files changed, 35 insertions(+), 13 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/pm.h 
b/sys/compat/linuxkpi/common/include/linux/pm.h
index 53be7399579d..79e1ed8ba1c6 100644
--- a/sys/compat/linuxkpi/common/include/linux/pm.h
+++ b/sys/compat/linuxkpi/common/include/linux/pm.h
@@ -1,7 +1,7 @@
 /*-
  * SPDX-License-Identifier: BSD-2-Clause
  *
- * Copyright (c) 2020 The FreeBSD Foundation
+ * Copyright (c) 2020-2024 The FreeBSD Foundation
  *
  * This software was developed by Björn Zeeb under sponsorship from
  * the FreeBSD Foundation.
@@ -54,25 +54,26 @@ struct dev_pm_domain {
 IS_ENABLED(CONFIG_PM_SLEEP) ? (_p) : NULL
 
 #ifdef CONFIG_PM_SLEEP
+#define__SET_PM_OPS(_suspendfunc, _resumefunc) \
+   .suspend= _suspendfunc, \
+   .resume = _resumefunc,  \
+   .freeze = _suspendfunc, \
+   .thaw   = _resumefunc,  \
+   .poweroff   = _suspendfunc, \
+   .restore= _resumefunc,  \
+
 #defineSIMPLE_DEV_PM_OPS(_name, _suspendfunc, _resumefunc) \
 const struct dev_pm_ops _name = {  \
-   .suspend= _suspendfunc, \
-   .resume = _resumefunc,  \
-   .freeze = _suspendfunc, \
-   .thaw   = _resumefunc,  \
-   .poweroff   = _suspendfunc, \
-   .restore= _resumefunc,  \
+   __SET_PM_OPS(_suspendfunc, _resumefunc) \
 }
 
 #defineDEFINE_SIMPLE_DEV_PM_OPS(_name, _suspendfunc, _resumefunc) \
 const struct dev_pm_ops _name = {  \
-   .suspend= _suspendfunc, \
-   .resume = _resumefunc,  \
-   .freeze = _suspendfunc, \
-   .thaw   = _resumefunc,  \
-   .poweroff   = _suspendfunc, \
-   .restore= _resumefunc,  \
+   __SET_PM_OPS(_suspendfunc, _resumefunc) \
 }
+
+#defineSET_SYSTEM_SLEEP_PM_OPS(_suspendfunc, _resumefunc)  \
+   __SET_PM_OPS(_suspendfunc, _resumefunc)
 #else
 #defineSIMPLE_DEV_PM_OPS(_name, _suspendfunc, _resumefunc) \
 const struct dev_pm_ops _name = {  \
@@ -82,6 +83,9 @@ const struct dev_pm_ops _name = { 
\
 }
 #endif
 
+bool linuxkpi_device_can_wakeup(struct device *);
+#definedevice_can_wakeup(_dev) linuxkpi_device_can_wakeup(_dev)
+
 static inline void
 pm_wakeup_event(struct device *dev __unused, unsigned int x __unused)
 {
diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c 
b/sys/compat/linuxkpi/common/src/linux_compat.c
index d3804e9ecf05..81127bf364f9 100644
--- a/sys/compat/linuxkpi/common/src/linux_compat.c
+++ b/sys/compat/linuxkpi/common/src/linux_compat.c
@@ -2773,6 +2773,24 @@ io_mapping_create_wc(resource_size_t base, unsigned long 
size)
return (io_mapping_init_wc(mapping, base, size));
 }
 
+/* We likely want a linuxkpi_device.c at some point. */
+bool
+device_can_wakeup(struct device *dev)
+{
+
+   if (dev == NULL)
+   return (false);
+   /*
+* XXX-BZ iwlwifi queries it as part of enabling WoWLAN.
+* Normally this would be based on a bool in dev->powe

git: 7cda20918644 - stable/13 - LinuxKPI: 802.11: return proper value for IEEE80211_CRYPTO_AES_CCM

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/13 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=7cda20918644f283590a5bb348066bdc2bef18b8

commit 7cda20918644f283590a5bb348066bdc2bef18b8
Author: Bjoern A. Zeeb 
AuthorDate: 2024-03-04 23:03:58 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 16:59:35 +

LinuxKPI: 802.11: return proper value for IEEE80211_CRYPTO_AES_CCM

In case of LKPI_80211_HW_CRYPTO we convert from LinuxKPI cipher_suites
to net80211 ic_cryptocaps fields. For WLAN_CIPHER_SUITE_CCMP we
accidentally returned the bit number instead of the shifted value
which leads to ieee80211_crypto_newkey() setting IEEE80211_KEY_SWCRYPT,
which in turned lead to us trying to decode the frame again despite
HW had already done it.  This was found out of a discussion in D43634.

Reviewed by:cc, adrian
Differential Revision: https://reviews.freebsd.org/D44208

(cherry picked from commit 906521f8176b13533556d742db4ab28e847b85c0)
---
 sys/compat/linuxkpi/common/src/linux_80211.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c 
b/sys/compat/linuxkpi/common/src/linux_80211.c
index 876ff3693bd0..e5fcb81dce6a 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -546,7 +546,7 @@ lkpi_l80211_to_net80211_cyphers(uint32_t wlan_cipher_suite)
case WLAN_CIPHER_SUITE_TKIP:
return (IEEE80211_CRYPTO_TKIP);
case WLAN_CIPHER_SUITE_CCMP:
-   return (IEEE80211_CIPHER_AES_CCM);
+   return (IEEE80211_CRYPTO_AES_CCM);
case WLAN_CIPHER_SUITE_WEP104:
return (IEEE80211_CRYPTO_WEP);
case WLAN_CIPHER_SUITE_AES_CMAC:



git: c91ba48865a6 - stable/13 - net8011: radiotap: add more EHT constants

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/13 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=c91ba48865a61a84f521085fd59ed797655e8816

commit c91ba48865a61a84f521085fd59ed797655e8816
Author: Bjoern A. Zeeb 
AuthorDate: 2024-04-02 23:34:22 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 17:00:10 +

net8011: radiotap: add more EHT constants

(cherry picked from commit ab95bca9988ab15a2502efd03db43068a0a2b18b)
---
 sys/net80211/ieee80211_radiotap.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/sys/net80211/ieee80211_radiotap.h 
b/sys/net80211/ieee80211_radiotap.h
index dba454a8fa42..d44f81b68b8c 100644
--- a/sys/net80211/ieee80211_radiotap.h
+++ b/sys/net80211/ieee80211_radiotap.h
@@ -540,6 +540,11 @@ struct ieee80211_radiotap_eht_usig {
 #defineIEEE80211_RADIOTAP_EHT_USIG_COMMON_VALIDATE_BITS_OK 
0x0080
 #defineIEEE80211_RADIOTAP_EHT_USIG_COMMON_PHY_VER  
0x7000
 #defineIEEE80211_RADIOTAP_EHT_USIG_COMMON_BW   
0x00038000
+#defineIEEE80211_RADIOTAP_EHT_USIG_COMMON_BW_20MHZ 0x0
+#defineIEEE80211_RADIOTAP_EHT_USIG_COMMON_BW_40MHZ 0x1
+#defineIEEE80211_RADIOTAP_EHT_USIG_COMMON_BW_80MHZ 0x2
+#defineIEEE80211_RADIOTAP_EHT_USIG_COMMON_BW_160MHZ0x3
+#defineIEEE80211_RADIOTAP_EHT_USIG_COMMON_BW_320MHZ_1  0x4
 #defineIEEE80211_RADIOTAP_EHT_USIG_COMMON_UL_DL
0x0004
 #defineIEEE80211_RADIOTAP_EHT_USIG_COMMON_BSS_COLOR
0x01f8
 #defineIEEE80211_RADIOTAP_EHT_USIG_COMMON_TXOP 
0xfe00



git: 1c17a175c4c1 - stable/13 - LinuxKPI: 802.11: fix for_each_sta_active_link()

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/13 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=1c17a175c4c1b9f0cd995d77e3015698e3e174a9

commit 1c17a175c4c1b9f0cd995d77e3015698e3e174a9
Author: Bjoern A. Zeeb 
AuthorDate: 2024-05-21 21:58:47 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 17:00:49 +

LinuxKPI: 802.11: fix for_each_sta_active_link()

Likely a c&p error from for_each_vif_active_link() to
for_each_sta_active_link().
We are checking the nitems on the vif instead of the sta in this macro.
Function wise there is no difference as the arrays are the same size
but for correctness fix this.

Sponsored by:   The FreeBSD Foundation

(cherry picked from commit 69b6c4a6ec6654978628ccd48edce46f00ac3e96)
---
 sys/compat/linuxkpi/common/include/net/mac80211.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/compat/linuxkpi/common/include/net/mac80211.h 
b/sys/compat/linuxkpi/common/include/net/mac80211.h
index fc9d7829dae3..6a477ae5c32a 100644
--- a/sys/compat/linuxkpi/common/include/net/mac80211.h
+++ b/sys/compat/linuxkpi/common/include/net/mac80211.h
@@ -1253,7 +1253,7 @@ ieee80211_hw_restart_disconnect(struct ieee80211_vif *vif)
(_link = rcu_dereference((_vif)->link_conf[_linkid])) )
 
 #definefor_each_sta_active_link(_vif, _sta, _linksta, _linkid) 
\
-for (_linkid = 0; _linkid < nitems((_vif)->link_conf); _linkid++)  \
+for (_linkid = 0; _linkid < nitems((_sta)->link); _linkid++)   \
if ( ((_vif)->active_links == 0 /* no MLO */ || \
((_vif)->active_links & BIT(_linkid)) != 0) &&  \
(_linksta = link_sta_dereference_protected((_sta), (_linkid))) )



git: ba0e9f526481 - stable/13 - LinuxKPI: 802.11: initalize lsta to NULL in linuxkpi_ieee80211_rx()

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/13 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=ba0e9f526481d087bb9b3dfeb341134a5d56a7c5

commit ba0e9f526481d087bb9b3dfeb341134a5d56a7c5
Author: Bjoern A. Zeeb 
AuthorDate: 2024-06-05 22:35:00 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 17:02:05 +

LinuxKPI: 802.11: initalize lsta to NULL in linuxkpi_ieee80211_rx()

The logic following this new assignment in some cases may not set lsta
but the later tracing is checking for it to be != NULL.
With lsta not initialized that check may not hold up and later we would
dereference lsta->state and possibly panic.

Sponsored by:   The FreeBSD Foundation
Reviewed by:emaste
Differential Revision: https://reviews.freebsd.org/D45507

(cherry picked from commit 582469016aed4fac3a7ead24dc31000edbb7e823)
---
 sys/compat/linuxkpi/common/src/linux_80211.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c 
b/sys/compat/linuxkpi/common/src/linux_80211.c
index e5fcb81dce6a..b48f64fb1b0f 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -4926,6 +4926,7 @@ no_trace_beacons:
goto err;
}
 
+   lsta = NULL;
if (sta != NULL) {
lsta = STA_TO_LSTA(sta);
ni = ieee80211_ref_node(lsta->ni);



git: 88de7a318d13 - stable/13 - LinuxKPI: 802.11: Fix definition of IEEE80211_HT_CAP_RX_STBC

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/13 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=88de7a318d1381acc8c654c50ed7ea185f9abbbe

commit 88de7a318d1381acc8c654c50ed7ea185f9abbbe
Author: Bjoern A. Zeeb 
AuthorDate: 2024-06-05 21:57:45 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 17:02:40 +

LinuxKPI: 802.11: Fix definition of IEEE80211_HT_CAP_RX_STBC

IEEE80211_HT_CAP_RX_STBC was set to 0x100 instead of 0x300.
Correct to get the expected behavior.

Sponsored by:   The FreeBSD Foundation
Fixes:  b0f73768220e9 LinuxKPI: 802.11 header updates
Reviewed by:adrian
Differential Revision: https://reviews.freebsd.org/D45506

(cherry picked from commit 3e0915b7b6857afdbd283f2d448906e6a032ee07)
---
 sys/compat/linuxkpi/common/include/linux/ieee80211.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/ieee80211.h 
b/sys/compat/linuxkpi/common/include/linux/ieee80211.h
index 2000e7480ff8..0fd90e921c77 100644
--- a/sys/compat/linuxkpi/common/include/linux/ieee80211.h
+++ b/sys/compat/linuxkpi/common/include/linux/ieee80211.h
@@ -263,7 +263,7 @@ enum ieee80211_ac_numbers {
 #defineIEEE80211_HT_CAP_SGI_20 0x0020  /* 
IEEE80211_HTCAP_SHORTGI20 */
 #defineIEEE80211_HT_CAP_SGI_40 0x0040  /* 
IEEE80211_HTCAP_SHORTGI40 */
 #defineIEEE80211_HT_CAP_TX_STBC0x0080  /* 
IEEE80211_HTCAP_TXSTBC */
-#defineIEEE80211_HT_CAP_RX_STBC0x0100  /* 
IEEE80211_HTCAP_RXSTBC */
+#defineIEEE80211_HT_CAP_RX_STBC0x0300  /* 
IEEE80211_HTCAP_RXSTBC */
 #defineIEEE80211_HT_CAP_RX_STBC_SHIFT  8   /* 
IEEE80211_HTCAP_RXSTBC_S */
 #defineIEEE80211_HT_CAP_MAX_AMSDU  0x0800  /* 
IEEE80211_HTCAP_MAXAMSDU */
 #defineIEEE80211_HT_CAP_DSSSCCK40  0x1000  /* 
IEEE80211_HTCAP_DSSSCCK40 */



git: 2f5608c9af3b - stable/13 - LinuxKPI: 802.11: use net80211 IEEE80211_HTCAP_* definitions

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/13 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=2f5608c9af3b4f5c8900ee8bf0291f92fda817b0

commit 2f5608c9af3b4f5c8900ee8bf0291f92fda817b0
Author: Bjoern A. Zeeb 
AuthorDate: 2024-06-07 23:57:04 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 17:02:46 +

LinuxKPI: 802.11: use net80211 IEEE80211_HTCAP_* definitions

Rather than using the values and leaving net80211 names in a comment
define the LinuxKPI IEEE80211_HT_CAP_* to the net80211 IEEE80211_HTCAP_*
names.  That way errors like the one fixed in 3e0915b7b685 are less
likely to happen.

Sponsored by:   The FreeBSD Foundation

(cherry picked from commit 63a327b954a38ecd46934a2911321f3ea3d500b3)
---
 .../linuxkpi/common/include/linux/ieee80211.h  | 26 +++---
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/ieee80211.h 
b/sys/compat/linuxkpi/common/include/linux/ieee80211.h
index 0fd90e921c77..aa1a0a4f3c5f 100644
--- a/sys/compat/linuxkpi/common/include/linux/ieee80211.h
+++ b/sys/compat/linuxkpi/common/include/linux/ieee80211.h
@@ -254,20 +254,20 @@ enum ieee80211_ac_numbers {
 #defineIEEE80211_WMM_IE_STA_QOSINFO_SP_ALL 0xf
 
 
-/* XXX net80211 calls these IEEE80211_HTCAP_* */
-#defineIEEE80211_HT_CAP_LDPC_CODING0x0001  /* 
IEEE80211_HTCAP_LDPC */
-#defineIEEE80211_HT_CAP_SUP_WIDTH_20_400x0002  /* 
IEEE80211_HTCAP_CHWIDTH40 */
-#defineIEEE80211_HT_CAP_SM_PS  0x000c  /* 
IEEE80211_HTCAP_SMPS */
+/* Define the LinuxKPI names directly to the net80211 ones. */
+#defineIEEE80211_HT_CAP_LDPC_CODINGIEEE80211_HTCAP_LDPC
+#defineIEEE80211_HT_CAP_SUP_WIDTH_20_40
IEEE80211_HTCAP_CHWIDTH40
+#defineIEEE80211_HT_CAP_SM_PS  IEEE80211_HTCAP_SMPS
 #defineIEEE80211_HT_CAP_SM_PS_SHIFT2
-#defineIEEE80211_HT_CAP_GRN_FLD0x0010  /* 
IEEE80211_HTCAP_GREENFIELD */
-#defineIEEE80211_HT_CAP_SGI_20 0x0020  /* 
IEEE80211_HTCAP_SHORTGI20 */
-#defineIEEE80211_HT_CAP_SGI_40 0x0040  /* 
IEEE80211_HTCAP_SHORTGI40 */
-#defineIEEE80211_HT_CAP_TX_STBC0x0080  /* 
IEEE80211_HTCAP_TXSTBC */
-#defineIEEE80211_HT_CAP_RX_STBC0x0300  /* 
IEEE80211_HTCAP_RXSTBC */
-#defineIEEE80211_HT_CAP_RX_STBC_SHIFT  8   /* 
IEEE80211_HTCAP_RXSTBC_S */
-#defineIEEE80211_HT_CAP_MAX_AMSDU  0x0800  /* 
IEEE80211_HTCAP_MAXAMSDU */
-#defineIEEE80211_HT_CAP_DSSSCCK40  0x1000  /* 
IEEE80211_HTCAP_DSSSCCK40 */
-#defineIEEE80211_HT_CAP_LSIG_TXOP_PROT 0x8000  /* 
IEEE80211_HTCAP_LSIGTXOPPROT */
+#defineIEEE80211_HT_CAP_GRN_FLD
IEEE80211_HTCAP_GREENFIELD
+#defineIEEE80211_HT_CAP_SGI_20 
IEEE80211_HTCAP_SHORTGI20
+#defineIEEE80211_HT_CAP_SGI_40 
IEEE80211_HTCAP_SHORTGI40
+#defineIEEE80211_HT_CAP_TX_STBCIEEE80211_HTCAP_TXSTBC
+#defineIEEE80211_HT_CAP_RX_STBCIEEE80211_HTCAP_RXSTBC
+#defineIEEE80211_HT_CAP_RX_STBC_SHIFT  IEEE80211_HTCAP_RXSTBC_S
+#defineIEEE80211_HT_CAP_MAX_AMSDU  IEEE80211_HTCAP_MAXAMSDU
+#defineIEEE80211_HT_CAP_DSSSCCK40  
IEEE80211_HTCAP_DSSSCCK40
+#defineIEEE80211_HT_CAP_LSIG_TXOP_PROT 
IEEE80211_HTCAP_LSIGTXOPPROT
 
 #defineIEEE80211_HT_MCS_TX_DEFINED 0x0001
 #defineIEEE80211_HT_MCS_TX_RX_DIFF 0x0002



git: 20a2fe68faac - main - pf: correctly reset max_win if the SYN-ACK lacks a wscale option.

2024-06-12 Thread Kristof Provost
The branch main has been updated by kp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=20a2fe68faacb98b3c87ce7ea46a16b0d6c2462b

commit 20a2fe68faacb98b3c87ce7ea46a16b0d6c2462b
Author: Kristof Provost 
AuthorDate: 2024-06-12 18:01:58 +
Commit: Kristof Provost 
CommitDate: 2024-06-12 21:33:11 +

pf: correctly reset max_win if the SYN-ACK lacks a wscale option.

pf was setting max_win to 0 and discarded retransmitted SYN-ACK segments 
without
wscale if the original SYN contained a wscale option. with gerhard@, ok
henning@

Obtained From:  OpenBSD
Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 sys/netpfil/pf/pf.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c
index 8c97d1bf200d..c635251c3490 100644
--- a/sys/netpfil/pf/pf.c
+++ b/sys/netpfil/pf/pf.c
@@ -5315,8 +5315,9 @@ pf_tcp_track_full(struct pf_kstate **state, struct 
pfi_kkif *kif,
dws = dst->wscale & PF_WSCALE_MASK;
} else {
/* fixup other window */
-   dst->max_win <<= dst->wscale &
-   PF_WSCALE_MASK;
+   dst->max_win = MIN(TCP_MAXWIN,
+   (u_int32_t)dst->max_win <<
+   (dst->wscale & PF_WSCALE_MASK));
/* in case of a retrans SYN|ACK */
dst->wscale = 0;
}



git: 07ed2396985f - main - pf: make TCP sequence number tracking less strict by one octet for FIN packets

2024-06-12 Thread Kristof Provost
The branch main has been updated by kp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=07ed2396985f211a1f9c2f84da99f955650df696

commit 07ed2396985f211a1f9c2f84da99f955650df696
Author: Kristof Provost 
AuthorDate: 2024-06-12 18:05:22 +
Commit: Kristof Provost 
CommitDate: 2024-06-12 21:33:11 +

pf: make TCP sequence number tracking less strict by one octet for FIN 
packets

The data of a TCP packet must fit into the announced window, but this is not
required for the sequence number of the FIN.  A packet with the FIN bit set 
and
containing data that fits exactly into the announced window was blocked. Our
stack generates such packets when the receive buffer size is set to 1024. 
Now
pf uses only the data lenght for window comparison.
OK henning@

Obtained From:  OpenBSD
Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 sys/netpfil/pf/pf.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c
index c635251c3490..edb95d7ef0ec 100644
--- a/sys/netpfil/pf/pf.c
+++ b/sys/netpfil/pf/pf.c
@@ -5246,7 +5246,7 @@ pf_tcp_track_full(struct pf_kstate **state, struct 
pfi_kkif *kif,
struct tcphdr   *th = &pd->hdr.tcp;
struct pf_state_peer*src, *dst;
u_int16_twin = ntohs(th->th_win);
-   u_int32_tack, end, seq, orig_seq;
+   u_int32_tack, end, data_end, seq, orig_seq;
u_int8_t sws, dws, psrc, pdst;
int  ackskew;
 
@@ -5323,6 +5323,7 @@ pf_tcp_track_full(struct pf_kstate **state, struct 
pfi_kkif *kif,
}
}
}
+   data_end = end;
if (th->th_flags & TH_FIN)
end++;
 
@@ -5353,6 +5354,7 @@ pf_tcp_track_full(struct pf_kstate **state, struct 
pfi_kkif *kif,
end = seq + pd->p_len;
if (th->th_flags & TH_SYN)
end++;
+   data_end = end;
if (th->th_flags & TH_FIN)
end++;
}
@@ -5374,7 +5376,7 @@ pf_tcp_track_full(struct pf_kstate **state, struct 
pfi_kkif *kif,
if (seq == end) {
/* Ease sequencing restrictions on no data packets */
seq = src->seqlo;
-   end = seq;
+   data_end = end = seq;
}
 
ackskew = dst->seqlo - ack;
@@ -5397,7 +5399,7 @@ pf_tcp_track_full(struct pf_kstate **state, struct 
pfi_kkif *kif,
}
 
 #defineMAXACKWINDOW (0x + 1500)/* 1500 is an arbitrary fudge 
factor */
-   if (SEQ_GEQ(src->seqhi, end) &&
+   if (SEQ_GEQ(src->seqhi, data_end) &&
/* Last octet inside other's window space */
SEQ_GEQ(seq, src->seqlo - (dst->max_win << dws)) &&
/* Retrans: not more than one window back */
@@ -5471,7 +5473,7 @@ pf_tcp_track_full(struct pf_kstate **state, struct 
pfi_kkif *kif,
} else if ((dst->state < TCPS_SYN_SENT ||
dst->state >= TCPS_FIN_WAIT_2 ||
src->state >= TCPS_FIN_WAIT_2) &&
-   SEQ_GEQ(src->seqhi + MAXACKWINDOW, end) &&
+   SEQ_GEQ(src->seqhi + MAXACKWINDOW, data_end) &&
/* Within a window forward of the originating packet */
SEQ_GEQ(seq, src->seqlo - MAXACKWINDOW)) {
/* Within a window backward of the originating packet */
@@ -5564,12 +5566,12 @@ pf_tcp_track_full(struct pf_kstate **state, struct 
pfi_kkif *kif,
pd->dir == PF_IN ? "in" : "out",
pd->dir == (*state)->direction ? "fwd" : "rev");
printf("pf: State failure on: %c %c %c %c | %c %c\n",
-   SEQ_GEQ(src->seqhi, end) ? ' ' : '1',
+   SEQ_GEQ(src->seqhi, data_end) ? ' ' : '1',
SEQ_GEQ(seq, src->seqlo - (dst->max_win << dws)) ?
' ': '2',
(ackskew >= -MAXACKWINDOW) ? ' ' : '3',
(ackskew <= (MAXACKWINDOW << sws)) ? ' ' : '4',
-   SEQ_GEQ(src->seqhi + MAXACKWINDOW, end) ?' ' :'5',
+   SEQ_GEQ(src->seqhi + MAXACKWINDOW, data_end) ?' ' 
:'5',
SEQ_GEQ(seq, src->seqlo - MAXACKWINDOW) ?' ' :'6');
}
REASON_SET(reason, PFRES_BADSTATE);



git: 83549ee250c0 - stable/13 - u3g: Add support for SIM7600G

2024-06-12 Thread Kristof Provost
The branch stable/13 has been updated by kp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=83549ee250c041bc46971d66b7a2f55bc11b41a5

commit 83549ee250c041bc46971d66b7a2f55bc11b41a5
Author: Maxime Thiebaut 
AuthorDate: 2024-06-06 10:43:46 +
Commit: Kristof Provost 
CommitDate: 2024-06-12 19:34:29 +

u3g: Add support for SIM7600G

Signed-off-by:  Maxime Thiebaut 
Reviewed by:kp

(cherry picked from commit b5b90ff9844d1cb780ff777fc42ad393e4683563)
---
 sys/dev/usb/serial/u3g.c | 1 +
 sys/dev/usb/usbdevs  | 1 +
 2 files changed, 2 insertions(+)

diff --git a/sys/dev/usb/serial/u3g.c b/sys/dev/usb/serial/u3g.c
index cbe7ecc5bf74..986e243c60d3 100644
--- a/sys/dev/usb/serial/u3g.c
+++ b/sys/dev/usb/serial/u3g.c
@@ -207,6 +207,7 @@ static const STRUCT_USB_HOST_ID u3g_devs[] = {
U3G_DEV(ALINK, 3GU, 0),
U3G_DEV(ALINK, DWM652U5, 0),
U3G_DEV(ALINK, SIM7600E, 0),
+   U3G_DEV(ALINK, SIM7600G, 0),
U3G_DEV(AMOI, H01, 0),
U3G_DEV(AMOI, H01A, 0),
U3G_DEV(AMOI, H02, 0),
diff --git a/sys/dev/usb/usbdevs b/sys/dev/usb/usbdevs
index 602420b44ce7..a32a53d49735 100644
--- a/sys/dev/usb/usbdevs
+++ b/sys/dev/usb/usbdevs
@@ -1064,6 +1064,7 @@ product ALCOR AU6390  0x6390  AU6390 USB-IDE converter
 product ALINK DWM652U5 0xce16  DWM-652
 product ALINK 3G   0x9000  3G modem
 product ALINK SIM7600E 0x9001  LTE modem
+product ALINK SIM7600G 0x9011  LTE modem
 product ALINK 3GU  0x9200  3G modem
 
 /* Altec Lansing products */



git: 1296443295ab - stable/14 - u3g: Add support for SIM7600G

2024-06-12 Thread Kristof Provost
The branch stable/14 has been updated by kp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=1296443295aba0dd3e10a3a84013b9e60aef6196

commit 1296443295aba0dd3e10a3a84013b9e60aef6196
Author: Maxime Thiebaut 
AuthorDate: 2024-06-06 10:43:46 +
Commit: Kristof Provost 
CommitDate: 2024-06-12 19:34:25 +

u3g: Add support for SIM7600G

Signed-off-by:  Maxime Thiebaut 
Reviewed by:kp

(cherry picked from commit b5b90ff9844d1cb780ff777fc42ad393e4683563)
---
 sys/dev/usb/serial/u3g.c | 1 +
 sys/dev/usb/usbdevs  | 1 +
 2 files changed, 2 insertions(+)

diff --git a/sys/dev/usb/serial/u3g.c b/sys/dev/usb/serial/u3g.c
index e0a1ff29b0a4..88f94ddaecc6 100644
--- a/sys/dev/usb/serial/u3g.c
+++ b/sys/dev/usb/serial/u3g.c
@@ -205,6 +205,7 @@ static const STRUCT_USB_HOST_ID u3g_devs[] = {
U3G_DEV(ALINK, 3GU, 0),
U3G_DEV(ALINK, DWM652U5, 0),
U3G_DEV(ALINK, SIM7600E, 0),
+   U3G_DEV(ALINK, SIM7600G, 0),
U3G_DEV(AMOI, H01, 0),
U3G_DEV(AMOI, H01A, 0),
U3G_DEV(AMOI, H02, 0),
diff --git a/sys/dev/usb/usbdevs b/sys/dev/usb/usbdevs
index 65dcb06c2f3f..2a217b1eaf17 100644
--- a/sys/dev/usb/usbdevs
+++ b/sys/dev/usb/usbdevs
@@ -1064,6 +1064,7 @@ product ALCOR AU6390  0x6390  AU6390 USB-IDE converter
 product ALINK DWM652U5 0xce16  DWM-652
 product ALINK 3G   0x9000  3G modem
 product ALINK SIM7600E 0x9001  LTE modem
+product ALINK SIM7600G 0x9011  LTE modem
 product ALINK 3GU  0x9200  3G modem
 
 /* Altec Lansing products */



git: 7f7389e66816 - stable/14 - man bluetooth/fwdownloaders: alignment nits, SPDX

2024-06-12 Thread Warner Losh
The branch stable/14 has been updated by imp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=7f7389e6681639fdbdeef9f5987d593e13b508b3

commit 7f7389e6681639fdbdeef9f5987d593e13b508b3
Author: Alexander Ziaee 
AuthorDate: 2024-05-31 19:27:58 +
Commit: Warner Losh 
CommitDate: 2024-06-12 21:46:24 +

man bluetooth/fwdownloaders: alignment nits, SPDX

MFC after: 3 days

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1267

(cherry picked from commit 9c0d6df100eda06697ad4ca86c97c554ee9d727c)
---
 usr.sbin/bluetooth/ath3kfw/ath3kfw.8 | 10 +++---
 usr.sbin/bluetooth/bcmfw/bcmfw.8 |  7 +--
 usr.sbin/bluetooth/iwmbtfw/iwmbtfw.8 | 14 +-
 3 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/usr.sbin/bluetooth/ath3kfw/ath3kfw.8 
b/usr.sbin/bluetooth/ath3kfw/ath3kfw.8
index 340871d31df8..ed015bbf229d 100644
--- a/usr.sbin/bluetooth/ath3kfw/ath3kfw.8
+++ b/usr.sbin/bluetooth/ath3kfw/ath3kfw.8
@@ -1,3 +1,6 @@
+.\"-
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
 .\" Copyright (c) 2010 Maksim Yevmenkin 
 .\" Copyright (c) 2013, 2016 Adrian Chadd 
 .\" All rights reserved.
@@ -31,6 +34,7 @@
 .Nd firmware download utility for Atheros AR3011/AR3012 chip based Bluetooth 
USB devices
 .Sh SYNOPSIS
 .Nm
+.Op Fl DI
 .Fl d Ar device_name
 .Fl f Ar firmware_path
 .Nm
@@ -58,19 +62,19 @@ utility will query the device to determine which firmware 
image and board
 configuration to load in at runtime.
 .Pp
 The options are as follows:
-.Bl -tag -width indent
+.Bl -tag -width "-f firmware_path"
 .It Fl D
 Enable verbose debugging.
 .It Fl d Ar device_name
 Specify
 .Xr ugen 4
 device name.
-.It I
-Enable informational debugging.
 .It Fl f Ar firmware_path
 Specify the directory containing the firmware files to search and upload.
 .It Fl h
 Display usage message and exit.
+.It Fl I
+Enable informational debugging.
 .El
 .Sh EXIT STATUS
 .Ex -std
diff --git a/usr.sbin/bluetooth/bcmfw/bcmfw.8 b/usr.sbin/bluetooth/bcmfw/bcmfw.8
index 22d793641759..b9fa72706d2d 100644
--- a/usr.sbin/bluetooth/bcmfw/bcmfw.8
+++ b/usr.sbin/bluetooth/bcmfw/bcmfw.8
@@ -1,3 +1,6 @@
+.\"-
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
 .\" Copyright (c) 2003 Maksim Yevmenkin 
 .\" All rights reserved.
 .\"
@@ -64,7 +67,7 @@ I am using the following files from the bluez-firmware-1.0 
package:
 .Dl "MD5 (BCM2033-FW.bin) = b4e142b3272cfe5a84b32fda6b4b032f"
 .Pp
 The options are as follows:
-.Bl -tag -width indent
+.Bl -tag -width "-m mini-driver_file_name"
 .It Fl f Ar firmware_file_name
 Specify firmware file name for download.
 .It Fl h
@@ -75,7 +78,7 @@ Specify mini-driver file name for download.
 Specify device name.
 .El
 .Sh FILES
-.Bl -tag -width ".Pa /dev/ubtbcmfw Ns Ar N Ns Pa \&. Ns Ar EE" -compact
+.Bl -tag -width "-m mini-driver_file_name" -compact
 .It Pa BCM2033-MD.hex
 Mini-driver image.
 .It Pa BCM2033-FW.bin
diff --git a/usr.sbin/bluetooth/iwmbtfw/iwmbtfw.8 
b/usr.sbin/bluetooth/iwmbtfw/iwmbtfw.8
index 368a3865a0eb..66517badd0fc 100644
--- a/usr.sbin/bluetooth/iwmbtfw/iwmbtfw.8
+++ b/usr.sbin/bluetooth/iwmbtfw/iwmbtfw.8
@@ -1,3 +1,6 @@
+.\"-
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
 .\" Copyright (c) 2013, 2016 Adrian Chadd 
 .\" Copyright (c) 2019 Vladimir Kondratyev 
 .\" Copyright (c) 2021 Philippe Michaud-Boudreault 
@@ -32,6 +35,7 @@
 USB devices
 .Sh SYNOPSIS
 .Nm
+.Op Fl DI
 .Fl d Ar device_name
 .Fl f Ar firmware_path
 .Nm
@@ -45,8 +49,8 @@ device.
 .Pp
 This utility will
 .Em only
-work with Intel Wireless 7260/8260/8265 chip based Bluetooth USB devices and 
some of
-their successors.
+work with Intel Wireless 7260/8260/8265 chip based Bluetooth USB devices
+and some of their successors.
 The identification is currently based on USB vendor ID/product ID pair.
 The vendor ID should be 0x8087
 .Pq Dv USB_VENDOR_INTEL2
@@ -62,19 +66,19 @@ utility will query the device to determine which firmware 
image and board
 configuration to load in at runtime.
 .Pp
 The options are as follows:
-.Bl -tag -width indent
+.Bl -tag -width "-f firmware_path"
 .It Fl D
 Enable verbose debugging.
 .It Fl d Ar device_name
 Specify
 .Xr ugen 4
 device name.
-.It Fl I
-Enable informational debugging.
 .It Fl f Ar firmware_path
 Specify the directory containing the firmware files to search and upload.
 .It Fl h
 Display usage message and exit.
+.It Fl I
+Enable informational debugging.
 .El
 .Sh EXIT STATUS
 .Ex -std



git: 484c2ce9752f - stable/14 - netlink: Fix C++ compile errors

2024-06-12 Thread Warner Losh
The branch stable/14 has been updated by imp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=484c2ce9752f610ab082a002341a290d683b8343

commit 484c2ce9752f610ab082a002341a290d683b8343
Author: cnbatch 
AuthorDate: 2024-05-17 13:09:44 +
Commit: Warner Losh 
CommitDate: 2024-06-12 21:46:24 +

netlink: Fix C++ compile errors

Allow these files to be included in C++ programs with careful casting to
the proper type, like C++ wants (and in a way that also works for C).

MFC After: 1 week
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1245

(cherry picked from commit ff92493a4f6504c49a6c84ec65053f493ff5d708)
---
 sys/netlink/netlink_snl.h   | 33 +
 sys/netlink/netlink_snl_route.h |  2 +-
 sys/netlink/netlink_snl_route_parsers.h | 10 +-
 3 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/sys/netlink/netlink_snl.h b/sys/netlink/netlink_snl.h
index f8387132f78a..03f2b7dc5c38 100644
--- a/sys/netlink/netlink_snl.h
+++ b/sys/netlink/netlink_snl.h
@@ -63,7 +63,7 @@
 
 #define_NLA_END(_start, _len)  ((char *)(_start) + (_len))
 #define NLA_FOREACH(_attr, _start, _len)  \
-for (_attr = (_start); \
+for (_attr = (struct nlattr *)(_start);\
((char *)_attr < _NLA_END(_start, _len)) && \
((char *)NLA_NEXT(_attr) <= _NLA_END(_start, _len));\
_attr =  NLA_NEXT(_attr))
@@ -80,7 +80,7 @@ struct linear_buffer {
 static inline struct linear_buffer *
 lb_init(uint32_t size)
 {
-   struct linear_buffer *lb = calloc(1, size);
+   struct linear_buffer *lb = (struct linear_buffer *)calloc(1, size);
 
if (lb != NULL) {
lb->base = (char *)(lb + 1);
@@ -102,7 +102,7 @@ lb_allocz(struct linear_buffer *lb, int len)
len = roundup2(len, alignof(__max_align_t));
if (lb->offset + len > lb->size)
return (NULL);
-   void *data = (void *)(lb->base + lb->offset);
+   char *data = (lb->base + lb->offset);
lb->offset += len;
return (data);
 }
@@ -275,7 +275,7 @@ snl_init(struct snl_state *ss, int netlink_family)
}
 
ss->bufsize = rcvbuf;
-   ss->buf = malloc(ss->bufsize);
+   ss->buf = (char *)malloc(ss->bufsize);
if (ss->buf == NULL) {
snl_free(ss);
return (false);
@@ -495,7 +495,8 @@ snl_parse_header(struct snl_state *ss, void *hdr, int len,
struct nlattr *nla_head;
 
/* Extract fields first (if any) */
-   snl_parse_fields(ss, hdr, parser->in_hdr_size, parser->fp, 
parser->fp_size, target);
+   snl_parse_fields(ss, (struct nlmsghdr *)hdr, parser->in_hdr_size,
+   parser->fp, parser->fp_size, target);
 
nla_head = (struct nlattr *)(void *)((char *)hdr + parser->in_hdr_size);
bool result = snl_parse_attrs_raw(ss, nla_head, len - 
parser->in_hdr_size,
@@ -616,7 +617,7 @@ snl_attr_get_stringn(struct snl_state *ss, struct nlattr 
*nla,
 {
int maxlen = NLA_DATA_LEN(nla);
 
-   char *buf = snl_allocz(ss, maxlen + 1);
+   char *buf = (char *)snl_allocz(ss, maxlen + 1);
if (buf == NULL)
return (false);
buf[maxlen] = '\0';
@@ -633,7 +634,7 @@ snl_attr_copy_string(struct snl_state *ss, struct nlattr 
*nla,
char *tmp;
 
if (snl_attr_get_string(ss, nla, NULL, &tmp)) {
-   strlcpy(target, tmp, (size_t)arg);
+   strlcpy((char *)target, tmp, (size_t)arg);
return (true);
}
return (false);
@@ -646,7 +647,7 @@ snl_attr_dup_string(struct snl_state *ss __unused, struct 
nlattr *nla,
size_t maxlen = NLA_DATA_LEN(nla);
 
if (strnlen((char *)NLA_DATA(nla), maxlen) < maxlen) {
-   char *buf = snl_allocz(ss, maxlen);
+   char *buf = (char *)snl_allocz(ss, maxlen);
if (buf == NULL)
return (false);
memcpy(buf, NLA_DATA(nla), maxlen);
@@ -675,14 +676,14 @@ snl_attr_get_parray_sz(struct snl_state *ss, struct 
nlattr *container_nla,
 uint32_t start_size, const void *arg, void *target)
 {
const struct snl_hdr_parser *p = (const struct snl_hdr_parser *)arg;
-   struct snl_parray *array = target;
+   struct snl_parray *array = (struct snl_parray *)target;
struct nlattr *nla;
uint32_t count = 0, size = start_size;
 
if (p->out_size == 0)
return (false);
 
-   array->items = snl_allocz(ss, size * sizeof(void *));
+   array->items = (void **)snl_allocz(ss, size * sizeof(void *));
if (array->items == NULL)
return (false);
 
@@ -712,7 +713,7 @@ snl_attr_get_parray_sz(struct snl_state *ss, struct nlattr 
*container_nla,
 
if (count == size) {
uint32_t new_size = size * 2;
- 

git: 657a482888d4 - stable/14 - man bluetooth/fwdownloaders: terse descriptions

2024-06-12 Thread Warner Losh
The branch stable/14 has been updated by imp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=657a482888d4465bfa6d2e90925406418e94bbc0

commit 657a482888d4465bfa6d2e90925406418e94bbc0
Author: Alexander Ziaee 
AuthorDate: 2024-05-31 12:13:54 +
Commit: Warner Losh 
CommitDate: 2024-06-12 21:46:25 +

man bluetooth/fwdownloaders: terse descriptions

+ descriptions no longer wrap on a standard console, no keywords removed
+ more consistent language with other firmware tooling manuals

MFC after: 3 days
Reviewed by: imp (bumped date for Nd changes)
Pull Request: https://github.com/freebsd/freebsd-src/pull/1266

(cherry picked from commit 2c901189bb65ea0bae03aa83459570a0f0ea0aa8)
---
 usr.sbin/bluetooth/ath3kfw/ath3kfw.8 | 4 ++--
 usr.sbin/bluetooth/bcmfw/bcmfw.8 | 6 ++
 usr.sbin/bluetooth/iwmbtfw/iwmbtfw.8 | 5 ++---
 3 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/usr.sbin/bluetooth/ath3kfw/ath3kfw.8 
b/usr.sbin/bluetooth/ath3kfw/ath3kfw.8
index ed015bbf229d..beb1b102b194 100644
--- a/usr.sbin/bluetooth/ath3kfw/ath3kfw.8
+++ b/usr.sbin/bluetooth/ath3kfw/ath3kfw.8
@@ -26,12 +26,12 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd June 4, 2016
+.Dd May 31, 2024
 .Dt ATH3KFW 8
 .Os
 .Sh NAME
 .Nm ath3kfw
-.Nd firmware download utility for Atheros AR3011/AR3012 chip based Bluetooth 
USB devices
+.Nd download firmware for Atheros AR3011/AR3012 Bluetooth USB devices
 .Sh SYNOPSIS
 .Nm
 .Op Fl DI
diff --git a/usr.sbin/bluetooth/bcmfw/bcmfw.8 b/usr.sbin/bluetooth/bcmfw/bcmfw.8
index b9fa72706d2d..50e9739340ee 100644
--- a/usr.sbin/bluetooth/bcmfw/bcmfw.8
+++ b/usr.sbin/bluetooth/bcmfw/bcmfw.8
@@ -25,14 +25,12 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $Id: bcmfw.8,v 1.7 2003/05/21 00:33:40 max Exp $
-.\"
-.Dd March 31, 2003
+.Dd May 31, 2024
 .Dt BCMFW 8
 .Os
 .Sh NAME
 .Nm bcmfw
-.Nd firmware download utility for Broadcom BCM2033 chip based Bluetooth USB 
devices
+.Nd download firmware for Broadcom BCM2033 Bluetooth USB devices
 .Sh SYNOPSIS
 .Nm
 .Op Fl h
diff --git a/usr.sbin/bluetooth/iwmbtfw/iwmbtfw.8 
b/usr.sbin/bluetooth/iwmbtfw/iwmbtfw.8
index 66517badd0fc..1924c5f3ce74 100644
--- a/usr.sbin/bluetooth/iwmbtfw/iwmbtfw.8
+++ b/usr.sbin/bluetooth/iwmbtfw/iwmbtfw.8
@@ -26,13 +26,12 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd May 3, 2021
+.Dd May 31, 2024
 .Dt IWMBTFW 8
 .Os
 .Sh NAME
 .Nm iwmbtfw
-.Nd firmware download utility for Intel Wireless 7260/8260/8265 chip based 
Bluetooth
-USB devices
+.Nd download firmware for Intel Wireless AC Bluetooth USB devices
 .Sh SYNOPSIS
 .Nm
 .Op Fl DI



git: e366cf07bc64 - stable/14 - smbfs manuals: describe consistently

2024-06-12 Thread Warner Losh
The branch stable/14 has been updated by imp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=e366cf07bc647948b3ae7861d24c0a1cc0570264

commit e366cf07bc647948b3ae7861d24c0a1cc0570264
Author: Alexander Ziaee 
AuthorDate: 2024-05-30 21:37:15 +
Commit: Warner Losh 
CommitDate: 2024-06-12 21:46:25 +

smbfs manuals: describe consistently

MFC after: 3 days

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/

(cherry picked from commit dddf29712f38ba1d804c02bcfd02d24098ae48b0)
---
 contrib/smbfs/mount_smbfs/mount_smbfs.8 | 3 +--
 contrib/smbfs/smbutil/smbutil.1 | 2 +-
 share/man/man5/nsmb.conf.5  | 7 ---
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/contrib/smbfs/mount_smbfs/mount_smbfs.8 
b/contrib/smbfs/mount_smbfs/mount_smbfs.8
index 4b4c205dc7da..604b1b414243 100644
--- a/contrib/smbfs/mount_smbfs/mount_smbfs.8
+++ b/contrib/smbfs/mount_smbfs/mount_smbfs.8
@@ -1,11 +1,10 @@
 .\" $Id: mount_smbfs.8,v 1.10 2002/04/16 02:47:41 bp Exp $
-.\" $FreeBSD$
 .Dd November 1, 2018
 .Dt MOUNT_SMBFS 8
 .Os
 .Sh NAME
 .Nm mount_smbfs
-.Nd "mount a shared resource from an SMB file server"
+.Nd mount a server message block (SMB1/CIFS) file system
 .Sh SYNOPSIS
 .Nm
 .Op Fl E Ar cs1 Ns Cm \&: Ns Ar cs2
diff --git a/contrib/smbfs/smbutil/smbutil.1 b/contrib/smbfs/smbutil/smbutil.1
index cf133bad309a..c82ba91ea99e 100644
--- a/contrib/smbfs/smbutil/smbutil.1
+++ b/contrib/smbfs/smbutil/smbutil.1
@@ -4,7 +4,7 @@
 .Os
 .Sh NAME
 .Nm smbutil
-.Nd "interface to the SMB requester"
+.Nd interface to the server message block (SMB1/CIFS) requester
 .Sh SYNOPSIS
 .Nm
 .Op Fl hv
diff --git a/share/man/man5/nsmb.conf.5 b/share/man/man5/nsmb.conf.5
index 1a09743874e5..0da10343ed77 100644
--- a/share/man/man5/nsmb.conf.5
+++ b/share/man/man5/nsmb.conf.5
@@ -1,3 +1,6 @@
+.\"-
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
 .\" Copyright (c) 2003
 .\" Originally written by Sergey A. Osokin
 .\" Rewritten by Tom Rhodes
@@ -28,9 +31,7 @@
 .Os
 .Sh NAME
 .Nm nsmb.conf
-.Nd configuration file for
-.Tn SMB
-requests
+.Nd configuration file for server message block (SMB1/CIFS) requests
 .Sh DESCRIPTION
 The
 .Nm



git: aeaff9c5deac - stable/14 - smbus manuals: include term SMBus in description

2024-06-12 Thread Warner Losh
The branch stable/14 has been updated by imp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=aeaff9c5deacd552eb0dbdfcd6731487e1e14b51

commit aeaff9c5deacd552eb0dbdfcd6731487e1e14b51
Author: Alexander Ziaee 
AuthorDate: 2024-05-30 21:58:20 +
Commit: Warner Losh 
CommitDate: 2024-06-12 21:53:22 +

smbus manuals: include term SMBus in description

Fixes: 5ad3b09f2fe9 (smb: distinguishable descriptions)
MFC after: 3 days
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/

(cherry picked from commit 8ccdf86ee57575b04983bc7be68c357fb83668f8)
---
 share/man/man4/iicsmb.4 | 8 +---
 share/man/man4/smb.4| 2 +-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/share/man/man4/iicsmb.4 b/share/man/man4/iicsmb.4
index b6f5e39ce5cc..ffa38000659f 100644
--- a/share/man/man4/iicsmb.4
+++ b/share/man/man4/iicsmb.4
@@ -1,5 +1,7 @@
-.\" Copyright (c) 1998, Nicolas Souchu
-.\" All rights reserved.
+.\"-
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
+.\" Copyright (c) 1998, Nicolas Souchu. All rights reserved.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
 .\" modification, are permitted provided that the following conditions
@@ -27,7 +29,7 @@
 .Os
 .Sh NAME
 .Nm iicsmb
-.Nd I2C to SMB bridge
+.Nd I2C to SMBus bridge
 .Sh SYNOPSIS
 .Cd "device iicsmb"
 .Pp
diff --git a/share/man/man4/smb.4 b/share/man/man4/smb.4
index d2a1c3b9a618..bec89d8cb05f 100644
--- a/share/man/man4/smb.4
+++ b/share/man/man4/smb.4
@@ -29,7 +29,7 @@
 .Os
 .Sh NAME
 .Nm smb
-.Nd SMB generic I/O device driver
+.Nd System Management Bus (SMBus) generic I/O device driver
 .Sh SYNOPSIS
 .Cd "device smb"
 .Sh DESCRIPTION



git: 170a7f2ec185 - stable/14 - ifconfig(8): wordsmith -G and -g descriptions

2024-06-12 Thread Warner Losh
The branch stable/14 has been updated by imp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=170a7f2ec18570e11b6b8530ce746d33119d9a6a

commit 170a7f2ec18570e11b6b8530ce746d33119d9a6a
Author: Pau Amma 
AuthorDate: 2024-06-06 21:12:53 +
Commit: Warner Losh 
CommitDate: 2024-06-12 21:53:56 +

ifconfig(8): wordsmith -G and -g descriptions

Remove spurious ".Ar groupname".
Add missing full stops.
While there, tweak word order for better grammar.

MFC after: 3 days

Reviewed by:Alexander Ziaee, Mina Galić, allanjude, imp
Differential Revision:  https://reviews.freebsd.org/D45092

(cherry picked from commit 21faf821a3046f2522dc8d49797f1c1ec74c6b0f)
---
 sbin/ifconfig/ifconfig.8 | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8
index fa463ad8af5d..259be41bf94b 100644
--- a/sbin/ifconfig/ifconfig.8
+++ b/sbin/ifconfig/ifconfig.8
@@ -1,3 +1,6 @@
+.\"-
+.\" SPDX-License-Identifier: BSD-3-Clause
+.\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"The Regents of the University of California.  All rights reserved.
 .\"
@@ -25,9 +28,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" From: @(#)ifconfig.8   8.3 (Berkeley) 1/5/94
-.\"
-.Dd May 12, 2024
+.Dd June 6, 2024
 .Dt IFCONFIG 8
 .Os
 .Sh NAME
@@ -216,11 +217,10 @@ Shortcut notation for
 Exclude members of the specified
 .Ar groupname
 from the output.
-.Ar groupname .
 .Pp
-Only one option
+Only one
 .Fl G
-should be specified as later override previous ones
+option should be specified as later ones override earlier ones.
 .Ar groupname
 may contain shell patterns in which case it should be quoted.
 .Pp
@@ -246,9 +246,9 @@ lists names of interfaces belonging to
 .Ar groupname .
 Any other flags and arguments are ignored in this case.
 .Pp
-Only one option
+Only one
 .Fl g
-should be specified as later override previous ones
+option should be specified as later ones override earlier ones.
 .Ar groupname
 may contain shell patterns in which case it should be quoted.
 .Pp



git: f9ac06af3b2d - stable/13 - net80211: move net_epoch into net80211

2024-06-12 Thread Bjoern A. Zeeb
The branch stable/13 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=f9ac06af3b2dec6ac75f5639cb1396f9d943fc06

commit f9ac06af3b2dec6ac75f5639cb1396f9d943fc06
Author: Bjoern A. Zeeb 
AuthorDate: 2023-10-29 14:25:23 +
Commit: Bjoern A. Zeeb 
CommitDate: 2024-06-12 22:18:50 +

net80211: move net_epoch into net80211

Move the net_epoch into net80211 around the if_input calls and out of
the driver (in this first case LinuxKPI).  This reduces coverage but
also allows us to alloc in calls like (*ampdu_rx_start) which do not
actually pass data up the stack.

The follow-up commits (squashed) reverts:
b65f813c1ab99448278961c5ca80dc422b1eae29
  Revert "Widen EPOCH(9) usage in PCI WLAN drivers.",
21c4082de9e2cf9a0fd81a9a981ab06022956847
  Revert "Widen EPOCH(9) usage in USB WLAN drivers.",
17c328b6aebfa03cd1c2cbfbbc617e3b341bf1e4
  Revert "Enter the network epoch in USB WiFi drivers when processing 
input",
af2441fbc7fa9e522e7f8697e5a181bdd4ff9e00
  Revert "[ath] Attempt to fix epoch handling.",
and 6c3e93cb5a4aa4b8a2d8d4d326f2a7c34d3a4458 for if_ath.c only
  ath: Revert "Use NET_TASK_INIT() and NET_GROUPTASK_INIT() for drivers 
that process".

Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D42427

(cherry picked from commit de607e3c230be88f6232b9c9fd6c37199648dc8c)
(cherry picked from commit 1c6dd33d26eb02c6145383a49150965eeca61120)
(cherry picked from commit 39b702797994fbd62a21dd3af6d4cd7045fded23)
(cherry picked from commit 75f298492a12d53df97c26963ec9f2dc0b052878)
(cherry picked from commit eb3821e6d92fa45ece7ec08efde45e35be1bdc95)
(cherry picked from commit 82506f26c03aa312b91e01a797f31e061749a76d)
---
 sys/compat/linuxkpi/common/src/linux_80211.c |  3 ---
 sys/dev/ath/if_ath_rx.c  | 11 +--
 sys/dev/ath/if_ath_rx_edma.c |  4 
 sys/dev/bwi/if_bwi.c |  3 ---
 sys/dev/bwn/if_bwn.c |  3 ---
 sys/dev/ipw/if_ipw.c |  3 ---
 sys/dev/iwi/if_iwi.c |  3 ---
 sys/dev/iwm/if_iwm.c |  5 -
 sys/dev/iwn/if_iwn.c |  3 ---
 sys/dev/malo/if_malo.c   |  3 ---
 sys/dev/mwl/if_mwl.c |  4 
 sys/dev/otus/if_otus.c   |  3 ---
 sys/dev/ral/rt2560.c |  4 +---
 sys/dev/ral/rt2661.c |  3 ---
 sys/dev/ral/rt2860.c |  3 ---
 sys/dev/rtwn/pci/rtwn_pci_rx.c   |  5 -
 sys/dev/rtwn/usb/rtwn_usb_rx.c   |  3 ---
 sys/dev/usb/wlan/if_rsu.c|  3 ---
 sys/dev/usb/wlan/if_rum.c|  3 ---
 sys/dev/usb/wlan/if_run.c|  3 ---
 sys/dev/usb/wlan/if_uath.c   |  3 ---
 sys/dev/usb/wlan/if_upgt.c   |  3 ---
 sys/dev/usb/wlan/if_ural.c   |  3 ---
 sys/dev/usb/wlan/if_urtw.c   |  3 ---
 sys/dev/usb/wlan/if_zyd.c|  3 ---
 sys/dev/wpi/if_wpi.c |  3 ---
 sys/dev/wtap/if_wtap.c   |  5 +
 sys/net80211/ieee80211_hostap.c  |  4 
 sys/net80211/ieee80211_input.c   |  3 +++
 29 files changed, 10 insertions(+), 95 deletions(-)

diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c 
b/sys/compat/linuxkpi/common/src/linux_80211.c
index b48f64fb1b0f..df72495e68b6 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -4802,7 +4802,6 @@ linuxkpi_ieee80211_rx(struct ieee80211_hw *hw, struct 
sk_buff *skb,
 struct ieee80211_sta *sta, struct napi_struct *napi __unused,
 struct list_head *list __unused)
 {
-   struct epoch_tracker et;
struct lkpi_hw *lhw;
struct ieee80211com *ic;
struct mbuf *m;
@@ -5021,7 +5020,6 @@ skip_device_ts:
}
 #endif
 
-   NET_EPOCH_ENTER(et);
if (ni != NULL) {
ok = ieee80211_input_mimo(ni, m);
ieee80211_free_node(ni);
@@ -5031,7 +5029,6 @@ skip_device_ts:
ok = ieee80211_input_mimo_all(ic, m);
/* mbuf got consumed. */
}
-   NET_EPOCH_EXIT(et);
 
 #ifdef LINUXKPI_DEBUG_80211
if (linuxkpi_debug_80211 & D80211_TRACE_RX)
diff --git a/sys/dev/ath/if_ath_rx.c b/sys/dev/ath/if_ath_rx.c
index 44edc75a5f09..586a56d8120e 100644
--- a/sys/dev/ath/if_ath_rx.c
+++ b/sys/dev/ath/if_ath_rx.c
@@ -666,8 +666,6 @@ ath_rx_pkt(struct ath_softc *sc, struct ath_rx_status *rs, 
HAL_STATUS status,
int is_good = 0;
struct ath_rx_edma *re = &sc->sc_rxedma[qtype];
 
-   NET_EPOCH_ASSERT();
-
/*
 * Calculate the correct 64 bit TSF given
 * the TSF64 register value and rs_tstamp.
@@

git: ec1f285f2e63 - main - nfscl: Add support for the NFSv4.1/4.2 WANT_xxx flags

2024-06-12 Thread Rick Macklem
The branch main has been updated by rmacklem:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=ec1f285f2e631b8aae3e08b3f68c6451a45c0941

commit ec1f285f2e631b8aae3e08b3f68c6451a45c0941
Author: Rick Macklem 
AuthorDate: 2024-06-12 23:11:10 +
Commit: Rick Macklem 
CommitDate: 2024-06-12 23:11:10 +

nfscl: Add support for the NFSv4.1/4.2 WANT_xxx flags

NFSv4.1/4.2 defined new OPEN_WANT_xxx flags that a client
can use to hint to the server that delegations are or are
not wanted.  This patch adds use of those delegations to
the client.

This patch should only affect the NFSv4.1/4.2 behaviour
when delegations are enabled, which is not the default.

MFC after:  1 month
---
 sys/fs/nfsclient/nfs_clrpcops.c | 77 -
 1 file changed, 68 insertions(+), 9 deletions(-)

diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c
index 8c5532268287..13bdc74655dd 100644
--- a/sys/fs/nfsclient/nfs_clrpcops.c
+++ b/sys/fs/nfsclient/nfs_clrpcops.c
@@ -389,13 +389,24 @@ nfsrpc_open(vnode_t vp, int amode, struct ucred *cred, 
NFSPROC_T *p)
mode |= NFSV4OPEN_ACCESSREAD;
if (amode & FWRITE)
mode |= NFSV4OPEN_ACCESSWRITE;
+   if (NFSHASNFSV4N(nmp)) {
+   if (!NFSHASPNFS(nmp) && nfscl_enablecallb != 0 &&
+   nfs_numnfscbd > 0) {
+   if ((mode & NFSV4OPEN_ACCESSWRITE) != 0)
+   mode |= NFSV4OPEN_WANTWRITEDELEG;
+   else
+   mode |= NFSV4OPEN_WANTANYDELEG;
+   } else
+   mode |= NFSV4OPEN_WANTNODELEG;
+   }
nfhp = np->n_fhp;
 
retrycnt = 0;
do {
dp = NULL;
-   error = nfscl_open(vp, nfhp->nfh_fh, nfhp->nfh_len, mode, 1,
-   cred, p, NULL, &op, &newone, &ret, 1, true);
+   error = nfscl_open(vp, nfhp->nfh_fh, nfhp->nfh_len,
+   (mode & NFSV4OPEN_ACCESSBOTH), 1, cred, p, NULL,
+   &op, &newone, &ret, 1, true);
if (error) {
return (error);
}
@@ -547,7 +558,8 @@ nfsrpc_openrpc(struct nfsmount *nmp, vnode_t vp, u_int8_t 
*nfhp, int fhlen,
cred);
NFSM_BUILD(tl, u_int32_t *, 5 * NFSX_UNSIGNED);
*tl++ = txdr_unsigned(op->nfso_own->nfsow_seqid);
-   *tl++ = txdr_unsigned(mode & NFSV4OPEN_ACCESSBOTH);
+   *tl++ = txdr_unsigned(mode & (NFSV4OPEN_ACCESSBOTH |
+   NFSV4OPEN_WANTDELEGMASK));
*tl++ = txdr_unsigned((mode >> NFSLCK_SHIFT) & NFSV4OPEN_DENYBOTH);
tsep = nfsmnt_mdssession(nmp);
*tl++ = tsep->nfsess_clientid.lval[0];
@@ -664,6 +676,13 @@ nfsrpc_openrpc(struct nfsmount *nmp, vnode_t vp, u_int8_t 
*nfhp, int fhlen,
&ret, &acesize, p);
if (error)
goto nfsmout;
+   } else if (deleg == NFSV4OPEN_DELEGATENONEEXT &&
+   NFSHASNFSV4N(nmp)) {
+   NFSM_DISSECT(tl, uint32_t *, NFSX_UNSIGNED);
+   deleg = fxdr_unsigned(uint32_t, *tl);
+   if (deleg == NFSV4OPEN_CONTENTION ||
+   deleg == NFSV4OPEN_RESOURCE)
+   NFSM_DISSECT(tl, uint32_t *, NFSX_UNSIGNED);
} else if (deleg != NFSV4OPEN_DELEGATENONE) {
error = NFSERR_BADXDR;
goto nfsmout;
@@ -1546,7 +1565,7 @@ nfsrpc_lookup(vnode_t dvp, char *name, int len, struct 
ucred *cred,
NFSM_BUILD(tl, uint32_t *, 6 * NFSX_UNSIGNED);
*tl++ = txdr_unsigned(NFSV4OP_OPEN);
*tl++ = 0;  /* seqid, ignored. */
-   *tl++ = txdr_unsigned(openmode);
+   *tl++ = txdr_unsigned(openmode | NFSV4OPEN_WANTNODELEG);
*tl++ = txdr_unsigned(NFSV4OPEN_DENYNONE);
*tl++ = 0;  /* ClientID, ignored. */
*tl = 0;
@@ -1668,6 +1687,13 @@ nfsrpc_lookup(vnode_t dvp, char *name, int len, struct 
ucred *cred,
ndp->nfsdl_stateid.other[0] = *tl++;
ndp->nfsdl_stateid.other[1] = *tl++;
ndp->nfsdl_stateid.other[2] = *tl++;
+   } else if (deleg == NFSV4OPEN_DELEGATENONEEXT &&
+   NFSHASNFSV4N(nmp)) {
+   NFSM_DISSECT(tl, uint32_t *, NFSX_UNSIGNED);
+   deleg = fxdr_unsigned(uint32_t, *tl);
+   if (deleg == NFSV4OPEN_CONTENTION ||
+   deleg == NFSV4OPEN_RESOURCE)
+   NFSM_DISSECT(tl, uint32_t *, NFSX_UNSIGNED);
} else if (deleg != NFSV4OPEN_DELEGATENONE) {
error = NFSERR_BADXDR;
go

git: 4308d6e0fc09 - main - nfscl: Add a check for VREG for delegations

2024-06-12 Thread Rick Macklem
The branch main has been updated by rmacklem:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=4308d6e0fc09c807483f09b8fea7f5182d19fd01

commit 4308d6e0fc09c807483f09b8fea7f5182d19fd01
Author: Rick Macklem 
AuthorDate: 2024-06-12 23:17:23 +
Commit: Rick Macklem 
CommitDate: 2024-06-12 23:17:23 +

nfscl: Add a check for VREG for delegations

Since delegations are only issued for regular files, check
v_type to see if the query is for a regular file.  This is
a simple optimization for the non-VREG case.
While here, fix a couple of global variable declarations.

This patch should only affect the NFSv4.1/4.2 behaviour
when delegations are enabled, which is not the default.

MFC after:  1 month
---
 sys/fs/nfsclient/nfs_clstate.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c
index 9fbaa6e63a56..aef5d71592af 100644
--- a/sys/fs/nfsclient/nfs_clstate.c
+++ b/sys/fs/nfsclient/nfs_clstate.c
@@ -93,9 +93,8 @@ NFSREQSPINLOCK;
 NFSCLSTATEMUTEX;
 int nfscl_inited = 0;
 struct nfsclhead nfsclhead;/* Head of clientid list */
-int nfscl_deleghighwater = NFSCLDELEGHIGHWATER;
-int nfscl_layouthighwater = NFSCLLAYOUTHIGHWATER;
 
+static int nfscl_deleghighwater = NFSCLDELEGHIGHWATER;
 static int nfscl_delegcnt = 0;
 static int nfscl_layoutcnt = 0;
 static int nfscl_getopen(struct nfsclownerhead *, struct nfsclopenhash *,
@@ -4647,7 +4646,7 @@ nfscl_mustflush(vnode_t vp)
 
np = VTONFS(vp);
nmp = VFSTONFS(vp->v_mount);
-   if (!NFSHASNFSV4(nmp))
+   if (!NFSHASNFSV4(nmp) || vp->v_type != VREG)
return (1);
NFSLOCKMNT(nmp);
if ((nmp->nm_privflag & NFSMNTP_DELEGISSUED) == 0) {
@@ -4687,7 +4686,7 @@ nfscl_nodeleg(vnode_t vp, int writedeleg)
 
np = VTONFS(vp);
nmp = VFSTONFS(vp->v_mount);
-   if (!NFSHASNFSV4(nmp))
+   if (!NFSHASNFSV4(nmp) || vp->v_type != VREG)
return (1);
NFSLOCKMNT(nmp);
if ((nmp->nm_privflag & NFSMNTP_DELEGISSUED) == 0) {



git: bb53f071e85a - main - nfscl: Add support for read delegations and atomic upgrade

2024-06-12 Thread Rick Macklem
The branch main has been updated by rmacklem:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=bb53f071e85a2ebb5b405e7fec4661a725b7caf5

commit bb53f071e85a2ebb5b405e7fec4661a725b7caf5
Author: Rick Macklem 
AuthorDate: 2024-06-12 23:41:12 +
Commit: Rick Macklem 
CommitDate: 2024-06-12 23:41:12 +

nfscl: Add support for read delegations and atomic upgrade

For NFSv4.1/4.2, an atomic upgrade of a delegation from a
read delegation to a write delegation is allowed and can
result in significantly improved performance.
This patch adds this upgrade to the NFSv4.1/4.2 client and
enables use of read delegations.

For a test case of building a FreeBSD kernel (sources and
output objects) over a NFSv4.2 mount, these changes reduced
the elapsed time by 30% and included a reduction of 80% for
RPC counts when delegations were enabled.  As such, with this
patch there are at least certain cases where enabling
delegations seems to be worth the increased complexity they
bring.

This patch should only affect the NFSv4.1/4.2 behaviour
when delegations are enabled, which is not the default.

MFC after:  1 month
---
 sys/fs/nfsclient/nfs_clstate.c | 38 ++
 sys/fs/nfsclient/nfs_clsubs.c  |  6 +++---
 sys/fs/nfsclient/nfs_clvnops.c |  2 +-
 3 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c
index aef5d71592af..0a1eb51e279f 100644
--- a/sys/fs/nfsclient/nfs_clstate.c
+++ b/sys/fs/nfsclient/nfs_clstate.c
@@ -439,18 +439,6 @@ nfscl_deleg(mount_t mp, struct nfsclclient *clp, u_int8_t 
*nfhp,
 
KASSERT(mp != NULL, ("nfscl_deleg: mp NULL"));
nmp = VFSTONFS(mp);
-   /*
-* First, if we have received a Read delegation for a file on a
-* read/write file system, just return it, because they aren't
-* useful, imho.
-*/
-   if (dp != NULL && !NFSMNT_RDONLY(mp) &&
-   (dp->nfsdl_flags & NFSCLDL_READ)) {
-   nfscl_trydelegreturn(dp, cred, nmp, p);
-   free(dp, M_NFSCLDELEG);
-   *dpp = NULL;
-   return (0);
-   }
 
/*
 * Since a delegation might be added to the mount,
@@ -478,17 +466,35 @@ nfscl_deleg(mount_t mp, struct nfsclclient *clp, u_int8_t 
*nfhp,
nfscl_delegcnt++;
} else {
/*
-* Delegation already exists, what do we do if a new one??
+* A delegation already exists.  If the new one is a Write
+* delegation and the old one a Read delegation, return the
+* Read delegation.  Otherwise, return the new delegation.
 */
if (dp != NULL) {
-   printf("Deleg already exists!\n");
-   free(dp, M_NFSCLDELEG);
-   *dpp = NULL;
+   if ((dp->nfsdl_flags & NFSCLDL_WRITE) != 0 &&
+   (tdp->nfsdl_flags & NFSCLDL_READ) != 0) {
+   TAILQ_REMOVE(&clp->nfsc_deleg, tdp, nfsdl_list);
+   LIST_REMOVE(tdp, nfsdl_hash);
+   *dpp = NULL;
+   TAILQ_INSERT_HEAD(&clp->nfsc_deleg, dp,
+   nfsdl_list);
+   LIST_INSERT_HEAD(NFSCLDELEGHASH(clp, nfhp,
+   fhlen), dp, nfsdl_hash);
+   dp->nfsdl_timestamp = NFSD_MONOSEC + 120;
+   } else {
+   *dpp = NULL;
+   tdp = dp;   /* Return this one. */
+   }
} else {
*dpp = tdp;
+   tdp = NULL;
}
}
NFSUNLOCKCLSTATE();
+   if (tdp != NULL) {
+   nfscl_trydelegreturn(tdp, cred, nmp, p);
+   free(tdp, M_NFSCLDELEG);
+   }
return (0);
 }
 
diff --git a/sys/fs/nfsclient/nfs_clsubs.c b/sys/fs/nfsclient/nfs_clsubs.c
index 80ab979d22d7..8bb51e29e1d1 100644
--- a/sys/fs/nfsclient/nfs_clsubs.c
+++ b/sys/fs/nfsclient/nfs_clsubs.c
@@ -188,7 +188,7 @@ ncl_getattrcache(struct vnode *vp, struct vattr *vaper)
np = VTONFS(vp);
vap = &np->n_vattr.na_vattr;
nmp = VFSTONFS(vp->v_mount);
-   mustflush = nfscl_mustflush(vp);/* must be before mtx_lock() */
+   mustflush = nfscl_nodeleg(vp, 0);   /* must be before mtx_lock() */
NFSLOCKNODE(np);
/* XXX n_mtime doesn't seem to be updated on a miss-and-reload */
timeo = (time_second - np->n_mtime.tv_sec) / 10;
@@ -221,8 +221,8 @@ ncl_getattrcache(struct vnode *vp, struct vattr *vaper)
(time_second - np->n_attrstamp), timeo);
 #endif
 
-   if ((time_second - np->n_attrstamp) >= timeo &&
-  

git: a16cb8709de7 - main - tzsetup: Correct UTC description

2024-06-12 Thread Ed Maste
The branch main has been updated by emaste:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=a16cb8709de7ddc6dd6ab71918af9fc5fd96f377

commit a16cb8709de7ddc6dd6ab71918af9fc5fd96f377
Author: Ed Maste 
AuthorDate: 2024-06-13 00:08:04 +
Commit: Ed Maste 
CommitDate: 2024-06-13 00:24:49 +

tzsetup: Correct UTC description

UTC is Coordinated Universal Time, not Greenwich Mean Time.

Reviewed by:imp, allanjude
MFC after:  1 week
Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45573
---
 usr.sbin/tzsetup/tzsetup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/usr.sbin/tzsetup/tzsetup.c b/usr.sbin/tzsetup/tzsetup.c
index fee5762b6fa6..617de4efb765 100644
--- a/usr.sbin/tzsetup/tzsetup.c
+++ b/usr.sbin/tzsetup/tzsetup.c
@@ -957,7 +957,7 @@ main(int argc, char **argv)
"If it is set to local time,\n"
"or you don't know, please choose NO here!");
 
-   conf.title = "Select local or UTC (Greenwich Mean Time) clock";
+   conf.title = "Select local or UTC (Coordinated Universal Time) 
clock";
if (bsddialog_yesno(&conf, prompt, 7, 73) == BSDDIALOG_YES) {
if (reallydoit)
unlink(path_wall_cmos_clock);