Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Jan 2000 02:54:40 +0900
From:      Tatsumi Hosokawa <hosokawa@itc.keio.ac.jp>
To:        imp@village.org
Cc:        mobile@FreeBSD.ORG
Subject:   if_sn now works on -current (Re: One more serious problem with -current PCCARD support )
Message-ID:  <863drs1vdr.wl@ringo.FromTo.Cc>
In-Reply-To: In your message of "Fri, 21 Jan 2000 00:56:51 %2B0900" <864sc820u4.wl@ringo.FromTo.Cc>
References:  <86r9fisfe2.wl@ringo.FromTo.Cc> <86u2kesizg.wl@ringo.FromTo.Cc> <200001180742.AAA15379@harmony.village.org> <864sc820u4.wl@ringo.FromTo.Cc>

next in thread | previous in thread | raw e-mail | index | archive | help
Megahertz X-Jack Ethernet now works on current.  This patch requires
the MAC address patch in <864sc820u4.wl@ringo.FromTo.Cc> with
following pccard.conf entry

card "Megahertz" "CC10BT/2"
        config  0x1 "sn0" ?
        ether attr2
        insert  logger -s Megahertz X-Jack Ethernet inserted
        insert  /etc/pccard_ether $device
        remove  logger -s Megahertz X-Jack Ethernet removed
        remove  /etc/pccard_ether_remove $device

This patch adds "attr2" keyword to /etc/pccard.conf and I'm afraid
that it can break feature freeze.  If it's not acceptable, I'll commit
it later.

Comments?

Index: sys/dev/sn/if_sn_pccard.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/sn/if_sn_pccard.c,v
retrieving revision 1.1
diff -u -r1.1 if_sn_pccard.c
--- sys/dev/sn/if_sn_pccard.c	1999/12/22 08:44:13	1.1
+++ sys/dev/sn/if_sn_pccard.c	2000/01/20 17:47:00
@@ -44,6 +44,7 @@
 #include <machine/resource.h>
 #include <sys/rman.h>
  
+#include <net/ethernet.h> 
 #include <net/if.h> 
 #include <net/if_arp.h>
 #include <net/if_media.h>
@@ -52,6 +53,7 @@
 
 #include <dev/sn/if_snreg.h>
 #include <dev/sn/if_snvar.h>
+#include <dev/pccard/pccardvar.h>
 
 /*
  * Initialize the device - called from Slot manager.
@@ -65,6 +67,17 @@
 static int
 sn_pccard_attach(device_t dev)
 {
+	struct sn_softc *sc = device_get_softc(dev);
+	int i;
+	u_char sum;
+	u_char ether_addr[ETHER_ADDR_LEN];
+
+	pccard_get_ether(dev, ether_addr);
+	for (i = 0, sum = 0; i < ETHER_ADDR_LEN; i++)
+		sum |= ether_addr[i];
+	if (sum)
+		bcopy(ether_addr, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
+
 	return (sn_attach(dev));
 }
 
Index: usr.sbin/pccard/pccardd/cardd.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pccard/pccardd/cardd.c,v
retrieving revision 1.43
diff -u -r1.43 cardd.c
--- usr.sbin/pccard/pccardd/cardd.c	2000/01/16 06:44:48	1.43
+++ usr.sbin/pccard/pccardd/cardd.c	2000/01/20 17:47:02
@@ -35,6 +35,7 @@
 #include <unistd.h>
 #include <errno.h>
 #include <fcntl.h>
+#include <ctype.h>
 #include <sys/ioctl.h>
 #include "cardd.h"
 
@@ -45,6 +46,7 @@
 static void		 card_removed(struct slot *);
 static void		 pr_cmd(struct cmd *);
 static void		 read_ether(struct slot *);
+static void		 read_ether_attr2(struct slot *sp);
 
 /*
  *	Dump configuration file data.
@@ -228,8 +230,18 @@
 			sp->cis->manuf, sp->cis->vers);
 		return;
 	}
-	if (cp->ether)
-		read_ether(sp);
+	if (cp->ether) {
+		struct ether *e = 0;
+		e = cp->ether;
+		switch (e->type) {
+		case ETHTYPE_ATTR2:
+			read_ether_attr2(sp);
+			break;
+		default:
+			read_ether(sp);
+			break;
+		}
+	}
 	if ((sp->config = assign_driver(cp)) == NULL) 
 		return;
 	if (assign_io(sp)) {
@@ -259,7 +271,7 @@
 {
 	unsigned char net_addr[12];
 
-	lseek(sp->fd, (off_t)sp->card->ether, SEEK_SET);
+	lseek(sp->fd, (off_t)sp->card->ether->value, SEEK_SET);
 	if (read(sp->fd, net_addr, sizeof(net_addr)) != sizeof(net_addr)) {
 		logerr("read err on net addr");
 		return;
@@ -274,6 +286,44 @@
 	    sp->eaddr[0], sp->eaddr[1], sp->eaddr[2],
 	    sp->eaddr[3], sp->eaddr[4], sp->eaddr[5]);
 }
+
+/*
+ *      Megahertz X-Jack Ethernet uses unique way to get/set MAC
+ *      address of the card.
+ */
+static void
+read_ether_attr2(struct slot *sp)
+{
+	int	i;
+	char	*hexaddr;
+
+	hexaddr = sp->cis->add_info2;
+	for (i = 0; i < 6; i++)
+		sp->eaddr[i] = 0;
+	if (!hexaddr)
+		return;
+	if (strlen(hexaddr) != 12)
+		return;
+	for (i = 0; i < 12; i++)
+		if (!isxdigit(hexaddr[i]))
+			return;
+	for (i = 0; i < 6; i++) {
+		u_int	d;
+		char	s[3];
+		s[0] = hexaddr[i * 2];
+		s[1] = hexaddr[i * 2 + 1];
+		s[2] = '\0';
+		if (!sscanf(s, "%x", &d)) {
+			int	j;
+			for (j = 0; j < 6; j++)
+				sp->eaddr[j] = 0;
+			return;
+		}
+		sp->eaddr[i] = (u_char)d;
+	}
+	sp->flags |= EADDR_CONFIGED;
+}
+
 
 /*
  *	assign_driver - Assign driver to card.
Index: usr.sbin/pccard/pccardd/cardd.h
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pccard/pccardd/cardd.h,v
retrieving revision 1.16
diff -u -r1.16 cardd.h
--- usr.sbin/pccard/pccardd/cardd.h	1999/08/28 01:17:36	1.16
+++ usr.sbin/pccard/pccardd/cardd.h	2000/01/20 17:47:03
@@ -53,11 +53,20 @@
 	char    inuse;
 };
 
+struct ether {
+	struct ether *next;
+	int	type;
+	int	value;
+};
+
+#define	ETHTYPE_GENERIC		0
+#define	ETHTYPE_ATTR2		1
+
 struct card {
 	struct card *next;
 	char   *manuf;
 	char   *version;
-	int     ether;			/* For net cards, ether at offset */
+	struct ether *ether;		/* For net cards, ether at offset */
 	int     reset_time;		/* Reset time */
 	int	iosize;			/* I/O window size (ignore location) */
 	struct card_config *config;	/* List of configs */
Index: usr.sbin/pccard/pccardd/file.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pccard/pccardd/file.c,v
retrieving revision 1.22
diff -u -r1.22 file.c
--- usr.sbin/pccard/pccardd/file.c	1999/08/28 01:17:36	1.22
+++ usr.sbin/pccard/pccardd/file.c	2000/01/20 17:47:04
@@ -213,10 +213,11 @@
 static void
 parse_card(void)
 {
-	char   *man, *vers;
+	char   *man, *vers, *tmp;
 	struct card *cp;
 	int     i, iosize;
 	struct card_config *confp, *lastp;
+	struct ether *ether;
 
 	confp = 0;
 	man = newstr(next_tok());
@@ -277,11 +278,22 @@
 			break;
 		case KWD_ETHER:
 			/* ether */
-			cp->ether = num_tok();
-			if (cp->ether == -1) {
-				error("illegal ether address offset");
-				cp->ether = 0;
+			ether = xmalloc(sizeof(*ether));
+			ether->type = ETHTYPE_GENERIC;
+			tmp = next_tok();
+			if (strcmp("attr2", tmp) == 0)
+				ether->type = ETHTYPE_ATTR2;
+			else {
+				pusht = 1;
+				ether->value = num_tok();
+				if (ether->value == -1) {
+					error("illegal ether address offset");
+					free(ether);
+					break;
+				}
 			}
+			ether->next = cp->ether;
+			cp->ether = ether;
 			break;
 		case KWD_INSERT:
 			/* insert */


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-mobile" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?863drs1vdr.wl>