~ubuntu-branches/debian/experimental/linux-tools/experimental

« back to all changes in this revision

Viewing changes to include/linux/netdevice.h

  • Committer: Package Import Robot
  • Author(s): Ben Hutchings
  • Date: 2014-02-02 16:57:49 UTC
  • mfrom: (1.1.10) (0.1.21 sid)
  • Revision ID: package-import@ubuntu.com-20140202165749-tw94o9t1t0a8txk6
Tags: 3.13-1~exp2
Merge changes from sid up to 3.12.6-3

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
#define SET_ETHTOOL_OPS(netdev,ops) \
61
61
        ( (netdev)->ethtool_ops = (ops) )
62
62
 
63
 
extern void netdev_set_default_ethtool_ops(struct net_device *dev,
64
 
                                           const struct ethtool_ops *ops);
 
63
void netdev_set_default_ethtool_ops(struct net_device *dev,
 
64
                                    const struct ethtool_ops *ops);
65
65
 
66
66
/* hardware address assignment types */
67
67
#define NET_ADDR_PERM           0       /* address is permanent (default) */
298
298
};
299
299
#define NETDEV_BOOT_SETUP_MAX 8
300
300
 
301
 
extern int __init netdev_boot_setup(char *str);
 
301
int __init netdev_boot_setup(char *str);
302
302
 
303
303
/*
304
304
 * Structure for NAPI scheduling similar to tasklet but with weighting
394
394
typedef enum rx_handler_result rx_handler_result_t;
395
395
typedef rx_handler_result_t rx_handler_func_t(struct sk_buff **pskb);
396
396
 
397
 
extern void __napi_schedule(struct napi_struct *n);
 
397
void __napi_schedule(struct napi_struct *n);
398
398
 
399
399
static inline bool napi_disable_pending(struct napi_struct *n)
400
400
{
445
445
 *
446
446
 * Mark NAPI processing as complete.
447
447
 */
448
 
extern void __napi_complete(struct napi_struct *n);
449
 
extern void napi_complete(struct napi_struct *n);
 
448
void __napi_complete(struct napi_struct *n);
 
449
void napi_complete(struct napi_struct *n);
450
450
 
451
451
/**
452
452
 *      napi_by_id - lookup a NAPI by napi_id
455
455
 * lookup @napi_id in napi_hash table
456
456
 * must be called under rcu_read_lock()
457
457
 */
458
 
extern struct napi_struct *napi_by_id(unsigned int napi_id);
 
458
struct napi_struct *napi_by_id(unsigned int napi_id);
459
459
 
460
460
/**
461
461
 *      napi_hash_add - add a NAPI to global hashtable
463
463
 *
464
464
 * generate a new napi_id and store a @napi under it in napi_hash
465
465
 */
466
 
extern void napi_hash_add(struct napi_struct *napi);
 
466
void napi_hash_add(struct napi_struct *napi);
467
467
 
468
468
/**
469
469
 *      napi_hash_del - remove a NAPI from global table
472
472
 * Warning: caller must observe rcu grace period
473
473
 * before freeing memory containing @napi
474
474
 */
475
 
extern void napi_hash_del(struct napi_struct *napi);
 
475
void napi_hash_del(struct napi_struct *napi);
476
476
 
477
477
/**
478
478
 *      napi_disable - prevent NAPI from scheduling
483
483
 */
484
484
static inline void napi_disable(struct napi_struct *n)
485
485
{
 
486
        might_sleep();
486
487
        set_bit(NAPI_STATE_DISABLE, &n->state);
487
488
        while (test_and_set_bit(NAPI_STATE_SCHED, &n->state))
488
489
                msleep(1);
664
665
extern struct rps_sock_flow_table __rcu *rps_sock_flow_table;
665
666
 
666
667
#ifdef CONFIG_RFS_ACCEL
667
 
extern bool rps_may_expire_flow(struct net_device *dev, u16 rxq_index,
668
 
                                u32 flow_id, u16 filter_id);
 
668
bool rps_may_expire_flow(struct net_device *dev, u16 rxq_index, u32 flow_id,
 
669
                         u16 filter_id);
669
670
#endif
670
671
 
671
672
/* This structure contains an instance of an RX queue. */
768
769
 *        (can also return NETDEV_TX_LOCKED iff NETIF_F_LLTX)
769
770
 *      Required can not be NULL.
770
771
 *
771
 
 * u16 (*ndo_select_queue)(struct net_device *dev, struct sk_buff *skb);
 
772
 * u16 (*ndo_select_queue)(struct net_device *dev, struct sk_buff *skb,
 
773
 *                         void *accel_priv);
772
774
 *      Called to decide which queue to when device supports multiple
773
775
 *      transmit queues.
774
776
 *
961
963
 *      Called by vxlan to notify the driver about a UDP port and socket
962
964
 *      address family that vxlan is not listening to anymore. The operation
963
965
 *      is protected by the vxlan_net->sock_lock.
 
966
 *
 
967
 * void* (*ndo_dfwd_add_station)(struct net_device *pdev,
 
968
 *                               struct net_device *dev)
 
969
 *      Called by upper layer devices to accelerate switching or other
 
970
 *      station functionality into hardware. 'pdev is the lowerdev
 
971
 *      to use for the offload and 'dev' is the net device that will
 
972
 *      back the offload. Returns a pointer to the private structure
 
973
 *      the upper layer will maintain.
 
974
 * void (*ndo_dfwd_del_station)(struct net_device *pdev, void *priv)
 
975
 *      Called by upper layer device to delete the station created
 
976
 *      by 'ndo_dfwd_add_station'. 'pdev' is the net device backing
 
977
 *      the station and priv is the structure returned by the add
 
978
 *      operation.
 
979
 * netdev_tx_t (*ndo_dfwd_start_xmit)(struct sk_buff *skb,
 
980
 *                                    struct net_device *dev,
 
981
 *                                    void *priv);
 
982
 *      Callback to use for xmit over the accelerated station. This
 
983
 *      is used in place of ndo_start_xmit on accelerated net
 
984
 *      devices.
964
985
 */
965
986
struct net_device_ops {
966
987
        int                     (*ndo_init)(struct net_device *dev);
970
991
        netdev_tx_t             (*ndo_start_xmit) (struct sk_buff *skb,
971
992
                                                   struct net_device *dev);
972
993
        u16                     (*ndo_select_queue)(struct net_device *dev,
973
 
                                                    struct sk_buff *skb);
 
994
                                                    struct sk_buff *skb,
 
995
                                                    void *accel_priv);
974
996
        void                    (*ndo_change_rx_flags)(struct net_device *dev,
975
997
                                                       int flags);
976
998
        void                    (*ndo_set_rx_mode)(struct net_device *dev);
1097
1119
        void                    (*ndo_del_vxlan_port)(struct  net_device *dev,
1098
1120
                                                      sa_family_t sa_family,
1099
1121
                                                      __be16 port);
 
1122
 
 
1123
        void*                   (*ndo_dfwd_add_station)(struct net_device *pdev,
 
1124
                                                        struct net_device *dev);
 
1125
        void                    (*ndo_dfwd_del_station)(struct net_device *pdev,
 
1126
                                                        void *priv);
 
1127
 
 
1128
        netdev_tx_t             (*ndo_dfwd_start_xmit) (struct sk_buff *skb,
 
1129
                                                        struct net_device *dev,
 
1130
                                                        void *priv);
1100
1131
};
1101
1132
 
1102
1133
/*
1131
1162
        unsigned long           mem_end;        /* shared mem end       */
1132
1163
        unsigned long           mem_start;      /* shared mem start     */
1133
1164
        unsigned long           base_addr;      /* device I/O address   */
1134
 
        unsigned int            irq;            /* device IRQ number    */
 
1165
        int                     irq;            /* device IRQ number    */
1135
1166
 
1136
1167
        /*
1137
1168
         *      Some hardware also needs these fields, but they are not
1143
1174
        struct list_head        dev_list;
1144
1175
        struct list_head        napi_list;
1145
1176
        struct list_head        unreg_list;
1146
 
        struct list_head        upper_dev_list; /* List of upper devices */
1147
 
        struct list_head        lower_dev_list;
 
1177
        struct list_head        close_list;
 
1178
 
 
1179
        /* directly linked devices, like slaves for bonding */
 
1180
        struct {
 
1181
                struct list_head upper;
 
1182
                struct list_head lower;
 
1183
        } adj_list;
 
1184
 
 
1185
        /* all linked devices, *including* neighbours */
 
1186
        struct {
 
1187
                struct list_head upper;
 
1188
                struct list_head lower;
 
1189
        } all_adj_list;
1148
1190
 
1149
1191
 
1150
1192
        /* currently active device features */
1183
1225
        /* Management operations */
1184
1226
        const struct net_device_ops *netdev_ops;
1185
1227
        const struct ethtool_ops *ethtool_ops;
 
1228
        const struct forwarding_accel_ops *fwd_ops;
1186
1229
 
1187
1230
        /* Hardware header description */
1188
1231
        const struct header_ops *header_ops;
1214
1257
        unsigned char           perm_addr[MAX_ADDR_LEN]; /* permanent hw address */
1215
1258
        unsigned char           addr_assign_type; /* hw address assignment type */
1216
1259
        unsigned char           addr_len;       /* hardware address length      */
1217
 
        unsigned char           neigh_priv_len;
 
1260
        unsigned short          neigh_priv_len;
1218
1261
        unsigned short          dev_id;         /* Used to differentiate devices
1219
1262
                                                 * that share the same link
1220
1263
                                                 * layer address
1487
1530
                f(dev, &dev->_tx[i], arg);
1488
1531
}
1489
1532
 
1490
 
extern struct netdev_queue *netdev_pick_tx(struct net_device *dev,
1491
 
                                           struct sk_buff *skb);
1492
 
extern u16 __netdev_pick_tx(struct net_device *dev, struct sk_buff *skb);
 
1533
struct netdev_queue *netdev_pick_tx(struct net_device *dev,
 
1534
                                    struct sk_buff *skb,
 
1535
                                    void *accel_priv);
 
1536
u16 __netdev_pick_tx(struct net_device *dev, struct sk_buff *skb);
1493
1537
 
1494
1538
/*
1495
1539
 * Net namespace inlines
1546
1590
#define SET_NETDEV_DEV(net, pdev)       ((net)->dev.parent = (pdev))
1547
1591
 
1548
1592
/* Set the sysfs device type for the network logical device to allow
1549
 
 * fin grained indentification of different network device types. For
 
1593
 * fine-grained identification of different network device types. For
1550
1594
 * example Ethernet, Wirelss LAN, Bluetooth, WiMAX etc.
1551
1595
 */
1552
1596
#define SET_NETDEV_DEVTYPE(net, devtype)        ((net)->dev.type = (devtype))
1673
1717
#define NETDEV_CHANGEUPPER      0x0015
1674
1718
#define NETDEV_RESEND_IGMP      0x0016
1675
1719
 
1676
 
extern int register_netdevice_notifier(struct notifier_block *nb);
1677
 
extern int unregister_netdevice_notifier(struct notifier_block *nb);
 
1720
int register_netdevice_notifier(struct notifier_block *nb);
 
1721
int unregister_netdevice_notifier(struct notifier_block *nb);
1678
1722
 
1679
1723
struct netdev_notifier_info {
1680
1724
        struct net_device *dev;
1697
1741
        return info->dev;
1698
1742
}
1699
1743
 
1700
 
extern int call_netdevice_notifiers_info(unsigned long val, struct net_device *dev,
1701
 
                                         struct netdev_notifier_info *info);
1702
 
extern int call_netdevice_notifiers(unsigned long val, struct net_device *dev);
 
1744
int call_netdevice_notifiers_info(unsigned long val, struct net_device *dev,
 
1745
                                  struct netdev_notifier_info *info);
 
1746
int call_netdevice_notifiers(unsigned long val, struct net_device *dev);
1703
1747
 
1704
1748
 
1705
1749
extern rwlock_t                         dev_base_lock;          /* Device list lock */
1754
1798
        return lh == &net->dev_base_head ? NULL : net_device_entry(lh);
1755
1799
}
1756
1800
 
1757
 
extern int                      netdev_boot_setup_check(struct net_device *dev);
1758
 
extern unsigned long            netdev_boot_base(const char *prefix, int unit);
1759
 
extern struct net_device *dev_getbyhwaddr_rcu(struct net *net, unsigned short type,
1760
 
                                              const char *hwaddr);
1761
 
extern struct net_device *dev_getfirstbyhwtype(struct net *net, unsigned short type);
1762
 
extern struct net_device *__dev_getfirstbyhwtype(struct net *net, unsigned short type);
1763
 
extern void             dev_add_pack(struct packet_type *pt);
1764
 
extern void             dev_remove_pack(struct packet_type *pt);
1765
 
extern void             __dev_remove_pack(struct packet_type *pt);
1766
 
extern void             dev_add_offload(struct packet_offload *po);
1767
 
extern void             dev_remove_offload(struct packet_offload *po);
1768
 
extern void             __dev_remove_offload(struct packet_offload *po);
 
1801
int netdev_boot_setup_check(struct net_device *dev);
 
1802
unsigned long netdev_boot_base(const char *prefix, int unit);
 
1803
struct net_device *dev_getbyhwaddr_rcu(struct net *net, unsigned short type,
 
1804
                                       const char *hwaddr);
 
1805
struct net_device *dev_getfirstbyhwtype(struct net *net, unsigned short type);
 
1806
struct net_device *__dev_getfirstbyhwtype(struct net *net, unsigned short type);
 
1807
void dev_add_pack(struct packet_type *pt);
 
1808
void dev_remove_pack(struct packet_type *pt);
 
1809
void __dev_remove_pack(struct packet_type *pt);
 
1810
void dev_add_offload(struct packet_offload *po);
 
1811
void dev_remove_offload(struct packet_offload *po);
 
1812
void __dev_remove_offload(struct packet_offload *po);
1769
1813
 
1770
 
extern struct net_device        *dev_get_by_flags_rcu(struct net *net, unsigned short flags,
1771
 
                                                      unsigned short mask);
1772
 
extern struct net_device        *dev_get_by_name(struct net *net, const char *name);
1773
 
extern struct net_device        *dev_get_by_name_rcu(struct net *net, const char *name);
1774
 
extern struct net_device        *__dev_get_by_name(struct net *net, const char *name);
1775
 
extern int              dev_alloc_name(struct net_device *dev, const char *name);
1776
 
extern int              dev_open(struct net_device *dev);
1777
 
extern int              dev_close(struct net_device *dev);
1778
 
extern void             dev_disable_lro(struct net_device *dev);
1779
 
extern int              dev_loopback_xmit(struct sk_buff *newskb);
1780
 
extern int              dev_queue_xmit(struct sk_buff *skb);
1781
 
extern int              register_netdevice(struct net_device *dev);
1782
 
extern void             unregister_netdevice_queue(struct net_device *dev,
1783
 
                                                   struct list_head *head);
1784
 
extern void             unregister_netdevice_many(struct list_head *head);
 
1814
struct net_device *dev_get_by_flags_rcu(struct net *net, unsigned short flags,
 
1815
                                        unsigned short mask);
 
1816
struct net_device *dev_get_by_name(struct net *net, const char *name);
 
1817
struct net_device *dev_get_by_name_rcu(struct net *net, const char *name);
 
1818
struct net_device *__dev_get_by_name(struct net *net, const char *name);
 
1819
int dev_alloc_name(struct net_device *dev, const char *name);
 
1820
int dev_open(struct net_device *dev);
 
1821
int dev_close(struct net_device *dev);
 
1822
void dev_disable_lro(struct net_device *dev);
 
1823
int dev_loopback_xmit(struct sk_buff *newskb);
 
1824
int dev_queue_xmit(struct sk_buff *skb);
 
1825
int dev_queue_xmit_accel(struct sk_buff *skb, void *accel_priv);
 
1826
int register_netdevice(struct net_device *dev);
 
1827
void unregister_netdevice_queue(struct net_device *dev, struct list_head *head);
 
1828
void unregister_netdevice_many(struct list_head *head);
1785
1829
static inline void unregister_netdevice(struct net_device *dev)
1786
1830
{
1787
1831
        unregister_netdevice_queue(dev, NULL);
1788
1832
}
1789
1833
 
1790
 
extern int              netdev_refcnt_read(const struct net_device *dev);
1791
 
extern void             free_netdev(struct net_device *dev);
1792
 
extern void             synchronize_net(void);
1793
 
extern int              init_dummy_netdev(struct net_device *dev);
 
1834
int netdev_refcnt_read(const struct net_device *dev);
 
1835
void free_netdev(struct net_device *dev);
 
1836
void netdev_freemem(struct net_device *dev);
 
1837
void synchronize_net(void);
 
1838
int init_dummy_netdev(struct net_device *dev);
1794
1839
 
1795
 
extern struct net_device        *dev_get_by_index(struct net *net, int ifindex);
1796
 
extern struct net_device        *__dev_get_by_index(struct net *net, int ifindex);
1797
 
extern struct net_device        *dev_get_by_index_rcu(struct net *net, int ifindex);
1798
 
extern int              netdev_get_name(struct net *net, char *name, int ifindex);
1799
 
extern int              dev_restart(struct net_device *dev);
 
1840
struct net_device *dev_get_by_index(struct net *net, int ifindex);
 
1841
struct net_device *__dev_get_by_index(struct net *net, int ifindex);
 
1842
struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex);
 
1843
int netdev_get_name(struct net *net, char *name, int ifindex);
 
1844
int dev_restart(struct net_device *dev);
1800
1845
#ifdef CONFIG_NETPOLL_TRAP
1801
 
extern int              netpoll_trap(void);
 
1846
int netpoll_trap(void);
1802
1847
#endif
1803
 
extern int             skb_gro_receive(struct sk_buff **head,
1804
 
                                       struct sk_buff *skb);
 
1848
int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb);
1805
1849
 
1806
1850
static inline unsigned int skb_gro_offset(const struct sk_buff *skb)
1807
1851
{
1872
1916
        return dev->header_ops->parse(skb, haddr);
1873
1917
}
1874
1918
 
 
1919
static inline int dev_rebuild_header(struct sk_buff *skb)
 
1920
{
 
1921
        const struct net_device *dev = skb->dev;
 
1922
 
 
1923
        if (!dev->header_ops || !dev->header_ops->rebuild)
 
1924
                return 0;
 
1925
        return dev->header_ops->rebuild(skb);
 
1926
}
 
1927
 
1875
1928
typedef int gifconf_func_t(struct net_device * dev, char __user * bufptr, int len);
1876
 
extern int              register_gifconf(unsigned int family, gifconf_func_t * gifconf);
 
1929
int register_gifconf(unsigned int family, gifconf_func_t *gifconf);
1877
1930
static inline int unregister_gifconf(unsigned int family)
1878
1931
{
1879
1932
        return register_gifconf(family, NULL);
1944
1997
 
1945
1998
DECLARE_PER_CPU_ALIGNED(struct softnet_data, softnet_data);
1946
1999
 
1947
 
extern void __netif_schedule(struct Qdisc *q);
 
2000
void __netif_schedule(struct Qdisc *q);
1948
2001
 
1949
2002
static inline void netif_schedule_queue(struct netdev_queue *txq)
1950
2003
{
2264
2317
}
2265
2318
 
2266
2319
#ifdef CONFIG_XPS
2267
 
extern int netif_set_xps_queue(struct net_device *dev,
2268
 
                               const struct cpumask *mask,
2269
 
                               u16 index);
 
2320
int netif_set_xps_queue(struct net_device *dev, const struct cpumask *mask,
 
2321
                        u16 index);
2270
2322
#else
2271
2323
static inline int netif_set_xps_queue(struct net_device *dev,
2272
2324
                                      const struct cpumask *mask,
2297
2349
        return dev->num_tx_queues > 1;
2298
2350
}
2299
2351
 
2300
 
extern int netif_set_real_num_tx_queues(struct net_device *dev,
2301
 
                                        unsigned int txq);
 
2352
int netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq);
2302
2353
 
2303
2354
#ifdef CONFIG_RPS
2304
 
extern int netif_set_real_num_rx_queues(struct net_device *dev,
2305
 
                                        unsigned int rxq);
 
2355
int netif_set_real_num_rx_queues(struct net_device *dev, unsigned int rxq);
2306
2356
#else
2307
2357
static inline int netif_set_real_num_rx_queues(struct net_device *dev,
2308
2358
                                                unsigned int rxq)
2329
2379
}
2330
2380
 
2331
2381
#define DEFAULT_MAX_NUM_RSS_QUEUES      (8)
2332
 
extern int netif_get_num_default_rss_queues(void);
 
2382
int netif_get_num_default_rss_queues(void);
2333
2383
 
2334
2384
/* Use this variant when it is known for sure that it
2335
2385
 * is executing from hardware interrupt context or with hardware interrupts
2336
2386
 * disabled.
2337
2387
 */
2338
 
extern void dev_kfree_skb_irq(struct sk_buff *skb);
 
2388
void dev_kfree_skb_irq(struct sk_buff *skb);
2339
2389
 
2340
2390
/* Use this variant in places where it could be invoked
2341
2391
 * from either hardware interrupt or other context, with hardware interrupts
2342
2392
 * either disabled or enabled.
2343
2393
 */
2344
 
extern void dev_kfree_skb_any(struct sk_buff *skb);
 
2394
void dev_kfree_skb_any(struct sk_buff *skb);
2345
2395
 
2346
 
extern int              netif_rx(struct sk_buff *skb);
2347
 
extern int              netif_rx_ni(struct sk_buff *skb);
2348
 
extern int              netif_receive_skb(struct sk_buff *skb);
2349
 
extern gro_result_t     napi_gro_receive(struct napi_struct *napi,
2350
 
                                         struct sk_buff *skb);
2351
 
extern void             napi_gro_flush(struct napi_struct *napi, bool flush_old);
2352
 
extern struct sk_buff * napi_get_frags(struct napi_struct *napi);
2353
 
extern gro_result_t     napi_gro_frags(struct napi_struct *napi);
 
2396
int netif_rx(struct sk_buff *skb);
 
2397
int netif_rx_ni(struct sk_buff *skb);
 
2398
int netif_receive_skb(struct sk_buff *skb);
 
2399
gro_result_t napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb);
 
2400
void napi_gro_flush(struct napi_struct *napi, bool flush_old);
 
2401
struct sk_buff *napi_get_frags(struct napi_struct *napi);
 
2402
gro_result_t napi_gro_frags(struct napi_struct *napi);
2354
2403
 
2355
2404
static inline void napi_free_frags(struct napi_struct *napi)
2356
2405
{
2358
2407
        napi->skb = NULL;
2359
2408
}
2360
2409
 
2361
 
extern int netdev_rx_handler_register(struct net_device *dev,
2362
 
                                      rx_handler_func_t *rx_handler,
2363
 
                                      void *rx_handler_data);
2364
 
extern void netdev_rx_handler_unregister(struct net_device *dev);
 
2410
int netdev_rx_handler_register(struct net_device *dev,
 
2411
                               rx_handler_func_t *rx_handler,
 
2412
                               void *rx_handler_data);
 
2413
void netdev_rx_handler_unregister(struct net_device *dev);
2365
2414
 
2366
 
extern bool             dev_valid_name(const char *name);
2367
 
extern int              dev_ioctl(struct net *net, unsigned int cmd, void __user *);
2368
 
extern int              dev_ethtool(struct net *net, struct ifreq *);
2369
 
extern unsigned int     dev_get_flags(const struct net_device *);
2370
 
extern int              __dev_change_flags(struct net_device *, unsigned int flags);
2371
 
extern int              dev_change_flags(struct net_device *, unsigned int);
2372
 
extern void             __dev_notify_flags(struct net_device *, unsigned int old_flags);
2373
 
extern int              dev_change_name(struct net_device *, const char *);
2374
 
extern int              dev_set_alias(struct net_device *, const char *, size_t);
2375
 
extern int              dev_change_net_namespace(struct net_device *,
2376
 
                                                 struct net *, const char *);
2377
 
extern int              dev_set_mtu(struct net_device *, int);
2378
 
extern void             dev_set_group(struct net_device *, int);
2379
 
extern int              dev_set_mac_address(struct net_device *,
2380
 
                                            struct sockaddr *);
2381
 
extern int              dev_change_carrier(struct net_device *,
2382
 
                                           bool new_carrier);
2383
 
extern int              dev_get_phys_port_id(struct net_device *dev,
2384
 
                                             struct netdev_phys_port_id *ppid);
2385
 
extern int              dev_hard_start_xmit(struct sk_buff *skb,
2386
 
                                            struct net_device *dev,
2387
 
                                            struct netdev_queue *txq);
2388
 
extern int              dev_forward_skb(struct net_device *dev,
2389
 
                                        struct sk_buff *skb);
 
2415
bool dev_valid_name(const char *name);
 
2416
int dev_ioctl(struct net *net, unsigned int cmd, void __user *);
 
2417
int dev_ethtool(struct net *net, struct ifreq *);
 
2418
unsigned int dev_get_flags(const struct net_device *);
 
2419
int __dev_change_flags(struct net_device *, unsigned int flags);
 
2420
int dev_change_flags(struct net_device *, unsigned int);
 
2421
void __dev_notify_flags(struct net_device *, unsigned int old_flags,
 
2422
                        unsigned int gchanges);
 
2423
int dev_change_name(struct net_device *, const char *);
 
2424
int dev_set_alias(struct net_device *, const char *, size_t);
 
2425
int dev_change_net_namespace(struct net_device *, struct net *, const char *);
 
2426
int dev_set_mtu(struct net_device *, int);
 
2427
void dev_set_group(struct net_device *, int);
 
2428
int dev_set_mac_address(struct net_device *, struct sockaddr *);
 
2429
int dev_change_carrier(struct net_device *, bool new_carrier);
 
2430
int dev_get_phys_port_id(struct net_device *dev,
 
2431
                         struct netdev_phys_port_id *ppid);
 
2432
int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
 
2433
                        struct netdev_queue *txq);
 
2434
int dev_forward_skb(struct net_device *dev, struct sk_buff *skb);
2390
2435
 
2391
2436
extern int              netdev_budget;
2392
2437
 
2393
2438
/* Called by rtnetlink.c:rtnl_unlock() */
2394
 
extern void netdev_run_todo(void);
 
2439
void netdev_run_todo(void);
2395
2440
 
2396
2441
/**
2397
2442
 *      dev_put - release reference to device
2424
2469
 * kind of lower layer not just hardware media.
2425
2470
 */
2426
2471
 
2427
 
extern void linkwatch_init_dev(struct net_device *dev);
2428
 
extern void linkwatch_fire_event(struct net_device *dev);
2429
 
extern void linkwatch_forget_dev(struct net_device *dev);
 
2472
void linkwatch_init_dev(struct net_device *dev);
 
2473
void linkwatch_fire_event(struct net_device *dev);
 
2474
void linkwatch_forget_dev(struct net_device *dev);
2430
2475
 
2431
2476
/**
2432
2477
 *      netif_carrier_ok - test if carrier present
2439
2484
        return !test_bit(__LINK_STATE_NOCARRIER, &dev->state);
2440
2485
}
2441
2486
 
2442
 
extern unsigned long dev_trans_start(struct net_device *dev);
2443
 
 
2444
 
extern void __netdev_watchdog_up(struct net_device *dev);
2445
 
 
2446
 
extern void netif_carrier_on(struct net_device *dev);
2447
 
 
2448
 
extern void netif_carrier_off(struct net_device *dev);
 
2487
unsigned long dev_trans_start(struct net_device *dev);
 
2488
 
 
2489
void __netdev_watchdog_up(struct net_device *dev);
 
2490
 
 
2491
void netif_carrier_on(struct net_device *dev);
 
2492
 
 
2493
void netif_carrier_off(struct net_device *dev);
2449
2494
 
2450
2495
/**
2451
2496
 *      netif_dormant_on - mark device as dormant.
2513
2558
        return test_bit(__LINK_STATE_PRESENT, &dev->state);
2514
2559
}
2515
2560
 
2516
 
extern void netif_device_detach(struct net_device *dev);
 
2561
void netif_device_detach(struct net_device *dev);
2517
2562
 
2518
 
extern void netif_device_attach(struct net_device *dev);
 
2563
void netif_device_attach(struct net_device *dev);
2519
2564
 
2520
2565
/*
2521
2566
 * Network interface message level settings
2724
2769
 
2725
2770
/* These functions live elsewhere (drivers/net/net_init.c, but related) */
2726
2771
 
2727
 
extern void             ether_setup(struct net_device *dev);
 
2772
void ether_setup(struct net_device *dev);
2728
2773
 
2729
2774
/* Support for loadable net-drivers */
2730
 
extern struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
2731
 
                                       void (*setup)(struct net_device *),
2732
 
                                       unsigned int txqs, unsigned int rxqs);
 
2775
struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
 
2776
                                    void (*setup)(struct net_device *),
 
2777
                                    unsigned int txqs, unsigned int rxqs);
2733
2778
#define alloc_netdev(sizeof_priv, name, setup) \
2734
2779
        alloc_netdev_mqs(sizeof_priv, name, setup, 1, 1)
2735
2780
 
2736
2781
#define alloc_netdev_mq(sizeof_priv, name, setup, count) \
2737
2782
        alloc_netdev_mqs(sizeof_priv, name, setup, count, count)
2738
2783
 
2739
 
extern int              register_netdev(struct net_device *dev);
2740
 
extern void             unregister_netdev(struct net_device *dev);
 
2784
int register_netdev(struct net_device *dev);
 
2785
void unregister_netdev(struct net_device *dev);
2741
2786
 
2742
2787
/* General hardware address lists handling functions */
2743
 
extern int __hw_addr_add_multiple(struct netdev_hw_addr_list *to_list,
2744
 
                                  struct netdev_hw_addr_list *from_list,
2745
 
                                  int addr_len, unsigned char addr_type);
2746
 
extern void __hw_addr_del_multiple(struct netdev_hw_addr_list *to_list,
2747
 
                                   struct netdev_hw_addr_list *from_list,
2748
 
                                   int addr_len, unsigned char addr_type);
2749
 
extern int __hw_addr_sync(struct netdev_hw_addr_list *to_list,
2750
 
                          struct netdev_hw_addr_list *from_list,
2751
 
                          int addr_len);
2752
 
extern void __hw_addr_unsync(struct netdev_hw_addr_list *to_list,
2753
 
                             struct netdev_hw_addr_list *from_list,
2754
 
                             int addr_len);
2755
 
extern void __hw_addr_flush(struct netdev_hw_addr_list *list);
2756
 
extern void __hw_addr_init(struct netdev_hw_addr_list *list);
 
2788
int __hw_addr_add_multiple(struct netdev_hw_addr_list *to_list,
 
2789
                           struct netdev_hw_addr_list *from_list,
 
2790
                           int addr_len, unsigned char addr_type);
 
2791
void __hw_addr_del_multiple(struct netdev_hw_addr_list *to_list,
 
2792
                            struct netdev_hw_addr_list *from_list,
 
2793
                            int addr_len, unsigned char addr_type);
 
2794
int __hw_addr_sync(struct netdev_hw_addr_list *to_list,
 
2795
                   struct netdev_hw_addr_list *from_list, int addr_len);
 
2796
void __hw_addr_unsync(struct netdev_hw_addr_list *to_list,
 
2797
                      struct netdev_hw_addr_list *from_list, int addr_len);
 
2798
void __hw_addr_flush(struct netdev_hw_addr_list *list);
 
2799
void __hw_addr_init(struct netdev_hw_addr_list *list);
2757
2800
 
2758
2801
/* Functions used for device addresses handling */
2759
 
extern int dev_addr_add(struct net_device *dev, const unsigned char *addr,
2760
 
                        unsigned char addr_type);
2761
 
extern int dev_addr_del(struct net_device *dev, const unsigned char *addr,
2762
 
                        unsigned char addr_type);
2763
 
extern int dev_addr_add_multiple(struct net_device *to_dev,
2764
 
                                 struct net_device *from_dev,
2765
 
                                 unsigned char addr_type);
2766
 
extern int dev_addr_del_multiple(struct net_device *to_dev,
2767
 
                                 struct net_device *from_dev,
2768
 
                                 unsigned char addr_type);
2769
 
extern void dev_addr_flush(struct net_device *dev);
2770
 
extern int dev_addr_init(struct net_device *dev);
 
2802
int dev_addr_add(struct net_device *dev, const unsigned char *addr,
 
2803
                 unsigned char addr_type);
 
2804
int dev_addr_del(struct net_device *dev, const unsigned char *addr,
 
2805
                 unsigned char addr_type);
 
2806
int dev_addr_add_multiple(struct net_device *to_dev,
 
2807
                          struct net_device *from_dev, unsigned char addr_type);
 
2808
int dev_addr_del_multiple(struct net_device *to_dev,
 
2809
                          struct net_device *from_dev, unsigned char addr_type);
 
2810
void dev_addr_flush(struct net_device *dev);
 
2811
int dev_addr_init(struct net_device *dev);
2771
2812
 
2772
2813
/* Functions used for unicast addresses handling */
2773
 
extern int dev_uc_add(struct net_device *dev, const unsigned char *addr);
2774
 
extern int dev_uc_add_excl(struct net_device *dev, const unsigned char *addr);
2775
 
extern int dev_uc_del(struct net_device *dev, const unsigned char *addr);
2776
 
extern int dev_uc_sync(struct net_device *to, struct net_device *from);
2777
 
extern int dev_uc_sync_multiple(struct net_device *to, struct net_device *from);
2778
 
extern void dev_uc_unsync(struct net_device *to, struct net_device *from);
2779
 
extern void dev_uc_flush(struct net_device *dev);
2780
 
extern void dev_uc_init(struct net_device *dev);
 
2814
int dev_uc_add(struct net_device *dev, const unsigned char *addr);
 
2815
int dev_uc_add_excl(struct net_device *dev, const unsigned char *addr);
 
2816
int dev_uc_del(struct net_device *dev, const unsigned char *addr);
 
2817
int dev_uc_sync(struct net_device *to, struct net_device *from);
 
2818
int dev_uc_sync_multiple(struct net_device *to, struct net_device *from);
 
2819
void dev_uc_unsync(struct net_device *to, struct net_device *from);
 
2820
void dev_uc_flush(struct net_device *dev);
 
2821
void dev_uc_init(struct net_device *dev);
2781
2822
 
2782
2823
/* Functions used for multicast addresses handling */
2783
 
extern int dev_mc_add(struct net_device *dev, const unsigned char *addr);
2784
 
extern int dev_mc_add_global(struct net_device *dev, const unsigned char *addr);
2785
 
extern int dev_mc_add_excl(struct net_device *dev, const unsigned char *addr);
2786
 
extern int dev_mc_del(struct net_device *dev, const unsigned char *addr);
2787
 
extern int dev_mc_del_global(struct net_device *dev, const unsigned char *addr);
2788
 
extern int dev_mc_sync(struct net_device *to, struct net_device *from);
2789
 
extern int dev_mc_sync_multiple(struct net_device *to, struct net_device *from);
2790
 
extern void dev_mc_unsync(struct net_device *to, struct net_device *from);
2791
 
extern void dev_mc_flush(struct net_device *dev);
2792
 
extern void dev_mc_init(struct net_device *dev);
 
2824
int dev_mc_add(struct net_device *dev, const unsigned char *addr);
 
2825
int dev_mc_add_global(struct net_device *dev, const unsigned char *addr);
 
2826
int dev_mc_add_excl(struct net_device *dev, const unsigned char *addr);
 
2827
int dev_mc_del(struct net_device *dev, const unsigned char *addr);
 
2828
int dev_mc_del_global(struct net_device *dev, const unsigned char *addr);
 
2829
int dev_mc_sync(struct net_device *to, struct net_device *from);
 
2830
int dev_mc_sync_multiple(struct net_device *to, struct net_device *from);
 
2831
void dev_mc_unsync(struct net_device *to, struct net_device *from);
 
2832
void dev_mc_flush(struct net_device *dev);
 
2833
void dev_mc_init(struct net_device *dev);
2793
2834
 
2794
2835
/* Functions used for secondary unicast and multicast support */
2795
 
extern void             dev_set_rx_mode(struct net_device *dev);
2796
 
extern void             __dev_set_rx_mode(struct net_device *dev);
2797
 
extern int              dev_set_promiscuity(struct net_device *dev, int inc);
2798
 
extern int              dev_set_allmulti(struct net_device *dev, int inc);
2799
 
extern void             netdev_state_change(struct net_device *dev);
2800
 
extern void             netdev_notify_peers(struct net_device *dev);
2801
 
extern void             netdev_features_change(struct net_device *dev);
 
2836
void dev_set_rx_mode(struct net_device *dev);
 
2837
void __dev_set_rx_mode(struct net_device *dev);
 
2838
int dev_set_promiscuity(struct net_device *dev, int inc);
 
2839
int dev_set_allmulti(struct net_device *dev, int inc);
 
2840
void netdev_state_change(struct net_device *dev);
 
2841
void netdev_notify_peers(struct net_device *dev);
 
2842
void netdev_features_change(struct net_device *dev);
2802
2843
/* Load a device via the kmod */
2803
 
extern void             dev_load(struct net *net, const char *name);
2804
 
extern struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
2805
 
                                               struct rtnl_link_stats64 *storage);
2806
 
extern void netdev_stats_to_stats64(struct rtnl_link_stats64 *stats64,
2807
 
                                    const struct net_device_stats *netdev_stats);
 
2844
void dev_load(struct net *net, const char *name);
 
2845
struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
 
2846
                                        struct rtnl_link_stats64 *storage);
 
2847
void netdev_stats_to_stats64(struct rtnl_link_stats64 *stats64,
 
2848
                             const struct net_device_stats *netdev_stats);
2808
2849
 
2809
2850
extern int              netdev_max_backlog;
2810
2851
extern int              netdev_tstamp_prequeue;
2811
2852
extern int              weight_p;
2812
2853
extern int              bpf_jit_enable;
2813
2854
 
2814
 
extern bool netdev_has_upper_dev(struct net_device *dev,
2815
 
                                 struct net_device *upper_dev);
2816
 
extern bool netdev_has_any_upper_dev(struct net_device *dev);
2817
 
extern struct net_device *netdev_upper_get_next_dev_rcu(struct net_device *dev,
2818
 
                                                        struct list_head **iter);
 
2855
bool netdev_has_upper_dev(struct net_device *dev, struct net_device *upper_dev);
 
2856
bool netdev_has_any_upper_dev(struct net_device *dev);
 
2857
struct net_device *netdev_all_upper_get_next_dev_rcu(struct net_device *dev,
 
2858
                                                     struct list_head **iter);
2819
2859
 
2820
2860
/* iterate through upper list, must be called under RCU read lock */
2821
 
#define netdev_for_each_upper_dev_rcu(dev, upper, iter) \
2822
 
        for (iter = &(dev)->upper_dev_list, \
2823
 
             upper = netdev_upper_get_next_dev_rcu(dev, &(iter)); \
2824
 
             upper; \
2825
 
             upper = netdev_upper_get_next_dev_rcu(dev, &(iter)))
2826
 
 
2827
 
extern struct net_device *netdev_master_upper_dev_get(struct net_device *dev);
2828
 
extern struct net_device *netdev_master_upper_dev_get_rcu(struct net_device *dev);
2829
 
extern int netdev_upper_dev_link(struct net_device *dev,
 
2861
#define netdev_for_each_all_upper_dev_rcu(dev, updev, iter) \
 
2862
        for (iter = &(dev)->all_adj_list.upper, \
 
2863
             updev = netdev_all_upper_get_next_dev_rcu(dev, &(iter)); \
 
2864
             updev; \
 
2865
             updev = netdev_all_upper_get_next_dev_rcu(dev, &(iter)))
 
2866
 
 
2867
void *netdev_lower_get_next_private(struct net_device *dev,
 
2868
                                    struct list_head **iter);
 
2869
void *netdev_lower_get_next_private_rcu(struct net_device *dev,
 
2870
                                        struct list_head **iter);
 
2871
 
 
2872
#define netdev_for_each_lower_private(dev, priv, iter) \
 
2873
        for (iter = (dev)->adj_list.lower.next, \
 
2874
             priv = netdev_lower_get_next_private(dev, &(iter)); \
 
2875
             priv; \
 
2876
             priv = netdev_lower_get_next_private(dev, &(iter)))
 
2877
 
 
2878
#define netdev_for_each_lower_private_rcu(dev, priv, iter) \
 
2879
        for (iter = &(dev)->adj_list.lower, \
 
2880
             priv = netdev_lower_get_next_private_rcu(dev, &(iter)); \
 
2881
             priv; \
 
2882
             priv = netdev_lower_get_next_private_rcu(dev, &(iter)))
 
2883
 
 
2884
void *netdev_adjacent_get_private(struct list_head *adj_list);
 
2885
struct net_device *netdev_master_upper_dev_get(struct net_device *dev);
 
2886
struct net_device *netdev_master_upper_dev_get_rcu(struct net_device *dev);
 
2887
int netdev_upper_dev_link(struct net_device *dev, struct net_device *upper_dev);
 
2888
int netdev_master_upper_dev_link(struct net_device *dev,
2830
2889
                                 struct net_device *upper_dev);
2831
 
extern int netdev_master_upper_dev_link(struct net_device *dev,
2832
 
                                        struct net_device *upper_dev);
2833
 
extern void netdev_upper_dev_unlink(struct net_device *dev,
2834
 
                                    struct net_device *upper_dev);
2835
 
extern int skb_checksum_help(struct sk_buff *skb);
2836
 
extern struct sk_buff *__skb_gso_segment(struct sk_buff *skb,
2837
 
        netdev_features_t features, bool tx_path);
2838
 
extern struct sk_buff *skb_mac_gso_segment(struct sk_buff *skb,
2839
 
                                          netdev_features_t features);
 
2890
int netdev_master_upper_dev_link_private(struct net_device *dev,
 
2891
                                         struct net_device *upper_dev,
 
2892
                                         void *private);
 
2893
void netdev_upper_dev_unlink(struct net_device *dev,
 
2894
                             struct net_device *upper_dev);
 
2895
void *netdev_lower_dev_get_private_rcu(struct net_device *dev,
 
2896
                                       struct net_device *lower_dev);
 
2897
void *netdev_lower_dev_get_private(struct net_device *dev,
 
2898
                                   struct net_device *lower_dev);
 
2899
int skb_checksum_help(struct sk_buff *skb);
 
2900
struct sk_buff *__skb_gso_segment(struct sk_buff *skb,
 
2901
                                  netdev_features_t features, bool tx_path);
 
2902
struct sk_buff *skb_mac_gso_segment(struct sk_buff *skb,
 
2903
                                    netdev_features_t features);
2840
2904
 
2841
2905
static inline
2842
2906
struct sk_buff *skb_gso_segment(struct sk_buff *skb, netdev_features_t features)
2858
2922
}
2859
2923
 
2860
2924
#ifdef CONFIG_BUG
2861
 
extern void netdev_rx_csum_fault(struct net_device *dev);
 
2925
void netdev_rx_csum_fault(struct net_device *dev);
2862
2926
#else
2863
2927
static inline void netdev_rx_csum_fault(struct net_device *dev)
2864
2928
{
2865
2929
}
2866
2930
#endif
2867
2931
/* rx skb timestamps */
2868
 
extern void             net_enable_timestamp(void);
2869
 
extern void             net_disable_timestamp(void);
 
2932
void net_enable_timestamp(void);
 
2933
void net_disable_timestamp(void);
2870
2934
 
2871
2935
#ifdef CONFIG_PROC_FS
2872
 
extern int __init dev_proc_init(void);
 
2936
int __init dev_proc_init(void);
2873
2937
#else
2874
2938
#define dev_proc_init() 0
2875
2939
#endif
2876
2940
 
2877
 
extern int netdev_class_create_file(struct class_attribute *class_attr);
2878
 
extern void netdev_class_remove_file(struct class_attribute *class_attr);
 
2941
int netdev_class_create_file_ns(struct class_attribute *class_attr,
 
2942
                                const void *ns);
 
2943
void netdev_class_remove_file_ns(struct class_attribute *class_attr,
 
2944
                                 const void *ns);
 
2945
 
 
2946
static inline int netdev_class_create_file(struct class_attribute *class_attr)
 
2947
{
 
2948
        return netdev_class_create_file_ns(class_attr, NULL);
 
2949
}
 
2950
 
 
2951
static inline void netdev_class_remove_file(struct class_attribute *class_attr)
 
2952
{
 
2953
        netdev_class_remove_file_ns(class_attr, NULL);
 
2954
}
2879
2955
 
2880
2956
extern struct kobj_ns_type_operations net_ns_type_operations;
2881
2957
 
2882
 
extern const char *netdev_drivername(const struct net_device *dev);
 
2958
const char *netdev_drivername(const struct net_device *dev);
2883
2959
 
2884
 
extern void linkwatch_run_queue(void);
 
2960
void linkwatch_run_queue(void);
2885
2961
 
2886
2962
static inline netdev_features_t netdev_get_wanted_features(
2887
2963
        struct net_device *dev)
2945
3021
        dev->gso_max_size = size;
2946
3022
}
2947
3023
 
 
3024
static inline void skb_gso_error_unwind(struct sk_buff *skb, __be16 protocol,
 
3025
                                        int pulled_hlen, u16 mac_offset,
 
3026
                                        int mac_len)
 
3027
{
 
3028
        skb->protocol = protocol;
 
3029
        skb->encapsulation = 1;
 
3030
        skb_push(skb, pulled_hlen);
 
3031
        skb_reset_transport_header(skb);
 
3032
        skb->mac_header = mac_offset;
 
3033
        skb->network_header = skb->mac_header + mac_len;
 
3034
        skb->mac_len = mac_len;
 
3035
}
 
3036
 
 
3037
static inline bool netif_is_macvlan(struct net_device *dev)
 
3038
{
 
3039
        return dev->priv_flags & IFF_MACVLAN;
 
3040
}
 
3041
 
2948
3042
static inline bool netif_is_bond_master(struct net_device *dev)
2949
3043
{
2950
3044
        return dev->flags & IFF_MASTER && dev->priv_flags & IFF_BONDING;
2973
3067
        return dev->name;
2974
3068
}
2975
3069
 
2976
 
extern __printf(3, 4)
 
3070
__printf(3, 4)
2977
3071
int netdev_printk(const char *level, const struct net_device *dev,
2978
3072
                  const char *format, ...);
2979
 
extern __printf(2, 3)
 
3073
__printf(2, 3)
2980
3074
int netdev_emerg(const struct net_device *dev, const char *format, ...);
2981
 
extern __printf(2, 3)
 
3075
__printf(2, 3)
2982
3076
int netdev_alert(const struct net_device *dev, const char *format, ...);
2983
 
extern __printf(2, 3)
 
3077
__printf(2, 3)
2984
3078
int netdev_crit(const struct net_device *dev, const char *format, ...);
2985
 
extern __printf(2, 3)
 
3079
__printf(2, 3)
2986
3080
int netdev_err(const struct net_device *dev, const char *format, ...);
2987
 
extern __printf(2, 3)
 
3081
__printf(2, 3)
2988
3082
int netdev_warn(const struct net_device *dev, const char *format, ...);
2989
 
extern __printf(2, 3)
 
3083
__printf(2, 3)
2990
3084
int netdev_notice(const struct net_device *dev, const char *format, ...);
2991
 
extern __printf(2, 3)
 
3085
__printf(2, 3)
2992
3086
int netdev_info(const struct net_device *dev, const char *format, ...);
2993
3087
 
2994
3088
#define MODULE_ALIAS_NETDEV(device) \
3029
3123
 * file/line information and a backtrace.
3030
3124
 */
3031
3125
#define netdev_WARN(dev, format, args...)                       \
3032
 
        WARN(1, "netdevice: %s\n" format, netdev_name(dev), ##args);
 
3126
        WARN(1, "netdevice: %s\n" format, netdev_name(dev), ##args)
3033
3127
 
3034
3128
/* netif printk helpers, similar to netdev_printk */
3035
3129