All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tony Nguyen <anthony.l.nguyen@intel.com>
To: davem@davemloft.net
Cc: Vinicius Costa Gomes <vinicius.gomes@intel.com>,
	netdev@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com,
	anthony.l.nguyen@intel.com, Aaron Brown <aaron.f.brown@intel.com>
Subject: [net-next 13/15] igc: Reject schedules with a base_time in the future
Date: Mon, 28 Sep 2020 10:59:06 -0700	[thread overview]
Message-ID: <20200928175908.318502-14-anthony.l.nguyen@intel.com> (raw)
In-Reply-To: <20200928175908.318502-1-anthony.l.nguyen@intel.com>

From: Vinicius Costa Gomes <vinicius.gomes@intel.com>

When we set the BASET registers of i225 with a base_time in the
future, i225 will "hold" all packets until that base_time is reached,
causing a lot of TX Hangs.

As this behaviour seems contrary to the expectations of the IEEE
802.1Q standard (section 8.6.9, especially 8.6.9.4.5), let's start by
rejecting these types of schedules. If this is too limiting, we can
for example, setup a timer to configure the BASET registers closer to
the start time, only blocking the packets for a "short" while.

Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
 drivers/net/ethernet/intel/igc/igc_main.c | 25 +++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
index 1c16cd35c81c..569747bbefd8 100644
--- a/drivers/net/ethernet/intel/igc/igc_main.c
+++ b/drivers/net/ethernet/intel/igc/igc_main.c
@@ -4702,14 +4702,35 @@ static int igc_save_launchtime_params(struct igc_adapter *adapter, int queue,
 	return 0;
 }
 
-static bool validate_schedule(const struct tc_taprio_qopt_offload *qopt)
+static bool is_base_time_past(ktime_t base_time, const struct timespec64 *now)
+{
+	struct timespec64 b;
+
+	b = ktime_to_timespec64(base_time);
+
+	return timespec64_compare(now, &b) > 0;
+}
+
+static bool validate_schedule(struct igc_adapter *adapter,
+			      const struct tc_taprio_qopt_offload *qopt)
 {
 	int queue_uses[IGC_MAX_TX_QUEUES] = { };
+	struct timespec64 now;
 	size_t n;
 
 	if (qopt->cycle_time_extension)
 		return false;
 
+	igc_ptp_read(adapter, &now);
+
+	/* If we program the controller's BASET registers with a time
+	 * in the future, it will hold all the packets until that
+	 * time, causing a lot of TX Hangs, so to avoid that, we
+	 * reject schedules that would start in the future.
+	 */
+	if (!is_base_time_past(qopt->base_time, &now))
+		return false;
+
 	for (n = 0; n < qopt->num_entries; n++) {
 		const struct tc_taprio_sched_entry *e;
 		int i;
@@ -4764,7 +4785,7 @@ static int igc_save_qbv_schedule(struct igc_adapter *adapter,
 	if (adapter->base_time)
 		return -EALREADY;
 
-	if (!validate_schedule(qopt))
+	if (!validate_schedule(adapter, qopt))
 		return -EINVAL;
 
 	adapter->cycle_time = qopt->cycle_time;
-- 
2.26.2


  parent reply	other threads:[~2020-09-28 17:59 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-28 17:58 [net-next 00/15] 1GbE Intel Wired LAN Driver Updates 2020-09-28 Tony Nguyen
2020-09-28 17:58 ` [net-next 01/15] igb: add XDP support Tony Nguyen
2020-09-28 19:55   ` David Miller
2020-09-28 22:30   ` Jakub Kicinski
2020-09-28 17:58 ` [net-next 02/15] igb: read PBA number from flash Tony Nguyen
2020-09-28 17:58 ` [net-next 03/15] igc: Add new device ID's Tony Nguyen
2020-09-28 17:58 ` [net-next 04/15] igc: Rename IGC_TSYNCTXCTL_VALID macro Tony Nguyen
2020-09-28 17:58 ` [net-next 05/15] igc: Don't reschedule ptp_tx work Tony Nguyen
2020-09-28 17:58 ` [net-next 06/15] igc: Remove timeout check from " Tony Nguyen
2020-09-28 17:59 ` [net-next 07/15] igc: Clean RX descriptor error flags Tony Nguyen
2020-09-28 17:59 ` [net-next 08/15] igc: Expose LPI counters Tony Nguyen
2020-09-28 17:59 ` [net-next 09/15] igc: Remove references to SYSTIMR register Tony Nguyen
2020-09-28 17:59 ` [net-next 10/15] igc: Save PTP time before a reset Tony Nguyen
2020-09-28 17:59 ` [net-next 11/15] igc: Remove reset disable flag Tony Nguyen
2020-09-28 17:59 ` [net-next 12/15] igc: Export a way to read the PTP timer Tony Nguyen
2020-09-28 17:59 ` Tony Nguyen [this message]
2020-09-28 17:59 ` [net-next 14/15] igc: Clean up nvm_info structure Tony Nguyen
2020-09-28 17:59 ` [net-next 15/15] e1000e: Add support for Meteor Lake Tony Nguyen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200928175908.318502-14-anthony.l.nguyen@intel.com \
    --to=anthony.l.nguyen@intel.com \
    --cc=aaron.f.brown@intel.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@redhat.com \
    --cc=sassmann@redhat.com \
    --cc=vinicius.gomes@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.