Port-vax archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: qt multi- and broadcast (was Re: dhcpcd not working in simh-vax with xq0:nat networking)



On Mon 13 Dec 2021 at 02:56:25 +0000, Mark Pizzolato - Info Comm wrote:
> Actually, the NetBSD QT driver does NOT handle multi-cast correctly at all, 
> so it should be fixed, which Olaf is working on.

So here is my work so far, which seems to work:

localhost# ifconfig
qt0: flags=0x8043<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
        address: 08:00:2b:af:2c:e8
        inet 192.168.178.58/24 broadcast 192.168.178.255 flags 0x0
        inet6 fe80::a00:2bff:feaf:2ce8%qt0/64 flags 0x0 scopeid 0x1
        inet6 2003:ca:5f06:1100:d26:3bf8:44fa:76e5/64 flags 0x0
        inet6 2003:ca:5f06:1100:a00:2bff:feaf:2ce8/128 flags 0x0
lo0: flags=0x8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33176
        inet 127.0.0.1/8 flags 0x0
        inet6 ::1/128 flags 0x20<NODAD>
        inet6 fe80::1%lo0/64 flags 0x0 scopeid 0x2
localhost#
Simulation stopped, PC: 801A1955 (MTPR R0,#12)
sim> show xq filter
Physical Address=08:00:2B:AF:2C:E8
Multicast Hash: 00 00 80 00 00 10 40 02

There are 4 bits on in the Multicast Hash. That corresponds nicely with
the result we saw earlier when using the qe driver:

sim> show xq filter
Filters:
  [ 0]: 08:00:2B:AF:2C:E8
  [ 1]: FF:FF:FF:FF:FF:FF
  [ 2]: 01:00:5E:00:00:01
  [ 3]: 33:33:FF:31:40:F7
  [ 4]: 33:33:00:00:00:01
  [ 5]: 33:33:FF:D3:A2:D3
  [ 6]: FF:FF:FF:FF:FF:FF
  [ 7]: FF:FF:FF:FF:FF:FF
  [ 8]: FF:FF:FF:FF:FF:FF
  [ 9]: FF:FF:FF:FF:FF:FF
  [10]: FF:FF:FF:FF:FF:FF
  [11]: FF:FF:FF:FF:FF:FF
  [12]: FF:FF:FF:FF:FF:FF
  [13]: FF:FF:FF:FF:FF:FF

The actual change is even quite simple: in a well-chosen place, insert a
call to lance_setladrf(), which I found earlier.

Of course there are some knock-on effects. The function needs to be
declared, so #include <dev/ic/lancevar.h> needs to be added. This header
contains lots of other things we're not using, but it requires struct
ifmedia: #include <net/if_media.h>.

Then it turns out that lance_setladrf(struct ethercom *, uint16_t *)
likes it multicast filter as 4 uint16_ts instead of 8 u_chars. So I
changed that declaration (nothing else uses it anyway). But then it's
weird to leave other fields in the struct as the old-fashioned u_short,
so I changed them to uint16_t too.

Furthermore, the dev/ic/lance.c file needs to be included if the qt
driver is included. In GENERIC it's already there because of various le
drivers. So fortunately it can be included without causing trouble.
I think I've done it the right way, but I'm not so familiar with the
"files" files.

And together that makes the diff below.

Index: conf/files
===================================================================
RCS file: /cvsroot/src/sys/conf/files,v
retrieving revision 1.1290
diff -u -r1.1290 files
--- conf/files	19 Nov 2021 23:46:54 -0000	1.1290
+++ conf/files	13 Dec 2021 13:54:53 -0000
@@ -754,7 +754,7 @@
 define	le32
 file	dev/ic/am7990.c			le24
 file	dev/ic/am79900.c		le32
-file	dev/ic/lance.c			le24 | le32
+file	dev/ic/lance.c			le24 | le32 | qt
 
 # DEC DEPCA-family of LANCE Ethernet controllers
 #
Index: dev/qbus/if_qt.c
===================================================================
RCS file: /cvsroot/src/sys/dev/qbus/if_qt.c,v
retrieving revision 1.25
diff -u -r1.25 if_qt.c
--- dev/qbus/if_qt.c	29 Jan 2020 05:57:21 -0000	1.25
+++ dev/qbus/if_qt.c	13 Dec 2021 13:54:53 -0000
@@ -116,6 +116,10 @@
 #include <dev/qbus/if_uba.h>
 #include <dev/qbus/if_qtreg.h>
 
+/* Share some multicast code from LANCE */
+#include <net/if_media.h>
+#include <dev/ic/lancevar.h>
+
 #define NRCV	QT_MAX_RCV	/* Receive descriptors (must be == 32) */
 #define NXMT	QT_MAX_XMT	/* Transmit descriptors	(must be == 12) */
 #if	NRCV != 32 || NXMT != 12
@@ -388,7 +392,10 @@
 	}
 	iniblk = &sc->sc_ib->qc_init;
 	iniblk->mode = ifp->if_flags & IFF_PROMISC ? INIT_MODE_PRO : 0;
-
+/*
+ * The multicast filter works "like LANCE".
+ */
+	lance_setladrf(&sc->is_ec, iniblk->laddr);
 
 /*
  * Now initialize the receive ring descriptors.  Because this routine can be
Index: dev/qbus/if_qtreg.h
===================================================================
RCS file: /cvsroot/src/sys/dev/qbus/if_qtreg.h,v
retrieving revision 1.5
diff -u -r1.5 if_qtreg.h
--- dev/qbus/if_qtreg.h	11 Dec 2005 12:23:29 -0000	1.5
+++ dev/qbus/if_qtreg.h	13 Dec 2021 13:54:53 -0000
@@ -207,18 +207,18 @@
 
 	struct	qt_init
 		{
-		short	mode;
-		u_char	paddr[6];	/* 48 bit physical address */
-		u_char	laddr[8];	/* 64 bit logical address filter */
-		u_short	rx_lo;		/* low 16 bits of receive ring addr */
-		u_short	rx_hi;		/* high 6 bits of receive ring addr */
-		u_short	tx_lo;		/* low 16 bits of transmit ring addr */
-		u_short	tx_hi;		/* high 6 bits of transmit ring addr */
-		u_short	options;
-		u_short	vector;
-		u_short	hit;
-		char	passwd[6];
-		char	pad[4];		/* even on 40 byte for alignment */
+		int16_t		mode;
+		u_char		paddr[6];	/* 48 bit physical address */
+		uint16_t	laddr[4];	/* 64 bit logical address filter */
+		uint16_t	rx_lo;		/* low 16 bits of receive ring addr */
+		uint16_t	rx_hi;		/* high 6 bits of receive ring addr */
+		uint16_t	tx_lo;		/* low 16 bits of transmit ring addr */
+		uint16_t	tx_hi;		/* high 6 bits of transmit ring addr */
+		uint16_t	options;
+		uint16_t	vector;
+		uint16_t	hit;
+		char		passwd[6];
+		char		pad[4];		/* even on 40 byte for alignment */
 		};
 
 #define	INIT_MODE_PRO	0x8000		/* Promiscuous mode */

-Olaf.
-- 
___ "Buying carbon credits is a bit like a serial killer paying someone else to
\X/  have kids to make his activity cost neutral." -The BOFH    falu.nl@rhialto

Attachment: signature.asc
Description: PGP signature



Home | Main Index | Thread Index | Old Index