source: SVN/cambria/redboot/packages/io/eth/current/include/eth_drv.h @ 1

Last change on this file since 1 was 1, checked in by Tim Harvey, 2 years ago

restored latest version of files from server backup

Signed-off-by: Tim Harvey <tharvey@…>

File size: 7.9 KB
Line 
1//==========================================================================
2//
3//      include/cyg/io/eth/eth_drv.h
4//
5//      High level networking driver interfaces
6//
7//==========================================================================
8//####ECOSGPLCOPYRIGHTBEGIN####
9// -------------------------------------------
10// This file is part of eCos, the Embedded Configurable Operating System.
11// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
12//
13// eCos is free software; you can redistribute it and/or modify it under
14// the terms of the GNU General Public License as published by the Free
15// Software Foundation; either version 2 or (at your option) any later version.
16//
17// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18// WARRANTY; without even the implied warranty of MERCHANTABILITY or
19// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
20// for more details.
21//
22// You should have received a copy of the GNU General Public License along
23// with eCos; if not, write to the Free Software Foundation, Inc.,
24// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25//
26// As a special exception, if other files instantiate templates or use macros
27// or inline functions from this file, or you compile this file and link it
28// with other works to produce a work based on this file, this file does not
29// by itself cause the resulting work to be covered by the GNU General Public
30// License. However the source code for this file must still be made available
31// in accordance with section (3) of the GNU General Public License.
32//
33// This exception does not invalidate any other reasons why a work based on
34// this file might be covered by the GNU General Public License.
35//
36// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
37// at http://sources.redhat.com/ecos/ecos-license/
38// -------------------------------------------
39//####ECOSGPLCOPYRIGHTEND####
40//==========================================================================
41//#####DESCRIPTIONBEGIN####
42//
43// Author(s):    gthomas
44// Contributors: gthomas
45// Date:         2000-01-10
46// Purpose:     
47// Description:  High level networking driver interfaces
48//             
49//
50//####DESCRIPTIONEND####
51//
52//==========================================================================
53
54// Ethernet driver structure
55
56#ifndef _ETH_DRV_H_
57#define _ETH_DRV_H_
58
59#include <pkgconf/system.h>
60#include <pkgconf/io_eth_drivers.h>
61
62#ifdef CYGPKG_NET
63#include <sys/param.h>
64#include <sys/socket.h>
65
66#include <net/if.h>
67
68#ifdef INET
69#include <netinet/in.h>
70#include <netinet/in_systm.h>
71#include <netinet/in_var.h>
72#include <netinet/ip.h>
73#include <netinet/if_ether.h>
74#endif
75
76#ifndef NBPFILTER
77#define NBPFILTER 0
78#endif
79
80#if NBPFILTER > 0
81#include <net/bpf.h>
82#include <net/bpfdesc.h>
83#endif
84
85#else // !CYGPKG_NET
86#include <cyg/hal/drv_api.h>
87#endif
88#ifdef CYGPKG_NET_LWIP
89#include "lwip/netif.h"
90#endif
91
92struct eth_drv_sg {
93    CYG_ADDRESS  buf;
94    CYG_ADDRWORD len;
95};
96
97#define MAX_ETH_DRV_SG CYGNUM_IO_ETH_DRIVERS_SG_LIST_SIZE
98
99struct eth_drv_sc;
100
101struct eth_drv_funs {
102    // Logical driver - initialization
103    void (*init)(struct eth_drv_sc *sc, 
104                 unsigned char *enaddr);
105    // Logical driver - incoming packet notifier
106    void (*recv)(struct eth_drv_sc *sc, 
107                 int total_len);
108    // Logical driver - outgoing packet notifier
109    void (*tx_done)(struct eth_drv_sc *sc, 
110                    CYG_ADDRESS key, 
111                    int status);
112};
113
114struct eth_hwr_funs {
115    // Initialize hardware (including startup)
116    void (*start)(struct eth_drv_sc *sc,
117                  unsigned char *enaddr,
118                  int flags);
119    // Shut down hardware
120    void (*stop)(struct eth_drv_sc *sc);
121    // Device control (ioctl pass-thru)
122    int  (*control)(struct eth_drv_sc *sc,
123                    unsigned long key,
124                    void *data,
125                    int   data_length);
126    // Query - can a packet be sent?
127    int  (*can_send)(struct eth_drv_sc *sc);
128    // Send a packet of data
129    void (*send)(struct eth_drv_sc *sc,
130                 struct eth_drv_sg *sg_list,
131                 int sg_len,
132                 int total_len,
133                 unsigned long key);
134    // Receive [unload] a packet of data
135    void (*recv)(struct eth_drv_sc *sc,
136                 struct eth_drv_sg *sg_list,
137                 int sg_len);
138    // Deliver data to/from device from/to stack memory space
139    // (moves lots of memcpy()s out of DSRs into thread)
140    void (*deliver)(struct eth_drv_sc *sc);
141    // Poll for interrupts/device service
142    void (*poll)(struct eth_drv_sc *sc);
143    // Get interrupt information from hardware driver
144    int (*int_vector)(struct eth_drv_sc *sc);
145    // Logical driver interface
146    struct eth_drv_funs *eth_drv, *eth_drv_old;
147};
148
149#ifdef CYGPKG_IO_ETH_DRIVERS_STAND_ALONE
150struct arpcom {
151    unsigned char esa[6];
152};
153#endif
154
155#ifdef CYGPKG_NET_LWIP
156struct arpcom {
157    struct netif ac_if;
158};
159#endif
160
161struct eth_drv_sc {
162    struct eth_hwr_funs *funs;
163    void                *driver_private;
164    const char          *dev_name;
165    int                  state;
166    struct arpcom        sc_arpcom; /* ethernet common */
167};
168
169#define ETH_DRV_SC(sc,priv,name,start,stop,control,can_send,send,recv,deliver,poll,int_vector) \
170static void start(struct eth_drv_sc *sc, unsigned char *enaddr, int flags); \
171static void stop(struct eth_drv_sc *sc); \
172static int  control(struct eth_drv_sc *sc, unsigned long key, void *data, int data_length); \
173static int  can_send(struct eth_drv_sc *sc); \
174static void send(struct eth_drv_sc *sc, struct eth_drv_sg *sg_list, int sg_len, int total, unsigned long key); \
175static void recv(struct eth_drv_sc *sc, struct eth_drv_sg *sg_list, int sg_len); \
176static void deliver(struct eth_drv_sc *sc); \
177static void poll(struct eth_drv_sc *sc); \
178static int  int_vector(struct eth_drv_sc *sc); \
179static struct eth_hwr_funs sc##_funs = {        \
180    start,                                      \
181    stop,                                       \
182    control,                                    \
183    can_send,                                   \
184    send,                                       \
185    recv,                                       \
186    deliver,                                    \
187    poll,                                       \
188    int_vector,                                 \
189    &eth_drv_funs,                              \
190    (struct eth_drv_funs *)0 };                 \
191struct eth_drv_sc sc = {&sc##_funs, priv, name};
192
193#define ETH_DRV_STATE_ACTIVE   0x0001
194#define ETH_DRV_NEEDS_DELIVERY 0x0002
195#define ETH_DRV_STATE_DEBUG    0x1000
196
197// Register this as your DSR within your driver: it will cause your deliver
198// routine to be called from the network thread.  The "data" parameter
199// *must* be your own "struct eth_drv_sc *sc" pointer.
200extern void eth_drv_dsr(cyg_vector_t vector,
201                        cyg_ucount32 count,
202                        cyg_addrword_t data);
203
204extern struct eth_drv_funs eth_drv_funs;
205
206#ifdef CYGPKG_IO_PCMCIA
207#ifdef CYGPKG_NET
208#include <cyg/io/eth/netdev.h>
209cyg_netdevtab_entry_t *eth_drv_netdev(char *name);
210#endif
211#endif // CYGPKG_IO_PCMCIA
212
213// Control 'key's
214#define ETH_DRV_SET_MAC_ADDRESS 0x0100
215
216#ifdef CYGPKG_NET
217#define ETH_DRV_GET_IF_STATS_UD 0x0101
218#define ETH_DRV_GET_IF_STATS    0x0102
219#include <cyg/io/eth/eth_drv_stats.h> // The struct * for these ops.
220#endif
221
222#ifndef ETHER_ADDR_LEN
223#define ETHER_ADDR_LEN 6
224#endif
225
226#define ETH_DRV_SET_MC_LIST     0x0110   // Set multicast list
227#define ETH_DRV_SET_MC_ALL      0x0111   // Set multicast all mode
228#define ETH_DRV_MAX_MC 8
229struct eth_drv_mc_list {
230    int len;
231    unsigned char addrs[ETH_DRV_MAX_MC][ETHER_ADDR_LEN];
232};
233
234#ifndef CYGPKG_NET
235extern void eth_drv_buffers_init(void);
236extern int  eth_drv_read(char *eth_hdr, char *buf, int len);
237extern void eth_drv_write(char *eth_hdr, char *buf, int len);
238extern int  eth_drv_int_vector(void);
239extern void eth_drv_stop(void);
240extern unsigned char __local_enet_addr[];
241extern struct eth_drv_sc *__local_enet_sc;
242#endif
243
244#endif // _ETH_DRV_H_
Note: See TracBrowser for help on using the repository browser.