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#ifndef _LINUX_NETDEVICE_H
26#define _LINUX_NETDEVICE_H
27
28#include <linux/if.h>
29#include <linux/if_ether.h>
30#include <linux/if_packet.h>
31
32#ifdef __KERNEL__
33#include <linux/timer.h>
34#include <linux/delay.h>
35#include <asm/atomic.h>
36#include <asm/cache.h>
37#include <asm/byteorder.h>
38
39#include <linux/device.h>
40#include <linux/percpu.h>
41#include <linux/dmaengine.h>
42#include <linux/workqueue.h>
43
44#include <net/net_namespace.h>
45#include <net/dsa.h>
46
47struct vlan_group;
48struct ethtool_ops;
49struct netpoll_info;
50
51struct wireless_dev;
52
53#define SET_ETHTOOL_OPS(netdev,ops) \
54 ( (netdev)->ethtool_ops = (ops) )
55
56#define HAVE_ALLOC_NETDEV
57
58#define HAVE_FREE_NETDEV
59#define HAVE_NETDEV_PRIV
60
61#define NET_XMIT_SUCCESS 0
62#define NET_XMIT_DROP 1
63#define NET_XMIT_CN 2
64#define NET_XMIT_POLICED 3
65#define NET_XMIT_MASK 0xFFFF
66
67
68#define NET_RX_SUCCESS 0
69#define NET_RX_DROP 1
70#define NET_RX_CN_LOW 2
71#define NET_RX_CN_MOD 3
72#define NET_RX_CN_HIGH 4
73#define NET_RX_BAD 5
74
75
76
77
78#define net_xmit_eval(e) ((e) == NET_XMIT_CN? 0 : (e))
79#define net_xmit_errno(e) ((e) != NET_XMIT_CN ? -ENOBUFS : 0)
80
81#endif
82
83#define MAX_ADDR_LEN 32
84
85
86#define NETDEV_TX_OK 0
87#define NETDEV_TX_BUSY 1
88#define NETDEV_TX_LOCKED -1
89
90#ifdef __KERNEL__
91
92
93
94
95
96
97#if defined(CONFIG_WLAN_80211) || defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
98# if defined(CONFIG_MAC80211_MESH)
99# define LL_MAX_HEADER 128
100# else
101# define LL_MAX_HEADER 96
102# endif
103#elif defined(CONFIG_TR)
104# define LL_MAX_HEADER 48
105#else
106# define LL_MAX_HEADER 32
107#endif
108
109#if !defined(CONFIG_NET_IPIP) && !defined(CONFIG_NET_IPIP_MODULE) && \
110 !defined(CONFIG_NET_IPGRE) && !defined(CONFIG_NET_IPGRE_MODULE) && \
111 !defined(CONFIG_IPV6_SIT) && !defined(CONFIG_IPV6_SIT_MODULE) && \
112 !defined(CONFIG_IPV6_TUNNEL) && !defined(CONFIG_IPV6_TUNNEL_MODULE)
113#define MAX_HEADER LL_MAX_HEADER
114#else
115#define MAX_HEADER (LL_MAX_HEADER + 48)
116#endif
117
118#endif
119
120
121
122
123
124
125struct net_device_stats
126{
127 unsigned long rx_packets;
128 unsigned long tx_packets;
129 unsigned long rx_bytes;
130 unsigned long tx_bytes;
131 unsigned long rx_errors;
132 unsigned long tx_errors;
133 unsigned long rx_dropped;
134 unsigned long tx_dropped;
135 unsigned long multicast;
136 unsigned long collisions;
137
138
139 unsigned long rx_length_errors;
140 unsigned long rx_over_errors;
141 unsigned long rx_crc_errors;
142 unsigned long rx_frame_errors;
143 unsigned long rx_fifo_errors;
144 unsigned long rx_missed_errors;
145
146
147 unsigned long tx_aborted_errors;
148 unsigned long tx_carrier_errors;
149 unsigned long tx_fifo_errors;
150 unsigned long tx_heartbeat_errors;
151 unsigned long tx_window_errors;
152
153
154 unsigned long rx_compressed;
155 unsigned long tx_compressed;
156};
157
158
159
160enum {
161 IF_PORT_UNKNOWN = 0,
162 IF_PORT_10BASE2,
163 IF_PORT_10BASET,
164 IF_PORT_AUI,
165 IF_PORT_100BASET,
166 IF_PORT_100BASETX,
167 IF_PORT_100BASEFX
168};
169
170#ifdef __KERNEL__
171
172#include <linux/cache.h>
173#include <linux/skbuff.h>
174
175struct neighbour;
176struct neigh_parms;
177struct sk_buff;
178
179struct netif_rx_stats
180{
181 unsigned total;
182 unsigned dropped;
183 unsigned time_squeeze;
184 unsigned cpu_collision;
185};
186
187DECLARE_PER_CPU(struct netif_rx_stats, netdev_rx_stat);
188
189struct dev_addr_list
190{
191 struct dev_addr_list *next;
192 u8 da_addr[MAX_ADDR_LEN];
193 u8 da_addrlen;
194 u8 da_synced;
195 int da_users;
196 int da_gusers;
197};
198
199
200
201
202
203#define dev_mc_list dev_addr_list
204#define dmi_addr da_addr
205#define dmi_addrlen da_addrlen
206#define dmi_users da_users
207#define dmi_gusers da_gusers
208
209struct hh_cache
210{
211 struct hh_cache *hh_next;
212 atomic_t hh_refcnt;
213
214
215
216
217
218
219 __be16 hh_type ____cacheline_aligned_in_smp;
220
221
222
223
224 u16 hh_len;
225 int (*hh_output)(struct sk_buff *skb);
226 seqlock_t hh_lock;
227
228
229#define HH_DATA_MOD 16
230#define HH_DATA_OFF(__len) \
231 (HH_DATA_MOD - (((__len - 1) & (HH_DATA_MOD - 1)) + 1))
232#define HH_DATA_ALIGN(__len) \
233 (((__len)+(HH_DATA_MOD-1))&~(HH_DATA_MOD - 1))
234 unsigned long hh_data[HH_DATA_ALIGN(LL_MAX_HEADER) / sizeof(long)];
235};
236
237
238
239
240
241
242
243
244
245
246
247
248#define LL_RESERVED_SPACE(dev) \
249 ((((dev)->hard_header_len+(dev)->needed_headroom)&~(HH_DATA_MOD - 1)) + HH_DATA_MOD)
250#define LL_RESERVED_SPACE_EXTRA(dev,extra) \
251 ((((dev)->hard_header_len+(dev)->needed_headroom+(extra))&~(HH_DATA_MOD - 1)) + HH_DATA_MOD)
252#define LL_ALLOCATED_SPACE(dev) \
253 ((((dev)->hard_header_len+(dev)->needed_headroom+(dev)->needed_tailroom)&~(HH_DATA_MOD - 1)) + HH_DATA_MOD)
254
255struct header_ops {
256 int (*create) (struct sk_buff *skb, struct net_device *dev,
257 unsigned short type, const void *daddr,
258 const void *saddr, unsigned len);
259 int (*parse)(const struct sk_buff *skb, unsigned char *haddr);
260 int (*rebuild)(struct sk_buff *skb);
261#define HAVE_HEADER_CACHE
262 int (*cache)(const struct neighbour *neigh, struct hh_cache *hh);
263 void (*cache_update)(struct hh_cache *hh,
264 const struct net_device *dev,
265 const unsigned char *haddr);
266};
267
268
269
270
271
272
273enum netdev_state_t
274{
275 __LINK_STATE_START,
276 __LINK_STATE_PRESENT,
277 __LINK_STATE_NOCARRIER,
278 __LINK_STATE_LINKWATCH_PENDING,
279 __LINK_STATE_DORMANT,
280};
281
282
283
284
285
286
287struct netdev_boot_setup {
288 char name[IFNAMSIZ];
289 struct ifmap map;
290};
291#define NETDEV_BOOT_SETUP_MAX 8
292
293extern int __init netdev_boot_setup(char *str);
294
295
296
297
298struct napi_struct {
299
300
301
302
303
304
305 struct list_head poll_list;
306
307 unsigned long state;
308 int weight;
309 int (*poll)(struct napi_struct *, int);
310#ifdef CONFIG_NETPOLL
311 spinlock_t poll_lock;
312 int poll_owner;
313 struct net_device *dev;
314 struct list_head dev_list;
315#endif
316};
317
318enum
319{
320 NAPI_STATE_SCHED,
321 NAPI_STATE_DISABLE,
322 NAPI_STATE_NPSVC,
323};
324
325extern void __napi_schedule(struct napi_struct *n);
326
327static inline int napi_disable_pending(struct napi_struct *n)
328{
329 return test_bit(NAPI_STATE_DISABLE, &n->state);
330}
331
332
333
334
335
336
337
338
339
340
341static inline int napi_schedule_prep(struct napi_struct *n)
342{
343 return !napi_disable_pending(n) &&
344 !test_and_set_bit(NAPI_STATE_SCHED, &n->state);
345}
346
347
348
349
350
351
352
353
354static inline void napi_schedule(struct napi_struct *n)
355{
356 if (napi_schedule_prep(n))
357 __napi_schedule(n);
358}
359
360
361static inline int napi_reschedule(struct napi_struct *napi)
362{
363 if (napi_schedule_prep(napi)) {
364 __napi_schedule(napi);
365 return 1;
366 }
367 return 0;
368}
369
370
371
372
373
374
375
376static inline void __napi_complete(struct napi_struct *n)
377{
378 BUG_ON(!test_bit(NAPI_STATE_SCHED, &n->state));
379 list_del(&n->poll_list);
380 smp_mb__before_clear_bit();
381 clear_bit(NAPI_STATE_SCHED, &n->state);
382}
383
384static inline void napi_complete(struct napi_struct *n)
385{
386 unsigned long flags;
387
388 local_irq_save(flags);
389 __napi_complete(n);
390 local_irq_restore(flags);
391}
392
393
394
395
396
397
398
399
400static inline void napi_disable(struct napi_struct *n)
401{
402 set_bit(NAPI_STATE_DISABLE, &n->state);
403 while (test_and_set_bit(NAPI_STATE_SCHED, &n->state))
404 msleep(1);
405 clear_bit(NAPI_STATE_DISABLE, &n->state);
406}
407
408
409
410
411
412
413
414
415static inline void napi_enable(struct napi_struct *n)
416{
417 BUG_ON(!test_bit(NAPI_STATE_SCHED, &n->state));
418 smp_mb__before_clear_bit();
419 clear_bit(NAPI_STATE_SCHED, &n->state);
420}
421
422#ifdef CONFIG_SMP
423
424
425
426
427
428
429
430
431static inline void napi_synchronize(const struct napi_struct *n)
432{
433 while (test_bit(NAPI_STATE_SCHED, &n->state))
434 msleep(1);
435}
436#else
437# define napi_synchronize(n) barrier()
438#endif
439
440enum netdev_queue_state_t
441{
442 __QUEUE_STATE_XOFF,
443 __QUEUE_STATE_FROZEN,
444};
445
446struct netdev_queue {
447 struct net_device *dev;
448 struct Qdisc *qdisc;
449 unsigned long state;
450 spinlock_t _xmit_lock;
451 int xmit_lock_owner;
452 struct Qdisc *qdisc_sleeping;
453} ____cacheline_aligned_in_smp;
454
455
456
457
458
459
460
461
462
463
464
465struct net_device
466{
467
468
469
470
471
472
473 char name[IFNAMSIZ];
474
475 struct hlist_node name_hlist;
476
477 char *ifalias;
478
479
480
481
482
483 unsigned long mem_end;
484 unsigned long mem_start;
485 unsigned long base_addr;
486 unsigned int irq;
487
488
489
490
491
492
493 unsigned char if_port;
494 unsigned char dma;
495
496 unsigned long state;
497
498 struct list_head dev_list;
499#ifdef CONFIG_NETPOLL
500 struct list_head napi_list;
501#endif
502
503
504 int (*init)(struct net_device *dev);
505
506
507
508
509 unsigned long features;
510#define NETIF_F_SG 1
511#define NETIF_F_IP_CSUM 2
512#define NETIF_F_NO_CSUM 4
513#define NETIF_F_HW_CSUM 8
514#define NETIF_F_IPV6_CSUM 16
515#define NETIF_F_HIGHDMA 32
516#define NETIF_F_FRAGLIST 64
517#define NETIF_F_HW_VLAN_TX 128
518#define NETIF_F_HW_VLAN_RX 256
519#define NETIF_F_HW_VLAN_FILTER 512
520#define NETIF_F_VLAN_CHALLENGED 1024
521#define NETIF_F_GSO 2048
522#define NETIF_F_LLTX 4096
523
524#define NETIF_F_NETNS_LOCAL 8192
525#define NETIF_F_LRO 32768
526
527
528#define NETIF_F_GSO_SHIFT 16
529#define NETIF_F_GSO_MASK 0xffff0000
530#define NETIF_F_TSO (SKB_GSO_TCPV4 << NETIF_F_GSO_SHIFT)
531#define NETIF_F_UFO (SKB_GSO_UDP << NETIF_F_GSO_SHIFT)
532#define NETIF_F_GSO_ROBUST (SKB_GSO_DODGY << NETIF_F_GSO_SHIFT)
533#define NETIF_F_TSO_ECN (SKB_GSO_TCP_ECN << NETIF_F_GSO_SHIFT)
534#define NETIF_F_TSO6 (SKB_GSO_TCPV6 << NETIF_F_GSO_SHIFT)
535
536
537#define NETIF_F_GSO_SOFTWARE (NETIF_F_TSO | NETIF_F_TSO_ECN | NETIF_F_TSO6)
538
539
540#define NETIF_F_GEN_CSUM (NETIF_F_NO_CSUM | NETIF_F_HW_CSUM)
541#define NETIF_F_V4_CSUM (NETIF_F_GEN_CSUM | NETIF_F_IP_CSUM)
542#define NETIF_F_V6_CSUM (NETIF_F_GEN_CSUM | NETIF_F_IPV6_CSUM)
543#define NETIF_F_ALL_CSUM (NETIF_F_V4_CSUM | NETIF_F_V6_CSUM)
544
545
546
547
548
549#define NETIF_F_ONE_FOR_ALL (NETIF_F_GSO_SOFTWARE | NETIF_F_GSO_ROBUST | \
550 NETIF_F_SG | NETIF_F_HIGHDMA | \
551 NETIF_F_FRAGLIST)
552
553
554 int ifindex;
555 int iflink;
556
557
558 struct net_device_stats* (*get_stats)(struct net_device *dev);
559 struct net_device_stats stats;
560
561#ifdef CONFIG_WIRELESS_EXT
562
563
564 const struct iw_handler_def * wireless_handlers;
565
566 struct iw_public_data * wireless_data;
567#endif
568 const struct ethtool_ops *ethtool_ops;
569
570
571 const struct header_ops *header_ops;
572
573
574
575
576
577
578
579
580 unsigned int flags;
581 unsigned short gflags;
582 unsigned short priv_flags;
583 unsigned short padded;
584
585 unsigned char operstate;
586 unsigned char link_mode;
587
588 unsigned mtu;
589 unsigned short type;
590 unsigned short hard_header_len;
591
592
593
594
595
596 unsigned short needed_headroom;
597 unsigned short needed_tailroom;
598
599 struct net_device *master;
600
601
602
603
604 unsigned char perm_addr[MAX_ADDR_LEN];
605 unsigned char addr_len;
606 unsigned short dev_id;
607
608 spinlock_t addr_list_lock;
609 struct dev_addr_list *uc_list;
610 int uc_count;
611 int uc_promisc;
612 struct dev_addr_list *mc_list;
613 int mc_count;
614 unsigned int promiscuity;
615 unsigned int allmulti;
616
617
618
619
620#ifdef CONFIG_NET_DSA
621 void *dsa_ptr;
622#endif
623 void *atalk_ptr;
624 void *ip_ptr;
625 void *dn_ptr;
626 void *ip6_ptr;
627 void *ec_ptr;
628 void *ax25_ptr;
629 struct wireless_dev *ieee80211_ptr;
630
631
632
633
634
635 unsigned long last_rx;
636
637 unsigned char dev_addr[MAX_ADDR_LEN];
638
639
640 unsigned char broadcast[MAX_ADDR_LEN];
641
642 struct netdev_queue rx_queue;
643
644 struct netdev_queue *_tx ____cacheline_aligned_in_smp;
645
646
647 unsigned int num_tx_queues;
648
649
650 unsigned int real_num_tx_queues;
651
652 unsigned long tx_queue_len;
653 spinlock_t tx_global_lock;
654
655
656
657 void *priv;
658 int (*hard_start_xmit) (struct sk_buff *skb,
659 struct net_device *dev);
660
661 unsigned long trans_start;
662
663 int watchdog_timeo;
664 struct timer_list watchdog_timer;
665
666
667
668
669
670 atomic_t refcnt ____cacheline_aligned_in_smp;
671
672
673 struct list_head todo_list;
674
675 struct hlist_node index_hlist;
676
677 struct net_device *link_watch_next;
678
679
680 enum { NETREG_UNINITIALIZED=0,
681 NETREG_REGISTERED,
682 NETREG_UNREGISTERING,
683 NETREG_UNREGISTERED,
684 NETREG_RELEASED,
685 } reg_state;
686
687
688 void (*uninit)(struct net_device *dev);
689
690 void (*destructor)(struct net_device *dev);
691
692
693 int (*open)(struct net_device *dev);
694 int (*stop)(struct net_device *dev);
695#define HAVE_NETDEV_POLL
696#define HAVE_CHANGE_RX_FLAGS
697 void (*change_rx_flags)(struct net_device *dev,
698 int flags);
699#define HAVE_SET_RX_MODE
700 void (*set_rx_mode)(struct net_device *dev);
701#define HAVE_MULTICAST
702 void (*set_multicast_list)(struct net_device *dev);
703#define HAVE_SET_MAC_ADDR
704 int (*set_mac_address)(struct net_device *dev,
705 void *addr);
706#define HAVE_VALIDATE_ADDR
707 int (*validate_addr)(struct net_device *dev);
708#define HAVE_PRIVATE_IOCTL
709 int (*do_ioctl)(struct net_device *dev,
710 struct ifreq *ifr, int cmd);
711#define HAVE_SET_CONFIG
712 int (*set_config)(struct net_device *dev,
713 struct ifmap *map);
714#define HAVE_CHANGE_MTU
715 int (*change_mtu)(struct net_device *dev, int new_mtu);
716
717#define HAVE_TX_TIMEOUT
718 void (*tx_timeout) (struct net_device *dev);
719
720 void (*vlan_rx_register)(struct net_device *dev,
721 struct vlan_group *grp);
722 void (*vlan_rx_add_vid)(struct net_device *dev,
723 unsigned short vid);
724 void (*vlan_rx_kill_vid)(struct net_device *dev,
725 unsigned short vid);
726
727 int (*neigh_setup)(struct net_device *dev, struct neigh_parms *);
728#ifdef CONFIG_NETPOLL
729 struct netpoll_info *npinfo;
730#endif
731#ifdef CONFIG_NET_POLL_CONTROLLER
732 void (*poll_controller)(struct net_device *dev);
733#endif
734
735 u16 (*select_queue)(struct net_device *dev,
736 struct sk_buff *skb);
737
738#ifdef CONFIG_NET_NS
739
740 struct net *nd_net;
741#endif
742
743
744 void *ml_priv;
745
746
747 struct net_bridge_port *br_port;
748
749 struct macvlan_port *macvlan_port;
750
751 struct garp_port *garp_port;
752
753
754 struct device dev;
755
756 struct attribute_group *sysfs_groups[3];
757
758
759 const struct rtnl_link_ops *rtnl_link_ops;
760
761
762 unsigned long vlan_features;
763
764
765#define GSO_MAX_SIZE 65536
766 unsigned int gso_max_size;
767};
768#define to_net_dev(d) container_of(d, struct net_device, dev)
769
770#define NETDEV_ALIGN 32
771#define NETDEV_ALIGN_CONST (NETDEV_ALIGN - 1)
772
773static inline
774struct netdev_queue *netdev_get_tx_queue(const struct net_device *dev,
775 unsigned int index)
776{
777 return &dev->_tx[index];
778}
779
780static inline void netdev_for_each_tx_queue(struct net_device *dev,
781 void (*f)(struct net_device *,
782 struct netdev_queue *,
783 void *),
784 void *arg)
785{
786 unsigned int i;
787
788 for (i = 0; i < dev->num_tx_queues; i++)
789 f(dev, &dev->_tx[i], arg);
790}
791
792
793
794
795static inline
796struct net *dev_net(const struct net_device *dev)
797{
798#ifdef CONFIG_NET_NS
799 return dev->nd_net;
800#else
801 return &init_net;
802#endif
803}
804
805static inline
806void dev_net_set(struct net_device *dev, struct net *net)
807{
808#ifdef CONFIG_NET_NS
809 release_net(dev->nd_net);
810 dev->nd_net = hold_net(net);
811#endif
812}
813
814static inline bool netdev_uses_dsa_tags(struct net_device *dev)
815{
816#ifdef CONFIG_NET_DSA_TAG_DSA
817 if (dev->dsa_ptr != NULL)
818 return dsa_uses_dsa_tags(dev->dsa_ptr);
819#endif
820
821 return 0;
822}
823
824static inline bool netdev_uses_trailer_tags(struct net_device *dev)
825{
826#ifdef CONFIG_NET_DSA_TAG_TRAILER
827 if (dev->dsa_ptr != NULL)
828 return dsa_uses_trailer_tags(dev->dsa_ptr);
829#endif
830
831 return 0;
832}
833
834
835
836
837
838
839
840static inline void *netdev_priv(const struct net_device *dev)
841{
842 return (char *)dev + ((sizeof(struct net_device)
843 + NETDEV_ALIGN_CONST)
844 & ~NETDEV_ALIGN_CONST);
845}
846
847
848
849
850#define SET_NETDEV_DEV(net, pdev) ((net)->dev.parent = (pdev))
851
852
853
854
855
856
857
858
859
860
861
862static inline void netif_napi_add(struct net_device *dev,
863 struct napi_struct *napi,
864 int (*poll)(struct napi_struct *, int),
865 int weight)
866{
867 INIT_LIST_HEAD(&napi->poll_list);
868 napi->poll = poll;
869 napi->weight = weight;
870#ifdef CONFIG_NETPOLL
871 napi->dev = dev;
872 list_add(&napi->dev_list, &dev->napi_list);
873 spin_lock_init(&napi->poll_lock);
874 napi->poll_owner = -1;
875#endif
876 set_bit(NAPI_STATE_SCHED, &napi->state);
877}
878
879
880
881
882
883
884
885static inline void netif_napi_del(struct napi_struct *napi)
886{
887#ifdef CONFIG_NETPOLL
888 list_del(&napi->dev_list);
889#endif
890}
891
892struct packet_type {
893 __be16 type;
894 struct net_device *dev;
895 int (*func) (struct sk_buff *,
896 struct net_device *,
897 struct packet_type *,
898 struct net_device *);
899 struct sk_buff *(*gso_segment)(struct sk_buff *skb,
900 int features);
901 int (*gso_send_check)(struct sk_buff *skb);
902 void *af_packet_priv;
903 struct list_head list;
904};
905
906#include <linux/interrupt.h>
907#include <linux/notifier.h>
908
909extern rwlock_t dev_base_lock;
910
911
912#define for_each_netdev(net, d) \
913 list_for_each_entry(d, &(net)->dev_base_head, dev_list)
914#define for_each_netdev_safe(net, d, n) \
915 list_for_each_entry_safe(d, n, &(net)->dev_base_head, dev_list)
916#define for_each_netdev_continue(net, d) \
917 list_for_each_entry_continue(d, &(net)->dev_base_head, dev_list)
918#define net_device_entry(lh) list_entry(lh, struct net_device, dev_list)
919
920static inline struct net_device *next_net_device(struct net_device *dev)
921{
922 struct list_head *lh;
923 struct net *net;
924
925 net = dev_net(dev);
926 lh = dev->dev_list.next;
927 return lh == &net->dev_base_head ? NULL : net_device_entry(lh);
928}
929
930static inline struct net_device *first_net_device(struct net *net)
931{
932 return list_empty(&net->dev_base_head) ? NULL :
933 net_device_entry(net->dev_base_head.next);
934}
935
936extern int netdev_boot_setup_check(struct net_device *dev);
937extern unsigned long netdev_boot_base(const char *prefix, int unit);
938extern struct net_device *dev_getbyhwaddr(struct net *net, unsigned short type, char *hwaddr);
939extern struct net_device *dev_getfirstbyhwtype(struct net *net, unsigned short type);
940extern struct net_device *__dev_getfirstbyhwtype(struct net *net, unsigned short type);
941extern void dev_add_pack(struct packet_type *pt);
942extern void dev_remove_pack(struct packet_type *pt);
943extern void __dev_remove_pack(struct packet_type *pt);
944
945extern struct net_device *dev_get_by_flags(struct net *net, unsigned short flags,
946 unsigned short mask);
947extern struct net_device *dev_get_by_name(struct net *net, const char *name);
948extern struct net_device *__dev_get_by_name(struct net *net, const char *name);
949extern int dev_alloc_name(struct net_device *dev, const char *name);
950extern int dev_open(struct net_device *dev);
951extern int dev_close(struct net_device *dev);
952extern void dev_disable_lro(struct net_device *dev);
953extern int dev_queue_xmit(struct sk_buff *skb);
954extern int register_netdevice(struct net_device *dev);
955extern void unregister_netdevice(struct net_device *dev);
956extern void free_netdev(struct net_device *dev);
957extern void synchronize_net(void);
958extern int register_netdevice_notifier(struct notifier_block *nb);
959extern int unregister_netdevice_notifier(struct notifier_block *nb);
960extern int call_netdevice_notifiers(unsigned long val, struct net_device *dev);
961extern struct net_device *dev_get_by_index(struct net *net, int ifindex);
962extern struct net_device *__dev_get_by_index(struct net *net, int ifindex);
963extern int dev_restart(struct net_device *dev);
964#ifdef CONFIG_NETPOLL_TRAP
965extern int netpoll_trap(void);
966#endif
967
968static inline int dev_hard_header(struct sk_buff *skb, struct net_device *dev,
969 unsigned short type,
970 const void *daddr, const void *saddr,
971 unsigned len)
972{
973 if (!dev->header_ops || !dev->header_ops->create)
974 return 0;
975
976 return dev->header_ops->create(skb, dev, type, daddr, saddr, len);
977}
978
979static inline int dev_parse_header(const struct sk_buff *skb,
980 unsigned char *haddr)
981{
982 const struct net_device *dev = skb->dev;
983
984 if (!dev->header_ops || !dev->header_ops->parse)
985 return 0;
986 return dev->header_ops->parse(skb, haddr);
987}
988
989typedef int gifconf_func_t(struct net_device * dev, char __user * bufptr, int len);
990extern int register_gifconf(unsigned int family, gifconf_func_t * gifconf);
991static inline int unregister_gifconf(unsigned int family)
992{
993 return register_gifconf(family, NULL);
994}
995
996
997
998
999
1000struct softnet_data
1001{
1002 struct Qdisc *output_queue;
1003 struct sk_buff_head input_pkt_queue;
1004 struct list_head poll_list;
1005 struct sk_buff *completion_queue;
1006
1007 struct napi_struct backlog;
1008#ifdef CONFIG_NET_DMA
1009 struct dma_chan *net_dma;
1010#endif
1011};
1012
1013DECLARE_PER_CPU(struct softnet_data,softnet_data);
1014
1015#define HAVE_NETIF_QUEUE
1016
1017extern void __netif_schedule(struct Qdisc *q);
1018
1019static inline void netif_schedule_queue(struct netdev_queue *txq)
1020{
1021 if (!test_bit(__QUEUE_STATE_XOFF, &txq->state))
1022 __netif_schedule(txq->qdisc);
1023}
1024
1025static inline void netif_tx_schedule_all(struct net_device *dev)
1026{
1027 unsigned int i;
1028
1029 for (i = 0; i < dev->num_tx_queues; i++)
1030 netif_schedule_queue(netdev_get_tx_queue(dev, i));
1031}
1032
1033static inline void netif_tx_start_queue(struct netdev_queue *dev_queue)
1034{
1035 clear_bit(__QUEUE_STATE_XOFF, &dev_queue->state);
1036}
1037
1038
1039
1040
1041
1042
1043
1044static inline void netif_start_queue(struct net_device *dev)
1045{
1046 netif_tx_start_queue(netdev_get_tx_queue(dev, 0));
1047}
1048
1049static inline void netif_tx_start_all_queues(struct net_device *dev)
1050{
1051 unsigned int i;
1052
1053 for (i = 0; i < dev->num_tx_queues; i++) {
1054 struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
1055 netif_tx_start_queue(txq);
1056 }
1057}
1058
1059static inline void netif_tx_wake_queue(struct netdev_queue *dev_queue)
1060{
1061#ifdef CONFIG_NETPOLL_TRAP
1062 if (netpoll_trap()) {
1063 clear_bit(__QUEUE_STATE_XOFF, &dev_queue->state);
1064 return;
1065 }
1066#endif
1067 if (test_and_clear_bit(__QUEUE_STATE_XOFF, &dev_queue->state))
1068 __netif_schedule(dev_queue->qdisc);
1069}
1070
1071
1072
1073
1074
1075
1076
1077
1078static inline void netif_wake_queue(struct net_device *dev)
1079{
1080 netif_tx_wake_queue(netdev_get_tx_queue(dev, 0));
1081}
1082
1083static inline void netif_tx_wake_all_queues(struct net_device *dev)
1084{
1085 unsigned int i;
1086
1087 for (i = 0; i < dev->num_tx_queues; i++) {
1088 struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
1089 netif_tx_wake_queue(txq);
1090 }
1091}
1092
1093static inline void netif_tx_stop_queue(struct netdev_queue *dev_queue)
1094{
1095 set_bit(__QUEUE_STATE_XOFF, &dev_queue->state);
1096}
1097
1098
1099
1100
1101
1102
1103
1104
1105static inline void netif_stop_queue(struct net_device *dev)
1106{
1107 netif_tx_stop_queue(netdev_get_tx_queue(dev, 0));
1108}
1109
1110static inline void netif_tx_stop_all_queues(struct net_device *dev)
1111{
1112 unsigned int i;
1113
1114 for (i = 0; i < dev->num_tx_queues; i++) {
1115 struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
1116 netif_tx_stop_queue(txq);
1117 }
1118}
1119
1120static inline int netif_tx_queue_stopped(const struct netdev_queue *dev_queue)
1121{
1122 return test_bit(__QUEUE_STATE_XOFF, &dev_queue->state);
1123}
1124
1125
1126
1127
1128
1129
1130
1131static inline int netif_queue_stopped(const struct net_device *dev)
1132{
1133 return netif_tx_queue_stopped(netdev_get_tx_queue(dev, 0));
1134}
1135
1136static inline int netif_tx_queue_frozen(const struct netdev_queue *dev_queue)
1137{
1138 return test_bit(__QUEUE_STATE_FROZEN, &dev_queue->state);
1139}
1140
1141
1142
1143
1144
1145
1146
1147static inline int netif_running(const struct net_device *dev)
1148{
1149 return test_bit(__LINK_STATE_START, &dev->state);
1150}
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166static inline void netif_start_subqueue(struct net_device *dev, u16 queue_index)
1167{
1168 struct netdev_queue *txq = netdev_get_tx_queue(dev, queue_index);
1169 clear_bit(__QUEUE_STATE_XOFF, &txq->state);
1170}
1171
1172
1173
1174
1175
1176
1177
1178
1179static inline void netif_stop_subqueue(struct net_device *dev, u16 queue_index)
1180{
1181 struct netdev_queue *txq = netdev_get_tx_queue(dev, queue_index);
1182#ifdef CONFIG_NETPOLL_TRAP
1183 if (netpoll_trap())
1184 return;
1185#endif
1186 set_bit(__QUEUE_STATE_XOFF, &txq->state);
1187}
1188
1189
1190
1191
1192
1193
1194
1195
1196static inline int __netif_subqueue_stopped(const struct net_device *dev,
1197 u16 queue_index)
1198{
1199 struct netdev_queue *txq = netdev_get_tx_queue(dev, queue_index);
1200 return test_bit(__QUEUE_STATE_XOFF, &txq->state);
1201}
1202
1203static inline int netif_subqueue_stopped(const struct net_device *dev,
1204 struct sk_buff *skb)
1205{
1206 return __netif_subqueue_stopped(dev, skb_get_queue_mapping(skb));
1207}
1208
1209
1210
1211
1212
1213
1214
1215
1216static inline void netif_wake_subqueue(struct net_device *dev, u16 queue_index)
1217{
1218 struct netdev_queue *txq = netdev_get_tx_queue(dev, queue_index);
1219#ifdef CONFIG_NETPOLL_TRAP
1220 if (netpoll_trap())
1221 return;
1222#endif
1223 if (test_and_clear_bit(__QUEUE_STATE_XOFF, &txq->state))
1224 __netif_schedule(txq->qdisc);
1225}
1226
1227
1228
1229
1230
1231
1232
1233static inline int netif_is_multiqueue(const struct net_device *dev)
1234{
1235 return (dev->num_tx_queues > 1);
1236}
1237
1238
1239
1240
1241
1242extern void dev_kfree_skb_irq(struct sk_buff *skb);
1243
1244
1245
1246
1247
1248extern void dev_kfree_skb_any(struct sk_buff *skb);
1249
1250#define HAVE_NETIF_RX 1
1251extern int netif_rx(struct sk_buff *skb);
1252extern int netif_rx_ni(struct sk_buff *skb);
1253#define HAVE_NETIF_RECEIVE_SKB 1
1254extern int netif_receive_skb(struct sk_buff *skb);
1255extern void netif_nit_deliver(struct sk_buff *skb);
1256extern int dev_valid_name(const char *name);
1257extern int dev_ioctl(struct net *net, unsigned int cmd, void __user *);
1258extern int dev_ethtool(struct net *net, struct ifreq *);
1259extern unsigned dev_get_flags(const struct net_device *);
1260extern int dev_change_flags(struct net_device *, unsigned);
1261extern int dev_change_name(struct net_device *, const char *);
1262extern int dev_set_alias(struct net_device *, const char *, size_t);
1263extern int dev_change_net_namespace(struct net_device *,
1264 struct net *, const char *);
1265extern int dev_set_mtu(struct net_device *, int);
1266extern int dev_set_mac_address(struct net_device *,
1267 struct sockaddr *);
1268extern int dev_hard_start_xmit(struct sk_buff *skb,
1269 struct net_device *dev,
1270 struct netdev_queue *txq);
1271
1272extern int netdev_budget;
1273
1274
1275extern void netdev_run_todo(void);
1276
1277
1278
1279
1280
1281
1282
1283static inline void dev_put(struct net_device *dev)
1284{
1285 atomic_dec(&dev->refcnt);
1286}
1287
1288
1289
1290
1291
1292
1293
1294static inline void dev_hold(struct net_device *dev)
1295{
1296 atomic_inc(&dev->refcnt);
1297}
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308extern void linkwatch_fire_event(struct net_device *dev);
1309
1310
1311
1312
1313
1314
1315
1316static inline int netif_carrier_ok(const struct net_device *dev)
1317{
1318 return !test_bit(__LINK_STATE_NOCARRIER, &dev->state);
1319}
1320
1321extern void __netdev_watchdog_up(struct net_device *dev);
1322
1323extern void netif_carrier_on(struct net_device *dev);
1324
1325extern void netif_carrier_off(struct net_device *dev);
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340static inline void netif_dormant_on(struct net_device *dev)
1341{
1342 if (!test_and_set_bit(__LINK_STATE_DORMANT, &dev->state))
1343 linkwatch_fire_event(dev);
1344}
1345
1346
1347
1348
1349
1350
1351
1352static inline void netif_dormant_off(struct net_device *dev)
1353{
1354 if (test_and_clear_bit(__LINK_STATE_DORMANT, &dev->state))
1355 linkwatch_fire_event(dev);
1356}
1357
1358
1359
1360
1361
1362
1363
1364static inline int netif_dormant(const struct net_device *dev)
1365{
1366 return test_bit(__LINK_STATE_DORMANT, &dev->state);
1367}
1368
1369
1370
1371
1372
1373
1374
1375
1376static inline int netif_oper_up(const struct net_device *dev) {
1377 return (dev->operstate == IF_OPER_UP ||
1378 dev->operstate == IF_OPER_UNKNOWN );
1379}
1380
1381
1382
1383
1384
1385
1386
1387static inline int netif_device_present(struct net_device *dev)
1388{
1389 return test_bit(__LINK_STATE_PRESENT, &dev->state);
1390}
1391
1392extern void netif_device_detach(struct net_device *dev);
1393
1394extern void netif_device_attach(struct net_device *dev);
1395
1396
1397
1398
1399#define HAVE_NETIF_MSG 1
1400
1401enum {
1402 NETIF_MSG_DRV = 0x0001,
1403 NETIF_MSG_PROBE = 0x0002,
1404 NETIF_MSG_LINK = 0x0004,
1405 NETIF_MSG_TIMER = 0x0008,
1406 NETIF_MSG_IFDOWN = 0x0010,
1407 NETIF_MSG_IFUP = 0x0020,
1408 NETIF_MSG_RX_ERR = 0x0040,
1409 NETIF_MSG_TX_ERR = 0x0080,
1410 NETIF_MSG_TX_QUEUED = 0x0100,
1411 NETIF_MSG_INTR = 0x0200,
1412 NETIF_MSG_TX_DONE = 0x0400,
1413 NETIF_MSG_RX_STATUS = 0x0800,
1414 NETIF_MSG_PKTDATA = 0x1000,
1415 NETIF_MSG_HW = 0x2000,
1416 NETIF_MSG_WOL = 0x4000,
1417};
1418
1419#define netif_msg_drv(p) ((p)->msg_enable & NETIF_MSG_DRV)
1420#define netif_msg_probe(p) ((p)->msg_enable & NETIF_MSG_PROBE)
1421#define netif_msg_link(p) ((p)->msg_enable & NETIF_MSG_LINK)
1422#define netif_msg_timer(p) ((p)->msg_enable & NETIF_MSG_TIMER)
1423#define netif_msg_ifdown(p) ((p)->msg_enable & NETIF_MSG_IFDOWN)
1424#define netif_msg_ifup(p) ((p)->msg_enable & NETIF_MSG_IFUP)
1425#define netif_msg_rx_err(p) ((p)->msg_enable & NETIF_MSG_RX_ERR)
1426#define netif_msg_tx_err(p) ((p)->msg_enable & NETIF_MSG_TX_ERR)
1427#define netif_msg_tx_queued(p) ((p)->msg_enable & NETIF_MSG_TX_QUEUED)
1428#define netif_msg_intr(p) ((p)->msg_enable & NETIF_MSG_INTR)
1429#define netif_msg_tx_done(p) ((p)->msg_enable & NETIF_MSG_TX_DONE)
1430#define netif_msg_rx_status(p) ((p)->msg_enable & NETIF_MSG_RX_STATUS)
1431#define netif_msg_pktdata(p) ((p)->msg_enable & NETIF_MSG_PKTDATA)
1432#define netif_msg_hw(p) ((p)->msg_enable & NETIF_MSG_HW)
1433#define netif_msg_wol(p) ((p)->msg_enable & NETIF_MSG_WOL)
1434
1435static inline u32 netif_msg_init(int debug_value, int default_msg_enable_bits)
1436{
1437
1438 if (debug_value < 0 || debug_value >= (sizeof(u32) * 8))
1439 return default_msg_enable_bits;
1440 if (debug_value == 0)
1441 return 0;
1442
1443 return (1 << debug_value) - 1;
1444}
1445
1446
1447static inline int netif_rx_schedule_prep(struct net_device *dev,
1448 struct napi_struct *napi)
1449{
1450 return napi_schedule_prep(napi);
1451}
1452
1453
1454
1455
1456static inline void __netif_rx_schedule(struct net_device *dev,
1457 struct napi_struct *napi)
1458{
1459 __napi_schedule(napi);
1460}
1461
1462
1463
1464static inline void netif_rx_schedule(struct net_device *dev,
1465 struct napi_struct *napi)
1466{
1467 if (netif_rx_schedule_prep(dev, napi))
1468 __netif_rx_schedule(dev, napi);
1469}
1470
1471
1472static inline int netif_rx_reschedule(struct net_device *dev,
1473 struct napi_struct *napi)
1474{
1475 if (napi_schedule_prep(napi)) {
1476 __netif_rx_schedule(dev, napi);
1477 return 1;
1478 }
1479 return 0;
1480}
1481
1482
1483
1484
1485static inline void __netif_rx_complete(struct net_device *dev,
1486 struct napi_struct *napi)
1487{
1488 __napi_complete(napi);
1489}
1490
1491
1492
1493
1494
1495
1496static inline void netif_rx_complete(struct net_device *dev,
1497 struct napi_struct *napi)
1498{
1499 unsigned long flags;
1500
1501
1502
1503
1504
1505 if (unlikely(test_bit(NAPI_STATE_NPSVC, &napi->state)))
1506 return;
1507 local_irq_save(flags);
1508 __netif_rx_complete(dev, napi);
1509 local_irq_restore(flags);
1510}
1511
1512static inline void __netif_tx_lock(struct netdev_queue *txq, int cpu)
1513{
1514 spin_lock(&txq->_xmit_lock);
1515 txq->xmit_lock_owner = cpu;
1516}
1517
1518static inline void __netif_tx_lock_bh(struct netdev_queue *txq)
1519{
1520 spin_lock_bh(&txq->_xmit_lock);
1521 txq->xmit_lock_owner = smp_processor_id();
1522}
1523
1524static inline int __netif_tx_trylock(struct netdev_queue *txq)
1525{
1526 int ok = spin_trylock(&txq->_xmit_lock);
1527 if (likely(ok))
1528 txq->xmit_lock_owner = smp_processor_id();
1529 return ok;
1530}
1531
1532static inline void __netif_tx_unlock(struct netdev_queue *txq)
1533{
1534 txq->xmit_lock_owner = -1;
1535 spin_unlock(&txq->_xmit_lock);
1536}
1537
1538static inline void __netif_tx_unlock_bh(struct netdev_queue *txq)
1539{
1540 txq->xmit_lock_owner = -1;
1541 spin_unlock_bh(&txq->_xmit_lock);
1542}
1543
1544
1545
1546
1547
1548
1549
1550static inline void netif_tx_lock(struct net_device *dev)
1551{
1552 unsigned int i;
1553 int cpu;
1554
1555 spin_lock(&dev->tx_global_lock);
1556 cpu = smp_processor_id();
1557 for (i = 0; i < dev->num_tx_queues; i++) {
1558 struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
1559
1560
1561
1562
1563
1564
1565
1566 __netif_tx_lock(txq, cpu);
1567 set_bit(__QUEUE_STATE_FROZEN, &txq->state);
1568 __netif_tx_unlock(txq);
1569 }
1570}
1571
1572static inline void netif_tx_lock_bh(struct net_device *dev)
1573{
1574 local_bh_disable();
1575 netif_tx_lock(dev);
1576}
1577
1578static inline void netif_tx_unlock(struct net_device *dev)
1579{
1580 unsigned int i;
1581
1582 for (i = 0; i < dev->num_tx_queues; i++) {
1583 struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
1584
1585
1586
1587
1588
1589 clear_bit(__QUEUE_STATE_FROZEN, &txq->state);
1590 if (!test_bit(__QUEUE_STATE_XOFF, &txq->state))
1591 __netif_schedule(txq->qdisc);
1592 }
1593 spin_unlock(&dev->tx_global_lock);
1594}
1595
1596static inline void netif_tx_unlock_bh(struct net_device *dev)
1597{
1598 netif_tx_unlock(dev);
1599 local_bh_enable();
1600}
1601
1602#define HARD_TX_LOCK(dev, txq, cpu) { \
1603 if ((dev->features & NETIF_F_LLTX) == 0) { \
1604 __netif_tx_lock(txq, cpu); \
1605 } \
1606}
1607
1608#define HARD_TX_UNLOCK(dev, txq) { \
1609 if ((dev->features & NETIF_F_LLTX) == 0) { \
1610 __netif_tx_unlock(txq); \
1611 } \
1612}
1613
1614static inline void netif_tx_disable(struct net_device *dev)
1615{
1616 unsigned int i;
1617 int cpu;
1618
1619 local_bh_disable();
1620 cpu = smp_processor_id();
1621 for (i = 0; i < dev->num_tx_queues; i++) {
1622 struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
1623
1624 __netif_tx_lock(txq, cpu);
1625 netif_tx_stop_queue(txq);
1626 __netif_tx_unlock(txq);
1627 }
1628 local_bh_enable();
1629}
1630
1631static inline void netif_addr_lock(struct net_device *dev)
1632{
1633 spin_lock(&dev->addr_list_lock);
1634}
1635
1636static inline void netif_addr_lock_bh(struct net_device *dev)
1637{
1638 spin_lock_bh(&dev->addr_list_lock);
1639}
1640
1641static inline void netif_addr_unlock(struct net_device *dev)
1642{
1643 spin_unlock(&dev->addr_list_lock);
1644}
1645
1646static inline void netif_addr_unlock_bh(struct net_device *dev)
1647{
1648 spin_unlock_bh(&dev->addr_list_lock);
1649}
1650
1651
1652
1653extern void ether_setup(struct net_device *dev);
1654
1655
1656extern struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name,
1657 void (*setup)(struct net_device *),
1658 unsigned int queue_count);
1659#define alloc_netdev(sizeof_priv, name, setup) \
1660 alloc_netdev_mq(sizeof_priv, name, setup, 1)
1661extern int register_netdev(struct net_device *dev);
1662extern void unregister_netdev(struct net_device *dev);
1663
1664extern void dev_set_rx_mode(struct net_device *dev);
1665extern void __dev_set_rx_mode(struct net_device *dev);
1666extern int dev_unicast_delete(struct net_device *dev, void *addr, int alen);
1667extern int dev_unicast_add(struct net_device *dev, void *addr, int alen);
1668extern int dev_unicast_sync(struct net_device *to, struct net_device *from);
1669extern void dev_unicast_unsync(struct net_device *to, struct net_device *from);
1670extern int dev_mc_delete(struct net_device *dev, void *addr, int alen, int all);
1671extern int dev_mc_add(struct net_device *dev, void *addr, int alen, int newonly);
1672extern int dev_mc_sync(struct net_device *to, struct net_device *from);
1673extern void dev_mc_unsync(struct net_device *to, struct net_device *from);
1674extern int __dev_addr_delete(struct dev_addr_list **list, int *count, void *addr, int alen, int all);
1675extern int __dev_addr_add(struct dev_addr_list **list, int *count, void *addr, int alen, int newonly);
1676extern int __dev_addr_sync(struct dev_addr_list **to, int *to_count, struct dev_addr_list **from, int *from_count);
1677extern void __dev_addr_unsync(struct dev_addr_list **to, int *to_count, struct dev_addr_list **from, int *from_count);
1678extern int dev_set_promiscuity(struct net_device *dev, int inc);
1679extern int dev_set_allmulti(struct net_device *dev, int inc);
1680extern void netdev_state_change(struct net_device *dev);
1681extern void netdev_bonding_change(struct net_device *dev);
1682extern void netdev_features_change(struct net_device *dev);
1683
1684extern void dev_load(struct net *net, const char *name);
1685extern void dev_mcast_init(void);
1686extern int netdev_max_backlog;
1687extern int weight_p;
1688extern int netdev_set_master(struct net_device *dev, struct net_device *master);
1689extern int skb_checksum_help(struct sk_buff *skb);
1690extern struct sk_buff *skb_gso_segment(struct sk_buff *skb, int features);
1691#ifdef CONFIG_BUG
1692extern void netdev_rx_csum_fault(struct net_device *dev);
1693#else
1694static inline void netdev_rx_csum_fault(struct net_device *dev)
1695{
1696}
1697#endif
1698
1699extern void net_enable_timestamp(void);
1700extern void net_disable_timestamp(void);
1701
1702#ifdef CONFIG_PROC_FS
1703extern void *dev_seq_start(struct seq_file *seq, loff_t *pos);
1704extern void *dev_seq_next(struct seq_file *seq, void *v, loff_t *pos);
1705extern void dev_seq_stop(struct seq_file *seq, void *v);
1706#endif
1707
1708extern int netdev_class_create_file(struct class_attribute *class_attr);
1709extern void netdev_class_remove_file(struct class_attribute *class_attr);
1710
1711extern char *netdev_drivername(const struct net_device *dev, char *buffer, int len);
1712
1713extern void linkwatch_run_queue(void);
1714
1715unsigned long netdev_increment_features(unsigned long all, unsigned long one,
1716 unsigned long mask);
1717unsigned long netdev_fix_features(unsigned long features, const char *name);
1718
1719static inline int net_gso_ok(int features, int gso_type)
1720{
1721 int feature = gso_type << NETIF_F_GSO_SHIFT;
1722 return (features & feature) == feature;
1723}
1724
1725static inline int skb_gso_ok(struct sk_buff *skb, int features)
1726{
1727 return net_gso_ok(features, skb_shinfo(skb)->gso_type);
1728}
1729
1730static inline int netif_needs_gso(struct net_device *dev, struct sk_buff *skb)
1731{
1732 return skb_is_gso(skb) &&
1733 (!skb_gso_ok(skb, dev->features) ||
1734 unlikely(skb->ip_summed != CHECKSUM_PARTIAL));
1735}
1736
1737static inline void netif_set_gso_max_size(struct net_device *dev,
1738 unsigned int size)
1739{
1740 dev->gso_max_size = size;
1741}
1742
1743
1744
1745
1746
1747static inline int skb_bond_should_drop(struct sk_buff *skb)
1748{
1749 struct net_device *dev = skb->dev;
1750 struct net_device *master = dev->master;
1751
1752 if (master &&
1753 (dev->priv_flags & IFF_SLAVE_INACTIVE)) {
1754 if ((dev->priv_flags & IFF_SLAVE_NEEDARP) &&
1755 skb->protocol == __constant_htons(ETH_P_ARP))
1756 return 0;
1757
1758 if (master->priv_flags & IFF_MASTER_ALB) {
1759 if (skb->pkt_type != PACKET_BROADCAST &&
1760 skb->pkt_type != PACKET_MULTICAST)
1761 return 0;
1762 }
1763 if (master->priv_flags & IFF_MASTER_8023AD &&
1764 skb->protocol == __constant_htons(ETH_P_SLOW))
1765 return 0;
1766
1767 return 1;
1768 }
1769 return 0;
1770}
1771
1772#endif
1773
1774#endif