Skip to content

Commit b9c872f

Browse files
CCX-Stingraydavem330
authored andcommitted
net/mlx5e: Move generic functions to new file
These functions were identified as ones that could be made generic and used by multiple drivers. Most of the contents of en_rx_am.c are moved to net_dim.c. Signed-off-by: Andy Gospodarek <[email protected]> Acked-by: Tal Gilboa <[email protected]> Acked-by: Saeed Mahameed <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f5e7f67 commit b9c872f

File tree

5 files changed

+55
-20
lines changed

5 files changed

+55
-20
lines changed

drivers/net/ethernet/mellanox/mlx5/core/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ mlx5_core-$(CONFIG_MLX5_FPGA) += fpga/cmd.o fpga/core.o fpga/conn.o fpga/sdk.o \
1414
fpga/ipsec.o
1515

1616
mlx5_core-$(CONFIG_MLX5_CORE_EN) += en_main.o en_common.o en_fs.o en_ethtool.o \
17-
en_tx.o en_rx.o en_rx_am.o en_txrx.o en_stats.o vxlan.o \
18-
en_arfs.o en_fs_ethtool.o en_selftest.o
17+
en_tx.o en_rx.o en_dim.o en_txrx.o en_stats.o vxlan.o \
18+
en_arfs.o en_fs_ethtool.o en_selftest.o net_dim.o
1919

2020
mlx5_core-$(CONFIG_MLX5_MPFS) += lib/mpfs.o
2121

drivers/net/ethernet/mellanox/mlx5/core/en.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
#include "wq.h"
5151
#include "mlx5_core.h"
5252
#include "en_stats.h"
53-
#include "en_dim.h"
53+
#include "net_dim.h"
5454

5555
#define MLX5_SET_CFG(p, f, v) MLX5_SET(create_flow_group_in, p, f, v)
5656

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright (c) 2016, Mellanox Technologies. All rights reserved.
3+
*
4+
* This software is available to you under a choice of one of two
5+
* licenses. You may choose to be licensed under the terms of the GNU
6+
* General Public License (GPL) Version 2, available from the file
7+
* COPYING in the main directory of this source tree, or the
8+
* OpenIB.org BSD license below:
9+
*
10+
* Redistribution and use in source and binary forms, with or
11+
* without modification, are permitted provided that the following
12+
* conditions are met:
13+
*
14+
* - Redistributions of source code must retain the above
15+
* copyright notice, this list of conditions and the following
16+
* disclaimer.
17+
*
18+
* - Redistributions in binary form must reproduce the above
19+
* copyright notice, this list of conditions and the following
20+
* disclaimer in the documentation and/or other materials
21+
* provided with the distribution.
22+
*
23+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27+
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28+
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30+
* SOFTWARE.
31+
*/
32+
33+
#include "en.h"
34+
35+
void mlx5e_rx_am_work(struct work_struct *work)
36+
{
37+
struct mlx5e_rx_am *am = container_of(work, struct mlx5e_rx_am,
38+
work);
39+
struct mlx5e_rq *rq = container_of(am, struct mlx5e_rq, am);
40+
struct mlx5e_cq_moder cur_profile = mlx5e_am_get_profile(am->mode,
41+
am->profile_ix);
42+
43+
mlx5_core_modify_cq_moderation(rq->mdev, &rq->cq.mcq,
44+
cur_profile.usec, cur_profile.pkts);
45+
46+
am->state = MLX5E_AM_START_MEASURE;
47+
}

drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c renamed to drivers/net/ethernet/mellanox/mlx5/core/net_dim.c

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright (c) 2016, Mellanox Technologies. All rights reserved.
3+
* Copyright (c) 2017-2018, Broadcom Limited. All rights reserved.
34
*
45
* This software is available to you under a choice of one of two
56
* licenses. You may choose to be licensed under the terms of the GNU
@@ -32,11 +33,11 @@
3233

3334
#include "en.h"
3435

36+
#define MLX5E_PARAMS_AM_NUM_PROFILES 5
3537
/* Adaptive moderation profiles */
3638
#define MLX5E_AM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE 256
3739
#define MLX5E_RX_AM_DEF_PROFILE_CQE 1
3840
#define MLX5E_RX_AM_DEF_PROFILE_EQE 1
39-
#define MLX5E_PARAMS_AM_NUM_PROFILES 5
4041

4142
/* All profiles sizes must be MLX5E_PARAMS_AM_NUM_PROFILES */
4243
#define MLX5_AM_EQE_PROFILES { \
@@ -61,7 +62,7 @@ profile[MLX5_CQ_PERIOD_NUM_MODES][MLX5E_PARAMS_AM_NUM_PROFILES] = {
6162
MLX5_AM_CQE_PROFILES,
6263
};
6364

64-
static inline struct mlx5e_cq_moder mlx5e_am_get_profile(u8 cq_period_mode, int ix)
65+
struct mlx5e_cq_moder mlx5e_am_get_profile(u8 cq_period_mode, int ix)
6566
{
6667
struct mlx5e_cq_moder cq_moder;
6768

@@ -82,7 +83,6 @@ struct mlx5e_cq_moder mlx5e_am_get_def_profile(u8 rx_cq_period_mode)
8283
return mlx5e_am_get_profile(rx_cq_period_mode, default_profile_ix);
8384
}
8485

85-
8686
static bool mlx5e_am_on_top(struct mlx5e_rx_am *am)
8787
{
8888
switch (am->tune_state) {
@@ -273,19 +273,6 @@ static void mlx5e_am_calc_stats(struct mlx5e_rx_am_sample *start,
273273
delta_us);
274274
}
275275

276-
void mlx5e_rx_am_work(struct work_struct *work)
277-
{
278-
struct mlx5e_rx_am *am = container_of(work, struct mlx5e_rx_am,
279-
work);
280-
struct mlx5e_rq *rq = container_of(am, struct mlx5e_rq, am);
281-
struct mlx5e_cq_moder cur_profile = profile[am->mode][am->profile_ix];
282-
283-
mlx5_core_modify_cq_moderation(rq->mdev, &rq->cq.mcq,
284-
cur_profile.usec, cur_profile.pkts);
285-
286-
am->state = MLX5E_AM_START_MEASURE;
287-
}
288-
289276
void mlx5e_rx_am(struct mlx5e_rx_am *am,
290277
u16 event_ctr,
291278
u64 packets,

drivers/net/ethernet/mellanox/mlx5/core/en_dim.h renamed to drivers/net/ethernet/mellanox/mlx5/core/net_dim.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2013-2015, Mellanox Technologies, Ltd. All rights reserved.
3-
* Copyright (c) 2017-2018, Broadcom Limited
3+
* Copyright (c) 2017-2018, Broadcom Limited. All rights reserved.
44
*
55
* This software is available to you under a choice of one of two
66
* licenses. You may choose to be licensed under the terms of the GNU
@@ -98,5 +98,6 @@ void mlx5e_rx_am(struct mlx5e_rx_am *am,
9898
u64 bytes);
9999
void mlx5e_rx_am_work(struct work_struct *work);
100100
struct mlx5e_cq_moder mlx5e_am_get_def_profile(u8 rx_cq_period_mode);
101+
struct mlx5e_cq_moder mlx5e_am_get_profile(u8 cq_period_mode, int ix);
101102

102103
#endif /* MLX5_AM_H */

0 commit comments

Comments
 (0)