3 * Ethernet Interface Skeleton
8 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
11 * Redistribution and use in source and binary forms, with or without modification,
12 * are permitted provided that the following conditions are met:
14 * 1. Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright notice,
17 * this list of conditions and the following disclaimer in the documentation
18 * and/or other materials provided with the distribution.
19 * 3. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
25 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
27 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
30 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
33 * This file is part of the lwIP TCP/IP stack.
35 * Author: Adam Dunkels <adam@sics.se>
40 * This file is a skeleton for developing Ethernet network interface
41 * drivers for lwIP. Add code to the low_level functions and do a
42 * search-and-replace for the word "ethernetif" to replace it with
43 * something that better describes your network interface.
46 #include <minix/sysutil.h>
47 #include <minix/netsock.h>
53 #include "lwip/pbuf.h"
55 #include <lwip/stats.h>
56 #include <lwip/snmp.h>
57 #include <netif/etharp.h>
59 #include <net/gen/ether.h>
60 #include <net/gen/eth_io.h>
65 extern endpoint_t lwip_ep
;
67 static err_t
low_level_output(__unused
struct netif
*netif
, struct pbuf
*pbuf
)
71 nic
= (struct nic
*) netif
->state
;
72 assert(&nic
->netif
== netif
);
74 debug_print("device /dev/%s", nic
->name
);
76 if (driver_tx_enqueue(nic
, pbuf
) != OK
)
79 /* if the driver is idle, start transmitting the packet */
80 if (nic
->state
== DRV_IDLE
) {
88 static void low_level_init(struct netif
*netif
)
91 struct nic
* nic
= (struct nic
*) netif
->state
;
95 /* set MAC hardware address length */
96 netif
->hwaddr_len
= ETHARP_HWADDR_LEN
;
98 /* maximum transfer unit */
100 nic
->max_pkt_sz
= ETH_MAX_PACK_SIZE
;
101 nic
->min_pkt_sz
= ETH_MIN_PACK_SIZE
;
103 /* device capabilities */
104 netif
->flags
= NETIF_FLAG_ETHARP
;
106 m
.m_net_netdrv_dl_conf
.mode
= DL_NOMODE
;
107 if (nic
->flags
& NWEO_EN_BROAD
)
108 m
.m_net_netdrv_dl_conf
.mode
|= DL_BROAD_REQ
;
109 if (nic
->flags
& NWEO_EN_MULTI
)
110 m
.m_net_netdrv_dl_conf
.mode
|= DL_MULTI_REQ
;
111 if (nic
->flags
& NWEO_EN_PROMISC
)
112 m
.m_net_netdrv_dl_conf
.mode
|= DL_PROMISC_REQ
;
116 if (asynsend(((struct nic
*)netif
->state
)->drv_ep
, &m
) != OK
)
117 printf("LWIP : ERROR cannot send DL_CONF to driver\n");
121 err_t
ethernetif_init(struct netif
*netif
)
124 * Initialize the snmp variables and counters inside the struct netif.
125 * The last argument should be replaced with your link speed, in units
126 * of bits per second.
127 NETIF_INIT_SNMP(netif, snmp_ifType_ethernet_csmacd, LINK_SPEED_OF_YOUR_NETIF_IN_BPS);
130 netif
->output
= etharp_output
;
131 netif
->linkoutput
= low_level_output
;
133 /* initialize the hardware */
134 low_level_init(netif
);