Coverage Report

Created: 2023-03-26 07:41

/src/openvswitch/lib/netdev-offload.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 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_OFFLOAD_H
19
#define NETDEV_OFFLOAD_H 1
20
21
#include "openvswitch/netdev.h"
22
#include "openvswitch/types.h"
23
#include "ovs-atomic.h"
24
#include "ovs-rcu.h"
25
#include "ovs-thread.h"
26
#include "openvswitch/ofp-meter.h"
27
#include "packets.h"
28
#include "flow.h"
29
30
#ifdef  __cplusplus
31
extern "C" {
32
#endif
33
34
struct dp_packet_batch;
35
struct dp_packet;
36
struct netdev_class;
37
struct netdev_rxq;
38
struct netdev_saved_flags;
39
struct ofpbuf;
40
struct in_addr;
41
struct in6_addr;
42
struct smap;
43
struct sset;
44
struct ovs_action_push_tnl;
45
46
47
/* Offload-capable (HW) netdev information */
48
struct netdev_hw_info {
49
    bool oor;   /* Out of Offload Resources ? */
50
    atomic_bool miss_api_supported;  /* hw_miss_packet_recover() supported.*/
51
    int offload_count;  /* Pending (non-offloaded) flow count */
52
    int pending_count;  /* Offloaded flow count */
53
    OVSRCU_TYPE(void *) offload_data; /* Offload metadata. */
54
};
55
56
enum hw_info_type {
57
    HW_INFO_TYPE_OOR = 1,   /* OOR state */
58
    HW_INFO_TYPE_PEND_COUNT = 2,  /* Pending(non-offloaded) flow count */
59
    HW_INFO_TYPE_OFFL_COUNT = 3   /* Offloaded flow count */
60
};
61
62
struct netdev_flow_dump {
63
    struct netdev *netdev;
64
    odp_port_t port;
65
    bool terse;
66
    struct nl_dump *nl_dump;
67
};
68
69
/* Flow offloading. */
70
struct offload_info {
71
    bool recirc_id_shared_with_tc;  /* Indicates whever tc chains will be in
72
                                     * sync with datapath recirc ids. */
73
74
    /*
75
     * The flow mark id assigened to the flow. If any pkts hit the flow,
76
     * it will be in the pkt meta data.
77
     */
78
    uint32_t flow_mark;
79
80
    bool tc_modify_flow_deleted; /* Indicate the tc modify flow put success
81
                                  * to delete the original flow. */
82
    odp_port_t orig_in_port; /* Originating in_port for tnl flows. */
83
};
84
85
DECLARE_EXTERN_PER_THREAD_DATA(unsigned int, netdev_offload_thread_id);
86
87
unsigned int netdev_offload_thread_nb(void);
88
unsigned int netdev_offload_thread_init(void);
89
unsigned int netdev_offload_ufid_to_thread_id(const ovs_u128 ufid);
90
91
static inline unsigned int
92
netdev_offload_thread_id(void)
93
0
{
94
0
    unsigned int id = *netdev_offload_thread_id_get();
95
96
0
    if (OVS_UNLIKELY(id == OVSTHREAD_ID_UNSET)) {
97
0
        id = netdev_offload_thread_init();
98
0
    }
99
100
0
    return id;
101
0
}
Unexecuted instantiation: flow.c:netdev_offload_thread_id
Unexecuted instantiation: netdev.c:netdev_offload_thread_id
Unexecuted instantiation: netdev-linux.c:netdev_offload_thread_id
Unexecuted instantiation: netdev-offload-tc.c:netdev_offload_thread_id
Unexecuted instantiation: dpif.c:netdev_offload_thread_id
Unexecuted instantiation: netdev-offload.c:netdev_offload_thread_id
Unexecuted instantiation: netdev-vport.c:netdev_offload_thread_id
Unexecuted instantiation: netdev-native-tnl.c:netdev_offload_thread_id
Unexecuted instantiation: dpif-netlink.c:netdev_offload_thread_id
Unexecuted instantiation: dpif-netdev.c:netdev_offload_thread_id
102
103
int netdev_flow_flush(struct netdev *);
104
int netdev_flow_dump_create(struct netdev *, struct netdev_flow_dump **dump,
105
                            bool terse);
106
int netdev_flow_dump_destroy(struct netdev_flow_dump *);
107
bool netdev_flow_dump_next(struct netdev_flow_dump *, struct match *,
108
                          struct nlattr **actions, struct dpif_flow_stats *,
109
                          struct dpif_flow_attrs *, ovs_u128 *ufid,
110
                          struct ofpbuf *rbuffer, struct ofpbuf *wbuffer);
111
int netdev_flow_put(struct netdev *, struct match *, struct nlattr *actions,
112
                    size_t actions_len, const ovs_u128 *,
113
                    struct offload_info *, struct dpif_flow_stats *);
114
int netdev_hw_miss_packet_recover(struct netdev *, struct dp_packet *);
115
int netdev_flow_get(struct netdev *, struct match *, struct nlattr **actions,
116
                    const ovs_u128 *, struct dpif_flow_stats *,
117
                    struct dpif_flow_attrs *, struct ofpbuf *wbuffer);
118
int netdev_flow_del(struct netdev *, const ovs_u128 *,
119
                    struct dpif_flow_stats *);
120
int netdev_init_flow_api(struct netdev *);
121
void netdev_uninit_flow_api(struct netdev *);
122
uint32_t netdev_get_block_id(struct netdev *);
123
int netdev_get_hw_info(struct netdev *, int);
124
void netdev_set_hw_info(struct netdev *, int, int);
125
bool netdev_any_oor(void);
126
bool netdev_is_flow_api_enabled(void);
127
void netdev_set_flow_api_enabled(const struct smap *ovs_other_config);
128
bool netdev_is_offload_rebalance_policy_enabled(void);
129
int netdev_flow_get_n_flows(struct netdev *netdev, uint64_t *n_flows);
130
131
struct dpif_port;
132
int netdev_ports_insert(struct netdev *, struct dpif_port *);
133
struct netdev *netdev_ports_get(odp_port_t port, const char *dpif_type);
134
int netdev_ports_remove(odp_port_t port, const char *dpif_type);
135
odp_port_t netdev_ifindex_to_odp_port(int ifindex);
136
137
/* For each of the ports with dpif_type, call cb with the netdev and port
138
 * number of the port, and an opaque user argument.
139
 * The returned value is used to continue traversing upon false or stop if
140
 * true.
141
 */
142
void netdev_ports_traverse(const char *dpif_type,
143
                           bool (*cb)(struct netdev *, odp_port_t, void *),
144
                           void *aux);
145
struct netdev_flow_dump **netdev_ports_flow_dump_create(
146
                                        const char *dpif_type,
147
                                        int *ports,
148
                                        bool terse);
149
void netdev_ports_flow_flush(const char *dpif_type);
150
int netdev_ports_flow_del(const char *dpif_type, const ovs_u128 *ufid,
151
                          struct dpif_flow_stats *stats);
152
int netdev_ports_flow_get(const char *dpif_type, struct match *match,
153
                          struct nlattr **actions,
154
                          const ovs_u128 *ufid,
155
                          struct dpif_flow_stats *stats,
156
                          struct dpif_flow_attrs *attrs,
157
                          struct ofpbuf *buf);
158
int netdev_ports_get_n_flows(const char *dpif_type,
159
                             odp_port_t port_no, uint64_t *n_flows);
160
161
void meter_offload_set(ofproto_meter_id, struct ofputil_meter_config *);
162
int meter_offload_get(ofproto_meter_id, struct ofputil_meter_stats *);
163
int meter_offload_del(ofproto_meter_id, struct ofputil_meter_stats *);
164
165
#ifdef  __cplusplus
166
}
167
#endif
168
169
#endif /* netdev-offload.h */