[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1509947098-10148-6-git-send-email-andy@greyhouse.net>
Date: Mon, 6 Nov 2017 00:44:51 -0500
From: Andy Gospodarek <andy@...yhouse.net>
To: netdev@...r.kernel.org
Cc: mchan@...adcom.com, saeedm@...lanox.com,
Andy Gospodarek <gospo@...adcom.com>
Subject: [RFC 3/9] mlx5_en: remove rq references in mlx5e_rx_am
From: Andy Gospodarek <gospo@...adcom.com>
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 <gospo@...adcom.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c | 22 +++++++++++++---------
drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.h | 5 ++++-
drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c | 5 ++++-
3 files changed, 21 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c
index acf32fe..845dbb8 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c
@@ -260,13 +260,15 @@ static bool mlx5e_am_decision(struct mlx5e_rx_am_stats *curr_stats,
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)
{
s->time = ktime_get();
- s->pkt_ctr = rq->stats.packets;
- s->byte_ctr = rq->stats.bytes;
- s->event_ctr = rq->cq.event_ctr;
+ s->pkt_ctr = packets;
+ s->byte_ctr = bytes;
+ s->event_ctr = event_ctr;
}
#define MLX5E_AM_NEVENTS 64
@@ -305,20 +307,22 @@ void mlx5e_rx_am_work(struct work_struct *work)
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_stats curr_stats;
u16 nevents;
switch (am->state) {
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);
if (nevents < MLX5E_AM_NEVENTS)
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,
&curr_stats);
if (mlx5e_am_decision(&curr_stats, am)) {
@@ -328,7 +332,7 @@ void mlx5e_rx_am(struct mlx5e_rq *rq)
}
/* fall through */
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;
break;
case MLX5E_AM_APPLY_NEW_PROFILE:
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.h b/drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.h
index 869e4e7..90e4913 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.h
@@ -71,7 +71,10 @@ enum {
MLX5_CQ_PERIOD_NUM_MODES
};
-void mlx5e_rx_am(struct mlx5e_rq *rq);
+void mlx5e_rx_am(struct mlx5e_rx_am *am,
+ u16 event_ctr,
+ u64 packets,
+ u64 bytes);
void mlx5e_rx_am_work(struct work_struct *work);
struct mlx5e_cq_moder mlx5e_am_get_def_profile(u8 rx_cq_period_mode);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c
index e906b75..8fed6c6 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c
@@ -77,7 +77,10 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget)
mlx5e_cq_arm(&c->sq[i].cq);
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->icosq.cq);
--
2.7.4
Powered by blists - more mailing lists