[Intel-wired-lan] [PATCH iwl-net v3] igc: Add TransmissionOverrun counter

Zulkifli, Muhammad Husaini muhammad.husaini.zulkifli at intel.com
Thu Jun 1 01:29:55 UTC 2023


Hi,

> -----Original Message-----
> From: Zulkifli, Muhammad Husaini <muhammad.husaini.zulkifli at intel.com>
> Sent: Thursday, 1 June, 2023 8:59 AM
> To: intel-wired-lan at osuosl.org
> Cc: Gomes, Vinicius <vinicius.gomes at intel.com>; Zulkifli, Muhammad
> Husaini <muhammad.husaini.zulkifli at intel.com>; Neftin, Sasha
> <sasha.neftin at intel.com>; tee.min.tan at linux.intel.com;
> vladimir.oltean at nxp.com; naamax.meir at linux.intel.com; Nguyen, Anthony L
> <anthony.l.nguyen at intel.com>
> Subject: [PATCH iwl-net v3] igc: Add TransmissionOverrun counter

Sorry I think I accidentally copy paste wrong subject prefix when generate
this V3 patch. It should go to "net-next". My bad.

> 
> Add TransmissionOverrun as per defined by IEEE 802.1Q Bridges.
> TransmissionOverrun counter shall be incremented if the implementation
> detects that a frame from a given queue is still being transmitted by the MAC
> when that gate-close event for that queue occurs.
> 
> This counter is utilised by the Certification conformance test to inform the
> user application whether any packets are currently being transmitted on a
> particular queue during a gate-close event.
> 
> Intel Discrete I225/I226 have a mechanism to not transmit a packets if the
> gate open time is insufficient for the packet transmission by setting the
> Strict_End bit. Thus, it is expected for this counter to be always zero at this
> moment.
> 
> Inspired from enetc_taprio_stats() and enetc_taprio_tc_stats(), now driver
> also report the tx_overruns counter per traffic class.
> 
> User can get this counter by using below command:
> 1) ethtool -S <interface> | grep Transmit_overruns
> 2) tc -s qdisc show dev <interface> root
> 3) tc -s class show dev <interface>
> 
> Signed-off-by: Muhammad Husaini Zulkifli
> <muhammad.husaini.zulkifli at intel.com>
> 
> ---
> V2 -> V3: Included new infra xstats to report back the counter to qdisc
> V1 -> V2: Change per-queue stats. Driver still remains adding the
> 	  statistic independently.
> ---
> ---
>  drivers/net/ethernet/intel/igc/igc.h         |  1 +
>  drivers/net/ethernet/intel/igc/igc_ethtool.c |  4 ++-
>  drivers/net/ethernet/intel/igc/igc_main.c    | 38 ++++++++++++++++++++
>  drivers/net/ethernet/intel/igc/igc_tsn.c     | 10 ++++++
>  4 files changed, 52 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/intel/igc/igc.h
> b/drivers/net/ethernet/intel/igc/igc.h
> index cb5751fab03c9..2a13e62b75d60 100644
> --- a/drivers/net/ethernet/intel/igc/igc.h
> +++ b/drivers/net/ethernet/intel/igc/igc.h
> @@ -46,6 +46,7 @@ struct igc_tx_queue_stats {
>  	u64 bytes;
>  	u64 restart_queue;
>  	u64 restart_queue2;
> +	u64 tx_overruns;
>  };
> 
>  struct igc_rx_queue_stats {
> diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c
> b/drivers/net/ethernet/intel/igc/igc_ethtool.c
> index 0e2cb00622d1a..6a10ae1474fc5 100644
> --- a/drivers/net/ethernet/intel/igc/igc_ethtool.c
> +++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c
> @@ -112,7 +112,7 @@ static const char
> igc_gstrings_test[][ETH_GSTRING_LEN] = {
>  	(sizeof(igc_gstrings_net_stats) / sizeof(struct igc_stats))  #define
> IGC_RX_QUEUE_STATS_LEN \
>  	(sizeof(struct igc_rx_queue_stats) / sizeof(u64)) -#define
> IGC_TX_QUEUE_STATS_LEN 3 /* packets, bytes, restart_queue */
> +#define IGC_TX_QUEUE_STATS_LEN 4 /* packets, bytes, restart_queue,
> +tx_overruns */
>  #define IGC_QUEUE_STATS_LEN \
>  	((((struct igc_adapter *)netdev_priv(netdev))->num_rx_queues * \
>  	  IGC_RX_QUEUE_STATS_LEN) + \
> @@ -781,6 +781,7 @@ static void igc_ethtool_get_strings(struct net_device
> *netdev, u32 stringset,
>  			ethtool_sprintf(&p, "tx_queue_%u_packets", i);
>  			ethtool_sprintf(&p, "tx_queue_%u_bytes", i);
>  			ethtool_sprintf(&p, "tx_queue_%u_restart", i);
> +			ethtool_sprintf(&p,
> "tx_queue_%u_Transmit_overruns", i);
>  		}
>  		for (i = 0; i < adapter->num_rx_queues; i++) {
>  			ethtool_sprintf(&p, "rx_queue_%u_packets", i); @@ -
> 850,6 +851,7 @@ static void igc_ethtool_get_stats(struct net_device
> *netdev,
>  			restart2  = ring->tx_stats.restart_queue2;
>  		} while (u64_stats_fetch_retry(&ring->tx_syncp2, start));
>  		data[i + 2] += restart2;
> +		data[i + 3] = ring->tx_stats.tx_overruns;
> 
>  		i += IGC_TX_QUEUE_STATS_LEN;
>  	}
> diff --git a/drivers/net/ethernet/intel/igc/igc_main.c
> b/drivers/net/ethernet/intel/igc/igc_main.c
> index aa9f23b7f0c1a..056925a7bcdd8 100644
> --- a/drivers/net/ethernet/intel/igc/igc_main.c
> +++ b/drivers/net/ethernet/intel/igc/igc_main.c
> @@ -6109,11 +6109,43 @@ static int igc_tsn_clear_schedule(struct
> igc_adapter *adapter)
>  		ring->start_time = 0;
>  		ring->end_time = NSEC_PER_SEC;
>  		ring->max_sdu = 0;
> +		ring->tx_stats.tx_overruns = 0;
>  	}
> 
>  	return 0;
>  }
> 
> +static void igc_taprio_stats(struct net_device *dev,
> +			     struct tc_taprio_qopt_stats *stats) {
> +	struct igc_adapter *adapter = netdev_priv(dev);
> +	u64 tx_overruns = 0;
> +	int i;
> +
> +	for (i = 0; i < adapter->num_tx_queues; i++) {
> +		struct igc_ring *tx_ring = adapter->tx_ring[i];
> +
> +		tx_overruns += tx_ring->tx_stats.tx_overruns;
> +	}
> +
> +	stats->tx_overruns = tx_overruns;
> +}
> +
> +static void igc_taprio_tc_stats(struct net_device *dev,
> +				struct tc_taprio_qopt_tc_stats *tc_stats) {
> +	struct tc_taprio_qopt_stats *stats = &tc_stats->stats;
> +	struct igc_adapter *adapter = netdev_priv(dev);
> +	struct igc_ring *tx_ring;
> +	int tc = tc_stats->tc;
> +	int txq;
> +
> +	txq = dev->tc_to_txq[tc].offset;
> +	tx_ring = adapter->tx_ring[txq];
> +
> +	stats->tx_overruns = tx_ring->tx_stats.tx_overruns; }
> +
>  static int igc_save_qbv_schedule(struct igc_adapter *adapter,
>  				 struct tc_taprio_qopt_offload *qopt)  { @@ -
> 6130,6 +6162,12 @@ static int igc_save_qbv_schedule(struct igc_adapter
> *adapter,
>  	case TAPRIO_CMD_DESTROY:
>  		adapter->qbv_enable = false;
>  		break;
> +	case TAPRIO_CMD_STATS:
> +		igc_taprio_stats(adapter->netdev, &qopt->stats);
> +		return 0;
> +	case TAPRIO_CMD_TC_STATS:
> +		igc_taprio_tc_stats(adapter->netdev, &qopt->tc_stats);
> +		return 0;
>  	default:
>  		return -EOPNOTSUPP;
>  	}
> diff --git a/drivers/net/ethernet/intel/igc/igc_tsn.c
> b/drivers/net/ethernet/intel/igc/igc_tsn.c
> index 6b299b83e7ef2..342530d11aae9 100644
> --- a/drivers/net/ethernet/intel/igc/igc_tsn.c
> +++ b/drivers/net/ethernet/intel/igc/igc_tsn.c
> @@ -136,6 +136,16 @@ static int igc_tsn_enable_offload(struct igc_adapter
> *adapter)
>  		txqctl |= IGC_TXQCTL_STRICT_CYCLE |
>  			IGC_TXQCTL_STRICT_END;
> 
> +		/* If it notices that a frame from a particular queue is still
> +		 * being transmitted by MAC, tx_overruns shall be increased.
> +		 * But currently driver setting Strict_End bit which indicate
> +		 * that packet from the queue can be transmitted only if they
> +		 * are expected to be completed before the windows of the
> +		 * queue is ended. Thus, this counter will always be zero
> when
> +		 * Strict_End is set.
> +		 */
> +		ring->tx_stats.tx_overruns  = 0;
> +
>  		if (ring->launchtime_enable)
>  			txqctl |= IGC_TXQCTL_QUEUE_MODE_LAUNCHT;
> 
> --
> 2.17.1



More information about the Intel-wired-lan mailing list