Commit bb709987 authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'count-tc-taprio-window-drops-in-enetc-driver'

Vladimir Oltean says:

====================
Count tc-taprio window drops in enetc driver

This series includes a patch from Po Liu (no longer with NXP) which
counts frames dropped by the tc-taprio offload in ethtool -S and in
ndo_get_stats64. It also contains a preparation patch from myself.
====================

Link: https://lore.kernel.org/r/20220510163615.6096-1-vladimir.oltean@nxp.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents d7722973 285e8ded
...@@ -172,7 +172,8 @@ static int enetc_map_tx_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb) ...@@ -172,7 +172,8 @@ static int enetc_map_tx_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb)
} }
tx_swbd->do_twostep_tstamp = do_twostep_tstamp; tx_swbd->do_twostep_tstamp = do_twostep_tstamp;
tx_swbd->check_wb = tx_swbd->do_twostep_tstamp; tx_swbd->qbv_en = !!(priv->active_offloads & ENETC_F_QBV);
tx_swbd->check_wb = tx_swbd->do_twostep_tstamp || tx_swbd->qbv_en;
if (do_vlan || do_onestep_tstamp || do_twostep_tstamp) if (do_vlan || do_onestep_tstamp || do_twostep_tstamp)
flags |= ENETC_TXBD_FLAGS_EX; flags |= ENETC_TXBD_FLAGS_EX;
...@@ -792,9 +793,9 @@ static void enetc_recycle_xdp_tx_buff(struct enetc_bdr *tx_ring, ...@@ -792,9 +793,9 @@ static void enetc_recycle_xdp_tx_buff(struct enetc_bdr *tx_ring,
static bool enetc_clean_tx_ring(struct enetc_bdr *tx_ring, int napi_budget) static bool enetc_clean_tx_ring(struct enetc_bdr *tx_ring, int napi_budget)
{ {
int tx_frm_cnt = 0, tx_byte_cnt = 0, tx_win_drop = 0;
struct net_device *ndev = tx_ring->ndev; struct net_device *ndev = tx_ring->ndev;
struct enetc_ndev_priv *priv = netdev_priv(ndev); struct enetc_ndev_priv *priv = netdev_priv(ndev);
int tx_frm_cnt = 0, tx_byte_cnt = 0;
struct enetc_tx_swbd *tx_swbd; struct enetc_tx_swbd *tx_swbd;
int i, bds_to_clean; int i, bds_to_clean;
bool do_twostep_tstamp; bool do_twostep_tstamp;
...@@ -821,6 +822,10 @@ static bool enetc_clean_tx_ring(struct enetc_bdr *tx_ring, int napi_budget) ...@@ -821,6 +822,10 @@ static bool enetc_clean_tx_ring(struct enetc_bdr *tx_ring, int napi_budget)
&tstamp); &tstamp);
do_twostep_tstamp = true; do_twostep_tstamp = true;
} }
if (tx_swbd->qbv_en &&
txbd->wb.status & ENETC_TXBD_STATS_WIN)
tx_win_drop++;
} }
if (tx_swbd->is_xdp_tx) if (tx_swbd->is_xdp_tx)
...@@ -873,6 +878,7 @@ static bool enetc_clean_tx_ring(struct enetc_bdr *tx_ring, int napi_budget) ...@@ -873,6 +878,7 @@ static bool enetc_clean_tx_ring(struct enetc_bdr *tx_ring, int napi_budget)
tx_ring->next_to_clean = i; tx_ring->next_to_clean = i;
tx_ring->stats.packets += tx_frm_cnt; tx_ring->stats.packets += tx_frm_cnt;
tx_ring->stats.bytes += tx_byte_cnt; tx_ring->stats.bytes += tx_byte_cnt;
tx_ring->stats.win_drop += tx_win_drop;
if (unlikely(tx_frm_cnt && netif_carrier_ok(ndev) && if (unlikely(tx_frm_cnt && netif_carrier_ok(ndev) &&
__netif_subqueue_stopped(ndev, tx_ring->index) && __netif_subqueue_stopped(ndev, tx_ring->index) &&
...@@ -2552,6 +2558,7 @@ struct net_device_stats *enetc_get_stats(struct net_device *ndev) ...@@ -2552,6 +2558,7 @@ struct net_device_stats *enetc_get_stats(struct net_device *ndev)
struct enetc_ndev_priv *priv = netdev_priv(ndev); struct enetc_ndev_priv *priv = netdev_priv(ndev);
struct net_device_stats *stats = &ndev->stats; struct net_device_stats *stats = &ndev->stats;
unsigned long packets = 0, bytes = 0; unsigned long packets = 0, bytes = 0;
unsigned long tx_dropped = 0;
int i; int i;
for (i = 0; i < priv->num_rx_rings; i++) { for (i = 0; i < priv->num_rx_rings; i++) {
...@@ -2567,10 +2574,12 @@ struct net_device_stats *enetc_get_stats(struct net_device *ndev) ...@@ -2567,10 +2574,12 @@ struct net_device_stats *enetc_get_stats(struct net_device *ndev)
for (i = 0; i < priv->num_tx_rings; i++) { for (i = 0; i < priv->num_tx_rings; i++) {
packets += priv->tx_ring[i]->stats.packets; packets += priv->tx_ring[i]->stats.packets;
bytes += priv->tx_ring[i]->stats.bytes; bytes += priv->tx_ring[i]->stats.bytes;
tx_dropped += priv->tx_ring[i]->stats.win_drop;
} }
stats->tx_packets = packets; stats->tx_packets = packets;
stats->tx_bytes = bytes; stats->tx_bytes = bytes;
stats->tx_dropped = tx_dropped;
return stats; return stats;
} }
......
...@@ -36,6 +36,7 @@ struct enetc_tx_swbd { ...@@ -36,6 +36,7 @@ struct enetc_tx_swbd {
u8 is_eof:1; u8 is_eof:1;
u8 is_xdp_tx:1; u8 is_xdp_tx:1;
u8 is_xdp_redirect:1; u8 is_xdp_redirect:1;
u8 qbv_en:1;
}; };
#define ENETC_RX_MAXFRM_SIZE ENETC_MAC_MAXFRM_SIZE #define ENETC_RX_MAXFRM_SIZE ENETC_MAC_MAXFRM_SIZE
...@@ -72,6 +73,7 @@ struct enetc_ring_stats { ...@@ -72,6 +73,7 @@ struct enetc_ring_stats {
unsigned int xdp_redirect_sg; unsigned int xdp_redirect_sg;
unsigned int recycles; unsigned int recycles;
unsigned int recycle_failures; unsigned int recycle_failures;
unsigned int win_drop;
}; };
struct enetc_xdp_data { struct enetc_xdp_data {
......
...@@ -204,6 +204,7 @@ static const char tx_ring_stats[][ETH_GSTRING_LEN] = { ...@@ -204,6 +204,7 @@ static const char tx_ring_stats[][ETH_GSTRING_LEN] = {
"Tx ring %2d frames", "Tx ring %2d frames",
"Tx ring %2d XDP frames", "Tx ring %2d XDP frames",
"Tx ring %2d XDP drops", "Tx ring %2d XDP drops",
"Tx window drop %2d frames",
}; };
static int enetc_get_sset_count(struct net_device *ndev, int sset) static int enetc_get_sset_count(struct net_device *ndev, int sset)
...@@ -279,6 +280,7 @@ static void enetc_get_ethtool_stats(struct net_device *ndev, ...@@ -279,6 +280,7 @@ static void enetc_get_ethtool_stats(struct net_device *ndev,
data[o++] = priv->tx_ring[i]->stats.packets; data[o++] = priv->tx_ring[i]->stats.packets;
data[o++] = priv->tx_ring[i]->stats.xdp_tx; data[o++] = priv->tx_ring[i]->stats.xdp_tx;
data[o++] = priv->tx_ring[i]->stats.xdp_tx_drops; data[o++] = priv->tx_ring[i]->stats.xdp_tx_drops;
data[o++] = priv->tx_ring[i]->stats.win_drop;
} }
for (i = 0; i < priv->num_rx_rings; i++) { for (i = 0; i < priv->num_rx_rings; i++) {
......
...@@ -543,6 +543,7 @@ enum enetc_txbd_flags { ...@@ -543,6 +543,7 @@ enum enetc_txbd_flags {
ENETC_TXBD_FLAGS_EX = BIT(6), ENETC_TXBD_FLAGS_EX = BIT(6),
ENETC_TXBD_FLAGS_F = BIT(7) ENETC_TXBD_FLAGS_F = BIT(7)
}; };
#define ENETC_TXBD_STATS_WIN BIT(7)
#define ENETC_TXBD_TXSTART_MASK GENMASK(24, 0) #define ENETC_TXBD_TXSTART_MASK GENMASK(24, 0)
#define ENETC_TXBD_FLAGS_OFFSET 24 #define ENETC_TXBD_FLAGS_OFFSET 24
......
...@@ -777,9 +777,6 @@ static void enetc_pf_netdev_setup(struct enetc_si *si, struct net_device *ndev, ...@@ -777,9 +777,6 @@ static void enetc_pf_netdev_setup(struct enetc_si *si, struct net_device *ndev,
ndev->priv_flags |= IFF_UNICAST_FLT; ndev->priv_flags |= IFF_UNICAST_FLT;
if (si->hw_features & ENETC_SI_F_QBV)
priv->active_offloads |= ENETC_F_QBV;
if (si->hw_features & ENETC_SI_F_PSFP && !enetc_psfp_enable(priv)) { if (si->hw_features & ENETC_SI_F_PSFP && !enetc_psfp_enable(priv)) {
priv->active_offloads |= ENETC_F_QCI; priv->active_offloads |= ENETC_F_QCI;
ndev->features |= NETIF_F_HW_TC; ndev->features |= NETIF_F_HW_TC;
...@@ -993,7 +990,8 @@ static void enetc_pl_mac_link_up(struct phylink_config *config, ...@@ -993,7 +990,8 @@ static void enetc_pl_mac_link_up(struct phylink_config *config,
int idx; int idx;
priv = netdev_priv(pf->si->ndev); priv = netdev_priv(pf->si->ndev);
if (priv->active_offloads & ENETC_F_QBV)
if (pf->si->hw_features & ENETC_SI_F_QBV)
enetc_sched_speed_set(priv, speed); enetc_sched_speed_set(priv, speed);
if (!phylink_autoneg_inband(mode) && if (!phylink_autoneg_inband(mode) &&
......
...@@ -70,6 +70,9 @@ static int enetc_setup_taprio(struct net_device *ndev, ...@@ -70,6 +70,9 @@ static int enetc_setup_taprio(struct net_device *ndev,
enetc_wr(&priv->si->hw, enetc_wr(&priv->si->hw,
ENETC_QBV_PTGCR_OFFSET, ENETC_QBV_PTGCR_OFFSET,
tge & (~ENETC_QBV_TGE)); tge & (~ENETC_QBV_TGE));
priv->active_offloads &= ~ENETC_F_QBV;
return 0; return 0;
} }
...@@ -125,6 +128,9 @@ static int enetc_setup_taprio(struct net_device *ndev, ...@@ -125,6 +128,9 @@ static int enetc_setup_taprio(struct net_device *ndev,
enetc_cbd_free_data_mem(priv->si, data_size, tmp, &dma); enetc_cbd_free_data_mem(priv->si, data_size, tmp, &dma);
if (!err)
priv->active_offloads |= ENETC_F_QBV;
return err; return err;
} }
......
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