]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/net/ipvlan/ipvlan.h
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[mirror_ubuntu-artful-kernel.git] / drivers / net / ipvlan / ipvlan.h
CommitLineData
2ad7bf36
MB
1/*
2 * Copyright (c) 2014 Mahesh Bandewar <maheshb@google.com>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of
7 * the License, or (at your option) any later version.
8 *
9 */
10#ifndef __IPVLAN_H
11#define __IPVLAN_H
12
13#include <linux/kernel.h>
14#include <linux/types.h>
15#include <linux/module.h>
16#include <linux/init.h>
17#include <linux/rculist.h>
18#include <linux/notifier.h>
19#include <linux/netdevice.h>
20#include <linux/etherdevice.h>
21#include <linux/if_arp.h>
22#include <linux/if_link.h>
23#include <linux/if_vlan.h>
24#include <linux/ip.h>
25#include <linux/inetdevice.h>
26#include <net/rtnetlink.h>
27#include <net/gre.h>
28#include <net/route.h>
29#include <net/addrconf.h>
30
31#define IPVLAN_DRV "ipvlan"
32#define IPV_DRV_VER "0.1"
33
34#define IPVLAN_HASH_SIZE (1 << BITS_PER_BYTE)
35#define IPVLAN_HASH_MASK (IPVLAN_HASH_SIZE - 1)
36
37#define IPVLAN_MAC_FILTER_BITS 8
38#define IPVLAN_MAC_FILTER_SIZE (1 << IPVLAN_MAC_FILTER_BITS)
39#define IPVLAN_MAC_FILTER_MASK (IPVLAN_MAC_FILTER_SIZE - 1)
40
41typedef enum {
42 IPVL_IPV6 = 0,
43 IPVL_ICMPV6,
44 IPVL_IPV4,
45 IPVL_ARP,
46} ipvl_hdr_type;
47
48struct ipvl_pcpu_stats {
49 u64 rx_pkts;
50 u64 rx_bytes;
51 u64 rx_mcast;
52 u64 tx_pkts;
53 u64 tx_bytes;
54 struct u64_stats_sync syncp;
55 u32 rx_errs;
56 u32 tx_drps;
57};
58
59struct ipvl_port;
60
61struct ipvl_dev {
62 struct net_device *dev;
63 struct list_head pnode;
64 struct ipvl_port *port;
65 struct net_device *phy_dev;
66 struct list_head addrs;
67 int ipv4cnt;
68 int ipv6cnt;
69 struct ipvl_pcpu_stats *pcpu_stats;
70 DECLARE_BITMAP(mac_filters, IPVLAN_MAC_FILTER_SIZE);
71 netdev_features_t sfeatures;
72 u32 msg_enable;
73 u16 mtu_adj;
74};
75
76struct ipvl_addr {
77 struct ipvl_dev *master; /* Back pointer to master */
78 union {
79 struct in6_addr ip6; /* IPv6 address on logical interface */
80 struct in_addr ip4; /* IPv4 address on logical interface */
81 } ipu;
82#define ip6addr ipu.ip6
83#define ip4addr ipu.ip4
84 struct hlist_node hlnode; /* Hash-table linkage */
85 struct list_head anode; /* logical-interface linkage */
86 struct rcu_head rcu;
87 ipvl_hdr_type atype;
88};
89
90struct ipvl_port {
91 struct net_device *dev;
92 struct hlist_head hlhead[IPVLAN_HASH_SIZE];
93 struct list_head ipvlans;
94 struct rcu_head rcu;
95 int count;
96 u16 mode;
97};
98
99static inline struct ipvl_port *ipvlan_port_get_rcu(const struct net_device *d)
100{
101 return rcu_dereference(d->rx_handler_data);
102}
103
104static inline struct ipvl_port *ipvlan_port_get_rtnl(const struct net_device *d)
105{
106 return rtnl_dereference(d->rx_handler_data);
107}
108
109static inline bool ipvlan_dev_master(struct net_device *d)
110{
111 return d->priv_flags & IFF_IPVLAN_MASTER;
112}
113
114static inline bool ipvlan_dev_slave(struct net_device *d)
115{
116 return d->priv_flags & IFF_IPVLAN_SLAVE;
117}
118
119void ipvlan_adjust_mtu(struct ipvl_dev *ipvlan, struct net_device *dev);
120void ipvlan_set_port_mode(struct ipvl_port *port, u32 nval);
121void ipvlan_init_secret(void);
122unsigned int ipvlan_mac_hash(const unsigned char *addr);
123rx_handler_result_t ipvlan_handle_frame(struct sk_buff **pskb);
124int ipvlan_queue_xmit(struct sk_buff *skb, struct net_device *dev);
125void ipvlan_ht_addr_add(struct ipvl_dev *ipvlan, struct ipvl_addr *addr);
126bool ipvlan_addr_busy(struct ipvl_dev *ipvlan, void *iaddr, bool is_v6);
127struct ipvl_addr *ipvlan_ht_addr_lookup(const struct ipvl_port *port,
128 const void *iaddr, bool is_v6);
129void ipvlan_ht_addr_del(struct ipvl_addr *addr, bool sync);
130#endif /* __IPVLAN_H */