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: Thu, 12 Aug 2021 21:03:00 +0000	[thread overview]
Message-ID: <CABO6shc22Cs0vAES_EJxp8PoQDfesbrPLFSsbKyYfpFE3cfV0w@mail.gmail.com> (raw)
In-Reply-To: <uFaDxdqVcqIhD8Dd4QtlnRS8PRJBqP8-vSoWaSKbFn5KOAnBrhn-TnEMCNM3nnoHcJ7lxYIAxbarM-TiZFfGinSdLYaMqWl-7xzE_KNoRJM=@protonmail.ch>

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

  reply	other threads:[~2021-08-13  1:27 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
2021-08-10 15:11                 ` Skylar Bleed
2021-08-12 21:03                   ` kemal [this message]
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=CABO6shc22Cs0vAES_EJxp8PoQDfesbrPLFSsbKyYfpFE3cfV0w@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).