From patchwork Mon Dec 4 08:48:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sneh Shah X-Patchwork-Id: 173138 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp2628762vqy; Mon, 4 Dec 2023 00:49:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IGhkGGr5KpZe0umPM/94seRJbZSOZ7of1jCN09Ndsw3XXZWAy9mxja5XqGCW3upg5ChewDg X-Received: by 2002:a05:6a00:a0a:b0:6ce:546e:eb1 with SMTP id p10-20020a056a000a0a00b006ce546e0eb1mr1023851pfh.39.1701679774801; Mon, 04 Dec 2023 00:49:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701679774; cv=none; d=google.com; s=arc-20160816; b=oZB4dt0aB8//QCJWgK85YLn3RgAzXDFLS0+Dv6OZ+4BdbPILpSRbmyfTypcHpLLhiU zq5IJ0xFRu/YculN1gPXqneOtSucnV9J04ZTprYRIJZivAKvq3dmXQszwPDVl0r4OyK7 3IifC8v2l/abHhenrdXYkWxJIWkICpJPRx0nkqrRzJR9/Nuqm+YigSe/oWh6EhglgB/u 8ViKl4vCQiK4NAEdTd4ER7oE0edF+1muLALT+byP5PzNkyGLF9PElxdnKJptp1qHUF2c yPJkE90fEN5Jeqb3p5CtKnHeO7e8slpjtslOck8yTJWB8SRQcmDgXGhc7k2CSrXs6KUl rcgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=CDImjb7xNhS+hFEs/G+MjK3uesJb5R58jLvNa7bSTkQ=; fh=1Jy5qpJ7e4FuBmQkVP0GCA4F+wDSel+w4r34NwoYij8=; b=zn6z6H5jdVH0gLLYJ08lXfHMOlhf0dZicPEhqOXSH27cRe/ahcVcfNL4sJuJ0HhJHI lpKXzUwP1UA6H3TVPnTEW4iVeGTiOWw/sjwvw/LS+XVE2f7rpMYQLuMYaRtQiAbLTmTn w7kVbCkUTLribjSx0ecXRGO7rXYANxQLLD6VJ0emH+FQWivPq99zIB4v5UYw9WCgh+uW rPcU6C7QtR17aeoz1rVNbrd0P5kPHemeAxcvR/as4Tz64EcxTxoiAe1Z2qpg36D3Z8mt 2RS9k0LwK/f9bC0HNIn/XPe3KTdT9DrwcEphxsQmjfEENHTac7RFOgTtZuNBtj3ViCQE ChFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=U+bCRgnt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id z3-20020a056a00240300b006cd852a8a83si7600702pfh.147.2023.12.04.00.49.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 00:49:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=U+bCRgnt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id B8F3E8059170; Mon, 4 Dec 2023 00:49:27 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343617AbjLDItS (ORCPT + 99 others); Mon, 4 Dec 2023 03:49:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230008AbjLDItS (ORCPT ); Mon, 4 Dec 2023 03:49:18 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AF859B; Mon, 4 Dec 2023 00:49:24 -0800 (PST) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B4669JV007345; Mon, 4 Dec 2023 08:49:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id; s=qcppdkim1; bh=CDImjb7xNhS+hFEs/G+MjK3uesJb5R58jLvNa7bSTkQ=; b=U+bCRgntYG6lWWqHu0G24OEAwGRnzT2DvjlKoUeZbX+NSHbR/qekM9/F7vfz7AbfVDRY 2rScwxS2vZgbVGax9Rr/UxvletHgygwfDqRUsc5wmdBihYvpAUePsw2qyeRld2tzdx+i ulgGH9T9dorOxHvxxLNCxEqVqkQdJ883QOZy+q5EhbxheDGx2B4fH4zesD0Sas5UfuGB EW5Gy4qhGdzo8BR1keCLa9Dg3jZdVlCBjuzyKsj3y5AQeOqq/iMtJsxbLguSJnUVxxFL NZkgloATzfDBXDY1llKMw8e3e/bKkRHStyLmKIYr6yFxdgthgFkDoMHuUs/Go/80oH1O OQ== Received: from apblrppmta02.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3uqvp13ex3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 Dec 2023 08:49:01 +0000 Received: from pps.filterd (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 3B48mvZE015621; Mon, 4 Dec 2023 08:48:57 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTP id 3uqwnkghc2-1; Mon, 04 Dec 2023 08:48:57 +0000 Received: from APBLRPPMTA02.qualcomm.com (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B48mvij015616; Mon, 4 Dec 2023 08:48:57 GMT Received: from hu-maiyas-hyd.qualcomm.com (hu-snehshah-hyd.qualcomm.com [10.147.246.35]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTP id 3B48muuD015615; Mon, 04 Dec 2023 08:48:57 +0000 Received: by hu-maiyas-hyd.qualcomm.com (Postfix, from userid 2319345) id 31B68602FA0; Mon, 4 Dec 2023 14:18:56 +0530 (+0530) From: Sneh Shah To: 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 Cc: Sneh Shah , kernel@quicinc.com, Andrew Halaney Subject: [PATCH net-next] net: stmmac: qcom-ethqos: Add sysfs nodes for qcom ethqos Date: Mon, 4 Dec 2023 14:18:54 +0530 Message-Id: <20231204084854.31543-1-quic_snehshah@quicinc.com> X-Mailer: git-send-email 2.17.1 X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: 4IRSw3F21LUYQeQxmbPsUmBIoZ8NIWJ3 X-Proofpoint-ORIG-GUID: 4IRSw3F21LUYQeQxmbPsUmBIoZ8NIWJ3 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-04_06,2023-11-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 impostorscore=0 suspectscore=0 malwarescore=0 phishscore=0 spamscore=0 clxscore=1015 priorityscore=1501 adultscore=0 mlxscore=0 lowpriorityscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2312040066 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,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 pete.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 (pete.vger.email [0.0.0.0]); Mon, 04 Dec 2023 00:49:28 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784340571948479796 X-GMAIL-MSGID: 1784340571948479796 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. 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[] = {