Skip to content

Commit f21ad61

Browse files
Inbar Karmydavem330
authored andcommitted
net/mlx4_en: Add dynamic variable to hold the number of user priorities (UP)
Until this patch, the number of UPs was hard coded for eight. Replace this with a variable in struct "mlx4_en_port_profile". Currently, the variable will hold the maximum number of UP, as before. The patch creates an infrastructure to add an option for dynamic change of the actual number of TCs. Signed-off-by: Inbar Karmy <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> Cc: Tarick Bedeir <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent cddbb79 commit f21ad61

File tree

5 files changed

+17
-13
lines changed

5 files changed

+17
-13
lines changed

drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ static int mlx4_en_ets_validate(struct mlx4_en_priv *priv, struct ieee_ets *ets)
303303
int has_ets_tc = 0;
304304

305305
for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
306-
if (ets->prio_tc[i] >= MLX4_EN_NUM_UP) {
306+
if (ets->prio_tc[i] >= priv->prof->num_up) {
307307
en_err(priv, "Bad priority in UP <=> TC mapping. TC: %d, UP: %d\n",
308308
i, ets->prio_tc[i]);
309309
return -EINVAL;

drivers/net/ethernet/mellanox/mlx4/en_ethtool.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,7 +1750,8 @@ static void mlx4_en_get_channels(struct net_device *dev,
17501750
channel->max_tx = MLX4_EN_MAX_TX_RING_P_UP;
17511751

17521752
channel->rx_count = priv->rx_ring_num;
1753-
channel->tx_count = priv->tx_ring_num[TX] / MLX4_EN_NUM_UP;
1753+
channel->tx_count = priv->tx_ring_num[TX] /
1754+
priv->prof->num_up;
17541755
}
17551756

17561757
static int mlx4_en_set_channels(struct net_device *dev,
@@ -1773,18 +1774,19 @@ static int mlx4_en_set_channels(struct net_device *dev,
17731774

17741775
mutex_lock(&mdev->state_lock);
17751776
xdp_count = priv->tx_ring_num[TX_XDP] ? channel->rx_count : 0;
1776-
if (channel->tx_count * MLX4_EN_NUM_UP + xdp_count > MAX_TX_RINGS) {
1777+
if (channel->tx_count * priv->prof->num_up + xdp_count >
1778+
MAX_TX_RINGS) {
17771779
err = -EINVAL;
17781780
en_err(priv,
17791781
"Total number of TX and XDP rings (%d) exceeds the maximum supported (%d)\n",
1780-
channel->tx_count * MLX4_EN_NUM_UP + xdp_count,
1782+
channel->tx_count * priv->prof->num_up + xdp_count,
17811783
MAX_TX_RINGS);
17821784
goto out;
17831785
}
17841786

17851787
memcpy(&new_prof, priv->prof, sizeof(struct mlx4_en_port_profile));
17861788
new_prof.num_tx_rings_p_up = channel->tx_count;
1787-
new_prof.tx_ring_num[TX] = channel->tx_count * MLX4_EN_NUM_UP;
1789+
new_prof.tx_ring_num[TX] = channel->tx_count * priv->prof->num_up;
17881790
new_prof.tx_ring_num[TX_XDP] = xdp_count;
17891791
new_prof.rx_ring_num = channel->rx_count;
17901792

@@ -1803,7 +1805,7 @@ static int mlx4_en_set_channels(struct net_device *dev,
18031805
netif_set_real_num_rx_queues(dev, priv->rx_ring_num);
18041806

18051807
if (netdev_get_num_tc(dev))
1806-
mlx4_en_setup_tc(dev, MLX4_EN_NUM_UP);
1808+
mlx4_en_setup_tc(dev, priv->prof->num_up);
18071809

18081810
en_warn(priv, "Using %d TX rings\n", priv->tx_ring_num[TX]);
18091811
en_warn(priv, "Using %d RX rings\n", priv->rx_ring_num);

drivers/net/ethernet/mellanox/mlx4/en_main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,9 @@ static int mlx4_en_get_profile(struct mlx4_en_dev *mdev)
169169
params->prof[i].tx_ppp = pfctx;
170170
params->prof[i].tx_ring_size = MLX4_EN_DEF_TX_RING_SIZE;
171171
params->prof[i].rx_ring_size = MLX4_EN_DEF_RX_RING_SIZE;
172+
params->prof[i].num_up = MLX4_EN_NUM_UP_HIGH;
172173
params->prof[i].tx_ring_num[TX] = params->num_tx_rings_p_up *
173-
MLX4_EN_NUM_UP;
174+
params->prof[i].num_up;
174175
params->prof[i].rss_rings = 0;
175176
params->prof[i].inline_thold = inline_thold;
176177
}

drivers/net/ethernet/mellanox/mlx4/en_netdev.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ int mlx4_en_setup_tc(struct net_device *dev, u8 up)
6060
int i;
6161
unsigned int offset = 0;
6262

63-
if (up && up != MLX4_EN_NUM_UP)
63+
if (up && up != MLX4_EN_NUM_UP_HIGH)
6464
return -EINVAL;
6565

6666
netdev_set_num_tc(dev, up);
@@ -2780,7 +2780,7 @@ static int mlx4_xdp_set(struct net_device *dev, struct bpf_prog *prog)
27802780
if (priv->tx_ring_num[TX] + xdp_ring_num > MAX_TX_RINGS) {
27812781
tx_changed = 1;
27822782
new_prof.tx_ring_num[TX] =
2783-
MAX_TX_RINGS - ALIGN(xdp_ring_num, MLX4_EN_NUM_UP);
2783+
MAX_TX_RINGS - ALIGN(xdp_ring_num, priv->prof->num_up);
27842784
en_warn(priv, "Reducing the number of TX rings, to not exceed the max total rings number.\n");
27852785
}
27862786

@@ -3271,7 +3271,7 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
32713271
priv->flags |= MLX4_EN_DCB_ENABLED;
32723272
priv->cee_config.pfc_state = false;
32733273

3274-
for (i = 0; i < MLX4_EN_NUM_UP; i++)
3274+
for (i = 0; i < MLX4_EN_NUM_UP_HIGH; i++)
32753275
priv->cee_config.dcb_pfc[i] = pfc_disabled;
32763276

32773277
if (mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_ETS_CFG) {

drivers/net/ethernet/mellanox/mlx4/mlx4_en.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@
115115
#define MLX4_EN_SMALL_PKT_SIZE 64
116116
#define MLX4_EN_MIN_TX_RING_P_UP 1
117117
#define MLX4_EN_MAX_TX_RING_P_UP 32
118-
#define MLX4_EN_NUM_UP 8
118+
#define MLX4_EN_NUM_UP_HIGH 8
119119
#define MLX4_EN_DEF_RX_RING_SIZE 1024
120120
#define MLX4_EN_DEF_TX_RING_SIZE MLX4_EN_DEF_RX_RING_SIZE
121121
#define MAX_TX_RINGS (MLX4_EN_MAX_TX_RING_P_UP * \
122-
MLX4_EN_NUM_UP)
122+
MLX4_EN_NUM_UP_HIGH)
123123

124124
#define MLX4_EN_DEFAULT_TX_WORK 256
125125

@@ -386,6 +386,7 @@ struct mlx4_en_port_profile {
386386
u8 rx_ppp;
387387
u8 tx_pause;
388388
u8 tx_ppp;
389+
u8 num_up;
389390
int rss_rings;
390391
int inline_thold;
391392
struct hwtstamp_config hwtstamp_config;
@@ -485,7 +486,7 @@ enum dcb_pfc_type {
485486

486487
struct mlx4_en_cee_config {
487488
bool pfc_state;
488-
enum dcb_pfc_type dcb_pfc[MLX4_EN_NUM_UP];
489+
enum dcb_pfc_type dcb_pfc[MLX4_EN_NUM_UP_HIGH];
489490
};
490491
#endif
491492

0 commit comments

Comments
 (0)