On 2020-07-03 20:33, Stefan Sperling wrote:
> On Wed, Jul 01, 2020 at 06:14:50PM -0500, Tim Chase wrote:
> > Just wanted to check back in if there's anything else I can get
> > you to help diagnose this.  
> 
> Please try this patch. It fixes the issue for me.

Sorry it has taken so long to get back to you.  Building a kernel
took ~12hr (finished 2020-07-03 as seen in the dmesg at the bottom
of this reply) and the rest of the base system took another 2 days.

I pulled the latest CVS sources, applied the patch, built, and
rebooted into the new kernel but unfortunately get the same
non-working results as before.  In case it matters, this is an
AR9281 which I imagine should be pretty close to the AR9280 that
you tested.

With the mostly-built kernel present, I can tack on any additional
patches you might need to instrument/debug it and rebuild if needed.
Fortunately, this is a junker non-critical machine, so I can repave
and/or rebuild whatever you need on it.

> Regarding "athn needs cold boot to work":
> Code comments I've seen in Linux suggest that the key table is not
> cleared automatically on some athn devices. There is code in our
> driver which is supposed to clear the on-device crypto key table
> when the interface comes up. This code ran very close in time after
> a full device reset. I suspect it could have run while the device
> wasn't fully initialized yet, and hence fail to reset keys which
> were installed earlier, or write garbage to the key table. Combined
> with the above bug this would lead to hardware using bad key table
> entries which results in decryption failures. This patch should fix
> that problem as well. It clears the table later in the startup
> sequence, and clears on-device keys when the interface is put down.

I've seen this once or twice as well where it would work briefly,
only to stop working and not come back.  I hadn't narrowed it down to
being related to a cold-boot but it also wasn't 100% of the time on
a cold boot.

> I have tested this fix on AR9280 (PCI) and AR9271 (USB), both in
> client and in hostap mode.
> 
> diff refs/heads/master refs/heads/athn-ccmpfix
> blob - 3a28d87bc88a0e7b9ed6c873bd7a07682cc91a0b
> blob + 1d739529d7d214bea314e50e847594dc01021a41
> --- sys/dev/ic/ar5008.c
> +++ sys/dev/ic/ar5008.c
> @@ -811,12 +811,20 @@ ar5008_ccmp_decap(struct athn_softc *sc,
> struct mbuf * /* Sanity checks to ensure this is really a key we
> installed. */ entry = (uintptr_t)k->k_priv;
>       if (k->k_flags & IEEE80211_KEY_GROUP) {
> -             if (k->k_id > IEEE80211_WEP_NKID ||
> +             if (k->k_id >= IEEE80211_WEP_NKID ||
>                   entry != k->k_id)
>                       return 1;
> -     } else if (entry != IEEE80211_WEP_NKID +
> -         IEEE80211_AID(ni->ni_associd))
> -             return 1;
> +     } else {
> +#ifndef IEEE80211_STA_ONLY
> +             if (ic->ic_opmode == IEEE80211_M_HOSTAP) {
> +                     if (entry != IEEE80211_WEP_NKID +
> +                         IEEE80211_AID(ni->ni_associd))
> +                             return 1;
> +             } else
> +#endif
> +                     if (entry != IEEE80211_WEP_NKID)
> +                             return 1;
> +     }
>  
>       /* Check that ExtIV bit is set. */
>       if (!(ivp[3] & IEEE80211_WEP_EXTIV))
> blob - 40725b02c43b54e10a87de333acdfd3b8270534d
> blob + f7aa77ba15cae787a42fdbffb8a9d9cd2d0226d2
> --- sys/dev/ic/athn.c
> +++ sys/dev/ic/athn.c
> @@ -1037,12 +1037,17 @@ athn_set_key(struct ieee80211com *ic,
> struct ieee80211 }
>  
>       if (!(k->k_flags & IEEE80211_KEY_GROUP)) {
> -             entry = IEEE80211_WEP_NKID +
> IEEE80211_AID(ni->ni_associd); +#ifndef IEEE80211_STA_ONLY
> +             if (ic->ic_opmode == IEEE80211_M_HOSTAP)
> +                     entry = IEEE80211_WEP_NKID +
> IEEE80211_AID(ni->ni_associd);
> +             else
> +#endif
> +                     entry = IEEE80211_WEP_NKID;
>               if (entry >= sc->kc_entries - IEEE80211_WEP_NKID)
>                       return ENOSPC;
>       } else {
>               entry = k->k_id;
> -             if (entry > IEEE80211_WEP_NKID)
> +             if (entry >= IEEE80211_WEP_NKID)
>                       return ENOSPC;
>       }
>       k->k_priv = (void *)entry;
> @@ -3056,10 +3061,6 @@ athn_init(struct ifnet *ifp)
>       else
>               athn_config_pcie(sc);
>  
> -     /* Reset HW key cache entries. */
> -     for (i = 0; i < sc->kc_entries; i++)
> -             athn_reset_key(sc, i);
> -
>       ops->enable_antenna_diversity(sc);
>  
>  #ifdef ATHN_BT_COEXISTENCE
> @@ -3086,6 +3087,10 @@ athn_init(struct ifnet *ifp)
>       /* Enable Rx. */
>       athn_rx_start(sc);
>  
> +     /* Reset HW key cache entries. */
> +     for (i = 0; i < sc->kc_entries; i++)
> +             athn_reset_key(sc, i);
> +
>       /* Enable interrupts. */
>       athn_enable_interrupts(sc);
>  
> @@ -3121,7 +3126,7 @@ athn_stop(struct ifnet *ifp, int disable)
>  {
>       struct athn_softc *sc = ifp->if_softc;
>       struct ieee80211com *ic = &sc->sc_ic;
> -     int qid;
> +     int qid, i;
>  
>       ifp->if_timer = sc->sc_tx_timer = 0;
>       ifp->if_flags &= ~IFF_RUNNING;
> @@ -3158,6 +3163,10 @@ athn_stop(struct ifnet *ifp, int disable)
>       AR_WRITE_BARRIER(sc);
>       athn_set_rxfilter(sc, 0);
>       athn_stop_rx_dma(sc);
> +
> +     /* Reset HW key cache entries. */
> +     for (i = 0; i < sc->kc_entries; i++)
> +             athn_reset_key(sc, i);
>  
>       athn_reset(sc, 0);
>       athn_init_pll(sc, NULL);
> 



OpenBSD 6.7-current (GENERIC.MP) #0: Fri Jul  3 21:14:17 CDT 2020
    [email protected]:/sys/arch/i386/compile/GENERIC.MP
real mem  = 2137178112 (2038MB)
avail mem = 2081857536 (1985MB)
random: good seed from bootblocks
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: date 05/20/09, BIOS32 rev. 0 @ 0xfdc80, SMBIOS rev. 2.5 @ 
0xf2430 (40 entries)
bios0: vendor Dell Inc. version "A05" date 05/20/2009
bios0: Dell Inc. Inspiron 1010
acpi0 at bios0: ACPI 3.0
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP HPET MCFG TCPA TMOR OSFR APIC BOOT SLIC SSDT
acpi0: wakeup devices PWRB(S3) PXS1(S5) PXS2(S3) USB1(S3) USB2(S3) USB3(S0) 
EHC1(S3)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpihpet0 at acpi0: 14318179 Hz
acpimcfg0 at acpi0
acpimcfg0: addr 0xe0000000, bus 0-255
acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Atom(TM) CPU Z520 @ 1.33GHz ("GenuineIntel" 686-class) 1.34 GHz, 
06-1c-02
cpu0: 
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,xTPR,PDCM,MOVBE,NXE,LAHF,PERF,SENSOR,MELTDOWN
mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
cpu0: apic clock running at 132MHz
cpu0: mwait min=64, max=64, C-substates=0.2.2.0.2.0.3, IBE
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Intel(R) Atom(TM) CPU Z520 @ 1.33GHz ("GenuineIntel" 686-class) 1.33 GHz, 
06-1c-02
cpu1: 
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,xTPR,PDCM,MOVBE,NXE,LAHF,PERF,SENSOR,MELTDOWN
ioapic0 at mainbus0: apid 2 pa 0xfec00000, version 20, 24 pins
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 2 (RP01)
acpiprt2 at acpi0: bus 3 (RP02)
acpiec0 at acpi0
acpicpu0 at acpi0: !C3(10@140 mwait.3@0x52), !C3(100@100 mwait.3@0x30), 
!C2(500@20 mwait.1@0x10), C1(1000@1 mwait.1), PSS
acpicpu1 at acpi0: !C3(10@140 mwait.3@0x52), !C3(100@100 mwait.3@0x30), 
!C2(500@20 mwait.1@0x10), C1(1000@1 mwait.1), PSS
"CPL0002" at acpi0 not configured
acpibtn0 at acpi0: LID0
acpibtn1 at acpi0: PWRB
"PNP0A08" at acpi0 not configured
acpicmos0 at acpi0
acpiac0 at acpi0: AC unit online
acpibat0 at acpi0: BAT1 serial 11 type Lion oem "Dell"
"SYN0601" at acpi0 not configured
acpivideo0 at acpi0: GFX0
acpivout0 at acpivideo0: DD04
acpivout1 at acpivideo0: DD05
bios0: ROM list: 0xc0000/0xe600! 0xce800/0x1000 0xe0000/0x1800!
cpu0: Enhanced SpeedStep 1330 MHz: speeds: 1333, 1067, 800 MHz
pci0 at mainbus0 bus 0: configuration mode 1 (no bios)
pchb0 at pci0 dev 0 function 0 "Intel US15W Host" rev 0x07
vga1 at pci0 dev 2 function 0 "Intel US15W Video" rev 0x07
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
azalia0 at pci0 dev 27 function 0 "Intel SCH HD Audio" rev 0x07: apic 2 int 22
azalia0: codecs: Realtek ALC269, CMD Technology/0x1392, using Realtek ALC269
audio0 at azalia0
ppb0 at pci0 dev 28 function 0 "Intel SCH PCIE" rev 0x07: apic 2 int 17
pci1 at ppb0 bus 2
re0 at pci1 dev 0 function 0 "Realtek 8101E" rev 0x02: RTL8102EL (0x2480), msi, 
address 00:24:e8:c6:d7:2c
rlphy0 at re0 phy 7: RTL8201L 10/100 PHY, rev. 1
ppb1 at pci0 dev 28 function 1 "Intel SCH PCIE" rev 0x07: apic 2 int 16
pci2 at ppb1 bus 3
athn0 at pci2 dev 0 function 0 "Atheros AR9281" rev 0x01: apic 2 int 17
athn0: AR9280 rev 2 (2T2R), ROM rev 22, address 00:24:d2:b3:8c:b4
uhci0 at pci0 dev 29 function 0 "Intel SCH USB" rev 0x07: apic 2 int 23
uhci1 at pci0 dev 29 function 1 "Intel SCH USB" rev 0x07: apic 2 int 19
uhci2 at pci0 dev 29 function 2 "Intel SCH USB" rev 0x07: apic 2 int 18
ehci0 at pci0 dev 29 function 7 "Intel SCH USB" rev 0x07: apic 2 int 21
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 configuration 1 interface 0 "Intel EHCI root hub" rev 2.00/1.00 
addr 1
pcib0 at pci0 dev 31 function 0 "Intel SCH LPC" rev 0x07
pciide0 at pci0 dev 31 function 1 "Intel SCH IDE" rev 0x07: DMA, channel 0 
wired to compatibility
wd0 at pciide0 channel 0 drive 0: <OCZ-AGILITY2>
wd0: 16-sector PIO, LBA48, 57241MB, 117231408 sectors
wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 5
usb1 at uhci0: USB revision 1.0
uhub1 at usb1 configuration 1 interface 0 "Intel UHCI root hub" rev 1.00/1.00 
addr 1
usb2 at uhci1: USB revision 1.0
uhub2 at usb2 configuration 1 interface 0 "Intel UHCI root hub" rev 1.00/1.00 
addr 1
usb3 at uhci2: USB revision 1.0
uhub3 at usb3 configuration 1 interface 0 "Intel UHCI root hub" rev 1.00/1.00 
addr 1
isa0 at pcib0
isadma0 at isa0
pckbc0 at isa0 port 0x60/5 irq 1 irq 12
pckbd0 at pckbc0 (kbd slot)
wskbd0 at pckbd0: console keyboard, using wsdisplay0
pms0 at pckbc0 (aux slot)
wsmouse0 at pms0 mux 0
pms0: Elantech Touchpad, version 2, firmware 0x20801
pcppi0 at isa0 port 0x61
spkr0 at pcppi0
npx0 at isa0 port 0xf0/16: reported by CPUID; using exception 16
uhub4 at uhub0 port 1 configuration 1 interface 0 "Alcor Micro product 0x6254" 
rev 2.00/1.00 addr 2
uvideo0 at uhub0 port 6 configuration 1 interface 0 "SuYin Integrated Webcam" 
rev 2.00/8c.02 addr 3
video0 at uvideo0
umass0 at uhub0 port 7 configuration 1 interface 0 "Generic USB2.0-CRW" rev 
2.00/58.87 addr 4
umass0: using SCSI over Bulk-Only
scsibus1 at umass0: 2 targets, initiator 0
sd0 at scsibus1 targ 1 lun 0: <Generic-, Multi-Card, 1.00> removable 
serial.0bda0158114173400000
vscsi0 at root
scsibus2 at vscsi0: 256 targets
softraid0 at root
scsibus3 at softraid0: 256 targets
sd1 at scsibus3 targ 1 lun 0: <OPENBSD, SR CRYPTO, 006>
sd1: 57239MB, 512 bytes/sector, 117225713 sectors
root on sd1a (7206a5e742b3a427.a) swap on sd1b dump on sd1b


Reply via email to