Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp924036rdd; Wed, 10 Jan 2024 03:51:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IE6bxX69kMzI6lVDyB4T3iAN5sFCN+aiKB99imkW2k2wfr1jKNqww/RBY+fB1knCoXzEVKN X-Received: by 2002:a05:6a20:7fa1:b0:199:d53a:3fe5 with SMTP id d33-20020a056a207fa100b00199d53a3fe5mr644257pzj.8.1704887481753; Wed, 10 Jan 2024 03:51:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704887481; cv=none; d=google.com; s=arc-20160816; b=uxqIk5LOapTAVTZvzMAhDCC2mS1DGW+ZMHpigF/Y64vwzK70UYwRvkxDxqlW/vXFs6 r3pf1BWmm00R4rG95OgRSR2Rx3x2JcE2xbAyisCrx4h1Qlgcdg8VfyDWkoq7FdLhB80f dPeIidPDopvPk2vhjMciMQakv/66q863Sd2c1uzLUyM43UfSjRAjEUsDGSz+FysQjoxK VPeHttq408HTiZL+q7wHt6FSZ4KCwq1VQ1BpB0OAOwK6vU0cnF9/gMUzL68dI0PBoB8v IywIgdDRM6Ahh982F54n3d/GekgsYcNs8ZELo2TGM5N9eT/0ha6p8Bjzls0WeGrQrBJV uDYg== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22121-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id br5-20020a056a00440500b006da53d6a8c5si3577139pfb.17.2024.01.10.03.51.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 03:51:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-22121-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22121-linux.lists.archive=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 495A5B2710E for ; Wed, 10 Jan 2024 11:47:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 405BA4BAB3; Wed, 10 Jan 2024 11:43:57 +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 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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 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 -- 2.42.0