Message ID | 20190508151321.39231-3-harry.van.haaren@intel.com |
---|---|
State | Superseded |
Headers | show |
Series | dpcls func ptrs & optimizations | expand |
On 5/8/2019 4:13 PM, Harry van Haaren wrote: > This commit moves some data-structures to be available > in the dpif-netdev.h header. This allows specific implementations > of the subtable lookup function to include just that header > file, and not require that the code exists in dpif-netdev.c > > Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com> > Thanks for the patch Harry, minor comments below. I assume for reviewing purposes you've broken this out from patch 1? > --- > > v6: > - Fix double * in code comments (Eelco) > - Reword comment on lookup_func for clarity (Harry) > - Rebase fixups > --- > lib/dpif-netdev.c | 50 --------------------------------------------- > lib/dpif-netdev.h | 52 +++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 52 insertions(+), 50 deletions(-) > > diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c > index e2e2c14e7..b5c3dad3c 100644 > --- a/lib/dpif-netdev.c > +++ b/lib/dpif-netdev.c > @@ -128,15 +128,6 @@ static struct odp_support dp_netdev_support = { > .ct_orig_tuple6 = true, > }; > > -/* Stores a miniflow with inline values */ > - > -struct netdev_flow_key { > - uint32_t hash; /* Hash function differs for different users. */ > - uint32_t len; /* Length of the following miniflow (incl. map). */ > - struct miniflow mf; > - uint64_t buf[FLOW_MAX_PACKET_U64S]; > -}; > - > /* EMC cache and SMC cache compose the datapath flow cache (DFC) > * > * Exact match cache for frequently used flows > @@ -7572,47 +7563,6 @@ dpif_dummy_register(enum dummy_level level) > > /* Datapath Classifier. */ > > -/* forward declaration for lookup_func typedef */ > -struct dpcls_subtable; > - > -/* Lookup function for a subtable in the dpcls. This function is called > - * by each subtable with an array of packets, and a bitmask of packets to > - * perform the lookup on. Using a function pointer gives flexibility to > - * optimize the lookup function based on subtable properties and the > - * CPU instruction set available at runtime. > - */ > -typedef uint32_t (*dpcls_subtable_lookup_func)(struct dpcls_subtable *subtable, > - uint32_t keys_map, const struct netdev_flow_key *keys[], > - struct dpcls_rule **rules); > - > -/* Prototype for generic lookup func, using same code path as before */ > -uint32_t > -dpcls_subtable_lookup_generic(struct dpcls_subtable *subtable, > - uint32_t keys_map, > - const struct netdev_flow_key *keys[], > - struct dpcls_rule **rules); > - > - > -/* A set of rules that all have the same fields wildcarded. */ > -struct dpcls_subtable { > - /* The fields are only used by writers. */ > - struct cmap_node cmap_node OVS_GUARDED; /* Within dpcls 'subtables_map'. */ > - > - /* These fields are accessed by readers. */ > - struct cmap rules; /* Contains "struct dpcls_rule"s. */ > - uint32_t hit_cnt; /* Number of match hits in subtable in current > - optimization interval. */ > - > - /* the lookup function to use for this subtable. If there is a known > - * property of the subtable (eg: only 3 bits of miniflow metadata is > - * used for the lookup) then this can point at an optimized version of > - * the lookup function for this particular subtable. */ > - dpcls_subtable_lookup_func lookup_func; > - > - struct netdev_flow_key mask; /* Wildcards for fields (const). */ > - /* 'mask' must be the last field, additional space is allocated here. */ > -}; > - > static void > dpcls_subtable_destroy_cb(struct dpcls_subtable *subtable) > { > diff --git a/lib/dpif-netdev.h b/lib/dpif-netdev.h > index 6db6ed2e2..4cd2ceea7 100644 > --- a/lib/dpif-netdev.h > +++ b/lib/dpif-netdev.h > @@ -24,6 +24,7 @@ > #include "openvswitch/types.h" > #include "dp-packet.h" > #include "packets.h" > +#include "cmap.h" Typically ovs header header files are added in alphabetical order. I see from above the headers are out of order already before your change but you might consider adding cmap.h before dpif.h. > > #ifdef __cplusplus > extern "C" { > @@ -38,6 +39,57 @@ bool dpif_is_netdev(const struct dpif *); > #define NR_QUEUE 1 > #define NR_PMD_THREADS 1 > > +/* forward declaration for lookup_func typedef */ > +struct dpcls_subtable; > +struct dpcls_rule; > + > +/* must be public as it is intantiated in subtable struct below */Minor typo in intantiated, comment capitalization and period. Ian > +struct netdev_flow_key { > + uint32_t hash; /* Hash function differs for different users. */ > + uint32_t len; /* Length of the following miniflow (incl. map). */ > + struct miniflow mf; > + uint64_t buf[FLOW_MAX_PACKET_U64S]; > +}; > + > +/* Lookup function for a subtable in the dpcls. This function is called > + * by each subtable with an array of packets, and a bitmask of packets to > + * perform the lookup on. Using a function pointer gives flexibility to > + * optimize the lookup function based on subtable properties and the > + * CPU instruction set available at runtime. > + */ > +typedef uint32_t (*dpcls_subtable_lookup_func)(struct dpcls_subtable *subtable, > + uint32_t keys_map, const struct netdev_flow_key *keys[], > + struct dpcls_rule **rules); > + > +/* Prototype for generic lookup func, using same code path as before */ > +uint32_t > +dpcls_subtable_lookup_generic(struct dpcls_subtable *subtable, > + uint32_t keys_map, > + const struct netdev_flow_key *keys[], > + struct dpcls_rule **rules); > + > +/* A set of rules that all have the same fields wildcarded. */ > +struct dpcls_subtable { > + /* The fields are only used by writers. */ > + struct cmap_node cmap_node OVS_GUARDED; /* Within dpcls 'subtables_map'. */ > + > + /* These fields are accessed by readers. */ > + struct cmap rules; /* Contains "struct dpcls_rule"s. */ > + uint32_t hit_cnt; /* Number of match hits in subtable in current > + optimization interval. */ > + > + /* The lookup function to use for this subtable. From a technical point of > + * view, this is just an implementation of mutliple dispatch. The attribute > + * used to identify the ideal function is the miniflow fingerprint that the > + * subtable matches on. The miniflow "bits" are used to select the actual > + * dpcls lookup implementation at subtable creation time. > + */ > + dpcls_subtable_lookup_func lookup_func; > + > + struct netdev_flow_key mask; /* Wildcards for fields (const). */ > + /* 'mask' must be the last field, additional space is allocated here. */ > +}; > + > #ifdef __cplusplus > } > #endif >
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index e2e2c14e7..b5c3dad3c 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -128,15 +128,6 @@ static struct odp_support dp_netdev_support = { .ct_orig_tuple6 = true, }; -/* Stores a miniflow with inline values */ - -struct netdev_flow_key { - uint32_t hash; /* Hash function differs for different users. */ - uint32_t len; /* Length of the following miniflow (incl. map). */ - struct miniflow mf; - uint64_t buf[FLOW_MAX_PACKET_U64S]; -}; - /* EMC cache and SMC cache compose the datapath flow cache (DFC) * * Exact match cache for frequently used flows @@ -7572,47 +7563,6 @@ dpif_dummy_register(enum dummy_level level) /* Datapath Classifier. */ -/* forward declaration for lookup_func typedef */ -struct dpcls_subtable; - -/* Lookup function for a subtable in the dpcls. This function is called - * by each subtable with an array of packets, and a bitmask of packets to - * perform the lookup on. Using a function pointer gives flexibility to - * optimize the lookup function based on subtable properties and the - * CPU instruction set available at runtime. - */ -typedef uint32_t (*dpcls_subtable_lookup_func)(struct dpcls_subtable *subtable, - uint32_t keys_map, const struct netdev_flow_key *keys[], - struct dpcls_rule **rules); - -/* Prototype for generic lookup func, using same code path as before */ -uint32_t -dpcls_subtable_lookup_generic(struct dpcls_subtable *subtable, - uint32_t keys_map, - const struct netdev_flow_key *keys[], - struct dpcls_rule **rules); - - -/* A set of rules that all have the same fields wildcarded. */ -struct dpcls_subtable { - /* The fields are only used by writers. */ - struct cmap_node cmap_node OVS_GUARDED; /* Within dpcls 'subtables_map'. */ - - /* These fields are accessed by readers. */ - struct cmap rules; /* Contains "struct dpcls_rule"s. */ - uint32_t hit_cnt; /* Number of match hits in subtable in current - optimization interval. */ - - /* the lookup function to use for this subtable. If there is a known - * property of the subtable (eg: only 3 bits of miniflow metadata is - * used for the lookup) then this can point at an optimized version of - * the lookup function for this particular subtable. */ - dpcls_subtable_lookup_func lookup_func; - - struct netdev_flow_key mask; /* Wildcards for fields (const). */ - /* 'mask' must be the last field, additional space is allocated here. */ -}; - static void dpcls_subtable_destroy_cb(struct dpcls_subtable *subtable) { diff --git a/lib/dpif-netdev.h b/lib/dpif-netdev.h index 6db6ed2e2..4cd2ceea7 100644 --- a/lib/dpif-netdev.h +++ b/lib/dpif-netdev.h @@ -24,6 +24,7 @@ #include "openvswitch/types.h" #include "dp-packet.h" #include "packets.h" +#include "cmap.h" #ifdef __cplusplus extern "C" { @@ -38,6 +39,57 @@ bool dpif_is_netdev(const struct dpif *); #define NR_QUEUE 1 #define NR_PMD_THREADS 1 +/* forward declaration for lookup_func typedef */ +struct dpcls_subtable; +struct dpcls_rule; + +/* must be public as it is intantiated in subtable struct below */ +struct netdev_flow_key { + uint32_t hash; /* Hash function differs for different users. */ + uint32_t len; /* Length of the following miniflow (incl. map). */ + struct miniflow mf; + uint64_t buf[FLOW_MAX_PACKET_U64S]; +}; + +/* Lookup function for a subtable in the dpcls. This function is called + * by each subtable with an array of packets, and a bitmask of packets to + * perform the lookup on. Using a function pointer gives flexibility to + * optimize the lookup function based on subtable properties and the + * CPU instruction set available at runtime. + */ +typedef uint32_t (*dpcls_subtable_lookup_func)(struct dpcls_subtable *subtable, + uint32_t keys_map, const struct netdev_flow_key *keys[], + struct dpcls_rule **rules); + +/* Prototype for generic lookup func, using same code path as before */ +uint32_t +dpcls_subtable_lookup_generic(struct dpcls_subtable *subtable, + uint32_t keys_map, + const struct netdev_flow_key *keys[], + struct dpcls_rule **rules); + +/* A set of rules that all have the same fields wildcarded. */ +struct dpcls_subtable { + /* The fields are only used by writers. */ + struct cmap_node cmap_node OVS_GUARDED; /* Within dpcls 'subtables_map'. */ + + /* These fields are accessed by readers. */ + struct cmap rules; /* Contains "struct dpcls_rule"s. */ + uint32_t hit_cnt; /* Number of match hits in subtable in current + optimization interval. */ + + /* The lookup function to use for this subtable. From a technical point of + * view, this is just an implementation of mutliple dispatch. The attribute + * used to identify the ideal function is the miniflow fingerprint that the + * subtable matches on. The miniflow "bits" are used to select the actual + * dpcls lookup implementation at subtable creation time. + */ + dpcls_subtable_lookup_func lookup_func; + + struct netdev_flow_key mask; /* Wildcards for fields (const). */ + /* 'mask' must be the last field, additional space is allocated here. */ +}; + #ifdef __cplusplus } #endif
This commit moves some data-structures to be available in the dpif-netdev.h header. This allows specific implementations of the subtable lookup function to include just that header file, and not require that the code exists in dpif-netdev.c Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com> --- v6: - Fix double * in code comments (Eelco) - Reword comment on lookup_func for clarity (Harry) - Rebase fixups --- lib/dpif-netdev.c | 50 --------------------------------------------- lib/dpif-netdev.h | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 50 deletions(-)