Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1360705rwl; Fri, 7 Apr 2023 14:46:54 -0700 (PDT) X-Google-Smtp-Source: AKy350bc6bklbWN7VeswQM0LdokHT332MLx5/5jQFEWZD9hAAkRh2Mnui50tf99SBdf7Qomff43P X-Received: by 2002:a17:903:2281:b0:1a1:b15a:d916 with SMTP id b1-20020a170903228100b001a1b15ad916mr5179451plh.3.1680904013822; Fri, 07 Apr 2023 14:46:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680904013; cv=none; d=google.com; s=arc-20160816; b=RrClsUQT0qgi6dgNu+HyYJZlS+kEvHPylPc6GKv0bVXbsu877uX4X5qWfE3eoJn9za Wrxv9DrhSRdZz4X02u7cmT4uMzHyHyzjVIQewrR9sQEhECIySplthWgtfGX5insNHlmp ycioDXeohk9qU02sRjoOHjHHFH3M6xNVrR6qtyF84VU6KBGuBCghDMDAI7kXb7S200/K VYcUcdQnpMv9XYcawcgB4ibcSt/okp/dZ+rNfvFm2QSvHdAUN5zKnmuqpFpBMhVArWq1 aCav5YwiGVuIns0VDrbIp5B40YjQo/lfe6vrvtGYLrwVFIg4wRGOPu7mVksZfh0JImuS CZcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=vdqeypLdeZy5Pw+OePubCqs35FYO2gFErqIeJGhxJpQ=; b=CxBssCMMjhoO6NxTzbSenDYK/1sP9/9sIM1R8uQTxmfmdHom2oucbaHWfS6skJP0f3 IRUlncxJ9xFaByhVNpq+Jyd+nmFlBVId9vQPJr/MSgqZQr/j8PAVTnS2AUOnzJC4lbI3 IGAoaZ/41riM4fjVOlGV9b3MSQSUSzgAzh8tidrCum6HO2jFirOGHs+GL1QGNpzrNu03 ci6zFrIwe0YO8G6BVqkvNrdxKDanbm7VghqOARcQNZbSNXA7hKUW8+2D/jrrq9RJC8Ie aSnfBOkmZb7AV8yAPeIiiXbSyPbes5v5sE13TS3MQts76eea70NsL8vFvGaTTgUNCR+Y 5gwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mojatatu-com.20210112.gappssmtp.com header.s=20210112 header.b=ZSwsypCn; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i62-20020a638741000000b0051389efe297si4373957pge.265.2023.04.07.14.46.41; Fri, 07 Apr 2023 14:46:53 -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=@mojatatu-com.20210112.gappssmtp.com header.s=20210112 header.b=ZSwsypCn; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231168AbjDGVkf (ORCPT + 99 others); Fri, 7 Apr 2023 17:40:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229567AbjDGVke (ORCPT ); Fri, 7 Apr 2023 17:40:34 -0400 Received: from mail-yb1-xb29.google.com (mail-yb1-xb29.google.com [IPv6:2607:f8b0:4864:20::b29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24B54BBA6 for ; Fri, 7 Apr 2023 14:40:32 -0700 (PDT) Received: by mail-yb1-xb29.google.com with SMTP id f188so31701784ybb.3 for ; Fri, 07 Apr 2023 14:40:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20210112.gappssmtp.com; s=20210112; t=1680903631; x=1683495631; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=vdqeypLdeZy5Pw+OePubCqs35FYO2gFErqIeJGhxJpQ=; b=ZSwsypCndkNbHiRgIvnilV+q+5NvrXqB0Q+KexWLRVBZ5TQywZEhyBpq5ceFcoml20 Jwq8LRiyNdeGwc/hekLVC8yme8O7cPXFJ/eIuz7YJVXB1wvaoqvtpxNIVEZgV8NYvUoF I/1WBFg7OGqcWcAnIGxruh55gh032yHBuu7OKMUjSUJPGWMLlgJfrcy7I/iYB7YN25zq f+8FPLnfqCTmXAJI63NpdNf2Pd2mBwitztlS+zd69g5HSMdz4e98eNBVRRcKXSSS5UVN RcFFuIwjax5b2O21NbrVKbl/nxQqOTU0PcE6RWmhtcTZ8LD/Nee3x3Qus9o5piVrF6Of EiNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680903631; x=1683495631; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vdqeypLdeZy5Pw+OePubCqs35FYO2gFErqIeJGhxJpQ=; b=FeVNVd3JR/hdvEWIRxEGOTpVwFsCSsK+vDh2irBKIVgzAFatNtkCrHvo8KRNFOoTb7 eCKU0L08ebhM8zdcmf77nQW7YSOIuxbVanyRpLIQP1Kq9Tpga8UYvQObb+0lC9Mth23w yt6M4NP4qZdUc1509u3thTQm2GwzveLlBnInnGZ02aj9bhqBkAVp0SRq5qYGlu/woCO7 g/W8G9QfNZL8cVYPmy5+8mK4Ry9BPRf8kSiWRZkVOVPI0haHWi0x8mxs4Bp77IdA1XWQ T7J9QqXFWemngDfOyhbqFRBQpWNFyq5fjvHr6n2r48pjk6Y7qbYy5h0EjP8Zb5Lqp2aQ zMuA== X-Gm-Message-State: AAQBX9d/ULfBwqRNOHlUy+aL1uidhvlG9QoQuEFQHIo5JF1DialZZStY cGXtK0FGaHrUiLbV6bnCxon34R2yIxUYe/INvnCtxQ== X-Received: by 2002:a25:6c07:0:b0:b8b:eea7:525b with SMTP id h7-20020a256c07000000b00b8beea7525bmr2495945ybc.7.1680903631291; Fri, 07 Apr 2023 14:40:31 -0700 (PDT) MIME-Version: 1.0 References: <20230403103440.2895683-1-vladimir.oltean@nxp.com> <20230403103440.2895683-7-vladimir.oltean@nxp.com> <20230407164103.vstxn2fmswno3ker@skbuf> <20230407193056.3rklegrgmn2yecuu@skbuf> In-Reply-To: <20230407193056.3rklegrgmn2yecuu@skbuf> From: Jamal Hadi Salim Date: Fri, 7 Apr 2023 17:40:20 -0400 Message-ID: Subject: Re: [PATCH v4 net-next 6/9] net/sched: mqprio: allow per-TC user input of FP adminStatus To: Vladimir Oltean Cc: Vladimir Oltean , netdev@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Gerhard Engleder , Amritha Nambiar , Ferenc Fejes , Xiaoliang Yang , Roger Quadros , Pranavi Somisetty , Harini Katakam , Giuseppe Cavallaro , Alexandre Torgue , Michael Sit Wei Hong , Mohammad Athari Bin Ismail , Oleksij Rempel , Jacob Keller , linux-kernel@vger.kernel.org, Ferenc Fejes , Simon Horman Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=0.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 On Fri, Apr 7, 2023 at 3:31=E2=80=AFPM Vladimir Oltean = wrote: > > On Fri, Apr 07, 2023 at 02:49:01PM -0400, Jamal Hadi Salim wrote: > > On Fri, Apr 7, 2023 at 12:41=E2=80=AFPM Vladimir Oltean wrote: > > > On Fri, Apr 07, 2023 at 12:22:26PM -0400, Jamal Hadi Salim wrote: > > > > > +enum { > > > > > + TC_FP_EXPRESS =3D 1, > > > > > + TC_FP_PREEMPTIBLE =3D 2, > > > > > +}; > > > > > > > > Suggestion: Add a MAX to this enum (as is traditionally done).. > > > > > > Max what? This doesn't count anything, it just expresses whether the > > > quality of one traffic class, from the Frame Preemption standard's > > > perspective, is express or preemptible... > > > > > > > > @@ -145,13 +149,94 @@ static int mqprio_parse_opt(struct net_devi= ce *dev, struct tc_mqprio_qopt *qopt, > > > > > return 0; > > > > > } > > > > > > > > > > +static const struct > > > > > +nla_policy mqprio_tc_entry_policy[TCA_MQPRIO_TC_ENTRY_MAX + 1] = =3D { > > > > > + [TCA_MQPRIO_TC_ENTRY_INDEX] =3D NLA_POLICY_MAX(NLA_U3= 2, > > > > > + TC_QOPT_= MAX_QUEUE), > > > > > > > > And use it here... > > > > > > Where? Above or below the comment? I think you mean below (for the > > > policy of TCA_MQPRIO_TC_ENTRY_FP)? > > > > That was what I meant. I misread that code thinking it was a nested > > TLV range check. If it is only going to be those two specific values, > > I understand - but then wondering why you need a u32; wouldnt a u8 be > > sufficient? > > I believe netlink isn't exactly optimized for passing small values; the > netlink attributes are going to be aligned to NLA_ALIGNTO (4) anyway, > so it's not like this is going to save space or something. Also, there's > a policy restricting the maximum, so arbitrarily large values cannot be > passed now, but could be passed later if needed. I did not see any good > enough reason to close that door. > > > The only reason you would need a MAX is if it is possible that new > > values greater than TC_FP_PREEMPTIBLE showing up in the future. > > Even if someone wants to add TC_FP_KINDA_PREEMPTIBLE =3D 3 and > TC_FP_PREEMPTIBLE_WITH_STRIPES =3D 4 in the future, I'm still not sure ho= w > a MAX definition exported by the kernel is going to help them? > > I mean, about the only thing that it would avoid is that I wouldn't be > changing the policy definition, but that's rather minor and doesn't > justify exporting something to UAPI? Yes, it is minor (and usually minor things generate the most emails;->). I may be misunderstanding what you mean by "doesnt justify exporting something to UAPI" - those definitions are part of uapi and are already being exported. > The changed MAX value is only a > property of the kernel headers that the application is compiled with - > it doesn't give the capability of the running kernel. > Maybe I am missing something or not communicating effectively. What i am suggesting is something very trivial: enum { TC_FP_EXPRESS =3D 1, TC_FP_PREEMPTIBLE =3D 2, TC_FP_MAX }; [TCA_MQPRIO_TC_ENTRY_FP] =3D NLA_POLICY_RANGE(NLA_U32, TC_FP_EXPRESS, TC_FP_MAX), And in a newer revision with TC_FP_PREEMPTIBLE_WITH_STRIPES: enum { TC_FP_EXPRESS =3D 1, TC_FP_PREEMPTIBLE =3D 2, TC_FP_PREEMPTIBLE_WITH_STRIPES =3D 3, TC_FP_MAX }; etc. Saves you one line in a patch for when TC_FP_PREEMPTIBLE_WITH_STRIPES shows= up. > To see whether TC_FP_PREEMPTIBLE_WITH_STRIPES is supported, the > application would have to try it and see if it fails. Which is also the > case right now with TC_FP_PREEMPTIBLE. You may be referring to the combination of iproute2/kernel. In all cases, NLA_POLICY_RANGE will take care of rejecting something out of bound. > > > > Lead up question: if the max is 16 then can preemptible_tcs for exa= mple be u32? > > > > > > I don't understand this question, sorry. preemptible_tcs is declared = as > > > "unsigned long", which IIUC is at least 32-bit. > > > > I meant: if you only had 16 possible values, meaning 16 bits are > > sufficient, (although i may be misunderstanding the goal of those > > bits) why not be explicit and use the proper type/size? > > If you think it's valuable to change the type of preemptible_tcs from > unsigned long to u16 and that's a more "proper" type, I can do so. No, no, it is a matter of taste and opinion. You may have noticed, trivial stuff like this gets the most comments and reviews normally(we just spent like 4-5 emails on this?). Poteto/potato: IOW, if i was to do it i would have used a u16 or u32 because i feel it would be more readable. I would have used NLA_U8 because i felt it is more fitting and i would have used a max value because it would save me one line in a patch in the future. I think weve spent enough electrons on this - I defer to you. cheers, jamal