aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorHans Petter Selasky <hselasky@FreeBSD.org>2019-05-08 10:34:14 +0000
committerHans Petter Selasky <hselasky@FreeBSD.org>2019-05-08 10:34:14 +0000
commit243853215d4a8b87056d2d5cc8e919b073caff7f (patch)
tree0c514040fcd0996e4173eba2328679697666ea91 /sys
parentffadb62f2021dd0a987081b164918dee408817ea (diff)
downloadsrc-243853215d4a8b87056d2d5cc8e919b073caff7f.tar.gz
src-243853215d4a8b87056d2d5cc8e919b073caff7f.zip
Correct number of elements for priority to traffic class mappings in mlx5en(4).
The number of priorities is always 8, while the number of traffic classes supported can vary. While at it convert the sysctl node into an array. MFC after: 3 days Sponsored by: Mellanox Technologies
Notes
Notes: svn path=/head/; revision=347260
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/mlx5/mlx5_en/en.h9
-rw-r--r--sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c50
-rw-r--r--sys/dev/mlx5/mlx5_en/mlx5_en_main.c140
3 files changed, 100 insertions, 99 deletions
diff --git a/sys/dev/mlx5/mlx5_en/en.h b/sys/dev/mlx5/mlx5_en/en.h
index fc127459ba28..57863a78f1e3 100644
--- a/sys/dev/mlx5/mlx5_en/en.h
+++ b/sys/dev/mlx5/mlx5_en/en.h
@@ -74,6 +74,9 @@
#include <dev/mlx5/mlx5_core/transobj.h>
#include <dev/mlx5/mlx5_core/mlx5_core.h>
+#define MLX5E_MAX_PRIORITY 8
+
+/* IEEE 802.1Qaz standard supported values */
#define IEEE_8021QAZ_MAX_TCS 8
#define MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE 0x7
@@ -483,10 +486,10 @@ struct mlx5e_params {
u16 rx_hash_log_tbl_sz;
u32 tx_pauseframe_control __aligned(4);
u32 rx_pauseframe_control __aligned(4);
- u32 tx_priority_flow_control __aligned(4);
- u32 rx_priority_flow_control __aligned(4);
u16 tx_max_inline;
u8 tx_min_inline_mode;
+ u8 tx_priority_flow_control;
+ u8 rx_priority_flow_control;
u8 channels_rsss;
};
@@ -525,7 +528,7 @@ struct mlx5e_params_ethtool {
MLX5E_PARAMS(MLX5E_STATS_VAR)
u64 max_bw_value[IEEE_8021QAZ_MAX_TCS];
u8 max_bw_share[IEEE_8021QAZ_MAX_TCS];
- u8 prio_tc[IEEE_8021QAZ_MAX_TCS];
+ u8 prio_tc[MLX5E_MAX_PRIORITY];
u8 dscp2prio[MLX5_MAX_SUPPORTED_DSCP];
u8 trust_state;
};
diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c b/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c
index abfcb15e4a65..cf03dde126c7 100644
--- a/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c
+++ b/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c
@@ -298,8 +298,8 @@ mlx5e_get_prio_tc(struct mlx5e_priv *priv)
return (EOPNOTSUPP);
}
- for (i = 0; i <= mlx5_max_tc(priv->mdev); i++) {
- err = -mlx5_query_port_prio_tc(mdev, i, &(priv->params_ethtool.prio_tc[i]));
+ for (i = 0; i != MLX5E_MAX_PRIORITY; i++) {
+ err = -mlx5_query_port_prio_tc(mdev, i, priv->params_ethtool.prio_tc + i);
if (err)
break;
}
@@ -311,29 +311,35 @@ static int
mlx5e_prio_to_tc_handler(SYSCTL_HANDLER_ARGS)
{
struct mlx5e_priv *priv = arg1;
- int prio_index = arg2;
struct mlx5_core_dev *mdev = priv->mdev;
+ uint8_t temp[MLX5E_MAX_PRIORITY];
int err;
- uint8_t result;
+ int i;
PRIV_LOCK(priv);
- result = priv->params_ethtool.prio_tc[prio_index];
- err = sysctl_handle_8(oidp, &result, 0, req);
- if (err || !req->newptr ||
- result == priv->params_ethtool.prio_tc[prio_index])
- goto done;
-
- if (result > mlx5_max_tc(mdev)) {
- err = ERANGE;
+ err = SYSCTL_OUT(req, priv->params_ethtool.prio_tc, MLX5E_MAX_PRIORITY);
+ if (err || !req->newptr)
goto done;
- }
-
- err = -mlx5_set_port_prio_tc(mdev, prio_index, result);
+ err = SYSCTL_IN(req, temp, MLX5E_MAX_PRIORITY);
if (err)
goto done;
- priv->params_ethtool.prio_tc[prio_index] = result;
+ for (i = 0; i != MLX5E_MAX_PRIORITY; i++) {
+ if (temp[i] > mlx5_max_tc(mdev)) {
+ err = ERANGE;
+ goto done;
+ }
+ }
+ for (i = 0; i != MLX5E_MAX_PRIORITY; i++) {
+ if (temp[i] == priv->params_ethtool.prio_tc[i])
+ continue;
+ err = -mlx5_set_port_prio_tc(mdev, i, temp[i]);
+ if (err)
+ goto done;
+ /* update cached value */
+ priv->params_ethtool.prio_tc[i] = temp[i];
+ }
done:
PRIV_UNLOCK(priv);
return (err);
@@ -1262,14 +1268,10 @@ mlx5e_create_ethtool(struct mlx5e_priv *priv)
/* Priority to traffic class mapping */
if (mlx5e_get_prio_tc(priv) == 0) {
- for (i = 0; i <= mlx5_max_tc(mdev); i++) {
- char name[32];
- snprintf(name, sizeof(name), "prio_%d_to_tc", i);
- SYSCTL_ADD_PROC(&priv->sysctl_ctx, SYSCTL_CHILDREN(qos_node),
- OID_AUTO, name, CTLTYPE_U8 | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
- priv, i, mlx5e_prio_to_tc_handler, "CU",
- "Set priority to traffic class");
- }
+ SYSCTL_ADD_PROC(&priv->sysctl_ctx, SYSCTL_CHILDREN(qos_node),
+ OID_AUTO, "prio_0_7_tc", CTLTYPE_U8 | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
+ priv, 0, mlx5e_prio_to_tc_handler, "CU",
+ "Set traffic class 0 to 7 for priority 0 to 7 inclusivly");
}
/* DSCP support */
diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
index 317c26609583..f06d303808da 100644
--- a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
+++ b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
@@ -281,7 +281,9 @@ mlx5e_set_port_pfc(struct mlx5e_priv *priv)
{
int error;
- if (priv->params.rx_pauseframe_control ||
+ if (priv->gone != 0) {
+ error = -ENXIO;
+ } else if (priv->params.rx_pauseframe_control ||
priv->params.tx_pauseframe_control) {
if_printf(priv->ifp,
"Global pauseframes must be disabled before enabling PFC.\n");
@@ -3443,79 +3445,98 @@ static int
mlx5e_sysctl_tx_priority_flow_control(SYSCTL_HANDLER_ARGS)
{
struct mlx5e_priv *priv = arg1;
+ uint8_t temp[MLX5E_MAX_PRIORITY];
uint32_t tx_pfc;
- uint32_t value;
- int error;
+ int err;
+ int i;
PRIV_LOCK(priv);
tx_pfc = priv->params.tx_priority_flow_control;
- /* get current value */
- value = (tx_pfc >> arg2) & 1;
+ for (i = 0; i != MLX5E_MAX_PRIORITY; i++)
+ temp[i] = (tx_pfc >> i) & 1;
- error = sysctl_handle_32(oidp, &value, 0, req);
+ err = SYSCTL_OUT(req, temp, MLX5E_MAX_PRIORITY);
+ if (err || !req->newptr)
+ goto done;
+ err = SYSCTL_IN(req, temp, MLX5E_MAX_PRIORITY);
+ if (err)
+ goto done;
- /* range check value */
- if (value != 0)
- priv->params.tx_priority_flow_control |= (1 << arg2);
- else
- priv->params.tx_priority_flow_control &= ~(1 << arg2);
+ priv->params.tx_priority_flow_control = 0;
- /* check if update is required */
- if (error == 0 && priv->gone == 0 &&
- tx_pfc != priv->params.tx_priority_flow_control) {
- error = -mlx5e_set_port_pfc(priv);
- /* restore previous value */
- if (error != 0)
- priv->params.tx_priority_flow_control= tx_pfc;
+ /* range check input value */
+ for (i = 0; i != MLX5E_MAX_PRIORITY; i++) {
+ if (temp[i] > 1) {
+ err = ERANGE;
+ goto done;
+ }
+ priv->params.tx_priority_flow_control |= (temp[i] << i);
}
+
+ /* check if update is required */
+ if (tx_pfc != priv->params.tx_priority_flow_control)
+ err = -mlx5e_set_port_pfc(priv);
+done:
+ if (err != 0)
+ priv->params.tx_priority_flow_control= tx_pfc;
PRIV_UNLOCK(priv);
- return (error);
+ return (err);
}
static int
mlx5e_sysctl_rx_priority_flow_control(SYSCTL_HANDLER_ARGS)
{
struct mlx5e_priv *priv = arg1;
+ uint8_t temp[MLX5E_MAX_PRIORITY];
uint32_t rx_pfc;
- uint32_t value;
- int error;
+ int err;
+ int i;
PRIV_LOCK(priv);
rx_pfc = priv->params.rx_priority_flow_control;
- /* get current value */
- value = (rx_pfc >> arg2) & 1;
+ for (i = 0; i != MLX5E_MAX_PRIORITY; i++)
+ temp[i] = (rx_pfc >> i) & 1;
- error = sysctl_handle_32(oidp, &value, 0, req);
+ err = SYSCTL_OUT(req, temp, MLX5E_MAX_PRIORITY);
+ if (err || !req->newptr)
+ goto done;
+ err = SYSCTL_IN(req, temp, MLX5E_MAX_PRIORITY);
+ if (err)
+ goto done;
- /* range check value */
- if (value != 0)
- priv->params.rx_priority_flow_control |= (1 << arg2);
- else
- priv->params.rx_priority_flow_control &= ~(1 << arg2);
+ priv->params.rx_priority_flow_control = 0;
- /* check if update is required */
- if (error == 0 && priv->gone == 0 &&
- rx_pfc != priv->params.rx_priority_flow_control) {
- error = -mlx5e_set_port_pfc(priv);
- /* restore previous value */
- if (error != 0)
- priv->params.rx_priority_flow_control= rx_pfc;
+ /* range check input value */
+ for (i = 0; i != MLX5E_MAX_PRIORITY; i++) {
+ if (temp[i] > 1) {
+ err = ERANGE;
+ goto done;
+ }
+ priv->params.rx_priority_flow_control |= (temp[i] << i);
}
+
+ /* check if update is required */
+ if (rx_pfc != priv->params.rx_priority_flow_control)
+ err = -mlx5e_set_port_pfc(priv);
+done:
+ if (err != 0)
+ priv->params.rx_priority_flow_control= rx_pfc;
PRIV_UNLOCK(priv);
- return (error);
+ return (err);
}
static void
mlx5e_setup_pauseframes(struct mlx5e_priv *priv)
{
- unsigned int x;
+#if (__FreeBSD_version < 1100000)
char path[96];
+#endif
int error;
/* enable pauseframes by default */
@@ -3540,25 +3561,6 @@ mlx5e_setup_pauseframes(struct mlx5e_priv *priv)
/* try to fetch tunable, if any */
TUNABLE_INT_FETCH(path, &priv->params.rx_pauseframe_control);
-
- for (x = 0; x != 8; x++) {
-
- /* compute path for sysctl */
- snprintf(path, sizeof(path), "dev.mce.%d.tx_priority_flow_control_%u",
- device_get_unit(priv->mdev->pdev->dev.bsddev), x);
-
- /* try to fetch tunable, if any */
- if (TUNABLE_INT_FETCH(path, &value) == 0 && value != 0)
- priv->params.tx_priority_flow_control |= 1 << x;
-
- /* compute path for sysctl */
- snprintf(path, sizeof(path), "dev.mce.%d.rx_priority_flow_control_%u",
- device_get_unit(priv->mdev->pdev->dev.bsddev), x);
-
- /* try to fetch tunable, if any */
- if (TUNABLE_INT_FETCH(path, &value) == 0 && value != 0)
- priv->params.rx_priority_flow_control |= 1 << x;
- }
#endif
/* register pauseframe SYSCTLs */
@@ -3572,22 +3574,16 @@ mlx5e_setup_pauseframes(struct mlx5e_priv *priv)
&priv->params.rx_pauseframe_control, 0,
"Set to enable RX pause frames. Clear to disable.");
- /* register priority_flow control, PFC, SYSCTLs */
- for (x = 0; x != 8; x++) {
- snprintf(path, sizeof(path), "tx_priority_flow_control_%u", x);
-
- SYSCTL_ADD_PROC(&priv->sysctl_ctx, SYSCTL_CHILDREN(priv->sysctl_ifnet),
- OID_AUTO, path, CTLTYPE_UINT | CTLFLAG_RWTUN |
- CTLFLAG_MPSAFE, priv, x, &mlx5e_sysctl_tx_priority_flow_control, "IU",
- "Set to enable TX ports flow control frames for given priority. Clear to disable.");
+ /* register priority flow control, PFC, SYSCTLs */
+ SYSCTL_ADD_PROC(&priv->sysctl_ctx, SYSCTL_CHILDREN(priv->sysctl_ifnet),
+ OID_AUTO, "tx_priority_flow_control", CTLTYPE_U8 | CTLFLAG_RWTUN |
+ CTLFLAG_MPSAFE, priv, 0, &mlx5e_sysctl_tx_priority_flow_control, "CU",
+ "Set to enable TX ports flow control frames for priorities 0..7. Clear to disable.");
- snprintf(path, sizeof(path), "rx_priority_flow_control_%u", x);
-
- SYSCTL_ADD_PROC(&priv->sysctl_ctx, SYSCTL_CHILDREN(priv->sysctl_ifnet),
- OID_AUTO, path, CTLTYPE_UINT | CTLFLAG_RWTUN |
- CTLFLAG_MPSAFE, priv, x, &mlx5e_sysctl_rx_priority_flow_control, "IU",
- "Set to enable RX ports flow control frames for given priority. Clear to disable.");
- }
+ SYSCTL_ADD_PROC(&priv->sysctl_ctx, SYSCTL_CHILDREN(priv->sysctl_ifnet),
+ OID_AUTO, "rx_priority_flow_control", CTLTYPE_U8 | CTLFLAG_RWTUN |
+ CTLFLAG_MPSAFE, priv, 0, &mlx5e_sysctl_rx_priority_flow_control, "CU",
+ "Set to enable RX ports flow control frames for priorities 0..7. Clear to disable.");
PRIV_LOCK(priv);