Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp99605rwn; Wed, 14 Sep 2022 16:48:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5r/lfHcCRMvTcxEOfvteN4BFkgzv9V9mo5KpuPKTNgO+Xe+yjdxBBXl48DWlEHtQ86LhgX X-Received: by 2002:a17:903:11c4:b0:178:634b:1485 with SMTP id q4-20020a17090311c400b00178634b1485mr1441789plh.142.1663199305145; Wed, 14 Sep 2022 16:48:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663199305; cv=none; d=google.com; s=arc-20160816; b=KlD4Ot5AIm/bLLo3a5YlZZltBXAuYQehxLBVqCGQrWeLtmfsyxwMQU3V2tywv4Tmjv k0FiRmk2own+X9LCYXPL8maoMRYYjpxLrM5ynEv0jRioFD4iN5SA1VRgiDl25H0UDoXp BOd4Zy0skAh+BHHVlnRDlUsAIQDRkXETsVuR1EB8EzykOgBhRTv/ndaKBNDYCmEyVzVw K45fKMZKkRB0XwAAXrk/VBZdLpYEAJzG+4XPmJrdiMAw/9CDfQGA7u/xvhzlsa/EtMly vg6xTIfpoJ7nTOhuv8Vj5JGjFF7RXvEDQDdIQiAh9EWEGMhLkRJk/LDwX8YnpP5fvTE4 Zi6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=N2w9IySEGSB1Hi/UPqHl+gM5XxUNcA5mpuTGYjsBITE=; b=iMRLpKuJgWupEvE7DiDsWlw1JkvUje0o70DFNnky6+iOH8N0BO5s8wTNGsA7BmwEGA J6XB+z+VCCQVsoP2GzJ5YJKHfsjyuBFFLQdSAyacvmEo93jjOgkX6ZBjZYrg+/1IADxT sLjSV1pndyjyCxDbU4yQ8i6LTOLDTf63z7H+2xN7VMzDpY+Fm0t6PypXojt5CAMCaRgK Weg6UJYM3eSbksxYxsV0os+cVHhesNsTKW1/XwFb1tdFw1lIRA1kszpRsKjq+ERZFOQn nogUookcm9ikXBDIDSSGSX1DOCFkcBg111GxAE/BILkdZ3M3PqyBJCcZ1EnTI4n0k25s PI5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ngEIPv9r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q9-20020a170902f78900b001708af3828fsi16947588pln.62.2022.09.14.16.48.12; Wed, 14 Sep 2022 16:48:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ngEIPv9r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229705AbiINXAS (ORCPT + 99 others); Wed, 14 Sep 2022 19:00:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229838AbiINXAL (ORCPT ); Wed, 14 Sep 2022 19:00:11 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1823C62ABE; Wed, 14 Sep 2022 16:00:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663196409; x=1694732409; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=Gy5Kr1K0CD2RjOuPjSjaim0htKIdr+oZcI5W0+mLzZA=; b=ngEIPv9r90EBFK7C19tsn8Ge0MjdFUlZSaedgLSxsM8CpQeS3nSpuWl6 KdCXcZaTKxmHvP9vy3B1SO/APqaY2OaAgJYe/o5A9sDzX7Wr+rY7kb/br wCKbyOekKchmZZJ/tDotsdbdFpAaHUxRStapNzZG9QpOCJfmJC04GCI+e zWlUMracmp4Z+xS1MZFOD58/mwat/XosTlUkNQMpThB+uh2Sbq9kbCzMA se7F3wx0Bwkurpc7dvNcoFotzeizVukkuaGYXCR4iGd2aga/82UeUshm+ GP8lUe6DJIa8Lk0vzD61SM2HlHA+hPWOdciSTHb56k2Bz8RKjHYJ6XLmM A==; X-IronPort-AV: E=McAfee;i="6500,9779,10470"; a="297288772" X-IronPort-AV: E=Sophos;i="5.93,316,1654585200"; d="scan'208";a="297288772" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2022 16:00:07 -0700 X-IronPort-AV: E=Sophos;i="5.93,316,1654585200"; d="scan'208";a="594575591" Received: from vcostago-desk1.jf.intel.com (HELO vcostago-desk1) ([10.54.70.10]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2022 16:00:07 -0700 From: Vinicius Costa Gomes To: Vladimir Oltean Cc: "netdev@vger.kernel.org" , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Xiaoliang Yang , Rui Sousa , Claudiu Manoil , Alexandre Belloni , "UNGLinuxDriver@microchip.com" , Andrew Lunn , Vivien Didelot , Florian Fainelli , Michael Walle , Maxim Kochetkov , Colin Foster , Richie Pearn , Kurt Kanzenbach , Vladimir Oltean , Jesse Brandeburg , Tony Nguyen , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Gerhard Engleder , Grygorii Strashko , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH net-next 04/13] net/sched: taprio: allow user input of per-tc max SDU In-Reply-To: <20220914221042.oenxhxacgt2xsb2k@skbuf> References: <20220914153303.1792444-1-vladimir.oltean@nxp.com> <20220914153303.1792444-5-vladimir.oltean@nxp.com> <87k065iqe1.fsf@intel.com> <20220914221042.oenxhxacgt2xsb2k@skbuf> Date: Wed, 14 Sep 2022 16:00:07 -0700 Message-ID: <871qsdimtk.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Vladimir Oltean writes: > On Wed, Sep 14, 2022 at 02:43:02PM -0700, Vinicius Costa Gomes wrote: >> > @@ -416,6 +417,9 @@ static int taprio_enqueue_one(struct sk_buff *skb, struct Qdisc *sch, >> > struct Qdisc *child, struct sk_buff **to_free) >> > { >> > struct taprio_sched *q = qdisc_priv(sch); >> > + struct net_device *dev = qdisc_dev(sch); >> > + int prio = skb->priority; >> > + u8 tc; >> > >> > /* sk_flags are only safe to use on full sockets. */ >> > if (skb->sk && sk_fullsock(skb->sk) && sock_flag(skb->sk, SOCK_TXTIME)) { >> > @@ -427,6 +431,12 @@ static int taprio_enqueue_one(struct sk_buff *skb, struct Qdisc *sch, >> > return qdisc_drop(skb, sch, to_free); >> > } >> > >> > + /* Devices with full offload are expected to honor this in hardware */ >> > + tc = netdev_get_prio_tc_map(dev, prio); >> > + if (q->max_sdu[tc] && >> > + q->max_sdu[tc] < max_t(int, 0, skb->len - skb_mac_header_len(skb))) >> > + return qdisc_drop(skb, sch, to_free); >> > + >> >> One minor idea, perhaps if you initialize q->max_sdu[] with a value that >> you could use to compare here (2^32 - 1), this comparison could be >> simplified. The issue is that that value would become invalid for a >> maximum SDU, not a problem for ethernet. > > Could do (and the fact that U32_MAX becomes a reserved value shouldn't > be a problem for any linklayer), but if I optimize the code for this one > place, I need, in turn, to increase the complexity in the netlink dump > and in the offload procedures, to hide what I've done. Hm, I just noticed something. During parse the user only sets the max-sdu for the traffic classes she is interested on. During dump you are showing all of them, the unset ones will be shown as zero, that seems a bit confusing, which could mean that you would have to add some checks anyway. For the offload side, you could just document that U32_MAX means unset. > > If I look at the difference in generated code, maybe it's worth it > (I get rid of a "cbz" instruction). Maybe it's worth simply creating a > shadow array of q->max_sdu[], but which is also adjusted for something > like dev->hard_header_len (also a fast path invariant)? This way, we > could only check for q->max_frm_len[tc] > skb->len and save even more > checks in the fast path. -- Vinicius