DPRINT was improved - masks support, more information in system.h; debug command...
[ZeXOS.git] / kernel / include / net / eth.h
blob5bbbf1789d7a0dfea6a50c4d1cc5d8f464a5f02c
1 /*
2 * ZeX/OS
3 * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com)
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/>.
19 #ifndef _ETH_H
20 #define _ETH_H
22 #include <net/net.h>
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;
34 unsigned short len;
35 char *buf;
36 } netdev_buffer_queue_t;
39 typedef struct netdev_t {
40 mac_addr_t dev_addr;
41 unsigned long base_addr;
42 void *priv;
43 unsigned char irq;
44 char *name;
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 */
55 int queue_rx_cnt;
56 int queue_tx_cnt;
58 /* queue for received/transfered data */
59 netdev_buffer_queue_t queue_rx_list;
60 netdev_buffer_queue_t queue_tx_list;
61 } netdev_t;
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);
70 #endif