Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c
Show All 31 Lines | |||||
#include <dev/mlx5/tls.h> | #include <dev/mlx5/tls.h> | ||||
#include <linux/delay.h> | #include <linux/delay.h> | ||||
#include <sys/ktls.h> | #include <sys/ktls.h> | ||||
#include <opencrypto/cryptodev.h> | #include <opencrypto/cryptodev.h> | ||||
#ifdef KERN_TLS | #ifdef KERN_TLS | ||||
#ifdef RATELIMIT | |||||
static if_snd_tag_modify_t mlx5e_tls_rl_snd_tag_modify; | |||||
#endif | |||||
static if_snd_tag_query_t mlx5e_tls_snd_tag_query; | |||||
static if_snd_tag_free_t mlx5e_tls_snd_tag_free; | |||||
static const struct if_snd_tag_sw mlx5e_tls_snd_tag_sw = { | |||||
.snd_tag_query = mlx5e_tls_snd_tag_query, | |||||
.snd_tag_free = mlx5e_tls_snd_tag_free | |||||
}; | |||||
#ifdef RATELIMIT | |||||
static const struct if_snd_tag_sw mlx5e_tls_rl_snd_tag_sw = { | |||||
.snd_tag_modify = mlx5e_tls_rl_snd_tag_modify, | |||||
.snd_tag_query = mlx5e_tls_snd_tag_query, | |||||
.snd_tag_free = mlx5e_tls_snd_tag_free | |||||
}; | |||||
#endif | |||||
MALLOC_DEFINE(M_MLX5E_TLS, "MLX5E_TLS", "MLX5 ethernet HW TLS"); | MALLOC_DEFINE(M_MLX5E_TLS, "MLX5E_TLS", "MLX5 ethernet HW TLS"); | ||||
/* software TLS context */ | /* software TLS context */ | ||||
struct mlx5_ifc_sw_tls_cntx_bits { | struct mlx5_ifc_sw_tls_cntx_bits { | ||||
struct mlx5_ifc_tls_static_params_bits param; | struct mlx5_ifc_tls_static_params_bits param; | ||||
struct mlx5_ifc_tls_progress_params_bits progress; | struct mlx5_ifc_tls_progress_params_bits progress; | ||||
struct { | struct { | ||||
uint8_t key_data[8][0x20]; | uint8_t key_data[8][0x20]; | ||||
▲ Show 20 Lines • Show All 228 Lines • ▼ Show 20 Lines | |||||
CTASSERT(MLX5E_TLS_ST_INIT == 0); | CTASSERT(MLX5E_TLS_ST_INIT == 0); | ||||
int | int | ||||
mlx5e_tls_snd_tag_alloc(struct ifnet *ifp, | mlx5e_tls_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) | ||||
{ | { | ||||
union if_snd_tag_alloc_params rl_params; | union if_snd_tag_alloc_params rl_params; | ||||
const struct if_snd_tag_sw *snd_tag_sw; | |||||
struct mlx5e_priv *priv; | struct mlx5e_priv *priv; | ||||
struct mlx5e_tls_tag *ptag; | struct mlx5e_tls_tag *ptag; | ||||
const struct tls_session_params *en; | const struct tls_session_params *en; | ||||
int error; | int error; | ||||
priv = ifp->if_softc; | priv = ifp->if_softc; | ||||
if (priv->gone != 0 || priv->tls.init == 0) | if (priv->gone != 0 || priv->tls.init == 0) | ||||
▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | #endif | ||||
memset(&rl_params, 0, sizeof(rl_params)); | memset(&rl_params, 0, sizeof(rl_params)); | ||||
rl_params.hdr = params->hdr; | rl_params.hdr = params->hdr; | ||||
switch (params->hdr.type) { | switch (params->hdr.type) { | ||||
#ifdef RATELIMIT | #ifdef RATELIMIT | ||||
case IF_SND_TAG_TYPE_TLS_RATE_LIMIT: | case IF_SND_TAG_TYPE_TLS_RATE_LIMIT: | ||||
rl_params.hdr.type = IF_SND_TAG_TYPE_RATE_LIMIT; | rl_params.hdr.type = IF_SND_TAG_TYPE_RATE_LIMIT; | ||||
rl_params.rate_limit.max_rate = params->tls_rate_limit.max_rate; | rl_params.rate_limit.max_rate = params->tls_rate_limit.max_rate; | ||||
snd_tag_sw = &mlx5e_tls_rl_snd_tag_sw; | |||||
break; | break; | ||||
#endif | #endif | ||||
case IF_SND_TAG_TYPE_TLS: | case IF_SND_TAG_TYPE_TLS: | ||||
rl_params.hdr.type = IF_SND_TAG_TYPE_UNLIMITED; | rl_params.hdr.type = IF_SND_TAG_TYPE_UNLIMITED; | ||||
snd_tag_sw = &mlx5e_tls_snd_tag_sw; | |||||
break; | break; | ||||
default: | default: | ||||
error = EOPNOTSUPP; | error = EOPNOTSUPP; | ||||
goto failure; | goto failure; | ||||
} | } | ||||
error = m_snd_tag_alloc(ifp, &rl_params, &ptag->rl_tag); | error = m_snd_tag_alloc(ifp, &rl_params, &ptag->rl_tag); | ||||
if (error) | if (error) | ||||
goto failure; | goto failure; | ||||
/* store pointer to mbuf tag */ | /* store pointer to mbuf tag */ | ||||
MPASS(ptag->tag.refcount == 0); | MPASS(ptag->tag.refcount == 0); | ||||
m_snd_tag_init(&ptag->tag, ifp, params->hdr.type); | m_snd_tag_init(&ptag->tag, ifp, params->hdr.type, snd_tag_sw); | ||||
*ppmt = &ptag->tag; | *ppmt = &ptag->tag; | ||||
queue_work(priv->tls.wq, &ptag->work); | queue_work(priv->tls.wq, &ptag->work); | ||||
flush_work(&ptag->work); | flush_work(&ptag->work); | ||||
return (0); | return (0); | ||||
failure: | failure: | ||||
mlx5e_tls_tag_zfree(ptag); | mlx5e_tls_tag_zfree(ptag); | ||||
return (error); | return (error); | ||||
} | } | ||||
int | |||||
mlx5e_tls_snd_tag_modify(struct m_snd_tag *pmt, union if_snd_tag_modify_params *params) | |||||
{ | |||||
#ifdef RATELIMIT | #ifdef RATELIMIT | ||||
static int | |||||
mlx5e_tls_rl_snd_tag_modify(struct m_snd_tag *pmt, union if_snd_tag_modify_params *params) | |||||
{ | |||||
union if_snd_tag_modify_params rl_params; | union if_snd_tag_modify_params rl_params; | ||||
struct mlx5e_tls_tag *ptag = | struct mlx5e_tls_tag *ptag = | ||||
container_of(pmt, struct mlx5e_tls_tag, tag); | container_of(pmt, struct mlx5e_tls_tag, tag); | ||||
int error; | int error; | ||||
#endif | |||||
switch (pmt->type) { | |||||
#ifdef RATELIMIT | |||||
case IF_SND_TAG_TYPE_TLS_RATE_LIMIT: | |||||
memset(&rl_params, 0, sizeof(rl_params)); | memset(&rl_params, 0, sizeof(rl_params)); | ||||
rl_params.rate_limit.max_rate = params->tls_rate_limit.max_rate; | rl_params.rate_limit.max_rate = params->tls_rate_limit.max_rate; | ||||
error = ptag->rl_tag->ifp->if_snd_tag_modify(ptag->rl_tag, | error = ptag->rl_tag->sw->snd_tag_modify(ptag->rl_tag, &rl_params); | ||||
&rl_params); | |||||
return (error); | return (error); | ||||
#endif | |||||
default: | |||||
return (EOPNOTSUPP); | |||||
} | } | ||||
} | #endif | ||||
int | static int | ||||
mlx5e_tls_snd_tag_query(struct m_snd_tag *pmt, union if_snd_tag_query_params *params) | mlx5e_tls_snd_tag_query(struct m_snd_tag *pmt, union if_snd_tag_query_params *params) | ||||
{ | { | ||||
struct mlx5e_tls_tag *ptag = | struct mlx5e_tls_tag *ptag = | ||||
container_of(pmt, struct mlx5e_tls_tag, tag); | container_of(pmt, struct mlx5e_tls_tag, tag); | ||||
int error; | |||||
switch (pmt->type) { | return (ptag->rl_tag->sw->snd_tag_query(ptag->rl_tag, params)); | ||||
#ifdef RATELIMIT | |||||
case IF_SND_TAG_TYPE_TLS_RATE_LIMIT: | |||||
#endif | |||||
case IF_SND_TAG_TYPE_TLS: | |||||
error = ptag->rl_tag->ifp->if_snd_tag_query(ptag->rl_tag, | |||||
params); | |||||
break; | |||||
default: | |||||
error = EOPNOTSUPP; | |||||
break; | |||||
} | } | ||||
return (error); | |||||
} | |||||
void | static void | ||||
mlx5e_tls_snd_tag_free(struct m_snd_tag *pmt) | mlx5e_tls_snd_tag_free(struct m_snd_tag *pmt) | ||||
{ | { | ||||
struct mlx5e_tls_tag *ptag = | struct mlx5e_tls_tag *ptag = | ||||
container_of(pmt, struct mlx5e_tls_tag, tag); | container_of(pmt, struct mlx5e_tls_tag, tag); | ||||
struct mlx5e_priv *priv; | struct mlx5e_priv *priv; | ||||
m_snd_tag_rele(ptag->rl_tag); | m_snd_tag_rele(ptag->rl_tag); | ||||
▲ Show 20 Lines • Show All 335 Lines • Show Last 20 Lines |