2 * Copyright (c) 2009 Nicira Networks.
3 * Distributed under the terms of the GNU GPL version 2.
5 * Significant portions of this file may be copied from parts of the Linux
6 * kernel, by Linus Torvalds and others.
9 /* Interface exported by openvswitch_mod. */
15 #include <linux/kernel.h>
16 #include <linux/mutex.h>
17 #include <linux/netlink.h>
18 #include <linux/netdevice.h>
19 #include <linux/workqueue.h>
20 #include <linux/skbuff.h>
21 #include <linux/version.h>
23 #include "brc_sysfs.h"
27 /* Mask for the priority bits in a vlan header. If we ever merge upstream
28 * then this should go into include/linux/if_vlan.h. */
29 #define VLAN_PCP_MASK 0xe000
31 #define DP_MAX_PORTS 256
32 #define DP_MAX_GROUPS 16
34 #define DP_L2_BITS (PAGE_SHIFT - ilog2(sizeof(struct sw_flow*)))
35 #define DP_L2_SIZE (1 << DP_L2_BITS)
38 #define DP_L1_BITS (PAGE_SHIFT - ilog2(sizeof(struct sw_flow**)))
39 #define DP_L1_SIZE (1 << DP_L1_BITS)
40 #define DP_L1_SHIFT DP_L2_BITS
42 #define DP_MAX_BUCKETS (DP_L1_SIZE * DP_L2_SIZE)
45 unsigned int n_buckets;
46 struct sw_flow ***flows[2];
51 #define DP_MAX_QUEUE_LEN 100
53 struct dp_stats_percpu {
60 struct dp_port_group {
71 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
74 struct kobject *ifobj;
81 struct sk_buff_head queues[DP_N_QUEUES];
82 wait_queue_head_t waitqueue;
86 struct dp_table *table;
89 struct dp_port_group *groups[DP_MAX_GROUPS];
93 struct net_bridge_port *ports[DP_MAX_PORTS];
94 struct list_head port_list; /* All ports, including local_port. */
97 struct dp_stats_percpu *stats_percpu;
100 struct net_bridge_port {
103 struct net_device *dev;
107 struct list_head node; /* Element in datapath.ports. */
110 extern struct notifier_block dp_device_notifier;
111 extern int (*dp_ioctl_hook)(struct net_device *dev, struct ifreq *rq, int cmd);
112 extern int (*dp_add_dp_hook)(struct datapath *dp);
113 extern int (*dp_del_dp_hook)(struct datapath *dp);
114 extern int (*dp_add_if_hook)(struct net_bridge_port *p);
115 extern int (*dp_del_if_hook)(struct net_bridge_port *p);
118 struct dp_table *dp_table_create(unsigned int n_buckets);
119 void dp_table_destroy(struct dp_table *, int free_flows);
120 struct sw_flow *dp_table_lookup(struct dp_table *, const struct odp_flow_key *);
121 struct sw_flow **dp_table_lookup_for_insert(struct dp_table *, const struct odp_flow_key *);
122 int dp_table_delete(struct dp_table *, struct sw_flow *);
123 int dp_table_expand(struct datapath *);
124 int dp_table_flush(struct datapath *);
125 int dp_table_foreach(struct dp_table *table,
126 int (*callback)(struct sw_flow *flow, void *aux),
129 void dp_process_received_packet(struct sk_buff *, struct net_bridge_port *);
130 int dp_del_port(struct net_bridge_port *, struct list_head *);
131 int dp_output_port(struct datapath *, struct sk_buff *, int out_port,
133 int dp_output_control(struct datapath *, struct sk_buff *, int, u32 arg);
134 void dp_set_origin(struct datapath *, u16, struct sk_buff *);
136 struct datapath *get_dp(int dp_idx);
138 static inline const char *dp_name(const struct datapath *dp)
140 return dp->ports[ODPP_LOCAL]->dev->name;
144 int skb_checksum_setup(struct sk_buff *skb);
146 static inline int skb_checksum_setup(struct sk_buff *skb)
152 #endif /* datapath.h */