]> git.proxmox.com Git - mirror_ovs.git/blame - lib/netdev-offload-provider.h
cirrus: Use FreeBSD 12.2.
[mirror_ovs.git] / lib / netdev-offload-provider.h
CommitLineData
5fc5c50f
IM
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"
b6cabb8f
IM
22#include "netdev-offload.h"
23#include "openvswitch/netdev.h"
5fc5c50f
IM
24#include "openvswitch/types.h"
25#include "packets.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31struct 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. */
19153657
VB
45 int (*flow_dump_create)(struct netdev *, struct netdev_flow_dump **dump,
46 bool terse);
5fc5c50f
IM
47 int (*flow_dump_destroy)(struct netdev_flow_dump *);
48
49 /* Returns true if there are more flows to dump.
50 * 'rbuffer' is used as a temporary buffer and needs to be pre allocated
51 * by the caller. While there are more flows the same 'rbuffer'
52 * should be provided. 'wbuffer' is used to store dumped actions and needs
53 * to be pre allocated by the caller. */
54 bool (*flow_dump_next)(struct netdev_flow_dump *, struct match *,
55 struct nlattr **actions,
56 struct dpif_flow_stats *stats,
57 struct dpif_flow_attrs *attrs, ovs_u128 *ufid,
58 struct ofpbuf *rbuffer, struct ofpbuf *wbuffer);
59
60 /* Offload the given flow on netdev.
61 * To modify a flow, use the same ufid.
62 * 'actions' are in netlink format, as with struct dpif_flow_put.
63 * 'info' is extra info needed to offload the flow.
64 * 'stats' is populated according to the rules set out in the description
65 * above 'struct dpif_flow_put'.
66 * Return 0 if successful, otherwise returns a positive errno value. */
67 int (*flow_put)(struct netdev *, struct match *, struct nlattr *actions,
68 size_t actions_len, const ovs_u128 *ufid,
69 struct offload_info *info, struct dpif_flow_stats *);
70
71 /* Queries a flow specified by ufid on netdev.
72 * Fills output buffer as 'wbuffer' in flow_dump_next, which
73 * needs to be be pre allocated.
74 * Return 0 if successful, otherwise returns a positive errno value. */
75 int (*flow_get)(struct netdev *, struct match *, struct nlattr **actions,
76 const ovs_u128 *ufid, struct dpif_flow_stats *,
77 struct dpif_flow_attrs *, struct ofpbuf *wbuffer);
78
79 /* Delete a flow specified by ufid from netdev.
80 * 'stats' is populated according to the rules set out in the description
81 * above 'struct dpif_flow_del'.
82 * Return 0 if successful, otherwise returns a positive errno value. */
83 int (*flow_del)(struct netdev *, const ovs_u128 *ufid,
84 struct dpif_flow_stats *);
85
c5b4b0ce
JL
86 /* Get the number of flows offloaded to netdev.
87 * Return 0 if successful, otherwise returns a positive errno value. */
88 int (*flow_get_n_flows)(struct netdev *, uint64_t *n_flows);
89
5fc5c50f
IM
90 /* Initializies the netdev flow api.
91 * Return 0 if successful, otherwise returns a positive errno value. */
92 int (*init_flow_api)(struct netdev *);
93};
94
95int netdev_register_flow_api_provider(const struct netdev_flow_api *);
96int netdev_unregister_flow_api_provider(const char *type);
65c73b3f 97bool netdev_flow_api_equals(const struct netdev *, const struct netdev *);
5fc5c50f
IM
98
99#ifdef __linux__
4f746d52 100extern const struct netdev_flow_api netdev_offload_tc;
5fc5c50f
IM
101#endif
102
b6cabb8f 103#ifdef DPDK_NETDEV
4f746d52 104extern const struct netdev_flow_api netdev_offload_dpdk;
b6cabb8f
IM
105#endif
106
5fc5c50f
IM
107#ifdef __cplusplus
108}
109#endif
110
111#endif /* NETDEV_FLOW_API_PROVIDER_H */