3 #include <pci-bother.h>
12 #include "lwip/pbuf.h"
14 #include <lwip/stats.h>
15 #include <lwip/snmp.h>
16 #include "netif/etharp.h"
17 #include "netif/ppp_oe.h"
19 static struct nic *_nic = 0x0;
20 static struct netif _netif;
22 extern struct pci_driver a3c90x_driver;
26 unsigned char pkt[1600];
29 struct eth_hdr *ethhdr;
35 smram_tseg_set_state(SMRAM_TSEG_OPEN);
37 if (!_nic->poll(_nic, 0))
43 len = _nic->packetlen;
45 outputf("NIC: Packet: %d bytes", len);
47 p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL);
50 outputf("NIC: out of memory for packet?");
51 LINK_STATS_INC(link.memerr);
52 LINK_STATS_INC(link.drop);
56 for(q = p; q != NULL; q = q->next)
58 memcpy(q->payload, pkt+pos, q->len);
62 LINK_STATS_INC(link.recv);
66 switch (htons(ethhdr->type)) {
69 if (_netif.input(p, &_netif) != ERR_OK)
71 LWIP_DEBUGF(NETIF_DEBUG, ("netdev_input: IP input error\n"));
77 outputf("Unhandled packet type %04x input", ethhdr->type);
83 static err_t _transmit(struct netif *netif, struct pbuf *p)
85 struct nic *nic = netif->state;
87 unsigned char pkt[1600];
90 for(q = p; q != NULL; q = q->next)
92 memcpy(pkt + len, q->payload, q->len);
96 outputf("NIC: Transmit packet: %d bytes", len);
98 nic->transmit(len, pkt);
100 LINK_STATS_INC(link.xmit);
105 static err_t _init(struct netif *netif)
107 struct nic *nic = netif->state;
109 LWIP_ASSERT("netif != NULL", (netif != NULL));
111 #if LWIP_NETIF_HOSTNAME
112 netif->hostname = "netwatch";
115 NETIF_INIT_SNMP(netif, snmp_ifType_ethernet_csmacd, 100000000);
117 netif->name[0] = 'e';
118 netif->name[1] = 'n';
119 netif->output = etharp_output;
120 netif->linkoutput = _transmit;
122 memcpy(netif->hwaddr, nic->hwaddr, 6);
124 netif->hwaddr_len = ETHARP_HWADDR_LEN;
125 netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP;
130 int eth_register(struct nic *nic)
132 static struct ip_addr ipa = { 0x2dba0280 } , netmask = { 0xF0FFFFFF } , gw = { 0x2eba0280 };
136 netif_add(&_netif, &ipa, &netmask, &gw, (void*)nic, _init, ethernet_input);
137 netif_set_default(&_netif);
138 netif_set_up(&_netif);
145 /* Required for DMA to work. :( */
146 smram_tseg_set_state(SMRAM_TSEG_OPEN);
148 pci_probe_driver(a3c90x_driver);