net/mlx5e: Fill mlx5e_create_cq_param in a function
authorMaxim Mikityanskiy <maximmi@mellanox.com>
Tue, 1 Dec 2020 22:42:08 +0000 (14:42 -0800)
committerSaeed Mahameed <saeedm@nvidia.com>
Tue, 8 Dec 2020 19:28:49 +0000 (11:28 -0800)
Create a function to fill the fields of struct mlx5e_create_cq_param
based on a channel. The purpose is code reuse between normal CQs, XSK
CQs and the upcoming QoS CQs.

Signed-off-by: Maxim Mikityanskiy <maximmi@mellanox.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/en/params.h
drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c
drivers/net/ethernet/mellanox/mlx5/core/en_main.c

index 3959254d4181677f153f041b06f933c9502692a4..807147d97a0fa48e8cc8c08121208dde5cadc6cf 100644 (file)
@@ -111,6 +111,7 @@ u16 mlx5e_get_rq_headroom(struct mlx5_core_dev *mdev,
 
 /* Build queue parameters */
 
+void mlx5e_build_create_cq_param(struct mlx5e_create_cq_param *ccp, struct mlx5e_channel *c);
 void mlx5e_build_rq_param(struct mlx5e_priv *priv,
                          struct mlx5e_params *params,
                          struct mlx5e_xsk_param *xsk,
index 7703e6553da6192f95f7a0a5316e9485b2a63fa3..d87c345878d3db9baeab2d19e027881851b200e1 100644 (file)
@@ -48,14 +48,11 @@ int mlx5e_open_xsk(struct mlx5e_priv *priv, struct mlx5e_params *params,
                   struct mlx5e_xsk_param *xsk, struct xsk_buff_pool *pool,
                   struct mlx5e_channel *c)
 {
-       struct mlx5e_create_cq_param ccp = {};
        struct mlx5e_channel_param *cparam;
+       struct mlx5e_create_cq_param ccp;
        int err;
 
-       ccp.napi = &c->napi;
-       ccp.ch_stats = c->stats;
-       ccp.node = cpu_to_node(c->cpu);
-       ccp.ix = c->ix;
+       mlx5e_build_create_cq_param(&ccp, c);
 
        if (!mlx5e_validate_xsk_param(params, xsk, priv->mdev))
                return -EINVAL;
index 2490d68cbd3242798fa22c29a1dab147e9186765..03831650f6558c7ebae31cd62f796a34aa2a84ab 100644 (file)
@@ -1806,18 +1806,25 @@ static int mlx5e_set_tx_maxrate(struct net_device *dev, int index, u32 rate)
        return err;
 }
 
+void mlx5e_build_create_cq_param(struct mlx5e_create_cq_param *ccp, struct mlx5e_channel *c)
+{
+       *ccp = (struct mlx5e_create_cq_param) {
+               .napi = &c->napi,
+               .ch_stats = c->stats,
+               .node = cpu_to_node(c->cpu),
+               .ix = c->ix,
+       };
+}
+
 static int mlx5e_open_queues(struct mlx5e_channel *c,
                             struct mlx5e_params *params,
                             struct mlx5e_channel_param *cparam)
 {
        struct dim_cq_moder icocq_moder = {0, 0};
-       struct mlx5e_create_cq_param ccp = {};
+       struct mlx5e_create_cq_param ccp;
        int err;
 
-       ccp.napi = &c->napi;
-       ccp.ch_stats = c->stats;
-       ccp.node = cpu_to_node(c->cpu);
-       ccp.ix = c->ix;
+       mlx5e_build_create_cq_param(&ccp, c);
 
        err = mlx5e_open_cq(c->priv, icocq_moder, &cparam->icosq.cqp, &ccp,
                            &c->async_icosq.cq);