1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
/*
* Copyright (c) 1997, 1998 The University of Utah and the Flux Group.
*
* This file is part of the OSKit Linux Glue Libraries, which are free
* software, also known as "open source;" you can redistribute them and/or
* modify them under the terms of the GNU General Public License (GPL),
* version 2, as published by the Free Software Foundation (FSF).
*
* The OSKit is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GPL for more details. You should have
* received a copy of the GPL along with the OSKit; see the file COPYING. If
* not, write to the FSF, 59 Temple Place #330, Boston, MA 02111-1307, USA.
*/
/*
* Linux net emulation definitions.
*/
#ifndef _LINUX_NET_H_
#define _LINUX_NET_H_
#include <linux/netdevice.h>
#include <oskit/io/bufio.h>
#include <oskit/io/netio.h>
#include "glue.h"
/*
* The automatically generated glue file for each network driver
* statically declares an instance of this structure,
* using the driver() macro
* defined in the appropriate network type-specific header
* (e.g., ethernet.h).
*/
struct net_driver {
struct driver_struct ds;
oskit_devinfo_t dev_info;
struct oskit_netdev_ops *dev_ops;
const char *basename;
oskit_guid_t *dev_iids;
int dev_niids;
int (*probe)(struct device *dev);
};
/*
* Each network device we find is represented by one of these structures,
* which is attached one-to-one to each Linux 'struct device'.
*
* Since we don't want to modify Linux's header files,
* and don't want Linux header files to have to cross-include ours,
* we can't simply add the contents of this struct to the device struct.
* It turns out we can't just wrap a device struct in our own struct either,
* because although it appears that under the "standard" practice
* we (the glue code) get to allocate the device struct and could extend it,
* some Linux net drivers play fast and loose and allocate their own.
* So instead we just maintain our own separate struct.
*
* Conveniently, Linux's device struct contains a pointer called 'my_alias'
* to a structure called 'net_alias', which in Linux is used
* only by the higher-level network load balancing code;
* we've commandeered this struct name for our own purposes
* and use the 'my_alias' pointer in the device struct
* as a back-pointer to our own device structure.
* Wonder of wonders, the name is even semi-appropriate.
*/
struct net_alias {
struct device *ldev; /* Linux net device struct */
struct net_driver *drv; /* Driver struct for this device */
oskit_netdev_t devi; /* Exported device node interface */
/*
* The following fields represent the per-open device state;
* they are simply part of the ether_device structure
* because we can fundamentally have only one opener at a time.
* (Packet demultiplexing must be done at a higher level.)
* A network device is "open" when send_ioi_count > 0.
*/
oskit_netio_t send_ioi; /* Exported net I/O intf for send */
unsigned send_ioi_count; /* Reference count for send_ioi */
oskit_netio_t *recv_ioi; /* Imported net I/O intf for recv */
};
/*
* These offsets are used to find the ether_device
* given a pointer to the exported etheri or send_ioi interfaces.
*/
#define DEVI_OFS ((int)&((struct net_alias*)0)->devi)
#define SEND_IOI_OFS ((int)&((struct net_alias*)0)->send_ioi)
oskit_error_t oskit_linux_net_init(void);
/* Common fdev probe routine for all Linux network drivers */
oskit_error_t oskit_linux_netdev_probe(struct driver_struct *ds);
/* Default implementations for oskit_netdev_t interface methods */
OSKIT_COMDECL_U oskit_linux_netdev_addref(oskit_netdev_t *intf);
OSKIT_COMDECL_U oskit_linux_netdev_release(oskit_netdev_t *intf);
OSKIT_COMDECL oskit_linux_netdev_getinfo(oskit_netdev_t *intf,
oskit_devinfo_t *out_info);
OSKIT_COMDECL oskit_linux_netdev_getdriver(oskit_netdev_t *intf,
oskit_driver_t **out_driver);
OSKIT_COMDECL oskit_linux_netdev_open(oskit_netdev_t *intf, unsigned flags,
oskit_netio_t *recv_net_io,
oskit_netio_t **out_send_net_io);
#endif /* _LINUX_NET_H_ */
|