Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1144896rdb; Wed, 20 Sep 2023 00:19:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHT2v956uQymzXhIlOfFaz6MtwogDWmpiN3e0wpRdTMHcDycDp1qrOBB0OcqwPyRjeh7Zsi X-Received: by 2002:a17:902:efce:b0:1bc:6dd9:82c3 with SMTP id ja14-20020a170902efce00b001bc6dd982c3mr1248683plb.37.1695194393352; Wed, 20 Sep 2023 00:19:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695194393; cv=none; d=google.com; s=arc-20160816; b=fQFRzNeXL1BJn7pQX6bT52aLotEkIzcVRMuMOM56uXPyZrEH2dGEUwzt9Kiy/c70OS XvOreEECU3kRfAuOZZBF/lXe0TdFkGOsayIS4qZm2OEaniXXUiMWC3byWzia+ZeqUn2S RM/7dcjT8NTMtxYvFh60EpDYggAhtFZpIKWBa9qe/Yw3PWRHMX3/AV7XboxuDEpyrElH TtRYc2wBp7ol39r5NLXQVCd5E1+gOYakmjFwR1sCJien1p+soU29qInB99CwBgxm/qkz 4A96h+x0xMpNUAH9Dpm9UzmBkx51ScdvbZnIhp+aVybp9DvgZVaYvlVMmVPAh+p7y+0r mQMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=57opYI9bmVXzLfUxI1bHU1pADvw5dfEhueeoF7T5bxk=; fh=n2gibFk7jxbiuRpBHcvIlSviXsqcatI3FdBFChVv45w=; b=WDTg7o07DGnqNAfOSPbP8DQlFRjcQSWHONU2G+vAEO9MyZ4svgujdG1nbUyWE7LrVO OHzj66lGljqUKynzPk5Z0gefSSu8lVtqLTfmUcl1Mj/KHwtyRe4wwsc7zIjuJPpqLjY3 vfTdHS+5OpJOcngceRabwi+ml4bsJTPTPhPXtFaCg22kuBvsIQHCkJF2vM0LzIKvGjQo hSNxalxXKS4AklnoE09hy2J5LemXvNlWuFhPnRFaatUUKa73Oh3GajrQM9tNYTEaAWo3 Hd8ZaHjol0vKN6iBOYqVb2bZ7r5mYyhzD4MuYi0ACsG/r6nzGSkKLe9yRRXk8ETv1mM8 lxAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=U+YO+seS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id q5-20020a17090311c500b001c0cb378f04si11705361plh.335.2023.09.20.00.19.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 00:19:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=U+YO+seS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 8B921830D134; Wed, 20 Sep 2023 00:19:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233638AbjITHT2 (ORCPT + 99 others); Wed, 20 Sep 2023 03:19:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233534AbjITHTZ (ORCPT ); Wed, 20 Sep 2023 03:19:25 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93E6FCA for ; Wed, 20 Sep 2023 00:19:18 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37707C433C7; Wed, 20 Sep 2023 07:19:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695194358; bh=WyO9M//XrozD9V7TnomV/MSTgBlPqTOV4kfhlkxyjSU=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=U+YO+seSaVhGE61tbw7daKIcwHsvtGx6VsQenbdtEZ77Rmrr0voTBoP7zvXToLX5p 8h8qn6gk0nul2EC9kuw8FTVswGOmVSVqIkK+rW9n8MTh7YQWlEjVNdVxcxmHCUAWY3 gHyLknMIgdQQP+Lu9GQQT0riUjYtZ6X5LfOJPq5uiUbtCzxkIPS/h4fmUaCO+NBq6E hCtyMJxOABL4mwaJX6HXJLxbgRg6yDuiCBrayvBkdDPuypU5P0lDwc6SlHs7EhbVyl uLq6ZqbALxmJiC1qzwR/gq0ZLWpCXlVkomuyrLntgNIkEVYmpGTdP6ZyLb5praUKFy 3tXT1Dw2+aMiA== Message-ID: <79bd4b5b-7ea8-4a3b-d098-9aecd43b1675@kernel.org> Date: Wed, 20 Sep 2023 10:19:12 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH v2] net: ethernet: ti: am65-cpsw: add mqprio qdisc offload in channel mode Content-Language: en-US To: Vladimir Oltean Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, s-vadapalli@ti.com, srk@ti.com, vigneshr@ti.com, p-varis@ti.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, rogerq@kernel.rog References: <20230918075358.5878-1-rogerq@kernel.org> <20230918075358.5878-1-rogerq@kernel.org> <20230919124703.hj2bvqeogfhv36qy@skbuf> From: Roger Quadros In-Reply-To: <20230919124703.hj2bvqeogfhv36qy@skbuf> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 20 Sep 2023 00:19:50 -0700 (PDT) Hi Vladimir, On 19/09/2023 15:47, Vladimir Oltean wrote: > Hi Roger, > > On Mon, Sep 18, 2023 at 10:53:58AM +0300, Roger Quadros wrote: >> -int am65_cpsw_qos_ndo_setup_tc(struct net_device *ndev, enum tc_setup_type type, >> - void *type_data) >> -{ >> - switch (type) { >> - case TC_QUERY_CAPS: >> - return am65_cpsw_tc_query_caps(ndev, type_data); >> - case TC_SETUP_QDISC_TAPRIO: >> - return am65_cpsw_setup_taprio(ndev, type_data); >> - case TC_SETUP_BLOCK: >> - return am65_cpsw_qos_setup_tc_block(ndev, type_data); >> - default: >> - return -EOPNOTSUPP; >> - } >> -} >> - >> -void am65_cpsw_qos_link_up(struct net_device *ndev, int link_speed) >> -{ >> - struct am65_cpsw_port *port = am65_ndev_to_port(ndev); >> - >> - if (!IS_ENABLED(CONFIG_TI_AM65_CPSW_TAS)) >> - return; >> - >> - am65_cpsw_est_link_up(ndev, link_speed); >> - port->qos.link_down_time = 0; >> -} >> - >> -void am65_cpsw_qos_link_down(struct net_device *ndev) >> -{ >> - struct am65_cpsw_port *port = am65_ndev_to_port(ndev); >> - >> - if (!IS_ENABLED(CONFIG_TI_AM65_CPSW_TAS)) >> - return; >> - >> - if (!port->qos.link_down_time) >> - port->qos.link_down_time = ktime_get(); >> - >> - port->qos.link_speed = SPEED_UNKNOWN; >> -} >> - > > Could you split the code movement to a separate change? OK. > >> + if (port->qos.link_speed != SPEED_UNKNOWN) { >> + if (min_rate_total > port->qos.link_speed) { >> + NL_SET_ERR_MSG_FMT_MOD(extack, "TX rate min %llu exceeds link speed %d\n", >> + min_rate_total, port->qos.link_speed); >> + return -EINVAL; >> + } >> + >> + if (max_rate_total > port->qos.link_speed) { >> + NL_SET_ERR_MSG_FMT_MOD(extack, "TX rate max %llu exceeds link speed %d\n", >> + max_rate_total, port->qos.link_speed); >> + return -EINVAL; >> + } >> + } > > Link speeds can be renegotiated, and the mqprio offload can be installed > while the link is down. So this restriction, while honorable, has limited > usefulness. For link down case it won't run those checks, but I get your point. I'll drop these checks. > >> + >> + p_mqprio->shaper_en = 1; > > s/1/true/ > >> + p_mqprio->max_rate_total = max_t(u64, min_rate_total, max_rate_total); >> + >> + return 0; >> +} >> + >> +static void am65_cpsw_reset_tc_mqprio(struct net_device *ndev) >> +{ >> + struct am65_cpsw_port *port = am65_ndev_to_port(ndev); >> + struct am65_cpsw_mqprio *p_mqprio = &port->qos.mqprio; >> + struct am65_cpsw_common *common = port->common; >> + >> + p_mqprio->shaper_en = 0; > > s/0/false/ > >> + p_mqprio->max_rate_total = 0; >> + >> + am65_cpsw_tx_pn_shaper_reset(port); >> + netdev_reset_tc(ndev); >> + netif_set_real_num_tx_queues(ndev, common->tx_ch_num); >> + >> + /* Reset all Queue priorities to 0 */ >> + writel(0, >> + port->port_base + AM65_CPSW_PN_REG_TX_PRI_MAP); > > What exactly needs pm_runtime_get_sync()? This writel() doesn't? Good catch. In my tests, the network interface was up so controller was already active. But we will need to do a pm_runtime_get_sync() if all network interfaces of the controller are down. So, I will need to move the pm_runtime_get_sync() call before am65_cpsw_reset_tc_mqprio(); > >> +} >> + >> +static int am65_cpsw_setup_mqprio(struct net_device *ndev, void *type_data) >> +{ >> + struct am65_cpsw_port *port = am65_ndev_to_port(ndev); >> + struct am65_cpsw_mqprio *p_mqprio = &port->qos.mqprio; >> + struct tc_mqprio_qopt_offload *mqprio = type_data; >> + struct am65_cpsw_common *common = port->common; >> + struct tc_mqprio_qopt *qopt = &mqprio->qopt; >> + int tc, offset, count, ret, prio; >> + u8 num_tc = qopt->num_tc; >> + u32 tx_prio_map = 0; >> + int i; >> + >> + memcpy(&p_mqprio->mqprio_hw, mqprio, sizeof(*mqprio)); >> + >> + if (!num_tc) { >> + am65_cpsw_reset_tc_mqprio(ndev); >> + return 0; >> + } >> + >> + ret = pm_runtime_get_sync(common->dev); >> + if (ret < 0) { >> + pm_runtime_put_noidle(common->dev); >> + return ret; >> + } -- cheers, -roger