Skip to content

Commit 472e12e

Browse files
committed
Merge branch 'dpaa2-eth-Add-new-statistics-counters'
Ioana Radulescu says: ==================== dpaa2-eth: Add new statistics counters Recent firmware versions offer access to more DPNI statistics counters. Add the relevant ones to ethtool interface stats. Also we can now make use of a new counter for in flight egress frames to avoid sleeping an arbitrary amount of time in the ndo_stop routine. v2: in patch 2/3, treat separately the error case for unsupported statistics pages ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 2c1f9e2 + 52b6a4f commit 472e12e

File tree

4 files changed

+93
-17
lines changed

4 files changed

+93
-17
lines changed

drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,7 +1348,7 @@ static u32 ingress_fq_count(struct dpaa2_eth_priv *priv)
13481348
return total;
13491349
}
13501350

1351-
static void wait_for_fq_empty(struct dpaa2_eth_priv *priv)
1351+
static void wait_for_ingress_fq_empty(struct dpaa2_eth_priv *priv)
13521352
{
13531353
int retries = 10;
13541354
u32 pending;
@@ -1360,6 +1360,31 @@ static void wait_for_fq_empty(struct dpaa2_eth_priv *priv)
13601360
} while (pending && --retries);
13611361
}
13621362

1363+
#define DPNI_TX_PENDING_VER_MAJOR 7
1364+
#define DPNI_TX_PENDING_VER_MINOR 13
1365+
static void wait_for_egress_fq_empty(struct dpaa2_eth_priv *priv)
1366+
{
1367+
union dpni_statistics stats;
1368+
int retries = 10;
1369+
int err;
1370+
1371+
if (dpaa2_eth_cmp_dpni_ver(priv, DPNI_TX_PENDING_VER_MAJOR,
1372+
DPNI_TX_PENDING_VER_MINOR) < 0)
1373+
goto out;
1374+
1375+
do {
1376+
err = dpni_get_statistics(priv->mc_io, 0, priv->mc_token, 6,
1377+
&stats);
1378+
if (err)
1379+
goto out;
1380+
if (stats.page_6.tx_pending_frames == 0)
1381+
return;
1382+
} while (--retries);
1383+
1384+
out:
1385+
msleep(500);
1386+
}
1387+
13631388
static int dpaa2_eth_stop(struct net_device *net_dev)
13641389
{
13651390
struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
@@ -1379,7 +1404,7 @@ static int dpaa2_eth_stop(struct net_device *net_dev)
13791404
* on WRIOP. After it finishes, wait until all remaining frames on Rx
13801405
* and Tx conf queues are consumed on NAPI poll.
13811406
*/
1382-
msleep(500);
1407+
wait_for_egress_fq_empty(priv);
13831408

13841409
do {
13851410
dpni_disable(priv->mc_io, 0, priv->mc_token);
@@ -1395,7 +1420,7 @@ static int dpaa2_eth_stop(struct net_device *net_dev)
13951420
*/
13961421
}
13971422

1398-
wait_for_fq_empty(priv);
1423+
wait_for_ingress_fq_empty(priv);
13991424
disable_ch_napi(priv);
14001425

14011426
/* Empty the buffer pool */

drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ static char dpaa2_ethtool_stats[][ETH_GSTRING_LEN] = {
2828
"[hw] rx nobuffer discards",
2929
"[hw] tx discarded frames",
3030
"[hw] tx confirmed frames",
31+
"[hw] tx dequeued bytes",
32+
"[hw] tx dequeued frames",
33+
"[hw] tx rejected bytes",
34+
"[hw] tx rejected frames",
35+
"[hw] tx pending frames",
3136
};
3237

3338
#define DPAA2_ETH_NUM_STATS ARRAY_SIZE(dpaa2_ethtool_stats)
@@ -188,27 +193,33 @@ static void dpaa2_eth_get_ethtool_stats(struct net_device *net_dev,
188193
struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
189194
struct dpaa2_eth_drv_stats *extras;
190195
struct dpaa2_eth_ch_stats *ch_stats;
196+
int dpni_stats_page_size[DPNI_STATISTICS_CNT] = {
197+
sizeof(dpni_stats.page_0),
198+
sizeof(dpni_stats.page_1),
199+
sizeof(dpni_stats.page_2),
200+
sizeof(dpni_stats.page_3),
201+
sizeof(dpni_stats.page_4),
202+
sizeof(dpni_stats.page_5),
203+
sizeof(dpni_stats.page_6),
204+
};
191205

192206
memset(data, 0,
193207
sizeof(u64) * (DPAA2_ETH_NUM_STATS + DPAA2_ETH_NUM_EXTRA_STATS));
194208

195209
/* Print standard counters, from DPNI statistics */
196-
for (j = 0; j <= 2; j++) {
210+
for (j = 0; j <= 6; j++) {
211+
/* We're not interested in pages 4 & 5 for now */
212+
if (j == 4 || j == 5)
213+
continue;
197214
err = dpni_get_statistics(priv->mc_io, 0, priv->mc_token,
198215
j, &dpni_stats);
199-
if (err != 0)
216+
if (err == -EINVAL)
217+
/* Older firmware versions don't support all pages */
218+
memset(&dpni_stats, 0, sizeof(dpni_stats));
219+
else
200220
netdev_warn(net_dev, "dpni_get_stats(%d) failed\n", j);
201-
switch (j) {
202-
case 0:
203-
num_cnt = sizeof(dpni_stats.page_0) / sizeof(u64);
204-
break;
205-
case 1:
206-
num_cnt = sizeof(dpni_stats.page_1) / sizeof(u64);
207-
break;
208-
case 2:
209-
num_cnt = sizeof(dpni_stats.page_2) / sizeof(u64);
210-
break;
211-
}
221+
222+
num_cnt = dpni_stats_page_size[j] / sizeof(u64);
212223
for (k = 0; k < num_cnt; k++)
213224
*(data + i++) = dpni_stats.raw.counter[k];
214225
}

drivers/net/ethernet/freescale/dpaa2/dpni.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1470,7 +1470,7 @@ int dpni_get_queue(struct fsl_mc_io *mc_io,
14701470
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
14711471
* @token: Token of DPNI object
14721472
* @page: Selects the statistics page to retrieve, see
1473-
* DPNI_GET_STATISTICS output. Pages are numbered 0 to 2.
1473+
* DPNI_GET_STATISTICS output. Pages are numbered 0 to 6.
14741474
* @stat: Structure containing the statistics
14751475
*
14761476
* Return: '0' on Success; Error code otherwise.

drivers/net/ethernet/freescale/dpaa2/dpni.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,26 @@ int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io,
416416
* lack of buffers
417417
* @page_2.egress_discarded_frames: Egress discarded frame count
418418
* @page_2.egress_confirmed_frames: Egress confirmed frame count
419+
* @page3: Page_3 statistics structure
420+
* @page_3.egress_dequeue_bytes: Cumulative count of the number of bytes
421+
* dequeued from egress FQs
422+
* @page_3.egress_dequeue_frames: Cumulative count of the number of frames
423+
* dequeued from egress FQs
424+
* @page_3.egress_reject_bytes: Cumulative count of the number of bytes in
425+
* egress frames whose enqueue was rejected
426+
* @page_3.egress_reject_frames: Cumulative count of the number of egress
427+
* frames whose enqueue was rejected
428+
* @page_4: Page_4 statistics structure: congestion points
429+
* @page_4.cgr_reject_frames: number of rejected frames due to congestion point
430+
* @page_4.cgr_reject_bytes: number of rejected bytes due to congestion point
431+
* @page_5: Page_5 statistics structure: policer
432+
* @page_5.policer_cnt_red: NUmber of red colored frames
433+
* @page_5.policer_cnt_yellow: number of yellow colored frames
434+
* @page_5.policer_cnt_green: number of green colored frames
435+
* @page_5.policer_cnt_re_red: number of recolored red frames
436+
* @page_5.policer_cnt_re_yellow: number of recolored yellow frames
437+
* @page_6: Page_6 statistics structure
438+
* @page_6.tx_pending_frames: total number of frames pending in egress FQs
419439
* @raw: raw statistics structure, used to index counters
420440
*/
421441
union dpni_statistics {
@@ -442,6 +462,26 @@ union dpni_statistics {
442462
u64 egress_discarded_frames;
443463
u64 egress_confirmed_frames;
444464
} page_2;
465+
struct {
466+
u64 egress_dequeue_bytes;
467+
u64 egress_dequeue_frames;
468+
u64 egress_reject_bytes;
469+
u64 egress_reject_frames;
470+
} page_3;
471+
struct {
472+
u64 cgr_reject_frames;
473+
u64 cgr_reject_bytes;
474+
} page_4;
475+
struct {
476+
u64 policer_cnt_red;
477+
u64 policer_cnt_yellow;
478+
u64 policer_cnt_green;
479+
u64 policer_cnt_re_red;
480+
u64 policer_cnt_re_yellow;
481+
} page_5;
482+
struct {
483+
u64 tx_pending_frames;
484+
} page_6;
445485
struct {
446486
u64 counter[DPNI_STATISTICS_CNT];
447487
} raw;

0 commit comments

Comments
 (0)