move vax headers into vax directories
[unix-history] / usr / src / sys / vax / if / if_dmc.c
index 4d00005..1f71e39 100644 (file)
@@ -1,4 +1,4 @@
-/*     if_dmc.c        4.6     82/03/19        */
+/*     if_dmc.c        4.19    82/10/10        */
 
 #include "dmc.h"
 #if NDMC > 0
 
 #include "dmc.h"
 #if NDMC > 0
@@ -19,18 +19,20 @@ int dmcdebug = 1;
 #include "../h/tty.h"
 #include "../h/protosw.h"
 #include "../h/socket.h"
 #include "../h/tty.h"
 #include "../h/protosw.h"
 #include "../h/socket.h"
-#include "../h/ubareg.h"
-#include "../h/ubavar.h"
-#include "../h/cpu.h"
-#include "../h/mtpr.h"
 #include "../h/vmmac.h"
 #include "../h/vmmac.h"
-#include "../net/in.h"
-#include "../net/in_systm.h"
+#include <errno.h>
+
 #include "../net/if.h"
 #include "../net/if.h"
-#include "../net/if_uba.h"
-#include "../net/if_dmc.h"
-#include "../net/ip.h"
-#include "../net/ip_var.h"
+#include "../net/route.h"
+#include "../netinet/in.h"
+#include "../netinet/in_systm.h"
+
+#include "../vax/cpu.h"
+#include "../vax/mtpr.h"
+#include "../vaxif/if_uba.h"
+#include "../vaxif/if_dmc.h"
+#include "../vaxuba/ubareg.h"
+#include "../vaxuba/ubavar.h"
 
 /*
  * Driver information for auto-configuration stuff.
 
 /*
  * Driver information for auto-configuration stuff.
@@ -41,8 +43,8 @@ u_short       dmcstd[] = { 0 };
 struct uba_driver dmcdriver =
        { dmcprobe, 0, dmcattach, 0, dmcstd, "dmc", dmcinfo };
 
 struct uba_driver dmcdriver =
        { dmcprobe, 0, dmcattach, 0, dmcstd, "dmc", dmcinfo };
 
-#define        DMC_PF  0xff            /* 8 bits of protocol type in ui_flags */
-#define        DMC_NET 0xff00          /* 8 bits of net number in ui_flags */
+#define        DMC_AF  0xff            /* 8 bits of address type in ui_flags */
+#define        DMC_NET 0xffffff00      /* 24 bits of net number in ui_flags */
 
 /*
  * DMC software status per interface.
 
 /*
  * DMC software status per interface.
@@ -91,14 +93,17 @@ dmcprobe(reg)
        for (i = 100000; i && (addr->bsel1 & DMC_RUN) == 0; i--)
                ;
        if ((addr->bsel1 & DMC_RUN) == 0)
        for (i = 100000; i && (addr->bsel1 & DMC_RUN) == 0; i--)
                ;
        if ((addr->bsel1 & DMC_RUN) == 0)
-               return(0);
+               return (0);
        addr->bsel1 &= ~DMC_MCLR;
        addr->bsel0 = DMC_RQI|DMC_IEI;
        DELAY(100000);
        addr->bsel1 = DMC_MCLR;
        for (i = 100000; i && (addr->bsel1 & DMC_RUN) == 0; i--)
                ;
        addr->bsel1 &= ~DMC_MCLR;
        addr->bsel0 = DMC_RQI|DMC_IEI;
        DELAY(100000);
        addr->bsel1 = DMC_MCLR;
        for (i = 100000; i && (addr->bsel1 & DMC_RUN) == 0; i--)
                ;
-       return(1);
+#ifdef ECHACK
+       br = 0x16;
+#endif
+       return (1);
 }
 
 /*
 }
 
 /*
@@ -110,18 +115,21 @@ dmcattach(ui)
        register struct uba_device *ui;
 {
        register struct dmc_softc *sc = &dmc_softc[ui->ui_unit];
        register struct uba_device *ui;
 {
        register struct dmc_softc *sc = &dmc_softc[ui->ui_unit];
+       register struct sockaddr_in *sin;
 
        sc->sc_if.if_unit = ui->ui_unit;
        sc->sc_if.if_name = "dmc";
        sc->sc_if.if_mtu = DMCMTU;
        sc->sc_if.if_net = (ui->ui_flags & DMC_NET) >> 8;
        sc->sc_if.if_host[0] = 17;      /* random number */
 
        sc->sc_if.if_unit = ui->ui_unit;
        sc->sc_if.if_name = "dmc";
        sc->sc_if.if_mtu = DMCMTU;
        sc->sc_if.if_net = (ui->ui_flags & DMC_NET) >> 8;
        sc->sc_if.if_host[0] = 17;      /* random number */
-       sc->sc_if.if_addr =
-           if_makeaddr(sc->sc_if.if_net, sc->sc_if.if_host[0]);
+       sin = (struct sockaddr_in *)&sc->sc_if.if_addr;
+       sin->sin_family = AF_INET;
+       sin->sin_addr = if_makeaddr(sc->sc_if.if_net, sc->sc_if.if_host[0]);
        sc->sc_if.if_init = dmcinit;
        sc->sc_if.if_output = dmcoutput;
        sc->sc_if.if_ubareset = dmcreset;
        sc->sc_if.if_init = dmcinit;
        sc->sc_if.if_output = dmcoutput;
        sc->sc_if.if_ubareset = dmcreset;
-       sc->sc_ifuba.ifuba_flags = UBA_NEEDBDP;
+       /* DON'T KNOW IF THIS WILL WORK WITH A BDP AT HIGH SPEEDS */
+       sc->sc_ifuba.ifu_flags = UBA_NEEDBDP | UBA_CANTWAIT;
        if_attach(&sc->sc_if);
 }
 
        if_attach(&sc->sc_if);
 }
 
@@ -161,6 +169,7 @@ dmcinit(unit)
        if (if_ubainit(&sc->sc_ifuba, ui->ui_ubanum, 0,
            (int)btoc(DMCMTU)) == 0) {
                printf("dmc%d: can't initialize\n", unit);
        if (if_ubainit(&sc->sc_ifuba, ui->ui_ubanum, 0,
            (int)btoc(DMCMTU)) == 0) {
                printf("dmc%d: can't initialize\n", unit);
+               sc->sc_if.if_flags &= ~IFF_UP;
                return;
        }
        addr = (struct dmcdevice *)ui->ui_addr;
                return;
        }
        addr = (struct dmcdevice *)ui->ui_addr;
@@ -172,6 +181,12 @@ dmcinit(unit)
        base = sc->sc_ifuba.ifu_r.ifrw_info & 0x3ffff;
        dmcload(sc, DMC_READ, base, ((base>>2)&DMC_XMEM)|DMCMTU);
        printd("  first read queued, addr 0x%x\n", base);
        base = sc->sc_ifuba.ifu_r.ifrw_info & 0x3ffff;
        dmcload(sc, DMC_READ, base, ((base>>2)&DMC_XMEM)|DMCMTU);
        printd("  first read queued, addr 0x%x\n", base);
+       sc->sc_if.if_flags |= IFF_UP;
+       /* set up routing table entry */
+       if ((sc->sc_if.if_flags & IFF_ROUTE) == 0) {
+               rtinit(&sc->sc_if.if_addr, &sc->sc_if.if_addr, RTF_HOST|RTF_UP);
+               sc->sc_if.if_flags |= IFF_ROUTE;
+       }
 }
 
 /*
 }
 
 /*
@@ -202,7 +217,7 @@ dmcstart(dev)
         * Have request mapped to UNIBUS for transmission.
         * Purge any stale data from this BDP and start the output.
         */
         * Have request mapped to UNIBUS for transmission.
         * Purge any stale data from this BDP and start the output.
         */
-       if (sc->sc_ifuba.ifuba_flags & UBA_NEEDBDP)
+       if (sc->sc_ifuba.ifu_flags & UBA_NEEDBDP)
                UBAPURGE(sc->sc_ifuba.ifu_uba, sc->sc_ifuba.ifu_w.ifrw_bdp);
        addr = sc->sc_ifuba.ifu_w.ifrw_info & 0x3ffff;
        printd("  len %d, addr 0x%x, ", len, addr);
                UBAPURGE(sc->sc_ifuba.ifu_uba, sc->sc_ifuba.ifu_w.ifrw_bdp);
        addr = sc->sc_ifuba.ifu_w.ifrw_info & 0x3ffff;
        printd("  len %d, addr 0x%x, ", len, addr);
@@ -247,21 +262,13 @@ dmcrint(unit)
        register struct dmc_softc *sc;
        register struct dmcdevice *addr;
        register int n;
        register struct dmc_softc *sc;
        register struct dmcdevice *addr;
        register int n;
-       int w0, w1; /* DEBUG */
 
        addr = (struct dmcdevice *)dmcinfo[unit]->ui_addr;
        sc = &dmc_softc[unit];
        while (addr->bsel0&DMC_RDYI) {
 
        addr = (struct dmcdevice *)dmcinfo[unit]->ui_addr;
        sc = &dmc_softc[unit];
        while (addr->bsel0&DMC_RDYI) {
-               w0 = getw(&sc->sc_que); /* DEBUG */
-               addr->sel4 = w0; /* DEBUG */
-               w1 = getw(&sc->sc_que); /* DEBUG */
-               addr->sel6 = w1; /* DEBUG */
-               /* DEBUG
                addr->sel4 = getw(&sc->sc_que);
                addr->sel6 = getw(&sc->sc_que);
                addr->sel4 = getw(&sc->sc_que);
                addr->sel6 = getw(&sc->sc_que);
-               DEBUG */
                addr->bsel0 &= ~(DMC_IEI|DMC_RQI);
                addr->bsel0 &= ~(DMC_IEI|DMC_RQI);
-               printd("  w0 0x%x, w1 0x%x\n", w0, w1);
                while (addr->bsel0&DMC_RDYI)
                        ;
                if (sc->sc_que.c_cc == 0)
                while (addr->bsel0&DMC_RDYI)
                        ;
                if (sc->sc_que.c_cc == 0)
@@ -306,22 +313,22 @@ dmcxint(unit)
                 * higher-level input routine.
                 */
                sc->sc_if.if_ipackets++;
                 * higher-level input routine.
                 */
                sc->sc_if.if_ipackets++;
-               if (sc->sc_ifuba.ifuba_flags & UBA_NEEDBDP)
+               if (sc->sc_ifuba.ifu_flags & UBA_NEEDBDP)
                        UBAPURGE(sc->sc_ifuba.ifu_uba,
                                sc->sc_ifuba.ifu_r.ifrw_bdp);
                len = arg & DMC_CCOUNT;
                printd("  read done, len %d\n", len);
                        UBAPURGE(sc->sc_ifuba.ifu_uba,
                                sc->sc_ifuba.ifu_r.ifrw_bdp);
                len = arg & DMC_CCOUNT;
                printd("  read done, len %d\n", len);
-               switch (ui->ui_flags & DMC_PF) {
+               switch (ui->ui_flags & DMC_AF) {
 #ifdef INET
 #ifdef INET
-               case PF_INET:
+               case AF_INET:
                        schednetisr(NETISR_IP);
                        inq = &ipintrq;
                        break;
 #endif
 
                default:
                        schednetisr(NETISR_IP);
                        inq = &ipintrq;
                        break;
 #endif
 
                default:
-                       printf("dmc%d: unknown packet type %d\n", unit,
-                           ui->ui_flags & DMC_NET);
+                       printf("dmc%d: unknown address type %d\n", unit,
+                           ui->ui_flags & DMC_AF);
                        goto setup;
                }
                m = if_rubaget(&sc->sc_ifuba, len, 0);
                        goto setup;
                }
                m = if_rubaget(&sc->sc_ifuba, len, 0);
@@ -380,30 +387,30 @@ setup:
  * Just send the data, header was supplied by
  * upper level protocol routines.
  */
  * Just send the data, header was supplied by
  * upper level protocol routines.
  */
-dmcoutput(ifp, m, pf)
+dmcoutput(ifp, m, dst)
        register struct ifnet *ifp;
        register struct mbuf *m;
        register struct ifnet *ifp;
        register struct mbuf *m;
-       int pf;
+       struct sockaddr *dst;
 {
        struct uba_device *ui = dmcinfo[ifp->if_unit];
        int s;
 
        printd("dmcoutput\n");
 {
        struct uba_device *ui = dmcinfo[ifp->if_unit];
        int s;
 
        printd("dmcoutput\n");
-       if (pf != (ui->ui_flags & DMC_PF)) {
-               printf("dmc%d: protocol %d not supported\n", ifp->if_unit, pf);
-               (void) m_freem(m);
-               return (0);
+       if (dst->sa_family != (ui->ui_flags & DMC_AF)) {
+               printf("dmc%d: af%d not supported\n", ifp->if_unit, pf);
+               m_freem(m);
+               return (EAFNOSUPPORT);
        }
        s = splimp();
        if (IF_QFULL(&ifp->if_snd)) {
                IF_DROP(&ifp->if_snd);
        }
        s = splimp();
        if (IF_QFULL(&ifp->if_snd)) {
                IF_DROP(&ifp->if_snd);
-               (void) m_freem(m);
+               m_freem(m);
                splx(s);
                splx(s);
-               return (0);
+               return (ENOBUFS);
        }
        IF_ENQUEUE(&ifp->if_snd, m);
        if (dmc_softc[ifp->if_unit].sc_oactive == 0)
                dmcstart(ifp->if_unit);
        splx(s);
        }
        IF_ENQUEUE(&ifp->if_snd, m);
        if (dmc_softc[ifp->if_unit].sc_oactive == 0)
                dmcstart(ifp->if_unit);
        splx(s);
-       return (1);
+       return (0);
 }
 }