All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Vinicius Costa Gomes <vinicius.gomes@intel.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: [PATCH 5.8 12/16] taprio: Fix using wrong queues in gate mask
Date: Fri, 11 Sep 2020 14:47:29 +0200	[thread overview]
Message-ID: <20200911122500.188587305@linuxfoundation.org> (raw)
In-Reply-To: <20200911122459.585735377@linuxfoundation.org>

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

[ Upstream commit 09e31cf0c528dac3358a081dc4e773d1b3de1bc9 ]

Since commit 9c66d1564676 ("taprio: Add support for hardware
offloading") there's a bit of inconsistency when offloading schedules
to the hardware:

In software mode, the gate masks are specified in terms of traffic
classes, so if say "sched-entry S 03 20000", it means that the traffic
classes 0 and 1 are open for 20us; when taprio is offloaded to
hardware, the gate masks are specified in terms of hardware queues.

The idea here is to fix hardware offloading, so schedules in hardware
and software mode have the same behavior. What's needed to do is to
map traffic classes to queues when applying the offload to the driver.

Fixes: 9c66d1564676 ("taprio: Add support for hardware offloading")
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/sched/sch_taprio.c |   30 ++++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)

--- a/net/sched/sch_taprio.c
+++ b/net/sched/sch_taprio.c
@@ -1177,9 +1177,27 @@ static void taprio_offload_config_change
 	spin_unlock(&q->current_entry_lock);
 }
 
-static void taprio_sched_to_offload(struct taprio_sched *q,
+static u32 tc_map_to_queue_mask(struct net_device *dev, u32 tc_mask)
+{
+	u32 i, queue_mask = 0;
+
+	for (i = 0; i < dev->num_tc; i++) {
+		u32 offset, count;
+
+		if (!(tc_mask & BIT(i)))
+			continue;
+
+		offset = dev->tc_to_txq[i].offset;
+		count = dev->tc_to_txq[i].count;
+
+		queue_mask |= GENMASK(offset + count - 1, offset);
+	}
+
+	return queue_mask;
+}
+
+static void taprio_sched_to_offload(struct net_device *dev,
 				    struct sched_gate_list *sched,
-				    const struct tc_mqprio_qopt *mqprio,
 				    struct tc_taprio_qopt_offload *offload)
 {
 	struct sched_entry *entry;
@@ -1194,7 +1212,8 @@ static void taprio_sched_to_offload(stru
 
 		e->command = entry->command;
 		e->interval = entry->interval;
-		e->gate_mask = entry->gate_mask;
+		e->gate_mask = tc_map_to_queue_mask(dev, entry->gate_mask);
+
 		i++;
 	}
 
@@ -1202,7 +1221,6 @@ static void taprio_sched_to_offload(stru
 }
 
 static int taprio_enable_offload(struct net_device *dev,
-				 struct tc_mqprio_qopt *mqprio,
 				 struct taprio_sched *q,
 				 struct sched_gate_list *sched,
 				 struct netlink_ext_ack *extack)
@@ -1224,7 +1242,7 @@ static int taprio_enable_offload(struct
 		return -ENOMEM;
 	}
 	offload->enable = 1;
-	taprio_sched_to_offload(q, sched, mqprio, offload);
+	taprio_sched_to_offload(dev, sched, offload);
 
 	err = ops->ndo_setup_tc(dev, TC_SETUP_QDISC_TAPRIO, offload);
 	if (err < 0) {
@@ -1486,7 +1504,7 @@ static int taprio_change(struct Qdisc *s
 	}
 
 	if (FULL_OFFLOAD_IS_ENABLED(q->flags))
-		err = taprio_enable_offload(dev, mqprio, q, new_admin, extack);
+		err = taprio_enable_offload(dev, q, new_admin, extack);
 	else
 		err = taprio_disable_offload(dev, q, extack);
 	if (err)



  parent reply	other threads:[~2020-09-11 14:09 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-11 12:47 [PATCH 5.8 00/16] 5.8.9-rc1 review Greg Kroah-Hartman
2020-09-11 12:47 ` [PATCH 5.8 01/16] io_uring: fix cancel of deferred reqs with ->files Greg Kroah-Hartman
2020-09-11 12:47 ` [PATCH 5.8 02/16] io_uring: fix linked deferred ->files cancellation Greg Kroah-Hartman
2020-09-11 12:47 ` [PATCH 5.8 03/16] RDMA/cma: Simplify DEVICE_REMOVAL for internal_id Greg Kroah-Hartman
2020-09-11 12:47 ` [PATCH 5.8 04/16] RDMA/cma: Using the standard locking pattern when delivering the removal event Greg Kroah-Hartman
2020-09-11 12:47 ` [PATCH 5.8 05/16] RDMA/cma: Remove unneeded locking for req paths Greg Kroah-Hartman
2020-09-11 12:47 ` [PATCH 5.8 06/16] RDMA/cma: Execute rdma_cm destruction from a handler properly Greg Kroah-Hartman
2020-09-11 12:47 ` [PATCH 5.8 07/16] ipv4: Silence suspicious RCU usage warning Greg Kroah-Hartman
2020-09-11 12:47 ` [PATCH 5.8 08/16] ipv6: Fix sysctl max for fib_multipath_hash_policy Greg Kroah-Hartman
2020-09-11 12:47 ` [PATCH 5.8 09/16] netlabel: fix problems with mapping removal Greg Kroah-Hartman
2020-09-11 12:47 ` [PATCH 5.8 10/16] net: usb: dm9601: Add USB ID of Keenetic Plus DSL Greg Kroah-Hartman
2020-09-11 12:47 ` [PATCH 5.8 11/16] sctp: not disable bh in the whole sctp_get_port_local() Greg Kroah-Hartman
2020-09-11 12:47 ` Greg Kroah-Hartman [this message]
2020-09-11 12:47 ` [PATCH 5.8 13/16] tipc: fix shutdown() of connectionless socket Greg Kroah-Hartman
2020-09-11 12:47 ` [PATCH 5.8 14/16] tipc: fix using smp_processor_id() in preemptible Greg Kroah-Hartman
2020-09-11 12:47 ` [PATCH 5.8 15/16] net: disable netpoll on fresh napis Greg Kroah-Hartman
2020-09-11 12:47 ` [PATCH 5.8 16/16] mptcp: free acked data before waiting for more memory Greg Kroah-Hartman
2020-09-11 17:10 ` [PATCH 5.8 00/16] 5.8.9-rc1 review Jon Hunter
2020-09-12 12:44   ` Greg Kroah-Hartman
2020-09-11 22:19 ` Shuah Khan
2020-09-12 12:44   ` Greg Kroah-Hartman
2020-09-12  2:19 ` Guenter Roeck
2020-09-12 12:44   ` Greg Kroah-Hartman
2020-09-12  7:27 ` Naresh Kamboju
2020-09-12 12:44   ` Greg Kroah-Hartman

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=20200911122500.188587305@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --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.