Implement OpenFlow hard timeouts.
[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/mutex.h>
7 #include <linux/netlink.h>
8 #include <linux/netdevice.h>
9 #include <linux/skbuff.h>
10 #include "openflow.h"
11 #include "flow.h"
12
13
14 #define NL_FLOWS_PER_MESSAGE 100
15
16 #ifdef NDEBUG
17 #define dprintk(x...)
18 #else
19 #define dprintk(x...) printk(x)
20 #endif
21
22 /* Capabilities supported by this implementation. */
23 #define OFP_SUPPORTED_CAPABILITIES ( OFPC_FLOW_STATS \
24                 | OFPC_TABLE_STATS \
25                 | OFPC_PORT_STATS \
26                 | OFPC_MULTI_PHY_TX )
27
28 /* Actions supported by this implementation. */
29 #define OFP_SUPPORTED_ACTIONS ( (1 << OFPAT_OUTPUT) \
30                 | (1 << OFPAT_SET_DL_VLAN) \
31                 | (1 << OFPAT_SET_DL_SRC) \
32                 | (1 << OFPAT_SET_DL_DST) \
33                 | (1 << OFPAT_SET_NW_SRC) \
34                 | (1 << OFPAT_SET_NW_DST) \
35                 | (1 << OFPAT_SET_TP_SRC) \
36                 | (1 << OFPAT_SET_TP_DST) )
37
38 struct sk_buff;
39
40 struct datapath {
41         int dp_idx;
42
43         /* Unique identifier for this datapath, incorporates the dp_idx and
44          * a hardware address */
45         uint64_t  id;
46
47         struct timer_list timer;        /* Expiration timer. */
48         struct sw_chain *chain;  /* Forwarding rules. */
49         struct task_struct *dp_task; /* Kernel thread for maintenance. */
50
51         /* Data related to the "of" device of this datapath */
52         struct net_device *netdev;
53
54         /* Configuration set from controller */
55         uint16_t flags;
56         uint16_t miss_send_len;
57
58         /* Switch ports. */
59         struct net_bridge_port *ports[OFPP_MAX];
60         struct net_bridge_port *local_port; /* OFPP_LOCAL port. */
61         struct list_head port_list; /* All ports, including local_port. */
62 };
63
64 /* Information necessary to reply to the sender of an OpenFlow message. */
65 struct sender {
66         uint32_t xid;           /* OpenFlow transaction ID of request. */
67         uint32_t pid;           /* Netlink process ID of sending socket. */
68         uint32_t seq;           /* Netlink sequence ID of request. */
69 };
70
71 extern struct mutex dp_mutex;
72
73 int dp_output_port(struct datapath *, struct sk_buff *, int out_port);
74 int dp_output_control(struct datapath *, struct sk_buff *, uint32_t, 
75                         size_t, int);
76 int dp_set_origin(struct datapath *, uint16_t, struct sk_buff *);
77 int dp_send_features_reply(struct datapath *, const struct sender *);
78 int dp_send_config_reply(struct datapath *, const struct sender *);
79 int dp_send_flow_expired(struct datapath *, struct sw_flow *,
80                          enum ofp_flow_expired_reason);
81 int dp_send_error_msg(struct datapath *, const struct sender *, 
82                         uint16_t, uint16_t, const uint8_t *, size_t);
83 int dp_update_port_flags(struct datapath *dp, const struct ofp_phy_port *opp);
84 int dp_send_echo_reply(struct datapath *, const struct sender *,
85                        const struct ofp_header *);
86
87 /* Should hold at least RCU read lock when calling */
88 struct datapath *dp_get(int dp_idx);
89
90 #endif /* datapath.h */