00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
#ifndef _LINUX_NETDEVICE_H
00026
#define _LINUX_NETDEVICE_H
00027
00028
#include <linux/if.h>
00029
#include <linux/if_ether.h>
00030
#include <linux/if_packet.h>
00031
00032
#include <asm/atomic.h>
00033
#include <asm/cache.h>
00034
#include <asm/byteorder.h>
00035
00036
#ifdef __KERNEL__
00037
#include <linux/config.h>
00038
#ifdef CONFIG_NET_PROFILE
00039
#include <net/profile.h>
00040
#endif
00041
00042
struct divert_blk;
00043
struct vlan_group;
00044
struct ethtool_ops;
00045
00046
00047 #define SET_ETHTOOL_OPS(netdev,ops) \
00048
( (netdev)->ethtool_ops = (ops) )
00049
00050 #define HAVE_ALLOC_NETDEV
00051
00052 #define HAVE_FREE_NETDEV
00053
00054 #define NET_XMIT_SUCCESS 0
00055 #define NET_XMIT_DROP 1
00056 #define NET_XMIT_CN 2
00057 #define NET_XMIT_POLICED 3
00058 #define NET_XMIT_BYPASS 4
00059
00060
00061
00062
00063 #define NET_RX_SUCCESS 0
00064 #define NET_RX_DROP 1
00065 #define NET_RX_CN_LOW 2
00066 #define NET_RX_CN_MOD 3
00067 #define NET_RX_CN_HIGH 4
00068 #define NET_RX_BAD 5
00069
00070 #define net_xmit_errno(e) ((e) != NET_XMIT_CN ? -ENOBUFS : 0)
00071
00072
#endif
00073
00074 #define MAX_ADDR_LEN 8
00075
00076
00077
00078
00079
00080
00081
#if !defined(CONFIG_AX25) && !defined(CONFIG_AX25_MODULE) && !defined(CONFIG_TR)
00082 #define LL_MAX_HEADER 32
00083
#else
00084
#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
00085
#define LL_MAX_HEADER 96
00086
#else
00087
#define LL_MAX_HEADER 48
00088
#endif
00089
#endif
00090
00091
#if !defined(CONFIG_NET_IPIP) && \
00092
!defined(CONFIG_IPV6) && !defined(CONFIG_IPV6_MODULE)
00093 #define MAX_HEADER LL_MAX_HEADER
00094
#else
00095
#define MAX_HEADER (LL_MAX_HEADER + 48)
00096
#endif
00097
00098
00099
00100
00101
00102
00103 struct net_device_stats
00104 {
00105 unsigned long rx_packets;
00106 unsigned long tx_packets;
00107 unsigned long rx_bytes;
00108 unsigned long tx_bytes;
00109 unsigned long rx_errors;
00110 unsigned long tx_errors;
00111 unsigned long rx_dropped;
00112 unsigned long tx_dropped;
00113 unsigned long multicast;
00114 unsigned long collisions;
00115
00116
00117 unsigned long rx_length_errors;
00118 unsigned long rx_over_errors;
00119 unsigned long rx_crc_errors;
00120 unsigned long rx_frame_errors;
00121 unsigned long rx_fifo_errors;
00122 unsigned long rx_missed_errors;
00123
00124
00125 unsigned long tx_aborted_errors;
00126 unsigned long tx_carrier_errors;
00127 unsigned long tx_fifo_errors;
00128 unsigned long tx_heartbeat_errors;
00129 unsigned long tx_window_errors;
00130
00131
00132 unsigned long rx_compressed;
00133 unsigned long tx_compressed;
00134 };
00135
00136
00137
00138
enum {
00139
IF_PORT_UNKNOWN = 0,
00140
IF_PORT_10BASE2,
00141
IF_PORT_10BASET,
00142
IF_PORT_AUI,
00143
IF_PORT_100BASET,
00144
IF_PORT_100BASETX,
00145
IF_PORT_100BASEFX
00146 };
00147
00148
#ifdef __KERNEL__
00149
00150
extern const char *
if_port_text[];
00151
00152
#include <linux/cache.h>
00153
#include <linux/skbuff.h>
00154
00155
struct neighbour;
00156
struct neigh_parms;
00157
struct sk_buff;
00158
00159 struct netif_rx_stats
00160 {
00161 unsigned total;
00162 unsigned dropped;
00163 unsigned time_squeeze;
00164 unsigned throttled;
00165 unsigned fastroute_hit;
00166 unsigned fastroute_success;
00167 unsigned fastroute_defer;
00168 unsigned fastroute_deferred_out;
00169 unsigned fastroute_latency_reduction;
00170 unsigned cpu_collision;
00171 }
____cacheline_aligned;
00172
00173
extern struct netif_rx_stats netdev_rx_stat[];
00174
00175
00176
00177
00178
00179
00180 struct dev_mc_list
00181 {
00182 struct dev_mc_list *
next;
00183 __u8
dmi_addr[
MAX_ADDR_LEN];
00184 unsigned char dmi_addrlen;
00185 int dmi_users;
00186 int dmi_gusers;
00187 };
00188
00189 struct hh_cache
00190 {
00191 struct hh_cache *
hh_next;
00192 atomic_t
hh_refcnt;
00193 unsigned short hh_type;
00194
00195
00196
00197 int hh_len;
00198 int (*hh_output)(
struct sk_buff *skb);
00199 rwlock_t
hh_lock;
00200
00201
00202 #define HH_DATA_MOD 16
00203 #define HH_DATA_OFF(__len) \
00204
(HH_DATA_MOD - ((__len) & (HH_DATA_MOD - 1)))
00205 #define HH_DATA_ALIGN(__len) \
00206
(((__len)+(HH_DATA_MOD-1))&~(HH_DATA_MOD - 1))
00207 unsigned long hh_data[
HH_DATA_ALIGN(LL_MAX_HEADER) /
sizeof(
long)];
00208 };
00209
00210
00211
00212
00213
00214
00215 enum netdev_state_t
00216 {
00217
__LINK_STATE_XOFF=0,
00218
__LINK_STATE_START,
00219
__LINK_STATE_PRESENT,
00220
__LINK_STATE_SCHED,
00221
__LINK_STATE_NOCARRIER,
00222
__LINK_STATE_RX_SCHED
00223 };
00224
00225
00226
00227
00228
00229
00230 struct netdev_boot_setup {
00231 char name[IFNAMSIZ];
00232 struct ifmap map;
00233 };
00234 #define NETDEV_BOOT_SETUP_MAX 8
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247 struct net_device
00248 {
00249
00250
00251
00252
00253
00254
00255 char name[IFNAMSIZ];
00256
00257
00258
00259
00260
00261 unsigned long rmem_end;
00262 unsigned long rmem_start;
00263 unsigned long mem_end;
00264 unsigned long mem_start;
00265 unsigned long base_addr;
00266 unsigned int irq;
00267
00268
00269
00270
00271
00272
00273 unsigned char if_port;
00274 unsigned char dma;
00275
00276 unsigned long state;
00277
00278 struct net_device *
next;
00279
00280
00281 int (*init)(
struct net_device *dev);
00282
00283
00284
00285 struct net_device *
next_sched;
00286
00287
00288 int ifindex;
00289 int iflink;
00290
00291
00292
struct net_device_stats* (*get_stats)(
struct net_device *dev);
00293
struct iw_statistics* (*get_wireless_stats)(
struct net_device *dev);
00294
00295
00296
00297 struct iw_handler_def *
wireless_handlers;
00298
00299 struct ethtool_ops *
ethtool_ops;
00300
00301
00302
00303
00304
00305
00306
00307
00308 unsigned long trans_start;
00309 unsigned long last_rx;
00310
00311 unsigned short flags;
00312 unsigned short gflags;
00313 unsigned short priv_flags;
00314 unsigned short unused_alignment_fixer;
00315
00316
00317
00318 unsigned mtu;
00319 unsigned short type;
00320 unsigned short hard_header_len;
00321 void *
priv;
00322
00323 struct net_device *
master;
00324
00325
00326
00327
00328 unsigned char broadcast[
MAX_ADDR_LEN];
00329 unsigned char dev_addr[
MAX_ADDR_LEN];
00330 unsigned char addr_len;
00331
00332 struct dev_mc_list *
mc_list;
00333 int mc_count;
00334 int promiscuity;
00335 int allmulti;
00336
00337 int watchdog_timeo;
00338 struct timer_list watchdog_timer;
00339
00340
00341
00342 void *
atalk_ptr;
00343 void *
ip_ptr;
00344 void *
dn_ptr;
00345 void *
ip6_ptr;
00346 void *
ec_ptr;
00347
00348 struct list_head poll_list;
00349 int quota;
00350 int weight;
00351
00352 struct Qdisc *
qdisc;
00353 struct Qdisc *
qdisc_sleeping;
00354 struct Qdisc *
qdisc_list;
00355 struct Qdisc *
qdisc_ingress;
00356 unsigned long tx_queue_len;
00357
00358
00359 spinlock_t
xmit_lock;
00360
00361
00362
00363 int xmit_lock_owner;
00364
00365 spinlock_t
queue_lock;
00366
00367 atomic_t
refcnt;
00368
00369 int deadbeaf;
00370
00371
00372 int features;
00373 #define NETIF_F_SG 1
00374 #define NETIF_F_IP_CSUM 2
00375 #define NETIF_F_NO_CSUM 4
00376 #define NETIF_F_HW_CSUM 8
00377 #define NETIF_F_DYNALLOC 16
00378 #define NETIF_F_HIGHDMA 32
00379 #define NETIF_F_FRAGLIST 64
00380 #define NETIF_F_HW_VLAN_TX 128
00381 #define NETIF_F_HW_VLAN_RX 256
00382 #define NETIF_F_HW_VLAN_FILTER 512
00383 #define NETIF_F_VLAN_CHALLENGED 1024
00384
00385
00386 void (*uninit)(
struct net_device *dev);
00387
00388 void (*destructor)(
struct net_device *dev);
00389
00390
00391 int (*open)(
struct net_device *dev);
00392 int (*stop)(
struct net_device *dev);
00393 int (*hard_start_xmit) (
struct sk_buff *skb,
00394
struct net_device *dev);
00395 #define HAVE_NETDEV_POLL
00396
int (*poll) (
struct net_device *dev,
int *quota);
00397 int (*hard_header) (
struct sk_buff *skb,
00398
struct net_device *dev,
00399
unsigned short type,
00400
void *daddr,
00401
void *saddr,
00402
unsigned len);
00403 int (*rebuild_header)(
struct sk_buff *skb);
00404 #define HAVE_MULTICAST
00405
void (*set_multicast_list)(
struct net_device *dev);
00406 #define HAVE_SET_MAC_ADDR
00407
int (*set_mac_address)(
struct net_device *dev,
00408
void *addr);
00409 #define HAVE_PRIVATE_IOCTL
00410
int (*do_ioctl)(
struct net_device *dev,
00411
struct ifreq *ifr,
int cmd);
00412 #define HAVE_SET_CONFIG
00413
int (*set_config)(
struct net_device *dev,
00414
struct ifmap *map);
00415 #define HAVE_HEADER_CACHE
00416
int (*hard_header_cache)(
struct neighbour *neigh,
00417
struct hh_cache *hh);
00418 void (*header_cache_update)(
struct hh_cache *hh,
00419
struct net_device *dev,
00420
unsigned char * haddr);
00421 #define HAVE_CHANGE_MTU
00422
int (*change_mtu)(
struct net_device *dev,
int new_mtu);
00423
00424 #define HAVE_TX_TIMEOUT
00425
void (*tx_timeout) (
struct net_device *dev);
00426
00427 void (*vlan_rx_register)(
struct net_device *dev,
00428
struct vlan_group *grp);
00429 void (*vlan_rx_add_vid)(
struct net_device *dev,
00430
unsigned short vid);
00431 void (*vlan_rx_kill_vid)(
struct net_device *dev,
00432
unsigned short vid);
00433
00434 int (*hard_header_parse)(
struct sk_buff *skb,
00435
unsigned char *haddr);
00436 int (*neigh_setup)(
struct net_device *dev,
struct neigh_parms *);
00437 int (*accept_fastpath)(
struct net_device *,
struct dst_entry*);
00438
00439
00440 struct module *
owner;
00441
00442
00443 struct net_bridge_port *
br_port;
00444
00445
#ifdef CONFIG_NET_FASTROUTE
00446
#define NETDEV_FASTROUTE_HMASK 0xF
00447
00448 rwlock_t fastpath_lock;
00449
struct dst_entry *fastpath[NETDEV_FASTROUTE_HMASK+1];
00450
#endif
00451
#ifdef CONFIG_NET_DIVERT
00452
00453
struct divert_blk *divert;
00454
#endif
00455 };
00456
00457
00458 struct packet_type
00459 {
00460 unsigned short type;
00461 struct net_device *
dev;
00462 int (*func) (
struct sk_buff *,
struct net_device *,
00463
struct packet_type *);
00464 void *
data;
00465 struct packet_type *
next;
00466 };
00467
00468
00469
#include <linux/interrupt.h>
00470
#include <linux/notifier.h>
00471
00472
extern struct net_device loopback_dev;
00473
extern struct net_device *
dev_base;
00474
extern rwlock_t
dev_base_lock;
00475
00476
extern int netdev_boot_setup_add(
char *name,
struct ifmap *map);
00477
extern int netdev_boot_setup_check(
struct net_device *dev);
00478
extern struct net_device *
dev_getbyhwaddr(
unsigned short type,
char *hwaddr);
00479
extern void dev_add_pack(
struct packet_type *pt);
00480
extern void dev_remove_pack(
struct packet_type *pt);
00481
extern int dev_get(
const char *name);
00482
extern struct net_device *
dev_get_by_flags(
unsigned short flags,
00483
unsigned short mask);
00484
extern struct net_device *
__dev_get_by_flags(
unsigned short flags,
00485
unsigned short mask);
00486
extern struct net_device *
dev_get_by_name(
const char *name);
00487
extern struct net_device *
__dev_get_by_name(
const char *name);
00488
extern struct net_device *
dev_alloc(
const char *name,
int *err);
00489
extern int dev_alloc_name(
struct net_device *dev,
const char *name);
00490
extern int dev_open(
struct net_device *dev);
00491
extern int dev_close(
struct net_device *dev);
00492
extern int dev_queue_xmit(
struct sk_buff *skb);
00493
extern int register_netdevice(
struct net_device *dev);
00494
extern int unregister_netdevice(
struct net_device *dev);
00495
extern int register_netdevice_notifier(
struct notifier_block *nb);
00496
extern int unregister_netdevice_notifier(
struct notifier_block *nb);
00497
extern int dev_new_index(
void);
00498
extern struct net_device *
dev_get_by_index(
int ifindex);
00499
extern struct net_device *
__dev_get_by_index(
int ifindex);
00500
extern int dev_restart(
struct net_device *dev);
00501
00502 typedef int gifconf_func_t(
struct net_device * dev,
char * bufptr,
int len);
00503
extern int register_gifconf(
unsigned int family,
gifconf_func_t * gifconf);
00504 static inline int unregister_gifconf(
unsigned int family)
00505 {
00506
return register_gifconf(family, 0);
00507 }
00508
00509
00510
00511
00512
00513
00514 struct softnet_data
00515 {
00516 int throttle;
00517 int cng_level;
00518 int avg_blog;
00519 struct sk_buff_head input_pkt_queue;
00520 struct list_head poll_list;
00521 struct net_device *
output_queue;
00522 struct sk_buff *
completion_queue;
00523
00524 struct net_device blog_dev;
00525 }
____cacheline_aligned;
00526
00527
00528
extern struct softnet_data softnet_data[NR_CPUS];
00529
00530 #define HAVE_NETIF_QUEUE
00531
00532 static inline void __netif_schedule(
struct net_device *dev)
00533 {
00534
if (!test_and_set_bit(
__LINK_STATE_SCHED, &dev->
state)) {
00535
unsigned long flags;
00536
int cpu = smp_processor_id();
00537
00538 local_irq_save(flags);
00539 dev->
next_sched =
softnet_data[cpu].
output_queue;
00540
softnet_data[cpu].
output_queue = dev;
00541 cpu_raise_softirq(cpu, NET_TX_SOFTIRQ);
00542 local_irq_restore(flags);
00543 }
00544 }
00545
00546 static inline void netif_schedule(
struct net_device *dev)
00547 {
00548
if (!test_bit(
__LINK_STATE_XOFF, &dev->
state))
00549
__netif_schedule(dev);
00550 }
00551
00552 static inline void netif_start_queue(
struct net_device *dev)
00553 {
00554 clear_bit(
__LINK_STATE_XOFF, &dev->
state);
00555 }
00556
00557 static inline void netif_wake_queue(
struct net_device *dev)
00558 {
00559
if (test_and_clear_bit(
__LINK_STATE_XOFF, &dev->
state))
00560
__netif_schedule(dev);
00561 }
00562
00563 static inline void netif_stop_queue(
struct net_device *dev)
00564 {
00565 set_bit(
__LINK_STATE_XOFF, &dev->
state);
00566 }
00567
00568 static inline int netif_queue_stopped(
struct net_device *dev)
00569 {
00570
return test_bit(
__LINK_STATE_XOFF, &dev->
state);
00571 }
00572
00573 static inline int netif_running(
struct net_device *dev)
00574 {
00575
return test_bit(
__LINK_STATE_START, &dev->
state);
00576 }
00577
00578
00579
00580
00581
00582 static inline void dev_kfree_skb_irq(
struct sk_buff *skb)
00583 {
00584
if (atomic_dec_and_test(&skb->
users)) {
00585
int cpu =smp_processor_id();
00586
unsigned long flags;
00587
00588 local_irq_save(flags);
00589 skb->
next =
softnet_data[cpu].
completion_queue;
00590
softnet_data[cpu].
completion_queue = skb;
00591 cpu_raise_softirq(cpu, NET_TX_SOFTIRQ);
00592 local_irq_restore(flags);
00593 }
00594 }
00595
00596
00597
00598
00599 static inline void dev_kfree_skb_any(
struct sk_buff *skb)
00600 {
00601
if (in_irq())
00602
dev_kfree_skb_irq(skb);
00603
else
00604
dev_kfree_skb(skb);
00605 }
00606
00607 #define HAVE_NETIF_RX 1
00608
extern int netif_rx(
struct sk_buff *skb);
00609 #define HAVE_NETIF_RECEIVE_SKB 1
00610
extern int netif_receive_skb(
struct sk_buff *skb);
00611
extern int dev_ioctl(
unsigned int cmd,
void *);
00612
extern int dev_ethtool(
struct ifreq *);
00613
extern int dev_change_flags(
struct net_device *,
unsigned);
00614
extern void dev_queue_xmit_nit(
struct sk_buff *skb,
struct net_device *dev);
00615
00616
extern void dev_init(
void);
00617
00618
extern int netdev_nit;
00619
00620
00621
00622
00623 static inline int netif_rx_ni(
struct sk_buff *skb)
00624 {
00625
int err =
netif_rx(skb);
00626
if (softirq_pending(smp_processor_id()))
00627 do_softirq();
00628
return err;
00629 }
00630
00631 static inline void dev_init_buffers(
struct net_device *dev)
00632 {
00633
00634 }
00635
00636
extern int netdev_finish_unregister(
struct net_device *dev);
00637
00638 static inline void dev_put(
struct net_device *dev)
00639 {
00640
if (atomic_dec_and_test(&dev->
refcnt))
00641
netdev_finish_unregister(dev);
00642 }
00643
00644 #define __dev_put(dev) atomic_dec(&(dev)->refcnt)
00645 #define dev_hold(dev) atomic_inc(&(dev)->refcnt)
00646
00647
00648
00649
00650
00651
00652 static inline int netif_carrier_ok(
struct net_device *dev)
00653 {
00654
return !test_bit(
__LINK_STATE_NOCARRIER, &dev->
state);
00655 }
00656
00657
extern void __netdev_watchdog_up(
struct net_device *dev);
00658
00659 static inline void netif_carrier_on(
struct net_device *dev)
00660 {
00661 clear_bit(
__LINK_STATE_NOCARRIER, &dev->
state);
00662
if (
netif_running(dev))
00663
__netdev_watchdog_up(dev);
00664 }
00665
00666 static inline void netif_carrier_off(
struct net_device *dev)
00667 {
00668 set_bit(
__LINK_STATE_NOCARRIER, &dev->
state);
00669 }
00670
00671
00672 static inline int netif_device_present(
struct net_device *dev)
00673 {
00674
return test_bit(
__LINK_STATE_PRESENT, &dev->
state);
00675 }
00676
00677 static inline void netif_device_detach(
struct net_device *dev)
00678 {
00679
if (test_and_clear_bit(
__LINK_STATE_PRESENT, &dev->
state) &&
00680
netif_running(dev)) {
00681
netif_stop_queue(dev);
00682 }
00683 }
00684
00685 static inline void netif_device_attach(
struct net_device *dev)
00686 {
00687
if (!test_and_set_bit(
__LINK_STATE_PRESENT, &dev->
state) &&
00688
netif_running(dev)) {
00689
netif_wake_queue(dev);
00690
__netdev_watchdog_up(dev);
00691 }
00692 }
00693
00694
00695
00696
00697 #define HAVE_NETIF_MSG 1
00698
00699
enum {
00700
NETIF_MSG_DRV = 0x0001,
00701
NETIF_MSG_PROBE = 0x0002,
00702
NETIF_MSG_LINK = 0x0004,
00703
NETIF_MSG_TIMER = 0x0008,
00704
NETIF_MSG_IFDOWN = 0x0010,
00705
NETIF_MSG_IFUP = 0x0020,
00706
NETIF_MSG_RX_ERR = 0x0040,
00707
NETIF_MSG_TX_ERR = 0x0080,
00708
NETIF_MSG_TX_QUEUED = 0x0100,
00709
NETIF_MSG_INTR = 0x0200,
00710
NETIF_MSG_TX_DONE = 0x0400,
00711
NETIF_MSG_RX_STATUS = 0x0800,
00712
NETIF_MSG_PKTDATA = 0x1000,
00713
NETIF_MSG_HW = 0x2000,
00714
NETIF_MSG_WOL = 0x4000,
00715 };
00716
00717 #define netif_msg_drv(p) ((p)->msg_enable & NETIF_MSG_DRV)
00718 #define netif_msg_probe(p) ((p)->msg_enable & NETIF_MSG_PROBE)
00719 #define netif_msg_link(p) ((p)->msg_enable & NETIF_MSG_LINK)
00720 #define netif_msg_timer(p) ((p)->msg_enable & NETIF_MSG_TIMER)
00721 #define netif_msg_ifdown(p) ((p)->msg_enable & NETIF_MSG_IFDOWN)
00722 #define netif_msg_ifup(p) ((p)->msg_enable & NETIF_MSG_IFUP)
00723 #define netif_msg_rx_err(p) ((p)->msg_enable & NETIF_MSG_RX_ERR)
00724 #define netif_msg_tx_err(p) ((p)->msg_enable & NETIF_MSG_TX_ERR)
00725 #define netif_msg_tx_queued(p) ((p)->msg_enable & NETIF_MSG_TX_QUEUED)
00726 #define netif_msg_intr(p) ((p)->msg_enable & NETIF_MSG_INTR)
00727 #define netif_msg_tx_done(p) ((p)->msg_enable & NETIF_MSG_TX_DONE)
00728 #define netif_msg_rx_status(p) ((p)->msg_enable & NETIF_MSG_RX_STATUS)
00729 #define netif_msg_pktdata(p) ((p)->msg_enable & NETIF_MSG_PKTDATA)
00730 #define netif_msg_hw(p) ((p)->msg_enable & NETIF_MSG_HW)
00731 #define netif_msg_wol(p) ((p)->msg_enable & NETIF_MSG_WOL)
00732
00733
00734
00735 static inline int netif_rx_schedule_prep(
struct net_device *dev)
00736 {
00737
return netif_running(dev) &&
00738 !test_and_set_bit(
__LINK_STATE_RX_SCHED, &dev->
state);
00739 }
00740
00741
00742
00743
00744
00745 static inline void __netif_rx_schedule(
struct net_device *dev)
00746 {
00747
unsigned long flags;
00748
int cpu = smp_processor_id();
00749
00750 local_irq_save(flags);
00751
dev_hold(dev);
00752 list_add_tail(&dev->
poll_list, &
softnet_data[cpu].
poll_list);
00753
if (dev->
quota < 0)
00754 dev->
quota += dev->
weight;
00755
else
00756 dev->
quota = dev->
weight;
00757 __cpu_raise_softirq(cpu, NET_RX_SOFTIRQ);
00758 local_irq_restore(flags);
00759 }
00760
00761
00762
00763 static inline void netif_rx_schedule(
struct net_device *dev)
00764 {
00765
if (
netif_rx_schedule_prep(dev))
00766
__netif_rx_schedule(dev);
00767 }
00768
00769
00770
00771
00772 static inline int netif_rx_reschedule(
struct net_device *dev,
int undo)
00773 {
00774
if (
netif_rx_schedule_prep(dev)) {
00775
unsigned long flags;
00776
int cpu = smp_processor_id();
00777
00778 dev->
quota += undo;
00779
00780 local_irq_save(flags);
00781 list_add_tail(&dev->
poll_list, &
softnet_data[cpu].
poll_list);
00782 __cpu_raise_softirq(cpu, NET_RX_SOFTIRQ);
00783 local_irq_restore(flags);
00784
return 1;
00785 }
00786
return 0;
00787 }
00788
00789
00790
00791
00792
00793
00794 static inline void netif_rx_complete(
struct net_device *dev)
00795 {
00796
unsigned long flags;
00797
00798 local_irq_save(flags);
00799
if (!test_bit(
__LINK_STATE_RX_SCHED, &dev->
state)) BUG();
00800 list_del(&dev->
poll_list);
00801 smp_mb__before_clear_bit();
00802 clear_bit(
__LINK_STATE_RX_SCHED, &dev->
state);
00803 local_irq_restore(flags);
00804 }
00805
00806 static inline void netif_poll_disable(
struct net_device *dev)
00807 {
00808
while (test_and_set_bit(
__LINK_STATE_RX_SCHED, &dev->
state)) {
00809
00810 current->state = TASK_INTERRUPTIBLE;
00811 schedule_timeout(1);
00812 }
00813 }
00814
00815 static inline void netif_poll_enable(
struct net_device *dev)
00816 {
00817 clear_bit(
__LINK_STATE_RX_SCHED, &dev->
state);
00818 }
00819
00820
00821
00822
00823 static inline void __netif_rx_complete(
struct net_device *dev)
00824 {
00825
if (!test_bit(
__LINK_STATE_RX_SCHED, &dev->
state)) BUG();
00826 list_del(&dev->
poll_list);
00827 smp_mb__before_clear_bit();
00828 clear_bit(
__LINK_STATE_RX_SCHED, &dev->
state);
00829 }
00830
00831 static inline void netif_tx_disable(
struct net_device *dev)
00832 {
00833 spin_lock_bh(&dev->
xmit_lock);
00834
netif_stop_queue(dev);
00835 spin_unlock_bh(&dev->
xmit_lock);
00836 }
00837
00838
00839
00840
extern void ether_setup(
struct net_device *dev);
00841
extern void fddi_setup(
struct net_device *dev);
00842
extern void tr_setup(
struct net_device *dev);
00843
extern void fc_setup(
struct net_device *dev);
00844
extern void fc_freedev(
struct net_device *dev);
00845
00846
extern struct net_device *
alloc_netdev(
int sizeof_priv,
const char *name,
00847
void (*setup)(
struct net_device *));
00848
extern int register_netdev(
struct net_device *dev);
00849
extern void unregister_netdev(
struct net_device *dev);
00850
00851
extern void dev_mc_upload(
struct net_device *dev);
00852
extern int dev_mc_delete(
struct net_device *dev,
void *addr,
int alen,
int all);
00853
extern int dev_mc_add(
struct net_device *dev,
void *addr,
int alen,
int newonly);
00854
extern void dev_mc_discard(
struct net_device *dev);
00855
extern void dev_set_promiscuity(
struct net_device *dev,
int inc);
00856
extern void dev_set_allmulti(
struct net_device *dev,
int inc);
00857
extern void netdev_state_change(
struct net_device *dev);
00858
00859
extern void dev_load(
const char *name);
00860
extern void dev_mcast_init(
void);
00861
extern int netdev_register_fc(
struct net_device *dev,
void (*stimul)(
struct net_device *dev));
00862
extern void netdev_unregister_fc(
int bit);
00863
extern int netdev_max_backlog;
00864
extern int weight_p;
00865
extern unsigned long netdev_fc_xoff;
00866
extern atomic_t
netdev_dropping;
00867
extern int netdev_set_master(
struct net_device *dev,
struct net_device *master);
00868
extern struct sk_buff *
skb_checksum_help(
struct sk_buff *skb);
00869
#ifdef CONFIG_NET_FASTROUTE
00870
extern int netdev_fastroute;
00871
extern int netdev_fastroute_obstacles;
00872
extern void dev_clear_fastroute(
struct net_device *dev);
00873
#endif
00874
00875 static inline void free_netdev(
struct net_device *dev)
00876 {
00877 kfree(dev);
00878 }
00879
00880
#endif
00881
00882
#endif