Skip to content

Commit 138968e

Browse files
CCX-Stingraydavem330
authored andcommitted
net/mlx5e: Remove rq references in mlx5e_rx_am
This makes mlx5e_am_sample more generic so that it can be called easily from a driver that does not use the same data structure to store these values in a single structure. 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 f58ee09 commit 138968e

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@ struct mlx5e_rx_am { /* Adaptive Moderation */
6666
u8 tired;
6767
};
6868

69-
struct mlx5e_rq;
70-
void mlx5e_rx_am(struct mlx5e_rq *rq);
69+
void mlx5e_rx_am(struct mlx5e_rx_am *am,
70+
u16 event_ctr,
71+
u64 packets,
72+
u64 bytes);
7173
void mlx5e_rx_am_work(struct work_struct *work);
7274
struct mlx5e_cq_moder mlx5e_am_get_def_profile(u8 rx_cq_period_mode);
7375

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -264,13 +264,15 @@ static bool mlx5e_am_decision(struct mlx5e_rx_am_stats *curr_stats,
264264
return am->profile_ix != prev_ix;
265265
}
266266

267-
static void mlx5e_am_sample(struct mlx5e_rq *rq,
267+
static void mlx5e_am_sample(u16 event_ctr,
268+
u64 packets,
269+
u64 bytes,
268270
struct mlx5e_rx_am_sample *s)
269271
{
270272
s->time = ktime_get();
271-
s->pkt_ctr = rq->stats.packets;
272-
s->byte_ctr = rq->stats.bytes;
273-
s->event_ctr = rq->cq.event_ctr;
273+
s->pkt_ctr = packets;
274+
s->byte_ctr = bytes;
275+
s->event_ctr = event_ctr;
274276
}
275277

276278
#define MLX5E_AM_NEVENTS 64
@@ -309,20 +311,22 @@ void mlx5e_rx_am_work(struct work_struct *work)
309311
am->state = MLX5E_AM_START_MEASURE;
310312
}
311313

312-
void mlx5e_rx_am(struct mlx5e_rq *rq)
314+
void mlx5e_rx_am(struct mlx5e_rx_am *am,
315+
u16 event_ctr,
316+
u64 packets,
317+
u64 bytes)
313318
{
314-
struct mlx5e_rx_am *am = &rq->am;
315319
struct mlx5e_rx_am_sample end_sample;
316320
struct mlx5e_rx_am_stats curr_stats;
317321
u16 nevents;
318322

319323
switch (am->state) {
320324
case MLX5E_AM_MEASURE_IN_PROGRESS:
321-
nevents = BIT_GAP(BITS_PER_TYPE(u16), rq->cq.event_ctr,
325+
nevents = BIT_GAP(BITS_PER_TYPE(u16), event_ctr,
322326
am->start_sample.event_ctr);
323327
if (nevents < MLX5E_AM_NEVENTS)
324328
break;
325-
mlx5e_am_sample(rq, &end_sample);
329+
mlx5e_am_sample(event_ctr, packets, bytes, &end_sample);
326330
mlx5e_am_calc_stats(&am->start_sample, &end_sample,
327331
&curr_stats);
328332
if (mlx5e_am_decision(&curr_stats, am)) {
@@ -332,7 +336,7 @@ void mlx5e_rx_am(struct mlx5e_rq *rq)
332336
}
333337
/* fall through */
334338
case MLX5E_AM_START_MEASURE:
335-
mlx5e_am_sample(rq, &am->start_sample);
339+
mlx5e_am_sample(event_ctr, packets, bytes, &am->start_sample);
336340
am->state = MLX5E_AM_MEASURE_IN_PROGRESS;
337341
break;
338342
case MLX5E_AM_APPLY_NEW_PROFILE:

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget)
7979
mlx5e_cq_arm(&c->sq[i].cq);
8080

8181
if (MLX5E_TEST_BIT(c->rq.state, MLX5E_RQ_STATE_AM))
82-
mlx5e_rx_am(&c->rq);
82+
mlx5e_rx_am(&c->rq.am,
83+
c->rq.cq.event_ctr,
84+
c->rq.stats.packets,
85+
c->rq.stats.bytes);
8386

8487
mlx5e_cq_arm(&c->rq.cq);
8588
mlx5e_cq_arm(&c->icosq.cq);

0 commit comments

Comments
 (0)