3 * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #define PROT_TYPE_IPV4 0x0800
25 #define PROT_TYPE_ARP 0x0806
27 #define ETHERNET_HEADER_SIZE (6+6+2)
28 #define ETHERNET_MAX_SIZE (ETHERNET_HEADER_SIZE+1500)
29 #define ETHERNET_MIN_SIZE (ETHERNET_HEADER_SIZE+46)
31 typedef struct netdev_buffer_queue_context
{
32 struct netdev_buffer_queue_context
*next
, *prev
;
36 } netdev_buffer_queue_t
;
39 typedef struct netdev_t
{
41 unsigned long base_addr
;
46 /* main functions, what works with ethernet directly */
47 unsigned (*read
) (char *, unsigned);
48 unsigned (*write
) (char *, unsigned);
50 /* some info about traffic */
51 unsigned long info_rx
;
52 unsigned long info_tx
;
54 /* actual queue count */
58 /* queue for received/transfered data */
59 netdev_buffer_queue_t queue_rx_list
;
60 netdev_buffer_queue_t queue_tx_list
;
64 extern netdev_t
*netdev_create (mac_addr_t addr_mac
, unsigned (*read
) (char *, unsigned), unsigned (*write
) (char *, unsigned), unsigned addr_io
);
65 extern unsigned netdev_rx_add_queue (struct netdev_t
*dev
, char *buffer
, unsigned len
);
66 extern netdev_buffer_queue_t
*netdev_rx_queue (struct netdev_t
*dev
);
67 extern unsigned netdev_rx_queue_flush (struct netdev_t
*dev
, netdev_buffer_queue_t
*queue
);
68 extern int netdev_rx (struct netdev_t
*dev
, char *buf
, unsigned len
);