linux/drivers/net/ethernet/mellanox/mlx5/core/en/params.h
<<
>>
Prefs
   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_rq_param {
  15        u32                        rqc[MLX5_ST_SZ_DW(rqc)];
  16        struct mlx5_wq_param       wq;
  17        struct mlx5e_rq_frags_info frags_info;
  18};
  19
  20struct mlx5e_sq_param {
  21        u32                        sqc[MLX5_ST_SZ_DW(sqc)];
  22        struct mlx5_wq_param       wq;
  23        bool                       is_mpw;
  24};
  25
  26struct mlx5e_cq_param {
  27        u32                        cqc[MLX5_ST_SZ_DW(cqc)];
  28        struct mlx5_wq_param       wq;
  29        u16                        eq_ix;
  30        u8                         cq_period_mode;
  31};
  32
  33struct mlx5e_channel_param {
  34        struct mlx5e_rq_param      rq;
  35        struct mlx5e_sq_param      sq;
  36        struct mlx5e_sq_param      xdp_sq;
  37        struct mlx5e_sq_param      icosq;
  38        struct mlx5e_cq_param      rx_cq;
  39        struct mlx5e_cq_param      tx_cq;
  40        struct mlx5e_cq_param      icosq_cq;
  41};
  42
  43static inline bool mlx5e_qid_get_ch_if_in_group(struct mlx5e_params *params,
  44                                                u16 qid,
  45                                                enum mlx5e_rq_group group,
  46                                                u16 *ix)
  47{
  48        int nch = params->num_channels;
  49        int ch = qid - nch * group;
  50
  51        if (ch < 0 || ch >= nch)
  52                return false;
  53
  54        *ix = ch;
  55        return true;
  56}
  57
  58static inline void mlx5e_qid_get_ch_and_group(struct mlx5e_params *params,
  59                                              u16 qid,
  60                                              u16 *ix,
  61                                              enum mlx5e_rq_group *group)
  62{
  63        u16 nch = params->num_channels;
  64
  65        *ix = qid % nch;
  66        *group = qid / nch;
  67}
  68
  69static inline bool mlx5e_qid_validate(const struct mlx5e_profile *profile,
  70                                      struct mlx5e_params *params, u64 qid)
  71{
  72        return qid < params->num_channels * profile->rq_groups;
  73}
  74
  75/* Parameter calculations */
  76
  77u16 mlx5e_get_linear_rq_headroom(struct mlx5e_params *params,
  78                                 struct mlx5e_xsk_param *xsk);
  79u32 mlx5e_rx_get_linear_frag_sz(struct mlx5e_params *params,
  80                                struct mlx5e_xsk_param *xsk);
  81u8 mlx5e_mpwqe_log_pkts_per_wqe(struct mlx5e_params *params,
  82                                struct mlx5e_xsk_param *xsk);
  83bool mlx5e_rx_is_linear_skb(struct mlx5e_params *params,
  84                            struct mlx5e_xsk_param *xsk);
  85bool mlx5e_rx_mpwqe_is_linear_skb(struct mlx5_core_dev *mdev,
  86                                  struct mlx5e_params *params,
  87                                  struct mlx5e_xsk_param *xsk);
  88u8 mlx5e_mpwqe_get_log_rq_size(struct mlx5e_params *params,
  89                               struct mlx5e_xsk_param *xsk);
  90u8 mlx5e_mpwqe_get_log_stride_size(struct mlx5_core_dev *mdev,
  91                                   struct mlx5e_params *params,
  92                                   struct mlx5e_xsk_param *xsk);
  93u8 mlx5e_mpwqe_get_log_num_strides(struct mlx5_core_dev *mdev,
  94                                   struct mlx5e_params *params,
  95                                   struct mlx5e_xsk_param *xsk);
  96u16 mlx5e_get_rq_headroom(struct mlx5_core_dev *mdev,
  97                          struct mlx5e_params *params,
  98                          struct mlx5e_xsk_param *xsk);
  99
 100/* Build queue parameters */
 101
 102void mlx5e_build_rq_param(struct mlx5e_priv *priv,
 103                          struct mlx5e_params *params,
 104                          struct mlx5e_xsk_param *xsk,
 105                          struct mlx5e_rq_param *param);
 106void mlx5e_build_sq_param_common(struct mlx5e_priv *priv,
 107                                 struct mlx5e_sq_param *param);
 108void mlx5e_build_rx_cq_param(struct mlx5e_priv *priv,
 109                             struct mlx5e_params *params,
 110                             struct mlx5e_xsk_param *xsk,
 111                             struct mlx5e_cq_param *param);
 112void mlx5e_build_tx_cq_param(struct mlx5e_priv *priv,
 113                             struct mlx5e_params *params,
 114                             struct mlx5e_cq_param *param);
 115void mlx5e_build_ico_cq_param(struct mlx5e_priv *priv,
 116                              u8 log_wq_size,
 117                              struct mlx5e_cq_param *param);
 118void mlx5e_build_icosq_param(struct mlx5e_priv *priv,
 119                             u8 log_wq_size,
 120                             struct mlx5e_sq_param *param);
 121void mlx5e_build_xdpsq_param(struct mlx5e_priv *priv,
 122                             struct mlx5e_params *params,
 123                             struct mlx5e_sq_param *param);
 124
 125#endif /* __MLX5_EN_PARAMS_H__ */
 126