summaryrefslogtreecommitdiff
path: root/sys/arch/mac68k/dev/if_snvar.h
diff options
context:
space:
mode:
authorbriggs <briggs@cvs.openbsd.org>1997-03-14 14:11:37 +0000
committerbriggs <briggs@cvs.openbsd.org>1997-03-14 14:11:37 +0000
commit6abc623185f505a4980059abbc75083c38a1099b (patch)
tree1ad85fbefacf36fe5a6645abb4713a475348b8ce /sys/arch/mac68k/dev/if_snvar.h
parentc6d2f9b120f174d89d9ef92b8883aa181b984fef (diff)
Updates from Yanagisawa and Denny. This seems to work.
Diffstat (limited to 'sys/arch/mac68k/dev/if_snvar.h')
-rw-r--r--sys/arch/mac68k/dev/if_snvar.h227
1 files changed, 104 insertions, 123 deletions
diff --git a/sys/arch/mac68k/dev/if_snvar.h b/sys/arch/mac68k/dev/if_snvar.h
index 4fffbb71bbb..e89d0f50966 100644
--- a/sys/arch/mac68k/dev/if_snvar.h
+++ b/sys/arch/mac68k/dev/if_snvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_snvar.h,v 1.1 1997/03/12 13:20:33 briggs Exp $ */
+/* $OpenBSD: if_snvar.h,v 1.2 1997/03/14 14:11:36 briggs Exp $ */
/*
* Copyright (c) 1991 Algorithmics Ltd (http://www.algor.co.uk)
@@ -11,6 +11,17 @@
*/
/*
+ * Memory access macros. Since we handle SONIC in 16 bit mode (PB5X0)
+ * and 32 bit mode (everything else) using a single GENERIC kernel
+ * binary, all structures have to be accessed using macros which can
+ * adjust the offsets appropriately.
+ */
+#define SWO(m, a, o, x) (m ? (*(u_int32_t *)((u_int32_t *)a + o) = (x)) : \
+ (*(u_int16_t *)((u_int16_t *)a + o) = (x)))
+#define SRO(m, a, o) (m ? (*(u_int32_t *)((u_int32_t *)a + o) & 0xffff) : \
+ (*(u_int16_t *)((u_int16_t *)a + o) & 0xffff))
+
+/*
* buffer sizes in 32 bit mode
* 1 TXpkt is 4 hdr words + (3 * FRAGMAX) + 1 link word
* FRAGMAX == 16 => 54 words == 216 bytes
@@ -19,18 +30,12 @@
* 1 Rda is 4 words == 16 bytes
*/
-#define NRRA 32 /* # receive resource descriptors */
-#define RRAMASK 0x1f /* the reason why it must be power of two */
-
#define NRBA 16 /* # receive buffers < NRRA */
#define RBAMASK 0x0f
-#define NRDA NRBA /* # receive descriptors */
+#define NRDA NRBA
#define NTDA 4 /* # transmit descriptors */
-
-#define CDASIZE sizeof(struct CDA)
-#define RRASIZE (NRRA*sizeof(struct RXrsrc))
-#define RDASIZE (NRDA*sizeof(struct RXpkt))
-#define TDASIZE (NTDA*sizeof(struct TXpkt))
+#define NRRA 32 /* # receive resource descriptors */
+#define RRAMASK 0x1f /* the reason why it must be power of two */
#define FCSSIZE 4 /* size of FCS appended to packets */
@@ -38,9 +43,8 @@
* maximum receive packet size plus 2 byte pad to make each
* one aligned. 4 byte slop (required for eobc)
*/
-#define RBASIZE(sc) \
- (sizeof(struct ether_header) + ETHERMTU + FCSSIZE + \
- ((sc)->sc_is16 ? 2 : 6))
+#define RBASIZE(sc) (sizeof(struct ether_header) + ETHERMTU + FCSSIZE + \
+ ((sc)->bitmode ? 6 : 2))
/*
* transmit buffer area
@@ -77,60 +81,70 @@ struct sn_stats {
int ls_maxslots; /* max ring slots on transmit */
};
+typedef struct mtd {
+ void *mtd_txp;
+ int mtd_vtxp;
+ unsigned char *mtd_buf;
+} mtd_t;
+
/*
* The sn_softc for Mac68k if_sn.
*/
typedef struct sn_softc {
- struct device sc_dev;
- struct arpcom sc_arpcom;
-#define sc_if sc_arpcom.ac_if /* network visible interface */
-#define sc_enaddr sc_arpcom.ac_enaddr /* hardware ethernet address */
+ struct device sc_dev;
+ struct arpcom sc_arpcom;
+#define sc_if sc_arpcom.ac_if /* network visible interface */
+#define sc_enaddr sc_arpcom.ac_enaddr /* hardware ethernet address */
bus_space_tag_t sc_regt;
bus_space_handle_t sc_regh;
- int sc_is16;
-
- unsigned int s_dcr; /* DCR for this instance */
- int slotno;
+ struct sn_stats sc_sum;
+ short sc_iflags;
+ unsigned short bitmode; /* 32 bit mode == 1, 16 == 0 */
- struct sonic_reg *sc_csr; /* hardware pointer */
+ unsigned int s_dcr; /* DCR for this instance */
+ int slotno; /* Slot number */
+ struct sonic_reg *sc_csr; /* hardware pointer */
+ int sc_rxmark; /* pos. in rx ring for reading buffs */
- int sc_rxmark; /* pos. in rx ring for reading bufs */
+ int sc_rramark; /* index into p_rra of wp */
+ void *p_rra[NRRA]; /* RX resource descs */
+ int v_rra[NRRA]; /* DMA addresses of p_rra */
+ int v_rea; /* ptr to the end of the rra space */
- int sc_rramark; /* index into rra of wp */
+ int sc_rdamark;
+ void *p_rda[NRDA];
+ int v_rda[NRDA];
- int sc_txhead; /* index of first TDA passed to chip */
- int sc_missed; /* missed packet counter */
+ caddr_t rbuf[NRBA];
- int txb_cnt; /* total number of xmit buffers */
- int txb_inuse; /* number of active xmit buffers */
- int txb_new; /* index of next open slot. */
+ int sc_txhead; /*XXX idx of first TDA passed to chip */
+ int sc_missed; /* missed packet counter */
- void *sc_lrxp; /* last RDA available to chip */
+ int txb_cnt; /* total number of xmit buffers */
+ int txb_inuse; /* number of active xmit buffers */
+ int txb_new; /* index of next open slot. */
- struct sn_stats sc_sum;
- short sc_iflags;
+ struct mtd mtda[NTDA];
+ int mtd_hw; /* idx of first mtd given to hw */
+ int mtd_prev; /* idx of last mtd given to hardware */
+ int mtd_free; /* next free mtd to use */
+ int mtd_tlinko; /*
+ * offset of tlink of last txp given
+ * to SONIC. Need to clear EOL on
+ * this word to add a desc.
+ */
- void *p_rra; /* struct RXrsrc: receiver resource descriptors */
- int v_rra; /* DMA address of rra */
- void *p_rda; /* struct RXpkt: receiver desriptors */
- int v_rda;
- void *p_tda; /* struct TXpkt: transmitter descriptors */
- int v_tda;
- void *p_cda; /* struct CDA: CAM descriptors */
- int v_cda; /* DMA address of CDA */
+ caddr_t tbuf[NTXB];
+ int vtbuf[NTXB]; /* DMA address of tbuf */
- void (*rxint) __P((struct sn_softc *));
- void (*txint) __P((struct sn_softc *));
+ void *p_cda;
+ int v_cda;
- caddr_t rbuf[NRBA];
- caddr_t tbuf[NTXB];
- int vtbuf[NTXB];
- unsigned char space[(1 + 1 + 8 + 5) * NBPG];
+ unsigned char space[(1 + 1 + 8 + 5) * NBPG];
} sn_softc_t;
-
/*
* Accessing SONIC data structures and registers as 32 bit values
* makes code endianess independent. The SONIC is however always in
@@ -144,41 +158,26 @@ typedef struct sn_softc {
* will be received. Note that more than one packet may be
* packed into a single buffer if constraints permit.
*/
-struct RXrsrc {
- u_long buff_ptrlo; /* buffer address LO */
- u_long buff_ptrhi; /* buffer address HI */
- u_long buff_wclo; /* buffer size (16bit words) LO */
- u_long buff_wchi; /* buffer size (16bit words) HI */
-};
-struct _short_RXrsrc {
- u_short buff_ptrlo; /* buffer address LO */
- u_short buff_ptrhi; /* buffer address HI */
- u_short buff_wclo; /* buffer size (16bit words) LO */
- u_short buff_wchi; /* buffer size (16bit words) HI */
-};
+#define RXRSRC_PTRLO 0 /* buffer address LO */
+#define RXRSRC_PTRHI 1 /* buffer address HI */
+#define RXRSRC_WCLO 2 /* buffer size (16bit words) LO */
+#define RXRSRC_WCHI 3 /* buffer size (16bit words) HI */
+
+#define RXRSRC_SIZE(sc) (sc->bitmode ? (4 * 4) : (4 * 2))
/*
* Receive Descriptor
* This structure holds information about packets received.
*/
-struct RXpkt {
- u_long status; /* + receive status */
- u_long byte_count; /* + packet byte count (including FCS) */
- u_long pkt_ptrlo; /* + packet data LO (in RBA) */
- u_long pkt_ptrhi; /* + packet data HI (in RBA) */
- u_long seq_no; /* + RBA sequence numbers */
- u_long rlink; /* link to next receive descriptor */
- u_long in_use; /* + packet available to SONIC */
-};
-struct _short_RXpkt {
- u_short status; /* + receive status */
- u_short byte_count; /* + packet byte count (including FCS) */
- u_short pkt_ptrlo; /* + packet data LO (in RBA) */
- u_short pkt_ptrhi; /* + packet data HI (in RBA) */
- u_short seq_no; /* + RBA sequence numbers */
- u_short rlink; /* link to next receive descriptor */
- u_short in_use; /* + packet available to SONIC */
-};
+#define RXPKT_STATUS 0
+#define RXPKT_BYTEC 1
+#define RXPKT_PTRLO 2
+#define RXPKT_PTRHI 3
+#define RXPKT_SEQNO 4
+#define RXPKT_RLINK 5
+#define RXPKT_INUSE 6
+#define RXPKT_SIZE(sc) (sc->bitmode ? (7 * 4) : (7 * 2))
+
#define RBASEQ(x) (((x)>>8)&0xff)
#define PSNSEQ(x) ((x) & 0xff)
@@ -186,54 +185,36 @@ struct _short_RXpkt {
* Transmit Descriptor
* This structure holds information about packets to be transmitted.
*/
-#define FRAGMAX 16 /* maximum number of fragments in a packet */
-struct TXpkt {
- u_long status; /* + transmitted packet status */
- u_long config; /* transmission configuration */
- u_long pkt_size; /* entire packet size in bytes */
- u_long frag_count; /* # fragments in packet */
- struct {
- u_long frag_ptrlo; /* pointer to packet fragment LO */
- u_long frag_ptrhi; /* pointer to packet fragment HI */
- u_long frag_size; /* fragment size */
- } u[FRAGMAX];
- u_long :32; /* This makes tcp->u[FRAGMAX].u_link.link valid! */
-};
-struct _short_TXpkt {
- u_short status; /* + transmitted packet status */
- u_short config; /* transmission configuration */
- u_short pkt_size; /* entire packet size in bytes */
- u_short frag_count; /* # fragments in packet */
- struct {
- u_short frag_ptrlo; /* pointer to packet fragment LO */
- u_short frag_ptrhi; /* pointer to packet fragment HI */
- u_short frag_size; /* fragment size */
- } u[FRAGMAX];
- u_short :16; /* This makes tcp->u[FRAGMAX].u_link.link valid! */
-};
+#define FRAGMAX 16 /* maximum number of fragments in a packet */
-#define tlink frag_ptrlo
+#define TXP_STATUS 0 /* + transmitted packet status */
+#define TXP_CONFIG 1 /* transmission configuration */
+#define TXP_PKTSIZE 2 /* entire packet size in bytes */
+#define TXP_FRAGCNT 3 /* # fragments in packet */
-#define EOL 0x0001 /* end of list marker for link fields */
+#define TXP_FRAGOFF 4 /* offset to first fragment */
+#define TXP_FRAGSIZE 3 /* size of each fragment desc */
+#define TXP_FPTRLO 0 /* ptr to packet fragment LO */
+#define TXP_FPTRHI 1 /* ptr to packet fragment HI */
+#define TXP_FSIZE 2 /* fragment size */
-#define MAXCAM 16 /* number of user entries in CAM */
-struct CDA {
- struct {
- u_long cam_ep; /* CAM Entry Pointer */
- u_long cam_ap0; /* CAM Address Port 0 xx-xx-xx-xx-YY-YY */
- u_long cam_ap1; /* CAM Address Port 1 xx-xx-YY-YY-xxxx */
- u_long cam_ap2; /* CAM Address Port 2 YY-YY-xx-xx-xx-xx */
- } desc[MAXCAM];
- u_long enable; /* mask enabling CAM entries */
-};
-struct _short_CDA {
- struct {
- u_short cam_ep; /* CAM Entry Pointer */
- u_short cam_ap0; /* CAM Address Port 0 xx-xx-xx-xx-YY-YY */
- u_short cam_ap1; /* CAM Address Port 1 xx-xx-YY-YY-xxxx */
- u_short cam_ap2; /* CAM Address Port 2 YY-YY-xx-xx-xx-xx */
- } desc[MAXCAM];
- u_short enable; /* mask enabling CAM entries */
-};
+#define TXP_WORDS TXP_FRAGOFF + FRAGMAX*TXP_FSIZE + 1 /* 1 for tlink */
+#define TXP_SIZE(sc) ((sc->bitmode) ? (TXP_WORDS*4) : (TXP_WORDS*2))
+
+#define EOL 0x0001 /* end of list marker for link fields */
+
+/*
+ * CDA, the CAM descriptor area. The SONIC has a 16 entry CAM to
+ * match incoming addresses against. It is programmed via DMA
+ * from a memory region.
+ */
+#define MAXCAM 16 /* number of user entries in CAM */
+#define CDA_CAMDESC 4 /* # words i na descriptor */
+#define CDA_CAMEP 0 /* CAM Address Port 0 xx-xx-xx-xx-YY-YY */
+#define CDA_CAMAP0 1 /* CAM Address Port 1 xx-xx-YY-YY-xx-xx */
+#define CDA_CAMAP1 2 /* CAM Address Port 2 YY-YY-xx-xx-xx-xx */
+#define CDA_CAMAP2 3
+#define CDA_ENABLE 64 /* mask enabling CAM entries */
+#define CDA_SIZE(sc) ((4*16 + 1) * ((sc->bitmode) ? 4 : 2))
void snsetup __P((struct sn_softc *sc));