1 // SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
2 /* Copyright (c) 2021, Mellanox Technologies inc. All rights reserved. */
3
4 #include "channels.h"
5 #include "en.h"
6 #include "en/ptp.h"
7
mlx5e_channels_get_num(struct mlx5e_channels * chs)8 unsigned int mlx5e_channels_get_num(struct mlx5e_channels *chs)
9 {
10 return chs->num;
11 }
12
mlx5e_channels_get_regular_rqn(struct mlx5e_channels * chs,unsigned int ix,u32 * rqn)13 void mlx5e_channels_get_regular_rqn(struct mlx5e_channels *chs, unsigned int ix, u32 *rqn)
14 {
15 struct mlx5e_channel *c;
16
17 WARN_ON(ix >= mlx5e_channels_get_num(chs));
18 c = chs->c[ix];
19
20 *rqn = c->rq.rqn;
21 }
22
mlx5e_channels_get_xsk_rqn(struct mlx5e_channels * chs,unsigned int ix,u32 * rqn)23 bool mlx5e_channels_get_xsk_rqn(struct mlx5e_channels *chs, unsigned int ix, u32 *rqn)
24 {
25 struct mlx5e_channel *c;
26
27 WARN_ON(ix >= mlx5e_channels_get_num(chs));
28 c = chs->c[ix];
29
30 if (!test_bit(MLX5E_CHANNEL_STATE_XSK, c->state))
31 return false;
32
33 *rqn = c->xskrq.rqn;
34 return true;
35 }
36
mlx5e_channels_get_ptp_rqn(struct mlx5e_channels * chs,u32 * rqn)37 bool mlx5e_channels_get_ptp_rqn(struct mlx5e_channels *chs, u32 *rqn)
38 {
39 struct mlx5e_ptp *c = chs->ptp;
40
41 if (!c || !test_bit(MLX5E_PTP_STATE_RX, c->state))
42 return false;
43
44 *rqn = c->rq.rqn;
45 return true;
46 }
47