0001
0002
0003
0004 #ifndef __MLX5_EN_PARAMS_H__
0005 #define __MLX5_EN_PARAMS_H__
0006
0007 #include "en.h"
0008
0009 struct mlx5e_xsk_param {
0010 u16 headroom;
0011 u16 chunk_size;
0012 };
0013
0014 struct mlx5e_cq_param {
0015 u32 cqc[MLX5_ST_SZ_DW(cqc)];
0016 struct mlx5_wq_param wq;
0017 u16 eq_ix;
0018 u8 cq_period_mode;
0019 };
0020
0021 struct mlx5e_rq_param {
0022 struct mlx5e_cq_param cqp;
0023 u32 rqc[MLX5_ST_SZ_DW(rqc)];
0024 struct mlx5_wq_param wq;
0025 struct mlx5e_rq_frags_info frags_info;
0026 };
0027
0028 struct mlx5e_sq_param {
0029 struct mlx5e_cq_param cqp;
0030 u32 sqc[MLX5_ST_SZ_DW(sqc)];
0031 struct mlx5_wq_param wq;
0032 bool is_mpw;
0033 bool is_tls;
0034 bool is_xdp_mb;
0035 u16 stop_room;
0036 };
0037
0038 struct mlx5e_channel_param {
0039 struct mlx5e_rq_param rq;
0040 struct mlx5e_sq_param txq_sq;
0041 struct mlx5e_sq_param xdp_sq;
0042 struct mlx5e_sq_param icosq;
0043 struct mlx5e_sq_param async_icosq;
0044 };
0045
0046 struct mlx5e_create_sq_param {
0047 struct mlx5_wq_ctrl *wq_ctrl;
0048 u32 cqn;
0049 u32 ts_cqe_to_dest_cqn;
0050 u32 tisn;
0051 u8 tis_lst_sz;
0052 u8 min_inline_mode;
0053 };
0054
0055 static inline bool mlx5e_qid_get_ch_if_in_group(struct mlx5e_params *params,
0056 u16 qid,
0057 enum mlx5e_rq_group group,
0058 u16 *ix)
0059 {
0060 int nch = params->num_channels;
0061 int ch = qid - nch * group;
0062
0063 if (ch < 0 || ch >= nch)
0064 return false;
0065
0066 *ix = ch;
0067 return true;
0068 }
0069
0070 static inline void mlx5e_qid_get_ch_and_group(struct mlx5e_params *params,
0071 u16 qid,
0072 u16 *ix,
0073 enum mlx5e_rq_group *group)
0074 {
0075 u16 nch = params->num_channels;
0076
0077 *ix = qid % nch;
0078 *group = qid / nch;
0079 }
0080
0081 static inline bool mlx5e_qid_validate(const struct mlx5e_profile *profile,
0082 struct mlx5e_params *params, u64 qid)
0083 {
0084 return qid < params->num_channels * profile->rq_groups;
0085 }
0086
0087
0088
0089 void mlx5e_reset_tx_moderation(struct mlx5e_params *params, u8 cq_period_mode);
0090 void mlx5e_reset_rx_moderation(struct mlx5e_params *params, u8 cq_period_mode);
0091 void mlx5e_set_tx_cq_mode_params(struct mlx5e_params *params, u8 cq_period_mode);
0092 void mlx5e_set_rx_cq_mode_params(struct mlx5e_params *params, u8 cq_period_mode);
0093
0094 bool slow_pci_heuristic(struct mlx5_core_dev *mdev);
0095 bool mlx5e_striding_rq_possible(struct mlx5_core_dev *mdev, struct mlx5e_params *params);
0096 void mlx5e_build_rq_params(struct mlx5_core_dev *mdev, struct mlx5e_params *params);
0097 void mlx5e_set_rq_type(struct mlx5_core_dev *mdev, struct mlx5e_params *params);
0098 void mlx5e_init_rq_type_params(struct mlx5_core_dev *mdev, struct mlx5e_params *params);
0099
0100 bool mlx5e_verify_rx_mpwqe_strides(struct mlx5_core_dev *mdev,
0101 u8 log_stride_sz, u8 log_num_strides);
0102 u16 mlx5e_get_linear_rq_headroom(struct mlx5e_params *params,
0103 struct mlx5e_xsk_param *xsk);
0104 u32 mlx5e_rx_get_min_frag_sz(struct mlx5e_params *params,
0105 struct mlx5e_xsk_param *xsk);
0106 u8 mlx5e_mpwqe_log_pkts_per_wqe(struct mlx5e_params *params,
0107 struct mlx5e_xsk_param *xsk);
0108 bool mlx5e_rx_is_linear_skb(struct mlx5e_params *params,
0109 struct mlx5e_xsk_param *xsk);
0110 bool mlx5e_rx_mpwqe_is_linear_skb(struct mlx5_core_dev *mdev,
0111 struct mlx5e_params *params,
0112 struct mlx5e_xsk_param *xsk);
0113 u8 mlx5e_mpwqe_get_log_rq_size(struct mlx5e_params *params,
0114 struct mlx5e_xsk_param *xsk);
0115 u8 mlx5e_shampo_get_log_hd_entry_size(struct mlx5_core_dev *mdev,
0116 struct mlx5e_params *params);
0117 u8 mlx5e_shampo_get_log_rsrv_size(struct mlx5_core_dev *mdev,
0118 struct mlx5e_params *params);
0119 u8 mlx5e_shampo_get_log_pkt_per_rsrv(struct mlx5_core_dev *mdev,
0120 struct mlx5e_params *params);
0121 u32 mlx5e_shampo_hd_per_wqe(struct mlx5_core_dev *mdev,
0122 struct mlx5e_params *params,
0123 struct mlx5e_rq_param *rq_param);
0124 u32 mlx5e_shampo_hd_per_wq(struct mlx5_core_dev *mdev,
0125 struct mlx5e_params *params,
0126 struct mlx5e_rq_param *rq_param);
0127 u8 mlx5e_mpwqe_get_log_stride_size(struct mlx5_core_dev *mdev,
0128 struct mlx5e_params *params,
0129 struct mlx5e_xsk_param *xsk);
0130 u8 mlx5e_mpwqe_get_log_num_strides(struct mlx5_core_dev *mdev,
0131 struct mlx5e_params *params,
0132 struct mlx5e_xsk_param *xsk);
0133 u8 mlx5e_mpwqe_get_min_wqe_bulk(unsigned int wq_sz);
0134 u16 mlx5e_get_rq_headroom(struct mlx5_core_dev *mdev,
0135 struct mlx5e_params *params,
0136 struct mlx5e_xsk_param *xsk);
0137
0138
0139
0140 void mlx5e_build_create_cq_param(struct mlx5e_create_cq_param *ccp, struct mlx5e_channel *c);
0141 int mlx5e_build_rq_param(struct mlx5_core_dev *mdev,
0142 struct mlx5e_params *params,
0143 struct mlx5e_xsk_param *xsk,
0144 u16 q_counter,
0145 struct mlx5e_rq_param *param);
0146 void mlx5e_build_drop_rq_param(struct mlx5_core_dev *mdev,
0147 u16 q_counter,
0148 struct mlx5e_rq_param *param);
0149 void mlx5e_build_sq_param_common(struct mlx5_core_dev *mdev,
0150 struct mlx5e_sq_param *param);
0151 void mlx5e_build_sq_param(struct mlx5_core_dev *mdev,
0152 struct mlx5e_params *params,
0153 struct mlx5e_sq_param *param);
0154 void mlx5e_build_tx_cq_param(struct mlx5_core_dev *mdev,
0155 struct mlx5e_params *params,
0156 struct mlx5e_cq_param *param);
0157 void mlx5e_build_xdpsq_param(struct mlx5_core_dev *mdev,
0158 struct mlx5e_params *params,
0159 struct mlx5e_xsk_param *xsk,
0160 struct mlx5e_sq_param *param);
0161 int mlx5e_build_channel_param(struct mlx5_core_dev *mdev,
0162 struct mlx5e_params *params,
0163 u16 q_counter,
0164 struct mlx5e_channel_param *cparam);
0165
0166 u16 mlx5e_calc_sq_stop_room(struct mlx5_core_dev *mdev, struct mlx5e_params *params);
0167 int mlx5e_validate_params(struct mlx5_core_dev *mdev, struct mlx5e_params *params);
0168
0169 #endif