child-cfg: Make HW offload auto mode configurable

Until now the configuration available to user for HW offload were:
hw_offload = no
hw_offload = yes

With this commit users will be able to configure auto mode using:
hw_offload = auto

Signed-off-by: Adi Nissim <[email protected]>
Reviewed-by: Aviv Heller <[email protected]>
This commit is contained in:
Adi Nissim
2018-03-21 10:32:02 +01:00
committed by Tobias Brunner
parent ee26f7156f
commit 8ced1570ab
5 changed files with 50 additions and 18 deletions
+23 -10
View File
@@ -533,7 +533,7 @@ static void log_child_data(child_data_t *data, char *name)
DBG2(DBG_CFG, " proposals = %#P", data->proposals);
DBG2(DBG_CFG, " local_ts = %#R", data->local_ts);
DBG2(DBG_CFG, " remote_ts = %#R", data->remote_ts);
DBG2(DBG_CFG, " hw_offload = %u", has_opt(OPT_HW_OFFLOAD));
DBG2(DBG_CFG, " hw_offload = %N", hw_offload_names, cfg->hw_offload);
DBG2(DBG_CFG, " sha256_96 = %u", has_opt(OPT_SHA256_96));
}
@@ -892,14 +892,6 @@ CALLBACK(parse_opt_ipcomp, bool,
return parse_option(out, OPT_IPCOMP, v);
}
/**
* Parse OPT_HW_OFFLOAD option
*/
CALLBACK(parse_opt_hw_offl, bool,
child_cfg_option_t *out, chunk_t v)
{
return parse_option(out, OPT_HW_OFFLOAD, v);
}
/**
* Parse OPT_SHA256_96 option
@@ -943,6 +935,27 @@ CALLBACK(parse_action, bool,
return FALSE;
}
/**
* Parse an hw_offload_t
*/
CALLBACK(parse_hw_offload, bool,
action_t *out, chunk_t v)
{
enum_map_t map[] = {
{ "no", HW_OFFLOAD_NO },
{ "yes", HW_OFFLOAD_YES },
{ "auto", HW_OFFLOAD_AUTO },
};
int d;
if (parse_map(map, countof(map), &d, v))
{
*out = d;
return TRUE;
}
return FALSE;
}
/**
* Parse a uint32_t with the given base
*/
@@ -1578,7 +1591,7 @@ CALLBACK(child_kv, bool,
{ "tfc_padding", parse_tfc, &child->cfg.tfc },
{ "priority", parse_uint32, &child->cfg.priority },
{ "interface", parse_string, &child->cfg.interface },
{ "hw_offload", parse_opt_hw_offl, &child->cfg.options },
{ "hw_offload", parse_hw_offload, &child->cfg.hw_offload },
{ "sha256_96", parse_opt_sha256_96,&child->cfg.options },
};