From patchwork Wed Jan 10 11:40:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Luo X-Patchwork-Id: 186839 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp735394dyi; Wed, 10 Jan 2024 03:47:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IGLqdwmOYKptsDJq4KRqrlvJ6FRM4joLj6IlhKLyrdQjby7aKqniJyM7c7SWM/9u8jifXNO X-Received: by 2002:a17:906:7197:b0:a27:654e:3fd with SMTP id h23-20020a170906719700b00a27654e03fdmr607538ejk.29.1704887276923; Wed, 10 Jan 2024 03:47:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704887276; cv=none; d=google.com; s=arc-20160816; b=XbKOoVzLJkgH/jeuIaIk+1G+A28lQeKirkbDN8OH3cUuShDZQwpzWaOI5lBnV4dB9A 65Q29ZMIQrRI42rUzGXGWqXhJzXSICiuUQi/KRCKMe2S3nCYfKmH1ILCR2NCLoAlPApG 7M0pKX0cnGh5kzha8ariU+I7HFHv0abiEL+Mh51G9psJFr1GcKk193v/DY2yg+/rWS/m WrjRlML6SbxQykh0J7b1tg/PlukYFWW6VOBgjwPwHqdAF7C/Pwd5SsVCuXhnokFTP7+k hoW01mIC/WSF/WJsMx4GDNi5t9J9g3D08GWUD5l5nd16OQjoRZyAvqddSb9eDOo0YNct 1BKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=JND3/LNjzReWO7D3+6yRtPc7s1nMiTrhCyJRg5lEo4k=; fh=VedTQI6oSWbClOWrHBDAwFLFM6rT7E/sRVqm9mlOWAU=; b=DgrBFAoCWu3AP64Ms76ILBkGQ/SK95zeHrMRUB+z3IHkQMxaYnjuCmJ91Toe9A36S8 trb2EzmFvP4Cezn9b7nwj/51ktvTwkQ5duS7l3GXjY8hcWsq4gcu60FbclVJX8SmMxoV 0uBSuHruuxXcoKfRe2eHC/p584mr1pg5PyvObCAtmSwN1ZSPGYsShlIbofG+FYIRfMtY 3vKE93FHNuJ+hsoFxjr8S5ExKDoEvdImayFofC0MnIcuAfM62I9/2ah0Gfc1CWsD4mYZ dgjxAhdJqnTimVvLvG4AByqknWjYZZo+cxPM9GQOjU0MBUWho1Hd8YZBAle3UhQMFUJ8 QJQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Z20P94F4; spf=pass (google.com: domain of linux-kernel+bounces-22121-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22121-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id j13-20020a170906278d00b00a231657d374si1693109ejc.831.2024.01.10.03.47.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 03:47:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-22121-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Z20P94F4; spf=pass (google.com: domain of linux-kernel+bounces-22121-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22121-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 664461F25D2A for ; Wed, 10 Jan 2024 11:47:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 486CC4C3AF; Wed, 10 Jan 2024 11:43:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="Z20P94F4" Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F14ED4879B; Wed, 10 Jan 2024 11:43:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40ABe0Nw026234; Wed, 10 Jan 2024 11:43:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= qcppdkim1; bh=JND3/LNjzReWO7D3+6yRtPc7s1nMiTrhCyJRg5lEo4k=; b=Z2 0P94F48UvZ9KXy9Ff0Q273Ngxl9YUL+aayJs9ILgtFYHyt7IyqWhYAVhzWcAzsTC jJbKUVgoGYepNgquTNQpnL1O/0h3K1O/JAr8oaIAyGwN+bdu3BlsR8D+ISj0uBnm SZcH+zha680wkpX6Ty7BplqSAqDECUNAi2lrfwukHE6gvL4lHv5nbGjM0BCzbE/2 5aXak9l7yHJow7t5nm/5/G1ZruOvlDwxqmnQ41qzL4f4mAz89YeLwOLFiUAAVlcu KLoo1n821A89TBNyoV1WA21Y+pemYXLyf6sh7hCGnb42x1gusVzr0omeePUBAi3v BZ9CnLgcGQZJ1BUey3cQ== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vh9vfj62p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Jan 2024 11:43:17 +0000 (GMT) Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 40ABhGuH008239 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Jan 2024 11:43:16 GMT Received: from akronite-sh-dev02.qualcomm.com (10.80.80.8) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Wed, 10 Jan 2024 03:43:06 -0800 From: Luo Jie To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , Subject: [PATCH net-next 13/20] net: ethernet: qualcomm: Export PPE function set_maxframe Date: Wed, 10 Jan 2024 19:40:25 +0800 Message-ID: <20240110114033.32575-14-quic_luoj@quicinc.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240110114033.32575-1-quic_luoj@quicinc.com> References: <20240110114033.32575-1-quic_luoj@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: n1QmJNn7dlqT7gHPUt13wc-Q_2D6pHOs X-Proofpoint-ORIG-GUID: n1QmJNn7dlqT7gHPUt13wc-Q_2D6pHOs 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-09_01,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 suspectscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2401100096 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787703881204984928 X-GMAIL-MSGID: 1787703881204984928 set_maxframe is called when the MTU of interface is configured, which limits the size of packet passed through PPE. Signed-off-by: Luo Jie --- drivers/net/ethernet/qualcomm/ppe/ppe.c | 41 +++++++++++++++++++++++++ include/linux/soc/qcom/ppe.h | 12 ++++++++ 2 files changed, 53 insertions(+) diff --git a/drivers/net/ethernet/qualcomm/ppe/ppe.c b/drivers/net/ethernet/qualcomm/ppe/ppe.c index 746ef42fea5d..d0e0fa9d5609 100644 --- a/drivers/net/ethernet/qualcomm/ppe/ppe.c +++ b/drivers/net/ethernet/qualcomm/ppe/ppe.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include "ppe.h" #include "ppe_regs.h" @@ -293,6 +294,45 @@ struct ppe_device *ppe_dev_get(struct platform_device *pdev) } EXPORT_SYMBOL_GPL(ppe_dev_get); +struct ppe_device_ops *ppe_ops_get(struct platform_device *pdev) +{ + struct ppe_device *ppe_dev = platform_get_drvdata(pdev); + + if (!ppe_dev) + return NULL; + + return ppe_dev->ppe_ops; +} +EXPORT_SYMBOL_GPL(ppe_ops_get); + +static int ppe_port_maxframe_set(struct ppe_device *ppe_dev, + int port, int maxframe_size) +{ + union ppe_mru_mtu_ctrl_cfg_u mru_mtu_cfg; + + /* The max frame size should be MTU added by ETH_HLEN in PPE */ + maxframe_size += ETH_HLEN; + + if (port < PPE_MC_MTU_CTRL_TBL_NUM) + ppe_mask(ppe_dev, PPE_MC_MTU_CTRL_TBL + PPE_MC_MTU_CTRL_TBL_INC * port, + PPE_MC_MTU_CTRL_TBL_MTU, + FIELD_PREP(PPE_MC_MTU_CTRL_TBL_MTU, maxframe_size)); + + memset(&mru_mtu_cfg, 0, sizeof(mru_mtu_cfg)); + ppe_read_tbl(ppe_dev, PPE_MRU_MTU_CTRL_TBL + PPE_MRU_MTU_CTRL_TBL_INC * port, + mru_mtu_cfg.val, sizeof(mru_mtu_cfg.val)); + + mru_mtu_cfg.bf.mru = maxframe_size; + mru_mtu_cfg.bf.mtu = maxframe_size; + + return ppe_write_tbl(ppe_dev, PPE_MRU_MTU_CTRL_TBL + PPE_MRU_MTU_CTRL_TBL_INC * port, + mru_mtu_cfg.val, sizeof(mru_mtu_cfg.val)); +} + +static struct ppe_device_ops qcom_ppe_ops = { + .set_maxframe = ppe_port_maxframe_set, +}; + static const struct regmap_range ppe_readable_ranges[] = { regmap_reg_range(0x0, 0x1FF), /* GLB */ regmap_reg_range(0x400, 0x5FF), /* LPI CSR */ @@ -1286,6 +1326,7 @@ static int qcom_ppe_probe(struct platform_device *pdev) ret, "ppe device hw init failed\n"); + ppe_dev->ppe_ops = &qcom_ppe_ops; ppe_dev->is_ppe_probed = true; return 0; } diff --git a/include/linux/soc/qcom/ppe.h b/include/linux/soc/qcom/ppe.h index 90566a8841b4..70ee192d9ef0 100644 --- a/include/linux/soc/qcom/ppe.h +++ b/include/linux/soc/qcom/ppe.h @@ -16,13 +16,25 @@ struct ppe_device { struct device *dev; struct regmap *regmap; + struct ppe_device_ops *ppe_ops; bool is_ppe_probed; void *ppe_priv; }; +/* PPE operations, which is used by the external driver like Ethernet + * DMA driver to configure PPE. + */ +struct ppe_device_ops { + int (*set_maxframe)(struct ppe_device *ppe_dev, int port, + int maxframe_size); +}; + /* Function used to check PPE platform dirver is registered correctly or not. */ bool ppe_is_probed(struct platform_device *pdev); /* Function used to get the PPE device */ struct ppe_device *ppe_dev_get(struct platform_device *pdev); + +/* Function used to get the operations of PPE device */ +struct ppe_device_ops *ppe_ops_get(struct platform_device *pdev); #endif