Changeset 457b4fc in rtems-libbsd


Ignore:
Timestamp:
09/12/18 13:15:12 (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
5, 5-freebsd-12, 6-freebsd-12, master
Children:
d101ed8
Parents:
860d833
git-author:
Sebastian Huber <sebastian.huber@…> (09/12/18 13:15:12)
git-committer:
Sebastian Huber <sebastian.huber@…> (09/21/18 08:29:43)
Message:

if_ffec_mpc8xx: Port driver to libbsd

Update #3523.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libbsd.py

    r860d833 r457b4fc  
    314314                'sys/dev/dw_mmc/dw_mmc.c',
    315315                'sys/dev/ffec/if_ffec_mcf548x.c',
     316                'sys/dev/ffec/if_ffec_mpc8xx.c',
    316317                'sys/dev/input/touchscreen/tsc_lpc32xx.c',
    317318                'sys/dev/smc/if_smc_nexus.c',
  • rtemsbsd/include/bsp/nexus-devices.h

    r860d833 r457b4fc  
    176176#endif /* QORIQ_CHIP_IS_T_VARIANT(QORIQ_CHIP_VARIANT) */
    177177
     178#elif defined(LIBBSP_POWERPC_TQM8XX_BSP_H)
     179
     180RTEMS_BSD_DEFINE_NEXUS_DEVICE(fec, 0, 0, NULL);
     181
    178182#endif
    179183
  • rtemsbsd/sys/dev/ffec/if_ffec_mpc8xx.c

    r860d833 r457b4fc  
    5252
    5353#include <bsp.h>
     54
     55#ifdef LIBBSP_POWERPC_TQM8XX_BSP_H
     56
    5457#include <stdio.h>
    55 #include <errno.h>
    56 #include <rtems/error.h>
    57 #include <rtems/rtems_bsdnet.h>
    58 #include <rtems/rtems_mii_ioctl.h>
    5958
    6059#include <sys/param.h>
     60#include <sys/types.h>
    6161#include <sys/mbuf.h>
     62#include <sys/malloc.h>
     63#include <sys/kernel.h>
     64#include <sys/module.h>
    6265#include <sys/socket.h>
    6366#include <sys/sockio.h>
    6467
     68#include <sys/bus.h>
     69#include <machine/bus.h>
     70
    6571#include <net/if.h>
    66 
    67 #include <netinet/in.h>
    68 #include <netinet/if_ether.h>
     72#include <net/ethernet.h>
     73#include <net/if_arp.h>
     74#include <net/if_dl.h>
     75#include <net/if_media.h>
     76#include <net/if_types.h>
     77#include <net/if_var.h>
     78
    6979#include <bsp/irq.h>
    70 
    71 #include <sys/types.h>
    72 #include <sys/socket.h>
     80#include <rtems/rtems_mii_ioctl.h>
     81#include <rtems/bsd/bsd.h>
     82#include <errno.h>
     83
     84/* FIXME */
     85rtems_id
     86rtems_bsdnet_newproc (char *name, int stacksize, void(*entry)(void *), void *arg);
     87#define SIO_RTEMS_SHOW_STATS _IO('i', 250)
    7388
    7489/*
     
    117132 */
    118133struct m8xx_fec_enet_struct {
    119   struct arpcom           arpcom;
     134  device_t                dev;
     135  struct ifnet            *ifp;
     136  struct mtx              mtx;
    120137  struct mbuf             **rxMbuf;
    121138  struct mbuf             **txMbuf;
    122   int                     acceptBroadcast;
    123139  int                     rxBdCount;
    124140  int                     txBdCount;
     
    126142  int                     txBdTail;
    127143  int                     txBdActiveCount;
     144  struct callout          watchdogCallout;
    128145  m8xxBufferDescriptor_t  *rxBdBase;
    129146  m8xxBufferDescriptor_t  *txBdBase;
    130147  rtems_id                rxDaemonTid;
    131148  rtems_id                txDaemonTid;
     149  int                     if_flags;
    132150
    133151  /*
     
    159177  unsigned long   txRawWait;
    160178};
    161 static struct m8xx_fec_enet_struct enet_driver[NIFACES];
     179
     180int fec_mode_adapt (struct ifnet *ifp);
     181
     182#define FEC_LOCK(sc) mtx_lock(&(sc)->mtx)
     183
     184#define FEC_UNLOCK(sc) mtx_unlock(&(sc)->mtx)
     185
     186#define FEC_EVENT RTEMS_EVENT_0
     187
     188static void fec_send_event(rtems_id task, rtems_event_set out)
     189{
     190  rtems_event_send(task, out);
     191}
     192
     193static void fec_wait_for_event(struct m8xx_fec_enet_struct *sc,
     194                               rtems_event_set in)
     195{
     196  rtems_event_set out;
     197
     198  FEC_UNLOCK(sc);
     199  rtems_event_receive(in, RTEMS_EVENT_ANY | RTEMS_WAIT, RTEMS_NO_TIMEOUT,
     200                      &out);
     201  FEC_LOCK(sc);
     202}
    162203
    163204/* declare ioctl function for internal use */
     
    325366 * FEC interrupt handler
    326367 */
    327 static void m8xx_fec_interrupt_handler (void *unused)
    328 {
     368static void m8xx_fec_interrupt_handler (void *arg)
     369{
     370  struct m8xx_fec_enet_struct *sc = arg;
     371
    329372  /*
    330373   * Frame received?
     
    332375  if (m8xx.fec.ievent & M8xx_FEC_IEVENT_RFINT) {
    333376    m8xx.fec.ievent = M8xx_FEC_IEVENT_RFINT;
    334     enet_driver[0].rxInterrupts++;
    335     rtems_bsdnet_event_send (enet_driver[0].rxDaemonTid, INTERRUPT_EVENT);
     377    sc->rxInterrupts++;
     378    fec_send_event (sc->rxDaemonTid, INTERRUPT_EVENT);
    336379  }
    337380
     
    341384  if (m8xx.fec.ievent & M8xx_FEC_IEVENT_TFINT) {
    342385    m8xx.fec.ievent = M8xx_FEC_IEVENT_TFINT;
    343     enet_driver[0].txInterrupts++;
    344     rtems_bsdnet_event_send (enet_driver[0].txDaemonTid, INTERRUPT_EVENT);
    345   }
    346 }
    347 
    348 /*
    349  * Please organize FEC controller code better by moving code from
    350  * m860_fec_initialize_hardware to m8xx_fec_ethernet_on
    351  */
    352 static void m8xx_fec_ethernet_on(const rtems_irq_connect_data* ptr){};
    353 static void m8xx_fec_ethernet_off(const rtems_irq_connect_data* ptr){};
    354 static int m8xx_fec_ethernet_isOn (const rtems_irq_connect_data* ptr)
    355 {
    356   return 1;
    357 }
    358 
    359 static rtems_irq_connect_data ethernetFECIrqData = {
    360   BSP_FAST_ETHERNET_CTRL,
    361   m8xx_fec_interrupt_handler,
    362   NULL,
    363   m8xx_fec_ethernet_on,
    364   m8xx_fec_ethernet_off,
    365   m8xx_fec_ethernet_isOn
    366 };
     386    sc->txInterrupts++;
     387    fec_send_event (sc->txDaemonTid, INTERRUPT_EVENT);
     388  }
     389}
    367390
    368391static void
     
    371394  int i;
    372395  unsigned char *hwaddr;
     396  rtems_status_code status;
    373397
    374398  /*
     
    410434   * Set our physical address
    411435   */
    412   hwaddr = sc->arpcom.ac_enaddr;
     436  hwaddr = IF_LLADDR(sc->ifp);
    413437
    414438  m8xx.fec.addr_low = (hwaddr[0] << 24) | (hwaddr[1] << 16) |
     
    431455   */
    432456  sc->rxMbuf = malloc (sc->rxBdCount * sizeof *sc->rxMbuf,
    433                        M_MBUF, M_NOWAIT);
     457                       M_TEMP, M_NOWAIT);
    434458  sc->txMbuf = malloc (sc->txBdCount * sizeof *sc->txMbuf,
    435                        M_MBUF, M_NOWAIT);
     459                       M_TEMP, M_NOWAIT);
    436460  if (!sc->rxMbuf || !sc->txMbuf)
    437461    rtems_panic ("No memory for mbuf pointers");
     
    503527   * Set up interrupts
    504528   */
    505   if (!BSP_install_rtems_irq_handler (&ethernetFECIrqData))
     529  status = rtems_interrupt_handler_install(BSP_FAST_ETHERNET_CTRL, "FEC",
     530                                           RTEMS_INTERRUPT_UNIQUE,
     531                                           m8xx_fec_interrupt_handler, sc);
     532  if (status != RTEMS_SUCCESSFUL)
    506533    rtems_panic ("Can't attach M860 FEC interrupt handler\n");
    507534
     
    510537{
    511538  struct m8xx_fec_enet_struct *sc = (struct m8xx_fec_enet_struct *)arg;
    512   struct ifnet *ifp = &sc->arpcom.ac_if;
     539  struct ifnet *ifp = sc->ifp;
    513540  struct mbuf *m;
    514541  uint16_t   status;
     
    516543  int rxBdIndex;
    517544
     545  FEC_LOCK(sc);
     546
    518547  /*
    519548   * Allocate space for incoming packets and start reception
     
    521550  for (rxBdIndex = 0 ; ;) {
    522551    rxBd = sc->rxBdBase + rxBdIndex;
    523     MGETHDR (m, M_WAIT, MT_DATA);
    524     MCLGET (m, M_WAIT);
     552    m = m_getcl(M_WAITOK, MT_DATA, M_PKTHDR);
    525553    m->m_pkthdr.rcvif = ifp;
    526554    sc->rxMbuf[rxBdIndex] = m;
     
    558586       */
    559587      while ((status = rxBd->status) & M8xx_BD_EMPTY) {
    560         rtems_event_set events;
    561 
    562588        /*
    563589         * Unmask RXF (Full frame received) event
     
    565591        m8xx.fec.ievent |= M8xx_FEC_IEVENT_RFINT;
    566592
    567         rtems_bsdnet_event_receive (INTERRUPT_EVENT,
    568                                     RTEMS_WAIT|RTEMS_EVENT_ANY,
    569                                     RTEMS_NO_TIMEOUT,
    570                                     &events);
     593        fec_wait_for_event (sc, INTERRUPT_EVENT);
    571594      }
    572595    }
     
    580603       * FIXME: Packet filtering hook could be done here.
    581604       */
    582       struct ether_header *eh;
    583605
    584606      /*
     
    588610
    589611      m = sc->rxMbuf[rxBdIndex];
    590       m->m_len = m->m_pkthdr.len = rxBd->length -
    591         sizeof(uint32_t) -
    592         sizeof(struct ether_header);
    593       eh = mtod (m, struct ether_header *);
    594       m->m_data += sizeof(struct ether_header);
    595       ether_input (ifp, eh, m);
     612      m->m_len = m->m_pkthdr.len = rxBd->length - sizeof(uint32_t);
     613      FEC_UNLOCK(sc);
     614      (*sc->ifp->if_input)(sc->ifp, m);
     615      FEC_LOCK(sc);
    596616
    597617      /*
    598618       * Allocate a new mbuf
    599619       */
    600       MGETHDR (m, M_WAIT, MT_DATA);
    601       MCLGET (m, M_WAIT);
     620      m = m_getcl(M_WAITOK, MT_DATA, M_PKTHDR);
    602621      m->m_pkthdr.rcvif = ifp;
    603622      sc->rxMbuf[rxBdIndex] = m;
     
    652671  int i;
    653672  int nRetired;
    654   struct mbuf *m, *n;
     673  struct mbuf *m;
    655674
    656675  i = sc->txBdTail;
     
    674693                    M8xx_BD_UNDERRUN)) {
    675694        if (status & M8xx_BD_LATE_COLLISION)
    676           enet_driver[0].txLateCollision++;
     695          sc->txLateCollision++;
    677696        if (status & M8xx_BD_RETRY_LIMIT)
    678           enet_driver[0].txRetryLimit++;
     697          sc->txRetryLimit++;
    679698        if (status & M8xx_BD_UNDERRUN)
    680           enet_driver[0].txUnderrun++;
     699          sc->txUnderrun++;
    681700
    682701      }
    683702      if (status & M8xx_BD_DEFER)
    684         enet_driver[0].txDeferred++;
     703        sc->txDeferred++;
    685704      if (status & M8xx_BD_HEARTBEAT)
    686         enet_driver[0].txHeartbeat++;
     705        sc->txHeartbeat++;
    687706      if (status & M8xx_BD_CARRIER_LOST)
    688         enet_driver[0].txLostCarrier++;
     707        sc->txLostCarrier++;
    689708    }
    690709    nRetired++;
     
    698717        nRetired--;
    699718        m = sc->txMbuf[sc->txBdTail];
    700         MFREE (m, n);
     719        m_free(m);
    701720        if (++sc->txBdTail == sc->txBdCount)
    702721          sc->txBdTail = 0;
     
    708727}
    709728
    710 static void fec_sendpacket (struct ifnet *ifp, struct mbuf *m)
    711 {
    712   struct m8xx_fec_enet_struct *sc = ifp->if_softc;
     729static void fec_sendpacket (struct m8xx_fec_enet_struct *sc, struct mbuf *m)
     730{
    713731  volatile m8xxBufferDescriptor_t *firstTxBd, *txBd;
    714732  /*  struct mbuf *l = NULL; */
     
    754772      m8xx_fec_Enet_retire_tx_bd (sc);
    755773      while ((sc->txBdActiveCount + nAdded) == sc->txBdCount) {
    756         rtems_event_set events;
    757 
    758774        /*
    759775         * Unmask TXB (buffer transmitted) and
     
    761777         */
    762778        m8xx.fec.ievent |= M8xx_FEC_IEVENT_TFINT;
    763         rtems_bsdnet_event_receive (INTERRUPT_EVENT,
    764                                     RTEMS_WAIT|RTEMS_EVENT_ANY,
    765                                     RTEMS_NO_TIMEOUT,
    766                                     &events);
     779        fec_wait_for_event (sc, INTERRUPT_EVENT);
    767780        m8xx_fec_Enet_retire_tx_bd (sc);
    768781      }
     
    808821       * Just toss empty mbufs
    809822       */
    810       struct mbuf *n;
    811       MFREE (m, n);
    812       m = n;
     823      m = m_free (m);
    813824      /*
    814825        if (l != NULL)
     
    838849{
    839850  struct m8xx_fec_enet_struct *sc = (struct m8xx_fec_enet_struct *)arg;
    840   struct ifnet *ifp = &sc->arpcom.ac_if;
     851  struct ifnet *ifp = sc->ifp;
    841852  struct mbuf *m;
    842   rtems_event_set events;
     853
     854  FEC_LOCK(sc);
    843855
    844856  for (;;) {
     
    846858     * Wait for packet
    847859     */
    848     rtems_bsdnet_event_receive (START_TRANSMIT_EVENT,
    849                                 RTEMS_EVENT_ANY | RTEMS_WAIT,
    850                                 RTEMS_NO_TIMEOUT,
    851                                 &events);
     860    fec_wait_for_event (sc, START_TRANSMIT_EVENT);
    852861
    853862    /*
     
    861870      if (!m)
    862871        break;
    863       fec_sendpacket (ifp, m);
     872      fec_sendpacket (sc, m);
    864873    }
    865     ifp->if_flags &= ~IFF_OACTIVE;
    866   }
    867 }
     874    ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
     875  }
     876}
     877
     878static void fec_watchdog (void *arg)
     879{
     880  struct m8xx_fec_enet_struct *sc = arg;
     881
     882  fec_mode_adapt(sc->ifp);
     883  callout_reset(&sc->watchdogCallout, FEC_WATCHDOG_TIMEOUT * hz,
     884                fec_watchdog, sc);
     885}
     886
    868887static void fec_init (void *arg)
    869888{
    870889  struct m8xx_fec_enet_struct *sc = arg;
    871   struct ifnet *ifp = &sc->arpcom.ac_if;
     890  struct ifnet *ifp = sc->ifp;
    872891
    873892  if (sc->txDaemonTid == 0) {
     
    902921   * init timer so the "watchdog function gets called periodically
    903922   */
    904   ifp->if_timer    = 1;
     923  callout_reset(&sc->watchdogCallout, hz, fec_watchdog, sc);
    905924
    906925  /*
    907926   * Tell the world that we're running.
    908927   */
    909   ifp->if_flags |= IFF_RUNNING;
     928  ifp->if_drv_flags |= IFF_DRV_RUNNING;
    910929
    911930  /*
     
    923942  struct m8xx_fec_enet_struct *sc = ifp->if_softc;
    924943
    925   rtems_bsdnet_event_send (sc->txDaemonTid, START_TRANSMIT_EVENT);
    926   ifp->if_flags |= IFF_OACTIVE;
    927 }
    928 
    929 static void fec_stop (struct m8xx_fec_enet_struct *sc)
    930 {
    931   struct ifnet *ifp = &sc->arpcom.ac_if;
    932 
    933   ifp->if_flags &= ~IFF_RUNNING;
     944  FEC_LOCK(sc);
     945  ifp->if_drv_flags |= IFF_DRV_OACTIVE;
     946  FEC_UNLOCK(sc);
     947  fec_send_event (sc->txDaemonTid, START_TRANSMIT_EVENT);
     948}
     949
     950static void fec_stop (struct ifnet *ifp)
     951{
     952  ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
    934953
    935954  /*
     
    944963static void fec_enet_stats (struct m8xx_fec_enet_struct *sc)
    945964{
    946   int media;
    947   int result;
    948   /*
    949    * fetch/print media info
    950    */
    951   media = IFM_MAKEWORD(0,0,0,sc->phy_default); /* fetch from default phy */
    952 
    953   result = fec_ioctl(&(sc->arpcom.ac_if),
    954                      SIOCGIFMEDIA,
    955                      (caddr_t)&media);
    956   if (result == 0) {
    957     rtems_ifmedia2str(media,NULL,0);
    958     printf ("\n");
    959   }
    960 
    961965  printf ("      Rx Interrupts:%-8lu", sc->rxInterrupts);
    962966  printf ("       Not First:%-8lu", sc->rxNotFirst);
     
    993997    rtems_mii_ioctl (&(sc->mdio_info),sc,command,(void *)data);
    994998    break;
    995   case SIOCGIFADDR:
    996   case SIOCSIFADDR:
    997     ether_ioctl (ifp, command, data);
    998     break;
    999999
    10001000  case SIOCSIFFLAGS:
    1001     switch (ifp->if_flags & (IFF_UP | IFF_RUNNING)) {
    1002     case IFF_RUNNING:
    1003       fec_stop (sc);
    1004       break;
    1005 
    1006     case IFF_UP:
    1007       fec_init (sc);
    1008       break;
    1009 
    1010     case IFF_UP | IFF_RUNNING:
    1011       fec_stop (sc);
    1012       fec_init (sc);
    1013       break;
    1014 
    1015     default:
    1016       break;
     1001    FEC_LOCK(sc);
     1002    if (ifp->if_flags & IFF_UP) {
     1003      if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
     1004        fec_init (sc);
     1005      }
     1006    } else {
     1007      if (ifp->if_drv_flags & IFF_DRV_RUNNING)
     1008        fec_stop (ifp);
    10171009    }
     1010    sc->if_flags = ifp->if_flags;
     1011    FEC_UNLOCK(sc);
    10181012    break;
    10191013
     
    10261020     */
    10271021  default:
    1028     error = EINVAL;
     1022    error = ether_ioctl(ifp, command, data);
    10291023    break;
    10301024  }
     
    11191113}
    11201114
    1121 /*=========================================================================*\
    1122 | Function:                                                                 |
    1123 \*-------------------------------------------------------------------------*/
    1124 static void fec_watchdog
    1125 (
    1126 /*-------------------------------------------------------------------------*\
    1127 | Purpose:                                                                  |
    1128 |   periodically poll the PHY. if mode has changed,                         |
    1129 |  then adjust the FEC settings                                             |
    1130 +---------------------------------------------------------------------------+
    1131 | Input Parameters:                                                         |
    1132 \*-------------------------------------------------------------------------*/
    1133  struct ifnet *ifp
    1134 )
    1135 /*-------------------------------------------------------------------------*\
    1136 | Return Value:                                                             |
    1137 |    1, if success                                                          |
    1138 \*=========================================================================*/
    1139 {
    1140   fec_mode_adapt(ifp);
    1141   ifp->if_timer    = FEC_WATCHDOG_TIMEOUT;
    1142 }
    1143 
    1144 int rtems_fec_driver_attach (struct rtems_bsdnet_ifconfig *config)
     1115static int fec_attach (device_t dev)
    11451116{
    11461117  struct m8xx_fec_enet_struct *sc;
    11471118  struct ifnet *ifp;
    1148   int mtu;
    1149   int unitNumber;
    1150   char *unitName;
    1151   static const uint8_t maczero[] ={0,0,0,0,0,0};
    1152 
    1153   /*
    1154    * Parse driver name
    1155    */
    1156   if ((unitNumber = rtems_bsdnet_parse_driver_name (config, &unitName)) < 0)
    1157     return 0;
    1158 
    1159   /*
    1160    * Is driver free?
    1161    */
    1162   if ((unitNumber <= 0) || (unitNumber > NIFACES)) {
    1163     printk ("Bad FEC unit number.\n");
    1164     return 0;
    1165   }
    1166   sc = &enet_driver[unitNumber - 1];
    1167   ifp = &sc->arpcom.ac_if;
    1168   if (ifp->if_softc != NULL) {
    1169     printk ("Driver already in use.\n");
    1170     return 0;
    1171   }
    1172 
    1173   /*
    1174    * Process options
    1175    */
    1176   if (config->hardware_address) {
    1177     memcpy (sc->arpcom.ac_enaddr, config->hardware_address, ETHER_ADDR_LEN);
    1178   }
    1179 #ifdef BSP_HAS_TQMMON
    1180   else if(0 != memcmp(maczero,TQM_BD_INFO.eth_addr,ETHER_ADDR_LEN)) {
    1181     memcpy (sc->arpcom.ac_enaddr, TQM_BD_INFO.eth_addr, ETHER_ADDR_LEN);
    1182   }
    1183 #endif
    1184   else {
    1185     /* FIXME to read the enaddr from NVRAM */
    1186   }
    1187   if (config->mtu)
    1188     mtu = config->mtu;
    1189   else
    1190     mtu = ETHERMTU;
    1191   if (config->rbuf_count)
    1192     sc->rxBdCount = config->rbuf_count;
    1193   else
    1194     sc->rxBdCount = RX_BUF_COUNT;
    1195   if (config->xbuf_count)
    1196     sc->txBdCount = config->xbuf_count;
    1197   else
    1198     sc->txBdCount = TX_BUF_COUNT * TX_BD_PER_BUF;
    1199   sc->acceptBroadcast = !config->ignore_broadcast;
     1119  int unitNumber = device_get_unit(dev);
     1120  uint8_t hwaddr[ETHER_ADDR_LEN];
     1121
     1122  /*
     1123   * enable FEC functionality at hardware pins*
     1124   * PD[3-15] are FEC pins
     1125   */
     1126  m8xx.pdpar |= 0x1fff;
     1127  m8xx.pddir |= 0x1fff;
     1128
     1129  rtems_bsd_get_mac_address(device_get_name(dev), device_get_unit(dev),
     1130                            hwaddr);
     1131
     1132  sc = device_get_softc(dev);
     1133  sc->dev = dev;
     1134  sc->ifp = ifp = if_alloc(IFT_ETHER);
     1135
     1136  mtx_init(&sc->mtx, device_get_nameunit(sc->dev), MTX_NETWORK_LOCK, MTX_DEF);
     1137  callout_init_mtx(&sc->watchdogCallout, &sc->mtx, 0);
     1138
     1139  sc->rxBdCount = RX_BUF_COUNT;
     1140  sc->txBdCount = TX_BUF_COUNT * TX_BD_PER_BUF;
    12001141
    12011142  /*
     
    12141155   */
    12151156  ifp->if_softc = sc;
    1216   ifp->if_unit = unitNumber;
    1217   ifp->if_name = unitName;
    1218   ifp->if_mtu = mtu;
     1157  if_initname(ifp, device_get_name(dev), device_get_unit(dev));
    12191158  ifp->if_init = fec_init;
    12201159  ifp->if_ioctl = fec_ioctl;
    12211160  ifp->if_start = m8xx_fec_enet_start;
    1222   ifp->if_output = ether_output;
    1223   ifp->if_watchdog =  fec_watchdog; /* XXX: timer is set in "init" */
    1224   ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX;
    1225   if (ifp->if_snd.ifq_maxlen == 0)
    1226     ifp->if_snd.ifq_maxlen = ifqmaxlen;
     1161  ifp->if_flags = IFF_BROADCAST | IFF_MULTICAST | IFF_SIMPLEX;
     1162  IFQ_SET_MAXLEN(&ifp->if_snd, sc->txBdCount - 1);
     1163  ifp->if_snd.ifq_drv_maxlen = sc->txBdCount - 1;
     1164  IFQ_SET_READY(&ifp->if_snd);
    12271165
    12281166  /*
    12291167   * Attach the interface
    12301168   */
    1231   if_attach (ifp);
    1232   ether_ifattach (ifp);
    1233   return 1;
     1169  ether_ifattach (ifp, hwaddr);
     1170  return 0;
    12341171};
    12351172
    1236 int rtems_fec_enet_driver_attach(struct rtems_bsdnet_ifconfig *config,
    1237                                  int attaching)
    1238 {
    1239   /*
    1240    * enable FEC functionality at hardware pins*
    1241    * PD[3-15] are FEC pins
    1242    */
    1243   if (attaching) {
    1244     m8xx.pdpar |= 0x1fff;
    1245     m8xx.pddir |= 0x1fff;
    1246   }
    1247   return rtems_fec_driver_attach(config);
    1248 }
     1173static int
     1174fec_probe(device_t dev)
     1175{
     1176        int unit = device_get_unit(dev);
     1177        int error;
     1178
     1179        if (unit >= 0 && unit < NIFACES) {
     1180                error = BUS_PROBE_DEFAULT;
     1181        } else {
     1182                error = ENXIO;
     1183        }
     1184
     1185        return (error);
     1186}
     1187
     1188static device_method_t fec_methods[] = {
     1189        /* Device interface */
     1190        DEVMETHOD(device_probe,         fec_probe),
     1191        DEVMETHOD(device_attach,        fec_attach),
     1192
     1193        DEVMETHOD_END
     1194};
     1195
     1196static driver_t fec_nexus_driver = {
     1197        "fec",
     1198        fec_methods,
     1199        sizeof(struct m8xx_fec_enet_struct)
     1200};
     1201
     1202static devclass_t fec_devclass;
     1203DRIVER_MODULE(fec, nexus, fec_nexus_driver, fec_devclass, 0, 0);
     1204MODULE_DEPEND(fec, nexus, 1, 1, 1);
     1205MODULE_DEPEND(fec, ether, 1, 1, 1);
     1206
     1207#endif /* LIBBSP_POWERPC_TQM8XX_BSP_H */
Note: See TracChangeset for help on using the changeset viewer.