mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 14:25:26 +00:00
tc: Add vxlan encap action with gbp option offload.
Add TC offload support for vxlan encap with gbp option. Reviewed-by: Gavi Teitz <gavi@nvidia.com> Reviewed-by: Roi Dayan <roid@nvidia.com> Reviewed-by: Simon Horman <simon.horman@corigine.com> Signed-off-by: Gavin Li <gavinl@nvidia.com> Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
This commit is contained in:
58
lib/tc.c
58
lib/tc.c
@@ -1290,6 +1290,35 @@ nl_parse_act_geneve_opts(const struct nlattr *in_nlattr,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
nl_parse_act_vxlan_opts(struct nlattr *in_nlattr, struct tc_action *action)
|
||||
{
|
||||
const struct ofpbuf *msg;
|
||||
struct nlattr *nla;
|
||||
struct ofpbuf buf;
|
||||
size_t left;
|
||||
|
||||
nl_attr_get_nested(in_nlattr, &buf);
|
||||
msg = &buf;
|
||||
|
||||
NL_ATTR_FOR_EACH (nla, left, ofpbuf_at(msg, 0, 0), msg->size) {
|
||||
uint16_t type = nl_attr_type(nla);
|
||||
int32_t gbp_raw;
|
||||
|
||||
switch (type) {
|
||||
case TCA_FLOWER_KEY_ENC_OPT_VXLAN_GBP:
|
||||
gbp_raw = nl_attr_get_u32(nla);
|
||||
odp_decode_gbp_raw(gbp_raw, &action->encap.gbp.id,
|
||||
&action->encap.gbp.flags);
|
||||
action->encap.gbp.id_present = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
nl_parse_act_tunnel_opts(struct nlattr *options, struct tc_action *action)
|
||||
{
|
||||
@@ -1314,7 +1343,12 @@ nl_parse_act_tunnel_opts(struct nlattr *options, struct tc_action *action)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
break;
|
||||
case TCA_TUNNEL_KEY_ENC_OPTS_VXLAN:
|
||||
err = nl_parse_act_vxlan_opts(nla, action);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2640,6 +2674,27 @@ nl_msg_put_act_tunnel_geneve_option(struct ofpbuf *request,
|
||||
nl_msg_end_nested(request, outer);
|
||||
}
|
||||
|
||||
static void
|
||||
nl_msg_put_act_tunnel_vxlan_opts(struct ofpbuf *request,
|
||||
struct tc_action_encap *encap)
|
||||
{
|
||||
size_t outer, inner;
|
||||
uint32_t gbp_raw;
|
||||
|
||||
if (!encap->gbp.id_present) {
|
||||
return;
|
||||
}
|
||||
|
||||
gbp_raw = odp_encode_gbp_raw(encap->gbp.flags,
|
||||
encap->gbp.id);
|
||||
outer = nl_msg_start_nested_with_flag(request, TCA_TUNNEL_KEY_ENC_OPTS);
|
||||
inner = nl_msg_start_nested_with_flag(request,
|
||||
TCA_TUNNEL_KEY_ENC_OPTS_VXLAN);
|
||||
nl_msg_put_u32(request, TCA_TUNNEL_KEY_ENC_OPT_VXLAN_GBP, gbp_raw);
|
||||
nl_msg_end_nested(request, inner);
|
||||
nl_msg_end_nested(request, outer);
|
||||
}
|
||||
|
||||
static void
|
||||
nl_msg_put_act_tunnel_key_set(struct ofpbuf *request,
|
||||
struct tc_action_encap *encap,
|
||||
@@ -2680,6 +2735,7 @@ nl_msg_put_act_tunnel_key_set(struct ofpbuf *request,
|
||||
nl_msg_put_be16(request, TCA_TUNNEL_KEY_ENC_DST_PORT,
|
||||
encap->tp_dst);
|
||||
}
|
||||
nl_msg_put_act_tunnel_vxlan_opts(request, encap);
|
||||
nl_msg_put_act_tunnel_geneve_option(request, &encap->data);
|
||||
nl_msg_put_u8(request, TCA_TUNNEL_KEY_NO_CSUM, encap->no_csum);
|
||||
}
|
||||
|
Reference in New Issue
Block a user