]> git.proxmox.com Git - mirror_ovs.git/blob - lib/netdev-offload-provider.h
netdev-offload: Introduce a function to validate same flow api handle.
[mirror_ovs.git] / lib / netdev-offload-provider.h
1 /*
2 * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2016 Nicira, Inc.
3 * Copyright (c) 2019 Samsung Electronics Co.,Ltd.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 #ifndef NETDEV_FLOW_API_PROVIDER_H
19 #define NETDEV_FLOW_API_PROVIDER_H 1
20
21 #include "flow.h"
22 #include "netdev-offload.h"
23 #include "openvswitch/netdev.h"
24 #include "openvswitch/types.h"
25 #include "packets.h"
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 struct netdev_flow_api {
32 char *type;
33 /* Flush all offloaded flows from a netdev.
34 * Return 0 if successful, otherwise returns a positive errno value. */
35 int (*flow_flush)(struct netdev *);
36
37 /* Flow dumping interface.
38 *
39 * This is the back-end for the flow dumping interface described in
40 * dpif.h. Please read the comments there first, because this code
41 * closely follows it.
42 *
43 * On success returns 0 and allocates data, on failure returns
44 * positive errno. */
45 int (*flow_dump_create)(struct netdev *, struct netdev_flow_dump **dump);
46 int (*flow_dump_destroy)(struct netdev_flow_dump *);
47
48 /* Returns true if there are more flows to dump.
49 * 'rbuffer' is used as a temporary buffer and needs to be pre allocated
50 * by the caller. While there are more flows the same 'rbuffer'
51 * should be provided. 'wbuffer' is used to store dumped actions and needs
52 * to be pre allocated by the caller. */
53 bool (*flow_dump_next)(struct netdev_flow_dump *, struct match *,
54 struct nlattr **actions,
55 struct dpif_flow_stats *stats,
56 struct dpif_flow_attrs *attrs, ovs_u128 *ufid,
57 struct ofpbuf *rbuffer, struct ofpbuf *wbuffer);
58
59 /* Offload the given flow on netdev.
60 * To modify a flow, use the same ufid.
61 * 'actions' are in netlink format, as with struct dpif_flow_put.
62 * 'info' is extra info needed to offload the flow.
63 * 'stats' is populated according to the rules set out in the description
64 * above 'struct dpif_flow_put'.
65 * Return 0 if successful, otherwise returns a positive errno value. */
66 int (*flow_put)(struct netdev *, struct match *, struct nlattr *actions,
67 size_t actions_len, const ovs_u128 *ufid,
68 struct offload_info *info, struct dpif_flow_stats *);
69
70 /* Queries a flow specified by ufid on netdev.
71 * Fills output buffer as 'wbuffer' in flow_dump_next, which
72 * needs to be be pre allocated.
73 * Return 0 if successful, otherwise returns a positive errno value. */
74 int (*flow_get)(struct netdev *, struct match *, struct nlattr **actions,
75 const ovs_u128 *ufid, struct dpif_flow_stats *,
76 struct dpif_flow_attrs *, struct ofpbuf *wbuffer);
77
78 /* Delete a flow specified by ufid from netdev.
79 * 'stats' is populated according to the rules set out in the description
80 * above 'struct dpif_flow_del'.
81 * Return 0 if successful, otherwise returns a positive errno value. */
82 int (*flow_del)(struct netdev *, const ovs_u128 *ufid,
83 struct dpif_flow_stats *);
84
85 /* Initializies the netdev flow api.
86 * Return 0 if successful, otherwise returns a positive errno value. */
87 int (*init_flow_api)(struct netdev *);
88 };
89
90 int netdev_register_flow_api_provider(const struct netdev_flow_api *);
91 int netdev_unregister_flow_api_provider(const char *type);
92 bool netdev_flow_api_equals(const struct netdev *, const struct netdev *);
93
94 #ifdef __linux__
95 extern const struct netdev_flow_api netdev_offload_tc;
96 #endif
97
98 #ifdef DPDK_NETDEV
99 extern const struct netdev_flow_api netdev_offload_dpdk;
100 #endif
101
102 #ifdef __cplusplus
103 }
104 #endif
105
106 #endif /* NETDEV_FLOW_API_PROVIDER_H */