1 // SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
2 /* Copyright (c) 2021, Mellanox Technologies inc. All rights reserved. */
9 unsigned int mlx5e_channels_get_num(struct mlx5e_channels *chs)
14 static struct mlx5e_channel *mlx5e_channels_get(struct mlx5e_channels *chs, unsigned int ix)
16 WARN_ON_ONCE(ix >= mlx5e_channels_get_num(chs));
20 bool mlx5e_channels_is_xsk(struct mlx5e_channels *chs, unsigned int ix)
22 struct mlx5e_channel *c = mlx5e_channels_get(chs, ix);
24 return test_bit(MLX5E_CHANNEL_STATE_XSK, c->state);
27 void mlx5e_channels_get_regular_rqn(struct mlx5e_channels *chs, unsigned int ix, u32 *rqn,
30 struct mlx5e_channel *c = mlx5e_channels_get(chs, ix);
34 *vhca_id = MLX5_CAP_GEN(c->mdev, vhca_id);
37 void mlx5e_channels_get_xsk_rqn(struct mlx5e_channels *chs, unsigned int ix, u32 *rqn,
40 struct mlx5e_channel *c = mlx5e_channels_get(chs, ix);
42 WARN_ON_ONCE(!test_bit(MLX5E_CHANNEL_STATE_XSK, c->state));
46 *vhca_id = MLX5_CAP_GEN(c->mdev, vhca_id);
49 bool mlx5e_channels_get_ptp_rqn(struct mlx5e_channels *chs, u32 *rqn)
51 struct mlx5e_ptp *c = chs->ptp;
53 if (!c || !test_bit(MLX5E_PTP_STATE_RX, c->state))
60 int mlx5e_channels_rx_change_dim(struct mlx5e_channels *chs, bool enable)
64 for (i = 0; i < chs->num; i++) {
65 int err = mlx5e_dim_rx_change(&chs->c[i]->rq, enable);
74 int mlx5e_channels_tx_change_dim(struct mlx5e_channels *chs, bool enable)
78 for (i = 0; i < chs->num; i++) {
79 for (tc = 0; tc < mlx5e_get_dcb_num_tc(&chs->params); tc++) {
80 int err = mlx5e_dim_tx_change(&chs->c[i]->sq[tc], enable);
90 int mlx5e_channels_rx_toggle_dim(struct mlx5e_channels *chs)
94 for (i = 0; i < chs->num; i++) {
95 /* If dim is enabled for the channel, reset the dim state so the
96 * collected statistics will be reset. This is useful for
97 * supporting legacy interfaces that allow things like changing
98 * the CQ period mode for all channels without disturbing
99 * individual channel configurations.
101 if (chs->c[i]->rq.dim) {
104 mlx5e_dim_rx_change(&chs->c[i]->rq, false);
105 err = mlx5e_dim_rx_change(&chs->c[i]->rq, true);
114 int mlx5e_channels_tx_toggle_dim(struct mlx5e_channels *chs)
118 for (i = 0; i < chs->num; i++) {
119 for (tc = 0; tc < mlx5e_get_dcb_num_tc(&chs->params); tc++) {
122 /* If dim is enabled for the channel, reset the dim
123 * state so the collected statistics will be reset. This
124 * is useful for supporting legacy interfaces that allow
125 * things like changing the CQ period mode for all
126 * channels without disturbing individual channel
129 if (!chs->c[i]->sq[tc].dim)
132 mlx5e_dim_tx_change(&chs->c[i]->sq[tc], false);
133 err = mlx5e_dim_tx_change(&chs->c[i]->sq[tc], true);