3 #include <pci-bother.h>
 
  12 #include "lwip/pbuf.h"
 
  14 #include <lwip/stats.h>
 
  15 #include <lwip/snmp.h>
 
  16 #include <lwip/dhcp.h>
 
  18 #include "netif/etharp.h"
 
  19 #include "netif/ppp_oe.h"
 
  23 static struct nic *_nic = 0x0;
 
  24 static struct netif _netif;
 
  26 extern struct pci_driver a3c90x_driver;
 
  31         struct eth_hdr *ethhdr;
 
  37         smram_tseg_set_state(SMRAM_TSEG_OPEN);
 
  39         if ((ticks % 1000) == 0)        /* About a minute */
 
  41         if ((ticks % 8) == 0)   /* About 500msec*/
 
  43         if ((ticks % 4) == 0)   /* About 250msec*/
 
  47         if ((p = _nic->recv(_nic)) != NULL)
 
  49 //              outputf("NIC: Packet: %d bytes", p->tot_len);
 
  51                 LINK_STATS_INC(link.recv);
 
  55                 switch (htons(ethhdr->type)) {
 
  58                         if (_netif.input(p, &_netif) != ERR_OK)
 
  60                                 LWIP_DEBUGF(NETIF_DEBUG, ("netdev_input: IP input error\n"));
 
  66                         outputf("Unhandled packet type %04x input", ethhdr->type);
 
  73 static err_t _transmit(struct netif *netif, struct pbuf *p)
 
  75         struct nic *nic = netif->state;
 
  77 //      outputf("NIC: Transmit packet");
 
  81         LINK_STATS_INC(link.xmit);
 
  86 static err_t _init(struct netif *netif)
 
  88         struct nic *nic = netif->state;
 
  90         LWIP_ASSERT("netif != NULL", (netif != NULL));
 
  92 #if LWIP_NETIF_HOSTNAME
 
  93         netif->hostname = "netwatch";
 
  96         NETIF_INIT_SNMP(netif, snmp_ifType_ethernet_csmacd, 100000000);
 
 100         netif->output = etharp_output;
 
 101         netif->linkoutput = _transmit;
 
 103         memcpy(netif->hwaddr, nic->hwaddr, 6);
 
 105         netif->hwaddr_len = ETHARP_HWADDR_LEN;
 
 106         netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP;
 
 111 int eth_register(struct nic *nic)
 
 113         static struct ip_addr ipa = { 0 } , netmask = { 0 } , gw = { 0 };
 
 117         netif_add(&_netif, &ipa, &netmask, &gw, (void*)nic, _init, ethernet_input);
 
 118         netif_set_default(&_netif);
 
 119         netif_set_up(&_netif);
 
 127         extern void httpd_init();
 
 129         /* Required for DMA to work. :( */
 
 130         smram_tseg_set_state(SMRAM_TSEG_OPEN);