Regards _Sugesh
> -----Original Message----- > From: dev [mailto:dev-boun...@openvswitch.org] On Behalf Of Johnson Li > Sent: Thursday, June 16, 2016 10:52 AM > To: dev@openvswitch.org > Subject: [ovs-dev] [RFC PATCH 07/14] Add APIs to set NSH keys for match > fields > > Signed-off-by: Johnson Li <johnson...@intel.com> > > diff --git a/include/openvswitch/match.h b/include/openvswitch/match.h > index c955753..a1cca7e 100644 > --- a/include/openvswitch/match.h > +++ b/include/openvswitch/match.h > @@ -86,6 +86,26 @@ void match_set_tun_gbp_id_masked(struct match > *match, ovs_be16 gbp_id, ovs_be16 void match_set_tun_gbp_id(struct > match *match, ovs_be16 gbp_id); void > match_set_tun_gbp_flags_masked(struct match *match, uint8_t flags, > uint8_t mask); void match_set_tun_gbp_flags(struct match *match, uint8_t > flags); > + > +void match_set_nsp_masked(struct match *, ovs_be32 nsp, ovs_be32 > mask); > +void match_set_nsi_masked(struct match *match, uint8_t nsi, uint8_t > +mask); void match_set_nsh_md_type_masked(struct match *match, > uint8_t md_type, > + uint8_t mask); void > +match_set_nsh_next_proto_masked(struct match *match, uint8_t > next_proto, > + uint8_t mask); void > +match_set_nshc1_masked(struct match *, ovs_be32 nshc1, ovs_be32 > mask); > +void match_set_nshc2_masked(struct match *, ovs_be32 nshc2, ovs_be32 > +mask); void match_set_nshc3_masked(struct match *, ovs_be32 nshc3, > +ovs_be32 mask); void match_set_nshc4_masked(struct match *, ovs_be32 > +nshc4, ovs_be32 mask); void match_set_nsp(struct match *, ovs_be32 > +nsp); void match_set_nsi(struct match *match, uint8_t nsi); void > +match_set_nsh_md_type(struct match *match, uint8_t md_type); void > +match_set_nsh_next_proto(struct match *match, uint8_t next_proto); > void > +match_set_nshc1(struct match *, ovs_be32 nshc1); void > +match_set_nshc2(struct match *, ovs_be32 nshc2); void > +match_set_nshc3(struct match *, ovs_be32 nshc3); void > +match_set_nshc4(struct match *, ovs_be32 nshc4); [Sugesh] I feel, match_set for every nsh field is a overkill especially when we implement NSH type-2? Can we do this some more optimized way? Consider the MD2 type as well when defining the match_set definitions. > + > void match_set_in_port(struct match *, ofp_port_t ofp_port); void > match_set_pkt_mark(struct match *, uint32_t pkt_mark); void > match_set_pkt_mark_masked(struct match *, uint32_t pkt_mark, uint32_t > mask); diff --git a/lib/match.c b/lib/match.c index f12c802..c0cc165 100644 > --- a/lib/match.c > +++ b/lib/match.c > @@ -837,6 +837,112 @@ match_set_nd_target_masked(struct match > *match, > match->wc.masks.nd_target = *mask; > } > > +void > +match_set_nsp_masked(struct match *match, ovs_be32 nsp, ovs_be32 > mask) > +{ > + match->wc.masks.nsh.nsp = mask; > + match->flow.nsh.nsp = nsp & mask; > +} > + > +void > +match_set_nsi_masked(struct match *match, uint8_t nsi, uint8_t mask) { > + match->wc.masks.nsh.nsi = mask; > + match->flow.nsh.nsi = nsi & mask; > +} > + > +void > +match_set_nsh_md_type_masked(struct match *match, > + uint8_t md_type, uint8_t mask) > +{ > + match->wc.masks.nsh.md_type = mask; > + match->flow.nsh.md_type = md_type & mask; } > + > +void > +match_set_nsh_next_proto_masked(struct match *match, > + uint8_t next_proto, uint8_t mask) { > + match->wc.masks.nsh.next_proto = mask; > + match->flow.nsh.next_proto = next_proto & mask; } > + > +void > +match_set_nshc1_masked(struct match *match, ovs_be32 nshc1, > ovs_be32 > +mask) { > + match->wc.masks.nsh.nshc1 = mask; > + match->flow.nsh.nshc1 = nshc1 & mask; } > + > +void > +match_set_nshc2_masked(struct match *match, ovs_be32 nshc2, > ovs_be32 > +mask) { > + match->wc.masks.nsh.nshc2 = mask; > + match->flow.nsh.nshc2 = nshc2 & mask; } > + > +void > +match_set_nshc3_masked(struct match *match, ovs_be32 nshc3, > ovs_be32 > +mask) { > + match->wc.masks.nsh.nshc3 = mask; > + match->flow.nsh.nshc3 = nshc3 & mask; } > + > +void > +match_set_nshc4_masked(struct match *match, ovs_be32 nshc4, > ovs_be32 > +mask) { > + match->wc.masks.nsh.nshc4 = mask; > + match->flow.nsh.nshc4 = nshc4 & mask; } > + > +void > +match_set_nsp(struct match *match, ovs_be32 nsp) { > + match_set_nsp_masked(match, nsp, OVS_BE32_MAX); } > + > +void > +match_set_nsi(struct match *match, uint8_t nsi) { > + match_set_nsi_masked(match, nsi, UINT8_MAX); } > + > +void > +match_set_nsh_md_type(struct match *match, uint8_t md_type) { > + match_set_nsh_md_type_masked(match, md_type, UINT8_MAX); } > + > +void > +match_set_nsh_next_proto(struct match *match, uint8_t next_proto) { > + match_set_nsh_next_proto_masked(match, next_proto, UINT8_MAX); } > + > +void > +match_set_nshc1(struct match *match, ovs_be32 nshc1) { > + match_set_nshc1_masked(match, nshc1, OVS_BE32_MAX); } > + > +void > +match_set_nshc2(struct match *match, ovs_be32 nshc2) { > + match_set_nshc2_masked(match, nshc2, OVS_BE32_MAX); } > + > +void > +match_set_nshc3(struct match *match, ovs_be32 nshc3) { > + match_set_nshc3_masked(match, nshc3, OVS_BE32_MAX); } > + > +void > +match_set_nshc4(struct match *match, ovs_be32 nshc4) { > + match_set_nshc4_masked(match, nshc4, OVS_BE32_MAX); } > + > /* Returns true if 'a' and 'b' wildcard the same fields and have the same > * values for fixed fields, otherwise false. */ bool > -- > 1.8.4.2 > > _______________________________________________ > dev mailing list > dev@openvswitch.org > http://openvswitch.org/mailman/listinfo/dev _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev