Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls_rx.c
Show First 20 Lines • Show All 652 Lines • ▼ Show 20 Lines | |||||
* | * | ||||
* Returns zero on success else an error happened. | * Returns zero on success else an error happened. | ||||
*/ | */ | ||||
int | int | ||||
mlx5e_tls_rx_snd_tag_alloc(struct ifnet *ifp, | mlx5e_tls_rx_snd_tag_alloc(struct ifnet *ifp, | ||||
union if_snd_tag_alloc_params *params, | union if_snd_tag_alloc_params *params, | ||||
struct m_snd_tag **ppmt) | struct m_snd_tag **ppmt) | ||||
{ | { | ||||
struct inpcb *inp; | |||||
struct mlx5e_iq *iq; | struct mlx5e_iq *iq; | ||||
struct mlx5e_priv *priv; | struct mlx5e_priv *priv; | ||||
struct mlx5e_tls_rx_tag *ptag; | struct mlx5e_tls_rx_tag *ptag; | ||||
struct mlx5_flow_rule *flow_rule; | struct mlx5_flow_rule *flow_rule; | ||||
const struct tls_session_params *en; | const struct tls_session_params *en; | ||||
uint32_t value; | uint32_t value; | ||||
int error; | int error; | ||||
priv = ifp->if_softc; | priv = ifp->if_softc; | ||||
if (unlikely(priv->gone != 0 || priv->tls_rx.init == 0 || | if (unlikely(priv->gone != 0 || priv->tls_rx.init == 0 || | ||||
params->hdr.flowtype == M_HASHTYPE_NONE)) | params->hdr.flowtype == M_HASHTYPE_NONE)) | ||||
return (EOPNOTSUPP); | return (EOPNOTSUPP); | ||||
inp = params->tls_rx.inp; | |||||
if (unlikely(inp == NULL)) | |||||
return (EINVAL); | |||||
error = 0; | |||||
INP_RLOCK(inp); | |||||
switch (INP_SOCKAF(inp->inp_socket)) { | |||||
#ifdef INET | |||||
case AF_INET: | |||||
if (priv->ifcap_rxtls4 == 0) | |||||
error = EOPNOTSUPP; | |||||
break; | |||||
#endif | |||||
#ifdef INET6 | |||||
case AF_INET6: | |||||
if (priv->ifcap_rxtls6 == 0) | |||||
error = EOPNOTSUPP; | |||||
break; | |||||
#endif | |||||
default: | |||||
error = EOPNOTSUPP; | |||||
break; | |||||
} | |||||
INP_RUNLOCK(inp); | |||||
if (error != 0) | |||||
return (error); | |||||
/* allocate new tag from zone, if any */ | /* allocate new tag from zone, if any */ | ||||
ptag = uma_zalloc(priv->tls_rx.zone, M_NOWAIT); | ptag = uma_zalloc(priv->tls_rx.zone, M_NOWAIT); | ||||
if (ptag == NULL) | if (ptag == NULL) | ||||
return (ENOMEM); | return (ENOMEM); | ||||
/* sanity check default values */ | /* sanity check default values */ | ||||
MPASS(ptag->dek_index == 0); | MPASS(ptag->dek_index == 0); | ||||
MPASS(ptag->dek_index_ok == 0); | MPASS(ptag->dek_index_ok == 0); | ||||
Show All 35 Lines | case 128 / 8: | ||||
} | } | ||||
} else { | } else { | ||||
if (MLX5_CAP_TLS(priv->mdev, tls_1_3_aes_gcm_128) == 0) { | if (MLX5_CAP_TLS(priv->mdev, tls_1_3_aes_gcm_128) == 0) { | ||||
error = EPROTONOSUPPORT; | error = EPROTONOSUPPORT; | ||||
goto failure; | goto failure; | ||||
} | } | ||||
} | } | ||||
error = mlx5e_tls_rx_set_params( | error = mlx5e_tls_rx_set_params( | ||||
ptag->crypto_params, params->tls_rx.inp, en); | ptag->crypto_params, inp, en); | ||||
if (error) | if (error) | ||||
goto failure; | goto failure; | ||||
break; | break; | ||||
case 256 / 8: | case 256 / 8: | ||||
if (en->tls_vminor == TLS_MINOR_VER_TWO) { | if (en->tls_vminor == TLS_MINOR_VER_TWO) { | ||||
if (MLX5_CAP_TLS(priv->mdev, tls_1_2_aes_gcm_256) == 0) { | if (MLX5_CAP_TLS(priv->mdev, tls_1_2_aes_gcm_256) == 0) { | ||||
error = EPROTONOSUPPORT; | error = EPROTONOSUPPORT; | ||||
goto failure; | goto failure; | ||||
} | } | ||||
} else { | } else { | ||||
if (MLX5_CAP_TLS(priv->mdev, tls_1_3_aes_gcm_256) == 0) { | if (MLX5_CAP_TLS(priv->mdev, tls_1_3_aes_gcm_256) == 0) { | ||||
error = EPROTONOSUPPORT; | error = EPROTONOSUPPORT; | ||||
goto failure; | goto failure; | ||||
} | } | ||||
} | } | ||||
error = mlx5e_tls_rx_set_params( | error = mlx5e_tls_rx_set_params( | ||||
ptag->crypto_params, params->tls_rx.inp, en); | ptag->crypto_params, inp, en); | ||||
if (error) | if (error) | ||||
goto failure; | goto failure; | ||||
break; | break; | ||||
default: | default: | ||||
error = EINVAL; | error = EINVAL; | ||||
goto failure; | goto failure; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | #endif | ||||
if (mlx5e_tls_rx_send_progress_parameters_sync(iq, ptag) != 0) { | if (mlx5e_tls_rx_send_progress_parameters_sync(iq, ptag) != 0) { | ||||
MLX5E_TLS_RX_STAT_INC(ptag, rx_error, 1); | MLX5E_TLS_RX_STAT_INC(ptag, rx_error, 1); | ||||
error = ENOMEM; | error = ENOMEM; | ||||
goto cleanup; | goto cleanup; | ||||
} | } | ||||
if (ifp->if_pcp != IFNET_PCP_NONE || params->tls_rx.vlan_id != 0) { | if (ifp->if_pcp != IFNET_PCP_NONE || params->tls_rx.vlan_id != 0) { | ||||
/* create flow rule for TLS RX traffic (tagged) */ | /* create flow rule for TLS RX traffic (tagged) */ | ||||
flow_rule = mlx5e_accel_fs_add_inpcb(priv, params->tls_rx.inp, | flow_rule = mlx5e_accel_fs_add_inpcb(priv, inp, | ||||
ptag->tirn, MLX5_FS_DEFAULT_FLOW_TAG, params->tls_rx.vlan_id); | ptag->tirn, MLX5_FS_DEFAULT_FLOW_TAG, params->tls_rx.vlan_id); | ||||
} else { | } else { | ||||
/* create flow rule for TLS RX traffic (untagged) */ | /* create flow rule for TLS RX traffic (untagged) */ | ||||
flow_rule = mlx5e_accel_fs_add_inpcb(priv, params->tls_rx.inp, | flow_rule = mlx5e_accel_fs_add_inpcb(priv, inp, | ||||
ptag->tirn, MLX5_FS_DEFAULT_FLOW_TAG, MLX5E_ACCEL_FS_ADD_INPCB_NO_VLAN); | ptag->tirn, MLX5_FS_DEFAULT_FLOW_TAG, MLX5E_ACCEL_FS_ADD_INPCB_NO_VLAN); | ||||
} | } | ||||
if (IS_ERR_OR_NULL(flow_rule)) { | if (IS_ERR_OR_NULL(flow_rule)) { | ||||
MLX5E_TLS_RX_STAT_INC(ptag, rx_error, 1); | MLX5E_TLS_RX_STAT_INC(ptag, rx_error, 1); | ||||
error = ENOMEM; | error = ENOMEM; | ||||
goto cleanup; | goto cleanup; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 200 Lines • Show Last 20 Lines |