]> git.proxmox.com Git - mirror_ovs.git/blame - lib/dpif-netdev-private.h
netdev-offload-tc: Use single 'once' variable for probing tc features
[mirror_ovs.git] / lib / dpif-netdev-private.h
CommitLineData
f5ace7cd
HH
1/*
2 * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2015 Nicira, Inc.
0f6a89d0 3 * Copyright (c) 2019 Intel Corporation.
f5ace7cd
HH
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 DPIF_NETDEV_PRIVATE_H
19#define DPIF_NETDEV_PRIVATE_H 1
20
21#include <stdbool.h>
22#include <stdint.h>
23
24#include "dpif.h"
25#include "cmap.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31/* Forward declaration for lookup_func typedef. */
32struct dpcls_subtable;
33struct dpcls_rule;
34
35/* Must be public as it is instantiated in subtable struct below. */
36struct netdev_flow_key {
37 uint32_t hash; /* Hash function differs for different users. */
38 uint32_t len; /* Length of the following miniflow (incl. map). */
39 struct miniflow mf;
40 uint64_t buf[FLOW_MAX_PACKET_U64S];
41};
42
43/* A rule to be inserted to the classifier. */
44struct dpcls_rule {
45 struct cmap_node cmap_node; /* Within struct dpcls_subtable 'rules'. */
46 struct netdev_flow_key *mask; /* Subtable's mask. */
47 struct netdev_flow_key flow; /* Matching key. */
48 /* 'flow' must be the last field, additional space is allocated here. */
49};
50
51/* Lookup function for a subtable in the dpcls. This function is called
52 * by each subtable with an array of packets, and a bitmask of packets to
53 * perform the lookup on. Using a function pointer gives flexibility to
54 * optimize the lookup function based on subtable properties and the
55 * CPU instruction set available at runtime.
56 */
57typedef
58uint32_t (*dpcls_subtable_lookup_func)(struct dpcls_subtable *subtable,
59 uint32_t keys_map,
60 const struct netdev_flow_key *keys[],
61 struct dpcls_rule **rules);
62
f5ace7cd
HH
63/* A set of rules that all have the same fields wildcarded. */
64struct dpcls_subtable {
65 /* The fields are only used by writers. */
66 struct cmap_node cmap_node OVS_GUARDED; /* Within dpcls 'subtables_map'. */
67
68 /* These fields are accessed by readers. */
69 struct cmap rules; /* Contains "struct dpcls_rule"s. */
70 uint32_t hit_cnt; /* Number of match hits in subtable in current
71 optimization interval. */
72
a0b36b39
HH
73 /* Miniflow fingerprint that the subtable matches on. The miniflow "bits"
74 * are used to select the actual dpcls lookup implementation at subtable
75 * creation time.
76 */
77 uint8_t mf_bits_set_unit0;
78 uint8_t mf_bits_set_unit1;
79
f5ace7cd
HH
80 /* The lookup function to use for this subtable. If there is a known
81 * property of the subtable (eg: only 3 bits of miniflow metadata is
82 * used for the lookup) then this can point at an optimized version of
83 * the lookup function for this particular subtable. */
84 dpcls_subtable_lookup_func lookup_func;
85
a0b36b39
HH
86 /* Caches the masks to match a packet to, reducing runtime calculations. */
87 uint64_t *mf_masks;
88
f5ace7cd
HH
89 struct netdev_flow_key mask; /* Wildcards for fields (const). */
90 /* 'mask' must be the last field, additional space is allocated here. */
91};
92
93/* Iterate through netdev_flow_key TNL u64 values specified by 'FLOWMAP'. */
94#define NETDEV_FLOW_KEY_FOR_EACH_IN_FLOWMAP(VALUE, KEY, FLOWMAP) \
95 MINIFLOW_FOR_EACH_IN_FLOWMAP (VALUE, &(KEY)->mf, FLOWMAP)
96
97/* Generates a mask for each bit set in the subtable's miniflow. */
98void
99netdev_flow_key_gen_masks(const struct netdev_flow_key *tbl,
100 uint64_t *mf_masks,
101 const uint32_t mf_bits_u0,
102 const uint32_t mf_bits_u1);
103
104/* Matches a dpcls rule against the incoming packet in 'target' */
105bool dpcls_rule_matches_key(const struct dpcls_rule *rule,
106 const struct netdev_flow_key *target);
107
108#ifdef __cplusplus
109}
110#endif
111
112#endif /* netdev-private.h */