Allow the datapath ID to be configured by changing the ofX MAC address.
[sliver-openvswitch.git] / datapath / datapath.h
1 /* Interface exported by OpenFlow module. */
2
3 #ifndef DATAPATH_H
4 #define DATAPATH_H 1
5
6 #include <linux/kernel.h>
7 #include <linux/mutex.h>
8 #include <linux/netlink.h>
9 #include <linux/netdevice.h>
10 #include <linux/workqueue.h>
11 #include <linux/skbuff.h>
12 #include "openflow/openflow.h"
13 #include "flow.h"
14
15
16 #define NL_FLOWS_PER_MESSAGE 100
17
18 #ifdef NDEBUG
19 #define dprintk(x...)
20 #else
21 #define dprintk(x...) printk(x)
22 #endif
23
24 /* Capabilities supported by this implementation. */
25 #define OFP_SUPPORTED_CAPABILITIES ( OFPC_FLOW_STATS \
26                 | OFPC_TABLE_STATS \
27                 | OFPC_PORT_STATS \
28                 | OFPC_MULTI_PHY_TX )
29
30 /* Actions supported by this implementation. */
31 #define OFP_SUPPORTED_ACTIONS ( (1 << OFPAT_OUTPUT) \
32                 | (1 << OFPAT_SET_VLAN_VID) \
33                 | (1 << OFPAT_SET_VLAN_PCP) \
34                 | (1 << OFPAT_STRIP_VLAN) \
35                 | (1 << OFPAT_SET_DL_SRC) \
36                 | (1 << OFPAT_SET_DL_DST) \
37                 | (1 << OFPAT_SET_NW_SRC) \
38                 | (1 << OFPAT_SET_NW_DST) \
39                 | (1 << OFPAT_SET_TP_SRC) \
40                 | (1 << OFPAT_SET_TP_DST) )
41
42 struct sk_buff;
43
44 #define DP_MAX_PORTS 255
45
46 struct datapath {
47         int dp_idx;
48
49         struct timer_list timer;        /* Expiration timer. */
50         struct sw_chain *chain;  /* Forwarding rules. */
51         struct task_struct *dp_task; /* Kernel thread for maintenance. */
52
53         /* Data related to the "of" device of this datapath */
54         struct net_device *netdev;
55
56         /* Configuration set from controller */
57         uint16_t flags;
58         uint16_t miss_send_len;
59
60         /* Switch ports. */
61         struct net_bridge_port *ports[DP_MAX_PORTS];
62         struct net_bridge_port *local_port; /* OFPP_LOCAL port. */
63         struct list_head port_list; /* All ports, including local_port. */
64 };
65
66 /* Information necessary to reply to the sender of an OpenFlow message. */
67 struct sender {
68         uint32_t xid;           /* OpenFlow transaction ID of request. */
69         uint32_t pid;           /* Netlink process ID of sending socket. */
70         uint32_t seq;           /* Netlink sequence ID of request. */
71 };
72
73 struct net_bridge_port {
74         u16     port_no;
75         u32 config;             /* Some subset of OFPPC_* flags. */
76         u32 state;              /* Some subset of OFPPS_* flags. */
77         spinlock_t lock;
78         struct work_struct port_task;
79         struct datapath *dp;
80         struct net_device *dev;
81         struct snat_conf *snat;  /* Only set if SNAT is configured for this port. */
82         struct list_head node;   /* Element in datapath.ports. */
83 };
84
85 extern struct mutex dp_mutex;
86 extern struct notifier_block dp_device_notifier;
87
88 int dp_del_switch_port(struct net_bridge_port *);
89 int dp_xmit_skb(struct sk_buff *skb);
90 int dp_output_port(struct datapath *, struct sk_buff *, int out_port,
91                    int ignore_no_fwd);
92 int dp_output_control(struct datapath *, struct sk_buff *, uint32_t, 
93                         size_t, int);
94 void dp_set_origin(struct datapath *, uint16_t, struct sk_buff *);
95 int dp_send_features_reply(struct datapath *, const struct sender *);
96 int dp_send_config_reply(struct datapath *, const struct sender *);
97 int dp_send_port_status(struct net_bridge_port *p, uint8_t status);
98 int dp_send_flow_expired(struct datapath *, struct sw_flow *,
99                          enum ofp_flow_expired_reason);
100 int dp_send_error_msg(struct datapath *, const struct sender *, 
101                         uint16_t, uint16_t, const void *, size_t);
102 int dp_update_port_flags(struct datapath *dp, const struct ofp_port_mod *opm);
103 int dp_send_echo_reply(struct datapath *, const struct sender *,
104                        const struct ofp_header *);
105 int dp_send_hello(struct datapath *, const struct sender *,
106                   const struct ofp_header *);
107
108 /* Should hold at least RCU read lock when calling */
109 struct datapath *dp_get(int dp_idx);
110
111 #endif /* datapath.h */