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;
28 void eth_recv(struct nic *nic, struct pbuf *p)
30 struct eth_hdr *ethhdr;
32 LINK_STATS_INC(link.recv);
36 switch (htons(ethhdr->type)) {
39 if (_netif.input(p, &_netif) != ERR_OK)
41 LWIP_DEBUGF(NETIF_DEBUG, ("netdev_input: IP input error\n"));
47 outputf("Unhandled packet type %04x input", ethhdr->type);
56 int i = 15; /* Don't process more than 15 packets at a time; we don't want the host to get TOO badly slowed down... */
61 smram_tseg_set_state(SMRAM_TSEG_OPEN);
63 if ((ticks % 1000) == 0) /* About a minute */
65 if ((ticks % 8) == 0) /* About 500msec*/
67 if ((ticks % 4) == 0) /* About 250msec*/
73 int n = _nic->recv(_nic);
80 static err_t _transmit(struct netif *netif, struct pbuf *p)
82 struct nic *nic = netif->state;
84 // outputf("NIC: Transmit packet");
86 nic->transmit(nic, p);
88 LINK_STATS_INC(link.xmit);
93 static err_t _init(struct netif *netif)
95 struct nic *nic = netif->state;
97 LWIP_ASSERT("netif != NULL", (netif != NULL));
99 #if LWIP_NETIF_HOSTNAME
100 netif->hostname = "netwatch";
103 NETIF_INIT_SNMP(netif, snmp_ifType_ethernet_csmacd, 100000000);
105 netif->name[0] = 'e';
106 netif->name[1] = 'n';
107 netif->output = etharp_output;
108 netif->linkoutput = _transmit;
110 memcpy(netif->hwaddr, nic->hwaddr, 6);
112 netif->hwaddr_len = ETHARP_HWADDR_LEN;
113 netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP;
118 int eth_register(struct nic *nic)
120 static struct ip_addr ipa = { 0 } , netmask = { 0 } , gw = { 0 };
124 netif_add(&_netif, &ipa, &netmask, &gw, (void*)nic, _init, ethernet_input);
125 netif_set_default(&_netif);
126 netif_set_up(&_netif);
134 extern void httpd_init();
136 /* Required for DMA to work. :( */
137 smram_tseg_set_state(SMRAM_TSEG_OPEN);