ral(4) 11n? I have spare hardware

2022-04-08 Thread stolen data
It's been great seeing iwm/iwn/iwx/athn getting a lot of updates lately. I
wonder if there's any work planned for getting 11n support to some of the
older but still capable Realtek chipsets in ral(4)?

I have a spare RT2860+RT2820 PCI card - Edimax EW-7728In - that I could
part with if any developer would be interested. Perhaps stsp@?


Re: [External] : Re: pfsync(4) snapshot lists must have dedicated link element

2022-04-08 Thread Alexandr Nedvedicky
Hello,

thank you for taking a look at it.


> 
> I think there is a use after free in you diff.  After you return
> from pfsync_delete_tdb() you must not access the TDB again.
> 
> Comments inline.
> 


> >
> > TAILQ_INIT(&sn->sn_upd_req_list);
> > -   TAILQ_CONCAT(&sn->sn_upd_req_list, &sc->sc_upd_req_list, ur_entry);
> > +   while (!TAILQ_EMPTY(&sc->sc_upd_req_list)) {
> > +   ur = TAILQ_FIRST(&sc->sc_upd_req_list);
> 
> Other loops have this idiom
> while ((ur = TAILQ_FIRST(&sc->sc_upd_req_list) != NULL) {
> 

new diff version uses 'TAILQ_FIRST()'


> > @@ -1827,18 +1853,20 @@ pfsync_sendout(void)
> > subh = (struct pfsync_subheader *)(m->m_data + offset);
> > offset += sizeof(*subh);
> >
> > -   mtx_enter(&sc->sc_tdb_mtx);
> > count = 0;
> > while ((t = TAILQ_FIRST(&sn.sn_tdb_q)) != NULL) {
> > -   TAILQ_REMOVE(&sn.sn_tdb_q, t, tdb_sync_entry);
> > +   TAILQ_REMOVE(&sn.sn_tdb_q, t, tdb_sync_snap);
> 
> I think the TDB in tdb_sync_snap list may be freed.  Maybe
> you should grab a refcount if you store them into a list.
> 

I see. pfsync must grab the reference count in pfsync_update_tdb(),
where tdb entry is inserted into queue. new diff  fixes that.

> > pfsync_out_tdb(t, m->m_data + offset);
> > offset += sizeof(struct pfsync_tdb);
> > +#ifdef PFSYNC_DEBUG
> > +   KASSERT(t->tdb_snapped == 1);
> > +#endif
> > +   t->tdb_snapped = 0;
> 
> This may also be use after free.

new diffs drops the reference as soon as pfsync(4) dispatches
the tdb into pfsync packet.


> > @@ -2525,7 +2565,17 @@ pfsync_delete_tdb(struct tdb *t)
> >
> > mtx_enter(&sc->sc_tdb_mtx);
> >
> > +   /*
> > +* if tdb entry is just being processed (found in snapshot),
> > +* then it can not be deleted. we just came too late
> > +*/
> > +   if (t->tdb_snapped) {
> > +   mtx_leave(&sc->sc_tdb_mtx);
> 
> You must not access the TDB after this point.  I thnik you cannot
> guarantee that.  The memory will freed after return.

new diff fixes that


> > diff --git a/sys/netinet/ip_ipsp.h b/sys/netinet/ip_ipsp.h
> > index c697994047b..ebdb6ada1ae 100644
> > --- a/sys/netinet/ip_ipsp.h
> > +++ b/sys/netinet/ip_ipsp.h
> > @@ -405,6 +405,7 @@ struct tdb {/* tunnel 
> > descriptor block */
> > u_int8_ttdb_wnd;/* Replay window */
> > u_int8_ttdb_satype; /* SA type (RFC2367, PF_KEY) */
> > u_int8_ttdb_updates;/* pfsync update counter */
> > +   u_int8_ttdb_snapped;/* dispatched by pfsync(4) */
> 
> u_int8_t is not atomic.  I you want to change tdb_snapped, you need
> a mutex that also protects the othere fields in the same 32 bit
> word everywhere.  I think a new flag TDBF_PFSYNC_SNAPPED in tdb_flags
> would be easier.  The tdb_flags are protected by tdb_mtx.
> 

I like your idea.

updated diff is below.


thanks and
regards
sashan

8<---8<---8<--8<
diff --git a/sys/net/if_pfsync.c b/sys/net/if_pfsync.c
index cb0f3fbdf52..536c3f9cb70 100644
--- a/sys/net/if_pfsync.c
+++ b/sys/net/if_pfsync.c
@@ -181,6 +181,7 @@ voidpfsync_q_del(struct pf_state *);
 
 struct pfsync_upd_req_item {
TAILQ_ENTRY(pfsync_upd_req_item)ur_entry;
+   TAILQ_ENTRY(pfsync_upd_req_item)ur_snap;
struct pfsync_upd_req   ur_msg;
 };
 TAILQ_HEAD(pfsync_upd_reqs, pfsync_upd_req_item);
@@ -295,7 +296,7 @@ voidpfsync_bulk_update(void *);
 void   pfsync_bulk_fail(void *);
 
 void   pfsync_grab_snapshot(struct pfsync_snapshot *, struct pfsync_softc *);
-void   pfsync_drop_snapshot(struct pfsync_snapshot *, struct pfsync_softc *);
+void   pfsync_drop_snapshot(struct pfsync_snapshot *);
 
 void   pfsync_send_dispatch(void *);
 void   pfsync_send_pkt(struct mbuf *);
@@ -422,8 +423,7 @@ pfsync_clone_destroy(struct ifnet *ifp)
sc->sc_deferred = 0;
mtx_leave(&sc->sc_deferrals_mtx);
 
-   while (!TAILQ_EMPTY(&deferrals)) {
-   pd = TAILQ_FIRST(&deferrals);
+   while ((pd = TAILQ_FIRST(&deferrals)) != NULL) {
TAILQ_REMOVE(&deferrals, pd, pd_entry);
pfsync_undefer(pd, 0);
}
@@ -1574,6 +1574,9 @@ void
 pfsync_grab_snapshot(struct pfsync_snapshot *sn, struct pfsync_softc *sc)
 {
int q;
+   struct pf_state *st;
+   struct pfsync_upd_req_item *ur;
+   struct tdb *tdb;
 
sn->sn_sc = sc;
 
@@ -1583,14 +1586,36 @@ pfsync_grab_snapshot(struct pfsync_snapshot *sn, struct 
pfsync_softc *sc)
 
for (q = 0; q < PFSYNC_S_COUNT; q++) {
TAILQ_INIT(&sn->sn_qs[q]);
-   TAILQ_CONCAT(&sn->sn_qs[q], &sc->sc_qs[q], sync_list);
+
+   while ((st = TAILQ_FIRST(

Re: patch: if_iwx.c add support for ax201 with subsystem id 0x0030

2022-04-08 Thread Sven Wolf

Hi Stefan,

on my device WL_22500_8 0x4df0 this patch doesn't work directly.
I get the error message:
iwx0: could not load firmware, 35
iwx0: failed to load init firmware

Under Linux the firmware iwlwifi-QuZ-a0-hr-b0-67.ucode is loaded for 
this device. Also my old patch 
(https://marc.info/?l=openbsd-bugs&m=164201744804674&w=2) works with the 
firmware for the WL_22500_5 devices.


With this small patch to your patch, wireless is working.

*** 9829,9834 
--- 9829,9835 
break;
case PCI_PRODUCT_INTEL_WL_22500_2:
case PCI_PRODUCT_INTEL_WL_22500_5:
+   case PCI_PRODUCT_INTEL_WL_22500_8:
/* These devices should be QuZ only. */
if (sc->sc_hw_rev != IWX_CSR_HW_REV_TYPE_QUZ) {
printf("%s: unsupported AX201 adapter\n", DEVNAME(sc));
***
*** 9858,9864 
break;
case PCI_PRODUCT_INTEL_WL_22500_4:
case PCI_PRODUCT_INTEL_WL_22500_7:
-   case PCI_PRODUCT_INTEL_WL_22500_8:
if (sc->sc_hw_rev != IWX_CSR_HW_REV_TYPE_QUZ)
sc->sc_fwname = IWX_QU_B_HR_B_FW;
else
--- 9859,9864 


Thanks,
Sven



On 4/8/22 14:40, Stefan Sperling wrote:

On Tue, Jan 11, 2022 at 10:33:39PM +, Iraklis Karagkiozoglou wrote:

Hello Stefan,

I tried to port the firmware detection and config values
from iwlwifi.

On iwx_cfg_trans_params and iwx_cfg structs I ported only
the fields iwx_attach was setting based on the iwx_device.

With best regards,
Iraklis Karagkiozoglou


Hi Iraklis,

It took me some time to get back to this, sorry about that.

The new patch below attempts to add support for any AX200/AX201 devices
which have firmware available in fw_update(4). This will hopefully cover
devices which people have reported as not detected and which should
already be working as long as we load the correct firmware image.

This new patch is based on your patch from January.
Thank you very much for doing the initial work on this.

After studying the Linux driver for some time I believe the following
approach could work for us: We only need a table for devices which
require overrides that cannot be detected on PCI vendor/product ID alone.
The rest of the Linux driver's table is not needed. We can simply set
default values based on the PCI vendor/product ID as we have always done.

My AX200 and AX201 devices are still working fine with this.
Tests on more devices would be very welcome, especially ones that are
not yet detected in -current.


diff refs/heads/master refs/heads/iwx-match
blob - df5614f9f6140ba069db8d60e724b1ab36d124a2
blob + 69f489127b1a6898d12f5f5b2683cb7b3558293b
--- share/man/man4/iwx.4
+++ share/man/man4/iwx.4
@@ -84,8 +84,12 @@ which are loaded when an interface is brought up:
  .Pp
  .Bl -tag -width Ds -offset indent -compact
  .It Pa /etc/firmware/iwx-cc-a0-67
-.It Pa /etc/firmware/iwx-QuZ-a0-hr-b0-67
+.It Pa /etc/firmware/iwx-Qu-b0-hr-b0-63
+.It Pa /etc/firmware/iwx-Qu-b0-jf-b0-63
  .It Pa /etc/firmware/iwx-Qu-c0-hr-b0-63
+.It Pa /etc/firmware/iwx-Qu-c0-jf-b0-63
+.It Pa /etc/firmware/iwx-QuZ-a0-hr-b0-67
+.It Pa /etc/firmware/iwx-QuZ-a0-jf-b0-63
  .El
  .Pp
  These firmware files are not free because Intel refuses to grant
blob - 11f582e67321c9782b9cb38e6ce948b465522c94
blob + 9ffa40d1606fc261ed610984b82e0dbcada90340
--- sys/dev/pci/if_iwx.c
+++ sys/dev/pci/if_iwx.c
@@ -491,6 +491,7 @@ int iwx_intr_msix(void *);
  int   iwx_match(struct device *, void *, void *);
  int   iwx_preinit(struct iwx_softc *);
  void  iwx_attach_hook(struct device *);
+const struct iwx_device_cfg *iwx_find_device_cfg(struct iwx_softc *);
  void  iwx_attach(struct device *, struct device *, void *);
  void  iwx_init_task(void *);
  int   iwx_activate(struct device *, int);
@@ -870,7 +871,7 @@ iwx_ctxt_info_init(struct iwx_softc *sc, const struct
/* size is in DWs */
ctxt_info->version.size = htole16(sizeof(*ctxt_info) / 4);
  
-	if (sc->sc_device_family >= IWX_DEVICE_FAMILY_22560)

+   if (sc->sc_device_family >= IWX_DEVICE_FAMILY_AX210)
rb_size = IWX_CTXT_INFO_RB_SIZE_2K;
else
rb_size = IWX_CTXT_INFO_RB_SIZE_4K;
@@ -9392,61 +9393,192 @@ static const struct pci_matchid iwx_devices[] = {
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WL_22500_3 },
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WL_22500_4,},
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WL_22500_5,},
+   { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WL_22500_6,},
+   { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WL_22500_7,},
+   { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WL_22500_8,},
  };
  
-static const struct pci_matchid iwx_subsystem_id_ax201[] = {

-   { PCI_VENDOR_INTEL, 0x0070 },
-   { PCI_VENDOR_INTEL, 0x0074 },
-   { PCI_VENDOR_INTEL, 0x0078 },
-   { PCI_VENDOR_INTEL, 0x007c },
-   { PCI_VENDOR_INTEL, 0x0310 },
-   { PCI_VENDOR_INTEL, 0x2074 },
-   { PCI_VENDOR_INTEL, 0x4

atascsi: constify method tables

2022-04-08 Thread Christian Weisgerber
This constifies the method tables used by the atascsi framework and
the ahci(4) and sili(4) drivers.

ok?
 
diff 9939c0709df17eb9b8160ad1561241ed2c4b8922 
83fd09f48cb0df5e29a782b651c4210e90f90b00
blob - 46c681203e8e39e25167f98907a2ecc848e9d1a4
blob + 19f61480e83314afe9d58d24b52e1b1d7e64ea93
--- sys/dev/ata/atascsi.c
+++ sys/dev/ata/atascsi.c
@@ -42,7 +42,7 @@ struct atascsi {
 
struct atascsi_host_port **as_host_ports;
 
-   struct atascsi_methods  *as_methods;
+   const struct atascsi_methods *as_methods;
struct scsi_adapter as_switch;
struct scsibus_softc*as_scsibus;
 
blob - a992001e82c39dbc9305141c08264956e890348b
blob + bf39ea0667b241a5cfc1118ed3890d2d6cf967f6
--- sys/dev/ata/atascsi.h
+++ sys/dev/ata/atascsi.h
@@ -374,7 +374,7 @@ struct atascsi_methods {
 struct atascsi_attach_args {
void*aaa_cookie;
 
-   struct atascsi_methods  *aaa_methods;
+   const struct atascsi_methods *aaa_methods;
void(*aaa_minphys)(struct buf *,
struct scsi_link *);
int aaa_nports;
blob - 571b29c29c4bd1113fca3314b6cf50f95db89bd0
blob + 46bf2f4526aa772461a011abe35a837c0d8ef300
--- sys/dev/ic/ahci.c
+++ sys/dev/ic/ahci.c
@@ -160,7 +160,7 @@ struct ata_xfer *   ahci_ata_get_xfer(void *, int);
 void   ahci_ata_put_xfer(struct ata_xfer *);
 void   ahci_ata_cmd(struct ata_xfer *);
 
-struct atascsi_methods ahci_atascsi_methods = {
+const struct atascsi_methods ahci_atascsi_methods = {
ahci_ata_probe,
ahci_ata_free,
ahci_ata_get_xfer,
blob - b2df117d41b126204e110facccb6dc7050dea347
blob + fecd665bfe4f985c244fc281e861cf62ebef615b
--- sys/dev/ic/sili.c
+++ sys/dev/ic/sili.c
@@ -202,7 +202,7 @@ voidsili_simulate_error(struct 
sili_ccb *ccb,
int *need_restart, int *err_port);
 #endif
 
-struct atascsi_methods sili_atascsi_methods = {
+const struct atascsi_methods sili_atascsi_methods = {
sili_ata_probe,
sili_ata_free,
sili_ata_get_xfer,

-- 
Christian "naddy" Weisgerber  na...@mips.inka.de



uoak*(4): constify method tables

2022-04-08 Thread Christian Weisgerber
This constifies the method tables in the OAK USB sensor drivers.
Bycatch from the ucom changes.

ok?
 
diff b29fcdeeb3e7dfaa7565194eb526a7ece255a8a8 
9939c0709df17eb9b8160ad1561241ed2c4b8922
blob - 789cef98e6a9a4d88bbb19b33e1801396618c591
blob + 511c0e62aec982253cdf4b27ae2af3e020cc6f9f
--- sys/dev/usb/uoak.h
+++ sys/dev/usb/uoak.h
@@ -133,7 +133,7 @@ struct uoak_softc {
struct uoak_config   sc_config[OAK_TARGET_MAXTYPES];
 
/* device specific methods */
-   struct uoak_methods  *sc_methods;
+   const struct uoak_methods *sc_methods;
 };
 
 
blob - d04fd5c5823740d5071c611c07f0dbe6249f6dfc
blob + 1ce4d75968d1031d4a610fd0535e46491874cd63
--- sys/dev/usb/uoaklux.c
+++ sys/dev/usb/uoaklux.c
@@ -96,7 +96,7 @@ const struct cfattach uoaklux_ca = {
uoaklux_detach,
 };
 
-struct uoak_methods uoaklux_methods = {
+const struct uoak_methods uoaklux_methods = {
uoaklux_dev_print,
uoaklux_dev_setting
 };
blob - 0257f4ee36873f494ad336150b26a3d51aa302e9
blob + ad54d29cdaf560cbc7120d846ee416bb59204b6f
--- sys/dev/usb/uoakrh.c
+++ sys/dev/usb/uoakrh.c
@@ -99,7 +99,7 @@ const struct cfattach uoakrh_ca = {
uoakrh_detach,
 };
 
-struct uoak_methods uoakrh_methods = {
+const struct uoak_methods uoakrh_methods = {
uoakrh_dev_print,
uoakrh_dev_setting
 };
blob - 011f5c858aa4c9b5d39a472a10eae7e05ba7148c
blob + 9f53491997ad6c1f3487079aca808a3046d2fb37
--- sys/dev/usb/uoakv.c
+++ sys/dev/usb/uoakv.c
@@ -100,7 +100,7 @@ const struct cfattach uoakv_ca = {
 
 };
 
-struct uoak_methods uoakv_methods = {
+const struct uoak_methods uoakv_methods = {
uoakv_dev_print,
uoakv_dev_setting
 };

-- 
Christian "naddy" Weisgerber  na...@mips.inka.de



ucom(4): constify method tables in USB serial drivers

2022-04-08 Thread Christian Weisgerber
This constifies the ucom method tables in the USB serial adapter
drivers, i.e., moves another kilobyte of function pointers into
read-only space.

ok?

diff 4df278d953b03573222cb39b422e005d4701614e 
b29fcdeeb3e7dfaa7565194eb526a7ece255a8a8
blob - 0f5d4bed40c58062bd043d0366485629d59c53cd
blob + bb96ad9ba3263b2647683d45bbb429ee0821c66e
--- sys/dev/usb/moscom.c
+++ sys/dev/usb/moscom.c
@@ -145,7 +145,7 @@ int moscom_param(void *, int, struct termios *);
 intmoscom_open(void *, int);
 intmoscom_cmd(struct moscom_softc *, int, int);
 
-struct ucom_methods moscom_methods = {
+const struct ucom_methods moscom_methods = {
NULL,
moscom_set,
moscom_param,
blob - 10b5df793ce6c39a343cedc1b375831fd7111fa9
blob + 02460365a0dbdd5f7dea9adb18da1667f224a2cb
--- sys/dev/usb/uark.c
+++ sys/dev/usb/uark.c
@@ -72,7 +72,7 @@ int   uark_param(void *, int, struct termios *);
 void   uark_break(void *, int, int);
 intuark_cmd(struct uark_softc *, uint16_t, uint16_t);
 
-struct ucom_methods uark_methods = {
+const struct ucom_methods uark_methods = {
uark_get_status,
uark_set,
uark_param,
blob - 1ca8871433d18ee8f427b1d25179e04e57e01c74
blob + 537ce7248f148f73e7343eaa041e15de8ec3eac6
--- sys/dev/usb/ubsa.c
+++ sys/dev/usb/ubsa.c
@@ -178,7 +178,7 @@ void ubsa_databits(struct ubsa_softc *, tcflag_t);
 void ubsa_stopbits(struct ubsa_softc *, tcflag_t);
 void ubsa_flow(struct ubsa_softc *, tcflag_t, tcflag_t);
 
-struct ucom_methods ubsa_methods = {
+const struct ucom_methods ubsa_methods = {
ubsa_get_status,
ubsa_set,
ubsa_param,
blob - 654b891542c81e1728ff9c49813441fe2da45048
blob + c8582f320d5756565f5b0e0398f7a91c4496d415
--- sys/dev/usb/uchcom.c
+++ sys/dev/usb/uchcom.c
@@ -215,7 +215,7 @@ int uchcom_match(struct device *, void *, void *);
 void   uchcom_attach(struct device *, struct device *, void *);
 intuchcom_detach(struct device *, int);
 
-struct ucom_methods uchcom_methods = {
+const struct ucom_methods uchcom_methods = {
uchcom_get_status,
uchcom_set,
uchcom_param,
blob - 8a4482fac9b511186211a5c3c83421da3db249b8
blob + 90fa0e99d53283b3d05b62d506a8bc0265698550
--- sys/dev/usb/ucom.c
+++ sys/dev/usb/ucom.c
@@ -102,7 +102,7 @@ struct ucom_softc {
struct usbd_pipe*sc_ipipe;  /* hid interrupt input pipe */
struct usbd_pipe*sc_opipe;  /* hid interrupt pipe */
 
-   struct ucom_methods *sc_methods;
+   const struct ucom_methods *sc_methods;
void*sc_parent;
int sc_portno;
 
blob - 216725b439b347c9acc33a5ff3c46a6ac1a49aea
blob + 321eed5ce3d61e64ed374b74f0555941e4a61f6b
--- sys/dev/usb/ucomvar.h
+++ sys/dev/usb/ucomvar.h
@@ -93,7 +93,7 @@ struct ucom_attach_args {
const char *info;   /* attach message */
struct usbd_device *device;
struct usbd_interface *iface;
-   struct ucom_methods *methods;
+   const struct ucom_methods *methods;
void *arg;
 };
 
blob - 4136a4752bd02d1ff2baf1665825a5b88339a782
blob + 9d17df368adb089ba19af989396808651720f271
--- sys/dev/usb/ucrcom.c
+++ sys/dev/usb/ucrcom.c
@@ -36,7 +36,7 @@ struct ucrcom_softc {
struct device   *sc_subdev;
 };
 
-struct ucom_methods ucrcom_methods = { NULL };
+const struct ucom_methods ucrcom_methods = { NULL };
 
 int ucrcom_match(struct device *, void *, void *);
 void ucrcom_attach(struct device *, struct device *, void *);
blob - cd1feaeedc005b29b1ec3b15388d0ea4fb3578e7
blob + d3bd683db41e947ada0caf3db8e8a5ea1caaa8bd
--- sys/dev/usb/ucycom.c
+++ sys/dev/usb/ucycom.c
@@ -129,7 +129,7 @@ voiducycom_close(void *, int);
 void   ucycom_write(void *, int, u_char *, u_char *, u_int32_t *);
 void   ucycom_read(void *, int, u_char **, u_int32_t *);
 
-struct ucom_methods ucycom_methods = {
+const struct ucom_methods ucycom_methods = {
NULL, /* ucycom_get_status, */
ucycom_set,
ucycom_param,
blob - fb7b8ae8621207b77e449e1461ad0fab764f1378
blob + 2e3f33863d4e3f91459a29a3bff05c585fdba167
--- sys/dev/usb/uftdi.c
+++ sys/dev/usb/uftdi.c
@@ -100,7 +100,7 @@ voiduftdi_break(void *sc, int portno, int onoff);
 intuftdi_8u232am_getrate(speed_t speed, int *rate);
 intuftdi_2232h_getrate(speed_t speed, int *rate);
 
-struct ucom_methods uftdi_methods = {
+const struct ucom_methods uftdi_methods = {
uftdi_get_status,
uftdi_set,
uftdi_param,
blob - 7ab16eb894ec27b7ad3e4c4783b342cffcd273c1
blob + dc2321ebfc86883ca67de5f913e3c6acc7eb4434
--- sys/dev/usb/uipaq.c
+++ sys/dev/usb/uipaq.c
@@ -94,7 +94,7 @@ void  uipaq_rts(struct uipaq_softc *sc, int onoff);
 void   uipaq_break(struct uipaq_softc* sc, int onoff);
 
 
-struct ucom_methods uipaq_methods = {
+const struct ucom_methods uipaq_methods = {
NULL,
uipaq_set,
NULL,
blob - be42faf696ebae3710e7aafe33a77481e28c9cfa
blob + 2f7dc60b684168fac1dcef7c67db9d8408

[ouex]hci(4), dwctwo(4): constify bus/pipe method tables

2022-04-08 Thread Christian Weisgerber
This constifies the bus method and pipe method tables in our USB
host controller drivers.

dwctwo(4) only exists on octeon, which I don't have access to.
Could somebody check that it builds?

ok?
 
diff b5489662588c813212f71c840fa931535322293d 
4df278d953b03573222cb39b422e005d4701614e
blob - 9b9d1635f902afef00a4111dfba8f86d13f74b4e
blob + 531b5ce59fdf62019b590df2868d57cc88912f31
--- sys/dev/usb/dwc2/dwc2.c
+++ sys/dev/usb/dwc2/dwc2.c
@@ -146,7 +146,7 @@ dwc2_free_bus_bandwidth(struct dwc2_hsotg *hsotg, u16 
 
 #define DWC2_INTR_ENDPT 1
 
-STATIC struct usbd_bus_methods dwc2_bus_methods = {
+STATIC const struct usbd_bus_methods dwc2_bus_methods = {
.open_pipe =dwc2_open,
.dev_setaddr =  dwc2_setaddr,
.soft_intr =dwc2_softintr,
@@ -155,7 +155,7 @@ STATIC struct usbd_bus_methods dwc2_bus_methods = {
.freex =dwc2_freex,
 };
 
-STATIC struct usbd_pipe_methods dwc2_root_ctrl_methods = {
+STATIC const struct usbd_pipe_methods dwc2_root_ctrl_methods = {
.transfer = dwc2_root_ctrl_transfer,
.start =dwc2_root_ctrl_start,
.abort =dwc2_root_ctrl_abort,
@@ -164,7 +164,7 @@ STATIC struct usbd_pipe_methods dwc2_root_ctrl_methods
.done = dwc2_root_ctrl_done,
 };
 
-STATIC struct usbd_pipe_methods dwc2_root_intr_methods = {
+STATIC const struct usbd_pipe_methods dwc2_root_intr_methods = {
.transfer = dwc2_root_intr_transfer,
.start =dwc2_root_intr_start,
.abort =dwc2_root_intr_abort,
@@ -173,7 +173,7 @@ STATIC struct usbd_pipe_methods dwc2_root_intr_methods
.done = dwc2_root_intr_done,
 };
 
-STATIC struct usbd_pipe_methods dwc2_device_ctrl_methods = {
+STATIC const struct usbd_pipe_methods dwc2_device_ctrl_methods = {
.transfer = dwc2_device_ctrl_transfer,
.start =dwc2_device_ctrl_start,
.abort =dwc2_device_ctrl_abort,
@@ -182,7 +182,7 @@ STATIC struct usbd_pipe_methods dwc2_device_ctrl_metho
.done = dwc2_device_ctrl_done,
 };
 
-STATIC struct usbd_pipe_methods dwc2_device_intr_methods = {
+STATIC const struct usbd_pipe_methods dwc2_device_intr_methods = {
.transfer = dwc2_device_intr_transfer,
.start =dwc2_device_intr_start,
.abort =dwc2_device_intr_abort,
@@ -191,7 +191,7 @@ STATIC struct usbd_pipe_methods dwc2_device_intr_metho
.done = dwc2_device_intr_done,
 };
 
-STATIC struct usbd_pipe_methods dwc2_device_bulk_methods = {
+STATIC const struct usbd_pipe_methods dwc2_device_bulk_methods = {
.transfer = dwc2_device_bulk_transfer,
.start =dwc2_device_bulk_start,
.abort =dwc2_device_bulk_abort,
@@ -200,7 +200,7 @@ STATIC struct usbd_pipe_methods dwc2_device_bulk_metho
.done = dwc2_device_bulk_done,
 };
 
-STATIC struct usbd_pipe_methods dwc2_device_isoc_methods = {
+STATIC const struct usbd_pipe_methods dwc2_device_isoc_methods = {
.transfer = dwc2_device_isoc_transfer,
.start =dwc2_device_isoc_start,
.abort =dwc2_device_isoc_abort,
blob - 350580c00b30f8edcfd5edf8ad8d1734624462c6
blob + 77c170f164432f7df92fe7dcd64b5df9fd079dd9
--- sys/dev/usb/ehci.c
+++ sys/dev/usb/ehci.c
@@ -218,7 +218,7 @@ voidehci_dump_exfer(struct ehci_xfer *);
 
 #define EHCI_INTR_ENDPT 1
 
-struct usbd_bus_methods ehci_bus_methods = {
+const struct usbd_bus_methods ehci_bus_methods = {
.open_pipe = ehci_open,
.dev_setaddr = ehci_setaddr,
.soft_intr = ehci_softintr,
@@ -227,7 +227,7 @@ struct usbd_bus_methods ehci_bus_methods = {
.freex = ehci_freex,
 };
 
-struct usbd_pipe_methods ehci_root_ctrl_methods = {
+const struct usbd_pipe_methods ehci_root_ctrl_methods = {
.transfer = ehci_root_ctrl_transfer,
.start = ehci_root_ctrl_start,
.abort = ehci_root_ctrl_abort,
@@ -235,7 +235,7 @@ struct usbd_pipe_methods ehci_root_ctrl_methods = {
.done = ehci_root_ctrl_done,
 };
 
-struct usbd_pipe_methods ehci_root_intr_methods = {
+const struct usbd_pipe_methods ehci_root_intr_methods = {
.transfer = ehci_root_intr_transfer,
.start = ehci_root_intr_start,
.abort = ehci_root_intr_abort,
@@ -243,7 +243,7 @@ struct usbd_pipe_methods ehci_root_intr_methods = {
.done = ehci_root_intr_done,
 };
 
-struct usbd_pipe_methods ehci_device_ctrl_methods = {
+const struct usbd_pipe_methods ehci_device_ctrl_methods = {
.transfer = ehci_device_ctrl_transfer,
.start = ehci_device_ctrl_start,
.abort = ehci_device_ctrl_abort,
@@ -251,7 +251,7 @@ struct usbd_pipe_methods ehci_device_ctrl_methods = {
.done = ehci_device_ctrl_done,
 };
 
-struct usbd_pipe_methods ehci_device_intr_methods = {
+const struct usbd_pipe_methods ehci_device_intr_methods = {
.transfer = ehci_device_intr_transfer,
.start = ehci_device_intr_start,
.abort = e

esm(4/i386), it(4): constify sensor tables

2022-04-08 Thread Christian Weisgerber
This constifies the tables of two unrelated sensor drivers:
esm(4/i386) and it(4).

ok?

diff d6a09d27ff49886a6b6f4bd1f7d89c0f90a64b40 refs/heads/const
blob - 0a734dc971d9402e738d08d014555c8afb95827b
blob + e8a4e5eeadcdcfd23c1dd525470e70522272676b
--- sys/arch/i386/i386/esm.c
+++ sys/arch/i386/i386/esm.c
@@ -68,7 +68,7 @@ enum esm_sensor_type {
  * map esm sensor types to kernel sensor types.
  * keep this in sync with the esm_sensor_type enum above.
  */
-enum sensor_type esm_typemap[] = {
+const enum sensor_type esm_typemap[] = {
SENSOR_INTEGER,
SENSOR_INDICATOR,
SENSOR_TEMP,
@@ -149,7 +149,7 @@ voidesm_refresh(void *);
 intesm_get_devmap(struct esm_softc *, int, struct esm_devmap *);
 void   esm_devmap(struct esm_softc *, struct esm_devmap *);
 void   esm_make_sensors(struct esm_softc *, struct esm_devmap *,
-   struct esm_sensor_map *, int);
+   const struct esm_sensor_map *, int);
 intesm_thresholds(struct esm_softc *, struct esm_devmap *,
struct esm_sensor *);
 
@@ -536,7 +536,7 @@ esm_get_devmap(struct esm_softc *sc, int dev, struct e
return (0);
 }
 
-struct esm_sensor_map esm_sensors_esm2[] = {
+const struct esm_sensor_map esm_sensors_esm2[] = {
{ ESM_S_UNKNOWN,0,  "Motherboard" },
{ ESM_S_TEMP,   0,  "CPU 1" },
{ ESM_S_TEMP,   0,  "CPU 2" },
@@ -604,7 +604,7 @@ struct esm_sensor_map esm_sensors_esm2[] = {
{ ESM_S_UNKNOWN,0,  "PS Over Temp" }
 };
 
-struct esm_sensor_map esm_sensors_backplane[] = {
+const struct esm_sensor_map esm_sensors_backplane[] = {
{ ESM_S_UNKNOWN,0,  "Backplane" },
{ ESM_S_UNKNOWN,0,  "Backplane Control" },
{ ESM_S_TEMP,   0,  "Backplane Top" },
@@ -639,7 +639,7 @@ struct esm_sensor_map esm_sensors_backplane[] = {
{ ESM_S_VOLTS,  0,  "Backplane +3.3V" },
 };
 
-struct esm_sensor_map esm_sensors_powerunit[] = {
+const struct esm_sensor_map esm_sensors_powerunit[] = {
{ ESM_S_UNKNOWN,0,  "Power Unit" },
{ ESM_S_VOLTSx10,   0,  "Power Supply 1 +5V" },
{ ESM_S_VOLTSx10,   0,  "Power Supply 1 +12V" },
@@ -698,7 +698,7 @@ struct esm_sensor_map esm_sensors_powerunit[] = {
 void
 esm_devmap(struct esm_softc *sc, struct esm_devmap *devmap)
 {
-   struct esm_sensor_map   *sensor_map = NULL;
+   const struct esm_sensor_map *sensor_map = NULL;
const char  *name = NULL, *fname = NULL;
int mapsize = 0;
 
@@ -828,7 +828,7 @@ esm_devmap(struct esm_softc *sc, struct esm_devmap *de
 
 void
 esm_make_sensors(struct esm_softc *sc, struct esm_devmap *devmap,
-struct esm_sensor_map *sensor_map, int mapsize)
+const struct esm_sensor_map *sensor_map, int mapsize)
 {
struct esm_smb_req  req;
struct esm_smb_resp resp;
blob - 9cdce94a36e88fb46230424e35e0ef1d9c3a8878
blob + 2b8109ca2fa617f88eb012b0dcd0fd040c01
--- sys/dev/isa/it.c
+++ sys/dev/isa/it.c
@@ -70,7 +70,7 @@ int it_wdog_cb(void *, int);
 #define RFACT(x, y)(RFACT_NONE * ((x) + (y)) / (y))
 
 
-struct {
+const struct {
enum sensor_typetype;
const char  *desc;
 } it_sensors[IT_EC_NUMSENSORS] = {
@@ -102,7 +102,7 @@ struct {
 };
 
 /* rfact values for voltage sensors */
-int it_vrfact[IT_VOLT_COUNT] = {
+const int it_vrfact[IT_VOLT_COUNT] = {
RFACT_NONE, /* VCORE_A  */
RFACT_NONE, /* VCORE_A  */
RFACT_NONE, /* +3.3V*/
@@ -114,12 +114,12 @@ int it_vrfact[IT_VOLT_COUNT] = {
RFACT_NONE  /* VBAT */
 };
 
-int it_fan_regs[] = {
+const int it_fan_regs[] = {
IT_EC_FAN_TAC1, IT_EC_FAN_TAC2, IT_EC_FAN_TAC3,
IT_EC_FAN_TAC4_LSB, IT_EC_FAN_TAC5_LSB
 };
 
-int it_fan_ext_regs[] = {
+const int it_fan_ext_regs[] = {
IT_EC_FAN_EXT_TAC1, IT_EC_FAN_EXT_TAC2, IT_EC_FAN_EXT_TAC3,
IT_EC_FAN_TAC4_MSB, IT_EC_FAN_TAC5_MSB
 };
-- 
Christian "naddy" Weisgerber  na...@mips.inka.de



Re: patch: if_iwx.c add support for ax201 with subsystem id 0x0030

2022-04-08 Thread Stefan Sperling
On Tue, Jan 11, 2022 at 10:33:39PM +, Iraklis Karagkiozoglou wrote:
> Hello Stefan,
> 
> I tried to port the firmware detection and config values
> from iwlwifi.
> 
> On iwx_cfg_trans_params and iwx_cfg structs I ported only
> the fields iwx_attach was setting based on the iwx_device.
> 
> With best regards,
> Iraklis Karagkiozoglou

Hi Iraklis,

It took me some time to get back to this, sorry about that.

The new patch below attempts to add support for any AX200/AX201 devices
which have firmware available in fw_update(4). This will hopefully cover
devices which people have reported as not detected and which should
already be working as long as we load the correct firmware image.

This new patch is based on your patch from January.
Thank you very much for doing the initial work on this.

After studying the Linux driver for some time I believe the following
approach could work for us: We only need a table for devices which
require overrides that cannot be detected on PCI vendor/product ID alone.
The rest of the Linux driver's table is not needed. We can simply set
default values based on the PCI vendor/product ID as we have always done.

My AX200 and AX201 devices are still working fine with this.
Tests on more devices would be very welcome, especially ones that are
not yet detected in -current.


diff refs/heads/master refs/heads/iwx-match
blob - df5614f9f6140ba069db8d60e724b1ab36d124a2
blob + 69f489127b1a6898d12f5f5b2683cb7b3558293b
--- share/man/man4/iwx.4
+++ share/man/man4/iwx.4
@@ -84,8 +84,12 @@ which are loaded when an interface is brought up:
 .Pp
 .Bl -tag -width Ds -offset indent -compact
 .It Pa /etc/firmware/iwx-cc-a0-67
-.It Pa /etc/firmware/iwx-QuZ-a0-hr-b0-67
+.It Pa /etc/firmware/iwx-Qu-b0-hr-b0-63
+.It Pa /etc/firmware/iwx-Qu-b0-jf-b0-63
 .It Pa /etc/firmware/iwx-Qu-c0-hr-b0-63
+.It Pa /etc/firmware/iwx-Qu-c0-jf-b0-63
+.It Pa /etc/firmware/iwx-QuZ-a0-hr-b0-67
+.It Pa /etc/firmware/iwx-QuZ-a0-jf-b0-63
 .El
 .Pp
 These firmware files are not free because Intel refuses to grant
blob - 11f582e67321c9782b9cb38e6ce948b465522c94
blob + 9ffa40d1606fc261ed610984b82e0dbcada90340
--- sys/dev/pci/if_iwx.c
+++ sys/dev/pci/if_iwx.c
@@ -491,6 +491,7 @@ int iwx_intr_msix(void *);
 intiwx_match(struct device *, void *, void *);
 intiwx_preinit(struct iwx_softc *);
 void   iwx_attach_hook(struct device *);
+const struct iwx_device_cfg *iwx_find_device_cfg(struct iwx_softc *);
 void   iwx_attach(struct device *, struct device *, void *);
 void   iwx_init_task(void *);
 intiwx_activate(struct device *, int);
@@ -870,7 +871,7 @@ iwx_ctxt_info_init(struct iwx_softc *sc, const struct 
/* size is in DWs */
ctxt_info->version.size = htole16(sizeof(*ctxt_info) / 4);
 
-   if (sc->sc_device_family >= IWX_DEVICE_FAMILY_22560)
+   if (sc->sc_device_family >= IWX_DEVICE_FAMILY_AX210)
rb_size = IWX_CTXT_INFO_RB_SIZE_2K;
else
rb_size = IWX_CTXT_INFO_RB_SIZE_4K;
@@ -9392,61 +9393,192 @@ static const struct pci_matchid iwx_devices[] = {
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WL_22500_3 },
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WL_22500_4,},
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WL_22500_5,},
+   { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WL_22500_6,},
+   { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WL_22500_7,},
+   { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WL_22500_8,},
 };
 
-static const struct pci_matchid iwx_subsystem_id_ax201[] = {
-   { PCI_VENDOR_INTEL, 0x0070 },
-   { PCI_VENDOR_INTEL, 0x0074 },
-   { PCI_VENDOR_INTEL, 0x0078 },
-   { PCI_VENDOR_INTEL, 0x007c },
-   { PCI_VENDOR_INTEL, 0x0310 },
-   { PCI_VENDOR_INTEL, 0x2074 },
-   { PCI_VENDOR_INTEL, 0x4070 },
-   /* TODO: There are more ax201 devices with "main" product ID 0x06f0 */
-};
 
 int
 iwx_match(struct device *parent, iwx_match_t match __unused, void *aux)
 {
struct pci_attach_args *pa = aux;
-   pcireg_t subid;
-   pci_vendor_id_t svid;
-   pci_product_id_t spid;
-   int i;
-
-   if (!pci_matchbyid(pa, iwx_devices, nitems(iwx_devices)))
-   return 0;
-
-   /*
-* Some PCI product IDs are shared among devices which use distinct
-* chips or firmware. We need to match the subsystem ID as well to
-* ensure that we have in fact found a supported device.
-*/
-   subid = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_SUBSYS_ID_REG);
-   svid = PCI_VENDOR(subid);
-   spid = PCI_PRODUCT(subid);
-
-   switch (PCI_PRODUCT(pa->pa_id)) {
-   case PCI_PRODUCT_INTEL_WL_22500_1: /* AX200 */
-   return 1; /* match any device */
-   case PCI_PRODUCT_INTEL_WL_22500_2: /* AX201 */
-   case PCI_PRODUCT_INTEL_WL_22500_3: /* AX201 */
-   case PCI_PRODUCT_INTEL_WL_22500_4: /* AX201 */
-   case PCI_PRODUCT_INTEL_WL_22500_5: /* AX201 */
-   for (i = 0; i < nitems(iwx_subsystem_id_ax201); i++) {

parallel IP forwarding

2022-04-08 Thread Alexander Bluhm
Hi,

I now the right time to commit the parallel forwarding diff?

Known limitiations are:
- Hrvoje has seen a crash with both pfsync and ipsec on his production
  machine.  But he cannot reproduce it in his lab.
- TCP processing gets slower as we have an additional queue between
  IP and protocol layer.
- Protocol layer may starve as 1 exclusive lock is fightig with 4
  shared locks.  This happens only when forwardig a lot.

The advantage of commiting is that we see how relevant these things
are in real world.  But the most important thing is that we learn
how all the locks behave under MP pressure.  You can add a lot of
locking, but only when you run in parallel, you see if it is correct.

An alternative could be to commit it with NET_TASKQ 1.  With only
one softnet thread I would expect to see less bugs, but there is
also less to learn.  NET_TASKQ 1 could be a safe point where we
could easily switch back.

bluhm

Index: net/if.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/net/if.c,v
retrieving revision 1.649
diff -u -p -r1.649 if.c
--- net/if.c25 Feb 2022 23:51:03 -  1.649
+++ net/if.c29 Mar 2022 12:44:05 -
@@ -237,7 +237,7 @@ int ifq_congestion;
 
 int netisr;
 
-#defineNET_TASKQ   1
+#defineNET_TASKQ   4
 struct taskq   *nettqmp[NET_TASKQ];
 
 struct task if_input_task_locked = TASK_INITIALIZER(if_netisr, NULL);
@@ -834,15 +834,10 @@ if_input_process(struct ifnet *ifp, stru
 * lists and the socket layer.
 */
 
-   /*
-* XXXSMP IPsec data structures are not ready to be accessed
-* by multiple network threads in parallel.  In this case
-* use an exclusive lock.
-*/
-   NET_LOCK();
+   NET_RLOCK_IN_SOFTNET();
while ((m = ml_dequeue(ml)) != NULL)
(*ifp->if_input)(ifp, m);
-   NET_UNLOCK();
+   NET_RUNLOCK_IN_SOFTNET();
 }
 
 void
@@ -899,6 +894,12 @@ if_netisr(void *unused)
arpintr();
KERNEL_UNLOCK();
}
+#endif
+   if (n & (1 << NETISR_IP))
+   ipintr();
+#ifdef INET6
+   if (n & (1 << NETISR_IPV6))
+   ip6intr();
 #endif
 #if NPPP > 0
if (n & (1 << NETISR_PPP)) {
Index: net/if_ethersubr.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/net/if_ethersubr.c,v
retrieving revision 1.278
diff -u -p -r1.278 if_ethersubr.c
--- net/if_ethersubr.c  22 Feb 2022 01:15:02 -  1.278
+++ net/if_ethersubr.c  29 Mar 2022 12:44:05 -
@@ -221,7 +221,10 @@ ether_resolve(struct ifnet *ifp, struct 
 
switch (af) {
case AF_INET:
+   KERNEL_LOCK();
+   /* XXXSMP there is a MP race in arpresolve() */
error = arpresolve(ifp, rt, m, dst, eh->ether_dhost);
+   KERNEL_UNLOCK();
if (error)
return (error);
eh->ether_type = htons(ETHERTYPE_IP);
@@ -244,7 +247,10 @@ ether_resolve(struct ifnet *ifp, struct 
break;
 #ifdef INET6
case AF_INET6:
+   KERNEL_LOCK();
+   /* XXXSMP there is a MP race in nd6_resolve() */
error = nd6_resolve(ifp, rt, m, dst, eh->ether_dhost);
+   KERNEL_UNLOCK();
if (error)
return (error);
eh->ether_type = htons(ETHERTYPE_IPV6);
@@ -270,13 +276,19 @@ ether_resolve(struct ifnet *ifp, struct 
break;
 #ifdef INET6
case AF_INET6:
+   KERNEL_LOCK();
+   /* XXXSMP there is a MP race in nd6_resolve() */
error = nd6_resolve(ifp, rt, m, dst, eh->ether_dhost);
+   KERNEL_UNLOCK();
if (error)
return (error);
break;
 #endif
case AF_INET:
+   KERNEL_LOCK();
+   /* XXXSMP there is a MP race in arpresolve() */
error = arpresolve(ifp, rt, m, dst, eh->ether_dhost);
+   KERNEL_UNLOCK();
if (error)
return (error);
break;
@@ -528,12 +540,14 @@ ether_input(struct ifnet *ifp, struct mb
case ETHERTYPE_PPPOE:
if (m->m_flags & (M_MCAST | M_BCAST))
goto dropanyway;
+   KERNEL_LOCK();
 #ifdef PIPEX
if (pipex_enable) {
struct pipex_session *session;
 
if ((session = pipex_pppoe_lookup_session(m)) != NULL) {
pipex_pppoe_input(m, session);
+   KERNEL_UNLOCK();
return;
   

Re: refcount btrace

2022-04-08 Thread Alexander Bluhm
On Fri, Apr 08, 2022 at 02:39:34AM +, Visa Hankala wrote:
> On Thu, Apr 07, 2022 at 07:55:11PM +0200, Alexander Bluhm wrote:
> > On Wed, Mar 23, 2022 at 06:13:27PM +0100, Alexander Bluhm wrote:
> > > In my opinion tracepoints give insight at minimal cost.  It is worth
> > > it to have it in GENERIC to make it easy to use.
> > 
> > After release I want to revive the btrace of refcounts discussion.
> > 
> > As mpi@ mentioned the idea of dt(4) is to have these trace points
> > in GENERIC kernel.  If you want to hunt a bug, just turn it on.
> > Refounting is a common place for bugs, leaks can be detected easily.
> > 
> > The alternative are some defines that you can compile in and access
> > from ddb.  This is more work and you would have to implement it for
> > every recount.
> > https://marc.info/?l=openbsd-tech&m=163786435916039&w=2
> > 
> > There is no measuarable performance difference.  dt(4) is written
> > in a way that is is only one additional branch.  At least my goal
> > is to add trace points to useful places when we identify them.
> 
> DT_INDEX_ENTER() still checks the index first, so it has two branches
> in practice.
> 
> I think dt_tracing should be checked first so that it serves as
> a gateway to the trace code. Under normal operation, the check's
> outcome is always the same, which is easy even for simple branch
> predictors.

Reordering the check is easy.  Now dt_tracing is first.

> I have a slight suspicion that dt(4) is now becoming a way to add code
> that would be otherwise unacceptable. Also, how "durable" are trace
> points perceived? Is an added trace point an achieved advantage that
> is difficult to remove even when its utility has diminished? There is
> a similarity to (ad hoc) debug printfs too.

As I understand dt(4) it is a replacement for debug printfs.  But
it has advantages.  I can be turnd on selectively from userland.
It does not spam the console, but can be processed in userland.  It
is always there, you don't have to recompile.

Of course you always have the printf or tracepoint at the worng
place.  I think people debugging the code should move them to
the useful places.  Then we may end with generally useful tool.
A least that is my hope.

There are obvious places to debug.  We have syscall entry and return.
And I think reference counting is also generally interesting.

bluhm

Index: dev/dt/dt_prov_static.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/dev/dt/dt_prov_static.c,v
retrieving revision 1.13
diff -u -p -r1.13 dt_prov_static.c
--- dev/dt/dt_prov_static.c 17 Mar 2022 14:53:59 -  1.13
+++ dev/dt/dt_prov_static.c 8 Apr 2022 09:40:29 -
@@ -87,6 +87,12 @@ DT_STATIC_PROBE1(smr, barrier_exit, "int
 DT_STATIC_PROBE0(smr, wakeup);
 DT_STATIC_PROBE2(smr, thread, "uint64_t", "uint64_t");
 
+/*
+ * reference counting
+ */
+DT_STATIC_PROBE0(refcnt, none);
+DT_STATIC_PROBE3(refcnt, inpcb, "void *", "int", "int");
+DT_STATIC_PROBE3(refcnt, tdb, "void *", "int", "int");
 
 /*
  * List of all static probes
@@ -127,15 +133,24 @@ struct dt_probe *const dtps_static[] = {
&_DT_STATIC_P(smr, barrier_exit),
&_DT_STATIC_P(smr, wakeup),
&_DT_STATIC_P(smr, thread),
+   /* refcnt */
+   &_DT_STATIC_P(refcnt, none),
+   &_DT_STATIC_P(refcnt, inpcb),
+   &_DT_STATIC_P(refcnt, tdb),
 };
 
+struct dt_probe *const *dtps_index_refcnt;
+
 int
 dt_prov_static_init(void)
 {
int i;
 
-   for (i = 0; i < nitems(dtps_static); i++)
+   for (i = 0; i < nitems(dtps_static); i++) {
+   if (dtps_static[i] == &_DT_STATIC_P(refcnt, none))
+   dtps_index_refcnt = &dtps_static[i];
dt_dev_register_probe(dtps_static[i]);
+   }
 
return i;
 }
Index: dev/dt/dtvar.h
===
RCS file: /data/mirror/openbsd/cvs/src/sys/dev/dt/dtvar.h,v
retrieving revision 1.13
diff -u -p -r1.13 dtvar.h
--- dev/dt/dtvar.h  27 Feb 2022 10:14:01 -  1.13
+++ dev/dt/dtvar.h  8 Apr 2022 09:42:19 -
@@ -313,11 +313,30 @@ extern volatile uint32_t  dt_tracing; /* 
 #defineDT_STATIC_ENTER(func, name, args...) do {   
\
extern struct dt_probe _DT_STATIC_P(func, name);\
struct dt_probe *dtp = &_DT_STATIC_P(func, name);   \
-   struct dt_provider *dtpv = dtp->dtp_prov;   \
\
if (__predict_false(dt_tracing) &&  \
__predict_false(dtp->dtp_recording)) {  \
+   struct dt_provider *dtpv = dtp->dtp_prov;   \
+   \
dtpv->dtpv_enter(dtpv, dtp, args);  \
+   }