ofp-util.h: Use NX_VENDOR_ID instead of literal numeric constant.
[sliver-openvswitch.git] / lib / xfif.h
1 /*
2  * Copyright (c) 2008, 2009, 2010 Nicira Networks.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17
18 #ifndef XFIF_H
19 #define XFIF_H 1
20
21 #include <stdbool.h>
22 #include <stddef.h>
23 #include <stdint.h>
24 #include "openflow/openflow.h"
25 #include "openvswitch/xflow.h"
26 #include "util.h"
27
28 #ifdef  __cplusplus
29 extern "C" {
30 #endif
31
32 struct xfif;
33 struct ofpbuf;
34 struct svec;
35 struct xfif_class;
36
37 void xf_run(void);
38 void xf_wait(void);
39
40 int xf_register_provider(const struct xfif_class *);
41 int xf_unregister_provider(const char *type);
42 void xf_enumerate_types(struct svec *types);
43
44 int xf_enumerate_names(const char *type, struct svec *names);
45 void xf_parse_name(const char *datapath_name, char **name, char **type);
46
47 int xfif_open(const char *name, const char *type, struct xfif **);
48 int xfif_create(const char *name, const char *type, struct xfif **);
49 int xfif_create_and_open(const char *name, const char *type, struct xfif **);
50 void xfif_close(struct xfif *);
51
52 const char *xfif_name(const struct xfif *);
53 const char *xfif_base_name(const struct xfif *);
54 int xfif_get_all_names(const struct xfif *, struct svec *);
55
56 int xfif_delete(struct xfif *);
57
58 int xfif_get_xf_stats(const struct xfif *, struct xflow_stats *);
59 int xfif_get_drop_frags(const struct xfif *, bool *drop_frags);
60 int xfif_set_drop_frags(struct xfif *, bool drop_frags);
61
62 int xfif_port_add(struct xfif *, const char *devname, uint16_t flags,
63                   uint16_t *port_no);
64 int xfif_port_del(struct xfif *, uint16_t port_no);
65 int xfif_port_query_by_number(const struct xfif *, uint16_t port_no,
66                               struct xflow_port *);
67 int xfif_port_query_by_name(const struct xfif *, const char *devname,
68                             struct xflow_port *);
69 int xfif_port_get_name(struct xfif *, uint16_t port_no,
70                        char *name, size_t name_size);
71 int xfif_port_list(const struct xfif *, struct xflow_port **, size_t *n_ports);
72
73 int xfif_port_poll(const struct xfif *, char **devnamep);
74 void xfif_port_poll_wait(const struct xfif *);
75
76 int xfif_port_group_get(const struct xfif *, uint16_t group,
77                         uint16_t **ports, size_t *n_ports);
78 int xfif_port_group_set(struct xfif *, uint16_t group,
79                         const uint16_t ports[], size_t n_ports);
80
81 int xfif_flow_flush(struct xfif *);
82 int xfif_flow_put(struct xfif *, struct xflow_flow_put *);
83 int xfif_flow_del(struct xfif *, struct xflow_flow *);
84 int xfif_flow_get(const struct xfif *, struct xflow_flow *);
85 int xfif_flow_get_multiple(const struct xfif *, struct xflow_flow[], size_t n);
86 int xfif_flow_list(const struct xfif *, struct xflow_flow[], size_t n,
87                    size_t *n_out);
88 int xfif_flow_list_all(const struct xfif *,
89                        struct xflow_flow **flowsp, size_t *np);
90
91 int xfif_execute(struct xfif *, uint16_t in_port,
92                  const union xflow_action[], size_t n_actions,
93                  const struct ofpbuf *);
94
95 /* Minimum number of bytes of headroom for a packet returned by xfif_recv()
96  * member function.  This headroom allows "struct xflow_msg" to be replaced by
97  * "struct ofp_packet_in" without copying the buffer. */
98 #define XFIF_RECV_MSG_PADDING (sizeof(struct ofp_packet_in) \
99                                - sizeof(struct xflow_msg))
100 BUILD_ASSERT_DECL(sizeof(struct ofp_packet_in) > sizeof(struct xflow_msg));
101 BUILD_ASSERT_DECL(XFIF_RECV_MSG_PADDING % 4 == 0);
102
103 int xfif_recv_get_mask(const struct xfif *, int *listen_mask);
104 int xfif_recv_set_mask(struct xfif *, int listen_mask);
105 int xfif_get_sflow_probability(const struct xfif *, uint32_t *probability);
106 int xfif_set_sflow_probability(struct xfif *, uint32_t probability);
107 int xfif_recv(struct xfif *, struct ofpbuf **);
108 int xfif_recv_purge(struct xfif *);
109 void xfif_recv_wait(struct xfif *);
110
111 void xfif_get_netflow_ids(const struct xfif *,
112                           uint8_t *engine_type, uint8_t *engine_id);
113
114 int xfif_queue_to_priority(const struct xfif *, uint32_t queue_id,
115                            uint32_t *priority);
116
117 #ifdef  __cplusplus
118 }
119 #endif
120
121 #endif /* xfif.h */