Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp297980pxk; Fri, 11 Sep 2020 07:15:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3KOJkvEwLm8YAclkJeYVaR7oIaSu86G+6rKoHDOgxmnqdm78RHpPyg8i8G5u7QxAkuV9r X-Received: by 2002:a17:906:f246:: with SMTP id gy6mr2208015ejb.373.1599833715389; Fri, 11 Sep 2020 07:15:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599833715; cv=none; d=google.com; s=arc-20160816; b=kzVxjmRnYn3g5D//hrmZXnERc3172l26FEvQIqFMDrC7kWR5lNf6CiiQZgWB7hKUCp SjKNJkrcoXeaQhgsTrGLHO5RXFbPY+2mfOaTkprfoObs89HVmVpDe9lsXZMXm/Fzl8wW u9S1sdbSuL/awlQ7JwxmwZNDY0qZpvn8hgAoGBKNYwaoSHzn1Z3XjLCsj9VSvG4+kEL3 VFt5WH8fjW3PKASVEdxpaa3uYED/PJioUkYruCGqSjnNXDhby+jWgMiInG+soNkxdNKp E03jATbR9lZmDkH/mtFx8SK0dMKqmRq8n5vn4KoFVKVgbZsxCKEdIfboixLQXh0Knrl0 BysQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xiaek7ppX/0i0tqeZMfLsZmqzdRoDMvzpet4qPNr+OE=; b=qFchQPD36/OSTZTRXbsp3zbDYtcwYwLtaR3y2/QVEkH+1jadFa9lpYURnjkxQ8YMKP juPWHoSIJr2+I593TyEQubY9jKhn96o0/maAba8NACdvjh8TlrjWNGrcuheXQYPDLy8o W3WB7hpC4AxROUaAF+GFscYkrDgOjNWpUniX4D97mNYbAbFKQJ5OpABtv3v6TJWIdM5f bQlsa2lq/gP112iJHkt0y5A1F0Q/egK7by3p3Y3hjjV+I5Wz1p6xHlfuDLmj+SsMRSIe ya7PpJEWhRemel8BzeWf6275J0L+ImfFehrkaQ+5VSYCFcCcg5b2KG2roQWfVWK2yqf5 m88w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Wn1T2ezp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n11si1343841edr.118.2020.09.11.07.14.51; Fri, 11 Sep 2020 07:15:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Wn1T2ezp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726280AbgIKOHf (ORCPT + 99 others); Fri, 11 Sep 2020 10:07:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:34914 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726285AbgIKN3X (ORCPT ); Fri, 11 Sep 2020 09:29:23 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3214022454; Fri, 11 Sep 2020 12:59:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599829175; bh=W1ZGXPCPWg4GDwJhPkYdlGLPtpBi+3EawQT0rGrBiAU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wn1T2ezpZ/I7K4BdGERS1TsY1h4gwXq1MnuHejCF5y8yWQgoDzpiUx0oO1KKhovKu brQGrObcBuAxluZ8B+TmGlrlUFB4ygRYDO/EIQWmKC8b5aLTiRuVJ3kuseZRHn8PzR z+/zpV1VxPtFHKpwL9o19X4l0yO2o1rhx9eINMgc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vinicius Costa Gomes , "David S. Miller" Subject: [PATCH 5.8 12/16] taprio: Fix using wrong queues in gate mask Date: Fri, 11 Sep 2020 14:47:29 +0200 Message-Id: <20200911122500.188587305@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122459.585735377@linuxfoundation.org> References: <20200911122459.585735377@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vinicius Costa Gomes [ 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 Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- 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)