9front - general discussion about 9front
 help / color / mirror / Atom feed
From: kemal <kemalinanc8@gmail.com>
To: 9front@9front.org
Subject: Re: [9front] driver for intel wireless 7260?
Date: Mon, 9 Aug 2021 12:05:39 +0000	[thread overview]
Message-ID: <CABO6shc3XK-MfWH3FoPJd0ZWEkxTMXO50+4V72Cr8jcpLfmf7w@mail.gmail.com> (raw)
In-Reply-To: <CABO6shfLWRxvNWU59MeeNp5Y5CAFp_YAX2dbkCTpm173FiRvtg@mail.gmail.com>

[-- 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);
 		}
 	}

  parent reply	other threads:[~2021-08-10  9:10 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-06  4:43 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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CABO6shc3XK-MfWH3FoPJd0ZWEkxTMXO50+4V72Cr8jcpLfmf7w@mail.gmail.com \
    --to=kemalinanc8@gmail.com \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).