Skip to content

Commit 8115b75

Browse files
CCX-Stingraydavem330
authored andcommitted
net/dim: use struct net_dim_sample as arg to net_dim
Simplify the arguments net_dim() by formatting them into a struct net_dim_sample before calling the function. Signed-off-by: Andy Gospodarek <[email protected]> Suggested-by: Tal Gilboa <[email protected]> Acked-by: Tal Gilboa <[email protected]> Acked-by: Saeed Mahameed <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4c4dbb4 commit 8115b75

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,14 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget)
7878
for (i = 0; i < c->num_tc; i++)
7979
mlx5e_cq_arm(&c->sq[i].cq);
8080

81-
if (MLX5E_TEST_BIT(c->rq.state, MLX5E_RQ_STATE_AM))
82-
net_dim(&c->rq.dim,
83-
c->rq.cq.event_ctr,
84-
c->rq.stats.packets,
85-
c->rq.stats.bytes);
81+
if (MLX5E_TEST_BIT(c->rq.state, MLX5E_RQ_STATE_AM)) {
82+
struct net_dim_sample dim_sample;
83+
net_dim_sample(c->rq.cq.event_ctr,
84+
c->rq.stats.packets,
85+
c->rq.stats.bytes,
86+
&dim_sample);
87+
net_dim(&c->rq.dim, dim_sample);
88+
}
8689

8790
mlx5e_cq_arm(&c->rq.cq);
8891
mlx5e_cq_arm(&c->icosq.cq);

include/linux/net_dim.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -342,21 +342,18 @@ static inline void net_dim_calc_stats(struct net_dim_sample *start,
342342
}
343343

344344
static inline void net_dim(struct net_dim *dim,
345-
u16 event_ctr,
346-
u64 packets,
347-
u64 bytes)
345+
struct net_dim_sample end_sample)
348346
{
349-
struct net_dim_sample end_sample;
350347
struct net_dim_stats curr_stats;
351348
u16 nevents;
352349

353350
switch (dim->state) {
354351
case NET_DIM_MEASURE_IN_PROGRESS:
355-
nevents = BIT_GAP(BITS_PER_TYPE(u16), event_ctr,
352+
nevents = BIT_GAP(BITS_PER_TYPE(u16),
353+
end_sample.event_ctr,
356354
dim->start_sample.event_ctr);
357355
if (nevents < NET_DIM_NEVENTS)
358356
break;
359-
net_dim_sample(event_ctr, packets, bytes, &end_sample);
360357
net_dim_calc_stats(&dim->start_sample, &end_sample,
361358
&curr_stats);
362359
if (net_dim_decision(&curr_stats, dim)) {
@@ -366,7 +363,6 @@ static inline void net_dim(struct net_dim *dim,
366363
}
367364
/* fall through */
368365
case NET_DIM_START_MEASURE:
369-
net_dim_sample(event_ctr, packets, bytes, &dim->start_sample);
370366
dim->state = NET_DIM_MEASURE_IN_PROGRESS;
371367
break;
372368
case NET_DIM_APPLY_NEW_PROFILE:

0 commit comments

Comments
 (0)