Commit be98737a authored by Tariq Toukan's avatar Tariq Toukan Committed by Saeed Mahameed

net/mlx5e: Use dynamic per-channel allocations in stats

Make stats array an array of pointer. This patch comes in to prepare for
the next patch where allocations of the stats are to be performed
dynamically on first usage.
Signed-off-by: default avatarLama Kayal <lkayal@nvidia.com>
Signed-off-by: default avatarTariq Toukan <tariqt@nvidia.com>
Reviewed-by: default avatarMoshe Shemesh <moshe@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent 473baf2e
...@@ -906,7 +906,7 @@ struct mlx5e_priv { ...@@ -906,7 +906,7 @@ struct mlx5e_priv {
struct net_device *netdev; struct net_device *netdev;
struct mlx5e_trap *en_trap; struct mlx5e_trap *en_trap;
struct mlx5e_stats stats; struct mlx5e_stats stats;
struct mlx5e_channel_stats *channel_stats; struct mlx5e_channel_stats **channel_stats;
struct mlx5e_channel_stats trap_stats; struct mlx5e_channel_stats trap_stats;
struct mlx5e_ptp_stats ptp_stats; struct mlx5e_ptp_stats ptp_stats;
u16 stats_nch; u16 stats_nch;
......
...@@ -20,7 +20,7 @@ mlx5e_hv_vhca_fill_ring_stats(struct mlx5e_priv *priv, int ch, ...@@ -20,7 +20,7 @@ mlx5e_hv_vhca_fill_ring_stats(struct mlx5e_priv *priv, int ch,
struct mlx5e_channel_stats *stats; struct mlx5e_channel_stats *stats;
int tc; int tc;
stats = &priv->channel_stats[ch]; stats = priv->channel_stats[ch];
data->rx_packets = stats->rq.packets; data->rx_packets = stats->rq.packets;
data->rx_bytes = stats->rq.bytes; data->rx_bytes = stats->rq.bytes;
......
...@@ -67,7 +67,7 @@ static int mlx5e_init_xsk_rq(struct mlx5e_channel *c, ...@@ -67,7 +67,7 @@ static int mlx5e_init_xsk_rq(struct mlx5e_channel *c,
rq->hw_mtu = MLX5E_SW2HW_MTU(params, params->sw_mtu); rq->hw_mtu = MLX5E_SW2HW_MTU(params, params->sw_mtu);
rq->xdpsq = &c->rq_xdpsq; rq->xdpsq = &c->rq_xdpsq;
rq->xsk_pool = pool; rq->xsk_pool = pool;
rq->stats = &c->priv->channel_stats[c->ix].xskrq; rq->stats = &c->priv->channel_stats[c->ix]->xskrq;
rq->ptp_cyc2time = mlx5_rq_ts_translator(mdev); rq->ptp_cyc2time = mlx5_rq_ts_translator(mdev);
rq_xdp_ix = c->ix + params->num_channels * MLX5E_RQ_GROUP_XSK; rq_xdp_ix = c->ix + params->num_channels * MLX5E_RQ_GROUP_XSK;
err = mlx5e_rq_set_handlers(rq, params, xsk); err = mlx5e_rq_set_handlers(rq, params, xsk);
......
...@@ -611,7 +611,7 @@ int mlx5e_ktls_add_rx(struct net_device *netdev, struct sock *sk, ...@@ -611,7 +611,7 @@ int mlx5e_ktls_add_rx(struct net_device *netdev, struct sock *sk,
priv_rx->rxq = rxq; priv_rx->rxq = rxq;
priv_rx->sk = sk; priv_rx->sk = sk;
priv_rx->rq_stats = &priv->channel_stats[rxq].rq; priv_rx->rq_stats = &priv->channel_stats[rxq]->rq;
priv_rx->sw_stats = &priv->tls->sw_stats; priv_rx->sw_stats = &priv->tls->sw_stats;
mlx5e_set_ktls_rx_priv_ctx(tls_ctx, priv_rx); mlx5e_set_ktls_rx_priv_ctx(tls_ctx, priv_rx);
......
...@@ -556,7 +556,7 @@ static struct mlx5_flow_handle *arfs_add_rule(struct mlx5e_priv *priv, ...@@ -556,7 +556,7 @@ static struct mlx5_flow_handle *arfs_add_rule(struct mlx5e_priv *priv,
rule = mlx5_add_flow_rules(ft, spec, &flow_act, &dest, 1); rule = mlx5_add_flow_rules(ft, spec, &flow_act, &dest, 1);
if (IS_ERR(rule)) { if (IS_ERR(rule)) {
err = PTR_ERR(rule); err = PTR_ERR(rule);
priv->channel_stats[arfs_rule->rxq].rq.arfs_err++; priv->channel_stats[arfs_rule->rxq]->rq.arfs_err++;
mlx5e_dbg(HW, priv, mlx5e_dbg(HW, priv,
"%s: add rule(filter id=%d, rq idx=%d, ip proto=0x%x) failed,err=%d\n", "%s: add rule(filter id=%d, rq idx=%d, ip proto=0x%x) failed,err=%d\n",
__func__, arfs_rule->filter_id, arfs_rule->rxq, __func__, arfs_rule->filter_id, arfs_rule->rxq,
......
...@@ -479,7 +479,7 @@ static int mlx5e_init_rxq_rq(struct mlx5e_channel *c, struct mlx5e_params *param ...@@ -479,7 +479,7 @@ static int mlx5e_init_rxq_rq(struct mlx5e_channel *c, struct mlx5e_params *param
rq->mdev = mdev; rq->mdev = mdev;
rq->hw_mtu = MLX5E_SW2HW_MTU(params, params->sw_mtu); rq->hw_mtu = MLX5E_SW2HW_MTU(params, params->sw_mtu);
rq->xdpsq = &c->rq_xdpsq; rq->xdpsq = &c->rq_xdpsq;
rq->stats = &c->priv->channel_stats[c->ix].rq; rq->stats = &c->priv->channel_stats[c->ix]->rq;
rq->ptp_cyc2time = mlx5_rq_ts_translator(mdev); rq->ptp_cyc2time = mlx5_rq_ts_translator(mdev);
err = mlx5e_rq_set_handlers(rq, params, NULL); err = mlx5e_rq_set_handlers(rq, params, NULL);
if (err) if (err)
...@@ -1161,10 +1161,10 @@ static int mlx5e_alloc_xdpsq(struct mlx5e_channel *c, ...@@ -1161,10 +1161,10 @@ static int mlx5e_alloc_xdpsq(struct mlx5e_channel *c,
sq->xsk_pool = xsk_pool; sq->xsk_pool = xsk_pool;
sq->stats = sq->xsk_pool ? sq->stats = sq->xsk_pool ?
&c->priv->channel_stats[c->ix].xsksq : &c->priv->channel_stats[c->ix]->xsksq :
is_redirect ? is_redirect ?
&c->priv->channel_stats[c->ix].xdpsq : &c->priv->channel_stats[c->ix]->xdpsq :
&c->priv->channel_stats[c->ix].rq_xdpsq; &c->priv->channel_stats[c->ix]->rq_xdpsq;
param->wq.db_numa_node = cpu_to_node(c->cpu); param->wq.db_numa_node = cpu_to_node(c->cpu);
err = mlx5_wq_cyc_create(mdev, &param->wq, sqc_wq, wq, &sq->wq_ctrl); err = mlx5_wq_cyc_create(mdev, &param->wq, sqc_wq, wq, &sq->wq_ctrl);
...@@ -1928,7 +1928,7 @@ static int mlx5e_open_sqs(struct mlx5e_channel *c, ...@@ -1928,7 +1928,7 @@ static int mlx5e_open_sqs(struct mlx5e_channel *c,
err = mlx5e_open_txqsq(c, c->priv->tisn[c->lag_port][tc], txq_ix, err = mlx5e_open_txqsq(c, c->priv->tisn[c->lag_port][tc], txq_ix,
params, &cparam->txq_sq, &c->sq[tc], tc, params, &cparam->txq_sq, &c->sq[tc], tc,
qos_queue_group_id, qos_queue_group_id,
&c->priv->channel_stats[c->ix].sq[tc]); &c->priv->channel_stats[c->ix]->sq[tc]);
if (err) if (err)
goto err_close_sqs; goto err_close_sqs;
} }
...@@ -2207,7 +2207,7 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix, ...@@ -2207,7 +2207,7 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix,
c->mkey_be = cpu_to_be32(priv->mdev->mlx5e_res.hw_objs.mkey); c->mkey_be = cpu_to_be32(priv->mdev->mlx5e_res.hw_objs.mkey);
c->num_tc = mlx5e_get_dcb_num_tc(params); c->num_tc = mlx5e_get_dcb_num_tc(params);
c->xdp = !!params->xdp_prog; c->xdp = !!params->xdp_prog;
c->stats = &priv->channel_stats[ix].ch; c->stats = &priv->channel_stats[ix]->ch;
c->aff_mask = irq_get_effective_affinity_mask(irq); c->aff_mask = irq_get_effective_affinity_mask(irq);
c->lag_port = mlx5e_enumerate_lag_port(priv->mdev, ix); c->lag_port = mlx5e_enumerate_lag_port(priv->mdev, ix);
...@@ -3371,7 +3371,7 @@ void mlx5e_fold_sw_stats64(struct mlx5e_priv *priv, struct rtnl_link_stats64 *s) ...@@ -3371,7 +3371,7 @@ void mlx5e_fold_sw_stats64(struct mlx5e_priv *priv, struct rtnl_link_stats64 *s)
int i; int i;
for (i = 0; i < priv->stats_nch; i++) { for (i = 0; i < priv->stats_nch; i++) {
struct mlx5e_channel_stats *channel_stats = &priv->channel_stats[i]; struct mlx5e_channel_stats *channel_stats = priv->channel_stats[i];
struct mlx5e_rq_stats *xskrq_stats = &channel_stats->xskrq; struct mlx5e_rq_stats *xskrq_stats = &channel_stats->xskrq;
struct mlx5e_rq_stats *rq_stats = &channel_stats->rq; struct mlx5e_rq_stats *rq_stats = &channel_stats->rq;
int j; int j;
...@@ -5196,8 +5196,20 @@ int mlx5e_priv_init(struct mlx5e_priv *priv, ...@@ -5196,8 +5196,20 @@ int mlx5e_priv_init(struct mlx5e_priv *priv,
if (!priv->channel_stats) if (!priv->channel_stats)
goto err_free_channel_tc2realtxq; goto err_free_channel_tc2realtxq;
for (i = 0; i < priv->stats_nch; i++) {
priv->channel_stats[i] = kvzalloc_node(sizeof(**priv->channel_stats),
GFP_KERNEL, node);
if (!priv->channel_stats[i])
goto err_free_channel_stats;
}
return 0; return 0;
err_free_channel_stats:
while (--i >= 0)
kvfree(priv->channel_stats[i]);
kfree(priv->channel_stats);
i = nch;
err_free_channel_tc2realtxq: err_free_channel_tc2realtxq:
while (--i >= 0) while (--i >= 0)
kfree(priv->channel_tc2realtxq[i]); kfree(priv->channel_tc2realtxq[i]);
...@@ -5221,6 +5233,8 @@ void mlx5e_priv_cleanup(struct mlx5e_priv *priv) ...@@ -5221,6 +5233,8 @@ void mlx5e_priv_cleanup(struct mlx5e_priv *priv)
if (!priv->mdev) if (!priv->mdev)
return; return;
for (i = 0; i < priv->stats_nch; i++)
kvfree(priv->channel_stats[i]);
kfree(priv->channel_stats); kfree(priv->channel_stats);
for (i = 0; i < priv->max_nch; i++) for (i = 0; i < priv->max_nch; i++)
kfree(priv->channel_tc2realtxq[i]); kfree(priv->channel_tc2realtxq[i]);
......
...@@ -2189,7 +2189,7 @@ static inline void mlx5i_complete_rx_cqe(struct mlx5e_rq *rq, ...@@ -2189,7 +2189,7 @@ static inline void mlx5i_complete_rx_cqe(struct mlx5e_rq *rq,
priv = mlx5i_epriv(netdev); priv = mlx5i_epriv(netdev);
tstamp = &priv->tstamp; tstamp = &priv->tstamp;
stats = &priv->channel_stats[rq->ix].rq; stats = rq->stats;
flags_rqpn = be32_to_cpu(cqe->flags_rqpn); flags_rqpn = be32_to_cpu(cqe->flags_rqpn);
g = (flags_rqpn >> 28) & 3; g = (flags_rqpn >> 28) & 3;
......
...@@ -463,7 +463,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(sw) ...@@ -463,7 +463,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(sw)
for (i = 0; i < priv->stats_nch; i++) { for (i = 0; i < priv->stats_nch; i++) {
struct mlx5e_channel_stats *channel_stats = struct mlx5e_channel_stats *channel_stats =
&priv->channel_stats[i]; priv->channel_stats[i];
int j; int j;
mlx5e_stats_grp_sw_update_stats_rq_stats(s, &channel_stats->rq); mlx5e_stats_grp_sw_update_stats_rq_stats(s, &channel_stats->rq);
...@@ -2197,21 +2197,21 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(channels) ...@@ -2197,21 +2197,21 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(channels)
for (i = 0; i < max_nch; i++) for (i = 0; i < max_nch; i++)
for (j = 0; j < NUM_CH_STATS; j++) for (j = 0; j < NUM_CH_STATS; j++)
data[idx++] = data[idx++] =
MLX5E_READ_CTR64_CPU(&priv->channel_stats[i].ch, MLX5E_READ_CTR64_CPU(&priv->channel_stats[i]->ch,
ch_stats_desc, j); ch_stats_desc, j);
for (i = 0; i < max_nch; i++) { for (i = 0; i < max_nch; i++) {
for (j = 0; j < NUM_RQ_STATS; j++) for (j = 0; j < NUM_RQ_STATS; j++)
data[idx++] = data[idx++] =
MLX5E_READ_CTR64_CPU(&priv->channel_stats[i].rq, MLX5E_READ_CTR64_CPU(&priv->channel_stats[i]->rq,
rq_stats_desc, j); rq_stats_desc, j);
for (j = 0; j < NUM_XSKRQ_STATS * is_xsk; j++) for (j = 0; j < NUM_XSKRQ_STATS * is_xsk; j++)
data[idx++] = data[idx++] =
MLX5E_READ_CTR64_CPU(&priv->channel_stats[i].xskrq, MLX5E_READ_CTR64_CPU(&priv->channel_stats[i]->xskrq,
xskrq_stats_desc, j); xskrq_stats_desc, j);
for (j = 0; j < NUM_RQ_XDPSQ_STATS; j++) for (j = 0; j < NUM_RQ_XDPSQ_STATS; j++)
data[idx++] = data[idx++] =
MLX5E_READ_CTR64_CPU(&priv->channel_stats[i].rq_xdpsq, MLX5E_READ_CTR64_CPU(&priv->channel_stats[i]->rq_xdpsq,
rq_xdpsq_stats_desc, j); rq_xdpsq_stats_desc, j);
} }
...@@ -2219,17 +2219,17 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(channels) ...@@ -2219,17 +2219,17 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(channels)
for (i = 0; i < max_nch; i++) for (i = 0; i < max_nch; i++)
for (j = 0; j < NUM_SQ_STATS; j++) for (j = 0; j < NUM_SQ_STATS; j++)
data[idx++] = data[idx++] =
MLX5E_READ_CTR64_CPU(&priv->channel_stats[i].sq[tc], MLX5E_READ_CTR64_CPU(&priv->channel_stats[i]->sq[tc],
sq_stats_desc, j); sq_stats_desc, j);
for (i = 0; i < max_nch; i++) { for (i = 0; i < max_nch; i++) {
for (j = 0; j < NUM_XSKSQ_STATS * is_xsk; j++) for (j = 0; j < NUM_XSKSQ_STATS * is_xsk; j++)
data[idx++] = data[idx++] =
MLX5E_READ_CTR64_CPU(&priv->channel_stats[i].xsksq, MLX5E_READ_CTR64_CPU(&priv->channel_stats[i]->xsksq,
xsksq_stats_desc, j); xsksq_stats_desc, j);
for (j = 0; j < NUM_XDPSQ_STATS; j++) for (j = 0; j < NUM_XDPSQ_STATS; j++)
data[idx++] = data[idx++] =
MLX5E_READ_CTR64_CPU(&priv->channel_stats[i].xdpsq, MLX5E_READ_CTR64_CPU(&priv->channel_stats[i]->xdpsq,
xdpsq_stats_desc, j); xdpsq_stats_desc, j);
} }
......
...@@ -117,7 +117,7 @@ static void mlx5i_grp_sw_update_stats(struct mlx5e_priv *priv) ...@@ -117,7 +117,7 @@ static void mlx5i_grp_sw_update_stats(struct mlx5e_priv *priv)
struct mlx5e_channel_stats *channel_stats; struct mlx5e_channel_stats *channel_stats;
struct mlx5e_rq_stats *rq_stats; struct mlx5e_rq_stats *rq_stats;
channel_stats = &priv->channel_stats[i]; channel_stats = priv->channel_stats[i];
rq_stats = &channel_stats->rq; rq_stats = &channel_stats->rq;
s.rx_packets += rq_stats->packets; s.rx_packets += rq_stats->packets;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment