Have the switch list all the stats types it support in the capabilities field.
[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_FLOW_STATS \
23                 | OFPC_TABLE_STATS \
24                 | OFPC_PORT_STATS \
25                 | OFPC_MULTI_PHY_TX )
26
27 /* Actions supported by this implementation. */
28 #define OFP_SUPPORTED_ACTIONS ( (1 << OFPAT_OUTPUT) \
29                 | (1 << OFPAT_SET_DL_VLAN) \
30                 | (1 << OFPAT_SET_DL_SRC) \
31                 | (1 << OFPAT_SET_DL_DST) \
32                 | (1 << OFPAT_SET_NW_SRC) \
33                 | (1 << OFPAT_SET_NW_DST) \
34                 | (1 << OFPAT_SET_TP_SRC) \
35                 | (1 << OFPAT_SET_TP_DST) )
36
37 struct sk_buff;
38
39 struct datapath {
40         int dp_idx;
41
42         /* Unique identifier for this datapath, incorporates the dp_idx and
43          * a hardware address */
44         uint64_t  id;
45
46         struct timer_list timer;        /* Expiration timer. */
47         struct sw_chain *chain;  /* Forwarding rules. */
48         struct task_struct *dp_task; /* Kernel thread for maintenance. */
49
50         /* Data related to the "of" device of this datapath */
51         struct net_device *netdev;
52
53         /* Configuration set from controller */
54         uint16_t flags;
55         uint16_t miss_send_len;
56
57         /* Switch ports. */
58         struct net_bridge_port *ports[OFPP_MAX];
59         struct net_bridge_port *local_port; /* OFPP_LOCAL port. */
60         struct list_head port_list; /* All ports, including local_port. */
61 };
62
63 /* Information necessary to reply to the sender of an OpenFlow message. */
64 struct sender {
65         uint32_t xid;           /* OpenFlow transaction ID of request. */
66         uint32_t pid;           /* Netlink process ID of sending socket. */
67         uint32_t seq;           /* Netlink sequence ID of request. */
68 };
69
70 int dp_output_port(struct datapath *, struct sk_buff *, int out_port);
71 int dp_output_control(struct datapath *, struct sk_buff *, uint32_t, 
72                         size_t, int);
73 int dp_set_origin(struct datapath *, uint16_t, struct sk_buff *);
74 int dp_send_features_reply(struct datapath *, const struct sender *);
75 int dp_send_config_reply(struct datapath *, const struct sender *);
76 int dp_send_flow_expired(struct datapath *, struct sw_flow *);
77 int dp_send_error_msg(struct datapath *, const struct sender *, 
78                         uint16_t, uint16_t, const uint8_t *, size_t);
79 int dp_update_port_flags(struct datapath *dp, const struct ofp_phy_port *opp);
80
81 /* Should hold at least RCU read lock when calling */
82 struct datapath *dp_get(int dp_idx);
83
84 #endif /* datapath.h */