Message ID | 20221123100303.323460-2-amorenoz@redhat.com |
---|---|
State | Superseded |
Headers | show |
Series | [ovs-dev,v1,01/11] python: fix datapath flow decoders | expand |
Context | Check | Description |
---|---|---|
ovsrobot/apply-robot | success | apply and check: success |
ovsrobot/github-robot-_Build_and_Test | success | github build: passed |
ovsrobot/intel-ovs-compilation | success | test: success |
On Wed, Nov 23, 2022 at 5:03 AM Adrian Moreno <amorenoz@redhat.com> wrote: > > We currently auto-generate a dictionary of field names and decoders. > However, sometimes fields can be specified by their cannonical NXM or > OXM names. > > Modify gen_ofp_field_decoders to also generate a dictionary of aliases > so it's easy to map OXM/NXM names to their fields and decoding > information. > > Signed-off-by: Adrian Moreno <amorenoz@redhat.com> Acked-by: Mike Pattrick <mkp@redhat.com> > --- > build-aux/gen_ofp_field_decoders | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/build-aux/gen_ofp_field_decoders b/build-aux/gen_ofp_field_decoders > index 96f99e860..0b797ee8c 100755 > --- a/build-aux/gen_ofp_field_decoders > +++ b/build-aux/gen_ofp_field_decoders > @@ -22,12 +22,16 @@ def main(): > fields = extract_fields.extract_ofp_fields(args.metaflow) > > field_decoders = {} > + aliases = {} > for field in fields: > decoder = get_decoder(field) > field_decoders[field.get("name")] = decoder > if field.get("extra_name"): > field_decoders[field.get("extra_name")] = decoder > > + for nxm in field.get("OXM", []): > + aliases[nxm[1]] = field.get("name") > + > code = """ > # This file is auto-generated. Do not edit! > > @@ -35,14 +39,25 @@ from ovs.flow import decoders > > field_decoders = {{ > {decoders} > +}} > + > +field_aliases = {{ > +{aliases} > }}""".format( > decoders="\n".join( > [ > " '{name}': {decoder},".format(name=name, decoder=decoder) > for name, decoder in field_decoders.items() > ] > + ), > + aliases="\n".join( > + [ > + " '{alias}': '{name}',".format(name=name, alias=alias) > + for alias, name in aliases.items() > + ] > ) > ) > + > print(code) > > > -- > 2.38.1 >
diff --git a/build-aux/gen_ofp_field_decoders b/build-aux/gen_ofp_field_decoders index 96f99e860..0b797ee8c 100755 --- a/build-aux/gen_ofp_field_decoders +++ b/build-aux/gen_ofp_field_decoders @@ -22,12 +22,16 @@ def main(): fields = extract_fields.extract_ofp_fields(args.metaflow) field_decoders = {} + aliases = {} for field in fields: decoder = get_decoder(field) field_decoders[field.get("name")] = decoder if field.get("extra_name"): field_decoders[field.get("extra_name")] = decoder + for nxm in field.get("OXM", []): + aliases[nxm[1]] = field.get("name") + code = """ # This file is auto-generated. Do not edit! @@ -35,14 +39,25 @@ from ovs.flow import decoders field_decoders = {{ {decoders} +}} + +field_aliases = {{ +{aliases} }}""".format( decoders="\n".join( [ " '{name}': {decoder},".format(name=name, decoder=decoder) for name, decoder in field_decoders.items() ] + ), + aliases="\n".join( + [ + " '{alias}': '{name}',".format(name=name, alias=alias) + for alias, name in aliases.items() + ] ) ) + print(code)
We currently auto-generate a dictionary of field names and decoders. However, sometimes fields can be specified by their cannonical NXM or OXM names. Modify gen_ofp_field_decoders to also generate a dictionary of aliases so it's easy to map OXM/NXM names to their fields and decoding information. Signed-off-by: Adrian Moreno <amorenoz@redhat.com> --- build-aux/gen_ofp_field_decoders | 15 +++++++++++++++ 1 file changed, 15 insertions(+)