Subject: sn driver with Apple Ethernet NB TP card
To: None <port-mac68k@NetBSD.ORG, scottr@og.org, briggs@puma.macbsd.com>
From: Ken Nakata <kenn@romulus.rutgers.edu>
List: port-mac68k
Date: 12/24/1997 14:33:56
----Next_Part(Wed_Dec_24_14:33:48_1997)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hi,
I'm trying to get sn driver to work on an Apple Ethernet NB TP card.
I've attached to this message my diffs to the driver.
The strangest thing is, it seems to be able to receive something, as
it shows:
# arp -an
? (165.230.193.72) at 08:00:20:0a:ad:36
? (165.230.193.109) at 00:a0:40:21:3f:15 permanent
#
Here, the second entry is the machine itself (IIci), and the first one
is the first nameserver in the /etc/resolv.conf. I have succeeded to
get another arp entry at one time.
However, I can't seem to send or receive anything other than that.
ping to a Sparc IPX sitting right next to the IIci fails like this:
# ping 165.230.193.105
PING 165.230.193.105 (165.230.193.105): 56 data bytes
ping: sendto: Host is down
ping: sendto: Host is down
ping: sendto: Host is down
ping: sendto: Host is down
^C
----165.230.193.105 PING Statistics----
12 packets transmitted, 0 packets received, 100% packet loss
#
This is on a subnet with net/broadcast address at 165.230.193.64 and
net mask ffffffc0.
netstat -rn says:
Routing tables
Protocol Family 4:
Destination Gateway Flags Refs Use Mtu Interface
127.0.0.1 127.0.0.1 UH 0 0 - lo0
165.230.193.64/26 link#1 UC 0 0 - sn0
165.230.193.72 08:00:20:0a:ad:36 UHL 0 378 - sn0
165.230.193.109 00:a0:40:21:3f:15 UHL 0 96 - lo0
Protocol Family 18:
Destination Gateway Flags Refs Use Mtu Interface
Does anyone have any idea? Thanks in advance,
Ken
----Next_Part(Wed_Dec_24_14:33:48_1997)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
*** ../src/sys/arch/mac68k/dev/if_sn.c Sun Dec 21 16:14:14 1997
--- if_sn.c Wed Dec 24 07:35:50 1997
***************
*** 131,137 ****
* for its descriptor areas, or expect the MD attach code
* to do that?
*/
! sc->space = malloc((SN_NPAGES + 1) * NBPG, M_DEVBUF, M_WAITOK);
if (sc->space == NULL) {
printf ("%s: memory allocation for descriptors failed\n",
sc->sc_dev.dv_xname);
--- 131,138 ----
* for its descriptor areas, or expect the MD attach code
* to do that?
*/
! if (sc->space == NULL)
! sc->space = malloc((SN_NPAGES + 1) * NBPG, M_DEVBUF, M_WAITOK);
if (sc->space == NULL) {
printf ("%s: memory allocation for descriptors failed\n",
sc->sc_dev.dv_xname);
***************
*** 213,218 ****
--- 214,223 ----
sc->sc_nrda = NBPG / RXPKT_SIZE(sc);
sc->p_rda = (caddr_t) p;
sc->v_rda = SONIC_GETDMA(p);
+ #if SN_DEBUG
+ printf("%s: p_rda = %08x, v_rda = %08x\n", sc->sc_dev.dv_xname, (unsigned)sc->p_rda,
+ (unsigned)sc->v_rda);
+ #endif
p = pp + NBPG;
***************
*** 1205,1215 ****
#define bbr(v) ((bbr4[(v)&0xf] << 4) | bbr4[((v)>>4) & 0xf])
void
! sn_get_enaddr(t, h, o, dst)
bus_space_tag_t t;
bus_space_handle_t h;
vm_offset_t o;
u_char *dst;
{
int i, do_bbr;
u_char b;
--- 1210,1221 ----
#define bbr(v) ((bbr4[(v)&0xf] << 4) | bbr4[((v)>>4) & 0xf])
void
! sn_get_enaddr(t, h, o, dst, incr)
bus_space_tag_t t;
bus_space_handle_t h;
vm_offset_t o;
u_char *dst;
+ int incr;
{
int i, do_bbr;
u_char b;
***************
*** 1251,1257 ****
dst[0] = (do_bbr) ? bbr(b) : b;
for (i = 1 ; i < ETHER_ADDR_LEN ; i++) {
! b = bus_space_read_1(t, h, o+i);
dst[i] = (do_bbr) ? bbr(b) : b;
}
}
--- 1257,1263 ----
dst[0] = (do_bbr) ? bbr(b) : b;
for (i = 1 ; i < ETHER_ADDR_LEN ; i++) {
! b = bus_space_read_1(t, h, o+(i*incr));
dst[i] = (do_bbr) ? bbr(b) : b;
}
}
*** ../src/sys/arch/mac68k/dev/if_sn_nubus.c Sun Dec 21 16:14:33 1997
--- if_sn_nubus.c Tue Dec 23 10:35:54 1997
***************
*** 41,46 ****
--- 41,47 ----
#include <net/if.h>
#include <net/if_ether.h>
+
#if 0 /* XXX this shouldn't be necessary; else reinsert */
#ifdef INET
#include <netinet/in.h>
***************
*** 55,60 ****
--- 56,63 ----
#include <mac68k/dev/if_snreg.h>
#include <mac68k/dev/if_snvar.h>
+ #include <machine/pte.h>
+
static int sn_nubus_match __P((struct device *, struct cfdata *, void *));
static void sn_nubus_attach __P((struct device *, struct device *, void *));
static int sn_nb_card_vendor __P((bus_space_tag_t, bus_space_handle_t,
***************
*** 88,95 ****
break;
case SN_VENDOR_APPLE:
- case SN_VENDOR_APPLE16:
case SN_VENDOR_DAYNA:
rv = 1;
break;
}
--- 91,99 ----
break;
case SN_VENDOR_APPLE:
case SN_VENDOR_DAYNA:
+ case SN_VENDOR_APPLE16:
+ case SN_VENDOR_APPLE16NB:
rv = 1;
break;
}
***************
*** 110,116 ****
{
struct sn_softc *sc = (void *)self;
struct nubus_attach_args *na = (struct nubus_attach_args *)aux;
! int i, success, offset;
bus_space_tag_t bst;
bus_space_handle_t bsh, tmp_bsh;
u_int8_t myaddr[ETHER_ADDR_LEN];
--- 114,120 ----
{
struct sn_softc *sc = (void *)self;
struct nubus_attach_args *na = (struct nubus_attach_args *)aux;
! int i, success, offset, distance;
bus_space_tag_t bst;
bus_space_handle_t bsh, tmp_bsh;
u_int8_t myaddr[ETHER_ADDR_LEN];
***************
*** 129,134 ****
--- 133,141 ----
sc->slotno = na->slot;
+ distance = 4;
+ sc->space = NULL;
+
switch (sn_nb_card_vendor(bst, bsh, na)) {
case SN_VENDOR_DAYNA:
sc->snr_dcr = DCR_ASYNC | DCR_WAIT0 |
***************
*** 148,154 ****
break;
}
! sn_get_enaddr(bst, tmp_bsh, 0, myaddr);
offset = 2;
success = 1;
--- 155,161 ----
break;
}
! sn_get_enaddr(bst, tmp_bsh, 0, myaddr, 1);
offset = 2;
success = 1;
***************
*** 172,178 ****
break;
}
! sn_get_enaddr(bst, tmp_bsh, 0, myaddr);
offset = 0;
success = 1;
--- 179,185 ----
break;
}
! sn_get_enaddr(bst, tmp_bsh, 0, myaddr, 1);
offset = 0;
success = 1;
***************
*** 196,204 ****
break;
}
! sn_get_enaddr(bst, tmp_bsh, 0, myaddr);
offset = 0;
success = 1;
break;
--- 203,256 ----
break;
}
! sn_get_enaddr(bst, tmp_bsh, 0, myaddr, 1);
!
! offset = 0;
! success = 1;
! break;
!
! case SN_VENDOR_APPLE16NB:
! sc->snr_dcr = DCR_ASYNC | DCR_WAIT0 |
! DCR_DMABLOCK | DCR_PO1 | DCR_RFT16 | DCR_TFT24;
! sc->snr_dcr2 = 0;
! sc->bitmode = 0; /* 16 bit card */
!
! if (bus_space_subregion(bst, bsh,
! 0xc0000, SN_REGSIZE, &sc->sc_regh)) {
! printf(": failed to map register space.\n");
! break;
! }
!
! if (bus_space_subregion(bst, bsh,
! 0x400001, ETHER_ADDR_LEN * 2, &tmp_bsh)) {
! printf(": failed to map ROM space.\n");
! break;
! }
!
! sn_get_enaddr(bst, tmp_bsh, 0, myaddr, 2);
+ #define ENNBTP 1
+ #if ENNBTP==0
+ physaccess((caddr_t)NUBUS_SLOT2PA(na->slot),
+ (caddr_t)NUBUS_SLOT2PA(na->slot),
+ (SN_NPAGES + 1) * NBPG, PG_V|PG_RW|PG_CI);
+ sc->space = (void*)NUBUS_SLOT2PA(na->slot);
+ #elif ENNBTP==1
+ if (bus_space_subregion(bst, bsh,
+ 0, (SN_NPAGES + 1) * NBPG, &tmp_bsh)) {
+ printf(": failed to map buffer RAM space.\n");
+ break;
+ }
+ /* XXX: isn't there a better way to convert a bus handle to a pointer? */
+ sc->space = (void *)tmp_bsh;
+ #else
+ sc->space = (void*)NUBUS_SLOT2PA(na->slot);
+ #endif
+ #if SN_DEBUG
+ printf(": mapping adapter memory at %08x\n", (unsigned)sc->space);
+ #endif
offset = 0;
+ distance = 2;
success = 1;
break;
***************
*** 223,229 ****
/* Regs are addressed as words, big endian. */
for (i = 0; i < SN_NREGS; i++) {
! sc->sc_reg_map[i] = (bus_size_t)((i * 4) + offset);
}
/* snsetup returns 1 if something fails */
--- 275,281 ----
/* Regs are addressed as words, big endian. */
for (i = 0; i < SN_NREGS; i++) {
! sc->sc_reg_map[i] = (bus_size_t)((i * distance) + offset);
}
/* snsetup returns 1 if something fails */
***************
*** 248,254 ****
switch (na->drsw) {
case NUBUS_DRSW_3COM:
if (na->drhw == NUBUS_DRHW_APPLE_SNT)
! vendor = SN_VENDOR_APPLE;
else if (na->drhw == NUBUS_DRHW_APPLE_SN)
vendor = SN_VENDOR_APPLE16;
break;
--- 300,306 ----
switch (na->drsw) {
case NUBUS_DRSW_3COM:
if (na->drhw == NUBUS_DRHW_APPLE_SNT)
! vendor = SN_VENDOR_APPLE16NB;
else if (na->drhw == NUBUS_DRHW_APPLE_SN)
vendor = SN_VENDOR_APPLE16;
break;
*** ../src/sys/arch/mac68k/dev/if_sn_obio.c Sun Dec 21 16:14:34 1997
--- if_sn_obio.c Fri Dec 19 08:36:23 1997
***************
*** 203,209 ****
return (-1);
}
! sn_get_enaddr(sc->sc_regt, bsh, 0, lladdr);
bus_space_unmap(sc->sc_regt, bsh, NBPG);
--- 203,209 ----
return (-1);
}
! sn_get_enaddr(sc->sc_regt, bsh, 0, lladdr, 1);
bus_space_unmap(sc->sc_regt, bsh, NBPG);
*** ../src/sys/arch/mac68k/dev/if_snvar.h Sun Dec 21 16:14:35 1997
--- if_snvar.h Fri Dec 19 08:36:45 1997
***************
*** 16,22 ****
#define SN_VENDOR_UNKNOWN 0xff /* Unknown */
#define SN_VENDOR_APPLE 0x00 /* Apple Computer/compatible */
#define SN_VENDOR_DAYNA 0x01 /* Dayna/Kinetics EtherPort */
! #define SN_VENDOR_APPLE16 0x02 /* Apple Twisted Pair NB */
/*
* Memory access macros. Since we handle SONIC in 16 bit mode (PB5X0)
--- 16,23 ----
#define SN_VENDOR_UNKNOWN 0xff /* Unknown */
#define SN_VENDOR_APPLE 0x00 /* Apple Computer/compatible */
#define SN_VENDOR_DAYNA 0x01 /* Dayna/Kinetics EtherPort */
! #define SN_VENDOR_APPLE16 0x02 /* Apple Twisted Pair LC */
! #define SN_VENDOR_APPLE16NB 0x03 /* Apple Twisted Pair NB */
/*
* Memory access macros. Since we handle SONIC in 16 bit mode (PB5X0)
***************
*** 215,218 ****
int snsetup __P((struct sn_softc *sc, u_int8_t *));
void snintr __P((void *, int));
void sn_get_enaddr __P((bus_space_tag_t t, bus_space_handle_t h,
! vm_offset_t o, u_char *dst));
--- 216,219 ----
int snsetup __P((struct sn_softc *sc, u_int8_t *));
void snintr __P((void *, int));
void sn_get_enaddr __P((bus_space_tag_t t, bus_space_handle_t h,
! vm_offset_t o, u_char *dst, int incr));
----Next_Part(Wed_Dec_24_14:33:48_1997)----