Thanks, I added some comments.
On Mon, Nov 14, 2011 at 12:50:33PM -0800, Ethan Jackson wrote: > Looks good to me. > > I think the flow_set_vlan_vid() function could possibly use a comment. > In particular, it may be worth noting that it clears the pcp value > when vid is OFP_VLAN_NONE. I don't feel strongly about it though. > > Ethan > > On Mon, Nov 7, 2011 at 21:50, Ben Pfaff <b...@nicira.com> wrote: > > --- > > ?lib/flow.c | ? 21 +++++++++++++++++++++ > > ?lib/flow.h | ? ?3 +++ > > ?2 files changed, 24 insertions(+), 0 deletions(-) > > > > diff --git a/lib/flow.c b/lib/flow.c > > index 1263734..bf7ba6d 100644 > > --- a/lib/flow.c > > +++ b/lib/flow.c > > @@ -985,6 +985,27 @@ flow_hash_fields_valid(enum nx_hash_fields fields) > > ? ? ? ? || fields == NX_HASH_FIELDS_SYMMETRIC_L4; > > ?} > > > > +void > > +flow_set_vlan_vid(struct flow *flow, ovs_be16 vid) > > +{ > > + ? ?if (vid == htons(OFP_VLAN_NONE)) { > > + ? ? ? ?flow->vlan_tci = htons(0); > > + ? ?} else { > > + ? ? ? ?vid &= htons(VLAN_VID_MASK); > > + ? ? ? ?flow->vlan_tci &= ~htons(VLAN_VID_MASK); > > + ? ? ? ?flow->vlan_tci |= htons(VLAN_CFI) | vid; > > + ? ?} > > +} > > + > > +void > > +flow_set_vlan_pcp(struct flow *flow, uint8_t pcp) > > +{ > > + ? ?pcp &= 0x07; > > + ? ?flow->vlan_tci &= ~htons(VLAN_PCP_MASK); > > + ? ?flow->vlan_tci |= htons((pcp << VLAN_PCP_SHIFT) | VLAN_CFI); > > +} > > + > > + > > ?/* Puts into 'b' a packet that flow_extract() would parse as having the > > given > > ?* 'flow'. > > ?* > > diff --git a/lib/flow.h b/lib/flow.h > > index 0abfe5a..b26949c 100644 > > --- a/lib/flow.h > > +++ b/lib/flow.h > > @@ -97,6 +97,9 @@ static inline int flow_compare(const struct flow *, const > > struct flow *); > > ?static inline bool flow_equal(const struct flow *, const struct flow *); > > ?static inline size_t flow_hash(const struct flow *, uint32_t basis); > > > > +void flow_set_vlan_vid(struct flow *, ovs_be16 vid); > > +void flow_set_vlan_pcp(struct flow *, uint8_t pcp); > > + > > ?void flow_compose(struct ofpbuf *, const struct flow *); > > > > ?static inline int > > -- > > 1.7.2.5 > > > > _______________________________________________ > > dev mailing list > > dev@openvswitch.org > > http://openvswitch.org/mailman/listinfo/dev > > _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev