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;
 
  30         unsigned char pkt[1600];
 
  33         struct eth_hdr *ethhdr;
 
  40         smram_tseg_set_state(SMRAM_TSEG_OPEN);
 
  42         if ((ticks % 1000) == 0)        /* About a minute */
 
  44         if ((ticks % 8) == 0)   /* About 500msec*/
 
  46         if ((ticks % 4) == 0)   /* About 250msec*/
 
  50         if (_nic->poll(_nic, 0))
 
  55                 len = _nic->packetlen;
 
  57                 outputf("NIC: Packet: %d bytes", len);
 
  59                 p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL);
 
  62                         outputf("NIC: out of memory for packet?");
 
  63                         LINK_STATS_INC(link.memerr);
 
  64                         LINK_STATS_INC(link.drop);
 
  68                 for(q = p; q != NULL; q = q->next)
 
  70                         memcpy(q->payload, pkt+pos, q->len);
 
  74                 LINK_STATS_INC(link.recv);
 
  78                 switch (htons(ethhdr->type)) {
 
  81                         if (_netif.input(p, &_netif) != ERR_OK)
 
  83                                 LWIP_DEBUGF(NETIF_DEBUG, ("netdev_input: IP input error\n"));
 
  89                         outputf("Unhandled packet type %04x input", ethhdr->type);
 
  96 static err_t _transmit(struct netif *netif, struct pbuf *p)
 
  98         struct nic *nic = netif->state;
 
 100         unsigned char pkt[1600];
 
 101         unsigned int len = 0;
 
 103         for(q = p; q != NULL; q = q->next)
 
 105                 memcpy(pkt + len, q->payload, q->len);
 
 109         outputf("NIC: Transmit packet: %d bytes", len);
 
 111         nic->transmit(len, pkt);
 
 113         LINK_STATS_INC(link.xmit);
 
 118 static err_t _init(struct netif *netif)
 
 120         struct nic *nic = netif->state;
 
 122         LWIP_ASSERT("netif != NULL", (netif != NULL));
 
 124 #if LWIP_NETIF_HOSTNAME
 
 125         netif->hostname = "netwatch";
 
 128         NETIF_INIT_SNMP(netif, snmp_ifType_ethernet_csmacd, 100000000);
 
 130         netif->name[0] = 'e';
 
 131         netif->name[1] = 'n';
 
 132         netif->output = etharp_output;
 
 133         netif->linkoutput = _transmit;
 
 135         memcpy(netif->hwaddr, nic->hwaddr, 6);
 
 137         netif->hwaddr_len = ETHARP_HWADDR_LEN;
 
 138         netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP;
 
 143 int eth_register(struct nic *nic)
 
 145         static struct ip_addr ipa = { 0 } , netmask = { 0 } , gw = { 0 };
 
 149         netif_add(&_netif, &ipa, &netmask, &gw, (void*)nic, _init, ethernet_input);
 
 150         netif_set_default(&_netif);
 
 151         netif_set_up(&_netif);
 
 159         extern void httpd_init();
 
 161         /* Required for DMA to work. :( */
 
 162         smram_tseg_set_state(SMRAM_TSEG_OPEN);