Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/mlx5/mlx5_en/mlx5_en_main.c
Show All 30 Lines | |||||
#include <sys/eventhandler.h> | #include <sys/eventhandler.h> | ||||
#include <sys/sockio.h> | #include <sys/sockio.h> | ||||
#include <machine/atomic.h> | #include <machine/atomic.h> | ||||
#include <net/debugnet.h> | #include <net/debugnet.h> | ||||
static int mlx5e_get_wqe_sz(struct mlx5e_priv *priv, u32 *wqe_sz, u32 *nsegs); | static int mlx5e_get_wqe_sz(struct mlx5e_priv *priv, u32 *wqe_sz, u32 *nsegs); | ||||
static if_snd_tag_query_t mlx5e_ul_snd_tag_query; | |||||
static if_snd_tag_free_t mlx5e_ul_snd_tag_free; | |||||
struct mlx5e_channel_param { | struct mlx5e_channel_param { | ||||
struct mlx5e_rq_param rq; | struct mlx5e_rq_param rq; | ||||
struct mlx5e_sq_param sq; | struct mlx5e_sq_param sq; | ||||
struct mlx5e_cq_param rx_cq; | struct mlx5e_cq_param rx_cq; | ||||
struct mlx5e_cq_param tx_cq; | struct mlx5e_cq_param tx_cq; | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 294 Lines • ▼ Show 20 Lines | static const struct media mlx5e_ext_mode_table[MLX5E_EXT_LINK_SPEEDS_NUMBER][MLX5E_CABLE_TYPE_NUMBER] = | ||||
/**/ | /**/ | ||||
[MLX5E_400GAUI_4_400GBASE_CR4_KR4][MLX5E_CABLE_TYPE_UNKNOWN] = { | [MLX5E_400GAUI_4_400GBASE_CR4_KR4][MLX5E_CABLE_TYPE_UNKNOWN] = { | ||||
.subtype = IFM_400G_LR8, /* XXX */ | .subtype = IFM_400G_LR8, /* XXX */ | ||||
.baudrate = IF_Gbps(400ULL), | .baudrate = IF_Gbps(400ULL), | ||||
}, | }, | ||||
}; | }; | ||||
static const struct if_snd_tag_sw mlx5e_ul_snd_tag_sw = { | |||||
.snd_tag_query = mlx5e_ul_snd_tag_query, | |||||
.snd_tag_free = mlx5e_ul_snd_tag_free | |||||
kib: I would put a comma at the end of line | |||||
}; | |||||
DEBUGNET_DEFINE(mlx5_en); | DEBUGNET_DEFINE(mlx5_en); | ||||
MALLOC_DEFINE(M_MLX5EN, "MLX5EN", "MLX5 Ethernet"); | MALLOC_DEFINE(M_MLX5EN, "MLX5EN", "MLX5 Ethernet"); | ||||
static void | static void | ||||
mlx5e_update_carrier(struct mlx5e_priv *priv) | mlx5e_update_carrier(struct mlx5e_priv *priv) | ||||
{ | { | ||||
struct mlx5_core_dev *mdev = priv->mdev; | struct mlx5_core_dev *mdev = priv->mdev; | ||||
▲ Show 20 Lines • Show All 1,751 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
int tc; | int tc; | ||||
/* setup priv and channel number */ | /* setup priv and channel number */ | ||||
c->priv = priv; | c->priv = priv; | ||||
c->ix = ix; | c->ix = ix; | ||||
/* setup send tag */ | /* setup send tag */ | ||||
m_snd_tag_init(&c->tag, c->priv->ifp, IF_SND_TAG_TYPE_UNLIMITED); | m_snd_tag_init(&c->tag, c->priv->ifp, IF_SND_TAG_TYPE_UNLIMITED, | ||||
&mlx5e_ul_snd_tag_sw); | |||||
init_completion(&c->completion); | init_completion(&c->completion); | ||||
mtx_init(&c->rq.mtx, "mlx5rx", MTX_NETWORK_LOCK, MTX_DEF); | mtx_init(&c->rq.mtx, "mlx5rx", MTX_NETWORK_LOCK, MTX_DEF); | ||||
callout_init_mtx(&c->rq.watchdog, &c->rq.mtx, 0); | callout_init_mtx(&c->rq.watchdog, &c->rq.mtx, 0); | ||||
for (tc = 0; tc != MLX5E_MAX_TX_NUM_TC; tc++) { | for (tc = 0; tc != MLX5E_MAX_TX_NUM_TC; tc++) { | ||||
▲ Show 20 Lines • Show All 2,044 Lines • ▼ Show 20 Lines | if (error == -EINVAL) { | ||||
priv->params.tx_priority_flow_control = 0; | priv->params.tx_priority_flow_control = 0; | ||||
/* update firmware */ | /* update firmware */ | ||||
(void) mlx5e_set_port_pause_and_pfc(priv); | (void) mlx5e_set_port_pause_and_pfc(priv); | ||||
} | } | ||||
PRIV_UNLOCK(priv); | PRIV_UNLOCK(priv); | ||||
} | } | ||||
int | static int | ||||
mlx5e_ul_snd_tag_alloc(struct ifnet *ifp, | mlx5e_ul_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 mlx5e_priv *priv; | struct mlx5e_priv *priv; | ||||
struct mlx5e_channel *pch; | struct mlx5e_channel *pch; | ||||
priv = ifp->if_softc; | priv = ifp->if_softc; | ||||
Show All 25 Lines | #endif | ||||
if (unlikely(pch->sq[0].running == 0)) | if (unlikely(pch->sq[0].running == 0)) | ||||
return (ENXIO); | return (ENXIO); | ||||
m_snd_tag_ref(&pch->tag); | m_snd_tag_ref(&pch->tag); | ||||
*ppmt = &pch->tag; | *ppmt = &pch->tag; | ||||
return (0); | return (0); | ||||
} | } | ||||
} | } | ||||
int | static int | ||||
mlx5e_ul_snd_tag_query(struct m_snd_tag *pmt, union if_snd_tag_query_params *params) | mlx5e_ul_snd_tag_query(struct m_snd_tag *pmt, union if_snd_tag_query_params *params) | ||||
{ | { | ||||
struct mlx5e_channel *pch = | struct mlx5e_channel *pch = | ||||
container_of(pmt, struct mlx5e_channel, tag); | container_of(pmt, struct mlx5e_channel, tag); | ||||
params->unlimited.max_rate = -1ULL; | params->unlimited.max_rate = -1ULL; | ||||
params->unlimited.queue_level = mlx5e_sq_queue_level(&pch->sq[0]); | params->unlimited.queue_level = mlx5e_sq_queue_level(&pch->sq[0]); | ||||
return (0); | return (0); | ||||
} | } | ||||
void | static void | ||||
mlx5e_ul_snd_tag_free(struct m_snd_tag *pmt) | mlx5e_ul_snd_tag_free(struct m_snd_tag *pmt) | ||||
{ | { | ||||
struct mlx5e_channel *pch = | struct mlx5e_channel *pch = | ||||
container_of(pmt, struct mlx5e_channel, tag); | container_of(pmt, struct mlx5e_channel, tag); | ||||
complete(&pch->completion); | complete(&pch->completion); | ||||
} | } | ||||
Show All 18 Lines | #ifdef KERN_TLS | ||||
case IF_SND_TAG_TYPE_TLS: | case IF_SND_TAG_TYPE_TLS: | ||||
return (mlx5e_tls_snd_tag_alloc(ifp, params, ppmt)); | return (mlx5e_tls_snd_tag_alloc(ifp, params, ppmt)); | ||||
#endif | #endif | ||||
default: | default: | ||||
return (EOPNOTSUPP); | return (EOPNOTSUPP); | ||||
} | } | ||||
} | } | ||||
static int | |||||
mlx5e_snd_tag_modify(struct m_snd_tag *pmt, union if_snd_tag_modify_params *params) | |||||
{ | |||||
switch (pmt->type) { | |||||
#ifdef RATELIMIT | #ifdef RATELIMIT | ||||
case IF_SND_TAG_TYPE_RATE_LIMIT: | |||||
return (mlx5e_rl_snd_tag_modify(pmt, params)); | |||||
#ifdef KERN_TLS | |||||
case IF_SND_TAG_TYPE_TLS_RATE_LIMIT: | |||||
return (mlx5e_tls_snd_tag_modify(pmt, params)); | |||||
#endif | |||||
#endif | |||||
case IF_SND_TAG_TYPE_UNLIMITED: | |||||
#ifdef KERN_TLS | |||||
case IF_SND_TAG_TYPE_TLS: | |||||
#endif | |||||
default: | |||||
return (EOPNOTSUPP); | |||||
} | |||||
} | |||||
static int | |||||
mlx5e_snd_tag_query(struct m_snd_tag *pmt, union if_snd_tag_query_params *params) | |||||
{ | |||||
switch (pmt->type) { | |||||
#ifdef RATELIMIT | |||||
case IF_SND_TAG_TYPE_RATE_LIMIT: | |||||
return (mlx5e_rl_snd_tag_query(pmt, params)); | |||||
#ifdef KERN_TLS | |||||
case IF_SND_TAG_TYPE_TLS_RATE_LIMIT: | |||||
return (mlx5e_tls_snd_tag_query(pmt, params)); | |||||
#endif | |||||
#endif | |||||
case IF_SND_TAG_TYPE_UNLIMITED: | |||||
return (mlx5e_ul_snd_tag_query(pmt, params)); | |||||
#ifdef KERN_TLS | |||||
case IF_SND_TAG_TYPE_TLS: | |||||
return (mlx5e_tls_snd_tag_query(pmt, params)); | |||||
#endif | |||||
default: | |||||
return (EOPNOTSUPP); | |||||
} | |||||
} | |||||
#ifdef RATELIMIT | |||||
#define NUM_HDWR_RATES_MLX 13 | #define NUM_HDWR_RATES_MLX 13 | ||||
static const uint64_t adapter_rates_mlx[NUM_HDWR_RATES_MLX] = { | static const uint64_t adapter_rates_mlx[NUM_HDWR_RATES_MLX] = { | ||||
135375, /* 1,083,000 */ | 135375, /* 1,083,000 */ | ||||
180500, /* 1,444,000 */ | 180500, /* 1,444,000 */ | ||||
270750, /* 2,166,000 */ | 270750, /* 2,166,000 */ | ||||
361000, /* 2,888,000 */ | 361000, /* 2,888,000 */ | ||||
541500, /* 4,332,000 */ | 541500, /* 4,332,000 */ | ||||
721875, /* 5,775,000 */ | 721875, /* 5,775,000 */ | ||||
Show All 28 Lines | mlx5e_ratelimit_query(struct ifnet *ifp __unused, struct if_ratelimit_query_results *q) | ||||
q->flags = RT_IS_FIXED_TABLE; | q->flags = RT_IS_FIXED_TABLE; | ||||
q->max_flows = 0; /* mlx has no limit */ | q->max_flows = 0; /* mlx has no limit */ | ||||
q->number_of_rates = NUM_HDWR_RATES_MLX; | q->number_of_rates = NUM_HDWR_RATES_MLX; | ||||
q->min_segment_burst = 1; | q->min_segment_burst = 1; | ||||
} | } | ||||
#endif | #endif | ||||
static void | static void | ||||
mlx5e_snd_tag_free(struct m_snd_tag *pmt) | |||||
{ | |||||
switch (pmt->type) { | |||||
#ifdef RATELIMIT | |||||
case IF_SND_TAG_TYPE_RATE_LIMIT: | |||||
mlx5e_rl_snd_tag_free(pmt); | |||||
break; | |||||
#ifdef KERN_TLS | |||||
case IF_SND_TAG_TYPE_TLS_RATE_LIMIT: | |||||
mlx5e_tls_snd_tag_free(pmt); | |||||
break; | |||||
#endif | |||||
#endif | |||||
case IF_SND_TAG_TYPE_UNLIMITED: | |||||
mlx5e_ul_snd_tag_free(pmt); | |||||
break; | |||||
#ifdef KERN_TLS | |||||
case IF_SND_TAG_TYPE_TLS: | |||||
mlx5e_tls_snd_tag_free(pmt); | |||||
break; | |||||
#endif | |||||
default: | |||||
break; | |||||
} | |||||
} | |||||
static void | |||||
mlx5e_ifm_add(struct mlx5e_priv *priv, int type) | mlx5e_ifm_add(struct mlx5e_priv *priv, int type) | ||||
{ | { | ||||
ifmedia_add(&priv->media, type | IFM_ETHER, 0, NULL); | ifmedia_add(&priv->media, type | IFM_ETHER, 0, NULL); | ||||
ifmedia_add(&priv->media, type | IFM_ETHER | | ifmedia_add(&priv->media, type | IFM_ETHER | | ||||
IFM_ETH_RXPAUSE | IFM_ETH_TXPAUSE, 0, NULL); | IFM_ETH_RXPAUSE | IFM_ETH_TXPAUSE, 0, NULL); | ||||
ifmedia_add(&priv->media, type | IFM_ETHER | IFM_ETH_RXPAUSE, 0, NULL); | ifmedia_add(&priv->media, type | IFM_ETHER | IFM_ETH_RXPAUSE, 0, NULL); | ||||
ifmedia_add(&priv->media, type | IFM_ETHER | IFM_ETH_TXPAUSE, 0, NULL); | ifmedia_add(&priv->media, type | IFM_ETHER | IFM_ETH_TXPAUSE, 0, NULL); | ||||
ifmedia_add(&priv->media, type | IFM_ETHER | IFM_FDX, 0, NULL); | ifmedia_add(&priv->media, type | IFM_ETHER | IFM_FDX, 0, NULL); | ||||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | #endif | ||||
ifp->if_capabilities |= IFCAP_HWSTATS | IFCAP_HWRXTSTMP; | ifp->if_capabilities |= IFCAP_HWSTATS | IFCAP_HWRXTSTMP; | ||||
ifp->if_capabilities |= IFCAP_MEXTPG; | ifp->if_capabilities |= IFCAP_MEXTPG; | ||||
ifp->if_capabilities |= IFCAP_TXTLS4 | IFCAP_TXTLS6; | ifp->if_capabilities |= IFCAP_TXTLS4 | IFCAP_TXTLS6; | ||||
#ifdef RATELIMIT | #ifdef RATELIMIT | ||||
ifp->if_capabilities |= IFCAP_TXRTLMT | IFCAP_TXTLS_RTLMT; | ifp->if_capabilities |= IFCAP_TXRTLMT | IFCAP_TXTLS_RTLMT; | ||||
#endif | #endif | ||||
ifp->if_capabilities |= IFCAP_VXLAN_HWCSUM | IFCAP_VXLAN_HWTSO; | ifp->if_capabilities |= IFCAP_VXLAN_HWCSUM | IFCAP_VXLAN_HWTSO; | ||||
ifp->if_snd_tag_alloc = mlx5e_snd_tag_alloc; | ifp->if_snd_tag_alloc = mlx5e_snd_tag_alloc; | ||||
ifp->if_snd_tag_free = mlx5e_snd_tag_free; | |||||
ifp->if_snd_tag_modify = mlx5e_snd_tag_modify; | |||||
ifp->if_snd_tag_query = mlx5e_snd_tag_query; | |||||
#ifdef RATELIMIT | #ifdef RATELIMIT | ||||
ifp->if_ratelimit_query = mlx5e_ratelimit_query; | ifp->if_ratelimit_query = mlx5e_ratelimit_query; | ||||
#endif | #endif | ||||
/* set TSO limits so that we don't have to drop TX packets */ | /* set TSO limits so that we don't have to drop TX packets */ | ||||
ifp->if_hw_tsomax = MLX5E_MAX_TX_PAYLOAD_SIZE - (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN); | ifp->if_hw_tsomax = MLX5E_MAX_TX_PAYLOAD_SIZE - (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN); | ||||
ifp->if_hw_tsomaxsegcount = MLX5E_MAX_TX_MBUF_FRAGS - 1 /* hdr */; | ifp->if_hw_tsomaxsegcount = MLX5E_MAX_TX_MBUF_FRAGS - 1 /* hdr */; | ||||
ifp->if_hw_tsomaxsegsize = MLX5E_MAX_TX_MBUF_SIZE; | ifp->if_hw_tsomaxsegsize = MLX5E_MAX_TX_MBUF_SIZE; | ||||
▲ Show 20 Lines • Show All 432 Lines • Show Last 20 Lines |
I would put a comma at the end of line