purge extraneous stuff
[unix-history] / usr / src / sys / vax / if / if_en.c
index 1b047ba..4df49c8 100644 (file)
@@ -1,4 +1,4 @@
-/*     if_en.c 4.34    82/02/21        */
+/*     if_en.c 4.43    82/03/19        */
 
 #include "en.h"
 
 
 #include "en.h"
 
@@ -26,6 +26,7 @@
 #include "../net/if_uba.h"
 #include "../net/ip.h"
 #include "../net/ip_var.h"
 #include "../net/if_uba.h"
 #include "../net/ip.h"
 #include "../net/ip_var.h"
+#include "../net/pup.h"
 
 #define        ENMTU   (1024+512)
 
 
 #define        ENMTU   (1024+512)
 
@@ -109,6 +110,8 @@ COUNT(ENATTACH);
 #endif
        es->es_if.if_addr =
            if_makeaddr(es->es_if.if_net, es->es_if.if_host[0]);
 #endif
        es->es_if.if_addr =
            if_makeaddr(es->es_if.if_net, es->es_if.if_host[0]);
+       es->es_if.if_broadaddr =
+           if_makeaddr(es->es_if.if_net, 0);
        es->es_if.if_init = eninit;
        es->es_if.if_output = enoutput;
        es->es_if.if_ubareset = enreset;
        es->es_if.if_init = eninit;
        es->es_if.if_output = enoutput;
        es->es_if.if_ubareset = enreset;
@@ -237,20 +240,22 @@ enxint(unit)
 {
        register struct uba_device *ui = eninfo[unit];
        register struct en_softc *es = &en_softc[unit];
 {
        register struct uba_device *ui = eninfo[unit];
        register struct en_softc *es = &en_softc[unit];
-       register struct endevice *addr;
+       register struct endevice *addr = (struct endevice *)ui->ui_addr;
 COUNT(ENXINT);
 
        if (es->es_oactive == 0)
                return;
 COUNT(ENXINT);
 
        if (es->es_oactive == 0)
                return;
-       addr = (struct endevice *)ui->ui_addr;
+       if (es->es_mask && (addr->en_ostat&EN_OERROR)) {
+               es->es_if.if_oerrors++;
+               if (es->es_if.if_oerrors % 100 == 0)
+                       printf("en%d: += 100 output errors\n", unit);
+               endocoll(unit);
+               return;
+       }
        es->es_if.if_opackets++;
        es->es_oactive = 0;
        es->es_delay = 0;
        es->es_mask = ~0;
        es->es_if.if_opackets++;
        es->es_oactive = 0;
        es->es_delay = 0;
        es->es_mask = ~0;
-       if (addr->en_ostat&EN_OERROR) {
-               es->es_if.if_oerrors++;
-               printf("en%d: output error\n", unit);
-       }
        if (es->es_ifuba.ifu_xtofree) {
                m_freem(es->es_ifuba.ifu_xtofree);
                es->es_ifuba.ifu_xtofree = 0;
        if (es->es_ifuba.ifu_xtofree) {
                m_freem(es->es_ifuba.ifu_xtofree);
                es->es_ifuba.ifu_xtofree = 0;
@@ -270,12 +275,20 @@ COUNT(ENXINT);
 encollide(unit)
        int unit;
 {
 encollide(unit)
        int unit;
 {
-       register struct en_softc *es = &en_softc[unit];
+       struct en_softc *es = &en_softc[unit];
 COUNT(ENCOLLIDE);
 
        es->es_if.if_collisions++;
        if (es->es_oactive == 0)
                return;
 COUNT(ENCOLLIDE);
 
        es->es_if.if_collisions++;
        if (es->es_oactive == 0)
                return;
+       endocoll(unit);
+}
+
+endocoll(unit)
+       int unit;
+{
+       register struct en_softc *es = &en_softc[unit];
+
        /*
         * Es_mask is a 16 bit number with n low zero bits, with
         * n the number of backoffs.  When es_mask is 0 we have
        /*
         * Es_mask is a 16 bit number with n low zero bits, with
         * n the number of backoffs.  When es_mask is 0 we have
@@ -295,7 +308,9 @@ COUNT(ENCOLLIDE);
        enstart(unit);
 }
 
        enstart(unit);
 }
 
-int    enprintierrors;
+struct sockaddr_pup pupsrc = { AF_PUP };
+struct sockaddr_pup pupdst = { AF_PUP };
+struct sockproto pupproto = { PF_PUP };
 /*
  * Ethernet interface receiver interrupt.
  * If input error just drop packet.
 /*
  * Ethernet interface receiver interrupt.
  * If input error just drop packet.
@@ -325,8 +340,8 @@ COUNT(ENRINT);
        UBAPURGE(es->es_ifuba.ifu_uba, es->es_ifuba.ifu_r.ifrw_bdp);
        if (addr->en_istat&EN_IERROR) {
                es->es_if.if_ierrors++;
        UBAPURGE(es->es_ifuba.ifu_uba, es->es_ifuba.ifu_r.ifrw_bdp);
        if (addr->en_istat&EN_IERROR) {
                es->es_if.if_ierrors++;
-               if (enprintierrors)
-               printf("en%d: input error\n", unit);
+               if (es->es_if.if_ierrors % 100 == 0)
+                       printf("en%d: += 100 input errors\n", unit);
                goto setup;
        }
 
                goto setup;
        }
 
@@ -358,13 +373,18 @@ COUNT(ENRINT);
                len = htons((u_short)endataaddr(en, off ? off+2 : 0, struct ip *)->ip_len);
                if (off)
                        len += 2;
                len = htons((u_short)endataaddr(en, off ? off+2 : 0, struct ip *)->ip_len);
                if (off)
                        len += 2;
-               setipintr();
-               inq = &ipintrq;
                break;
 #endif
                break;
 #endif
-
+#ifdef PUP
+       case ENPUP_PUPTYPE:
+               len = endataaddr(en, off, struct pup_header *)->pup_length;
+               if (off)
+                       len -= 2;
+               break;
+#endif
+               
        default:
        default:
-               printf("en%d: unknow pkt type 0x%x\n", en->en_type);
+               printf("en%d: unknown pkt type 0x%x\n", unit, en->en_type);
                goto setup;
        }
        if (len == 0)
                goto setup;
        }
        if (len == 0)
@@ -383,7 +403,30 @@ COUNT(ENRINT);
                m->m_off += 2;
                m->m_len -= 2;
        }
                m->m_off += 2;
                m->m_len -= 2;
        }
-       IF_ENQUEUE(inq, m);
+       switch (en->en_type) {
+
+#ifdef INET
+       case ENPUP_IPTYPE:
+               schednetisr(NETISR_IP);
+               inq = &ipintrq;
+               break;
+#endif
+       case ENPUP_PUPTYPE: {
+               struct pup_header *pup = mtod(m, struct pup_header *);
+
+               pupproto.sp_protocol = pup->pup_type;
+               pupdst.spup_addr = pup->pup_dport;
+               pupsrc.spup_addr = pup->pup_sport;
+               raw_input(m, &pupproto, (struct sockaddr *)&pupdst,
+                (struct sockaddr *)&pupsrc);
+               goto setup;
+               }
+       }
+       if (IF_QFULL(inq)) {
+               IF_DROP(inq);
+               (void) m_freem(m);
+       } else
+               IF_ENQUEUE(inq, m);
 
 setup:
        /*
 
 setup:
        /*
@@ -405,10 +448,9 @@ enoutput(ifp, m0, pf)
        struct mbuf *m0;
        int pf;
 {
        struct mbuf *m0;
        int pf;
 {
-       int type, dest;
+       int type, dest, s, off;
        register struct mbuf *m = m0;
        register struct en_header *en;
        register struct mbuf *m = m0;
        register struct en_header *en;
-       int s;
 
 COUNT(ENOUTPUT);
        switch (pf) {
 
 COUNT(ENOUTPUT);
        switch (pf) {
@@ -416,7 +458,6 @@ COUNT(ENOUTPUT);
 #ifdef INET
        case PF_INET: {
                register struct ip *ip = mtod(m0, struct ip *);
 #ifdef INET
        case PF_INET: {
                register struct ip *ip = mtod(m0, struct ip *);
-               int off;
 
 #ifndef ENKLUDGE
                dest = ip->ip_dst.s_addr >> 24;
 
 #ifndef ENKLUDGE
                dest = ip->ip_dst.s_addr >> 24;
@@ -438,6 +479,24 @@ COUNT(ENOUTPUT);
                goto gottype;
                }
 #endif
                goto gottype;
                }
 #endif
+#ifdef PUP
+       case PF_PUP: {
+               register struct pup_header *pup = mtod(m, struct pup_header *);
+
+               dest = pup->pup_dhost;
+               off = pup->pup_length - m->m_len;
+               if (off > 0 && (off & 0x1ff) == 0 && m->m_off >= MMINOFF + 2) {
+                       type = ENPUP_TRAIL + (off>>9);
+                       m->m_off -= 2;
+                       m->m_len += 2;
+                       *mtod(m, u_short *) = ENPUP_PUPTYPE;
+                       goto gottrailertype;
+               }
+               type = ENPUP_PUPTYPE;
+               off = 0;
+               goto gottype;
+               }
+#endif
 
        default:
                printf("en%d: can't encapsulate pf%d\n", ifp->if_unit, pf);
 
        default:
                printf("en%d: can't encapsulate pf%d\n", ifp->if_unit, pf);
@@ -486,6 +545,12 @@ gottype:
         * not yet active.
         */
        s = splimp();
         * not yet active.
         */
        s = splimp();
+       if (IF_QFULL(&ifp->if_snd)) {
+               IF_DROP(&ifp->if_snd);
+               m_freem(m);
+               splx(s);
+               return (0);
+       }
        IF_ENQUEUE(&ifp->if_snd, m);
        if (en_softc[ifp->if_unit].es_oactive == 0)
                enstart(ifp->if_unit);
        IF_ENQUEUE(&ifp->if_snd, m);
        if (en_softc[ifp->if_unit].es_oactive == 0)
                enstart(ifp->if_unit);