9front - general discussion about 9front
 help / color / mirror / Atom feed
* Re: [9front] driver for intel wireless 7260?
@ 2021-08-06  4:43 qwx
  2021-08-06  4:57 ` Skylar Bleed
                   ` (2 more replies)
  0 siblings, 3 replies; 29+ messages in thread
From: qwx @ 2021-08-06  4:43 UTC (permalink / raw)
  To: 9front

Hi,

Am I the only one who doesn't see /sys/src/9/pc/etheriwl.c actually
updated after the latest commits?

	; ramfs
	; cd /tmp
	; git/clone gits://git.9front.org/plan9front/plan9front
	fetching...
	indexing 94186 objects: 100%
	checking out repository...
	; grep 7260 plan9front/sys/src/9/pc/etheriwl.c

The patch unfortunately doesn't work for me after a quick test on
a x240 (did=0x08b2), I have to change Type7260 to 20, not 30, and
it just dies with a firmware error (with 6.9 firmware).

I can't test more than that right now, but I'll try again later.

Thanks!

qwx

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [9front] driver for intel wireless 7260?
  2021-08-06  4:43 [9front] driver for intel wireless 7260? qwx
@ 2021-08-06  4:57 ` Skylar Bleed
  2021-08-06 10:06 ` cinap_lenrek
  2021-08-06 14:07 ` kemal
  2 siblings, 0 replies; 29+ messages in thread
From: Skylar Bleed @ 2021-08-06  4:57 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 878 bytes --]

I couldn't get it to work either but I also have no fucking idea what I'm doing because I am not that familiar with plan9 or writing/installing drivers in general so it could perhaps be a setup issue on my part.

On Fri, Aug 6, 2021 at 12:43 AM, qwx <qwx@sciops.net> wrote:

> Hi,
>
> Am I the only one who doesn't see /sys/src/9/pc/etheriwl.c actually
> updated after the latest commits?
>
> ; ramfs
> ; cd /tmp
> ; git/clone gits://git.9front.org/plan9front/plan9front
> fetching...
> indexing 94186 objects: 100%
> checking out repository...
> ; grep 7260 plan9front/sys/src/9/pc/etheriwl.c
>
> The patch unfortunately doesn't work for me after a quick test on
> a x240 (did=0x08b2), I have to change Type7260 to 20, not 30, and
> it just dies with a firmware error (with 6.9 firmware).
>
> I can't test more than that right now, but I'll try again later.
>
> Thanks!
>
> qwx

[-- Attachment #2: Type: text/html, Size: 1127 bytes --]

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [9front] driver for intel wireless 7260?
  2021-08-06  4:43 [9front] driver for intel wireless 7260? qwx
  2021-08-06  4:57 ` Skylar Bleed
@ 2021-08-06 10:06 ` cinap_lenrek
  2021-08-06 17:56   ` Skylar Bleed
  2021-08-06 14:07 ` kemal
  2 siblings, 1 reply; 29+ messages in thread
From: cinap_lenrek @ 2021-08-06 10:06 UTC (permalink / raw)
  To: 9front

yeah, i must have botched the merge... apparently it reverted
back etheriwl during the merge commit...

--
cinap

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [9front] driver for intel wireless 7260?
  2021-08-06  4:43 [9front] driver for intel wireless 7260? qwx
  2021-08-06  4:57 ` Skylar Bleed
  2021-08-06 10:06 ` cinap_lenrek
@ 2021-08-06 14:07 ` kemal
  2 siblings, 0 replies; 29+ messages in thread
From: kemal @ 2021-08-06 14:07 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 1007 bytes --]

2021-08-06 4:43 GMT, qwx <qwx@sciops.net>:
> The patch unfortunately doesn't work for me after a quick test on
> a x240 (did=0x08b2), I have to change Type7260 to 20, not 30, and
> it just dies with a firmware error (with 6.9 firmware).
>
> I can't test more than that right now, but I'll try again later.

when you try it again, would you please mail the whole error
message here, so i can debug it? here is an example error
message:

#l1: firmware: iwm-7260-17, rev 11, build 3216344376, size [3]
14000+2c000 + [3] 14000+2c000 + 0
#l1: fatal firmware error
lastcmd: 136 (0x88)
error: id 65, trm_hw_status 000002f0 00000000,
branchlink2 0000099a, interruptlink 0000d340 0000b8ca,
errordata 00000000 00000200 02030000
#l1: cmd 136: flushq: broken
readnvmsect: flushq: broken
#l1: cmd 152: qcmd: broken
#l1: qcmd: broken

also apparently i'm not supposed to do the niclock/nicunlock
dance for tx commands, so check if qid == 4 so that we know
it was sent by cmd(). perhaps might solve things? diff attached.

[-- Attachment #2: diff.txt --]
[-- Type: text/plain, Size: 643 bytes --]

--- /sys/src/9/pc/etheriwl.c
+++ /sys/src/9/pc/etheriwl.c
@@ -3452,7 +3452,7 @@
 		return "qcmd: broken";
 	}
 	/* wake up the nic (just needed for 7k) */
-	if(ctlr->family == 7000 && q->n == 0)
+	if(ctlr->family == 7000 && qid == 4 && q->n == 0)
 		if(niclock(ctlr) != nil){
 			iunlock(ctlr);
 			return "qcmd: busy";
@@ -4283,8 +4283,8 @@
 		if(tx != nil && tx->n > 0){
 			tx->n--;
 			wakeup(tx);
-			/* unlock 7k family nics as all commands are done */
-			if(ctlr->family == 7000 && tx->n == 0)
+			/* unlock 7k family nics as the command is done */
+			if(ctlr->family == 7000 && qid == 4 && tx->n == 0)
 				nicunlock(ctlr);
 		}
 	}

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [9front] driver for intel wireless 7260?
  2021-08-06 10:06 ` cinap_lenrek
@ 2021-08-06 17:56   ` Skylar Bleed
  2021-08-06 23:48     ` cinap_lenrek
  2021-08-07 10:30     ` kemal
  0 siblings, 2 replies; 29+ messages in thread
From: Skylar Bleed @ 2021-08-06 17:56 UTC (permalink / raw)
  To: 9front

hi,

I hope this isn't dumb (or redundant, but I think my other message got lost because I accidentally made it html), but are there any instructions on how to get the driver working now (assuming it does work)? I am a big newbie so I don't know what I'm doing.

I applied the patch and did a `mk all; mk install`, then put the obsd firmware (cinap said I needed iwm-8260-17 but since that doesn't seem to exist I'm guessing it was a typo for iwm-7260-17) in /lib/firmware, and then rebooted, but whenever I try to `bind -a '#l1' /net` or run any other command which involves '#l1', I get an error like "#l1: no free devices". Does this sound like a driver issue or a "I set up my machine wrong" issue to you guys?

and just for good measure, is there any documentation explaining the '#' devices? I don't really understand them and I can't find any docs.

thank you
skye bleed

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [9front] driver for intel wireless 7260?
  2021-08-06 17:56   ` Skylar Bleed
@ 2021-08-06 23:48     ` cinap_lenrek
  2021-08-07  2:59       ` Skylar Bleed
  2021-08-07 10:30     ` kemal
  1 sibling, 1 reply; 29+ messages in thread
From: cinap_lenrek @ 2021-08-06 23:48 UTC (permalink / raw)
  To: 9front

no free devices means it hasnt even detected your card.

--
cinap

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [9front] driver for intel wireless 7260?
  2021-08-06 23:48     ` cinap_lenrek
@ 2021-08-07  2:59       ` Skylar Bleed
  2021-08-07 11:16         ` cinap_lenrek
  0 siblings, 1 reply; 29+ messages in thread
From: Skylar Bleed @ 2021-08-07  2:59 UTC (permalink / raw)
  To: 9front

Oh, do you have any idea why that might be? Perhaps it goes in hand with the fact that ethernet no longer works for me on 9front, even though it did when I had been trying it out on an older release (EMAILSCHADEN, I think) a number of months ago, like maybe support for something specific to my computer was for some reason removed?

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On Friday, August 6th, 2021 at 7:48 PM, <cinap_lenrek@felloff.net> wrote:

> no free devices means it hasnt even detected your card.
>
> --------------------------------------------------------
>
> cinap

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [9front] driver for intel wireless 7260?
  2021-08-06 17:56   ` Skylar Bleed
  2021-08-06 23:48     ` cinap_lenrek
@ 2021-08-07 10:30     ` kemal
  1 sibling, 0 replies; 29+ messages in thread
From: kemal @ 2021-08-07 10:30 UTC (permalink / raw)
  To: 9front

> I applied the patch and did a `mk all; mk install`, then put the obsd
> firmware (cinap said I needed iwm-8260-17 but since that doesn't seem to
> exist I'm guessing it was a typo for iwm-7260-17) in /lib/firmware, and then
> rebooted, but whenever I try to `bind -a '#l1' /net` or run any other
> command which involves '#l1', I get an error like "#l1: no free devices".
> Does this sound like a driver issue or a "I set up my machine wrong" issue
> to you guys?

may you try finding the line in /sys/src/9/pc/etheriwl.c where Type7260 is
defined, then change the definition from 30 to 20. it seems that it was 20.
then rebuild the kernel, then change the kernel with the command
`9fs 9fat; mv 9pc64 /n/9fat/9pc64`. after rebooting, you might see a
"fatal firmware error", so if one happens mail the contents of the error, so
i can debug it.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [9front] driver for intel wireless 7260?
  2021-08-07  2:59       ` Skylar Bleed
@ 2021-08-07 11:16         ` cinap_lenrek
  2021-08-07 14:39           ` Skylar Bleed
  0 siblings, 1 reply; 29+ messages in thread
From: cinap_lenrek @ 2021-08-07 11:16 UTC (permalink / raw)
  To: 9front

> Oh, do you have any idea why that might be?

you'r not providing any usefull information.

whats the pci vid/did of your card?

> Perhaps it goes in hand with the fact that
> ethernet no longer works for me on 9front,
> even though it did when I had been trying
> it out on an older release (EMAILSCHADEN,
> I think) a number of months ago,
> like maybe support for something specific
> to my computer was for some reason removed?

i dont remember any removals of supported
pci id's in any driver, never ever.

in fact, i dont think there where any chnages
to ethernet drivers between these releases.

you need to provide some information about
the pci device and then we can lee why the
driver doesnt detect it.

--
cinap

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [9front] driver for intel wireless 7260?
  2021-08-07 11:16         ` cinap_lenrek
@ 2021-08-07 14:39           ` Skylar Bleed
  2021-08-07 22:14             ` kemal
  2021-08-07 22:27             ` ori
  0 siblings, 2 replies; 29+ messages in thread
From: Skylar Bleed @ 2021-08-07 14:39 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 549 bytes --]

> after rebooting, you might see a "fatal firmware error", so if one happens mail the contents of the error, so i can debug it.

I can't send the output in text form because it can't connect to the internet, but I've attached a picture of my screen.

> you'r not providing any usefull information.
> whats the pci vid/did of your card?

I don't really know what things are useful for you to have, sorry. I wasn't exaggerating when I said I was a newbie. I attached a picture of the output from pci -v; if you need more than that I'll send it.

[-- Attachment #2: 2021-08-07 10.31.50.jpg --]
[-- Type: image/jpeg, Size: 119071 bytes --]

[-- Attachment #3: 2021-08-07 10.37.29.jpg --]
[-- Type: image/jpeg, Size: 151144 bytes --]

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [9front] driver for intel wireless 7260?
  2021-08-07 14:39           ` Skylar Bleed
@ 2021-08-07 22:14             ` kemal
  2021-08-08 14:35               ` Skylar Bleed
  2021-08-09 12:05               ` kemal
  2021-08-07 22:27             ` ori
  1 sibling, 2 replies; 29+ messages in thread
From: kemal @ 2021-08-07 22:14 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 1033 bytes --]

2021-08-07 14:39 GMT, Skylar Bleed <skylarbleed@protonmail.ch>:
> I can't send the output in text form because it can't connect to the
> internet, but I've attached a picture of my screen.

ok, this is the firmware error that also happened on qwx's 7260.

now with qwx we have managed to solve 2 firmware errors that
happened:

1-the error you just sent. the line that was reading the mac
address from the nvm failed. why? apparently fw doesn't like
us reading just 6 bytes, reading 8 bytes works... wtf...
2-sendmccupdate spitted a BAD_COMMAND error. apparently
7260 doesn't support the mcc update command, so check the
ucode capabilities to see if we can run it.

now we're still facing one more firmware error, this one:

http://okturing.com/src/11797/body

for some reason, any command on rxoff7000 fails with
BAD_COMMAND. i didn't see anything wrong with command
data, and 7260 supports these, so i am kind of puzzled why it
happens. will look into it tommorow.

if someone wonders, the changes we made are attached in
diff.txt

[-- Attachment #2: diff.txt --]
[-- Type: text/plain, Size: 2357 bytes --]

--- /sys/src/9/pc/etheriwl.c
+++ /sys/src/9/pc/etheriwl.c
@@ -329,7 +329,18 @@
 	SchedTransTblOff	= 0x7E0,		// +q*2
 };
 
+/*
+ * uCode capabilities
+ */
 enum {
+	/* capa[0] */
+	UcodeCapLar	= (1<<1),
+	
+	/* capa[2] */
+	UcodeCapLar2	= (1<<9),
+};
+
+enum {
 	FilterPromisc		= 1<<0,
 	FilterCtl		= 1<<1,
 	FilterMulticast		= 1<<2,
@@ -635,7 +646,7 @@
 	Type2030	= 12,
 	Type2000	= 16,
 
-	Type7260	= 30,
+	Type7260	= 20,
 	Type8265	= 35,
 };
 
@@ -1984,7 +1995,7 @@
 	*p++ = mcc[0];
 	*p++ = 0;
 	*p++ = 0;	// reserved
-	if(1){
+	if(ctlr->fw->capa[2] & UcodeCapLar2){
 		p += 4;
 		p += 5*4;
 	}
@@ -2272,7 +2283,9 @@
 			ea[5] = a1 >> 0;
 		}
 	} else {
-		readnvmsect(ctlr, 0, ea, Eaddrlen, 0x15<<1);
+		/* fw gets angry if we read 6 bytes instead of 8 */
+		readnvmsect(ctlr, 0, buf, 8, 0x15<<1);
+		memmove(ea, buf, Eaddrlen);
 	}
 	memmove(ctlr->edev->addr, ea, Eaddrlen);
 
@@ -2822,13 +2835,13 @@
 	return cmd(ctlr, 210, c, 11*4);
 }
 
-static void
+static char*
 tttxbackoff(Ctlr *ctlr)
 {
 	uchar c[4];
 	
 	put32(c, 0);
-	cmd(ctlr, 126, c, sizeof(c));
+	return cmd(ctlr, 126, c, sizeof(c));
 }
 
 static char*
@@ -2897,16 +2910,16 @@
 
 		/* Initialize tx backoffs to the minimum. */
 		if(ctlr->family == 7000)
-			tttxbackoff(ctlr);
+			if((err = tttxbackoff(ctlr)) != nil)
+				return err;
 
 		if((err = updatedevicepower(ctlr)) != nil){
 			print("can't update device power: %s\n", err);
 			return err;
 		}
-		if((err = sendmccupdate(ctlr, "ZZ")) != nil){
-			print("can't disable beacon filter: %s\n", err);
-			return err;
-		}
+		if(ctlr->fw->capa[0] & UcodeCapLar)
+			if((err = sendmccupdate(ctlr, "ZZ")) != nil)
+				return err;
 		if((err = disablebeaconfilter(ctlr)) != nil){
 			print("can't disable beacon filter: %s\n", err);
 			return err;
@@ -3452,7 +3465,7 @@
 		return "qcmd: broken";
 	}
 	/* wake up the nic (just needed for 7k) */
-	if(ctlr->family == 7000 && q->n == 0)
+	if(ctlr->family == 7000 && qid == 4 && q->n == 0)
 		if(niclock(ctlr) != nil){
 			iunlock(ctlr);
 			return "qcmd: busy";
@@ -4283,8 +4296,8 @@
 		if(tx != nil && tx->n > 0){
 			tx->n--;
 			wakeup(tx);
-			/* unlock 7k family nics as all commands are done */
-			if(ctlr->family == 7000 && tx->n == 0)
+			/* unlock 7k family nics as the command is done */
+			if(ctlr->family == 7000 && qid == 4 && tx->n == 0)
 				nicunlock(ctlr);
 		}
 	}

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [9front] driver for intel wireless 7260?
  2021-08-07 14:39           ` Skylar Bleed
  2021-08-07 22:14             ` kemal
@ 2021-08-07 22:27             ` ori
  1 sibling, 0 replies; 29+ messages in thread
From: ori @ 2021-08-07 22:27 UTC (permalink / raw)
  To: 9front

Quoth Skylar Bleed <skylarbleed@protonmail.ch>:
> > after rebooting, you might see a "fatal firmware error", so if one happens mail the contents of the error, so i can debug it.
> 
> I can't send the output in text form because it can't connect to the internet, but I've attached a picture of my screen.

If you can plug it in wired, that would probably help.
 
> > you'r not providing any usefull information.
> > whats the pci vid/did of your card?
> 
> I don't really know what things are useful for you to have, sorry.
> I wasn't exaggerating when I said I was a newbie. I attached a
> picture of the output from pci -v; if you need more than that I'll send it.

Ok. That's useful -- From that output:

1. You're trying to bind '#l1' at boot, and then
   when you were trying to do it manually later,
   we'd already determined we couldn't load it.

   The interesting errors come from the *first*
   attempt to bind the device.

2. It looks like the firmware is crashing when
   reading an nvm section. I think kemal was
   looking at this.



^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [9front] driver for intel wireless 7260?
  2021-08-07 22:14             ` kemal
@ 2021-08-08 14:35               ` Skylar Bleed
  2021-08-09 12:05               ` kemal
  1 sibling, 0 replies; 29+ messages in thread
From: Skylar Bleed @ 2021-08-08 14:35 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 107 bytes --]

just tried kemal's patch and it looks like I'm getting the same error qwx was, so at least it's consistent!

[-- Attachment #2: 2021-08-08 10.33.08.jpg --]
[-- Type: image/jpeg, Size: 157000 bytes --]

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [9front] driver for intel wireless 7260?
  2021-08-07 22:14             ` kemal
  2021-08-08 14:35               ` Skylar Bleed
@ 2021-08-09 12:05               ` kemal
  2021-08-10 15:11                 ` Skylar Bleed
  1 sibling, 1 reply; 29+ messages in thread
From: kemal @ 2021-08-09 12:05 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 917 bytes --]

2021-08-07 22:14 GMT, kemal <kemalinanc8@gmail.com>:
> for some reason, any command on rxoff7000 fails with
> BAD_COMMAND. i didn't see anything wrong with command
> data, and 7260 supports these, so i am kind of puzzled why it
> happens. will look into it tommorow.

i looked more into this. 3 things:
1. *only* settimeevent fails. the other errors are produced because
driver does not reset the card after the error.
2. settimeevent does not have anything wrong in it's command data.
so it's probably not caused by that.
3. apparently, time event command had an older api. it was removed
from openbsd cuz apparently all supported fw versions support it,
but i have a suspicion. what if *-17 actually requires the old api?
in addition that change was added as a patch, perhaps it was not tested
well. a diff is attached that now checks if card actually supports
api v2, and if not send the command in the v1 format.

[-- Attachment #2: diff.txt --]
[-- Type: text/plain, Size: 4271 bytes --]

--- /sys/src/9/pc/etheriwl.c
+++ /sys/src/9/pc/etheriwl.c
@@ -329,7 +329,25 @@
 	SchedTransTblOff	= 0x7E0,		// +q*2
 };
 
+/*
+ * uCode API flags
+ */
 enum {
+	UcodeFlgTe2	= 1<<9,
+};
+
+/*
+ * uCode capabilities
+ */
+enum {
+	/* capa[0] */
+	UcodeCapLar	= 1<<1,
+	
+	/* capa[2] */
+	UcodeCapLar2	= 1<<9,
+};
+
+enum {
 	FilterPromisc		= 1<<0,
 	FilterCtl		= 1<<1,
 	FilterMulticast		= 1<<2,
@@ -418,6 +436,7 @@
 	uint	build;
 	char	descr[64+1];
 
+	u32int	flags;
 	u32int	capa[4];
 	u32int	api[4];
 
@@ -635,7 +654,7 @@
 	Type2030	= 12,
 	Type2000	= 16,
 
-	Type7260	= 30,
+	Type7260	= 20,
 	Type8265	= 35,
 };
 
@@ -1478,6 +1497,11 @@
 				s = &i->boot.text;
 				s->addr = 0x00000000;
 				goto Sect;
+			case 18:
+				if(l < 4)
+					goto Tooshort;
+				i->flags = get32(p);
+				break;
 			case 19:
 				if(i->main.nsect >= nelem(i->main.sect))
 					return "too many main sections";
@@ -1984,7 +2008,7 @@
 	*p++ = mcc[0];
 	*p++ = 0;
 	*p++ = 0;	// reserved
-	if(1){
+	if(ctlr->fw->capa[2] & UcodeCapLar2){
 		p += 4;
 		p += 5*4;
 	}
@@ -2272,7 +2296,9 @@
 			ea[5] = a1 >> 0;
 		}
 	} else {
-		readnvmsect(ctlr, 0, ea, Eaddrlen, 0x15<<1);
+		/* fw gets angry if we read 6 bytes instead of 8 */
+		readnvmsect(ctlr, 0, buf, 8, 0x15<<1);
+		memmove(ea, buf, Eaddrlen);
 	}
 	memmove(ctlr->edev->addr, ea, Eaddrlen);
 
@@ -2641,7 +2667,7 @@
 settimeevent(Ctlr *ctlr, int amr, int ival)
 {
 	int duration, delay, timeid;
-	uchar c[9*4], *p;
+	uchar c[14*4], *p;
 	char *err;
 
 	switch(amr){
@@ -2682,16 +2708,40 @@
 	p += 4;
 	put32(p, delay);
 	p += 4;
+	if((ctlr->fw->flags & UcodeFlgTe2) == 0){
+		put32(p, 0); 	// dep policy
+		p += 4;
+	}
 	put32(p, 0);	// depends on
 	p += 4;
-	put32(p, 1);	// interval
-	p += 4;
-	put32(p, duration);
-	p += 4;
-	*p++ = 1;	// repeat
-	*p++ = 0;	// max frags
-	put16(p, 1<<0 | 1<<1 | 1<<11);	// policy
-	p += 2;
+	if((ctlr->fw->flags & UcodeFlgTe2) == 0){
+		put32(p, 0);	// is present (reverse of absence flag)
+		p += 4;
+	}
+	
+	if(ctlr->fw->flags & UcodeFlgTe2){
+		put32(p, 1);	// interval
+		p += 4;
+		put32(p, duration);
+		p += 4;
+		*p++ = 1;	// repeat
+		*p++ = 0;	// max frags
+		put16(p, 1<<0 | 1<<1 | 1<<11);	// policy
+		p += 2;
+	}else{
+		put32(p, 0);	// max frags
+		p += 4;
+		put32(p, 1);	// interval
+		p += 4;
+		put32(p, 0);	// interval reciprocal (UNUSED)
+		p += 4;
+		put32(p, duration);
+		p += 4;
+		put32(p, 1);	// repeat
+		p += 4;
+		put32(p, 1<<0 | 1<<1);	// notify
+		p += 4;
+	}
 
 	ctlr->te.active = 0;
 	if((err =  cmd(ctlr, 41, c, p - c)) != nil)
@@ -2822,13 +2872,13 @@
 	return cmd(ctlr, 210, c, 11*4);
 }
 
-static void
+static char*
 tttxbackoff(Ctlr *ctlr)
 {
 	uchar c[4];
 	
 	put32(c, 0);
-	cmd(ctlr, 126, c, sizeof(c));
+	return cmd(ctlr, 126, c, sizeof(c));
 }
 
 static char*
@@ -2897,16 +2947,16 @@
 
 		/* Initialize tx backoffs to the minimum. */
 		if(ctlr->family == 7000)
-			tttxbackoff(ctlr);
+			if((err = tttxbackoff(ctlr)) != nil)
+				return err;
 
 		if((err = updatedevicepower(ctlr)) != nil){
 			print("can't update device power: %s\n", err);
 			return err;
 		}
-		if((err = sendmccupdate(ctlr, "ZZ")) != nil){
-			print("can't disable beacon filter: %s\n", err);
-			return err;
-		}
+		if(ctlr->fw->capa[0] & UcodeCapLar)
+			if((err = sendmccupdate(ctlr, "ZZ")) != nil)
+				return err;
 		if((err = disablebeaconfilter(ctlr)) != nil){
 			print("can't disable beacon filter: %s\n", err);
 			return err;
@@ -3418,6 +3468,7 @@
 static char*
 qcmd(Ctlr *ctlr, uint qid, uint code, uchar *data, int size, Block *block)
 {
+	char *err;
 	int hdrlen;
 	Block *bcmd;
 	uchar *d, *c;
@@ -3452,10 +3503,10 @@
 		return "qcmd: broken";
 	}
 	/* wake up the nic (just needed for 7k) */
-	if(ctlr->family == 7000 && q->n == 0)
-		if(niclock(ctlr) != nil){
+	if(ctlr->family == 7000 && qid == 4 && q->n == 0)
+		if((err = niclock(ctlr)) != nil){
 			iunlock(ctlr);
-			return "qcmd: busy";
+			return err;
 		}
 	q->n++;
 	q->lastcmd = code;
@@ -4283,8 +4334,8 @@
 		if(tx != nil && tx->n > 0){
 			tx->n--;
 			wakeup(tx);
-			/* unlock 7k family nics as all commands are done */
-			if(ctlr->family == 7000 && tx->n == 0)
+			/* unlock 7k family nics as the command is done */
+			if(ctlr->family == 7000 && qid == 4 && tx->n == 0)
 				nicunlock(ctlr);
 		}
 	}

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [9front] driver for intel wireless 7260?
  2021-08-09 12:05               ` kemal
@ 2021-08-10 15:11                 ` Skylar Bleed
  2021-08-12 21:03                   ` kemal
  0 siblings, 1 reply; 29+ messages in thread
From: Skylar Bleed @ 2021-08-10 15:11 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 132 bytes --]

I tried the diff and I'm not sure that it changed anything, but here's a picture (the left is /dev/kprint, the right is /dev/kmesg).

[-- Attachment #2: 2021-08-10 11.08.04.jpg --]
[-- Type: image/jpeg, Size: 184393 bytes --]

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [9front] driver for intel wireless 7260?
  2021-08-10 15:11                 ` Skylar Bleed
@ 2021-08-12 21:03                   ` kemal
  2021-08-13 19:49                     ` Skylar Bleed
  2021-08-13 23:41                     ` kemal
  0 siblings, 2 replies; 29+ messages in thread
From: kemal @ 2021-08-12 21:03 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 792 bytes --]

2021-08-10 15:11 GMT, Skylar Bleed <skylarbleed@protonmail.ch>:
> I tried the diff and I'm not sure that it changed anything, but here's a
> picture (the left is /dev/kprint, the right is /dev/kmesg).

yup. it didn't change anything.

now i think there can be only one reason why it still fails.

unless we are authenticated, fw hops between channels. our driver
forces the fw onto a channel using a time event. to do this, our driver
sends a command to the fw telling "add a time event".

fw may not be in a good situation, and may not active the time event.
on rxoff7000 we will try to remove it, and perhaps at that point fw gets
angry, telling "wtf?!??! it's not even actived, why are you removing it?".
let's try modifying it in the next settimeevent instead.

the new diff is attached.

[-- Attachment #2: diff.txt --]
[-- Type: text/plain, Size: 4384 bytes --]

--- /sys/src/9/pc/etheriwl.c
+++ /sys/src/9/pc/etheriwl.c
@@ -329,7 +329,18 @@
 	SchedTransTblOff	= 0x7E0,		// +q*2
 };
 
+/*
+ * uCode capabilities
+ */
 enum {
+	/* capa[0] */
+	UcodeCapLar	= 1<<1,
+	
+	/* capa[2] */
+	UcodeCapLar2	= 1<<9,
+};
+
+enum {
 	FilterPromisc		= 1<<0,
 	FilterCtl		= 1<<1,
 	FilterMulticast		= 1<<2,
@@ -418,6 +429,7 @@
 	uint	build;
 	char	descr[64+1];
 
+	u32int	flags;
 	u32int	capa[4];
 	u32int	api[4];
 
@@ -635,7 +647,7 @@
 	Type2030	= 12,
 	Type2000	= 16,
 
-	Type7260	= 30,
+	Type7260	= 20,
 	Type8265	= 35,
 };
 
@@ -1478,6 +1490,11 @@
 				s = &i->boot.text;
 				s->addr = 0x00000000;
 				goto Sect;
+			case 18:
+				if(l < 4)
+					goto Tooshort;
+				i->flags = get32(p);
+				break;
 			case 19:
 				if(i->main.nsect >= nelem(i->main.sect))
 					return "too many main sections";
@@ -1984,7 +2001,7 @@
 	*p++ = mcc[0];
 	*p++ = 0;
 	*p++ = 0;	// reserved
-	if(1){
+	if(ctlr->fw->capa[2] & UcodeCapLar2){
 		p += 4;
 		p += 5*4;
 	}
@@ -2272,7 +2289,9 @@
 			ea[5] = a1 >> 0;
 		}
 	} else {
-		readnvmsect(ctlr, 0, ea, Eaddrlen, 0x15<<1);
+		/* fw gets angry if we read 6 bytes instead of 8 */
+		readnvmsect(ctlr, 0, buf, 8, 0x15<<1);
+		memmove(ea, buf, Eaddrlen);
 	}
 	memmove(ctlr->edev->addr, ea, Eaddrlen);
 
@@ -2655,6 +2674,9 @@
 			amr = CmdModify;
 		}
 		break;
+	case CmdRemove:
+		if(!ctlr->te.active)
+			return nil;	
 	default:
 		timeid = ctlr->te.id;
 		if(timeid == -1)
@@ -2678,20 +2700,24 @@
 	put32(p, timeid);
 	p += 4;
 
-	put32(p, 0);	// apply time
-	p += 4;
-	put32(p, delay);
-	p += 4;
-	put32(p, 0);	// depends on
-	p += 4;
-	put32(p, 1);	// interval
-	p += 4;
-	put32(p, duration);
-	p += 4;
-	*p++ = 1;	// repeat
-	*p++ = 0;	// max frags
-	put16(p, 1<<0 | 1<<1 | 1<<11);	// policy
-	p += 2;
+	if(amr == CmdRemove)
+		p += 6*4;
+	else{
+		put32(p, 0);	// apply time
+		p += 4;
+		put32(p, delay);
+		p += 4;
+		put32(p, 0);	// depends on
+		p += 4;
+		put32(p, 1);	// interval
+		p += 4;
+		put32(p, duration);
+		p += 4;
+		*p++ = 1;	// repeat
+		*p++ = 0;	// max frags
+		put16(p, 1<<0 | 1<<1 | 1<<11);	// policy
+		p += 2;
+	}
 
 	ctlr->te.active = 0;
 	if((err =  cmd(ctlr, 41, c, p - c)) != nil)
@@ -2822,13 +2848,13 @@
 	return cmd(ctlr, 210, c, 11*4);
 }
 
-static void
+static char*
 tttxbackoff(Ctlr *ctlr)
 {
 	uchar c[4];
 	
 	put32(c, 0);
-	cmd(ctlr, 126, c, sizeof(c));
+	return cmd(ctlr, 126, c, sizeof(c));
 }
 
 static char*
@@ -2897,16 +2923,16 @@
 
 		/* Initialize tx backoffs to the minimum. */
 		if(ctlr->family == 7000)
-			tttxbackoff(ctlr);
+			if((err = tttxbackoff(ctlr)) != nil)
+				return err;
 
 		if((err = updatedevicepower(ctlr)) != nil){
 			print("can't update device power: %s\n", err);
 			return err;
 		}
-		if((err = sendmccupdate(ctlr, "ZZ")) != nil){
-			print("can't disable beacon filter: %s\n", err);
-			return err;
-		}
+		if(ctlr->fw->capa[0] & UcodeCapLar)
+			if((err = sendmccupdate(ctlr, "ZZ")) != nil)
+				return err;
 		if((err = disablebeaconfilter(ctlr)) != nil){
 			print("can't disable beacon filter: %s\n", err);
 			return err;
@@ -3418,6 +3444,7 @@
 static char*
 qcmd(Ctlr *ctlr, uint qid, uint code, uchar *data, int size, Block *block)
 {
+	char *err;
 	int hdrlen;
 	Block *bcmd;
 	uchar *d, *c;
@@ -3452,10 +3479,10 @@
 		return "qcmd: broken";
 	}
 	/* wake up the nic (just needed for 7k) */
-	if(ctlr->family == 7000 && q->n == 0)
-		if(niclock(ctlr) != nil){
+	if(ctlr->family == 7000 && qid == 4 && q->n == 0)
+		if((err = niclock(ctlr)) != nil){
 			iunlock(ctlr);
-			return "qcmd: busy";
+			return err;
 		}
 	q->n++;
 	q->lastcmd = code;
@@ -3586,9 +3613,16 @@
 	int i;
 
 	for(i = 0; i < nelem(ctlr->tx); i++)
-		flushq(ctlr, i);
-	settimeevent(ctlr, CmdRemove, 0);
+		if((err = flushq(ctlr, i)) != nil){
+			print("can't flush queue %d: %s", i, err);
+			return err;
+		}
 
+	if((err = settimeevent(ctlr, CmdRemove, 0)) != nil){
+		print("can't remove time event: %s", err);
+		return err;
+	}
+
 	if((err = setbindingquotas(ctlr, -1)) != nil){
 		print("can't disable quotas: %s\n", err);
 		return err;
@@ -4283,8 +4317,8 @@
 		if(tx != nil && tx->n > 0){
 			tx->n--;
 			wakeup(tx);
-			/* unlock 7k family nics as all commands are done */
-			if(ctlr->family == 7000 && tx->n == 0)
+			/* unlock 7k family nics as the command is done */
+			if(ctlr->family == 7000 && qid == 4 && tx->n == 0)
 				nicunlock(ctlr);
 		}
 	}

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [9front] driver for intel wireless 7260?
  2021-08-12 21:03                   ` kemal
@ 2021-08-13 19:49                     ` Skylar Bleed
  2021-08-14 13:26                       ` kemal
  2021-08-13 23:41                     ` kemal
  1 sibling, 1 reply; 29+ messages in thread
From: Skylar Bleed @ 2021-08-13 19:49 UTC (permalink / raw)
  To: 9front

well, I'm still getting the same error even with the diff, but perhaps I should actually make sure I'm applying it right. I've been applying the patch to the current etheriwl.c file in git, not the version that was last patched, because when I did that it'd give me an error about rejects. is that what I should be doing? I know I should have asked sooner than this but I was a bit embarrassed.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [9front] driver for intel wireless 7260?
  2021-08-12 21:03                   ` kemal
  2021-08-13 19:49                     ` Skylar Bleed
@ 2021-08-13 23:41                     ` kemal
  2021-08-14 17:25                       ` cinap_lenrek
  2021-08-14 17:50                       ` kemal
  1 sibling, 2 replies; 29+ messages in thread
From: kemal @ 2021-08-13 23:41 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 414 bytes --]

2021-08-12 21:03 GMT, kemal <kemalinanc8@gmail.com>:
> the new diff is attached.

IGNORE THIS DIFF.

with qwx, we have managed to make 7260 finally work.

tho we still have one issue. driver works slow as fuck compared
to older 5k-6k generation of cards. we think that this is caused
by iwl not being able to get calibration results from the fw.
i will look into this more tommorow.

the current diff is attached.

[-- Attachment #2: diff.txt --]
[-- Type: text/plain, Size: 6166 bytes --]

--- /sys/src/9/pc/etheriwl.c
+++ /sys/src/9/pc/etheriwl.c
@@ -329,7 +329,29 @@
 	SchedTransTblOff	= 0x7E0,		// +q*2
 };
 
+/*
+ * uCode TLV api
+ */
 enum {
+	/* api[0] */
+	UcodeApiSta	= 1<<30,
+};
+
+/*
+ * uCode capabilities
+ */
+enum {
+	/* capa[0] */
+	UcodeCapLar	= 1<<1,
+
+	/* capa[1] */
+	UcodeCapQuota	= 1<<12,
+	
+	/* capa[2] */
+	UcodeCapLar2	= 1<<9,
+};
+
+enum {
 	FilterPromisc		= 1<<0,
 	FilterCtl		= 1<<1,
 	FilterMulticast		= 1<<2,
@@ -418,6 +440,7 @@
 	uint	build;
 	char	descr[64+1];
 
+	u32int	flags;
 	u32int	capa[4];
 	u32int	api[4];
 
@@ -635,7 +658,7 @@
 	Type2030	= 12,
 	Type2000	= 16,
 
-	Type7260	= 30,
+	Type7260	= 20,
 	Type8265	= 35,
 };
 
@@ -1478,6 +1501,11 @@
 				s = &i->boot.text;
 				s->addr = 0x00000000;
 				goto Sect;
+			case 18:
+				if(l < 4)
+					goto Tooshort;
+				i->flags = get32(p);
+				break;
 			case 19:
 				if(i->main.nsect >= nelem(i->main.sect))
 					return "too many main sections";
@@ -1984,7 +2012,7 @@
 	*p++ = mcc[0];
 	*p++ = 0;
 	*p++ = 0;	// reserved
-	if(1){
+	if(ctlr->fw->capa[2] & UcodeCapLar2){
 		p += 4;
 		p += 5*4;
 	}
@@ -2272,7 +2300,9 @@
 			ea[5] = a1 >> 0;
 		}
 	} else {
-		readnvmsect(ctlr, 0, ea, Eaddrlen, 0x15<<1);
+		/* fw gets angry if we read 6 bytes */
+		readnvmsect(ctlr, 0, buf, 8, 0x15<<1);
+		memmove(ea, buf, Eaddrlen);
 	}
 	memmove(ctlr->edev->addr, ea, Eaddrlen);
 
@@ -2366,7 +2396,7 @@
 		p += 2;			/* sleep_tx_count */
 		p++;			/* sleep state flags */
 
-		*p++ = (ctlr->fw->api[0] & (1<<30)) != 0 ? type : 0;		/* station_type */
+		*p++ = ctlr->fw->api[0] & UcodeApiSta ? type : 0;		/* station_type */
 
 		p += 2;			/* assoc id */
 
@@ -2375,7 +2405,7 @@
 		put32(p, 1<<0);
 		p += 4;			/* tfd_queue_mask */
 
-		if(1){
+		if(ctlr->fw->api[0] & UcodeApiSta){
 			p += 2;		/* rx_ba_window */
 			p++;		/* sp_length */
 			p++;		/* uapsd_acs */
@@ -2640,7 +2670,7 @@
 static char*
 settimeevent(Ctlr *ctlr, int amr, int ival)
 {
-	int duration, delay, timeid;
+	int timeid;
 	uchar c[9*4], *p;
 	char *err;
 
@@ -2662,14 +2692,6 @@
 		break;
 	}
 
-	if(ival){
-		duration = ival*2;
-		delay = ival/2;
-	} else {
-		duration = 1024;
-		delay = 0;
-	}
-
 	memset(p = c, 0, sizeof(c));
 	put32(p, ctlr->macid);
 	p += 4;
@@ -2678,32 +2700,36 @@
 	put32(p, timeid);
 	p += 4;
 
-	put32(p, 0);	// apply time
-	p += 4;
-	put32(p, delay);
-	p += 4;
-	put32(p, 0);	// depends on
-	p += 4;
-	put32(p, 1);	// interval
-	p += 4;
-	put32(p, duration);
-	p += 4;
-	*p++ = 1;	// repeat
-	*p++ = 0;	// max frags
-	put16(p, 1<<0 | 1<<1 | 1<<11);	// policy
-	p += 2;
+	if(amr == CmdRemove)
+		p += 6*4;
+	else{
+		put32(p, 0);			// apply time
+		p += 4;
+		put32(p, ival/2);		// max delay
+		p += 4;
+		put32(p, 0);			// depends on
+		p += 4;
+		put32(p, 1);			// interval
+		p += 4;
+		put32(p, ival? ival*2: 1024);	// duration
+		p += 4;
+		*p++ = 1;			// repeat
+		*p++ = 0;			// max frags
+		put16(p, 1<<0 | 1<<1 | 1<<11);	// policy
+		p += 2;
+	}
 
 	ctlr->te.active = 0;
 	if((err =  cmd(ctlr, 41, c, p - c)) != nil)
 		return err;
 
+	tsleep(&ctlr->te, timeeventdone, ctlr, 100);
 	if(amr == CmdRemove){
 		ctlr->te.active = 0;
 		ctlr->te.id = -1;
 		return nil;
-	}
-	tsleep(&ctlr->te, timeeventdone, ctlr, 100);
-	return ctlr->te.active? nil: "timeevent did not start";
+	}else
+		return ctlr->te.active? nil: "timeevent did not start";
 }
 
 
@@ -2713,6 +2739,9 @@
 	uchar c[4*(3*4)], *p;
 	int i;
 
+	if((ctlr->fw->capa[1] & UcodeCapQuota) == 0)
+		return nil;
+
 	i = 0;
 	p = c;
 
@@ -2822,13 +2851,13 @@
 	return cmd(ctlr, 210, c, 11*4);
 }
 
-static void
+static char*
 tttxbackoff(Ctlr *ctlr)
 {
 	uchar c[4];
 	
 	put32(c, 0);
-	cmd(ctlr, 126, c, sizeof(c));
+	return cmd(ctlr, 126, c, sizeof(c));
 }
 
 static char*
@@ -2848,6 +2877,9 @@
 	char *err;
 
 	if(ctlr->calib.done == 0){
+		if(ctlr->family == 7000)
+			if((err = sendbtcoexadv(ctlr)) != nil)
+				return err;
 		if((err = readnvmconfig(ctlr)) != nil)
 			return err;
 	}
@@ -2897,16 +2929,16 @@
 
 		/* Initialize tx backoffs to the minimum. */
 		if(ctlr->family == 7000)
-			tttxbackoff(ctlr);
+			if((err = tttxbackoff(ctlr)) != nil)
+				return err;
 
 		if((err = updatedevicepower(ctlr)) != nil){
 			print("can't update device power: %s\n", err);
 			return err;
 		}
-		if((err = sendmccupdate(ctlr, "ZZ")) != nil){
-			print("can't disable beacon filter: %s\n", err);
-			return err;
-		}
+		if(ctlr->fw->capa[0] & UcodeCapLar)
+			if((err = sendmccupdate(ctlr, "ZZ")) != nil)
+				return err;
 		if((err = disablebeaconfilter(ctlr)) != nil){
 			print("can't disable beacon filter: %s\n", err);
 			return err;
@@ -3418,6 +3450,7 @@
 static char*
 qcmd(Ctlr *ctlr, uint qid, uint code, uchar *data, int size, Block *block)
 {
+	char *err;
 	int hdrlen;
 	Block *bcmd;
 	uchar *d, *c;
@@ -3452,10 +3485,10 @@
 		return "qcmd: broken";
 	}
 	/* wake up the nic (just needed for 7k) */
-	if(ctlr->family == 7000 && q->n == 0)
-		if(niclock(ctlr) != nil){
+	if(ctlr->family == 7000 && qid == 4 && q->n == 0)
+		if((err = niclock(ctlr)) != nil){
 			iunlock(ctlr);
-			return "qcmd: busy";
+			return err;
 		}
 	q->n++;
 	q->lastcmd = code;
@@ -3586,9 +3619,16 @@
 	int i;
 
 	for(i = 0; i < nelem(ctlr->tx); i++)
-		flushq(ctlr, i);
-	settimeevent(ctlr, CmdRemove, 0);
+		if((err = flushq(ctlr, i)) != nil){
+			print("can't flush queue %d: %s\n", i, err);
+			return err;
+		}
 
+	if((err = settimeevent(ctlr, CmdRemove, 0)) != nil){
+		print("can't remove time event: %s\n", err);
+		return err;
+	}
+
 	if((err = setbindingquotas(ctlr, -1)) != nil){
 		print("can't disable quotas: %s\n", err);
 		return err;
@@ -3630,7 +3670,7 @@
 		return err;
 	}
 	if((err = setbindingcontext(ctlr, CmdAdd)) != nil){
-		print("removing bindingcontext: %s\n", err);
+		print("adding bindingcontext: %s\n", err);
 		return err;
 	}
 	if((err = setmcastfilter(ctlr)) != nil){
@@ -4283,8 +4323,8 @@
 		if(tx != nil && tx->n > 0){
 			tx->n--;
 			wakeup(tx);
-			/* unlock 7k family nics as all commands are done */
-			if(ctlr->family == 7000 && tx->n == 0)
+			/* unlock 7k family nics as the command is done */
+			if(ctlr->family == 7000 && qid == 4 && tx->n == 0)
 				nicunlock(ctlr);
 		}
 	}

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [9front] driver for intel wireless 7260?
  2021-08-13 19:49                     ` Skylar Bleed
@ 2021-08-14 13:26                       ` kemal
  0 siblings, 0 replies; 29+ messages in thread
From: kemal @ 2021-08-14 13:26 UTC (permalink / raw)
  To: 9front

2021-08-13 19:49 GMT, Skylar Bleed <skylarbleed@protonmail.ch>:
> well, I'm still getting the same error even with the diff, but perhaps I
> should actually make sure I'm applying it right. I've been applying the
> patch to the current etheriwl.c file in git, not the version that was last
> patched, because when I did that it'd give me an error about rejects. is
> that what I should be doing? I know I should have asked sooner than this but
> I was a bit embarrassed.

the commands:

git/revert /sys/src/9/pc/etheriwl.c
ape/patch -p0 <diff.txt

should work.

in addition, don't forget to build the kernel and place it into 9fat
with these commands:

cd /sys/src/9/pc64
mk install
9fs 9fat
mv 9pc64 /n/9fat/9pc64
mk clean

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [9front] driver for intel wireless 7260?
  2021-08-13 23:41                     ` kemal
@ 2021-08-14 17:25                       ` cinap_lenrek
  2021-08-14 17:50                       ` kemal
  1 sibling, 0 replies; 29+ messages in thread
From: cinap_lenrek @ 2021-08-14 17:25 UTC (permalink / raw)
  To: 9front

> with qwx, we have managed to make 7260 finally work.

congratulations! keep on the good work :-)

--
cinap

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [9front] driver for intel wireless 7260?
  2021-08-13 23:41                     ` kemal
  2021-08-14 17:25                       ` cinap_lenrek
@ 2021-08-14 17:50                       ` kemal
  1 sibling, 0 replies; 29+ messages in thread
From: kemal @ 2021-08-14 17:50 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 535 bytes --]

2021-08-13 23:41 GMT, kemal <kemalinanc8@gmail.com>:
> the current diff is attached.

also ignore this diff.

driver was reading the mac address from the nvm wrong.

1- as driver reads 8 bytes from nvm instead of 6 so fw doesn't
spit us an ADVANCED_SYSASSERT, it was reading 2 more
extra bytes. apparently those 2 extra bytes were put to
the first 2 bytes of our buffer, so we got to skip that.
2- the mac address is encoded in a weird le16 order. we have
to byte swap so we get the correct mac address.

the current diff is attached.

[-- Attachment #2: diff.txt --]
[-- Type: text/plain, Size: 6315 bytes --]

--- /sys/src/9/pc/etheriwl.c
+++ /sys/src/9/pc/etheriwl.c
@@ -329,7 +329,29 @@
 	SchedTransTblOff	= 0x7E0,		// +q*2
 };
 
+/*
+ * uCode TLV api
+ */
 enum {
+	/* api[0] */
+	UcodeApiSta	= 1<<30,
+};
+
+/*
+ * uCode capabilities
+ */
+enum {
+	/* capa[0] */
+	UcodeCapLar	= 1<<1,
+
+	/* capa[1] */
+	UcodeCapQuota	= 1<<12,
+	
+	/* capa[2] */
+	UcodeCapLar2	= 1<<9,
+};
+
+enum {
 	FilterPromisc		= 1<<0,
 	FilterCtl		= 1<<1,
 	FilterMulticast		= 1<<2,
@@ -418,6 +440,7 @@
 	uint	build;
 	char	descr[64+1];
 
+	u32int	flags;
 	u32int	capa[4];
 	u32int	api[4];
 
@@ -635,7 +658,7 @@
 	Type2030	= 12,
 	Type2000	= 16,
 
-	Type7260	= 30,
+	Type7260	= 20,
 	Type8265	= 35,
 };
 
@@ -1478,6 +1501,11 @@
 				s = &i->boot.text;
 				s->addr = 0x00000000;
 				goto Sect;
+			case 18:
+				if(l < 4)
+					goto Tooshort;
+				i->flags = get32(p);
+				break;
 			case 19:
 				if(i->main.nsect >= nelem(i->main.sect))
 					return "too many main sections";
@@ -1984,7 +2012,7 @@
 	*p++ = mcc[0];
 	*p++ = 0;
 	*p++ = 0;	// reserved
-	if(1){
+	if(ctlr->fw->capa[2] & UcodeCapLar2){
 		p += 4;
 		p += 5*4;
 	}
@@ -2272,7 +2300,15 @@
 			ea[5] = a1 >> 0;
 		}
 	} else {
-		readnvmsect(ctlr, 0, ea, Eaddrlen, 0x15<<1);
+		/* fw gets angry if we read 6 bytes */
+		readnvmsect(ctlr, 0, buf, 8, 0x15<<1);
+		/* the first 2 bytes is garbage and the byte order is le16 */
+		ea[0] = buf[3];
+		ea[1] = buf[2];
+		ea[2] = buf[5];
+		ea[3] = buf[4];
+		ea[4] = buf[7];
+		ea[5] = buf[6];
 	}
 	memmove(ctlr->edev->addr, ea, Eaddrlen);
 
@@ -2366,7 +2402,7 @@
 		p += 2;			/* sleep_tx_count */
 		p++;			/* sleep state flags */
 
-		*p++ = (ctlr->fw->api[0] & (1<<30)) != 0 ? type : 0;		/* station_type */
+		*p++ = ctlr->fw->api[0] & UcodeApiSta ? type : 0;		/* station_type */
 
 		p += 2;			/* assoc id */
 
@@ -2375,7 +2411,7 @@
 		put32(p, 1<<0);
 		p += 4;			/* tfd_queue_mask */
 
-		if(1){
+		if(ctlr->fw->api[0] & UcodeApiSta){
 			p += 2;		/* rx_ba_window */
 			p++;		/* sp_length */
 			p++;		/* uapsd_acs */
@@ -2640,7 +2676,7 @@
 static char*
 settimeevent(Ctlr *ctlr, int amr, int ival)
 {
-	int duration, delay, timeid;
+	int timeid;
 	uchar c[9*4], *p;
 	char *err;
 
@@ -2662,14 +2698,6 @@
 		break;
 	}
 
-	if(ival){
-		duration = ival*2;
-		delay = ival/2;
-	} else {
-		duration = 1024;
-		delay = 0;
-	}
-
 	memset(p = c, 0, sizeof(c));
 	put32(p, ctlr->macid);
 	p += 4;
@@ -2678,32 +2706,36 @@
 	put32(p, timeid);
 	p += 4;
 
-	put32(p, 0);	// apply time
-	p += 4;
-	put32(p, delay);
-	p += 4;
-	put32(p, 0);	// depends on
-	p += 4;
-	put32(p, 1);	// interval
-	p += 4;
-	put32(p, duration);
-	p += 4;
-	*p++ = 1;	// repeat
-	*p++ = 0;	// max frags
-	put16(p, 1<<0 | 1<<1 | 1<<11);	// policy
-	p += 2;
+	if(amr == CmdRemove)
+		p += 6*4;
+	else{
+		put32(p, 0);			// apply time
+		p += 4;
+		put32(p, ival/2);		// max delay
+		p += 4;
+		put32(p, 0);			// depends on
+		p += 4;
+		put32(p, 1);			// interval
+		p += 4;
+		put32(p, ival? ival*2: 1024);	// duration
+		p += 4;
+		*p++ = 1;			// repeat
+		*p++ = 0;			// max frags
+		put16(p, 1<<0 | 1<<1 | 1<<11);	// policy
+		p += 2;
+	}
 
 	ctlr->te.active = 0;
 	if((err =  cmd(ctlr, 41, c, p - c)) != nil)
 		return err;
 
+	tsleep(&ctlr->te, timeeventdone, ctlr, 100);
 	if(amr == CmdRemove){
 		ctlr->te.active = 0;
 		ctlr->te.id = -1;
 		return nil;
-	}
-	tsleep(&ctlr->te, timeeventdone, ctlr, 100);
-	return ctlr->te.active? nil: "timeevent did not start";
+	}else
+		return ctlr->te.active? nil: "timeevent did not start";
 }
 
 
@@ -2713,6 +2745,9 @@
 	uchar c[4*(3*4)], *p;
 	int i;
 
+	if((ctlr->fw->capa[1] & UcodeCapQuota) == 0)
+		return nil;
+
 	i = 0;
 	p = c;
 
@@ -2822,13 +2857,13 @@
 	return cmd(ctlr, 210, c, 11*4);
 }
 
-static void
+static char*
 tttxbackoff(Ctlr *ctlr)
 {
 	uchar c[4];
 	
 	put32(c, 0);
-	cmd(ctlr, 126, c, sizeof(c));
+	return cmd(ctlr, 126, c, sizeof(c));
 }
 
 static char*
@@ -2848,6 +2883,9 @@
 	char *err;
 
 	if(ctlr->calib.done == 0){
+		if(ctlr->family == 7000)
+			if((err = sendbtcoexadv(ctlr)) != nil)
+				return err;
 		if((err = readnvmconfig(ctlr)) != nil)
 			return err;
 	}
@@ -2897,16 +2935,16 @@
 
 		/* Initialize tx backoffs to the minimum. */
 		if(ctlr->family == 7000)
-			tttxbackoff(ctlr);
+			if((err = tttxbackoff(ctlr)) != nil)
+				return err;
 
 		if((err = updatedevicepower(ctlr)) != nil){
 			print("can't update device power: %s\n", err);
 			return err;
 		}
-		if((err = sendmccupdate(ctlr, "ZZ")) != nil){
-			print("can't disable beacon filter: %s\n", err);
-			return err;
-		}
+		if(ctlr->fw->capa[0] & UcodeCapLar)
+			if((err = sendmccupdate(ctlr, "ZZ")) != nil)
+				return err;
 		if((err = disablebeaconfilter(ctlr)) != nil){
 			print("can't disable beacon filter: %s\n", err);
 			return err;
@@ -3418,6 +3456,7 @@
 static char*
 qcmd(Ctlr *ctlr, uint qid, uint code, uchar *data, int size, Block *block)
 {
+	char *err;
 	int hdrlen;
 	Block *bcmd;
 	uchar *d, *c;
@@ -3452,10 +3491,10 @@
 		return "qcmd: broken";
 	}
 	/* wake up the nic (just needed for 7k) */
-	if(ctlr->family == 7000 && q->n == 0)
-		if(niclock(ctlr) != nil){
+	if(ctlr->family == 7000 && qid == 4 && q->n == 0)
+		if((err = niclock(ctlr)) != nil){
 			iunlock(ctlr);
-			return "qcmd: busy";
+			return err;
 		}
 	q->n++;
 	q->lastcmd = code;
@@ -3586,9 +3625,16 @@
 	int i;
 
 	for(i = 0; i < nelem(ctlr->tx); i++)
-		flushq(ctlr, i);
-	settimeevent(ctlr, CmdRemove, 0);
+		if((err = flushq(ctlr, i)) != nil){
+			print("can't flush queue %d: %s\n", i, err);
+			return err;
+		}
 
+	if((err = settimeevent(ctlr, CmdRemove, 0)) != nil){
+		print("can't remove time event: %s\n", err);
+		return err;
+	}
+
 	if((err = setbindingquotas(ctlr, -1)) != nil){
 		print("can't disable quotas: %s\n", err);
 		return err;
@@ -3630,7 +3676,7 @@
 		return err;
 	}
 	if((err = setbindingcontext(ctlr, CmdAdd)) != nil){
-		print("removing bindingcontext: %s\n", err);
+		print("adding bindingcontext: %s\n", err);
 		return err;
 	}
 	if((err = setmcastfilter(ctlr)) != nil){
@@ -4283,8 +4329,8 @@
 		if(tx != nil && tx->n > 0){
 			tx->n--;
 			wakeup(tx);
-			/* unlock 7k family nics as all commands are done */
-			if(ctlr->family == 7000 && tx->n == 0)
+			/* unlock 7k family nics as the command is done */
+			if(ctlr->family == 7000 && qid == 4 && tx->n == 0)
 				nicunlock(ctlr);
 		}
 	}

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [9front] driver for intel wireless 7260?
  2021-08-05 12:41           ` kemal
  2021-08-05 21:19             ` Eckard Brauer
@ 2021-08-05 22:33             ` cinap_lenrek
  1 sibling, 0 replies; 29+ messages in thread
From: cinap_lenrek @ 2021-08-05 22:33 UTC (permalink / raw)
  To: 9front

excellent! applied.

--
cinap

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [9front] driver for intel wireless 7260?
  2021-08-05 12:41           ` kemal
@ 2021-08-05 21:19             ` Eckard Brauer
  2021-08-05 22:33             ` cinap_lenrek
  1 sibling, 0 replies; 29+ messages in thread
From: Eckard Brauer @ 2021-08-05 21:19 UTC (permalink / raw)
  To: 9front

Will try it out these days - am a bit unde rstress currently as my
mother in law is just dying, so i'd have to be a bit more bound to the
family...

Am Thu, 5 Aug 2021 12:41:30 +0000
schrieb kemal <kemalinanc8@gmail.com>:

>  [...]
>
> ok, i cleaned it up.



--

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [9front] driver for intel wireless 7260?
  2021-08-05  7:52         ` cinap_lenrek
@ 2021-08-05 12:41           ` kemal
  2021-08-05 21:19             ` Eckard Brauer
  2021-08-05 22:33             ` cinap_lenrek
  0 siblings, 2 replies; 29+ messages in thread
From: kemal @ 2021-08-05 12:41 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 177 bytes --]

> avoid this stuff. this code depends on the endianess of
> the arch... everyone else is preparing bytes,
> even if we just need to provide a single long.

ok, i cleaned it up.

[-- Attachment #2: diff.txt --]
[-- Type: text/plain, Size: 2882 bytes --]

--- /sys/src/9/pc/etheriwl.c
+++ /sys/src/9/pc/etheriwl.c
@@ -1,9 +1,10 @@
 /*
  * Intel WiFi Link driver.
  *
- * Written without any documentation but Damien Bergaminis
- * OpenBSD iwn(4) and iwm(4) driver sources. Requires intel
- * firmware to be present in /lib/firmware/iwn-* on attach.
+ * Written without any documentation but Damien Bergamini's
+ * iwn(4) and Stefan Sperling's iwm(4) OpenBSD driver sources.
+ * Requires Intel firmware to be present in /lib/firmware/iw[nm]-*
+ * on attach.
  */
 
 #include "u.h"
@@ -242,6 +243,8 @@
 
 	SbCpu1Status	= 0xa01e30,
 	SbCpu2Status	= 0xa01e34,
+	OscClk		= 0xa04068,
+		OscClkCtrl	= 1<<3,
 	UregChick	= 0xa05c00,
 		UregChickMsiEnable	= 1<<24,
 
@@ -632,6 +635,7 @@
 	Type2030	= 12,
 	Type2000	= 16,
 
+	Type7260	= 30,
 	Type8265	= 35,
 };
 
@@ -686,6 +690,7 @@
 	[Type6005] "iwn-6005", /* see in iwlattach() below */
 	[Type2030] "iwn-2030",
 	[Type2000] "iwn-2000",
+	[Type7260] "iwm-7260-17",
 };
 
 static char *qcmd(Ctlr *ctlr, uint qid, uint code, uchar *data, int size, Block *block);
@@ -1088,6 +1093,23 @@
 		nicunlock(ctlr);
 	}
 
+	/* Enable the oscillator to count wake up time for L1 exit. (weird W/A) */
+	if(ctlr->type == Type7260){
+		if((err = niclock(ctlr)) != nil)
+			return err;
+
+		prphread(ctlr, OscClk);
+		prphread(ctlr, OscClk);
+		delay(20);
+
+		prphwrite(ctlr, OscClk, prphread(ctlr, OscClk) | OscClkCtrl);
+
+		prphread(ctlr, OscClk);
+		prphread(ctlr, OscClk);
+
+		nicunlock(ctlr);
+	}
+
 	if(ctlr->family < 8000){
 		if((err = niclock(ctlr)) != nil)
 			return err;
@@ -2800,6 +2822,15 @@
 	return cmd(ctlr, 210, c, 11*4);
 }
 
+static void
+tttxbackoff(Ctlr *ctlr)
+{
+	uchar c[4];
+	
+	put32(c, 0);
+	cmd(ctlr, 126, c, sizeof(c));
+}
+
 static char*
 updatedevicepower(Ctlr *ctlr)
 {
@@ -2864,6 +2895,10 @@
 		if((err = sendbtcoexadv(ctlr)) != nil)
 			return err;
 
+		/* Initialize tx backoffs to the minimum. */
+		if(ctlr->family == 7000)
+			tttxbackoff(ctlr);
+
 		if((err = updatedevicepower(ctlr)) != nil){
 			print("can't update device power: %s\n", err);
 			return err;
@@ -3416,6 +3451,12 @@
 		iunlock(ctlr);
 		return "qcmd: broken";
 	}
+	/* wake up the nic (just needed for 7k) */
+	if(ctlr->family == 7000 && q->n == 0)
+		if(niclock(ctlr) != nil){
+			iunlock(ctlr);
+			return "qcmd: busy";
+		}
 	q->n++;
 	q->lastcmd = code;
 
@@ -4242,6 +4283,9 @@
 		if(tx != nil && tx->n > 0){
 			tx->n--;
 			wakeup(tx);
+			/* unlock 7k family nics as all commands are done */
+			if(ctlr->family == 7000 && tx->n == 0)
+				nicunlock(ctlr);
 		}
 	}
 
@@ -4349,6 +4393,11 @@
 		case 0x088e:	/* Centrino Advanced-N 6235 */
 		case 0x088f:	/* Centrino Advanced-N 6235 */
 			family = 0;
+			fwname = nil;
+			break;
+		case 0x08b1:	/* Wireless AC 7260 */
+		case 0x08b2:	/* Wireless AC 7260 */
+			family = 7000;
 			fwname = nil;
 			break;
 		case 0x24f3:	/* Wireless AC 8260 */

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [9front] driver for intel wireless 7260?
  2021-08-05  0:32       ` kemal
@ 2021-08-05  7:52         ` cinap_lenrek
  2021-08-05 12:41           ` kemal
  0 siblings, 1 reply; 29+ messages in thread
From: cinap_lenrek @ 2021-08-05  7:52 UTC (permalink / raw)
  To: 9front

static void
+tttxbackoff(Ctlr *ctlr, u32int backoff)
+{
+	cmd(ctlr, 126, (uchar*)&backoff, sizeof(backoff));
+}

avoid this stuff. this code depends on the endianess of
the arch... everyone else is preparing bytes,
even if we just need to provide a single long.

--
cinap

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [9front] driver for intel wireless 7260?
  2021-08-04 20:50     ` kemal
@ 2021-08-05  0:32       ` kemal
  2021-08-05  7:52         ` cinap_lenrek
  0 siblings, 1 reply; 29+ messages in thread
From: kemal @ 2021-08-05  0:32 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 353 bytes --]

> just now i cleaned up those patches and now i have a diff that
> should work. it can be applied with `ape/patch -p0 < diff.txt`

fuck forgot one thing... openbsd sends a command for 7k family
after boot, it initializes tx backoffs to minimum. in addition,
obsd does not check for errors for this command, gonna do the
same.

the new diff is attached.

[-- Attachment #2: diff.txt --]
[-- Type: text/plain, Size: 2945 bytes --]

--- /sys/src/9/pc/etheriwl.c
+++ /sys/src/9/pc/etheriwl.c
@@ -1,9 +1,10 @@
 /*
  * Intel WiFi Link driver.
  *
- * Written without any documentation but Damien Bergaminis
- * OpenBSD iwn(4) and iwm(4) driver sources. Requires intel
- * firmware to be present in /lib/firmware/iwn-* on attach.
+ * Written without any documentation but Damien Bergamini's
+ * iwn(4) and Stefan Sperling's iwm(4) OpenBSD driver sources.
+ * Requires Intel firmware to be present in /lib/firmware/iw[nm]-*
+ * on attach.
  */
 
 #include "u.h"
@@ -242,6 +243,8 @@
 
 	SbCpu1Status	= 0xa01e30,
 	SbCpu2Status	= 0xa01e34,
+	OscClk		= 0xa04068,
+		OscClkCtrl	= 1<<3,
 	UregChick	= 0xa05c00,
 		UregChickMsiEnable	= 1<<24,
 
@@ -631,6 +634,7 @@
 	Type6005	= 11,	/* also Centrino Advanced-N 6030, 6235 */
 	Type2030	= 12,
 	Type2000	= 16,
+	Type7260	= 30,
 
 	Type8265	= 35,
 };
@@ -686,6 +690,7 @@
 	[Type6005] "iwn-6005", /* see in iwlattach() below */
 	[Type2030] "iwn-2030",
 	[Type2000] "iwn-2000",
+	[Type7260] "iwm-7260-17",
 };
 
 static char *qcmd(Ctlr *ctlr, uint qid, uint code, uchar *data, int size, Block *block);
@@ -1088,6 +1093,22 @@
 		nicunlock(ctlr);
 	}
 
+	/* Enable the oscillator to count wake up time for L1 exit. (weird W/A) */
+	if(ctlr->type == Type7260){
+		if((err = niclock(ctlr)) != nil)
+			return err;
+
+		prphread(ctlr, OscClk);
+		prphread(ctlr, OscClk);
+		delay(20);
+
+		prphwrite(ctlr, OscClk, prphread(ctlr, OscClk) | OscClkCtrl);
+
+		prphread(ctlr, OscClk);
+		prphread(ctlr, OscClk);
+
+		nicunlock(ctlr);
+	}
 	if(ctlr->family < 8000){
 		if((err = niclock(ctlr)) != nil)
 			return err;
@@ -2800,6 +2821,12 @@
 	return cmd(ctlr, 210, c, 11*4);
 }
 
+static void
+tttxbackoff(Ctlr *ctlr, u32int backoff)
+{
+	cmd(ctlr, 126, (uchar*)&backoff, sizeof(backoff));
+}
+
 static char*
 updatedevicepower(Ctlr *ctlr)
 {
@@ -2864,6 +2891,10 @@
 		if((err = sendbtcoexadv(ctlr)) != nil)
 			return err;
 
+		/* Initialize tx backoffs to the minimum. */
+		if(ctlr->family == 7000)
+			tttxbackoff(ctlr, 0);
+
 		if((err = updatedevicepower(ctlr)) != nil){
 			print("can't update device power: %s\n", err);
 			return err;
@@ -3416,6 +3447,12 @@
 		iunlock(ctlr);
 		return "qcmd: broken";
 	}
+	/* wake up the nic (just needed for 7k) */
+	if(ctlr->family == 7000 && q->n == 0)
+		if(niclock(ctlr) != nil){
+			iunlock(ctlr);
+			return "qcmd: busy";
+		}
 	q->n++;
 	q->lastcmd = code;
 
@@ -4242,6 +4279,9 @@
 		if(tx != nil && tx->n > 0){
 			tx->n--;
 			wakeup(tx);
+			/* unlock 7k family nics as all commands are done */
+			if(ctlr->family == 7000 && tx->n == 0)
+				nicunlock(ctlr);
 		}
 	}
 
@@ -4349,6 +4389,11 @@
 		case 0x088e:	/* Centrino Advanced-N 6235 */
 		case 0x088f:	/* Centrino Advanced-N 6235 */
 			family = 0;
+			fwname = nil;
+			break;
+		case 0x08b1:	/* Wireless AC 7260 */
+		case 0x08b2:	/* Wireless AC 7260 */
+			family = 7000;
 			fwname = nil;
 			break;
 		case 0x24f3:	/* Wireless AC 8260 */

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [9front] driver for intel wireless 7260?
  2021-07-27  7:21   ` Aw: " Eckard Brauer
@ 2021-08-04 20:50     ` kemal
  2021-08-05  0:32       ` kemal
  0 siblings, 1 reply; 29+ messages in thread
From: kemal @ 2021-08-04 20:50 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 742 bytes --]

2021-07-27 7:21 GMT, Eckard Brauer <eckard.brauer@gmx.de>:
> Just a few weeks ago, I had some mailing with Kemal for that topic, as
> he tried to help me on that. My little understanding reached it's end
> early, and unfortunately we had no luck getting the card to work
> finally, but Kemal already did some patches I tried out.

correct. (except for the few weeks part, it has been months :))

just now i cleaned up those patches and now i have a diff that
should work. it can be applied with `ape/patch -p0 < diff.txt`

this diff might work with 3160, but requires normal additions like
pci ids etc. PLUS this line:

"	if(ctlr->type == Type7260){"

being changed to

"	if(ctlr->type == Type7260 || ctlr->type == Type3160){

hope it works.

[-- Attachment #2: diff.txt --]
[-- Type: text/plain, Size: 2419 bytes --]

--- /sys/src/9/pc/etheriwl.c
+++ /sys/src/9/pc/etheriwl.c
@@ -1,9 +1,10 @@
 /*
  * Intel WiFi Link driver.
  *
- * Written without any documentation but Damien Bergaminis
- * OpenBSD iwn(4) and iwm(4) driver sources. Requires intel
- * firmware to be present in /lib/firmware/iwn-* on attach.
+ * Written without any documentation but Damien Bergamini's
+ * iwn(4) and Stefan Sperling's iwm(4) OpenBSD driver sources.
+ * Requires Intel firmware to be present in /lib/firmware/iw[nm]-*
+ * on attach.
  */
 
 #include "u.h"
@@ -242,6 +243,8 @@
 
 	SbCpu1Status	= 0xa01e30,
 	SbCpu2Status	= 0xa01e34,
+	OscClk		= 0xa04068,
+		OscClkCtrl	= 1<<3,
 	UregChick	= 0xa05c00,
 		UregChickMsiEnable	= 1<<24,
 
@@ -631,6 +634,7 @@
 	Type6005	= 11,	/* also Centrino Advanced-N 6030, 6235 */
 	Type2030	= 12,
 	Type2000	= 16,
+	Type7260	= 30,
 
 	Type8265	= 35,
 };
@@ -686,6 +690,7 @@
 	[Type6005] "iwn-6005", /* see in iwlattach() below */
 	[Type2030] "iwn-2030",
 	[Type2000] "iwn-2000",
+	[Type7260] "iwm-7260-17",
 };
 
 static char *qcmd(Ctlr *ctlr, uint qid, uint code, uchar *data, int size, Block *block);
@@ -1088,6 +1093,22 @@
 		nicunlock(ctlr);
 	}
 
+	/* Enable the oscillator to count wake up time for L1 exit. (weird W/A) */
+	if(ctlr->type == Type7260){
+		if((err = niclock(ctlr)) != nil)
+			return err;
+
+		prphread(ctlr, OscClk);
+		prphread(ctlr, OscClk);
+		delay(20);
+
+		prphwrite(ctlr, OscClk, prphread(ctlr, OscClk) | OscClkCtrl);
+
+		prphread(ctlr, OscClk);
+		prphread(ctlr, OscClk);
+
+		nicunlock(ctlr);
+	}
 	if(ctlr->family < 8000){
 		if((err = niclock(ctlr)) != nil)
 			return err;
@@ -3416,6 +3437,12 @@
 		iunlock(ctlr);
 		return "qcmd: broken";
 	}
+	/* wake up the nic (just needed for 7k) */
+	if(ctlr->family == 7000 && q->n == 0)
+		if(niclock(ctlr) != nil){
+			iunlock(ctlr);
+			return "qcmd: busy";
+		}
 	q->n++;
 	q->lastcmd = code;
 
@@ -4242,6 +4269,9 @@
 		if(tx != nil && tx->n > 0){
 			tx->n--;
 			wakeup(tx);
+			/* unlock 7k family nics as all commands are done */
+			if(ctlr->family == 7000 && tx->n == 0)
+				nicunlock(ctlr);
 		}
 	}
 
@@ -4349,6 +4379,11 @@
 		case 0x088e:	/* Centrino Advanced-N 6235 */
 		case 0x088f:	/* Centrino Advanced-N 6235 */
 			family = 0;
+			fwname = nil;
+			break;
+		case 0x08b1:	/* Wireless AC 7260 */
+		case 0x08b2:	/* Wireless AC 7260 */
+			family = 7000;
 			fwname = nil;
 			break;
 		case 0x24f3:	/* Wireless AC 8260 */

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [9front] driver for intel wireless 7260?
  2021-07-26 16:30 Skylar Bleed
@ 2021-07-26 19:29 ` cinap_lenrek
  2021-07-27  7:21   ` Aw: " Eckard Brauer
  0 siblings, 1 reply; 29+ messages in thread
From: cinap_lenrek @ 2021-07-26 19:29 UTC (permalink / raw)
  To: 9front

it falls into the family of /sys/src/9/pc/etheriwl.c
supported cards.

it is just that i havnt had the hardware, so the
driver will ignore it.

add pci id and initialize ctlr->family to 7000.

you'll need iwm-8260-17 and then troubleshoot from there.

the etheriwl driver is based on iwn/iwm obsd drivers 
(becasue there is no other "documentation"),
so check there for differences and switches around the
device family for unhandled cases.

money is not a problem. time and availability of hw is.
you will do yourself and us more good by just doing the
work.

--
cinap

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [9front] driver for intel wireless 7260?
@ 2021-07-26 16:30 Skylar Bleed
  2021-07-26 19:29 ` cinap_lenrek
  0 siblings, 1 reply; 29+ messages in thread
From: Skylar Bleed @ 2021-07-26 16:30 UTC (permalink / raw)
  To: 9front

does this exist yet? is there any plan to make it exist? I wanted to check in again because I really want to try 9front again, but having no internet always forces me to turn back to some BSD system or something. I did try to roll my own a while back but I am not skilled enough to do that yet lol. if people aren't working on it, I could try to put out a bounty for it, but honestly I am pretty low on cash at the moment.

cheers
skye

^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2021-08-14 21:13 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-06  4:43 [9front] driver for intel wireless 7260? qwx
2021-08-06  4:57 ` Skylar Bleed
2021-08-06 10:06 ` cinap_lenrek
2021-08-06 17:56   ` Skylar Bleed
2021-08-06 23:48     ` cinap_lenrek
2021-08-07  2:59       ` Skylar Bleed
2021-08-07 11:16         ` cinap_lenrek
2021-08-07 14:39           ` Skylar Bleed
2021-08-07 22:14             ` kemal
2021-08-08 14:35               ` Skylar Bleed
2021-08-09 12:05               ` kemal
2021-08-10 15:11                 ` Skylar Bleed
2021-08-12 21:03                   ` kemal
2021-08-13 19:49                     ` Skylar Bleed
2021-08-14 13:26                       ` kemal
2021-08-13 23:41                     ` kemal
2021-08-14 17:25                       ` cinap_lenrek
2021-08-14 17:50                       ` kemal
2021-08-07 22:27             ` ori
2021-08-07 10:30     ` kemal
2021-08-06 14:07 ` kemal
  -- strict thread matches above, loose matches on Subject: below --
2021-07-26 16:30 Skylar Bleed
2021-07-26 19:29 ` cinap_lenrek
2021-07-27  7:21   ` Aw: " Eckard Brauer
2021-08-04 20:50     ` kemal
2021-08-05  0:32       ` kemal
2021-08-05  7:52         ` cinap_lenrek
2021-08-05 12:41           ` kemal
2021-08-05 21:19             ` Eckard Brauer
2021-08-05 22:33             ` cinap_lenrek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).