2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 14:25:26 +00:00

flow: Refactor some of VLAN helper functions

By default, these function are to change the first vlan vid and pcp
in the flow. Add a parameter as index for vlans if we want to handle
the second ones.

Signed-off-by: Jianbo Liu <jianbol@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
This commit is contained in:
Jianbo Liu
2018-07-17 02:01:56 +00:00
committed by Simon Horman
parent b5ad40a9b8
commit 2f9366beb4
7 changed files with 25 additions and 25 deletions

View File

@@ -2520,14 +2520,14 @@ flow_hash_in_wildcards(const struct flow *flow,
*
* - Other values of 'vid' should not be used. */
void
flow_set_dl_vlan(struct flow *flow, ovs_be16 vid)
flow_set_dl_vlan(struct flow *flow, ovs_be16 vid, int id)
{
if (vid == htons(OFP10_VLAN_NONE)) {
flow->vlans[0].tci = htons(0);
flow->vlans[id].tci = htons(0);
} else {
vid &= htons(VLAN_VID_MASK);
flow->vlans[0].tci &= ~htons(VLAN_VID_MASK);
flow->vlans[0].tci |= htons(VLAN_CFI) | vid;
flow->vlans[id].tci &= ~htons(VLAN_VID_MASK);
flow->vlans[id].tci |= htons(VLAN_CFI) | vid;
}
}
@@ -2560,11 +2560,11 @@ flow_set_vlan_vid(struct flow *flow, ovs_be16 vid)
* After calling this function, 'flow' will not match packets without a VLAN
* header. */
void
flow_set_vlan_pcp(struct flow *flow, uint8_t pcp)
flow_set_vlan_pcp(struct flow *flow, uint8_t pcp, int id)
{
pcp &= 0x07;
flow->vlans[0].tci &= ~htons(VLAN_PCP_MASK);
flow->vlans[0].tci |= htons((pcp << VLAN_PCP_SHIFT) | VLAN_CFI);
flow->vlans[id].tci &= ~htons(VLAN_PCP_MASK);
flow->vlans[id].tci |= htons((pcp << VLAN_PCP_SHIFT) | VLAN_CFI);
}
/* Counts the number of VLAN headers. */