2 * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2016 Nicira, Inc.
3 * Copyright (c) 2019 Samsung Electronics Co.,Ltd.
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:
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #ifndef NETDEV_FLOW_API_PROVIDER_H
19 #define NETDEV_FLOW_API_PROVIDER_H 1
22 #include "netdev-offload.h"
23 #include "openvswitch/netdev.h"
24 #include "openvswitch/types.h"
31 struct netdev_flow_api
{
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
*);
37 /* Flow dumping interface.
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
43 * On success returns 0 and allocates data, on failure returns
45 int (*flow_dump_create
)(struct netdev
*, struct netdev_flow_dump
**dump
);
46 int (*flow_dump_destroy
)(struct netdev_flow_dump
*);
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
);
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
*);
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
);
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
*);
85 /* Initializies the netdev flow api.
86 * Return 0 if successful, otherwise returns a positive errno value. */
87 int (*init_flow_api
)(struct netdev
*);
90 int netdev_register_flow_api_provider(const struct netdev_flow_api
*);
91 int netdev_unregister_flow_api_provider(const char *type
);
94 extern const struct netdev_flow_api netdev_offload_tc
;
98 extern const struct netdev_flow_api netdev_offload_dpdk
;
105 #endif /* NETDEV_FLOW_API_PROVIDER_H */