Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2825573rdb; Mon, 4 Dec 2023 08:28:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IFva3Q3/viT3PbnkbN9sh8IniwnU+QyTQPEzPX+aGUHoHU72zvrvhsh3sgqL99HIBp6Xhjk X-Received: by 2002:a05:6358:5bd5:b0:170:17eb:3794 with SMTP id i21-20020a0563585bd500b0017017eb3794mr6152144rwf.60.1701707335751; Mon, 04 Dec 2023 08:28:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701707335; cv=none; d=google.com; s=arc-20160816; b=RE2q+9quTdszmHI5739jIehGbJENntlV7fRgW2Hp70BXJNC/dKNobEeEv0YavGENtq CFUodAtEmaB34NSs53r+ADoSXmyKnNvepZK/GMvzYEbf/tOMJ6acR8Pb4FswJERbkBdb Wlx3OWzLq3xiLv5Mk3tOLmsP/okrmSv6Ec8XBJMxvIZrj3ITfAqGNgxguBNWNqK72Xd8 E/Hz96I7yXuYrBobA4G3V5Vtw+aSSm76zh4iU8x/ZUqKID7JXIAYH107VABkvbyBnUaz 3OrDWRBAixwKswOLncQ3kY+U0Rb6MbGog1fuDRVFCyLUdUoonYJsqeIbgzHU78Y+gX+6 1b1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=gAU3Hn2EcC2tDwdpQGcIZBTBdISwHYB8S1Rwgv+7iic=; fh=oUQXlm9N18NE8BciMxTG8yakJePvyLDL7KOQwgHv8WI=; b=fIhsTTvuj90kwCY7Mqd1np385HsjGgi035WQIioU0idOvkRfrpzTjcLPHUarN+5t20 ILPr7NhDQ6l6WL1sZlbssutEJ/zAzb/ZgqLJIvbm+R0OARfnH1uupDPdEPWuF7S5cUWn 6e2uMxXMEWgocDvr9Ce0YAaEw4qfT6C3PAX3hKfoA1uw8C5yBZDmXuXJcPLx5ZNC2u8M ouEU2WtBd0EagOtJsP4C3gwGSdqU1gl9/M3Olq/kvu9L6rar1ghF8d83zLwTTNAVOOSF VJxh7w5cu8sOs3hI2iBBFgEmcTw+P12LyeyX8cwcLaGXYXHJVWJuL6bNVnS+cP+Wn7Ca 9rgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=f3KwE9Rs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id h187-20020a636cc4000000b005c688ff346bsi2010791pgc.589.2023.12.04.08.28.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 08:28:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=f3KwE9Rs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id 4414F80972B6; Mon, 4 Dec 2023 08:28:52 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344671AbjLDQ2c (ORCPT + 99 others); Mon, 4 Dec 2023 11:28:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234809AbjLDQ23 (ORCPT ); Mon, 4 Dec 2023 11:28:29 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE04899 for ; Mon, 4 Dec 2023 08:28:35 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BBC2C433C9; Mon, 4 Dec 2023 16:28:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701707315; bh=dKDKr3gvolScXhXGPFpnjQmlMO642TbJVWqWievKFhc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=f3KwE9Rscpf9FC+mLKjKbovT28jw+vIXOZj6gBgjLVekxsoJi5A6Do+OBDJyEEwoJ zHlAohZsNUdLhgs6MwEDHj4hWPpefc2/40EtAC7c47iEUpdls0tV/r9AKQmUqSMDxy kT8YRNxVuKwyJ1EiRr4lJTZ9V5rwp5w/sRidaJudvLKc+do/OIx4h//55aFuPcDL4p r/7qq+wKSCuAUdGWVy8s8Ym/34Y0hMXVV0G/+BsJ0ZYppkuX7D8YsPS3PftmzILpIZ bFLPoC2HPS2Q5Q5jUvo3OpiWQXIAatEpVxO0s28C2TDKr5tZBWc/JxidPDY8fiaTr6 l1tlf8eOICSOA== Date: Mon, 4 Dec 2023 08:31:57 -0800 From: Bjorn Andersson To: Sneh Shah Cc: Vinod Koul , Bhupesh Sharma , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@quicinc.com, Andrew Halaney Subject: Re: [PATCH net-next] net: stmmac: qcom-ethqos: Add sysfs nodes for qcom ethqos Message-ID: References: <20231204084854.31543-1-quic_snehshah@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231204084854.31543-1-quic_snehshah@quicinc.com> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Mon, 04 Dec 2023 08:28:52 -0800 (PST) On Mon, Dec 04, 2023 at 02:18:54PM +0530, Sneh Shah wrote: > Add sysfs nodes to conifigure routing of specific vlan id to GVM queue. > GVM queue is not exposed to PVM stmmac, so TC ops can't configure routing. > Perhaps I'm just not familiar enough with the details of stmmac, but can you please describe what PVM and GVM is? Regards, Bjorn > Signed-off-by: Sneh Shah > --- > .../stmicro/stmmac/dwmac-qcom-ethqos.c | 216 +++++++++++++++++- > 1 file changed, 215 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c > index d3bf42d0fceb..ea89045a90a1 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c > @@ -109,6 +109,8 @@ struct qcom_ethqos { > unsigned int num_por; > bool rgmii_config_loopback_en; > bool has_emac_ge_3; > + int gvm_vlan_prio; > + int gvm_queue; > }; > > static int rgmii_readl(struct qcom_ethqos *ethqos, unsigned int offset) > @@ -710,6 +712,214 @@ static void ethqos_ptp_clk_freq_config(struct stmmac_priv *priv) > netdev_dbg(priv->dev, "PTP rate %d\n", plat_dat->clk_ptp_rate); > } > > +static ssize_t gvm_vlan_routing_store(struct device *dev, > + struct device_attribute *attr, > + const char *user_buf, size_t size) > +{ > + struct net_device *netdev = to_net_dev(dev); > + struct stmmac_priv *priv; > + struct qcom_ethqos *ethqos; > + u32 prio; > + s8 input = 0; > + > + if (!netdev) { > + pr_err("netdev is NULL\n"); > + return -EINVAL; > + } > + > + priv = netdev_priv(netdev); > + if (!priv) { > + pr_err("priv is NULL\n"); > + return -EINVAL; > + } > + > + ethqos = priv->plat->bsp_priv; > + if (!ethqos) { > + pr_err("ethqos is NULL\n"); > + return -EINVAL; > + } > + > + if (kstrtos8(user_buf, 0, &input)) { > + pr_err("Error in reading option from user\n"); > + return -EINVAL; > + } > + > + if (input < 1 || input > 7) { > + pr_err("Invalid option set by user\n"); > + return -EINVAL; > + } > + > + if (input == ethqos->gvm_vlan_prio) > + pr_err("No effect as duplicate input\n"); > + > + ethqos->gvm_vlan_prio = input; > + prio = 1 << input; > + > + stmmac_rx_queue_prio(priv, priv->hw, prio, ethqos->gvm_queue); > + > + return size; > +} > + > +static ssize_t gvm_queue_mapping_store(struct device *dev, > + struct device_attribute *attr, > + const char *user_buf, size_t size) > +{ > + struct net_device *netdev = to_net_dev(dev); > + struct stmmac_priv *priv; > + struct qcom_ethqos *ethqos; > + u32 prio; > + s8 input = 0; > + > + if (!netdev) { > + pr_err("netdev is NULL\n"); > + return -EINVAL; > + } > + > + priv = netdev_priv(netdev); > + if (!priv) { > + pr_err("priv is NULL\n"); > + return -EINVAL; > + } > + > + ethqos = priv->plat->bsp_priv; > + if (!ethqos) { > + pr_err("ethqos is NULL\n"); > + return -EINVAL; > + } > + > + if (kstrtos8(user_buf, 0, &input)) { > + pr_err("Error in reading option from user\n"); > + return -EINVAL; > + } > + > + if (input == ethqos->gvm_queue) > + pr_err("No effect as duplicate input\n"); > + > + ethqos->gvm_queue = input; > + prio = 1 << input; > + > + return size; > +} > + > +static ssize_t gvm_queue_mapping_show(struct device *dev, > + struct device_attribute *attr, char *user_buf) > +{ > + struct net_device *netdev = to_net_dev(dev); > + struct stmmac_priv *priv; > + struct qcom_ethqos *ethqos; > + > + if (!netdev) { > + pr_err("netdev is NULL\n"); > + return -EINVAL; > + } > + > + priv = netdev_priv(netdev); > + if (!priv) { > + pr_err("priv is NULL\n"); > + return -EINVAL; > + } > + > + ethqos = priv->plat->bsp_priv; > + if (!ethqos) { > + pr_err("ethqos is NULL\n"); > + return -EINVAL; > + } > + > + return scnprintf(user_buf, 256, "%d\n", ethqos->gvm_queue); > +} > + > +static ssize_t gvm_vlan_routing_show(struct device *dev, > + struct device_attribute *attr, char *user_buf) > +{ > + struct net_device *netdev = to_net_dev(dev); > + struct stmmac_priv *priv; > + struct qcom_ethqos *ethqos; > + > + if (!netdev) { > + pr_err("netdev is NULL\n"); > + return -EINVAL; > + } > + > + priv = netdev_priv(netdev); > + if (!priv) { > + pr_err("priv is NULL\n"); > + return -EINVAL; > + } > + > + ethqos = priv->plat->bsp_priv; > + if (!ethqos) { > + pr_err("ethqos is NULL\n"); > + return -EINVAL; > + } > + > + return scnprintf(user_buf, 256, "%d\n", ethqos->gvm_vlan_prio); > +} > + > +static DEVICE_ATTR_RW(gvm_queue_mapping); > + > +static DEVICE_ATTR_RW(gvm_vlan_routing); > + > +static int ethqos_remove_sysfs(struct qcom_ethqos *ethqos) > +{ > + struct net_device *net_dev; > + > + if (!ethqos) { > + pr_err("ethqos is NULL\n"); > + return -EINVAL; > + } > + > + net_dev = platform_get_drvdata(ethqos->pdev); > + if (!net_dev) { > + pr_err("netdev is NULL\n"); > + return -EINVAL; > + } > + > + sysfs_remove_file(&net_dev->dev.kobj, > + &dev_attr_gvm_queue_mapping.attr); > + sysfs_remove_file(&net_dev->dev.kobj, > + &dev_attr_gvm_vlan_routing.attr); > + > + return 0; > +} > + > +static int ethqos_create_sysfs(struct qcom_ethqos *ethqos) > +{ > + int ret; > + struct net_device *net_dev; > + > + if (!ethqos) { > + pr_err("ethqos is NULL\n"); > + return -EINVAL; > + } > + > + net_dev = platform_get_drvdata(ethqos->pdev); > + if (!net_dev) { > + pr_err("netdev is NULL\n"); > + return -EINVAL; > + } > + > + ret = sysfs_create_file(&net_dev->dev.kobj, > + &dev_attr_gvm_queue_mapping.attr); > + if (ret) { > + pr_err("unable to create passthrough_en sysfs node\n"); > + goto fail; > + } > + > + ret = sysfs_create_file(&net_dev->dev.kobj, > + &dev_attr_gvm_vlan_routing.attr); > + if (ret) { > + pr_err("unable to create cv2x_priority sysfs node\n"); > + goto fail; > + } > + > + return ret; > + > +fail: > + ethqos_remove_sysfs(ethqos); > + > + return ret; > +} > + > static int qcom_ethqos_probe(struct platform_device *pdev) > { > struct device_node *np = pdev->dev.of_node; > @@ -812,7 +1022,11 @@ static int qcom_ethqos_probe(struct platform_device *pdev) > plat_dat->serdes_powerdown = qcom_ethqos_serdes_powerdown; > } > > - return devm_stmmac_pltfr_probe(pdev, plat_dat, &stmmac_res); > + ret = devm_stmmac_pltfr_probe(pdev, plat_dat, &stmmac_res); > + if (ret) > + return ret; > + > + return ethqos_create_sysfs(ethqos); > } > > static const struct of_device_id qcom_ethqos_match[] = { > -- > 2.17.1 > >