params.h (5915B)
1/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ 2/* Copyright (c) 2019 Mellanox Technologies. */ 3 4#ifndef __MLX5_EN_PARAMS_H__ 5#define __MLX5_EN_PARAMS_H__ 6 7#include "en.h" 8 9struct mlx5e_xsk_param { 10 u16 headroom; 11 u16 chunk_size; 12}; 13 14struct mlx5e_cq_param { 15 u32 cqc[MLX5_ST_SZ_DW(cqc)]; 16 struct mlx5_wq_param wq; 17 u16 eq_ix; 18 u8 cq_period_mode; 19}; 20 21struct mlx5e_rq_param { 22 struct mlx5e_cq_param cqp; 23 u32 rqc[MLX5_ST_SZ_DW(rqc)]; 24 struct mlx5_wq_param wq; 25 struct mlx5e_rq_frags_info frags_info; 26}; 27 28struct mlx5e_sq_param { 29 struct mlx5e_cq_param cqp; 30 u32 sqc[MLX5_ST_SZ_DW(sqc)]; 31 struct mlx5_wq_param wq; 32 bool is_mpw; 33 bool is_tls; 34 bool is_xdp_mb; 35 u16 stop_room; 36}; 37 38struct mlx5e_channel_param { 39 struct mlx5e_rq_param rq; 40 struct mlx5e_sq_param txq_sq; 41 struct mlx5e_sq_param xdp_sq; 42 struct mlx5e_sq_param icosq; 43 struct mlx5e_sq_param async_icosq; 44}; 45 46struct mlx5e_create_sq_param { 47 struct mlx5_wq_ctrl *wq_ctrl; 48 u32 cqn; 49 u32 ts_cqe_to_dest_cqn; 50 u32 tisn; 51 u8 tis_lst_sz; 52 u8 min_inline_mode; 53}; 54 55static inline bool mlx5e_qid_get_ch_if_in_group(struct mlx5e_params *params, 56 u16 qid, 57 enum mlx5e_rq_group group, 58 u16 *ix) 59{ 60 int nch = params->num_channels; 61 int ch = qid - nch * group; 62 63 if (ch < 0 || ch >= nch) 64 return false; 65 66 *ix = ch; 67 return true; 68} 69 70static inline void mlx5e_qid_get_ch_and_group(struct mlx5e_params *params, 71 u16 qid, 72 u16 *ix, 73 enum mlx5e_rq_group *group) 74{ 75 u16 nch = params->num_channels; 76 77 *ix = qid % nch; 78 *group = qid / nch; 79} 80 81static inline bool mlx5e_qid_validate(const struct mlx5e_profile *profile, 82 struct mlx5e_params *params, u64 qid) 83{ 84 return qid < params->num_channels * profile->rq_groups; 85} 86 87/* Parameter calculations */ 88 89void mlx5e_reset_tx_moderation(struct mlx5e_params *params, u8 cq_period_mode); 90void mlx5e_reset_rx_moderation(struct mlx5e_params *params, u8 cq_period_mode); 91void mlx5e_set_tx_cq_mode_params(struct mlx5e_params *params, u8 cq_period_mode); 92void mlx5e_set_rx_cq_mode_params(struct mlx5e_params *params, u8 cq_period_mode); 93 94bool slow_pci_heuristic(struct mlx5_core_dev *mdev); 95bool mlx5e_striding_rq_possible(struct mlx5_core_dev *mdev, struct mlx5e_params *params); 96void mlx5e_build_rq_params(struct mlx5_core_dev *mdev, struct mlx5e_params *params); 97void mlx5e_set_rq_type(struct mlx5_core_dev *mdev, struct mlx5e_params *params); 98void mlx5e_init_rq_type_params(struct mlx5_core_dev *mdev, struct mlx5e_params *params); 99 100bool mlx5e_verify_rx_mpwqe_strides(struct mlx5_core_dev *mdev, 101 u8 log_stride_sz, u8 log_num_strides); 102u16 mlx5e_get_linear_rq_headroom(struct mlx5e_params *params, 103 struct mlx5e_xsk_param *xsk); 104u32 mlx5e_rx_get_min_frag_sz(struct mlx5e_params *params, 105 struct mlx5e_xsk_param *xsk); 106u8 mlx5e_mpwqe_log_pkts_per_wqe(struct mlx5e_params *params, 107 struct mlx5e_xsk_param *xsk); 108bool mlx5e_rx_is_linear_skb(struct mlx5e_params *params, 109 struct mlx5e_xsk_param *xsk); 110bool mlx5e_rx_mpwqe_is_linear_skb(struct mlx5_core_dev *mdev, 111 struct mlx5e_params *params, 112 struct mlx5e_xsk_param *xsk); 113u8 mlx5e_mpwqe_get_log_rq_size(struct mlx5e_params *params, 114 struct mlx5e_xsk_param *xsk); 115u8 mlx5e_shampo_get_log_hd_entry_size(struct mlx5_core_dev *mdev, 116 struct mlx5e_params *params); 117u8 mlx5e_shampo_get_log_rsrv_size(struct mlx5_core_dev *mdev, 118 struct mlx5e_params *params); 119u8 mlx5e_shampo_get_log_pkt_per_rsrv(struct mlx5_core_dev *mdev, 120 struct mlx5e_params *params); 121u32 mlx5e_shampo_hd_per_wqe(struct mlx5_core_dev *mdev, 122 struct mlx5e_params *params, 123 struct mlx5e_rq_param *rq_param); 124u32 mlx5e_shampo_hd_per_wq(struct mlx5_core_dev *mdev, 125 struct mlx5e_params *params, 126 struct mlx5e_rq_param *rq_param); 127u8 mlx5e_mpwqe_get_log_stride_size(struct mlx5_core_dev *mdev, 128 struct mlx5e_params *params, 129 struct mlx5e_xsk_param *xsk); 130u8 mlx5e_mpwqe_get_log_num_strides(struct mlx5_core_dev *mdev, 131 struct mlx5e_params *params, 132 struct mlx5e_xsk_param *xsk); 133u8 mlx5e_mpwqe_get_min_wqe_bulk(unsigned int wq_sz); 134u16 mlx5e_get_rq_headroom(struct mlx5_core_dev *mdev, 135 struct mlx5e_params *params, 136 struct mlx5e_xsk_param *xsk); 137 138/* Build queue parameters */ 139 140void mlx5e_build_create_cq_param(struct mlx5e_create_cq_param *ccp, struct mlx5e_channel *c); 141int mlx5e_build_rq_param(struct mlx5_core_dev *mdev, 142 struct mlx5e_params *params, 143 struct mlx5e_xsk_param *xsk, 144 u16 q_counter, 145 struct mlx5e_rq_param *param); 146void mlx5e_build_drop_rq_param(struct mlx5_core_dev *mdev, 147 u16 q_counter, 148 struct mlx5e_rq_param *param); 149void mlx5e_build_sq_param_common(struct mlx5_core_dev *mdev, 150 struct mlx5e_sq_param *param); 151void mlx5e_build_sq_param(struct mlx5_core_dev *mdev, 152 struct mlx5e_params *params, 153 struct mlx5e_sq_param *param); 154void mlx5e_build_tx_cq_param(struct mlx5_core_dev *mdev, 155 struct mlx5e_params *params, 156 struct mlx5e_cq_param *param); 157void mlx5e_build_xdpsq_param(struct mlx5_core_dev *mdev, 158 struct mlx5e_params *params, 159 struct mlx5e_xsk_param *xsk, 160 struct mlx5e_sq_param *param); 161int mlx5e_build_channel_param(struct mlx5_core_dev *mdev, 162 struct mlx5e_params *params, 163 u16 q_counter, 164 struct mlx5e_channel_param *cparam); 165 166u16 mlx5e_calc_sq_stop_room(struct mlx5_core_dev *mdev, struct mlx5e_params *params); 167int mlx5e_validate_params(struct mlx5_core_dev *mdev, struct mlx5e_params *params); 168 169#endif /* __MLX5_EN_PARAMS_H__ */