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