Changeset 573b4cd6 in rtems-libbsd


Ignore:
Timestamp:
10/08/14 06:04:59 (9 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, 5, 5-freebsd-12, 6-freebsd-12, freebsd-9.3, master
Children:
403d0b8
Parents:
70fa95a
git-author:
Sebastian Huber <sebastian.huber@…> (10/08/14 06:04:59)
git-committer:
Sebastian Huber <sebastian.huber@…> (10/08/14 13:03:29)
Message:

ppp: Port to new stack

Files:
3 added
11 edited

Legend:

Unmodified
Added
Removed
  • Makefile

    r70fa95a r573b4cd6  
    2323COMMON_FLAGS += -Ifreebsd/lib/libmemstat
    2424COMMON_FLAGS += -Ifreebsd/lib/libipsec
     25COMMON_FLAGS += -Irtemsbsd/sys
    2526COMMON_FLAGS += -ImDNSResponder/mDNSCore
    2627COMMON_FLAGS += -ImDNSResponder/mDNSShared
     
    101102LIB_C_FILES += rtemsbsd/rtems/syslog.c
    102103LIB_C_FILES += rtemsbsd/ftpd/ftpd.c
     104LIB_C_FILES += rtemsbsd/pppd/auth.c
     105LIB_C_FILES += rtemsbsd/pppd/ccp.c
     106LIB_C_FILES += rtemsbsd/pppd/chap.c
     107LIB_C_FILES += rtemsbsd/pppd/chap_ms.c
     108LIB_C_FILES += rtemsbsd/pppd/chat.c
     109LIB_C_FILES += rtemsbsd/pppd/demand.c
     110LIB_C_FILES += rtemsbsd/pppd/fsm.c
     111LIB_C_FILES += rtemsbsd/pppd/ipcp.c
     112LIB_C_FILES += rtemsbsd/pppd/lcp.c
     113LIB_C_FILES += rtemsbsd/pppd/magic.c
     114LIB_C_FILES += rtemsbsd/pppd/options.c
     115LIB_C_FILES += rtemsbsd/pppd/rtemsmain.c
     116LIB_C_FILES += rtemsbsd/pppd/rtemspppd.c
     117LIB_C_FILES += rtemsbsd/pppd/sys-rtems.c
     118LIB_C_FILES += rtemsbsd/pppd/upap.c
     119LIB_C_FILES += rtemsbsd/pppd/utils.c
    103120LIB_C_FILES += rtemsbsd/sys/dev/usb/controller/ehci_mpc83xx.c
    104121LIB_C_FILES += rtemsbsd/sys/dev/usb/controller/ohci_lpc24xx.c
     
    106123LIB_C_FILES += rtemsbsd/sys/dev/smc/if_smc_nexus.c
    107124LIB_C_FILES += rtemsbsd/sys/dev/ffec/if_ffec_mcf548x.c
     125LIB_C_FILES += rtemsbsd/sys/net/if_ppp.c
     126LIB_C_FILES += rtemsbsd/sys/net/ppp_tty.c
    108127LIB_C_FILES += rtemsbsd/telnetd/check_passwd.c
    109128LIB_C_FILES += rtemsbsd/telnetd/des.c
     
    13391358D_FILES += $(TEST_CONDVAR01_D_FILES)
    13401359RUN_TESTS += $(TEST_CONDVAR01)
     1360
     1361TEST_PPP01 = testsuite/ppp01/ppp01.exe
     1362TEST_PPP01_O_FILES =
     1363TEST_PPP01_D_FILES =
     1364TEST_PPP01_O_FILES += testsuite/ppp01/test_main.o
     1365TEST_PPP01_D_FILES += testsuite/ppp01/test_main.d
     1366$(TEST_PPP01): $(TEST_PPP01_O_FILES) $(LIB)
     1367        $(LINK.c) -Wl,-Map,testsuite/ppp01/ppp01.map $^ -lm -lz -o $@
     1368TESTS += $(TEST_PPP01)
     1369O_FILES += $(TEST_PPP01_O_FILES)
     1370D_FILES += $(TEST_PPP01_D_FILES)
    13411371LIB_C_FILES += dhcpcd/arp.c
    13421372dhcpcd/arp.o: dhcpcd/arp.c
  • freebsd-to-rtems.py

    r70fa95a r573b4cd6  
    429429                        'COMMON_FLAGS += -Ifreebsd/lib/libmemstat\n' \
    430430                        'COMMON_FLAGS += -Ifreebsd/lib/libipsec\n' \
     431                        'COMMON_FLAGS += -Irtemsbsd/sys\n' \
    431432                        'COMMON_FLAGS += -ImDNSResponder/mDNSCore\n' \
    432433                        'COMMON_FLAGS += -ImDNSResponder/mDNSShared\n' \
     
    699700                'rtems/syslog.c',
    700701                'ftpd/ftpd.c',
     702                'pppd/auth.c',
     703                'pppd/ccp.c',
     704                'pppd/chap.c',
     705                'pppd/chap_ms.c',
     706                'pppd/chat.c',
     707                'pppd/demand.c',
     708                'pppd/fsm.c',
     709                'pppd/ipcp.c',
     710                'pppd/lcp.c',
     711                'pppd/magic.c',
     712                'pppd/options.c',
     713                'pppd/rtemsmain.c',
     714                'pppd/rtemspppd.c',
     715                'pppd/sys-rtems.c',
     716                'pppd/upap.c',
     717                'pppd/utils.c',
    701718                'sys/dev/usb/controller/ehci_mpc83xx.c',
    702719                'sys/dev/usb/controller/ohci_lpc24xx.c',
     
    704721                'sys/dev/smc/if_smc_nexus.c',
    705722                'sys/dev/ffec/if_ffec_mcf548x.c',
     723                'sys/net/if_ppp.c',
     724                'sys/net/ppp_tty.c',
    706725                'telnetd/check_passwd.c',
    707726                'telnetd/des.c',
     
    24742493tests.addTest('mutex01', ['test_main'])
    24752494tests.addTest('condvar01', ['test_main'])
     2495tests.addTest('ppp01', ['test_main'], runTest = False)
    24762496
    24772497dhcpcd = Module('dhcpcd')
  • rtemsbsd/pppd/ipcp.c

    r70fa95a r573b4cd6  
    3838#include "ipcp.h"
    3939#include "pathnames.h"
    40 
    41 #include <rtems/bsdnet/servers.h>
    4240
    4341static const char rcsid[] = RCSID;
     
    15781576    uint32_t peerdns1, uint32_t peerdns2)
    15791577{
    1580   /* initialize values */
    1581   rtems_bsdnet_nameserver_count = 0;
    1582 
    1583   /* check to see if primary was specified */
    1584   if ( peerdns1 ) {
    1585     rtems_bsdnet_nameserver[rtems_bsdnet_nameserver_count].s_addr = peerdns1;
    1586     rtems_bsdnet_nameserver_count++;
    1587   }
    1588 
    1589   /* check to see if secondary was specified */
    1590   if ( peerdns2 ) {
    1591     rtems_bsdnet_nameserver[rtems_bsdnet_nameserver_count].s_addr = peerdns2;
    1592     rtems_bsdnet_nameserver_count++;
    1593   }
    1594 
    1595   /* initialize resolver */
    1596   __res_init();
     1578    FILE *f;
     1579
     1580    f = fopen(_PATH_RESOLV, "w");
     1581    if (f == NULL) {
     1582        error("Failed to create %s: %m", _PATH_RESOLV);
     1583        return;
     1584    }
     1585
     1586    if (peerdns1)
     1587        fprintf(f, "nameserver %s\n", ip_ntoa(peerdns1));
     1588
     1589    if (peerdns2)
     1590        fprintf(f, "nameserver %s\n", ip_ntoa(peerdns2));
     1591
     1592    if (ferror(f))
     1593        error("Write failed to %s: %m", _PATH_RESOLV);
     1594
     1595    fclose(f);
    15971596}
    15981597
  • rtemsbsd/pppd/pathnames.h

    r70fa95a r573b4cd6  
    2929#define _PATH_CONNERRS   _ROOT_PATH "/etc/ppp/connect-errors"
    3030#define _PATH_PEERFILES  _ROOT_PATH "/etc/ppp/peers/"
    31 #define _PATH_RESOLV     _ROOT_PATH "/etc/ppp/resolv.conf"
     31#define _PATH_RESOLV     _ROOT_PATH "/etc/resolv.conf"
    3232
    3333#define _PATH_USEROPT    ".ppprc"
  • rtemsbsd/pppd/pppd.h

    r70fa95a r573b4cd6  
    3232#include <rtems/rtemsdialer.h>
    3333#include <stdint.h>
     34#include <arpa/nameser.h>
     35#include <arpa/nameser_compat.h>
    3436
    3537#if defined(__STDC__)
     
    4648#include "eui64.h"
    4749#endif
     50
     51#include "namespace.h"
    4852
    4953/*
     
    503507}
    504508
    505 
    506 #define GETSHORT(s, cp) { \
    507         (s) = *(cp)++ << 8; \
    508         (s) |= *(cp)++; \
    509 }
    510 #define PUTSHORT(s, cp) { \
    511         *(cp)++ = (u_char) ((s) >> 8); \
    512         *(cp)++ = (u_char) (s); \
    513 }
    514 
    515 #define GETLONG(l, cp) { \
    516         (l) = *(cp)++ << 8; \
    517         (l) |= *(cp)++; (l) <<= 8; \
    518         (l) |= *(cp)++; (l) <<= 8; \
    519         (l) |= *(cp)++; \
    520 }
    521 #define PUTLONG(l, cp) { \
    522         *(cp)++ = (u_char) ((l) >> 24); \
    523         *(cp)++ = (u_char) ((l) >> 16); \
    524         *(cp)++ = (u_char) ((l) >> 8); \
    525         *(cp)++ = (u_char) (l); \
    526 }
    527 
    528509#define INCPTR(n, cp)   ((cp) += (n))
    529510#define DECPTR(n, cp)   ((cp) -= (n))
  • rtemsbsd/pppd/rtemsmain.c

    r70fa95a r573b4cd6  
    4242#include <rtems.h>
    4343#include <rtems/rtems_bsdnet.h>
     44#include <rtems/rtemsdialer.h>
    4445
    4546#include "pppd.h"
     
    5657#include "pathnames.h"
    5758#include "patchlevel.h"
    58 #include "rtemsdialer.h"
    5959
    6060#ifdef CBCP_SUPPORT
  • rtemsbsd/pppd/rtemspppd.c

    r70fa95a r573b4cd6  
    1111 */
    1212
     13#include <rtems/rtemspppd.h>
    1314#include <rtems.h>
    14 #include <rtems/rtems_bsdnet.h>
    1515#include "pppd.h"
    16 #include "rtemspppd.h"
    1716
    1817
     
    8382  rtems_name          taskName;
    8483
    85   /* determine priority value */
    86   if ( rtems_bsdnet_config.network_task_priority ) {
    87     priority = rtems_bsdnet_config.network_task_priority;
    88   }
    89 
    9084  /* initialize the exit hook */
    9185  rtems_pppd_exitfp = (rtems_pppd_hookfunction)0;
  • rtemsbsd/pppd/sys-rtems.c

    r70fa95a r573b4cd6  
    6060#include <rtems/rtems_bsdnet.h>
    6161#include <rtems/termiostypes.h>
    62 extern int      rtems_bsdnet_microseconds_per_tick;
    6362extern rtems_id rtems_pppd_taskid;
    6463
     
    501500
    502501  /* recommended delay to help negotiation */
    503   ticks = 300000/rtems_bsdnet_microseconds_per_tick;
     502  ticks = 300000/rtems_configuration_get_microseconds_per_tick();
    504503  rtems_task_wake_after(ticks);
    505504}
     
    523522    else {
    524523      ticks = (timo->tv_sec * 1000000 + timo->tv_usec) /
    525         rtems_bsdnet_microseconds_per_tick;
     524        rtems_configuration_get_microseconds_per_tick();
    526525      if(ticks <= 0)
    527526        ticks = 1;
  • rtemsbsd/sys/net/if_ppp.c

    r70fa95a r573b4cd6  
     1#include <machine/rtems-bsd-kernel-space.h>
     2
    13/*
    24 * if_ppp.c - Point-to-Point Protocol (PPP) Asynchronous driver.
     
    8082#endif
    8183
    82 #include "opt_inet.h"
    83 #include "opt_ipx.h"
    84 #include "opt_mac.h"
    85 #include "opt_ppp.h"
     84#include <rtems/bsd/local/opt_inet.h>
     85#include <rtems/bsd/local/opt_ipx.h>
     86#include <rtems/bsd/local/opt_mac.h>
     87#include <rtems/bsd/local/opt_ppp.h>
    8688
    8789#if NPPP > 0
     
    9193#include <rtems/rtems_bsdnet.h>
    9294#include <rtems/rtemspppd.h>
    93 #include <sys/param.h>
     95#include <rtems/bsd/sys/param.h>
    9496#include <sys/systm.h>
    9597#include <sys/proc.h>
     
    100102#include <sys/time.h>
    101103#include <sys/malloc.h>
     104#include <sys/module.h>
     105
     106#include <sys/bus.h>
     107#include <machine/bus.h>
    102108
    103109#include <net/if.h>
     
    189195#endif /* PPP_COMPRESS */
    190196
    191 extern struct ifqueue    ipintrq;
    192197static struct timeval    ppp_time;
    193198
     
    199204ppp_unit(struct ppp_softc *sc)
    200205{
    201   return sc->sc_if.if_unit;
     206  return device_get_unit(sc->sc_dev);
    202207}
    203208
     
    205210{
    206211  rtems_event_set             events;
    207   rtems_interrupt_level       level;
    208212  struct ppp_softc           *sc = (struct ppp_softc *)arg;
    209213  struct mbuf                *mp = (struct mbuf      *)0;
     
    220224
    221225    if ( events ) {
    222       /* get the network semaphore */
    223       rtems_bsdnet_semaphore_obtain();
    224 
    225226      /* check to see if new packet was received */
    226227      if ( events & RX_PACKET ) {
    227228        /* get received packet mbuf chain */
    228         rtems_interrupt_disable(level);
    229         IF_DEQUEUE(&sc->sc_rawq, m);
    230         rtems_interrupt_enable(level);
     229        m = if_ppp_dequeue(&sc->sc_rawq);
    231230
    232231        /* ensure packet was retrieved */
     
    243242
    244243      /* place mbuf on freeq */
    245       rtems_interrupt_disable(level);
    246       IF_ENQUEUE(&sc->sc_freeq, mp);
    247       rtems_interrupt_enable(level);
     244      if_ppp_enqueue(&sc->sc_freeq, mp);
    248245      mp = (struct mbuf *)0;
    249 
    250       /* release the network semaphore */
    251       rtems_bsdnet_semaphore_release();
    252246
    253247      /* check to see if queue is empty */
     
    280274    if ( events & TX_TRANSMIT ) {
    281275      /* received event from interrupt handler - free current mbuf */
    282       rtems_bsdnet_semaphore_obtain();
    283 
    284276      m_freem(sc->sc_outm);
    285      
    286       rtems_bsdnet_semaphore_release();
    287277
    288278      /* chain is done - clear the values */
     
    304294          /* clear output flags */
    305295          sc->sc_outflag      = 0;
    306           sc->sc_if.if_flags &= ~IFF_OACTIVE;
     296          sc->sc_ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
    307297        }
    308298        else {
     
    310300          iprocess            = 1;
    311301          sc->sc_outflag      = SC_TX_BUSY;
    312           sc->sc_if.if_flags |= IFF_OACTIVE;
     302          sc->sc_ifp->if_drv_flags |= IFF_DRV_OACTIVE;
    313303        }
    314304      }
     
    390380        sc->sc_outfcsbuf[sc->sc_outfcslen++] = ~sc->sc_outfcs & 0xff;
    391381        sc->sc_outfcsbuf[sc->sc_outfcslen++] = (~sc->sc_outfcs >> 8) & 0xff;
    392         microtime(&sc->sc_if.if_lastchange);
     382        microtime(&sc->sc_ifp->if_lastchange);
    393383 
    394384        /* write out frame byte to start the transmission */
     
    400390      if ( mf != (struct mbuf *)0 ) {
    401391        /* free empty mbufs */
    402         rtems_bsdnet_semaphore_obtain();
    403392        m_freem(mf);
    404         rtems_bsdnet_semaphore_release();
    405393      }
    406394    }
     
    412400  rtems_status_code   status;
    413401  uint32_t      priority = 100;
    414 
    415   /* determine priority value */
    416   if ( rtems_bsdnet_config.network_task_priority ) {
    417     priority = rtems_bsdnet_config.network_task_priority;
    418   }
    419402
    420403  /* check to see if we need to start up daemons */
     
    453436  /* mark driver running and output inactive */
    454437  /* ilya: IFF_RUNNING flag will be marked after the IPCP goes up */
    455 /*  sc->sc_if.if_flags |= IFF_RUNNING;  */
     438/*  sc->sc_ifp->if_flags |= IFF_RUNNING;        */
    456439}
    457440
     
    459442 * Called from boot code to establish ppp interfaces.
    460443 */
    461 int rtems_ppp_driver_attach(struct rtems_bsdnet_ifconfig *config, int attaching)
     444static int ppp_attach(device_t dev)
    462445{
    463 /*    int                 i = (int)0;   */
    464     struct ppp_softc   *sc;
    465     char               *name;
    466     int                 number;
    467    
    468    
    469     number = rtems_bsdnet_parse_driver_name (config, &name);
    470    
    471     if (!attaching || (number >= NPPP))
    472         return 0;
    473        
    474     sc = &ppp_softc[number];
    475    
    476     if (sc->sc_if.if_name != NULL)
    477         return 0;       /* interface is already attached */
    478    
    479 /*    for (sc = ppp_softc; i < NPPP; sc++) {    */
    480         sc->sc_if.if_name = name /*"ppp"*/;
    481         sc->sc_if.if_unit = number /*i++*/;
    482         sc->sc_if.if_mtu = PPP_MTU;
    483         sc->sc_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
    484         sc->sc_if.if_type = IFT_PPP;
    485         sc->sc_if.if_hdrlen = PPP_HDRLEN;
    486         sc->sc_if.if_ioctl = pppsioctl;
    487         sc->sc_if.if_output = pppoutput;
    488         sc->sc_if.if_snd.ifq_maxlen = IFQ_MAXLEN;
    489         sc->sc_inq.ifq_maxlen = IFQ_MAXLEN;
    490         sc->sc_fastq.ifq_maxlen = IFQ_MAXLEN;
    491         sc->sc_rawq.ifq_maxlen = IFQ_MAXLEN;
    492         sc->sc_freeq.ifq_maxlen = NUM_MBUFQ;
    493 
    494         /* initialize and attach */
    495         ppp_init(sc);
    496         if_attach(&sc->sc_if);
    497 #if NBPFILTER > 0
    498         bpfattach(&sc->sc_bpf, &sc->sc_if, DLT_PPP, PPP_HDRLEN);
    499 #endif
    500 /*    } */
    501 
    502     return ( 1 );
     446    int unit = device_get_unit(dev);
     447    struct ppp_softc *sc;
     448    struct ifnet *ifp;
     449
     450    if (unit >= NPPP)
     451        return (ENXIO);
     452
     453    sc = &ppp_softc[unit];
     454    device_set_softc(dev, sc);
     455
     456    sc->sc_ifp = ifp = if_alloc(IFT_PPP);
     457    if (sc->sc_ifp == NULL)
     458        return (ENOMEM);
     459
     460    sc->sc_dev = dev;
     461    sc->sc_inq.ifq_maxlen = IFQ_MAXLEN;
     462    sc->sc_rawq.ifq_maxlen = IFQ_MAXLEN;
     463    sc->sc_freeq.ifq_maxlen = NUM_MBUFQ;
     464
     465    ifq_init(&sc->sc_fastq, ifp);
     466
     467    if_initname(ifp, device_get_name(dev), device_get_unit(dev));
     468    ifp->if_softc = sc;
     469    ifp->if_mtu = PPP_MTU;
     470    ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
     471    ifp->if_type = IFT_PPP;
     472    ifp->if_hdrlen = PPP_HDRLEN;
     473    ifp->if_ioctl = pppsioctl;
     474    ifp->if_output = pppoutput;
     475    ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
     476
     477    /* initialize and attach */
     478    ppp_init(sc);
     479    if_attach(ifp);
     480
     481    return 0;
    503482}
    504483
     
    554533{
    555534    struct mbuf *m;
    556     rtems_interrupt_level       level;
    557 
    558     if_down(&sc->sc_if);
    559     sc->sc_if.if_flags &= ~(IFF_UP|IFF_RUNNING);
     535
     536    if_down(sc->sc_ifp);
     537    sc->sc_ifp->if_flags &= ~IFF_UP;
     538    sc->sc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
    560539    sc->sc_devp = NULL;
    561540    sc->sc_xfer = 0;
    562541
    563     rtems_interrupt_disable(level);
    564542    if ( sc->sc_m != NULL ) {
    565543        m_freem(sc->sc_m);
     
    573551    }
    574552    do {
    575       IF_DEQUEUE(&sc->sc_freeq, m);
     553      m = if_ppp_dequeue(&sc->sc_freeq);
    576554      if (m != NULL) {
    577555        m_freem(m);
     
    579557    } while ( m != NULL );
    580558    do {
    581       IF_DEQUEUE(&sc->sc_rawq, m);
     559      m = if_ppp_dequeue(&sc->sc_rawq);
    582560      if (m != NULL) {
    583561        m_freem(m);
    584562      }
    585563    } while ( m != NULL );
    586     rtems_interrupt_enable(level);
    587564
    588565    for (;;) {
     
    851828{
    852829    /*struct proc *p = curproc;*/       /* XXX */
    853     register struct ppp_softc *sc = &ppp_softc[ifp->if_unit];
     830    register struct ppp_softc *sc = ifp->if_softc;
    854831    register struct ifaddr *ifa = (struct ifaddr *)data;
    855832    register struct ifreq *ifr = (struct ifreq *)data;
     
    862839    switch (cmd) {
    863840    case SIOCSIFFLAGS:
    864         if ((ifp->if_flags & IFF_RUNNING) == 0)
     841        if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
    865842            ifp->if_flags &= ~IFF_UP;
    866843        break;
     
    877854
    878855    case SIOCSIFMTU:
    879         sc->sc_if.if_mtu = ifr->ifr_mtu;
     856        sc->sc_ifp->if_mtu = ifr->ifr_mtu;
    880857        break;
    881858
    882859    case SIOCGIFMTU:
    883         ifr->ifr_mtu = sc->sc_if.if_mtu;
     860        ifr->ifr_mtu = sc->sc_ifp->if_mtu;
    884861        break;
    885862
     
    899876            break;
    900877        }
    901         break;
    902 
    903     case SIO_RTEMS_SHOW_STATS:
    904         printf("              MRU:%-8u",   sc->sc_mru);
    905         printf("   Bytes received:%-8u",   sc->sc_stats.ppp_ibytes);
    906         printf(" Packets received:%-8u",   sc->sc_stats.ppp_ipackets);
    907         printf("   Receive errors:%-8u\n", sc->sc_stats.ppp_ierrors);
    908         printf("       Bytes sent:%-8u",   sc->sc_stats.ppp_obytes);
    909         printf("     Packets sent:%-8u",   sc->sc_stats.ppp_opackets);
    910         printf("  Transmit errors:%-8u\n", sc->sc_stats.ppp_oerrors);
    911878        break;
    912879
     
    953920int
    954921pppoutput(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst,
    955     struct rtentry *rtp)
     922    struct route *rtp)
    956923{
    957     register struct ppp_softc *sc = &ppp_softc[ifp->if_unit];
     924    register struct ppp_softc *sc = ifp->if_softc;
    958925    int protocol, address, control;
    959926    u_char *cp;
    960927    int s, error;
    961928    struct ip *ip;
    962     struct ifqueue *ifq;
     929    struct ifaltq *ifq;
    963930    enum NPmode mode;
    964931    int len;
    965932    struct mbuf *m;
    966933
    967     if (sc->sc_devp == NULL || (ifp->if_flags & IFF_RUNNING) == 0
     934    if (sc->sc_devp == NULL || (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0
    968935        || ((ifp->if_flags & IFF_UP) == 0 && dst->sa_family != AF_UNSPEC)) {
    969936        error = ENETDOWN;       /* sort of */
     
    10961063    } else {
    10971064        ifq = (m0->m_flags & M_HIGHPRI)? &sc->sc_fastq: &ifp->if_snd;
    1098         if (IF_QFULL(ifq) && dst->sa_family != AF_UNSPEC) {
    1099             IF_DROP(ifq);
     1065        if (_IF_QFULL(ifq) && dst->sa_family != AF_UNSPEC) {
     1066            IFQ_INC_DROPS(ifq);
    11001067            splx(s);
    1101             sc->sc_if.if_oerrors++;
     1068            sc->sc_ifp->if_oerrors++;
    11021069            sc->sc_stats.ppp_oerrors++;
    11031070            error = ENOBUFS;
     
    11281095{
    11291096    struct mbuf *m, **mpp;
    1130     struct ifqueue *ifq;
     1097    struct ifaltq *ifq;
    11311098    enum NPmode mode;
    11321099
     
    11471114            *mpp = m->m_nextpkt;
    11481115            m->m_nextpkt = NULL;
    1149             ifq = (m->m_flags & M_HIGHPRI)? &sc->sc_fastq: &sc->sc_if.if_snd;
    1150             if (IF_QFULL(ifq)) {
    1151                 IF_DROP(ifq);
    1152                 sc->sc_if.if_oerrors++;
     1116            ifq = (m->m_flags & M_HIGHPRI)? &sc->sc_fastq: &sc->sc_ifp->if_snd;
     1117            if (_IF_QFULL(ifq)) {
     1118                IFQ_INC_DROPS(ifq);
     1119                sc->sc_ifp->if_oerrors++;
    11531120                sc->sc_stats.ppp_oerrors++;
    11541121            } else
     
    11901157     * normal queue.
    11911158     */
    1192     rtems_bsdnet_semaphore_obtain();
    11931159    IF_DEQUEUE(&sc->sc_fastq, m);
    11941160    if (m == NULL)
    1195         IF_DEQUEUE(&sc->sc_if.if_snd, m);
    1196     rtems_bsdnet_semaphore_release();
     1161        IF_DEQUEUE(&sc->sc_ifp->if_snd, m);
    11971162
    11981163    if (m == NULL)
     
    12671232            slen += mp->m_len;
    12681233        clen = (*sc->sc_xcomp->compress)
    1269             (sc->sc_xc_state, &mcomp, m, slen, sc->sc_if.if_mtu + PPP_HDRLEN);
     1234            (sc->sc_xc_state, &mcomp, m, slen, sc->sc_ifp->if_mtu + PPP_HDRLEN);
    12701235        if (mcomp != NULL) {
    12711236            if (sc->sc_flags & SC_CCP_UP) {
     
    14301395{
    14311396    struct mbuf  *mf = (struct mbuf *)0;
    1432     struct ifnet *ifp = &sc->sc_if;
     1397    struct ifnet *ifp = sc->sc_ifp;
    14331398    struct ifqueue *inq;
    14341399    int s, ilen, proto, rv;
     
    16811646        m->m_data += PPP_HDRLEN;
    16821647        m->m_len -= PPP_HDRLEN;
    1683         schednetisr(NETISR_IP);
    1684         inq = &ipintrq;
     1648        netisr_dispatch(NETISR_IP, m);
    16851649        break;
    16861650#endif
     
    16921656        inq = &sc->sc_inq;
    16931657        rv = 1;
    1694         break;
    1695     }
    1696 
    1697     /*
    1698      * Put the packet on the appropriate input queue.
    1699      */
    1700     s = splimp();
    1701     if (IF_QFULL(inq)) {
    1702         IF_DROP(inq);
     1658
     1659        /*
     1660         * Put the packet on the appropriate input queue.
     1661         */
     1662        s = splimp();
     1663        if (_IF_QFULL(inq)) {
     1664            IFQ_INC_DROPS(inq);
     1665            splx(s);
     1666            if (sc->sc_flags & SC_DEBUG)
     1667                printf("ppp%d: input queue full\n", ppp_unit(sc));
     1668            ifp->if_iqdrops++;
     1669            goto bad;
     1670        }
     1671        IF_ENQUEUE(inq, m);
    17031672        splx(s);
    1704         if (sc->sc_flags & SC_DEBUG)
    1705             printf("ppp%d: input queue full\n", ppp_unit(sc));
    1706         ifp->if_iqdrops++;
    1707         goto bad;
    1708     }
    1709     IF_ENQUEUE(inq, m);
    1710     splx(s);
     1673
     1674        break;
     1675    }
    17111676
    17121677    ifp->if_ipackets++;
     
    17231688 bad:
    17241689    m_freem(m);
    1725     sc->sc_if.if_ierrors++;
     1690    sc->sc_ifp->if_ierrors++;
    17261691    sc->sc_stats.ppp_ierrors++;
    17271692    return mf;
     
    17631728}
    17641729
     1730static int ppp_probe(device_t dev)
     1731{
     1732    int unit = device_get_unit(dev);
     1733    int error;
     1734
     1735    if (unit < NPPP) {
     1736        error = BUS_PROBE_DEFAULT;
     1737    } else {
     1738        error = ENXIO;
     1739    }
     1740
     1741    return error;
     1742}
     1743
     1744static device_method_t ppp_methods[] = {
     1745    /* Device interface */
     1746    DEVMETHOD(device_probe, ppp_probe),
     1747    DEVMETHOD(device_attach, ppp_attach),
     1748
     1749    DEVMETHOD_END
     1750};
     1751
     1752static driver_t ppp_nexus_driver = {
     1753    "ppp",
     1754    ppp_methods,
     1755    0,
     1756    NULL,
     1757    0,
     1758    NULL
     1759};
     1760
     1761static devclass_t ppp_devclass;
     1762
     1763DRIVER_MODULE(ppp, nexus, ppp_nexus_driver, ppp_devclass, 0, 0);
     1764MODULE_DEPEND(ppp, nexus, 1, 1, 1);
     1765
    17651766#endif  /* NPPP > 0 */
  • rtemsbsd/sys/net/if_pppvar.h

    r70fa95a r573b4cd6  
    7070 */
    7171struct ppp_softc {
    72         struct  ifnet sc_if;            /* network-visible interface */
     72        device_t sc_dev;
     73        struct mtx sc_mtx;
     74        struct  ifnet *sc_ifp;          /* network-visible interface */
    7375        u_int   sc_flags;               /* control/status bits; see if_ppp.h */
    7476        void    *sc_devp;               /* pointer to device-dep structure */
     
    7880        short   sc_mru;                 /* max receive unit */
    7981        pid_t   sc_xfer;                /* used in transferring unit */
    80         struct  ifqueue sc_rawq;        /* received packets */
     82        struct  ifqueue sc_rawq;                /* received packets */
    8183        struct  ifqueue sc_inq;         /* queue of input packets for daemon */
    82         struct  ifqueue sc_fastq;       /* interactive output packet q */
     84        struct  ifaltq sc_fastq;        /* interactive output packet q */
    8385        struct  mbuf *sc_npqueue;       /* output packets not to be sent yet */
    8486        struct  mbuf **sc_npqtail;      /* ptr to last next ptr in npqueue */
     
    131133void    pppdealloc(struct ppp_softc *sc);
    132134int     pppoutput(struct ifnet *, struct mbuf *,
    133                        struct sockaddr *, struct rtentry *);
     135                       struct sockaddr *, struct route *);
    134136int     pppioctl(struct ppp_softc *sc, ioctl_command_t cmd, caddr_t data,
    135137                      int flag, struct proc *p);
     
    154156#define SC_TX_PENDING   0x0010
    155157
     158/*
     159 * Special interface queue functions to exchange mbufs between task and
     160 * interrupt context via pppinput() and pppstart().
     161 */
     162
     163static inline void
     164if_ppp_enqueue(struct ifqueue *ifq, struct mbuf *m)
     165{
     166        rtems_interrupt_level level;
     167
     168        rtems_interrupt_disable(level);
     169        _IF_ENQUEUE(ifq, m);
     170        rtems_interrupt_enable(level);
     171}
     172
     173static inline struct mbuf *
     174if_ppp_dequeue(struct ifqueue *ifq)
     175{
     176        struct mbuf *m;
     177        rtems_interrupt_level level;
     178
     179        rtems_interrupt_disable(level);
     180        _IF_DEQUEUE(ifq, m);
     181        rtems_interrupt_enable(level);
     182
     183        return m;
     184}
     185
    156186#ifdef __cplusplus
    157187}
  • rtemsbsd/sys/net/ppp_tty.c

    r70fa95a r573b4cd6  
     1#include <machine/rtems-bsd-kernel-space.h>
     2
    13/*
    24 * ppp_tty.c - Point-to-Point Protocol (PPP) driver for asynchronous
     
    7981#endif
    8082
    81 #include "opt_ppp.h"            /* XXX for ppp_defs.h */
     83#include <rtems/bsd/local/opt_ppp.h>            /* XXX for ppp_defs.h */
    8284
    8385#if NPPP > 0
    8486
    85 #include <sys/param.h>
     87#include <rtems/bsd/sys/param.h>
    8688#include <sys/systm.h>
    8789#include <sys/proc.h>
     
    227229   
    228230    /* preallocate mbufs for free queue */
    229     rtems_bsdnet_semaphore_obtain();
    230231    for (i=0; i<NUM_MBUFQ; i++) {
    231232      pppallocmbuf(sc, &m);
     
    236237      else {
    237238        /* enqueue mbuf for later use */
    238         IF_ENQUEUE(&sc->sc_freeq, m);
     239        if_ppp_enqueue(&sc->sc_freeq, m);
    239240      }
    240241      m = (struct mbuf *)0;
    241242    }
    242     rtems_bsdnet_semaphore_release();
    243243
    244244    /* initialize values */
    245     sc->sc_if.if_flags |= IFF_RUNNING;
    246     sc->sc_if.if_baudrate =
     245    sc->sc_ifp->if_drv_flags |= IFF_DRV_RUNNING;
     246    sc->sc_ifp->if_baudrate =
    247247        rtems_termios_baud_to_number(tty->termios.c_cflag & CBAUD);
    248248
     
    268268        tty->t_sc = NULL;
    269269        if (tty == (struct rtems_termios_tty *)sc->sc_devp) {
    270             rtems_bsdnet_semaphore_obtain();
    271270            pppasyncrelinq(sc);
    272271            pppdealloc(sc);
    273             rtems_bsdnet_semaphore_release();
    274272        }
    275273    }
     
    329327
    330328    /* Get the packet from the input queue */
    331     rtems_bsdnet_semaphore_obtain();
    332329    IF_DEQUEUE(&sc->sc_inq, m0);
    333330
     
    348345    /* free mbuf chain */
    349346    m_freem(m0);
    350     rtems_bsdnet_semaphore_release();
    351347
    352348    /* update return values */
     
    381377    struct mbuf                 **mp;
    382378
    383     rtems_bsdnet_semaphore_obtain();
    384379    for (mp = &m0; maximum; mp = &m->m_next) {
    385380        MGET(m, M_WAIT, MT_DATA);
     
    411406    m0->m_len  -= PPP_HDRLEN;
    412407
    413     n = pppoutput(&sc->sc_if, m0, &dst, (struct rtentry *)0);
    414     rtems_bsdnet_semaphore_release();
     408    n = pppoutput(sc->sc_ifp, m0, &dst, NULL);
    415409
    416410    return ( n );
     
    471465
    472466    default:
    473         rtems_bsdnet_semaphore_obtain();
    474467        error = pppioctl(sc, cmd, data, 0, NULL);
    475         rtems_bsdnet_semaphore_release();
    476468    }
    477469    return error;
     
    747739    if (sc->sc_m == NULL) {
    748740        rtems_event_send(sc->sc_rxtask, RX_EMPTY);
    749         IF_DEQUEUE(&sc->sc_freeq, sc->sc_m);
     741        sc->sc_m = if_ppp_dequeue(&sc->sc_freeq);
    750742        if ( sc->sc_m == NULL ) {
    751743          return 0;
     
    778770            if ((sc->sc_flags & (SC_FLUSH | SC_ESCAPED)) == 0){
    779771                /* bad fcs error */
    780                 sc->sc_if.if_ierrors++;
     772                sc->sc_ifp->if_ierrors++;
    781773                sc->sc_stats.ppp_ierrors++;
    782774            } else
     
    788780            if (ilen) {
    789781                /* too short error */
    790                 sc->sc_if.if_ierrors++;
     782                sc->sc_ifp->if_ierrors++;
    791783                sc->sc_stats.ppp_ierrors++;
    792784                sc->sc_flags |= SC_PKTLOST;
     
    809801          sc->sc_flags &= ~SC_PKTLOST;
    810802        }
    811         IF_ENQUEUE(&sc->sc_rawq, m);
     803        if_ppp_enqueue(&sc->sc_rawq, m);
    812804
    813805        /* setup next mbuf chain */
    814         IF_DEQUEUE(&sc->sc_freeq, sc->sc_m);
     806        sc->sc_m = if_ppp_dequeue(&sc->sc_freeq);
    815807
    816808        /* send rx packet event */
     
    883875        if (m->m_next == NULL) {
    884876          /* get next available mbuf for the chain */
    885           IF_DEQUEUE(&sc->sc_freeq, m->m_next);
     877          m->m_next = if_ppp_dequeue(&sc->sc_freeq);
    886878          if (m->m_next == NULL) {
    887879            /* too few mbufs */
     
    907899 flush:
    908900    if (!(sc->sc_flags & SC_FLUSH)) {
    909         sc->sc_if.if_ierrors++;
     901        sc->sc_ifp->if_ierrors++;
    910902        sc->sc_stats.ppp_ierrors++;
    911903        sc->sc_flags |= SC_FLUSH;
Note: See TracChangeset for help on using the changeset viewer.