Commit 138968e9 authored by Andy Gospodarek's avatar Andy Gospodarek Committed by David S. Miller

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: default avatarAndy Gospodarek <gospo@broadcom.com>
Acked-by: default avatarTal Gilboa <talgi@mellanox.com>
Acked-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f58ee099
...@@ -66,8 +66,10 @@ struct mlx5e_rx_am { /* Adaptive Moderation */ ...@@ -66,8 +66,10 @@ struct mlx5e_rx_am { /* Adaptive Moderation */
u8 tired; u8 tired;
}; };
struct mlx5e_rq; void mlx5e_rx_am(struct mlx5e_rx_am *am,
void mlx5e_rx_am(struct mlx5e_rq *rq); u16 event_ctr,
u64 packets,
u64 bytes);
void mlx5e_rx_am_work(struct work_struct *work); void mlx5e_rx_am_work(struct work_struct *work);
struct mlx5e_cq_moder mlx5e_am_get_def_profile(u8 rx_cq_period_mode); struct mlx5e_cq_moder mlx5e_am_get_def_profile(u8 rx_cq_period_mode);
......
...@@ -264,13 +264,15 @@ static bool mlx5e_am_decision(struct mlx5e_rx_am_stats *curr_stats, ...@@ -264,13 +264,15 @@ static bool mlx5e_am_decision(struct mlx5e_rx_am_stats *curr_stats,
return am->profile_ix != prev_ix; return am->profile_ix != prev_ix;
} }
static void mlx5e_am_sample(struct mlx5e_rq *rq, static void mlx5e_am_sample(u16 event_ctr,
u64 packets,
u64 bytes,
struct mlx5e_rx_am_sample *s) struct mlx5e_rx_am_sample *s)
{ {
s->time = ktime_get(); s->time = ktime_get();
s->pkt_ctr = rq->stats.packets; s->pkt_ctr = packets;
s->byte_ctr = rq->stats.bytes; s->byte_ctr = bytes;
s->event_ctr = rq->cq.event_ctr; s->event_ctr = event_ctr;
} }
#define MLX5E_AM_NEVENTS 64 #define MLX5E_AM_NEVENTS 64
...@@ -309,20 +311,22 @@ void mlx5e_rx_am_work(struct work_struct *work) ...@@ -309,20 +311,22 @@ void mlx5e_rx_am_work(struct work_struct *work)
am->state = MLX5E_AM_START_MEASURE; am->state = MLX5E_AM_START_MEASURE;
} }
void mlx5e_rx_am(struct mlx5e_rq *rq) void mlx5e_rx_am(struct mlx5e_rx_am *am,
u16 event_ctr,
u64 packets,
u64 bytes)
{ {
struct mlx5e_rx_am *am = &rq->am;
struct mlx5e_rx_am_sample end_sample; struct mlx5e_rx_am_sample end_sample;
struct mlx5e_rx_am_stats curr_stats; struct mlx5e_rx_am_stats curr_stats;
u16 nevents; u16 nevents;
switch (am->state) { switch (am->state) {
case MLX5E_AM_MEASURE_IN_PROGRESS: case MLX5E_AM_MEASURE_IN_PROGRESS:
nevents = BIT_GAP(BITS_PER_TYPE(u16), rq->cq.event_ctr, nevents = BIT_GAP(BITS_PER_TYPE(u16), event_ctr,
am->start_sample.event_ctr); am->start_sample.event_ctr);
if (nevents < MLX5E_AM_NEVENTS) if (nevents < MLX5E_AM_NEVENTS)
break; break;
mlx5e_am_sample(rq, &end_sample); mlx5e_am_sample(event_ctr, packets, bytes, &end_sample);
mlx5e_am_calc_stats(&am->start_sample, &end_sample, mlx5e_am_calc_stats(&am->start_sample, &end_sample,
&curr_stats); &curr_stats);
if (mlx5e_am_decision(&curr_stats, am)) { if (mlx5e_am_decision(&curr_stats, am)) {
...@@ -332,7 +336,7 @@ void mlx5e_rx_am(struct mlx5e_rq *rq) ...@@ -332,7 +336,7 @@ void mlx5e_rx_am(struct mlx5e_rq *rq)
} }
/* fall through */ /* fall through */
case MLX5E_AM_START_MEASURE: case MLX5E_AM_START_MEASURE:
mlx5e_am_sample(rq, &am->start_sample); mlx5e_am_sample(event_ctr, packets, bytes, &am->start_sample);
am->state = MLX5E_AM_MEASURE_IN_PROGRESS; am->state = MLX5E_AM_MEASURE_IN_PROGRESS;
break; break;
case MLX5E_AM_APPLY_NEW_PROFILE: case MLX5E_AM_APPLY_NEW_PROFILE:
......
...@@ -79,7 +79,10 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget) ...@@ -79,7 +79,10 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget)
mlx5e_cq_arm(&c->sq[i].cq); mlx5e_cq_arm(&c->sq[i].cq);
if (MLX5E_TEST_BIT(c->rq.state, MLX5E_RQ_STATE_AM)) if (MLX5E_TEST_BIT(c->rq.state, MLX5E_RQ_STATE_AM))
mlx5e_rx_am(&c->rq); mlx5e_rx_am(&c->rq.am,
c->rq.cq.event_ctr,
c->rq.stats.packets,
c->rq.stats.bytes);
mlx5e_cq_arm(&c->rq.cq); mlx5e_cq_arm(&c->rq.cq);
mlx5e_cq_arm(&c->icosq.cq); mlx5e_cq_arm(&c->icosq.cq);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment